From 8476ea5ea80deaf7e73065870cddf6b2ec4f96e7 Mon Sep 17 00:00:00 2001 From: Tomaz Canabrava Date: Sat, 16 Nov 2013 18:52:14 -0200 Subject: Selects the dive before the deleted ones. This patch makes a selection just after the dives that got deleted, or nothing if the list is empty. Signed-off-by: Tomaz Canabrava Signed-off-by: Dirk Hohndel --- qt-ui/divelistview.cpp | 7 +++++++ 1 file changed, 7 insertions(+) (limited to 'qt-ui') diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index 4a35176b8..df8bd44f6 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -473,12 +473,14 @@ void DiveListView::deleteDive() // 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; for (i = 0; i < dive_table.nr; i++) { d = get_dive(i); if (!d->selected) continue; delete_single_dive(i); i--; // so the next dive isn't skipped... it's now #i + lastDiveNr = i; } if (amount_selected == 0) { if (i > 0) @@ -488,6 +490,11 @@ void DiveListView::deleteDive() } mark_divelist_changed(TRUE); mainWindow()->refreshDisplay(); + if(lastDiveNr != -1){ + clearSelection(); + selectDive(lastDiveNr); + rememberSelection(); + } } void DiveListView::testSlot() -- cgit v1.2.3-70-g09d2