diff options
author | Robert Bieber <robby@bieberphoto.com> | 2010-05-26 21:13:14 +0000 |
---|---|---|
committer | Robert Bieber <robby@bieberphoto.com> | 2010-05-26 21:13:14 +0000 |
commit | 565cd0096393dcd3a33b546d76714c64c2c786e3 (patch) | |
tree | 2b1882d987048bb00cd394a50f1cb24585b08af5 /utils/themeeditor/parsetreenode.cpp | |
parent | 28a7c5d3692e59b5c80a9f713cf931b6453cb1ca (diff) | |
download | rockbox-565cd0096393dcd3a33b546d76714c64c2c786e3.tar.gz rockbox-565cd0096393dcd3a33b546d76714c64c2c786e3.zip |
Trying to implement QAbstractItemModel for parse trees, haven't got it working yet (current state will spawn an empty treeview window)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26318 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor/parsetreenode.cpp')
-rw-r--r-- | utils/themeeditor/parsetreenode.cpp | 56 |
1 files changed, 56 insertions, 0 deletions
diff --git a/utils/themeeditor/parsetreenode.cpp b/utils/themeeditor/parsetreenode.cpp new file mode 100644 index 0000000000..97cb559906 --- /dev/null +++ b/utils/themeeditor/parsetreenode.cpp | |||
@@ -0,0 +1,56 @@ | |||
1 | #include "parsetreenode.h" | ||
2 | |||
3 | ParseTreeNode::ParseTreeNode(struct skin_element* data, ParseTreeNode* parent, | ||
4 | bool stop): | ||
5 | parentLink(parent), element(data) | ||
6 | { | ||
7 | |||
8 | if(stop) | ||
9 | return; | ||
10 | for(int i = 0; i < 5; i++) | ||
11 | appendChild(new ParseTreeNode(data, this, true)); | ||
12 | } | ||
13 | |||
14 | ParseTreeNode::~ParseTreeNode() | ||
15 | { | ||
16 | qDeleteAll(children); | ||
17 | } | ||
18 | |||
19 | void ParseTreeNode::appendChild(ParseTreeNode* child) | ||
20 | { | ||
21 | children.append(child); | ||
22 | } | ||
23 | |||
24 | ParseTreeNode* ParseTreeNode::child(int row) | ||
25 | { | ||
26 | return children[row]; | ||
27 | } | ||
28 | |||
29 | int ParseTreeNode::childCount() const | ||
30 | { | ||
31 | return children.count(); | ||
32 | } | ||
33 | |||
34 | int ParseTreeNode::columnCount() const | ||
35 | { | ||
36 | return 2; | ||
37 | } | ||
38 | |||
39 | QVariant ParseTreeNode::data(int column) const | ||
40 | { | ||
41 | if(column == 0) | ||
42 | return element->type; | ||
43 | else | ||
44 | return element->line; | ||
45 | } | ||
46 | int ParseTreeNode::row() const | ||
47 | { | ||
48 | if(parentLink) | ||
49 | return parentLink->children.indexOf(const_cast<ParseTreeNode*>(this)); | ||
50 | return 0; | ||
51 | } | ||
52 | |||
53 | ParseTreeNode* ParseTreeNode::parent() | ||
54 | { | ||
55 | return parentLink; | ||
56 | } | ||