Fix QgsCollapsibleGroupBox signal and scrolling issue

- Signal now passes pointer to custom widget; calling isCollapsed() now works in connected slot
- Keep expanded group boxes in scroll areas from scrolling on first showing of dialog
This commit is contained in:
Larry Shaffer 2012-09-14 19:31:08 -06:00
parent 2edbc04876
commit 8f0cb990ae
2 changed files with 7 additions and 6 deletions

View File

@ -85,7 +85,6 @@ void QgsCollapsibleGroupBox::showEvent( QShowEvent * event )
event->accept();
return;
}
mShown = true;
// check if groupbox was set to flat in Designer or in code
mInitFlat = isFlat();
@ -111,11 +110,12 @@ void QgsCollapsibleGroupBox::showEvent( QShowEvent * event )
}
else
{
/* manually expanding (already default) on show may scroll scroll areas;
still emit signal for connections using expanded state */
// emit signal for connections using expanded state
emit collapsedStateChanged( this );
}
// set mShown after first setCollapsed call or expanded groupboxes
// will scroll scroll areas when first shown
mShown = true;
event->accept();
}
@ -292,7 +292,7 @@ void QgsCollapsibleGroupBox::setCollapsed( bool collapse )
mCollapseButton->setIcon( collapse ? mExpandIcon : mCollapseIcon );
// if expanding and is in a QScrollArea, scroll down to make entire widget visible
if ( mScrollOnExpand && !collapse && mParentScrollArea )
if ( mShown && mScrollOnExpand && !collapse && mParentScrollArea )
{
// process events so entire widget is shown
QApplication::processEvents();

View File

@ -48,7 +48,8 @@ class GUI_EXPORT QgsCollapsibleGroupBox : public QGroupBox
void setScrollOnExpand( bool scroll ) { mScrollOnExpand = scroll; }
signals:
void collapsedStateChanged( QWidget* );
/** Signal emitted when groupbox collapsed/expanded state is changed, and when first shown */
void collapsedStateChanged( QgsCollapsibleGroupBox* );
public slots:
void checkToggled( bool ckd );