The config key / option bindings only allowed for a single name so far.
Add an additional description field, which can be used for longer
descriptions of the config keys / options.
Hook up the input/output format option descriptions.
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;
}
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;
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)
private:
static shared_ptr<prop::Property> bind_enum(const QString &name,
- const srd_decoder_option *option,
+ const QString &desc, const srd_decoder_option *option,
prop::Property::Getter getter, prop::Property::Setter setter);
Glib::VariantBase getter(const char *id);
break;
case SR_CONF_CAPTURE_RATIO:
- bind_int(name, "%", pair<int64_t, int64_t>(0, 100),
+ bind_int(name, "", "%", pair<int64_t, int64_t>(0, 100),
get, set);
break;
case SR_CONF_TRIGGER_SLOPE:
case SR_CONF_COUPLING:
case SR_CONF_CLOCK_EDGE:
- bind_enum(name, key, capabilities, get, set);
+ bind_enum(name, "", key, capabilities, get, set);
break;
case SR_CONF_FILTER:
case SR_CONF_EXTERNAL_CLOCK:
case SR_CONF_RLE:
case SR_CONF_POWER_OFF:
- bind_bool(name, get, set);
+ bind_bool(name, "", get, set);
break;
case SR_CONF_TIMEBASE:
- bind_enum(name, key, capabilities, get, set, print_timebase);
+ bind_enum(name, "", key, capabilities, get, set, print_timebase);
break;
case SR_CONF_VDIV:
- bind_enum(name, key, capabilities, get, set, print_vdiv);
+ bind_enum(name, "", key, capabilities, get, set, print_vdiv);
break;
case SR_CONF_VOLTAGE_THRESHOLD:
- bind_enum(name, key, capabilities, get, set, print_voltage_threshold);
+ bind_enum(name, "", key, capabilities, get, set, print_voltage_threshold);
break;
case SR_CONF_PROBE_FACTOR:
if (capabilities.count(Capability::LIST))
- bind_enum(name, key, capabilities, get, set, print_probe_factor);
+ bind_enum(name, "", key, capabilities, get, set, print_probe_factor);
else
- bind_int(name, "", pair<int64_t, int64_t>(1, 500), get, set);
+ bind_int(name, "", "", pair<int64_t, int64_t>(1, 500), get, set);
break;
default:
}
}
-void Device::bind_bool(const QString &name,
+void Device::bind_bool(const QString &name, const QString &desc,
Property::Getter getter, Property::Setter setter)
{
assert(configurable_);
properties_.push_back(shared_ptr<Property>(new Bool(
- name, getter, setter)));
+ name, desc, getter, setter)));
}
-void Device::bind_enum(const QString &name,
+void Device::bind_enum(const QString &name, const QString &desc,
const ConfigKey *key, set<const Capability *> capabilities,
Property::Getter getter,
Property::Setter setter, function<QString (Glib::VariantBase)> printer)
while ((iter.next_value(gvar)))
values.push_back(make_pair(gvar, printer(gvar)));
- properties_.push_back(shared_ptr<Property>(new Enum(name, values,
+ properties_.push_back(shared_ptr<Property>(new Enum(name, desc, values,
getter, setter)));
}
-void Device::bind_int(const QString &name, QString suffix,
+void Device::bind_int(const QString &name, const QString &desc, QString suffix,
optional< pair<int64_t, int64_t> > range,
Property::Getter getter, Property::Setter setter)
{
assert(configurable_);
- properties_.push_back(shared_ptr<Property>(new Int(name, suffix, range,
- getter, setter)));
+ properties_.push_back(shared_ptr<Property>(new Int(name, desc, suffix,
+ range, getter, setter)));
}
QString Device::print_timebase(Glib::VariantBase gvar)
void config_changed();
private:
- void bind_bool(const QString &name,
+ void bind_bool(const QString &name, const QString &desc,
prop::Property::Getter getter, prop::Property::Setter setter);
- void bind_enum(const QString &name,
+ void bind_enum(const QString &name, const QString &desc,
const sigrok::ConfigKey *key,
set<const sigrok::Capability *> capabilities,
prop::Property::Getter getter, prop::Property::Setter setter,
function<QString (Glib::VariantBase)> printer = print_gvariant);
- void bind_int(const QString &name, QString suffix,
+ void bind_int(const QString &name, const QString &desc, QString suffix,
boost::optional< pair<int64_t, int64_t> > range,
prop::Property::Getter getter, prop::Property::Setter setter);
assert(opt);
const QString name = QString::fromStdString(opt->name());
+ const QString desc = QString::fromStdString(opt->description());
const VariantBase def_val = opt->default_value();
const vector<VariantBase> values = opt->values();
shared_ptr<Property> prop;
if (!opt->values().empty())
- prop = bind_enum(name, values, get, set);
+ prop = bind_enum(name, desc, values, get, set);
else if (def_val.is_of_type(VariantType("b")))
- prop = shared_ptr<Property>(new Bool(name, get, set));
+ prop = shared_ptr<Property>(new Bool(name, desc, get, set));
else if (def_val.is_of_type(VariantType("d")))
- prop = shared_ptr<Property>(new Double(name, 2, "",
+ prop = shared_ptr<Property>(new Double(name, desc, 2, "",
none, none, get, set));
else if (def_val.is_of_type(VariantType("i")) ||
def_val.is_of_type(VariantType("t")) ||
def_val.is_of_type(VariantType("u")))
prop = shared_ptr<Property>(
- new Int(name, "", none, get, set));
+ new Int(name, desc, "", none, get, set));
else if (def_val.is_of_type(VariantType("s")))
prop = shared_ptr<Property>(
- new String(name, get, set));
+ new String(name, desc, get, set));
else
continue;
}
shared_ptr<Property> InputOutput::bind_enum(
- const QString &name, const vector<VariantBase> &values,
+ const QString &name, const QString &desc, const vector<VariantBase> &values,
Property::Getter getter, Property::Setter setter)
{
vector< pair<VariantBase, QString> > enum_vals;
for (VariantBase var : values)
enum_vals.push_back(make_pair(var, print_gvariant(var)));
- return shared_ptr<Property>(new Enum(name, enum_vals, getter, setter));
+ return shared_ptr<Property>(new Enum(name, desc, enum_vals, getter, setter));
}
} // namespace binding
/**
* A helper function to bind an option list to and enum property.
* @param name the name of the property.
+ * @param name the description of the property.
* @param values the list of values.
* @param getter the getter that will read the values out of the map.
* @param setter the setter that will set the values into the map.
*/
shared_ptr<prop::Property> bind_enum(const QString &name,
- const vector<Glib::VariantBase> &values,
+ const QString &desc, const vector<Glib::VariantBase> &values,
prop::Property::Getter getter, prop::Property::Setter setter);
private:
namespace pv {
namespace prop {
-Bool::Bool(QString name, Getter getter, Setter setter) :
- Property(name, getter, setter),
+Bool::Bool(QString name, QString desc, Getter getter, Setter setter) :
+ Property(name, desc, getter, setter),
check_box_(nullptr)
{
}
Q_OBJECT;
public:
- Bool(QString name, Getter getter, Setter setter);
+ Bool(QString name, QString desc, Getter getter, Setter setter);
virtual ~Bool() = default;
namespace prop {
Double::Double(QString name,
+ QString desc,
int decimals,
QString suffix,
optional< pair<double, double> > range,
optional<double> step,
Getter getter,
Setter setter) :
- Property(name, getter, setter),
+ Property(name, desc, getter, setter),
decimals_(decimals),
suffix_(suffix),
range_(range),
Q_OBJECT
public:
- Double(QString name, int decimals, QString suffix,
+ Double(QString name, QString desc, int decimals, QString suffix,
boost::optional< pair<double, double> > range,
boost::optional<double> step,
Getter getter,
namespace pv {
namespace prop {
-Enum::Enum(QString name,
+Enum::Enum(QString name, QString desc,
vector<pair<Glib::VariantBase, QString> > values,
Getter getter, Setter setter) :
- Property(name, getter, setter),
+ Property(name, desc, getter, setter),
values_(values),
selector_(nullptr)
{
Q_OBJECT;
public:
- Enum(QString name, vector<pair<Glib::VariantBase, QString> > values,
+ Enum(QString name, QString desc,
+ vector<pair<Glib::VariantBase, QString> > values,
Getter getter, Setter setter);
virtual ~Enum() = default;
namespace prop {
Int::Int(QString name,
+ QString desc,
QString suffix,
optional< pair<int64_t, int64_t> > range,
Getter getter,
Setter setter) :
- Property(name, getter, setter),
+ Property(name, desc, getter, setter),
suffix_(suffix),
range_(range),
spin_box_(nullptr)
Q_OBJECT;
public:
- Int(QString name, QString suffix,
+ Int(QString name, QString desc, QString suffix,
boost::optional< pair<int64_t, int64_t> > range,
Getter getter, Setter setter);
namespace pv {
namespace prop {
-Property::Property(QString name, Getter getter, Setter setter) :
+Property::Property(QString name, QString desc, Getter getter, Setter setter) :
getter_(getter),
setter_(setter),
- name_(name)
+ name_(name),
+ desc_(desc)
{
}
return name_;
}
+const QString& Property::desc() const
+{
+ return desc_;
+}
+
bool Property::labeled_widget() const
{
return false;
typedef function<void (Glib::VariantBase)> Setter;
protected:
- Property(QString name, Getter getter, Setter setter);
+ Property(QString name, QString desc, Getter getter, Setter setter);
public:
const QString& name() const;
+ const QString& desc() const;
virtual QWidget* get_widget(QWidget *parent,
bool auto_commit = false) = 0;
private:
QString name_;
+ QString desc_;
};
} // namespace prop
namespace prop {
String::String(QString name,
+ QString desc,
Getter getter,
Setter setter) :
- Property(name, getter, setter),
+ Property(name, desc, getter, setter),
line_edit_(nullptr)
{
}
Q_OBJECT;
public:
- String(QString name, Getter getter, Setter setter);
+ String(QString name, QString desc, Getter getter, Setter setter);
QWidget* get_widget(QWidget *parent, bool auto_commit);