BibleTime
|
#include <btbookshelfmodel.h>
Classes | |
struct | ConstructInPrivate |
Used to restrict construction to newInstance() only. More... | |
Public Types | |
enum | ModuleRole { ModuleNameRole = Qt::UserRole , ModuleIconRole , ModulePointerRole , ModuleCategoryRole , ModuleLanguageRole , ModuleHiddenRole , ModuleInstallPathRole , ModuleHasIndexRole , ModuleIndexSizeRole , ModuleDescriptionRole , UserRole } |
Public Member Functions | |
void | addModule (CSwordModuleInfo *const module) |
BtBookshelfModel (BtBookshelfModel &&)=delete | |
BtBookshelfModel (BtBookshelfModel const &)=delete | |
BtBookshelfModel (ConstructInPrivate const &) | |
void | clear (bool destroy=false) |
QVariant | data (const QModelIndex &index, int role) const override |
QVariant | data (CSwordModuleInfo *module, int role) const |
CSwordModuleInfo * | getModule (const QString &name) const |
QVariant | headerData (int section, Qt::Orientation orientation, int role=Qt::DisplayRole) const override |
CSwordModuleInfo * | module (QModelIndex const &index) const |
QList< CSwordModuleInfo * > const & | moduleList () const |
BtBookshelfModel & | operator= (BtBookshelfModel &&)=delete |
BtBookshelfModel & | operator= (BtBookshelfModel const &)=delete |
void | removeModule (CSwordModuleInfo *const module, bool destroy=false) |
void | removeModules (BtConstModuleSet const &modules, bool destroy=false) |
void | removeModules (const QList< CSwordModuleInfo * > &modules, bool destroy=false) |
int | rowCount (const QModelIndex &parent=QModelIndex()) const override |
bool | setData (const QModelIndex &index, const QVariant &value, int role=ModuleHiddenRole) override |
~BtBookshelfModel () noexcept override | |
Static Public Member Functions | |
static std::shared_ptr< BtBookshelfModel > | newInstance () |
Protected Slots | |
void | moduleHidden (bool hidden) |
void | moduleIndexed (bool indexed) |
void | moduleUnlocked (bool unlocked) |
Private Member Functions | |
void | moduleDataChanged (CSwordModuleInfo *module) |
Private Attributes | |
QList< CSwordModuleInfo * > | m_data |
Implements a simple list model projecting CSwordModuleInfo instances. This model is mostly implemented to provide an interface the the underlying data and to provide notifications when modules are added, removed or changed. If you want to use a model for widgets, the BtBookshelfTreeModel might be a better choice, since it also provides sorting and grouping.
Definition at line 35 of file btbookshelfmodel.h.
Definition at line 41 of file btbookshelfmodel.h.
|
delete |
|
delete |
BtBookshelfModel::BtBookshelfModel | ( | ConstructInPrivate const & | ) |
Definition at line 26 of file btbookshelfmodel.cpp.
|
overridedefaultnoexcept |
void BtBookshelfModel::addModule | ( | CSwordModuleInfo *const | module | ) |
Appends the given module to this model.
[in] | module | Module to add. |
Definition at line 131 of file btbookshelfmodel.cpp.
References BT_ASSERT, BT_CONNECT, CSwordModuleInfo::hasIndexChanged(), CSwordModuleInfo::hiddenChanged(), m_data, module(), moduleHidden(), moduleIndexed(), moduleUnlocked(), and CSwordModuleInfo::unlockedChanged().
void BtBookshelfModel::clear | ( | bool | destroy = false | ) |
Clears the data of the whole model by removing all items.
[in] | destroy | If true, all CSwordModuleInfo instances in this model are also destroyed. |
Definition at line 120 of file btbookshelfmodel.cpp.
References m_data.
|
override |
Definition at line 74 of file btbookshelfmodel.cpp.
QVariant BtBookshelfModel::data | ( | CSwordModuleInfo * | module, |
int | role | ||
) | const |
Definition at line 40 of file btbookshelfmodel.cpp.
References CSwordModuleInfo::AbsoluteDataPath, BT_ASSERT, CSwordModuleInfo::category(), CSwordModuleInfo::config(), CSwordModuleInfo::Description, CSwordModuleInfo::hasIndex(), CSwordModuleInfo::indexSize(), CSwordModuleInfo::isHidden(), module(), ModuleCategoryRole, ModuleDescriptionRole, ModuleHasIndexRole, ModuleHiddenRole, CSwordModuleInfo::moduleIcon(), ModuleIconRole, ModuleIndexSizeRole, ModuleInstallPathRole, ModuleLanguageRole, ModuleNameRole, ModulePointerRole, and CSwordModuleInfo::name().
CSwordModuleInfo * BtBookshelfModel::getModule | ( | const QString & | name | ) | const |
Returns the first module found with the given name.
[in] | name | Name of the module to find. |
Definition at line 183 of file btbookshelfmodel.cpp.
References m_data, module(), CSwordModuleInfo::name(), and UNLIKELY.
|
override |
Definition at line 85 of file btbookshelfmodel.cpp.
|
inline |
Given an index of this model, this method returns a pointer to the underlying CSwordModuleInfo instance corresponding to the given index.
[in] | index | An index to this model. |
Definition at line 90 of file btbookshelfmodel.h.
References data(), and ModulePointerRole.
Referenced by addModule(), data(), getModule(), moduleDataChanged(), removeModule(), and removeModules().
|
private |
Called internally when module data changes. This method emits any neccessary signals for this model.
[in] | module | The module that changed status. |
Definition at line 208 of file btbookshelfmodel.cpp.
References BT_ASSERT, m_data, and module().
Referenced by moduleHidden(), moduleIndexed(), and moduleUnlocked().
|
protectedslot |
Slot DIRECTLY called by CSwordModuleInfo when the hidden status of the respective module changes.
[in] | hidden | True, if the module was hidden; false, if the module was shown. |
Definition at line 190 of file btbookshelfmodel.cpp.
References BT_ASSERT, and moduleDataChanged().
Referenced by addModule(), and removeModule().
|
protectedslot |
Slot DIRECTLY called by CSwordModuleInfo when the indexed status of the respective module changes.
[in] | indexed | True, if the module was indexed; false if the index was deleted. |
Definition at line 196 of file btbookshelfmodel.cpp.
References BT_ASSERT, and moduleDataChanged().
Referenced by addModule(), and removeModule().
|
inline |
Returns the list of handled modules as a list of CSwordModuleInfo* pointers.
Definition at line 144 of file btbookshelfmodel.h.
References m_data.
|
protectedslot |
Slot DIRECTLY called by CSwordModuleInfo when the locked status of the respective module changes.
[in] | unlocked | True, if the module was unlocked; false if the module was locked. |
Definition at line 202 of file btbookshelfmodel.cpp.
References BT_ASSERT, and moduleDataChanged().
Referenced by addModule(), and removeModule().
|
static |
Definition at line 28 of file btbookshelfmodel.cpp.
Referenced by BtBookshelfWorksPage::BtBookshelfWorksPage().
|
delete |
|
delete |
void BtBookshelfModel::removeModule | ( | CSwordModuleInfo *const | module, |
bool | destroy = false |
||
) |
Removes the given module from this model and optionally destroys it.
[in] | module | The module to remove from this model. |
[in] | destroy | If true, the given CSwordModuleInfo instance is destroyed. |
Definition at line 149 of file btbookshelfmodel.cpp.
References CSwordModuleInfo::hasIndexChanged(), CSwordModuleInfo::hiddenChanged(), m_data, module(), moduleHidden(), moduleIndexed(), moduleUnlocked(), and CSwordModuleInfo::unlockedChanged().
Referenced by removeModules().
void BtBookshelfModel::removeModules | ( | BtConstModuleSet const & | modules, |
bool | destroy = false |
||
) |
Removes all modules from the given set from this model and optionally destroys them.
[in] | modules | The set of modules to remove from this model. |
[in] | destroy | If true, the given CSwordModuleInfo instances are destroyed. |
Definition at line 177 of file btbookshelfmodel.cpp.
References module(), and removeModule().
Referenced by removeModules().
void BtBookshelfModel::removeModules | ( | const QList< CSwordModuleInfo * > & | modules, |
bool | destroy = false |
||
) |
Removes all modules from the given list from this model and optionally destroys them.
[in] | modules | The list of modules to remove from this model. |
[in] | destroy | If true, the given CSwordModuleInfo instances are destroyed. |
Definition at line 168 of file btbookshelfmodel.cpp.
References module(), and removeModules().
|
override |
Definition at line 33 of file btbookshelfmodel.cpp.
|
override |
Definition at line 99 of file btbookshelfmodel.cpp.
References m_data, and ModuleHiddenRole.
|
private |
The underlying data as a list of pointers to the respective CSwordModuleInfo instances.
Definition at line 186 of file btbookshelfmodel.h.
Referenced by addModule(), clear(), data(), getModule(), moduleDataChanged(), moduleList(), removeModule(), and setData().