diff --git a/CMakeLists.txt b/CMakeLists.txt index 54a3b78..1fe5082 100644 --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -1,80 +1,80 @@ cmake_minimum_required(VERSION 3.5) -set(PIM_VERSION "5.11.40") +set(PIM_VERSION "5.11.41") project(kdepim-apps-lib VERSION ${PIM_VERSION}) set(KF5_MIN_VERSION "5.57.0") find_package(ECM ${KF5_MIN_VERSION} CONFIG REQUIRED) set(CMAKE_MODULE_PATH ${ECM_MODULE_PATH}) set(LIBRARY_NAMELINK) if (POLICY CMP0053) cmake_policy(SET CMP0053 NEW) endif() include(GenerateExportHeader) include(ECMGenerateHeaders) include(ECMGeneratePriFile) include(ECMSetupVersion) include(FeatureSummary) include(KDEInstallDirs) include(KDECMakeSettings) include(KDEFrameworkCompilerSettings NO_POLICY_SCOPE) include(ECMQtDeclareLoggingCategory) include(ECMAddTests) set(KDEPIM_APPS_LIB_VERSION ${PIM_VERSION}) set(QT_REQUIRED_VERSION "5.10.0") set(AKONADI_VERSION "5.11.40") set(GRANTLEETHEME_LIB_VERSION "5.11.40") set(KCONTACTS_LIB_VERSION "5.11.42") set(AKONADICONTACT_LIB_VERSION "5.11.40") set(LIBKLEO_LIB_VERSION "5.11.40") set(PIMCOMMON_LIB_VERSION "5.11.40") find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Widgets DBus Gui) find_package(KF5Config ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5ConfigWidgets ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5CoreAddons ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5I18n ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5IconThemes ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5KIO ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Service ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5WidgetsAddons ${KF5_MIN_VERSION} CONFIG REQUIRED) find_package(KF5Akonadi ${AKONADI_VERSION} CONFIG REQUIRED) find_package(KF5AkonadiContact ${AKONADICONTACT_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Contacts ${KCONTACTS_LIB_VERSION} CONFIG REQUIRED) find_package(KF5GrantleeTheme ${GRANTLEETHEME_LIB_VERSION} CONFIG REQUIRED) find_package(KF5Libkleo ${LIBKLEO_LIB_VERSION} CONFIG REQUIRED) find_package(KF5PimCommonAkonadi ${PIMCOMMON_LIB_VERSION} CONFIG REQUIRED) find_package(Grantlee5 "5.1" CONFIG REQUIRED) find_package(KF5Prison ${KF5_MIN_VERSION} CONFIG REQUIRED) if(BUILD_TESTING) find_package(Qt5 ${QT_REQUIRED_VERSION} CONFIG REQUIRED Test) add_definitions(-DBUILD_TESTING) endif() # workaround for https://bugreports.qt.io/browse/QTBUG-74665 (bug in qt5.13 reevaluate it) if (${Qt5Widgets_VERSION} STREQUAL "5.13.0") MESSAGE(STATUS "Qt version: ${Qt5Widgets_VERSION} DISABLE compile without deprecated methods. bug QTBUG-74665") else() add_definitions(-DQT_DISABLE_DEPRECATED_BEFORE=0x060000) endif() add_definitions(-DQT_NO_FOREACH) add_subdirectory(libfollowupreminder) add_subdirectory(libkdepimdbusinterfaces) add_subdirectory(libsendlater) add_subdirectory(kaddressbookgrantlee) add_subdirectory(kaddressbookimportexport) feature_summary(WHAT ALL FATAL_ON_MISSING_REQUIRED_PACKAGES) install( FILES kdepim-apps-lib.renamecategories kdepim-apps-lib.categories DESTINATION ${KDE_INSTALL_CONFDIR} ) diff --git a/kaddressbookgrantlee/src/CMakeLists.txt b/kaddressbookgrantlee/src/CMakeLists.txt index 97dc8be..5dbf8a0 100644 --- a/kaddressbookgrantlee/src/CMakeLists.txt +++ b/kaddressbookgrantlee/src/CMakeLists.txt @@ -1,120 +1,119 @@ add_definitions(-DTRANSLATION_DOMAIN=\"libkaddressbookgrantlee\") set(kaddressbook_grantlee_LIB_SRCS widget/grantleecontactviewer.cpp formatter/grantleecontactformatter.cpp formatter/grantleecontactgroupformatter.cpp formatter/grantleecontactutils.cpp ) set(kaddressbook_grantlee_object_LIB_SRCS - contactobject/contactgrantleeaddressobject.cpp contactobject/contactgrantleecryptoobject.cpp contactobject/contactgrantleeimobject.cpp contactobject/contactgrantleewebsite.cpp ) set(kaddressbook_grantlee_printing_LIB_SRCS printing/contactgrantleeprintobject.cpp printing/grantleeprint.cpp ) add_library(KF5KaddressbookGrantlee ${kaddressbook_grantlee_LIB_SRCS} ${kaddressbook_grantlee_printing_LIB_SRCS} ${kaddressbook_grantlee_object_LIB_SRCS}) generate_export_header(KF5KaddressbookGrantlee BASE_NAME kaddressbook_grantlee) add_library(KF5::KaddressbookGrantlee ALIAS KF5KaddressbookGrantlee) target_include_directories(KF5KaddressbookGrantlee INTERFACE "$") target_include_directories(KF5KaddressbookGrantlee PUBLIC "$") target_link_libraries(KF5KaddressbookGrantlee PUBLIC Grantlee5::Templates PRIVATE KF5::ConfigWidgets KF5::Service KF5::GrantleeTheme KF5::AkonadiCore KF5::ContactEditor KF5::Contacts KF5::AkonadiContact KF5::IconThemes KF5::Libkleo KF5::I18n KF5::PimCommon ) set_target_properties(KF5KaddressbookGrantlee PROPERTIES VERSION ${KADDRESSBOOKGRANTLEE_VERSION_STRING} SOVERSION ${KADDRESSBOOKGRANTLEE_SOVERSION} EXPORT_NAME KaddressbookGrantlee ) install(TARGETS KF5KaddressbookGrantlee EXPORT KF5KaddressbookGrantleeTargets ${KF5_INSTALL_TARGETS_DEFAULT_ARGS} ${LIBRARY_NAMELINK} ) ecm_generate_headers(KaddressbookGrantlee_CamelCaseformatter_HEADERS HEADER_NAMES GrantleeContactFormatter GrantleeContactGroupFormatter REQUIRED_HEADERS KaddressbookGrantlee_formatter_HEADERS RELATIVE formatter PREFIX KaddressbookGrantlee ) ecm_generate_headers(KaddressbookGrantlee_CamelCasewidgets_HEADERS HEADER_NAMES GrantleeContactViewer REQUIRED_HEADERS KaddressbookGrantlee_widgets_HEADERS RELATIVE widget PREFIX KaddressbookGrantlee ) ecm_generate_headers(KaddressbookGrantlee_CamelCaseprinting_HEADERS HEADER_NAMES GrantleePrint REQUIRED_HEADERS KaddressbookGrantlee_printing_HEADERS RELATIVE printing PREFIX KaddressbookGrantlee ) ecm_generate_pri_file(BASE_NAME KaddressbookGrantlee LIB_NAME KF5KaddressbookGrantlee DEPS "Grantlee5" FILENAME_VAR PRI_FILENAME INCLUDE_INSTALL_DIR ${KDE_INSTALL_INCLUDEDIR_KF5}/KaddressbookGrantlee ) install(FILES ${KaddressbookGrantlee_CamelCasewidgets_HEADERS} ${KaddressbookGrantlee_CamelCaseformatter_HEADERS} ${KaddressbookGrantlee_CamelCaseprinting_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/KaddressbookGrantlee COMPONENT Devel ) install(FILES ${KaddressbookGrantlee_HEADERS} ${KaddressbookGrantlee_widgets_HEADERS} ${CMAKE_CURRENT_BINARY_DIR}/kaddressbook_grantlee_export.h ${KaddressbookGrantlee_formatter_HEADERS} ${KaddressbookGrantlee_printing_HEADERS} DESTINATION ${KDE_INSTALL_INCLUDEDIR_KF5}/kaddressbookgrantlee COMPONENT Devel ) install(FILES ${PRI_FILENAME} DESTINATION ${ECM_MKSPECS_INSTALL_DIR}) if (BUILD_TESTING) add_subdirectory(printing/autotests) endif() diff --git a/kaddressbookgrantlee/src/contactobject/contactgrantleeaddressobject.cpp b/kaddressbookgrantlee/src/contactobject/contactgrantleeaddressobject.cpp deleted file mode 100644 index b31b90c..0000000 --- a/kaddressbookgrantlee/src/contactobject/contactgrantleeaddressobject.cpp +++ /dev/null @@ -1,76 +0,0 @@ -/* - Copyright (C) 2013-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 "contactgrantleeaddressobject.h" - -using namespace KAddressBookGrantlee; -ContactGrantleeAddressObject::ContactGrantleeAddressObject(const KContacts::Address &address, QObject *parent) - : QObject(parent) - , mAddress(address) -{ -} - -ContactGrantleeAddressObject::~ContactGrantleeAddressObject() -{ -} - -QString ContactGrantleeAddressObject::type() const -{ - return KContacts::Address::typeLabel(mAddress.type()); -} - -QString ContactGrantleeAddressObject::street() const -{ - return mAddress.street(); -} - -QString ContactGrantleeAddressObject::postOfficeBox() const -{ - return mAddress.postOfficeBox(); -} - -QString ContactGrantleeAddressObject::locality() const -{ - return mAddress.locality(); -} - -QString ContactGrantleeAddressObject::region() const -{ - return mAddress.region(); -} - -QString ContactGrantleeAddressObject::postalCode() const -{ - return mAddress.postalCode(); -} - -QString ContactGrantleeAddressObject::country() const -{ - return mAddress.country(); -} - -QString ContactGrantleeAddressObject::label() const -{ - return mAddress.label(); -} - -QString ContactGrantleeAddressObject::formattedAddress() const -{ - return mAddress.formattedAddress().replace(QLatin1Char('\n'), QStringLiteral("
")); -} diff --git a/kaddressbookgrantlee/src/contactobject/contactgrantleeaddressobject.h b/kaddressbookgrantlee/src/contactobject/contactgrantleeaddressobject.h deleted file mode 100644 index 3ebb3fe..0000000 --- a/kaddressbookgrantlee/src/contactobject/contactgrantleeaddressobject.h +++ /dev/null @@ -1,56 +0,0 @@ -/* - Copyright (C) 2013-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_CONTACTGRANTLEEADDRESSOBJECT_H -#define PRINT_CONTACTGRANTLEEADDRESSOBJECT_H -#include -#include -namespace KAddressBookGrantlee { -class ContactGrantleeAddressObject : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString type READ type) - Q_PROPERTY(QString street READ street) - Q_PROPERTY(QString postOfficeBox READ postOfficeBox) - Q_PROPERTY(QString locality READ locality) - Q_PROPERTY(QString region READ region) - Q_PROPERTY(QString postalCode READ postalCode) - Q_PROPERTY(QString country READ country) - Q_PROPERTY(QString label READ label) - Q_PROPERTY(QString formattedAddress READ formattedAddress) - -public: - explicit ContactGrantleeAddressObject(const KContacts::Address &address, QObject *parent = nullptr); - ~ContactGrantleeAddressObject(); - - Q_REQUIRED_RESULT QString type() const; - Q_REQUIRED_RESULT QString street() const; - Q_REQUIRED_RESULT QString postOfficeBox() const; - Q_REQUIRED_RESULT QString locality() const; - Q_REQUIRED_RESULT QString region() const; - Q_REQUIRED_RESULT QString postalCode() const; - Q_REQUIRED_RESULT QString country() const; - Q_REQUIRED_RESULT QString label() const; - Q_REQUIRED_RESULT QString formattedAddress() const; - -private: - KContacts::Address mAddress; -}; -} -#endif // PRINT_CONTACTGRANTLEEADDRESSOBJECT_H diff --git a/kaddressbookgrantlee/src/formatter/grantleecontactformatter.cpp b/kaddressbookgrantlee/src/formatter/grantleecontactformatter.cpp index e5819e0..d049906 100644 --- a/kaddressbookgrantlee/src/formatter/grantleecontactformatter.cpp +++ b/kaddressbookgrantlee/src/formatter/grantleecontactformatter.cpp @@ -1,532 +1,479 @@ /* This file is part of KAddressBook. Copyright (c) 2010 Tobias Koenig This library is free software; you can redistribute it and/or modify it under the terms of the GNU Library General Public License as published by the Free Software Foundation; either version 2 of the License, or (at your option) any later version. This library 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 Library General Public License for more details. You should have received a copy of the GNU Library General Public License along with this library; see the file COPYING.LIB. If not, write to the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. */ #include "grantleecontactformatter.h" #include "grantleetheme/grantleetheme.h" #include "grantleecontactutils.h" -#include "../contactobject/contactgrantleeaddressobject.h" #include "../contactobject/contactgrantleeimobject.h" #include "../contactobject/contactgrantleecryptoobject.h" #include "../contactobject/contactgrantleewebsite.h" #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include #include using namespace KAddressBookGrantlee; // Grantlee has no Q_GADGET support yet #define GRANTLEE_MAKE_GADGET(Class) \ GRANTLEE_BEGIN_LOOKUP(Class) \ const auto idx = Class::staticMetaObject.indexOfProperty(property.toUtf8().constData()); \ if (idx < 0) { \ return {};} \ const auto mp = Class::staticMetaObject.property(idx); \ return mp.readOnGadget(&object); \ GRANTLEE_END_LOOKUP +GRANTLEE_MAKE_GADGET(KContacts::Address) GRANTLEE_MAKE_GADGET(KContacts::Email) GRANTLEE_MAKE_GADGET(KContacts::PhoneNumber) class Q_DECL_HIDDEN GrantleeContactFormatter::Private { public: Private() : forceDisableQRCode(false) , showQRCode(true) { KConfig config(QStringLiteral("akonadi_contactrc")); KConfigGroup group(&config, QStringLiteral("View")); showQRCode = group.readEntry("QRCodes", true); mEngine = new Grantlee::Engine; mTemplateLoader = QSharedPointer(new Grantlee::FileSystemTemplateLoader()); } ~Private() { delete mEngine; mTemplateLoader.clear(); } void changeGrantleePath(const QString &path) { mTemplateLoader->setTemplateDirs(QStringList() << path); mEngine->addTemplateLoader(mTemplateLoader); mSelfcontainedTemplate = mEngine->loadByName(QStringLiteral("contact.html")); if (mSelfcontainedTemplate->error()) { mErrorMessage += mSelfcontainedTemplate->errorString() + QStringLiteral("
"); } mEmbeddableTemplate = mEngine->loadByName(QStringLiteral("contact_embedded.html")); if (mEmbeddableTemplate->error()) { mErrorMessage += mEmbeddableTemplate->errorString() + QStringLiteral("
"); } } QVector mObjects; Grantlee::Engine *mEngine = nullptr; QSharedPointer mTemplateLoader; Grantlee::Template mSelfcontainedTemplate; Grantlee::Template mEmbeddableTemplate; QString mErrorMessage; bool forceDisableQRCode = false; bool showQRCode = false; }; GrantleeContactFormatter::GrantleeContactFormatter() : d(new Private) { + Grantlee::registerMetaType(); Grantlee::registerMetaType(); Grantlee::registerMetaType(); } GrantleeContactFormatter::~GrantleeContactFormatter() { delete d; } void GrantleeContactFormatter::setAbsoluteThemePath(const QString &path) { d->changeGrantleePath(path); } void GrantleeContactFormatter::setGrantleeTheme(const GrantleeTheme::Theme &theme) { d->changeGrantleePath(theme.absolutePath()); } void GrantleeContactFormatter::setForceDisableQRCode(bool b) { if (d->forceDisableQRCode != b) { d->forceDisableQRCode = b; } } bool GrantleeContactFormatter::forceDisableQRCode() const { return d->forceDisableQRCode; } void GrantleeContactFormatter::setShowQRCode(bool b) { d->showQRCode = b; } inline static void setHashField(QVariantHash &hash, const QString &name, const QString &value) { if (!value.isEmpty()) { hash.insert(name, value); } } static QVariantHash imAddressHash(const QString &typeKey, const QString &imAddress) { QVariantHash addressObject; const QString dispLabel = i18nc("@title:row label for an Instant Messaging address, %1 is I18Ned protocol name", "IM (%1)", IMProtocols::self()->name(typeKey)); setHashField(addressObject, QStringLiteral("type"), dispLabel); setHashField(addressObject, QStringLiteral("imAddress"), imAddress); const QString iconUrl = QUrl::fromLocalFile(KIconLoader::global()->iconPath(IMProtocols::self()->icon(typeKey), -KIconLoader::SizeSmall)).url(); const QString url = QStringLiteral("").arg(iconUrl, QString::number(KIconLoader::SizeSmall)); addressObject.insert(QStringLiteral("imIcon"), url); return addressObject; } -static QVariantHash addressHash(const KContacts::Address &address, int counter) -{ - QVariantHash addressObject; - - setHashField(addressObject, QStringLiteral("type"), - KContacts::Address::typeLabel(address.type())); - - setHashField(addressObject, QStringLiteral("street"), address.street()); - - setHashField(addressObject, QStringLiteral("postOfficeBox"), address.postOfficeBox()); - - setHashField(addressObject, QStringLiteral("locality"), address.locality()); - - setHashField(addressObject, QStringLiteral("region"), address.region()); - - setHashField(addressObject, QStringLiteral("postalCode"), address.postalCode()); - - setHashField(addressObject, QStringLiteral("country"), address.country()); - - setHashField(addressObject, QStringLiteral("label"), address.label()); - - setHashField(addressObject, QStringLiteral("formattedAddress"), address.formattedAddress()); - - QString formattedAddress; - - if (address.label().isEmpty()) { - formattedAddress = address.formattedAddress().trimmed(); - } else { - formattedAddress = address.label(); - } - - if (!formattedAddress.isEmpty()) { - //Replace all \n by only one
- formattedAddress = formattedAddress.replace(QRegularExpression(QStringLiteral("\n+")), QStringLiteral("
")); - - const QString link = QStringLiteral("%2"). - arg(counter); - QString url = link.arg(formattedAddress); - addressObject.insert(QStringLiteral("formattedAddressLink"), url); - - url = link.arg(QStringLiteral("")); - addressObject.insert(QStringLiteral("formattedAddressIcon"), url); - } - - return addressObject; -} - static int contactAge(const QDate &date) { QDate now = QDate::currentDate(); int age = now.year() - date.year(); if (date > now.addYears(-age)) { age--; } return age; } QString GrantleeContactFormatter::toHtml(HtmlForm form) const { if (!d->mErrorMessage.isEmpty()) { return d->mErrorMessage; } KContacts::Addressee rawContact; const Akonadi::Item localItem = item(); if (localItem.isValid() && localItem.hasPayload()) { rawContact = localItem.payload(); } else { rawContact = contact(); } if (rawContact.isEmpty()) { return QString(); } QVariantHash contactObject; GrantleeContactUtils grantleeContactUtil; // Name parts setHashField(contactObject, QStringLiteral("name"), rawContact.realName()); setHashField(contactObject, QStringLiteral("formattedName"), rawContact.formattedName()); setHashField(contactObject, QStringLiteral("prefix"), rawContact.prefix()); setHashField(contactObject, QStringLiteral("givenName"), rawContact.givenName()); setHashField(contactObject, QStringLiteral("additionalName"), rawContact.additionalName()); setHashField(contactObject, QStringLiteral("familyName"), rawContact.familyName()); setHashField(contactObject, QStringLiteral("suffix"), rawContact.suffix()); setHashField(contactObject, QStringLiteral("nickName"), rawContact.nickName()); // Dates const QDate birthday = rawContact.birthday().date(); if (birthday.isValid()) { grantleeContactUtil.insertVariableToQVariantHash(contactObject, QStringLiteral("birthdayi18n")); const QString formattedBirthday = QLocale().toString(birthday); contactObject.insert(QStringLiteral("birthday"), formattedBirthday); const int years = contactAge(birthday); contactObject.insert(QStringLiteral("age"), QString::number(years)); contactObject.insert(QStringLiteral("birthdayage"), QString(formattedBirthday +QStringLiteral("  ") +i18np("(One year old)", "(%1 years old)", years))); } const QDate anniversary = QDate::fromString(rawContact.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("X-Anniversary")), Qt::ISODate); if (anniversary.isValid()) { contactObject.insert(QStringLiteral("anniversary"), QLocale().toString(anniversary)); grantleeContactUtil.insertVariableToQVariantHash(contactObject, QStringLiteral("anniversaryi18n")); } // Emails grantleeContactUtil.insertVariableToQVariantHash(contactObject, QStringLiteral("emailsi18n")); contactObject.insert(QStringLiteral("emails"), QVariant::fromValue(rawContact.emailList())); // Phone numbers contactObject.insert(QStringLiteral("phoneNumbers"), QVariant::fromValue(rawContact.phoneNumbers())); // IM QVariantList imAddresses; const QStringList customs = rawContact.customs(); for (const QString &custom : customs) { if (custom.startsWith(QLatin1String("messaging/"))) { int pos = custom.indexOf(QLatin1Char(':')); QString key = custom.left(pos); key.remove(QStringLiteral("-All")); const QString value = custom.mid(pos + 1); imAddresses.append(imAddressHash(key, value)); } } 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")); } // 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")); } // Address Book const QString addressBookName = rawContact.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("AddressBook")); if (!addressBookName.isEmpty()) { contactObject.insert(QStringLiteral("addressBookName"), addressBookName); grantleeContactUtil.insertVariableToQVariantHash(contactObject, QStringLiteral("addressBookNamei18n")); } // Addresses - QVariantList addresses; - int counter = 0; - const KContacts::Address::List lstAddresses = rawContact.addresses(); - addresses.reserve(lstAddresses.count()); - for (const KContacts::Address &address : lstAddresses) { - addresses.append(addressHash(address, counter)); - counter++; - } + contactObject.insert(QStringLiteral("addresses"), QVariant::fromValue(rawContact.addresses())); + // Note if (!rawContact.note().isEmpty()) { const QString notes = QStringLiteral("%1").arg(rawContact.note().replace(QLatin1Char('\n'), QStringLiteral("
"))); contactObject.insert(QStringLiteral("note"), notes); grantleeContactUtil.insertVariableToQVariantHash(contactObject, QStringLiteral("notei18n")); } - contactObject.insert(QStringLiteral("addresses"), addresses); setHashField(contactObject, QStringLiteral("mailer"), rawContact.mailer()); setHashField(contactObject, QStringLiteral("title"), rawContact.title()); setHashField(contactObject, QStringLiteral("role"), rawContact.role()); QString job = rawContact.title(); if (job.isEmpty()) { job = rawContact.role(); } if (job.isEmpty()) { job = rawContact.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("X-Profession")); } setHashField(contactObject, QStringLiteral("job"), job); setHashField(contactObject, QStringLiteral("organization"), rawContact.organization()); setHashField(contactObject, QStringLiteral("department"), rawContact.department()); grantleeContactUtil.insertVariableToQVariantHash(contactObject, QStringLiteral("departmenti18n")); //setHashField( contactObject, QStringLiteral( "note" ), rawContact.note() ); setHashField(contactObject, QStringLiteral("profession"), rawContact.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("X-Profession"))); grantleeContactUtil.insertVariableToQVariantHash(contactObject, QStringLiteral("Professioni18n")); setHashField(contactObject, QStringLiteral("office"), rawContact.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("X-Office"))); grantleeContactUtil.insertVariableToQVariantHash(contactObject, QStringLiteral("officei18n")); setHashField(contactObject, QStringLiteral("manager"), rawContact.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("X-ManagersName"))); grantleeContactUtil.insertVariableToQVariantHash(contactObject, QStringLiteral("manageri18n")); setHashField(contactObject, QStringLiteral("assistant"), rawContact.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("X-AssistantsName"))); grantleeContactUtil.insertVariableToQVariantHash(contactObject, QStringLiteral("assistanti18n")); setHashField(contactObject, QStringLiteral("spouse"), rawContact.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("X-SpousesName"))); grantleeContactUtil.insertVariableToQVariantHash(contactObject, QStringLiteral("spousei18n")); setHashField(contactObject, QStringLiteral("imAddress"), rawContact.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("X-IMAddress"))); grantleeContactUtil.insertVariableToQVariantHash(contactObject, QStringLiteral("imAddressi18n")); // Custom fields QVariantList customFields; QVariantList customFieldsUrl; static QSet blacklistedKeys; if (blacklistedKeys.isEmpty()) { blacklistedKeys.insert(QStringLiteral("CRYPTOPROTOPREF")); blacklistedKeys.insert(QStringLiteral("OPENPGPFP")); blacklistedKeys.insert(QStringLiteral("SMIMEFP")); blacklistedKeys.insert(QStringLiteral("CRYPTOSIGNPREF")); blacklistedKeys.insert(QStringLiteral("CRYPTOENCRYPTPREF")); blacklistedKeys.insert(QStringLiteral("Anniversary")); blacklistedKeys.insert(QStringLiteral("BlogFeed")); blacklistedKeys.insert(QStringLiteral("Profession")); blacklistedKeys.insert(QStringLiteral("Office")); blacklistedKeys.insert(QStringLiteral("ManagersName")); blacklistedKeys.insert(QStringLiteral("AssistantsName")); blacklistedKeys.insert(QStringLiteral("SpousesName")); blacklistedKeys.insert(QStringLiteral("IMAddress")); blacklistedKeys.insert(QStringLiteral("AddressBook")); blacklistedKeys.insert(QStringLiteral("MailPreferedFormatting")); blacklistedKeys.insert(QStringLiteral("MailAllowToRemoteContent")); blacklistedKeys.insert(QStringLiteral("MAILPREFEREDFORMATTING")); blacklistedKeys.insert(QStringLiteral("MAILALLOWTOREMOTECONTENT")); } if (!customs.empty()) { for (QString custom : qAsConst(customs)) { //krazy:exclude=foreach if (custom.startsWith(QLatin1String("KADDRESSBOOK-"))) { custom.remove(QStringLiteral("KADDRESSBOOK-X-")); custom.remove(QStringLiteral("KADDRESSBOOK-")); int pos = custom.indexOf(QLatin1Char(':')); QString key = custom.left(pos); QString value = custom.mid(pos + 1); if (blacklistedKeys.contains(key)) { continue; } bool addUrl = false; // check whether it is a custom local field for (int i = 0; i < customFieldDescriptions().size(); ++i) { const QVariantMap description = customFieldDescriptions().at(i); if (description.value(QStringLiteral("key")).toString() == key) { key = description.value(QStringLiteral("title")).toString(); const QString descriptionType = description.value(QStringLiteral("type")).toString(); if (descriptionType == QLatin1String("boolean")) { if (value == QLatin1String("true")) { value = i18nc("Boolean value", "yes"); } else { value = i18nc("Boolean value", "no"); } } else if (descriptionType == QLatin1String("date")) { const QDate date = QDate::fromString(value, Qt::ISODate); value = QLocale().toString(date, QLocale::ShortFormat); } else if (descriptionType == QLatin1String("time")) { const QTime time = QTime::fromString(value, Qt::ISODate); value = QLocale::system().toString(time, QLocale::ShortFormat); } else if (descriptionType == QLatin1String("datetime")) { const QDateTime dateTime = QDateTime::fromString(value, Qt::ISODate); value = QLocale().toString(dateTime, QLocale::ShortFormat); } else if (descriptionType == QLatin1String("url")) { value = KStringHandler::tagUrls(value.toHtmlEscaped()); addUrl = true; } break; } } QVariantHash customFieldObject; customFieldObject.insert(QStringLiteral("title"), key); customFieldObject.insert(QStringLiteral("value"), value); if (addUrl) { customFieldsUrl.append(customFieldObject); } else { customFields.append(customFieldObject); } } } } contactObject.insert(QStringLiteral("customFields"), customFields); contactObject.insert(QStringLiteral("customFieldsUrl"), customFieldsUrl); if (!d->forceDisableQRCode) { if (d->showQRCode) { contactObject.insert(QStringLiteral("hasqrcode"), QStringLiteral("true")); } } QVariantHash colorsObject; colorsObject.insert( QStringLiteral("linkColor"), KColorScheme(QPalette::Active, KColorScheme::View).foreground().color().name()); colorsObject.insert( QStringLiteral("textColor"), KColorScheme(QPalette::Active, KColorScheme::View).foreground().color().name()); colorsObject.insert( QStringLiteral("backgroundColor"), KColorScheme(QPalette::Active, KColorScheme::View).background().color().name()); QVariantHash mapping; mapping.insert(QStringLiteral("contact"), contactObject); mapping.insert(QStringLiteral("colors"), colorsObject); Grantlee::Context context(mapping); if (form == SelfcontainedForm) { return d->mSelfcontainedTemplate->render(&context); } else if (form == EmbeddableForm) { return d->mEmbeddableTemplate->render(&context); } else { return QString(); } } diff --git a/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.cpp b/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.cpp index 18f40d4..287006d 100644 --- a/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.cpp +++ b/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.cpp @@ -1,293 +1,285 @@ /* Copyright (C) 2013-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 "contactgrantleeprintobject.h" -#include "../contactobject/contactgrantleeaddressobject.h" #include "../contactobject/contactgrantleeimobject.h" #include "../contactobject/contactgrantleecryptoobject.h" #include "../contactobject/contactgrantleewebsite.h" #include #include #include #include #include #include #include using namespace KAddressBookGrantlee; ContactGrantleePrintObject::ContactGrantleePrintObject(const KContacts::Addressee &address, QObject *parent) : QObject(parent) , mAddress(address) { - const auto addresses = address.addresses(); - mListAddress.reserve(addresses.size()); - for (const KContacts::Address &addr : addresses) { - mListAddress << new ContactGrantleeAddressObject(addr); - } - 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/"))) { const int pos = custom.indexOf(QLatin1Char(':')); QString key = custom.left(pos); key.remove(QStringLiteral("-All")); const QString value = custom.mid(pos + 1); mListIm << new ContactGrantleeImObject(key, value); } } mCryptoObject = new ContactGrantleeCryptoObject(address); } ContactGrantleePrintObject::~ContactGrantleePrintObject() { - qDeleteAll(mListAddress); qDeleteAll(mListIm); qDeleteAll(mListWebSite); delete mCryptoObject; } QString ContactGrantleePrintObject::realName() const { return mAddress.realName(); } QString ContactGrantleePrintObject::formattedName() const { return mAddress.formattedName(); } QString ContactGrantleePrintObject::prefix() const { return mAddress.prefix(); } QString ContactGrantleePrintObject::givenName() const { return mAddress.givenName(); } QString ContactGrantleePrintObject::additionalName() const { return mAddress.additionalName(); } QString ContactGrantleePrintObject::familyName() const { return mAddress.familyName(); } QString ContactGrantleePrintObject::suffix() const { return mAddress.suffix(); } QString ContactGrantleePrintObject::nickName() const { return mAddress.nickName(); } QString ContactGrantleePrintObject::name() const { return mAddress.name(); } QString ContactGrantleePrintObject::languages() const { QString result; QStringList langList; const KContacts::Lang::List lstLangs = mAddress.langs(); langList.reserve(lstLangs.count()); for (const KContacts::Lang &lang : lstLangs) { langList.append(lang.language()); } if (!langList.isEmpty()) { result = langList.join(QLatin1Char(',')); } return result; } QVariantList ContactGrantleePrintObject::emails() const { // ### temporary hack until this becomes a KContact::Addressee gadget itself and we can remove this const auto idx = KContacts::Addressee::staticMetaObject.indexOfProperty("emails"); Q_ASSERT(idx >= 0); const auto prop = KContacts::Addressee::staticMetaObject.property(idx); return prop.readOnGadget(&mAddress).toList(); } QString ContactGrantleePrintObject::organization() const { return mAddress.organization(); } QString ContactGrantleePrintObject::note() const { return mAddress.note().replace(QLatin1Char('\n'), QStringLiteral("
")); } QString ContactGrantleePrintObject::webPage() const { return mAddress.url().url().toDisplayString(); } QString ContactGrantleePrintObject::webSite() const { return webPage(); } QString ContactGrantleePrintObject::title() const { return mAddress.title(); } QString ContactGrantleePrintObject::preferredEmail() const { return mAddress.preferredEmail(); } QString ContactGrantleePrintObject::role() const { return mAddress.role(); } QString ContactGrantleePrintObject::birthday() const { return QLocale().toString(mAddress.birthday().date(), QLocale::LongFormat); } QString ContactGrantleePrintObject::department() const { return mAddress.department(); } -QVariant ContactGrantleePrintObject::addresses() const +QVector ContactGrantleePrintObject::addresses() const { - return QVariant::fromValue(mListAddress); + return mAddress.addresses(); } QVariant ContactGrantleePrintObject::webSites() const { return QVariant::fromValue(mListWebSite); } QVector ContactGrantleePrintObject::phones() const { return mAddress.phoneNumbers(); } QVariant ContactGrantleePrintObject::instantManging() const { return QVariant::fromValue(mListIm); } QVariant ContactGrantleePrintObject::geo() const { return QVariant::fromValue(mAddress.geo()); } QVariant ContactGrantleePrintObject::crypto() const { return QVariant::fromValue(mCryptoObject); } QString ContactGrantleePrintObject::addressBookName() const { const QString addressBookName = mAddress.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("AddressBook")); return addressBookName; } QString ContactGrantleePrintObject::photo() const { if (mAddress.photo().isEmpty()) { return QString(); } else { const QString photoStr = QStringLiteral("  ") .arg(imgToDataUrl(mAddress.photo().data()), QString::number(60), QString::number(60)); return photoStr; } } QString ContactGrantleePrintObject::imgToDataUrl(const QImage &image) const { QByteArray ba; QBuffer buffer(&ba); buffer.open(QIODevice::WriteOnly); image.save(&buffer, "PNG"); return QStringLiteral("data:image/%1;base64,%2").arg(QStringLiteral("PNG"), QString::fromLatin1(ba.toBase64())); } QString ContactGrantleePrintObject::logo() const { if (mAddress.logo().isEmpty()) { return QString(); } else { const QString photoStr = QStringLiteral("  ") .arg(imgToDataUrl(mAddress.logo().data()), QString::number(60), QString::number(60)); return photoStr; } } QString ContactGrantleePrintObject::anniversary() const { const QDate anniversary = QDate::fromString(mAddress.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("X-Anniversary")), Qt::ISODate); if (anniversary.isValid()) { return QLocale().toString(anniversary); } return QString(); } QString ContactGrantleePrintObject::profession() const { return mAddress.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("X-Profession")); } QString ContactGrantleePrintObject::office() const { return mAddress.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("X-Office")); } QString ContactGrantleePrintObject::manager() const { return mAddress.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("X-ManagersName")); } QString ContactGrantleePrintObject::assistant() const { return mAddress.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("X-AssistantsName")); } QString ContactGrantleePrintObject::spouse() const { return mAddress.custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("X-SpousesName")); } diff --git a/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.h b/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.h index 872365a..3c24087 100644 --- a/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.h +++ b/kaddressbookgrantlee/src/printing/contactgrantleeprintobject.h @@ -1,116 +1,115 @@ /* Copyright (C) 2013-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 CONTACTGRANTLEEPRINTOBJECT_H #define CONTACTGRANTLEEPRINTOBJECT_H #include #include #include namespace KAddressBookGrantlee { class ContactGrantleeCryptoObject; class ContactGrantleePrintObject : public QObject { Q_OBJECT Q_PROPERTY(QString name READ name) Q_PROPERTY(QString realName READ realName) Q_PROPERTY(QString formattedName READ formattedName) Q_PROPERTY(QString prefix READ prefix) Q_PROPERTY(QString givenName READ givenName) Q_PROPERTY(QString additionalName READ additionalName) Q_PROPERTY(QString familyName READ familyName) Q_PROPERTY(QString suffix READ suffix) 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(QString title READ title) Q_PROPERTY(QString preferredEmail READ preferredEmail) Q_PROPERTY(QString role READ role) Q_PROPERTY(QString birthday READ birthday) Q_PROPERTY(QString department READ department) - Q_PROPERTY(QVariant addresses READ addresses) + Q_PROPERTY(QVector addresses READ addresses) Q_PROPERTY(QVector phones READ phones) Q_PROPERTY(QVariant instantManging READ instantManging) Q_PROPERTY(QString addressBookName READ addressBookName) Q_PROPERTY(QString photo READ photo) Q_PROPERTY(QString logo READ logo) Q_PROPERTY(QVariant crypto READ crypto) Q_PROPERTY(QString anniversary READ anniversary) Q_PROPERTY(QString profession READ profession) Q_PROPERTY(QString office READ office) Q_PROPERTY(QString manager READ manager) 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(QVariantList emails READ emails) //Add more functions public: explicit ContactGrantleePrintObject(const KContacts::Addressee &address, QObject *parent = nullptr); ~ContactGrantleePrintObject(); Q_REQUIRED_RESULT QString name() const; Q_REQUIRED_RESULT QString realName() const; Q_REQUIRED_RESULT QString formattedName() const; Q_REQUIRED_RESULT QString prefix() const; Q_REQUIRED_RESULT QString givenName() const; Q_REQUIRED_RESULT QString additionalName() const; Q_REQUIRED_RESULT QString familyName() const; Q_REQUIRED_RESULT QString suffix() const; Q_REQUIRED_RESULT QString nickName() const; 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 QString title() const; Q_REQUIRED_RESULT QString preferredEmail() const; Q_REQUIRED_RESULT QString role() const; Q_REQUIRED_RESULT QString birthday() const; Q_REQUIRED_RESULT QString department() const; - Q_REQUIRED_RESULT QVariant addresses() const; + Q_REQUIRED_RESULT QVector addresses() const; Q_REQUIRED_RESULT QVector phones() const; Q_REQUIRED_RESULT QString addressBookName() const; Q_REQUIRED_RESULT QVariant instantManging() const; Q_REQUIRED_RESULT QVariant geo() const; Q_REQUIRED_RESULT QString photo() const; Q_REQUIRED_RESULT QString logo() const; Q_REQUIRED_RESULT QVariant crypto() const; Q_REQUIRED_RESULT QString anniversary() const; Q_REQUIRED_RESULT QString profession() const; Q_REQUIRED_RESULT QString office() const; Q_REQUIRED_RESULT QString manager() const; Q_REQUIRED_RESULT QString assistant() const; Q_REQUIRED_RESULT QString spouse() const; Q_REQUIRED_RESULT QString languages() const; Q_REQUIRED_RESULT QVariant webSites() const; private: QString imgToDataUrl(const QImage &image) const; - QList mListAddress; QList mListIm; QList mListWebSite; ContactGrantleeCryptoObject *mCryptoObject = nullptr; KContacts::Addressee mAddress; }; } Q_DECLARE_METATYPE(QList) #endif // CONTACTGRANTLEEPRINTOBJECT_H diff --git a/kaddressbookgrantlee/src/printing/grantleeprint.cpp b/kaddressbookgrantlee/src/printing/grantleeprint.cpp index 1c6eea1..ff46941 100644 --- a/kaddressbookgrantlee/src/printing/grantleeprint.cpp +++ b/kaddressbookgrantlee/src/printing/grantleeprint.cpp @@ -1,118 +1,120 @@ /* Copyright (C) 2015-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 "grantleeprint.h" #include "contactgrantleeprintobject.h" #include "formatter/grantleecontactutils.h" #include #include #include #include #include // Grantlee has no Q_GADGET support yet #define GRANTLEE_MAKE_GADGET(Class) \ GRANTLEE_BEGIN_LOOKUP(Class) \ const auto idx = Class::staticMetaObject.indexOfProperty(property.toUtf8().constData()); \ if (idx < 0) { \ return {};} \ const auto mp = Class::staticMetaObject.property(idx); \ return mp.readOnGadget(&object); \ GRANTLEE_END_LOOKUP +GRANTLEE_MAKE_GADGET(KContacts::Address) GRANTLEE_MAKE_GADGET(KContacts::Email) GRANTLEE_MAKE_GADGET(KContacts::Geo) GRANTLEE_MAKE_GADGET(KContacts::PhoneNumber) using namespace KAddressBookGrantlee; GrantleePrint::GrantleePrint(QObject *parent) : PimCommon::GenericGrantleeFormatter(parent) { init(); } GrantleePrint::GrantleePrint(const QString &themePath, QObject *parent) : PimCommon::GenericGrantleeFormatter(QStringLiteral("theme.html"), themePath, parent) { init(); } GrantleePrint::~GrantleePrint() { } void GrantleePrint::init() { + Grantlee::registerMetaType(); Grantlee::registerMetaType(); Grantlee::registerMetaType(); Grantlee::registerMetaType(); } QString GrantleePrint::contactsToHtml(const KContacts::Addressee::List &contacts) { if (!errorMessage().isEmpty()) { return errorMessage(); } if (contacts.isEmpty()) { return QString(); } QVariantList contactsList; QList lst; const int numberContacts(contacts.count()); lst.reserve(numberContacts); contactsList.reserve(numberContacts); for (const KContacts::Addressee &address : contacts) { ContactGrantleePrintObject *contactPrintObject = new ContactGrantleePrintObject(address); lst.append(contactPrintObject); contactsList << QVariant::fromValue(static_cast(contactPrintObject)); } QVariantHash mapping; QVariantHash contactI18n; GrantleeContactUtils grantleeContactUtil; grantleeContactUtil.insertVariableToQVariantHash(contactI18n, QStringLiteral("birthdayi18n")); grantleeContactUtil.insertVariableToQVariantHash(contactI18n, QStringLiteral("anniversaryi18n")); grantleeContactUtil.insertVariableToQVariantHash(contactI18n, QStringLiteral("emailsi18n")); grantleeContactUtil.insertVariableToQVariantHash(contactI18n, QStringLiteral("websitei18n")); grantleeContactUtil.insertVariableToQVariantHash(contactI18n, QStringLiteral("blogUrli18n")); grantleeContactUtil.insertVariableToQVariantHash(contactI18n, QStringLiteral("addressBookNamei18n")); grantleeContactUtil.insertVariableToQVariantHash(contactI18n, QStringLiteral("notei18n")); grantleeContactUtil.insertVariableToQVariantHash(contactI18n, QStringLiteral("departmenti18n")); grantleeContactUtil.insertVariableToQVariantHash(contactI18n, QStringLiteral("Professioni18n")); grantleeContactUtil.insertVariableToQVariantHash(contactI18n, QStringLiteral("officei18n")); grantleeContactUtil.insertVariableToQVariantHash(contactI18n, QStringLiteral("manageri18n")); grantleeContactUtil.insertVariableToQVariantHash(contactI18n, QStringLiteral("assistanti18n")); grantleeContactUtil.insertVariableToQVariantHash(contactI18n, QStringLiteral("spousei18n")); grantleeContactUtil.insertVariableToQVariantHash(contactI18n, QStringLiteral("imAddressi18n")); grantleeContactUtil.insertVariableToQVariantHash(contactI18n, QStringLiteral("latitudei18n")); grantleeContactUtil.insertVariableToQVariantHash(contactI18n, QStringLiteral("longitudei18n")); grantleeContactUtil.insertVariableToQVariantHash(contactI18n, QStringLiteral("organizationi18n")); grantleeContactUtil.insertVariableToQVariantHash(contactI18n, QStringLiteral("titlei18n")); grantleeContactUtil.insertVariableToQVariantHash(contactI18n, QStringLiteral("nextcontacti18n")); mapping.insert(QStringLiteral("contacti18n"), contactI18n); mapping.insert(QStringLiteral("contacts"), contactsList); const QString content = render(mapping); qDeleteAll(lst); return content; }