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>
This commit is contained in:
Berthold Stoeger 2020-03-04 21:10:05 +01:00
parent c585fd9f8e
commit 0bd821183d
6 changed files with 83 additions and 20 deletions

View file

@ -82,6 +82,19 @@ private:
event *eventToRemove; // for redo
};
class AddGasSwitch : public EventBase {
public:
AddGasSwitch(struct dive *d, int dcNr, int seconds, int tank);
private:
bool workToBeDone() override;
void undoit() override;
void redoit() override;
std::vector<int> cylinders; // cylinders that are modified
std::vector<OwningEventPtr> eventsToAdd;
std::vector<event *> eventsToRemove;
};
} // namespace Command
#endif // COMMAND_EVENT_H