Undo: implement rudimentary support for undo of dive-merging

For this, an output-parameter was added to the backend merge_dives()
function. When non-zero, instead of adding the merged dive to
the preferred trip, the preferred trip is returned to the caller.

Since the new UndoObject, just like the delete-dives UndoObject,
needs to remove/readd a set of dives, the corresponding functionality
was split-off in a helper function.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2018-07-21 18:28:33 +02:00 committed by Dirk Hohndel
parent 302f6adb79
commit 014c04f8bd
7 changed files with 220 additions and 50 deletions

View file

@ -26,7 +26,7 @@
* struct dive *unregister_dive(int idx)
* void delete_single_dive(int idx)
* void add_single_dive(int idx, struct dive *dive)
* void merge_two_dives(struct dive *a, struct dive *b)
* struct dive *merge_two_dives(struct dive *a, struct dive *b)
* void select_dive(int idx)
* void deselect_dive(int idx)
* void mark_divelist_changed(int changed)
@ -1060,7 +1060,7 @@ struct dive *merge_two_dives(struct dive *a, struct dive *b)
if (i < 0 || j < 0)
// something is wrong with those dives. Bail
return NULL;
res = merge_dives(a, b, b->when - a->when, false);
res = merge_dives(a, b, b->when - a->when, false, NULL);
if (!res)
return NULL;