]> sigrok.org Git - pulseview.git/commitdiff
Implemented getter behaviour in Enum
authorJoel Holdsworth <redacted>
Sun, 3 Mar 2013 15:46:32 +0000 (15:46 +0000)
committerJoel Holdsworth <redacted>
Sun, 3 Mar 2013 16:51:20 +0000 (16:51 +0000)
pv/prop/enum.cpp

index f762bd1a8ab83e56a1d8f2e9d3e733e54d9dc573..ce33c5a8e724b779214d61416e23cda74b91db39 100644 (file)
@@ -47,12 +47,18 @@ QWidget* Enum::get_widget(QWidget *parent)
        if (_selector)
                return _selector;
 
+       const void *value = NULL;
+       if(_getter)
+               value = _getter();
+
        _selector = new QComboBox(parent);
-       for (vector< pair<const void*, QString> >::const_iterator i =
-                       _values.begin();
-               i != _values.end(); i++)
-               _selector->addItem((*i).second,
-                       qVariantFromValue((void*)(*i).first));
+       for(unsigned int i = 0; i < _values.size(); i++) {
+               const pair<const void*, QString> &v = _values[i];
+               _selector->addItem(v.second,
+                       qVariantFromValue((void*)v.first));
+               if(v.first == value)
+                       _selector->setCurrentIndex(i);
+       }
 
        return _selector;
 }