mirror of
https://github.com/swift-project/pilotclient.git
synced 2026-04-05 09:15:34 +08:00
Gimmick and formatting
* flags for VATSIM servers * improved country resolution
This commit is contained in:
@@ -119,8 +119,7 @@ namespace BlackMisc
|
||||
if (this->m_designator.length() > 2)
|
||||
{
|
||||
// relative to images
|
||||
return CIcon("airlines/" + m_designator.toLower() + ".png",
|
||||
this->convertToQString());
|
||||
return CIcon("airlines/" + m_designator.toLower() + ".png", this->convertToQString());
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -26,8 +26,7 @@ namespace BlackMisc
|
||||
if (this->m_dbKey.length() == 2)
|
||||
{
|
||||
// relative to images
|
||||
return CIcon("flags/" + m_dbKey.toLower() + ".png",
|
||||
this->convertToQString());
|
||||
return CIcon("flags/" + m_dbKey.toLower() + ".png", this->convertToQString());
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -73,7 +72,7 @@ namespace BlackMisc
|
||||
if (name.isEmpty() || m_name.isEmpty()) { return false; }
|
||||
if (name.length() < 5)
|
||||
{
|
||||
return m_name.length() == name.length() && m_name.startsWith(name, Qt::CaseInsensitive);
|
||||
return m_name.length() == name.length() && (m_name.startsWith(name, Qt::CaseInsensitive) || name.startsWith(m_name, Qt::CaseInsensitive));
|
||||
}
|
||||
else
|
||||
{
|
||||
|
||||
@@ -32,17 +32,22 @@ namespace BlackMisc
|
||||
CCountry CCountryList::findBestMatchByCountryName(const QString &countryName) const
|
||||
{
|
||||
if (countryName.isEmpty()) { return CCountry(); }
|
||||
|
||||
static const QRegExp reg("[^a-z]", Qt::CaseInsensitive);
|
||||
QString cn(countryName);
|
||||
cn.remove(reg);
|
||||
CCountryList countries = this->findBy([&](const CCountry & country)
|
||||
{
|
||||
return country.matchesCountryName(countryName);
|
||||
return country.matchesCountryName(cn);
|
||||
});
|
||||
if (countries.size() < 2) { return countries.frontOrDefault(); }
|
||||
|
||||
// find best match
|
||||
// find best match by further reducing
|
||||
for (const CCountry &c : countries)
|
||||
{
|
||||
if (c.getName() == countryName) { return c; }
|
||||
if (c.getName().startsWith(countryName, Qt::CaseInsensitive)) { return c; }
|
||||
if (c.getName() == cn) { return c; }
|
||||
if (c.getName().startsWith(cn, Qt::CaseInsensitive)) { return c; }
|
||||
if (cn.startsWith(c.getName(), Qt::CaseInsensitive)) { return c; }
|
||||
}
|
||||
return countries.front();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user