undo: switch to affected dive on undo/redo of event-changes

Select and make current the affected dive. And also switch
to the divecomputer that was affected.

Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
This commit is contained in:
Berthold Stoeger 2020-03-05 23:10:44 +01:00
parent 48b4dc9c84
commit e39063f6df
2 changed files with 11 additions and 2 deletions

View file

@ -2,6 +2,7 @@
#include "command_event.h"
#include "core/dive.h"
#include "core/selection.h"
#include "core/subsurface-qt/divelistnotifier.h"
#include "core/libdivecomputer.h"
#include "core/gettextfromc.h"
@ -17,15 +18,21 @@ EventBase::EventBase(struct dive *dIn, int dcNrIn) :
void EventBase::redo()
{
redoit(); // Call actual function in base class
invalidate_dive_cache(d);
emit diveListNotifier.eventsChanged(d);
updateDive();
}
void EventBase::undo()
{
undoit(); // Call actual function in base class
updateDive();
}
void EventBase::updateDive()
{
invalidate_dive_cache(d);
emit diveListNotifier.eventsChanged(d);
dc_number = dcNr;
setSelection({ d }, d);
}
AddEventBase::AddEventBase(struct dive *d, int dcNr, struct event *ev) : EventBase(d, dcNr),

View file

@ -29,6 +29,8 @@ protected:
// are probably not stable.
struct dive *d;
int dcNr;
private:
void updateDive();
};
class AddEventBase : public EventBase {