Cleanup use of custom provider definitions, use common map_provider.hpp

This commit is contained in:
Dan Paulat 2023-04-30 14:47:30 -05:00
parent 6f40c75a33
commit c77c899040
3 changed files with 48 additions and 38 deletions

View file

@ -1,8 +1,11 @@
#include <scwx/qt/settings/general_settings.hpp>
#include <scwx/qt/settings/settings_container.hpp>
#include <scwx/qt/map/map_provider.hpp>
#include <array>
#include <boost/algorithm/string.hpp>
namespace scwx
{
namespace qt
@ -12,9 +15,6 @@ namespace settings
static const std::string logPrefix_ = "scwx::qt::settings::general_settings";
static const std::array<std::string, 2> kMapProviderValues_ {"mapbox",
"maptiler"};
class GeneralSettingsImpl
{
public:
@ -41,9 +41,15 @@ public:
mapProvider_.SetValidator(
[](const std::string& value)
{
return std::find(kMapProviderValues_.cbegin(),
kMapProviderValues_.cend(),
value) != kMapProviderValues_.cend();
return std::find_if(map::MapProviderIterator().begin(),
map::MapProviderIterator().end(),
[&value](map::MapProvider mapProvider)
{
std::string mapProviderName =
map::GetMapProviderName(mapProvider);
boost::to_lower(mapProviderName);
return value == mapProviderName;
}) != map::MapProviderIterator().end();
});
mapboxApiKey_.SetValidator([](const std::string& value)
{ return !value.empty(); });