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
29namespace Grantlee
30{
31
32class RenderContext;
33
34class ContextPrivate;
35
37
117class GRANTLEE_TEMPLATES_EXPORT Context
118{
119public:
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
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 {
243 RelativeUrls
244 };
245
250 void setUrlType(UrlType type);
251
256
263 void setRelativeMediaPath(const QString &relativePath);
264
268 QString relativeMediaPath() const;
269
276
277private:
278 Q_DECLARE_PRIVATE(Context)
279 ContextPrivate *const d_ptr;
280};
281}
282
283#endif
The Context class holds the context to render a Template with.
Definition context.h:118
QVariant lookup(const QString &str) const
QSharedPointer< AbstractLocalizer > localizer() const
@ AbsoluteUrls
Absolute URLs should be put in the template.
Definition context.h:242
RenderContext * renderContext() const
QList< QPair< QString, QString > > externalMedia() const
void setRelativeMediaPath(const QString &relativePath)
Context(const QVariantHash &hash)
void insert(const QString &name, QObject *object)
void setLocalizer(QSharedPointer< AbstractLocalizer > localizer)
Context(const Context &other)
void setUrlType(UrlType type)
void insert(const QString &name, const QVariant &variant)
Context & operator=(const Context &other)
QString relativeMediaPath() const
UrlType urlType() const
Provides storage facility for state while rendering a template.
The Grantlee namespace holds all public Grantlee API.
Definition Mainpage.dox:8