Changeset View
Changeset View
Standalone View
Standalone View
kaddressbookgrantlee/src/printing/contactgrantleeprintobject.cpp
Show All 12 Lines | 1 | /* | |||
---|---|---|---|---|---|
13 | 13 | | |||
14 | You should have received a copy of the GNU General Public License | 14 | You should have received a copy of the GNU General Public License | ||
15 | along with this program; see the file COPYING. If not, write to | 15 | along with this program; see the file COPYING. If not, write to | ||
16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | 16 | the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, | ||
17 | Boston, MA 02110-1301, USA. | 17 | Boston, MA 02110-1301, USA. | ||
18 | */ | 18 | */ | ||
19 | 19 | | |||
20 | #include "contactgrantleeprintobject.h" | 20 | #include "contactgrantleeprintobject.h" | ||
21 | #include "../contactobject/contactgrantleeaddressobject.h" | | |||
22 | #include "../contactobject/contactgrantleeimobject.h" | 21 | #include "../contactobject/contactgrantleeimobject.h" | ||
23 | #include "../contactobject/contactgrantleecryptoobject.h" | 22 | #include "../contactobject/contactgrantleecryptoobject.h" | ||
24 | #include "../contactobject/contactgrantleewebsite.h" | 23 | #include "../contactobject/contactgrantleewebsite.h" | ||
25 | 24 | | |||
26 | #include <KContacts/PhoneNumber> | 25 | #include <KContacts/PhoneNumber> | ||
27 | 26 | | |||
28 | #include <QBuffer> | 27 | #include <QBuffer> | ||
29 | #include <QVariant> | 28 | #include <QVariant> | ||
30 | #include <grantlee/metatype.h> | 29 | #include <grantlee/metatype.h> | ||
31 | #include <QLocale> | 30 | #include <QLocale> | ||
32 | #include <QMetaProperty> | 31 | #include <QMetaProperty> | ||
33 | #include <QImage> | 32 | #include <QImage> | ||
34 | 33 | | |||
35 | using namespace KAddressBookGrantlee; | 34 | using namespace KAddressBookGrantlee; | ||
36 | 35 | | |||
37 | ContactGrantleePrintObject::ContactGrantleePrintObject(const KContacts::Addressee &address, QObject *parent) | 36 | ContactGrantleePrintObject::ContactGrantleePrintObject(const KContacts::Addressee &address, QObject *parent) | ||
38 | : QObject(parent) | 37 | : QObject(parent) | ||
39 | , mAddress(address) | 38 | , mAddress(address) | ||
40 | { | 39 | { | ||
41 | const auto addresses = address.addresses(); | | |||
42 | mListAddress.reserve(addresses.size()); | | |||
43 | for (const KContacts::Address &addr : addresses) { | | |||
44 | mListAddress << new ContactGrantleeAddressObject(addr); | | |||
45 | } | | |||
46 | | ||||
47 | const auto webSites = address.extraUrlList(); | 40 | const auto webSites = address.extraUrlList(); | ||
48 | mListWebSite.reserve(webSites.size()); | 41 | mListWebSite.reserve(webSites.size()); | ||
49 | for (const KContacts::ResourceLocatorUrl &webSite : webSites) { | 42 | for (const KContacts::ResourceLocatorUrl &webSite : webSites) { | ||
50 | mListWebSite << new ContactGrantleeWebSite(webSite); | 43 | mListWebSite << new ContactGrantleeWebSite(webSite); | ||
51 | } | 44 | } | ||
52 | 45 | | |||
53 | const QStringList customs = mAddress.customs(); | 46 | const QStringList customs = mAddress.customs(); | ||
54 | for (const QString &custom : customs) { | 47 | for (const QString &custom : customs) { | ||
55 | if (custom.startsWith(QLatin1String("messaging/"))) { | 48 | if (custom.startsWith(QLatin1String("messaging/"))) { | ||
56 | const int pos = custom.indexOf(QLatin1Char(':')); | 49 | const int pos = custom.indexOf(QLatin1Char(':')); | ||
57 | QString key = custom.left(pos); | 50 | QString key = custom.left(pos); | ||
58 | key.remove(QStringLiteral("-All")); | 51 | key.remove(QStringLiteral("-All")); | ||
59 | const QString value = custom.mid(pos + 1); | 52 | const QString value = custom.mid(pos + 1); | ||
60 | mListIm << new ContactGrantleeImObject(key, value); | 53 | mListIm << new ContactGrantleeImObject(key, value); | ||
61 | } | 54 | } | ||
62 | } | 55 | } | ||
63 | mCryptoObject = new ContactGrantleeCryptoObject(address); | 56 | mCryptoObject = new ContactGrantleeCryptoObject(address); | ||
64 | } | 57 | } | ||
65 | 58 | | |||
66 | ContactGrantleePrintObject::~ContactGrantleePrintObject() | 59 | ContactGrantleePrintObject::~ContactGrantleePrintObject() | ||
67 | { | 60 | { | ||
68 | qDeleteAll(mListAddress); | | |||
69 | qDeleteAll(mListIm); | 61 | qDeleteAll(mListIm); | ||
70 | qDeleteAll(mListWebSite); | 62 | qDeleteAll(mListWebSite); | ||
71 | delete mCryptoObject; | 63 | delete mCryptoObject; | ||
72 | } | 64 | } | ||
73 | 65 | | |||
74 | QString ContactGrantleePrintObject::realName() const | 66 | QString ContactGrantleePrintObject::realName() const | ||
75 | { | 67 | { | ||
76 | return mAddress.realName(); | 68 | return mAddress.realName(); | ||
▲ Show 20 Lines • Show All 103 Lines • ▼ Show 20 Line(s) | 171 | { | |||
180 | return QLocale().toString(mAddress.birthday().date(), QLocale::LongFormat); | 172 | return QLocale().toString(mAddress.birthday().date(), QLocale::LongFormat); | ||
181 | } | 173 | } | ||
182 | 174 | | |||
183 | QString ContactGrantleePrintObject::department() const | 175 | QString ContactGrantleePrintObject::department() const | ||
184 | { | 176 | { | ||
185 | return mAddress.department(); | 177 | return mAddress.department(); | ||
186 | } | 178 | } | ||
187 | 179 | | |||
188 | QVariant ContactGrantleePrintObject::addresses() const | 180 | QVector<KContacts::Address> ContactGrantleePrintObject::addresses() const | ||
189 | { | 181 | { | ||
190 | return QVariant::fromValue(mListAddress); | 182 | return mAddress.addresses(); | ||
191 | } | 183 | } | ||
192 | 184 | | |||
193 | QVariant ContactGrantleePrintObject::webSites() const | 185 | QVariant ContactGrantleePrintObject::webSites() const | ||
194 | { | 186 | { | ||
195 | return QVariant::fromValue(mListWebSite); | 187 | return QVariant::fromValue(mListWebSite); | ||
196 | } | 188 | } | ||
197 | 189 | | |||
198 | QVector<KContacts::PhoneNumber> ContactGrantleePrintObject::phones() const | 190 | QVector<KContacts::PhoneNumber> ContactGrantleePrintObject::phones() const | ||
▲ Show 20 Lines • Show All 95 Lines • Show Last 20 Lines |