Skip to content

Commit fe715a5

Browse files
ui: fixed crash selecting rows on old PyQt versions
In PyQt < 5.15 isRowSelected() requires two arguments (row and parent). Since 5.15, the parent argument is optional, and the default value is an empty QModelIndex(). In order to support old PyQt versions (Ubuntu 20.x), we add always the second argument. - Misc: headers reorganization.
1 parent e6bd14e commit fe715a5

File tree

1 file changed

+12
-8
lines changed

1 file changed

+12
-8
lines changed

ui/opensnitch/customwidgets/generictableview.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
from PyQt5.QtGui import QColor, QStandardItemModel, QStandardItem
2-
from PyQt5.QtSql import QSqlQueryModel, QSqlQuery, QSql
3-
from PyQt5.QtWidgets import QTableView, QAbstractSlider
4-
from PyQt5.QtCore import QItemSelectionRange, QItemSelectionModel, QItemSelection, pyqtSignal, QEvent, Qt
5-
import time
1+
from PyQt5.QtGui import QStandardItemModel
2+
from PyQt5.QtSql import QSqlQuery, QSql
3+
from PyQt5.QtWidgets import QTableView
4+
from PyQt5.QtCore import (
5+
QItemSelectionRange,
6+
QItemSelectionModel,
7+
QItemSelection,
8+
QModelIndex,
9+
pyqtSignal,
10+
QEvent,
11+
Qt)
612
import math
713

8-
from PyQt5.QtCore import QCoreApplication as QC
9-
1014
class GenericTableModel(QStandardItemModel):
1115
rowCountChanged = pyqtSignal()
1216
beginViewPortRefresh = pyqtSignal()
@@ -302,7 +306,7 @@ def mouseMoveEvent(self, event):
302306
clickedItem = self.model().index(row, self.trackingCol)
303307
if clickedItem.data() == None:
304308
return
305-
self.handleMouseMoveEvent(row, clickedItem, self.selectionModel().isRowSelected(row))
309+
self.handleMouseMoveEvent(row, clickedItem, self.selectionModel().isRowSelected(row, QModelIndex()))
306310

307311
finally:
308312
# call upper implementation to select/deselect rows.

0 commit comments

Comments
 (0)