-
Notifications
You must be signed in to change notification settings - Fork 0
/
treeitem.h
110 lines (76 loc) · 2.35 KB
/
treeitem.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
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
#ifndef TREEITEM_H_
#define TREEITEM_H_
#include <QAbstractItemModel>
#include <QModelIndex>
#include <QVariant>
#include "olaworker.h"
class TreeItemInterface {
public:
virtual ~TreeItemInterface() {}
virtual TreeItemInterface *parent() = 0;
virtual int childCount() const = 0;
virtual TreeItemInterface *child(int row) = 0;
virtual int columnCount() const = 0;
virtual QVariant data(int column) const = 0;
virtual int row() const = 0;
static const int kColumnCount;
};
class SourceTreeItem;
class UniverseTreeItem;
class RootTreeItem : public TreeItemInterface {
public:
~RootTreeItem();
TreeItemInterface* parent() { return NULL; }
void reset();
int childCount() const;
TreeItemInterface *child(int row);
int columnCount() const { return kColumnCount; }
QVariant data(int column) const;
int row() const;
int indexOf(const SourceTreeItem *item) const;
void insert(int i, SourceTreeItem *child);
void appendChild(SourceTreeItem *child);
SourceTreeItem *sourceAt(int i);
void Remove(int i);
private:
QList<SourceTreeItem*> children_;
};
class SourceTreeItem : public TreeItemInterface {
public:
SourceTreeItem(const E131Source &data, RootTreeItem *parent);
~SourceTreeItem();
TreeItemInterface* parent() { return parent_; }
int childCount() const;
TreeItemInterface *child(int row);
int columnCount() const;
QVariant data(int column) const;
int row() const;
int indexOf(const UniverseTreeItem *item) const;
void insert(int i, UniverseTreeItem *child);
void appendChild(UniverseTreeItem *child);
void Update(const E131Source &entry);
ola::acn::CID cid() const { return source_.cid; }
UniverseTreeItem *universeAt(int i);
void Remove(int i);
private:
RootTreeItem *parent_;
E131Source source_;
QVariant row_data_;
QList<UniverseTreeItem*> children_;
};
class UniverseTreeItem : public TreeItemInterface {
public:
UniverseTreeItem(uint16_t universe, SourceTreeItem *parent);
TreeItemInterface* parent() { return parent_; }
int childCount() const { return 0; }
TreeItemInterface *child(int row) { return NULL; }
int columnCount() const { return kColumnCount; }
QVariant data(int column) const;
int row() const;
uint16_t universe() const { return universe_id_; }
private:
SourceTreeItem *parent_;
uint16_t universe_id_;
QString universe_;
};
#endif // TREEITEM_H_