diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2018-10-08 15:43:06 +0200 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2018-10-11 16:25:32 -0700 |
commit | dd44dc4ab8fb888dcb3046ae5ecca2b24fe9e44f (patch) | |
tree | 7fcbb53d6d256308c7963fa3f825247c68f19018 /desktop-widgets/locationinformation.cpp | |
parent | 8091497745c385666e38a7911881189dbd0d73e0 (diff) | |
download | subsurface-dd44dc4ab8fb888dcb3046ae5ecca2b24fe9e44f.tar.gz |
Map: pass down dive site in prepareForGetDiveCoordinates()
Instead of reading out the global object "displayed_dive_site",
pass the dive site to be edited in arguments to
prepareForGetDiveCoordinates() and enter edit mode.
Simplify the code in LocationInformationWidget by not using
signals to call the prepareForGetDiveCoordinates() function.
While doing this, collect common code in accept() and reject()
in the already existing resetState() function.
This is another entry in a series of commits that makes
data-flow more clear by removing access to the global
"displayed_dive_site" object.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/locationinformation.cpp')
-rw-r--r-- | desktop-widgets/locationinformation.cpp | 22 |
1 files changed, 6 insertions, 16 deletions
diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp index 5fc1eb4d0..64c0574b9 100644 --- a/desktop-widgets/locationinformation.cpp +++ b/desktop-widgets/locationinformation.cpp @@ -49,14 +49,8 @@ LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBo ui.diveSiteListView->setModelColumn(LocationInformationModel::NAME); ui.diveSiteListView->installEventFilter(this); // Map Management Code. - connect(this, &LocationInformationWidget::requestCoordinates, - MapWidget::instance(), &MapWidget::prepareForGetDiveCoordinates); - connect(this, &LocationInformationWidget::endRequestCoordinates, - MapWidget::instance(), &MapWidget::endGetDiveCoordinates); connect(MapWidget::instance(), &MapWidget::coordinatesChanged, this, &LocationInformationWidget::updateGpsCoordinates); - connect(this, &LocationInformationWidget::endEditDiveSite, - MapWidget::instance(), &MapWidget::repopulateLabels); } bool LocationInformationWidget::eventFilter(QObject *object, QEvent *ev) @@ -213,19 +207,11 @@ void LocationInformationWidget::acceptChanges() copy_dive_site(currentDs, &displayed_dive_site); mark_divelist_changed(true); resetState(); - emit endRequestCoordinates(); - emit endEditDiveSite(); - emit stopFilterDiveSite(); - updateLocationOnMap(); } void LocationInformationWidget::rejectChanges() { resetState(); - emit endRequestCoordinates(); - emit stopFilterDiveSite(); - emit endEditDiveSite(); - updateLocationOnMap(); } void LocationInformationWidget::showEvent(QShowEvent *ev) @@ -240,8 +226,7 @@ void LocationInformationWidget::showEvent(QShowEvent *ev) } else { clearLabels(); } - emit requestCoordinates(); - + MapWidget::instance()->prepareForGetDiveCoordinates(displayed_dive_site.uuid); QGroupBox::showEvent(ev); } @@ -264,6 +249,11 @@ void LocationInformationWidget::resetState() MainWindow::instance()->dive_list()->setEnabled(true); MainWindow::instance()->setEnabledToolbar(true); ui.diveSiteMessage->setText(tr("Dive site management")); + MapWidget::instance()->endGetDiveCoordinates(); + MapWidget::instance()->repopulateLabels(); + emit stopFilterDiveSite(); + emit endEditDiveSite(); + updateLocationOnMap(); } void LocationInformationWidget::enableEdition() |