forked from len0rd/rockbox
Theme Editor: Began implementing classes to display project files and settings in the project panel
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26706 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
007ef43a50
commit
61b5f0c973
6 changed files with 209 additions and 14 deletions
|
@ -33,6 +33,7 @@ EditorWindow::EditorWindow(QWidget *parent) :
|
||||||
{
|
{
|
||||||
ui->setupUi(this);
|
ui->setupUi(this);
|
||||||
prefs = new PreferencesDialog(this);
|
prefs = new PreferencesDialog(this);
|
||||||
|
project = new ProjectModel();
|
||||||
loadSettings();
|
loadSettings();
|
||||||
setupUI();
|
setupUI();
|
||||||
setupMenus();
|
setupMenus();
|
||||||
|
@ -75,11 +76,6 @@ void EditorWindow::saveSettings()
|
||||||
|
|
||||||
void EditorWindow::setupUI()
|
void EditorWindow::setupUI()
|
||||||
{
|
{
|
||||||
/* Displaying some files to test the file tree view */
|
|
||||||
QFileSystemModel* model = new QFileSystemModel;
|
|
||||||
model->setRootPath(QDir::currentPath());
|
|
||||||
ui->fileTree->setModel(model);
|
|
||||||
|
|
||||||
/* Connecting the tab bar signals */
|
/* Connecting the tab bar signals */
|
||||||
QObject::connect(ui->editorTabs, SIGNAL(currentChanged(int)),
|
QObject::connect(ui->editorTabs, SIGNAL(currentChanged(int)),
|
||||||
this, SLOT(shiftTab(int)));
|
this, SLOT(shiftTab(int)));
|
||||||
|
@ -98,6 +94,9 @@ void EditorWindow::setupUI()
|
||||||
parseStatus = new QLabel(this);
|
parseStatus = new QLabel(this);
|
||||||
ui->statusbar->addPermanentWidget(parseStatus);
|
ui->statusbar->addPermanentWidget(parseStatus);
|
||||||
|
|
||||||
|
/* Setting up the project viewer */
|
||||||
|
ui->projectTree->setModel(project);
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
void EditorWindow::setupMenus()
|
void EditorWindow::setupMenus()
|
||||||
|
@ -250,7 +249,7 @@ void EditorWindow::tabTitleChanged(QString title)
|
||||||
void EditorWindow::showPanel()
|
void EditorWindow::showPanel()
|
||||||
{
|
{
|
||||||
if(sender() == ui->actionFile_Panel)
|
if(sender() == ui->actionFile_Panel)
|
||||||
ui->fileDock->setVisible(true);
|
ui->projectDock->setVisible(true);
|
||||||
if(sender() == ui->actionPreview_Panel)
|
if(sender() == ui->actionPreview_Panel)
|
||||||
ui->skinPreviewDock->setVisible(true);
|
ui->skinPreviewDock->setVisible(true);
|
||||||
if(sender() == ui->actionDisplay_Panel)
|
if(sender() == ui->actionDisplay_Panel)
|
||||||
|
|
|
@ -29,6 +29,7 @@
|
||||||
#include "skinhighlighter.h"
|
#include "skinhighlighter.h"
|
||||||
#include "skindocument.h"
|
#include "skindocument.h"
|
||||||
#include "preferencesdialog.h"
|
#include "preferencesdialog.h"
|
||||||
|
#include "projectmodel.h"
|
||||||
|
|
||||||
namespace Ui {
|
namespace Ui {
|
||||||
class EditorWindow;
|
class EditorWindow;
|
||||||
|
@ -66,6 +67,7 @@ private:
|
||||||
Ui::EditorWindow *ui;
|
Ui::EditorWindow *ui;
|
||||||
PreferencesDialog* prefs;
|
PreferencesDialog* prefs;
|
||||||
QLabel* parseStatus;
|
QLabel* parseStatus;
|
||||||
|
ProjectModel* project;
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif // EDITORWINDOW_H
|
#endif // EDITORWINDOW_H
|
||||||
|
|
|
@ -40,7 +40,7 @@
|
||||||
<x>0</x>
|
<x>0</x>
|
||||||
<y>0</y>
|
<y>0</y>
|
||||||
<width>628</width>
|
<width>628</width>
|
||||||
<height>25</height>
|
<height>27</height>
|
||||||
</rect>
|
</rect>
|
||||||
</property>
|
</property>
|
||||||
<widget class="QMenu" name="menuFile">
|
<widget class="QMenu" name="menuFile">
|
||||||
|
@ -49,6 +49,7 @@
|
||||||
</property>
|
</property>
|
||||||
<addaction name="actionNew_Document"/>
|
<addaction name="actionNew_Document"/>
|
||||||
<addaction name="actionOpen_Document"/>
|
<addaction name="actionOpen_Document"/>
|
||||||
|
<addaction name="actionOpen_Project"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
<addaction name="actionClose_Document"/>
|
<addaction name="actionClose_Document"/>
|
||||||
<addaction name="separator"/>
|
<addaction name="separator"/>
|
||||||
|
@ -100,9 +101,9 @@
|
||||||
<addaction name="actionToolbarOpen"/>
|
<addaction name="actionToolbarOpen"/>
|
||||||
<addaction name="actionToolbarSave"/>
|
<addaction name="actionToolbarSave"/>
|
||||||
</widget>
|
</widget>
|
||||||
<widget class="QDockWidget" name="fileDock">
|
<widget class="QDockWidget" name="projectDock">
|
||||||
<property name="windowTitle">
|
<property name="windowTitle">
|
||||||
<string>Files</string>
|
<string>Project</string>
|
||||||
</property>
|
</property>
|
||||||
<attribute name="dockWidgetArea">
|
<attribute name="dockWidgetArea">
|
||||||
<number>1</number>
|
<number>1</number>
|
||||||
|
@ -110,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="fileTree"/>
|
<widget class="QTreeView" name="projectTree"/>
|
||||||
</item>
|
</item>
|
||||||
</layout>
|
</layout>
|
||||||
</widget>
|
</widget>
|
||||||
|
@ -175,7 +176,7 @@
|
||||||
<bool>false</bool>
|
<bool>false</bool>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>&File Panel</string>
|
<string>P&roject Panel</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
<action name="actionPreview_Panel">
|
<action name="actionPreview_Panel">
|
||||||
|
@ -277,9 +278,14 @@
|
||||||
<string>Save</string>
|
<string>Save</string>
|
||||||
</property>
|
</property>
|
||||||
</action>
|
</action>
|
||||||
|
<action name="actionOpen_Project">
|
||||||
|
<property name="text">
|
||||||
|
<string>Open P&roject</string>
|
||||||
|
</property>
|
||||||
|
</action>
|
||||||
</widget>
|
</widget>
|
||||||
<tabstops>
|
<tabstops>
|
||||||
<tabstop>fileTree</tabstop>
|
<tabstop>projectTree</tabstop>
|
||||||
<tabstop>skinPreview</tabstop>
|
<tabstop>skinPreview</tabstop>
|
||||||
<tabstop>parseTree</tabstop>
|
<tabstop>parseTree</tabstop>
|
||||||
<tabstop>fromTree</tabstop>
|
<tabstop>fromTree</tabstop>
|
||||||
|
|
114
utils/themeeditor/projectmodel.cpp
Normal file
114
utils/themeeditor/projectmodel.cpp
Normal file
|
@ -0,0 +1,114 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* 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 "projectmodel.h"
|
||||||
|
|
||||||
|
ProjectModel::ProjectModel(QObject *parent) :
|
||||||
|
QAbstractItemModel(parent)
|
||||||
|
{
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
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 Qt::ItemIsEnabled | Qt::ItemIsSelectable;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool ProjectModel::setData(const QModelIndex &index, const QVariant &value,
|
||||||
|
int role)
|
||||||
|
{
|
||||||
|
return true;
|
||||||
|
}
|
72
utils/themeeditor/projectmodel.h
Normal file
72
utils/themeeditor/projectmodel.h
Normal file
|
@ -0,0 +1,72 @@
|
||||||
|
/***************************************************************************
|
||||||
|
* __________ __ ___.
|
||||||
|
* 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 PROJECTMODEL_H
|
||||||
|
#define PROJECTMODEL_H
|
||||||
|
|
||||||
|
#include <QAbstractItemModel>
|
||||||
|
|
||||||
|
class ProjectNode;
|
||||||
|
|
||||||
|
class ProjectModel : public QAbstractItemModel
|
||||||
|
{
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
static const int numColumns = 1;
|
||||||
|
|
||||||
|
ProjectModel(QObject *parent = 0);
|
||||||
|
virtual ~ProjectModel();
|
||||||
|
|
||||||
|
QModelIndex index(int row, int column, 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 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);
|
||||||
|
|
||||||
|
|
||||||
|
signals:
|
||||||
|
|
||||||
|
public slots:
|
||||||
|
|
||||||
|
private:
|
||||||
|
ProjectNode* root;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
/* 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 QString title() const = 0;
|
||||||
|
virtual Qt::ItemFlags flags(const QModelIndex& index) const = 0;
|
||||||
|
virtual void activated(const QModelIndex& index) = 0;
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // PROJECTMODEL_H
|
|
@ -15,7 +15,8 @@ HEADERS += tag_table.h \
|
||||||
skinhighlighter.h \
|
skinhighlighter.h \
|
||||||
skindocument.h \
|
skindocument.h \
|
||||||
preferencesdialog.h \
|
preferencesdialog.h \
|
||||||
codeeditor.h
|
codeeditor.h \
|
||||||
|
projectmodel.h
|
||||||
SOURCES += tag_table.c \
|
SOURCES += tag_table.c \
|
||||||
skin_parser.c \
|
skin_parser.c \
|
||||||
skin_scan.c \
|
skin_scan.c \
|
||||||
|
@ -27,7 +28,8 @@ SOURCES += tag_table.c \
|
||||||
skinhighlighter.cpp \
|
skinhighlighter.cpp \
|
||||||
skindocument.cpp \
|
skindocument.cpp \
|
||||||
preferencesdialog.cpp \
|
preferencesdialog.cpp \
|
||||||
codeeditor.cpp
|
codeeditor.cpp \
|
||||||
|
projectmodel.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