Cutelyst  2.13.0
grantleeview.h
1 /*
2  * Copyright (C) 2013-2018 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 Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 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  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library; if not, write to the Free Software
16  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
17  */
18 #ifndef GRANTLEE_VIEW_H
19 #define GRANTLEE_VIEW_H
20 
21 #include <QObject>
22 #include <QStringList>
23 #include <QLocale>
24 #include <QVector>
25 
26 #include <Cutelyst/View>
27 
28 class QTranslator;
29 
30 namespace Grantlee {
31 class Engine;
32 }
33 
34 namespace Cutelyst {
35 
36 class GrantleeViewPrivate;
48 class CUTELYST_VIEW_GRANTLEE_EXPORT GrantleeView final : public View
49 {
50  Q_OBJECT
51  Q_DECLARE_PRIVATE(GrantleeView)
52 public:
56  explicit GrantleeView(QObject *parent = nullptr, const QString &name = QString());
57 
58  Q_PROPERTY(QStringList includePaths READ includePaths WRITE setIncludePaths NOTIFY changed)
62  QStringList includePaths() const;
63 
67  void setIncludePaths(const QStringList &paths);
68 
69  Q_PROPERTY(QString templateExtension READ templateExtension WRITE setTemplateExtension NOTIFY changed)
73  QString templateExtension() const;
74 
78  void setTemplateExtension(const QString &extension);
79 
80  Q_PROPERTY(QString wrapper READ wrapper WRITE setWrapper NOTIFY changed)
81 
82 
85  QString wrapper() const;
86 
91  void setWrapper(const QString &name);
92 
93  Q_PROPERTY(bool cache READ isCaching WRITE setCache NOTIFY changed)
97  bool isCaching() const;
98 
103  void setCache(bool enable);
104 
108  Grantlee::Engine *engine() const;
109 
113  void preloadTemplates();
114 
115  QByteArray render(Context *c) const final;
116 
146  void addTranslator(const QLocale &locale, QTranslator *translator);
147 
159  void addTranslator(const QString &locale, QTranslator *translator);
160 
189  void addTranslationCatalog(const QString &path, const QString &catalog);
190 
199  void addTranslationCatalogs(const QHash<QString, QString> &catalogs);
200 
226  QVector<QLocale> loadTranslationsFromDir(const QString &filename, const QString &directory, const QString &prefix = QStringLiteral("."), const QString &suffix = QStringLiteral(".qm"));
227 
228 Q_SIGNALS:
229  void changed();
230 };
231 
232 }
233 
234 #endif // GRANTLEE_VIEW_H
Cutelyst::Context
The Cutelyst Context.
Definition: context.h:50
Cutelyst::View
Cutelyst View abstract view component
Definition: view.h:34
Cutelyst
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:7
Cutelyst::GrantleeView
Definition: grantleeview.h:48