Add ability to undo removing of dives from trips

Add the functionality to undo/redo removing of dives from trips. The
code calling remove_dive_from_trip has moved to the UndoCommands class.

Signed-off-by: Grace Karanja <gracie.karanja89@gmail.com>
Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
This commit is contained in:
Grace Karanja 2015-04-10 09:39:51 +03:00 committed by Dirk Hohndel
parent 8e32faa866
commit 193edd9f13
3 changed files with 44 additions and 1 deletions

View file

@ -622,10 +622,14 @@ void DiveListView::removeFromTrip()
//TODO: move this to C-code.
int i;
struct dive *d;
QMap<struct dive*, dive_trip*> divesToRemove;
for_each_dive (i, d) {
if (d->selected)
remove_dive_from_trip(d, false);
divesToRemove.insert(d, d->divetrip);
}
UndoRemoveDivesFromTrip *undoCommand = new UndoRemoveDivesFromTrip(divesToRemove);
MainWindow::instance()->undoStack->push(undoCommand);
rememberSelection();
reload(currentLayout, false);
fixMessyQtModelBehaviour();