From e5a3ec2baf5bc57f93f5ea19fa9198e2a3e080db Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Wed, 2 Jun 2010 20:36:30 +0000 Subject: Changed build subdirectory git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26492 a1c6a512-1295-4272-9138-f99709370657 --- utils/themeeditor/parsetreemodel.cpp | 39 +++++++++++++++++++++++++++++++++++- 1 file changed, 38 insertions(+), 1 deletion(-) (limited to 'utils/themeeditor/parsetreemodel.cpp') 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(); -- cgit v1.2.3