summaryrefslogtreecommitdiffstats
path: root/qt-ui/divelistview.cpp
diff options
context:
space:
mode:
authorGravatar Linus Torvalds <torvalds@linux-foundation.org>2013-06-07 18:25:30 -0700
committerGravatar Dirk Hohndel <dirk@hohndel.org>2013-06-07 21:39:52 -0700
commit00d5ab1bdcabca68b1a03c3d414e7a8cea4168ea (patch)
tree2cc9542b9fe4924f5440399f9915f3c19c8b1d98 /qt-ui/divelistview.cpp
parentef873b40821e3bc327b67ec980d1317112d2aa87 (diff)
downloadsubsurface-00d5ab1bdcabca68b1a03c3d414e7a8cea4168ea.tar.gz
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 <torvalds@linux-foundation.org> Signed-off-by: Dirk Hohndel <dirk@hohndel.org>
Diffstat (limited to 'qt-ui/divelistview.cpp')
-rw-r--r--qt-ui/divelistview.cpp7
1 files changed, 5 insertions, 2 deletions
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<QSortFilterProxyModel*>(model());
QModelIndexList match = m->match(m->index(0,0), TreeItemDT::NR, dive->number, 1, Qt::MatchRecursive);
+ QFlags<QItemSelectionModel::SelectionFlag> 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);
}