summaryrefslogtreecommitdiffstats
path: root/utils/themeeditor/parsetreemodel.cpp
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-05-30 01:20:05 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-05-30 01:20:05 +0000
commit9843626b6941f63b964c3352e996032247115aad (patch)
tree157a0a54d14c403e859fe44c76ecb1fdb6f98bfb /utils/themeeditor/parsetreemodel.cpp
parentcc07d688668d6e8ec3c6bb66fe2e36462ef6c8b7 (diff)
downloadrockbox-9843626b6941f63b964c3352e996032247115aad.tar.gz
rockbox-9843626b6941f63b964c3352e996032247115aad.tar.bz2
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.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 @@
#include "parsetreemodel.h"
#include <QObject>
-ParseTreeModel::ParseTreeModel(char* wps, QObject* parent):
+ParseTreeModel::ParseTreeModel(char* document, QObject* parent):
QAbstractItemModel(parent)
{
- this->tree = skin_parse(wps);
- this->root = new ParseTreeNode(tree, 0);
+ this->tree = skin_parse(document);
+ this->root = new ParseTreeNode(tree);
}
ParseTreeModel::~ParseTreeModel()
{
- delete root;
+ if(root)
+ delete root;
+ if(tree)
+ skin_free_tree(tree);
}
-QString genCode()
+QString ParseTreeModel::genCode()
{
- return QString();
+ return root->genCode();
}
-/*
QModelIndex ParseTreeModel::index(int row, int column,
const QModelIndex& parent) const
{
- if(!hasIndex(row, column, parent))
- return QModelIndex();
-
- ParseTreeNode* parentLookup;
-
- if(!parent.isValid())
- parentLookup = root;
- else
- parentLookup = static_cast<ParseTreeNode*>(parent.internalPointer());
-
- ParseTreeNode* childLookup = parentLookup->child(row);
- if(childLookup)
- return createIndex(row, column, childLookup);
- else
- return QModelIndex();
+ return QModelIndex();
}
QModelIndex ParseTreeModel::parent(const QModelIndex &child) const
{
- if(!child.isValid())
- return QModelIndex();
-
- ParseTreeNode* childLookup = static_cast<ParseTreeNode*>
- (child.internalPointer());
- ParseTreeNode* parentLookup = childLookup->parent();
-
- if(parentLookup == root)
- return QModelIndex();
-
- return createIndex(parentLookup->row(), 0, parentLookup);
+ return QModelIndex();
}
int ParseTreeModel::rowCount(const QModelIndex &parent) const
{
- ParseTreeNode* parentLookup;
- if(parent.column() > 0)
- return 0;
-
- if(!parent.isValid())
- parentLookup = root;
- else
- parentLookup = static_cast<ParseTreeNode*>(parent.internalPointer());
-
- return parentLookup->childCount();
+ return 0;
}
int ParseTreeModel::columnCount(const QModelIndex &parent) const
{
- return 2;
+ return 0;
}
-
QVariant ParseTreeModel::data(const QModelIndex &index, int role) const
{
- if(!index.isValid() || role != Qt::DisplayRole)
- return QVariant();
-
- ParseTreeNode* item = static_cast<ParseTreeNode*>(index.internalPointer());
- return item->data(index.column());
+ return QVariant();
}
-*/