BibleTime
cdisplaytemplatemgr.h
Go to the documentation of this file.
1/*********
2*
3* In the name of the Father, and of the Son, and of the Holy Spirit.
4*
5* This file is part of BibleTime's source code, https://bibletime.info/
6*
7* Copyright 1999-2026 by the BibleTime developers.
8* The BibleTime source code is licensed under the GNU General Public License
9* version 2.0.
10*
11**********/
12
13#pragma once
14
15#include <QHash>
16#include <QString>
17#include <QStringList>
18#include "../../util/btassert.h"
19#include "../drivers/btmodulelist.h"
20#include "../drivers/cswordmoduleinfo.h"
21
22
23/**
24 Manages the display templates used in the filters and display classes.
25 \note This is a singleton.
26*/
28
29 public: // types:
30
31 /**
32 Settings which are used to fill the content into the template.
33 */
34 struct Settings {
35
36 /** The list of modules */
38
39 /** The title which is used for the new processed HTML page */
40 QString title;
41
42 /** The language for the HTML page. */
43 QString langAbbrev{"en"};
44
45 /** The CSS ID which is used in the content part of the page */
46 QString pageCSS_ID;
47
48 /** The language direction for the HTML page. */
51
52 };
53
54 public: // methods:
55
56 /**
57 \param[out] errorMessage Set to error string on error, otherwise set
58 to QString().
59 */
60 explicit CDisplayTemplateMgr(QString & errorMessage);
61
62 /**
63 \returns the list of available templates.
64 */
65 QStringList const & availableTemplates() const
67
68 /**
69 \brief Fills the template.
70
71 Fills rendered content into the template given by the name.
72
73 \param name The name of the template to fill.
74 \param content The content which should be filled into the template.
75 \param settings The settings which are used to process the templating
76 process.
77
78 \returns The full HTML template HTML code including the CSS data.
79 */
80 QString fillTemplate(const QString & name,
81 QString content,
82 const Settings & settings) const;
83
84 /**
85 \returns the name of the active template.
86 */
87 static QString activeTemplateName();
88
89 /**
90 \returns The singleton instance of the instance of this class.
91 */
94 return m_instance;
95 }
96
97 private: // methods:
98
99 /** Preloads a single template from disk: */
100 void loadTemplate(const QString & filename);
101 void loadCSSTemplate(const QString & filename);
102
103 private: // fields:
104
109
110};
#define BT_ASSERT(...)
Definition btassert.h:17
QList< CSwordModuleInfo const * > BtConstModuleList
static QString activeTemplateName()
QHash< QString, QString > m_templateMap
void loadCSSTemplate(const QString &filename)
QHash< QString, QString > m_cssMap
static CDisplayTemplateMgr * m_instance
QString fillTemplate(const QString &name, QString content, const Settings &settings) const
Fills the template.
static CDisplayTemplateMgr * instance()
QStringList const & availableTemplates() const
void loadTemplate(const QString &filename)
QStringList m_availableTemplateNamesCache
CSwordModuleInfo::TextDirection textDirection