diff options
author | Berthold Stoeger <bstoeger@mail.tuwien.ac.at> | 2019-02-18 21:30:11 +0100 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2019-04-12 18:19:07 +0300 |
commit | 464721b2ecf27e4ecd7e3a29b78e626838ef82b8 (patch) | |
tree | f08216dead6f13374681184e9092ff1650fe6181 /desktop-widgets/command_edit.cpp | |
parent | ebfa36682602de1ed5c6ae53aabaf68b0b7f3b24 (diff) | |
download | subsurface-464721b2ecf27e4ecd7e3a29b78e626838ef82b8.tar.gz |
Undo: select dives on undo of editing commands
Save selected dives when generating an edit-command. Restore the
selection and current dive in undo()/redo().
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/command_edit.cpp')
-rw-r--r-- | desktop-widgets/command_edit.cpp | 14 |
1 files changed, 11 insertions, 3 deletions
diff --git a/desktop-widgets/command_edit.cpp b/desktop-widgets/command_edit.cpp index b8727bfb6..f92d045aa 100644 --- a/desktop-widgets/command_edit.cpp +++ b/desktop-widgets/command_edit.cpp @@ -8,7 +8,7 @@ namespace Command { -static std::vector<dive *> getSelectedDives(bool currentDiveOnly) +static std::vector<dive *> getDives(bool currentDiveOnly) { if (currentDiveOnly) return current_dive ? std::vector<dive *> { current_dive } @@ -27,7 +27,8 @@ static std::vector<dive *> getSelectedDives(bool currentDiveOnly) template<typename T> EditBase<T>::EditBase(T newValue, bool currentDiveOnly) : value(std::move(newValue)), - dives(getSelectedDives(currentDiveOnly)), + dives(getDives(currentDiveOnly)), + selectedDives(getDiveSelection()), current(current_dive) { } @@ -88,6 +89,9 @@ void EditBase<T>::undo() emit diveListNotifier.divesChanged(trip, divesInTrip, id); }); + if (setSelection(selectedDives, current)) + emit diveListNotifier.selectionChanged(); // If the selection changed -> tell the frontend + mark_divelist_changed(true); } @@ -404,7 +408,8 @@ DiveField EditMode::fieldId() const // ***** Tag based commands ***** EditTagsBase::EditTagsBase(const QStringList &newListIn, bool currentDiveOnly) : - dives(getSelectedDives(currentDiveOnly)), + dives(getDives(currentDiveOnly)), + selectedDives(getDiveSelection()), current(current_dive), newList(newListIn) { @@ -498,6 +503,9 @@ void EditTagsBase::undo() emit diveListNotifier.divesChanged(trip, divesInTrip, id); }); + if (setSelection(selectedDives, current)) + emit diveListNotifier.selectionChanged(); // If the selection changed -> tell the frontend + mark_divelist_changed(true); } |