1
0
Fork 0
forked from len0rd/rockbox

Theme Editor: Working on the project viewer infrastructure

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26714 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Bieber 2010-06-09 07:51:22 +00:00
parent 6efc8d5bc1
commit ceddd2f1e8
8 changed files with 226 additions and 16 deletions

View file

@ -21,11 +21,12 @@
#include "projectmodel.h"
#include "projectfiles.h"
ProjectModel::ProjectModel(QObject *parent) :
ProjectModel::ProjectModel(QString config, QObject *parent) :
QAbstractItemModel(parent)
{
root = new ProjectRoot(config);
}
ProjectModel::~ProjectModel()
@ -59,7 +60,7 @@ QModelIndex ProjectModel::parent(const QModelIndex &child) const
ProjectNode* foundParent = static_cast<ProjectNode*>
(child.internalPointer())->parent();
if(foundParent == root)
if(foundParent == 0)
return QModelIndex();
return createIndex(foundParent->row(), 0, foundParent);
@ -104,7 +105,8 @@ QVariant ProjectModel::headerData(int col, Qt::Orientation orientation,
Qt::ItemFlags ProjectModel::flags(const QModelIndex &index) const
{
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
return static_cast<ProjectNode*>
(index.internalPointer())->flags(index.column());
}
bool ProjectModel::setData(const QModelIndex &index, const QVariant &value,
@ -112,3 +114,15 @@ bool ProjectModel::setData(const QModelIndex &index, const QVariant &value,
{
return true;
}
/* Constructor and destructor for the root class */
ProjectRoot::ProjectRoot(QString config)
{
children.append(new ProjectFiles(this));
}
ProjectRoot::~ProjectRoot()
{
for(int i = 0; i < children.count(); i++)
delete children[i];
}