X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fprop%2Fenum.cpp;h=9044c6bae9d3c6335589c26e7be65835186a7b81;hp=2249b570851fd183aeb943cb857923584902608a;hb=f45925927eba2b93f367e63f5e3b651e24c67eb3;hpb=7a2b7394beb87938121b48f81422873002d74155 diff --git a/pv/prop/enum.cpp b/pv/prop/enum.cpp index 2249b570..9044c6ba 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 { @@ -45,12 +45,14 @@ Enum::~Enum() g_variant_unref(_values[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 +64,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 +85,10 @@ void Enum::commit() _setter((GVariant*)_selector->itemData(index).value()); } +void Enum::on_current_item_changed(int) +{ + commit(); +} + } // prop } // pv