* Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
+#include <cassert>
+
+#include <QFormLayout>
+
+#include <pv/prop/property.h>
+
#include "binding.h"
+using std::shared_ptr;
+
namespace pv {
namespace prop {
namespace binding {
-const std::vector< boost::shared_ptr<Property> >& Binding::properties()
+const std::vector< std::shared_ptr<Property> >& Binding::properties()
{
return _properties;
}
+void Binding::commit()
+{
+ for (shared_ptr<pv::prop::Property> p : _properties) {
+ assert(p);
+ p->commit();
+ }
+}
+
+void Binding::add_properties_to_form(QFormLayout *layout,
+ bool auto_commit) const
+{
+ assert(layout);
+
+ for (shared_ptr<pv::prop::Property> p : _properties)
+ {
+ assert(p);
+
+ QWidget *const widget = p->get_widget(layout->parentWidget(),
+ auto_commit);
+ if (p->labeled_widget())
+ layout->addRow(widget);
+ else
+ layout->addRow(p->name(), widget);
+ }
+}
+
+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;
+}
+
+QString Binding::print_gvariant(Glib::VariantBase gvar)
+{
+ QString s;
+
+ if (!gvar.gobj())
+ s = QString::fromStdString("(null)");
+ else if (gvar.is_of_type(Glib::VariantType("s")))
+ s = QString::fromStdString(
+ Glib::VariantBase::cast_dynamic<Glib::Variant<std::string>>(
+ gvar).get());
+ else
+ s = QString::fromStdString(gvar.print());
+
+ return s;
+}
+
} // binding
} // prop
} // pv