File indexing completed on 2024-10-06 09:35:05
0001 /* 0002 This file is part of the KContacts framework. 0003 SPDX-FileCopyrightText: 2001 Cornelius Schumacher <schumacher@kde.org> 0004 SPDX-FileCopyrightText: 2013 Tobias Koenig <tokoe@kde.org> 0005 0006 SPDX-License-Identifier: LGPL-2.0-or-later 0007 */ 0008 0009 #ifndef KCONTACTS_ADDRESSEE_H 0010 #define KCONTACTS_ADDRESSEE_H 0011 0012 #include <QDateTime> 0013 #include <QMap> 0014 #include <QSharedDataPointer> 0015 #include <QStringList> 0016 #include <QUrl> 0017 0018 #include "address.h" 0019 #include "addresseelist.h" 0020 #include "calendarurl.h" 0021 #include "clientpidmap.h" 0022 #include "email.h" 0023 #include "fieldgroup.h" 0024 #include "gender.h" 0025 #include "geo.h" 0026 #include "impp.h" 0027 #include "key.h" 0028 #include "lang.h" 0029 #include "nickname.h" 0030 #include "org.h" 0031 #include "phonenumber.h" 0032 #include "picture.h" 0033 #include "related.h" 0034 #include "resourcelocatorurl.h" 0035 #include "role.h" 0036 #include "secrecy.h" 0037 #include "sound.h" 0038 #include "timezone.h" 0039 #include "title.h" 0040 0041 namespace KContacts 0042 { 0043 /** 0044 @short address book entry 0045 0046 This class represents an entry in the address book. 0047 0048 The data of this class is implicitly shared. You can pass this class by value. 0049 0050 If you need the name of a field for presenting it to the user you should use 0051 the functions ending in Label(). They return a translated string which can be 0052 used as label for the corresponding field. 0053 0054 About the name fields: 0055 0056 givenName() is the first name and familyName() the last name. In some 0057 countries the family name comes first, that's the reason for the 0058 naming. formattedName() is the full name with the correct formatting. 0059 It is used as an override, when the correct formatting can't be generated 0060 from the other name fields automatically. 0061 0062 realName() returns a fully formatted name(). It uses formattedName, if set, 0063 otherwise it constructs the name from the name fields. As fallback, if 0064 nothing else is set it uses name(). 0065 0066 name() is the NAME type of RFC2426. It can be used as internal name for the 0067 data entry, but shouldn't be used for displaying the data to the user. 0068 */ 0069 class KCONTACTS_EXPORT Addressee 0070 { 0071 friend KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const Addressee &); 0072 friend KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, Addressee &); 0073 0074 Q_GADGET 0075 Q_PROPERTY(bool isEmpty READ isEmpty) 0076 Q_PROPERTY(QString uid READ uid WRITE setUid) 0077 Q_PROPERTY(QString name READ name WRITE setName) 0078 Q_PROPERTY(QString formattedName READ formattedName WRITE setFormattedName) 0079 Q_PROPERTY(QString familyName READ familyName WRITE setFamilyName) 0080 Q_PROPERTY(QString givenName READ givenName WRITE setGivenName) 0081 Q_PROPERTY(QString additionalName READ additionalName WRITE setAdditionalName) 0082 Q_PROPERTY(QString prefix READ prefix WRITE setPrefix) 0083 Q_PROPERTY(QString suffix READ suffix WRITE setSuffix) 0084 Q_PROPERTY(QString nickName READ nickName) 0085 Q_PROPERTY(QDateTime birthday READ birthday WRITE setBirthdayProperty) // special write method due to withTime argument 0086 Q_PROPERTY(bool birthdayHasTime READ birthdayHasTime) 0087 Q_PROPERTY(QString mailer READ mailer WRITE setMailer) 0088 Q_PROPERTY(KContacts::Geo geo READ geo WRITE setGeo) 0089 Q_PROPERTY(QString title READ title) 0090 Q_PROPERTY(QString role READ role) 0091 Q_PROPERTY(QString organization READ organization) 0092 Q_PROPERTY(QString department READ department WRITE setDepartment) 0093 Q_PROPERTY(QString note READ note WRITE setNote) 0094 Q_PROPERTY(QString productId READ productId WRITE setProductId) 0095 Q_PROPERTY(QDateTime revision READ revision) 0096 Q_PROPERTY(QString sortString READ sortString WRITE setSortString) 0097 Q_PROPERTY(KContacts::ResourceLocatorUrl url READ url WRITE setUrl) 0098 Q_PROPERTY(QString realName READ realName) 0099 Q_PROPERTY(QString assembledName READ assembledName) 0100 Q_PROPERTY(QString preferredEmail READ preferredEmail) 0101 Q_PROPERTY(QStringList categories READ categories WRITE setCategories) 0102 Q_PROPERTY(QStringList customs READ customs) 0103 Q_PROPERTY(bool changed READ changed WRITE setChanged) 0104 Q_PROPERTY(QDate anniversary READ anniversary WRITE setAnniversary) 0105 Q_PROPERTY(QString assistantsName READ assistantsName WRITE setAssistantsName) 0106 Q_PROPERTY(QUrl blogFeed READ blogFeed WRITE setBlogFeed) 0107 Q_PROPERTY(QString managersName READ managersName WRITE setManagersName) 0108 Q_PROPERTY(QString office READ office WRITE setOffice) 0109 Q_PROPERTY(QString profession READ profession WRITE setProfession) 0110 Q_PROPERTY(QString spousesName READ spousesName WRITE setSpousesName) 0111 Q_PROPERTY(KContacts::Picture photo READ photo WRITE setPhoto) 0112 0113 // using variants for QML compatibility, can be changed to proper types once QML supports that 0114 Q_PROPERTY(QVariantList emails READ emailsVariant WRITE setEmailsVariant) 0115 Q_PROPERTY(QVariantList phoneNumbers READ phoneNumbersVariant WRITE setPhoneNumbersVariant) 0116 Q_PROPERTY(QVariantList addresses READ addressesVariant) 0117 Q_PROPERTY(QVariantList urls READ urlsVariant) 0118 Q_PROPERTY(QVariantList impps READ imppsVariant WRITE setImppsVariant) 0119 0120 // ### the following properties are still missing: 0121 // - logos, photos, sounds 0122 // - keys 0123 // - the list variants for nicks, titles, roles, orgs 0124 // - timezone, secrecy, gender, kind, members, relationships, language 0125 // - field groups, sourceUrls, calendarUrls 0126 0127 public: 0128 /** 0129 A list of addressee objects 0130 */ 0131 typedef AddresseeList List; 0132 0133 #if KCONTACTS_ENABLE_DEPRECATED_SINCE(5, 88) 0134 /** 0135 A map from unique identifier to addressee. 0136 0137 @deprecated Since 5.88, as it's not used anywhere. 0138 0139 @see uid() 0140 */ 0141 KCONTACTS_DEPRECATED_VERSION(5, 88, "Deprecated, not used anywhere.") 0142 typedef QHash<QString, Addressee> Map; 0143 #endif 0144 0145 /** 0146 Construct an empty address book entry. 0147 */ 0148 Addressee(); 0149 0150 /** 0151 Destroys the address book entry. 0152 */ 0153 ~Addressee(); 0154 0155 /** 0156 Copy constructor. 0157 */ 0158 Addressee(const Addressee &other); 0159 0160 /** 0161 Assignment operator. 0162 0163 @return a reference to @c this 0164 */ 0165 Addressee &operator=(const Addressee &other); 0166 0167 /** 0168 Equality operator. 0169 0170 @return @c true if @c this and the given addressee are equal, 0171 otherwise @c false 0172 */ 0173 bool operator==(const Addressee &other) const; 0174 0175 /** 0176 Not-equal operator. 0177 0178 @return @c true if @c this and the given addressee are not equal, 0179 otherwise @c false 0180 */ 0181 bool operator!=(const Addressee &other) const; 0182 0183 /** 0184 Return if the address book entry is empty. 0185 */ 0186 bool isEmpty() const; 0187 0188 /** 0189 Set unique identifier. 0190 0191 @param uid the KABC unique identifier 0192 */ 0193 void setUid(const QString &uid); 0194 0195 /** 0196 Return unique identifier. 0197 */ 0198 QString uid() const; 0199 0200 /** 0201 Return translated label for uid field. 0202 */ 0203 static QString uidLabel(); 0204 0205 /** 0206 Set name. 0207 */ 0208 void setName(const QString &name); 0209 0210 /** 0211 Return name. 0212 */ 0213 QString name() const; 0214 0215 /** 0216 Return translated label for name field. 0217 */ 0218 static QString nameLabel(); 0219 0220 /** 0221 Set formatted name. 0222 */ 0223 void setFormattedName(const QString &formattedName); 0224 0225 /** 0226 Return formatted name. 0227 */ 0228 QString formattedName() const; 0229 0230 /** 0231 Return translated label for formattedName field. 0232 */ 0233 static QString formattedNameLabel(); 0234 0235 /** 0236 Set family name. 0237 */ 0238 void setFamilyName(const QString &familyName); 0239 0240 /** 0241 Return family name. 0242 */ 0243 QString familyName() const; 0244 0245 /** 0246 Return translated label for familyName field. 0247 */ 0248 static QString familyNameLabel(); 0249 0250 /** 0251 Set given name. 0252 */ 0253 void setGivenName(const QString &givenName); 0254 0255 /** 0256 Return given name. 0257 */ 0258 QString givenName() const; 0259 0260 /** 0261 Return translated label for givenName field. 0262 */ 0263 static QString givenNameLabel(); 0264 0265 /** 0266 Set additional names. 0267 */ 0268 void setAdditionalName(const QString &additionalName); 0269 0270 /** 0271 Return additional names. 0272 */ 0273 QString additionalName() const; 0274 0275 /** 0276 Return translated label for additionalName field. 0277 */ 0278 static QString additionalNameLabel(); 0279 0280 /** 0281 Set honorific prefixes. 0282 */ 0283 void setPrefix(const QString &prefix); 0284 0285 /** 0286 Return honorific prefixes. 0287 */ 0288 QString prefix() const; 0289 0290 /** 0291 Return translated label for prefix field. 0292 */ 0293 static QString prefixLabel(); 0294 0295 /** 0296 Set honorific suffixes. 0297 */ 0298 void setSuffix(const QString &suffix); 0299 0300 /** 0301 Return honorific suffixes. 0302 */ 0303 QString suffix() const; 0304 0305 /** 0306 Return translated label for suffix field. 0307 */ 0308 static QString suffixLabel(); 0309 0310 /** 0311 Set nick name. 0312 */ 0313 void setNickName(const QString &nickName); 0314 void setNickName(const NickName &nickName); 0315 void insertExtraNickName(const NickName &nickName); 0316 void setExtraNickNameList(const NickName::List &nickNameList); 0317 NickName::List extraNickNameList() const; 0318 0319 /** 0320 Return nick name. 0321 */ 0322 QString nickName() const; 0323 0324 /** 0325 Return translated label for nickName field. 0326 */ 0327 static QString nickNameLabel(); 0328 0329 /** 0330 Set birthday (date and time). If withTime is false the time will be set 0331 to midnight and birthdayHasTime() will return false afterwards. 0332 @since 5.4 0333 */ 0334 void setBirthday(const QDateTime &birthday, bool withTime = true); 0335 0336 /** 0337 Set birthday (date only). birthdayHasTime() will return false afterwards. 0338 */ 0339 void setBirthday(const QDate &birthday); 0340 0341 /** 0342 Return birthday. (If a valid date has been set, birthday().time() will 0343 always return a valid QTime!) 0344 */ 0345 QDateTime birthday() const; 0346 0347 /** 0348 Returns true if birthday has been set with a time. Returns false otherwise. 0349 */ 0350 bool birthdayHasTime() const; 0351 0352 /** 0353 Return translated label for birthday field. 0354 */ 0355 static QString birthdayLabel(); 0356 0357 /** 0358 Return translated label for homeAddressStreet field. 0359 */ 0360 static QString homeAddressStreetLabel(); 0361 0362 /** 0363 Return translated label for homeAddressPostOfficeBox field. 0364 */ 0365 static QString homeAddressPostOfficeBoxLabel(); 0366 0367 /** 0368 Return translated label for homeAddressLocality field. 0369 */ 0370 static QString homeAddressLocalityLabel(); 0371 0372 /** 0373 Return translated label for homeAddressRegion field. 0374 */ 0375 static QString homeAddressRegionLabel(); 0376 0377 /** 0378 Return translated label for homeAddressPostalCode field. 0379 */ 0380 static QString homeAddressPostalCodeLabel(); 0381 0382 /** 0383 Return translated label for homeAddressCountry field. 0384 */ 0385 static QString homeAddressCountryLabel(); 0386 0387 /** 0388 Return translated label for homeAddressLabel field. 0389 */ 0390 static QString homeAddressLabelLabel(); 0391 0392 /** 0393 Return translated label for businessAddressStreet field. 0394 */ 0395 static QString businessAddressStreetLabel(); 0396 0397 /** 0398 Return translated label for businessAddressPostOfficeBox field. 0399 */ 0400 static QString businessAddressPostOfficeBoxLabel(); 0401 0402 /** 0403 Return translated label for businessAddressLocality field. 0404 */ 0405 static QString businessAddressLocalityLabel(); 0406 0407 /** 0408 Return translated label for businessAddressRegion field. 0409 */ 0410 static QString businessAddressRegionLabel(); 0411 0412 /** 0413 Return translated label for businessAddressPostalCode field. 0414 */ 0415 static QString businessAddressPostalCodeLabel(); 0416 0417 /** 0418 Return translated label for businessAddressCountry field. 0419 */ 0420 static QString businessAddressCountryLabel(); 0421 0422 /** 0423 Return translated label for businessAddressLabel field. 0424 */ 0425 static QString businessAddressLabelLabel(); 0426 0427 /** 0428 Return translated label for homePhone field. 0429 */ 0430 static QString homePhoneLabel(); 0431 0432 /** 0433 Return translated label for businessPhone field. 0434 */ 0435 static QString businessPhoneLabel(); 0436 0437 /** 0438 Return translated label for mobilePhone field. 0439 */ 0440 static QString mobilePhoneLabel(); 0441 0442 /** 0443 Return translated label for homeFax field. 0444 */ 0445 static QString homeFaxLabel(); 0446 0447 /** 0448 Return translated label for businessFax field. 0449 */ 0450 static QString businessFaxLabel(); 0451 0452 /** 0453 Return translated label for carPhone field. 0454 */ 0455 static QString carPhoneLabel(); 0456 0457 /** 0458 Return translated label for isdn field. 0459 */ 0460 static QString isdnLabel(); 0461 0462 /** 0463 Return translated label for pager field. 0464 */ 0465 static QString pagerLabel(); 0466 0467 /** 0468 Return translated label for email field. 0469 */ 0470 static QString emailLabel(); 0471 0472 /** 0473 Set mail client. 0474 */ 0475 void setMailer(const QString &mailer); 0476 0477 /** 0478 Return mail client. 0479 */ 0480 QString mailer() const; 0481 0482 /** 0483 Return translated label for mailer field. 0484 */ 0485 static QString mailerLabel(); 0486 0487 /** 0488 Set time zone. 0489 */ 0490 void setTimeZone(const TimeZone &timeZone); 0491 0492 /** 0493 Return time zone. 0494 */ 0495 TimeZone timeZone() const; 0496 0497 /** 0498 Return translated label for timeZone field. 0499 */ 0500 static QString timeZoneLabel(); 0501 0502 /** 0503 Set geographic position. 0504 */ 0505 void setGeo(const Geo &geo); 0506 0507 /** 0508 Return geographic position. 0509 */ 0510 Geo geo() const; 0511 0512 /** 0513 Return translated label for geo field. 0514 */ 0515 static QString geoLabel(); 0516 0517 /** 0518 Set title. 0519 */ 0520 // Remove in kf6 0521 void setTitle(const QString &title); 0522 void setTitle(const Title &title); 0523 void insertExtraTitle(const Title &title); 0524 void setExtraTitleList(const Title::List &urltitle); 0525 Title::List extraTitleList() const; 0526 /** 0527 Return title. 0528 */ 0529 QString title() const; 0530 0531 /** 0532 Return translated label for title field. 0533 */ 0534 static QString titleLabel(); 0535 0536 /** 0537 Set role. 0538 */ 0539 void setRole(const QString &role); 0540 void setRole(const Role &role); 0541 void insertExtraRole(const Role &role); 0542 void setExtraRoleList(const Role::List &roleList); 0543 Role::List extraRoleList() const; 0544 0545 /** 0546 Return role. 0547 */ 0548 QString role() const; 0549 0550 /** 0551 Return translated label for role field. 0552 */ 0553 static QString roleLabel(); 0554 0555 /** 0556 Set organization. 0557 */ 0558 // Remove in kf6 0559 void setOrganization(const QString &organization); 0560 void setOrganization(const Org &organization); 0561 void insertExtraOrganization(const Org &organization); 0562 void setExtraOrganizationList(const Org::List &orgList); 0563 Org::List extraOrganizationList() const; 0564 0565 /** 0566 Return organization. 0567 */ 0568 QString organization() const; 0569 0570 /** 0571 Return translated label for organization field. 0572 */ 0573 static QString organizationLabel(); 0574 0575 /** 0576 Set department. 0577 */ 0578 void setDepartment(const QString &department); 0579 0580 /** 0581 Return department. 0582 */ 0583 QString department() const; 0584 0585 /** 0586 Return translated label for department field. 0587 */ 0588 static QString departmentLabel(); 0589 0590 /** 0591 Set note. 0592 */ 0593 void setNote(const QString ¬e); 0594 0595 /** 0596 Return note. 0597 */ 0598 QString note() const; 0599 0600 /** 0601 Return translated label for note field. 0602 */ 0603 static QString noteLabel(); 0604 0605 /** 0606 Set product identifier. 0607 */ 0608 void setProductId(const QString &productId); 0609 0610 /** 0611 Return product identifier. 0612 */ 0613 QString productId() const; 0614 0615 /** 0616 Return translated label for productId field. 0617 */ 0618 static QString productIdLabel(); 0619 0620 /** 0621 Set revision date. 0622 */ 0623 void setRevision(const QDateTime &revision); 0624 0625 /** 0626 Return revision date. 0627 */ 0628 QDateTime revision() const; 0629 0630 /** 0631 Return translated label for revision field. 0632 */ 0633 static QString revisionLabel(); 0634 0635 /** 0636 Set sort string. 0637 */ 0638 void setSortString(const QString &sortString); 0639 0640 /** 0641 Return sort string. 0642 */ 0643 QString sortString() const; 0644 0645 /** 0646 Return translated label for sortString field. 0647 */ 0648 static QString sortStringLabel(); 0649 0650 /** 0651 Set homepage. 0652 */ 0653 void setUrl(const ResourceLocatorUrl &url); 0654 // kf6: remove it 0655 void setUrl(const QUrl &url); 0656 0657 /** 0658 Return homepage. 0659 */ 0660 ResourceLocatorUrl url() const; 0661 0662 /** 0663 Return translated label for url field. 0664 */ 0665 static QString urlLabel(); 0666 0667 /** 0668 Set security class. 0669 */ 0670 void setSecrecy(const Secrecy &secrecy); 0671 0672 /** 0673 Return security class. 0674 */ 0675 Secrecy secrecy() const; 0676 0677 /** 0678 Return translated label for secrecy field. 0679 */ 0680 static QString secrecyLabel(); 0681 0682 /** 0683 Set logo. 0684 */ 0685 void setLogo(const Picture &logo); 0686 0687 /** 0688 Return logo. 0689 */ 0690 Picture logo() const; 0691 0692 /** 0693 Return translated label for logo field. 0694 */ 0695 static QString logoLabel(); 0696 0697 /** 0698 Set photo. 0699 */ 0700 void setPhoto(const Picture &photo); 0701 0702 /** 0703 Return photo. 0704 */ 0705 Picture photo() const; 0706 0707 /** 0708 Return translated label for photo field. 0709 */ 0710 static QString photoLabel(); 0711 0712 /** 0713 Set sound. 0714 */ 0715 void setSound(const Sound &sound); 0716 0717 /** 0718 Return sound. 0719 */ 0720 Sound sound() const; 0721 0722 /** 0723 Return translated label for sound field. 0724 */ 0725 static QString soundLabel(); 0726 0727 /** 0728 Set name fields by parsing the given string and trying to associate the 0729 parts of the string with according fields. This function should probably 0730 be a bit more clever. 0731 */ 0732 void setNameFromString(const QString &s); 0733 0734 /** 0735 Return the name of the addressee. This is calculated from all the name 0736 fields. 0737 */ 0738 QString realName() const; 0739 0740 /** 0741 Return the name that consists of all name parts. 0742 */ 0743 QString assembledName() const; 0744 0745 /** 0746 Return email address including real name. 0747 0748 @param email Email address to be used to construct the full email string. 0749 If this is QString() the preferred email address is used. 0750 */ 0751 QString fullEmail(const QString &email = QString()) const; 0752 0753 #if KCONTACTS_ENABLE_DEPRECATED_SINCE(5, 88) 0754 /** 0755 Insert an email address. If the email address already exists in this 0756 addressee it is not duplicated. 0757 0758 @param email Email address 0759 @param preferred Set to true, if this is the preferred email address of 0760 the addressee. 0761 0762 @deprecated Since 5.88, use addEmail(const Email &) instead; you can use the Email 0763 methods to set any parameters, e.g. Email::setPreferred(), Email::setType() ...etc 0764 */ 0765 KCONTACTS_DEPRECATED_VERSION(5, 88, "Use addEmail(const Email &), and the Email class setter methods instead.") 0766 void insertEmail(const QString &email, bool preferred = false, const QMap<QString, QStringList> ¶m = QMap<QString, QStringList>()); 0767 #endif 0768 0769 /** 0770 Adds an email address. If the email address (i.e. @p email.mail()) already 0771 exists in this addressee it won't be duplicated, instead @p email is assigned 0772 to it. 0773 0774 @since 5.88 0775 */ 0776 void addEmail(const Email &email); 0777 0778 /** 0779 Remove email address. If the email address doesn't exist, nothing happens. 0780 0781 @param email Email address to remove 0782 */ 0783 void removeEmail(const QString &email); 0784 0785 /** 0786 Return preferred email address. This is the first email address or the last 0787 one added with insertEmail() or addEmail() with a set preferred parameter. 0788 */ 0789 QString preferredEmail() const; 0790 0791 /** 0792 Return list of all email addresses. 0793 */ 0794 QStringList emails() const; 0795 0796 /** 0797 Set the emails to @p list. 0798 The first email address gets the preferred one! 0799 @param list The list of email addresses. 0800 */ 0801 void setEmails(const QStringList &list); 0802 0803 /** 0804 Insert a phone number. If a phone number with the same id already exists 0805 in this addressee it is not duplicated. 0806 0807 @param phoneNumber The telephone number to insert to the addressee 0808 */ 0809 void insertPhoneNumber(const PhoneNumber &phoneNumber); 0810 0811 /** 0812 Remove phone number. If no phone number with the given id exists for this 0813 addressee, nothing happens. 0814 0815 @param phoneNumber The telephone number to remove from the addressee 0816 */ 0817 void removePhoneNumber(const PhoneNumber &phoneNumber); 0818 0819 /** 0820 Return phone number, which matches the given type. 0821 0822 @param type The type of phone number to get 0823 */ 0824 PhoneNumber phoneNumber(PhoneNumber::Type type) const; 0825 0826 /** 0827 Return list of all phone numbers. 0828 */ 0829 PhoneNumber::List phoneNumbers() const; 0830 0831 void setPhoneNumbers(const PhoneNumber::List &phoneNumbers); 0832 0833 /** 0834 Return list of phone numbers with a special type. 0835 0836 @param type The type of phone number to get 0837 */ 0838 PhoneNumber::List phoneNumbers(PhoneNumber::Type type) const; 0839 0840 /** 0841 Return phone number with the given id. 0842 0843 @param id The identifier of the phone number to look for. 0844 See PhoneNumber::id() 0845 */ 0846 PhoneNumber findPhoneNumber(const QString &id) const; 0847 0848 /** 0849 Insert a key. If a key with the same id already exists 0850 in this addressee it is not duplicated. 0851 0852 @param key The key to insert 0853 */ 0854 void insertKey(const Key &key); 0855 0856 /** 0857 Remove a key. If no key with the given id exists for this 0858 addressee, nothing happens. 0859 0860 @param key The key to remove 0861 */ 0862 void removeKey(const Key &key); 0863 0864 /** 0865 Return key, which matches the given type. 0866 If @p type == Key::Custom you can specify a string 0867 that should match. If you leave the string empty, the first 0868 key with a custom value is returned. 0869 0870 @param type The type of key to look for 0871 @param customTypeString A string to match custom keys against when 0872 @p type is @c Key::Custom 0873 */ 0874 Key key(Key::Type type, const QString &customTypeString = QString()) const; 0875 0876 /** 0877 Return list of all keys. 0878 */ 0879 Key::List keys() const; 0880 0881 /** 0882 Set the list of keys 0883 @param keys The keys to be set. 0884 */ 0885 void setKeys(const Key::List &keys); 0886 0887 /** 0888 Return list of keys with a special type. 0889 If @p type == Key::Custom you can specify a string 0890 that should match. If you leave the string empty, all custom 0891 keys will be returned. 0892 0893 @param type The type of key to look for 0894 @param customTypeString A string to match custom keys against when 0895 @p type is @c Key::Custom 0896 */ 0897 Key::List keys(Key::Type type, const QString &customTypeString = QString()) const; 0898 0899 /** 0900 Return key with the given id. 0901 0902 @param id The identifier of the key to look for. See Key::id() 0903 */ 0904 Key findKey(const QString &id) const; 0905 0906 /** 0907 Insert an address. If an address with the same id already exists 0908 in this addressee it is not duplicated. 0909 0910 @param address The address to insert 0911 */ 0912 void insertAddress(const Address &address); 0913 0914 /** 0915 Remove address. If no address with the given id exists for this 0916 addressee, nothing happens. 0917 0918 @param address The address to remove 0919 */ 0920 void removeAddress(const Address &address); 0921 0922 /** 0923 Set the addressee 0924 0925 @param addresses The new addresses 0926 @since 5.100 0927 */ 0928 void setAddresses(const Address::List &addresses); 0929 0930 /** 0931 Return address, which matches the given type. 0932 0933 @param type The type of address to look for 0934 */ 0935 Address address(Address::Type type) const; 0936 0937 /** 0938 Return list of all addresses. 0939 */ 0940 Address::List addresses() const; 0941 0942 /** 0943 Return list of addresses with a special type. 0944 0945 @param type The type of addresses to look for 0946 */ 0947 Address::List addresses(Address::Type type) const; 0948 0949 /** 0950 Return address with the given id. 0951 0952 @param id The identifier of the address to look for. See Address::id() 0953 */ 0954 Address findAddress(const QString &id) const; 0955 0956 /** 0957 Insert category. If the category already exists it is not duplicated. 0958 */ 0959 void insertCategory(const QString &category); 0960 0961 /** 0962 Remove category. 0963 */ 0964 void removeCategory(const QString &category); 0965 0966 /** 0967 Return, if addressee has the given category. 0968 */ 0969 bool hasCategory(const QString &category) const; 0970 0971 /** 0972 Set categories to given value. 0973 */ 0974 void setCategories(const QStringList &category); 0975 0976 /** 0977 Return list of all set categories. 0978 */ 0979 QStringList categories() const; 0980 0981 /** 0982 Insert custom entry. The entry is identified by the name of the inserting 0983 application and a unique name. If an entry with the given app and name 0984 already exists its value is replaced with the new given value. 0985 0986 An empty value isn't allowed (nothing happens if this is called with 0987 any of the three arguments being empty) 0988 0989 @param app Name of the application inserting this custom entry 0990 @param name Name of this application specific custom entry 0991 @param value Value of this application specific custom entry 0992 */ 0993 void insertCustom(const QString &app, const QString &name, const QString &value); 0994 0995 /** 0996 Remove custom entry. 0997 0998 @param app Name of the application which has inserted this custom entry 0999 @param name Name of this application specific custom entry 1000 */ 1001 void removeCustom(const QString &app, const QString &name); 1002 1003 /** 1004 Return value of custom entry, identified by app and entry name. 1005 1006 @param app Name of the application which has inserted this custom entry 1007 @param name Name of this application specific custom entry 1008 */ 1009 QString custom(const QString &app, const QString &name) const; 1010 1011 /** 1012 Set all custom entries. 1013 */ 1014 void setCustoms(const QStringList &customs); 1015 1016 /** 1017 Return list of all custom entries. 1018 1019 The format of the custom entries is 'app-key:value' and the list is sorted 1020 alphabetically by 'app-key'. 1021 */ 1022 QStringList customs() const; 1023 1024 /** 1025 Parse full email address. The result is given back in fullName and email. 1026 1027 @param rawEmail The input string to parse for name and email 1028 @param fullName The name part of the @p rawEmail input, if it contained one 1029 @param email The email part of the @p rawEmail input, if it contained one 1030 */ 1031 static void parseEmailAddress(const QString &rawEmail, QString &fullName, QString &email); 1032 1033 /** 1034 Returns string representation of the addressee. 1035 */ 1036 QString toString() const; 1037 1038 /** 1039 Mark addressee as changed. 1040 1041 @param value Sets the status indicating changed data 1042 */ 1043 void setChanged(bool value); 1044 1045 /** 1046 Return whether the addressee is changed. 1047 */ 1048 bool changed() const; 1049 1050 /** 1051 Returns the MIME type used for Addressees 1052 */ 1053 static QString mimeType(); 1054 1055 KContacts::Email::List emailList() const; 1056 void setEmailList(const Email::List &list); 1057 1058 /** 1059 * Remove Language 1060 * @brief removeLang 1061 * @param language 1062 */ 1063 void removeLang(const QString &language); 1064 /** 1065 * Insert Language 1066 * @brief insertLang 1067 * @param language 1068 */ 1069 void insertLang(const Lang &language); 1070 /** 1071 * @brief langs 1072 * @return List of lang 1073 */ 1074 Lang::List langs() const; 1075 void setLangs(const Lang::List &langs); 1076 1077 void setGender(const Gender &gender); 1078 Gender gender() const; 1079 1080 QString kind() const; 1081 void setKind(const QString &kind); 1082 1083 void insertCalendarUrl(const CalendarUrl &calendarUrl); 1084 CalendarUrl::List calendarUrlList() const; 1085 1086 void insertExtraSound(const Sound &sound); 1087 void setExtraSoundList(const Sound::List &soundList); 1088 Sound::List extraSoundList() const; 1089 1090 void insertExtraPhoto(const Picture &picture); 1091 void setExtraPhotoList(const Picture::List &pictureList); 1092 Picture::List extraPhotoList() const; 1093 1094 void insertExtraLogo(const Picture &logo); 1095 void setExtraLogoList(const Picture::List &logoList); 1096 Picture::List extraLogoList() const; 1097 1098 ResourceLocatorUrl::List extraUrlList() const; 1099 void setExtraUrlList(const ResourceLocatorUrl::List &urlList); 1100 void insertExtraUrl(const ResourceLocatorUrl &url); 1101 1102 // Member 1103 void insertMember(const QString &member); 1104 void setMembers(const QStringList &c); 1105 QStringList members() const; 1106 1107 // Relation 1108 void insertRelationship(const Related &related); 1109 void setRelationships(const Related::List &c); 1110 Related::List relationships() const; 1111 1112 // Source 1113 void insertSourceUrl(const QUrl &url); 1114 void setSourcesUrlList(const QVector<QUrl> &urlList); 1115 QVector<QUrl> sourcesUrlList() const; 1116 1117 // Impp 1118 Impp::List imppList() const; 1119 void setImppList(const Impp::List &imppList); 1120 void insertImpp(const Impp &impp); 1121 1122 // FieldGroup 1123 FieldGroup::List fieldGroupList() const; 1124 void setFieldGroupList(const FieldGroup::List &fieldGroupList); 1125 void insertFieldGroup(const FieldGroup &fieldGroup); 1126 1127 // ClientPidMap 1128 ClientPidMap::List clientPidMapList() const; 1129 void setClientPidMapList(const ClientPidMap::List &clientpidmaplist); 1130 void insertClientPidMap(const ClientPidMap &clientpidmap); 1131 1132 /** 1133 * Returns the contact's anniversary date. 1134 * @note This is a non-standard extension using the @c X-Anniversary field. 1135 * @since 5.12 1136 */ 1137 QDate anniversary() const; 1138 /** 1139 * Sets the contact's anniversary date. 1140 * @note This is a non-standard extension using the @c X-Anniversary field. 1141 * @since 5.12 1142 */ 1143 void setAnniversary(const QDate &anniversary); 1144 1145 /** 1146 * Returns the contact's assistant's name. 1147 * @note This is a non-standard extension using the @c X-AssistantsName field. 1148 * @since 5.12 1149 */ 1150 QString assistantsName() const; 1151 /** 1152 * Set the contact's assistant's name. 1153 * @note This is a non-standard extension using the @c X-AssistantsName field. 1154 * @since 5.12 1155 */ 1156 void setAssistantsName(const QString &assistantsName); 1157 1158 /** 1159 * Returns the contact's blog feed. 1160 * @note This is a non-standard extension using the @c BlogFeed field. 1161 * @since 5.12 1162 */ 1163 QUrl blogFeed() const; 1164 /** 1165 * Set the contact's blog feed. 1166 * @note This is a non-standard extension using the @c BlogFeed field. 1167 * @since 5.12 1168 */ 1169 void setBlogFeed(const QUrl &blogFeed); 1170 1171 /** 1172 * Returns the contact's manager's name. 1173 * @note This is a non-standard extension using the @c X-ManagersName field. 1174 * @since 5.12 1175 */ 1176 QString managersName() const; 1177 /** 1178 * Set the contact's manager's name. 1179 * @note This is a non-standard extension using the @c X-ManagersName field. 1180 * @since 5.12 1181 */ 1182 void setManagersName(const QString &managersName); 1183 1184 /** 1185 * Returns the contact's office. 1186 * @note This is a non-standard extension using the @c X-Office field. 1187 * @since 5.12 1188 */ 1189 QString office() const; 1190 /** 1191 * Set the contact's office. 1192 * @note This is a non-standard extension using the @c X-Office field. 1193 * @since 5.12 1194 */ 1195 void setOffice(const QString &office); 1196 1197 /** 1198 * Returns the contact's profession. 1199 * @note This is a non-standard extension using the @c X-Profession field. 1200 * @since 5.12 1201 */ 1202 QString profession() const; 1203 /** 1204 * Set the contact's profession. 1205 * @note This is a non-standard extension using the @c X-Profession field. 1206 * @since 5.12 1207 */ 1208 void setProfession(const QString &profession); 1209 1210 /** 1211 * Returns the contact's spouse's name. 1212 * @note This is a non-standard extension using the @c X-SpousesName field. 1213 * @since 5.12 1214 */ 1215 QString spousesName() const; 1216 /** 1217 * Set the contact's spouse's name. 1218 * @note This is a non-standard extension using the @c X-SpousesName field. 1219 * @since 5.12 1220 */ 1221 void setSpousesName(const QString &spousesName); 1222 1223 private: 1224 KCONTACTS_NO_EXPORT void setBirthdayProperty(const QDateTime &birthday); 1225 KCONTACTS_NO_EXPORT QVariantList emailsVariant() const; 1226 KCONTACTS_NO_EXPORT void setEmailsVariant(const QVariantList &emails); 1227 KCONTACTS_NO_EXPORT QVariantList phoneNumbersVariant() const; 1228 KCONTACTS_NO_EXPORT void setPhoneNumbersVariant(const QVariantList &emails); 1229 KCONTACTS_NO_EXPORT QVariantList addressesVariant() const; 1230 KCONTACTS_NO_EXPORT QVariantList urlsVariant() const; 1231 KCONTACTS_NO_EXPORT QVariantList imppsVariant() const; 1232 KCONTACTS_NO_EXPORT void setImppsVariant(const QVariantList &impps); 1233 1234 class Private; 1235 QSharedDataPointer<Private> d; 1236 }; 1237 1238 KCONTACTS_EXPORT QDataStream &operator<<(QDataStream &, const Addressee &); 1239 KCONTACTS_EXPORT QDataStream &operator>>(QDataStream &, Addressee &); 1240 } 1241 1242 #define KCONTACTS_ADDRESSEE_METATYPE_DEFINED 1 1243 Q_DECLARE_METATYPE(KContacts::Addressee) 1244 1245 #endif