summaryrefslogtreecommitdiffstats
path: root/commands
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-03-03 22:54:54 +0100
committerGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2020-04-07 00:13:35 +0200
commit33fb6461fbe7e389081e77853e63638a1a343623 (patch)
treeb45c374e565ce03a44b54860580e1413ba15090f /commands
parent7018783f64f664af97032da4ba4d357c05b52aaf (diff)
downloadsubsurface-33fb6461fbe7e389081e77853e63638a1a343623.tar.gz
undo: add undo command for dive-mode switch
This basically copies the bookmark code, with the addition that the dive mode is recorded in the text of the undo command. Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'commands')
-rw-r--r--commands/command.cpp5
-rw-r--r--commands/command.h1
-rw-r--r--commands/command_event.cpp7
-rw-r--r--commands/command_event.h5
4 files changed, 18 insertions, 0 deletions
diff --git a/commands/command.cpp b/commands/command.cpp
index e9b4e0738..4f92038b9 100644
--- a/commands/command.cpp
+++ b/commands/command.cpp
@@ -334,4 +334,9 @@ void addEventBookmark(struct dive *d, int dcNr, int seconds)
execute(new AddEventBookmark(d, dcNr, seconds));
}
+void addEventDivemodeSwitch(struct dive *d, int dcNr, int seconds, int divemode)
+{
+ execute(new AddEventDivemodeSwitch(d, dcNr, seconds, divemode));
+}
+
} // namespace Command
diff --git a/commands/command.h b/commands/command.h
index 88614b1e9..1644063a7 100644
--- a/commands/command.h
+++ b/commands/command.h
@@ -107,6 +107,7 @@ void editTripNotes(dive_trip *trip, const QString &s);
// 6) Event commands
void addEventBookmark(struct dive *d, int dcNr, int seconds);
+void addEventDivemodeSwitch(struct dive *d, int dcNr, int seconds, int divemode);
} // namespace Command
diff --git a/commands/command_event.cpp b/commands/command_event.cpp
index d945fbb02..ddef502bc 100644
--- a/commands/command_event.cpp
+++ b/commands/command_event.cpp
@@ -4,6 +4,7 @@
#include "core/dive.h"
#include "core/subsurface-qt/divelistnotifier.h"
#include "core/libdivecomputer.h"
+#include "core/gettextfromc.h"
namespace Command {
@@ -42,4 +43,10 @@ AddEventBookmark::AddEventBookmark(struct dive *d, int dcNr, int seconds) :
setText(tr("Add bookmark"));
}
+AddEventDivemodeSwitch::AddEventDivemodeSwitch(struct dive *d, int dcNr, int seconds, int divemode) :
+ AddEventBase(d, dcNr, create_event(seconds, SAMPLE_EVENT_BOOKMARK, 0, divemode, QT_TRANSLATE_NOOP("gettextFromC", "modechange")))
+{
+ setText(tr("Add dive mode switch to %1").arg(gettextFromC::tr(divemode_text_ui[divemode])));
+}
+
} // namespace Command
diff --git a/commands/command_event.h b/commands/command_event.h
index 6e387d543..3130a128f 100644
--- a/commands/command_event.h
+++ b/commands/command_event.h
@@ -39,6 +39,11 @@ public:
AddEventBookmark(struct dive *d, int dcNr, int seconds);
};
+class AddEventDivemodeSwitch : public AddEventBase {
+public:
+ AddEventDivemodeSwitch(struct dive *d, int dcNr, int seconds, int divemode);
+};
+
} // namespace Command
#endif // COMMAND_EVENT_H