]> sigrok.org Git - pulseview.git/commitdiff
Moved form generation into Binding
authorJoel Holdsworth <redacted>
Fri, 6 Sep 2013 13:46:33 +0000 (14:46 +0100)
committerJoel Holdsworth <redacted>
Sun, 29 Sep 2013 14:56:12 +0000 (23:56 +0900)
pv/dialogs/deviceoptions.cpp
pv/dialogs/deviceoptions.h
pv/prop/binding/binding.cpp
pv/prop/binding/binding.h

index 39e41b589acfea3b110623cbf7cc310c7ef7ef5c..fe21c9a42b6ee49fef94125fc62ff0187a3f81fd 100644 (file)
@@ -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<pv::prop::Property> > &properties =
-               _device_options_binding.properties();
-       BOOST_FOREACH(shared_ptr<pv::prop::Property> 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<pv::prop::Property> > &properties =
-               _device_options_binding.properties();
-       BOOST_FOREACH(shared_ptr<pv::prop::Property> 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()
index 4753bfd02644ce1a25d7b19c3877aebe4a3f59e4..059d336e78e246328c933ad8f0e762fe592fe155 100644 (file)
@@ -45,9 +45,6 @@ protected:
        void accept();
 
 private:
-
-       QWidget* get_property_form();
-
        void setup_probes();
 
        void set_all_probes(bool set);
index 7d38cb4629b5498c5d9cd0bc92dd4982909b8177..3c9bba5aee16483c14596def207d5ca6d0b0249b 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
+#include <boost/foreach.hpp>
+
+#include <QFormLayout>
+
+#include <pv/prop/property.h>
+
 #include "binding.h"
 
+using namespace boost;
+
 namespace pv {
 namespace prop {
 namespace binding {
@@ -29,6 +37,30 @@ const std::vector< boost::shared_ptr<Property> >& Binding::properties()
        return _properties;
 }
 
+void Binding::commit()
+{
+       BOOST_FOREACH(shared_ptr<pv::prop::Property> 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<pv::prop::Property> 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
index 7bb3238b09ffbbf0bfbcefd2f12612d3d6fdcf38..bdc4487b62c663429d64783366dc4c72dab66a39 100644 (file)
@@ -38,10 +38,12 @@ class Binding
 public:
        const std::vector< boost::shared_ptr<Property> >& properties();
 
+       void commit();
+
+       QWidget* get_property_form(QWidget *parent) const;
+
 protected:
        std::vector< boost::shared_ptr<Property> > _properties;
-
-       QWidget *_form;
 };
 
 } // binding