summaryrefslogtreecommitdiff
path: root/utils/themeeditor/parsetreemodel.cpp
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-06-02 20:36:30 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-06-02 20:36:30 +0000
commite5a3ec2baf5bc57f93f5ea19fa9198e2a3e080db (patch)
tree68002e6e06420e7b6453cc00a8f049114b19a721 /utils/themeeditor/parsetreemodel.cpp
parent87174d83fdde79a70bc3daad20729df585b7bbff (diff)
downloadrockbox-e5a3ec2baf5bc57f93f5ea19fa9198e2a3e080db.tar.gz
rockbox-e5a3ec2baf5bc57f93f5ea19fa9198e2a3e080db.zip
Changed build subdirectory
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26492 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor/parsetreemodel.cpp')
-rw-r--r--utils/themeeditor/parsetreemodel.cpp39
1 files changed, 38 insertions, 1 deletions
diff --git a/utils/themeeditor/parsetreemodel.cpp b/utils/themeeditor/parsetreemodel.cpp
index 9faa9ea560..918903bb68 100644
--- a/utils/themeeditor/parsetreemodel.cpp
+++ b/utils/themeeditor/parsetreemodel.cpp
@@ -31,7 +31,11 @@ ParseTreeModel::ParseTreeModel(const char* document, QObject* parent):
31 QAbstractItemModel(parent) 31 QAbstractItemModel(parent)
32{ 32{
33 this->tree = skin_parse(document); 33 this->tree = skin_parse(document);
34 this->root = new ParseTreeNode(tree); 34
35 if(tree)
36 this->root = new ParseTreeNode(tree);
37 else
38 this->root = 0;
35} 39}
36 40
37 41
@@ -48,6 +52,36 @@ QString ParseTreeModel::genCode()
48 return root->genCode(); 52 return root->genCode();
49} 53}
50 54
55bool ParseTreeModel::changeTree(const char *document)
56{
57 struct skin_element* test = skin_parse(document);
58
59 if(!test)
60 return false;
61
62 ParseTreeNode* temp = new ParseTreeNode(test);
63 if(root && temp->genHash() == root->genHash())
64 {
65 delete temp;
66 return true;
67 }
68
69 if(root)
70 {
71 emit beginRemoveRows(QModelIndex(), 0, root->numChildren() - 1);
72 delete root;
73 emit endRemoveRows();
74 }
75
76 root = temp;
77
78 emit beginInsertRows(QModelIndex(), 0, temp->numChildren() - 1);
79 emit endInsertRows();
80
81 return true;
82
83}
84
51QModelIndex ParseTreeModel::index(int row, int column, 85QModelIndex ParseTreeModel::index(int row, int column,
52 const QModelIndex& parent) const 86 const QModelIndex& parent) const
53{ 87{
@@ -83,6 +117,9 @@ QModelIndex ParseTreeModel::parent(const QModelIndex &child) const
83 117
84int ParseTreeModel::rowCount(const QModelIndex &parent) const 118int ParseTreeModel::rowCount(const QModelIndex &parent) const
85{ 119{
120 if(!root)
121 return 0;
122
86 if(!parent.isValid()) 123 if(!parent.isValid())
87 return root->numChildren(); 124 return root->numChildren();
88 125