2019-03-12 21:35:43 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
// Note: this header file is used by the undo-machinery and should not be included elsewhere.
|
|
|
|
|
|
|
|
#ifndef COMMAND_DIVESITE_H
|
|
|
|
#define COMMAND_DIVESITE_H
|
|
|
|
|
|
|
|
#include "command_base.h"
|
|
|
|
|
|
|
|
#include <QVector>
|
|
|
|
|
|
|
|
// We put everything in a namespace, so that we can shorten names without polluting the global namespace
|
|
|
|
namespace Command {
|
|
|
|
|
2019-03-13 19:58:25 +00:00
|
|
|
class AddDiveSite : public Base {
|
|
|
|
public:
|
|
|
|
AddDiveSite(const QString &name);
|
|
|
|
private:
|
|
|
|
bool workToBeDone() override;
|
|
|
|
void undo() override;
|
|
|
|
void redo() override;
|
|
|
|
|
|
|
|
// Note: we only add one dive site. Nevertheless, we use vectors so that we
|
|
|
|
// can reuse the dive site deletion code.
|
|
|
|
// For redo
|
|
|
|
std::vector<dive_site *> sitesToRemove;
|
|
|
|
|
|
|
|
// For undo
|
|
|
|
std::vector<OwningDiveSitePtr> sitesToAdd;
|
|
|
|
};
|
|
|
|
|
2019-03-12 21:35:43 +00:00
|
|
|
class DeleteDiveSites : public Base {
|
|
|
|
public:
|
|
|
|
DeleteDiveSites(const QVector<dive_site *> &sites);
|
|
|
|
private:
|
|
|
|
bool workToBeDone() override;
|
2019-03-12 22:51:39 +00:00
|
|
|
void undo() override;
|
|
|
|
void redo() override;
|
2019-03-12 21:35:43 +00:00
|
|
|
|
|
|
|
// For redo
|
|
|
|
std::vector<dive_site *> sitesToRemove;
|
|
|
|
|
|
|
|
// For undo
|
|
|
|
std::vector<OwningDiveSitePtr> sitesToAdd;
|
2019-03-12 22:51:39 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class EditDiveSiteName : public Base {
|
|
|
|
public:
|
|
|
|
EditDiveSiteName(dive_site *ds, const QString &name);
|
|
|
|
private:
|
|
|
|
bool workToBeDone() override;
|
2019-03-12 21:35:43 +00:00
|
|
|
void undo() override;
|
|
|
|
void redo() override;
|
2019-03-12 22:51:39 +00:00
|
|
|
|
|
|
|
dive_site *ds;
|
|
|
|
QString value; // Value to be set
|
2019-03-12 21:35:43 +00:00
|
|
|
};
|
|
|
|
|
2019-03-13 19:10:22 +00:00
|
|
|
class EditDiveSiteDescription : public Base {
|
|
|
|
public:
|
|
|
|
EditDiveSiteDescription(dive_site *ds, const QString &description);
|
|
|
|
private:
|
|
|
|
bool workToBeDone() override;
|
|
|
|
void undo() override;
|
|
|
|
void redo() override;
|
|
|
|
|
|
|
|
dive_site *ds;
|
|
|
|
QString value; // Value to be set
|
|
|
|
};
|
|
|
|
|
2019-03-13 23:00:54 +00:00
|
|
|
class EditDiveSiteNotes : public Base {
|
|
|
|
public:
|
|
|
|
EditDiveSiteNotes(dive_site *ds, const QString ¬es);
|
|
|
|
private:
|
|
|
|
bool workToBeDone() override;
|
|
|
|
void undo() override;
|
|
|
|
void redo() override;
|
|
|
|
|
|
|
|
dive_site *ds;
|
|
|
|
QString value; // Value to be set
|
|
|
|
};
|
|
|
|
|
2019-03-14 07:26:50 +00:00
|
|
|
|
|
|
|
class EditDiveSiteCountry : public Base {
|
|
|
|
public:
|
|
|
|
EditDiveSiteCountry(dive_site *ds, const QString &country);
|
|
|
|
private:
|
|
|
|
bool workToBeDone() override;
|
|
|
|
void undo() override;
|
|
|
|
void redo() override;
|
|
|
|
|
|
|
|
dive_site *ds;
|
|
|
|
QString value; // Value to be set
|
|
|
|
};
|
|
|
|
|
2019-03-14 21:07:48 +00:00
|
|
|
class EditDiveSiteLocation : public Base {
|
|
|
|
public:
|
2019-03-14 22:28:45 +00:00
|
|
|
EditDiveSiteLocation(dive_site *ds, location_t location);
|
2019-03-14 21:07:48 +00:00
|
|
|
private:
|
|
|
|
bool workToBeDone() override;
|
|
|
|
void undo() override;
|
|
|
|
void redo() override;
|
|
|
|
|
|
|
|
dive_site *ds;
|
|
|
|
location_t value; // Value to be set
|
|
|
|
};
|
|
|
|
|
2019-03-15 13:32:55 +00:00
|
|
|
class EditDiveSiteTaxonomy : public Base {
|
|
|
|
public:
|
|
|
|
EditDiveSiteTaxonomy(dive_site *ds, taxonomy_data &taxonomy);
|
|
|
|
~EditDiveSiteTaxonomy(); // free taxonomy
|
|
|
|
private:
|
|
|
|
bool workToBeDone() override;
|
|
|
|
void undo() override;
|
|
|
|
void redo() override;
|
|
|
|
|
|
|
|
dive_site *ds;
|
|
|
|
taxonomy_data value; // Value to be set
|
|
|
|
};
|
|
|
|
|
2019-03-15 16:41:31 +00:00
|
|
|
class MergeDiveSites : public Base {
|
|
|
|
public:
|
|
|
|
MergeDiveSites(dive_site *ds, const QVector<dive_site *> &sites);
|
|
|
|
private:
|
|
|
|
bool workToBeDone() override;
|
|
|
|
void undo() override;
|
|
|
|
void redo() override;
|
|
|
|
|
|
|
|
dive_site *ds;
|
|
|
|
|
|
|
|
// For redo
|
|
|
|
std::vector<dive_site *> sitesToRemove;
|
|
|
|
|
|
|
|
// For undo
|
|
|
|
std::vector<OwningDiveSitePtr> sitesToAdd;
|
|
|
|
};
|
|
|
|
|
2019-03-12 21:35:43 +00:00
|
|
|
} // namespace Command
|
|
|
|
|
|
|
|
#endif // COMMAND_DIVESITE_H
|