/**************************************************************************** * * (c) 2009-2016 QGROUNDCONTROL PROJECT * * QGroundControl is licensed according to the terms in the file * COPYING.md in the root of the source code directory. * ****************************************************************************/ #include "FlightMapSettings.h" #include #include const char* FlightMapSettings::flightMapSettingsGroupName = "FlightMap"; const char* FlightMapSettings::mapProviderSettingsName = "MapProvider"; const char* FlightMapSettings::mapTypeSettingsName = "MapType"; const char* FlightMapSettings::_settingsGroupName = "FlightMap"; FlightMapSettings::FlightMapSettings(QObject* parent) : SettingsGroup(flightMapSettingsGroupName, QString(_settingsGroupName) /* root settings group */, parent) , _mapProviderFact(NULL) , _mapTypeFact(NULL) { QQmlEngine::setObjectOwnership(this, QQmlEngine::CppOwnership); qmlRegisterUncreatableType("QGroundControl.SettingsManager", 1, 0, "FlightMapSettings", "Reference only"); // Save the original version since we modify based on map provider _savedMapTypeStrings = _nameToMetaDataMap[mapTypeSettingsName]->enumStrings(); _savedMapTypeValues = _nameToMetaDataMap[mapTypeSettingsName]->enumValues(); #ifdef QGC_NO_GOOGLE_MAPS // Find google in the list and remove it FactMetaData* metaData = _nameToMetaDataMap[mapProviderSettingsName]; QVariantList enumValues = metaData->enumValues(); QStringList enumStrings = metaData->enumStrings(); _removeEnumValue(mapProviderGoogle, enumStrings, enumValues); metaData->setEnumInfo(enumStrings, enumValues); #endif _newMapProvider(mapProvider()->rawValue()); } Fact* FlightMapSettings::mapProvider(void) { if (!_mapProviderFact) { _mapProviderFact = _createSettingsFact(mapProviderSettingsName); connect(_mapProviderFact, &Fact::rawValueChanged, this, &FlightMapSettings::_newMapProvider); } return _mapProviderFact; } Fact* FlightMapSettings::mapType(void) { if (!_mapTypeFact) { _mapTypeFact = _createSettingsFact(mapTypeSettingsName); } return _mapTypeFact; } void FlightMapSettings::_removeEnumValue(int value, QStringList& enumStrings, QVariantList& enumValues) { bool found = false; int removeIndex; for (removeIndex=0; removeIndexsetEnumInfo(enumStrings, enumValues); emit mapTypeChanged(); // Check that map type is still valid for this new map provider bool found = false; int currentMapType = mapType()->rawValue().toInt(); for (int i=0; isetRawValue(0); } }