Grantlee  5.0.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 
109 class GRANTLEE_TEMPLATES_EXPORT Context
110 {
111 public:
112 
116  Context();
120  explicit Context( const QVariantHash &hash );
121 
122 
126  Context( const Context &other );
127 
131  Context& operator =( const Context &other );
132 
133 #ifndef Q_QDOC
134 
139  bool autoEscape() const;
140 
146  void setAutoEscape( bool autoescape );
147 #endif
148 
151  ~Context();
152 
156  QVariant lookup( const QString &str ) const;
157 
161  void insert( const QString &name, QObject *object );
162 
166  void insert( const QString &name, const QVariant &variant );
167 
172  void push();
173 
178  void pop();
179 
180 #ifndef Q_QDOC
181 
184  QVariantHash stackHash( int depth ) const;
185 
190  bool isMutating() const;
191 
196  void setMutating( bool mutating );
197 
201  void addExternalMedia( const QString &absolutePart, const QString &relativePart );
202 
206  void clearExternalMedia();
207 #endif
208 
214  void setLocalizer( QSharedPointer<AbstractLocalizer> localizer );
215 
219  QSharedPointer<AbstractLocalizer> localizer() const;
220 
224  QList<QPair<QString, QString> > externalMedia() const;
225 
229  enum UrlType
230  {
232  RelativeUrls
233  };
234 
239  void setUrlType( UrlType type );
240 
244  UrlType urlType() const;
245 
250  void setRelativeMediaPath( const QString &relativePath );
251 
255  QString relativeMediaPath() const;
256 
262  RenderContext* renderContext() const;
263 
264 private:
265  Q_DECLARE_PRIVATE( Context )
266  ContextPrivate * const d_ptr;
267 };
268 
269 }
270 
271 #endif
The Context class holds the context to render a template with.
Definition: context.h:109
Absolute URLs should be put in the template.
Definition: context.h:231
Provides storage facility for state while rendering a template.
Definition: rendercontext.h:45
The Grantlee namespace holds all public Grantlee API.
Definition: Mainpage.dox:7