Cutelyst  1.5.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;
42 class CUTELYST_VIEW_GRANTLEE_EXPORT GrantleeView : public View
43 {
44  Q_OBJECT
45  Q_DECLARE_PRIVATE(GrantleeView)
46 public:
47  explicit GrantleeView(QObject *parent = nullptr, const QString &name = QString());
48  ~GrantleeView();
49 
50  Q_PROPERTY(QStringList includePaths READ includePaths WRITE setIncludePaths)
51  QStringList includePaths() const;
52  void setIncludePaths(const QStringList &paths);
53 
54  Q_PROPERTY(QString templateExtension READ templateExtension WRITE setTemplateExtension)
55  QString templateExtension() const;
56  void setTemplateExtension(const QString &extension);
57 
58  Q_PROPERTY(QString wrapper READ wrapper WRITE setWrapper)
59  QString wrapper() const;
60  void setWrapper(const QString &name);
61 
62  Q_PROPERTY(bool cache READ isCaching WRITE setCache)
63  bool isCaching() const;
64  void setCache(bool enable);
65 
66  Grantlee::Engine *engine() const;
67 
68  void preloadTemplates();
69 
70  QByteArray render(Context *c) const final;
71 
99  void addTranslator(const QLocale &locale, QTranslator *translator);
100 
110  void addTranslator(const QString &locale, QTranslator *translator);
111 
140  void addTranslationCatalog(const QString &path, const QString &catalog);
141 
150  void addTranslationCatalogs(const QHash<QString, QString> &catalogs);
151 
152 protected:
153  GrantleeViewPrivate *d_ptr;
154 };
155 
156 }
157 
158 #endif // GRANTLEE_VIEW_H
The Cutelyst Context.
Definition: context.h:52
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:7