mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
core: move clone_delete_divecomputer() to struct dive_table
Since this calls force_fixup_dive() it needs access to other dives in the dive_table. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
parent
576d3a3bc6
commit
79bf79ad7f
5 changed files with 25 additions and 26 deletions
|
|
@ -1219,3 +1219,25 @@ struct std::unique_ptr<dive> dive_table::try_to_merge(const struct dive &a, cons
|
|||
res->dive_site = site; /* Caller has to call site->add_dive()! */
|
||||
return std::move(res);
|
||||
}
|
||||
|
||||
/* Clone a dive and delete given dive computer */
|
||||
std::unique_ptr<dive> dive_table::clone_delete_divecomputer(const struct dive &d, int dc_number)
|
||||
{
|
||||
/* copy the dive */
|
||||
auto res = std::make_unique<dive>(d);
|
||||
|
||||
/* make a new unique id, since we still can't handle two equal ids */
|
||||
res->id = dive_getUniqID();
|
||||
|
||||
if (res->dcs.size() <= 1)
|
||||
return res;
|
||||
|
||||
if (dc_number < 0 || static_cast<size_t>(dc_number) >= res->dcs.size())
|
||||
return res;
|
||||
|
||||
res->dcs.erase(res->dcs.begin() + dc_number);
|
||||
|
||||
force_fixup_dive(*res);
|
||||
|
||||
return res;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue