X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Ftreemodel.h;h=c72021683730a35fdeaa2f2b68b0278eb9aee70d;hp=2b7928c53a3c3e1624c56c69ab08a03f26272060;hb=a7f5d6a23f7214b11f6db85346a67fd7d02767da;hpb=44b22c4419f478a20f6324f9f3a700a2dec56302 diff --git a/src/client/treemodel.h b/src/client/treemodel.h index 2b7928c5..c7202168 100644 --- a/src/client/treemodel.h +++ b/src/client/treemodel.h @@ -23,6 +23,7 @@ #include #include +#include #include /***************************************** @@ -30,6 +31,7 @@ *****************************************/ class TreeItem : public QObject { Q_OBJECT + Q_PROPERTY(uint id READ id) public: TreeItem(const QList &data, TreeItem *parent = 0); @@ -39,17 +41,35 @@ 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; + + Qt::ItemFlags flags() const; + void setFlags(Qt::ItemFlags); + int row() const; TreeItem *parent(); - + + +private slots: + void childDestroyed(); + + protected: - QList childItems; - TreeItem *parentItem; QList itemData; + +private: + QList _childItems; + QHash _childHash; // uint to be compatible to qHash functions + TreeItem *_parentItem; + Qt::ItemFlags _flags; }; @@ -67,16 +87,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; - void clear(); + virtual void clear(); protected: bool removeRow(int row, const QModelIndex &parent = QModelIndex()); bool removeRows(int row, int count, const QModelIndex &parent = QModelIndex()); - + TreeItem *rootItem; };