From da83212c79576734bf80fc3bfc0ae9b14057c06a Mon Sep 17 00:00:00 2001 From: Sebastien Bourdeauducq Date: Sat, 17 Oct 2015 19:11:17 +0800 Subject: [PATCH] gui: autodetect whether QSortFilterProxyModel is in QtCore or QtGui --- artiq/gui/datasets.py | 7 ++++++- artiq/gui/log.py | 9 +++++++-- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/artiq/gui/datasets.py b/artiq/gui/datasets.py index 3d547902b..4af8a59ac 100644 --- a/artiq/gui/datasets.py +++ b/artiq/gui/datasets.py @@ -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 diff --git a/artiq/gui/log.py b/artiq/gui/log.py index bbb3ad2b0..b9c75df05 100644 --- a/artiq/gui/log.py +++ b/artiq/gui/log.py @@ -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):