|
8 | 8 |
|
9 | 9 | import numpy as np |
10 | 10 | from AnyQt.QtCore import ( |
11 | | - QItemSelection, QItemSelectionModel, QItemSelectionRange, Qt |
| 11 | + QItemSelection, QItemSelectionModel, QItemSelectionRange, Qt, |
| 12 | + pyqtSignal as Signal |
12 | 13 | ) |
13 | 14 | from AnyQt.QtGui import QFontMetrics |
14 | 15 | from AnyQt.QtWidgets import ( |
@@ -76,6 +77,8 @@ def from_variable(cls, variable): |
76 | 77 |
|
77 | 78 |
|
78 | 79 | class TableView(QTableView): |
| 80 | + manualSelection = Signal() |
| 81 | + |
79 | 82 | def __init__(self, parent=None, **kwargs): |
80 | 83 | super().__init__(parent=parent, |
81 | 84 | selectionBehavior=QTableView.SelectRows, |
@@ -105,6 +108,10 @@ def setVHeaderFixedWidthFromLabel(self, max_label): |
105 | 108 | width = QFontMetrics(header.font()).width(max_label) |
106 | 109 | header.setFixedWidth(min(width + 40, 400)) |
107 | 110 |
|
| 111 | + def mousePressEvent(self, event): |
| 112 | + super().mousePressEvent(event) |
| 113 | + self.manualSelection.emit() |
| 114 | + |
108 | 115 |
|
109 | 116 | class TableModel(PyTableModel): |
110 | 117 | def __init__(self, *args, **kwargs): |
@@ -310,7 +317,7 @@ def __init__(self): |
310 | 317 | def _set_select_manual(): |
311 | 318 | self.setSelectionMethod(OWRank.SelectManual) |
312 | 319 |
|
313 | | - view.pressed.connect(_set_select_manual) |
| 320 | + view.manualSelection.connect(_set_select_manual) |
314 | 321 | view.verticalHeader().sectionClicked.connect(_set_select_manual) |
315 | 322 | view.horizontalHeader().sectionClicked.connect(self.headerClick) |
316 | 323 |
|
|
0 commit comments