X-Git-Url: http://git.code-monkey.de/?a=blobdiff_plain;f=pv%2Fprop%2Fenum.cpp;h=71cd431548da771ff5e3a9289480f62c5d5b71d2;hb=1e5faac3a34145620fedf7344c442d9e0a4e2296;hp=2249b570851fd183aeb943cb857923584902608a;hpb=7a2b7394beb87938121b48f81422873002d74155;p=pulseview.git diff --git a/pv/prop/enum.cpp b/pv/prop/enum.cpp index 2249b57..71cd431 100644 --- a/pv/prop/enum.cpp +++ b/pv/prop/enum.cpp @@ -24,8 +24,8 @@ #include "enum.h" -using namespace boost; -using namespace std; +using std::pair; +using std::vector; namespace pv { namespace prop { @@ -41,16 +41,19 @@ Enum::Enum(QString name, Enum::~Enum() { - for (unsigned int i = 0; i < _values.size(); i++) - g_variant_unref(_values[i].first); + for (vector< pair >::const_iterator i = + _values.begin(); i != _values.end(); i++) + g_variant_unref((*i).first); } -QWidget* Enum::get_widget(QWidget *parent) +QWidget* Enum::get_widget(QWidget *parent, bool auto_commit) { if (_selector) return _selector; GVariant *const value = _getter ? _getter() : NULL; + if (!value) + return NULL; _selector = new QComboBox(parent); for (unsigned int i = 0; i < _values.size(); i++) { @@ -62,6 +65,10 @@ QWidget* Enum::get_widget(QWidget *parent) g_variant_unref(value); + if (auto_commit) + connect(_selector, SIGNAL(currentIndexChanged(int)), + this, SLOT(on_current_item_changed(int))); + return _selector; } @@ -79,5 +86,10 @@ void Enum::commit() _setter((GVariant*)_selector->itemData(index).value()); } +void Enum::on_current_item_changed(int) +{ + commit(); +} + } // prop } // pv