diff --git a/logbook/adif.cpp b/logbook/adif.cpp index 5676b58c6..7077b5659 100644 --- a/logbook/adif.cpp +++ b/logbook/adif.cpp @@ -2,22 +2,23 @@ #include #include +#include #include /* -W1XT20m14.076DM33JT65-21-14201104220417042441st JT65A QSO. Him: mag loop 20WVK3ACFqf22lb -IK1SOW20m14.076JN35JT65-19-1120110422052505333VK3ACFqf22lb +W1XT20m14.076DM33JT65-21-142011042204171204243541st JT65A QSO. Him: mag loop 20WVK3ACFqf22lb +IK1SOW20m14.076JN35JT65-19-11201104220525010533593VK3ACFqf22lb W4ABC> ... */ -void ADIF::init(QString filename) +void ADIF::init(QString const& filename) { _filename = filename; _data.clear(); } -QString ADIF::_extractField(const QString line, const QString fieldName) +QString ADIF::_extractField(QString const& line, QString const& fieldName) { int fieldNameIndex = line.indexOf(fieldName,0,Qt::CaseInsensitive); if (fieldNameIndex >=0) @@ -74,7 +75,7 @@ void ADIF::load() } -void ADIF::add(const QString call, const QString band, const QString mode, const QString date) +void ADIF::add(QString const& call, QString const& band, QString const& mode, QString const& date) { QSO q; q.call = call; @@ -86,7 +87,7 @@ void ADIF::add(const QString call, const QString band, const QString mode, const } // return true if in the log same band and mode (where JT65 == JT9) -bool ADIF::match(const QString call, const QString band, const QString mode) +bool ADIF::match(QString const& call, QString const& band, QString const& mode) { QList qsos = _data.values(call); if (qsos.size()>0) @@ -138,8 +139,8 @@ int ADIF::getCount() // open ADIF file and append the QSO details. Return true on success -bool ADIF::addQSOToFile(const QString hisCall, const QString hisGrid, const QString mode, const QString rptSent, const QString rptRcvd, const QString dateOn, const QString timeOn, QString dateOff, const QString timeOff, const QString band, - const QString comments, const QString name, const QString strDialFreq, const QString m_myCall, const QString m_myGrid, const QString m_txPower) +bool ADIF::addQSOToFile(QString const& hisCall, QString const& hisGrid, QString const& mode, QString const& rptSent, QString const& rptRcvd, QDateTime const& dateTimeOn, QDateTime const& dateTimeOff, QString const& band, + QString const& comments, QString const& name, QString const& strDialFreq, QString const& m_myCall, QString const& m_myGrid, QString const& m_txPower) { QFile f2(_filename); if (!f2.open(QIODevice::Text | QIODevice::Append)) @@ -156,10 +157,10 @@ bool ADIF::addQSOToFile(const QString hisCall, const QString hisGrid, const QStr t+=" " + mode; t+=" " + rptSent; t+=" " + rptRcvd; - t+=" " + dateOn; - t+=" " + timeOn; - t+=" " + dateOff; - t+=" " + timeOff; + t+=" " + dateTimeOn.date ().toString ("yyyyMMdd"); + t+=" " + dateTimeOn.time ().toString ("hhmmss"); + t+=" " + dateTimeOff.date ().toString ("yyyyMMdd"); + t+=" " + dateTimeOff.time ().toString ("hhmmss"); t+=" " + band; t+=" " + strDialFreq; t+=" " + diff --git a/logbook/adif.h b/logbook/adif.h index a54db8eb0..00e0c74c8 100644 --- a/logbook/adif.h +++ b/logbook/adif.h @@ -16,20 +16,21 @@ #include #endif +class QDateTime; class ADIF { public: - void init(QString filename); + void init(QString const& filename); void load(); - void add(const QString call, const QString band, const QString mode, const QString date); - bool match(const QString call, const QString band, const QString mode); + void add(QString const& call, QString const& band, QString const& mode, QString const& date); + bool match(QString const& call, QString const& band, QString const& mode); QList getCallList(); int getCount(); // open ADIF file and append the QSO details. Return true on success - bool addQSOToFile(const QString hisCall, const QString hisGrid, const QString mode, const QString rptSent, const QString rptRcvd, const QString dateOn, const QString timeOn, const QString dateOff, const QString timeOff, const QString band, - const QString comments, const QString name, const QString strDialFreq, const QString m_myCall, const QString m_myGrid, const QString m_txPower); + bool addQSOToFile(QString const& hisCall, QString const& hisGrid, QString const& mode, QString const& rptSent, QString const& rptRcvd, QDateTime const& dateTimeOn, QDateTime const& dateTimeOff, QString const& band, + QString const& comments, QString const& name, QString const& strDialFreq, QString const& m_myCall, QString const& m_myGrid, QString const& m_txPower); static QString bandFromFrequency(double dialFreq); @@ -39,10 +40,10 @@ class ADIF QString call,band,mode,date; }; - QMultiHash _data; + QMultiHash _data; QString _filename; - QString _extractField(const QString line, const QString fieldName); + QString _extractField(QString const& line, QString const& fieldName); }; diff --git a/logqso.cpp b/logqso.cpp index 16239ecb1..c6ad3dd1f 100644 --- a/logqso.cpp +++ b/logqso.cpp @@ -48,9 +48,10 @@ void LogQSO::storeSettings () const m_settings->endGroup (); } -void LogQSO::initLogQSO(QString hisCall, QString hisGrid, QString mode, - QString rptSent, QString rptRcvd, QDateTime dateTimeOn, QDateTime dateTimeOff, - Radio::Frequency dialFreq, QString myCall, QString myGrid, +void LogQSO::initLogQSO(QString const& hisCall, QString const& hisGrid, QString mode, + QString const& rptSent, QString const& rptRcvd, + QDateTime const& dateTimeOn, QDateTime const& dateTimeOff, + Radio::Frequency dialFreq, QString const& myCall, QString const& myGrid, bool noSuffix, bool toRTTY, bool dBtoComments) { if(!isHidden()) return; @@ -72,16 +73,8 @@ void LogQSO::initLogQSO(QString hisCall, QString hisGrid, QString mode, ui->mode->setText(mode); ui->sent->setText(rptSent); ui->rcvd->setText(rptRcvd); - m_dateTimeOn=dateTimeOn; - m_dateTimeOff=dateTimeOff; - QString dateOn=dateTimeOn.toString("yyyy-MM-dd"); - ui->dateOn->setText(dateOn); - QString timeOn=dateTimeOn.toString("hhmm"); - ui->timeOn->setText(timeOn); - QString dateOff=dateTimeOff.toString("yyyy-MM-dd"); - ui->dateOff->setText(dateOff); - QString timeOff=dateTimeOff.toString("hhmm"); - ui->timeOff->setText(timeOff); + ui->start_date_time->setDateTime (dateTimeOn); + ui->end_date_time->setDateTime (dateTimeOff); m_dialFreq=dialFreq; m_myCall=myCall; m_myGrid=myGrid; @@ -101,21 +94,8 @@ void LogQSO::accept() mode=ui->mode->text(); rptSent=ui->sent->text(); rptRcvd=ui->rcvd->text(); - m_dateTimeOn = m_dateTimeOn.fromString(ui->dateOn->text()+" "+ui->timeOn->text(),"yyyy-MM-dd hhmm"); - m_dateTimeOff = m_dateTimeOff.fromString(ui->dateOff->text()+" "+ui->timeOff->text(),"yyyy-MM-dd hhmm"); - - // set time off and on back to UTC as the above QDateTime::fromString() - // creates a local time value -- this would be al so much simpler if - // QDateTimeEdit widgets had been used - m_dateTimeOff.setTimeSpec (Qt::UTC); - m_dateTimeOn.setTimeSpec (Qt::UTC); - - dateOn=ui->dateOn->text(); - dateOn=dateOn.mid(0,4) + dateOn.mid(5,2) + dateOn.mid(8,2); - timeOn=ui->timeOn->text(); - dateOff=ui->dateOff->text(); - dateOff=dateOff.mid(0,4) + dateOff.mid(5,2) + dateOff.mid(8,2); - timeOff=ui->timeOff->text(); + m_dateTimeOn = ui->start_date_time->dateTime (); + m_dateTimeOff = ui->end_date_time->dateTime (); band=ui->band->text(); name=ui->name->text(); m_txPower=ui->txPower->text(); @@ -128,7 +108,7 @@ void LogQSO::accept() ADIF adifile; auto adifilePath = QDir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)}.absoluteFilePath ("wsjtx_log.adi"); adifile.init(adifilePath); - if (!adifile.addQSOToFile(hisCall,hisGrid,mode,rptSent,rptRcvd,dateOn,timeOn,dateOff,timeOff,band,comments,name,strDialFreq,m_myCall,m_myGrid,m_txPower)) + if (!adifile.addQSOToFile(hisCall,hisGrid,mode,rptSent,rptRcvd,m_dateTimeOn,m_dateTimeOff,band,comments,name,strDialFreq,m_myCall,m_myGrid,m_txPower)) { MessageBox::warning_message (this, tr ("Log file error"), tr ("Cannot open \"%1\"").arg (adifilePath)); @@ -142,9 +122,9 @@ void LogQSO::accept() tr ("Error: %1").arg (f.errorString ())); } else { QString logEntry=m_dateTimeOn.date().toString("yyyy-MM-dd,") + - m_dateTimeOn.time().toString("hh:mm,") + + m_dateTimeOn.time().toString("hh:mm:ss,") + m_dateTimeOff.date().toString("yyyy-MM-dd,") + - m_dateTimeOff.time().toString("hh:mm,") + hisCall + "," + + m_dateTimeOff.time().toString("hh:mm:ss,") + hisCall + "," + hisGrid + "," + strDialFreq + "," + mode + "," + rptSent + "," + rptRcvd + "," + m_txPower + "," + comments + "," + name; diff --git a/logqso.h b/logqso.h index 55b0dd9cd..8ef0e413c 100644 --- a/logqso.h +++ b/logqso.h @@ -25,9 +25,10 @@ class LogQSO : public QDialog public: explicit LogQSO(QString const& programTitle, QSettings *, QWidget *parent = 0); ~LogQSO(); - void initLogQSO(QString hisCall, QString hisGrid, QString mode, - QString rptSent, QString rptRcvd, QDateTime dateTimeOn,QDateTime dateTimeOff, - Radio::Frequency dialFreq, QString myCall, QString myGrid, + void initLogQSO(QString const& hisCall, QString const& hisGrid, QString mode, + QString const& rptSent, QString const& rptRcvd, QDateTime const& dateTimeOn, + QDateTime const& dateTimeOff, + Radio::Frequency dialFreq, QString const& myCall, QString const& myGrid, bool noSuffix, bool toRTTY, bool dBtoComments); public slots: diff --git a/logqso.ui b/logqso.ui index 8926f8d05..e8e46caa8 100644 --- a/logqso.ui +++ b/logqso.ui @@ -2,23 +2,13 @@ LogQSO - - - - - Qt::Vertical - - - QSizePolicy::MinimumExpanding - - - - 20 - 13 - - - - + + + 0 + 0 + + + @@ -32,678 +22,277 @@ - - - Qt::Vertical - - - QSizePolicy::MinimumExpanding - - - - 20 - 13 - - - + + + + + + + + 10 + + + + Call + + + Qt::AlignCenter + + + + + + + + + + + + + + + 10 + + + + Start + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + dd/MM/yyyy HH:mm:ss + + + + + + + + + + + + 10 + + + + End + + + Qt::AlignCenter + + + + + + + + 0 + 0 + + + + dd/MM/yyyy HH:mm:ss + + + + + + - - - - 0 - 0 - - - - - 70 - 0 - - - - - 70 - 16777215 - - - - - 10 - - - - Call - - - Qt::AlignCenter - - + + + + + + 10 + + + + Mode + + + Qt::AlignCenter + + + + + + + + 70 + 16777215 + + + + + - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - - 10 - - - - Start Date - - - Qt::AlignCenter - - + + + + + + 10 + + + + Band + + + Qt::AlignCenter + + + + + + + + 50 + 16777215 + + + + + - - - - 0 - 0 - - - - - 50 - 0 - - - - - 60 - 16777215 - - - - - 10 - - - - Start Time - - - Qt::AlignCenter - - + + + + + + 10 + + + + Rpt Sent + + + Qt::AlignCenter + + + + + + + + 50 + 16777215 + + + + + - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - - 10 - - - - End Date - - - Qt::AlignCenter - - + + + + + + 10 + + + + Rpt Rcvd + + + Qt::AlignCenter + + + + + + + + 50 + 16777215 + + + + + - - - - 0 - 0 - - - - - 50 - 0 - - - - - 60 - 16777215 - - - - - 10 - - - - End Time - - - Qt::AlignCenter - - + + + + + + 10 + + + + Grid + + + Qt::AlignCenter + + + + + + + + 70 + 16777215 + + + + + + + + + + + + true + + + + 10 + + + + Name + + + Qt::AlignCenter + + + + + + + true + + + + - - - - - - - 0 - 0 - - - - - 70 - 0 - - - - - 70 - 16777215 - - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - - - - - - 50 - 0 - - - - - 60 - 16777215 - - - - - - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - - - - - - 50 - 0 - - - - - 60 - 16777215 - - - - - - - - - - Qt::Vertical - - - QSizePolicy::MinimumExpanding - - - - 20 - 13 - - - - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - - 10 - - - - Mode - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - - 10 - - - - Band - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - - 10 - - - - Rpt Sent - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - - 10 - - - - Rpt Rcvd - - - Qt::AlignCenter - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - - 10 - - - - Grid - - - Qt::AlignCenter - - - - - - - true - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - - 10 - - - - Name - - - Qt::AlignCenter - - - - - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - - - - - - 0 - 0 - - - - - 50 - 0 - - - - - 50 - 16777215 - - - - - - - - true - - - - 0 - 0 - - - - - 100 - 0 - - - - - 100 - 16777215 - - - - - - - - - - Qt::Vertical - - - QSizePolicy::MinimumExpanding - - - - 20 - 13 - - - - - - - 65 - 0 - - Tx power @@ -721,22 +310,6 @@ - - - - Qt::Vertical - - - QSizePolicy::MinimumExpanding - - - - 20 - 13 - - - - @@ -744,12 +317,6 @@ true - - - 65 - 0 - - 10 @@ -776,6 +343,19 @@ + + + + Qt::Vertical + + + + 20 + 40 + + + + @@ -790,10 +370,8 @@ call - dateOn - timeOn - dateOff - timeOff + start_date_time + end_date_time mode band sent diff --git a/mainwindow.cpp b/mainwindow.cpp index bd0d551a0..9e9e7d6d2 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -715,8 +715,6 @@ MainWindow::MainWindow(QDir const& temp_directory, bool multiple, ui->decodedTextLabel2->setText(t); readSettings(); //Restore user's setup params m_audioThread.start (m_audioThreadPriority); - m_dateTimeDefault=QDateTime(QDate(1900,1,1),QTime(0,0)); - m_dateTimeQSOOn=m_dateTimeDefault; #ifdef WIN32 if (!m_multiple) @@ -1660,7 +1658,6 @@ void MainWindow::on_autoButton_clicked (bool checked) } ui->sbTxPercent->setPalette(palette); } - set_dateTimeQSO(-1); } void MainWindow::auto_tx_mode (bool state) @@ -2445,7 +2442,7 @@ void MainWindow::decode() //decode() dec_data.params.ntol=20; dec_data.params.naggressive=0; } - if(dec_data.params.nutc < m_nutc0) m_RxLog = 1; //Date and Time to all.txt + if(dec_data.params.nutc < m_nutc0) m_RxLog = 1; //Date and Time to ALL.TXT if(dec_data.params.newdat==1 and !m_diskData) m_nutc0=dec_data.params.nutc; dec_data.params.ntxmode=9; if(m_modeTx=="JT65") dec_data.params.ntxmode=65; @@ -3376,13 +3373,14 @@ void MainWindow::set_dateTimeQSO(int m_ntx) // This should mean that Tx2 or Tx3 has been repeated so don't update the start time // We reset it in several places if (m_ntx == -1) { // we use a default date to detect change - m_dateTimeQSOOn=m_dateTimeDefault; + m_dateTimeQSOOn = QDateTime {}; } - else if (m_dateTimeQSOOn != m_dateTimeDefault) { + else if (m_dateTimeQSOOn.isValid ()) { return; } else { // we also take of m_TRperiod/2 to allow for late clicks - m_dateTimeQSOOn=QDateTime::currentDateTimeUtc().addSecs((-(m_ntx-1)*m_TRperiod)-m_TRperiod/2); + auto now = QDateTime::currentDateTimeUtc(); + m_dateTimeQSOOn = now.addSecs (-(m_ntx - 2) * m_TRperiod - (now.time ().second () % m_TRperiod)); } } @@ -3393,11 +3391,9 @@ void MainWindow::set_ntx(int n) //set_ntx() void MainWindow::on_txrb1_toggled(bool status) { - // if Tx 1 is clicked we won't use it so reset to default - // We may hang on this message for quite a while trying - // to get a response perhaps when another QSO is going on if (status) { m_ntx=1; + set_dateTimeQSO(-1); // we reset here as tx2/tx3 is used for start times } } @@ -3479,12 +3475,14 @@ void MainWindow::on_txb5_clicked() void MainWindow::on_txb6_clicked() { m_ntx=6; + set_dateTimeQSO(-1); ui->txrb6->setChecked(true); if (m_transmitting) m_restart=true; } void MainWindow::doubleClickOnCall2(bool shift, bool ctrl) { + set_dateTimeQSO(-1); // reset our QSO start time m_decodedText2=true; doubleClickOnCall(shift,ctrl); m_decodedText2=false; @@ -3494,7 +3492,6 @@ void MainWindow::doubleClickOnCall(bool shift, bool ctrl) { QTextCursor cursor; QString t; //Full contents - set_dateTimeQSO(-1); // reset our QSO start time if(m_mode=="ISCAT") { MessageBox::information_message (this, "Double-click not presently implemented for ISCAT mode"); @@ -3942,8 +3939,6 @@ void MainWindow::genStdMsgs(QString rpt) } } } - m_ntx=1; - ui->txrb1->setChecked(true); m_rpt=rpt; } @@ -4227,15 +4222,15 @@ void MainWindow::on_logQSOButton_clicked() //Log QSO button { if (!m_hisCall.size ()) return; // m_dateTimeQSOOn should really already be set but we'll ensure it gets set to something just in case - if (m_dateTimeQSOOn==m_dateTimeDefault) - m_dateTimeQSOOn=QDateTime::currentDateTimeUtc(); - m_dateTimeQSOOff = QDateTime::currentDateTimeUtc(); - if(m_dateTimeQSOOff < m_dateTimeQSOOn) m_dateTimeQSOOff=m_dateTimeQSOOn; + if (!m_dateTimeQSOOn.isValid ()) { + m_dateTimeQSOOn = QDateTime::currentDateTimeUtc(); + } + auto dateTimeQSOOff = QDateTime::currentDateTimeUtc(); + if (dateTimeQSOOff < m_dateTimeQSOOn) dateTimeQSOOff = m_dateTimeQSOOn; m_logDlg->initLogQSO (m_hisCall, m_hisGrid, m_modeTx, m_rptSent, m_rptRcvd, - m_dateTimeQSOOn, m_dateTimeQSOOff, m_freqNominal + ui->TxFreqSpinBox->value(), + m_dateTimeQSOOn, dateTimeQSOOff, m_freqNominal + ui->TxFreqSpinBox->value(), m_config.my_callsign(), m_config.my_grid(), m_noSuffix, m_config.log_as_RTTY(), m_config.report_in_comments()); - m_dateTimeQSOOn = m_dateTimeDefault; } void MainWindow::acceptQSO2(QDateTime const& QSO_date_off, QString const& call, QString const& grid @@ -4253,6 +4248,7 @@ void MainWindow::acceptQSO2(QDateTime const& QSO_date_off, QString const& call, { clearDX (); } + m_dateTimeQSOOn = QDateTime {}; } int MainWindow::nWidgets(QString t) diff --git a/mainwindow.h b/mainwindow.h index 0ae2082de..ad65f543a 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -519,8 +519,6 @@ private: QSet m_sfx; QDateTime m_dateTimeQSOOn; - QDateTime m_dateTimeQSOOff; - QDateTime m_dateTimeDefault; QSharedMemory *mem_jt9; LogBook m_logBook;