mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
b5d4d88fe5
commit
7c63956ee4
6 changed files with 57 additions and 9 deletions
|
@ -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*)
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue