Replace the last line of the text edit when the new line is
the last line followed by a suffix.
This commit is contained in:
		@@ -248,11 +248,15 @@ void MainWindow::onReplaceLast(QStringList newTextLines, QString suffix) {
 | 
				
			|||||||
void MainWindow::onReplaceLast(QString text, QString suffix) {
 | 
					void MainWindow::onReplaceLast(QString text, QString suffix) {
 | 
				
			||||||
    // Utils::printInfoMsg(QString("ON REPLACE LAST (TEXT) CALLED AT ")
 | 
					    // Utils::printInfoMsg(QString("ON REPLACE LAST (TEXT) CALLED AT ")
 | 
				
			||||||
    //    + QDateTime::currentDateTime().toString(Qt::ISODateWithMs));
 | 
					    //    + QDateTime::currentDateTime().toString(Qt::ISODateWithMs));
 | 
				
			||||||
 | 
					 | 
				
			||||||
    QString editText = ui->updateStatus->toPlainText();
 | 
					    QString editText = ui->updateStatus->toPlainText();
 | 
				
			||||||
    QStringList lines = editText.split('\n', QString::SplitBehavior::SkipEmptyParts);
 | 
					    QStringList lines = editText.split('\n', QString::SplitBehavior::SkipEmptyParts);
 | 
				
			||||||
    if (lines.size() > 0) {
 | 
					    if (lines.size() > 0) {
 | 
				
			||||||
        lines.removeLast();
 | 
					        // removing the last line is really meant for refreshing the last line
 | 
				
			||||||
 | 
					        // with a string very similar than the original one, typically only
 | 
				
			||||||
 | 
					        // followed by a suffix.
 | 
				
			||||||
 | 
					        if (lines.last().contains(text)) {
 | 
				
			||||||
 | 
					            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;
 | 
					            QString const add = text.leftJustified(m_width-10) + suffix;
 | 
				
			||||||
            if (!add.isEmpty()) {
 | 
					            if (!add.isEmpty()) {
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user