core: include divesite table directly in divelog

Having this as a pointer is an artifact from the C/C++ split.
The divesitetable header is small enough so that we can
include it directly.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-06-08 16:30:24 +02:00 committed by bstoeger
parent 7792f54a73
commit 5af9d28291
29 changed files with 90 additions and 91 deletions

View file

@ -30,7 +30,7 @@ static std::vector<dive_site *> addDiveSites(std::vector<std::unique_ptr<dive_si
}
// Add dive site to core, but remember a non-owning pointer first.
auto add_res = divelog.sites->put(std::move(ds)); // Return ownership to backend.
auto add_res = divelog.sites.put(std::move(ds)); // Return ownership to backend.
res.push_back(add_res.ptr);
emit diveListNotifier.diveSiteAdded(res.back(), add_res.idx); // Inform frontend of new dive site.
}
@ -60,7 +60,7 @@ static std::vector<std::unique_ptr<dive_site>> removeDiveSites(std::vector<dive_
}
// Remove dive site from core and take ownership.
auto pull_res = divelog.sites->pull(ds);
auto pull_res = divelog.sites.pull(ds);
res.push_back(std::move(pull_res.ptr));
emit diveListNotifier.diveSiteDeleted(ds, pull_res.idx); // Inform frontend of removed dive site.
}
@ -101,7 +101,7 @@ ImportDiveSites::ImportDiveSites(dive_site_table sites, const QString &source)
for (auto &new_ds: sites) {
// Don't import dive sites that already exist.
// We might want to be smarter here and merge dive site data, etc.
if (divelog.sites->get_same(*new_ds))
if (divelog.sites.get_same(*new_ds))
continue;
sitesToAdd.push_back(std::move(new_ds));
}
@ -145,7 +145,7 @@ void DeleteDiveSites::undo()
PurgeUnusedDiveSites::PurgeUnusedDiveSites()
{
setText(Command::Base::tr("purge unused dive sites"));
for (const auto &ds: *divelog.sites) {
for (const auto &ds: divelog.sites) {
if (ds->dives.empty())
sitesToRemove.push_back(ds.get());
}
@ -382,7 +382,7 @@ ApplyGPSFixes::ApplyGPSFixes(const std::vector<DiveAndLocation> &fixes)
siteLocations.push_back({ ds, dl.location });
}
} else {
ds = divelog.sites->create(dl.name.toStdString());
ds = divelog.sites.create(dl.name.toStdString());
ds->location = dl.location;
ds->add_dive(dl.d);
dl.d->dive_site = nullptr; // This will be set on redo()