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>
This commit is contained in:
Berthold Stoeger 2020-04-19 18:48:23 +02:00 committed by Dirk Hohndel
parent 6ae2d36e38
commit 4374605c12
7 changed files with 129 additions and 22 deletions

View file

@ -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