diff options
Diffstat (limited to 'src/backend/managers/cdisplaytemplatemgr.h')
-rw-r--r-- | src/backend/managers/cdisplaytemplatemgr.h | 119 |
1 files changed, 65 insertions, 54 deletions
diff --git a/src/backend/managers/cdisplaytemplatemgr.h b/src/backend/managers/cdisplaytemplatemgr.h index 16725a5..9b96e8b 100644 --- a/src/backend/managers/cdisplaytemplatemgr.h +++ b/src/backend/managers/cdisplaytemplatemgr.h @@ -2,7 +2,7 @@ * * This file is part of BibleTime's source code, http://www.bibletime.info/. * -* Copyright 1999-2008 by the BibleTime developers. +* Copyright 1999-2011 by the BibleTime developers. * The BibleTime source code is licensed under the GNU General Public License version 2.0. * **********/ @@ -18,71 +18,82 @@ class CSwordModuleInfo; /** - * Manages the display templates used in the filters and display classes. - * @author The BibleTime team + Manages the display templates used in the filters and display classes. + \note This is a singleton. */ class CDisplayTemplateMgr { - public: - /** Settings which are used to fill the content into the template. + public: /* Types: */ + /** + Settings which are used to fill the content into the template. */ - struct Settings { - /** Constructor. Constructs the new settings object. The default values are empty. - */ - Settings() { - title = QString::null; - langAbbrev = QString::null; - pageCSS_ID = QString::null; - pageDirection = QString("ltr"); - }; - - QList<CSwordModuleInfo*> modules; /**< the list of modules */ - QString title; /**< the title which is used for the new processed HTML page */ - QString langAbbrev; /**< the language for the HTML page. */ - QString pageDirection; /**< the language for the HTML page. */ - QString pageCSS_ID; /**< the CSS ID which is used in the content part of the page */ + Settings() : pageDirection("ltr") {} + + /** The list of modules */ + QList<const CSwordModuleInfo*> modules; + + /** The title which is used for the new processed HTML page */ + QString title; + + /** The language for the HTML page. */ + QString langAbbrev; + + /** The language direction for the HTML page. */ + QString pageDirection; + + /** The CSS ID which is used in the content part of the page */ + QString pageCSS_ID; }; - /** Available templates. - * @return The list of templates, which are available. + public: /* Methods: */ + + /** + \param[out] errorMessage Set to error string on error, otherwise set + to QString::null. */ - inline const QStringList availableTemplates(); - /** Fill template. Fill rendered content into the template given by the name. - * @param name The name of the template - * @param content The content which should be filled into the template - * @param settings The settings which are used to process the templating process - * @return The full HTML template HTML code including the CSS data. + explicit CDisplayTemplateMgr(QString &errorMessage); + + /** + \returns the list of available templates. */ - const QString fillTemplate( const QString& name, const QString& content, Settings& settings); - /** Default template. - * @return The i18n'ed name of the default template + inline const QStringList availableTemplates() const { + return m_templateMap.keys(); + } + + /** + \brief Fills the template. + + Fills rendered content into the template given by the name. + + \param name The name of the template to fill. + \param content The content which should be filled into the template. + \param settings The settings which are used to process the templating + process. + + \returns The full HTML template HTML code including the CSS data. */ - inline static const QString defaultTemplate(); - - protected: - friend class CPointers; - /** Display template manager constructor. Protected to just allow CPointers to create objects. */ - CDisplayTemplateMgr(); - /** Destructor. */ - ~CDisplayTemplateMgr(); - /** Does the actual work of loading templates from disk */ - void loadTemplates(); - - private: - QMap<QString, QString> m_templateMap; -}; + const QString fillTemplate( const QString& name, const QString& content, Settings& settings); -inline const QString CDisplayTemplateMgr::defaultTemplate() { - return QString("Blue.tmpl"); -} + /** + \returns the name of the default template. + */ + inline static const char *defaultTemplate() { return "Blue.tmpl"; } -/** - * CDisplayTemplateMgr::availableTemplates() - */ -inline const QStringList CDisplayTemplateMgr::availableTemplates() { - return m_templateMap.keys(); -} + /** + \returns The singleton instance of the instance of this class. + */ + static inline CDisplayTemplateMgr *instance() { + Q_ASSERT(m_instance != 0); + return m_instance; + }; + private: /* Methods: */ + /** Preloads a single template from disk: */ + void loadTemplate(const QString &filename); + private: /* Fields: */ + QMap<QString, QString> m_templateMap; + static CDisplayTemplateMgr *m_instance; +}; #endif |