aboutsummaryrefslogtreecommitdiffstats
path: root/desktop-widgets/locationinformation.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-03-14 08:26:50 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-04-12 18:19:07 +0300
commit021aa4bd5742c575e56f36fd057e11679aaa35a5 (patch)
treed1380c7813cf5856929d14ec4492e57bcddacae1 /desktop-widgets/locationinformation.cpp
parent4d183e0d75a3ae5b536abb6ea254ba224d713f72 (diff)
downloadsubsurface-021aa4bd5742c575e56f36fd057e11679aaa35a5.tar.gz
Undo: implement undo of dive site country editing
Simply copy the code of notes editing, but use the taxonomy_* functions to read and set the value. Moreover, replace the three TAXONOMY_n field ids by a single TAXONOMY id. We will probably never show one column per taxonomy field, but rather a single column with a string derived from all taxonomy fields. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/locationinformation.cpp')
-rw-r--r--desktop-widgets/locationinformation.cpp21
1 files changed, 6 insertions, 15 deletions
diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp
index f02b45bd0..19d2befd2 100644
--- a/desktop-widgets/locationinformation.cpp
+++ b/desktop-widgets/locationinformation.cpp
@@ -139,6 +139,9 @@ void LocationInformationWidget::diveSiteChanged(struct dive_site *ds, int field)
case LocationInformationModel::NOTES:
ui.diveSiteNotes->setText(diveSite->notes);
return;
+ case LocationInformationModel::TAXONOMY:
+ ui.diveSiteCountry->setText(taxonomy_get_country(&diveSite->taxonomy));
+ return;
default:
return;
}
@@ -183,18 +186,6 @@ void LocationInformationWidget::acceptChanges()
return;
}
- char *uiString;
- uiString = copy_qstring(ui.diveSiteCountry->text());
- // if the user entered a different country, first update the local taxonomy
- // this below will get copied into the diveSite
- if (!same_string(uiString, taxonomy_get_country(&taxonomy)) &&
- !empty_string(uiString))
- taxonomy_set_country(&taxonomy, uiString, taxonomy_origin::GEOMANUAL);
- else
- free(uiString);
- // now update the diveSite
- copy_taxonomy(&taxonomy, &diveSite->taxonomy);
-
if (!ui.diveSiteCoordinates->text().isEmpty())
parseGpsText(ui.diveSiteCoordinates->text(), diveSite->location);
mark_divelist_changed(true);
@@ -277,10 +268,10 @@ void LocationInformationWidget::on_diveSiteCoordinates_textChanged(const QString
}
}
-void LocationInformationWidget::on_diveSiteCountry_textChanged(const QString& text)
+void LocationInformationWidget::on_diveSiteCountry_editingFinished()
{
- if (!same_string(qPrintable(text), taxonomy_get_country(&taxonomy)))
- markChangedWidget(ui.diveSiteCountry);
+ if (diveSite)
+ Command::editDiveSiteCountry(diveSite, ui.diveSiteCountry->text());
}
void LocationInformationWidget::on_diveSiteDescription_editingFinished()