core: move merge_dives() functios to struct dive_table

These functions have to access other dives in the list to
calculate CNS, etc, so let's call them from there.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2024-06-24 20:47:02 +02:00 committed by bstoeger
parent 8ec1f008ab
commit 4d7291d4a1
6 changed files with 178 additions and 163 deletions

View file

@ -921,7 +921,7 @@ MergeDives::MergeDives(const QVector <dive *> &dives)
return;
}
auto [d, trip, site] = merge_dives(*dives[0], *dives[1], dives[1]->when - dives[0]->when, false);
auto [d, trip, site] = divelog.dives.merge_dives(*dives[0], *dives[1], dives[1]->when - dives[0]->when, false);
// Currently, the core code selects the dive -> this is not what we want, as
// we manually manage the selection post-command.
@ -931,7 +931,7 @@ MergeDives::MergeDives(const QVector <dive *> &dives)
// Set the preferred dive trip, so that for subsequent merges the better trip can be selected
d->divetrip = trip;
for (int i = 2; i < dives.count(); ++i) {
auto [d2, trip, site] = merge_dives(*d, *dives[i], dives[i]->when - d->when, false);
auto [d2, trip, site] = divelog.dives.merge_dives(*d, *dives[i], dives[i]->when - d->when, false);
d = std::move(d2);
// Set the preferred dive trip and site, so that for subsequent merges the better trip and site can be selected
d->divetrip = trip;