BibleTime
Public Member Functions | Private Member Functions | Private Attributes | List of all members
BtModuleTextModel Class Reference

Model that represents the entire text of a given module. More...

#include <btmoduletextmodel.h>

Inheritance diagram for BtModuleTextModel:

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
 
CSwordKeyindexToKey (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< FindStatem_findState
 
int m_firstEntry
 
QString m_highlightWords
 
int m_maxEntries
 
BtConstModuleList m_moduleInfoList
 
QStringList m_modules
 
BtModuleTextFilterm_textFilter
 

Detailed Description

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.

Note
Four parallel modules are supported.

Definition at line 101 of file btmoduletextmodel.h.

Constructor & Destructor Documentation

◆ BtModuleTextModel()

BtModuleTextModel::BtModuleTextModel ( QObject parent = nullptr)

Definition at line 59 of file btmoduletextmodel.cpp.

Member Function Documentation

◆ bookData()

QString BtModuleTextModel::bookData ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
private

◆ columnCount()

int BtModuleTextModel::columnCount ( const QModelIndex &  parent = QModelIndex()) const
override

Reimplemented from QAbstractItemModel.

Definition at line 273 of file btmoduletextmodel.cpp.

◆ data()

QVariant BtModuleTextModel::data ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
override

◆ firstEntryIndex()

int BtModuleTextModel::firstEntryIndex ( ) const
inlinenoexcept

Get index offset of first entry of module

Definition at line 132 of file btmoduletextmodel.h.

References m_firstEntry.

Referenced by BtQmlInterface::scrollToSwordKey().

◆ indexToBookKey()

CSwordTreeKey BtModuleTextModel::indexToBookKey ( int  index) const
private

◆ indexToKey()

CSwordKey * BtModuleTextModel::indexToKey ( int  index,
int  moduleNum 
) const

◆ indexToKeyName()

QString BtModuleTextModel::indexToKeyName ( int  index) const

◆ indexToVerse()

int BtModuleTextModel::indexToVerse ( int  index) const

◆ indexToVerseKey() [1/2]

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().

◆ indexToVerseKey() [2/2]

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().

◆ isBible()

bool BtModuleTextModel::isBible ( ) const
private

◆ isBook()

bool BtModuleTextModel::isBook ( ) const
private

◆ isCommentary()

bool BtModuleTextModel::isCommentary ( ) const
private

◆ isLexicon()

bool BtModuleTextModel::isLexicon ( ) const
private

◆ isSelected()

bool BtModuleTextModel::isSelected ( int  index) const
private

◆ keyToIndex()

int BtModuleTextModel::keyToIndex ( CSwordKey const &  key) const

◆ lexiconData()

QString BtModuleTextModel::lexiconData ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
private

◆ reloadModules()

void BtModuleTextModel::reloadModules ( )

◆ roleNames()

QHash< int, QByteArray > BtModuleTextModel::roleNames ( ) const
override

◆ rowCount()

int BtModuleTextModel::rowCount ( const QModelIndex &  parent = QModelIndex()) const
override

Reimplemented from QAbstractItemModel.

Definition at line 277 of file btmoduletextmodel.cpp.

References m_maxEntries.

Referenced by BtQmlInterface::findText().

◆ setData()

bool BtModuleTextModel::setData ( const QModelIndex &  index,
const QVariant &  value,
int  role = Qt::EditRole 
)
overridevirtual

Reimplemented from QAbstractItemModel.

Definition at line 452 of file btmoduletextmodel.cpp.

References getColumnFromRole(), indexToVerseKey(), and m_moduleInfoList.

Referenced by BtQmlInterface::setRawText().

◆ setDisplayOptions()

void BtModuleTextModel::setDisplayOptions ( const DisplayOptions displayOptions)

◆ setFilterOptions()

void BtModuleTextModel::setFilterOptions ( FilterOptions  filterOptions)

◆ setFindState()

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().

◆ 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().

◆ setModules()

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().

◆ setTextFilter()

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().

◆ verseData()

QString BtModuleTextModel::verseData ( const QModelIndex &  index,
int  role = Qt::DisplayRole 
) const
private

◆ verseKeyToIndex()

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().

Member Data Documentation

◆ m_displayRendering

Rendering::CDisplayRendering BtModuleTextModel::m_displayRendering
private

◆ m_findState

std::optional<FindState> BtModuleTextModel::m_findState
private

Definition at line 194 of file btmoduletextmodel.h.

Referenced by data(), and setFindState().

◆ m_firstEntry

int BtModuleTextModel::m_firstEntry
private

◆ m_highlightWords

QString BtModuleTextModel::m_highlightWords
private

Definition at line 188 of file btmoduletextmodel.h.

Referenced by data(), setHighlightWords(), and verseData().

◆ m_maxEntries

int BtModuleTextModel::m_maxEntries
private

Definition at line 191 of file btmoduletextmodel.h.

Referenced by reloadModules(), and rowCount().

◆ m_moduleInfoList

BtConstModuleList BtModuleTextModel::m_moduleInfoList
private

◆ m_modules

QStringList BtModuleTextModel::m_modules
private

Definition at line 187 of file btmoduletextmodel.h.

Referenced by reloadModules(), and setModules().

◆ m_textFilter

BtModuleTextFilter* BtModuleTextModel::m_textFilter
private

Definition at line 192 of file btmoduletextmodel.h.

Referenced by data(), and setTextFilter().


The documentation for this class was generated from the following files: