projects
/
pulseview.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
Change namespace for the trace view and implement ViewBase
[pulseview.git]
/
pv
/
prop
/
double.cpp
diff --git
a/pv/prop/double.cpp
b/pv/prop/double.cpp
index 188286ae1c4ff08a22687c0ac11704c69920ff23..f4e6e443a5bb6f2e7dcf27fe29053f6daed50090 100644
(file)
--- a/
pv/prop/double.cpp
+++ b/
pv/prop/double.cpp
@@
-22,10
+22,10
@@
#include <QDoubleSpinBox>
#include <QDoubleSpinBox>
-#include "double.h"
+#include "double.h
pp
"
-using
namespace std
;
-using
namespace boost
;
+using
boost::optional
;
+using
std::pair
;
namespace pv {
namespace prop {
namespace pv {
namespace prop {
@@
-38,53
+38,54
@@
Double::Double(QString name,
Getter getter,
Setter setter) :
Property(name, getter, setter),
Getter getter,
Setter setter) :
Property(name, getter, setter),
- _decimals(decimals),
- _suffix(suffix),
- _range(range),
- _step(step),
- _spin_box(NULL)
-{
-}
-
-Double::~Double()
+ decimals_(decimals),
+ suffix_(suffix),
+ range_(range),
+ step_(step),
+ spin_box_(nullptr)
{
}
QWidget* Double::get_widget(QWidget *parent, bool auto_commit)
{
{
}
QWidget* Double::get_widget(QWidget *parent, bool auto_commit)
{
- if (_spin_box)
- return _spin_box;
+ if (spin_box_)
+ return spin_box_;
+
+ if (!getter_)
+ return nullptr;
+
+ Glib::VariantBase variant = getter_();
+ if (!variant.gobj())
+ return nullptr;
- _spin_box = new QDoubleSpinBox(parent);
- _spin_box->setDecimals(_decimals);
- _spin_box->setSuffix(_suffix);
- if (_range)
- _spin_box->setRange(_range->first, _range->second);
- if (_step)
- _spin_box->setSingleStep(*_step);
+ double value = Glib::VariantBase::cast_dynamic<Glib::Variant<double>>(
+ variant).get();
- GVariant *const value = _getter ? _getter() : NULL;
+ spin_box_ = new QDoubleSpinBox(parent);
+ spin_box_->setDecimals(decimals_);
+ spin_box_->setSuffix(suffix_);
+ if (range_)
+ spin_box_->setRange(range_->first, range_->second);
+ if (step_)
+ spin_box_->setSingleStep(*step_);
- if (value) {
- _spin_box->setValue(g_variant_get_double(value));
- g_variant_unref(value);
- }
+ spin_box_->setValue(value);
if (auto_commit)
if (auto_commit)
- connect(
_spin_box
, SIGNAL(valueChanged(double)),
+ connect(
spin_box_
, SIGNAL(valueChanged(double)),
this, SLOT(on_value_changed(double)));
this, SLOT(on_value_changed(double)));
- return
_spin_box
;
+ return
spin_box_
;
}
void Double::commit()
{
}
void Double::commit()
{
- assert(
_setter
);
+ assert(
setter_
);
- if (!
_spin_box
)
+ if (!
spin_box_
)
return;
return;
-
_setter(g_variant_new_double(_spin_box
->value()));
+
setter_(Glib::Variant<double>::create(spin_box_
->value()));
}
void Double::on_value_changed(double)
}
void Double::on_value_changed(double)