BibleTime
Classes | Public Types | Public Slots | Signals | Public Member Functions | Protected Slots | Protected Member Functions | Private Types | Private Member Functions | Private Attributes | List of all members
BtBookshelfTreeModel Class Reference

#include <btbookshelftreemodel.h>

Inheritance diagram for BtBookshelfTreeModel:

Classes

class  Grouping
 

Public Types

enum  CheckedBehavior { CHECKED , UNCHECKED , MODULE_HIDDEN , MODULE_INDEXED }
 
enum  Group : int { GROUP_CATEGORY = 0 , GROUP_LANGUAGE = 1 , GROUP_INDEXING }
 
enum  ModuleRole { CheckStateRole = BtBookshelfModel::UserRole , UserRole = BtBookshelfModel::UserRole + 100 }
 

Public Slots

void setCheckable (bool checkable)
 
void setCheckedModules (BtConstModuleSet const &modules)
 
void setDefaultChecked (CheckedBehavior const b)
 
void setGroupingOrder (BtBookshelfTreeModel::Grouping const &groupingOrder, bool emitSignal=true)
 
void setSourceModel (std::shared_ptr< QAbstractItemModel > sourceModel)
 

Signals

void groupingOrderChanged (BtBookshelfTreeModel::Grouping newGrouping)
 
void moduleChecked (CSwordModuleInfo *module, bool checked)
 

Public Member Functions

 BtBookshelfTreeModel (BtConfigCore const &config, QString const &configKey, QObject *const parent=nullptr)
 
 BtBookshelfTreeModel (Grouping const &grouping, QObject *parent=nullptr)
 
 BtBookshelfTreeModel (QObject *parent=nullptr)
 
bool checkable () const
 
BtModuleSet constcheckedModules () const
 
int columnCount (QModelIndex const &parent=QModelIndex()) const override
 
QVariant data (CSwordModuleInfo &module, int role=Qt::DisplayRole) const
 
QVariant data (QModelIndex const &index, int role=Qt::DisplayRole) const override
 
CheckedBehavior defaultChecked () const
 
Qt::ItemFlags flags (QModelIndex const &index) const override
 
Grouping constgroupingOrder () const
 
bool hasChildren (QModelIndex const &parent=QModelIndex()) const override
 
QVariant headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override
 
QModelIndex index (int row, int column, QModelIndex const &parent=QModelIndex()) const override
 
CSwordModuleInfomodule (QModelIndex const &index) const
 
QList< CSwordModuleInfo * > modules () const
 
QModelIndex parent (QModelIndex const &index) const override
 
int rowCount (QModelIndex const &parent=QModelIndex()) const override
 
bool setData (QModelIndex const &index, QVariant const &value, int role) override
 
std::shared_ptr< QAbstractItemModelsourceModel () const noexcept
 
 ~BtBookshelfTreeModel () override
 

Protected Slots

void moduleDataChanged (QModelIndex const &topLeft, QModelIndex const &bottomRight)
 
void moduleInserted (QModelIndex const &parent, int start, int end)
 
void moduleRemoved (QModelIndex const &parent, int start, int end)
 

Protected Member Functions

void resetData ()
 

Private Types

using ModuleItemMap = QMap< CSwordModuleInfo *, BookshelfModel::ModuleItem * >
 
using SourceIndexMap = QMap< CSwordModuleInfo *, QPersistentModelIndex >
 

Private Member Functions

void addModule (CSwordModuleInfo &module, bool checked, bool inReset)
 
template<class T >
QModelIndex getGroup (CSwordModuleInfo const &module, QModelIndex const parentIndex, bool &beginInsert)
 
QModelIndex getIndex (BookshelfModel::Item const &item)
 
BookshelfModel::ItemgetItem (QModelIndex const &index) const
 
void removeModule (CSwordModuleInfo &module)
 
void resetParentCheckStates (QModelIndex parentIndex, bool inReset)
 

Private Attributes

bool m_checkable
 
BtModuleSet m_checkedModulesCache
 
CheckedBehavior m_defaultChecked
 
Grouping m_groupingOrder
 
ModuleItemMap m_modules
 
std::unique_ptr< BookshelfModel::Itemm_rootItem
 
SourceIndexMap m_sourceIndexMap
 
std::shared_ptr< QAbstractItemModelm_sourceModel
 

Detailed Description

Definition at line 37 of file btbookshelftreemodel.h.

Member Typedef Documentation

◆ ModuleItemMap

Definition at line 44 of file btbookshelftreemodel.h.

◆ SourceIndexMap

