Undo: make "delete dive computer" undoable

Simply reuse the code for "move dive computer" by creating
a DiveComputerBase base class.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-05-19 14:27:10 +02:00 committed by Dirk Hohndel
parent eba6e76b96
commit 0bc96905bf
7 changed files with 60 additions and 25 deletions

View file

@ -4234,10 +4234,22 @@ static void delete_divecomputer(struct dive *d, int num)
invalidate_dive_cache(d);
}
/* always acts on the current dive */
void delete_current_divecomputer(void)
/* Clone a dive and delete goven dive computer */
struct dive *clone_delete_divecomputer(const struct dive *d, int dc_number)
{
delete_divecomputer(current_dive, dc_number);
struct dive *res;
/* copy the dive */
res = alloc_dive();
copy_dive(d, res);
/* make a new unique id, since we still can't handle two equal ids */
res->id = dive_getUniqID();
invalidate_dive_cache(res);
delete_divecomputer(res, dc_number);
return res;
}
/*