mirror of
https://github.com/subsurface/subsurface.git
synced 2025-02-19 22:16:15 +00:00
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>
This commit is contained in:
parent
ef873b4082
commit
00d5ab1bdc
3 changed files with 8 additions and 4 deletions
|
@ -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);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue