forked from len0rd/rockbox
Theme Editor: Stripped out the sub-classes for ProjectModel and turned ProjectModel into a list model, also replaced the project tree view with a list view
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26839 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
4b0c1cf23b
commit
046832c821
9 changed files with 56 additions and 580 deletions
|
@ -275,7 +275,6 @@ void EditorWindow::openProject()
|
||||||
|
|
||||||
project = new ProjectModel(fileName, this);
|
project = new ProjectModel(fileName, this);
|
||||||
ui->projectTree->setModel(project);
|
ui->projectTree->setModel(project);
|
||||||
ui->projectTree->expandAll();
|
|
||||||
|
|
||||||
QObject::connect(ui->projectTree, SIGNAL(activated(QModelIndex)),
|
QObject::connect(ui->projectTree, SIGNAL(activated(QModelIndex)),
|
||||||
project, SLOT(activated(QModelIndex)));
|
project, SLOT(activated(QModelIndex)));
|
||||||
|
|
|
@ -111,7 +111,7 @@
|
||||||
<widget class="QWidget" name="dockWidgetContents_2">
|
<widget class="QWidget" name="dockWidgetContents_2">
|
||||||
<layout class="QVBoxLayout" name="verticalLayout_4">
|
<layout class="QVBoxLayout" name="verticalLayout_4">
|
||||||
<item>
|
<item>
|
||||||
<widget class="QTreeView" name="projectTree"/>
|
<widget class="QListView" name="projectTree"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
|
|
@ -1,133 +0,0 @@
|
||||||
/***************************************************************************
|
|
||||||
* __________ __ ___.
|
|
||||||
* 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 "projectfiles.h"
|
|
||||||
|
|
||||||
ProjectFiles::ProjectFiles(QHash<QString, QString>& settings,
|
|
||||||
ProjectModel* model, ProjectNode* parent)
|
|
||||||
: parentLink(parent)
|
|
||||||
{
|
|
||||||
base = settings.value("themebase");
|
|
||||||
|
|
||||||
QList<QString> keys;
|
|
||||||
keys.append("wps");
|
|
||||||
keys.append("rwps");
|
|
||||||
keys.append("sbs");
|
|
||||||
keys.append("rsbs");
|
|
||||||
keys.append("fms");
|
|
||||||
keys.append("rfms");
|
|
||||||
|
|
||||||
for(int i = 0; i < keys.count(); i++)
|
|
||||||
{
|
|
||||||
QString file = settings.value(keys[i], "");
|
|
||||||
if(file != "" && file != "-")
|
|
||||||
{
|
|
||||||
file.replace("/.rockbox/", "");
|
|
||||||
children.append(new ProjectFile(file, model, this));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
ProjectFiles::~ProjectFiles()
|
|
||||||
{
|
|
||||||
for(int i = 0; i < children.count(); i++)
|
|
||||||
delete children[i];
|
|
||||||
}
|
|
||||||
|
|
||||||
ProjectNode* ProjectFiles::parent() const
|
|
||||||
{
|
|
||||||
return parentLink;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProjectNode* ProjectFiles::child(int row) const
|
|
||||||
{
|
|
||||||
if(row >= 0 && row < children.count())
|
|
||||||
return children[row];
|
|
||||||
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
int ProjectFiles::numChildren() const
|
|
||||||
{
|
|
||||||
return children.count();
|
|
||||||
}
|
|
||||||
|
|
||||||
int ProjectFiles::row() const
|
|
||||||
{
|
|
||||||
return parentLink->indexOf(const_cast<ProjectFiles*>(this));
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant ProjectFiles::data(int column) const
|
|
||||||
{
|
|
||||||
if(column == 0)
|
|
||||||
return QObject::tr("Project Files");
|
|
||||||
else
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
Qt::ItemFlags ProjectFiles::flags(int column) const
|
|
||||||
{
|
|
||||||
if(column == 0)
|
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectFiles::activated()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Project File functions */
|
|
||||||
ProjectFile::ProjectFile(QString file, ProjectModel* model,
|
|
||||||
ProjectNode* parent)
|
|
||||||
:parentLink(parent), file(file)
|
|
||||||
{
|
|
||||||
this->model = model;
|
|
||||||
}
|
|
||||||
|
|
||||||
ProjectFile::~ProjectFile()
|
|
||||||
{
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant ProjectFile::data(int column) const
|
|
||||||
{
|
|
||||||
if(column == 0)
|
|
||||||
return file;
|
|
||||||
else
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
Qt::ItemFlags ProjectFile::flags(int column) const
|
|
||||||
{
|
|
||||||
if(column == 0)
|
|
||||||
return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectFile::activated()
|
|
||||||
{
|
|
||||||
QString base = dynamic_cast<ProjectFiles*>(parentLink)->getBase();
|
|
||||||
model->loadFile(base + "/" + file);
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,73 +0,0 @@
|
||||||
/***************************************************************************
|
|
||||||
* __________ __ ___.
|
|
||||||
* 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 PROJECTFILES_H
|
|
||||||
#define PROJECTFILES_H
|
|
||||||
|
|
||||||
#include "projectmodel.h"
|
|
||||||
#include <QHash>
|
|
||||||
|
|
||||||
class ProjectFiles : public ProjectNode
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ProjectFiles(QHash<QString, QString>& settings, ProjectModel* model,
|
|
||||||
ProjectNode* parent);
|
|
||||||
virtual ~ProjectFiles();
|
|
||||||
|
|
||||||
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();
|
|
||||||
|
|
||||||
QString getBase(){ return base; }
|
|
||||||
|
|
||||||
private:
|
|
||||||
ProjectNode* parentLink;
|
|
||||||
QString base;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/* A class to enumerate a single file */
|
|
||||||
class ProjectFile: public ProjectNode
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ProjectFile(QString file, ProjectModel* model, ProjectNode* parent);
|
|
||||||
virtual ~ProjectFile();
|
|
||||||
|
|
||||||
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<ProjectFile*>(this));
|
|
||||||
}
|
|
||||||
virtual QVariant data(int column) const;
|
|
||||||
virtual Qt::ItemFlags flags(int column) const;
|
|
||||||
virtual void activated();
|
|
||||||
|
|
||||||
private:
|
|
||||||
ProjectNode* parentLink;
|
|
||||||
QString file;
|
|
||||||
};
|
|
||||||
|
|
||||||
#endif // PROJECTFILES_H
|
|
|
@ -21,124 +21,18 @@
|
||||||
|
|
||||||
|
|
||||||
#include "projectmodel.h"
|
#include "projectmodel.h"
|
||||||
#include "projectfiles.h"
|
|
||||||
#include "projectsettings.h"
|
|
||||||
#include "editorwindow.h"
|
#include "editorwindow.h"
|
||||||
|
|
||||||
#include <QFile>
|
#include <QFile>
|
||||||
#include <QTextStream>
|
#include <QTextStream>
|
||||||
#include <QHash>
|
#include <QMap>
|
||||||
#include <QDir>
|
#include <QDir>
|
||||||
|
|
||||||
ProjectModel::ProjectModel(QString config, EditorWindow* mainWindow,
|
ProjectModel::ProjectModel(QString config, EditorWindow* mainWindow,
|
||||||
QObject *parent)
|
QObject *parent)
|
||||||
: QAbstractItemModel(parent),
|
: QAbstractListModel(parent),
|
||||||
mainWindow(mainWindow)
|
mainWindow(mainWindow)
|
||||||
{
|
{
|
||||||
root = new ProjectRoot(config, this);
|
|
||||||
}
|
|
||||||
|
|
||||||
ProjectModel::~ProjectModel()
|
|
||||||
{
|
|
||||||
if(root)
|
|
||||||
delete root;
|
|
||||||
}
|
|
||||||
|
|
||||||
QModelIndex ProjectModel::index(int row, int column,
|
|
||||||
const QModelIndex& parent) const
|
|
||||||
{
|
|
||||||
|
|
||||||
if(!hasIndex(row, column, parent))
|
|
||||||
return QModelIndex();
|
|
||||||
|
|
||||||
ProjectNode* foundParent = root;
|
|
||||||
if(parent.isValid())
|
|
||||||
foundParent = static_cast<ProjectNode*>(parent.internalPointer());
|
|
||||||
|
|
||||||
if(row < foundParent->numChildren() && row >= 0)
|
|
||||||
return createIndex(row, column, foundParent->child(row));
|
|
||||||
else
|
|
||||||
return QModelIndex();
|
|
||||||
}
|
|
||||||
|
|
||||||
QModelIndex ProjectModel::parent(const QModelIndex &child) const
|
|
||||||
{
|
|
||||||
if(!child.isValid())
|
|
||||||
return QModelIndex();
|
|
||||||
|
|
||||||
ProjectNode* foundParent = static_cast<ProjectNode*>
|
|
||||||
(child.internalPointer())->parent();
|
|
||||||
|
|
||||||
if(foundParent == root)
|
|
||||||
return QModelIndex();
|
|
||||||
|
|
||||||
return createIndex(foundParent->row(), 0, foundParent);
|
|
||||||
}
|
|
||||||
|
|
||||||
int ProjectModel::rowCount(const QModelIndex &parent) const
|
|
||||||
{
|
|
||||||
if(!root)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
if(!parent.isValid())
|
|
||||||
return root->numChildren();
|
|
||||||
|
|
||||||
if(parent.column() != 0)
|
|
||||||
return 0;
|
|
||||||
|
|
||||||
return static_cast<ProjectNode*>(parent.internalPointer())->numChildren();
|
|
||||||
}
|
|
||||||
|
|
||||||
int ProjectModel::columnCount(const QModelIndex &parent) const
|
|
||||||
{
|
|
||||||
return numColumns;
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant ProjectModel::data(const QModelIndex &index, int role) const
|
|
||||||
{
|
|
||||||
if(!index.isValid())
|
|
||||||
return QVariant();
|
|
||||||
|
|
||||||
if(role != Qt::DisplayRole)
|
|
||||||
return QVariant();
|
|
||||||
|
|
||||||
return static_cast<ProjectNode*>
|
|
||||||
(index.internalPointer())->data(index.column());
|
|
||||||
}
|
|
||||||
|
|
||||||
QVariant ProjectModel::headerData(int col, Qt::Orientation orientation,
|
|
||||||
int role) const
|
|
||||||
{
|
|
||||||
return QVariant();
|
|
||||||
}
|
|
||||||
|
|
||||||
Qt::ItemFlags ProjectModel::flags(const QModelIndex &index) const
|
|
||||||
{
|
|
||||||
return static_cast<ProjectNode*>
|
|
||||||
(index.internalPointer())->flags(index.column());
|
|
||||||
}
|
|
||||||
|
|
||||||
bool ProjectModel::setData(const QModelIndex &index, const QVariant &value,
|
|
||||||
int role)
|
|
||||||
{
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectModel::loadFile(QString file)
|
|
||||||
{
|
|
||||||
mainWindow->loadTabFromFile(file);
|
|
||||||
}
|
|
||||||
|
|
||||||
void ProjectModel::activated(const QModelIndex &index)
|
|
||||||
{
|
|
||||||
static_cast<ProjectNode*>(index.internalPointer())->activated();
|
|
||||||
}
|
|
||||||
|
|
||||||
/* Constructor and destructor for the root class */
|
|
||||||
ProjectRoot::ProjectRoot(QString config, ProjectModel* model)
|
|
||||||
{
|
|
||||||
this->model = model;
|
|
||||||
|
|
||||||
/* Reading the config file */
|
/* Reading the config file */
|
||||||
QFile cfg(config);
|
QFile cfg(config);
|
||||||
cfg.open(QFile::ReadOnly | QFile::Text);
|
cfg.open(QFile::ReadOnly | QFile::Text);
|
||||||
|
@ -172,14 +66,53 @@ ProjectRoot::ProjectRoot(QString config, ProjectModel* model)
|
||||||
|
|
||||||
cfg.close();
|
cfg.close();
|
||||||
|
|
||||||
/* Showing the files */
|
/* Adding the files, starting with the .cfg */
|
||||||
children.append(new ProjectFiles(settings, model, this));
|
config.replace(base.canonicalPath() + "/", "");
|
||||||
children.append(new ProjectSettings(settings, model, this));
|
files.append(config);
|
||||||
|
|
||||||
|
QList<QString> keys;
|
||||||
|
keys.append("wps");
|
||||||
|
keys.append("rwps");
|
||||||
|
keys.append("sbs");
|
||||||
|
keys.append("rsbs");
|
||||||
|
keys.append("fms");
|
||||||
|
keys.append("rfms");
|
||||||
|
|
||||||
|
for(int i = 0; i < keys.count(); i++)
|
||||||
|
{
|
||||||
|
QString file = settings.value(keys[i], "");
|
||||||
|
if(file != "" && file != "-")
|
||||||
|
{
|
||||||
|
file.replace("/.rockbox/", "");
|
||||||
|
files.append(file);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ProjectRoot::~ProjectRoot()
|
ProjectModel::~ProjectModel()
|
||||||
{
|
{
|
||||||
for(int i = 0; i < children.count(); i++)
|
}
|
||||||
delete children[i];
|
|
||||||
|
int ProjectModel::rowCount(const QModelIndex& parent) const
|
||||||
|
{
|
||||||
|
return files.count();
|
||||||
|
}
|
||||||
|
|
||||||
|
QVariant ProjectModel::data(const QModelIndex &index, int role) const
|
||||||
|
{
|
||||||
|
if(!index.isValid())
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
if(role != Qt::DisplayRole)
|
||||||
|
return QVariant();
|
||||||
|
|
||||||
|
return files[index.row()];
|
||||||
|
}
|
||||||
|
|
||||||
|
void ProjectModel::activated(const QModelIndex &index)
|
||||||
|
{
|
||||||
|
mainWindow->loadTabFromFile(settings.value("themebase", "")
|
||||||
|
+ "/" + files[index.row()]);
|
||||||
}
|
}
|
||||||
|
|
|
@ -22,13 +22,12 @@
|
||||||
#ifndef PROJECTMODEL_H
|
#ifndef PROJECTMODEL_H
|
||||||
#define PROJECTMODEL_H
|
#define PROJECTMODEL_H
|
||||||
|
|
||||||
#include <QAbstractItemModel>
|
#include <QAbstractListModel>
|
||||||
#include <QHash>
|
#include <QMap>
|
||||||
|
|
||||||
class ProjectNode;
|
|
||||||
class EditorWindow;
|
class EditorWindow;
|
||||||
|
|
||||||
class ProjectModel : public QAbstractItemModel
|
class ProjectModel : public QAbstractListModel
|
||||||
{
|
{
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
public:
|
public:
|
||||||
|
@ -42,16 +41,8 @@ public:
|
||||||
ProjectModel(QString config, EditorWindow* mainWindow, QObject *parent = 0);
|
ProjectModel(QString config, EditorWindow* mainWindow, QObject *parent = 0);
|
||||||
virtual ~ProjectModel();
|
virtual ~ProjectModel();
|
||||||
|
|
||||||
QModelIndex index(int row, int column, const QModelIndex& parent) const;
|
int rowCount(const QModelIndex& parent) const;
|
||||||
QModelIndex parent(const QModelIndex &child) const;
|
|
||||||
int rowCount(const QModelIndex &parent) const;
|
|
||||||
int columnCount(const QModelIndex &parent) const;
|
|
||||||
QVariant data(const QModelIndex &index, int role) const;
|
QVariant data(const QModelIndex &index, int role) const;
|
||||||
QVariant headerData(int col, Qt::Orientation orientation, int role) const;
|
|
||||||
Qt::ItemFlags flags(const QModelIndex &index) const;
|
|
||||||
bool setData(const QModelIndex &index, const QVariant &value, int role);
|
|
||||||
|
|
||||||
void loadFile(QString file);
|
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
|
|
||||||
|
@ -59,55 +50,9 @@ public slots:
|
||||||
void activated(const QModelIndex& index);
|
void activated(const QModelIndex& index);
|
||||||
|
|
||||||
private:
|
private:
|
||||||
ProjectNode* root;
|
|
||||||
EditorWindow* mainWindow;
|
EditorWindow* mainWindow;
|
||||||
|
QMap<QString, QString> settings;
|
||||||
|
QList<QString> files;
|
||||||
};
|
};
|
||||||
|
|
||||||
/* A simple abstract class required for categories */
|
|
||||||
class ProjectNode
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
virtual ProjectNode* parent() const = 0;
|
|
||||||
virtual ProjectNode* child(int row) const = 0;
|
|
||||||
virtual int numChildren() const = 0;
|
|
||||||
virtual int row() const = 0;
|
|
||||||
virtual QVariant data(int column) const = 0;
|
|
||||||
virtual Qt::ItemFlags flags(int column) const = 0;
|
|
||||||
virtual void activated() = 0;
|
|
||||||
|
|
||||||
int indexOf(ProjectNode* child){ return children.indexOf(child); }
|
|
||||||
|
|
||||||
protected:
|
|
||||||
QList<ProjectNode*> children;
|
|
||||||
ProjectModel* model;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
/* A simple implementation of ProjectNode for the root */
|
|
||||||
class ProjectRoot : public ProjectNode
|
|
||||||
{
|
|
||||||
public:
|
|
||||||
ProjectRoot(QString config, ProjectModel* model);
|
|
||||||
virtual ~ProjectRoot();
|
|
||||||
|
|
||||||
virtual ProjectNode* parent() const{ return 0; }
|
|
||||||
virtual ProjectNode* child(int row) const
|
|
||||||
{
|
|
||||||
if(row >= 0 && row < children.count())
|
|
||||||
return children[row];
|
|
||||||
else
|
|
||||||
return 0;
|
|
||||||
}
|
|
||||||
virtual int numChildren() const{ return children.count(); }
|
|
||||||
virtual int row() const{ return 0; }
|
|
||||||
virtual QVariant data(int column) const{ return QVariant(); }
|
|
||||||
virtual Qt::ItemFlags flags(int column) const{ return 0; }
|
|
||||||
virtual void activated(){ }
|
|
||||||
|
|
||||||
private:
|
|
||||||
QHash<QString, QString> settings;
|
|
||||||
|
|
||||||
};
|
|
||||||
|
|
||||||
|
|
||||||
#endif // PROJECTMODEL_H
|
#endif // PROJECTMODEL_H
|
||||||
|
|
|
@ -1,120 +0,0 @@
|
||||||
/***************************************************************************
|
|
||||||
* __________ __ ___.
|
|
||||||
* 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()
|
|
||||||
{
|
|
||||||
}
|
|
||||||
|
|
|
@ -1,71 +0,0 @@
|
||||||
/***************************************************************************
|
|
||||||
* __________ __ ___.
|
|
||||||
* 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
|
|
|
@ -16,9 +16,7 @@ HEADERS += tag_table.h \
|
||||||
skindocument.h \
|
skindocument.h \
|
||||||
preferencesdialog.h \
|
preferencesdialog.h \
|
||||||
codeeditor.h \
|
codeeditor.h \
|
||||||
projectmodel.h \
|
projectmodel.h
|
||||||
projectfiles.h \
|
|
||||||
projectsettings.h
|
|
||||||
SOURCES += tag_table.c \
|
SOURCES += tag_table.c \
|
||||||
skin_parser.c \
|
skin_parser.c \
|
||||||
skin_scan.c \
|
skin_scan.c \
|
||||||
|
@ -31,9 +29,7 @@ SOURCES += tag_table.c \
|
||||||
skindocument.cpp \
|
skindocument.cpp \
|
||||||
preferencesdialog.cpp \
|
preferencesdialog.cpp \
|
||||||
codeeditor.cpp \
|
codeeditor.cpp \
|
||||||
projectmodel.cpp \
|
projectmodel.cpp
|
||||||
projectfiles.cpp \
|
|
||||||
projectsettings.cpp
|
|
||||||
OTHER_FILES += README \
|
OTHER_FILES += README \
|
||||||
resources/windowicon.png \
|
resources/windowicon.png \
|
||||||
resources/appicon.xcf \
|
resources/appicon.xcf \
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue