diff --git a/CMakeLists.txt b/CMakeLists.txt --- a/CMakeLists.txt +++ b/CMakeLists.txt @@ -61,7 +61,6 @@ find_package(KF5IMAP ${KIMAP_LIB_VERSION} CONFIG REQUIRED) find_package(KF5LibkdepimAkonadi ${LIBKDEPIM_LIB_VERSION} CONFIG REQUIRED) find_package(KF5PimTextEdit ${KPIMTEXTEDIT_LIB_VERSION} CONFIG REQUIRED) -find_package(Grantlee5 "5.1" CONFIG REQUIRED) find_package(KF5Purpose ${KF5_MIN_VERSION} CONFIG REQUIRED) diff --git a/src/pimcommon/CMakeLists.txt b/src/pimcommon/CMakeLists.txt --- a/src/pimcommon/CMakeLists.txt +++ b/src/pimcommon/CMakeLists.txt @@ -110,10 +110,6 @@ ) -set(libpimcommon_genericgrantlee_SRCS - genericgrantlee/genericgrantleeformatter.cpp - ) - set(libpimcommon_networkmanager_SRCS network/networkmanager.cpp ) @@ -123,7 +119,6 @@ ${libpimcommon_configure_plugins_SRCS} ${libpimcommon_networkmanager_SRCS} ${libpimcommon_configure_plugins_SRCS} - ${libpimcommon_genericgrantlee_SRCS} ${libpimcommon_shareserviceurl_SRCS} ${libpimcommon_migrate_SRCS} ${libpimcommon_util_SRCS} @@ -179,7 +174,6 @@ KF5::Completion KF5::KIOWidgets Qt5::PrintSupport - Grantlee5::Templates KF5::Purpose KF5::PurposeWidgets ) @@ -230,14 +224,6 @@ RELATIVE genericplugins ) -ecm_generate_headers(PimCommon_CamelCasegenericgrantlee_HEADERS - HEADER_NAMES - GenericGrantleeFormatter - REQUIRED_HEADERS PimCommon_genericgrantlee_HEADERS - PREFIX PimCommon - RELATIVE genericgrantlee - ) - ecm_generate_headers(PimCommon_CamelCasenetworkmanager_HEADERS HEADER_NAMES NetworkManager @@ -373,7 +359,6 @@ ${PimCommon_Camelcaselogactivities_HEADERS} ${PimCommon_CamelCasenetworkmanager_HEADERS} ${PimCommon_CamelCase_HEADERS} - ${PimCommon_CamelCasegenericgrantlee_HEADERS} ${PimCommon_CamelCasejob_HEADERS} ${PimCommon_Camelcaseautocorrection_HEADERS} ${PimCommon_Camelcaseautocorrectionwidgets_HEADERS} @@ -409,7 +394,6 @@ ${PimCommon_autocorrection_HEADERS} ${PimCommon_autocorrectionwidgets_HEADERS} ${PimCommon_customtools_HEADERS} - ${PimCommon_genericgrantlee_HEADERS} ${PimCommon_job_HEADERS} ${PimCommon_managerserversidesubscription_HEADERS} ${PimCommon_migrate_HEADERS} diff --git a/src/pimcommon/genericgrantlee/genericgrantleeformatter.h b/src/pimcommon/genericgrantlee/genericgrantleeformatter.h deleted file mode 100644 --- a/src/pimcommon/genericgrantlee/genericgrantleeformatter.h +++ /dev/null @@ -1,52 +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; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#ifndef GENERICGRANTLEEFORMATTER_H -#define GENERICGRANTLEEFORMATTER_H - -#include "pimcommon_export.h" -#include -#include - -#include - -namespace PimCommon { -class GenericGrantleeFormatterPrivate; -class PIMCOMMON_EXPORT GenericGrantleeFormatter : public QObject -{ - Q_OBJECT -public: - explicit GenericGrantleeFormatter(QObject *parent = nullptr); - explicit GenericGrantleeFormatter(const QString &defaultHtmlMain, const QString &themePath, QObject *parent = nullptr); - ~GenericGrantleeFormatter(); - - void setDefaultHtmlMainFile(const QString &name); - - void changeGrantleePath(const QString &path); - Q_REQUIRED_RESULT QString errorMessage() const; - - Q_REQUIRED_RESULT QString render(const QVariantHash &mapping) const; - - //For debug - void setContent(const QString &content); - void refreshTemplate(); -private: - std::unique_ptr const d; -}; -} -#endif // GENERICGRANTLEEFORMATTER_H diff --git a/src/pimcommon/genericgrantlee/genericgrantleeformatter.cpp b/src/pimcommon/genericgrantlee/genericgrantleeformatter.cpp deleted file mode 100644 --- a/src/pimcommon/genericgrantlee/genericgrantleeformatter.cpp +++ /dev/null @@ -1,104 +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; if not, write to the Free Software Foundation, Inc., - 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA -*/ - -#include "genericgrantleeformatter.h" - -#include - -using namespace PimCommon; - -class PimCommon::GenericGrantleeFormatterPrivate -{ -public: - GenericGrantleeFormatterPrivate() - : mEngine(new Grantlee::Engine) - { - } - - QString mThemePath; - QString mDefaultMainFile; - std::unique_ptr mEngine; - QString mErrorMessage; - QSharedPointer mTemplateLoader; - Grantlee::Template mTemplate; -}; - - -GenericGrantleeFormatter::GenericGrantleeFormatter(const QString &defaultHtmlMain, const QString &themePath, QObject *parent) - : QObject(parent) - , d(new PimCommon::GenericGrantleeFormatterPrivate) -{ - d->mThemePath = themePath; - d->mDefaultMainFile = defaultHtmlMain; - changeGrantleePath(d->mThemePath); -} - -GenericGrantleeFormatter::GenericGrantleeFormatter(QObject *parent) - : QObject(parent) - , d(new PimCommon::GenericGrantleeFormatterPrivate) -{ -} - -GenericGrantleeFormatter::~GenericGrantleeFormatter() = default; - -void GenericGrantleeFormatter::setDefaultHtmlMainFile(const QString &name) -{ - if (d->mDefaultMainFile != name) { - d->mDefaultMainFile = name; - refreshTemplate(); - } -} - -void GenericGrantleeFormatter::changeGrantleePath(const QString &path) -{ - if (!d->mTemplateLoader) { - d->mTemplateLoader.reset(new Grantlee::FileSystemTemplateLoader); - } - d->mTemplateLoader->setTemplateDirs(QStringList() << path); - d->mEngine->addTemplateLoader(d->mTemplateLoader); - - refreshTemplate(); -} - -QString GenericGrantleeFormatter::errorMessage() const -{ - return d->mErrorMessage; -} - -QString GenericGrantleeFormatter::render(const QVariantHash &mapping) const -{ - Grantlee::Context context(mapping); - const QString contentHtml = d->mTemplate->render(&context); - return contentHtml; -} - -void GenericGrantleeFormatter::setContent(const QString &content) -{ - d->mTemplate = d->mEngine->newTemplate(content, QStringLiteral("content")); - if (d->mTemplate->error()) { - d->mErrorMessage = d->mTemplate->errorString() + QLatin1String("
"); - } -} - -void GenericGrantleeFormatter::refreshTemplate() -{ - d->mTemplate = d->mEngine->loadByName(d->mDefaultMainFile); - if (d->mTemplate->error()) { - d->mErrorMessage += d->mTemplate->errorString() + QLatin1String("
"); - } -}