Commit 7a774c97 authored by Sebastian Eichelbaum's avatar Sebastian Eichelbaum

[CHANGE] - property group widgets can now be collapsed

parent 5efa8aa5
......@@ -25,6 +25,7 @@
#include <string>
#include <QtGui/QGroupBox>
#include <QtGui/QPushButton>
#include <QtGui/QScrollArea>
#include "WQtDSBWidget.h"
......@@ -114,11 +115,11 @@ void WQtDSBWidget::addGroup( WQtDSBWidget* widget, bool asScrollArea )
{
++m_numberOfWidgets;
// TODO(ebaum): extend it to collapse the group
QGroupBox* group = new QGroupBox( widget->getName() , this );
// create a scrollbox and group box containing the widget
QWidget* group = new QWidget( this );
QScrollArea *scrollArea;
QGridLayout *grid = new QGridLayout();
QScrollArea* scrollArea;
QGridLayout* grid = new QGridLayout();
grid->addWidget( widget, 0, 0 );
group->setLayout( grid );
......@@ -129,17 +130,50 @@ void WQtDSBWidget::addGroup( WQtDSBWidget* widget, bool asScrollArea )
group->show();
}
// create a new group box
int row = m_controlLayout->rowCount();
// encapsulate it into an collapsable widget
QFrame* box = new QFrame( this );
box->setFrameShape( QFrame::StyledPanel );
box->setFrameShadow( QFrame::Raised );
QGridLayout* boxLayout = new QGridLayout( box );
// create a button as title
QPushButton* boxTitle = new QPushButton( this );
boxLayout->addWidget( boxTitle, 0, 0 );
// set the button up
QSizePolicy sizePolicy( QSizePolicy::Expanding, QSizePolicy::Fixed );
sizePolicy.setHorizontalStretch( 0 );
sizePolicy.setVerticalStretch( 0 );
sizePolicy.setHeightForWidth( boxTitle->sizePolicy().hasHeightForWidth() );
boxTitle->setSizePolicy( sizePolicy );
boxTitle->setCheckable( true );
boxTitle->setChecked( true );
boxTitle->setFlat( true );
QFont font;
font.setBold( true );
boxTitle->setFont( font );
boxTitle->setText( widget->getName() );
// toggle should cause the body widget to appear/disappear
connect( boxTitle, SIGNAL( toggled( bool ) ), group, SLOT( setVisible( bool ) ) );
// create a body widget
if ( asScrollArea )
{
m_controlLayout->addWidget( scrollArea, row, 0, 1, 2 );
boxLayout->addWidget( scrollArea, 1, 0 );
}
else
{
m_controlLayout->addWidget( group, row, 0, 1, 2 );
boxLayout->addWidget( group, 1, 0 );
}
// insert into layout
int row = m_controlLayout->rowCount();
m_controlLayout->addWidget( box, row, 0, 1, 2 );
}
void WQtDSBWidget::groupTitleToggled( bool checked, QWidget* widget )
{
}
void WQtDSBWidget::addSpacer()
......
......@@ -203,6 +203,16 @@ private:
* The number of widgets inside this one.
*/
unsigned int m_numberOfWidgets;
public slots:
/**
* Called whenever a group toggle button has been checked.
*
* \param checked true if checked
* \param widget the widget handled by the button
*/
void groupTitleToggled( bool checked, QWidget* widget );
};
#endif // WQTDSBWIDGET_H
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