diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-03-14 22:07:48 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-04-12 18:19:07 +0300 |
commit | fa4fedbb488eacff72d5d8691b4da8b34634a71e (patch) | |
tree | 8a751c99f2731832cdf71db420d55ed95f913bad /desktop-widgets/locationinformation.cpp | |
parent | 1deded787405f10af65c4dfe7c19b5e4a5ea3cdc (diff) | |
download | subsurface-fa4fedbb488eacff72d5d8691b4da8b34634a71e.tar.gz |
Undo: implement undo of dive site location editing
Simply copy the code of note editing. It's a bit more complex,
since we have to parse the Gps coordinates. For consitency,
rename the COORD field to LOCATION (the field in the dive_site
struct is called LOCATION).
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/locationinformation.cpp')
-rw-r--r-- | desktop-widgets/locationinformation.cpp | 32 |
1 files changed, 11 insertions, 21 deletions
diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp index 19d2befd2..17e9d488e 100644 --- a/desktop-widgets/locationinformation.cpp +++ b/desktop-widgets/locationinformation.cpp @@ -142,6 +142,15 @@ void LocationInformationWidget::diveSiteChanged(struct dive_site *ds, int field) case LocationInformationModel::TAXONOMY: ui.diveSiteCountry->setText(taxonomy_get_country(&diveSite->taxonomy)); return; + case LocationInformationModel::LOCATION: + filter_model.setCoordinates(diveSite->location); + if (has_location(&diveSite->location)) { + enableLocationButtons(true); + ui.diveSiteCoordinates->setText(printGPSCoords(&diveSite->location)); + } else { + enableLocationButtons(false); + ui.diveSiteCoordinates->clear(); + } default: return; } @@ -181,14 +190,6 @@ bool parseGpsText(const QString &text, location_t &location) void LocationInformationWidget::acceptChanges() { - if (!diveSite) { - qWarning() << "did not have valid dive site in LocationInformationWidget"; - return; - } - - if (!ui.diveSiteCoordinates->text().isEmpty()) - parseGpsText(ui.diveSiteCoordinates->text(), diveSite->location); - mark_divelist_changed(true); resetState(); } @@ -250,22 +251,11 @@ void LocationInformationWidget::enableEdition() ui.diveSiteMessage->setText(tr("You are editing a dive site")); } -void LocationInformationWidget::on_diveSiteCoordinates_textChanged(const QString &text) +void LocationInformationWidget::on_diveSiteCoordinates_editingFinished() { if (!diveSite) return; - location_t location; - bool ok_old = has_location(&diveSite->location); - bool ok = parseGpsText(text, location); - if (ok != ok_old || !same_location(&location, &diveSite->location)) { - if (ok) { - markChangedWidget(ui.diveSiteCoordinates); - enableLocationButtons(true); - filter_model.setCoordinates(location); - } else { - enableLocationButtons(false); - } - } + Command::editDiveSiteLocation(diveSite, ui.diveSiteCoordinates->text()); } void LocationInformationWidget::on_diveSiteCountry_editingFinished() |