From 656ba6a6fb78616a471ad14776759aaaa2472268 Mon Sep 17 00:00:00 2001 From: Bill Somerville Date: Mon, 7 Aug 2017 14:31:05 +0000 Subject: [PATCH] Merged from WSJT-X v1.8 branch: ------------------------------------------------------------------------ r8012 | bsomervi | 2017-08-07 15:29:25 +0100 (Mon, 07 Aug 2017) | 1 line Better fix for KG4 call country lookup and worked before status ------------------------------------------------------------------------ git-svn-id: svn+ssh://svn.code.sf.net/p/wsjt/wsjt/branches/wsjtx@8013 ab8295b8-cf94-4d9e-aec4-7959e3be5d79 --- displaytext.cpp | 10 ---------- logbook/countrydat.cpp | 34 +++++++++++++++++++++++----------- logbook/countrydat.h | 2 +- logbook/logbook.cpp | 1 + 4 files changed, 25 insertions(+), 22 deletions(-) diff --git a/displaytext.cpp b/displaytext.cpp index 124f180ee..8d28ac879 100644 --- a/displaytext.cpp +++ b/displaytext.cpp @@ -153,16 +153,6 @@ QString DisplayText::appendDXCCWorkedB4(QString message, QString const& callsign countryName.replace ("European", "EU"); countryName.replace ("African", "AF"); - // - // deal with special rules that cty.dat does not cope with - // - - // KG4 2x1 and 2x3 calls that map to Gitmo are mainland US not Gitmo - if (call.startsWith ("KG4") && call.size () != 5) - { - countryName.replace ("Guantanamo Bay", "U.S.A."); - } - message += countryName; } return message; diff --git a/logbook/countrydat.cpp b/logbook/countrydat.cpp index 1d88e059e..613d4aeeb 100644 --- a/logbook/countrydat.cpp +++ b/logbook/countrydat.cpp @@ -117,19 +117,31 @@ void CountryDat::load() } // return country name else "" -QString CountryDat::find(const QString prefix) +QString CountryDat::find(QString prefix) { - QString pf = prefix.toUpper(); - while(pf.length() >= 1) + prefix = prefix.toUpper (); + auto pf = prefix; + while (pf.size () >= 1) { - if (_data.contains(pf)) - { - QString country = _data.value(pf); - return country; - } - pf = pf.left(pf.length()-1); - } - return ""; + if (_data.contains (pf)) + { + QString country {_data.value (pf)}; + + // + // deal with special rules that cty.dat does not cope with + // + + // KG4 2x1 and 2x3 calls that map to Gitmo are mainland US not Gitmo + if (prefix.startsWith ("KG4") && prefix.size () != 5) + { + country.replace ("Guantanamo Bay", "United States"); + } + + return country; + } + pf = pf.left (pf.size () - 1); + } + return QString {}; } diff --git a/logbook/countrydat.h b/logbook/countrydat.h index b9803a7be..ce5d70e3b 100644 --- a/logbook/countrydat.h +++ b/logbook/countrydat.h @@ -19,7 +19,7 @@ class CountryDat public: void init(const QString filename); void load(); - QString find(const QString prefix); // return country name or "" + QString find(QString prefix); // return country name or "" QStringList getCountryNames() { return _countryNames; }; private: diff --git a/logbook/logbook.cpp b/logbook/logbook.cpp index f074116b3..9fb8a79d0 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); + if (countryName.length() > 0) // country was found countryWorkedBefore = _worked.getHasWorked(countryName); else