Debian Codegraph @

utils/fgqcanvas/canvastreemodel.h

raw symbols SCIP
1 //
2 // Copyright (C) 2017 James Turner [email protected]
3 //
4 // This program is free software; you can redistribute it and/or
5 // modify it under the terms of the GNU General Public License as
6 // published by the Free Software Foundation; either version 2 of the
7 // License, or (at your option) any later version.
8 //
9 // This program is distributed in the hope that it will be useful, but
10 // WITHOUT ANY WARRANTY; without even the implied warranty of
11 // MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
12 // General Public License for more details.
13 //
14 // You should have received a copy of the GNU General Public License
15 // along with this program; if not, write to the Free Software
16 // Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
17
18 #ifndef CANVASTREEMODEL_H
19 #define CANVASTREEMODEL_H
20
21 #include <QAbstractItemModel>
22
23 #include "fgcanvasgroup.h"
24
25 class CanvasTreeModel : public QAbstractItemModel
26 {
27 public:
28 CanvasTreeModel(FGCanvasGroup* root);
29
30 FGCanvasElement* elementFromIndex(const QModelIndex& index) const;
31
32 protected:
33 virtual int rowCount(const QModelIndex &parent) const override;
34 virtual int columnCount(const QModelIndex &parent) const override;
35
36 virtual QVariant data(const QModelIndex &index, int role) const override;
37
38 virtual bool hasChildren(const QModelIndex &parent) const override;
39
40 virtual QModelIndex index(int row, int column, const QModelIndex &parent) const override;
41
42 virtual QModelIndex parent(const QModelIndex &child) const override;
43
44 virtual Qt::ItemFlags flags(const QModelIndex &index) const override;
45
46 virtual bool setData(const QModelIndex &index, const QVariant &value, int role) override;
47 private:
48 QModelIndex indexForGroup(FGCanvasGroup *group) const;
49
50 void onGroupChildAdded();
51 void onGroupChildRemoved(int index);
52
53 FGCanvasGroup* _root;
54 };
55
56 #endif // CANVASTREEMODEL_H