File tree Expand file tree Collapse file tree 2 files changed +7
-13
lines changed
Expand file tree Collapse file tree 2 files changed +7
-13
lines changed Original file line number Diff line number Diff line change @@ -55,6 +55,12 @@ class CodeEditor : public QPlainTextEdit {
5555 void lineNumberAreaPaintEvent (QPaintEvent *event);
5656 int lineNumberAreaWidth ();
5757
58+ /* *
59+ * Set source code to show, goto error line and highlight that line.
60+ * \param code The source code.
61+ * \param errorLine line number
62+ * \param symbols the related symbols, these are marked
63+ */
5864 void setError (const QString &code, int errorLine, const QStringList &symbols);
5965
6066protected:
Original file line number Diff line number Diff line change @@ -134,17 +134,5 @@ void MainWindow::showResult(QListWidgetItem *item)
134134 f.open (QIODevice::ReadOnly | QIODevice::Text);
135135 QTextStream textStream (&f);
136136 const QString fileData = textStream.readAll ();
137- ui->code ->setPlainText (fileData);
138- for (int pos = 0 , line = 1 ; pos < fileData.size (); ++pos) {
139- if (fileData[pos] == ' \n ' ) {
140- ++line;
141- if (line == lineNumber) {
142- QTextCursor textCursor = ui->code ->textCursor ();
143- textCursor.setPosition (pos+1 );
144- ui->code ->setTextCursor (textCursor);
145- ui->code ->centerCursor ();
146- break ;
147- }
148- }
149- }
137+ ui->code ->setError (fileData, lineNumber, QStringList ());
150138}
You can’t perform that action at this time.
0 commit comments