diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-11-03 15:04:48 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-12-05 10:14:25 -0800 |
commit | b3f530bfb9d099414d833e7b0eb8c71cb3780eca (patch) | |
tree | 879112df23e236e93e80cf4a726504fb7dccf09c /core/equipment.c | |
parent | b3253304a59b85c76f8a70f20ada4139e715a5b3 (diff) | |
download | subsurface-b3f530bfb9d099414d833e7b0eb8c71cb3780eca.tar.gz |
Undo: make weight-deletion an undoable action
This one is a bit more complicated than weight adding, because the
multiple-dive case is not well defined. If multiple dives are selected,
this implementation will search for weights that are identical to the
weight deleted in the currently shown dive. The position of the weight
in the list is ignored.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'core/equipment.c')
-rw-r--r-- | core/equipment.c | 16 |
1 files changed, 14 insertions, 2 deletions
diff --git a/core/equipment.c b/core/equipment.c index 39505a39d..bd1a0b4e3 100644 --- a/core/equipment.c +++ b/core/equipment.c @@ -111,12 +111,24 @@ void add_weightsystem_description(const weightsystem_t *weightsystem) } } +weightsystem_t clone_weightsystem(weightsystem_t ws) +{ + weightsystem_t res = { ws.weight, copy_string(ws.description) }; + return res; +} + /* Add a clone of a weightsystem to the end of a weightsystem table. * Cloned in means that the description-string is copied. */ void add_cloned_weightsystem(struct weightsystem_table *t, weightsystem_t ws) { - weightsystem_t w_clone = { ws.weight, copy_string(ws.description) }; - add_to_weightsystem_table(t, t->nr, w_clone); + add_to_weightsystem_table(t, t->nr, clone_weightsystem(ws)); +} + +/* Add a clone of a weightsystem to the end of a weightsystem table. + * Cloned in means that the description-string is copied. */ +void add_cloned_weightsystem_at(struct weightsystem_table *t, weightsystem_t ws) +{ + add_to_weightsystem_table(t, t->nr, clone_weightsystem(ws)); } /* Add a clone of a cylinder to the end of a cylinder table. |