X-Git-Url: https://sigrok.org/gitweb/?a=blobdiff_plain;f=pv%2Fprop%2Fbinding%2Fbinding.cpp;h=ec3127254b71c8e82085b4cb0f802020c65e2aa0;hb=636782c1f942d1acdb56a0561c2e0fd52cc39ddb;hp=e75b9556d638054b141a346125587e24f04e1b2b;hpb=c8df600577e9c7b1ca90baf6bd01ccc980f89464;p=pulseview.git diff --git a/pv/prop/binding/binding.cpp b/pv/prop/binding/binding.cpp index e75b9556..ec312725 100644 --- a/pv/prop/binding/binding.cpp +++ b/pv/prop/binding/binding.cpp @@ -18,42 +18,59 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include - #include -#include "binding.h" +#include #include -using namespace boost; +#include "binding.h" + +using boost::shared_ptr; namespace pv { namespace prop { namespace binding { -Binding::Binding() : - _form(NULL) +const std::vector< boost::shared_ptr >& Binding::properties() { + return _properties; } -QWidget* Binding::get_form(QWidget *parent) +void Binding::commit() { - if(_form) - return _form; + BOOST_FOREACH(shared_ptr p, _properties) { + assert(p); + p->commit(); + } +} - _form = new QWidget(parent); - QFormLayout *const layout = new QFormLayout(_form); - _form->setLayout(layout); +void Binding::add_properties_to_form(QFormLayout *layout, + bool auto_commit) const +{ + assert(layout); - BOOST_FOREACH(shared_ptr p, _properties) + BOOST_FOREACH(shared_ptr p, _properties) { assert(p); - layout->addRow(p->name(), p->get_widget(_form)); + + QWidget *const widget = p->get_widget(layout->parentWidget(), + auto_commit); + if (p->labeled_widget()) + layout->addRow(widget); + else + layout->addRow(p->name(), widget); } +} - return _form; +QWidget* Binding::get_property_form(QWidget *parent, + bool auto_commit) const +{ + QWidget *const form = new QWidget(parent); + QFormLayout *const layout = new QFormLayout(form); + form->setLayout(layout); + add_properties_to_form(layout, auto_commit); + return form; } } // binding