diff options
Diffstat (limited to 'logbook')
| -rw-r--r-- | logbook/adif.cpp | 73 | ||||
| -rw-r--r-- | logbook/adif.h | 12 | ||||
| -rw-r--r-- | logbook/countrydat.cpp | 23 | ||||
| -rw-r--r-- | logbook/logbook.cpp | 1 |
4 files changed, 69 insertions, 40 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; diff --git a/logbook/adif.h b/logbook/adif.h index e4772055..727ca995 100644 --- a/logbook/adif.h +++ b/logbook/adif.h @@ -29,10 +29,16 @@ class ADIF int getCount() const; // open ADIF file and append the QSO details. Return true on success - 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); + bool addQSOToFile(QByteArray const& ADIF_record); - private: + 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); + + +private: struct QSO { QString call,band,mode,date; diff --git a/logbook/countrydat.cpp b/logbook/countrydat.cpp index 7f3d613b..d1997a97 100644 --- a/logbook/countrydat.cpp +++ b/logbook/countrydat.cpp @@ -18,7 +18,8 @@ #include "countrydat.h" #include <QFile> #include <QTextStream> - +#include <QDebug> +#include "Radio.hpp" void CountryDat::init(const QString filename) { @@ -91,6 +92,11 @@ void CountryDat::load() QString name = _extractName(line1); if (name.length()>0) { + QString continent=line1.mid(36,2); + QString principalPrefix=line1.mid(69,4); + int i1=principalPrefix.indexOf(":"); + if(i1>0) principalPrefix=principalPrefix.mid(0,i1); + name += "; " + principalPrefix + "; " + continent; _countryNames << name; bool more = true; QStringList prefixs; @@ -126,14 +132,15 @@ QString CountryDat::find(QString call) const return fixup (_data.value ("=" + call), call); } - auto prefix = call; - while (prefix.size () >= 1) + auto prefix = Radio::effective_prefix (call); + auto match_candidate = prefix; + while (match_candidate.size () >= 1) { - if (_data.contains (prefix)) + if (_data.contains (match_candidate)) { - return fixup (_data.value (prefix), call); + return fixup (_data.value (match_candidate), prefix); } - prefix = prefix.left (prefix.size () - 1); + match_candidate = match_candidate.left (match_candidate.size () - 1); } return QString {}; } @@ -145,9 +152,9 @@ QString CountryDat::fixup (QString country, QString const& call) const // // KG4 2x1 and 2x3 calls that map to Gitmo are mainland US not Gitmo - if (call.startsWith ("KG4") && call.size () != 5) + if (call.startsWith ("KG4") && call.size () != 5 && call.size () != 3) { - country.replace ("Guantanamo Bay", "United States"); + country.replace ("Guantanamo Bay; KG4; NA", "United States; K; NA"); } return country; } diff --git a/logbook/logbook.cpp b/logbook/logbook.cpp index 48d6a2a6..e938910d 100644 --- a/logbook/logbook.cpp +++ b/logbook/logbook.cpp @@ -75,6 +75,7 @@ void LogBook::match(/*in*/const QString call, QString currentBand = ""; // match any band callWorkedBefore = _log.match(call,currentBand,currentMode); countryName = _countries.find(call); +// qDebug() << "B" << countryName; if (countryName.length() > 0) // country was found countryWorkedBefore = _worked.getHasWorked(countryName); |
