summaryrefslogtreecommitdiffstats
path: root/profile-widget
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-03-04 21:10:05 +0100
committerGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-04-07 00:13:35 +0200
commit0bd821183d715f709d378e8ac1a75aa0c3d0f2cc (patch)
treee6d182e6922d7c06bf09b17c9c953f8b5dc78e85 /profile-widget
parentc585fd9f8ee0c1f27f997b4e19984b50d150f6cb (diff)
downloadsubsurface-0bd821183d715f709d378e8ac1a75aa0c3d0f2cc.tar.gz
undo: implement gas switch
This is a bit hairy as - in theory - one gas switch can remove other gas switch(es) at the same timestamp. However, I did not find a way to test it. Moreover, it is not clear whether the dive-tabs are properly updated on undo/redo. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'profile-widget')
-rw-r--r--profile-widget/profilewidget2.cpp21
1 files changed, 1 insertions, 20 deletions
diff --git a/profile-widget/profilewidget2.cpp b/profile-widget/profilewidget2.cpp
index f236ed550..6072d4c0d 100644
--- a/profile-widget/profilewidget2.cpp
+++ b/profile-widget/profilewidget2.cpp
@@ -1645,26 +1645,7 @@ void ProfileWidget2::changeGas(int tank, int seconds)
if (!current_dive || tank < 0 || tank >= current_dive->cylinders.nr)
return;
- // if there is a gas change at this time stamp, remove it before adding the new one
- struct event *gasChangeEvent = current_dc->events;
- while ((gasChangeEvent = get_next_event_mutable(gasChangeEvent, "gaschange")) != NULL) {
- if (gasChangeEvent->time.seconds == seconds) {
- remove_event(gasChangeEvent);
- gasChangeEvent = current_dc->events;
- } else {
- gasChangeEvent = gasChangeEvent->next;
- }
- }
- add_gas_switch_event(current_dive, current_dc, seconds, tank);
- // this means we potentially have a new tank that is being used and needs to be shown
- fixup_dive(current_dive);
- invalidate_dive_cache(current_dive);
-
- // FIXME - this no longer gets written to the dive list - so we need to enableEdition() here
-
- emit updateDiveInfo();
- mark_divelist_changed(true);
- replot();
+ Command::addGasSwitch(current_dive, dc_number, seconds, tank);
}
#endif