X-Git-Url: http://git.code-monkey.de/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fprop%2Fenum.cpp;fp=pv%2Fprop%2Fenum.cpp;h=03524344048d5ca27e4a06b3a7f72f3f17e18fd6;hp=6439a725c7adbdca16d90865c622da719fe9ef3b;hb=e8d009288de28cb194bc7964f96677c2baf900c9;hpb=87b79835014a386fb51b52bc993dbb693bd27197 diff --git a/pv/prop/enum.cpp b/pv/prop/enum.cpp index 6439a72..0352434 100644 --- a/pv/prop/enum.cpp +++ b/pv/prop/enum.cpp @@ -31,22 +31,16 @@ namespace pv { namespace prop { Enum::Enum(QString name, - vector > values, + vector > values, Getter getter, Setter setter) : Property(name, getter, setter), _values(values), _selector(NULL) { - for (vector< pair >::const_iterator i = - _values.begin(); i != _values.end(); i++) - g_variant_ref((*i).first); } Enum::~Enum() { - for (vector< pair >::const_iterator i = - _values.begin(); i != _values.end(); i++) - g_variant_unref((*i).first); } QWidget* Enum::get_widget(QWidget *parent, bool auto_commit) @@ -54,20 +48,21 @@ QWidget* Enum::get_widget(QWidget *parent, bool auto_commit) if (_selector) return _selector; - GVariant *const value = _getter ? _getter() : NULL; - if (!value) + if (!_getter) + return NULL; + + Glib::VariantBase variant = _getter(); + if (!variant.gobj()) return NULL; _selector = new QComboBox(parent); for (unsigned int i = 0; i < _values.size(); i++) { - const pair &v = _values[i]; - _selector->addItem(v.second, qVariantFromValue((void*)v.first)); - if (value && g_variant_equal(v.first, value)) + const pair &v = _values[i]; + _selector->addItem(v.second, qVariantFromValue(v.first)); + if (v.first.equal(variant)) _selector->setCurrentIndex(i); } - g_variant_unref(value); - if (auto_commit) connect(_selector, SIGNAL(currentIndexChanged(int)), this, SLOT(on_current_item_changed(int))); @@ -86,7 +81,7 @@ void Enum::commit() if (index < 0) return; - _setter((GVariant*)_selector->itemData(index).value()); + _setter(_selector->itemData(index).value()); } void Enum::on_current_item_changed(int)