X-Git-Url: https://git.quassel-irc.org/?p=quassel.git;a=blobdiff_plain;f=src%2Fclient%2Ftreemodel.h;h=dc7e70d2d1e308753dcf2f01ec03c84a97f1a43d;hp=a4039843b40004e89d1612b5dcc90fc0c85bf04f;hb=1f83867af2efc7be65d60f7c3dfe59774122a883;hpb=13b2affbdccd1d52479e49affdb81a77258392a6 diff --git a/src/client/treemodel.h b/src/client/treemodel.h index a4039843..dc7e70d2 100644 --- a/src/client/treemodel.h +++ b/src/client/treemodel.h @@ -1,11 +1,11 @@ /*************************************************************************** - * Copyright (C) 2005-07 by The Quassel Team * + * Copyright (C) 2005-07 by the Quassel IRC Team * * devel@quassel-irc.org * * * * This program is free software; you can redistribute it and/or modify * * it under the terms of the GNU General Public License as published by * * the Free Software Foundation; either version 2 of the License, or * - * (at your option) any later version. * + * (at your option) version 3. * * * * This program is distributed in the hope that it will be useful, * * but WITHOUT ANY WARRANTY; without even the implied warranty of * @@ -21,33 +21,55 @@ #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); TreeItem(TreeItem *parent = 0); virtual ~TreeItem(); - + void appendChild(TreeItem *child); void removeChild(int row); - - TreeItem *child(int row); + + virtual quint64 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; }; @@ -56,21 +78,25 @@ protected: *****************************************/ class TreeModel : public QAbstractItemModel { Q_OBJECT - + public: TreeModel(const QList &, QObject *parent = 0); virtual ~TreeModel(); - + QVariant data(const QModelIndex &index, int role) const; 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; };