diff options
Diffstat (limited to 'src/backend/bookshelfmodel/btbookshelftreemodel.h')
-rw-r--r-- | src/backend/bookshelfmodel/btbookshelftreemodel.h | 26 |
1 files changed, 21 insertions, 5 deletions
diff --git a/src/backend/bookshelfmodel/btbookshelftreemodel.h b/src/backend/bookshelfmodel/btbookshelftreemodel.h index e73b154..47ce672 100644 --- a/src/backend/bookshelfmodel/btbookshelftreemodel.h +++ b/src/backend/bookshelfmodel/btbookshelftreemodel.h @@ -15,8 +15,10 @@ #include <QAbstractItemModel> +#include <QList> #include <QMap> #include <QPersistentModelIndex> +#include <QSet> #include "backend/bookshelfmodel/btbookshelfmodel.h" #include "backend/bookshelfmodel/item.h" @@ -39,8 +41,17 @@ class BtBookshelfTreeModel: public QAbstractItemModel { CheckStateRole = BtBookshelfModel::UserRole, UserRole = BtBookshelfModel::UserRole + 100 }; - enum Group { GROUP_CATEGORY = 0, GROUP_LANGUAGE, GROUP_DISTRIBUTION }; - enum CheckedBehavior { CHECKED, UNCHECKED, MODULE_HIDDEN }; + enum Group { + GROUP_CATEGORY = 0, + GROUP_LANGUAGE = 1, + GROUP_INDEXING + }; + enum CheckedBehavior { + 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. */ + }; typedef QList<Group> Grouping; BtBookshelfTreeModel(QObject *parent = 0); @@ -56,7 +67,8 @@ class BtBookshelfTreeModel: public QAbstractItemModel { const QModelIndex &parent = QModelIndex()) const; virtual QModelIndex parent(const QModelIndex &index) const; - virtual QVariant data(const QModelIndex &index, int role) const; + virtual QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; + QVariant data(CSwordModuleInfo *module, int role = Qt::DisplayRole) const; virtual Qt::ItemFlags flags(const QModelIndex &index) const; virtual QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; @@ -82,7 +94,9 @@ class BtBookshelfTreeModel: public QAbstractItemModel { return m_defaultChecked; } - QList<CSwordModuleInfo*> checkedModules() const; + inline const QSet<CSwordModuleInfo*> &checkedModules() const { + return m_checkedModulesCache; + } protected: QVariant parentData(BookshelfModel::ModuleItem *item, int role) const; @@ -100,7 +114,7 @@ class BtBookshelfTreeModel: public QAbstractItemModel { QModelIndex parentIndex) { BookshelfModel::Item *parentItem(getItem(parentIndex)); int groupIndex; - T *groupItem(parentItem->getGroupItem<T>(module, &groupIndex)); + T *groupItem(parentItem->getGroupItem<T>(module, groupIndex)); if (groupItem == 0) { groupItem = new T(module); @@ -129,6 +143,8 @@ class BtBookshelfTreeModel: public QAbstractItemModel { Grouping m_groupingOrder; CheckedBehavior m_defaultChecked; bool m_checkable; + + QSet<CSwordModuleInfo*> m_checkedModulesCache; }; QDataStream &operator<<(QDataStream &os, const BtBookshelfTreeModel::Grouping &o); |