summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/locationinformation.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-03-15 14:32:55 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-12 18:19:07 +0300
commit7c63956ee4798a835794eee8189b73e3df07594d (patch)
tree720106a3a5927e140733be5571fb8ff1fc4ca4ae /desktop-widgets/locationinformation.cpp
parentb5d4d88fe596fa91a3f3491fe8acc220a0df7b72 (diff)
downloadsubsurface-7c63956ee4798a835794eee8189b73e3df07594d.tar.gz
Undo: implement undo of geo lookup
Simply copy code of the other edit dive site functions. Here though introduce a destructor in the undo command to free the taxonomy data. Remove the taxonomy member of the LocationInformationWidget class, because it is not needed anymore. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/locationinformation.cpp')
-rw-r--r--desktop-widgets/locationinformation.cpp14
1 files changed, 7 insertions, 7 deletions
diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp
index 39bd6678f..244e85f8d 100644
--- a/desktop-widgets/locationinformation.cpp
+++ b/desktop-widgets/locationinformation.cpp
@@ -10,6 +10,7 @@
#include "desktop-widgets/modeldelegates.h"
#include "core/subsurface-qt/DiveListNotifier.h"
#include "command.h"
+#include "core/taxonomy.h"
#include <QDebug>
#include <QShowEvent>
@@ -21,7 +22,6 @@
LocationInformationWidget::LocationInformationWidget(QWidget *parent) : QGroupBox(parent), diveSite(nullptr)
{
- memset(&taxonomy, 0, sizeof(taxonomy));
ui.setupUi(this);
ui.diveSiteMessage->setCloseButtonVisible(false);
@@ -92,7 +92,7 @@ void LocationInformationWidget::updateLabels()
ui.diveSiteName->setText(diveSite->name);
else
ui.diveSiteName->clear();
- const char *country = taxonomy_get_country(&taxonomy);
+ const char *country = taxonomy_get_country(&diveSite->taxonomy);
if (country)
ui.diveSiteCountry->setText(country);
else
@@ -110,7 +110,7 @@ void LocationInformationWidget::updateLabels()
else
ui.diveSiteCoordinates->clear();
- ui.locationTags->setText(constructLocationTags(&taxonomy, false));
+ ui.locationTags->setText(constructLocationTags(&diveSite->taxonomy, false));
}
void LocationInformationWidget::diveSiteChanged(struct dive_site *ds, int field)
@@ -129,6 +129,7 @@ void LocationInformationWidget::diveSiteChanged(struct dive_site *ds, int field)
return;
case LocationInformationModel::TAXONOMY:
ui.diveSiteCountry->setText(taxonomy_get_country(&diveSite->taxonomy));
+ ui.locationTags->setText(constructLocationTags(&diveSite->taxonomy, false));
return;
case LocationInformationModel::LOCATION:
filter_model.setCoordinates(diveSite->location);
@@ -178,7 +179,6 @@ void LocationInformationWidget::initFields(dive_site *ds)
{
diveSite = ds;
if (ds) {
- copy_taxonomy(&ds->taxonomy, &taxonomy);
filter_model.set(ds, ds->location);
updateLabels();
enableLocationButtons(dive_site_has_gps_location(ds));
@@ -187,7 +187,6 @@ void LocationInformationWidget::initFields(dive_site *ds)
if (m)
m->invalidate();
} else {
- free_taxonomy(&taxonomy);
filter_model.set(0, location_t { degrees_t{ 0 }, degrees_t{ 0 } });
clearLabels();
}
@@ -228,10 +227,11 @@ void LocationInformationWidget::on_diveSiteNotes_editingFinished()
void LocationInformationWidget::reverseGeocode()
{
location_t location = parseGpsText(ui.diveSiteCoordinates->text());
- if (!has_location(&location))
+ if (!diveSite || !has_location(&location))
return;
+ taxonomy_data taxonomy = { 0 };
reverseGeoLookup(location.lat, location.lon, &taxonomy);
- ui.locationTags->setText(constructLocationTags(&taxonomy, false));
+ Command::editDiveSiteTaxonomy(diveSite, taxonomy);
}
DiveLocationFilterProxyModel::DiveLocationFilterProxyModel(QObject*)