Cutelyst  2.1.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 : public View
49 {
50  Q_OBJECT
51  Q_DECLARE_PRIVATE(GrantleeView)
52 public:
56  explicit GrantleeView(QObject *parent = nullptr, const QString &name = QString());
57  ~GrantleeView();
58 
59  Q_PROPERTY(QStringList includePaths READ includePaths WRITE setIncludePaths NOTIFY changed)
63  QStringList includePaths() const;
64 
68  void setIncludePaths(const QStringList &paths);
69 
70  Q_PROPERTY(QString templateExtension READ templateExtension WRITE setTemplateExtension NOTIFY changed)
74  QString templateExtension() const;
75 
79  void setTemplateExtension(const QString &extension);
80 
81  Q_PROPERTY(QString wrapper READ wrapper WRITE setWrapper NOTIFY changed)
82 
83 
86  QString wrapper() const;
87 
92  void setWrapper(const QString &name);
93 
94  Q_PROPERTY(bool cache READ isCaching WRITE setCache NOTIFY changed)
98  bool isCaching() const;
99 
104  void setCache(bool enable);
105 
109  Grantlee::Engine *engine() const;
110 
114  void preloadTemplates();
115 
116  QByteArray render(Context *c) const final;
117 
147  void addTranslator(const QLocale &locale, QTranslator *translator);
148 
160  void addTranslator(const QString &locale, QTranslator *translator);
161 
190  void addTranslationCatalog(const QString &path, const QString &catalog);
191 
200  void addTranslationCatalogs(const QHash<QString, QString> &catalogs);
201 
227  QVector<QLocale> loadTranslationsFromDir(const QString &filename, const QString &directory, const QString &prefix = QStringLiteral("."), const QString &suffix = QStringLiteral(".qm"));
228 
229 Q_SIGNALS:
230  void changed();
231 
232 protected:
233  GrantleeViewPrivate *d_ptr;
234 };
235 
236 }
237 
238 #endif // GRANTLEE_VIEW_H
The Cutelyst Context.
Definition: context.h:50
The Cutelyst namespace holds all public Cutelyst API.
Definition: Mainpage.dox:7
Cutelyst View abstract view component
Definition: view.h:33