undo: store all cylinders in EditCylinderBase

We stored only one cylinder in EditCylinderBase, which is the
base class of RemoveCylinder and EditCylinder. This turns out
to be too crude: when removing the "same" cylinder from
multiple dives, there are some "hidden variables" such as
bestmix_o2 or manually_added, which might actually be different.
We don't want to overwrite those on undo of delete.
Moreover, the cylinder edit is way too crude at the moment,
as it overwrites the whole cylinder even when the user edited
only a single field. To enable a more refined edit, we have
to store each changed cylinder.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-03-27 09:22:11 +01:00
parent 5b65776e43
commit 4e8a838f74
2 changed files with 26 additions and 40 deletions

View file

@ -393,7 +393,7 @@ protected:
EditCylinderBase(int index, bool currentDiveOnly, bool nonProtectedOnly, int sameCylinderFlags);
~EditCylinderBase();
cylinder_t cyl;
std::vector<cylinder_t> cyl;
std::vector<int> indexes; // An index for each dive in the dives vector.
bool workToBeDone() override;
};
@ -409,9 +409,7 @@ private:
class EditCylinder : public EditCylinderBase {
public:
EditCylinder(int index, cylinder_t cyl, bool currentDiveOnly); // Clones cylinder
~EditCylinder();
private:
cylinder_t new_cyl;
void undo() override;
void redo() override;
};