pv/prop/bool.cpp
pv/prop/double.cpp
pv/prop/enum.cpp
+ pv/prop/int.cpp
pv/prop/property.cpp
pv/prop/binding/binding.cpp
pv/prop/binding/deviceoptions.cpp
#include <pv/prop/bool.h>
#include <pv/prop/double.h>
#include <pv/prop/enum.h>
+#include <pv/prop/int.h>
using namespace boost;
using namespace std;
bind_samplerate(name, gvar_list);
break;
+ case SR_CONF_CAPTURE_RATIO:
+ bind_int(name, key, "%", make_pair(0L, 100L));
+ break;
+
case SR_CONF_PATTERN_MODE:
case SR_CONF_BUFFERSIZE:
case SR_CONF_TRIGGER_SOURCE:
bind(config_setter, _sdi, key, _1))));
}
+void DeviceOptions::bind_int(const QString &name, int key, QString suffix,
+ optional< std::pair<int64_t, int64_t> > range)
+{
+ _properties.push_back(shared_ptr<Property>(
+ new Int(name, suffix, range,
+ bind(config_getter, _sdi, key),
+ bind(config_setter, _sdi, key, _1))));
+}
+
QString DeviceOptions::print_gvariant(GVariant *const gvar)
{
QString s;
#define PULSEVIEW_PV_PROP_BINDING_DEVICEOPTIONS_H
#include <boost/function.hpp>
+#include <boost/optional.hpp>
#include <QString>
void bind_enum(const QString &name, int key,
GVariant *const gvar_list,
boost::function<QString (GVariant*)> printer = print_gvariant);
+ void bind_int(const QString &name, int key, QString suffix,
+ boost::optional< std::pair<int64_t, int64_t> > range);
static QString print_gvariant(GVariant *const gvar);
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#include <assert.h>
+
+#include <QSpinBox>
+
+#include "int.h"
+
+using namespace std;
+using namespace boost;
+
+namespace pv {
+namespace prop {
+
+Int::Int(QString name,
+ QString suffix,
+ optional< pair<int64_t, int64_t> > range,
+ Getter getter,
+ Setter setter) :
+ Property(name, getter, setter),
+ _suffix(suffix),
+ _range(range),
+ _spin_box(NULL)
+{
+}
+
+QWidget* Int::get_widget(QWidget *parent)
+{
+ if (_spin_box)
+ return _spin_box;
+
+ _spin_box = new QSpinBox(parent);
+ _spin_box->setSuffix(_suffix);
+ if (_range)
+ _spin_box->setRange((int)_range->first, (int)_range->second);
+
+ GVariant *const value = _getter ? _getter() : NULL;
+ if (value) {
+ _spin_box->setValue((int)g_variant_get_int64(value));
+ g_variant_unref(value);
+ }
+
+ return _spin_box;
+}
+
+void Int::commit()
+{
+ assert(_setter);
+
+ if (!_spin_box)
+ return;
+
+ _setter(g_variant_new_int64(_spin_box->value()));
+}
+
+} // prop
+} // pv
--- /dev/null
+/*
+ * This file is part of the PulseView project.
+ *
+ * Copyright (C) 2013 Joel Holdsworth <joel@airwebreathe.org.uk>
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ */
+
+#ifndef PULSEVIEW_PV_PROP_INT_H
+#define PULSEVIEW_PV_PROP_INT_H
+
+#include <utility>
+
+#include <boost/optional.hpp>
+
+#include "property.h"
+
+class QSpinBox;
+
+namespace pv {
+namespace prop {
+
+class Int : public Property
+{
+public:
+ Int(QString name, QString suffix,
+ boost::optional< std::pair<int64_t, int64_t> > range,
+ Getter getter, Setter setter);
+
+ QWidget* get_widget(QWidget *parent);
+
+ void commit();
+
+private:
+ const QString _suffix;
+ const boost::optional< std::pair<int64_t, int64_t> > _range;
+
+ QSpinBox *_spin_box;
+};
+
+} // prop
+} // pv
+
+#endif // PULSEVIEW_PV_PROP_INT_H