1
0
Fork 0
forked from len0rd/rockbox

Theme Editor: Fixed bug in parser handling empty lines and made ParseTreeModel handle the new VIEWPORT element properly

git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26792 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
Robert Bieber 2010-06-11 19:51:34 +00:00
parent 0cca15c6d0
commit 3c95dbb208
6 changed files with 34 additions and 13 deletions

View file

@ -132,7 +132,7 @@ void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
if(errors.contains(blockNumber + 1))
{
painter.fillRect(QRect(0, top, lineNumberArea->width(),
fontMetrics().height()), Qt::red);
fontMetrics().height()), errorColor);
}
painter.setPen(Qt::black);
painter.drawText(0, top, lineNumberArea->width(),

View file

@ -61,6 +61,7 @@ public:
int lineNumberAreaWidth();
void addError(int line){ errors.append(line); }
void clearErrors(){ errors.clear(); }
void setErrorColor(QColor color){ errorColor = color; }
protected:
void resizeEvent(QResizeEvent *event);
@ -72,6 +73,7 @@ private slots:
private:
QWidget *lineNumberArea;
QList<int> errors;
QColor errorColor;
};
//![codeeditordefinition]

View file

@ -56,7 +56,6 @@ ParseTreeNode::ParseTreeNode(struct skin_element* data, ParseTreeNode* parent)
}
break;
case VIEWPORT:
case CONDITIONAL:
for(int i = 0; i < element->params_count; i++)
children.append(new ParseTreeNode(&data->params[i], this));
@ -71,6 +70,11 @@ ParseTreeNode::ParseTreeNode(struct skin_element* data, ParseTreeNode* parent)
}
break;
case VIEWPORT:
for(int i = 0; i < element->params_count; i++)
children.append(new ParseTreeNode(&data->params[i], this));
/* Deliberate fall-through here */
case LINE:
for(int i = 0; i < data->children_count; i++)
{

View file

@ -249,9 +249,19 @@ static struct skin_element* skin_parse_line_optional(char** document,
retval = skin_alloc_element();
retval->type = LINE;
retval->line = skin_line;
if(*cursor != '\0')
if(*cursor != '\0' && *cursor != '\n'
&& !(conditional && (*cursor == ARGLISTSEPERATESYM
|| *cursor == ARGLISTCLOSESYM
|| *cursor == ENUMLISTSEPERATESYM
|| *cursor == ENUMLISTCLOSESYM)))
{
retval->children_count = 1;
else retval->children_count = 0;
}
else
{
retval->children_count = 0;
}
if(retval->children_count > 0)
retval->children = skin_alloc_children(1);

View file

@ -146,10 +146,8 @@ void SkinDocument::settingsChanged()
palette.setColor(QPalette::All, QPalette::Text, fg);
editor->setPalette(palette);
errorColor = QTextCharFormat();
QColor highlight = settings.value("errorColor", Qt::red).value<QColor>();
errorColor.setBackground(highlight);
errorColor.setProperty(QTextFormat::FullWidthSelection, true);
editor->setErrorColor(highlight);
/* Setting the font */
QFont def("Monospace");
@ -175,10 +173,19 @@ void SkinDocument::codeChanged()
if(skin_error_line() > 0)
{
editor->addError(skin_error_line());
}
else
/* Now we're going to attempt parsing again at each line, until we find
one that won't error out
QTextDocument doc(editor->document()->toPlainText());
if(skin_error_line() > 0)
{
editor->setExtraSelections(QList<QTextEdit::ExtraSelection>());
QTextCursor rest(&doc);
for(int i = 0; i < skin_error_line(); i++)
rest.movePosition(QTextCursor::NextBlock,
QTextCursor::KeepAnchor);
rest.clearSelection();
}*/
}
if(editor->document()->toPlainText() != saved)

View file

@ -79,8 +79,6 @@ private:
QString saved;
QString parseStatus;
QTextCharFormat errorColor;
QLayout* layout;
CodeEditor* editor;