summaryrefslogtreecommitdiffstats
path: root/commands/command_pictures.h
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-04-19 18:48:23 +0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2020-05-06 13:58:09 -0700
commit4374605c1295ede804d1ae1355094f8a3e0429e9 (patch)
treec1ab60086a08627a8b3d10f25aef14339e5bc792 /commands/command_pictures.h
parent6ae2d36e381b4f676eb9d8c0e06245989ef16383 (diff)
downloadsubsurface-4374605c1295ede804d1ae1355094f8a3e0429e9.tar.gz
undo: make adding of pictures undoable
This one is a bit hairy, because two things might happen if the picture has a geo location: - A dive gets a newly generated dive site set. - The dive site of a dive is edited. Therefore the undo command has to store keep track of that. Oh my. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'commands/command_pictures.h')
-rw-r--r--commands/command_pictures.h26
1 files changed, 26 insertions, 0 deletions
diff --git a/commands/command_pictures.h b/commands/command_pictures.h
index 802c63c6c..472a92565 100644
--- a/commands/command_pictures.h
+++ b/commands/command_pictures.h
@@ -35,5 +35,31 @@ private:
bool workToBeDone() override;
};
+class AddPictures final : public Base {
+public:
+ AddPictures(const std::vector<PictureListForAddition> &pictures);
+private:
+ struct DiveSiteEntry {
+ dive *d;
+ dive_site *ds;
+ };
+ struct DiveSiteEditEntry {
+ dive_site *ds;
+ location_t location;
+ };
+ std::vector<PictureListForAddition> picturesToAdd; // for redo
+ std::vector<OwningDiveSitePtr> sitesToAdd; //for redo
+ std::vector<PictureListForDeletion> picturesToRemove; // for undo
+ std::vector<dive_site *> sitesToRemove; // for undo
+ std::vector<DiveSiteEntry> sitesToSet; // for redo and undo
+ std::vector<DiveSiteEditEntry> sitesToEdit; // for redo and undo
+
+ void swapDiveSites();
+
+ void undo() override;
+ void redo() override;
+ bool workToBeDone() override;
+};
+
} // namespace Command
#endif