From 21d78121ade941adf9eaad399e6b8146298b421f Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Mon, 2 Oct 2017 23:03:44 -0700 Subject: 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 --- desktop-widgets/locationinformation.cpp | 21 +++++++++++++-------- 1 file changed, 13 insertions(+), 8 deletions(-) (limited to 'desktop-widgets/locationinformation.cpp') 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); } -- cgit v1.2.3-70-g09d2