using BtBookshelfTreeModel::SourceIndexMap = QMap<CSwordModuleInfo *, QPersistentModelIndex>
private

Definition at line 45 of file btbookshelftreemodel.h.

Member Enumeration Documentation

◆ CheckedBehavior

Enumerator
CHECKED 

Check all added modules by default.

UNCHECKED 

Uncheck all added modules by default.

MODULE_HIDDEN 

By default, check only added modules that are not hidden.

MODULE_INDEXED 

By default, check only added modules that are indexed.

Definition at line 60 of file btbookshelftreemodel.h.

◆ Group

Enumerator
GROUP_CATEGORY 
GROUP_LANGUAGE 
GROUP_INDEXING 

Definition at line 54 of file btbookshelftreemodel.h.

◆ ModuleRole

Enumerator
CheckStateRole 
UserRole 

Definition at line 49 of file btbookshelftreemodel.h.

Constructor & Destructor Documentation

◆ BtBookshelfTreeModel() [1/3]

BtBookshelfTreeModel::BtBookshelfTreeModel ( QObject parent = nullptr)

Definition at line 68 of file btbookshelftreemodel.cpp.

◆ BtBookshelfTreeModel() [2/3]

BtBookshelfTreeModel::BtBookshelfTreeModel ( BtConfigCore const config,
QString const configKey,
QObject *const  parent = nullptr 
)

◆ BtBookshelfTreeModel() [3/3]

BtBookshelfTreeModel::BtBookshelfTreeModel ( Grouping const grouping,
QObject parent = nullptr 
)

Definition at line 89 of file btbookshelftreemodel.cpp.

◆ ~BtBookshelfTreeModel()

BtBookshelfTreeModel::~BtBookshelfTreeModel ( )
overridedefault

Member Function Documentation

◆ addModule()

void BtBookshelfTreeModel::addModule ( CSwordModuleInfo module,
bool  checked,
bool  inReset 
)
private

◆ checkable()

bool BtBookshelfTreeModel::checkable ( ) const
inline

Definition at line 144 of file btbookshelftreemodel.h.

References m_checkable.

Referenced by setCheckable().

◆ checkedModules()

BtModuleSet const & BtBookshelfTreeModel::checkedModules ( ) const
inline

◆ columnCount()

int BtBookshelfTreeModel::columnCount ( QModelIndex const parent = QModelIndex()) const
override

Definition at line 103 of file btbookshelftreemodel.cpp.

References parent().

Referenced by resetData().

◆ data() [1/2]

QVariant BtBookshelfTreeModel::data ( CSwordModuleInfo module,
int  role = Qt::DisplayRole 
) const

Definition at line 180 of file btbookshelftreemodel.cpp.

References BT_ASSERT, m_sourceIndexMap, m_sourceModel, and module().

◆ data() [2/2]

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

◆ defaultChecked()

CheckedBehavior BtBookshelfTreeModel::defaultChecked ( ) const
inline

Definition at line 145 of file btbookshelftreemodel.h.

References m_defaultChecked.

◆ flags()

Qt::ItemFlags BtBookshelfTreeModel::flags ( QModelIndex const index) const
override

◆ getGroup()

template<class T >
QModelIndex BtBookshelfTreeModel::getGroup ( CSwordModuleInfo const &  module,
QModelIndex const  parentIndex,
bool &  beginInsert 
)
inlineprivate

◆ getIndex()

QModelIndex BtBookshelfTreeModel::getIndex ( BookshelfModel::Item const item)
private

◆ getItem()

Item & BtBookshelfTreeModel::getItem ( QModelIndex const index) const
private

Definition at line 474 of file btbookshelftreemodel.cpp.

References BT_ASSERT, index(), m_rootItem, and UNLIKELY.

Referenced by addModule(), getGroup(), hasChildren(), index(), and rowCount().

◆ groupingOrder()

Grouping const & BtBookshelfTreeModel::groupingOrder ( ) const
inline

◆ groupingOrderChanged

void BtBookshelfTreeModel::groupingOrderChanged ( BtBookshelfTreeModel::Grouping  newGrouping)
signal

◆ hasChildren()

bool BtBookshelfTreeModel::hasChildren ( QModelIndex const parent = QModelIndex()) const
override

Definition at line 109 of file btbookshelftreemodel.cpp.

References BookshelfModel::Item::children(), getItem(), and parent().

◆ headerData()

QVariant BtBookshelfTreeModel::headerData ( int  section,
Qt::Orientation  orientation,
int  role = Qt::DisplayRole 
) const
override

Definition at line 260 of file btbookshelftreemodel.cpp.

References m_sourceModel.

