Dominik Demuth
6b71de8265
fixes #32, #34, #39 Co-authored-by: Dominik Demuth <dominik.demuth@physik.tu-darmstadt.de> Reviewed-on: #40
21 lines
750 B
Python
21 lines
750 B
Python
from ..Qt import QtWidgets, QtGui, QtCore
|
|
|
|
|
|
class QListWidgetSelect(QtWidgets.QListWidget):
|
|
"""
|
|
Extension of QListWidget to change the check state of all selected QListWidgetItems with space key
|
|
"""
|
|
|
|
def __init__(self, parent=None):
|
|
super().__init__(parent=parent)
|
|
|
|
def keyPressEvent(self, evt: QtGui.QKeyEvent):
|
|
if evt.key() == QtCore.Qt.Key.Key_Space:
|
|
for idx in self.selectedIndexes():
|
|
item = self.itemFromIndex(idx)
|
|
cs = item.checkState()
|
|
item.setCheckState(QtCore.Qt.CheckState.Unchecked if cs == QtCore.Qt.CheckState.Checked
|
|
else QtCore.Qt.CheckState.Checked)
|
|
else:
|
|
super().keyPressEvent(evt)
|