Commit 2287af31 authored by Laurent Montel's avatar Laurent Montel 😁

Add support for multi website

parent 7733f446
......@@ -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
)
......
......@@ -21,6 +21,7 @@
#include "contactgrantleeprintimobject.h"
#include "contactgrantleeprintgeoobject.h"
#include "contactgrantleeprintcryptoobject.h"
#include "contactgrantleeprintwebsite.h"
#include <KContacts/PhoneNumber>
......@@ -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);
......
......@@ -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<QObject *> mListAddress;
QList<QObject *> mListPhones;
QList<QObject *> mListIm;
QList<QObject *> mListWebSite;
ContactGrantleePrintGeoObject *mGeoObject;
ContactGrantleePrintCryptoObject *mCryptoObject;
KContacts::Addressee mAddress;
......
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
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 <QUrl>
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;
}
/*
Copyright (c) 2016 Montel Laurent <montel@kde.org>
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 <QObject>
#include <KContacts/ResourceLocatorUrl>
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
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment