diff options
author | Robert Bieber <robby@bieberphoto.com> | 2010-05-30 01:20:05 +0000 |
---|---|---|
committer | Robert Bieber <robby@bieberphoto.com> | 2010-05-30 01:20:05 +0000 |
commit | 9843626b6941f63b964c3352e996032247115aad (patch) | |
tree | 157a0a54d14c403e859fe44c76ecb1fdb6f98bfb /utils/themeeditor/parsetreemodel.cpp | |
parent | cc07d688668d6e8ec3c6bb66fe2e36462ef6c8b7 (diff) | |
download | rockbox-9843626b6941f63b964c3352e996032247115aad.tar.gz rockbox-9843626b6941f63b964c3352e996032247115aad.zip |
Themeditor: Got the ParseTreeNode class in good shape, preparing to start on ParseTreeModel
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26400 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor/parsetreemodel.cpp')
-rw-r--r-- | utils/themeeditor/parsetreemodel.cpp | 65 |
1 files changed, 14 insertions, 51 deletions
diff --git a/utils/themeeditor/parsetreemodel.cpp b/utils/themeeditor/parsetreemodel.cpp index c99f166c41..4c46320bb3 100644 --- a/utils/themeeditor/parsetreemodel.cpp +++ b/utils/themeeditor/parsetreemodel.cpp | |||
@@ -23,85 +23,48 @@ | |||
23 | #include "parsetreemodel.h" | 23 | #include "parsetreemodel.h" |
24 | #include <QObject> | 24 | #include <QObject> |
25 | 25 | ||
26 | ParseTreeModel::ParseTreeModel(char* wps, QObject* parent): | 26 | ParseTreeModel::ParseTreeModel(char* document, QObject* parent): |
27 | QAbstractItemModel(parent) | 27 | QAbstractItemModel(parent) |
28 | { | 28 | { |
29 | this->tree = skin_parse(wps); | 29 | this->tree = skin_parse(document); |
30 | this->root = new ParseTreeNode(tree, 0); | 30 | this->root = new ParseTreeNode(tree); |
31 | } | 31 | } |
32 | 32 | ||
33 | 33 | ||
34 | ParseTreeModel::~ParseTreeModel() | 34 | ParseTreeModel::~ParseTreeModel() |
35 | { | 35 | { |
36 | delete root; | 36 | if(root) |
37 | delete root; | ||
38 | if(tree) | ||
39 | skin_free_tree(tree); | ||
37 | } | 40 | } |
38 | 41 | ||
39 | QString genCode() | 42 | QString ParseTreeModel::genCode() |
40 | { | 43 | { |
41 | return QString(); | 44 | return root->genCode(); |
42 | } | 45 | } |
43 | 46 | ||
44 | /* | ||
45 | QModelIndex ParseTreeModel::index(int row, int column, | 47 | QModelIndex ParseTreeModel::index(int row, int column, |
46 | const QModelIndex& parent) const | 48 | const QModelIndex& parent) const |
47 | { | 49 | { |
48 | if(!hasIndex(row, column, parent)) | 50 | return QModelIndex(); |
49 | return QModelIndex(); | ||
50 | |||
51 | ParseTreeNode* parentLookup; | ||
52 | |||
53 | if(!parent.isValid()) | ||
54 | parentLookup = root; | ||
55 | else | ||
56 | parentLookup = static_cast<ParseTreeNode*>(parent.internalPointer()); | ||
57 | |||
58 | ParseTreeNode* childLookup = parentLookup->child(row); | ||
59 | if(childLookup) | ||
60 | return createIndex(row, column, childLookup); | ||
61 | else | ||
62 | return QModelIndex(); | ||
63 | } | 51 | } |
64 | 52 | ||
65 | QModelIndex ParseTreeModel::parent(const QModelIndex &child) const | 53 | QModelIndex ParseTreeModel::parent(const QModelIndex &child) const |
66 | { | 54 | { |
67 | if(!child.isValid()) | 55 | return QModelIndex(); |
68 | return QModelIndex(); | ||
69 | |||
70 | ParseTreeNode* childLookup = static_cast<ParseTreeNode*> | ||
71 | (child.internalPointer()); | ||
72 | ParseTreeNode* parentLookup = childLookup->parent(); | ||
73 | |||
74 | if(parentLookup == root) | ||
75 | return QModelIndex(); | ||
76 | |||
77 | return createIndex(parentLookup->row(), 0, parentLookup); | ||
78 | } | 56 | } |
79 | 57 | ||
80 | int ParseTreeModel::rowCount(const QModelIndex &parent) const | 58 | int ParseTreeModel::rowCount(const QModelIndex &parent) const |
81 | { | 59 | { |
82 | ParseTreeNode* parentLookup; | 60 | return 0; |
83 | if(parent.column() > 0) | ||
84 | return 0; | ||
85 | |||
86 | if(!parent.isValid()) | ||
87 | parentLookup = root; | ||
88 | else | ||
89 | parentLookup = static_cast<ParseTreeNode*>(parent.internalPointer()); | ||
90 | |||
91 | return parentLookup->childCount(); | ||
92 | } | 61 | } |
93 | 62 | ||
94 | int ParseTreeModel::columnCount(const QModelIndex &parent) const | 63 | int ParseTreeModel::columnCount(const QModelIndex &parent) const |
95 | { | 64 | { |
96 | return 2; | 65 | return 0; |
97 | } | 66 | } |
98 | |||
99 | QVariant ParseTreeModel::data(const QModelIndex &index, int role) const | 67 | QVariant ParseTreeModel::data(const QModelIndex &index, int role) const |
100 | { | 68 | { |
101 | if(!index.isValid() || role != Qt::DisplayRole) | 69 | return QVariant(); |
102 | return QVariant(); | ||
103 | |||
104 | ParseTreeNode* item = static_cast<ParseTreeNode*>(index.internalPointer()); | ||
105 | return item->data(index.column()); | ||
106 | } | 70 | } |
107 | */ | ||