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 (CSwordModuleInfo *module, int role) const |
QVariant | data (QModelIndex const &index, int role) const override |
CSwordModuleInfo * | getModule (QString const &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 (QList< CSwordModuleInfo * > const &modules, bool destroy=false) |
int | rowCount (QModelIndex const &parent=QModelIndex()) const override |
bool | setData (QModelIndex const &index, QVariant const &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 133 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 122 of file btbookshelfmodel.cpp.
References m_data.
QVariant BtBookshelfModel::data | ( | CSwordModuleInfo * | module, |
int | role | ||
) | const |
Definition at line 40 of file btbookshelfmodel.cpp.
References BT_ASSERT, CSwordModuleInfo::category(), CSwordModuleInfo::config(), CSwordModuleInfo::Description, module(), ModuleCategoryRole, ModuleDescriptionRole, ModuleHasIndexRole, ModuleHiddenRole, CSwordModuleInfo::moduleIcon(), ModuleIconRole, ModuleIndexSizeRole, ModuleInstallPathRole, ModuleLanguageRole, ModuleNameRole, ModulePointerRole, and CSwordModuleInfo::name().
|
override |
Definition at line 75 of file btbookshelfmodel.cpp.
CSwordModuleInfo * BtBookshelfModel::getModule | ( | QString const & | name | ) | const |
Returns the first module found with the given name.
[in] | name | Name of the module to find. |
Definition at line 187 of file btbookshelfmodel.cpp.
References m_data, module(), CSwordModuleInfo::name(), and UNLIKELY.
|
override |
Definition at line 87 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(), removeModules(), 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 212 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 194 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 200 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 206 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 151 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 179 of file btbookshelfmodel.cpp.
References module(), and removeModule().
Referenced by removeModules().
void BtBookshelfModel::removeModules | ( | QList< CSwordModuleInfo * > const & | 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 170 of file btbookshelfmodel.cpp.
References module(), and removeModules().
|
override |
Definition at line 33 of file btbookshelfmodel.cpp.
|
override |
Definition at line 101 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().