• Skip to content
  • Skip to link menu
KDE API Reference
  • KDE API Reference
  • kdepim API Reference
  • KDE Home
  • Contact Us
 

knotes

  • sources
  • kde-4.14
  • kdepim
  • knotes
  • print
knotegrantleeprint.cpp
Go to the documentation of this file.
1 /*
2  Copyright (c) 2015 Montel Laurent <montel@kde.org>
3 
4  This program is free software; you can redistribute it and/or modify it
5  under the terms of the GNU General Public License, version 2, as
6  published by the Free Software Foundation.
7 
8  This program is distributed in the hope that it will be useful, but
9  WITHOUT ANY WARRANTY; without even the implied warranty of
10  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
11  General Public License for more details.
12 
13  You should have received a copy of the GNU General Public License along
14  with this program; if not, write to the Free Software Foundation, Inc.,
15  51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
16 */
17 
18 #include "knotegrantleeprint.h"
19 #include "knoteprintobject.h"
20 #include <KLocalizedString>
21 #include <grantlee/context.h>
22 #include <grantlee/engine.h>
23 
24 KNoteGrantleePrint::KNoteGrantleePrint(QObject *parent)
25  : QObject(parent)
26 {
27  mEngine = new Grantlee::Engine;
28 }
29 
30 KNoteGrantleePrint::KNoteGrantleePrint(const QString &themePath, QObject *parent)
31  : QObject(parent)
32 {
33  mEngine = new Grantlee::Engine;
34  mTemplateLoader = Grantlee::FileSystemTemplateLoader::Ptr( new Grantlee::FileSystemTemplateLoader );
35 
36  mTemplateLoader->setTemplateDirs(QStringList() << themePath);
37  mEngine->addTemplateLoader(mTemplateLoader);
38 
39  mSelfcontainedTemplate = mEngine->loadByName(QLatin1String("theme.html"));
40  if (mSelfcontainedTemplate->error()) {
41  mErrorMessage = mSelfcontainedTemplate->errorString() + QLatin1String("<br>");
42  }
43 }
44 
45 KNoteGrantleePrint::~KNoteGrantleePrint()
46 {
47  mEngine->deleteLater();
48  mEngine = 0;
49 }
50 
51 QString KNoteGrantleePrint::errorMessage() const
52 {
53  return mErrorMessage;
54 }
55 
56 void KNoteGrantleePrint::setContent(const QString &content)
57 {
58  mSelfcontainedTemplate = mEngine->newTemplate(content, QLatin1String("content"));
59  if (mSelfcontainedTemplate->error()) {
60  mErrorMessage = mSelfcontainedTemplate->errorString() + QLatin1String("<br>");
61  }
62 }
63 
64 QString KNoteGrantleePrint::notesToHtml(const QList<KNotePrintObject *> lst)
65 {
66  if (lst.isEmpty())
67  return QString();
68  QVariantList notes;
69  Q_FOREACH(KNotePrintObject *n, lst)
70  notes << QVariant::fromValue(static_cast<QObject*>(n));
71  Grantlee::Context c;
72  c.insert(QLatin1String("notes"), notes);
73  c.insert(QLatin1String("alarm_i18n"), i18n("Alarm:"));
74  c.insert(QLatin1String("note_is_locked_i18n"), i18n("Note is locked"));
75 
76  const QString htmlText = mSelfcontainedTemplate->render(&c);
77  return htmlText;
78 }
KNotePrintObject
Definition: knoteprintobject.h:27
KNoteGrantleePrint::KNoteGrantleePrint
KNoteGrantleePrint(QObject *parent=0)
Definition: knotegrantleeprint.cpp:24
KNoteGrantleePrint::setContent
void setContent(const QString &content)
Definition: knotegrantleeprint.cpp:56
knoteprintobject.h
QObject
QList::isEmpty
bool isEmpty() const
QString
QList
QStringList
QLatin1String
KNoteGrantleePrint::~KNoteGrantleePrint
~KNoteGrantleePrint()
Definition: knotegrantleeprint.cpp:45
KNoteGrantleePrint::errorMessage
QString errorMessage() const
Definition: knotegrantleeprint.cpp:51
knotegrantleeprint.h
KNoteGrantleePrint::notesToHtml
QString notesToHtml(const QList< KNotePrintObject * > lst)
Definition: knotegrantleeprint.cpp:64
This file is part of the KDE documentation.
Documentation copyright © 1996-2020 The KDE developers.
Generated on Mon Jun 22 2020 13:32:28 by doxygen 1.8.7 written by Dimitri van Heesch, © 1997-2006

KDE's Doxygen guidelines are available online.

knotes

Skip menu "knotes"
  • Main Page
  • Namespace List
  • Namespace Members
  • Alphabetical List
  • Class List
  • Class Hierarchy
  • Class Members
  • File List
  • File Members

kdepim API Reference

Skip menu "kdepim API Reference"
  • akonadi_next
  • akregator
  • blogilo
  • calendarsupport
  • console
  •   kabcclient
  •   konsolekalendar
  • kaddressbook
  • kalarm
  •   lib
  • kdgantt2
  • kjots
  • kleopatra
  • kmail
  • knode
  • knotes
  • kontact
  • korgac
  • korganizer
  • ktimetracker
  • libkdepim
  • libkleo
  • libkpgp
  • mailcommon
  • messagelist
  • messageviewer
  • pimprint

Search



Report problems with this website to our bug tracking system.
Contact the specific authors with questions and comments about the page contents.

KDE® and the K Desktop Environment® logo are registered trademarks of KDE e.V. | Legal