]> sigrok.org Git - sigrok-meter.git/commitdiff
Add PySide compatibility.
authorJens Steinhauser <redacted>
Tue, 6 Oct 2015 11:52:43 +0000 (13:52 +0200)
committerUwe Hermann <redacted>
Tue, 6 Oct 2015 14:21:36 +0000 (16:21 +0200)
datamodel.py
mainwindow.py

index 2914fc37a8ba2d82a5bda4a98e37e29359bb1dfa..2b29fa4b3db328c6d398f63a533c8e7989c7f9b9 100644 (file)
@@ -18,7 +18,6 @@
 ## Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
 ##
 
-import collections
 import itertools
 import math
 import qtcompat
@@ -134,7 +133,7 @@ class MeasurementDataModel(QtGui.QStandardItemModel):
         item = QtGui.QStandardItem()
         item.setData(uid, MeasurementDataModel.idRole)
         item.setData(desc, MeasurementDataModel.descRole)
-        item.setData(collections.defaultdict(Trace), MeasurementDataModel.tracesRole)
+        item.setData({}, MeasurementDataModel.tracesRole)
         item.setData(next(self._colorgen), MeasurementDataModel.colorRole)
         self.appendRow(item)
         self.sort(0)
@@ -161,8 +160,15 @@ class MeasurementDataModel(QtGui.QStandardItemModel):
         if not math.isinf(value) and not math.isnan(value):
             sample = (timestamp, value)
             traces = item.data(MeasurementDataModel.tracesRole)
+
+            # It's not possible to use 'collections.defaultdict' here, because
+            # PySide doesn't return the original type that was passed in.
+            if not (unit in traces):
+                traces[unit] = Trace()
             traces[unit].append(sample)
 
+            item.setData(traces, MeasurementDataModel.tracesRole)
+
 class MultimeterDelegate(QtGui.QStyledItemDelegate):
     '''Delegate to show the data items from a MeasurementDataModel.'''
 
index 8ac3b3de142f7fa828a0c7fdbf18a874b28c0097..7398a5a84c5da87bb255efcc186e524785c41f02 100644 (file)
@@ -185,6 +185,7 @@ class MainWindow(QtGui.QMainWindow):
             idx = self.model.index(row, 0)
             deviceID = self.model.data(idx,
                             datamodel.MeasurementDataModel.idRole)
+            deviceID = tuple(deviceID) # PySide returns a list.
             traces = self.model.data(idx,
                             datamodel.MeasurementDataModel.tracesRole)