15 #include <QRegularExpression>
18 #include "../../util/btassert.h"
19 #include "../config/btconfig.h"
20 #include "../drivers/cswordmoduleinfo.h"
21 #include "../keys/cswordkey.h"
22 #include "../keys/cswordversekey.h"
23 #include "../managers/cdisplaytemplatemgr.h"
24 #include "../managers/referencemanager.h"
27 #pragma GCC diagnostic push
28 #pragma GCC diagnostic ignored "-Wextra-semi"
29 #pragma GCC diagnostic ignored "-Wsuggest-override"
30 #pragma GCC diagnostic ignored "-Wzero-as-null-pointer-constant"
32 #pragma clang diagnostic push
33 #pragma clang diagnostic ignored "-Wsuggest-destructor-override"
39 #pragma clang diagnostic pop
41 #pragma GCC diagnostic pop
57 QString
const & keyName,
73 static_cast<sword::VerseKey *
>(module->
swordModule().getKey())
85 if (k1.
verse() == 1) {
90 tree.emplace_back(k1.
key(), modules, preverse_settings);
95 tree.emplace_back(k1.
key(), modules, preverse_settings);
99 tree.emplace_back(keyName, modules, Settings{
false, keyRendering});
116 if (isBible && (vk.
verse() == 0)) {
122 case KeyTreeItem::Settings::NoKey:
123 linkText = QString();
126 case KeyTreeItem::Settings::ExpandedShort:
133 case KeyTreeItem::Settings::CompleteShort:
140 case KeyTreeItem::Settings::ExpandedLong:
142 linkText = QStringLiteral(
"%1 (%2)").arg(vk.
key(), module.
name());
147 case KeyTreeItem::Settings::CompleteLong:
154 case KeyTreeItem::Settings::SimpleKey:
164 QStringLiteral(
"%1:%2")
168 linkText = QString::number(vk.
verse());
175 if (upper.book() != lower.book()) {
177 }
else if(upper.chapter() != lower.chapter()) {
178 linkText += QStringLiteral(
"%1:%2").arg(upper.chapter())
181 linkText += QString::number(upper.verse());
185 linkText = QString::number(vk.
verse());
192 linkText = item.
key();
198 if (linkText.isEmpty()) {
199 return QStringLiteral(
"<a name=\"%1\"></a>").arg(
203 return QStringLiteral(
"<a name=\"%1\" href=\"%2\">%3</a>\n")
213 static QRegularExpression
const re(QStringLiteral(R
"PCRE(\s)PCRE"));
214 return key.trimmed().remove(re).replace(
':',
'_');
257 if (modules.count() == 1)
258 if (
auto const lang = modules.first()->language())
259 if (
auto const & abbrev = lang->abbrev(); !abbrev.isEmpty())
262 if (modules.count() == 1)
BtConfig & btConfig()
This is a shortchand for BtConfig::getInstance().
QList< CSwordModuleInfo const * > BtConstModuleList
QString fillTemplate(const QString &name, const QString &content, const Settings &settings) const
Fills the template.
static QString activeTemplateName()
static CDisplayTemplateMgr * instance()
virtual QString key() const =0
QString const & name() const
sword::SWModule & swordModule() const
CSwordKey implementation for Sword's VerseKey.
CSwordVerseKey upperBound() const
QString key() const final override
bool setKey(const QString &key) final override
QString shortText() const
CSwordVerseKey lowerBound() const
Rendering for the html display widget.
QString m_displayTemplateName
QString entryLink(KeyTreeItem const &item, CSwordModuleInfo const &module) const override
static QString keyToHTMLAnchor(QString const &key)
QString finishText(QString const &text, KeyTree const &tree) const override
QString renderDisplayEntry(BtConstModuleList const &modules, QString const &key, CTextRendering::KeyTreeItem::Settings::KeyRenderingFace keyRendering=CTextRendering::KeyTreeItem::Settings::CompleteShort) const
CSwordKey const * mappedKey() const
Settings const & settings() const
BtConstModuleList const & modules() const
QString const & key() const
Text rendering based on trees.
std::list< KeyTreeItem > KeyTree
QString renderKeyTree(KeyTree const &tree) const
static BtConstModuleList collectModules(KeyTree const &tree)
QString encodeHyperlink(CSwordModuleInfo const &module, QString const &key)
CSwordModuleInfo::TextDirection textDirection
BtConstModuleList modules
@ NoKey
means no key shown at all
KeyRenderingFace keyRenderingFace