diff options
Diffstat (limited to 'utils/themeeditor/models')
-rw-r--r-- | utils/themeeditor/models/parsetreemodel.cpp | 27 | ||||
-rw-r--r-- | utils/themeeditor/models/parsetreemodel.h | 2 | ||||
-rw-r--r-- | utils/themeeditor/models/parsetreenode.cpp | 12 | ||||
-rw-r--r-- | utils/themeeditor/models/projectmodel.h | 2 |
4 files changed, 34 insertions, 9 deletions
diff --git a/utils/themeeditor/models/parsetreemodel.cpp b/utils/themeeditor/models/parsetreemodel.cpp index 41cecc4c20..4e94bfa0bf 100644 --- a/utils/themeeditor/models/parsetreemodel.cpp +++ b/utils/themeeditor/models/parsetreemodel.cpp | |||
@@ -29,6 +29,8 @@ | |||
29 | 29 | ||
30 | #include <QObject> | 30 | #include <QObject> |
31 | #include <QPixmap> | 31 | #include <QPixmap> |
32 | #include <QMap> | ||
33 | #include <QDir> | ||
32 | 34 | ||
33 | ParseTreeModel::ParseTreeModel(const char* document, QObject* parent): | 35 | ParseTreeModel::ParseTreeModel(const char* document, QObject* parent): |
34 | QAbstractItemModel(parent) | 36 | QAbstractItemModel(parent) |
@@ -270,23 +272,40 @@ bool ParseTreeModel::setData(const QModelIndex &index, const QVariant &value, | |||
270 | return true; | 272 | return true; |
271 | } | 273 | } |
272 | 274 | ||
273 | QGraphicsScene* ParseTreeModel::render(ProjectModel* project) | 275 | QGraphicsScene* ParseTreeModel::render(ProjectModel* project, |
276 | const QString* file) | ||
274 | { | 277 | { |
275 | scene->clear(); | 278 | scene->clear(); |
276 | 279 | ||
277 | /* Setting the background */ | 280 | /* Setting the background */ |
278 | scene->setBackgroundBrush(QBrush(QPixmap(":/render/scenebg.png"))); | 281 | scene->setBackgroundBrush(QBrush(QPixmap(":/render/scenebg.png"))); |
279 | 282 | ||
283 | /* Preparing settings */ | ||
284 | QMap<QString, QString> settings; | ||
285 | if(project) | ||
286 | settings = project->getSettings(); | ||
287 | |||
288 | /* Setting themebase if it can't be derived from the project */ | ||
289 | if(settings.value("themebase", "") == "" && file && QFile::exists(*file)) | ||
290 | { | ||
291 | QDir base(*file); | ||
292 | base.cdUp(); | ||
293 | settings.insert("themebase", base.canonicalPath()); | ||
294 | } | ||
295 | |||
296 | RBScreen* screen = 0; | ||
297 | RBRenderInfo info(this, project, &settings, screen); | ||
298 | |||
280 | /* Adding the screen */ | 299 | /* Adding the screen */ |
281 | RBScreen* screen = new RBScreen(project); | 300 | screen = new RBScreen(info); |
282 | scene->addItem(screen); | 301 | scene->addItem(screen); |
283 | 302 | ||
284 | RBRenderInfo info(this, project, screen); | 303 | info = RBRenderInfo(this, project, &settings, screen); |
304 | |||
285 | 305 | ||
286 | /* Rendering the tree */ | 306 | /* Rendering the tree */ |
287 | if(root) | 307 | if(root) |
288 | root->render(info); | 308 | root->render(info); |
289 | 309 | ||
290 | |||
291 | return scene; | 310 | return scene; |
292 | } | 311 | } |
diff --git a/utils/themeeditor/models/parsetreemodel.h b/utils/themeeditor/models/parsetreemodel.h index 1f252a3f20..df64403bf5 100644 --- a/utils/themeeditor/models/parsetreemodel.h +++ b/utils/themeeditor/models/parsetreemodel.h | |||
@@ -60,7 +60,7 @@ public: | |||
60 | Qt::ItemFlags flags(const QModelIndex &index) const; | 60 | Qt::ItemFlags flags(const QModelIndex &index) const; |
61 | bool setData(const QModelIndex &index, const QVariant &value, int role); | 61 | bool setData(const QModelIndex &index, const QVariant &value, int role); |
62 | 62 | ||
63 | QGraphicsScene* render(ProjectModel* project); | 63 | QGraphicsScene* render(ProjectModel* project, const QString* file = 0); |
64 | 64 | ||
65 | static QString safeSetting(ProjectModel* project, QString key, | 65 | static QString safeSetting(ProjectModel* project, QString key, |
66 | QString fallback) | 66 | QString fallback) |
diff --git a/utils/themeeditor/models/parsetreenode.cpp b/utils/themeeditor/models/parsetreenode.cpp index 97beca4c3d..a74dd2350b 100644 --- a/utils/themeeditor/models/parsetreenode.cpp +++ b/utils/themeeditor/models/parsetreenode.cpp | |||
@@ -25,6 +25,8 @@ | |||
25 | #include "parsetreenode.h" | 25 | #include "parsetreenode.h" |
26 | #include "parsetreemodel.h" | 26 | #include "parsetreemodel.h" |
27 | 27 | ||
28 | #include <iostream> | ||
29 | |||
28 | int ParseTreeNode::openConditionals = 0; | 30 | int ParseTreeNode::openConditionals = 0; |
29 | 31 | ||
30 | /* Root element constructor */ | 32 | /* Root element constructor */ |
@@ -490,11 +492,13 @@ void ParseTreeNode::render(const RBRenderInfo& info) | |||
490 | return; | 492 | return; |
491 | } | 493 | } |
492 | 494 | ||
493 | switch(element->type) | 495 | if(element->type != VIEWPORT) |
494 | { | 496 | { |
495 | case VIEWPORT: | 497 | std::cerr << QObject::tr("Error in parse tree").toStdString() |
496 | rendered = new RBViewport(element, info); | 498 | << std::endl; |
497 | break; | 499 | return; |
498 | } | 500 | } |
501 | |||
502 | rendered = new RBViewport(element, info); | ||
499 | } | 503 | } |
500 | 504 | ||
diff --git a/utils/themeeditor/models/projectmodel.h b/utils/themeeditor/models/projectmodel.h index 791c07ea2e..4cc531b88f 100644 --- a/utils/themeeditor/models/projectmodel.h +++ b/utils/themeeditor/models/projectmodel.h | |||
@@ -49,6 +49,8 @@ public: | |||
49 | return settings.value(key, fallback); | 49 | return settings.value(key, fallback); |
50 | } | 50 | } |
51 | 51 | ||
52 | const QMap<QString, QString>& getSettings() const{ return settings; } | ||
53 | |||
52 | signals: | 54 | signals: |
53 | 55 | ||
54 | public slots: | 56 | public slots: |