From ca66c6401c8a5c660687036c5d5a6ca3c1cb1cd9 Mon Sep 17 00:00:00 2001 From: Jordan Sherer Date: Wed, 5 Sep 2018 15:14:39 -0400 Subject: [PATCH] Fixed bug in printing. Do not append to a line that already has an EOT marker --- mainwindow.cpp | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index aad870a..d445b6e 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -5895,14 +5895,23 @@ void MainWindow::writeNoticeTextToUI(QDateTime date, QString text){ int MainWindow::writeMessageTextToUI(QDateTime date, QString text, int freq, bool bold, int block){ auto c = ui->textEditRX->textCursor(); - // find an existing block ( + // find an existing block (that does not contain an EOT marker) bool found = false; if(block != -1){ QTextBlock b = c.document()->findBlockByNumber(block); c.setPosition(b.position()); - c.movePosition(QTextCursor::EndOfBlock); - found = true; - } else { + c.movePosition(QTextCursor::EndOfBlock, QTextCursor::KeepAnchor); + + auto blockText = c.selectedText(); + c.clearSelection(); + c.movePosition(QTextCursor::EndOfBlock, QTextCursor::MoveAnchor); + + if(!blockText.contains("\u2301")){ + found = true; + } + } + + if(!found){ c.movePosition(QTextCursor::End); if(c.block().length() > 1){ c.insertBlock();