From 00d5ab1bdcabca68b1a03c3d414e7a8cea4168ea Mon Sep 17 00:00:00 2001 From: Linus Torvalds Date: Fri, 7 Jun 2013 18:25:30 -0700 Subject: Make a map ctrl-click toggle the selection state This way the map selection works like normal selections do. Except we don't do "ranged" selections (shift-click) for fairly obvious reasons. Signed-off-by: Linus Torvalds Signed-off-by: Dirk Hohndel --- qt-ui/divelistview.cpp | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) (limited to 'qt-ui/divelistview.cpp') diff --git a/qt-ui/divelistview.cpp b/qt-ui/divelistview.cpp index cbd62408b..a37b6ba3b 100644 --- a/qt-ui/divelistview.cpp +++ b/qt-ui/divelistview.cpp @@ -47,16 +47,19 @@ void DiveListView::unselectDives() selectionModel()->clearSelection(); } -void DiveListView::selectDive(struct dive *dive, bool scrollto) +void DiveListView::selectDive(struct dive *dive, bool scrollto, bool toggle) { QSortFilterProxyModel *m = qobject_cast(model()); QModelIndexList match = m->match(m->index(0,0), TreeItemDT::NR, dive->number, 1, Qt::MatchRecursive); + QFlags flags; QModelIndex idx = match.first(); QModelIndex parent = idx.parent(); if (parent.isValid()) expand(parent); - selectionModel()->select( idx, QItemSelectionModel::Select | QItemSelectionModel::Rows); + flags = toggle ? QItemSelectionModel::Toggle : QItemSelectionModel::Select; + flags |= QItemSelectionModel::Rows; + selectionModel()->select( idx, flags); if (scrollto) scrollTo(idx, PositionAtCenter); } -- cgit v1.2.3-70-g09d2