summaryrefslogtreecommitdiff
path: root/utils/themeeditor/editorwindow.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'utils/themeeditor/editorwindow.cpp')
-rw-r--r--utils/themeeditor/editorwindow.cpp63
1 files changed, 63 insertions, 0 deletions
diff --git a/utils/themeeditor/editorwindow.cpp b/utils/themeeditor/editorwindow.cpp
new file mode 100644
index 0000000000..42ca22cec2
--- /dev/null
+++ b/utils/themeeditor/editorwindow.cpp
@@ -0,0 +1,63 @@
1/***************************************************************************
2 * __________ __ ___.
3 * Open \______ \ ____ ____ | | _\_ |__ _______ ___
4 * Source | _// _ \_/ ___\| |/ /| __ \ / _ \ \/ /
5 * Jukebox | | ( <_> ) \___| < | \_\ ( <_> > < <
6 * Firmware |____|_ /\____/ \___ >__|_ \|___ /\____/__/\_ \
7 * \/ \/ \/ \/ \/
8 * $Id$
9 *
10 * Copyright (C) 2010 Robert Bieber
11 *
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.
16 *
17 * This software is distributed on an "AS IS" basis, WITHOUT WARRANTY OF ANY
18 * KIND, either express or implied.
19 *
20 ****************************************************************************/
21
22#include "editorwindow.h"
23#include "ui_editorwindow.h"
24
25#include <iostream>
26
27EditorWindow::EditorWindow(QWidget *parent) :
28 QMainWindow(parent),
29 ui(new Ui::EditorWindow)
30{
31 ui->setupUi(this);
32
33 tree = 0;
34
35 /* Connecting the buttons */
36 QObject::connect(ui->code, SIGNAL(cursorPositionChanged()),
37 this, SLOT(updateTree()));
38 QObject::connect(ui->fromTree, SIGNAL(pressed()),
39 this, SLOT(updateCode()));
40}
41
42void EditorWindow::updateTree()
43{
44 if(tree)
45 delete tree;
46
47 tree = new ParseTreeModel(ui->code->document()->toPlainText().toAscii());
48 ui->parseTree->setModel(tree);
49 ui->parseTree->expandAll();
50}
51
52void EditorWindow::updateCode()
53{
54 tree->genCode();
55 ui->code->setDocument(new QTextDocument(tree->genCode()));
56}
57
58EditorWindow::~EditorWindow()
59{
60 delete ui;
61 if(tree)
62 delete tree;
63}