]> sigrok.org Git - pulseview.git/blame - pv/prop/binding/binding.cpp
Moved form generation into Binding
[pulseview.git] / pv / prop / binding / binding.cpp
CommitLineData
c8df6005
JH
1/*
2 * This file is part of the PulseView project.
3 *
4 * Copyright (C) 2012 Joel Holdsworth <joel@airwebreathe.org.uk>
5 *
6 * This program is free software; you can redistribute it and/or modify
7 * it under the terms of the GNU General Public License as published by
8 * the Free Software Foundation; either version 2 of the License, or
9 * (at your option) any later version.
10 *
11 * This program is distributed in the hope that it will be useful,
12 * but WITHOUT ANY WARRANTY; without even the implied warranty of
13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14 * GNU General Public License for more details.
15 *
16 * You should have received a copy of the GNU General Public License
17 * along with this program; if not, write to the Free Software
18 * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
19 */
20
8481fbdf
JH
21#include <boost/foreach.hpp>
22
23#include <QFormLayout>
24
25#include <pv/prop/property.h>
26
c8df6005
JH
27#include "binding.h"
28
8481fbdf
JH
29using namespace boost;
30
c8df6005
JH
31namespace pv {
32namespace prop {
33namespace binding {
34
479bcabe 35const std::vector< boost::shared_ptr<Property> >& Binding::properties()
3a69ef6b 36{
479bcabe 37 return _properties;
3a69ef6b
JH
38}
39
8481fbdf
JH
40void Binding::commit()
41{
42 BOOST_FOREACH(shared_ptr<pv::prop::Property> p, _properties) {
43 assert(p);
44 p->commit();
45 }
46}
47
48QWidget* Binding::get_property_form(QWidget *parent) const
49{
50 QWidget *const form = new QWidget(parent);
51 QFormLayout *const layout = new QFormLayout(form);
52 form->setLayout(layout);
53
54 BOOST_FOREACH(shared_ptr<pv::prop::Property> p, _properties)
55 {
56 assert(p);
57 const QString label = p->labeled_widget() ? QString() : p->name();
58 layout->addRow(label, p->get_widget(form));
59 }
60
61 return form;
62}
63
c8df6005
JH
64} // binding
65} // prop
66} // pv