OpenWalnut  1.5.0dev
WPropertyTriggerWidget.cpp
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/WPropertyVariable.h"
27 
28 #include "WPropertyTriggerWidget.h"
29 
30 WPropertyTriggerWidget::WPropertyTriggerWidget( WPropTrigger property, QGridLayout* propertyGrid, QWidget* parent ):
31  WPropertyWidget( property, propertyGrid, parent ),
32  m_triggerProperty( property ),
33  m_button( WPREFERRED_LABEL_LENGTH, &m_parameterWidgets ),
34  m_layout( &m_parameterWidgets ),
35  m_asText( WPREFERRED_LABEL_LENGTH, &m_informationWidgets ),
36  m_infoLayout( &m_informationWidgets )
37 {
38  // initialize members
39  m_button.setCheckable( true );
40  update();
41 
42  // layout both against each other
43  m_layout.addWidget( &m_button );
44  m_layout.setMargin( WGLOBAL_MARGIN );
45  m_layout.setSpacing( WGLOBAL_SPACING );
46  m_button.setText( QString::fromStdString( property->getDescription() ) );
47 
48  m_button.setMinimumHeight( WMIN_WIDGET_HEIGHT );
49 
50  m_parameterWidgets.setLayout( &m_layout );
51 
52  // Information Output ( Property Purpose = PV_PURPOSE_INFORMATION )
53  m_infoLayout.addWidget( &m_asText );
54  m_infoLayout.setMargin( WGLOBAL_MARGIN );
55  m_infoLayout.setSpacing( WGLOBAL_SPACING );
56  m_informationWidgets.setLayout( &m_infoLayout );
57 
58  // connect the modification signal of m_checkbox with our callback
59  connect( &m_button, SIGNAL( toggled( bool ) ), this, SLOT( changed() ) );
60 }
61 
63 {
64  // cleanup
65 }
66 
68 {
69  // simply set the new state
72 
73  // do not forget to update the label
74  m_asText.setText( m_triggerProperty->get() == WPVBaseTypes::PV_TRIGGER_TRIGGERED ? QString( "Operation triggered" ) : QString( "Ready" ) );
75 }
76 
78 {
79  // set the value
81 }
82 
virtual void update()
Called whenever the widget should update.
void changed()
called whenever the user modifies the widget
WPropertyTriggerWidget(WPropTrigger property, QGridLayout *propertyGrid, QWidget *parent=0)
Constructor.
QHBoxLayout m_layout
Layout used to position the label and the checkbox.
WPropTrigger m_triggerProperty
The boolean property represented by this widget.
virtual ~WPropertyTriggerWidget()
Destructor.
WScaleToolButton m_button
If asButton is set to true: use this button instead of the m_checkbox.
WScaleLabel m_asText
Used to show the property as text.
QHBoxLayout m_infoLayout
The layout used for the pure output (information properties)
Class building the base for all widgets representing properties.
QWidget m_informationWidgets
The widget containing a layout and provides the widgets for showing information properties.
QWidget m_parameterWidgets
The widget containing a layout and provides the edit widgets for the property.
virtual void invalidate(bool invalid=true)
This method marks this widget as invalid.
virtual void setText(const QString &text)
reimplemented function to setText
Definition: WScaleLabel.cpp:93
virtual void setText(const QString &text)
reimplemented function to setText
@ PV_TRIGGER_TRIGGERED
Trigger property: got triggered.
@ PV_TRIGGER_READY
Trigger property: is ready to be triggered (again)