From 479bcabe6b4d0b1f51984085d9944ce6b03ed07c Mon Sep 17 00:00:00 2001 From: Joel Holdsworth Date: Sun, 7 Apr 2013 20:20:55 +0100 Subject: [PATCH 1/1] Moved get_property_form out of pv::prop::binding::Binding --- pv/dialogs/deviceoptions.cpp | 35 ++++++++++++++++++++++++++++-- pv/dialogs/deviceoptions.h | 3 +++ pv/prop/binding/binding.cpp | 41 ++---------------------------------- pv/prop/binding/binding.h | 7 +----- 4 files changed, 39 insertions(+), 47 deletions(-) diff --git a/pv/dialogs/deviceoptions.cpp b/pv/dialogs/deviceoptions.cpp index e6b2f847..39e41b58 100644 --- a/pv/dialogs/deviceoptions.cpp +++ b/pv/dialogs/deviceoptions.cpp @@ -20,8 +20,16 @@ #include "deviceoptions.h" +#include + +#include #include +#include + +using namespace boost; +using namespace std; + namespace pv { namespace dialogs { @@ -66,7 +74,7 @@ DeviceOptions::DeviceOptions(QWidget *parent, struct sr_dev_inst *sdi) : _props_box.setLayout(&_props_box_layout); - _props_box_layout.addWidget(_device_options_binding.get_form(this)); + _props_box_layout.addWidget(get_property_form()); _layout.addWidget(&_props_box); _layout.addWidget(&_button_box); @@ -89,7 +97,30 @@ void DeviceOptions::accept() } // Commit the properties - _device_options_binding.commit(); + 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; } void DeviceOptions::setup_probes() diff --git a/pv/dialogs/deviceoptions.h b/pv/dialogs/deviceoptions.h index 059d336e..4753bfd0 100644 --- a/pv/dialogs/deviceoptions.h +++ b/pv/dialogs/deviceoptions.h @@ -45,6 +45,9 @@ 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 3b15f5a9..7d38cb46 100644 --- a/pv/prop/binding/binding.cpp +++ b/pv/prop/binding/binding.cpp @@ -18,52 +18,15 @@ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA */ -#include -#include - -#include - #include "binding.h" -#include - -using namespace boost; - namespace pv { namespace prop { namespace binding { -Binding::Binding() : - _form(NULL) -{ -} - -QWidget* Binding::get_form(QWidget *parent) -{ - if (_form) - return _form; - - _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; -} - -void Binding::commit() +const std::vector< boost::shared_ptr >& Binding::properties() { - BOOST_FOREACH(shared_ptr p, _properties) - { - assert(p); - p->commit(); - } + return _properties; } } // binding diff --git a/pv/prop/binding/binding.h b/pv/prop/binding/binding.h index f0b06ae2..7bb3238b 100644 --- a/pv/prop/binding/binding.h +++ b/pv/prop/binding/binding.h @@ -36,12 +36,7 @@ namespace binding { class Binding { public: - Binding(); - -public: - QWidget* get_form(QWidget *parent); - - void commit(); + const std::vector< boost::shared_ptr >& properties(); protected: std::vector< boost::shared_ptr > _properties; -- 2.30.2