]> sigrok.org Git - pulseview.git/commitdiff
Moved get_property_form out of pv::prop::binding::Binding
authorJoel Holdsworth <redacted>
Sun, 7 Apr 2013 19:20:55 +0000 (20:20 +0100)
committerJoel Holdsworth <redacted>
Mon, 8 Apr 2013 18:08:18 +0000 (19:08 +0100)
pv/dialogs/deviceoptions.cpp
pv/dialogs/deviceoptions.h
pv/prop/binding/binding.cpp
pv/prop/binding/binding.h

index e6b2f847d12969f15d78ffa01cbd89e0a8ef337b..39e41b589acfea3b110623cbf7cc310c7ef7ef5c 100644 (file)
 
 #include "deviceoptions.h"
 
+#include <boost/foreach.hpp>
+
+#include <QFormLayout>
 #include <QListWidget>
 
+#include <pv/prop/property.h>
+
+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<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;
 }
 
 void DeviceOptions::setup_probes()
index 059d336e78e246328c933ad8f0e762fe592fe155..4753bfd02644ce1a25d7b19c3877aebe4a3f59e4 100644 (file)
@@ -45,6 +45,9 @@ protected:
        void accept();
 
 private:
+
+       QWidget* get_property_form();
+
        void setup_probes();
 
        void set_all_probes(bool set);
index 3b15f5a9ebfed1858258461b63bb0b33c62ba15c..7d38cb4629b5498c5d9cd0bc92dd4982909b8177 100644 (file)
  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301 USA
  */
 
-#include <QFormLayout>
-#include <QWidget>
-
-#include <boost/foreach.hpp>
-
 #include "binding.h"
 
-#include <pv/prop/property.h>
-
-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<Property> 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<Property> >& Binding::properties()
 {
-       BOOST_FOREACH(shared_ptr<Property> p, _properties)
-       {
-               assert(p);
-               p->commit();
-       }
+       return _properties;
 }
 
 } // binding
index f0b06ae288daed7dad5677aeae30028bf0362cb3..7bb3238b09ffbbf0bfbcefd2f12612d3d6fdcf38 100644 (file)
@@ -36,12 +36,7 @@ namespace binding {
 class Binding
 {
 public:
-       Binding();
-
-public:
-       QWidget* get_form(QWidget *parent);
-
-       void commit();
+       const std::vector< boost::shared_ptr<Property> >& properties();
 
 protected:
        std::vector< boost::shared_ptr<Property> > _properties;