diff options
author | 2018-07-20 20:26:06 +0200 | |
---|---|---|
committer | 2018-10-11 16:22:27 -0700 | |
commit | 302f6adb79681da3fe53336f1e4c7525f46fd47d (patch) | |
tree | ce752cf002ec01cd9c26a804e49b2ee5b516d6ac /desktop-widgets/divelistview.cpp | |
parent | 12df9faaa2037b5155ebb84a7f6f6102491a0091 (diff) | |
download | subsurface-302f6adb79681da3fe53336f1e4c7525f46fd47d.tar.gz |
Undo: implement rudimentary support for undo of dive-splitting
For this, the core functionality of the split_dive() and
split_dive_at_time() functions were split out into new
split_dive_dont_insert() and split_dive_at_time_dont_insert(),
which do not add the new dives to the log. Thus, the undo-command
can take ownership of these dives, without having to remove them
first.
The split-dive functionality is temporarily made desktop-only
until mobile also supports "UndoObjects".
Signed-off-by: Berthold Stoeger <bstoeger@mail.tuwien.ac.at>
Diffstat (limited to 'desktop-widgets/divelistview.cpp')
-rw-r--r-- | desktop-widgets/divelistview.cpp | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/desktop-widgets/divelistview.cpp b/desktop-widgets/divelistview.cpp index 945a7381e..938a4e3e5 100644 --- a/desktop-widgets/divelistview.cpp +++ b/desktop-widgets/divelistview.cpp @@ -633,12 +633,16 @@ void DiveListView::splitDives() int i; struct dive *dive; + // Let's collect the dives to be split first, so that we don't catch newly inserted dives! + QVector<struct dive *> dives; for_each_dive (i, dive) { if (dive->selected) - split_dive(dive); + dives.append(dive); + } + for (struct dive *d: dives) { + UndoSplitDives *undoCommand = new UndoSplitDives(d, duration_t{-1}); + MainWindow::instance()->undoStack->push(undoCommand); } - MainWindow::instance()->refreshProfile(); - MainWindow::instance()->refreshDisplay(); } void DiveListView::renumberDives() |