diff options
| author | Robert Bieber <robby@bieberphoto.com> | 2010-06-17 06:59:46 +0000 |
|---|---|---|
| committer | Robert Bieber <robby@bieberphoto.com> | 2010-06-17 06:59:46 +0000 |
| commit | 75560845aad0cc8d1fccfeda5534489ca278ac80 (patch) | |
| tree | cd51bb9dfb0a8a94677ac4b4beced11de9afd5b1 /utils/themeeditor/models | |
| parent | 36b934d241d2560be6693f90c9aba501a1ec0ae7 (diff) | |
| download | rockbox-75560845aad0cc8d1fccfeda5534489ca278ac80.zip rockbox-75560845aad0cc8d1fccfeda5534489ca278ac80.tar.gz rockbox-75560845aad0cc8d1fccfeda5534489ca278ac80.tar.bz2 rockbox-75560845aad0cc8d1fccfeda5534489ca278ac80.tar.xz | |
Theme Editor: Working on renderer infrastructure
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26878 a1c6a512-1295-4272-9138-f99709370657
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 a709ea7..0b80416 100644 --- a/utils/themeeditor/models/parsetreemodel.cpp +++ b/utils/themeeditor/models/parsetreemodel.cpp @@ -36,6 +36,8 @@ ParseTreeModel::ParseTreeModel(const char* document, QObject* parent): this->root = new ParseTreeNode(tree); else this->root = 0; + + scene = new QGraphicsScene(); } @@ -264,3 +266,15 @@ bool ParseTreeModel::setData(const QModelIndex &index, const QVariant &value, emit dataChanged(index, index); return true; } + +QGraphicsScene* ParseTreeModel::render(ProjectModel* project) +{ + scene->clear(); + + /* First we set the screen size */ + int screenWidth = safeSetting(project, "#screenwidth", "300").toInt(); + int screenHeight = safeSetting(project, "#screenheight", "200").toInt(); + scene->addRect(0, 0, screenWidth, screenHeight); + + return scene; +} diff --git a/utils/themeeditor/models/parsetreemodel.h b/utils/themeeditor/models/parsetreemodel.h index 55af549..1f252a3 100644 --- a/utils/themeeditor/models/parsetreemodel.h +++ b/utils/themeeditor/models/parsetreemodel.h @@ -21,12 +21,14 @@ #include "skin_parser.h" #include "skin_debug.h" +#include "projectmodel.h" #ifndef PARSETREEMODEL_H #define PARSETREEMODEL_H #include <QAbstractItemModel> #include <QList> +#include <QGraphicsScene> #include "parsetreenode.h" @@ -58,9 +60,22 @@ public: Qt::ItemFlags flags(const QModelIndex &index) const; bool setData(const QModelIndex &index, const QVariant &value, int role); + QGraphicsScene* render(ProjectModel* project); + + static QString safeSetting(ProjectModel* project, QString key, + QString fallback) + { + if(project) + return project->getSetting(key, fallback); + else + return fallback; + } + + private: ParseTreeNode* root; struct skin_element* tree; + QGraphicsScene* scene; }; diff --git a/utils/themeeditor/models/projectmodel.h b/utils/themeeditor/models/projectmodel.h index 6623917..791c07e 100644 --- a/utils/themeeditor/models/projectmodel.h +++ b/utils/themeeditor/models/projectmodel.h @@ -44,7 +44,10 @@ public: int rowCount(const QModelIndex& parent) const; QVariant data(const QModelIndex &index, int role) const; - QString getSetting(QString key){ return settings.value(key, ""); } + QString getSetting(QString key, QString fallback = "") + { + return settings.value(key, fallback); + } signals: |