summaryrefslogtreecommitdiff
path: root/src/backend/bookshelfmodel/item.h
diff options
context:
space:
mode:
Diffstat (limited to 'src/backend/bookshelfmodel/item.h')
-rw-r--r--src/backend/bookshelfmodel/item.h43
1 files changed, 9 insertions, 34 deletions
diff --git a/src/backend/bookshelfmodel/item.h b/src/backend/bookshelfmodel/item.h
index 665343f..f10da04 100644
--- a/src/backend/bookshelfmodel/item.h
+++ b/src/backend/bookshelfmodel/item.h
@@ -17,6 +17,7 @@
#include <QList>
#include <QString>
#include <QtGlobal>
+#include <QVariant>
class CSwordModuleInfo;
@@ -30,7 +31,7 @@ class Item {
ITEM_CATEGORY = 1,
ITEM_LANGUAGE = 2,
ITEM_MODULE = 3,
- ITEM_DISTRIBUTION = 4
+ ITEM_INDEXING = 4
};
Item(Type type);
@@ -54,21 +55,11 @@ class Item {
/**
\brief Returns the list of child items of this node.
*/
- inline const QList<Item*> &children() const {
+ inline QList<Item*> &children() {
return m_children;
}
/**
- \brief Returns a pointer to the child item at the given index.
- \pre The given index is valid
- \param[in] index Index of child item to return.
- */
- Item *childAt(int index) const {
- Q_ASSERT(index >= 0 && index < m_children.size());
- return m_children.at(index);
- }
-
- /**
\brief Returns the index of this item under its parent.
\retval -1 if this item has no parent.
*/
@@ -97,18 +88,13 @@ class Item {
newItem->setParent(this);
}
- inline void deleteChildAt(int index) {
- Q_ASSERT(index >= 0 && index <= m_children.size());
- delete m_children.takeAt(index);
- }
-
template <class T>
- T *getGroupItem(CSwordModuleInfo *module, int *index) {
+ T *getGroupItem(CSwordModuleInfo *module, int &outIndex) {
for (int i(0); i < m_children.size(); i++) {
Q_ASSERT(m_children.at(i)->type() == T::GROUP_TYPE);
T *item(static_cast<T*>(m_children.at(i)));
if (item->fitFor(module)) {
- if (index != 0) *index = i;
+ outIndex = i;
return item;
}
}
@@ -116,23 +102,14 @@ class Item {
}
/**
- \brief Returns the visible name of the item.
+ \brief Returns data for this item.
*/
- inline virtual QString name() const {
- return QString::null;
- }
-
- /**
- \brief Returns the visible icon of the item.
- */
- inline virtual QIcon icon() const {
- return QIcon();
- }
+ virtual QVariant data(int role = Qt::DisplayRole) const;
/**
\brief Returns the check state of this item.
*/
- inline const Qt::CheckState checkState() const {
+ inline Qt::CheckState checkState() const {
return m_checkState;
}
@@ -148,7 +125,7 @@ class Item {
\brief Returns whether this item is fit to contain the given module.
\param[in] module The module to check with.
\retval true If this item is a group and can contain the given module.
- \retval false This item is not a group or a wrong group.
+ \retval false This item is not a group or is a wrong group.
*/
inline virtual bool fitFor(CSwordModuleInfo *module) const {
Q_UNUSED(module);
@@ -160,8 +137,6 @@ class Item {
*/
virtual bool operator<(const Item &other) const;
- virtual bool isHidden() const;
-
protected:
inline void setParent(Item *parent) {
Q_ASSERT(parent != 0);