File indexing completed on 2024-11-24 04:44:15
0001 /* 0002 This file is part of libkabc and/or kaddressbook. 0003 SPDX-FileCopyrightText: 2002-2004 Klarälvdalens Datakonsult AB <info@klaralvdalens-datakonsult.se> 0004 0005 SPDX-License-Identifier: LGPL-2.0-or-later 0006 */ 0007 0008 #pragma once 0009 0010 #include "kolabbase.h" 0011 #include <QImage> 0012 0013 namespace KContacts 0014 { 0015 class Addressee; 0016 class Picture; 0017 class Sound; 0018 } 0019 0020 namespace KolabV2 0021 { 0022 class Contact : public KolabBase 0023 { 0024 public: 0025 struct PhoneNumber { 0026 public: 0027 QString type; 0028 QString number; 0029 }; 0030 0031 struct Address { 0032 public: 0033 Address() 0034 : kdeAddressType(-1) 0035 { 0036 } 0037 0038 int kdeAddressType; // KContacts::Address::Type 0039 QString type; // kolab-compliant address type: home, work or other 0040 QString street; 0041 QString pobox; 0042 QString locality; 0043 QString region; 0044 QString postalCode; 0045 QString country; 0046 }; 0047 0048 explicit Contact(const KContacts::Addressee *address); 0049 Contact(const QString &xml); 0050 ~Contact() override; 0051 0052 void saveTo(KContacts::Addressee *address); 0053 0054 QString type() const override 0055 { 0056 return QStringLiteral("Contact"); 0057 } 0058 0059 void setGivenName(const QString &name); 0060 QString givenName() const; 0061 0062 void setMiddleNames(const QString &names); 0063 QString middleNames() const; 0064 0065 void setLastName(const QString &name); 0066 QString lastName() const; 0067 0068 void setFullName(const QString &name); 0069 QString fullName() const; 0070 0071 void setInitials(const QString &initials); 0072 QString initials() const; 0073 0074 void setPrefix(const QString &prefix); 0075 QString prefix() const; 0076 0077 void setSuffix(const QString &suffix); 0078 QString suffix() const; 0079 0080 void setRole(const QString &role); 0081 QString role() const; 0082 0083 void setFreeBusyUrl(const QString &fbUrl); 0084 QString freeBusyUrl() const; 0085 0086 void setOrganization(const QString &organization); 0087 QString organization() const; 0088 0089 void setWebPage(const QString &url); 0090 QString webPage() const; 0091 0092 void setIMAddress(const QString &imAddress); 0093 QString imAddress() const; 0094 0095 void setDepartment(const QString &department); 0096 QString department() const; 0097 0098 void setOfficeLocation(const QString &location); 0099 QString officeLocation() const; 0100 0101 void setProfession(const QString &profession); 0102 QString profession() const; 0103 0104 void setTitle(const QString &title); 0105 QString title() const; 0106 0107 void setManagerName(const QString &name); 0108 QString managerName() const; 0109 0110 void setAssistant(const QString &name); 0111 QString assistant() const; 0112 0113 void setNickName(const QString &name); 0114 QString nickName() const; 0115 0116 void setSpouseName(const QString &name); 0117 QString spouseName() const; 0118 0119 void setBirthday(QDate date); 0120 QDate birthday() const; 0121 0122 void setAnniversary(QDate date); 0123 QDate anniversary() const; 0124 0125 void setPicture(const QImage &image, const QString &format) 0126 { 0127 mPicture = image; 0128 mPictureFormat = format; 0129 } 0130 0131 QString pictureAttachmentName() const 0132 { 0133 return mPictureAttachmentName; 0134 } 0135 0136 QString pictureFormat() const 0137 { 0138 return mPictureFormat; 0139 } 0140 0141 QImage picture() const 0142 { 0143 return mPicture; 0144 } 0145 0146 void setLogo(const QImage &image, const QString &format) 0147 { 0148 mLogo = image; 0149 mLogoFormat = format; 0150 } 0151 0152 QString logoAttachmentName() const 0153 { 0154 return mLogoAttachmentName; 0155 } 0156 0157 QString logoFormat() const 0158 { 0159 return mLogoFormat; 0160 } 0161 0162 QImage logo() const 0163 { 0164 return mLogo; 0165 } 0166 0167 void setSound(const QByteArray &sound) 0168 { 0169 mSound = sound; 0170 } 0171 0172 QString soundAttachmentName() const 0173 { 0174 return mSoundAttachmentName; 0175 } 0176 0177 QByteArray sound() const 0178 { 0179 return mSound; 0180 } 0181 0182 void setChildren(const QString &children); 0183 QString children() const; 0184 0185 void setGender(const QString &gender); 0186 QString gender() const; 0187 0188 void setLanguage(const QString &language); 0189 QString language() const; 0190 0191 void addPhoneNumber(const PhoneNumber &number); 0192 QList<PhoneNumber> &phoneNumbers(); 0193 const QList<PhoneNumber> &phoneNumbers() const; 0194 0195 void addEmail(const Email &email); 0196 QList<Email> &emails(); 0197 const QList<Email> &emails() const; 0198 0199 QString fullEmail() const; 0200 0201 void addAddress(const Address &address); 0202 QList<Address> &addresses(); 0203 const QList<Address> &addresses() const; 0204 0205 // which address is preferred: home or business or other 0206 void setPreferredAddress(const QString &address); 0207 QString preferredAddress() const; 0208 0209 float latitude() const 0210 { 0211 return mLatitude; 0212 } 0213 0214 void setLatitude(float latitude) 0215 { 0216 mLatitude = latitude; 0217 } 0218 0219 float longitude() const 0220 { 0221 return mLongitude; 0222 } 0223 0224 void setLongitude(float longitude) 0225 { 0226 mLongitude = longitude; 0227 } 0228 0229 // Load the attributes of this class 0230 bool loadAttribute(QDomElement &) override; 0231 0232 // Save the attributes of this class 0233 bool saveAttributes(QDomElement &) const override; 0234 0235 // Load this note by reading the XML file 0236 bool loadXML(const QDomDocument &xml) override; 0237 0238 // Serialize this note to an XML string 0239 QString saveXML() const override; 0240 0241 protected: 0242 void setFields(const KContacts::Addressee *); 0243 0244 private: 0245 bool loadNameAttribute(QDomElement &element); 0246 void saveNameAttribute(QDomElement &element) const; 0247 0248 bool loadPhoneAttribute(QDomElement &element); 0249 void savePhoneAttributes(QDomElement &element) const; 0250 0251 void saveEmailAttributes(QDomElement &element) const; 0252 0253 bool loadAddressAttribute(QDomElement &element); 0254 void saveAddressAttributes(QDomElement &element) const; 0255 0256 void loadCustomAttributes(QDomElement &element); 0257 void saveCustomAttributes(QDomElement &element) const; 0258 0259 QImage loadPictureFromAddressee(const KContacts::Picture &picture); 0260 0261 QByteArray loadSoundFromAddressee(const KContacts::Sound &sound); 0262 0263 QString productID() const override; 0264 0265 QString mGivenName; 0266 QString mMiddleNames; 0267 QString mLastName; 0268 QString mFullName; 0269 QString mInitials; 0270 QString mPrefix; 0271 QString mSuffix; 0272 QString mRole; 0273 QString mFreeBusyUrl; 0274 QString mOrganization; 0275 QString mWebPage; 0276 QString mIMAddress; 0277 QString mDepartment; 0278 QString mOfficeLocation; 0279 QString mProfession; 0280 QString mTitle; 0281 QString mManagerName; 0282 QString mAssistant; 0283 QString mNickName; 0284 QString mSpouseName; 0285 QDate mBirthday; 0286 QDate mAnniversary; 0287 QImage mPicture; 0288 QString mPictureFormat; 0289 QImage mLogo; 0290 QString mLogoFormat; 0291 QByteArray mSound; 0292 QString mPictureAttachmentName; 0293 QString mLogoAttachmentName; 0294 QString mSoundAttachmentName; 0295 QString mChildren; 0296 QString mGender; 0297 QString mLanguage; 0298 QList<PhoneNumber> mPhoneNumbers; 0299 QList<Email> mEmails; 0300 QString mFullEmail; 0301 QList<Address> mAddresses; 0302 QString mPreferredAddress; 0303 float mLatitude; 0304 float mLongitude; 0305 bool mHasGeo = false; 0306 struct Custom { 0307 QString app; 0308 QString name; 0309 QString value; 0310 }; 0311 QList<Custom> mCustomList; 0312 }; 0313 }