From: Joel Holdsworth Date: Sun, 3 Mar 2013 15:46:32 +0000 (+0000) Subject: Implemented getter behaviour in Enum X-Git-Tag: pulseview-0.1.0~111 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=d191508b2cfa24b5cf56c5184e7609353582f972;p=pulseview.git Implemented getter behaviour in Enum --- diff --git a/pv/prop/enum.cpp b/pv/prop/enum.cpp index f762bd1a..ce33c5a8 100644 --- a/pv/prop/enum.cpp +++ b/pv/prop/enum.cpp @@ -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_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 &v = _values[i]; + _selector->addItem(v.second, + qVariantFromValue((void*)v.first)); + if(v.first == value) + _selector->setCurrentIndex(i); + } return _selector; }