diff options
Diffstat (limited to 'utils')
-rw-r--r-- | utils/themeeditor/editorwindow.cpp | 1 | ||||
-rw-r--r-- | utils/themeeditor/editorwindow.ui | 2 | ||||
-rw-r--r-- | utils/themeeditor/projectfiles.cpp | 133 | ||||
-rw-r--r-- | utils/themeeditor/projectfiles.h | 73 | ||||
-rw-r--r-- | utils/themeeditor/projectmodel.cpp | 161 | ||||
-rw-r--r-- | utils/themeeditor/projectmodel.h | 67 | ||||
-rw-r--r-- | utils/themeeditor/projectsettings.cpp | 120 | ||||
-rw-r--r-- | utils/themeeditor/projectsettings.h | 71 | ||||
-rw-r--r-- | utils/themeeditor/themeeditor.pro | 8 |
9 files changed, 56 insertions, 580 deletions
diff --git a/utils/themeeditor/editorwindow.cpp b/utils/themeeditor/editorwindow.cpp index d137897763..035fe57f2d 100644 --- a/utils/themeeditor/editorwindow.cpp +++ b/utils/themeeditor/editorwindow.cpp | |||
@@ -275,7 +275,6 @@ void EditorWindow::openProject() | |||
275 | 275 | ||
276 | project = new ProjectModel(fileName, this); | 276 | project = new ProjectModel(fileName, this); |
277 | ui->projectTree->setModel(project); | 277 | ui->projectTree->setModel(project); |
278 | ui->projectTree->expandAll(); | ||
279 | 278 | ||
280 | QObject::connect(ui->projectTree, SIGNAL(activated(QModelIndex)), | 279 | QObject::connect(ui->projectTree, SIGNAL(activated(QModelIndex)), |
281 | project, SLOT(activated(QModelIndex))); | 280 | project, SLOT(activated(QModelIndex))); |
diff --git a/utils/themeeditor/editorwindow.ui b/utils/themeeditor/editorwindow.ui index a3ea666c78..61b5f222a5 100644 --- a/utils/themeeditor/editorwindow.ui +++ b/utils/themeeditor/editorwindow.ui | |||
@@ -111,7 +111,7 @@ | |||
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="QListView" name="projectTree"/> |
115 | </item> | 115 | </item> |
116 | </layout> | 116 | </layout> |
117 | </widget> | 117 | </widget> |
diff --git a/utils/themeeditor/projectfiles.cpp b/utils/themeeditor/projectfiles.cpp deleted file mode 100644 index f687e23767..0000000000 --- a/utils/themeeditor/projectfiles.cpp +++ /dev/null | |||
@@ -1,133 +0,0 @@ | |||
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(QHash<QString, QString>& settings, | ||
25 | ProjectModel* model, ProjectNode* parent) | ||
26 | : parentLink(parent) | ||
27 | { | ||
28 | base = settings.value("themebase"); | ||
29 | |||
30 | QList<QString> keys; | ||
31 | keys.append("wps"); | ||
32 | keys.append("rwps"); | ||
33 | keys.append("sbs"); | ||
34 | keys.append("rsbs"); | ||
35 | keys.append("fms"); | ||
36 | keys.append("rfms"); | ||
37 | |||
38 | for(int i = 0; i < keys.count(); i++) | ||
39 | { | ||
40 | QString file = settings.value(keys[i], ""); | ||
41 | if(file != "" && file != "-") | ||
42 | { | ||
43 | file.replace("/.rockbox/", ""); | ||
44 | children.append(new ProjectFile(file, model, this)); | ||
45 | } | ||
46 | } | ||
47 | } | ||
48 | |||
49 | ProjectFiles::~ProjectFiles() | ||
50 | { | ||
51 | for(int i = 0; i < children.count(); i++) | ||
52 | delete children[i]; | ||
53 | } | ||
54 | |||
55 | ProjectNode* ProjectFiles::parent() const | ||
56 | { | ||
57 | return parentLink; | ||
58 | } | ||
59 | |||
60 | ProjectNode* ProjectFiles::child(int row) const | ||
61 | { | ||
62 | if(row >= 0 && row < children.count()) | ||
63 | return children[row]; | ||
64 | |||
65 | return 0; | ||
66 | } | ||
67 | |||
68 | int ProjectFiles::numChildren() const | ||
69 | { | ||
70 | return children.count(); | ||
71 | } | ||
72 | |||
73 | int ProjectFiles::row() const | ||
74 | { | ||
75 | return parentLink->indexOf(const_cast<ProjectFiles*>(this)); | ||
76 | } | ||
77 | |||
78 | QVariant ProjectFiles::data(int column) const | ||
79 | { | ||
80 | if(column == 0) | ||
81 | return QObject::tr("Project Files"); | ||
82 | else | ||
83 | return QVariant(); | ||
84 | } | ||
85 | |||
86 | Qt::ItemFlags ProjectFiles::flags(int column) const | ||
87 | { | ||
88 | if(column == 0) | ||
89 | return Qt::ItemIsEnabled | Qt::ItemIsSelectable; | ||
90 | else | ||
91 | return 0; | ||
92 | } | ||
93 | |||
94 | void ProjectFiles::activated() | ||
95 | { | ||
96 | |||
97 | } | ||
98 | |||
99 | /* Project File functions */ | ||
100 | ProjectFile::ProjectFile(QString file, ProjectModel* model, | ||
101 | ProjectNode* parent) | ||
102 | :parentLink(parent), file(file) | ||
103 | { | ||
104 | this->model = model; | ||
105 | } | ||
106 | |||
107 | ProjectFile::~ProjectFile() | ||
108 | { | ||
109 | |||
110 | } | ||
111 | |||
112 | QVariant ProjectFile::data(int column) const | ||
113 | { | ||
114 | if(column == 0) | ||
115 | return file; | ||
116 | else | ||
117 | return QVariant(); | ||
118 | } | ||
119 | |||
120 | Qt::ItemFlags ProjectFile::flags(int column) const | ||
121 | { | ||
122 | if(column == 0) | ||
123 | return Qt::ItemIsEnabled | Qt::ItemIsSelectable; | ||
124 | else | ||
125 | return 0; | ||
126 | } | ||
127 | |||
128 | void ProjectFile::activated() | ||
129 | { | ||
130 | QString base = dynamic_cast<ProjectFiles*>(parentLink)->getBase(); | ||
131 | model->loadFile(base + "/" + file); | ||
132 | } | ||
133 | |||
diff --git a/utils/themeeditor/projectfiles.h b/utils/themeeditor/projectfiles.h deleted file mode 100644 index 6fec62882c..0000000000 --- a/utils/themeeditor/projectfiles.h +++ /dev/null | |||
@@ -1,73 +0,0 @@ | |||
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 | #include <QHash> | ||
27 | |||
28 | class ProjectFiles : public ProjectNode | ||
29 | { | ||
30 | public: | ||
31 | ProjectFiles(QHash<QString, QString>& settings, ProjectModel* model, | ||
32 | ProjectNode* parent); | ||
33 | virtual ~ProjectFiles(); | ||
34 | |||
35 | virtual ProjectNode* parent() const; | ||
36 | virtual ProjectNode* child(int row) const; | ||
37 | virtual int numChildren() const; | ||
38 | virtual int row() const; | ||
39 | virtual QVariant data(int column) const; | ||
40 | virtual Qt::ItemFlags flags(int column) const; | ||
41 | virtual void activated(); | ||
42 | |||
43 | QString getBase(){ return base; } | ||
44 | |||
45 | private: | ||
46 | ProjectNode* parentLink; | ||
47 | QString base; | ||
48 | |||
49 | }; | ||
50 | |||
51 | /* A class to enumerate a single file */ | ||
52 | class ProjectFile: public ProjectNode | ||
53 | { | ||
54 | public: | ||
55 | ProjectFile(QString file, ProjectModel* model, ProjectNode* parent); | ||
56 | virtual ~ProjectFile(); | ||
57 | |||
58 | virtual ProjectNode* parent() const{ return parentLink; } | ||
59 | virtual ProjectNode* child(int row) const{ return 0; } | ||
60 | virtual int numChildren() const{ return 0; } | ||
61 | virtual int row() const{ | ||
62 | return parentLink->indexOf(const_cast<ProjectFile*>(this)); | ||
63 | } | ||
64 | virtual QVariant data(int column) const; | ||
65 | virtual Qt::ItemFlags flags(int column) const; | ||
66 | virtual void activated(); | ||
67 | |||
68 | private: | ||
69 | ProjectNode* parentLink; | ||
70 | QString file; | ||
71 | }; | ||
72 | |||
73 | #endif // PROJECTFILES_H | ||
diff --git a/utils/themeeditor/projectmodel.cpp b/utils/themeeditor/projectmodel.cpp index da810d4906..925be81950 100644 --- a/utils/themeeditor/projectmodel.cpp +++ b/utils/themeeditor/projectmodel.cpp | |||
@@ -21,124 +21,18 @@ | |||
21 | 21 | ||
22 | 22 | ||
23 | #include "projectmodel.h" | 23 | #include "projectmodel.h" |
24 | #include "projectfiles.h" | ||
25 | #include "projectsettings.h" | ||
26 | #include "editorwindow.h" | 24 | #include "editorwindow.h" |
27 | 25 | ||
28 | #include <QFile> | 26 | #include <QFile> |
29 | #include <QTextStream> | 27 | #include <QTextStream> |
30 | #include <QHash> | 28 | #include <QMap> |
31 | #include <QDir> | 29 | #include <QDir> |
32 | 30 | ||
33 | ProjectModel::ProjectModel(QString config, EditorWindow* mainWindow, | 31 | ProjectModel::ProjectModel(QString config, EditorWindow* mainWindow, |
34 | QObject *parent) | 32 | QObject *parent) |
35 | : QAbstractItemModel(parent), | 33 | : QAbstractListModel(parent), |
36 | mainWindow(mainWindow) | 34 | mainWindow(mainWindow) |
37 | { | 35 | { |
38 | root = new ProjectRoot(config, this); | ||
39 | } | ||
40 | |||
41 | ProjectModel::~ProjectModel() | ||
42 | { | ||
43 | if(root) | ||
44 | delete root; | ||
45 | } | ||
46 | |||
47 | QModelIndex ProjectModel::index(int row, int column, | ||
48 | const QModelIndex& parent) const | ||
49 | { | ||
50 | |||
51 | if(!hasIndex(row, column, parent)) | ||
52 | return QModelIndex(); | ||
53 | |||
54 | ProjectNode* foundParent = root; | ||
55 | if(parent.isValid()) | ||
56 | foundParent = static_cast<ProjectNode*>(parent.internalPointer()); | ||
57 | |||
58 | if(row < foundParent->numChildren() && row >= 0) | ||
59 | return createIndex(row, column, foundParent->child(row)); | ||
60 | else | ||
61 | return QModelIndex(); | ||
62 | } | ||
63 | |||
64 | QModelIndex ProjectModel::parent(const QModelIndex &child) const | ||
65 | { | ||
66 | if(!child.isValid()) | ||
67 | return QModelIndex(); | ||
68 | |||
69 | ProjectNode* foundParent = static_cast<ProjectNode*> | ||
70 | (child.internalPointer())->parent(); | ||
71 | |||
72 | if(foundParent == root) | ||
73 | return QModelIndex(); | ||
74 | |||
75 | return createIndex(foundParent->row(), 0, foundParent); | ||
76 | } | ||
77 | |||
78 | int ProjectModel::rowCount(const QModelIndex &parent) const | ||
79 | { | ||
80 | if(!root) | ||
81 | return 0; | ||
82 | |||
83 | if(!parent.isValid()) | ||
84 | return root->numChildren(); | ||
85 | |||
86 | if(parent.column() != 0) | ||
87 | return 0; | ||
88 | |||
89 | return static_cast<ProjectNode*>(parent.internalPointer())->numChildren(); | ||
90 | } | ||
91 | |||
92 | int ProjectModel::columnCount(const QModelIndex &parent) const | ||
93 | { | ||
94 | return numColumns; | ||
95 | } | ||
96 | |||
97 | QVariant ProjectModel::data(const QModelIndex &index, int role) const | ||
98 | { | ||
99 | if(!index.isValid()) | ||
100 | return QVariant(); | ||
101 | |||
102 | if(role != Qt::DisplayRole) | ||
103 | return QVariant(); | ||
104 | |||
105 | return static_cast<ProjectNode*> | ||
106 | (index.internalPointer())->data(index.column()); | ||
107 | } | ||
108 | |||
109 | QVariant ProjectModel::headerData(int col, Qt::Orientation orientation, | ||
110 | int role) const | ||
111 | { | ||
112 | return QVariant(); | ||
113 | } | ||
114 | |||
115 | Qt::ItemFlags ProjectModel::flags(const QModelIndex &index) const | ||
116 | { | ||
117 | return static_cast<ProjectNode*> | ||
118 | (index.internalPointer())->flags(index.column()); | ||
119 | } | ||
120 | |||
121 | bool ProjectModel::setData(const QModelIndex &index, const QVariant &value, | ||
122 | int role) | ||
123 | { | ||
124 | return true; | ||
125 | } | ||
126 | |||
127 | void ProjectModel::loadFile(QString file) | ||
128 | { | ||
129 | mainWindow->loadTabFromFile(file); | ||
130 | } | ||
131 | |||
132 | void ProjectModel::activated(const QModelIndex &index) | ||
133 | { | ||
134 | static_cast<ProjectNode*>(index.internalPointer())->activated(); | ||
135 | } | ||
136 | |||
137 | /* Constructor and destructor for the root class */ | ||
138 | ProjectRoot::ProjectRoot(QString config, ProjectModel* model) | ||
139 | { | ||
140 | this->model = model; | ||
141 | |||
142 | /* Reading the config file */ | 36 | /* Reading the config file */ |
143 | QFile cfg(config); | 37 | QFile cfg(config); |
144 | cfg.open(QFile::ReadOnly | QFile::Text); | 38 | cfg.open(QFile::ReadOnly | QFile::Text); |
@@ -172,14 +66,53 @@ ProjectRoot::ProjectRoot(QString config, ProjectModel* model) | |||
172 | 66 | ||
173 | cfg.close(); | 67 | cfg.close(); |
174 | 68 | ||
175 | /* Showing the files */ | 69 | /* Adding the files, starting with the .cfg */ |
176 | children.append(new ProjectFiles(settings, model, this)); | 70 | config.replace(base.canonicalPath() + "/", ""); |
177 | children.append(new ProjectSettings(settings, model, this)); | 71 | files.append(config); |
72 | |||
73 | QList<QString> keys; | ||
74 | keys.append("wps"); | ||
75 | keys.append("rwps"); | ||
76 | keys.append("sbs"); | ||
77 | keys.append("rsbs"); | ||
78 | keys.append("fms"); | ||
79 | keys.append("rfms"); | ||
80 | |||
81 | for(int i = 0; i < keys.count(); i++) | ||
82 | { | ||
83 | QString file = settings.value(keys[i], ""); | ||
84 | if(file != "" && file != "-") | ||
85 | { | ||
86 | file.replace("/.rockbox/", ""); | ||
87 | files.append(file); | ||
88 | } | ||
89 | } | ||
178 | 90 | ||
91 | |||
92 | } | ||
93 | |||
94 | ProjectModel::~ProjectModel() | ||
95 | { | ||
179 | } | 96 | } |
180 | 97 | ||
181 | ProjectRoot::~ProjectRoot() | 98 | int ProjectModel::rowCount(const QModelIndex& parent) const |
99 | { | ||
100 | return files.count(); | ||
101 | } | ||
102 | |||
103 | QVariant ProjectModel::data(const QModelIndex &index, int role) const | ||
104 | { | ||
105 | if(!index.isValid()) | ||
106 | return QVariant(); | ||
107 | |||
108 | if(role != Qt::DisplayRole) | ||
109 | return QVariant(); | ||
110 | |||
111 | return files[index.row()]; | ||
112 | } | ||
113 | |||
114 | void ProjectModel::activated(const QModelIndex &index) | ||
182 | { | 115 | { |
183 | for(int i = 0; i < children.count(); i++) | 116 | mainWindow->loadTabFromFile(settings.value("themebase", "") |
184 | delete children[i]; | 117 | + "/" + files[index.row()]); |
185 | } | 118 | } |
diff --git a/utils/themeeditor/projectmodel.h b/utils/themeeditor/projectmodel.h index c7147fa83f..d577f00a69 100644 --- a/utils/themeeditor/projectmodel.h +++ b/utils/themeeditor/projectmodel.h | |||
@@ -22,13 +22,12 @@ | |||
22 | #ifndef PROJECTMODEL_H | 22 | #ifndef PROJECTMODEL_H |
23 | #define PROJECTMODEL_H | 23 | #define PROJECTMODEL_H |
24 | 24 | ||
25 | #include <QAbstractItemModel> | 25 | #include <QAbstractListModel> |
26 | #include <QHash> | 26 | #include <QMap> |
27 | 27 | ||
28 | class ProjectNode; | ||
29 | class EditorWindow; | 28 | class EditorWindow; |
30 | 29 | ||
31 | class ProjectModel : public QAbstractItemModel | 30 | class ProjectModel : public QAbstractListModel |
32 | { | 31 | { |
33 | Q_OBJECT | 32 | Q_OBJECT |
34 | public: | 33 | public: |
@@ -42,16 +41,8 @@ public: | |||
42 | ProjectModel(QString config, EditorWindow* mainWindow, QObject *parent = 0); | 41 | ProjectModel(QString config, EditorWindow* mainWindow, QObject *parent = 0); |
43 | virtual ~ProjectModel(); | 42 | virtual ~ProjectModel(); |
44 | 43 | ||
45 | QModelIndex index(int row, int column, const QModelIndex& parent) const; | 44 | int rowCount(const QModelIndex& parent) const; |
46 | QModelIndex parent(const QModelIndex &child) const; | ||
47 | int rowCount(const QModelIndex &parent) const; | ||
48 | int columnCount(const QModelIndex &parent) const; | ||
49 | QVariant data(const QModelIndex &index, int role) const; | 45 | QVariant data(const QModelIndex &index, int role) const; |
50 | QVariant headerData(int col, Qt::Orientation orientation, int role) const; | ||
51 | Qt::ItemFlags flags(const QModelIndex &index) const; | ||
52 | bool setData(const QModelIndex &index, const QVariant &value, int role); | ||
53 | |||
54 | void loadFile(QString file); | ||
55 | 46 | ||
56 | signals: | 47 | signals: |
57 | 48 | ||
@@ -59,55 +50,9 @@ public slots: | |||
59 | void activated(const QModelIndex& index); | 50 | void activated(const QModelIndex& index); |
60 | 51 | ||
61 | private: | 52 | private: |
62 | ProjectNode* root; | ||
63 | EditorWindow* mainWindow; | 53 | EditorWindow* mainWindow; |
54 | QMap<QString, QString> settings; | ||
55 | QList<QString> files; | ||
64 | }; | 56 | }; |
65 | 57 | ||
66 | /* A simple abstract class required for categories */ | ||
67 | class ProjectNode | ||
68 | { | ||
69 | public: | ||
70 | virtual ProjectNode* parent() const = 0; | ||
71 | virtual ProjectNode* child(int row) const = 0; | ||
72 | virtual int numChildren() const = 0; | ||
73 | virtual int row() const = 0; | ||
74 | virtual QVariant data(int column) const = 0; | ||
75 | virtual Qt::ItemFlags flags(int column) const = 0; | ||
76 | virtual void activated() = 0; | ||
77 | |||
78 | int indexOf(ProjectNode* child){ return children.indexOf(child); } | ||
79 | |||
80 | protected: | ||
81 | QList<ProjectNode*> children; | ||
82 | ProjectModel* model; | ||
83 | |||
84 | }; | ||
85 | |||
86 | /* A simple implementation of ProjectNode for the root */ | ||
87 | class ProjectRoot : public ProjectNode | ||
88 | { | ||
89 | public: | ||
90 | ProjectRoot(QString config, ProjectModel* model); | ||
91 | virtual ~ProjectRoot(); | ||
92 | |||
93 | virtual ProjectNode* parent() const{ return 0; } | ||
94 | virtual ProjectNode* child(int row) const | ||
95 | { | ||
96 | if(row >= 0 && row < children.count()) | ||
97 | return children[row]; | ||
98 | else | ||
99 | return 0; | ||
100 | } | ||
101 | virtual int numChildren() const{ return children.count(); } | ||
102 | virtual int row() const{ return 0; } | ||
103 | virtual QVariant data(int column) const{ return QVariant(); } | ||
104 | virtual Qt::ItemFlags flags(int column) const{ return 0; } | ||
105 | virtual void activated(){ } | ||
106 | |||
107 | private: | ||
108 | QHash<QString, QString> settings; | ||
109 | |||
110 | }; | ||
111 | |||
112 | |||
113 | #endif // PROJECTMODEL_H | 58 | #endif // PROJECTMODEL_H |
diff --git a/utils/themeeditor/projectsettings.cpp b/utils/themeeditor/projectsettings.cpp deleted file mode 100644 index a477f2bdfc..0000000000 --- a/utils/themeeditor/projectsettings.cpp +++ /dev/null | |||
@@ -1,120 +0,0 @@ | |||
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 "projectsettings.h" | ||
23 | |||
24 | ProjectSettings::ProjectSettings(QHash<QString, QString>& settings, | ||
25 | ProjectModel* model, ProjectNode* parent) | ||
26 | : parentLink(parent) | ||
27 | { | ||
28 | QHash<QString, QString>::iterator i; | ||
29 | for(i = settings.begin(); i != settings.end(); i++) | ||
30 | { | ||
31 | QPair<QString, QString> value(i.key(), i.value()); | ||
32 | children.append(new ProjectSetting(value, model, this)); | ||
33 | } | ||
34 | } | ||
35 | |||
36 | ProjectSettings::~ProjectSettings() | ||
37 | { | ||
38 | for(int i = 0; i < children.count(); i++) | ||
39 | delete children[i]; | ||
40 | } | ||
41 | |||
42 | ProjectNode* ProjectSettings::parent() const | ||
43 | { | ||
44 | return parentLink; | ||
45 | } | ||
46 | |||
47 | ProjectNode* ProjectSettings::child(int row) const | ||
48 | { | ||
49 | if(row >= 0 && row < children.count()) | ||
50 | return children[row]; | ||
51 | |||
52 | return 0; | ||
53 | } | ||
54 | |||
55 | int ProjectSettings::numChildren() const | ||
56 | { | ||
57 | return children.count(); | ||
58 | } | ||
59 | |||
60 | int ProjectSettings::row() const | ||
61 | { | ||
62 | return parentLink->indexOf(const_cast<ProjectSettings*>(this)); | ||
63 | } | ||
64 | |||
65 | QVariant ProjectSettings::data(int column) const | ||
66 | { | ||
67 | if(column == 0) | ||
68 | return QObject::tr("Project Settings"); | ||
69 | else | ||
70 | return QVariant(); | ||
71 | } | ||
72 | |||
73 | Qt::ItemFlags ProjectSettings::flags(int column) const | ||
74 | { | ||
75 | if(column == 0) | ||
76 | return Qt::ItemIsEnabled | Qt::ItemIsSelectable; | ||
77 | else | ||
78 | return 0; | ||
79 | } | ||
80 | |||
81 | void ProjectSettings::activated() | ||
82 | { | ||
83 | |||
84 | } | ||
85 | |||
86 | /* Project File functions */ | ||
87 | ProjectSetting::ProjectSetting(QPair<QString, QString> setting, | ||
88 | ProjectModel* model, ProjectNode* parent) | ||
89 | :parentLink(parent), setting(setting) | ||
90 | { | ||
91 | this->model = model; | ||
92 | } | ||
93 | |||
94 | ProjectSetting::~ProjectSetting() | ||
95 | { | ||
96 | |||
97 | } | ||
98 | |||
99 | QVariant ProjectSetting::data(int column) const | ||
100 | { | ||
101 | if(column == 0) | ||
102 | return setting.first; | ||
103 | else if(column == 1) | ||
104 | return setting.second; | ||
105 | else | ||
106 | return QVariant(); | ||
107 | } | ||
108 | |||
109 | Qt::ItemFlags ProjectSetting::flags(int column) const | ||
110 | { | ||
111 | if(column == 0 || column == 1) | ||
112 | return Qt::ItemIsEnabled | Qt::ItemIsSelectable; | ||
113 | else | ||
114 | return 0; | ||
115 | } | ||
116 | |||
117 | void ProjectSetting::activated() | ||
118 | { | ||
119 | } | ||
120 | |||
diff --git a/utils/themeeditor/projectsettings.h b/utils/themeeditor/projectsettings.h deleted file mode 100644 index ed785ac02c..0000000000 --- a/utils/themeeditor/projectsettings.h +++ /dev/null | |||
@@ -1,71 +0,0 @@ | |||
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 PROJCETSETTINGS_H | ||
23 | #define PROJECTSETTINGS_H | ||
24 | |||
25 | #include "projectmodel.h" | ||
26 | #include <QHash> | ||
27 | |||
28 | class ProjectSettings : public ProjectNode | ||
29 | { | ||
30 | public: | ||
31 | ProjectSettings(QHash<QString, QString>& settings, ProjectModel* model, | ||
32 | ProjectNode* parent); | ||
33 | virtual ~ProjectSettings(); | ||
34 | |||
35 | virtual ProjectNode* parent() const; | ||
36 | virtual ProjectNode* child(int row) const; | ||
37 | virtual int numChildren() const; | ||
38 | virtual int row() const; | ||
39 | virtual QVariant data(int column) const; | ||
40 | virtual Qt::ItemFlags flags(int column) const; | ||
41 | virtual void activated(); | ||
42 | |||
43 | private: | ||
44 | ProjectNode* parentLink; | ||
45 | |||
46 | }; | ||
47 | |||
48 | /* A class to enumerate a single file */ | ||
49 | class ProjectSetting: public ProjectNode | ||
50 | { | ||
51 | public: | ||
52 | ProjectSetting(QPair<QString, QString> setting, ProjectModel* model, | ||
53 | ProjectNode* parent); | ||
54 | virtual ~ProjectSetting(); | ||
55 | |||
56 | virtual ProjectNode* parent() const{ return parentLink; } | ||
57 | virtual ProjectNode* child(int row) const{ return 0; } | ||
58 | virtual int numChildren() const{ return 0; } | ||
59 | virtual int row() const{ | ||
60 | return parentLink->indexOf(const_cast<ProjectSetting*>(this)); | ||
61 | } | ||
62 | virtual QVariant data(int column) const; | ||
63 | virtual Qt::ItemFlags flags(int column) const; | ||
64 | virtual void activated(); | ||
65 | |||
66 | private: | ||
67 | ProjectNode* parentLink; | ||
68 | QPair<QString, QString> setting; | ||
69 | }; | ||
70 | |||
71 | #endif // PROJECTSETTINGS_H | ||
diff --git a/utils/themeeditor/themeeditor.pro b/utils/themeeditor/themeeditor.pro index b86b4debb4..128f56996d 100644 --- a/utils/themeeditor/themeeditor.pro +++ b/utils/themeeditor/themeeditor.pro | |||
@@ -16,9 +16,7 @@ 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 \ | ||
21 | projectsettings.h | ||
22 | SOURCES += tag_table.c \ | 20 | SOURCES += tag_table.c \ |
23 | skin_parser.c \ | 21 | skin_parser.c \ |
24 | skin_scan.c \ | 22 | skin_scan.c \ |
@@ -31,9 +29,7 @@ SOURCES += tag_table.c \ | |||
31 | skindocument.cpp \ | 29 | skindocument.cpp \ |
32 | preferencesdialog.cpp \ | 30 | preferencesdialog.cpp \ |
33 | codeeditor.cpp \ | 31 | codeeditor.cpp \ |
34 | projectmodel.cpp \ | 32 | projectmodel.cpp |
35 | projectfiles.cpp \ | ||
36 | projectsettings.cpp | ||
37 | OTHER_FILES += README \ | 33 | OTHER_FILES += README \ |
38 | resources/windowicon.png \ | 34 | resources/windowicon.png \ |
39 | resources/appicon.xcf \ | 35 | resources/appicon.xcf \ |