summaryrefslogtreecommitdiffstats
path: root/desktop-widgets/command_divelist.cpp
diff options
context:
space:
mode:
authorGravatar Berthold Stoeger <bstoeger@mail.tuwien.ac.at>2019-06-23 11:13:41 +0200
committerGravatar bstoeger <32835590+bstoeger@users.noreply.github.com>2019-06-23 20:08:46 +0200
commite1abf9485cf59f1b8cb79d827fa386af48f095a4 (patch)
tree6e4c7d0fd30402622f3264c7e6e57de279d11f2e /desktop-widgets/command_divelist.cpp
parent27944a52b1c2a1c68ccfe88c4a84d3f74fb8b512 (diff)
downloadsubsurface-e1abf9485cf59f1b8cb79d827fa386af48f095a4.tar.gz
Undo: unify selection behavior in dive-list commands
Some commands tried to retain the current selection on undo/redo, others set the selection to the modified dives. The latter was introduced because it was easier in some cases, but it is probably more user-friendly because the user gets feedback on the change. Therefore, unify to always select the affected dives on undo()/redo(). Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/command_divelist.cpp')
-rw-r--r--desktop-widgets/command_divelist.cpp17
1 files changed, 17 insertions, 0 deletions
diff --git a/desktop-widgets/command_divelist.cpp b/desktop-widgets/command_divelist.cpp
index 4c699fdd6..26708e07d 100644
--- a/desktop-widgets/command_divelist.cpp
+++ b/desktop-widgets/command_divelist.cpp
@@ -614,6 +614,9 @@ void ShiftTime::redoit()
emit diveListNotifier.divesTimeChanged(timeChanged, diveList);
emit diveListNotifier.divesChanged(diveList, DiveField::DATETIME);
+ // Select the changed dives
+ restoreSelection(diveList.toStdVector(), diveList[0]);
+
// Negate the time-shift so that the next call does the reverse
timeChanged = -timeChanged;
}
@@ -638,6 +641,13 @@ RenumberDives::RenumberDives(const QVector<QPair<dive *, int>> &divesToRenumberI
void RenumberDives::undoit()
{
renumberDives(divesToRenumber);
+
+ // Select the changed dives
+ std::vector<dive *> dives;
+ dives.reserve(divesToRenumber.size());
+ for (const QPair<dive *, int> &item: divesToRenumber)
+ dives.push_back(item.first);
+ restoreSelection(dives, dives[0]);
}
bool RenumberDives::workToBeDone()
@@ -660,6 +670,13 @@ void TripBase::redoit()
{
moveDivesBetweenTrips(divesToMove);
sort_trip_table(&trip_table); // Though unlikely, moving dives may reorder trips
+
+ // Select the moved dives
+ std::vector<dive *> dives;
+ dives.reserve(divesToMove.divesToMove.size());
+ for (const DiveToTrip &item: divesToMove.divesToMove)
+ dives.push_back(item.dive);
+ restoreSelection(dives, dives[0]);
}
void TripBase::undoit()