diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-08-30 22:19:23 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-09-06 11:48:47 -0700 |
commit | f818ac3352b5a66d6fcc452ddc5ebb84a18bb29a (patch) | |
tree | 4f2af3624ea3854e7f876e2bcb506943d0a19453 /map-widget | |
parent | a921acb3ce30ef5cbc4ea8093fcc0bdae13fb109 (diff) | |
download | subsurface-f818ac3352b5a66d6fcc452ddc5ebb84a18bb29a.tar.gz |
Map: replace enterEditMode()/exitEditMode() by updateEditMode()
There weree two functions in MapWidgetHelper: one to enter and
one to exit edit mode. Both functions set the flag and emitted
a signal if the flag had changed.
Since the edit mode only depends on a flag of the filter this
can be simplified to a simple function that updates the flag
and raises the signal if the flag changed.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'map-widget')
-rw-r--r-- | map-widget/qmlmapwidgethelper.cpp | 32 | ||||
-rw-r--r-- | map-widget/qmlmapwidgethelper.h | 3 |
2 files changed, 11 insertions, 24 deletions
diff --git a/map-widget/qmlmapwidgethelper.cpp b/map-widget/qmlmapwidgethelper.cpp index 96db063ae..b49ec248d 100644 --- a/map-widget/qmlmapwidgethelper.cpp +++ b/map-widget/qmlmapwidgethelper.cpp @@ -96,16 +96,21 @@ void MapWidgetHelper::centerOnSelectedDiveSite() } } -void MapWidgetHelper::reloadMapLocations() +void MapWidgetHelper::updateEditMode() { #ifndef SUBSURFACE_MOBILE // The filter being set to dive site is the signal that we are in dive site edit mode. // This is the case when either the dive site edit tab or the dive site list tab are active. - if (MultiFilterSortModel::instance()->diveSiteMode()) - enterEditMode(); - else - exitEditMode(); + bool old = m_editMode; + m_editMode = MultiFilterSortModel::instance()->diveSiteMode(); + if (old != m_editMode) + emit editModeChanged(); #endif +} + +void MapWidgetHelper::reloadMapLocations() +{ + updateEditMode(); m_mapLocationModel->reload(m_map); } @@ -225,23 +230,6 @@ void MapWidgetHelper::diveSiteChanged(struct dive_site *ds, int field) centerOnDiveSite(ds); } -void MapWidgetHelper::exitEditMode() -{ - if (!m_editMode) - return; - m_editMode = false; - emit editModeChanged(); -} - -void MapWidgetHelper::enterEditMode() -{ - if (m_editMode) - return; - - m_editMode = true; - emit editModeChanged(); -} - QString MapWidgetHelper::pluginObject() { QString lang = uiLanguage(NULL).replace('_', '-'); diff --git a/map-widget/qmlmapwidgethelper.h b/map-widget/qmlmapwidgethelper.h index 86d9a8ff5..4079b6aa0 100644 --- a/map-widget/qmlmapwidgethelper.h +++ b/map-widget/qmlmapwidgethelper.h @@ -38,8 +38,7 @@ public: QString pluginObject(); private: - void enterEditMode(); - void exitEditMode(); + void updateEditMode(); QObject *m_map; MapLocationModel *m_mapLocationModel; qreal m_smallCircleRadius; |