aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Tomaz Canabrava <tcanabrava@kde.org>2013-11-16 18:52:14 -0200
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-11-16 20:23:22 -0800
commit8476ea5ea80deaf7e73065870cddf6b2ec4f96e7 (patch)
treef6d743a0d8f31bf34faf4fecebdaf3710b9dc131
parent73cd8f3e569b5214b03dbc613a18d5d50dbec98f (diff)
downloadsubsurface-8476ea5ea80deaf7e73065870cddf6b2ec4f96e7.tar.gz
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 <tcanabrava@kde.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
-rw-r--r--qt-ui/divelistview.cpp7
1 files changed, 7 insertions, 0 deletions
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()