|
Grantlee
5.1.0
|
00001 /* 00002 This file is part of the Grantlee template system. 00003 00004 Copyright (c) 2009,2010 Stephen Kelly <steveire@gmail.com> 00005 00006 This library is free software; you can redistribute it and/or 00007 modify it under the terms of the GNU Lesser General Public 00008 License as published by the Free Software Foundation; either version 00009 2.1 of the Licence, or (at your option) any later version. 00010 00011 This library is distributed in the hope that it will be useful, 00012 but WITHOUT ANY WARRANTY; without even the implied warranty of 00013 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU 00014 Lesser General Public License for more details. 00015 00016 You should have received a copy of the GNU Lesser General Public 00017 License along with this library. If not, see <http://www.gnu.org/licenses/>. 00018 00019 */ 00020 00021 #ifndef GRANTLEE_CONTEXT_H 00022 #define GRANTLEE_CONTEXT_H 00023 00024 #include "abstractlocalizer.h" 00025 #include "grantlee_templates_export.h" 00026 00027 #include <QtCore/QVariantHash> 00028 00029 namespace Grantlee 00030 { 00031 00032 class RenderContext; 00033 00034 class ContextPrivate; 00035 00037 00117 class GRANTLEE_TEMPLATES_EXPORT Context 00118 { 00119 public: 00123 Context(); 00128 explicit Context(const QVariantHash &hash); 00129 00133 Context(const Context &other); 00134 00138 Context &operator=(const Context &other); 00139 00140 #ifndef Q_QDOC 00141 00147 bool autoEscape() const; 00148 00155 void setAutoEscape(bool autoescape); 00156 #endif 00157 00160 ~Context(); 00161 00165 QVariant lookup(const QString &str) const; 00166 00171 void insert(const QString &name, QObject *object); 00172 00177 void insert(const QString &name, const QVariant &variant); 00178 00183 void push(); 00184 00189 void pop(); 00190 00191 #ifndef Q_QDOC 00192 00195 QVariantHash stackHash(int depth) const; 00196 00201 bool isMutating() const; 00202 00207 void setMutating(bool mutating); 00208 00212 void addExternalMedia(const QString &absolutePart, 00213 const QString &relativePart); 00214 00218 void clearExternalMedia(); 00219 #endif 00220 00226 void setLocalizer(QSharedPointer<AbstractLocalizer> localizer); 00227 00231 QSharedPointer<AbstractLocalizer> localizer() const; 00232 00236 QList<QPair<QString, QString>> externalMedia() const; 00237 00241 enum UrlType { 00242 AbsoluteUrls, 00243 RelativeUrls 00244 }; 00245 00250 void setUrlType(UrlType type); 00251 00255 UrlType urlType() const; 00256 00262 void setRelativeMediaPath(const QString &relativePath); 00263 00267 QString relativeMediaPath() const; 00268 00276 RenderContext *renderContext() const; 00277 00278 private: 00279 Q_DECLARE_PRIVATE(Context) 00280 ContextPrivate *const d_ptr; 00281 }; 00282 } 00283 00284 #endif
1.7.6.1