treemodel.h

00001 /*
00002  * Silence
00003  *
00004  * Copyright (C) 2009 Manuel Unglaub
00005  *
00006  * This file is part of Silence.
00007  *
00008  * Silence is free software: you can redistribute it and/or modify
00009  * it under the terms of the GNU General Public License as published by
00010  * the Free Software Foundation, version GPLv2 only of the License.
00011  *
00012  * Silence is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016 
00017  * You should have received a copy of the GNU General Public License
00018  * along with Silence.  If not, see <http://www.gnu.org/licenses/>.
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 
Generated on Fri May 14 19:12:50 2010 for Silence by  doxygen 1.6.3