aboutsummaryrefslogtreecommitdiffstats
path: root/qt-ui/divelistview.cpp
diff options
context:
space:
mode:
authorGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-21 17:58:15 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2014-08-21 17:58:15 -0700
commit4a04fc2a1bf9fc424645cda9257e24b43bbb1b71 (patch)
tree0a2c248fc25883d50b017fc9987ff8a2235d2f25 /qt-ui/divelistview.cpp
parentb8823acef986579491bdc90b3161772c1a697c16 (diff)
downloadsubsurface-4a04fc2a1bf9fc424645cda9257e24b43bbb1b71.tar.gz
Fix selection logic when manually adding a dive
This was an interesting bug. When adding a dive that would end up in the middle of the dive list, the newest dive in the dive list would end up marked in the dive structure as selected - even though it wasn't visualized as selected by Qt. Bad things happen if the user then made changes to that dive without selecting something else first, for example by either editing the dive or doing things to it like removing it from or adding it to a trip. The same operation would also be applied to the newest dive in the dive list. Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/divelistview.cpp')
-rw-r--r--qt-ui/divelistview.cpp8
1 files changed, 7 insertions, 1 deletions
diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp
index 117d02247..0d0d999f4 100644
--- a/qt-ui/divelistview.cpp
+++ b/qt-ui/divelistview.cpp
@@ -189,13 +189,19 @@ void DiveListView::selectTrip(dive_trip_t *trip)
void DiveListView::unselectDives()
{
+ // make sure we don't try to redraw the dives during the selection change
+ selected_dive = -1;
+ amount_selected = 0;
+ // clear the Qt selection
selectionModel()->clearSelection();
// clearSelection should emit selectionChanged() but sometimes that
// appears not to happen
+ // since we are unselecting all dives there is no need to use deselect_dive() - that
+ // would only cause pointless churn
int i;
struct dive *dive;
for_each_dive(i, dive) {
- deselect_dive(i);
+ dive->selected = false;
}
}