Theme Editor: Began integrating device configuration panel with renderer
[kugel-rb.git] / utils / themeeditor / models / parsetreemodel.h
blob463f6ca82d8559211d39e0de19ddf98405d2d87e
1 /***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
10 * Copyright (C) 2010 Robert Bieber
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.
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
20 ****************************************************************************/
22 #include "skin_parser.h"
23 #include "skin_debug.h"
24 #include "projectmodel.h"
25 #include "devicestate.h"
27 #ifndef PARSETREEMODEL_H
28 #define PARSETREEMODEL_H
30 #include <QAbstractItemModel>
31 #include <QList>
32 #include <QGraphicsScene>
34 #include "parsetreenode.h"
35 #include "devicestate.h"
37 class ParseTreeModel : public QAbstractItemModel
40 Q_OBJECT
42 public:
43 /* Constants */
44 static const int numColumns = 3;
45 static const int typeColumn = 0;
46 static const int lineColumn = 1;
47 static const int valueColumn = 2;
49 /* Initializes a tree with a skin document in a string */
50 ParseTreeModel(const char* document, QObject* parent = 0);
51 virtual ~ParseTreeModel();
53 QString genCode();
54 /* Changes the parse tree to a new document */
55 QString changeTree(const char* document);
56 QModelIndex index(int row, int column, const QModelIndex& parent) const;
57 QModelIndex parent(const QModelIndex &child) const;
58 int rowCount(const QModelIndex &parent) const;
59 int columnCount(const QModelIndex &parent) const;
60 QVariant data(const QModelIndex &index, int role) const;
61 QVariant headerData(int col, Qt::Orientation orientation, int role) const;
62 Qt::ItemFlags flags(const QModelIndex &index) const;
63 bool setData(const QModelIndex &index, const QVariant &value, int role);
65 QGraphicsScene* render(ProjectModel* project, DeviceState* device,
66 const QString* file = 0);
68 static QString safeSetting(ProjectModel* project, QString key,
69 QString fallback)
71 if(project)
72 return project->getSetting(key, fallback);
73 else
74 return fallback;
78 private:
79 ParseTreeNode* root;
80 struct skin_element* tree;
81 QGraphicsScene* scene;
86 #endif // PARSETREEMODEL_H