diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,5 +1,5 @@ cmake_minimum_required(VERSION 3.5) -set(PIM_VERSION "5.11.41") +set(PIM_VERSION "5.11.42") project(kdepim-apps-lib VERSION ${PIM_VERSION}) set(KF5_MIN_VERSION "5.57.0") @@ -31,7 +31,7 @@ set(AKONADI_VERSION "5.11.40") set(GRANTLEETHEME_LIB_VERSION "5.11.40") -set(KCONTACTS_LIB_VERSION "5.11.42") +set(KCONTACTS_LIB_VERSION "5.11.43") set(AKONADICONTACT_LIB_VERSION "5.11.40") set(LIBKLEO_LIB_VERSION "5.11.40") set(PIMCOMMON_LIB_VERSION "5.11.40") diff --git a/kaddressbookgrantlee/src/CMakeLists.txt b/kaddressbookgrantlee/src/CMakeLists.txt --- a/kaddressbookgrantlee/src/CMakeLists.txt +++ b/kaddressbookgrantlee/src/CMakeLists.txt @@ -10,7 +10,6 @@ set(kaddressbook_grantlee_object_LIB_SRCS contactobject/contactgrantleecryptoobject.cpp contactobject/contactgrantleeimobject.cpp - contactobject/contactgrantleewebsite.cpp ) set(kaddressbook_grantlee_printing_LIB_SRCS diff --git a/kaddressbookgrantlee/src/contactobject/contactgrantleewebsite.h b/kaddressbookgrantlee/src/contactobject/contactgrantleewebsite.h deleted file mode 100644 --- a/kaddressbookgrantlee/src/contactobject/contactgrantleewebsite.h +++ /dev/null @@ -1,40 +0,0 @@ -/* - Copyright (C) 2016-2019 Montel Laurent - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - 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; see the file COPYING. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#ifndef PRINT_CONTACTGRANTLEEWEBSITE_H -#define PRINT_CONTACTGRANTLEEWEBSITE_H - -#include -#include -namespace KAddressBookGrantlee { -class ContactGrantleeWebSite : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString url READ url) - Q_PROPERTY(bool preferred READ preferred) -public: - explicit ContactGrantleeWebSite(const KContacts::ResourceLocatorUrl &resourceLocator, QObject *parent = nullptr); - ~ContactGrantleeWebSite(); - Q_REQUIRED_RESULT QString url() const; - Q_REQUIRED_RESULT bool preferred() const; -private: - KContacts::ResourceLocatorUrl mResourceLocator; -}; -} -#endif // PRINT_CONTACTGRANTLEEWEBSITE_H diff --git a/kaddressbookgrantlee/src/contactobject/contactgrantleewebsite.cpp b/kaddressbookgrantlee/src/contactobject/contactgrantleewebsite.cpp deleted file mode 100644 --- a/kaddressbookgrantlee/src/contactobject/contactgrantleewebsite.cpp +++ /dev/null @@ -1,45 +0,0 @@ -/* - Copyright (C) 2016-2019 Montel Laurent - - This program is free software; you can redistribute it and/or - modify it under the terms of the GNU General Public - License as published by the Free Software Foundation; either - version 2 of the License, or (at your option) any later version. - - 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; see the file COPYING. If not, write to - the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, - Boston, MA 02110-1301, USA. -*/ - -#include "contactgrantleewebsite.h" -#include - -using namespace KAddressBookGrantlee; - -ContactGrantleeWebSite::ContactGrantleeWebSite(const KContacts::ResourceLocatorUrl &resourceLocator, QObject *parent) - : QObject(parent) - , mResourceLocator(resourceLocator) -{ -} - -ContactGrantleeWebSite::~ContactGrantleeWebSite() -{ -} - -QString ContactGrantleeWebSite::url() const -{ - return mResourceLocator.url().toDisplayString(); -} - -bool ContactGrantleeWebSite::preferred() const -{ - const QStringList value = mResourceLocator.parameters().value(QStringLiteral("type")); - //Validate PREF and pref - return value.contains(QLatin1String("pref"), Qt::CaseInsensitive); -} diff --git a/kaddressbookgrantlee/src/formatter/grantleecontactformatter.cpp b/kaddressbookgrantlee/src/formatter/grantleecontactformatter.cpp --- a/kaddressbookgrantlee/src/formatter/grantleecontactformatter.cpp +++ b/kaddressbookgrantlee/src/formatter/grantleecontactformatter.cpp @@ -24,7 +24,6 @@ #include "grantleecontactutils.h" #include "../contactobject/contactgrantleeimobject.h" #include "../contactobject/contactgrantleecryptoobject.h" -#include "../contactobject/contactgrantleewebsite.h" #include #include @@ -63,6 +62,13 @@ GRANTLEE_MAKE_GADGET(KContacts::Address) GRANTLEE_MAKE_GADGET(KContacts::Email) GRANTLEE_MAKE_GADGET(KContacts::PhoneNumber) +GRANTLEE_MAKE_GADGET(KContacts::ResourceLocatorUrl) + +GRANTLEE_BEGIN_LOOKUP(QUrl) +if (property == QLatin1String("scheme")) { + return object.scheme(); +} +GRANTLEE_END_LOOKUP class Q_DECL_HIDDEN GrantleeContactFormatter::Private { @@ -118,6 +124,8 @@ Grantlee::registerMetaType(); Grantlee::registerMetaType(); Grantlee::registerMetaType(); + Grantlee::registerMetaType(); + Grantlee::registerMetaType(); } GrantleeContactFormatter::~GrantleeContactFormatter() @@ -265,28 +273,12 @@ contactObject.insert(QStringLiteral("imAddresses"), imAddresses); // Homepage - QVariantList websites; - const KContacts::ResourceLocatorUrl::List extraUrlList = rawContact.extraUrlList(); - for (const KContacts::ResourceLocatorUrl &resourceLocator : extraUrlList) { - QString url = resourceLocator.url().url(); - if (!url.startsWith(QLatin1String("http://")) - && !url.startsWith(QLatin1String("https://"))) { - url = QStringLiteral("http://") + url; - } - websites.append(KStringHandler::tagUrls(url)); - } - if (!websites.isEmpty()) { - contactObject.insert(QStringLiteral("websites"), websites); - grantleeContactUtil.insertVariableToQVariantHash(contactObject, QStringLiteral("websitei18n")); - } + grantleeContactUtil.insertVariableToQVariantHash(contactObject, QStringLiteral("websitei18n")); + contactObject.insert(QStringLiteral("urls"), QVariant::fromValue(rawContact.extraUrlList())); // Blog Feed - const QString blog - = rawContact.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("BlogFeed")); - if (!blog.isEmpty()) { - contactObject.insert(QStringLiteral("blogUrl"), KStringHandler::tagUrls(blog)); - grantleeContactUtil.insertVariableToQVariantHash(contactObject, QStringLiteral("blogUrli18n")); - } + contactObject.insert(QStringLiteral("blogFeed"), rawContact.blogFeed()); + grantleeContactUtil.insertVariableToQVariantHash(contactObject, QStringLiteral("blogUrli18n")); // Address Book const QString addressBookName diff --git a/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.h b/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.h --- a/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.h +++ b/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.h @@ -38,8 +38,7 @@ Q_PROPERTY(QString nickName READ nickName) Q_PROPERTY(QString organization READ organization) Q_PROPERTY(QString note READ note) - Q_PROPERTY(QString webPage READ webPage) - Q_PROPERTY(QString webSite READ webSite) + Q_PROPERTY(KContacts::ResourceLocatorUrl url READ url) Q_PROPERTY(QString title READ title) Q_PROPERTY(QString preferredEmail READ preferredEmail) Q_PROPERTY(QString role READ role) @@ -59,7 +58,7 @@ Q_PROPERTY(QString assistant READ assistant) Q_PROPERTY(QString spouse READ spouse) Q_PROPERTY(QString languages READ languages) - Q_PROPERTY(QVariant webSites READ webSites) + Q_PROPERTY(QVector urls READ urls) Q_PROPERTY(QVariantList emails READ emails) //Add more functions @@ -79,9 +78,7 @@ Q_REQUIRED_RESULT QVariantList emails() const; Q_REQUIRED_RESULT QString organization() const; Q_REQUIRED_RESULT QString note() const; - //webPage deprecated. - Q_REQUIRED_RESULT QString webPage() const; - Q_REQUIRED_RESULT QString webSite() const; + Q_REQUIRED_RESULT KContacts::ResourceLocatorUrl url() const; Q_REQUIRED_RESULT QString title() const; Q_REQUIRED_RESULT QString preferredEmail() const; Q_REQUIRED_RESULT QString role() const; @@ -102,11 +99,10 @@ Q_REQUIRED_RESULT QString assistant() const; Q_REQUIRED_RESULT QString spouse() const; Q_REQUIRED_RESULT QString languages() const; - Q_REQUIRED_RESULT QVariant webSites() const; + Q_REQUIRED_RESULT QVector urls() const; private: QString imgToDataUrl(const QImage &image) const; QList mListIm; - QList mListWebSite; ContactGrantleeCryptoObject *mCryptoObject = nullptr; KContacts::Addressee mAddress; }; diff --git a/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.cpp b/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.cpp --- a/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.cpp +++ b/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.cpp @@ -20,7 +20,6 @@ #include "contactgrantleeprintobject.h" #include "../contactobject/contactgrantleeimobject.h" #include "../contactobject/contactgrantleecryptoobject.h" -#include "../contactobject/contactgrantleewebsite.h" #include @@ -37,12 +36,6 @@ : QObject(parent) , mAddress(address) { - const auto webSites = address.extraUrlList(); - mListWebSite.reserve(webSites.size()); - for (const KContacts::ResourceLocatorUrl &webSite : webSites) { - mListWebSite << new ContactGrantleeWebSite(webSite); - } - const QStringList customs = mAddress.customs(); for (const QString &custom : customs) { if (custom.startsWith(QLatin1String("messaging/"))) { @@ -59,7 +52,6 @@ ContactGrantleePrintObject::~ContactGrantleePrintObject() { qDeleteAll(mListIm); - qDeleteAll(mListWebSite); delete mCryptoObject; } @@ -142,14 +134,9 @@ return mAddress.note().replace(QLatin1Char('\n'), QStringLiteral("
")); } -QString ContactGrantleePrintObject::webPage() const -{ - return mAddress.url().url().toDisplayString(); -} - -QString ContactGrantleePrintObject::webSite() const +KContacts::ResourceLocatorUrl ContactGrantleePrintObject::url() const { - return webPage(); + return mAddress.url(); } QString ContactGrantleePrintObject::title() const @@ -182,9 +169,9 @@ return mAddress.addresses(); } -QVariant ContactGrantleePrintObject::webSites() const +QVector ContactGrantleePrintObject::urls() const { - return QVariant::fromValue(mListWebSite); + return mAddress.extraUrlList(); } QVector ContactGrantleePrintObject::phones() const diff --git a/kaddressbookgrantlee/src/printing/grantleeprint.cpp b/kaddressbookgrantlee/src/printing/grantleeprint.cpp --- a/kaddressbookgrantlee/src/printing/grantleeprint.cpp +++ b/kaddressbookgrantlee/src/printing/grantleeprint.cpp @@ -43,6 +43,13 @@ GRANTLEE_MAKE_GADGET(KContacts::Email) GRANTLEE_MAKE_GADGET(KContacts::Geo) GRANTLEE_MAKE_GADGET(KContacts::PhoneNumber) +GRANTLEE_MAKE_GADGET(KContacts::ResourceLocatorUrl) + +GRANTLEE_BEGIN_LOOKUP(QUrl) +if (property == QLatin1String("scheme")) { + return object.scheme(); +} +GRANTLEE_END_LOOKUP using namespace KAddressBookGrantlee; @@ -68,6 +75,8 @@ Grantlee::registerMetaType(); Grantlee::registerMetaType(); Grantlee::registerMetaType(); + Grantlee::registerMetaType(); + Grantlee::registerMetaType(); } QString GrantleePrint::contactsToHtml(const KContacts::Addressee::List &contacts)