Grantlee 0.2.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_core_export.h" 00026 00027 #include <QtCore/QVariantHash> 00028 00029 namespace Grantlee 00030 { 00031 00032 class RenderContext; 00033 00034 class ContextPrivate; 00035 00037 00109 class GRANTLEE_CORE_EXPORT Context 00110 { 00111 public: 00112 00116 Context(); 00120 explicit Context( const QVariantHash &hash ); 00121 00122 00126 Context( const Context &other ); 00127 00131 Context& operator =( const Context &other ); 00132 00133 #ifndef Q_QDOC 00134 00139 bool autoEscape() const; 00140 00146 void setAutoEscape( bool autoescape ); 00147 #endif 00148 00151 ~Context(); 00152 00156 QVariant lookup( const QString &str ) const; 00157 00161 void insert( const QString &name, QObject *object ); 00162 00166 void insert( const QString &name, const QVariant &variant ); 00167 00172 void push(); 00173 00178 void pop(); 00179 00180 #ifndef Q_QDOC 00181 00184 QVariantHash stackHash( int depth ) const; 00185 00190 bool isMutating() const; 00191 00196 void setMutating( bool mutating ); 00197 00201 void addExternalMedia( const QString &absolutePart, const QString &relativePart ); 00202 00206 void clearExternalMedia(); 00207 #endif 00208 00214 void setLocalizer( AbstractLocalizer::Ptr localizer ); 00215 00219 AbstractLocalizer::Ptr localizer() const; 00220 00224 QList<QPair<QString, QString> > externalMedia() const; 00225 00229 enum UrlType 00230 { 00231 AbsoluteUrls, 00232 RelativeUrls 00233 }; 00234 00239 void setUrlType( UrlType type ); 00240 00244 UrlType urlType() const; 00245 00250 void setRelativeMediaPath( const QString &relativePath ); 00251 00255 QString relativeMediaPath() const; 00256 00262 RenderContext* renderContext() const; 00263 00264 private: 00265 Q_DECLARE_PRIVATE( Context ) 00266 ContextPrivate * const d_ptr; 00267 }; 00268 00269 } 00270 00271 #endif 00272