cutelyst  4.5.1
A C++ Web Framework built on top of Qt, using the simple approach of Catalyst (Perl) framework.
cuteleeview.h
1 /*
2  * SPDX-FileCopyrightText: (C) 2013-2022 Daniel Nicoletti <dantti12@gmail.com>
3  * SPDX-License-Identifier: BSD-3-Clause
4  */
5 #ifndef CUTELEE_VIEW_H
6 #define CUTELEE_VIEW_H
7 
8 #include <Cutelyst/Plugins/View/cutelee_export.h>
9 #include <Cutelyst/View>
10 
11 #include <QLocale>
12 #include <QObject>
13 #include <QStringList>
14 #include <QVector>
15 
16 class QTranslator;
17 
18 namespace Cutelee {
19 class Engine;
20 }
21 
22 namespace Cutelyst {
23 
24 class CuteleeViewPrivate;
138 class CUTELYST_VIEW_CUTELEE_EXPORT CuteleeView final : public View
139 {
140  Q_OBJECT
141  Q_DECLARE_PRIVATE(CuteleeView)
142 public:
150  explicit CuteleeView(QObject *parent = nullptr, const QString &name = QString());
151 
152  Q_PROPERTY(QStringList includePaths READ includePaths WRITE setIncludePaths NOTIFY changed)
157  QStringList includePaths() const;
158 
163  void setIncludePaths(const QStringList &paths);
164 
165  Q_PROPERTY(
166  QString templateExtension READ templateExtension WRITE setTemplateExtension NOTIFY changed)
171  QString templateExtension() const;
172 
177  void setTemplateExtension(const QString &extension);
178 
179  Q_PROPERTY(QString wrapper READ wrapper WRITE setWrapper NOTIFY changed)
180 
181 
185  [[nodiscard]] QString wrapper() const;
186 
192  void setWrapper(const QString &name);
193 
194  Q_PROPERTY(bool cache READ isCaching WRITE setCache NOTIFY changed)
199  bool isCaching() const;
200 
206  void setCache(bool enable);
207 
211  [[nodiscard]] Cutelee::Engine *engine() const;
212 
216  void preloadTemplates();
217 
218  QByteArray render(Context *c) const override final;
219 
254  void addTranslator(const QLocale &locale, QTranslator *translator);
255 
268  void addTranslator(const QString &locale, QTranslator *translator);
269 
301  void addTranslationCatalog(const QString &path, const QString &catalog);
302 
313  void addTranslationCatalogs(const QMultiHash<QString, QString> &catalogs);
314 
345  QVector<QLocale> loadTranslationsFromDir(const QString &filename,
346  const QString &directory,
347  const QString &prefix = QStringLiteral("."),
348  const QString &suffix = QStringLiteral(".qm"));
349 
350 Q_SIGNALS:
351  void changed();
352 };
353 
354 } // namespace Cutelyst
355 
356 #endif // CUTELEE_VIEW_H
The Cutelyst Context.
Definition: context.h:42
A view that renders templates using Cutelee engine.
Definition: cuteleeview.h:139
Abstract View component for Cutelyst.
Definition: view.h:25
The Cutelyst namespace holds all public Cutelyst API.