df64403bf5b984b74273148e11e04f3a9eb20bc6
[kugel-rb.git] / utils / themeeditor / models / parsetreemodel.h
blobdf64403bf5b984b74273148e11e04f3a9eb20bc6
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"
26 #ifndef PARSETREEMODEL_H
27 #define PARSETREEMODEL_H
29 #include <QAbstractItemModel>
30 #include <QList>
31 #include <QGraphicsScene>
33 #include "parsetreenode.h"
35 class ParseTreeModel : public QAbstractItemModel
38 Q_OBJECT
40 public:
41 /* Constants */
42 static const int numColumns = 3;
43 static const int typeColumn = 0;
44 static const int lineColumn = 1;
45 static const int valueColumn = 2;
47 /* Initializes a tree with a skin document in a string */
48 ParseTreeModel(const char* document, QObject* parent = 0);
49 virtual ~ParseTreeModel();
51 QString genCode();
52 /* Changes the parse tree to a new document */
53 QString changeTree(const char* document);
54 QModelIndex index(int row, int column, const QModelIndex& parent) const;
55 QModelIndex parent(const QModelIndex &child) const;
56 int rowCount(const QModelIndex &parent) const;
57 int columnCount(const QModelIndex &parent) const;
58 QVariant data(const QModelIndex &index, int role) const;
59 QVariant headerData(int col, Qt::Orientation orientation, int role) const;
60 Qt::ItemFlags flags(const QModelIndex &index) const;
61 bool setData(const QModelIndex &index, const QVariant &value, int role);
63 QGraphicsScene* render(ProjectModel* project, const QString* file = 0);
65 static QString safeSetting(ProjectModel* project, QString key,
66 QString fallback)
68 if(project)
69 return project->getSetting(key, fallback);
70 else
71 return fallback;
75 private:
76 ParseTreeNode* root;
77 struct skin_element* tree;
78 QGraphicsScene* scene;
83 #endif // PARSETREEMODEL_H