treemodel.h
00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018
00019
00020
00021 #ifndef TREEMODEL_H
00022 #define TREEMODEL_H
00023
00024 #include "src/data/node/node.h"
00025 #include <QAbstractItemModel>
00026 #include <QModelIndex>
00027 #include <QVariant>
00028
00029
00039 class TreeModel : public QAbstractItemModel
00040 {
00041 Q_OBJECT
00042
00043 public:
00049 TreeModel(QObject *parent = 0);
00050
00058 QVariant data(const QModelIndex &index, int role) const;
00059
00069 bool setData(const QModelIndex &index, const QVariant &value, int role = Qt::EditRole);
00070
00077 Qt::ItemFlags flags(const QModelIndex &index) const;
00078
00087 QVariant headerData(int section, Qt::Orientation orientation, int role = Qt::DisplayRole) const;
00088
00097 QModelIndex index(int row, int column, const QModelIndex &parent = QModelIndex()) const;
00098
00105 QModelIndex parent(const QModelIndex &index) const;
00106
00114 int rowCount(const QModelIndex &parent = QModelIndex()) const;
00115
00123 int columnCount(const QModelIndex &parent = QModelIndex()) const;
00124
00134 bool insertRows(int position, int rows, const QModelIndex &parent = QModelIndex());
00135
00145 bool removeRows(int position, int rows, const QModelIndex &parent = QModelIndex());
00146
00152 Qt::DropActions supportedDropActions() const;
00153
00160 QMimeData* mimeData(const QModelIndexList &indexes) const;
00161
00172 bool dropMimeData(const QMimeData *data, Qt::DropAction action, int row, int column, const QModelIndex & parent);
00173
00179 QStringList mimeTypes() const;
00180
00187 Node* getItem(const QModelIndex &index) const;
00188
00194 QModelIndex findByNodeId(int id);
00195
00196 signals:
00202 void dropped(QModelIndex index);
00203
00204 private:
00205 Node *rootItem;
00206
00207 QModelIndex findByNodeId(int id, QModelIndex &searchindex);
00208 };
00209
00210 #endif // TREEMODEL_H
00211
00212
00213