1
0
Fork 0
forked from len0rd/rockbox

Theme Editor: Added project settings to the project panel view

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26737 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Bieber 2010-06-10 07:51:21 +00:00
parent cb26aecf92
commit c3a698e46a
6 changed files with 199 additions and 11 deletions

View file

@ -111,14 +111,7 @@
<widget class="QWidget" name="dockWidgetContents_2">
<layout class="QVBoxLayout" name="verticalLayout_4">
<item>
<widget class="QTreeView" name="projectTree">
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
<attribute name="headerVisible">
<bool>false</bool>
</attribute>
</widget>
<widget class="QTreeView" name="projectTree"/>
</item>
</layout>
</widget>

View file

@ -22,6 +22,7 @@
#include "projectmodel.h"
#include "projectfiles.h"
#include "projectsettings.h"
#include "editorwindow.h"
#include <QFile>
@ -173,6 +174,7 @@ ProjectRoot::ProjectRoot(QString config, ProjectModel* model)
/* Showing the files */
children.append(new ProjectFiles(settings, model, this));
children.append(new ProjectSettings(settings, model, this));
}

View file

@ -32,7 +32,7 @@ class ProjectModel : public QAbstractItemModel
{
Q_OBJECT
public:
static const int numColumns = 1;
static const int numColumns = 2;
static QString fileFilter()
{

View file

@ -0,0 +1,120 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2010 Robert Bieber
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#include "projectsettings.h"
ProjectSettings::ProjectSettings(QHash<QString, QString>& settings,
ProjectModel* model, ProjectNode* parent)
: parentLink(parent)
{
QHash<QString, QString>::iterator i;
for(i = settings.begin(); i != settings.end(); i++)
{
QPair<QString, QString> value(i.key(), i.value());
children.append(new ProjectSetting(value, model, this));
}
}
ProjectSettings::~ProjectSettings()
{
for(int i = 0; i < children.count(); i++)
delete children[i];
}
ProjectNode* ProjectSettings::parent() const
{
return parentLink;
}
ProjectNode* ProjectSettings::child(int row) const
{
if(row >= 0 && row < children.count())
return children[row];
return 0;
}
int ProjectSettings::numChildren() const
{
return children.count();
}
int ProjectSettings::row() const
{
return parentLink->indexOf(const_cast<ProjectSettings*>(this));
}
QVariant ProjectSettings::data(int column) const
{
if(column == 0)
return QObject::tr("Project Settings");
else
return QVariant();
}
Qt::ItemFlags ProjectSettings::flags(int column) const
{
if(column == 0)
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
else
return 0;
}
void ProjectSettings::activated()
{
}
/* Project File functions */
ProjectSetting::ProjectSetting(QPair<QString, QString> setting,
ProjectModel* model, ProjectNode* parent)
:parentLink(parent), setting(setting)
{
this->model = model;
}
ProjectSetting::~ProjectSetting()
{
}
QVariant ProjectSetting::data(int column) const
{
if(column == 0)
return setting.first;
else if(column == 1)
return setting.second;
else
return QVariant();
}
Qt::ItemFlags ProjectSetting::flags(int column) const
{
if(column == 0 || column == 1)
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
else
return 0;
}
void ProjectSetting::activated()
{
}

View file

@ -0,0 +1,71 @@
/***************************************************************************
* __________ __ ___.
* Open \______ \ ____ ____ | | _\_ |__ _______ ___
* Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
* Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
* Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
* \/ \/ \/ \/ \/
* $Id$
*
* Copyright (C) 2010 Robert Bieber
*
* This program is free software; you can redistribute it and/or
* modify it under the terms of the GNU General Public License
* as published by the Free Software Foundation; either version 2
* of the License, or (at your option) any later version.
*
* This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
* KIND, either express or implied.
*
****************************************************************************/
#ifndef PROJCETSETTINGS_H
#define PROJECTSETTINGS_H
#include "projectmodel.h"
#include <QHash>
class ProjectSettings : public ProjectNode
{
public:
ProjectSettings(QHash<QString, QString>& settings, ProjectModel* model,
ProjectNode* parent);
virtual ~ProjectSettings();
virtual ProjectNode* parent() const;
virtual ProjectNode* child(int row) const;
virtual int numChildren() const;
virtual int row() const;
virtual QVariant data(int column) const;
virtual Qt::ItemFlags flags(int column) const;
virtual void activated();
private:
ProjectNode* parentLink;
};
/* A class to enumerate a single file */
class ProjectSetting: public ProjectNode
{
public:
ProjectSetting(QPair<QString, QString> setting, ProjectModel* model,
ProjectNode* parent);
virtual ~ProjectSetting();
virtual ProjectNode* parent() const{ return parentLink; }
virtual ProjectNode* child(int row) const{ return 0; }
virtual int numChildren() const{ return 0; }
virtual int row() const{
return parentLink->indexOf(const_cast<ProjectSetting*>(this));
}
virtual QVariant data(int column) const;
virtual Qt::ItemFlags flags(int column) const;
virtual void activated();
private:
ProjectNode* parentLink;
QPair<QString, QString> setting;
};
#endif // PROJECTSETTINGS_H

View file

@ -17,7 +17,8 @@ HEADERS += tag_table.h \
preferencesdialog.h \
codeeditor.h \
projectmodel.h \
projectfiles.h
projectfiles.h \
projectsettings.h
SOURCES += tag_table.c \
skin_parser.c \
skin_scan.c \
@ -31,7 +32,8 @@ SOURCES += tag_table.c \
preferencesdialog.cpp \
codeeditor.cpp \
projectmodel.cpp \
projectfiles.cpp
projectfiles.cpp \
projectsettings.cpp
OTHER_FILES += README \
resources/windowicon.png \
resources/appicon.xcf \