From 59731d70e8df7a74207fa3153cd610911bbe4dc2 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Marjam=C3=A4ki?= Date: Sat, 1 Sep 2018 06:39:22 +0200 Subject: [PATCH] triage: set error line properly --- gui/codeeditor.h | 6 ++++++ tools/triage/mainwindow.cpp | 14 +------------- 2 files changed, 7 insertions(+), 13 deletions(-) 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()); }