QSettings settings(DIRECTORY_NAME, FILE_NAME);
- // register meta type for custom GeoCoordinate class so that saving the settings does work
- qRegisterMetaType<GeoCoordinate>("GeoCoordinate");
- qRegisterMetaTypeStreamOperators<GeoCoordinate>("GeoCoordinate");
-
settings.setValue(MAP_LAST_POSITION, QVariant::fromValue(centerGeoCoordinate()));
settings.setValue(MAP_LAST_ZOOMLEVEL, m_zoomLevel);
}
// init can be only done if both values exists in the settings
if (settings.contains(MAP_LAST_POSITION) && settings.contains(MAP_LAST_ZOOMLEVEL)) {
- qWarning() << __PRETTY_FUNCTION__ << "both settings found";
QVariant zoomLevel = settings.value(MAP_LAST_ZOOMLEVEL);
QVariant location = settings.value(MAP_LAST_POSITION);
- // init can be only done if we are able to convert variants into target data types
+
+ // also the init can be only done if we are able to convert variants into target data types
if (zoomLevel.canConvert<int>() && location.canConvert<GeoCoordinate>()) {
- qWarning() << __PRETTY_FUNCTION__ << "both settings can be converted";
m_zoomLevel = zoomLevel.toInt();
m_sceneCoordinate = SceneCoordinate(location.value<GeoCoordinate>());
}
}
+ // emit zoom level and center coordinate so that all parts of the map system gets initialized
+ // NOTE: emit is also done even if we weren't able to read initial valuef from the settings
+ // so that the default values set in the constructor are used
emit zoomLevelChanged(m_zoomLevel);
scrollToPosition(m_sceneCoordinate);
}