X-Git-Url: https://sigrok.org/gitweb/?p=pulseview.git;a=blobdiff_plain;f=pv%2Fprop%2Fstring.cpp;h=7fcc656958b9fed74d6f91c89f29e2ebe58d429e;hp=b9de789b90298042104bd0b60b2ea94e8bd45668;hb=a28c30252fd32d3185c62062dfad74ae659ae383;hpb=7112a4581822c43241a55fbd61c98bee062d452b diff --git a/pv/prop/string.cpp b/pv/prop/string.cpp index b9de789b..7fcc6569 100644 --- a/pv/prop/string.cpp +++ b/pv/prop/string.cpp @@ -20,13 +20,11 @@ #include +#include #include #include "string.h" -using namespace std; -using namespace boost; - namespace pv { namespace prop { @@ -38,19 +36,23 @@ String::String(QString name, { } -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; } @@ -66,5 +68,10 @@ void String::commit() _setter(g_variant_new_string(ba.data())); } +void String::on_text_edited(const QString&) +{ + commit(); +} + } // prop } // pv