Grantlee 5.3.0

context.h
1/*
2 This file is part of the Grantlee template system.
3
4 Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com>
5
6 This library is free software; you can redistribute it and/or
7 modify it under the terms of the GNU Lesser General Public
8 License as published by the Free Software Foundation; either version
9 2.1 of the Licence, or (at your option) any later version.
10
11 This library is distributed in the hope that it will be useful,
12 but WITHOUT ANY WARRANTY; without even the implied warranty of
13 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
14 Lesser General Public License for more details.
15
16 You should have received a copy of the GNU Lesser General Public
17 License along with this library. If not, see <http://www.gnu.org/licenses/>.
18
19*/
20
21#ifndef GRANTLEE_CONTEXT_H
22#define GRANTLEE_CONTEXT_H
23
24#include "abstractlocalizer.h"
25#include "grantlee_templates_export.h"
26
27#include <QtCore/QVariantHash>
28
29 namespace Grantlee
30{
31
32 class RenderContext;
33
34 class ContextPrivate;
35
37
117 class GRANTLEE_TEMPLATES_EXPORT Context
118{
119 public:
123 Context();
128 explicit Context(const QVariantHash &hash);
129
133 Context(const Context &other);
134
138 Context &operator=(const Context &other);
139
140#ifndef Q_QDOC
147 bool autoEscape() const;
148
155 void setAutoEscape(bool autoescape);
156#endif
160 ~Context();
161
165 QVariant lookup(const QString &str) const;
166
171 void insert(const QString &name, QObject *object);
172
177 void insert(const QString &name, const QVariant &variant);
178
183 void push();
184
189 void pop();
190
191#ifndef Q_QDOC
195 QVariantHash stackHash(int depth) const;
196
201 bool isMutating() const;
202
207 void setMutating(bool mutating);
208
212 void addExternalMedia(const QString &absolutePart,
213 const QString &relativePart);
214
218 void clearExternalMedia();
219#endif
220
226 void setLocalizer(QSharedPointer<AbstractLocalizer> localizer);
227
231 QSharedPointer<AbstractLocalizer> localizer() const;
232
236 QList<QPair<QString, QString>> externalMedia() const;
237
241 enum UrlType {
242 AbsoluteUrls,
243 RelativeUrls
244 };
245
250 void setUrlType(UrlType type);
251
255 UrlType urlType() const;
256
263 void setRelativeMediaPath(const QString &relativePath);
264
268 QString relativeMediaPath() const;
269
275 RenderContext *renderContext() const;
276
277 private:
278 Q_DECLARE_PRIVATE(Context)
279 ContextPrivate *const d_ptr;
280};
281}
282
283#endif
Grantlee::Context
The Context class holds the context to render a Template with.
Definition: context.h:118
Grantlee::Context::lookup
QVariant lookup(const QString &str) const
Grantlee::Context::localizer
QSharedPointer< AbstractLocalizer > localizer() const
Grantlee::Context::UrlType
UrlType
Definition: context.h:241
Grantlee::Context::AbsoluteUrls
@ AbsoluteUrls
Absolute URLs should be put in the template.
Definition: context.h:242
Grantlee::Context::renderContext
RenderContext * renderContext() const
Grantlee::Context::externalMedia
QList< QPair< QString, QString > > externalMedia() const
Grantlee::Context::setRelativeMediaPath
void setRelativeMediaPath(const QString &relativePath)
Grantlee::Context::Context
Context(const QVariantHash &hash)
Grantlee::Context::insert
void insert(const QString &name, QObject *object)
Grantlee::Context::pop
void pop()
Grantlee::Context::setLocalizer
void setLocalizer(QSharedPointer< AbstractLocalizer > localizer)
Grantlee::Context::Context
Context(const Context &other)
Grantlee::Context::~Context
~Context()
Grantlee::Context::setUrlType
void setUrlType(UrlType type)
Grantlee::Context::Context
Context()
Grantlee::Context::insert
void insert(const QString &name, const QVariant &variant)
Grantlee::Context::operator=
Context & operator=(const Context &other)
Grantlee::Context::relativeMediaPath
QString relativeMediaPath() const
Grantlee::Context::push
void push()
Grantlee::Context::urlType
UrlType urlType() const
Grantlee::RenderContext
Provides storage facility for state while rendering a template.
Definition: rendercontext.h:47
Grantlee
The Grantlee namespace holds all public Grantlee API.
Definition: Mainpage.dox:8