From be7c40d45f8e781bb9a52134776d076c87d4419d Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Mon, 12 Nov 2018 16:05:10 +0000 Subject: [PATCH 1/2] Remove redundant ExchangeValidator class as now done by a regexp validator --- validators/ExchangeValidator.cpp | 65 -------------------------------- validators/ExchangeValidator.hpp | 19 ---------- widgets/mainwindow.cpp | 1 - 3 files changed, 85 deletions(-) delete mode 100644 validators/ExchangeValidator.cpp delete mode 100644 validators/ExchangeValidator.hpp diff --git a/validators/ExchangeValidator.cpp b/validators/ExchangeValidator.cpp deleted file mode 100644 index 92c77e6aa..000000000 --- a/validators/ExchangeValidator.cpp +++ /dev/null @@ -1,65 +0,0 @@ -#include -#include "ExchangeValidator.hpp" - -ExchangeValidator::ExchangeValidator (QObject * parent) - : QValidator {parent} -{ -} - -auto ExchangeValidator::validate (QString& input, int& length) const -> State -{ - bool ok=false; - QStringList w=input.split(" "); - int nwords=w.size(); - length=input.size(); - input = input.toUpper (); - - if(nwords==1 and length<=3) { - //ARRL RTTY Roundup -// ntype=4; -// ok=exch_valid_(&ntype, const_cast(input.toLatin1().constData()),length); - QStringList states; - states << "AL" << "AK" << "AZ" << "AR" << "CA" << "CO" - << "CT" << "DE" << "FL" << "GA" << "HI" << "ID" - << "IL" << "IN" << "IA" << "KS" << "KY" << "LA" - << "ME" << "MD" << "MA" << "MI" << "MN" << "MS" - << "MO" << "MT" << "NE" << "NV" << "NH" << "NJ" - << "NM" << "NY" << "NC" << "ND" << "OH" << "OK" - << "OR" << "PA" << "RI" << "SC" << "SD" << "TN" - << "TX" << "UT" << "VT" << "VA" << "WA" << "WV" - << "WI" << "WY" << "NB" << "NS" << "QC" << "ON" - << "MB" << "SK" << "AB" << "BC" << "NWT" << "NF" - << "LB" << "NU" << "YT" << "PEI" << "DC" << "DX"; - if(states.contains(input)) ok=true; - - } - if(nwords==2 and w.at(1).size()<=3) { - //ARRL Field Day - int n=w.at(0).size(); - if(n>3) goto done; - int ntx=w.at(0).left(n-1).toInt(); - if(ntx<1 or ntx>32) goto done; - QString c1=w.at(0).right(1); - if(c1<"A" or c1>"F") goto done; - QStringList sections; - sections << "AB" << "AK" << "AL" << "AR" << "AZ" << "BC" - << "CO" << "CT" << "DE" << "EB" << "EMA" << "ENY" - << "EPA" << "EWA" << "GA" << "GTA" << "IA" << "ID" - << "IL" << "IN" << "KS" << "KY" << "LA" << "LAX" - << "MAR" << "MB" << "MDC" << "ME" << "MI" << "MN" - << "MO" << "MS" << "MT" << "NC" << "ND" << "NE" - << "NFL" << "NH" << "NL" << "NLI" << "NM" << "NNJ" - << "NNY" << "NT" << "NTX" << "NV" << "OH" << "OK" - << "ONE" << "ONN" << "ONS" << "OR" << "ORG" << "PAC" - << "PR" << "QC" << "RI" << "SB" << "SC" << "SCV" - << "SD" << "SDG" << "SF" << "SFL" << "SJV" << "SK" - << "SNJ" << "STX" << "SV" << "TN" << "UT" << "VA" - << "VI" << "VT" << "WCF" << "WI" << "WMA" << "WNY" - << "WPA" << "WTX" << "WV" << "WWA" << "WY" << "DX"; - if(sections.contains(w.at(1))) ok=true; - } - -done: - if(ok) return Acceptable; - return Intermediate; -} diff --git a/validators/ExchangeValidator.hpp b/validators/ExchangeValidator.hpp deleted file mode 100644 index 1e7b508dc..000000000 --- a/validators/ExchangeValidator.hpp +++ /dev/null @@ -1,19 +0,0 @@ -#ifndef EXCHANGE_VALIDATOR_HPP__ -#define EXCHANGE_VALIDATOR_HPP__ - -#include - -// ExchangeValidator - QValidator for Field Day and RTTY Roundup exchanges - -class ExchangeValidator final - : public QValidator -{ -public: - ExchangeValidator (QObject * parent = nullptr); - - // QValidator implementation - State validate (QString& input, int& length) const override; - -}; - -#endif diff --git a/widgets/mainwindow.cpp b/widgets/mainwindow.cpp index 287ed6133..a3d7bc967 100644 --- a/widgets/mainwindow.cpp +++ b/widgets/mainwindow.cpp @@ -59,7 +59,6 @@ #include "MultiSettings.hpp" #include "validators/MaidenheadLocatorValidator.hpp" #include "validators/CallsignValidator.hpp" -#include "validators/ExchangeValidator.hpp" #include "EqualizationToolsDialog.hpp" #include "LotWUsers.hpp" #include "logbook/AD1CCty.hpp" From 1fb8eaf13b06e6cb23bc81853fd8e9ce657aa8bc Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Mon, 12 Nov 2018 16:59:02 +0000 Subject: [PATCH 2/2] Send STX ADIF field when sending contest serial numbers This assumes that the last sent exchange field is a serial number if there is more than one word in the exchange sent and the last word is a positive non-zero number. --- logbook/logbook.cpp | 17 ++++++++++++++++- 1 file changed, 16 insertions(+), 1 deletion(-) diff --git a/logbook/logbook.cpp b/logbook/logbook.cpp index cf4e594f1..f7dfc83b3 100644 --- a/logbook/logbook.cpp +++ b/logbook/logbook.cpp @@ -77,7 +77,22 @@ QByteArray LogBook::QSOToADIF (QString const& hisCall, QString const& hisGrid, Q if(comments!="") t += " " + comments; if(name!="") t += " " + name; if(operator_call!="") t+=" " + operator_call; - if(xRcvd!="") { + if (xSent.size ()) + { + auto words = xSent.split (' ', QString::SkipEmptyParts); + if (words.size () > 1) + { + bool ok; + auto sn = words.back ().toUInt (&ok); + if (ok && sn) + { + // assume last word is a serial if there are at least + // two words and if it is positive numeric + t += " ' + words.back (); + } + } + } + if (xRcvd.size ()) { QString t1=""; if(xRcvd.split(" ").size()==2) t1=xRcvd.split(" ").at(1); if(t1.toInt()>0) {