From 788190872b1c50af68b694d40383b70bb9f7ee98 Mon Sep 17 00:00:00 2001 From: f4exb Date: Fri, 8 Mar 2024 15:36:03 +0100 Subject: [PATCH] Callsign: removed comma separated country data --- sdrbase/util/callsign.cpp | 35 ----------------------------------- sdrbase/util/callsign.h | 1 - sdrbase/util/countrydat.cpp | 5 ++--- sdrbase/util/countrydat.h | 2 -- sdrbench/test_callsign.cpp | 3 +-- 5 files changed, 3 insertions(+), 43 deletions(-) diff --git a/sdrbase/util/callsign.cpp b/sdrbase/util/callsign.cpp index 45226d89d..e3136f454 100644 --- a/sdrbase/util/callsign.cpp +++ b/sdrbase/util/callsign.cpp @@ -144,41 +144,6 @@ QString Callsign::striped_prefix (QString callsign) return match.captured("prefix"); } -QString Callsign::getCountryData(QString const& callsign) -{ - QString pf = callsign.toUpper(); - - while (!pf.isEmpty ()) - { - QString country = ""; - - if (pf.length() == callsign.length()) - { - country = m_countryDat.getData().value("="+pf, country); - - if (!country.isEmpty ()) { - return country; - } else { - pf = effective_prefix(callsign); - } - } - - if (pf == "KG4" && callsign.length() != 5) { - pf = "AA"; - } - - country = m_countryDat.getData().value(pf, country); - - if (!country.isEmpty ()) { - return country; - } - - pf = pf.left(pf.length()-1); - } - - return " ,?,where?, , "; -} - CountryDat::CountryInfo Callsign::getCountryInfo(QString const& callsign) { QString pf = callsign.toUpper(); diff --git a/sdrbase/util/callsign.h b/sdrbase/util/callsign.h index ffff9fa6b..2a6d7bfb6 100644 --- a/sdrbase/util/callsign.h +++ b/sdrbase/util/callsign.h @@ -41,7 +41,6 @@ public: static QString base_callsign(QString); static QString effective_prefix(QString); static QString striped_prefix(QString); - QString getCountryData(QString const& callsign); CountryDat::CountryInfo getCountryInfo(QString const& callsign); private: diff --git a/sdrbase/util/countrydat.cpp b/sdrbase/util/countrydat.cpp index 420831d02..19743698f 100644 --- a/sdrbase/util/countrydat.cpp +++ b/sdrbase/util/countrydat.cpp @@ -44,7 +44,7 @@ const CountryDat::CountryInfo CountryDat::nullCountry = CountryDat::CountryInfo{ void CountryDat::init() { - _data.clear(); + _countries.clear(); _name.clear(); _name.insert("where?","where?"); _name.insert("Sov Mil Order of Malta","Sov Mil Order of Malta"); @@ -544,7 +544,7 @@ QStringList CountryDat::_extractPrefix(QString &line, bool &more) void CountryDat::load() { - _data.clear(); + _countries.clear(); QFile inputFile(":/data/cty.dat"); if (inputFile.open(QIODevice::ReadOnly)) @@ -610,7 +610,6 @@ void CountryDat::load() _continent = continent; } - _data.insert(p, _continent + ',' + masterPrefix + ',' + country + ',' + _cqz + ',' + _ituz); _countries.insert(p, CountryInfo{_continent, masterPrefix, country, _cqz, _ituz}); } } diff --git a/sdrbase/util/countrydat.h b/sdrbase/util/countrydat.h index 482500eb5..e193adbc6 100644 --- a/sdrbase/util/countrydat.h +++ b/sdrbase/util/countrydat.h @@ -49,7 +49,6 @@ public: void init(); void load(); - const QHash& getData() const { return _data; } const QHash& getCountries() const { return _countries; } static const CountryInfo nullCountry; @@ -63,7 +62,6 @@ private: QStringList _extractPrefix(QString &line, bool &more); QString _filename; - QHash _data; QHash _name; QHash _countries; }; diff --git a/sdrbench/test_callsign.cpp b/sdrbench/test_callsign.cpp index 585af868b..4eba22c24 100644 --- a/sdrbench/test_callsign.cpp +++ b/sdrbench/test_callsign.cpp @@ -38,9 +38,8 @@ void MainBench::testCallsign(const QString& argsStr) qInfo("%s is the base callsign of %s", qPrintable(Callsign::base_callsign(argsStr)), qPrintable(argsStr)); qInfo("%s is the effective prefix of %s", qPrintable(Callsign::effective_prefix(argsStr)), qPrintable(argsStr)); qInfo("%s is the striped prefix of %s", qPrintable(Callsign::striped_prefix(argsStr)), qPrintable(argsStr)); - qInfo("%s is the country data for callsign %s", qPrintable(Callsign::instance()->getCountryData(argsStr)), qPrintable(argsStr)); CountryDat::CountryInfo countryInfo = Callsign::instance()->getCountryInfo(argsStr); - qInfo("%s is the continent", qPrintable(countryInfo.continent)); + qInfo("%s DXCC country infoirmation", qPrintable(argsStr)); qInfo("%s is the continent", qPrintable(countryInfo.continent)); qInfo("%s is the country", qPrintable(countryInfo.country)); qInfo("%s is the master prefix", qPrintable(countryInfo.masterPrefix)); qInfo("%s is the cq zone", qPrintable(countryInfo.cqZone));