From 726d08c2f71920acd8e5cc9b2d6850d1249466aa Mon Sep 17 00:00:00 2001 From: Berthold Stoeger Date: Wed, 17 Jul 2019 15:49:45 +0200 Subject: Undo: make editing of dive number undoable When pressing F2 in the dive list, the number can be edited. Make this action undoable by implementing a EditNumber command. This command is differs from the other undo commands, as not the currently selected dives are changed. This means that the EditCommand needs an alternative constructor taking a single dive. This constructor was implemented in the base class so that all edit commands can now be called with a single dive. Signed-off-by: Berthold Stoeger --- qt-models/divetripmodel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) (limited to 'qt-models') diff --git a/qt-models/divetripmodel.cpp b/qt-models/divetripmodel.cpp index 3956ab6e2..09c5c308d 100644 --- a/qt-models/divetripmodel.cpp +++ b/qt-models/divetripmodel.cpp @@ -7,6 +7,7 @@ #include "core/qthelper.h" #include "core/subsurface-string.h" #include "core/tag.h" +#include "desktop-widgets/command.h" #include #include #include @@ -412,8 +413,7 @@ bool DiveTripModelBase::setData(const QModelIndex &index, const QVariant &value, if (dive->number == v) return false; } - d->number = v; - mark_divelist_changed(true); + Command::editNumber(v, d); return true; } -- cgit v1.2.3-70-g09d2