Ref T718, improved country "resolution" in server names/descriptions

This commit is contained in:
Klaus Basan
2019-08-29 18:13:48 +02:00
committed by Mat Sutcliffe
parent 009719a7be
commit bb8f46ed68
3 changed files with 22 additions and 7 deletions

View File

@@ -95,7 +95,7 @@ namespace BlackGui
const CCountry country(this->findCountry(server));
if (country.getName().isEmpty())
{
this->addItem(d);
this->addItem(CIcons::empty16(), d);
}
else
{
@@ -135,7 +135,21 @@ namespace BlackGui
{
if (!CServerListSelector::knowsAllCountries()) { return CCountry(); }
static const CCountryList countries(sGui->getWebDataServices()->getCountries());
return countries.findBestMatchByCountryName(server.getName());
const CCountry ctryByName = countries.findBestMatchByCountryName(server.getName());
if (ctryByName.isValid()) { return ctryByName; }
// own approach, see if description contains a valid countr name
for (const CCountry &testCtry : countries)
{
if (testCtry.getName().isEmpty()) { continue; }
if (server.getDescription().contains(testCtry.getName(), Qt::CaseInsensitive))
{
return testCtry;
}
}
const CCountry ctryByDescription = countries.findBestMatchByCountryName(server.getDescription());
return ctryByDescription;
}
} // ns
} // ns