gui: autodetect whether QSortFilterProxyModel is in QtCore or QtGui

This commit is contained in:
Sebastien Bourdeauducq 2015-10-17 19:11:17 +08:00
parent 7f5e264971
commit da83212c79
2 changed files with 13 additions and 3 deletions

View File

@ -12,6 +12,11 @@ from artiq.tools import short_format
from artiq.gui.tools import DictSyncModel
from artiq.gui.displays import *
try:
QSortFilterProxyModel = QtCore.QSortFilterProxyModel
except AttributeError:
QSortFilterProxyModel = QtGui.QSortFilterProxyModel
logger = logging.getLogger(__name__)
@ -89,7 +94,7 @@ class DatasetsDock(dockarea.Dock):
def init_datasets_model(self, init):
self.table_model = DatasetsModel(self.table, init)
self.table_model_filter = QtCore.QSortFilterProxyModel()
self.table_model_filter = QSortFilterProxyModel()
self.table_model_filter.setSourceModel(self.table_model)
self.table.setModel(self.table_model_filter)
return self.table_model

View File

@ -8,6 +8,11 @@ from pyqtgraph import dockarea, LayoutWidget
from artiq.protocols.sync_struct import Subscriber
from artiq.gui.tools import ListSyncModel
try:
QSortFilterProxyModel = QtCore.QSortFilterProxyModel
except AttributeError:
QSortFilterProxyModel = QtGui.QSortFilterProxyModel
def _level_to_name(level):
if level >= logging.CRITICAL:
@ -67,9 +72,9 @@ class _LogModel(ListSyncModel):
return v[3]
class _LevelFilterProxyModel(QtCore.QSortFilterProxyModel):
class _LevelFilterProxyModel(QSortFilterProxyModel):
def __init__(self, min_level):
QtCore.QSortFilterProxyModel.__init__(self)
QSortFilterProxyModel.__init__(self)
self.min_level = min_level
def filterAcceptsRow(self, sourceRow, sourceParent):