1
//---------------------------------------------------------------------------
3
// Project: OpenWalnut ( http://www.openwalnut.org )
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
6
// For more information see http://www.openwalnut.org/copying
8
// This file is part of OpenWalnut.
10
// OpenWalnut is free software: you can redistribute it and/or modify
11
// it under the terms of the GNU Lesser General Public License as published by
12
// the Free Software Foundation, either version 3 of the License, or
13
// (at your option) any later version.
15
// OpenWalnut is distributed in the hope that it will be useful,
16
// but WITHOUT ANY WARRANTY; without even the implied warranty of
17
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18
// GNU Lesser General Public License for more details.
20
// You should have received a copy of the GNU Lesser General Public License
21
// along with OpenWalnut. If not, see <http://www.gnu.org/licenses/>.
23
//---------------------------------------------------------------------------
25
#include "../WGuiConsts.h"
26
#include "core/common/WAssert.h"
27
#include "WPropertyStructWidget.h"
28
#include "WPropertyStructWidget.moc"
30
WPropertyStructWidget::WPropertyStructWidget( WPropertyGroupBase::SPtr property, QGridLayout* propertyGrid, QWidget* parent ):
31
WPropertyWidget( property, propertyGrid, parent ),
33
m_layout( &m_parameterWidgets )
35
// although we could also work with other group types, we limit this widget to PV_STRUCT properties, because they have fixed size and cannot
36
// be modified somehow. If you remove this assert, ensure the widget is able to handle dynamic updates in the group!
37
WAssert( property->getType() == PV_STRUCT, "WPropertyStructWidget is only compatible with WPropertyStruct instances." );
39
// go through the widgets
40
WPropertyGroupBase::PropertySharedContainerType::ReadTicket r = property->getProperties();
41
for( WPropertyGroupBase::PropertyConstIterator iter = r->get().begin(); iter != r->get().end(); ++iter )
43
WAssert( ( *iter )->getType() != PV_GROUP, "WPropertyStructWidget does not support PV_GROUP properties in a struct." );
45
// create the widget. Leave the control layout NULL to only get the info widget and parameter widget without label
46
WPropertyWidget* w = WPropertyWidget::construct( *iter, NULL, this );
47
WAssert( w, "WPropertyStructWidget does not support other unsupported properties in a struct." );
50
m_layout.addWidget( w );
52
// store the list of widgets to later forward the update calls
53
m_widgets.push_back( w );
56
// layout both against each other
57
m_layout.setMargin( WGLOBAL_MARGIN );
58
m_layout.setSpacing( WGLOBAL_SPACING );
59
m_parameterWidgets.setLayout( &m_layout );
61
// NOTE: an info layout is not needed. This is automatically done by the child widgets
64
WPropertyStructWidget::~WPropertyStructWidget()
69
void WPropertyStructWidget::update()
71
for( WidgetList::const_iterator iter = m_widgets.begin(); iter != m_widgets.end(); ++iter )
73
( *iter )->requestUpdate();