16 #include "../../util/btassert.h"
17 #include "../drivers/cswordmoduleinfo.h"
18 #include "../drivers/cswordbiblemoduleinfo.h"
19 #include "../drivers/cswordbookmoduleinfo.h"
20 #include "../drivers/cswordlexiconmoduleinfo.h"
21 #include "../cswordmodulesearch.h"
22 #include "../keys/cswordtreekey.h"
23 #include "../keys/cswordversekey.h"
24 #include "../managers/colormanager.h"
25 #include "../managers/cswordbackend.h"
26 #include "../rendering/ctextrendering.h"
63 , m_textFilter(nullptr)
92 tk.setPosition(sword::BOTTOM);
115 text = QStringLiteral(
"invalid");
129 int pos = t.indexOf(QStringLiteral(
"\"highlightwords\""), from);
136 int position = from + 14;
137 t.insert(position,
'2');
142 return QVariant(text);
146 int row = index.row();
150 moduleList << lexiconModule;
151 QString keyName = lexiconModule->
entries()[row];
154 if (keyName.isEmpty())
157 text.replace(QStringLiteral(
"#CHAPTERTITLE#"), QString());
158 text.replace(QStringLiteral(
"#TEXT_ALIGN#"), QStringLiteral(
"left"));
173 int bookIndex = index.row() * 4;
176 moduleList << bookModule;
177 if (key.
key().isEmpty())
186 text.replace(QStringLiteral(
"#CHAPTERTITLE#"), QString());
187 text.replace(QStringLiteral(
"#TEXT_ALIGN#"), QStringLiteral(
"left"));
202 int row = index.row();
204 int verse = key.
verse();
211 QString chapterTitle;
214 QStringLiteral(
"%1 %2").arg(key.
bookName(),
215 QString::number(key.
chapter()));
227 modules.append(module);
234 return QStringLiteral(
"<center><h3>%1</h3></center>")
241 auto const & rawText = mKey.
rawText();
243 QStringLiteral(
"%1 %2")
244 .arg(QString::number(verse),
246 ? QStringLiteral(
"<span style=\"color:gray\">"
247 "<small>%1</small></span>")
248 .arg(tr(
"Click to edit"))
256 if (!key.
key().isEmpty())
265 text.replace(QStringLiteral(
"#CHAPTERTITLE#"), chapterTitle);
266 text.replace(QStringLiteral(
"#TEXT_ALIGN#"), QStringLiteral(
"left"));
282 static auto const roleNames_ =
314 if (module ==
nullptr)
321 if (module ==
nullptr)
328 if (module ==
nullptr)
335 if (module ==
nullptr)
342 if (
auto const *
const treeKey =
dynamic_cast<CSwordTreeKey const *
>(&key))
343 return treeKey->offset() / 4u;
344 if (
auto const *
const vKey =
dynamic_cast<CSwordVerseKey const *
>(&key))
345 return vKey->index();
382 key->setKey(keyName);
391 int bookIndex = index * 4;
404 return qobject_cast<CSwordLexiconModuleInfo const *>(
406 return QStringLiteral(
"???");
411 && (!findState || (
m_findState->index != findState->index)))
413 QModelIndex oldIndexToClear = index(
m_findState->index, 0);
415 Q_EMIT dataChanged(oldIndexToClear, oldIndexToClear);
420 QModelIndex index = this->index(
m_findState->index, 0);
421 Q_EMIT dataChanged(index, index);
425 const QString& highlightWords,
bool ) {
453 const QModelIndex &index,
454 const QVariant &value,
459 Q_EMIT dataChanged(index, index);
QList< CSwordModuleInfo const * > BtConstModuleList
static int getColumnFromRole(int role)
virtual QString processText(const QString &text)=0
virtual ~BtModuleTextFilter()=0
QString bookData(const QModelIndex &index, int role=Qt::DisplayRole) const
CSwordKey * indexToKey(int index, int moduleNum) const
int rowCount(const QModelIndex &parent=QModelIndex()) const override
void setDisplayOptions(const DisplayOptions &displayOptions)
std::optional< FindState > m_findState
int verseKeyToIndex(const CSwordVerseKey &key) const
int columnCount(const QModelIndex &parent=QModelIndex()) const override
CSwordTreeKey indexToBookKey(int index) const
BtConstModuleList m_moduleInfoList
BtModuleTextModel(QObject *parent=nullptr)
QString lexiconData(const QModelIndex &index, int role=Qt::DisplayRole) const
bool isCommentary() const
void setModules(const QStringList &modules)
void setHighlightWords(const QString &highlightWords, bool caseSensitive)
int keyToIndex(CSwordKey const &key) const
int indexToVerse(int index) const
void setFilterOptions(FilterOptions filterOptions)
CSwordVerseKey indexToVerseKey(int index) const
QString verseData(const QModelIndex &index, int role=Qt::DisplayRole) const
QString indexToKeyName(int index) const
void setTextFilter(BtModuleTextFilter *textFilter)
QHash< int, QByteArray > roleNames() const override
virtual bool setData(const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override
BtModuleTextFilter * m_textFilter
Rendering::CDisplayRendering m_displayRendering
QVariant data(const QModelIndex &index, int role=Qt::DisplayRole) const override
void setFindState(std::optional< FindState > findState)
static CSwordBackend & instance() noexcept
Implementation for Sword Bibles.
CSwordVerseKey const & lowerBound() const
CSwordVerseKey const & upperBound() const
Class for generic book support.
sword::TreeKeyIdx * tree() const
const QStringList & entries() const
virtual CSwordKey * createKey() const =0
virtual bool isWritable() const
CSwordKey implementation for Sword's TreeKey.
QString key() const final override
void setOffset(Offset value)
CSwordKey implementation for Sword's VerseKey.
QString key() const final override
bool setKey(const QString &key) final override
QString renderDisplayEntry(BtConstModuleList const &modules, QString const &key, CTextRendering::KeyTreeItem::Settings::KeyRenderingFace keyRendering=CTextRendering::KeyTreeItem::Settings::CompleteShort) const
DisplayOptions const & displayOptions() const noexcept
void setFilterOptions(FilterOptions const &filterOptions) noexcept
void setDisplayOptions(DisplayOptions const &displayOptions) noexcept
FilterOptions const & filterOptions() const noexcept
QStringList r(content.left(bodyIndex))
QString highlightSearchedText(QString const &content, QString const &searchedText, bool plainSearchedText)
QString replaceColors(QString content)
DisplayOptions const defaultDisplayOptions
FilterOptions const defaultFilterOptions
bool displayOptionsAreEqual(DisplayOptions const &opts) const noexcept
bool filterOptionsAreEqual(FilterOptions const &opts) const noexcept
@ SimpleKey
means only versenumber or only lexicon entry name
@ NoKey
means no key shown at all