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
This commit is contained in:
Bill Somerville 2017-08-07 14:31:05 +00:00
parent febcf6b554
commit 656ba6a6fb
4 changed files with 25 additions and 22 deletions

View File

@ -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;

View File

@ -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 {};
}

View File

@ -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:

View File

@ -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