diff --git a/displaytext.cpp b/displaytext.cpp index fad222761..094099e90 100644 --- a/displaytext.cpp +++ b/displaytext.cpp @@ -28,6 +28,11 @@ void DisplayText::setContentFont(QFont const& font) cursor.mergeCharFormat (m_charFormat); cursor.clearSelection (); cursor.movePosition (QTextCursor::End); + + // position so viewport scrolled to left + cursor.movePosition (QTextCursor::Up); + cursor.movePosition (QTextCursor::StartOfLine); + setTextCursor (cursor); ensureCursorVisible (); } @@ -40,11 +45,9 @@ void DisplayText::mouseDoubleClickEvent(QMouseEvent *e) QTextEdit::mouseDoubleClickEvent(e); } -void DisplayText::insertLineSpacer() +void DisplayText::insertLineSpacer(QString const& line) { - QString tt="----------------------------------------"; - QString bg="#d3d3d3"; - _insertText(tt,bg); + _insertText (line, "#d3d3d3"); } void DisplayText::_insertText(const QString text, const QString bg) @@ -59,6 +62,11 @@ void DisplayText::_insertText(const QString text, const QString bg) cursor.movePosition (QTextCursor::End, QTextCursor::KeepAnchor); cursor.mergeCharFormat (m_charFormat); cursor.clearSelection (); + + // position so viewport scrolled to left + cursor.movePosition (QTextCursor::Up); + cursor.movePosition (QTextCursor::StartOfLine); + setTextCursor (cursor); ensureCursorVisible (); } diff --git a/displaytext.h b/displaytext.h index 0c481ab3d..7bca6a0eb 100644 --- a/displaytext.h +++ b/displaytext.h @@ -14,7 +14,7 @@ public: explicit DisplayText(QWidget *parent = 0); void setContentFont (QFont const&); - void insertLineSpacer(); + void insertLineSpacer(QString const&); void displayDecodedText(DecodedText decodedText, QString myCall, bool displayDXCCEntity, LogBook logBook, QColor color_CQ, QColor color_MyCall, QColor color_DXCC, QColor color_NewCall); diff --git a/mainwindow.cpp b/mainwindow.cpp index f9dd1b6fc..4beabefe5 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1384,10 +1384,16 @@ void MainWindow::readFromStdout() //readFromStdout msgBox("Cannot open \"" + f.fileName () + "\" for append:" + f.errorString ()); } - if(m_config.insert_blank () && m_blankLine) + if (m_config.insert_blank () && m_blankLine) { - ui->decodedTextBrowser->insertLineSpacer(); - m_blankLine=false; + QString band; + if (QDateTime::currentMSecsSinceEpoch() / 1000 - m_secBandChanged > 50) + { + auto const& bands_model = m_config.bands (); + band = ' ' + bands_model->data (bands_model->find (m_dialFreq + ui->TxFreqSpinBox->value ())).toString (); + } + ui->decodedTextBrowser->insertLineSpacer (band.rightJustified (40, '-')); + m_blankLine = false; } DecodedText decodedtext; @@ -2513,7 +2519,8 @@ void MainWindow::acceptQSO2(bool accepted) { if(accepted) { - QString band = ADIF::bandFromFrequency ((m_dialFreq + ui->TxFreqSpinBox->value ()) / 1.e6); + auto const& bands_model = m_config.bands (); + auto band = bands_model->data (bands_model->find (m_dialFreq + ui->TxFreqSpinBox->value ())).toString (); QString date = m_dateTimeQSO.toString("yyyy-MM-dd"); date=date.mid(0,4) + date.mid(5,2) + date.mid(8,2); m_logBook.addAsWorked(m_hisCall,band,m_modeTx,date);