summaryrefslogtreecommitdiffstats
path: root/commands/command_edit.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-11-08 22:47:38 +0100
committerGravatar Dirk Hohndel <dirk@hohndel.org>2019-12-05 10:14:25 -0800
commit72c6b838662f1fb79a806ac2264c7215efa0aa67 (patch)
tree8b10fe7ad548a62ed428347c8a35882ee291b41a /commands/command_edit.h
parent029c9ccf020fdb73c148da489e0e7b1acd3ca149 (diff)
downloadsubsurface-72c6b838662f1fb79a806ac2264c7215efa0aa67.tar.gz
Undo: make weight editing undoable
Implement the EditWeight undo command. Since there is common code (storage of the old weight), this creates a common base class for RemoveWeight and EditWeight. The model calls directly into the undo command, which is somewhat unfortunate as it feels like a layering violation. It's the easy thing to do for now. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'commands/command_edit.h')
-rw-r--r--commands/command_edit.h26
1 files changed, 21 insertions, 5 deletions
diff --git a/commands/command_edit.h b/commands/command_edit.h
index c23f06094..76b538b4d 100644
--- a/commands/command_edit.h
+++ b/commands/command_edit.h
@@ -339,16 +339,32 @@ private:
bool workToBeDone() override;
};
-class RemoveWeight : public EditDivesBase {
+class EditWeightBase : public EditDivesBase {
+protected:
+ EditWeightBase(int index, bool currentDiveOnly);
+ ~EditWeightBase();
+
+ weightsystem_t ws;
+ std::vector<int> indexes; // An index for each dive in the dives vector.
+ bool workToBeDone() override;
+};
+
+class RemoveWeight : public EditWeightBase {
public:
RemoveWeight(int index, bool currentDiveOnly);
- ~RemoveWeight();
private:
- weightsystem_t ws;
- std::vector<int> indexes; // An index for each dive in the dives vector.
void undo() override;
void redo() override;
- bool workToBeDone() override;
+};
+
+class EditWeight : public EditWeightBase {
+public:
+ EditWeight(int index, weightsystem_t ws, bool currentDiveOnly); // Clones ws
+ ~EditWeight();
+private:
+ weightsystem_t new_ws;
+ void undo() override;
+ void redo() override;
};
} // namespace Command