Add some debug message when adding content to the text edit of the GUI.

This commit is contained in:
Gerhard Hoffmann 2023-09-09 15:06:21 +02:00
parent df0951d671
commit 9a65cb4456

View File

@ -320,6 +320,8 @@ void MainWindow::onQuit() {
} }
void MainWindow::scrollDownTextEdit() { void MainWindow::scrollDownTextEdit() {
qCritical() << "ON REPLACE LAST CALLED AT" << QDateTime::currentDateTime().toString(Qt::ISODateWithMs);
ui->updateStatus->setEnabled(true); ui->updateStatus->setEnabled(true);
QTextCursor tmpCursor = ui->updateStatus->textCursor(); QTextCursor tmpCursor = ui->updateStatus->textCursor();
@ -329,6 +331,8 @@ void MainWindow::scrollDownTextEdit() {
} }
void MainWindow::onAppendText(QString text, QString suffix) { void MainWindow::onAppendText(QString text, QString suffix) {
qCritical() << "ON APPEND CALLED AT" << QDateTime::currentDateTime().toString(Qt::ISODateWithMs);
QString editText = ui->updateStatus->toPlainText(); QString editText = ui->updateStatus->toPlainText();
if (!suffix.isNull() && suffix.size() > 0) { if (!suffix.isNull() && suffix.size() > 0) {
//qInfo() << "TEXT" << text << "SUFFIX" << suffix; //qInfo() << "TEXT" << text << "SUFFIX" << suffix;
@ -336,21 +340,26 @@ void MainWindow::onAppendText(QString text, QString suffix) {
editText += QString("\n").leftJustified(m_width-3, '='); editText += QString("\n").leftJustified(m_width-3, '=');
editText += " "; editText += " ";
} }
editText += (QString("\n") + text).leftJustified(m_width - (2 + suffix.size()) ) + suffix; QString const &add = (QString("\n") + text).leftJustified(m_width - (2 + suffix.size())) + suffix;
editText += add;
} else { } else {
editText += text.leftJustified(m_width-9); QString const &add = text.leftJustified(m_width-9);
editText += add;
} }
Utils::printLineEditInfo(editText.split('\n')); Utils::printLineEditInfo(editText.split('\n', QString::SplitBehavior::SkipEmptyParts));
ui->updateStatus->setPlainText(editText.trimmed()); ui->updateStatus->setText(editText.trimmed());
scrollDownTextEdit(); scrollDownTextEdit();
} }
void MainWindow::onReplaceLast(QStringList newTextLines, QString suffix) { void MainWindow::onReplaceLast(QStringList newTextLines, QString suffix) {
qCritical() << "ON REPLACE LAST CALLED AT" << QDateTime::currentDateTime().toString(Qt::ISODateWithMs);
int const s = newTextLines.size(); int const s = newTextLines.size();
if (s > 0) { if (s > 0) {
QString editText = ui->updateStatus->toPlainText(); QString editText = ui->updateStatus->toPlainText();
QStringList lines = editText.split('\n'); QStringList lines = editText.split('\n', QString::SplitBehavior::SkipEmptyParts);
QString newText; QString newText;
if (lines.size() >= s) { if (lines.size() >= s) {
for (int i = 0; i < s; ++i) { for (int i = 0; i < s; ++i) {
@ -379,17 +388,24 @@ void MainWindow::onReplaceLast(QStringList newTextLines, QString suffix) {
} }
void MainWindow::onReplaceLast(QString text, QString suffix) { void MainWindow::onReplaceLast(QString text, QString suffix) {
//qInfo() << "REPL TEXT" << text << "SUFFIX" << suffix; qCritical() << "ON REPLACE LAST CALLED AT" << QDateTime::currentDateTime().toString(Qt::ISODateWithMs);
QString editText = ui->updateStatus->toPlainText(); QString editText = ui->updateStatus->toPlainText();
QStringList lines = editText.split('\n'); QStringList lines = editText.split('\n', QString::SplitBehavior::SkipEmptyParts);
if (lines.size() > 0) { if (lines.size() > 0) {
lines.removeLast(); lines.removeLast();
if (!suffix.isNull() && suffix.size() > 0 && suffix != "\n") { if (!suffix.isNull() && suffix.size() > 0 && suffix != "\n") {
QString const add = text.leftJustified(m_width-10) + suffix;
if (!add.isEmpty()) {
lines += text.leftJustified(m_width-10) + suffix; lines += text.leftJustified(m_width-10) + suffix;
}
} else { } else {
QString const add = text.leftJustified(m_width-10);
if (!add.isEmpty()) {
lines += text.leftJustified(m_width-10); lines += text.leftJustified(m_width-10);
} }
} }
}
Utils::printLineEditInfo(lines); Utils::printLineEditInfo(lines);
ui->updateStatus->setText(lines.join('\n').trimmed()); ui->updateStatus->setText(lines.join('\n').trimmed());