mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
7018783f64
commit
33fb6461fb
5 changed files with 19 additions and 4 deletions
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -1606,10 +1606,7 @@ void ProfileWidget2::addBookmark(int seconds)
|
|||
|
||||
void ProfileWidget2::addDivemodeSwitch(int seconds, int divemode)
|
||||
{
|
||||
add_event(current_dc, seconds, SAMPLE_EVENT_BOOKMARK, 0, divemode, QT_TRANSLATE_NOOP("gettextFromC", "modechange"));
|
||||
invalidate_dive_cache(current_dive);
|
||||
mark_divelist_changed(true);
|
||||
replot();
|
||||
Command::addEventDivemodeSwitch(current_dive, dc_number, seconds, divemode);
|
||||
}
|
||||
|
||||
void ProfileWidget2::addSetpointChange(int seconds)
|
||||
|
|
Loading…
Add table
Reference in a new issue