mirror of
https://github.com/ynput/ayon-core.git
synced 2026-01-01 08:24:53 +01:00
enhanced 'DeselectableTreeView'
This commit is contained in:
parent
c6b2ab3f22
commit
de504e8c85
1 changed files with 8 additions and 2 deletions
|
|
@ -7,7 +7,6 @@ class DeselectableTreeView(QtWidgets.QTreeView):
|
||||||
"""A tree view that deselects on clicking on an empty area in the view"""
|
"""A tree view that deselects on clicking on an empty area in the view"""
|
||||||
|
|
||||||
def mousePressEvent(self, event):
|
def mousePressEvent(self, event):
|
||||||
|
|
||||||
index = self.indexAt(event.pos())
|
index = self.indexAt(event.pos())
|
||||||
if not index.isValid():
|
if not index.isValid():
|
||||||
# clear the selection
|
# clear the selection
|
||||||
|
|
@ -15,7 +14,14 @@ class DeselectableTreeView(QtWidgets.QTreeView):
|
||||||
# clear the current index
|
# clear the current index
|
||||||
self.setCurrentIndex(QtCore.QModelIndex())
|
self.setCurrentIndex(QtCore.QModelIndex())
|
||||||
|
|
||||||
QtWidgets.QTreeView.mousePressEvent(self, event)
|
elif (
|
||||||
|
self.selectionModel().isSelected(index)
|
||||||
|
and len(self.selectionModel().selectedRows()) == 1
|
||||||
|
and event.modifiers() == QtCore.Qt.NoModifier
|
||||||
|
):
|
||||||
|
event.setModifiers(QtCore.Qt.ControlModifier)
|
||||||
|
|
||||||
|
super().mousePressEvent(event)
|
||||||
|
|
||||||
|
|
||||||
class TreeView(QtWidgets.QTreeView):
|
class TreeView(QtWidgets.QTreeView):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue