summaryrefslogtreecommitdiff
path: root/logbook/adif.cpp
diff options
context:
space:
mode:
authorEnrico Rossi <e.rossi@tecnobrain.com>2018-11-03 17:52:26 +0100
committerEnrico Rossi <e.rossi@tecnobrain.com>2018-11-03 17:52:26 +0100
commitb4aebf2d137b892f53503b13785ecae900062ff7 (patch)
tree3ba99b2baec2292f2e13bfe90a5e401a5f4c47a5 /logbook/adif.cpp
parent37f727ac0746fd85504aa46c1f023c09b3eff33a (diff)
New upstream version 1.9.1+repackupstream/1.9.1+repack
* Drop local hamlib copy (commit d1b545be). * Drop local boost copy (1.63.0).
Diffstat (limited to 'logbook/adif.cpp')
-rw-r--r--logbook/adif.cpp73
1 files changed, 44 insertions, 29 deletions
diff --git a/logbook/adif.cpp b/logbook/adif.cpp
index fc1fdbeb..a1be7de5 100644
--- a/logbook/adif.cpp
+++ b/logbook/adif.cpp
@@ -14,13 +14,13 @@
void ADIF::init(QString const& filename)
{
_filename = filename;
- _data.clear();
+ _data.clear();
}
QString ADIF::extractField(QString const& record, QString const& fieldName) const
{
- int fieldNameIndex = record.indexOf (fieldName + ':', 0, Qt::CaseInsensitive);
+ int fieldNameIndex = record.indexOf ('<' + fieldName + ':', 0, Qt::CaseInsensitive);
if (fieldNameIndex >=0)
{
int closingBracketIndex = record.indexOf('>',fieldNameIndex);
@@ -165,17 +165,55 @@ QList<QString> ADIF::getCallList() const
++i;
}
return p;
-}
+}
+
+
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)
+{
+ QString t;
+ t = "<call:" + QString::number(hisCall.length()) + ">" + hisCall;
+ t += " <gridsquare:" + QString::number(hisGrid.length()) + ">" + hisGrid;
+ 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>" + 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()) + ">" +
+ m_myCall;
+ t += " <my_gridsquare:" + QString::number(m_myGrid.length()) + ">" +
+ m_myGrid;
+ if (m_txPower != "")
+ t += " <tx_pwr:" + QString::number(m_txPower.length()) +
+ ">" + m_txPower;
+ if (comments != "")
+ t += " <comment:" + QString::number(comments.length()) +
+ ">" + comments;
+ if (name != "")
+ t += " <name:" + QString::number(name.length()) +
+ ">" + name;
+ if (operator_call!="")
+ t+=" <operator:" + QString::number(operator_call.length()) +
+ ">" + operator_call;
+ return t.toLatin1 ();
+}
+
// open ADIF file and append the QSO details. Return true on success
-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)
+bool ADIF::addQSOToFile(QByteArray const& ADIF_record)
{
QFile f2(_filename);
if (!f2.open(QIODevice::Text | QIODevice::Append))
@@ -186,30 +224,7 @@ bool ADIF::addQSOToFile(QString const& hisCall, QString const& hisGrid, QString
if (f2.size()==0)
out << "WSJT-X ADIF Export<eoh>" << endl; // new file
- QString t;
- t="<call:" + QString::number(hisCall.length()) + ">" + hisCall;
- t+=" <gridsquare:" + QString::number(hisGrid.length()) + ">" + hisGrid;
- 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>" + 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()) + ">" +
- m_myCall;
- t+=" <my_gridsquare:" + QString::number(m_myGrid.length()) + ">" +
- m_myGrid;
- if(m_txPower!="") t+= " <tx_pwr:" + QString::number(m_txPower.length()) +
- ">" + m_txPower;
- if(comments!="") t+=" <comment:" + QString::number(comments.length()) +
- ">" + comments;
- if(name!="") t+=" <name:" + QString::number(name.length()) +
- ">" + name;
- t+=" <eor>";
- out << t << endl;
+ out << ADIF_record << " <eor>" << endl;
f2.close();
}
return true;