X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Ftreemodel.h;h=27360ba1c0e5ec4267f60418adcadd70b9df0a8b;hp=a4039843b40004e89d1612b5dcc90fc0c85bf04f;hb=012df68ce8a743a71bfe3beda529a21c02daddb6;hpb=13b2affbdccd1d52479e49affdb81a77258392a6 diff --git a/src/client/treemodel.h b/src/client/treemodel.h index a4039843..27360ba1 100644 --- a/src/client/treemodel.h +++ b/src/client/treemodel.h @@ -21,13 +21,17 @@ #ifndef _TREEMODEL_H_ #define _TREEMODEL_H_ -#include +#include +#include +#include +#include /***************************************** * general item used in the Tree Model *****************************************/ class TreeItem : public QObject { Q_OBJECT + Q_PROPERTY(uint id READ id) public: TreeItem(const QList &data, TreeItem *parent = 0); @@ -37,7 +41,9 @@ public: void appendChild(TreeItem *child); void removeChild(int row); - TreeItem *child(int row); + virtual uint id() const; + TreeItem *child(int row) const; + TreeItem *childById(const uint &) const; int childCount() const; int columnCount() const; virtual QVariant data(int column, int role) const; @@ -45,7 +51,8 @@ public: TreeItem *parent(); protected: - QList childItems; + QList childItems; + QHash childHash; // uint to be compatible to qHash functions TreeItem *parentItem; QList itemData; }; @@ -65,13 +72,17 @@ public: virtual Qt::ItemFlags flags(const QModelIndex &index) const; QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const; QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const; + QModelIndex indexById(uint id, const QModelIndex &parent = QModelIndex()) const; QModelIndex parent(const QModelIndex &index) const; int rowCount(const QModelIndex &parent = QModelIndex()) const; int columnCount(const QModelIndex &parent = QModelIndex()) const; + virtual void clear(); + protected: bool removeRow(int row, const QModelIndex &parent = QModelIndex()); - + bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); + TreeItem *rootItem; };