From 2287af31d514b848fbe95247dcc709a97f45c4ee Mon Sep 17 00:00:00 2001 From: Montel Laurent Date: Tue, 22 Mar 2016 07:08:21 +0100 Subject: [PATCH] Add support for multi website --- kaddressbookgrantlee/src/CMakeLists.txt | 1 + .../printing/contactgrantleeprintobject.cpp | 15 +++++++ .../src/printing/contactgrantleeprintobject.h | 4 ++ .../printing/contactgrantleeprintwebsite.cpp | 43 +++++++++++++++++++ .../printing/contactgrantleeprintwebsite.h | 38 ++++++++++++++++ 5 files changed, 101 insertions(+) create mode 100644 kaddressbookgrantlee/src/printing/contactgrantleeprintwebsite.cpp create mode 100644 kaddressbookgrantlee/src/printing/contactgrantleeprintwebsite.h diff --git a/kaddressbookgrantlee/src/CMakeLists.txt b/kaddressbookgrantlee/src/CMakeLists.txt index 4194f38..b7af766 100644 --- a/kaddressbookgrantlee/src/CMakeLists.txt +++ b/kaddressbookgrantlee/src/CMakeLists.txt @@ -20,6 +20,7 @@ set(kaddressbook_grantlee_printing_LIB_SRCS printing/contactgrantleeprintimobject.cpp printing/contactgrantleeprintobject.cpp printing/contactgrantleeprintphoneobject.cpp + printing/contactgrantleeprintwebsite.cpp printing/grantleeprint.cpp ) diff --git a/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.cpp b/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.cpp index 2c23ae6..0a9de3f 100644 --- a/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.cpp +++ b/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.cpp @@ -21,6 +21,7 @@ #include "contactgrantleeprintimobject.h" #include "contactgrantleeprintgeoobject.h" #include "contactgrantleeprintcryptoobject.h" +#include "contactgrantleeprintwebsite.h" #include @@ -41,11 +42,19 @@ ContactGrantleePrintObject::ContactGrantleePrintObject(const KContacts::Addresse mListAddress << new ContactGrantleePrintAddressObject(addr); } + const auto webSites = address.extraUrlList(); + mListWebSite.reserve(webSites.size()); + Q_FOREACH (const KContacts::ResourceLocatorUrl &webSite, webSites) { + mListWebSite << new ContactGrantleePrintWebSite(webSite); + } + const auto phoneNumbers = address.phoneNumbers(); mListPhones.reserve(phoneNumbers.size()); Q_FOREACH (const KContacts::PhoneNumber &phone, phoneNumbers) { mListPhones << new ContactGrantleePrintPhoneObject(phone); } + + const QStringList customs = mAddress.customs(); if (!customs.empty()) { Q_FOREACH (const QString &custom, customs) { @@ -68,6 +77,7 @@ ContactGrantleePrintObject::~ContactGrantleePrintObject() qDeleteAll(mListAddress); qDeleteAll(mListPhones); qDeleteAll(mListIm); + qDeleteAll(mListWebSite); delete mCryptoObject; } @@ -192,6 +202,11 @@ QVariant ContactGrantleePrintObject::addresses() const return QVariant::fromValue(mListAddress); } +QVariant ContactGrantleePrintObject::webSites() const +{ + return QVariant::fromValue(mListWebSite); +} + QVariant ContactGrantleePrintObject::phones() const { return QVariant::fromValue(mListPhones); diff --git a/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.h b/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.h index b23fd42..3ce7fbf 100644 --- a/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.h +++ b/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.h @@ -27,6 +27,7 @@ class ContactGrantleePrintPhoneObject; class ContactGrantleePrintImObject; class ContactGrantleePrintGeoObject; class ContactGrantleePrintCryptoObject; +class ContactGrantleePrintWebSite; class ContactGrantleePrintObject : public QObject { Q_OBJECT @@ -63,6 +64,7 @@ class ContactGrantleePrintObject : public QObject Q_PROPERTY(QString assistant READ assistant) Q_PROPERTY(QString spouse READ spouse) Q_PROPERTY(QString languages READ languages) + Q_PROPERTY(QVariant webSites READ webSites) //Add more functions public: @@ -104,11 +106,13 @@ public: QString assistant() const; QString spouse() const; QString languages() const; + QVariant webSites() const; private: QString imgToDataUrl(const QImage &image) const; QList mListAddress; QList mListPhones; QList mListIm; + QList mListWebSite; ContactGrantleePrintGeoObject *mGeoObject; ContactGrantleePrintCryptoObject *mCryptoObject; KContacts::Addressee mAddress; diff --git a/kaddressbookgrantlee/src/printing/contactgrantleeprintwebsite.cpp b/kaddressbookgrantlee/src/printing/contactgrantleeprintwebsite.cpp new file mode 100644 index 0000000..1f096ab --- /dev/null +++ b/kaddressbookgrantlee/src/printing/contactgrantleeprintwebsite.cpp @@ -0,0 +1,43 @@ +/* + Copyright (c) 2016 Montel Laurent + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License, version 2, as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#include "contactgrantleeprintwebsite.h" +#include + +using namespace KAddressBookGrantlee; + +ContactGrantleePrintWebSite::ContactGrantleePrintWebSite(const KContacts::ResourceLocatorUrl &resourceLocator, QObject *parent) + : QObject(parent) +{ + +} + +ContactGrantleePrintWebSite::~ContactGrantleePrintWebSite() +{ + +} + +QString ContactGrantleePrintWebSite::url() const +{ + return mResourceLocator.url().toDisplayString(); +} + +bool ContactGrantleePrintWebSite::preferred() const +{ + //TODO + return false; +} diff --git a/kaddressbookgrantlee/src/printing/contactgrantleeprintwebsite.h b/kaddressbookgrantlee/src/printing/contactgrantleeprintwebsite.h new file mode 100644 index 0000000..2d6993a --- /dev/null +++ b/kaddressbookgrantlee/src/printing/contactgrantleeprintwebsite.h @@ -0,0 +1,38 @@ +/* + Copyright (c) 2016 Montel Laurent + + This program is free software; you can redistribute it and/or modify it + under the terms of the GNU General Public License, version 2, as + published by the Free Software Foundation. + + This program is distributed in the hope that it will be useful, but + WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + General Public License for more details. + + You should have received a copy of the GNU General Public License along + with this program; if not, write to the Free Software Foundation, Inc., + 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA +*/ + +#ifndef CONTACTGRANTLEEPRINTWEBSITE_H +#define CONTACTGRANTLEEPRINTWEBSITE_H + +#include +#include +namespace KAddressBookGrantlee +{ +class ContactGrantleePrintWebSite : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString url READ url) +public: + explicit ContactGrantleePrintWebSite(const KContacts::ResourceLocatorUrl &resourceLocator, QObject *parent = Q_NULLPTR); + ~ContactGrantleePrintWebSite(); + QString url() const; + bool preferred() const; +private: + KContacts::ResourceLocatorUrl mResourceLocator; +}; +} +#endif // CONTACTGRANTLEEPRINTWEBSITE_H -- GitLab