undo: implement ApplyGPSFixes undo command

This gets a list of dives with GPS fixes and
1) Adds new dive sites if the dive hasn't a dive site set
2) Edits the location of the dive site

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2019-11-16 21:35:26 +01:00 committed by Dirk Hohndel
parent 89047b3541
commit 93bdaa9bb5
4 changed files with 81 additions and 1 deletions

View file

@ -5,6 +5,7 @@
#define COMMAND_DIVESITE_H
#include "command_base.h"
#include "core/gpslocation.h"
#include <QVector>
@ -110,7 +111,6 @@ private:
QString value; // Value to be set
};
class EditDiveSiteCountry : public Base {
public:
EditDiveSiteCountry(dive_site *ds, const QString &country);
@ -165,6 +165,30 @@ private:
std::vector<OwningDiveSitePtr> sitesToAdd;
};
class ApplyGPSFixes : public Base {
public:
// Note: the dive site table is consumed after the call it will be empty.
ApplyGPSFixes(const std::vector<DiveAndLocation> &fixes);
private:
bool workToBeDone() override;
void undo() override;
void redo() override;
// For undo
std::vector<dive_site *> sitesToRemove;
// For redo
std::vector<OwningDiveSitePtr> sitesToAdd;
// For redo and undo
struct SiteAndLocation {
dive_site *ds;
location_t location;
};
std::vector<SiteAndLocation> siteLocations;
void editDiveSites();
};
} // namespace Command
#endif // COMMAND_DIVESITE_H