Cleaning up the "Log QSO" function. (Not finished, yet...)

git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@3342 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
Joe Taylor 2013-06-06 15:09:49 +00:00
parent 08c28ecb6c
commit e97d3c1406
4 changed files with 58 additions and 55 deletions

View File

@ -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<eoh>" << endl;
@ -109,8 +107,7 @@ void LogQSO::accept()
t+=" <rst_sent:" + QString::number(rptSent.length()) + ">" + rptSent;
t+=" <rst_rcvd:" + QString::number(rptRcvd.length()) + ">" + rptRcvd;
t+=" <qso_date:8>" + date;
t+=" <time_on:4>" + qsoStart;
// t+=" <time_off:4>" + qsoStop;
t+=" <time_on:4>" + time;
t+=" <band:" + QString::number(band.length()) + ">" + band;
t+=" <freq:" + QString::number(strDialFreq.length()) + ">" + strDialFreq;
t+=" <station_callsign:" + QString::number(m_myCall.length()) + ">" +
@ -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();
}

View File

@ -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();

View File

@ -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("");

View File

@ -322,7 +322,7 @@ private:
QStringList m_macro;
QStringList m_dFreq;
QDateTime dateTimeQSO;
QDateTime m_dateTimeQSO;
SoundInThread soundInThread; //Instantiate the audio threads
SoundOutThread soundOutThread;