diff --git a/src/blackgui/components/networkdetailscomponent.cpp b/src/blackgui/components/networkdetailscomponent.cpp index 2856b9bc5..ab80375cc 100644 --- a/src/blackgui/components/networkdetailscomponent.cpp +++ b/src/blackgui/components/networkdetailscomponent.cpp @@ -106,7 +106,7 @@ namespace BlackGui::Components if (vatsimFsdServers.isEmpty()) { return; } vatsimFsdServers.sortBy(&CServer::getName); const CServer currentServer = m_networkSetup.getLastVatsimServer(); - ui->comp_VatsimServers->setServers(vatsimFsdServers, true); + ui->comp_VatsimServers->setServers(vatsimFsdServers); ui->comp_VatsimServers->preSelect(currentServer.getName()); } } diff --git a/src/blackgui/components/serverlistselector.cpp b/src/blackgui/components/serverlistselector.cpp index 94cc35656..a4266bcbc 100644 --- a/src/blackgui/components/serverlistselector.cpp +++ b/src/blackgui/components/serverlistselector.cpp @@ -27,10 +27,10 @@ namespace BlackGui::Components connect(this, &QComboBox::currentTextChanged, this, &CServerListSelector::onServerTextChanged); } - void CServerListSelector::setServers(const CServerList &servers, bool nameIsCountry) + void CServerListSelector::setServers(const CServerList &servers) { if (m_servers == servers) { return; } - this->setServerItems(servers, nameIsCountry); + this->setServerItems(servers); if (!servers.isEmpty() && !m_pendingPreselect.isEmpty()) { this->preSelect(m_pendingPreselect); @@ -64,7 +64,7 @@ namespace BlackGui::Components return false; } - void CServerListSelector::setServerItems(const CServerList &servers, bool nameToCountry) + void CServerListSelector::setServerItems(const CServerList &servers) { QString currentlySelected(this->currentText()); int index = -1; @@ -72,7 +72,6 @@ namespace BlackGui::Components m_items.clear(); this->clear(); // ui - nameToCountry = nameToCountry && knowsAllCountries(); for (const CServer &server : servers) { const QString d(server.getName() + ": " + server.getDescription()); @@ -82,22 +81,7 @@ namespace BlackGui::Components index = m_items.size() - 1; } - if (nameToCountry) - { - const CCountry country(this->findCountry(server)); - if (country.getName().isEmpty()) - { - this->addItem(CIcons::empty16(), d); - } - else - { - this->addItem(CIcon(country.toIcon()).toPixmap(), d); - } - } - else - { - this->addItem(d); - } + this->addItem(d); } // reselect @@ -118,29 +102,4 @@ namespace BlackGui::Components emit this->serverChanged(this->currentServer()); } - bool CServerListSelector::knowsAllCountries() - { - return (sGui && sGui->getWebDataServices() && sGui->getWebDataServices()->getCountriesCount() > 0); - } - - CCountry CServerListSelector::findCountry(const CServer &server) - { - if (!CServerListSelector::knowsAllCountries()) { return CCountry(); } - static const CCountryList countries(sGui->getWebDataServices()->getCountries()); - 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 diff --git a/src/blackgui/components/serverlistselector.h b/src/blackgui/components/serverlistselector.h index 9fffcfac5..891e9921e 100644 --- a/src/blackgui/components/serverlistselector.h +++ b/src/blackgui/components/serverlistselector.h @@ -9,7 +9,6 @@ #include "blackgui/blackguiexport.h" #include "blackmisc/network/data/lastserver.h" #include "blackmisc/network/serverlist.h" -#include "blackmisc/country.h" #include "blackmisc/datacache.h" #include @@ -28,7 +27,7 @@ namespace BlackGui::Components explicit CServerListSelector(QWidget *parent = nullptr); //! Set the servers - void setServers(const BlackMisc::Network::CServerList &servers, bool nameIsCountry = false); + void setServers(const BlackMisc::Network::CServerList &servers); //! Get the current server BlackMisc::Network::CServer currentServer() const; @@ -42,17 +41,11 @@ namespace BlackGui::Components private: //! Build the item string descriptions - void setServerItems(const BlackMisc::Network::CServerList &servers, bool nameToCountry); + void setServerItems(const BlackMisc::Network::CServerList &servers); //! Server index has been changed void onServerTextChanged(const QString &text); - //! Do we know all countries? - static bool knowsAllCountries(); - - //! Turn server name into country (for VATSIM servers) - static BlackMisc::CCountry findCountry(const BlackMisc::Network::CServer &server); - BlackMisc::Network::CServerList m_servers; //!< corresponding servers QStringList m_items; //!< items strings QString m_pendingPreselect; //!< pending preselect value