-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathTreeModel.h
81 lines (74 loc) · 1.93 KB
/
TreeModel.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
class TreeModel;
#ifndef TREEMODEL_H
#define TREEMODEL_H
#include <QAbstractItemModel>
#include <QModelIndex>
#include <QVariant>
#include "Graph.h"
#include "Model.h"
#include "TreeItem.h"
/**
* Class representing model of the TreeView.
*/
class TreeModel : public QAbstractItemModel
{
Q_OBJECT
public:
/**
* Creates the model for the treeview.
*/
TreeModel( QObject *parent, Model * mod, QString Name);
/**
* Destructor for the model of the treeview.
*/
~TreeModel();
/**
* Returns data (text) from the index.
*/
QVariant data(const QModelIndex &index, int role) const;
/**
* Returns flags for the index.
*/
Qt::ItemFlags flags(const QModelIndex &index) const;
/**
* Returns data for headers of the view.
*/
QVariant headerData(int section, Qt::Orientation orientation,
int role = Qt::DisplayRole) const;
/**
* Returns index fromt he current row and column.
*/
QModelIndex index(int row, int column,
const QModelIndex &parent = QModelIndex()) const;
/**
* Returns parent of the given item.
* @param child Item, of which the parent is needed.
*/
QModelIndex parent(const QModelIndex &child) const;
/**
* Returns number of childitems of the current item.
*/
int rowCount(const QModelIndex &parent = QModelIndex()) const;
/**
* Returns number of colums in the view.
*/
int columnCount(const QModelIndex &parent = QModelIndex()) const;
/**
* Returns graphics item of the item at the given index, or of it's parent (recursively).
*/
QGraphicsItem * getItemOrParent( QModelIndex index);
/**
* Model of the project.
*/
Model * mod;
private:
/**
* Name of the graph, which is represented.
*/
QString graphName;
/**
* Root item of the view.
*/
TreeItem *rootItem;
};
#endif // TREEMODEL_H