Skip to content

Commit 320ec18

Browse files
ui: improved rows selection (4)
discard current selection: - if the user right clicked on a row not part of a selection. - if the user clicked on a row, and there's only one row selected. - if the user clicked on a row already selected.
1 parent fe715a5 commit 320ec18

File tree

1 file changed

+7
-2
lines changed

1 file changed

+7
-2
lines changed

ui/opensnitch/customwidgets/generictableview.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,13 @@ def mousePressEvent(self, event):
364364
del self._rows_selection[clickedItem.data()]
365365
flags = QItemSelectionModel.Rows | QItemSelectionModel.Deselect
366366
else:
367-
deselectCurRow = len(self._rows_selection.keys()) == 1
368-
if not rightBtnPressed:
367+
deselectCurRow = len(self._rows_selection.keys()) == 1 and not rightBtnPressed
368+
# discard current selection:
369+
# - if the user right clicked on a row not part of a selection.
370+
# - if the user clicked on a row, and there's only one row
371+
# selected.
372+
# - if the user clicked on a row already selected.
373+
if (not rowSelected and rightBtnPressed) or not rightBtnPressed or deselectCurRow:
369374
self.selectionModel().clear()
370375
self._rows_selection = {}
371376
if rowSelected and deselectCurRow and not rightBtnPressed:

0 commit comments

Comments
 (0)