Added slot onReplaceLast() to handle adding a QStringList to the text edit.
This commit is contained in:
		@@ -161,9 +161,40 @@ void MainWindow::onAppendText(QString text, QString suffix) {
 | 
				
			|||||||
    }
 | 
					    }
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    Utils::printLineEditInfo(editText.split('\n'));
 | 
					    Utils::printLineEditInfo(editText.split('\n'));
 | 
				
			||||||
 | 
					 | 
				
			||||||
    ui->updateStatus->setPlainText(editText.trimmed());
 | 
					    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) {
 | 
					void MainWindow::onReplaceLast(QString text, QString suffix) {
 | 
				
			||||||
 
 | 
				
			|||||||
@@ -27,6 +27,7 @@ public:
 | 
				
			|||||||
 | 
					
 | 
				
			||||||
public slots:
 | 
					public slots:
 | 
				
			||||||
    void onAppendText(QString, QString suffix = "");
 | 
					    void onAppendText(QString, QString suffix = "");
 | 
				
			||||||
 | 
					    void onReplaceLast(QStringList, QString suffix = "");
 | 
				
			||||||
    void onReplaceLast(QString, QString suffix = "");
 | 
					    void onReplaceLast(QString, QString suffix = "");
 | 
				
			||||||
    void onShowErrorMessage(QString, QString);
 | 
					    void onShowErrorMessage(QString, QString);
 | 
				
			||||||
    void onStopStartTimer();
 | 
					    void onStopStartTimer();
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user