summaryrefslogtreecommitdiff
path: root/src/backend/bookshelfmodel/btbookshelftreemodel.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/bookshelfmodel/btbookshelftreemodel.h')
-rw-r--r--src/backend/bookshelfmodel/btbookshelftreemodel.h41
1 files changed, 28 insertions, 13 deletions
diff --git a/src/backend/bookshelfmodel/btbookshelftreemodel.h b/src/backend/bookshelfmodel/btbookshelftreemodel.h
index 0a84ac3..84293e1 100644
--- a/src/backend/bookshelfmodel/btbookshelftreemodel.h
+++ b/src/backend/bookshelfmodel/btbookshelftreemodel.h
@@ -20,34 +20,37 @@
#include "backend/bookshelfmodel/item.h"
namespace BookshelfModel {
- class ModuleItem;
+class ModuleItem;
}
class CSwordModuleInfo;
+class QDataStream;
class BtBookshelfTreeModel: public QAbstractItemModel {
- Q_OBJECT
+ Q_OBJECT
+ Q_ENUMS(Group)
- typedef QMap<CSwordModuleInfo*, BookshelfModel::ModuleItem*> ModuleItemMap;
+ typedef QMap<CSwordModuleInfo*, BookshelfModel::ModuleItem*> ModuleItemMap;
public:
enum ModuleRole {
CheckStateRole = BtBookshelfModel::UserRole,
UserRole = BtBookshelfModel::UserRole + 100
};
- enum Group { GROUP_CATEGORY, GROUP_LANGUAGE, GROUP_DISTRIBUTION };
+ enum Group { GROUP_CATEGORY = 0, GROUP_LANGUAGE, GROUP_DISTRIBUTION };
typedef QList<Group> Grouping;
BtBookshelfTreeModel(QObject *parent = 0);
+ BtBookshelfTreeModel(const Grouping &grouping, QObject *parent = 0);
virtual ~BtBookshelfTreeModel();
virtual int rowCount(const QModelIndex &parent = QModelIndex()) const;
virtual int columnCount(const QModelIndex &parent = QModelIndex())
- const;
+ const;
virtual bool hasChildren(const QModelIndex &parent = QModelIndex())
- const;
+ const;
virtual QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex())
- const;
+ const;
virtual QModelIndex parent(const QModelIndex &index) const;
virtual QVariant data(const QModelIndex &index, int role) const;
virtual Qt::ItemFlags flags(const QModelIndex &index) const;
@@ -57,15 +60,23 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
int role);
void setSourceModel(QAbstractListModel *sourceModel);
- inline QAbstractListModel *sourceModel() const { return m_sourceModel; }
+ inline QAbstractListModel *sourceModel() const {
+ return m_sourceModel;
+ }
void setGroupingOrder(const Grouping &groupingOrder);
- inline Grouping groupingOrder() const { return m_groupingOrder; }
+ inline Grouping groupingOrder() const {
+ return m_groupingOrder;
+ }
void setCheckable(bool checkable);
- inline bool checkable() const { return m_checkable; }
+ inline bool checkable() const {
+ return m_checkable;
+ }
inline void setDefaultChecked(bool defaultChecked) {
m_defaultChecked = defaultChecked;
}
- inline bool defaultChecked() const { return m_defaultChecked; }
+ inline bool defaultChecked() const {
+ return m_defaultChecked;
+ }
QList<CSwordModuleInfo*> checkedModules() const;
@@ -80,8 +91,7 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
template <class T>
QModelIndex getGroup(CSwordModuleInfo *module,
- QModelIndex parentIndex)
- {
+ QModelIndex parentIndex) {
BookshelfModel::Item *parentItem(getItem(parentIndex));
int groupIndex;
T *groupItem(parentItem->getGroupItem<T>(module, &groupIndex));
@@ -111,4 +121,9 @@ class BtBookshelfTreeModel: public QAbstractItemModel {
bool m_defaultChecked;
};
+QDataStream &operator<<(QDataStream &os, const BtBookshelfTreeModel::Grouping &o);
+QDataStream &operator>>(QDataStream &is, BtBookshelfTreeModel::Grouping &o);
+
+Q_DECLARE_METATYPE(BtBookshelfTreeModel::Grouping);
+
#endif // BTBOOKSHELFTREEMODEL_H