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> 51 class CUTELYST_LIBRARY
Context :
public QObject
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)
81 void error(
const QString &error);
97 void setState(
bool state);
127 QString actionName()
const;
157 QString controllerName()
const;
168 Controller *controller(
const QString &name)
const;
173 View *view(
const QString &name = QString())
const;
180 View *customView()
const;
193 bool setCustomView(
const QString &name);
214 inline void stash(
const QVariantHash &unite);
227 QVariantHash &stash();
232 QVariant stash(
const QString &key)
const;
237 QVariant stash(
const QString &key,
const QVariant &defaultValue)
const;
244 QVariant stashTake(
const QString &key);
250 bool stashRemove(
const QString &key);
255 void setStash(
const QString &key,
const QVariant &value);
265 QStack<Component *> stack()
const;
278 QUrl uriFor(
const QString &path = QString(),
292 inline QUrl uriFor(
const QString &path,
304 QUrl uriFor(
Action *action,
314 inline QUrl uriFor(
Action *action,
340 QUrl uriForAction(
const QString &path,
348 inline QUrl uriForAction(
const QString &path,
355 bool detached()
const;
362 void detach(
Action *action =
nullptr);
428 bool forward(
const QString &action);
433 Action *getAction(
const QString &action,
const QString &ns = QString())
const;
438 QVector<Action *> getActions(
const QString &action,
const QString &ns = QString())
const;
443 QVector<Plugin *> plugins()
const;
448 template <
typename T>
451 const auto pluginsConst = plugins();
452 for (
Plugin *plugin : pluginsConst) {
453 auto p = qobject_cast<T>(plugin);
473 QLocale locale()
const;
489 void setLocale(
const QLocale &locale);
494 QVariant config(
const QString &key,
const QVariant &defaultValue = QVariant())
const;
499 QVariantMap config()
const;
514 QString translate(
const char *context,
const char *sourceText,
const char *disambiguation =
nullptr,
int n = -1)
const;
528 Q_DECL_DEPRECATED
bool wait(uint count = 1);
541 void next(
bool force =
false);
562 ContextPrivate *d_ptr;
569 {
stash().unite(unite); }
584 #endif // CUTELYST_CONTEXT_H QMap< QString, QString > ParamsMultiMap
QUrl uriFor(const QString &path=QString(), const QStringList &args=QStringList(), const ParamsMultiMap &queryValues=ParamsMultiMap()) const
The Cutelyst Component base class.
This class represents a Cutelyst Action.
QUrl uriForAction(const QString &path, const QStringList &captures=QStringList(), const QStringList &args=QStringList(), const ParamsMultiMap &queryValues=ParamsMultiMap()) const
Cutelyst Controller base class
T plugin()
Returns the registered plugin that casts to the template type T.
The Cutelyst namespace holds all public Cutelyst API.
Cutelyst View abstract view component
The Cutelyst Application.