def mousePressEvent(self, event):
if event.button() in (Qt.LeftButton, Qt.RightButton):
self._oldSelection = set(self._selection)
index = self._findIndexForEvent(event)
modifiers = event.modifiers()
if index is None:
if not (modifiers & Qt.ControlModifier or
modifiers & Qt.ShiftModifier):
# TODO: consider setSelection(None)
self.setSelection(set())
return
if modifiers & Qt.ControlModifier:
if index in self._selection:
self._selection.remove(index)
else:
self._selection.add(index)
elif modifiers & Qt.ShiftModifier:
self._selection = self._linearSelection(index)
elif index not in self._selection:
self._selection = {index}
else:
self._maybeDragPosition = event.localPos()
self._lastSelectedCell = index
self.selectionChanged.emit()
self.update()
else:
super(GlyphCellWidget, self).mousePressEvent(event)
评论列表
文章目录