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>
This commit is contained in:
Dirk Hohndel 2017-10-02 23:03:44 -07:00
parent de10fd4021
commit 21d78121ad
8 changed files with 21 additions and 24 deletions

View file

@ -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);
}