mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: convert taxonomy.c to C++
Since the taxonomy is now a real C++ struct with constructor and destructor, dive_site has to be converted to C++ as well. A bit hairy for now, but will ultimately be distinctly simpler. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
5f36c8ccde
commit
8797aa499a
39 changed files with 259 additions and 336 deletions
|
@ -67,7 +67,7 @@ void DivesiteImportDialog::on_ok_clicked()
|
|||
struct dive_site_table selectedSites = empty_dive_site_table;
|
||||
for (int i = 0; i < importedSites.nr; i++)
|
||||
if (divesiteImportedModel->data(divesiteImportedModel->index(i, 0), Qt::CheckStateRole) == Qt::Checked) {
|
||||
struct dive_site *newSite = alloc_dive_site();
|
||||
struct dive_site *newSite = new dive_site;
|
||||
copy_dive_site(importedSites.dive_sites[i], newSite);
|
||||
add_dive_site_to_table(newSite, &selectedSites);
|
||||
}
|
||||
|
|
|
@ -133,9 +133,9 @@ void LocationInformationWidget::updateLabels()
|
|||
ui.diveSiteName->setText(diveSite->name);
|
||||
else
|
||||
ui.diveSiteName->clear();
|
||||
const char *country = taxonomy_get_country(&diveSite->taxonomy);
|
||||
if (country)
|
||||
ui.diveSiteCountry->setText(country);
|
||||
std::string country = taxonomy_get_country(diveSite->taxonomy);
|
||||
if (!country.empty())
|
||||
ui.diveSiteCountry->setText(QString::fromStdString(country));
|
||||
else
|
||||
ui.diveSiteCountry->clear();
|
||||
if (diveSite->description)
|
||||
|
@ -152,7 +152,7 @@ void LocationInformationWidget::updateLabels()
|
|||
ui.diveSiteCoordinates->clear();
|
||||
coordinatesSetWarning(false);
|
||||
|
||||
ui.locationTags->setText(constructLocationTags(&diveSite->taxonomy, false));
|
||||
ui.locationTags->setText(constructLocationTags(diveSite->taxonomy, false));
|
||||
}
|
||||
|
||||
void LocationInformationWidget::unitsChanged()
|
||||
|
@ -181,8 +181,8 @@ void LocationInformationWidget::diveSiteChanged(struct dive_site *ds, int field)
|
|||
ui.diveSiteNotes->setText(diveSite->notes);
|
||||
return;
|
||||
case LocationInformationModel::TAXONOMY:
|
||||
ui.diveSiteCountry->setText(taxonomy_get_country(&diveSite->taxonomy));
|
||||
ui.locationTags->setText(constructLocationTags(&diveSite->taxonomy, false));
|
||||
ui.diveSiteCountry->setText(QString::fromStdString(taxonomy_get_country(diveSite->taxonomy)));
|
||||
ui.locationTags->setText(constructLocationTags(diveSite->taxonomy, false));
|
||||
return;
|
||||
case LocationInformationModel::LOCATION:
|
||||
filter_model.setCoordinates(diveSite->location);
|
||||
|
@ -342,10 +342,8 @@ void LocationInformationWidget::reverseGeocode()
|
|||
if (!ds || !has_location(&location))
|
||||
return;
|
||||
taxonomy_data taxonomy = reverseGeoLookup(location.lat, location.lon);
|
||||
if (ds != diveSite) {
|
||||
free_taxonomy(&taxonomy);
|
||||
if (ds != diveSite)
|
||||
return;
|
||||
}
|
||||
// This call transfers ownership of the taxonomy memory into an EditDiveSiteTaxonomy object
|
||||
Command::editDiveSiteTaxonomy(ds, taxonomy);
|
||||
}
|
||||
|
|
|
@ -468,12 +468,12 @@ void LocationFilterDelegate::paint(QPainter *painter, const QStyleOptionViewItem
|
|||
for (int i = 0; i < 3; i++) {
|
||||
if (prefs.geocoding.category[i] == TC_NONE)
|
||||
continue;
|
||||
const char *value = taxonomy_get_value(&ds->taxonomy, prefs.geocoding.category[i]);
|
||||
if (empty_string(value))
|
||||
std::string value = taxonomy_get_value(ds->taxonomy, prefs.geocoding.category[i]);
|
||||
if (!value.empty())
|
||||
continue;
|
||||
if(!bottomText.isEmpty())
|
||||
bottomText += " / ";
|
||||
bottomText += QString(value);
|
||||
bottomText += QString::fromStdString(value);
|
||||
}
|
||||
|
||||
if (bottomText.isEmpty())
|
||||
|
|
|
@ -178,7 +178,7 @@ void TabDiveNotes::updateDiveSite(struct dive *d)
|
|||
struct dive_site *ds = d->dive_site;
|
||||
ui.location->setCurrentDiveSite(d);
|
||||
if (ds) {
|
||||
ui.locationTags->setText(constructLocationTags(&ds->taxonomy, true));
|
||||
ui.locationTags->setText(constructLocationTags(ds->taxonomy, true));
|
||||
|
||||
if (ui.locationTags->text().isEmpty() && has_location(&ds->location))
|
||||
ui.locationTags->setText(printGPSCoords(&ds->location));
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue