mirror of
https://github.com/subsurface/subsurface.git
synced 2024-11-28 05:00:20 +00:00
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>
This commit is contained in:
parent
ebfa366826
commit
464721b2ec
2 changed files with 16 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
|
||||
|
|
|
@ -34,7 +34,9 @@ protected:
|
|||
bool workToBeDone() override;
|
||||
|
||||
std::vector<dive *> dives; // Dives to be edited.
|
||||
struct dive *current; // On undo, we set the current dive at the time of the operation.
|
||||
// On undo, we set the selection and current dive at the time of the operation.
|
||||
std::vector<dive *> selectedDives;
|
||||
struct dive *current;
|
||||
public:
|
||||
EditBase(T newValue, bool currentDiveOnly);
|
||||
|
||||
|
@ -162,6 +164,8 @@ class EditTagsBase : public Base {
|
|||
// the active dive when the user initialized the action. This dive
|
||||
// will be made the current dive on redo / undo.
|
||||
std::vector<dive *> dives;
|
||||
// On undo, we set the selection and current dive at the time of the operation.
|
||||
std::vector<dive *> selectedDives;
|
||||
struct dive *current;
|
||||
QStringList newList; // Temporary until initialized
|
||||
public:
|
||||
|
|
Loading…
Reference in a new issue