summaryrefslogtreecommitdiffstats
path: root/desktop-widgets
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2017-10-02 23:03:44 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2017-10-04 08:05:09 -0700
commit21d78121ade941adf9eaad399e6b8146298b421f (patch)
tree56cc4109f116d7b667163e960fcc7936fdf4c6aa /desktop-widgets
parentde10fd4021f7fa7e203782df29456c09e07165e8 (diff)
downloadsubsurface-21d78121ade941adf9eaad399e6b8146298b421f.tar.gz
Don't add separate country field, use taxonomy
The more I looked at the code that added the country to the dive site, the more it seemed redundant given what we have with the taxonomy. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'desktop-widgets')
-rw-r--r--desktop-widgets/locationinformation.cpp21
1 files changed, 13 insertions, 8 deletions
diff --git a/desktop-widgets/locationinformation.cpp b/desktop-widgets/locationinformation.cpp
index 3c347b774..065f249f1 100644
--- a/desktop-widgets/locationinformation.cpp
+++ b/desktop-widgets/locationinformation.cpp
@@ -93,8 +93,9 @@ void LocationInformationWidget::updateLabels()
ui.diveSiteName->setText(displayed_dive_site.name);
else
ui.diveSiteName->clear();
- if (displayed_dive_site.country)
- ui.diveSiteCountry->setText(displayed_dive_site.country);
+ const char *country = taxonomy_get_country(&displayed_dive_site.taxonomy);
+ if (country)
+ ui.diveSiteCountry->setText(country);
else
ui.diveSiteCountry->clear();
if (displayed_dive_site.description)
@@ -151,11 +152,15 @@ void LocationInformationWidget::acceptChanges()
free(currentDs->description);
currentDs->description = copy_string(uiString);
}
- uiString = ui.diveSiteCountry->text().toUtf8().data();
- if (!same_string(uiString, currentDs->country)) {
- free(currentDs->country);
- currentDs->country = copy_string(uiString);
- }
+ uiString = copy_string(ui.diveSiteCountry->text().toUtf8().data());
+ // if the user entered a different contriy, first update the taxonomy
+ // for the displayed dive site; this below will get copied into the currentDs
+ if (!same_string(uiString, taxonomy_get_country(&displayed_dive_site.taxonomy)) &&
+ !same_string(uiString, ""))
+ taxonomy_set_country(&displayed_dive_site.taxonomy, copy_string(uiString), taxonomy_origin::GEOMANUAL);
+ // now update the currentDs (which we then later copy back ontop of displayed_dive_site
+ copy_dive_site_taxonomy(&displayed_dive_site, currentDs);
+
uiString = ui.diveSiteNotes->document()->toPlainText().toUtf8().data();
if (!same_string(uiString, currentDs->notes)) {
free(currentDs->notes);
@@ -254,7 +259,7 @@ void LocationInformationWidget::on_diveSiteCoordinates_textChanged(const QString
void LocationInformationWidget::on_diveSiteCountry_textChanged(const QString& text)
{
- if (!same_string(qPrintable(text), displayed_dive_site.country))
+ if (!same_string(qPrintable(text), taxonomy_get_country(&displayed_dive_site.taxonomy)))
markChangedWidget(ui.diveSiteCountry);
}