NCL Composer  0.1.5
 All Classes Functions Variables Pages
TreeModel.h
1 /*
2  * Copyright 2011 TeleMidia/PUC-Rio.
3  *
4  * This library is free software; you can redistribute it and/or
5  * modify it under the terms of the GNU Lesser General Public
6  * License as published by the Free Software Foundation; either
7  * version 2.1 of the License, or (at your option) any later version.
8  *
9  * This library is distributed in the hope that it will be useful,
10  * but WITHOUT ANY WARRANTY; without even the implied warranty of
11  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12  * Lesser General Public License for more details.
13  *
14  * You should have received a copy of the GNU Lesser General Public
15  * License along with this library. If not, see
16  * <http://www.gnu.org/licenses/>.
17  */
18 #ifndef TREEMODEL_H
19 #define TREEMODEL_H
20 
21 #include <QAbstractItemModel>
22 #include <QModelIndex>
23 #include <QVariant>
24 
25 class TreeItem;
26 
27 class TreeModel : public QAbstractItemModel
28 {
29  Q_OBJECT
30 
31 public:
32  TreeModel(const QString &data, QObject *parent = 0);
33  ~TreeModel();
34 
35  QVariant data(const QModelIndex &index, int role) const;
36  Qt::ItemFlags flags(const QModelIndex &index) const;
37  QVariant headerData(int section, Qt::Orientation orientation,
38  int role = Qt::DisplayRole) const;
39  QModelIndex index(int row, int column,
40  const QModelIndex &parent = QModelIndex()) const;
41  QModelIndex parent(const QModelIndex &index) const;
42  int rowCount(const QModelIndex &parent = QModelIndex()) const;
43  int columnCount(const QModelIndex &parent = QModelIndex()) const;
44 
45 private:
46  void setupModelData(const QStringList &lines, TreeItem *parent);
47 
48  TreeItem *rootItem;
49 };
50 
51 #endif