diff options
Diffstat (limited to 'utils/themeeditor/models')
-rw-r--r-- | utils/themeeditor/models/parsetreemodel.cpp | 14 | ||||
-rw-r--r-- | utils/themeeditor/models/parsetreemodel.h | 15 | ||||
-rw-r--r-- | utils/themeeditor/models/projectmodel.h | 5 |
3 files changed, 33 insertions, 1 deletions
diff --git a/utils/themeeditor/models/parsetreemodel.cpp b/utils/themeeditor/models/parsetreemodel.cpp index a709ea762f..0b80416d3a 100644 --- a/utils/themeeditor/models/parsetreemodel.cpp +++ b/utils/themeeditor/models/parsetreemodel.cpp | |||
@@ -36,6 +36,8 @@ ParseTreeModel::ParseTreeModel(const char* document, QObject* parent): | |||
36 | this->root = new ParseTreeNode(tree); | 36 | this->root = new ParseTreeNode(tree); |
37 | else | 37 | else |
38 | this->root = 0; | 38 | this->root = 0; |
39 | |||
40 | scene = new QGraphicsScene(); | ||
39 | } | 41 | } |
40 | 42 | ||
41 | 43 | ||
@@ -264,3 +266,15 @@ bool ParseTreeModel::setData(const QModelIndex &index, const QVariant &value, | |||
264 | emit dataChanged(index, index); | 266 | emit dataChanged(index, index); |
265 | return true; | 267 | return true; |
266 | } | 268 | } |
269 | |||
270 | QGraphicsScene* ParseTreeModel::render(ProjectModel* project) | ||
271 | { | ||
272 | scene->clear(); | ||
273 | |||
274 | /* First we set the screen size */ | ||
275 | int screenWidth = safeSetting(project, "#screenwidth", "300").toInt(); | ||
276 | int screenHeight = safeSetting(project, "#screenheight", "200").toInt(); | ||
277 | scene->addRect(0, 0, screenWidth, screenHeight); | ||
278 | |||
279 | return scene; | ||
280 | } | ||
diff --git a/utils/themeeditor/models/parsetreemodel.h b/utils/themeeditor/models/parsetreemodel.h index 55af549e6c..1f252a3f20 100644 --- a/utils/themeeditor/models/parsetreemodel.h +++ b/utils/themeeditor/models/parsetreemodel.h | |||
@@ -21,12 +21,14 @@ | |||
21 | 21 | ||
22 | #include "skin_parser.h" | 22 | #include "skin_parser.h" |
23 | #include "skin_debug.h" | 23 | #include "skin_debug.h" |
24 | #include "projectmodel.h" | ||
24 | 25 | ||
25 | #ifndef PARSETREEMODEL_H | 26 | #ifndef PARSETREEMODEL_H |
26 | #define PARSETREEMODEL_H | 27 | #define PARSETREEMODEL_H |
27 | 28 | ||
28 | #include <QAbstractItemModel> | 29 | #include <QAbstractItemModel> |
29 | #include <QList> | 30 | #include <QList> |
31 | #include <QGraphicsScene> | ||
30 | 32 | ||
31 | #include "parsetreenode.h" | 33 | #include "parsetreenode.h" |
32 | 34 | ||
@@ -58,9 +60,22 @@ public: | |||
58 | Qt::ItemFlags flags(const QModelIndex &index) const; | 60 | Qt::ItemFlags flags(const QModelIndex &index) const; |
59 | bool setData(const QModelIndex &index, const QVariant &value, int role); | 61 | bool setData(const QModelIndex &index, const QVariant &value, int role); |
60 | 62 | ||
63 | QGraphicsScene* render(ProjectModel* project); | ||
64 | |||
65 | static QString safeSetting(ProjectModel* project, QString key, | ||
66 | QString fallback) | ||
67 | { | ||
68 | if(project) | ||
69 | return project->getSetting(key, fallback); | ||
70 | else | ||
71 | return fallback; | ||
72 | } | ||
73 | |||
74 | |||
61 | private: | 75 | private: |
62 | ParseTreeNode* root; | 76 | ParseTreeNode* root; |
63 | struct skin_element* tree; | 77 | struct skin_element* tree; |
78 | QGraphicsScene* scene; | ||
64 | }; | 79 | }; |
65 | 80 | ||
66 | 81 | ||
diff --git a/utils/themeeditor/models/projectmodel.h b/utils/themeeditor/models/projectmodel.h index 6623917420..791c07ea2e 100644 --- a/utils/themeeditor/models/projectmodel.h +++ b/utils/themeeditor/models/projectmodel.h | |||
@@ -44,7 +44,10 @@ public: | |||
44 | int rowCount(const QModelIndex& parent) const; | 44 | int rowCount(const QModelIndex& parent) const; |
45 | QVariant data(const QModelIndex &index, int role) const; | 45 | QVariant data(const QModelIndex &index, int role) const; |
46 | 46 | ||
47 | QString getSetting(QString key){ return settings.value(key, ""); } | 47 | QString getSetting(QString key, QString fallback = "") |
48 | { | ||
49 | return settings.value(key, fallback); | ||
50 | } | ||
48 | 51 | ||
49 | signals: | 52 | signals: |
50 | 53 | ||