Cutelyst  1.7.0
grantleeview.h
1 /*
2  * Copyright (C) 2013-2016 Daniel Nicoletti <dantti12@gmail.com>
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Library General Public
6  * License as published by the Free Software Foundation; either
7  * version 2 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Library General Public License for more details.
13  *
14  * You should have received a copy of the GNU Library General Public License
15  * along with this library; see the file COPYING.LIB. If not, write to
16  * the Free Software Foundation, Inc., 51 Franklin Street, Fifth Floor,
17  * Boston, MA 02110-1301, USA.
18  */
19 
20 #ifndef GRANTLEE_VIEW_H
21 #define GRANTLEE_VIEW_H
22 
23 #include <QObject>
24 #include <QStringList>
25 #include <QLocale>
26 
27 #include <Cutelyst/View>
28 
29 class QTranslator;
30 
31 namespace Grantlee {
32 class Engine;
33 }
34 
35 namespace Cutelyst {
36 
37 class GrantleeViewPrivate;
49 class CUTELYST_VIEW_GRANTLEE_EXPORT GrantleeView : public View
50 {
51  Q_OBJECT
52  Q_DECLARE_PRIVATE(GrantleeView)
53 public:
57  explicit GrantleeView(QObject *parent = nullptr, const QString &name = QString());
58  ~GrantleeView();
59 
60  Q_PROPERTY(QStringList includePaths READ includePaths WRITE setIncludePaths)
64  QStringList includePaths() const;
65 
69  void setIncludePaths(const QStringList &paths);
70 
71  Q_PROPERTY(QString templateExtension READ templateExtension WRITE setTemplateExtension)
75  QString templateExtension() const;
76 
80  void setTemplateExtension(const QString &extension);
81 
82  Q_PROPERTY(QString wrapper READ wrapper WRITE setWrapper)
83 
84 
87  QString wrapper() const;
88 
93  void setWrapper(const QString &name);
94 
95  Q_PROPERTY(bool cache READ isCaching WRITE setCache)
99  bool isCaching() const;
100 
105  void setCache(bool enable);
106 
110  Grantlee::Engine *engine() const;
111 
115  void preloadTemplates();
116 
117  QByteArray render(Context *c) const final;
118 
146  void addTranslator(const QLocale &locale, QTranslator *translator);
147 
157  void addTranslator(const QString &locale, QTranslator *translator);
158 
187  void addTranslationCatalog(const QString &path, const QString &catalog);
188 
197  void addTranslationCatalogs(const QHash<QString, QString> &catalogs);
198 
199 protected:
200  GrantleeViewPrivate *d_ptr;
201 };
202 
203 }
204 
205 #endif // GRANTLEE_VIEW_H
The Cutelyst Context.
Definition: context.h:52
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:7
Cutelyst View abstract view component
Definition: view.h:35