BibleTime
ctextrendering.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-2025 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 <list>
16#include <QString>
17#include "../btglobal.h"
18#include "../drivers/btmodulelist.h"
19
20
21class CSwordKey;
22class CSwordVerseKey;
23
24namespace Rendering {
25
26/**
27 * CTextRendering is BibleTime's place where the actual rendering takes place.
28 * It provides several methods to convert an abstract tree of items
29 * into a string of html.
30 *
31 * @short Text rendering based on trees
32 * @author The BibleTime team
33*/
35
36 public: // types:
37
38 class KeyTreeItem;
39
40 using KeyTree = std::list<KeyTreeItem>;
41
43
44 public: // types:
45
46 struct Settings {
47
49 NoKey, ///< means no key shown at all
50 SimpleKey, ///< means only versenumber or only lexicon entry name
51 CompleteShort, ///< means key like "Gen 1:1"
52 CompleteLong, ///< means "Genesis 1:1"
53 ExpandedShort, /// means "KJV:Gen 1:1"
54 ExpandedLong /// means "Genesis 1:1 (KJV)"
55 };
56
59
60 }; /* struct Settings */
61
62 public: // methods:
63
65 KeyTreeItem(KeyTreeItem const &&) = delete;
66
67 KeyTreeItem(const QString &key,
68 const CSwordModuleInfo *module,
69 const Settings &settings);
70
71 KeyTreeItem(const QString &key,
73 const Settings &settings);
74
75 KeyTreeItem(const QString &startKey,
76 const QString &stopKey,
77 const CSwordModuleInfo *module,
78 const Settings &settings);
79
80 KeyTreeItem(const QString &content, const Settings &settings);
81
83 KeyTreeItem & operator=(KeyTreeItem const &&) = delete;
84
85 QString const & getAlternativeContent() const
86 { return m_alternativeContent; }
87
89 { return !m_alternativeContent.isNull(); }
90
91 BtConstModuleList const & modules() const
92 { return m_moduleList; }
93
94 QString const & key() const { return m_key; }
95
96 Settings const & settings() const { return m_settings; }
97
98 KeyTree & childList() const noexcept { return m_childList; }
99
100 void setMappedKey(CSwordKey const * key) const
101 { m_mappedKey = key; }
102
103 CSwordKey const * mappedKey() const { return m_mappedKey; }
104
105 private: // fields:
106
109 QString m_key;
110 mutable CSwordKey const * m_mappedKey = nullptr;
112
114
115 }; /* class KeyTreeItem */
116
117 public: // methods:
118
119 CTextRendering(bool addText);
120 CTextRendering(bool addText,
123
125
126 FilterOptions const & filterOptions() const noexcept
127 { return m_filterOptions; }
128
130 static_assert(noexcept(m_filterOptions = filterOptions));
132 }
133
134 DisplayOptions const & displayOptions() const noexcept
135 { return m_displayOptions; }
136
138 static_assert(noexcept(m_displayOptions = displayOptions));
140 }
141
142 QString renderKeyTree(KeyTree const & tree) const;
143
144 QString renderKeyRange(
145 CSwordVerseKey const & lowerBound,
146 CSwordVerseKey const & upperBound,
147 const BtConstModuleList &modules,
148 const QString &hightlightKey = QString(),
149 const KeyTreeItem::Settings &settings = KeyTreeItem::Settings());
150
151 QString renderSingleKey(
152 const QString &key,
153 const BtConstModuleList &modules,
154 const KeyTreeItem::Settings &settings = KeyTreeItem::Settings());
155
156 protected: // methods:
157
158 static BtConstModuleList collectModules(KeyTree const & tree);
159 virtual QString renderEntry(KeyTreeItem const & item,
160 CSwordKey * key = nullptr) const;
161 virtual QString finishText(QString const & text,
162 KeyTree const & tree) const;
163 virtual QString entryLink(KeyTreeItem const & item,
164 CSwordModuleInfo const & module) const;
165
166 protected: // fields:
167
170 bool const m_addText;
171
172}; /* class CTextRendering */
173
174} /* namespace Rendering */
QList< CSwordModuleInfo const * > BtConstModuleList
CSwordKey implementation for Sword's VerseKey.
KeyTreeItem & operator=(KeyTreeItem const &&)=delete
KeyTree & childList() const noexcept
void setMappedKey(CSwordKey const *key) const
QString const & getAlternativeContent() const
CSwordKey const * mappedKey() const
KeyTreeItem & operator=(KeyTreeItem &&)=delete
BtConstModuleList const & modules() const
KeyTreeItem(KeyTreeItem const &&)=delete
KeyTreeItem(KeyTreeItem &&)=delete
Text rendering based on trees.
virtual QString renderEntry(KeyTreeItem const &item, CSwordKey *key=nullptr) const
virtual QString finishText(QString const &text, KeyTree const &tree) const
QString renderSingleKey(const QString &key, const BtConstModuleList &modules, const KeyTreeItem::Settings &settings=KeyTreeItem::Settings())
virtual QString entryLink(KeyTreeItem const &item, CSwordModuleInfo const &module) const
QString renderKeyRange(CSwordVerseKey const &lowerBound, CSwordVerseKey const &upperBound, const BtConstModuleList &modules, const QString &hightlightKey=QString(), const KeyTreeItem::Settings &settings=KeyTreeItem::Settings())
std::list< KeyTreeItem > KeyTree
QString renderKeyTree(KeyTree const &tree) const
FilterOptions const & filterOptions() const noexcept
DisplayOptions m_displayOptions
void setFilterOptions(FilterOptions const &filterOptions) noexcept
DisplayOptions const & displayOptions() const noexcept
static BtConstModuleList collectModules(KeyTree const &tree)
void setDisplayOptions(DisplayOptions const &displayOptions) noexcept
@ SimpleKey
means only versenumber or only lexicon entry name