From 9f2e1b1e1a1dae857fe74728b91c5393d5f1c283 Mon Sep 17 00:00:00 2001 From: Robert Bieber Date: Sun, 30 May 2010 01:47:35 +0000 Subject: Theme Editor: Got a barely functional treeview in place git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26401 a1c6a512-1295-4272-9138-f99709370657 --- utils/themeeditor/parsetreemodel.cpp | 45 ++++++++++++++++++++++++++++++++---- 1 file changed, 40 insertions(+), 5 deletions(-) (limited to 'utils/themeeditor/parsetreemodel.cpp') diff --git a/utils/themeeditor/parsetreemodel.cpp b/utils/themeeditor/parsetreemodel.cpp index 4c46320bb3..08f10615ef 100644 --- a/utils/themeeditor/parsetreemodel.cpp +++ b/utils/themeeditor/parsetreemodel.cpp @@ -47,24 +47,59 @@ QString ParseTreeModel::genCode() QModelIndex ParseTreeModel::index(int row, int column, const QModelIndex& parent) const { - return QModelIndex(); + if(!hasIndex(row, column, parent)) + return QModelIndex(); + + ParseTreeNode* foundParent; + + if(parent.isValid()) + foundParent = static_cast(parent.internalPointer()); + else + foundParent = root; + + if(row < foundParent->numChildren() && row >= 0) + return createIndex(row, column, foundParent->child(row)); + else + return QModelIndex(); } QModelIndex ParseTreeModel::parent(const QModelIndex &child) const { - return QModelIndex(); + if(!child.isValid()) + return QModelIndex(); + + ParseTreeNode* foundParent = static_cast + (child.internalPointer())->getParent(); + + if(foundParent == root) + return QModelIndex(); + + return createIndex(foundParent->getRow(), 0, foundParent); } int ParseTreeModel::rowCount(const QModelIndex &parent) const { - return 0; + if(!parent.isValid()) + return root->numChildren(); + + if(parent.column() > 0) + return 0; + + return static_cast(parent.internalPointer())->numChildren(); } int ParseTreeModel::columnCount(const QModelIndex &parent) const { - return 0; + return 3; } QVariant ParseTreeModel::data(const QModelIndex &index, int role) const { - return QVariant(); + if(!index.isValid()) + return QVariant(); + + if(role != Qt::DisplayRole) + return QVariant(); + + return static_cast(index.internalPointer())-> + data(index.column()); } -- cgit v1.2.3