forked from len0rd/rockbox
Theme Editor: Switched error highlighting to the line numbers
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26785 a1c6a512-1295-4272-9138-f99709370657
This commit is contained in:
parent
3fec40194c
commit
0c38353869
3 changed files with 13 additions and 13 deletions
|
@ -128,9 +128,15 @@ void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
|
|||
while (block.isValid() && top <= event->rect().bottom()) {
|
||||
if (block.isVisible() && bottom >= event->rect().top()) {
|
||||
QString number = QString::number(blockNumber + 1);
|
||||
/* Drawing an error circle if necessary */
|
||||
if(errors.contains(blockNumber + 1))
|
||||
{
|
||||
painter.fillRect(QRect(0, top, lineNumberArea->width(),
|
||||
fontMetrics().height()), Qt::red);
|
||||
}
|
||||
painter.setPen(Qt::black);
|
||||
painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(),
|
||||
Qt::AlignRight, number);
|
||||
painter.drawText(0, top, lineNumberArea->width(),
|
||||
fontMetrics().height(), Qt::AlignRight, number);
|
||||
}
|
||||
|
||||
block = block.next();
|
||||
|
|
|
@ -59,6 +59,8 @@ public:
|
|||
|
||||
void lineNumberAreaPaintEvent(QPaintEvent *event);
|
||||
int lineNumberAreaWidth();
|
||||
void addError(int line){ errors.append(line); }
|
||||
void clearErrors(){ errors.clear(); }
|
||||
|
||||
protected:
|
||||
void resizeEvent(QResizeEvent *event);
|
||||
|
@ -69,6 +71,7 @@ private slots:
|
|||
|
||||
private:
|
||||
QWidget *lineNumberArea;
|
||||
QList<int> errors;
|
||||
};
|
||||
|
||||
//![codeeditordefinition]
|
||||
|
|
|
@ -166,6 +166,7 @@ void SkinDocument::settingsChanged()
|
|||
|
||||
void SkinDocument::codeChanged()
|
||||
{
|
||||
editor->clearErrors();
|
||||
parseStatus = model->changeTree(editor->document()->
|
||||
toPlainText().toAscii());
|
||||
statusLabel->setText(parseStatus);
|
||||
|
@ -173,17 +174,7 @@ void SkinDocument::codeChanged()
|
|||
/* Highlighting if an error was found */
|
||||
if(skin_error_line() > 0)
|
||||
{
|
||||
QList<QTextEdit::ExtraSelection> highlight;
|
||||
QTextEdit::ExtraSelection error;
|
||||
|
||||
/* Finding the apropriate line */
|
||||
error.cursor = QTextCursor(editor->document()->
|
||||
findBlockByNumber(skin_error_line() - 1));
|
||||
error.format = errorColor;
|
||||
highlight.append(error);
|
||||
|
||||
editor->setExtraSelections(highlight);
|
||||
|
||||
editor->addError(skin_error_line());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue