From a221de3c9d20460caff1196c8d045f3ddb36524f Mon Sep 17 00:00:00 2001 From: Joe Taylor Date: Tue, 2 Oct 2018 15:52:25 -0400 Subject: [PATCH] Save contest exchange to ADIF log. (Not finished...) --- logbook/adif.cpp | 38 +++++++++++++++----------------------- logbook/adif.h | 11 ++++++----- logqso.cpp | 11 ++++++++--- logqso.h | 6 +++++- mainwindow.cpp | 34 +++++++++++++++++++++++----------- messageaveraging.cpp | 1 - 6 files changed, 57 insertions(+), 44 deletions(-) diff --git a/logbook/adif.cpp b/logbook/adif.cpp index d4878d5d7..a804e6992 100644 --- a/logbook/adif.cpp +++ b/logbook/adif.cpp @@ -180,11 +180,12 @@ int ADIF::getCount() const return _data.size(); } -QByteArray ADIF::QSOToADIF(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, QString const& operator_call) +QByteArray ADIF::QSOToADIF(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, QString const& operator_call, + QString const& xSent, QString const& xRcvd) { QString t; t = "" + hisCall; @@ -198,26 +199,17 @@ QByteArray ADIF::QSOToADIF(QString const& hisCall, QString const& hisGrid, QStri t += " " + dateTimeOff.time().toString("hhmmss"); t += " " + band; t += " " + strDialFreq; - t += " " + - m_myCall; - t += " " + - m_myGrid; - if (m_txPower != "") - t += " " + m_txPower; - if (comments != "") - t += " " + comments; - if (name != "") - t += " " + name; - if (operator_call!="") - t+=" " + operator_call; - return t.toLatin1 (); + t += " " + m_myCall; + t += " " + m_myGrid; + if(m_txPower!="") t += " " + m_txPower; + if(comments!="") t += " " + comments; + if(name!="") t += " " + name; + if(operator_call!="") t+=" " + operator_call; + if(xSent!="") t += " " + xSent; + if(xRcvd!="") t += " " + xRcvd; + return t.toLatin1(); } - // open ADIF file and append the QSO details. Return true on success bool ADIF::addQSOToFile(QByteArray const& ADIF_record) { diff --git a/logbook/adif.h b/logbook/adif.h index 384ba4924..d203227f1 100644 --- a/logbook/adif.h +++ b/logbook/adif.h @@ -33,11 +33,12 @@ class ADIF // open ADIF file and append the QSO details. Return true on success bool addQSOToFile(QByteArray const& ADIF_record); - QByteArray QSOToADIF(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, QString const& operator_call); + QByteArray QSOToADIF(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, QString const& operator_call, + QString const& xSent, QString const& xRcvd); private: struct QSO diff --git a/logqso.cpp b/logqso.cpp index e66f2e696..be3ae2f88 100644 --- a/logqso.cpp +++ b/logqso.cpp @@ -60,9 +60,13 @@ void LogQSO::initLogQSO(QString const& hisCall, QString const& hisGrid, QString QDateTime const& dateTimeOn, QDateTime const& dateTimeOff, Radio::Frequency dialFreq, QString const& myCall, QString const& myGrid, bool noSuffix, bool toRTTY, bool dBtoComments, bool bFox, - bool bAutoLog, QString const& opCall) + bool bAutoLog, QString const& opCall, qint32 nContest, + QString xSent, QString xRcvd) { if(!isHidden()) return; + m_nContest=nContest; + m_xSent=xSent; + m_xRcvd=xRcvd; ui->call->setText(hisCall); ui->grid->setText(hisGrid); ui->name->setText(""); @@ -120,8 +124,9 @@ void LogQSO::accept() auto adifilePath = QDir {QStandardPaths::writableLocation (QStandardPaths::DataLocation)}.absoluteFilePath ("wsjtx_log.adi"); adifile.init(adifilePath); - QByteArray ADIF {adifile.QSOToADIF (hisCall, hisGrid, mode, rptSent, rptRcvd, m_dateTimeOn, m_dateTimeOff, band - , comments, name, strDialFreq, m_myCall, m_myGrid, m_txPower, operator_call)}; + QByteArray ADIF {adifile.QSOToADIF (hisCall, hisGrid, mode, rptSent, rptRcvd, + m_dateTimeOn, m_dateTimeOff, band, comments, name, strDialFreq, m_myCall, + m_myGrid, m_txPower, operator_call, m_xSent, m_xRcvd)}; if (!adifile.addQSOToFile (ADIF)) { MessageBox::warning_message (this, tr ("Log file error"), diff --git a/logqso.h b/logqso.h index 971117dd8..f70e297d7 100644 --- a/logqso.h +++ b/logqso.h @@ -34,7 +34,8 @@ public: QDateTime const& dateTimeOff, Radio::Frequency dialFreq, QString const& myCall, QString const& myGrid, bool noSuffix, bool toRTTY, bool dBtoComments, bool bFox, - bool bAutoLog, QString const& opCall); + bool bAutoLog, QString const& opCall, qint32 nContest, QString xSent, + QString xRcvd); public slots: void accept(); @@ -62,6 +63,9 @@ private: Radio::Frequency m_dialFreq; QString m_myCall; QString m_myGrid; + QString m_xSent; + QString m_xRcvd; + qint32 m_nContest; QDateTime m_dateTimeOn; QDateTime m_dateTimeOff; }; diff --git a/mainwindow.cpp b/mainwindow.cpp index 2d741bd26..7a0c4daf2 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -5167,23 +5167,35 @@ void MainWindow::on_logQSOButton_clicked() //Log QSO button if (dateTimeQSOOff < m_dateTimeQSOOn) dateTimeQSOOff = m_dateTimeQSOOn; QString grid=m_hisGrid; if(grid=="....") grid=""; - bool bAutoLog=m_config.autoLog() and m_nContest>0; - m_logDlg->initLogQSO (m_hisCall, grid, m_modeTx, m_rptSent, m_rptRcvd, - 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_config.bFox(), bAutoLog, m_opCall); - if(m_nContest!=NONE) { + if(m_nContest>NONE and m_nContestsbSerialNumber->value(); - ui->sbSerialNumber->setValue(n+1); - cabLog(); //Call the Cabrillo contest logger + if(m_nContest==EU_VHF) { + m_rptSent=m_xSent.split(" ").at(0).left(2); + m_rptRcvd=m_xRcvd.split(" ").at(0).left(2); } + if(m_nContest==FIELD_DAY) { + m_rptSent=m_xSent.split(" ").at(0); + m_rptRcvd=m_xRcvd.split(" ").at(0); + } + if(m_nContest==RTTY) { + m_rptSent=m_xSent.split(" ").at(0); + m_rptRcvd=m_xRcvd.split(" ").at(0); + } + int n=ui->sbSerialNumber->value(); + ui->sbSerialNumber->setValue(n+1); + cabLog(); //Call the Cabrillo contest logger } + + bool bAutoLog=m_config.autoLog() and m_nContest>0; + m_logDlg->initLogQSO (m_hisCall, grid, m_modeTx, m_rptSent, m_rptRcvd, + 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_config.bFox(), + bAutoLog, m_opCall, m_nContest, m_xSent, m_xRcvd); } void MainWindow::cabLog() diff --git a/messageaveraging.cpp b/messageaveraging.cpp index 496249ae3..bf98fd782 100644 --- a/messageaveraging.cpp +++ b/messageaveraging.cpp @@ -156,5 +156,4 @@ void MessageAveraging::contestAddLog(qint32 nContest, QString logLine) int score=m_mult_*m_nLogged_; t.sprintf("Score: %d",score); ui->lab3->setText(t); - qDebug() << m_nLogged_ << m_mult_ << score; }