summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2018-10-08 13:51:57 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2018-10-11 16:25:32 -0700
commit754160d625d374cc2b98df53511371b0ab286c7a (patch)
tree1e9cc3363f9b7ec2598e714b34ad6f3cb3c364a0
parent66c5c5f72b82bd07c6222dbf624d6389237a590b (diff)
downloadsubsurface-754160d625d374cc2b98df53511371b0ab286c7a.tar.gz
Map: pass changed coordinates via signal
The coordinates of a "dragged flag" were passed out-of-bound via the global "displayed_dive_site" object and then a signal was sent to notify of the changed coordinates. Instead, pass the coordinates directly via the signal. This makes the data- and control-flow more clear. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
-rw-r--r--desktop-widgets/locationinformation.cpp4
-rw-r--r--desktop-widgets/locationinformation.h3
-rw-r--r--desktop-widgets/mapwidget.cpp7
-rw-r--r--desktop-widgets/mapwidget.h4
-rw-r--r--map-widget/qmlmapwidgethelper.cpp10
-rw-r--r--map-widget/qmlmapwidgethelper.h2
6 files changed, 14 insertions, 16 deletions
diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp
index 28a33ba2e..5fc1eb4d0 100644
--- a/desktop-widgets/locationinformation.cpp
+++ b/desktop-widgets/locationinformation.cpp
@@ -141,10 +141,10 @@ void LocationInformationWidget::clearLabels()
ui.locationTags->clear();
}
-void LocationInformationWidget::updateGpsCoordinates()
+void LocationInformationWidget::updateGpsCoordinates(degrees_t latitude, degrees_t longitude)
{
QString oldText = ui.diveSiteCoordinates->text();
- const char *coords = printGPSCoords(displayed_dive_site.latitude.udeg, displayed_dive_site.longitude.udeg);
+ const char *coords = printGPSCoords(latitude.udeg, longitude.udeg);
ui.diveSiteCoordinates->setText(coords);
enableLocationButtons(dive_site_has_gps_location(&displayed_dive_site));
free((void *)coords);
diff --git a/desktop-widgets/locationinformation.h b/desktop-widgets/locationinformation.h
index 66d52a490..0e425e217 100644
--- a/desktop-widgets/locationinformation.h
+++ b/desktop-widgets/locationinformation.h
@@ -2,6 +2,7 @@
#ifndef LOCATIONINFORMATION_H
#define LOCATIONINFORMATION_H
+#include "core/units.h"
#include "ui_locationInformation.h"
#include <stdint.h>
#include <QAbstractListModel>
@@ -20,7 +21,7 @@ protected:
public slots:
void acceptChanges();
void rejectChanges();
- void updateGpsCoordinates();
+ void updateGpsCoordinates(degrees_t latitude, degrees_t longitude);
void markChangedWidget(QWidget *w);
void enableEdition();
void resetState();
diff --git a/desktop-widgets/mapwidget.cpp b/desktop-widgets/mapwidget.cpp
index 2966401d2..4b626fcc8 100644
--- a/desktop-widgets/mapwidget.cpp
+++ b/desktop-widgets/mapwidget.cpp
@@ -46,8 +46,7 @@ void MapWidget::doneLoading(QQuickWidget::Status status)
m_mapHelper = rootObject()->findChild<MapWidgetHelper *>();
connect(m_mapHelper, SIGNAL(selectedDivesChanged(QList<int>)),
this, SLOT(selectedDivesChanged(QList<int>)));
- connect(m_mapHelper, SIGNAL(coordinatesChanged()),
- this, SLOT(coordinatesChangedLocal()));
+ connect(m_mapHelper, &MapWidgetHelper::coordinatesChanged, this, &MapWidget::coordinatesChangedLocal);
}
void MapWidget::centerOnSelectedDiveSite()
@@ -116,10 +115,10 @@ void MapWidget::selectedDivesChanged(QList<int> list)
skipReload = false;
}
-void MapWidget::coordinatesChangedLocal()
+void MapWidget::coordinatesChangedLocal(degrees_t latitude, degrees_t longitude)
{
CHECK_IS_READY_RETURN_VOID();
- emit coordinatesChanged();
+ emit coordinatesChanged(latitude, longitude);
}
void MapWidget::updateDiveSiteCoordinates(uint32_t uuid, degrees_t latitude, degrees_t longitude)
diff --git a/desktop-widgets/mapwidget.h b/desktop-widgets/mapwidget.h
index aa528c980..e85dd885b 100644
--- a/desktop-widgets/mapwidget.h
+++ b/desktop-widgets/mapwidget.h
@@ -25,7 +25,7 @@ public:
void reload();
signals:
- void coordinatesChanged();
+ void coordinatesChanged(degrees_t latitude, degrees_t longitude);
public slots:
void centerOnSelectedDiveSite();
@@ -35,7 +35,7 @@ public slots:
void repopulateLabels();
void prepareForGetDiveCoordinates();
void selectedDivesChanged(QList<int>);
- void coordinatesChangedLocal();
+ void coordinatesChangedLocal(degrees_t latitude, degrees_t longitude);
void doneLoading(QQuickWidget::Status status);
void updateDiveSiteCoordinates(uint32_t uuid, degrees_t latitude, degrees_t longitude);
diff --git a/map-widget/qmlmapwidgethelper.cpp b/map-widget/qmlmapwidgethelper.cpp
index f5be15ba6..b4ab8efd8 100644
--- a/map-widget/qmlmapwidgethelper.cpp
+++ b/map-widget/qmlmapwidgethelper.cpp
@@ -272,9 +272,8 @@ void MapWidgetHelper::updateCurrentDiveSiteCoordinatesFromMap(quint32 uuid, QGeo
MapLocation *loc = m_mapLocationModel->getMapLocationForUuid(uuid);
if (loc)
loc->setCoordinate(coord);
- displayed_dive_site.latitude.udeg = lrint(coord.latitude() * 1000000.0);
- displayed_dive_site.longitude.udeg = lrint(coord.longitude() * 1000000.0);
- emit coordinatesChanged();
+ emit coordinatesChanged(degrees_t { (int)lrint(coord.latitude() * 1000000.0) },
+ degrees_t { (int)lrint(coord.longitude() * 1000000.0) });
}
void MapWidgetHelper::updateDiveSiteCoordinates(uint32_t uuid, degrees_t latitude, degrees_t longitude)
@@ -305,9 +304,8 @@ void MapWidgetHelper::setEditMode(bool editMode)
} else {
coord = exists->coordinate();
}
- displayed_dive_site.latitude.udeg = lrint(coord.latitude() * 1000000.0);
- displayed_dive_site.longitude.udeg = lrint(coord.longitude() * 1000000.0);
- emit coordinatesChanged();
+ 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 77f352965..466e8944d 100644
--- a/map-widget/qmlmapwidgethelper.h
+++ b/map-widget/qmlmapwidgethelper.h
@@ -55,7 +55,7 @@ signals:
void modelChanged();
void editModeChanged();
void selectedDivesChanged(QList<int> list);
- void coordinatesChanged();
+ void coordinatesChanged(degrees_t latitude, degrees_t longitude);
void pluginObjectChanged();
};