#include <assert.h>
+#include <QLineEdit>
#include <QSpinBox>
#include "string.h"
-using namespace std;
-using namespace boost;
-
namespace pv {
namespace prop {
{
}
-QWidget* String::get_widget(QWidget *parent)
+QWidget* String::get_widget(QWidget *parent, bool auto_commit)
{
if (_line_edit)
return _line_edit;
+ GVariant *const value = _getter ? _getter() : NULL;
+ if (!value)
+ return NULL;
+
_line_edit = new QLineEdit(parent);
+ _line_edit->setText(QString::fromUtf8(
+ g_variant_get_string(value, NULL)));
+ g_variant_unref(value);
- GVariant *const value = _getter ? _getter() : NULL;
- if (value) {
- _line_edit->setText(QString(
- g_variant_get_string(value, NULL)));
- g_variant_unref(value);
- }
+ if (auto_commit)
+ connect(_line_edit, SIGNAL(textEdited(const QString&)),
+ this, SLOT(on_text_edited(const QString&)));
return _line_edit;
}
_setter(g_variant_new_string(ba.data()));
}
+void String::on_text_edited(const QString&)
+{
+ commit();
+}
+
} // prop
} // pv