diff options
Diffstat (limited to 'utils/themeeditor')
-rw-r--r-- | utils/themeeditor/editorwindow.cpp | 36 | ||||
-rw-r--r-- | utils/themeeditor/editorwindow.h | 1 | ||||
-rw-r--r-- | utils/themeeditor/editorwindow.ui | 12 | ||||
-rw-r--r-- | utils/themeeditor/projectfiles.cpp | 77 | ||||
-rw-r--r-- | utils/themeeditor/projectfiles.h | 46 | ||||
-rw-r--r-- | utils/themeeditor/projectmodel.cpp | 22 | ||||
-rw-r--r-- | utils/themeeditor/projectmodel.h | 42 | ||||
-rw-r--r-- | utils/themeeditor/themeeditor.pro | 6 |
8 files changed, 226 insertions, 16 deletions
diff --git a/utils/themeeditor/editorwindow.cpp b/utils/themeeditor/editorwindow.cpp index 5184281809..d1f3609c50 100644 --- a/utils/themeeditor/editorwindow.cpp +++ b/utils/themeeditor/editorwindow.cpp | |||
@@ -33,7 +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 | project = 0; |
37 | loadSettings(); | 37 | loadSettings(); |
38 | setupUI(); | 38 | setupUI(); |
39 | setupMenus(); | 39 | setupMenus(); |
@@ -94,9 +94,6 @@ void EditorWindow::setupUI() | |||
94 | parseStatus = new QLabel(this); | 94 | parseStatus = new QLabel(this); |
95 | ui->statusbar->addPermanentWidget(parseStatus); | 95 | ui->statusbar->addPermanentWidget(parseStatus); |
96 | 96 | ||
97 | /* Setting up the project viewer */ | ||
98 | ui->projectTree->setModel(project); | ||
99 | |||
100 | } | 97 | } |
101 | 98 | ||
102 | void EditorWindow::setupMenus() | 99 | void EditorWindow::setupMenus() |
@@ -130,6 +127,8 @@ void EditorWindow::setupMenus() | |||
130 | QObject::connect(ui->actionToolbarOpen, SIGNAL(triggered()), | 127 | QObject::connect(ui->actionToolbarOpen, SIGNAL(triggered()), |
131 | this, SLOT(openFile())); | 128 | this, SLOT(openFile())); |
132 | 129 | ||
130 | QObject::connect(ui->actionOpen_Project, SIGNAL(triggered()), | ||
131 | this, SLOT(openProject())); | ||
133 | } | 132 | } |
134 | 133 | ||
135 | void EditorWindow::addTab(SkinDocument *doc) | 134 | void EditorWindow::addTab(SkinDocument *doc) |
@@ -239,6 +238,33 @@ void EditorWindow::openFile() | |||
239 | settings.endGroup(); | 238 | settings.endGroup(); |
240 | } | 239 | } |
241 | 240 | ||
241 | void EditorWindow::openProject() | ||
242 | { | ||
243 | QString fileName; | ||
244 | QSettings settings; | ||
245 | |||
246 | settings.beginGroup("ProjectModel"); | ||
247 | QString directory = settings.value("defaultDirectory", "").toString(); | ||
248 | fileName = QFileDialog::getOpenFileName(this, tr("Open Project"), directory, | ||
249 | ProjectModel::fileFilter()); | ||
250 | |||
251 | if(QFile::exists(fileName)) | ||
252 | { | ||
253 | |||
254 | if(project) | ||
255 | delete project; | ||
256 | |||
257 | project = new ProjectModel(fileName); | ||
258 | ui->projectTree->setModel(project); | ||
259 | |||
260 | fileName.chop(fileName.length() - fileName.lastIndexOf('/') - 1); | ||
261 | settings.setValue("defaultDirectory", fileName); | ||
262 | |||
263 | } | ||
264 | |||
265 | settings.endGroup(); | ||
266 | |||
267 | } | ||
242 | 268 | ||
243 | void EditorWindow::tabTitleChanged(QString title) | 269 | void EditorWindow::tabTitleChanged(QString title) |
244 | { | 270 | { |
@@ -288,4 +314,6 @@ EditorWindow::~EditorWindow() | |||
288 | { | 314 | { |
289 | delete ui; | 315 | delete ui; |
290 | delete prefs; | 316 | delete prefs; |
317 | if(project) | ||
318 | delete project; | ||
291 | } | 319 | } |
diff --git a/utils/themeeditor/editorwindow.h b/utils/themeeditor/editorwindow.h index f8a04b0b70..adcee0ece4 100644 --- a/utils/themeeditor/editorwindow.h +++ b/utils/themeeditor/editorwindow.h | |||
@@ -53,6 +53,7 @@ private slots: | |||
53 | void saveCurrent(); | 53 | void saveCurrent(); |
54 | void saveCurrentAs(); | 54 | void saveCurrentAs(); |
55 | void openFile(); | 55 | void openFile(); |
56 | void openProject(); | ||
56 | void tabTitleChanged(QString title); | 57 | void tabTitleChanged(QString title); |
57 | void updateCurrent(); /* Generates code in the current tab */ | 58 | void updateCurrent(); /* Generates code in the current tab */ |
58 | 59 | ||
diff --git a/utils/themeeditor/editorwindow.ui b/utils/themeeditor/editorwindow.ui index 1aa53549af..30d1da087f 100644 --- a/utils/themeeditor/editorwindow.ui +++ b/utils/themeeditor/editorwindow.ui | |||
@@ -111,7 +111,14 @@ | |||
111 | <widget class="QWidget" name="dockWidgetContents_2"> | 111 | <widget class="QWidget" name="dockWidgetContents_2"> |
112 | <layout class="QVBoxLayout" name="verticalLayout_4"> | 112 | <layout class="QVBoxLayout" name="verticalLayout_4"> |
113 | <item> | 113 | <item> |
114 | <widget class="QTreeView" name="projectTree"/> | 114 | <widget class="QTreeView" name="projectTree"> |
115 | <attribute name="headerVisible"> | ||
116 | <bool>false</bool> | ||
117 | </attribute> | ||
118 | <attribute name="headerVisible"> | ||
119 | <bool>false</bool> | ||
120 | </attribute> | ||
121 | </widget> | ||
115 | </item> | 122 | </item> |
116 | </layout> | 123 | </layout> |
117 | </widget> | 124 | </widget> |
@@ -282,6 +289,9 @@ | |||
282 | <property name="text"> | 289 | <property name="text"> |
283 | <string>Open P&roject</string> | 290 | <string>Open P&roject</string> |
284 | </property> | 291 | </property> |
292 | <property name="shortcut"> | ||
293 | <string>Ctrl+Shift+O</string> | ||
294 | </property> | ||
285 | </action> | 295 | </action> |
286 | </widget> | 296 | </widget> |
287 | <tabstops> | 297 | <tabstops> |
diff --git a/utils/themeeditor/projectfiles.cpp b/utils/themeeditor/projectfiles.cpp new file mode 100644 index 0000000000..441ff1169e --- /dev/null +++ b/utils/themeeditor/projectfiles.cpp | |||
@@ -0,0 +1,77 @@ | |||
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 | #include "projectfiles.h" | ||
23 | |||
24 | ProjectFiles::ProjectFiles(ProjectNode* parent): parentLink(parent) | ||
25 | { | ||
26 | } | ||
27 | |||
28 | ProjectFiles::~ProjectFiles() | ||
29 | { | ||
30 | for(int i = 0; i < children.count(); i++) | ||
31 | delete children[i]; | ||
32 | } | ||
33 | |||
34 | ProjectNode* ProjectFiles::parent() const | ||
35 | { | ||
36 | return parentLink; | ||
37 | } | ||
38 | |||
39 | ProjectNode* ProjectFiles::child(int row) const | ||
40 | { | ||
41 | if(row >= 0 && row < children.count()) | ||
42 | return children[row]; | ||
43 | |||
44 | return 0; | ||
45 | } | ||
46 | |||
47 | int ProjectFiles::numChildren() const | ||
48 | { | ||
49 | return children.count(); | ||
50 | } | ||
51 | |||
52 | int ProjectFiles::row() const | ||
53 | { | ||
54 | return parentLink->indexOf(const_cast<ProjectFiles*>(this)); | ||
55 | } | ||
56 | |||
57 | QVariant ProjectFiles::data(int column) const | ||
58 | { | ||
59 | if(column == 0) | ||
60 | return QObject::tr("Project Files"); | ||
61 | else | ||
62 | return QVariant(); | ||
63 | } | ||
64 | |||
65 | Qt::ItemFlags ProjectFiles::flags(int column) const | ||
66 | { | ||
67 | if(column == 0) | ||
68 | return Qt::ItemIsEnabled | Qt::ItemIsSelectable; | ||
69 | else | ||
70 | return 0; | ||
71 | } | ||
72 | |||
73 | void ProjectFiles::activated() | ||
74 | { | ||
75 | |||
76 | } | ||
77 | |||
diff --git a/utils/themeeditor/projectfiles.h b/utils/themeeditor/projectfiles.h new file mode 100644 index 0000000000..5fcbff73b2 --- /dev/null +++ b/utils/themeeditor/projectfiles.h | |||
@@ -0,0 +1,46 @@ | |||
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 PROJECTFILES_H | ||
23 | #define PROJECTFILES_H | ||
24 | |||
25 | #include "projectmodel.h" | ||
26 | |||
27 | class ProjectFiles : public ProjectNode | ||
28 | { | ||
29 | public: | ||
30 | ProjectFiles(ProjectNode* parent); | ||
31 | virtual ~ProjectFiles(); | ||
32 | |||
33 | virtual ProjectNode* parent() const; | ||
34 | virtual ProjectNode* child(int row) const; | ||
35 | virtual int numChildren() const; | ||
36 | virtual int row() const; | ||
37 | virtual QVariant data(int column) const; | ||
38 | virtual Qt::ItemFlags flags(int column) const; | ||
39 | virtual void activated(); | ||
40 | |||
41 | private: | ||
42 | ProjectNode* parentLink; | ||
43 | |||
44 | }; | ||
45 | |||
46 | #endif // PROJECTFILES_H | ||
diff --git a/utils/themeeditor/projectmodel.cpp b/utils/themeeditor/projectmodel.cpp index 8a26aa3263..aeca1c76a7 100644 --- a/utils/themeeditor/projectmodel.cpp +++ b/utils/themeeditor/projectmodel.cpp | |||
@@ -21,11 +21,12 @@ | |||
21 | 21 | ||
22 | 22 | ||
23 | #include "projectmodel.h" | 23 | #include "projectmodel.h" |
24 | #include "projectfiles.h" | ||
24 | 25 | ||
25 | ProjectModel::ProjectModel(QObject *parent) : | 26 | ProjectModel::ProjectModel(QString config, QObject *parent) : |
26 | QAbstractItemModel(parent) | 27 | QAbstractItemModel(parent) |
27 | { | 28 | { |
28 | 29 | root = new ProjectRoot(config); | |
29 | } | 30 | } |
30 | 31 | ||
31 | ProjectModel::~ProjectModel() | 32 | ProjectModel::~ProjectModel() |
@@ -59,7 +60,7 @@ QModelIndex ProjectModel::parent(const QModelIndex &child) const | |||
59 | ProjectNode* foundParent = static_cast<ProjectNode*> | 60 | ProjectNode* foundParent = static_cast<ProjectNode*> |
60 | (child.internalPointer())->parent(); | 61 | (child.internalPointer())->parent(); |
61 | 62 | ||
62 | if(foundParent == root) | 63 | if(foundParent == 0) |
63 | return QModelIndex(); | 64 | return QModelIndex(); |
64 | 65 | ||
65 | return createIndex(foundParent->row(), 0, foundParent); | 66 | return createIndex(foundParent->row(), 0, foundParent); |
@@ -104,7 +105,8 @@ QVariant ProjectModel::headerData(int col, Qt::Orientation orientation, | |||
104 | 105 | ||
105 | Qt::ItemFlags ProjectModel::flags(const QModelIndex &index) const | 106 | Qt::ItemFlags ProjectModel::flags(const QModelIndex &index) const |
106 | { | 107 | { |
107 | return Qt::ItemIsEnabled | Qt::ItemIsSelectable; | 108 | return static_cast<ProjectNode*> |
109 | (index.internalPointer())->flags(index.column()); | ||
108 | } | 110 | } |
109 | 111 | ||
110 | bool ProjectModel::setData(const QModelIndex &index, const QVariant &value, | 112 | bool ProjectModel::setData(const QModelIndex &index, const QVariant &value, |
@@ -112,3 +114,15 @@ bool ProjectModel::setData(const QModelIndex &index, const QVariant &value, | |||
112 | { | 114 | { |
113 | return true; | 115 | return true; |
114 | } | 116 | } |
117 | |||
118 | /* Constructor and destructor for the root class */ | ||
119 | ProjectRoot::ProjectRoot(QString config) | ||
120 | { | ||
121 | children.append(new ProjectFiles(this)); | ||
122 | } | ||
123 | |||
124 | ProjectRoot::~ProjectRoot() | ||
125 | { | ||
126 | for(int i = 0; i < children.count(); i++) | ||
127 | delete children[i]; | ||
128 | } | ||
diff --git a/utils/themeeditor/projectmodel.h b/utils/themeeditor/projectmodel.h index e3bf93dcb5..62cf00818c 100644 --- a/utils/themeeditor/projectmodel.h +++ b/utils/themeeditor/projectmodel.h | |||
@@ -32,7 +32,12 @@ Q_OBJECT | |||
32 | public: | 32 | public: |
33 | static const int numColumns = 1; | 33 | static const int numColumns = 1; |
34 | 34 | ||
35 | ProjectModel(QObject *parent = 0); | 35 | static QString fileFilter() |
36 | { | ||
37 | return QObject::tr("Project Files (*.cfg);;All Files (*.*)"); | ||
38 | } | ||
39 | |||
40 | ProjectModel(QString config, QObject *parent = 0); | ||
36 | virtual ~ProjectModel(); | 41 | virtual ~ProjectModel(); |
37 | 42 | ||
38 | QModelIndex index(int row, int column, const QModelIndex& parent) const; | 43 | QModelIndex index(int row, int column, const QModelIndex& parent) const; |
@@ -51,7 +56,6 @@ public slots: | |||
51 | 56 | ||
52 | private: | 57 | private: |
53 | ProjectNode* root; | 58 | ProjectNode* root; |
54 | |||
55 | }; | 59 | }; |
56 | 60 | ||
57 | /* A simple abstract class required for categories */ | 61 | /* A simple abstract class required for categories */ |
@@ -63,10 +67,38 @@ public: | |||
63 | virtual int numChildren() const = 0; | 67 | virtual int numChildren() const = 0; |
64 | virtual int row() const = 0; | 68 | virtual int row() const = 0; |
65 | virtual QVariant data(int column) const = 0; | 69 | virtual QVariant data(int column) const = 0; |
66 | virtual QString title() const = 0; | 70 | virtual Qt::ItemFlags flags(int column) const = 0; |
67 | virtual Qt::ItemFlags flags(const QModelIndex& index) const = 0; | 71 | virtual void activated() = 0; |
68 | virtual void activated(const QModelIndex& index) = 0; | 72 | |
73 | int indexOf(ProjectNode* child){ return children.indexOf(child); } | ||
74 | |||
75 | protected: | ||
76 | QList<ProjectNode*> children; | ||
69 | 77 | ||
70 | }; | 78 | }; |
71 | 79 | ||
80 | /* A simple implementation of ProjectNode for the root */ | ||
81 | class ProjectRoot : public ProjectNode | ||
82 | { | ||
83 | public: | ||
84 | ProjectRoot(QString config); | ||
85 | virtual ~ProjectRoot(); | ||
86 | |||
87 | virtual ProjectNode* parent() const{ return 0; } | ||
88 | virtual ProjectNode* child(int row) const | ||
89 | { | ||
90 | if(row >= 0 && row < children.count()) | ||
91 | return children[row]; | ||
92 | else | ||
93 | return 0; | ||
94 | } | ||
95 | virtual int numChildren() const{ return children.count(); } | ||
96 | virtual int row() const{ return 0; } | ||
97 | virtual QVariant data(int column) const{ return QVariant(); } | ||
98 | virtual Qt::ItemFlags flags(int column) const{ return 0; } | ||
99 | virtual void activated(){ } | ||
100 | |||
101 | }; | ||
102 | |||
103 | |||
72 | #endif // PROJECTMODEL_H | 104 | #endif // PROJECTMODEL_H |
diff --git a/utils/themeeditor/themeeditor.pro b/utils/themeeditor/themeeditor.pro index 128f56996d..d78ea681a6 100644 --- a/utils/themeeditor/themeeditor.pro +++ b/utils/themeeditor/themeeditor.pro | |||
@@ -16,7 +16,8 @@ HEADERS += tag_table.h \ | |||
16 | skindocument.h \ | 16 | skindocument.h \ |
17 | preferencesdialog.h \ | 17 | preferencesdialog.h \ |
18 | codeeditor.h \ | 18 | codeeditor.h \ |
19 | projectmodel.h | 19 | projectmodel.h \ |
20 | projectfiles.h | ||
20 | SOURCES += tag_table.c \ | 21 | SOURCES += tag_table.c \ |
21 | skin_parser.c \ | 22 | skin_parser.c \ |
22 | skin_scan.c \ | 23 | skin_scan.c \ |
@@ -29,7 +30,8 @@ SOURCES += tag_table.c \ | |||
29 | skindocument.cpp \ | 30 | skindocument.cpp \ |
30 | preferencesdialog.cpp \ | 31 | preferencesdialog.cpp \ |
31 | codeeditor.cpp \ | 32 | codeeditor.cpp \ |
32 | projectmodel.cpp | 33 | projectmodel.cpp \ |
34 | projectfiles.cpp | ||
33 | OTHER_FILES += README \ | 35 | OTHER_FILES += README \ |
34 | resources/windowicon.png \ | 36 | resources/windowicon.png \ |
35 | resources/appicon.xcf \ | 37 | resources/appicon.xcf \ |