7#include <Cutelyst/async.h>
8#include <Cutelyst/cutelyst_global.h>
9#include <Cutelyst/request.h>
11#include <QtCore/QObject>
12#include <QtCore/QStack>
13#include <QtCore/QStringList>
15#include <QtCore/QVariant>
37class CUTELYST_LIBRARY
Context :
public QObject
40 Q_PROPERTY(
Action *action READ action CONSTANT)
41 Q_PROPERTY(QString actionName READ actionName CONSTANT)
42 Q_PROPERTY(QString ns READ ns CONSTANT)
43 Q_PROPERTY(QString
namespace READ ns CONSTANT)
44 Q_PROPERTY(
Request *req READ request CONSTANT)
45 Q_PROPERTY(
Request *request READ request CONSTANT)
46 Q_PROPERTY(
Controller *controller READ controller CONSTANT)
47 Q_PROPERTY(QString controllerName READ controllerName CONSTANT)
48 Q_PROPERTY(QVariantMap config READ config CONSTANT)
49 Q_PROPERTY(
bool state READ state CONSTANT)
62 [[nodiscard]]
bool error()
const noexcept;
67 void appendError(
const QString &error);
72 [[nodiscard]] QStringList errors()
const noexcept;
77 [[nodiscard]]
bool state()
const noexcept;
83 void setState(
bool state)
noexcept;
88 [[nodiscard]]
Engine *engine()
const noexcept;
98 [[nodiscard]]
Response *response()
const noexcept;
103 [[nodiscard]]
Response *res()
const noexcept;
108 [[nodiscard]]
Action *action()
const noexcept;
113 [[nodiscard]] QString actionName()
const noexcept;
122 [[nodiscard]] QString ns()
const noexcept;
128 [[nodiscard]]
Request *request()
const noexcept;
133 [[nodiscard]]
Request *req()
const noexcept;
138 [[nodiscard]]
Dispatcher *dispatcher()
const noexcept;
143 [[nodiscard]] QString controllerName()
const noexcept;
148 [[nodiscard]]
Controller *controller()
const noexcept;
154 [[nodiscard]]
Controller *controller(QStringView name)
const;
159 [[nodiscard]]
View *view(QStringView name = {})
const;
166 [[nodiscard]]
View *customView()
const noexcept;
179 bool setCustomView(QStringView name);
202 void stash(
const QVariantHash &unite);
215 [[nodiscard]] QVariantHash &stash();
220 [[nodiscard]] QVariant stash(
const QString &key)
const;
225 [[nodiscard]] QVariant stash(
const QString &key,
const QVariant &defaultValue)
const;
232 QVariant stashTake(
const QString &key);
238 bool stashRemove(
const QString &key);
243 void setStash(
const QString &key,
const QVariant &value);
253 [[nodiscard]] QStack<Component *> stack()
const noexcept;
266 [[nodiscard]] QUrl uriFor(
const QString &path = {},
267 const QStringList &args = {},
280 [[nodiscard]]
inline QUrl uriFor(
const QString &path,
const ParamsMultiMap &queryValues)
const;
291 [[nodiscard]] QUrl uriFor(
Action *action,
292 const QStringList &captures = {},
293 const QStringList &args = {},
326 [[nodiscard]] QUrl uriForAction(QStringView path,
327 const QStringList &captures = {},
328 const QStringList &args = {},
334 [[nodiscard]]
inline QUrl uriForAction(QStringView path,
341 bool detached()
const noexcept;
348 void detach(
Action *action =
nullptr);
365 void detachAsync()
noexcept;
414 bool forward(QStringView action);
419 [[nodiscard]]
Action *getAction(QStringView action, QStringView ns = {})
const;
424 [[nodiscard]] QVector<Action *> getActions(QStringView action, QStringView ns = {})
const;
429 [[nodiscard]] QVector<Plugin *> plugins()
const;
434 template <
typename T>
437 const auto pluginsConst = plugins();
438 for (
Plugin *plugin : pluginsConst) {
439 auto p = qobject_cast<T>(plugin);
459 [[nodiscard]] QLocale locale() const noexcept;
475 void setLocale(const QLocale &locale);
480 [[nodiscard]] QVariant config(const QString &key, const QVariant &defaultValue = {})
const;
485 [[nodiscard]] QVariantMap config() const noexcept;
500 [[nodiscard]] QString translate(const
char *context,
501 const
char *sourceText,
502 const
char *disambiguation =
nullptr,
539 [[nodiscard]] inline QString qtTrId(const
char *
id,
int n = -1) const;
552 Context(ContextPrivate *priv);
554 friend class Application;
556 friend class ActionChain;
557 friend class DispatchType;
560 friend class Controller;
562 ContextPrivate *d_ptr;
565 Q_DECLARE_PRIVATE(Context)
570 return uriFor(path, QStringList(), queryValues);
575 return uriFor(action, QStringList(), QStringList(), queryValues);
578inline QUrl Context::uriForAction(QStringView path,
const ParamsMultiMap &queryValues)
const
580 return uriForAction(path, QStringList(), QStringList(), queryValues);
583inline QString Context::qtTrId(
const char *
id,
int n)
const
585 return translate(
nullptr,
id,
nullptr, n);
This class represents a Cutelyst Action.
The Cutelyst Application.
The Cutelyst Component base class.
T plugin()
Returns the registered plugin that casts to the template type T.
Cutelyst Controller base class
Cutelyst View abstract view component
The Cutelyst namespace holds all public Cutelyst API.
QMultiMap< QString, QString > ParamsMultiMap