Members of the KDE Community are recommended to subscribe to the kde-community mailing list at https://mail.kde.org/mailman/listinfo/kde-community to allow them to participate in important discussions and receive other important announcements

Commit 1f8330fd authored by Laurent Montel's avatar Laurent Montel 😁

Improve class to allow to create testcase

parent 17ef5c6b
......@@ -27,6 +27,12 @@
using namespace KABPrinting;
GrantleePrint::GrantleePrint(QObject *parent)
: QObject(parent)
{
mEngine = new Grantlee::Engine;
}
GrantleePrint::GrantleePrint(const QString &themePath, QObject *parent)
: QObject(parent)
{
......@@ -47,6 +53,14 @@ GrantleePrint::~GrantleePrint()
delete mEngine;
}
void GrantleePrint::setContent(const QString &content)
{
mSelfcontainedTemplate = mEngine->newTemplate(content, QLatin1String("content"));
if ( mSelfcontainedTemplate->error() ) {
mErrorMessage = mSelfcontainedTemplate->errorString() + QLatin1String("<br>");
}
}
QString GrantleePrint::contactsToHtml( const KABC::Addressee::List &contacts )
{
if (!mErrorMessage.isEmpty())
......
......@@ -18,6 +18,7 @@
#ifndef GRANTLEEPRINT_H
#define GRANTLEEPRINT_H
#include "kaddressbook_export.h"
#include <QObject>
#include <grantlee/templateloader.h>
#include <KABC/Addressee>
......@@ -27,19 +28,23 @@ class Engine;
}
namespace KABPrinting {
class GrantleePrint : public QObject
class KADDRESSBOOK_EXPORT GrantleePrint : public QObject
{
Q_OBJECT
public:
explicit GrantleePrint(QObject *parent = 0);
explicit GrantleePrint(const QString &themePath, QObject *parent = 0);
~GrantleePrint();
void setContent(const QString &content);
QString contactsToHtml( const KABC::Addressee::List &contacts );
private:
QString mErrorMessage;
Grantlee::Engine *mEngine;
Grantlee::FileSystemTemplateLoader::Ptr mTemplateLoader;
Grantlee::Template mSelfcontainedTemplate;
QString mErrorMessage;
Grantlee::Engine *mEngine;
};
}
#endif // GRANTLEEPRINT_H
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment