Added slot onReplaceLast() to handle adding a QStringList to the text edit.

This commit is contained in:
Gerhard Hoffmann 2023-08-18 11:48:29 +02:00
parent 2ac8c4cfc6
commit 17ddfd0ddd
2 changed files with 34 additions and 2 deletions

View File

@ -161,9 +161,40 @@ void MainWindow::onAppendText(QString text, QString suffix) {
}
Utils::printLineEditInfo(editText.split('\n'));
ui->updateStatus->setPlainText(editText.trimmed());
ui->updateStatus->setEnabled(true);
scrollDownTextEdit();
}
void MainWindow::onReplaceLast(QStringList newTextLines, QString suffix) {
int const s = newTextLines.size();
if (s > 0) {
QString editText = ui->updateStatus->toPlainText();
QStringList lines = editText.split('\n');
QString newText;
if (lines.size() >= s) {
for (int i = 0; i < s; ++i) {
lines.removeLast();
}
if (lines.size() > 0) {
newText = lines.join('\n');
newText += '\n';
}
QStringList newLines;
for (int i = 0; i < s; ++i) {
if (i == 0 && !suffix.isNull() && suffix.size() > 0 && suffix != "\n") {
newLines += Utils::rstrip(newTextLines.at(i).leftJustified(m_width-10) + suffix);
} else {
newLines += Utils::rstrip(newTextLines.at(i).leftJustified(m_width-10));
}
}
lines += newLines;
newText += newLines.join(' ');
}
ui->updateStatus->setText(newText);
Utils::printLineEditInfo(lines);
scrollDownTextEdit();
}
}
void MainWindow::onReplaceLast(QString text, QString suffix) {

View File

@ -27,6 +27,7 @@ public:
public slots:
void onAppendText(QString, QString suffix = "");
void onReplaceLast(QStringList, QString suffix = "");
void onReplaceLast(QString, QString suffix = "");
void onShowErrorMessage(QString, QString);
void onStopStartTimer();