diff --git a/logqso.cpp b/logqso.cpp index acbea045b..e213ba0c8 100644 --- a/logqso.cpp +++ b/logqso.cpp @@ -5,22 +5,21 @@ LogQSO::LogQSO(QWidget *parent) : - QDialog(parent), - ui(new Ui::LogQSO) + QDialog(parent), + ui(new Ui::LogQSO) { - ui->setupUi(this); + ui->setupUi(this); } LogQSO::~LogQSO() { - delete ui; + delete ui; } void LogQSO::initLogQSO(QString hisCall, QString hisGrid, QString mode, - QString rptSent, QString rptRcvd, QString date, - QString qsoStart, QString qsoStop, double dialFreq, - QString myCall, QString myGrid, bool noSuffix, - bool toRTTY, bool dBtoComments) + QString rptSent, QString rptRcvd, QDateTime dateTime, + double dialFreq, QString myCall, QString myGrid, + bool noSuffix, bool toRTTY, bool dBtoComments) { ui->call->setText(hisCall); ui->grid->setText(hisGrid); @@ -35,10 +34,11 @@ void LogQSO::initLogQSO(QString hisCall, QString hisGrid, QString mode, ui->mode->setText(mode); ui->sent->setText(rptSent); ui->rcvd->setText(rptRcvd); - date=date.mid(0,4) + "-" + date.mid(4,2) + "-" + date.mid(6,2); + m_dateTime=dateTime; + QString date=dateTime.toString("yyyy-MM-dd"); ui->date->setText(date); - ui->time->setText(qsoStart); - if(qsoStart=="") ui->time->setText(qsoStop); //Silence compiler warning + QString time=dateTime.toString("hhmm"); + ui->time->setText(time); m_dialFreq=dialFreq; m_myCall=myCall; m_myGrid=myGrid; @@ -74,31 +74,29 @@ void LogQSO::initLogQSO(QString hisCall, QString hisGrid, QString mode, void LogQSO::accept() { + QString hisCall,hisGrid,mode,rptSent,rptRcvd,date,time,band; + QString comments,name; + + hisCall=ui->call->text(); + hisGrid=ui->grid->text(); + mode=ui->mode->text(); + rptSent=ui->sent->text(); + rptRcvd=ui->rcvd->text(); + date=ui->date->text(); + date=date.mid(0,4) + date.mid(5,2) + date.mid(8,2); + time=ui->time->text(); + band=ui->band->text(); + name=ui->name->text(); + comments=ui->comments->text(); + QString strDialFreq(QString::number(m_dialFreq,'f',6)); + +//Log this QSO to file wsjtx_log.adi QFile f2("wsjtx_log.adi"); if(!f2.open(QIODevice::Text | QIODevice::Append)) { QMessageBox m; m.setText("Cannot open file \"wsjtx_log.adi\"."); m.exec(); } else { - QString hisCall,hisGrid,mode,rptSent,rptRcvd,date,qsoStart,band; - QString comments,name; -// if(qsoStart=="") qsoStart=qsoStop; -// if(qsoStop=="") qsoStop=qsoStart; - - hisCall=ui->call->text(); - hisGrid=ui->grid->text(); - mode=ui->mode->text(); - rptSent=ui->sent->text(); - rptRcvd=ui->rcvd->text(); - date=ui->date->text(); - date=date.mid(0,4) + date.mid(5,2) + date.mid(8,2); - qsoStart=ui->time->text(); - band=ui->band->text(); - name=ui->name->text(); - comments=ui->comments->text(); - - QString strDialFreq(QString::number(m_dialFreq,'f',6)); - QTextStream out(&f2); if(f2.size()==0) out << "WSJT-X ADIF Export" << endl; @@ -109,8 +107,7 @@ void LogQSO::accept() t+=" " + rptSent; t+=" " + rptRcvd; t+=" " + date; - t+=" " + qsoStart; -// t+=" " + qsoStop; + t+=" " + time; t+=" " + band; t+=" " + strDialFreq; t+=" " + @@ -125,6 +122,24 @@ void LogQSO::accept() out << t << endl; f2.close(); } + +//Log this QSO to file wsjtx.log + QFile f("wsjtx.log"); + if(!f.open(QIODevice::Text | QIODevice::Append)) { + QMessageBox m; + m.setText("Cannot open file \"wsjtx.log\"."); + m.exec(); + } else { + QString logEntry=m_dateTime.date().toString("yyyy-MMM-dd,") + + m_dateTime.time().toString("hh:mm,") + hisCall + "," + + hisGrid + "," + strDialFreq + "," + mode + + "," + rptSent + "," + rptRcvd + "," + comments; + QTextStream out(&f); + out << logEntry << endl; + f.close(); + } + +//Clean up and finish logging emit(acceptQSO(true)); QDialog::accept(); } diff --git a/logqso.h b/logqso.h index a4edbb00e..68cf80816 100644 --- a/logqso.h +++ b/logqso.h @@ -19,15 +19,17 @@ public: explicit LogQSO(QWidget *parent = 0); ~LogQSO(); void initLogQSO(QString hisCall, QString hisGrid, QString mode, - QString rptSent, QString rptRcvd, QString date, - QString qsoStart, QString qsoStop, double dialFreq, - QString myCall, QString myGrid, bool noSuffix, - bool toRTTY, bool dBtoComments); + QString rptSent, QString rptRcvd, QDateTime dateTime, + double dialFreq, QString myCall, QString myGrid, + bool noSuffix, bool toRTTY, bool dBtoComments); double m_dialFreq; + QString m_myCall; QString m_myGrid; + QDateTime m_dateTime; + public slots: void accept(); void reject(); diff --git a/mainwindow.cpp b/mainwindow.cpp index 77fdaadee..0d28e530e 100644 --- a/mainwindow.cpp +++ b/mainwindow.cpp @@ -2339,13 +2339,12 @@ void MainWindow::on_genStdMsgsPushButton_clicked() //genStdMsgs button void MainWindow::on_logQSOButton_clicked() //Log QSO button { if(m_hisCall=="") return; - dateTimeQSO = QDateTime::currentDateTimeUtc(); - QString date=dateTimeQSO.toString("yyyyMMdd"); + m_dateTimeQSO=QDateTime::currentDateTimeUtc(); logDlg = new LogQSO(0); - logDlg->initLogQSO(m_hisCall,m_hisGrid,m_mode,m_rptSent,m_rptRcvd,date, - m_qsoStart,m_qsoStop,m_dialFreq + m_txFreq / 1e6,m_myCall,m_myGrid, - m_noSuffix,m_toRTTY,m_dBtoComments); + logDlg->initLogQSO(m_hisCall,m_hisGrid,m_mode,m_rptSent,m_rptRcvd, + m_dateTimeQSO,m_dialFreq,m_myCall,m_myGrid, + m_noSuffix,m_toRTTY,m_dBtoComments); connect(logDlg, SIGNAL(acceptQSO(bool)),this,SLOT(acceptQSO2(bool))); if(m_logQSOgeom != QRect(500,400,424,283)) logDlg->setGeometry(m_logQSOgeom); logDlg->show(); @@ -2355,19 +2354,6 @@ void MainWindow::acceptQSO2(bool accepted) { if(accepted) { m_logQSOgeom=logDlg->geometry(); - QString date=dateTimeQSO.toString("yyyyMMdd"); - QFile f("wsjtx.log"); - if(!f.open(QIODevice::Text | QIODevice::Append)) { - msgBox("Cannot open file \"wsjtx.log\"."); - } else { - QString logEntry=dateTimeQSO.date().toString("yyyy-MMM-dd,") + - dateTimeQSO.time().toString("hh:mm,") + m_hisCall + "," + - m_hisGrid + "," + QString::number(m_dialFreq) + "," + m_mode + - "," + m_rptSent + "," + m_rptRcvd; - QTextStream out(&f); - out << logEntry << endl; - f.close(); - } if(m_clearCallGrid) { m_hisCall=""; ui->dxCallEntry->setText(""); diff --git a/mainwindow.h b/mainwindow.h index 2fa9906db..12d752ddb 100644 --- a/mainwindow.h +++ b/mainwindow.h @@ -322,7 +322,7 @@ private: QStringList m_macro; QStringList m_dFreq; - QDateTime dateTimeQSO; + QDateTime m_dateTimeQSO; SoundInThread soundInThread; //Instantiate the audio threads SoundOutThread soundOutThread;