From 07d5fd23bb655c80745d20f557f676fdce431bc0 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Wed, 19 May 2021 13:04:23 -0400 Subject: [PATCH] Double-click on callsign now populates DXgrid (if available) as well as DXcall. --- map65/mainwindow.cpp | 39 ++++++++++++++++++++++++++++++++++++--- map65/mainwindow.h | 1 + map65/messages.cpp | 4 ++-- 3 files changed, 39 insertions(+), 5 deletions(-) diff --git a/map65/mainwindow.cpp b/map65/mainwindow.cpp index 3652fcbd0..b7462429a 100644 --- a/map65/mainwindow.cpp +++ b/map65/mainwindow.cpp @@ -1763,9 +1763,21 @@ void MainWindow::doubleClickOnCall(QString hiscall, bool ctrl) ui->txFirstCheckBox->setChecked(m_txFirst); if((t2.indexOf("#")>0) and m_modeTx!="JT65") on_pbTxMode_clicked(); if((t2.indexOf(":")>0) and m_modeTx!="Q65") on_pbTxMode_clicked(); + + QString t3=t.mid(i1); + int i3=t3.indexOf("\n"); + if(i3<0) i3=t3.length(); + t3=t3.left(i3); + auto const& words = t3.mid(30).split(' ', Qt::SkipEmptyParts); + QString grid=words[2]; + if(isGrid4(grid) and hiscall==words[1]) { + ui->dxGridEntry->setText(grid); + } else { + lookup(); + } + QString rpt=""; if(ctrl or m_modeTx=="Q65") rpt=t2.mid(25,3); - lookup(); genStdMsgs(rpt); if(t2.indexOf(m_myCall)>0) { m_ntx=2; @@ -1778,6 +1790,7 @@ void MainWindow::doubleClickOnCall(QString hiscall, bool ctrl) //doubleClickOnMessages void MainWindow::doubleClickOnMessages(QString hiscall, QString t2) { + if(hiscall.length()<3) return; if(m_worked[hiscall]) { msgBox("Possible dupe: " + hiscall + " already in log."); } @@ -1785,7 +1798,15 @@ void MainWindow::doubleClickOnMessages(QString hiscall, QString t2) int n = 60*t2.mid(13,2).toInt() + t2.mid(15,2).toInt(); m_txFirst = ((n%2) == 1); ui->txFirstCheckBox->setChecked(m_txFirst); - lookup(); + + auto const& words = t2.mid(25).split(' ', Qt::SkipEmptyParts); + QString grid=words[2]; + if(isGrid4(grid) and hiscall==words[1]) { + ui->dxGridEntry->setText(grid); + } else { + lookup(); + } + genStdMsgs(""); if(t2.indexOf(m_myCall)>0) { m_ntx=2; @@ -2065,9 +2086,11 @@ void MainWindow::on_logQSOButton_clicked() //Log QSO button { int nMHz=int(datcom_.fcenter); QDateTime t = QDateTime::currentDateTimeUtc(); + QString qsoMode=lab5->text(); + if(m_modeTx.startsWith("Q65")) qsoMode=lab6->text(); QString logEntry=t.date().toString("yyyy-MMM-dd,") + t.time().toString("hh:mm,") + m_hisCall + "," + m_hisGrid + "," + - QString::number(nMHz) + "," + lab6->text() + "\r\n"; + QString::number(nMHz) + "," + qsoMode + "\r\n"; int ret = QMessageBox::warning(this, "Log Entry", "Please confirm log entry:\n\n" + logEntry + "\n", @@ -2262,3 +2285,13 @@ void MainWindow::on_pbTxMode_clicked() // m_wideGraph->setModeTx(m_modeTx); // statusChanged(); } + +bool MainWindow::isGrid4(QString g) +{ + if(g.length()!=4) return false; + if(g.mid(0,1)<'A' or g.mid(0,1)>'R') return false; + if(g.mid(1,1)<'A' or g.mid(1,1)>'R') return false; + if(g.mid(2,1)<'0' or g.mid(2,1)>'9') return false; + if(g.mid(3,1)<'0' or g.mid(3,1)>'9') return false; + return true; +} diff --git a/map65/mainwindow.h b/map65/mainwindow.h index b38de2430..eba776438 100644 --- a/map65/mainwindow.h +++ b/map65/mainwindow.h @@ -288,6 +288,7 @@ private: void ba2msg(QByteArray ba, char* message); void msgtype(QString t, QLineEdit* tx); void stub(); + bool isGrid4(QString g); bool subProcessFailed (QProcess *, int exit_code, QProcess::ExitStatus); }; diff --git a/map65/messages.cpp b/map65/messages.cpp index 177b7fb56..8a2cc92f9 100644 --- a/map65/messages.cpp +++ b/map65/messages.cpp @@ -80,9 +80,9 @@ void Messages::selectCallsign2(bool /*ctrl*/) QString hiscall=t.mid(i0+1,i1-i0-1); if(hiscall!="") { if(hiscall.length() < 13) { - QString t1 = t.mid(0,i); //contents up to text cursor + QString t1 = t.mid(0,i+14); //contents up to text cursor int i1=t1.lastIndexOf("\n") + 1; - QString t2 = t1.mid(i1,i-i1); //selected line + QString t2 = t1.mid(i1,i+14-i1); //selected line emit click2OnCallsign(hiscall,t2); } }