forked from OpenDDS/OpenDDS
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathMonitorDataModel.h
More file actions
210 lines (155 loc) · 4.98 KB
/
Copy pathMonitorDataModel.h
File metadata and controls
210 lines (155 loc) · 4.98 KB
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
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
/*
*
*
* Distributed under the OpenDDS License.
* See: http://www.opendds.org/license.html
*/
#ifndef MONITORDATAMODEL_H
#define MONITORDATAMODEL_H
// Tell GCC to ignore implicitly declared copy methods as long as
// Qt is not compliant.
#ifdef __GNUC__
# pragma GCC diagnostic push
# pragma GCC diagnostic ignored "-Wdeprecated-copy"
#endif
#include <QtCore/QAbstractItemModel>
#ifdef __GNUC__
# pragma GCC diagnostic pop
#endif
#include <vector>
namespace Monitor {
class TreeNode;
/**
* @class MonitorDataModel
*
* @brief Interface to a model encapsulating repository data.
*
* This class provides the interface for a view to interact with
* encapsulated data of a repository model.
*/
class MonitorDataModel : public QAbstractItemModel {
Q_OBJECT
public:
/**
* @brief Construct with an optional parent link.
*
* @param parent link to parent object of this one
*/
MonitorDataModel( QObject* parent = 0);
virtual ~MonitorDataModel();
/* Exposing data from the model */
/// Obtain an index from a node.
QModelIndex index( TreeNode* node, int column) const;
/// Obtain a node from an index.
TreeNode* getNode( const QModelIndex &index, bool defaultToRoot = true) const;
/* Model update methods. */
/// Change to a new tree of data.
void newRoot( TreeNode* root);
/// Data values have changed in a single node, update the view.
void updated( TreeNode* node, int column);
/// Data values have changed in a range of nodes, update the view.
void updated( TreeNode* left, int lcol, TreeNode* right, int rcol);
/// Underlying model has changed, update the layout.
void changed();
/// Add a new node as a new row of data.
void addData( int row, QList< QVariant> list, const QModelIndex& parent);
//
// QAbstractModel interfaces.
//
virtual QModelIndex index(
int row,
int column,
const QModelIndex& parent = QModelIndex()
) const;
virtual QModelIndex parent( const QModelIndex& index) const;
/* Readonly interface methods */
virtual QVariant data( const QModelIndex& index, int role) const;
virtual Qt::ItemFlags flags( const QModelIndex& index) const;
virtual QVariant headerData(
int section,
Qt::Orientation orientation,
int role = Qt::DisplayRole
) const;
virtual int rowCount( const QModelIndex& parent = QModelIndex()) const;
virtual int columnCount( const QModelIndex& parent = QModelIndex()) const;
/* Editable interface methods */
virtual bool setData(
const QModelIndex& index,
const QVariant& value,
int role = Qt::EditRole
);
virtual bool setHeaderData(
int section,
Qt::Orientation orientation,
const QVariant& value,
int role = Qt::EditRole
);
/* Resizable interface methods */
virtual bool insertRows(
int row,
int count,
const QModelIndex& parent = QModelIndex()
);
virtual bool removeRows(
int row,
int count,
const QModelIndex& parent = QModelIndex()
);
virtual bool insertColumns(
int column,
int count,
const QModelIndex& parent = QModelIndex()
);
virtual bool removeColumns(
int column,
int count,
const QModelIndex& parent = QModelIndex()
);
/* Sorting */
virtual void sort(
int column,
Qt::SortOrder order = Qt::AscendingOrder
);
void doSort(
int column,
Qt::SortOrder order = Qt::AscendingOrder,
const QModelIndex& index = QModelIndex()
);
/* Drag and drop support */
/* Also requires insert rows/columns, remove rows/columns and setData */
// Drag
virtual QMimeData* mimeData( const QModelIndexList& indexes) const;
// Drop
virtual bool setItemData(
const QModelIndex& index,
const QMap<int, QVariant>& roles
);
virtual Qt::DropActions supportedDropActions() const;
virtual QStringList mimeTypes() const;
virtual bool dropMimeData(
const QMimeData* data,
Qt::DropAction action,
int row,
int column,
const QModelIndex& parent
);
virtual bool removeRow(
int row,
const QModelIndex& parent = QModelIndex()
);
virtual bool removeColumn(
int column,
const QModelIndex& parent = QModelIndex()
);
/* Optimization methods */
virtual bool hasChildren(
const QModelIndex& parent = QModelIndex()
) const;
virtual bool canFetchMore( const QModelIndex& parent) const;
virtual void fetchMore( const QModelIndex& parent);
private:
/// Root node of the tree.
TreeNode* root_;
};
} // End of namespace Monitor
#endif /* MONITORDATAMODEL_H */