]> sigrok.org Git - sigrok-meter.git/commitdiff
Sort the devices and channels.
authorJens Steinhauser <redacted>
Mon, 17 Nov 2014 15:37:07 +0000 (16:37 +0100)
committerJens Steinhauser <redacted>
Tue, 18 Nov 2014 15:11:41 +0000 (16:11 +0100)
sigrok-meter

index 6febbc393941d2738f42e7e6ce4460e220d65727..8501cfa65ba0c68e727b2d981e168b6e4d309e5a 100755 (executable)
@@ -230,7 +230,11 @@ class MeasurementDataModel(QtGui.QStandardItemModel):
     def __init__(self, parent):
         super(self.__class__, self).__init__(parent)
 
-        # used in 'format_mag()' to check against
+        # Use the description text to sort the items for now, because the
+        # _idRole holds tuples, and using them to sort doesn't work.
+        self.setSortRole(MeasurementDataModel.descRole)
+
+        # Used in 'format_mag()' to check against.
         self.inf = float('inf')
 
     def format_unit(self, u):
@@ -308,6 +312,7 @@ class MeasurementDataModel(QtGui.QStandardItemModel):
         item.setData(uid, MeasurementDataModel._idRole)
         item.setData(desc, MeasurementDataModel.descRole)
         self.appendRow(item)
+        self.sort(0)
         return item
 
     @QtCore.Slot(object, object)