BibleTime
|
Model that represents the entire text of a given module. More...
#include <btmoduletextmodel.h>
Public Member Functions | |
BtModuleTextModel (QObject *parent=nullptr) | |
int | columnCount (const QModelIndex &parent=QModelIndex()) const override |
QVariant | data (const QModelIndex &index, int role=Qt::DisplayRole) const override |
int | firstEntryIndex () const noexcept |
CSwordKey * | indexToKey (int index, int moduleNum) const |
QString | indexToKeyName (int index) const |
int | indexToVerse (int index) const |
CSwordVerseKey | indexToVerseKey (int index) const |
CSwordVerseKey | indexToVerseKey (int index, CSwordModuleInfo const &module) const |
int | keyToIndex (CSwordKey const &key) const |
void | reloadModules () |
QHash< int, QByteArray > | roleNames () const override |
int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
virtual bool | setData (const QModelIndex &index, const QVariant &value, int role=Qt::EditRole) override |
void | setDisplayOptions (const DisplayOptions &displayOptions) |
void | setFilterOptions (FilterOptions filterOptions) |
void | setFindState (std::optional< FindState > findState) |
void | setHighlightWords (const QString &highlightWords, bool caseSensitive) |
void | setModules (const QStringList &modules) |
void | setTextFilter (BtModuleTextFilter *textFilter) |
int | verseKeyToIndex (const CSwordVerseKey &key) const |
Private Member Functions | |
QString | bookData (const QModelIndex &index, int role=Qt::DisplayRole) const |
CSwordTreeKey | indexToBookKey (int index) const |
bool | isBible () const |
bool | isBook () const |
bool | isCommentary () const |
bool | isLexicon () const |
bool | isSelected (int index) const |
QString | lexiconData (const QModelIndex &index, int role=Qt::DisplayRole) const |
QString | verseData (const QModelIndex &index, int role=Qt::DisplayRole) const |
Private Attributes | |
Rendering::CDisplayRendering | m_displayRendering |
std::optional< FindState > | m_findState |
int | m_firstEntry |
QString | m_highlightWords |
int | m_maxEntries |
BtConstModuleList | m_moduleInfoList |
QStringList | m_modules |
BtModuleTextFilter * | m_textFilter |
Model that represents the entire text of a given module.
It is used by a QML ListView to view a small portion of the available module text. Only the portions of the module that are currently displayed and some just above or below this, are instantiated.
Definition at line 101 of file btmoduletextmodel.h.
BtModuleTextModel::BtModuleTextModel | ( | QObject * | parent = nullptr | ) |
Definition at line 59 of file btmoduletextmodel.cpp.
|
private |
returns text string for each model index
Definition at line 168 of file btmoduletextmodel.cpp.
References Rendering::CTextRendering::displayOptions(), CSwordTreeKey::key(), m_displayRendering, m_moduleInfoList, Rendering::CTextRendering::KeyTreeItem::Settings::NoKey, Rendering::CDisplayRendering::renderDisplayEntry(), CSwordTreeKey::setOffset(), Rendering::CTextRendering::KeyTreeItem::Settings::SimpleKey, ModuleEntry::Text0Role, ModuleEntry::TextRole, CSwordBookModuleInfo::tree(), and DisplayOptions::verseNumbers.
Referenced by data().
|
override |
Reimplemented from QAbstractItemModel.
Definition at line 273 of file btmoduletextmodel.cpp.
|
override |
Reimplemented from QAbstractItemModel.
Definition at line 105 of file btmoduletextmodel.cpp.
References bookData(), CSwordModuleSearch::highlightSearchedText(), isBible(), isBook(), isCommentary(), isLexicon(), lexiconData(), m_findState, m_highlightWords, m_textFilter, BtModuleTextFilter::processText(), and verseData().
Referenced by BtQmlInterface::findText(), and BtQmlInterface::rawText().
|
inlinenoexcept |
Get index offset of first entry of module
Definition at line 132 of file btmoduletextmodel.h.
References m_firstEntry.
Referenced by BtQmlInterface::scrollToSwordKey().
|
private |
Definition at line 386 of file btmoduletextmodel.cpp.
References m_moduleInfoList, CSwordTreeKey::setOffset(), and CSwordBookModuleInfo::tree().
Referenced by indexToKeyName().
CSwordKey * BtModuleTextModel::indexToKey | ( | int | index, |
int | moduleNum | ||
) | const |
Convert index(row) into CSwordVerseKey.
Definition at line 377 of file btmoduletextmodel.cpp.
References CSwordModuleInfo::createKey(), indexToKeyName(), and m_moduleInfoList.
Referenced by BtCopyByReferencesDialog::BtCopyByReferencesDialog(), and BtQmlInterface::getMouseClickedKey().
QString BtModuleTextModel::indexToKeyName | ( | int | index | ) | const |
Get reference name from index(row).
Definition at line 396 of file btmoduletextmodel.cpp.
References indexToBookKey(), indexToVerseKey(), isBible(), isBook(), isCommentary(), isLexicon(), CSwordTreeKey::key(), CSwordVerseKey::key(), and m_moduleInfoList.
Referenced by BtQmlInterface::changeReference(), BtQmlInterface::copyRange(), BtQmlInterface::dragHandler(), indexToKey(), and BtQmlInterface::openEditor().
int BtModuleTextModel::indexToVerse | ( | int | index | ) | const |
Convert index(row) into verse.
Definition at line 367 of file btmoduletextmodel.cpp.
References m_firstEntry, m_moduleInfoList, CSwordVerseKey::setIndex(), CSwordVerseKey::setIntros(), and CSwordVerseKey::verse().
Referenced by BtQmlInterface::indexToVerse().
CSwordVerseKey BtModuleTextModel::indexToVerseKey | ( | int | index | ) | const |
Convert index(row) into CSwordVerseKey.
Definition at line 354 of file btmoduletextmodel.cpp.
References m_moduleInfoList.
Referenced by BtQmlInterface::getRawText(), indexToKeyName(), setData(), and verseData().
CSwordVerseKey BtModuleTextModel::indexToVerseKey | ( | int | index, |
CSwordModuleInfo const & | module | ||
) | const |
Convert index(row) into CSwordVerseKey.
Definition at line 358 of file btmoduletextmodel.cpp.
References m_firstEntry, CSwordVerseKey::setIndex(), and CSwordVerseKey::setIntros().
|
private |
Definition at line 312 of file btmoduletextmodel.cpp.
References CSwordModuleInfo::Bible, m_moduleInfoList, and CSwordModuleInfo::type().
Referenced by data(), indexToKeyName(), and reloadModules().
|
private |
Definition at line 319 of file btmoduletextmodel.cpp.
References CSwordModuleInfo::GenericBook, m_moduleInfoList, and CSwordModuleInfo::type().
Referenced by data(), indexToKeyName(), and reloadModules().
|
private |
Definition at line 326 of file btmoduletextmodel.cpp.
References CSwordModuleInfo::Commentary, m_moduleInfoList, and CSwordModuleInfo::type().
Referenced by data(), indexToKeyName(), and reloadModules().
|
private |
Definition at line 333 of file btmoduletextmodel.cpp.
References CSwordModuleInfo::Lexicon, m_moduleInfoList, and CSwordModuleInfo::type().
Referenced by data(), indexToKeyName(), and reloadModules().
|
private |
int BtModuleTextModel::keyToIndex | ( | CSwordKey const & | key | ) | const |
Convert CSwordKey into index.
Definition at line 341 of file btmoduletextmodel.cpp.
Referenced by BtCopyByReferencesDialog::BtCopyByReferencesDialog(), and BtQmlInterface::scrollToSwordKey().
|
private |
Definition at line 145 of file btmoduletextmodel.cpp.
References CSwordLexiconModuleInfo::entries(), m_displayRendering, m_moduleInfoList, ModuleEntry::ReferenceRole, Rendering::CDisplayRendering::renderDisplayEntry(), ColorManager::replaceColors(), ModuleEntry::Text0Role, and ModuleEntry::TextRole.
Referenced by data().
void BtModuleTextModel::reloadModules | ( | ) |
Load module pointers from module names
Definition at line 67 of file btmoduletextmodel.cpp.
References BT_ASSERT, CSwordVerseKey::index(), CSwordBackend::instance(), isBible(), isBook(), isCommentary(), isLexicon(), CSwordBibleModuleInfo::lowerBound(), m_firstEntry, m_maxEntries, m_moduleInfoList, m_modules, and CSwordBibleModuleInfo::upperBound().
Referenced by setModules().
|
override |
Used by model to get the roleNames and corresponding role numbers.
Definition at line 281 of file btmoduletextmodel.cpp.
References r(), ModuleEntry::ReferenceRole, ModuleEntry::Text0Role, ModuleEntry::Text1Role, ModuleEntry::Text2Role, ModuleEntry::Text3Role, ModuleEntry::Text4Role, ModuleEntry::Text5Role, ModuleEntry::Text6Role, ModuleEntry::Text7Role, ModuleEntry::Text8Role, ModuleEntry::Text9Role, ModuleEntry::TextRole, ModuleEntry::Title0Role, ModuleEntry::Title1Role, ModuleEntry::Title2Role, ModuleEntry::Title3Role, ModuleEntry::Title4Role, ModuleEntry::Title5Role, ModuleEntry::Title6Role, ModuleEntry::Title7Role, ModuleEntry::Title8Role, and ModuleEntry::Title9Role.
|
override |
Reimplemented from QAbstractItemModel.
Definition at line 277 of file btmoduletextmodel.cpp.
References m_maxEntries.
Referenced by BtQmlInterface::findText().
|
overridevirtual |
Reimplemented from QAbstractItemModel.
Definition at line 452 of file btmoduletextmodel.cpp.
References getColumnFromRole(), indexToVerseKey(), and m_moduleInfoList.
Referenced by BtQmlInterface::setRawText().
void BtModuleTextModel::setDisplayOptions | ( | const DisplayOptions & | displayOptions | ) |
Definition at line 431 of file btmoduletextmodel.cpp.
References Rendering::CTextRendering::displayOptions(), DisplayOptions::displayOptionsAreEqual(), m_displayRendering, and Rendering::CTextRendering::setDisplayOptions().
void BtModuleTextModel::setFilterOptions | ( | FilterOptions | filterOptions | ) |
Set the filter options used for rendering module text.
Definition at line 439 of file btmoduletextmodel.cpp.
References Rendering::CTextRendering::filterOptions(), FilterOptions::filterOptionsAreEqual(), m_displayRendering, and Rendering::CTextRendering::setFilterOptions().
Referenced by BtQmlInterface::setFilterOptions().
void BtModuleTextModel::setFindState | ( | std::optional< FindState > | findState | ) |
Set the state of the currently found word functionality
Definition at line 409 of file btmoduletextmodel.cpp.
References m_findState.
Referenced by BtQmlInterface::findText(), and BtQmlInterface::setHighlightWords().
void BtModuleTextModel::setHighlightWords | ( | const QString & | highlightWords, |
bool | caseSensitive | ||
) |
Set the color of word that are highlighted
Definition at line 424 of file btmoduletextmodel.cpp.
References m_highlightWords.
Referenced by BtQmlInterface::setHighlightWords().
void BtModuleTextModel::setModules | ( | const QStringList & | modules | ) |
Specifies one or more module names for use by the model
Definition at line 99 of file btmoduletextmodel.cpp.
References m_modules, and reloadModules().
Referenced by BtQmlInterface::setModules().
void BtModuleTextModel::setTextFilter | ( | BtModuleTextFilter * | textFilter | ) |
Set the text options used for rendering module text.
Definition at line 447 of file btmoduletextmodel.cpp.
References BT_ASSERT, and m_textFilter.
Referenced by BtQmlInterface::BtQmlInterface().
|
private |
Definition at line 201 of file btmoduletextmodel.cpp.
References CSwordVerseKey::bookName(), CSwordVerseKey::chapter(), Rendering::CTextRendering::displayOptions(), getColumnFromRole(), CSwordModuleSearch::highlightSearchedText(), indexToVerseKey(), CSwordModuleInfo::isWritable(), CSwordVerseKey::key(), m_displayRendering, m_highlightWords, m_moduleInfoList, Rendering::CTextRendering::KeyTreeItem::Settings::NoKey, CSwordKey::rawText(), Rendering::CDisplayRendering::renderDisplayEntry(), ColorManager::replaceColors(), CSwordVerseKey::setKey(), Rendering::CTextRendering::KeyTreeItem::Settings::SimpleKey, ModuleEntry::TextRole, ModuleEntry::Title0Role, ModuleEntry::Title9Role, CSwordVerseKey::verse(), and DisplayOptions::verseNumbers.
Referenced by data().
int BtModuleTextModel::verseKeyToIndex | ( | const CSwordVerseKey & | key | ) | const |
Convert CSwordVerseKey into index(row).
Definition at line 349 of file btmoduletextmodel.cpp.
References CSwordVerseKey::index(), and m_firstEntry.
Referenced by BtQmlInterface::getCurrentModelIndex().
|
private |
Definition at line 193 of file btmoduletextmodel.h.
Referenced by bookData(), lexiconData(), setDisplayOptions(), setFilterOptions(), and verseData().
|
private |
Definition at line 194 of file btmoduletextmodel.h.
Referenced by data(), and setFindState().
|
private |
Definition at line 190 of file btmoduletextmodel.h.
Referenced by firstEntryIndex(), indexToVerse(), indexToVerseKey(), reloadModules(), and verseKeyToIndex().
|
private |
Definition at line 188 of file btmoduletextmodel.h.
Referenced by data(), setHighlightWords(), and verseData().
|
private |
Definition at line 191 of file btmoduletextmodel.h.
Referenced by reloadModules(), and rowCount().
|
private |
Definition at line 186 of file btmoduletextmodel.h.
Referenced by bookData(), indexToBookKey(), indexToKey(), indexToKeyName(), indexToVerse(), indexToVerseKey(), isBible(), isBook(), isCommentary(), isLexicon(), lexiconData(), reloadModules(), setData(), and verseData().
|
private |
Definition at line 187 of file btmoduletextmodel.h.
Referenced by reloadModules(), and setModules().
|
private |
Definition at line 192 of file btmoduletextmodel.h.
Referenced by data(), and setTextFilter().