#include "bool.h"
-using namespace std;
-using namespace boost;
-
namespace pv {
namespace prop {
{
}
-QWidget* Bool::get_widget(QWidget *parent)
+QWidget* Bool::get_widget(QWidget *parent, bool auto_commit)
{
if (_check_box)
return _check_box;
- _check_box = new QCheckBox(name(), parent);
-
GVariant *const value = _getter ? _getter() : NULL;
+ if (!value)
+ return NULL;
+
+ _check_box = new QCheckBox(name(), parent);
+ _check_box->setCheckState(g_variant_get_boolean(value) ?
+ Qt::Checked : Qt::Unchecked);
+ g_variant_unref(value);
- if (value) {
- _check_box->setCheckState(g_variant_get_boolean(value) ?
- Qt::Checked : Qt::Unchecked);
- g_variant_unref(value);
- }
+ if (auto_commit)
+ connect(_check_box, SIGNAL(stateChanged(int)),
+ this, SLOT(on_state_changed(int)));
return _check_box;
}
_check_box->checkState() == Qt::Checked));
}
+void Bool::on_state_changed(int)
+{
+ commit();
+}
+
} // prop
} // pv