summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-06-07 20:29:46 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-06-07 20:29:46 +0000
commit0e44ce9bedbea1244ef971b48f38a9c48eecf0f5 (patch)
tree79b074202ee1d425abbfb5bb2449701a5fba48bc
parentbd2ba8068c6cbc58299e98896abd08301a51214f (diff)
downloadrockbox-0e44ce9bedbea1244ef971b48f38a9c48eecf0f5.tar.gz
rockbox-0e44ce9bedbea1244ef971b48f38a9c48eecf0f5.tar.bz2
rockbox-0e44ce9bedbea1244ef971b48f38a9c48eecf0f5.zip
Theme Editor: Changed anged error reporting method in parser, added error messages to status bar in editor
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26672 a1c6a512-1295-4272-9138-f99709370657
-rw-r--r--utils/themeeditor/editorwindow.cpp12
-rw-r--r--utils/themeeditor/editorwindow.h2
-rw-r--r--utils/themeeditor/parsetreemodel.cpp13
-rw-r--r--utils/themeeditor/parsetreemodel.h3
-rw-r--r--utils/themeeditor/skin_debug.c40
-rw-r--r--utils/themeeditor/skin_debug.h2
-rw-r--r--utils/themeeditor/skindocument.cpp11
-rw-r--r--utils/themeeditor/skindocument.h9
8 files changed, 65 insertions, 27 deletions
diff --git a/utils/themeeditor/editorwindow.cpp b/utils/themeeditor/editorwindow.cpp
index 8e81829a41..ca5f8bfa73 100644
--- a/utils/themeeditor/editorwindow.cpp
+++ b/utils/themeeditor/editorwindow.cpp
@@ -94,6 +94,10 @@ void EditorWindow::setupUI()
QObject::connect(ui->actionPreferences, SIGNAL(triggered()),
prefs, SLOT(exec()));
+ /* Setting up the parse status label */
+ parseStatus = new QLabel(this);
+ ui->statusbar->addWidget(parseStatus);
+
}
void EditorWindow::setupMenus()
@@ -144,7 +148,7 @@ void EditorWindow::addTab(SkinDocument *doc)
void EditorWindow::newTab()
{
- SkinDocument* doc = new SkinDocument;
+ SkinDocument* doc = new SkinDocument(parseStatus);
addTab(doc);
}
@@ -161,8 +165,12 @@ void EditorWindow::shiftTab(int index)
}
else
{
+ /* Syncing the tree view and the status bar */
ui->parseTree->setModel(dynamic_cast<SkinDocument*>
(ui->editorTabs->currentWidget())->getModel());
+ parseStatus->setText(dynamic_cast<SkinDocument*>
+ (ui->editorTabs->currentWidget())->getStatus());
+
ui->actionSave_Document->setEnabled(true);
ui->actionSave_Document_As->setEnabled(true);
ui->actionClose_Document->setEnabled(true);
@@ -220,7 +228,7 @@ void EditorWindow::openFile()
QString current = fileNames[i];
/* Adding a new document for each file name */
- SkinDocument* doc = new SkinDocument(current);
+ SkinDocument* doc = new SkinDocument(parseStatus, current);
addTab(doc);
/* And setting the new default directory */
diff --git a/utils/themeeditor/editorwindow.h b/utils/themeeditor/editorwindow.h
index 5f39ed35d6..3bab704bb6 100644
--- a/utils/themeeditor/editorwindow.h
+++ b/utils/themeeditor/editorwindow.h
@@ -23,6 +23,7 @@
#define EDITORWINDOW_H
#include <QMainWindow>
+#include <QLabel>
#include "parsetreemodel.h"
#include "skinhighlighter.h"
@@ -64,6 +65,7 @@ private:
Ui::EditorWindow *ui;
PreferencesDialog* prefs;
+ QLabel* parseStatus;
};
#endif // EDITORWINDOW_H
diff --git a/utils/themeeditor/parsetreemodel.cpp b/utils/themeeditor/parsetreemodel.cpp
index 8da0c26ef3..787122d02d 100644
--- a/utils/themeeditor/parsetreemodel.cpp
+++ b/utils/themeeditor/parsetreemodel.cpp
@@ -55,18 +55,23 @@ QString ParseTreeModel::genCode()
return "";
}
-bool ParseTreeModel::changeTree(const char *document)
+QString ParseTreeModel::changeTree(const char *document)
{
struct skin_element* test = skin_parse(document);
if(!test)
- return false;
+ {
+ QString error = tr("Error on line ") +
+ QString::number(skin_error_line())
+ + tr(": ") + QString(skin_error_message());
+ return error;
+ }
ParseTreeNode* temp = new ParseTreeNode(test);
if(root && temp->genHash() == root->genHash())
{
delete temp;
- return true;
+ return tr("Document Parses Successfully");
}
if(root)
@@ -81,7 +86,7 @@ bool ParseTreeModel::changeTree(const char *document)
emit beginInsertRows(QModelIndex(), 0, temp->numChildren() - 1);
emit endInsertRows();
- return true;
+ return tr("Document Parses Successfully");
}
diff --git a/utils/themeeditor/parsetreemodel.h b/utils/themeeditor/parsetreemodel.h
index 76960937f1..55af549e6c 100644
--- a/utils/themeeditor/parsetreemodel.h
+++ b/utils/themeeditor/parsetreemodel.h
@@ -48,8 +48,7 @@ public:
QString genCode();
/* Changes the parse tree to a new document */
- bool changeTree(const char* document);
-
+ QString changeTree(const char* document);
QModelIndex index(int row, int column, const QModelIndex& parent) const;
QModelIndex parent(const QModelIndex &child) const;
int rowCount(const QModelIndex &parent) const;
diff --git a/utils/themeeditor/skin_debug.c b/utils/themeeditor/skin_debug.c
index 4d691892ff..4a2ef32206 100644
--- a/utils/themeeditor/skin_debug.c
+++ b/utils/themeeditor/skin_debug.c
@@ -31,54 +31,68 @@
int debug_indent_level = 0;
extern int skin_line;
+/* Global error variables */
+int error_line;
+char* error_message;
+
/* Debugging functions */
void skin_error(enum skin_errorcode error)
{
- fprintf(stderr, "Error on line %d: ", skin_line);
+ error_line = skin_line;
switch(error)
{
case MEMORY_LIMIT_EXCEEDED:
- fprintf(stderr, "Memory limit exceeded\n");
+ error_message = "Memory limit exceeded";
break;
case NEWLINE_EXPECTED:
- fprintf(stderr, "Newline expected\n");
+ error_message = "Newline expected";
break;
case ILLEGAL_TAG:
- fprintf(stderr, "Illegal tag\n");
+ error_message = "Illegal tag";
break;
case ARGLIST_EXPECTED:
- fprintf(stderr, "Argument list expected\n");
+ error_message = "Argument list expected";
break;
case TOO_MANY_ARGS:
- fprintf(stderr, "Too many arguments given\n");
+ error_message = "Too many arguments given";
break;
case DEFAULT_NOT_ALLOWED:
- fprintf(stderr, "Argument can not be set to default\n");
+ error_message = "Argument can not be set to default";
break;
case UNEXPECTED_NEWLINE:
- fprintf(stderr, "Unexpected newline\n");
+ error_message = "Unexpected newline";
break;
case INSUFFICIENT_ARGS:
- fprintf(stderr, "Not enough arguments\n");
+ error_message = "Not enough arguments";
break;
case INT_EXPECTED:
- fprintf(stderr, "Expected integer\n");
+ error_message = "Expected integer";
break;
case SEPERATOR_EXPECTED:
- fprintf(stderr, "Expected argument seperator\n");
+ error_message = "Expected argument seperator";
break;
case CLOSE_EXPECTED:
- fprintf(stderr, "Expected list close\n");
+ error_message = "Expected list close";
break;
case MULTILINE_EXPECTED:
- fprintf(stderr, "Expected subline seperator\n");
+ error_message = "Expected subline seperator";
break;
};
}
+int skin_error_line()
+{
+ return error_line;
+}
+
+char* skin_error_message()
+{
+ return error_message;
+}
+
void skin_debug_tree(struct skin_element* root)
{
int i;
diff --git a/utils/themeeditor/skin_debug.h b/utils/themeeditor/skin_debug.h
index 6b2a1bd1f5..24c66e6671 100644
--- a/utils/themeeditor/skin_debug.h
+++ b/utils/themeeditor/skin_debug.h
@@ -32,6 +32,8 @@ extern "C"
/* Debugging functions */
void skin_error(enum skin_errorcode error);
+int skin_error_line();
+char* skin_error_message();
void skin_debug_tree(struct skin_element* root);
/* Auxiliary debug functions */
diff --git a/utils/themeeditor/skindocument.cpp b/utils/themeeditor/skindocument.cpp
index 80a4fa330d..c7b69688f6 100644
--- a/utils/themeeditor/skindocument.cpp
+++ b/utils/themeeditor/skindocument.cpp
@@ -27,7 +27,8 @@
#include <QMessageBox>
#include <QFileDialog>
-SkinDocument::SkinDocument(QWidget *parent) : QWidget(parent)
+SkinDocument::SkinDocument(QLabel* statusLabel, QWidget *parent) :
+ QWidget(parent), statusLabel(statusLabel)
{
setupUI();
@@ -36,8 +37,8 @@ SkinDocument::SkinDocument(QWidget *parent) : QWidget(parent)
saved = "";
}
-SkinDocument::SkinDocument(QString file, QWidget *parent):
- QWidget(parent), fileName(file)
+SkinDocument::SkinDocument(QLabel* statusLabel, QString file, QWidget *parent):
+ QWidget(parent), fileName(file), statusLabel(statusLabel)
{
setupUI();
@@ -155,7 +156,9 @@ void SkinDocument::settingsChanged()
void SkinDocument::codeChanged()
{
- model->changeTree(editor->document()->toPlainText().toAscii());
+ parseStatus = model->changeTree(editor->document()->
+ toPlainText().toAscii());
+ statusLabel->setText(parseStatus);
if(editor->document()->toPlainText() != saved)
emit titleChanged(title + QChar('*'));
diff --git a/utils/themeeditor/skindocument.h b/utils/themeeditor/skindocument.h
index cf8f8a0313..4a6516f6de 100644
--- a/utils/themeeditor/skindocument.h
+++ b/utils/themeeditor/skindocument.h
@@ -23,6 +23,7 @@
#define SKINDOCUMENT_H
#include <QWidget>
+#include <QLabel>
#include <QHBoxLayout>
#include <QPlainTextEdit>
@@ -44,14 +45,15 @@ public:
"All Files (*.*)");
}
- SkinDocument(QWidget *parent = 0);
- SkinDocument(QString file, QWidget* parent = 0);
+ SkinDocument(QLabel* statusLabel, QWidget *parent = 0);
+ SkinDocument(QLabel* statusLabel, QString file, QWidget* parent = 0);
virtual ~SkinDocument();
void connectPrefs(PreferencesDialog* prefs);
ParseTreeModel* getModel(){ return model; }
QString getTitle(){ return title; }
+ QString getStatus(){ return parseStatus; }
void genCode(){ editor->document()->setPlainText(model->genCode()); }
void save();
@@ -74,12 +76,15 @@ private:
QString title;
QString fileName;
QString saved;
+ QString parseStatus;
QLayout* layout;
QPlainTextEdit* editor;
SkinHighlighter* highlighter;
ParseTreeModel* model;
+
+ QLabel* statusLabel;
};
#endif // SKINDOCUMENT_H