◆ index()

QModelIndex BtBookshelfTreeModel::index ( int  row,
int  column,
QModelIndex const parent = QModelIndex() 
) const
override

◆ module()

CSwordModuleInfo * BtBookshelfTreeModel::module ( QModelIndex const index) const
inline

◆ moduleChecked

void BtBookshelfTreeModel::moduleChecked ( CSwordModuleInfo module,
bool  checked 
)
signal

◆ moduleDataChanged

void BtBookshelfTreeModel::moduleDataChanged ( QModelIndex const topLeft,
QModelIndex const bottomRight 
)
protectedslot

◆ moduleInserted

void BtBookshelfTreeModel::moduleInserted ( QModelIndex const parent,
int  start,
int  end 
)
protectedslot

◆ moduleRemoved

void BtBookshelfTreeModel::moduleRemoved ( QModelIndex const parent,
int  start,
int  end 
)
protectedslot

◆ modules()

QList< CSwordModuleInfo * > BtBookshelfTreeModel::modules ( ) const
inline

Definition at line 146 of file btbookshelftreemodel.h.

References m_modules.

Referenced by setCheckedModules().

◆ parent()

QModelIndex BtBookshelfTreeModel::parent ( QModelIndex const index) const
override

◆ removeModule()

void BtBookshelfTreeModel::removeModule ( CSwordModuleInfo module)
private

◆ resetData()

void BtBookshelfTreeModel::resetData ( )
protected

Definition at line 377 of file btbookshelftreemodel.cpp.

References columnCount(), index(), parent(), and rowCount().

Referenced by setCheckable().

◆ resetParentCheckStates()

void BtBookshelfTreeModel::resetParentCheckStates ( QModelIndex  parentIndex,
bool  inReset 
)
private

Definition at line 500 of file btbookshelftreemodel.cpp.

References BT_ASSERT, BookshelfModel::Item::checkState(), and getGroup().

Referenced by addModule(), removeModule(), and setData().

◆ rowCount()

int BtBookshelfTreeModel::rowCount ( QModelIndex const parent = QModelIndex()) const
override

Definition at line 99 of file btbookshelftreemodel.cpp.

References BookshelfModel::Item::children(), getItem(), and parent().

Referenced by resetData().

◆ setCheckable

void BtBookshelfTreeModel::setCheckable ( bool  checkable)
slot

◆ setCheckedModules

void BtBookshelfTreeModel::setCheckedModules ( BtConstModuleSet const modules)
slot

◆ setData()

bool BtBookshelfTreeModel::setData ( QModelIndex const index,
QVariant const value,
int  role 
)
override

◆ setDefaultChecked

void BtBookshelfTreeModel::setDefaultChecked ( CheckedBehavior const  b)
inlineslot

◆ setGroupingOrder

void BtBookshelfTreeModel::setGroupingOrder ( BtBookshelfTreeModel::Grouping const groupingOrder,
bool  emitSignal = true 
)
slot

◆ setSourceModel

void BtBookshelfTreeModel::setSourceModel ( std::shared_ptr< QAbstractItemModel sourceModel)
slot

◆ sourceModel()

std::shared_ptr< QAbstractItemModel > BtBookshelfTreeModel::sourceModel ( ) const
inlinenoexcept

Definition at line 140 of file btbookshelftreemodel.h.

References m_sourceModel.

Referenced by setSourceModel(), and BtOpenWorkActionMenu::sourceModel().

Member Data Documentation

◆ m_checkable

bool BtBookshelfTreeModel::m_checkable
private

Definition at line 214 of file btbookshelftreemodel.h.

Referenced by checkable(), data(), flags(), and setCheckable().

◆ m_checkedModulesCache

BtModuleSet BtBookshelfTreeModel::m_checkedModulesCache
private

◆ m_defaultChecked

CheckedBehavior BtBookshelfTreeModel::m_defaultChecked
private

◆ m_groupingOrder

Grouping BtBookshelfTreeModel::m_groupingOrder
private

Definition at line 212 of file btbookshelftreemodel.h.

Referenced by addModule(), groupingOrder(), and setGroupingOrder().

◆ m_modules

ModuleItemMap BtBookshelfTreeModel::m_modules
private

◆ m_rootItem

std::unique_ptr<BookshelfModel::Item> BtBookshelfTreeModel::m_rootItem
private

◆ m_sourceIndexMap

SourceIndexMap BtBookshelfTreeModel::m_sourceIndexMap
private

◆ m_sourceModel

std::shared_ptr<QAbstractItemModel> BtBookshelfTreeModel::m_sourceModel
private

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