5#ifndef CUTELYST_CONTEXT_H
6#define CUTELYST_CONTEXT_H
8#include <Cutelyst/async.h>
9#include <Cutelyst/cutelyst_global.h>
10#include <Cutelyst/request.h>
12#include <QtCore/QObject>
13#include <QtCore/QStack>
14#include <QtCore/QStringList>
16#include <QtCore/QVariant>
41 Q_PROPERTY(Action *action READ action CONSTANT)
47 Q_PROPERTY(Controller *controller READ controller CONSTANT)
49 Q_PROPERTY(QVariantMap config READ config CONSTANT)
63 bool error()
const noexcept;
78 bool state()
const noexcept;
89 Engine *
engine()
const noexcept;
94 Application *
app()
const noexcept;
109 Action *action()
const noexcept;
114 QString actionName()
const noexcept;
129 Request *request()
const noexcept;
144 QString controllerName()
const;
149 Controller *controller()
const noexcept;
155 Controller *controller(
const QString &name)
const;
208 void stash(
const QVariantHash &unite);
221 QVariantHash &
stash();
353 void detach(Action *action =
nullptr);
439 template <
typename T>
442 const auto pluginsConst =
plugins();
443 for (Plugin *
plugin : pluginsConst) {
464 QLocale locale() const noexcept;
480 void setLocale(const
QLocale &locale);
490 QVariantMap config() const noexcept;
505 QString translate(const
char *context,
506 const
char *sourceText,
507 const
char *disambiguation =
nullptr,
544 inline
QString qtTrId(const
char *
id,
int n = -1) const;
557 Context(ContextPrivate *priv);
559 friend class Application;
561 friend class ActionChain;
562 friend class DispatchType;
565 friend class Controller;
567 ContextPrivate *d_ptr;
570 Q_DECLARE_PRIVATE(Context)
590 return translate(
nullptr,
id,
nullptr, n);
This class represents a Cutelyst Action.
The Cutelyst Application.
The Cutelyst Component base class.
QVector< Action * > getActions(const QString &action, const QString &ns={}) const
QStringList errors() const noexcept
Returns a list of errors that were defined.
bool forward(Component *component)
void stash(const QVariantHash &unite)
QUrl uriFor(const QString &path=QString(), const QStringList &args=QStringList(), const ParamsMultiMap &queryValues=ParamsMultiMap()) const
QVector< Plugin * > plugins() const
Context(Application *app)
Constructs a new DUMMY Context object that is child of Application This currently is experimental to ...
Action * getAction(const QString &action, const QString &ns={}) const
void detach(Action *action=nullptr)
QStack< Component * > stack() const noexcept
void setState(bool state) noexcept
Sets the state of the current executed action, setting to false will make the dispatcher skip non pro...
Response * res() const noexcept
QString translate(const char *context, const char *sourceText, const char *disambiguation=nullptr, int n=-1) const
void setStash(const QString &key, const QVariant &value)
bool stashRemove(const QString &key)
QVariant stashTake(const QString &key)
void attachAsync()
attachAsync
QString qtTrId(const char *id, int n=-1) const
View * customView() const noexcept
bool detached() const noexcept
View * view(const QString &name) const
QUrl uriForAction(const QString &path, const QStringList &captures=QStringList(), const QStringList &args=QStringList(), const ParamsMultiMap &queryValues=ParamsMultiMap()) const
Dispatcher * dispatcher() const noexcept
Application * app() const noexcept
void detachAsync() noexcept
bool setCustomView(const QString &name)
Engine * engine() const noexcept
T plugin()
Returns the registered plugin that casts to the template type T.
bool error() const noexcept
Returns true if an error was set.
Response * response() const noexcept
Cutelyst Controller base class
Cutelyst View abstract view component
The Cutelyst namespace holds all public Cutelyst API.
QMultiMap< QString, QString > ParamsMultiMap
T qobject_cast(QObject *object)