summaryrefslogtreecommitdiff
path: root/utils/themeeditor
diff options
context:
space:
mode:
Diffstat (limited to 'utils/themeeditor')
-rw-r--r--utils/themeeditor/editorwindow.cpp11
-rw-r--r--utils/themeeditor/editorwindow.h2
-rw-r--r--utils/themeeditor/editorwindow.ui18
-rw-r--r--utils/themeeditor/projectmodel.cpp114
-rw-r--r--utils/themeeditor/projectmodel.h72
-rw-r--r--utils/themeeditor/themeeditor.pro6
6 files changed, 209 insertions, 14 deletions
diff --git a/utils/themeeditor/editorwindow.cpp b/utils/themeeditor/editorwindow.cpp
index cc2a0fb350..5184281809 100644
--- a/utils/themeeditor/editorwindow.cpp
+++ b/utils/themeeditor/editorwindow.cpp
@@ -33,6 +33,7 @@ EditorWindow::EditorWindow(QWidget *parent) :
33{ 33{
34 ui->setupUi(this); 34 ui->setupUi(this);
35 prefs = new PreferencesDialog(this); 35 prefs = new PreferencesDialog(this);
36 project = new ProjectModel();
36 loadSettings(); 37 loadSettings();
37 setupUI(); 38 setupUI();
38 setupMenus(); 39 setupMenus();
@@ -75,11 +76,6 @@ void EditorWindow::saveSettings()
75 76
76void EditorWindow::setupUI() 77void EditorWindow::setupUI()
77{ 78{
78 /* Displaying some files to test the file tree view */
79 QFileSystemModel* model = new QFileSystemModel;
80 model->setRootPath(QDir::currentPath());
81 ui->fileTree->setModel(model);
82
83 /* Connecting the tab bar signals */ 79 /* Connecting the tab bar signals */
84 QObject::connect(ui->editorTabs, SIGNAL(currentChanged(int)), 80 QObject::connect(ui->editorTabs, SIGNAL(currentChanged(int)),
85 this, SLOT(shiftTab(int))); 81 this, SLOT(shiftTab(int)));
@@ -98,6 +94,9 @@ void EditorWindow::setupUI()
98 parseStatus = new QLabel(this); 94 parseStatus = new QLabel(this);
99 ui->statusbar->addPermanentWidget(parseStatus); 95 ui->statusbar->addPermanentWidget(parseStatus);
100 96
97 /* Setting up the project viewer */
98 ui->projectTree->setModel(project);
99
101} 100}
102 101
103void EditorWindow::setupMenus() 102void EditorWindow::setupMenus()
@@ -250,7 +249,7 @@ void EditorWindow::tabTitleChanged(QString title)
250void EditorWindow::showPanel() 249void EditorWindow::showPanel()
251{ 250{
252 if(sender() == ui->actionFile_Panel) 251 if(sender() == ui->actionFile_Panel)
253 ui->fileDock->setVisible(true); 252 ui->projectDock->setVisible(true);
254 if(sender() == ui->actionPreview_Panel) 253 if(sender() == ui->actionPreview_Panel)
255 ui->skinPreviewDock->setVisible(true); 254 ui->skinPreviewDock->setVisible(true);
256 if(sender() == ui->actionDisplay_Panel) 255 if(sender() == ui->actionDisplay_Panel)
diff --git a/utils/themeeditor/editorwindow.h b/utils/themeeditor/editorwindow.h
index 3bab704bb6..f8a04b0b70 100644
--- a/utils/themeeditor/editorwindow.h
+++ b/utils/themeeditor/editorwindow.h
@@ -29,6 +29,7 @@
29#include "skinhighlighter.h" 29#include "skinhighlighter.h"
30#include "skindocument.h" 30#include "skindocument.h"
31#include "preferencesdialog.h" 31#include "preferencesdialog.h"
32#include "projectmodel.h"
32 33
33namespace Ui { 34namespace Ui {
34 class EditorWindow; 35 class EditorWindow;
@@ -66,6 +67,7 @@ private:
66 Ui::EditorWindow *ui; 67 Ui::EditorWindow *ui;
67 PreferencesDialog* prefs; 68 PreferencesDialog* prefs;
68 QLabel* parseStatus; 69 QLabel* parseStatus;
70 ProjectModel* project;
69}; 71};
70 72
71#endif // EDITORWINDOW_H 73#endif // EDITORWINDOW_H
diff --git a/utils/themeeditor/editorwindow.ui b/utils/themeeditor/editorwindow.ui
index b25243f254..1aa53549af 100644
--- a/utils/themeeditor/editorwindow.ui
+++ b/utils/themeeditor/editorwindow.ui
@@ -40,7 +40,7 @@
40 <x>0</x> 40 <x>0</x>
41 <y>0</y> 41 <y>0</y>
42 <width>628</width> 42 <width>628</width>
43 <height>25</height> 43 <height>27</height>
44 </rect> 44 </rect>
45 </property> 45 </property>
46 <widget class="QMenu" name="menuFile"> 46 <widget class="QMenu" name="menuFile">
@@ -49,6 +49,7 @@
49 </property> 49 </property>
50 <addaction name="actionNew_Document"/> 50 <addaction name="actionNew_Document"/>
51 <addaction name="actionOpen_Document"/> 51 <addaction name="actionOpen_Document"/>
52 <addaction name="actionOpen_Project"/>
52 <addaction name="separator"/> 53 <addaction name="separator"/>
53 <addaction name="actionClose_Document"/> 54 <addaction name="actionClose_Document"/>
54 <addaction name="separator"/> 55 <addaction name="separator"/>
@@ -100,9 +101,9 @@
100 <addaction name="actionToolbarOpen"/> 101 <addaction name="actionToolbarOpen"/>
101 <addaction name="actionToolbarSave"/> 102 <addaction name="actionToolbarSave"/>
102 </widget> 103 </widget>
103 <widget class="QDockWidget" name="fileDock"> 104 <widget class="QDockWidget" name="projectDock">
104 <property name="windowTitle"> 105 <property name="windowTitle">
105 <string>Files</string> 106 <string>Project</string>
106 </property> 107 </property>
107 <attribute name="dockWidgetArea"> 108 <attribute name="dockWidgetArea">
108 <number>1</number> 109 <number>1</number>
@@ -110,7 +111,7 @@
110 <widget class="QWidget" name="dockWidgetContents_2"> 111 <widget class="QWidget" name="dockWidgetContents_2">
111 <layout class="QVBoxLayout" name="verticalLayout_4"> 112 <layout class="QVBoxLayout" name="verticalLayout_4">
112 <item> 113 <item>
113 <widget class="QTreeView" name="fileTree"/> 114 <widget class="QTreeView" name="projectTree"/>
114 </item> 115 </item>
115 </layout> 116 </layout>
116 </widget> 117 </widget>
@@ -175,7 +176,7 @@
175 <bool>false</bool> 176 <bool>false</bool>
176 </property> 177 </property>
177 <property name="text"> 178 <property name="text">
178 <string>&amp;File Panel</string> 179 <string>P&amp;roject Panel</string>
179 </property> 180 </property>
180 </action> 181 </action>
181 <action name="actionPreview_Panel"> 182 <action name="actionPreview_Panel">
@@ -277,9 +278,14 @@
277 <string>Save</string> 278 <string>Save</string>
278 </property> 279 </property>
279 </action> 280 </action>
281 <action name="actionOpen_Project">
282 <property name="text">
283 <string>Open P&amp;roject</string>
284 </property>
285 </action>
280 </widget> 286 </widget>
281 <tabstops> 287 <tabstops>
282 <tabstop>fileTree</tabstop> 288 <tabstop>projectTree</tabstop>
283 <tabstop>skinPreview</tabstop> 289 <tabstop>skinPreview</tabstop>
284 <tabstop>parseTree</tabstop> 290 <tabstop>parseTree</tabstop>
285 <tabstop>fromTree</tabstop> 291 <tabstop>fromTree</tabstop>
diff --git a/utils/themeeditor/projectmodel.cpp b/utils/themeeditor/projectmodel.cpp
new file mode 100644
index 0000000000..8a26aa3263
--- /dev/null
+++ b/utils/themeeditor/projectmodel.cpp
@@ -0,0 +1,114 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Robert Bieber
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22
23#include "projectmodel.h"
24
25ProjectModel::ProjectModel(QObject *parent) :
26 QAbstractItemModel(parent)
27{
28
29}
30
31ProjectModel::~ProjectModel()
32{
33 if(root)
34 delete root;
35}
36
37QModelIndex ProjectModel::index(int row, int column,
38 const QModelIndex& parent) const
39{
40
41 if(!hasIndex(row, column, parent))
42 return QModelIndex();
43
44 ProjectNode* foundParent = root;
45 if(parent.isValid())
46 foundParent = static_cast<ProjectNode*>(parent.internalPointer());
47
48 if(row < foundParent->numChildren() && row >= 0)
49 return createIndex(row, column, foundParent->child(row));
50 else
51 return QModelIndex();
52}
53
54QModelIndex ProjectModel::parent(const QModelIndex &child) const
55{
56 if(!child.isValid())
57 return QModelIndex();
58
59 ProjectNode* foundParent = static_cast<ProjectNode*>
60 (child.internalPointer())->parent();
61
62 if(foundParent == root)
63 return QModelIndex();
64
65 return createIndex(foundParent->row(), 0, foundParent);
66}
67
68int ProjectModel::rowCount(const QModelIndex &parent) const
69{
70 if(!root)
71 return 0;
72
73 if(!parent.isValid())
74 return root->numChildren();
75
76 if(parent.column() != 0)
77 return 0;
78
79 return static_cast<ProjectNode*>(parent.internalPointer())->numChildren();
80}
81
82int ProjectModel::columnCount(const QModelIndex &parent) const
83{
84 return numColumns;
85}
86
87QVariant ProjectModel::data(const QModelIndex &index, int role) const
88{
89 if(!index.isValid())
90 return QVariant();
91
92 if(role != Qt::DisplayRole)
93 return QVariant();
94
95 return static_cast<ProjectNode*>
96 (index.internalPointer())->data(index.column());
97}
98
99QVariant ProjectModel::headerData(int col, Qt::Orientation orientation,
100 int role) const
101{
102 return QVariant();
103}
104
105Qt::ItemFlags ProjectModel::flags(const QModelIndex &index) const
106{
107 return Qt::ItemIsEnabled | Qt::ItemIsSelectable;
108}
109
110bool ProjectModel::setData(const QModelIndex &index, const QVariant &value,
111 int role)
112{
113 return true;
114}
diff --git a/utils/themeeditor/projectmodel.h b/utils/themeeditor/projectmodel.h
new file mode 100644
index 0000000000..e3bf93dcb5
--- /dev/null
+++ b/utils/themeeditor/projectmodel.h
@@ -0,0 +1,72 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Robert Bieber
11 *
12 * This program is free software; you can redistribute it and/or
13 * modify it under the terms of the GNU General Public License
14 * as published by the Free Software Foundation; either version 2
15 * of the License, or (at your option) any later version.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#ifndef PROJECTMODEL_H
23#define PROJECTMODEL_H
24
25#include <QAbstractItemModel>
26
27class ProjectNode;
28
29class ProjectModel : public QAbstractItemModel
30{
31Q_OBJECT
32public:
33 static const int numColumns = 1;
34
35 ProjectModel(QObject *parent = 0);
36 virtual ~ProjectModel();
37
38 QModelIndex index(int row, int column, const QModelIndex& parent) const;
39 QModelIndex parent(const QModelIndex &child) const;
40 int rowCount(const QModelIndex &parent) const;
41 int columnCount(const QModelIndex &parent) const;
42 QVariant data(const QModelIndex &index, int role) const;
43 QVariant headerData(int col, Qt::Orientation orientation, int role) const;
44 Qt::ItemFlags flags(const QModelIndex &index) const;
45 bool setData(const QModelIndex &index, const QVariant &value, int role);
46
47
48signals:
49
50public slots:
51
52private:
53 ProjectNode* root;
54
55};
56
57/* A simple abstract class required for categories */
58class ProjectNode
59{
60public:
61 virtual ProjectNode* parent() const = 0;
62 virtual ProjectNode* child(int row) const = 0;
63 virtual int numChildren() const = 0;
64 virtual int row() const = 0;
65 virtual QVariant data(int column) const = 0;
66 virtual QString title() const = 0;
67 virtual Qt::ItemFlags flags(const QModelIndex& index) const = 0;
68 virtual void activated(const QModelIndex& index) = 0;
69
70};
71
72#endif // PROJECTMODEL_H
diff --git a/utils/themeeditor/themeeditor.pro b/utils/themeeditor/themeeditor.pro
index e0fcdc09d5..128f56996d 100644
--- a/utils/themeeditor/themeeditor.pro
+++ b/utils/themeeditor/themeeditor.pro
@@ -15,7 +15,8 @@ HEADERS += tag_table.h \
15 skinhighlighter.h \ 15 skinhighlighter.h \
16 skindocument.h \ 16 skindocument.h \
17 preferencesdialog.h \ 17 preferencesdialog.h \
18 codeeditor.h 18 codeeditor.h \
19 projectmodel.h
19SOURCES += tag_table.c \ 20SOURCES += tag_table.c \
20 skin_parser.c \ 21 skin_parser.c \
21 skin_scan.c \ 22 skin_scan.c \
@@ -27,7 +28,8 @@ SOURCES += tag_table.c \
27 skinhighlighter.cpp \ 28 skinhighlighter.cpp \
28 skindocument.cpp \ 29 skindocument.cpp \
29 preferencesdialog.cpp \ 30 preferencesdialog.cpp \
30 codeeditor.cpp 31 codeeditor.cpp \
32 projectmodel.cpp
31OTHER_FILES += README \ 33OTHER_FILES += README \
32 resources/windowicon.png \ 34 resources/windowicon.png \
33 resources/appicon.xcf \ 35 resources/appicon.xcf \