From a94c84d5982a10cd9adfd421aed41cf159dd3303 Mon Sep 17 00:00:00 2001 From: Dirk Hohndel Date: Fri, 2 Oct 2015 14:50:12 -0400 Subject: Undo/redo of dive deletion needs to handle trips as well If we delete dives that were part of a trip, that trip may get deleted as well. So if we undo that operation we need to bring back the trip, too. This also deals with a bug in the original code that did the delete both in calling code (in divelistview.cpp) and in the redo function. Because of the nature of the delete this didn't really matter but it is of course wrong and with the new code it would in fact cause an issue. Signed-off-by: Dirk Hohndel --- qt-ui/divelistview.cpp | 11 ++--------- 1 file changed, 2 insertions(+), 9 deletions(-) (limited to 'qt-ui/divelistview.cpp') diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index 51720a317..d2386ecf1 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -776,23 +776,16 @@ void DiveListView::deleteDive() if (!d) return; - //TODO: port this to C-code. int i; - // after a dive is deleted the ones following it move forward in the dive_table - // so instead of using the for_each_dive macro I'm using an explicit for loop - // to make this easier to understand int lastDiveNr = -1; QList deletedDives; //a list of all deleted dives to be stored in the undo command for_each_dive (i, d) { if (!d->selected) continue; - struct dive* undo_entry = alloc_dive(); - copy_dive(get_dive(i), undo_entry); - deletedDives.append(undo_entry); - delete_single_dive(i); - i--; // so the next dive isn't skipped... it's now #i + deletedDives.append(d); lastDiveNr = i; } + // the actual dive deletion is happening in the redo command that is implicitly triggered UndoDeleteDive *undoEntry = new UndoDeleteDive(deletedDives); MainWindow::instance()->undoStack->push(undoEntry); if (amount_selected == 0) { -- cgit v1.2.3-70-g09d2