diff options
-rw-r--r-- | desktop-widgets/mapwidget.cpp | 12 | ||||
-rw-r--r-- | desktop-widgets/mapwidget.h | 1 | ||||
-rw-r--r-- | map-widget/qmlmapwidgethelper.cpp | 31 | ||||
-rw-r--r-- | map-widget/qmlmapwidgethelper.h | 6 |
4 files changed, 21 insertions, 29 deletions
diff --git a/desktop-widgets/mapwidget.cpp b/desktop-widgets/mapwidget.cpp index 4b626fcc8..ca519b774 100644 --- a/desktop-widgets/mapwidget.cpp +++ b/desktop-widgets/mapwidget.cpp @@ -82,27 +82,21 @@ void MapWidget::repopulateLabels() void MapWidget::reload() { CHECK_IS_READY_RETURN_VOID(); - setEditMode(false); + m_mapHelper->exitEditMode(); if (!skipReload) m_mapHelper->reloadMapLocations(); } -void MapWidget::setEditMode(bool editMode) -{ - CHECK_IS_READY_RETURN_VOID(); - m_mapHelper->setEditMode(editMode); -} - void MapWidget::endGetDiveCoordinates() { CHECK_IS_READY_RETURN_VOID(); - setEditMode(false); + m_mapHelper->exitEditMode(); } void MapWidget::prepareForGetDiveCoordinates() { CHECK_IS_READY_RETURN_VOID(); - setEditMode(true); + m_mapHelper->enterEditMode(); } void MapWidget::selectedDivesChanged(QList<int> list) diff --git a/desktop-widgets/mapwidget.h b/desktop-widgets/mapwidget.h index e85dd885b..7ce8e7df8 100644 --- a/desktop-widgets/mapwidget.h +++ b/desktop-widgets/mapwidget.h @@ -40,7 +40,6 @@ public slots: void updateDiveSiteCoordinates(uint32_t uuid, degrees_t latitude, degrees_t longitude); private: - void setEditMode(bool editMode); static MapWidget *m_instance; QQuickItem *m_rootItem; MapWidgetHelper *m_mapHelper; diff --git a/map-widget/qmlmapwidgethelper.cpp b/map-widget/qmlmapwidgethelper.cpp index b4ab8efd8..b892cdcea 100644 --- a/map-widget/qmlmapwidgethelper.cpp +++ b/map-widget/qmlmapwidgethelper.cpp @@ -285,28 +285,27 @@ void MapWidgetHelper::updateDiveSiteCoordinates(uint32_t uuid, degrees_t latitud QMetaObject::invokeMethod(m_map, "centerOnCoordinate", Q_ARG(QVariant, QVariant::fromValue(coord))); } -bool MapWidgetHelper::editMode() +void MapWidgetHelper::exitEditMode() { - return m_editMode; + m_editMode = false; + emit editModeChanged(); } -void MapWidgetHelper::setEditMode(bool editMode) +void MapWidgetHelper::enterEditMode() { - m_editMode = editMode; + m_editMode = true; MapLocation *exists = m_mapLocationModel->getMapLocationForUuid(displayed_dive_site.uuid); - if (editMode) { - QGeoCoordinate coord; - // if divesite uuid doesn't exist in the model, add a new MapLocation. - if (!exists) { - coord = m_map->property("center").value<QGeoCoordinate>(); - m_mapLocationModel->add(new MapLocation(displayed_dive_site.uuid, coord, - QString(displayed_dive_site.name))); - } else { - coord = exists->coordinate(); - } - emit coordinatesChanged(degrees_t { (int)lrint(coord.latitude() * 1000000.0) }, - degrees_t { (int)lrint(coord.longitude() * 1000000.0) }); + QGeoCoordinate coord; + // if divesite uuid doesn't exist in the model, add a new MapLocation. + if (!exists) { + coord = m_map->property("center").value<QGeoCoordinate>(); + m_mapLocationModel->add(new MapLocation(displayed_dive_site.uuid, coord, + QString(displayed_dive_site.name))); + } else { + coord = exists->coordinate(); } + emit coordinatesChanged(degrees_t { (int)lrint(coord.latitude() * 1000000.0) }, + degrees_t { (int)lrint(coord.longitude() * 1000000.0) }); emit editModeChanged(); } diff --git a/map-widget/qmlmapwidgethelper.h b/map-widget/qmlmapwidgethelper.h index 466e8944d..132e15310 100644 --- a/map-widget/qmlmapwidgethelper.h +++ b/map-widget/qmlmapwidgethelper.h @@ -21,7 +21,7 @@ class MapWidgetHelper : public QObject { Q_OBJECT Q_PROPERTY(QObject *map MEMBER m_map) Q_PROPERTY(MapLocationModel *model MEMBER m_mapLocationModel NOTIFY modelChanged) - Q_PROPERTY(bool editMode READ editMode WRITE setEditMode NOTIFY editModeChanged) + Q_PROPERTY(bool editMode MEMBER m_editMode NOTIFY editModeChanged) Q_PROPERTY(QString pluginObject READ pluginObject NOTIFY pluginObjectChanged) public: @@ -37,8 +37,8 @@ public: Q_INVOKABLE void updateCurrentDiveSiteCoordinatesFromMap(quint32 uuid, QGeoCoordinate coord); Q_INVOKABLE void selectVisibleLocations(); void updateDiveSiteCoordinates(uint32_t uuid, degrees_t latitude, degrees_t longitude); - bool editMode(); - void setEditMode(bool editMode); + void enterEditMode(); + void exitEditMode(); QString pluginObject(); private: |