mirror of
https://github.com/saitohirga/WSJT-X.git
synced 2024-12-25 20:33:08 -05:00
Fix logged QSO start and end times
This change also adds seconds resolution to log files and log QSO fields. This change makes the log QSO dialog more layout friendly and uses a QDateTimeEdit for QSO start and end times. git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@7827 ab8295b8-cf94-4d9e-aec4-7959e3be5d79
This commit is contained in:
parent
66b347d83f
commit
dac5831189
@ -2,22 +2,23 @@
|
||||
|
||||
#include <QFile>
|
||||
#include <QTextStream>
|
||||
#include <QDateTime>
|
||||
#include <QDebug>
|
||||
|
||||
/*
|
||||
<CALL:4>W1XT<BAND:3>20m<FREQ:6>14.076<GRIDSQUARE:4>DM33<MODE:4>JT65<RST_RCVD:3>-21<RST_SENT:3>-14<QSO_DATE:8>20110422<TIME_ON:4>0417<TIME_OFF:4>0424<TX_PWR:1>4<COMMENT:34>1st JT65A QSO. Him: mag loop 20W<STATION_CALLSIGN:6>VK3ACF<MY_GRIDSQUARE:6>qf22lb<eor>
|
||||
<CALL:6>IK1SOW<BAND:3>20m<FREQ:6>14.076<GRIDSQUARE:4>JN35<MODE:4>JT65<RST_RCVD:3>-19<RST_SENT:3>-11<QSO_DATE:8>20110422<TIME_ON:4>0525<TIME_OFF:4>0533<TX_PWR:1>3<STATION_CALLSIGN:6>VK3ACF<MY_GRIDSQUARE:6>qf22lb<eor>
|
||||
<CALL:4>W1XT<BAND:3>20m<FREQ:6>14.076<GRIDSQUARE:4>DM33<MODE:4>JT65<RST_RCVD:3>-21<RST_SENT:3>-14<QSO_DATE:8>20110422<TIME_ON:6>041712<TIME_OFF:6>042435<TX_PWR:1>4<COMMENT:34>1st JT65A QSO. Him: mag loop 20W<STATION_CALLSIGN:6>VK3ACF<MY_GRIDSQUARE:6>qf22lb<eor>
|
||||
<CALL:6>IK1SOW<BAND:3>20m<FREQ:6>14.076<GRIDSQUARE:4>JN35<MODE:4>JT65<RST_RCVD:3>-19<RST_SENT:3>-11<QSO_DATE:8>20110422<TIME_ON:6>052501<TIME_OFF:6>053359<TX_PWR:1>3<STATION_CALLSIGN:6>VK3ACF<MY_GRIDSQUARE:6>qf22lb<eor>
|
||||
<CALL:6:S>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<QSO> 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:" + QString::number(mode.length()) + ">" + mode;
|
||||
t+=" <rst_sent:" + QString::number(rptSent.length()) + ">" + rptSent;
|
||||
t+=" <rst_rcvd:" + QString::number(rptRcvd.length()) + ">" + rptRcvd;
|
||||
t+=" <qso_date:8>" + dateOn;
|
||||
t+=" <time_on:4>" + timeOn;
|
||||
t+=" <qso_date_off:8>" + dateOff;
|
||||
t+=" <time_off:4>" + timeOff;
|
||||
t+=" <qso_date:8>" + dateTimeOn.date ().toString ("yyyyMMdd");
|
||||
t+=" <time_on:6>" + dateTimeOn.time ().toString ("hhmmss");
|
||||
t+=" <qso_date_off:8>" + dateTimeOff.date ().toString ("yyyyMMdd");
|
||||
t+=" <time_off:6>" + dateTimeOff.time ().toString ("hhmmss");
|
||||
t+=" <band:" + QString::number(band.length()) + ">" + band;
|
||||
t+=" <freq:" + QString::number(strDialFreq.length()) + ">" + strDialFreq;
|
||||
t+=" <station_callsign:" + QString::number(m_myCall.length()) + ">" +
|
||||
|
@ -16,20 +16,21 @@
|
||||
#include <QtGui>
|
||||
#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<QString> 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<QString, QSO> _data;
|
||||
QMultiHash<QString, QSO> _data;
|
||||
QString _filename;
|
||||
|
||||
QString _extractField(const QString line, const QString fieldName);
|
||||
QString _extractField(QString const& line, QString const& fieldName);
|
||||
};
|
||||
|
||||
|
||||
|
42
logqso.cpp
42
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;
|
||||
|
7
logqso.h
7
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:
|
||||
|
@ -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)
|
||||
|
@ -519,8 +519,6 @@ private:
|
||||
QSet<QString> m_sfx;
|
||||
|
||||
QDateTime m_dateTimeQSOOn;
|
||||
QDateTime m_dateTimeQSOOff;
|
||||
QDateTime m_dateTimeDefault;
|
||||
|
||||
QSharedMemory *mem_jt9;
|
||||
LogBook m_logBook;
|
||||
|
Loading…
Reference in New Issue
Block a user