From 3dd94595c399c0f4c34ec14978df6e01da0d0210 Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Tue, 19 Mar 2013 13:18:23 +0000 Subject: [PATCH] Add "gridOK()" functiion, used for PSKreporter and double-clock on call. Double-click on decoded line copies valid grid to dxGrid box. Add button workd with an empty call3.txt file. QSO start/stop times rationalized (somewhat). git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3056 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- mainwindow.cpp | 69 ++++++++++++++++++++++++++++---------------------- mainwindow.h | 2 ++ 2 files changed, 41 insertions(+), 30 deletions(-) diff --git a/mainwindow.cpp b/mainwindow.cpp index e2ae424f2..390b3368c 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -1064,16 +1064,7 @@ void MainWindow::readFromStdout() //readFromStdout QString g2=c2.mid(i2+1,4); c2=c2.mid(0,i2); QString remote="call," + c2 + ","; - if(g2.mid(0,1).compare("A")>=0 and - g2.mid(0,1).compare("R")<=0 and - g2.mid(1,1).compare("A")>=0 and - g2.mid(1,1).compare("R")<=0 and - g2.mid(2,1).compare("0")>=0 and - g2.mid(2,1).compare("9")<=0 and - g2.mid(3,1).compare("0")>=0 and - g2.mid(3,1).compare("9")<=0) { - remote += "gridsquare," + g2 + ","; - } + if(gridOK(g2)) remote += "gridsquare," + g2 + ","; int nHz=t.mid(22,4).toInt(); uint nfreq=1000000.0*g_pWideGraph->dialFreq() + nHz + 0.5; remote += "freq," + QString::number(nfreq); @@ -1090,9 +1081,6 @@ void MainWindow::readFromStdout() //readFromStdout wchar_t tlocal[256]; local.toWCharArray(tlocal); -// qDebug() << "A:" << QString::fromWCharArray(tlocal,local.length()); -// qDebug() << "B:" << QString::fromWCharArray(tremote,remote.length()); - int flags=REPORTER_SOURCE_AUTOMATIC; rc=ReporterSeenCallsign(tremote,tlocal,flags); if(rc!=0) { @@ -1427,7 +1415,11 @@ void MainWindow::doubleClickOnCall(bool shift, bool ctrl) g_pWideGraph->setQSOfreq(nfreq); } QString hiscall=t4.at(7); + QString hisgrid=""; + if(t4.length()>=9) hisgrid=t4.at(8); ui->dxCallEntry->setText(hiscall); + lookup(); + if(ui->dxGridEntry->text()=="" and gridOK(hisgrid)) ui->dxGridEntry->setText(hisgrid); int n = 60*t2.mid(0,2).toInt() + t2.mid(2,2).toInt(); int nmod=n%(m_TRperiod/30); m_txFirst=(nmod!=0); @@ -1438,13 +1430,6 @@ void MainWindow::doubleClickOnCall(bool shift, bool ctrl) if(rpt.indexOf(" ")==0) rpt="+" + rpt.mid(1,2); if(rpt.toInt()<-50) rpt="-50"; if(rpt.toInt()>49) rpt="+49"; - if(ctrl) { - int i4=t.mid(i2,20).indexOf(" "); - QString hisgrid=t.mid(i2,20).mid(i4+1,4); - ui->dxGridEntry->setText(hisgrid); - } else { - lookup(); - } genStdMsgs(rpt); if(t2.indexOf(m_myCall)>0) { m_ntx=2; @@ -1551,6 +1536,14 @@ void MainWindow::on_addButton_clicked() //Add button msgBox("Cannot open " + call3File); return; } + if(f1.size()==0) { + f1.close(); + f1.open(QIODevice::WriteOnly | QIODevice::Text); + QTextStream out(&f1); + out << "ZZZZZZ" << endl; + f1.close(); + f1.open(QIODevice::ReadOnly | QIODevice::Text); + } QString tmpFile = m_appDir + "/CALL3.TMP"; QFile f2(tmpFile); if(!f2.open(QIODevice::WriteOnly | QIODevice::Text)) { @@ -1731,17 +1724,20 @@ void MainWindow::on_logQSOButton_clicked() //Log QSO button QTextStream out(&f2); if(f2.size()==0) out << "WSJT-X ADIF Export" << endl; + if(m_qsoStop=="") m_qsoStop=m_qsoStart; + if(m_qsoStart=="") m_qsoStart=m_qsoStop; + QString t; t="" + m_hisCall; - t+= "" + m_hisGrid; - t+= "" + m_mode; - t+= "" + m_rptSent; - t+= "" + m_rptRcvd; - t+= ""; - t+= "" + m_qsoStart; - t+= "" + m_qsoStop; - t+= "" + m_myCall; - t+= "" + m_myGrid; + t+=" " + m_hisGrid; + t+=" " + m_mode; + t+=" " + m_rptSent; + t+=" " + m_rptRcvd; + t+=" " + date; + t+=" " + m_qsoStart; + t+=" " + m_qsoStop; + t+=" " + m_myCall; + t+=" " + m_myGrid; out << t << endl; f2.close(); } @@ -1911,7 +1907,7 @@ void MainWindow::showMacros(const QPoint &pos) popupMenu.addAction(popup2); connect(popup1,SIGNAL(triggered()), this, SLOT(onPopup1())); connect(popup2,SIGNAL(triggered()), this, SLOT(onPopup2())); - QAction* selectedItem = popupMenu.exec(globalPos); + popupMenu.exec(globalPos); } void MainWindow::onPopup1() @@ -1923,3 +1919,16 @@ void MainWindow::onPopup2() { ui->tx5->setText("TNX 73 GL"); } + +bool MainWindow::gridOK(QString g) +{ + bool b=g.mid(0,1).compare("A")>=0 and + g.mid(0,1).compare("R")<=0 and + g.mid(1,1).compare("A")>=0 and + g.mid(1,1).compare("R")<=0 and + g.mid(2,1).compare("0")>=0 and + g.mid(2,1).compare("9")<=0 and + g.mid(3,1).compare("0")>=0 and + g.mid(3,1).compare("9")<=0; + return b; +} diff --git a/mainwindow.h b/mainwindow.h index 0a2b3bff2..d33318095 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -230,6 +230,8 @@ private slots: void msgtype(QString t, QLineEdit* tx); void stub(); void statusChanged(); + + bool gridOK(QString g); }; extern void getfile(QString fname, int ntrperiod);