]> sigrok.org Git - pulseview.git/blobdiff - pv/binding/decoder.cpp
binding/prop: Add a description field.
[pulseview.git] / pv / binding / decoder.cpp
index c5d014879f51d9580ab249328e387356fe6e4a09..f2e2e1d579f46eabe7b67104de3a103a6647055a 100644 (file)
@@ -23,8 +23,8 @@
 
 #include <boost/none_t.hpp>
 
-#include <pv/data/decoderstack.hpp>
 #include <pv/data/decode/decoder.hpp>
+#include <pv/data/decoderstack.hpp>
 #include <pv/prop/double.hpp>
 #include <pv/prop/enum.hpp>
 #include <pv/prop/int.hpp>
@@ -72,16 +72,16 @@ Decoder::Decoder(
                shared_ptr<Property> prop;
 
                if (opt->values)
-                       prop = bind_enum(name, opt, get, set);
+                       prop = bind_enum(name, "", opt, get, set);
                else if (g_variant_is_of_type(opt->def, G_VARIANT_TYPE("d")))
-                       prop = shared_ptr<Property>(new Double(name, 2, "",
+                       prop = shared_ptr<Property>(new Double(name, "", 2, "",
                                none, none, get, set));
                else if (g_variant_is_of_type(opt->def, G_VARIANT_TYPE("x")))
                        prop = shared_ptr<Property>(
-                               new Int(name, "", none, get, set));
+                               new Int(name, "", "", none, get, set));
                else if (g_variant_is_of_type(opt->def, G_VARIANT_TYPE("s")))
                        prop = shared_ptr<Property>(
-                               new String(name, get, set));
+                               new String(name, "", get, set));
                else
                        continue;
 
@@ -90,7 +90,8 @@ Decoder::Decoder(
 }
 
 shared_ptr<Property> Decoder::bind_enum(
-       const QString &name, const srd_decoder_option *option,
+       const QString &name, const QString &desc,
+       const srd_decoder_option *option,
        Property::Getter getter, Property::Setter setter)
 {
        vector< pair<Glib::VariantBase, QString> > values;
@@ -99,7 +100,7 @@ shared_ptr<Property> Decoder::bind_enum(
                values.push_back(make_pair(var, print_gvariant(var)));
        }
 
-       return shared_ptr<Property>(new Enum(name, values, getter, setter));
+       return shared_ptr<Property>(new Enum(name, desc, values, getter, setter));
 }
 
 Glib::VariantBase Decoder::getter(const char *id)
@@ -128,10 +129,7 @@ Glib::VariantBase Decoder::getter(const char *id)
                }
        }
 
-       if (val)
-               return Glib::VariantBase(val, true);
-       else
-               return Glib::VariantBase();
+       return (val) ? Glib::VariantBase(val, true) : Glib::VariantBase();
 }
 
 void Decoder::setter(const char *id, Glib::VariantBase value)
@@ -143,5 +141,5 @@ void Decoder::setter(const char *id, Glib::VariantBase value)
        decoder_stack_->begin_decode();
 }
 
-} // binding
-} // pv
+}  // namespace binding
+}  // namespace pv