summaryrefslogtreecommitdiffstats
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.tar.bz2
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):
QAbstractItemModel(parent)
{
this->tree = skin_parse(document);
- this->root = new ParseTreeNode(tree);
+
+ if(tree)
+ this->root = new ParseTreeNode(tree);
+ else
+ this->root = 0;
}
@@ -48,6 +52,36 @@ QString ParseTreeModel::genCode()
return root->genCode();
}
+bool ParseTreeModel::changeTree(const char *document)
+{
+ struct skin_element* test = skin_parse(document);
+
+ if(!test)
+ return false;
+
+ ParseTreeNode* temp = new ParseTreeNode(test);
+ if(root && temp->genHash() == root->genHash())
+ {
+ delete temp;
+ return true;
+ }
+
+ if(root)
+ {
+ emit beginRemoveRows(QModelIndex(), 0, root->numChildren() - 1);
+ delete root;
+ emit endRemoveRows();
+ }
+
+ root = temp;
+
+ emit beginInsertRows(QModelIndex(), 0, temp->numChildren() - 1);
+ emit endInsertRows();
+
+ return true;
+
+}
+
QModelIndex ParseTreeModel::index(int row, int column,
const QModelIndex& parent) const
{
@@ -83,6 +117,9 @@ QModelIndex ParseTreeModel::parent(const QModelIndex &child) const
int ParseTreeModel::rowCount(const QModelIndex &parent) const
{
+ if(!root)
+ return 0;
+
if(!parent.isValid())
return root->numChildren();