From 9c213d0a97dea13849bfb5bd3ebba5f2d3460d7b Mon Sep 17 00:00:00 2001 From: Gerhard Hoffmann Date: Sun, 10 Sep 2023 16:55:32 +0200 Subject: [PATCH] Added some better debug output in the slots concerned with the text edit of the main window ("update status"). Use insertPlainText() when adding to the text edit to simplify code. --- mainwindow.cpp | 29 +++++++++++++++++++---------- 1 file changed, 19 insertions(+), 10 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index 42c5d3f..d1989cd 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -329,7 +329,8 @@ void MainWindow::onQuit() { } void MainWindow::scrollDownTextEdit() { - qCritical() << "ON REPLACE LAST CALLED AT" << QDateTime::currentDateTime().toString(Qt::ISODateWithMs); + Utils::printInfoMsg(QString("SCROLL-DOWN-TEXT_EDIT CALLED AT ") + + QDateTime::currentDateTime().toString(Qt::ISODateWithMs)); ui->updateStatus->setEnabled(true); @@ -340,30 +341,37 @@ void MainWindow::scrollDownTextEdit() { } void MainWindow::onAppendText(QString text, QString suffix) { - qCritical() << "ON APPEND CALLED AT" << QDateTime::currentDateTime().toString(Qt::ISODateWithMs); + Utils::printInfoMsg(QString("ON APPEND CALLED AT ") + + QDateTime::currentDateTime().toString(Qt::ISODateWithMs)); QString editText = ui->updateStatus->toPlainText(); if (!suffix.isNull() && suffix.size() > 0) { //qInfo() << "TEXT" << text << "SUFFIX" << suffix; if (suffix == Worker::UPDATE_STEP_SUCCESS || suffix == Worker::UPDATE_STEP_FAIL) { - editText += QString("\n").leftJustified(m_width-3, '='); - editText += " "; + ui->updateStatus->insertPlainText(QString("\n").leftJustified(m_width-3, '=') + " "); + // editText += QString("\n").leftJustified(m_width-3, '='); + // editText += " "; } QString const &add = (QString("\n") + text).leftJustified(m_width - (2 + suffix.size())) + suffix; - editText += add; + ui->updateStatus->insertPlainText(add); + // editText += add; } else { QString const &add = text.leftJustified(m_width-9); - editText += add; + ui->updateStatus->insertPlainText(add); + //editText += add; } - Utils::printLineEditInfo(editText.split('\n', QString::SplitBehavior::SkipEmptyParts)); - ui->updateStatus->setText(editText.trimmed()); + // debug + // QString editText = ui->updateStatus->toPlainText(); + // Utils::printLineEditInfo(editText.split('\n', QString::SplitBehavior::SkipEmptyParts)); + // ui->updateStatus->setText(editText.trimmed()); scrollDownTextEdit(); } void MainWindow::onReplaceLast(QStringList newTextLines, QString suffix) { - qCritical() << "ON REPLACE LAST CALLED AT" << QDateTime::currentDateTime().toString(Qt::ISODateWithMs); + Utils::printInfoMsg(QString("ON REPLACE LAST (LIST) CALLED AT ") + + QDateTime::currentDateTime().toString(Qt::ISODateWithMs)); int const s = newTextLines.size(); if (s > 0) { @@ -397,7 +405,8 @@ void MainWindow::onReplaceLast(QStringList newTextLines, QString suffix) { } void MainWindow::onReplaceLast(QString text, QString suffix) { - qCritical() << "ON REPLACE LAST CALLED AT" << QDateTime::currentDateTime().toString(Qt::ISODateWithMs); + Utils::printInfoMsg(QString("ON REPLACE LAST (TEXT) CALLED AT ") + + QDateTime::currentDateTime().toString(Qt::ISODateWithMs)); QString editText = ui->updateStatus->toPlainText(); QStringList lines = editText.split('\n', QString::SplitBehavior::SkipEmptyParts);