projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Enum: Reference gvariants in the values list
[pulseview.git]
/
pv
/
prop
/
double.cpp
diff --git
a/pv/prop/double.cpp
b/pv/prop/double.cpp
index 6f6fe0c1ea7e228ca7ed1487efa13e7202a3f5c2..93b45d327362f93b12595a4249e154bcdac0bb14 100644
(file)
--- a/
pv/prop/double.cpp
+++ b/
pv/prop/double.cpp
@@
-24,8
+24,8
@@
#include "double.h"
#include "double.h"
-using
namespace std
;
-using
namespace boost
;
+using
boost::optional
;
+using
std::pair
;
namespace pv {
namespace prop {
namespace pv {
namespace prop {
@@
-46,11
+46,19
@@
Double::Double(QString name,
{
}
{
}
-QWidget* Double::get_widget(QWidget *parent)
+Double::~Double()
+{
+}
+
+QWidget* Double::get_widget(QWidget *parent, bool auto_commit)
{
if (_spin_box)
return _spin_box;
{
if (_spin_box)
return _spin_box;
+ GVariant *const value = _getter ? _getter() : NULL;
+ if (!value)
+ return NULL;
+
_spin_box = new QDoubleSpinBox(parent);
_spin_box->setDecimals(_decimals);
_spin_box->setSuffix(_suffix);
_spin_box = new QDoubleSpinBox(parent);
_spin_box->setDecimals(_decimals);
_spin_box->setSuffix(_suffix);
@@
-59,12
+67,12
@@
QWidget* Double::get_widget(QWidget *parent)
if (_step)
_spin_box->setSingleStep(*_step);
if (_step)
_spin_box->setSingleStep(*_step);
- GVariant *const value = _getter ? _getter() : NULL;
+ _spin_box->setValue(g_variant_get_double(value));
+ g_variant_unref(value);
- if (value) {
- _spin_box->setValue(g_variant_get_double(value));
- g_variant_unref(value);
- }
+ if (auto_commit)
+ connect(_spin_box, SIGNAL(valueChanged(double)),
+ this, SLOT(on_value_changed(double)));
return _spin_box;
}
return _spin_box;
}
@@
-79,5
+87,10
@@
void Double::commit()
_setter(g_variant_new_double(_spin_box->value()));
}
_setter(g_variant_new_double(_spin_box->value()));
}
+void Double::on_value_changed(double)
+{
+ commit();
+}
+
} // prop
} // pv
} // prop
} // pv