summaryrefslogtreecommitdiff
path: root/utils/themeeditor/parsetreemodel.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/themeeditor/parsetreemodel.cpp')
-rw-r--r--utils/themeeditor/parsetreemodel.cpp65
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
26ParseTreeModel::ParseTreeModel(char* wps, QObject* parent): 26ParseTreeModel::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
34ParseTreeModel::~ParseTreeModel() 34ParseTreeModel::~ParseTreeModel()
35{ 35{
36 delete root; 36 if(root)
37 delete root;
38 if(tree)
39 skin_free_tree(tree);
37} 40}
38 41
39QString genCode() 42QString ParseTreeModel::genCode()
40{ 43{
41 return QString(); 44 return root->genCode();
42} 45}
43 46
44/*
45QModelIndex ParseTreeModel::index(int row, int column, 47QModelIndex 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
65QModelIndex ParseTreeModel::parent(const QModelIndex &child) const 53QModelIndex 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
80int ParseTreeModel::rowCount(const QModelIndex &parent) const 58int 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
94int ParseTreeModel::columnCount(const QModelIndex &parent) const 63int ParseTreeModel::columnCount(const QModelIndex &parent) const
95{ 64{
96 return 2; 65 return 0;
97} 66}
98
99QVariant ParseTreeModel::data(const QModelIndex &index, int role) const 67QVariant 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*/