[Companion] It's now possible to add Categories

This commit is contained in:
Bertrand Songis
2017-01-18 08:27:17 +01:00
parent e740a88e13
commit 8abc2a7179
4 changed files with 58 additions and 41 deletions
+9 -3
View File
@@ -34,14 +34,14 @@ class TreeItem
{
public:
explicit TreeItem(const QVector<QVariant> & itemData);
explicit TreeItem(TreeItem * parent, int modelIndex = -1);
explicit TreeItem(TreeItem * parent, int categoryIndex, int modelIndex);
~TreeItem();
TreeItem *child(int number);
TreeItem * child(int number);
int childCount() const;
int columnCount() const;
QVariant data(int column) const;
TreeItem * appendChild(int modelIndex);
TreeItem * appendChild(int categoryIndex, int modelIndex);
TreeItem * parent();
bool removeChildren(int position, int count);
@@ -49,11 +49,13 @@ class TreeItem
bool setData(int column, const QVariant &value);
int getModelIndex() const { return modelIndex; }
int getCategoryIndex() const { return categoryIndex; }
private:
QList<TreeItem*> childItems;
QVector<QVariant> itemData;
TreeItem * parentItem;
int categoryIndex;
int modelIndex;
};
@@ -92,6 +94,10 @@ class TreeModel : public QAbstractItemModel
return getItem(index)->getModelIndex();
}
int getCategoryIndex(const QModelIndex & index) const {
return getItem(index)->getCategoryIndex();
}
private:
TreeItem * getItem(const QModelIndex & index) const;
TreeItem * rootItem;