From: Joel Holdsworth Date: Fri, 6 Sep 2013 13:46:33 +0000 (+0100) Subject: Moved form generation into Binding X-Git-Tag: pulseview-0.2.0~292 X-Git-Url: https://sigrok.org/gitaction?a=commitdiff_plain;h=8481fbdf89e8f26a0d5ef0b69e32d25be5e2f6e4;p=pulseview.git Moved form generation into Binding --- diff --git a/pv/dialogs/deviceoptions.cpp b/pv/dialogs/deviceoptions.cpp index 39e41b58..fe21c9a4 100644 --- a/pv/dialogs/deviceoptions.cpp +++ b/pv/dialogs/deviceoptions.cpp @@ -74,7 +74,8 @@ DeviceOptions::DeviceOptions(QWidget *parent, struct sr_dev_inst *sdi) : _props_box.setLayout(&_props_box_layout); - _props_box_layout.addWidget(get_property_form()); + _props_box_layout.addWidget( + _device_options_binding.get_property_form(this)); _layout.addWidget(&_props_box); _layout.addWidget(&_button_box); @@ -97,30 +98,7 @@ void DeviceOptions::accept() } // Commit the properties - const vector< shared_ptr > &properties = - _device_options_binding.properties(); - BOOST_FOREACH(shared_ptr p, properties) { - assert(p); - p->commit(); - } -} - -QWidget* DeviceOptions::get_property_form() -{ - QWidget *const form = new QWidget(this); - QFormLayout *const layout = new QFormLayout(form); - form->setLayout(layout); - - const vector< shared_ptr > &properties = - _device_options_binding.properties(); - BOOST_FOREACH(shared_ptr p, properties) - { - assert(p); - const QString label = p->labeled_widget() ? QString() : p->name(); - layout->addRow(label, p->get_widget(form)); - } - - return form; + _device_options_binding.commit(); } void DeviceOptions::setup_probes() diff --git a/pv/dialogs/deviceoptions.h b/pv/dialogs/deviceoptions.h index 4753bfd0..059d336e 100644 --- a/pv/dialogs/deviceoptions.h +++ b/pv/dialogs/deviceoptions.h @@ -45,9 +45,6 @@ protected: void accept(); private: - - QWidget* get_property_form(); - void setup_probes(); void set_all_probes(bool set); diff --git a/pv/prop/binding/binding.cpp b/pv/prop/binding/binding.cpp index 7d38cb46..3c9bba5a 100644 --- a/pv/prop/binding/binding.cpp +++ b/pv/prop/binding/binding.cpp @@ -18,8 +18,16 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ +#include + +#include + +#include + #include "binding.h" +using namespace boost; + namespace pv { namespace prop { namespace binding { @@ -29,6 +37,30 @@ const std::vector< boost::shared_ptr >& Binding::properties() return _properties; } +void Binding::commit() +{ + BOOST_FOREACH(shared_ptr p, _properties) { + assert(p); + p->commit(); + } +} + +QWidget* Binding::get_property_form(QWidget *parent) const +{ + QWidget *const form = new QWidget(parent); + QFormLayout *const layout = new QFormLayout(form); + form->setLayout(layout); + + BOOST_FOREACH(shared_ptr p, _properties) + { + assert(p); + const QString label = p->labeled_widget() ? QString() : p->name(); + layout->addRow(label, p->get_widget(form)); + } + + return form; +} + } // binding } // prop } // pv diff --git a/pv/prop/binding/binding.h b/pv/prop/binding/binding.h index 7bb3238b..bdc4487b 100644 --- a/pv/prop/binding/binding.h +++ b/pv/prop/binding/binding.h @@ -38,10 +38,12 @@ class Binding public: const std::vector< boost::shared_ptr >& properties(); + void commit(); + + QWidget* get_property_form(QWidget *parent) const; + protected: std::vector< boost::shared_ptr > _properties; - - QWidget *_form; }; } // binding