From 4374605c1295ede804d1ae1355094f8a3e0429e9 Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Sun, 19 Apr 2020 18:48:23 +0200 Subject: 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 --- commands/command_pictures.h | 26 ++++++++++++++++++++++++++ 1 file changed, 26 insertions(+) (limited to 'commands/command_pictures.h') 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 &pictures); +private: + struct DiveSiteEntry { + dive *d; + dive_site *ds; + }; + struct DiveSiteEditEntry { + dive_site *ds; + location_t location; + }; + std::vector picturesToAdd; // for redo + std::vector sitesToAdd; //for redo + std::vector picturesToRemove; // for undo + std::vector sitesToRemove; // for undo + std::vector sitesToSet; // for redo and undo + std::vector sitesToEdit; // for redo and undo + + void swapDiveSites(); + + void undo() override; + void redo() override; + bool workToBeDone() override; +}; + } // namespace Command #endif -- cgit v1.2.3-70-g09d2