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.42") +set(PIM_VERSION "5.11.43") project(kdepim-apps-lib VERSION ${PIM_VERSION}) set(KF5_MIN_VERSION "5.57.0") diff --git a/kaddressbookgrantlee/src/CMakeLists.txt b/kaddressbookgrantlee/src/CMakeLists.txt --- a/kaddressbookgrantlee/src/CMakeLists.txt +++ b/kaddressbookgrantlee/src/CMakeLists.txt @@ -10,16 +10,15 @@ set(kaddressbook_grantlee_object_LIB_SRCS contactobject/contactgrantleecryptoobject.cpp contactobject/contactgrantleeimobject.cpp + contactobject/contactgrantleewrapper.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) diff --git a/kaddressbookgrantlee/src/contactobject/contactgrantleewrapper.h b/kaddressbookgrantlee/src/contactobject/contactgrantleewrapper.h new file mode 100644 --- /dev/null +++ b/kaddressbookgrantlee/src/contactobject/contactgrantleewrapper.h @@ -0,0 +1,77 @@ +/* + Copyright (C) 2019 Volker Krause + + 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 KADDRESSBOOKGRANTLEE_CONTACTGRANTLEEWRAPPER_H +#define KADDRESSBOOKGRANTLEE_CONTACTGRANTLEEWRAPPER_H + +#include + +namespace KAddressBookGrantlee { + +/** + * Additional properties for the KContacts::Addressee Grantlee model. + */ +class ContactGrantleeWrapper : public KContacts::Addressee +{ + Q_GADGET + // ### those probably should eventually become i18n calls in the template itself + Q_PROPERTY(QString addressBookLabel READ addressBookLabel) + Q_PROPERTY(QString anniversaryLabel READ anniversaryLabel) + Q_PROPERTY(QString assistantLabel READ assistantLabel) + Q_PROPERTY(QString birthdayLabel READ birthdayLabel) + Q_PROPERTY(QString departmentLabel READ departmentLabel) + Q_PROPERTY(QString noteLabel READ noteLabel) + Q_PROPERTY(QString managerLabel READ managerLabel) + Q_PROPERTY(QString officeLabel READ officeLabel) + Q_PROPERTY(QString professionLabel READ professionLabel) + Q_PROPERTY(QString spouseLabel READ spouseLabel) + + Q_PROPERTY(QString addressBookName READ addressBookName) + Q_PROPERTY(int age READ age) + + // ### those two would be unneccessary if we had a proper way for formatting dates in Grantlee + Q_PROPERTY(QString formattedBirthday READ formattedBirthday) + Q_PROPERTY(QString formattedAnniversary READ formattedAnniversary) + + // ### this is temporary, until KContacts::Impp takes over this part + Q_PROPERTY(QVariantList imAddresses READ imAddresses) + +private: + QString addressBookLabel() const; + QString anniversaryLabel() const; + QString assistantLabel() const; + QString managerLabel() const; + QString officeLabel() const; + QString professionLabel() const; + QString spouseLabel() const; + + QString addressBookName() const; + int age() const; + + QString formattedBirthday() const; + QString formattedAnniversary() const; + + QVariantList imAddresses() const; +}; + +} + +Q_DECLARE_METATYPE(KAddressBookGrantlee::ContactGrantleeWrapper) + +#endif // KADDRESSBOOKGRANTLEE_CONTACTGRANTLEEWRAPPER_H diff --git a/kaddressbookgrantlee/src/contactobject/contactgrantleewrapper.cpp b/kaddressbookgrantlee/src/contactobject/contactgrantleewrapper.cpp new file mode 100644 --- /dev/null +++ b/kaddressbookgrantlee/src/contactobject/contactgrantleewrapper.cpp @@ -0,0 +1,116 @@ +/* + Copyright (C) 2019 Volker Krause + + 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 "contactgrantleewrapper.h" + +#include + +#include + +#include + +using namespace KAddressBookGrantlee; + +static_assert(sizeof(KContacts::Addressee) == sizeof(KAddressBookGrantlee::ContactGrantleeWrapper), "Grantlee wrapper must not have member variables to prevent sliciing issues"); + +QString ContactGrantleeWrapper::addressBookLabel() const +{ + return i18n("Address Book"); +} + +QString ContactGrantleeWrapper::anniversaryLabel() const +{ + return i18n("Anniversary"); +} + +QString ContactGrantleeWrapper::assistantLabel() const +{ + return i18n("Assistant's Name"); +} + +QString ContactGrantleeWrapper::managerLabel() const +{ + return i18n("Manager's Name"); +} + +QString ContactGrantleeWrapper::officeLabel() const +{ + return i18n("Office"); +} + +QString ContactGrantleeWrapper::professionLabel() const +{ + return i18n("Profession"); +} + +QString ContactGrantleeWrapper::spouseLabel() const +{ + return i18n("Partner's Name"); +} + +QString ContactGrantleeWrapper::addressBookName() const +{ + return custom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("AddressBook")); +} + +int ContactGrantleeWrapper::age() const +{ + QDate now = QDate::currentDate(); + int age = now.year() - birthday().date().year(); + if (birthday().date() > now.addYears(-age)) { + age--; + } + return age; +} + +QString ContactGrantleeWrapper::formattedBirthday() const +{ + return QLocale().toString(birthday().date()); +} + +QString ContactGrantleeWrapper::formattedAnniversary() const +{ + return QLocale().toString(anniversary()); +} + +static QVariantHash imAddressHash(const QString &typeKey, const QString &imAddress) +{ + QVariantHash addressObject; + addressObject.insert(QStringLiteral("serviceLabel"), IMProtocols::self()->name(typeKey)); + addressObject.insert(QStringLiteral("address"), imAddress); + addressObject.insert(QStringLiteral("serviceIcon"), IMProtocols::self()->icon(typeKey)); + return addressObject; +} + +QVariantList ContactGrantleeWrapper::imAddresses() const +{ + QVariantList imAddrs; + const QStringList customs = this->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); + imAddrs.append(imAddressHash(key, value)); + } + } + + return imAddrs; +} 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 @@ -22,8 +22,7 @@ #include "grantleecontactformatter.h" #include "grantleetheme/grantleetheme.h" #include "grantleecontactutils.h" -#include "../contactobject/contactgrantleeimobject.h" -#include "../contactobject/contactgrantleecryptoobject.h" +#include "../contactobject/contactgrantleewrapper.h" #include @@ -38,13 +37,10 @@ #include -#include #include #include #include -#include - #include #include #include @@ -66,6 +62,7 @@ GRANTLEE_MAKE_GADGET(KContacts::Email) GRANTLEE_MAKE_GADGET(KContacts::PhoneNumber) GRANTLEE_MAKE_GADGET(KContacts::ResourceLocatorUrl) +GRANTLEE_MAKE_GADGET(KAddressBookGrantlee::ContactGrantleeWrapper) GRANTLEE_BEGIN_LOOKUP(QUrl) if (property == QLatin1String("scheme")) { @@ -127,6 +124,7 @@ Grantlee::registerMetaType(); Grantlee::registerMetaType(); Grantlee::registerMetaType(); + Grantlee::registerMetaType(); Grantlee::registerMetaType(); } @@ -162,41 +160,6 @@ 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 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()) { @@ -215,231 +178,82 @@ 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 - grantleeContactUtil.insertVariableToQVariantHash(contactObject, QStringLiteral("websitei18n")); - contactObject.insert(QStringLiteral("urls"), QVariant::fromValue(rawContact.extraUrlList())); - - // Blog Feed - contactObject.insert(QStringLiteral("blogFeed"), rawContact.blogFeed()); - 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 - 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")); - } - - - 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-")); + static QSet blacklistedKeys = { + QStringLiteral("CRYPTOPROTOPREF"), + QStringLiteral("OPENPGPFP"), + QStringLiteral("SMIMEFP"), + QStringLiteral("CRYPTOSIGNPREF"), + QStringLiteral("CRYPTOENCRYPTPREF"), + QStringLiteral("Anniversary"), + QStringLiteral("BlogFeed"), + QStringLiteral("Profession"), + QStringLiteral("Office"), + QStringLiteral("ManagersName"), + QStringLiteral("AssistantsName"), + QStringLiteral("SpousesName"), + QStringLiteral("IMAddress"), + QStringLiteral("AddressBook"), + QStringLiteral("MailPreferedFormatting"), + QStringLiteral("MailAllowToRemoteContent"), + QStringLiteral("MAILPREFEREDFORMATTING"), + QStringLiteral("MAILALLOWTOREMOTECONTENT") + }; + + const auto customs = rawContact.customs(); + for (QString custom : customs) { + 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); + int pos = custom.indexOf(QLatin1Char(':')); + QString key = custom.left(pos); + QString value = custom.mid(pos + 1); - if (blacklistedKeys.contains(key)) { - continue; - } + 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; + 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"); } - break; + } 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; } - } - QVariantHash customFieldObject; - customFieldObject.insert(QStringLiteral("title"), key); - customFieldObject.insert(QStringLiteral("value"), value); - - if (addUrl) { - customFieldsUrl.append(customFieldObject); - } else { - customFields.append(customFieldObject); + break; } } - } - } - - contactObject.insert(QStringLiteral("customFields"), customFields); - contactObject.insert(QStringLiteral("customFieldsUrl"), customFieldsUrl); - - if (!d->forceDisableQRCode) { - if (d->showQRCode) { - contactObject.insert(QStringLiteral("hasqrcode"), QStringLiteral("true")); + QVariantHash customFieldObject; + customFieldObject.insert(QStringLiteral("title"), key); + customFieldObject.insert(QStringLiteral("value"), value); + + if (addUrl) { + customFieldsUrl.append(customFieldObject); + } else { + customFields.append(customFieldObject); + } } } @@ -458,8 +272,11 @@ KColorScheme(QPalette::Active, KColorScheme::View).background().color().name()); QVariantHash mapping; - mapping.insert(QStringLiteral("contact"), contactObject); + mapping.insert(QStringLiteral("contact"), QVariant::fromValue(*reinterpret_cast(&rawContact))); mapping.insert(QStringLiteral("colors"), colorsObject); + mapping.insert(QStringLiteral("customFields"), customFields); + mapping.insert(QStringLiteral("customFieldsUrl"), customFieldsUrl); + mapping.insert(QStringLiteral("hasqrcode"), !d->forceDisableQRCode && d->showQRCode); Grantlee::Context context(mapping); context.setLocalizer(d->mEngine->localizer());