~ubuntu-branches/ubuntu/raring/openwalnut/raring

« back to all changes in this revision

Viewing changes to src/qt4gui/controlPanel/WPropertyStructWidget.cpp

  • Committer: Package Import Robot
  • Author(s): Sebastian Eichelbaum
  • Date: 2012-12-12 11:26:32 UTC
  • mfrom: (3.1.1 sid)
  • Revision ID: package-import@ubuntu.com-20121212112632-xhiuwkxuz5h0idkh
Tags: 1.3.1+hg5849-1
* Minor changes compared to 1.3.0 but included several bug fixes.
* See http://www.openwalnut.org/versions/4

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
//---------------------------------------------------------------------------
 
2
//
 
3
// Project: OpenWalnut ( http://www.openwalnut.org )
 
4
//
 
5
// Copyright 2009 OpenWalnut Community, BSV@Uni-Leipzig and CNCF@MPI-CBS
 
6
// For more information see http://www.openwalnut.org/copying
 
7
//
 
8
// This file is part of OpenWalnut.
 
9
//
 
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.
 
14
//
 
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.
 
19
//
 
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/>.
 
22
//
 
23
//---------------------------------------------------------------------------
 
24
 
 
25
#include "../WGuiConsts.h"
 
26
#include "core/common/WAssert.h"
 
27
#include "WPropertyStructWidget.h"
 
28
#include "WPropertyStructWidget.moc"
 
29
 
 
30
WPropertyStructWidget::WPropertyStructWidget( WPropertyGroupBase::SPtr property, QGridLayout* propertyGrid, QWidget* parent ):
 
31
    WPropertyWidget( property, propertyGrid, parent ),
 
32
    m_struct( property ),
 
33
    m_layout( &m_parameterWidgets )
 
34
{
 
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." );
 
38
 
 
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 )
 
42
    {
 
43
        WAssert( ( *iter )->getType() != PV_GROUP, "WPropertyStructWidget does not support PV_GROUP properties in a struct." );
 
44
 
 
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." );
 
48
 
 
49
        // add the widgets
 
50
        m_layout.addWidget( w );
 
51
 
 
52
        // store the list of widgets to later forward the update calls
 
53
        m_widgets.push_back( w );
 
54
    }
 
55
 
 
56
    // layout both against each other
 
57
    m_layout.setMargin( WGLOBAL_MARGIN );
 
58
    m_layout.setSpacing( WGLOBAL_SPACING );
 
59
    m_parameterWidgets.setLayout( &m_layout );
 
60
 
 
61
    // NOTE: an info layout is not needed. This is automatically done by the child widgets
 
62
}
 
63
 
 
64
WPropertyStructWidget::~WPropertyStructWidget()
 
65
{
 
66
    // cleanup
 
67
}
 
68
 
 
69
void WPropertyStructWidget::update()
 
70
{
 
71
    for( WidgetList::const_iterator iter = m_widgets.begin(); iter != m_widgets.end(); ++iter )
 
72
    {
 
73
        ( *iter )->requestUpdate();
 
74
    }
 
75
}
 
76