diff --git a/gui/codeeditor.h b/gui/codeeditor.h index 9519a6551..bdc52c56e 100644 --- a/gui/codeeditor.h +++ b/gui/codeeditor.h @@ -55,6 +55,12 @@ public: void lineNumberAreaPaintEvent(QPaintEvent *event); int lineNumberAreaWidth(); + /** + * Set source code to show, goto error line and highlight that line. + * \param code The source code. + * \param errorLine line number + * \param symbols the related symbols, these are marked + */ void setError(const QString &code, int errorLine, const QStringList &symbols); protected: diff --git a/tools/triage/mainwindow.cpp b/tools/triage/mainwindow.cpp index aaf841dfc..3a1b6b8d6 100644 --- a/tools/triage/mainwindow.cpp +++ b/tools/triage/mainwindow.cpp @@ -134,17 +134,5 @@ void MainWindow::showResult(QListWidgetItem *item) f.open(QIODevice::ReadOnly | QIODevice::Text); QTextStream textStream(&f); const QString fileData = textStream.readAll(); - ui->code->setPlainText(fileData); - for (int pos = 0, line = 1; pos < fileData.size(); ++pos) { - if (fileData[pos] == '\n') { - ++line; - if (line == lineNumber) { - QTextCursor textCursor = ui->code->textCursor(); - textCursor.setPosition(pos+1); - ui->code->setTextCursor(textCursor); - ui->code->centerCursor(); - break; - } - } - } + ui->code->setError(fileData, lineNumber, QStringList()); }