diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2013-06-07 18:25:30 -0700 |
---|---|---|
committer | Dirk Hohndel <dirk@hohndel.org> | 2013-06-07 21:39:52 -0700 |
commit | 00d5ab1bdcabca68b1a03c3d414e7a8cea4168ea (patch) | |
tree | 2cc9542b9fe4924f5440399f9915f3c19c8b1d98 /qt-ui | |
parent | ef873b40821e3bc327b67ec980d1317112d2aa87 (diff) | |
download | subsurface-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')
-rw-r--r-- | qt-ui/divelistview.cpp | 7 | ||||
-rw-r--r-- | qt-ui/divelistview.h | 2 | ||||
-rw-r--r-- | qt-ui/globe.cpp | 3 |
3 files changed, 8 insertions, 4 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); } diff --git a/qt-ui/divelistview.h b/qt-ui/divelistview.h index a9b986f97..c578baa17 100644 --- a/qt-ui/divelistview.h +++ b/qt-ui/divelistview.h @@ -27,7 +27,7 @@ public: void reload(DiveTripModel::Layout layout, bool forceSort = true); bool eventFilter(QObject* , QEvent* ); void unselectDives(); - void selectDive(struct dive *, bool scrollto = false); + void selectDive(struct dive *, bool scrollto = false, bool toggle = false); void contextMenuEvent(QContextMenuEvent *event); public slots: diff --git a/qt-ui/globe.cpp b/qt-ui/globe.cpp index 78283e49e..778118913 100644 --- a/qt-ui/globe.cpp +++ b/qt-ui/globe.cpp @@ -82,6 +82,7 @@ void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit) int idx; struct dive *dive; bool clear = !(QApplication::keyboardModifiers() && Qt::ControlModifier); + bool toggle = !clear; bool first = true; for_each_dive(idx, dive) { long lat_diff, lon_diff; @@ -100,7 +101,7 @@ void GlobeGPS::mouseClicked(qreal lon, qreal lat, GeoDataCoordinates::Unit unit) mainWindow()->dive_list()->unselectDives(); clear = false; } - mainWindow()->dive_list()->selectDive(dive, first); + mainWindow()->dive_list()->selectDive(dive, first, toggle); first = false; } } |