forked from len0rd/rockbox
Trying to implement QAbstractItemModel for parse trees, haven't got it working yet (current state will spawn an empty treeview window)
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26318 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
28a7c5d369
commit
565cd00963
6 changed files with 267 additions and 3 deletions
56
utils/themeeditor/parsetreenode.cpp
Normal file
56
utils/themeeditor/parsetreenode.cpp
Normal file
|
@ -0,0 +1,56 @@
|
|||
#include "parsetreenode.h"
|
||||
|
||||
ParseTreeNode::ParseTreeNode(struct skin_element* data, ParseTreeNode* parent,
|
||||
bool stop):
|
||||
parentLink(parent), element(data)
|
||||
{
|
||||
|
||||
if(stop)
|
||||
return;
|
||||
for(int i = 0; i < 5; i++)
|
||||
appendChild(new ParseTreeNode(data, this, true));
|
||||
}
|
||||
|
||||
ParseTreeNode::~ParseTreeNode()
|
||||
{
|
||||
qDeleteAll(children);
|
||||
}
|
||||
|
||||
void ParseTreeNode::appendChild(ParseTreeNode* child)
|
||||
{
|
||||
children.append(child);
|
||||
}
|
||||
|
||||
ParseTreeNode* ParseTreeNode::child(int row)
|
||||
{
|
||||
return children[row];
|
||||
}
|
||||
|
||||
int ParseTreeNode::childCount() const
|
||||
{
|
||||
return children.count();
|
||||
}
|
||||
|
||||
int ParseTreeNode::columnCount() const
|
||||
{
|
||||
return 2;
|
||||
}
|
||||
|
||||
QVariant ParseTreeNode::data(int column) const
|
||||
{
|
||||
if(column == 0)
|
||||
return element->type;
|
||||
else
|
||||
return element->line;
|
||||
}
|
||||
int ParseTreeNode::row() const
|
||||
{
|
||||
if(parentLink)
|
||||
return parentLink->children.indexOf(const_cast<ParseTreeNode*>(this));
|
||||
return 0;
|
||||
}
|
||||
|
||||
ParseTreeNode* ParseTreeNode::parent()
|
||||
{
|
||||
return parentLink;
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue