18 #ifndef CUTELYST_CONTEXT_H
19 #define CUTELYST_CONTEXT_H
21 #include <QtCore/QObject>
22 #include <QtCore/QVariant>
23 #include <QtCore/QUrl>
24 #include <QtCore/QStringList>
25 #include <QtCore/QStack>
27 #include <Cutelyst/async.h>
28 #include <Cutelyst/request.h>
29 #include <Cutelyst/cutelyst_global.h>
54 Q_PROPERTY(
Action* action READ action CONSTANT)
55 Q_PROPERTY(
QString actionName READ actionName CONSTANT)
56 Q_PROPERTY(
QString ns READ ns CONSTANT)
57 Q_PROPERTY(
QString namespace READ ns CONSTANT)
58 Q_PROPERTY(
Request *req READ request CONSTANT)
59 Q_PROPERTY(
Request *request READ request CONSTANT)
60 Q_PROPERTY(
Controller *controller READ controller CONSTANT)
61 Q_PROPERTY(
QString controllerName READ controllerName CONSTANT)
62 Q_PROPERTY(QVariantMap config READ config CONSTANT)
63 Q_PROPERTY(
bool state READ state CONSTANT)
76 bool error()
const noexcept;
81 void error(
const QString &error);
91 bool state()
const noexcept;
97 void setState(
bool state) noexcept;
102 Engine *engine()
const noexcept;
112 Response *response()
const noexcept;
122 Action *action()
const noexcept;
127 QString actionName()
const noexcept;
142 Request *request()
const noexcept;
157 QString controllerName()
const;
180 View *customView()
const noexcept;
193 bool setCustomView(
const QString &name);
216 void stash(
const QVariantHash &unite);
229 QVariantHash &stash();
252 bool stashRemove(
const QString &key);
357 bool detached()
const noexcept;
364 void detach(
Action *action =
nullptr);
381 void detachAsync() noexcept;
430 bool forward(
const QString &action);
450 template <
typename T>
453 const auto pluginsConst = plugins();
454 for (
Plugin *plugin : pluginsConst) {
455 auto p = qobject_cast<T>(plugin);
475 QLocale locale() const noexcept;
491 void setLocale(const
QLocale &locale);
501 QVariantMap config() const noexcept;
516 QString translate(const
char *context, const
char *sourceText, const
char *disambiguation =
nullptr,
int n = -1) const;
529 Context(ContextPrivate *priv);
531 friend class Application;
533 friend class ActionChain;
534 friend class DispatchType;
537 friend class Controller;
539 ContextPrivate *d_ptr;
542 Q_DECLARE_PRIVATE(Context)
546 {
return uriFor(path,
QStringList(), queryValues); }
This class represents a Cutelyst Action.
The Cutelyst Application.
The Cutelyst Component base class.
QUrl uriFor(const QString &path=QString(), const QStringList &args=QStringList(), const ParamsMultiMap &queryValues=ParamsMultiMap()) const
QUrl uriForAction(const QString &path, const QStringList &captures=QStringList(), const QStringList &args=QStringList(), const ParamsMultiMap &queryValues=ParamsMultiMap()) const
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