-
Notifications
You must be signed in to change notification settings - Fork 12
/
qtSDLTreeModel.h
57 lines (47 loc) · 1.78 KB
/
qtSDLTreeModel.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
#ifndef QTSDLTREEMODEL_H
#define QTSDLTREEMODEL_H
#include <QVector>
#include <QAbstractItemModel>
#include <auth/pnVaultNode.h>
#include <SDL/plSDLMgr.h>
class plStateDataRecord;
class plStateVariable;
class qtSDLTreeModel : public QAbstractItemModel
{
Q_OBJECT
private:
plResManager* resmgr;
plStateDataRecord* sdl;
enum ItemType { kSDR, kVar, kVal };
struct SDLModelIndex {
QModelIndex parent;
ItemType type;
int row, column;
union {
plStateDataRecord* sdr;
plStateVariable* sv;
void* raw;
} ptr;
bool operator==(const SDLModelIndex& other) const {
return parent == other.parent && type == other.type && row == other.row && column == other.column && ptr.raw == other.ptr.raw;
}
};
mutable QVector<SDLModelIndex> indices;
QModelIndex ICreateIndex(int row, int column, const QModelIndex& parent, void* ptr, ItemType type) const;
public:
explicit qtSDLTreeModel(QObject* parent, plVaultBlob blob, plSDLMgr* sdlmgr, plResManager* resmgr);
~qtSDLTreeModel();
QModelIndex index(int row, int column, const QModelIndex& parent) const;
QModelIndex parent(const QModelIndex &child) const;
int rowCount(const QModelIndex& parent) const;
int columnCount(const QModelIndex& parent) const;
QVariant data(const QModelIndex& index, int role = Qt::DisplayRole) const;
QVariant headerData(int section, Qt::Orientation orientation, int role) const;
Qt::ItemFlags flags(const QModelIndex &index) const;
bool setData(const QModelIndex &index, const QVariant &value, int role);
signals:
void dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
void sdlEdited(plStateDataRecord* sdl);
public slots:
};
#endif // QTSDLTREEMODEL_H