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.44") +set(PIM_VERSION "5.11.45") project(kdepim-apps-lib VERSION ${PIM_VERSION}) set(KF5_MIN_VERSION "5.57.0") @@ -30,7 +30,7 @@ set(QT_REQUIRED_VERSION "5.10.0") set(AKONADI_VERSION "5.11.40") -set(GRANTLEETHEME_LIB_VERSION "5.11.40") +set(GRANTLEETHEME_LIB_VERSION "5.11.41") set(KCONTACTS_LIB_VERSION "5.11.43") set(AKONADICONTACT_LIB_VERSION "5.11.40") set(LIBKLEO_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 @@ -20,19 +20,18 @@ target_link_libraries(KF5KaddressbookGrantlee PUBLIC - Grantlee5::Templates + KF5::GrantleeTheme PRIVATE + Grantlee5::Templates 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 diff --git a/kaddressbookgrantlee/src/contactobject/contactgrantleewrapper.cpp b/kaddressbookgrantlee/src/contactobject/contactgrantleewrapper.cpp --- a/kaddressbookgrantlee/src/contactobject/contactgrantleewrapper.cpp +++ b/kaddressbookgrantlee/src/contactobject/contactgrantleewrapper.cpp @@ -160,3 +160,5 @@ return imAddrs; } + +#include "moc_contactgrantleewrapper.cpp" diff --git a/kaddressbookgrantlee/src/printing/autotests/CMakeLists.txt b/kaddressbookgrantlee/src/printing/autotests/CMakeLists.txt --- a/kaddressbookgrantlee/src/printing/autotests/CMakeLists.txt +++ b/kaddressbookgrantlee/src/printing/autotests/CMakeLists.txt @@ -1,4 +1,4 @@ ecm_add_test(grantleeprinttest.cpp NAME_PREFIX "kaddressbookgrantlee-printing-" - LINK_LIBRARIES KF5::KaddressbookGrantlee Qt5::Test KF5::Contacts KF5::PimCommon + LINK_LIBRARIES KF5::KaddressbookGrantlee Qt5::Test KF5::Contacts ) diff --git a/kaddressbookgrantlee/src/printing/autotests/grantleeprinttest.h b/kaddressbookgrantlee/src/printing/autotests/grantleeprinttest.h --- a/kaddressbookgrantlee/src/printing/autotests/grantleeprinttest.h +++ b/kaddressbookgrantlee/src/printing/autotests/grantleeprinttest.h @@ -29,7 +29,6 @@ explicit GrantleePrintTest(QObject *parent = nullptr); ~GrantleePrintTest(); private Q_SLOTS: - void shouldHaveDefaultValue(); void shouldReturnEmptyStringWhenNotContentAndNoContacts(); void shouldReturnEmptyStringWhenAddContentWithoutContacts(); void shouldReturnStringWhenAddContentAndContacts(); diff --git a/kaddressbookgrantlee/src/printing/autotests/grantleeprinttest.cpp b/kaddressbookgrantlee/src/printing/autotests/grantleeprinttest.cpp --- a/kaddressbookgrantlee/src/printing/autotests/grantleeprinttest.cpp +++ b/kaddressbookgrantlee/src/printing/autotests/grantleeprinttest.cpp @@ -30,62 +30,45 @@ { } -void GrantleePrintTest::shouldHaveDefaultValue() -{ - KAddressBookGrantlee::GrantleePrint *grantleePrint = new KAddressBookGrantlee::GrantleePrint; - QVERIFY(grantleePrint); - grantleePrint->deleteLater(); - grantleePrint = nullptr; -} - void GrantleePrintTest::shouldReturnEmptyStringWhenNotContentAndNoContacts() { - KAddressBookGrantlee::GrantleePrint *grantleePrint = new KAddressBookGrantlee::GrantleePrint; + KAddressBookGrantlee::GrantleePrint grantleePrint; KContacts::Addressee::List lst; - QVERIFY(grantleePrint->contactsToHtml(lst).isEmpty()); - grantleePrint->deleteLater(); - grantleePrint = nullptr; + QVERIFY(grantleePrint.contactsToHtml(lst).isEmpty()); } void GrantleePrintTest::shouldReturnEmptyStringWhenAddContentWithoutContacts() { - KAddressBookGrantlee::GrantleePrint *grantleePrint = new KAddressBookGrantlee::GrantleePrint; - grantleePrint->setContent(QStringLiteral("foo")); + KAddressBookGrantlee::GrantleePrint grantleePrint; + grantleePrint.setTemplateContent(QStringLiteral("foo")); KContacts::Addressee::List lst; - - QVERIFY(grantleePrint->contactsToHtml(lst).isEmpty()); - grantleePrint->deleteLater(); - grantleePrint = nullptr; + QVERIFY(grantleePrint.contactsToHtml(lst).isEmpty()); } void GrantleePrintTest::shouldReturnStringWhenAddContentAndContacts() { - KAddressBookGrantlee::GrantleePrint *grantleePrint = new KAddressBookGrantlee::GrantleePrint; - grantleePrint->setContent(QStringLiteral("foo")); + KAddressBookGrantlee::GrantleePrint grantleePrint; + grantleePrint.setTemplateContent(QStringLiteral("foo")); KContacts::Addressee::List lst; KContacts::Addressee address; address.setName(QStringLiteral("foo1")); address.insertEmail(QStringLiteral("foo@kde.org"), true); lst << address; - QCOMPARE(grantleePrint->contactsToHtml(lst), QStringLiteral("foo")); - grantleePrint->deleteLater(); - grantleePrint = nullptr; + QCOMPARE(grantleePrint.contactsToHtml(lst), QStringLiteral("foo")); } void GrantleePrintTest::shouldReturnEmails() { - KAddressBookGrantlee::GrantleePrint *grantleePrint = new KAddressBookGrantlee::GrantleePrint; + KAddressBookGrantlee::GrantleePrint grantleePrint; KContacts::Addressee::List lst; KContacts::Addressee address; address.setName(QStringLiteral("foo1")); address.insertEmail(QStringLiteral("foo@kde.org"), true); lst << address; - grantleePrint->setContent(QStringLiteral("{% if contacts %}{% for contact in contacts %}{% if contact.name %}{{ contact.name }}{% endif %}{% endfor %}{% endif %}")); + grantleePrint.setTemplateContent(QStringLiteral("{% if contacts %}{% for contact in contacts %}{% if contact.name %}{{ contact.name }}{% endif %}{% endfor %}{% endif %}")); - QCOMPARE(grantleePrint->contactsToHtml(lst), QStringLiteral("foo1")); - grantleePrint->deleteLater(); - grantleePrint = nullptr; + QCOMPARE(grantleePrint.contactsToHtml(lst), QStringLiteral("foo1")); } void GrantleePrintTest::shouldDisplayContactInfo_data() @@ -116,7 +99,7 @@ QFETCH(QString, variable); QFETCH(QString, result); - KAddressBookGrantlee::GrantleePrint *grantleePrint = new KAddressBookGrantlee::GrantleePrint; + KAddressBookGrantlee::GrantleePrint grantleePrint; KContacts::Addressee::List lst; KContacts::Addressee address; address.setGivenName(QStringLiteral("foo-givenname")); @@ -141,11 +124,9 @@ address.insertCustom(QStringLiteral("KADDRESSBOOK"), QStringLiteral("X-SpousesName"), QStringLiteral("foo-spousesname")); lst << address; - grantleePrint->setContent(QStringLiteral("{% if contacts %}{% for contact in contacts %}{% if contact.%1 %}{{ contact.%1 }}{% endif %}{% endfor %}{% endif %}").arg(variable)); + grantleePrint.setTemplateContent(QStringLiteral("{% if contacts %}{% for contact in contacts %}{% if contact.%1 %}{{ contact.%1 }}{% endif %}{% endfor %}{% endif %}").arg(variable)); - QCOMPARE(grantleePrint->contactsToHtml(lst), result); - grantleePrint->deleteLater(); - grantleePrint = nullptr; + QCOMPARE(grantleePrint.contactsToHtml(lst), result); } QTEST_MAIN(GrantleePrintTest) diff --git a/kaddressbookgrantlee/src/printing/grantleeprint.h b/kaddressbookgrantlee/src/printing/grantleeprint.h --- a/kaddressbookgrantlee/src/printing/grantleeprint.h +++ b/kaddressbookgrantlee/src/printing/grantleeprint.h @@ -21,17 +21,16 @@ #define GRANTLEEPRINT_H #include "kaddressbook_grantlee_export.h" -#include -#include + +#include #include namespace KAddressBookGrantlee { -class KADDRESSBOOK_GRANTLEE_EXPORT GrantleePrint : public PimCommon::GenericGrantleeFormatter +class KADDRESSBOOK_GRANTLEE_EXPORT GrantleePrint : public GrantleeTheme::GenericFormatter { - Q_OBJECT public: - explicit GrantleePrint(QObject *parent = nullptr); - explicit GrantleePrint(const QString &themePath, QObject *parent = nullptr); + GrantleePrint(); + explicit GrantleePrint(const QString &themePath); ~GrantleePrint(); Q_REQUIRED_RESULT QString contactsToHtml(const KContacts::Addressee::List &contacts); 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 @@ -27,6 +27,7 @@ #include #include +#include // Grantlee has no Q_GADGET support yet #define GRANTLEE_MAKE_GADGET(Class) \ @@ -53,21 +54,18 @@ using namespace KAddressBookGrantlee; -GrantleePrint::GrantleePrint(QObject *parent) - : PimCommon::GenericGrantleeFormatter(parent) +GrantleePrint::GrantleePrint() { init(); } -GrantleePrint::GrantleePrint(const QString &themePath, QObject *parent) - : PimCommon::GenericGrantleeFormatter(QStringLiteral("theme.html"), themePath, parent) +GrantleePrint::GrantleePrint(const QString &themePath) + : GrantleeTheme::GenericFormatter(QStringLiteral("theme.html"), themePath) { init(); } -GrantleePrint::~GrantleePrint() -{ -} +GrantleePrint::~GrantleePrint() = default; void GrantleePrint::init() {