Commit e1ad61ec authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] - prepared property widgets to be more general -> allow them to be...

[CHANGE] - prepared property widgets to be more general -> allow them to be extended to the new information properties
parent 874c5d92
......@@ -29,9 +29,9 @@
WPropertyBoolWidget::WPropertyBoolWidget( WPropBool property, QGridLayout* propertyGrid, QWidget* parent, bool asButton ):
WPropertyWidget( property, propertyGrid, parent ),
m_boolProperty( property ),
m_checkbox( this ),
m_button( this ),
m_layout(),
m_checkbox( &m_parameterWidgets ),
m_button( &m_parameterWidgets ),
m_layout( &m_parameterWidgets ),
m_asButton( asButton )
{
// initialize members
......@@ -47,7 +47,7 @@ WPropertyBoolWidget::WPropertyBoolWidget( WPropBool property, QGridLayout* prope
{
m_layout.setContentsMargins( 1, 1, 1, 1 );
}
setLayout( &m_layout );
m_parameterWidgets.setLayout( &m_layout );
// connect the modification signal of m_checkbox with our callback
connect( &m_checkbox, SIGNAL( toggled( bool ) ), this, SLOT( changed() ) );
......
......@@ -37,11 +37,11 @@
WPropertyColorWidget::WPropertyColorWidget( WPropColor property, QGridLayout* propertyGrid, QWidget* parent ):
WPropertyWidget( property, propertyGrid, parent ),
m_colorProperty( property ),
m_button( this ),
m_button( &m_parameterWidgets ),
m_layout()
{
// initialize members
setLayout( &m_layout );
m_parameterWidgets.setLayout( &m_layout );
// layout both against each other
m_layout.addWidget( &m_button );
......
......@@ -35,11 +35,11 @@
WPropertyDoubleWidget::WPropertyDoubleWidget( WPropDouble property, QGridLayout* propertyGrid, QWidget* parent ):
WPropertyWidget( property, propertyGrid, parent ),
m_doubleProperty( property ),
m_spin( this ),
m_layout()
m_spin( &m_parameterWidgets ),
m_layout( &m_parameterWidgets )
{
// initialize members
setLayout( &m_layout );
m_parameterWidgets.setLayout( &m_layout );
// layout both against each other
m_layout.addWidget( &m_spin );
......
......@@ -38,11 +38,11 @@
WPropertyFilenameWidget::WPropertyFilenameWidget( WPropFilename property, QGridLayout* propertyGrid, QWidget* parent ):
WPropertyWidget( property, propertyGrid, parent ),
m_fnProperty( property ),
m_button( this ),
m_layout()
m_button( &m_parameterWidgets ),
m_layout( &m_parameterWidgets )
{
// initialize members
setLayout( &m_layout );
m_parameterWidgets.setLayout( &m_layout );
// layout both against each other
m_layout.addWidget( &m_button );
......
......@@ -37,19 +37,20 @@
WPropertyIntWidget::WPropertyIntWidget( WPropInt property, QGridLayout* propertyGrid, QWidget* parent ):
WPropertyWidget( property, propertyGrid, parent ),
m_intProperty( property ),
m_slider( Qt::Horizontal, this ),
m_edit( this ),
m_layout( this )
m_slider( Qt::Horizontal, &m_parameterWidgets ),
m_edit( &m_parameterWidgets ),
m_layout( &m_parameterWidgets )
{
// initialize members
m_edit.resize( m_edit.minimumSizeHint().width() , m_edit.size().height() );
m_edit.setMaximumWidth( m_edit.minimumSizeHint().width() );
setLayout( &m_layout );
// layout both against each other
m_layout.addWidget( &m_slider );
m_layout.addWidget( &m_edit );
m_parameterWidgets.setLayout( &m_layout );
update();
// connect the modification signal of the edit and slider with our callback
......@@ -111,6 +112,7 @@ void WPropertyIntWidget::update()
// resize the text widget
m_edit.setMaxLength( length );
m_edit.setMaximumWidth( m_edit.minimumSizeHint().width() * length / 2 );
m_edit.setMinimumWidth( m_edit.minimumSizeHint().width() * length / 2 );
m_edit.resize( m_edit.minimumSizeHint().width() * length / 2, m_edit.size().height() );
// set the initial values
......
......@@ -35,11 +35,11 @@
WPropertyStringWidget::WPropertyStringWidget( WPropString property, QGridLayout* propertyGrid, QWidget* parent ):
WPropertyWidget( property, propertyGrid, parent ),
m_stringProperty( property ),
m_edit( this ),
m_layout( this )
m_edit( &m_parameterWidgets ),
m_layout( &m_parameterWidgets )
{
// initialize members
setLayout( &m_layout );
m_parameterWidgets.setLayout( &m_layout );
// layout
m_layout.addWidget( &m_edit );
......
......@@ -29,8 +29,8 @@
WPropertyTriggerWidget::WPropertyTriggerWidget( WPropTrigger property, QGridLayout* propertyGrid, QWidget* parent ):
WPropertyWidget( property, propertyGrid, parent ),
m_triggerProperty( property ),
m_button( this ),
m_layout()
m_button( &m_parameterWidgets ),
m_layout( &m_parameterWidgets )
{
// initialize members
m_button.setCheckable( true );
......@@ -41,7 +41,7 @@ WPropertyTriggerWidget::WPropertyTriggerWidget( WPropTrigger property, QGridLayo
m_button.setText( QString::fromStdString( property->getDescription() ) );
m_layout.setContentsMargins( 1, 1, 1, 1 );
setLayout( &m_layout );
m_parameterWidgets.setLayout( &m_layout );
// connect the modification signal of m_checkbox with our callback
connect( &m_button, SIGNAL( toggled( bool ) ), this, SLOT( changed() ) );
......
......@@ -32,11 +32,12 @@
#include "WPropertyWidget.h"
WPropertyWidget::WPropertyWidget( boost::shared_ptr< WPropertyBase > property, QGridLayout* propertyGrid, QWidget* parent ):
QWidget( parent ),
QStackedWidget( parent ),
m_property( property ),
m_propertyGrid( propertyGrid ),
m_label( this ),
m_useLabel( m_propertyGrid ),
m_parameterWidgets(), // parent gets set by the QStackWidget
m_invalid( false )
{
if ( m_useLabel )
......@@ -53,6 +54,8 @@ WPropertyWidget::WPropertyWidget( boost::shared_ptr< WPropertyBase > property,
m_propertyGrid->addWidget( this, row, 1 );
}
addWidget( &m_parameterWidgets );
// setup the update callback
m_connection = m_property->getUpdateCondition()->subscribeSignal( boost::bind( &WPropertyWidget::propertyChangeNotifier, this ) );
}
......
......@@ -30,6 +30,7 @@
#include <boost/shared_ptr.hpp>
#include <QtGui/QWidget>
#include <QtGui/QStackedWidget>
#include <QtGui/QLabel>
#include <QtGui/QGridLayout>
......@@ -39,7 +40,7 @@
/**
* Class building the base for all widgets representing properties. It simply contains the handled property object.
*/
class WPropertyWidget: public QWidget
class WPropertyWidget: public QStackedWidget
{
Q_OBJECT
......@@ -107,6 +108,11 @@ protected:
*/
bool m_useLabel;
/**
* The widget containing a layout and provides the edit widgets for the property.
*/
QWidget m_parameterWidgets;
/**
* Flag denoting whether the widget is set to an invalid value.
*/
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment