2018-07-23 21:41:23 +00:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#ifndef COMMAND_H
|
|
|
|
#define COMMAND_H
|
|
|
|
|
|
|
|
#include "core/dive.h"
|
2020-04-17 21:18:58 +00:00
|
|
|
#include "core/pictureobj.h"
|
2018-07-23 21:41:23 +00:00
|
|
|
#include <QVector>
|
|
|
|
#include <QAction>
|
2019-11-16 20:35:26 +00:00
|
|
|
#include <vector>
|
|
|
|
|
|
|
|
struct DiveAndLocation;
|
2018-07-23 21:41:23 +00:00
|
|
|
|
|
|
|
// We put everything in a namespace, so that we can shorten names without polluting the global namespace
|
|
|
|
namespace Command {
|
|
|
|
|
Undo: make adding of planned dive undo-able
Planned dives were still added by directly calling core code.
This could confuse the undo-machinery, leading to crashes.
Instead, use the proper undo-command. The problem is that as
opposed to the other AddDive-commands, planned dives may
belong to a trip. Thus, the interface to the AddDive command
was changed to respect the divetrip field. Make sure that
the other callers reset that field (actually, it should never
be set). Add a comment describing the perhaps surprising
interface (the passed-in dive, usually displayed dive, is
reset).
Moreover, a dive cloned in the planner is not assigned a
new number. Thus, add an argument to the AddDive-command,
which expresses whether a new number should be generated
for the to-be-added dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-09-08 17:58:11 +00:00
|
|
|
// 1) General commands
|
2019-05-23 18:30:10 +00:00
|
|
|
|
2019-03-30 17:39:27 +00:00
|
|
|
void init(); // Setup signals to inform frontend of clean status.
|
2018-07-23 21:41:23 +00:00
|
|
|
void clear(); // Reset the undo stack. Delete all commands.
|
2019-03-30 17:39:27 +00:00
|
|
|
void setClean(); // Call after save - this marks a state where no changes need to be saved.
|
|
|
|
bool isClean(); // Any changes need to be saved?
|
2018-07-23 21:41:23 +00:00
|
|
|
QAction *undoAction(QObject *parent); // Create an undo action.
|
|
|
|
QAction *redoAction(QObject *parent); // Create an redo action.
|
2020-03-05 16:56:17 +00:00
|
|
|
QString changesMade(); // return a string with the texts from all commands on the undo stack -> for commit message
|
2018-07-23 21:41:23 +00:00
|
|
|
|
Undo: make adding of planned dive undo-able
Planned dives were still added by directly calling core code.
This could confuse the undo-machinery, leading to crashes.
Instead, use the proper undo-command. The problem is that as
opposed to the other AddDive-commands, planned dives may
belong to a trip. Thus, the interface to the AddDive command
was changed to respect the divetrip field. Make sure that
the other callers reset that field (actually, it should never
be set). Add a comment describing the perhaps surprising
interface (the passed-in dive, usually displayed dive, is
reset).
Moreover, a dive cloned in the planner is not assigned a
new number. Thus, add an argument to the AddDive-command,
which expresses whether a new number should be generated
for the to-be-added dive.
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
2018-09-08 17:58:11 +00:00
|
|
|
// 2) Dive-list related commands
|
|
|
|
|
2019-03-03 16:10:09 +00:00
|
|
|
// If d->dive_trip is null and autogroup is true, dives within the auto-group
|
|
|
|
// distance are added to a trip. dive d is consumed (the structure is reset)!
|
|
|
|
// If newNumber is true, the dive is assigned a new number, depending on the
|
|
|
|
// insertion position.
|
2020-02-06 21:56:10 +00:00
|
|
|
void addDive(dive *d, bool autogroup, bool newNumber);
|
2019-09-22 17:42:30 +00:00
|
|
|
void importDives(struct dive_table *dives, struct trip_table *trips,
|
|
|
|
struct dive_site_table *sites, int flags, const QString &source); // The tables are consumed!
|
2018-07-23 21:41:23 +00:00
|
|
|
void deleteDive(const QVector<struct dive*> &divesToDelete);
|
2020-01-03 15:04:54 +00:00
|
|
|
void shiftTime(const std::vector<dive *> &changedDives, int amount);
|
2018-07-30 13:55:29 +00:00
|
|
|
void renumberDives(const QVector<QPair<dive *, int>> &divesToRenumber);
|
2018-07-23 21:41:23 +00:00
|
|
|
void removeDivesFromTrip(const QVector<dive *> &divesToRemove);
|
|
|
|
void removeAutogenTrips();
|
|
|
|
void addDivesToTrip(const QVector<dive *> &divesToAddIn, dive_trip *trip);
|
|
|
|
void createTrip(const QVector<dive *> &divesToAddIn);
|
|
|
|
void autogroupDives();
|
|
|
|
void mergeTrips(dive_trip *trip1, dive_trip *trip2);
|
|
|
|
void splitDives(dive *d, duration_t time);
|
2019-03-31 08:20:13 +00:00
|
|
|
void splitDiveComputer(dive *d, int dc_num);
|
2019-05-17 20:22:55 +00:00
|
|
|
void moveDiveComputerToFront(dive *d, int dc_num);
|
2019-05-19 12:27:10 +00:00
|
|
|
void deleteDiveComputer(dive *d, int dc_num);
|
2018-07-23 21:41:23 +00:00
|
|
|
void mergeDives(const QVector <dive *> &dives);
|
2019-11-16 20:35:26 +00:00
|
|
|
void applyGPSFixes(const std::vector<DiveAndLocation> &fixes);
|
2018-07-23 21:41:23 +00:00
|
|
|
|
2019-03-12 21:35:43 +00:00
|
|
|
// 3) Dive-site related commands
|
|
|
|
|
|
|
|
void deleteDiveSites(const QVector <dive_site *> &sites);
|
2019-03-12 22:51:39 +00:00
|
|
|
void editDiveSiteName(dive_site *ds, const QString &value);
|
2019-03-13 19:10:22 +00:00
|
|
|
void editDiveSiteDescription(dive_site *ds, const QString &value);
|
2019-03-13 23:00:54 +00:00
|
|
|
void editDiveSiteNotes(dive_site *ds, const QString &value);
|
2019-03-14 07:26:50 +00:00
|
|
|
void editDiveSiteCountry(dive_site *ds, const QString &value);
|
2019-03-14 22:28:45 +00:00
|
|
|
void editDiveSiteLocation(dive_site *ds, location_t value);
|
2019-03-15 13:32:55 +00:00
|
|
|
void editDiveSiteTaxonomy(dive_site *ds, taxonomy_data &value); // value is consumed (i.e. will be erased after call)!
|
2019-03-13 19:58:25 +00:00
|
|
|
void addDiveSite(const QString &name);
|
2019-05-05 03:40:27 +00:00
|
|
|
void importDiveSites(struct dive_site_table *sites, const QString &source);
|
2019-03-15 16:41:31 +00:00
|
|
|
void mergeDiveSites(dive_site *ds, const QVector<dive_site *> &sites);
|
2019-03-19 18:52:54 +00:00
|
|
|
void purgeUnusedDiveSites();
|
2019-03-12 21:35:43 +00:00
|
|
|
|
2019-01-25 17:27:31 +00:00
|
|
|
// 4) Dive editing related commands
|
|
|
|
|
2019-05-23 18:27:19 +00:00
|
|
|
int editNotes(const QString &newValue, bool currentDiveOnly);
|
|
|
|
int editSuit(const QString &newValue, bool currentDiveOnly);
|
|
|
|
int editMode(int index, int newValue, bool currentDiveOnly);
|
2019-12-12 22:07:17 +00:00
|
|
|
int editInvalid(int newValue, bool currentDiveOnly);
|
2019-05-23 18:27:19 +00:00
|
|
|
int editRating(int newValue, bool currentDiveOnly);
|
|
|
|
int editVisibility(int newValue, bool currentDiveOnly);
|
2019-11-28 19:04:52 +00:00
|
|
|
int editWaveSize(int newValue, bool currentDiveOnly);
|
|
|
|
int editCurrent(int newValue, bool currentDiveOnly);
|
|
|
|
int editSurge(int newValue, bool currentDiveOnly);
|
|
|
|
int editChill(int newValue, bool currentDiveOnly);
|
2019-05-23 18:27:19 +00:00
|
|
|
int editAirTemp(int newValue, bool currentDiveOnly);
|
|
|
|
int editWaterTemp(int newValue, bool currentDiveOnly);
|
|
|
|
int editAtmPress(int newValue, bool currentDiveOnly);
|
2019-11-19 17:16:45 +00:00
|
|
|
int editWaterTypeUser(int newValue, bool currentDiveOnly);
|
2019-05-23 18:27:19 +00:00
|
|
|
int editDepth(int newValue, bool currentDiveOnly);
|
|
|
|
int editDuration(int newValue, bool currentDiveOnly);
|
|
|
|
int editDiveSite(struct dive_site *newValue, bool currentDiveOnly);
|
|
|
|
int editDiveSiteNew(const QString &newName, bool currentDiveOnly);
|
|
|
|
int editTags(const QStringList &newList, bool currentDiveOnly);
|
|
|
|
int editBuddies(const QStringList &newList, bool currentDiveOnly);
|
|
|
|
int editDiveMaster(const QStringList &newList, bool currentDiveOnly);
|
2019-02-23 17:17:20 +00:00
|
|
|
void pasteDives(const dive *d, dive_components what);
|
2019-10-06 18:54:25 +00:00
|
|
|
void replanDive(dive *d); // dive computer(s) and cylinder(s) will be reset!
|
2019-11-30 14:51:34 +00:00
|
|
|
void editProfile(dive *d); // dive computer(s) and cylinder(s) will be reset!
|
2019-11-02 20:19:29 +00:00
|
|
|
int addWeight(bool currentDiveOnly);
|
2019-11-03 14:04:48 +00:00
|
|
|
int removeWeight(int index, bool currentDiveOnly);
|
2019-11-08 21:47:38 +00:00
|
|
|
int editWeight(int index, weightsystem_t ws, bool currentDiveOnly);
|
2020-02-23 10:43:50 +00:00
|
|
|
int addCylinder(bool currentDiveOnly);
|
|
|
|
int removeCylinder(int index, bool currentDiveOnly);
|
2020-03-27 20:09:59 +00:00
|
|
|
enum class EditCylinderType {
|
|
|
|
TYPE,
|
|
|
|
PRESSURE,
|
|
|
|
GASMIX
|
|
|
|
};
|
|
|
|
int editCylinder(int index, cylinder_t cyl, EditCylinderType type, bool currentDiveOnly);
|
2020-01-10 00:25:37 +00:00
|
|
|
#ifdef SUBSURFACE_MOBILE
|
|
|
|
// Edits a dive and creates a divesite (if createDs != NULL) or edits a divesite (if changeDs != NULL).
|
|
|
|
// Takes ownership of newDive and createDs!
|
|
|
|
void editDive(dive *oldDive, dive *newDive, dive_site *createDs, dive_site *changeDs, location_t dsLocation);
|
|
|
|
#endif
|
2019-01-25 17:27:31 +00:00
|
|
|
|
2019-05-23 18:30:10 +00:00
|
|
|
// 5) Trip editing commands
|
|
|
|
|
2019-02-24 20:22:33 +00:00
|
|
|
void editTripLocation(dive_trip *trip, const QString &s);
|
|
|
|
void editTripNotes(dive_trip *trip, const QString &s);
|
|
|
|
|
2020-03-03 21:34:50 +00:00
|
|
|
// 6) Event commands
|
|
|
|
|
|
|
|
void addEventBookmark(struct dive *d, int dcNr, int seconds);
|
2020-03-03 21:54:54 +00:00
|
|
|
void addEventDivemodeSwitch(struct dive *d, int dcNr, int seconds, int divemode);
|
2020-03-03 22:31:46 +00:00
|
|
|
void addEventSetpointChange(struct dive *d, int dcNr, int seconds, pressure_t pO2);
|
2020-03-04 17:13:02 +00:00
|
|
|
void renameEvent(struct dive *d, int dcNr, struct event *ev, const char *name);
|
2020-03-04 17:25:47 +00:00
|
|
|
void removeEvent(struct dive *d, int dcNr, struct event *ev);
|
2020-03-04 20:10:05 +00:00
|
|
|
void addGasSwitch(struct dive *d, int dcNr, int seconds, int tank);
|
2020-03-03 21:34:50 +00:00
|
|
|
|
2020-04-14 20:07:00 +00:00
|
|
|
// 7) Picture (media) commands
|
|
|
|
|
2020-04-17 21:18:58 +00:00
|
|
|
struct PictureListForDeletion {
|
|
|
|
dive *d;
|
|
|
|
std::vector<std::string> filenames;
|
|
|
|
};
|
|
|
|
struct PictureListForAddition {
|
|
|
|
dive *d;
|
|
|
|
std::vector<PictureObj> pics;
|
|
|
|
};
|
2020-04-14 20:07:00 +00:00
|
|
|
void setPictureOffset(dive *d, const QString &filename, offset_t offset);
|
2020-04-17 21:18:58 +00:00
|
|
|
void removePictures(const std::vector<PictureListForDeletion> &pictures);
|
2020-04-19 16:48:23 +00:00
|
|
|
void addPictures(const std::vector<PictureListForAddition> &pictures);
|
2020-04-14 20:07:00 +00:00
|
|
|
|
2018-07-23 21:41:23 +00:00
|
|
|
} // namespace Command
|
|
|
|
|
|
|
|
#endif // COMMAND_H
|