summaryrefslogtreecommitdiff
path: root/utils/themeeditor
diff options
context:
space:
mode:
authorRobert Bieber <robby@bieberphoto.com>2010-06-11 19:03:49 +0000
committerRobert Bieber <robby@bieberphoto.com>2010-06-11 19:03:49 +0000
commit0c383538693f04d1e5bc81f4af6a6e9585296bcb (patch)
treed024070233b007b1e1c232c600f9b17009b2bd2e /utils/themeeditor
parent3fec40194c2c07a1693536f08cb9214cec390cf9 (diff)
downloadrockbox-0c383538693f04d1e5bc81f4af6a6e9585296bcb.tar.gz
rockbox-0c383538693f04d1e5bc81f4af6a6e9585296bcb.zip
Theme Editor: Switched error highlighting to the line numbers
git-svn-id: svn://svn.rockbox.org/rockbox/trunk@26785 a1c6a512-1295-4272-9138-f99709370657
Diffstat (limited to 'utils/themeeditor')
-rw-r--r--utils/themeeditor/codeeditor.cpp10
-rw-r--r--utils/themeeditor/codeeditor.h3
-rw-r--r--utils/themeeditor/skindocument.cpp13
3 files changed, 13 insertions, 13 deletions
diff --git a/utils/themeeditor/codeeditor.cpp b/utils/themeeditor/codeeditor.cpp
index 672b210d2e..d4b46ac52e 100644
--- a/utils/themeeditor/codeeditor.cpp
+++ b/utils/themeeditor/codeeditor.cpp
@@ -128,9 +128,15 @@ void CodeEditor::lineNumberAreaPaintEvent(QPaintEvent *event)
128 while (block.isValid() && top <= event->rect().bottom()) { 128 while (block.isValid() && top <= event->rect().bottom()) {
129 if (block.isVisible() && bottom >= event->rect().top()) { 129 if (block.isVisible() && bottom >= event->rect().top()) {
130 QString number = QString::number(blockNumber + 1); 130 QString number = QString::number(blockNumber + 1);
131 /* Drawing an error circle if necessary */
132 if(errors.contains(blockNumber + 1))
133 {
134 painter.fillRect(QRect(0, top, lineNumberArea->width(),
135 fontMetrics().height()), Qt::red);
136 }
131 painter.setPen(Qt::black); 137 painter.setPen(Qt::black);
132 painter.drawText(0, top, lineNumberArea->width(), fontMetrics().height(), 138 painter.drawText(0, top, lineNumberArea->width(),
133 Qt::AlignRight, number); 139 fontMetrics().height(), Qt::AlignRight, number);
134 } 140 }
135 141
136 block = block.next(); 142 block = block.next();
diff --git a/utils/themeeditor/codeeditor.h b/utils/themeeditor/codeeditor.h
index edbe218ec4..ec36d50c22 100644
--- a/utils/themeeditor/codeeditor.h
+++ b/utils/themeeditor/codeeditor.h
@@ -59,6 +59,8 @@ public:
59 59
60 void lineNumberAreaPaintEvent(QPaintEvent *event); 60 void lineNumberAreaPaintEvent(QPaintEvent *event);
61 int lineNumberAreaWidth(); 61 int lineNumberAreaWidth();
62 void addError(int line){ errors.append(line); }
63 void clearErrors(){ errors.clear(); }
62 64
63protected: 65protected:
64 void resizeEvent(QResizeEvent *event); 66 void resizeEvent(QResizeEvent *event);
@@ -69,6 +71,7 @@ private slots:
69 71
70private: 72private:
71 QWidget *lineNumberArea; 73 QWidget *lineNumberArea;
74 QList<int> errors;
72}; 75};
73 76
74//![codeeditordefinition] 77//![codeeditordefinition]
diff --git a/utils/themeeditor/skindocument.cpp b/utils/themeeditor/skindocument.cpp
index f7c902f30f..b67c70db61 100644
--- a/utils/themeeditor/skindocument.cpp
+++ b/utils/themeeditor/skindocument.cpp
@@ -166,6 +166,7 @@ void SkinDocument::settingsChanged()
166 166
167void SkinDocument::codeChanged() 167void SkinDocument::codeChanged()
168{ 168{
169 editor->clearErrors();
169 parseStatus = model->changeTree(editor->document()-> 170 parseStatus = model->changeTree(editor->document()->
170 toPlainText().toAscii()); 171 toPlainText().toAscii());
171 statusLabel->setText(parseStatus); 172 statusLabel->setText(parseStatus);
@@ -173,17 +174,7 @@ void SkinDocument::codeChanged()
173 /* Highlighting if an error was found */ 174 /* Highlighting if an error was found */
174 if(skin_error_line() > 0) 175 if(skin_error_line() > 0)
175 { 176 {
176 QList<QTextEdit::ExtraSelection> highlight; 177 editor->addError(skin_error_line());
177 QTextEdit::ExtraSelection error;
178
179 /* Finding the apropriate line */
180 error.cursor = QTextCursor(editor->document()->
181 findBlockByNumber(skin_error_line() - 1));
182 error.format = errorColor;
183 highlight.append(error);
184
185 editor->setExtraSelections(highlight);
186
187 } 178 }
188 else 179 else
189 { 180 {