X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fprop%2Fbinding%2Fdeviceoptions.cpp;h=2dc237a885ec6eec83f9efbdde0654ef0aa9b049;hp=016486922d86a95dcc1282684d2695d3f828c585;hb=48c8844588e204568a7ae58abe0fb2070cd56d77;hpb=8dd4419097191563045396946f0dcff5ac9714b2 diff --git a/pv/prop/binding/deviceoptions.cpp b/pv/prop/binding/deviceoptions.cpp index 01648692..2dc237a8 100644 --- a/pv/prop/binding/deviceoptions.cpp +++ b/pv/prop/binding/deviceoptions.cpp @@ -22,9 +22,11 @@ #include +#include + #include "deviceoptions.h" -#include +#include #include #include #include @@ -45,8 +47,8 @@ namespace pv { namespace prop { namespace binding { -DeviceOptions::DeviceOptions(shared_ptr dev_inst, - const sr_probe_group *group) : +DeviceOptions::DeviceOptions(shared_ptr dev_inst, + const sr_channel_group *group) : _dev_inst(dev_inst), _group(group) { @@ -122,8 +124,9 @@ void DeviceOptions::bind_bool(const QString &name, int key) { assert(_dev_inst); _properties.push_back(shared_ptr(new Bool(name, - bind(&DevInst::get_config, _dev_inst, _group, key), - bind(&DevInst::set_config, _dev_inst, _group, key, _1)))); + bind(&device::DevInst::get_config, _dev_inst, _group, key), + bind(&device::DevInst::set_config, _dev_inst, + _group, key, _1)))); } void DeviceOptions::bind_enum(const QString &name, int key, @@ -134,15 +137,20 @@ void DeviceOptions::bind_enum(const QString &name, int key, vector< pair > values; assert(_dev_inst); - assert(gvar_list); + if (!gvar_list) { + qDebug() << "Config key " << key << " was listed, but no " + "options were given"; + return; + } g_variant_iter_init (&iter, gvar_list); while ((gvar = g_variant_iter_next_value (&iter))) values.push_back(make_pair(gvar, printer(gvar))); _properties.push_back(shared_ptr(new Enum(name, values, - bind(&DevInst::get_config, _dev_inst, _group, key), - bind(&DevInst::set_config, _dev_inst, _group, key, _1)))); + bind(&device::DevInst::get_config, _dev_inst, _group, key), + bind(&device::DevInst::set_config, _dev_inst, + _group, key, _1)))); } void DeviceOptions::bind_int(const QString &name, int key, QString suffix, @@ -151,24 +159,8 @@ void DeviceOptions::bind_int(const QString &name, int key, QString suffix, assert(_dev_inst); _properties.push_back(shared_ptr(new Int(name, suffix, range, - bind(&DevInst::get_config, _dev_inst, _group, key), - bind(&DevInst::set_config, _dev_inst, _group, key, _1)))); -} - -QString DeviceOptions::print_gvariant(GVariant *const gvar) -{ - QString s; - - if (g_variant_is_of_type(gvar, G_VARIANT_TYPE("s"))) - s = QString::fromUtf8(g_variant_get_string(gvar, NULL)); - else - { - gchar *const text = g_variant_print(gvar, FALSE); - s = QString::fromUtf8(text); - g_free(text); - } - - return s; + bind(&device::DevInst::get_config, _dev_inst, _group, key), + bind(&device::DevInst::set_config, _dev_inst, _group, key, _1)))); } QString DeviceOptions::print_timebase(GVariant *const gvar)