2018-07-23 23:41:23 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0
|
|
|
|
#ifndef COMMAND_H
|
|
|
|
#define COMMAND_H
|
|
|
|
|
2022-11-12 08:40:04 +01:00
|
|
|
#include "core/divelog.h"
|
|
|
|
#include "core/equipment.h"
|
2020-04-17 23:18:58 +02:00
|
|
|
#include "core/pictureobj.h"
|
2020-10-25 19:13:42 +01:00
|
|
|
#include "core/taxonomy.h"
|
2018-07-23 23:41:23 +02:00
|
|
|
#include <QVector>
|
|
|
|
#include <QAction>
|
2019-11-16 21:35:26 +01:00
|
|
|
#include <vector>
|
|
|
|
|
2022-11-12 08:40:04 +01:00
|
|
|
struct divecomputer;
|
|
|
|
struct divelog;
|
|
|
|
struct dive_components;
|
|
|
|
struct dive_site;
|
|
|
|
struct dive_trip;
|
|
|
|
struct event;
|
2019-11-16 21:35:26 +01:00
|
|
|
struct DiveAndLocation;
|
2020-05-27 09:31:26 +02:00
|
|
|
struct FilterData;
|
2020-10-17 16:07:39 +02:00
|
|
|
struct filter_preset_table;
|
2018-07-23 23:41:23 +02: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 19:58:11 +02:00
|
|
|
// 1) General commands
|
2019-05-23 20:30:10 +02:00
|
|
|
|
2019-03-30 18:39:27 +01:00
|
|
|
void init(); // Setup signals to inform frontend of clean status.
|
2018-07-23 23:41:23 +02:00
|
|
|
void clear(); // Reset the undo stack. Delete all commands.
|
2019-03-30 18:39:27 +01: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 23:41:23 +02:00
|
|
|
QAction *undoAction(QObject *parent); // Create an undo action.
|
2022-11-06 12:18:27 +01:00
|
|
|
QAction *redoAction(QObject *parent); // Create a redo action.
|
|
|
|
QString changesMade(); // Return a string with the texts from all commands on the undo stack -> for commit message.
|
2022-02-14 21:47:12 +01:00
|
|
|
bool placingCommand(); // Currently executing a new command -> might not have to update the field the user just edited.
|
2018-07-23 23:41:23 +02: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 19:58:11 +02:00
|
|
|
// 2) Dive-list related commands
|
|
|
|
|
2019-03-03 17:10:09 +01: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 22:56:10 +01:00
|
|
|
void addDive(dive *d, bool autogroup, bool newNumber);
|
2022-11-12 08:40:04 +01:00
|
|
|
void importDives(struct divelog *log, int flags, const QString &source); // The tables are consumed!
|
2018-07-23 23:41:23 +02:00
|
|
|
void deleteDive(const QVector<struct dive*> &divesToDelete);
|
2020-01-03 16:04:54 +01:00
|
|
|
void shiftTime(const std::vector<dive *> &changedDives, int amount);
|
2018-07-30 15:55:29 +02:00
|
|
|
void renumberDives(const QVector<QPair<dive *, int>> &divesToRenumber);
|
2018-07-23 23:41:23 +02: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 10:20:13 +02:00
|
|
|
void splitDiveComputer(dive *d, int dc_num);
|
2019-05-17 22:22:55 +02:00
|
|
|
void moveDiveComputerToFront(dive *d, int dc_num);
|
2019-05-19 14:27:10 +02:00
|
|
|
void deleteDiveComputer(dive *d, int dc_num);
|
2018-07-23 23:41:23 +02:00
|
|
|
void mergeDives(const QVector <dive *> &dives);
|
2019-11-16 21:35:26 +01:00
|
|
|
void applyGPSFixes(const std::vector<DiveAndLocation> &fixes);
|
2018-07-23 23:41:23 +02:00
|
|
|
|
2019-03-12 22:35:43 +01:00
|
|
|
// 3) Dive-site related commands
|
|
|
|
|
|
|
|
void deleteDiveSites(const QVector <dive_site *> &sites);
|
2019-03-12 23:51:39 +01:00
|
|
|
void editDiveSiteName(dive_site *ds, const QString &value);
|
2019-03-13 20:10:22 +01:00
|
|
|
void editDiveSiteDescription(dive_site *ds, const QString &value);
|
2019-03-14 00:00:54 +01:00
|
|
|
void editDiveSiteNotes(dive_site *ds, const QString &value);
|
2019-03-14 08:26:50 +01:00
|
|
|
void editDiveSiteCountry(dive_site *ds, const QString &value);
|
2019-03-14 23:28:45 +01:00
|
|
|
void editDiveSiteLocation(dive_site *ds, location_t value);
|
2019-03-15 14:32:55 +01:00
|
|
|
void editDiveSiteTaxonomy(dive_site *ds, taxonomy_data &value); // value is consumed (i.e. will be erased after call)!
|
2019-03-13 20:58:25 +01:00
|
|
|
void addDiveSite(const QString &name);
|
2019-05-04 20:40:27 -07:00
|
|
|
void importDiveSites(struct dive_site_table *sites, const QString &source);
|
2019-03-15 17:41:31 +01:00
|
|
|
void mergeDiveSites(dive_site *ds, const QVector<dive_site *> &sites);
|
2019-03-19 19:52:54 +01:00
|
|
|
void purgeUnusedDiveSites();
|
2019-03-12 22:35:43 +01:00
|
|
|
|
2019-01-25 18:27:31 +01:00
|
|
|
// 4) Dive editing related commands
|
|
|
|
|
2019-05-23 20:27:19 +02: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 23:07:17 +01:00
|
|
|
int editInvalid(int newValue, bool currentDiveOnly);
|
2019-05-23 20:27:19 +02:00
|
|
|
int editRating(int newValue, bool currentDiveOnly);
|
|
|
|
int editVisibility(int newValue, bool currentDiveOnly);
|
2019-11-28 21:04:52 +02: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 20:27:19 +02:00
|
|
|
int editAirTemp(int newValue, bool currentDiveOnly);
|
|
|
|
int editWaterTemp(int newValue, bool currentDiveOnly);
|
|
|
|
int editAtmPress(int newValue, bool currentDiveOnly);
|
2019-11-19 19:16:45 +02:00
|
|
|
int editWaterTypeUser(int newValue, bool currentDiveOnly);
|
2019-05-23 20:27:19 +02: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);
|
2022-02-12 14:03:18 +01:00
|
|
|
int editDiveGuide(const QStringList &newList, bool currentDiveOnly);
|
2019-02-23 18:17:20 +01:00
|
|
|
void pasteDives(const dive *d, dive_components what);
|
2022-02-13 19:32:19 +01:00
|
|
|
enum class EditProfileType {
|
|
|
|
ADD,
|
|
|
|
REMOVE,
|
|
|
|
MOVE,
|
2024-05-25 19:03:39 +12:00
|
|
|
EDIT,
|
2022-02-13 19:32:19 +01:00
|
|
|
};
|
|
|
|
void replanDive(dive *d); // dive computer(s) and cylinder(s) of first argument will be consumed!
|
2022-05-21 21:30:57 +02:00
|
|
|
void editProfile(const dive *d, int dcNr, EditProfileType type, int count);
|
2019-11-02 21:19:29 +01:00
|
|
|
int addWeight(bool currentDiveOnly);
|
2019-11-03 15:04:48 +01:00
|
|
|
int removeWeight(int index, bool currentDiveOnly);
|
2019-11-08 22:47:38 +01:00
|
|
|
int editWeight(int index, weightsystem_t ws, bool currentDiveOnly);
|
2020-02-23 11:43:50 +01:00
|
|
|
int addCylinder(bool currentDiveOnly);
|
|
|
|
int removeCylinder(int index, bool currentDiveOnly);
|
2020-03-27 21:09:59 +01:00
|
|
|
enum class EditCylinderType {
|
|
|
|
TYPE,
|
|
|
|
PRESSURE,
|
|
|
|
GASMIX
|
|
|
|
};
|
|
|
|
int editCylinder(int index, cylinder_t cyl, EditCylinderType type, bool currentDiveOnly);
|
2022-05-21 21:13:32 +02:00
|
|
|
void editSensors(int toCylinder, int fromCylinder, int dcNr);
|
2020-01-10 08:25:37 +08: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 18:27:31 +01:00
|
|
|
|
2019-05-23 20:30:10 +02:00
|
|
|
// 5) Trip editing commands
|
|
|
|
|
2019-02-24 21:22:33 +01:00
|
|
|
void editTripLocation(dive_trip *trip, const QString &s);
|
|
|
|
void editTripNotes(dive_trip *trip, const QString &s);
|
|
|
|
|
2020-03-03 22:34:50 +01:00
|
|
|
// 6) Event commands
|
|
|
|
|
|
|
|
void addEventBookmark(struct dive *d, int dcNr, int seconds);
|
2020-03-03 22:54:54 +01:00
|
|
|
void addEventDivemodeSwitch(struct dive *d, int dcNr, int seconds, int divemode);
|
2020-03-03 23:31:46 +01:00
|
|
|
void addEventSetpointChange(struct dive *d, int dcNr, int seconds, pressure_t pO2);
|
2020-03-04 18:13:02 +01:00
|
|
|
void renameEvent(struct dive *d, int dcNr, struct event *ev, const char *name);
|
2020-03-04 18:25:47 +01:00
|
|
|
void removeEvent(struct dive *d, int dcNr, struct event *ev);
|
2020-03-04 21:10:05 +01:00
|
|
|
void addGasSwitch(struct dive *d, int dcNr, int seconds, int tank);
|
2020-03-03 22:34:50 +01:00
|
|
|
|
2020-04-14 22:07:00 +02:00
|
|
|
// 7) Picture (media) commands
|
|
|
|
|
2020-04-17 23:18:58 +02:00
|
|
|
struct PictureListForDeletion {
|
|
|
|
dive *d;
|
|
|
|
std::vector<std::string> filenames;
|
|
|
|
};
|
|
|
|
struct PictureListForAddition {
|
|
|
|
dive *d;
|
|
|
|
std::vector<PictureObj> pics;
|
|
|
|
};
|
2020-04-14 22:07:00 +02:00
|
|
|
void setPictureOffset(dive *d, const QString &filename, offset_t offset);
|
2020-04-17 23:18:58 +02:00
|
|
|
void removePictures(const std::vector<PictureListForDeletion> &pictures);
|
2020-04-19 18:48:23 +02:00
|
|
|
void addPictures(const std::vector<PictureListForAddition> &pictures);
|
2020-04-14 22:07:00 +02:00
|
|
|
|
2020-10-25 07:53:40 +01:00
|
|
|
// 8) Device commands
|
|
|
|
|
2021-08-17 11:14:42 -07:00
|
|
|
void editDeviceNickname(struct divecomputer *dc, const QString &nickname);
|
2020-10-25 07:53:40 +01:00
|
|
|
|
|
|
|
// 9) Filter commands
|
2020-05-27 09:31:26 +02:00
|
|
|
|
|
|
|
void createFilterPreset(const QString &name, const FilterData &data);
|
|
|
|
void removeFilterPreset(int index);
|
|
|
|
void editFilterPreset(int index, const FilterData &data);
|
|
|
|
|
2018-07-23 23:41:23 +02:00
|
|
|
} // namespace Command
|
|
|
|
|
|
|
|
#endif // COMMAND_H
|