QGIS API Documentation  master-6227475
src/gui/qgscollapsiblegroupbox.cpp
Go to the documentation of this file.
00001 /***************************************************************************
00002                           qgscollapsiblegroupbox.cpp
00003                              -------------------
00004     begin                : August 2012
00005     copyright            : (C) 2012 by Etienne Tourigny
00006     email                : etourigny dot dev at gmail dot com
00007  ***************************************************************************/
00008 
00009 /***************************************************************************
00010  *                                                                         *
00011  *   This program is free software; you can redistribute it and/or modify  *
00012  *   it under the terms of the GNU General Public License as published by  *
00013  *   the Free Software Foundation; either version 2 of the License, or     *
00014  *   (at your option) any later version.                                   *
00015  *                                                                         *
00016  ***************************************************************************/
00017 
00018 #include "qgscollapsiblegroupbox.h"
00019 
00020 #include "qgsapplication.h"
00021 #include "qgslogger.h"
00022 
00023 #include <QToolButton>
00024 #include <QMouseEvent>
00025 #include <QPushButton>
00026 #include <QStyleOptionGroupBox>
00027 #include <QSettings>
00028 #include <QScrollArea>
00029 
00030 QIcon QgsCollapsibleGroupBoxBasic::mCollapseIcon;
00031 QIcon QgsCollapsibleGroupBoxBasic::mExpandIcon;
00032 
00033 QgsCollapsibleGroupBoxBasic::QgsCollapsibleGroupBoxBasic( QWidget *parent )
00034     : QGroupBox( parent )
00035 {
00036   init();
00037 }
00038 
00039 QgsCollapsibleGroupBoxBasic::QgsCollapsibleGroupBoxBasic( const QString &title,
00040     QWidget *parent )
00041     : QGroupBox( title, parent )
00042 {
00043   init();
00044 }
00045 
00046 QgsCollapsibleGroupBoxBasic::~QgsCollapsibleGroupBoxBasic()
00047 {
00048   //QgsDebugMsg( "Entered" );
00049 }
00050 
00051 void QgsCollapsibleGroupBoxBasic::init()
00052 {
00053   //QgsDebugMsg( "Entered" );
00054   // variables
00055   mCollapsed = false;
00056   mInitFlat = false;
00057   mInitFlatChecked = false;
00058   mScrollOnExpand = true;
00059   mShown = false;
00060   mParentScrollArea = 0;
00061   mSyncParent = 0;
00062   mSyncGroup = "";
00063   mAltDown = false;
00064   mShiftDown = false;
00065   mTitleClicked = false;
00066 
00067   // init icons
00068   if ( mCollapseIcon.isNull() )
00069   {
00070     mCollapseIcon = QgsApplication::getThemeIcon( "/mIconCollapse.png" );
00071     mExpandIcon = QgsApplication::getThemeIcon( "/mIconExpand.png" );
00072   }
00073 
00074   // collapse button
00075   mCollapseButton = new QgsGroupBoxCollapseButton( this );
00076   mCollapseButton->setObjectName( "collapseButton" );
00077   mCollapseButton->setAutoRaise( true );
00078   mCollapseButton->setFixedSize( 16, 16 );
00079   // TODO set size (as well as margins) depending on theme, in updateStyle()
00080   mCollapseButton->setIconSize( QSize( 12, 12 ) );
00081   mCollapseButton->setIcon( mCollapseIcon );
00082 
00083   connect( mCollapseButton, SIGNAL( clicked() ), this, SLOT( toggleCollapsed() ) );
00084   connect( this, SIGNAL( toggled( bool ) ), this, SLOT( checkToggled( bool ) ) );
00085   connect( this, SIGNAL( clicked( bool ) ), this, SLOT( checkClicked( bool ) ) );
00086 }
00087 
00088 void QgsCollapsibleGroupBoxBasic::showEvent( QShowEvent * event )
00089 {
00090   //QgsDebugMsg( "Entered" );
00091   // initialise widget on first show event only
00092   if ( mShown )
00093   {
00094     event->accept();
00095     return;
00096   }
00097 
00098   // check if groupbox was set to flat in Designer or in code
00099   if ( !mInitFlatChecked )
00100   {
00101     mInitFlat = isFlat();
00102     mInitFlatChecked = true;
00103   }
00104 
00105   // find parent QScrollArea - this might not work in complex layouts - should we look deeper?
00106   if ( parent() && parent()->parent() )
00107     mParentScrollArea = dynamic_cast<QScrollArea*>( parent()->parent()->parent() );
00108   else
00109     mParentScrollArea = 0;
00110   if ( mParentScrollArea )
00111   {
00112     QgsDebugMsg( "found a QScrollArea parent: " + mParentScrollArea->objectName() );
00113   }
00114   else
00115   {
00116     QgsDebugMsg( "did not find a QScrollArea parent" );
00117   }
00118 
00119   updateStyle();
00120 
00121   // expand if needed - any calls to setCollapsed() before only set mCollapsed, but have UI effect
00122   if ( mCollapsed )
00123   {
00124     setCollapsed( mCollapsed );
00125   }
00126   else
00127   {
00128     // emit signal for connections using collapsed state
00129     emit collapsedStateChanged( isCollapsed() );
00130   }
00131 
00132   // verify triangle mirrors groupbox's enabled state
00133   mCollapseButton->setEnabled( isEnabled() );
00134 
00135   // set mShown after first setCollapsed call or expanded groupboxes
00136   // will scroll scroll areas when first shown
00137   mShown = true;
00138   event->accept();
00139 }
00140 
00141 void QgsCollapsibleGroupBoxBasic::mousePressEvent( QMouseEvent *event )
00142 {
00143   // avoid leaving checkbox in pressed state if alt- or shift-clicking
00144   if ( event->modifiers() & ( Qt::AltModifier | Qt::ControlModifier | Qt::ShiftModifier )
00145        && titleRect().contains( event->pos() )
00146        && isCheckable() )
00147   {
00148     event->ignore();
00149     return;
00150   }
00151 
00152   // default behaviour - pass to QGroupBox
00153   QGroupBox::mousePressEvent( event );
00154 }
00155 
00156 void QgsCollapsibleGroupBoxBasic::mouseReleaseEvent( QMouseEvent *event )
00157 {
00158   mAltDown = ( event->modifiers() & ( Qt::AltModifier | Qt::ControlModifier ) );
00159   mShiftDown = ( event->modifiers() & Qt::ShiftModifier );
00160   mTitleClicked = ( titleRect().contains( event->pos() ) );
00161 
00162   // sync group when title is alt-clicked
00163   // collapse/expand when title is clicked and non-checkable
00164   // expand current and collapse others on shift-click
00165   if ( event->button() == Qt::LeftButton && mTitleClicked &&
00166        ( mAltDown || mShiftDown || !isCheckable() ) )
00167   {
00168     toggleCollapsed();
00169     return;
00170   }
00171 
00172   // default behaviour - pass to QGroupBox
00173   QGroupBox::mouseReleaseEvent( event );
00174 }
00175 
00176 void QgsCollapsibleGroupBoxBasic::changeEvent( QEvent *event )
00177 {
00178   // always re-enable mCollapseButton when groupbox was previously disabled
00179   // e.g. resulting from a disabled parent of groupbox, or a signal/slot connection
00180 
00181   // default behaviour - pass to QGroupBox
00182   QGroupBox::changeEvent( event );
00183 
00184   if ( event->type() == QEvent::EnabledChange && isEnabled() )
00185     mCollapseButton->setEnabled( true );
00186 }
00187 
00188 void QgsCollapsibleGroupBoxBasic::setSyncGroup( QString grp )
00189 {
00190   mSyncGroup = grp;
00191   QString tipTxt = QString( "" );
00192   if ( !grp.isEmpty() )
00193   {
00194     tipTxt = tr( "Ctrl(or Alt)-click to toggle all" ) + "\n" + tr( "Shift-click to expand, then collapse others" );
00195   }
00196   mCollapseButton->setToolTip( tipTxt );
00197 }
00198 
00199 QRect QgsCollapsibleGroupBoxBasic::titleRect() const
00200 {
00201   QStyleOptionGroupBox box;
00202   initStyleOption( &box );
00203   return style()->subControlRect( QStyle::CC_GroupBox, &box,
00204                                   QStyle::SC_GroupBoxLabel, this );
00205 }
00206 
00207 void QgsCollapsibleGroupBoxBasic::clearModifiers()
00208 {
00209   mCollapseButton->setAltDown( false );
00210   mCollapseButton->setShiftDown( false );
00211   mAltDown = false;
00212   mShiftDown = false;
00213 }
00214 
00215 void QgsCollapsibleGroupBoxBasic::checkToggled( bool chkd )
00216 {
00217   Q_UNUSED( chkd );
00218   mCollapseButton->setEnabled( true ); // always keep enabled
00219 }
00220 
00221 void QgsCollapsibleGroupBoxBasic::checkClicked( bool chkd )
00222 {
00223   // expand/collapse when checkbox toggled by user click.
00224   // don't do this on toggle signal, otherwise group boxes will default to collapsed
00225   // in option dialog constructors, reducing discovery of options by new users and
00226   // overriding user's auto-saved collapsed/expanded state for the group box
00227   if ( chkd && isCollapsed() )
00228     setCollapsed( false );
00229   else if ( ! chkd && ! isCollapsed() )
00230     setCollapsed( true );
00231 }
00232 
00233 void QgsCollapsibleGroupBoxBasic::toggleCollapsed()
00234 {
00235   // verify if sender is this group box's collapse button
00236   bool senderCollBtn = false;
00237   QgsGroupBoxCollapseButton* collBtn = qobject_cast<QgsGroupBoxCollapseButton*>( QObject::sender() );
00238   senderCollBtn = ( collBtn && collBtn == mCollapseButton );
00239 
00240   mAltDown = ( mAltDown || mCollapseButton->altDown() );
00241   mShiftDown = ( mShiftDown || mCollapseButton->shiftDown() );
00242 
00243   // find any sync group siblings and toggle them
00244   if (( senderCollBtn || mTitleClicked )
00245       && ( mAltDown || mShiftDown )
00246       && !mSyncGroup.isEmpty() )
00247   {
00248     QgsDebugMsg( "Alt or Shift key down, syncing group" );
00249     // get pointer to parent or grandparent widget
00250     if ( parentWidget() )
00251     {
00252       mSyncParent = parentWidget();
00253       if ( mSyncParent->parentWidget() )
00254       {
00255         // don't use whole app for grandparent (common for dialogs that use main window for parent)
00256         if ( mSyncParent->parentWidget()->objectName() != QString( "QgisApp" ) )
00257         {
00258           mSyncParent = mSyncParent->parentWidget();
00259         }
00260       }
00261     }
00262     else
00263     {
00264       mSyncParent = 0;
00265     }
00266 
00267     if ( mSyncParent )
00268     {
00269       QgsDebugMsg( "found sync parent: " + mSyncParent->objectName() );
00270 
00271       bool thisCollapsed = mCollapsed; // get state of current box before its changed
00272       foreach ( QgsCollapsibleGroupBoxBasic *grpbox, mSyncParent->findChildren<QgsCollapsibleGroupBoxBasic*>() )
00273       {
00274         if ( grpbox->syncGroup() == syncGroup() && grpbox->isEnabled() )
00275         {
00276           if ( mShiftDown && grpbox == dynamic_cast<QgsCollapsibleGroupBoxBasic *>( this ) )
00277           {
00278             // expand current group box on shift-click
00279             setCollapsed( false );
00280           }
00281           else
00282           {
00283             grpbox->setCollapsed( mShiftDown ? true : !thisCollapsed );
00284           }
00285         }
00286       }
00287 
00288       clearModifiers();
00289       return;
00290     }
00291     else
00292     {
00293       QgsDebugMsg( "did not find a sync parent" );
00294     }
00295   }
00296 
00297   // expand current group box on shift-click, even if no sync group
00298   if ( mShiftDown )
00299   {
00300     setCollapsed( false );
00301   }
00302   else
00303   {
00304     setCollapsed( !mCollapsed );
00305   }
00306 
00307   clearModifiers();
00308 }
00309 
00310 void QgsCollapsibleGroupBoxBasic::updateStyle()
00311 {
00312   setUpdatesEnabled( false );
00313 
00314   QSettings settings;
00315   // NOTE: QGIS-Style groupbox styled in app stylesheet
00316   bool usingQgsStyle = settings.value( "qgis/stylesheet/groupBoxCustom", QVariant( false ) ).toBool();
00317 
00318   QStyleOptionGroupBox box;
00319   initStyleOption( &box );
00320   QRect rectFrame = style()->subControlRect( QStyle::CC_GroupBox, &box,
00321                     QStyle::SC_GroupBoxFrame, this );
00322   QRect rectTitle = titleRect();
00323 
00324   // margin/offset defaults
00325   int marginLeft = 20;  // title margin for disclosure triangle
00326   int marginRight = 5;  // a little bit of space on the right, to match space on the left
00327   int offsetLeft = 0;   // offset for oxygen theme
00328   int offsetStyle = QApplication::style()->objectName().contains( "macintosh" ) ? ( usingQgsStyle ? 1 : 8 ) : 0;
00329   int topBuffer = ( usingQgsStyle ? 3 : 1 ) + offsetStyle; // space between top of title or triangle and widget above
00330   int offsetTop =  topBuffer;
00331   int offsetTopTri = topBuffer; // offset for triangle
00332 
00333   if ( mCollapseButton->height() < rectTitle.height() ) // triangle's height > title text's, offset triangle
00334   {
00335     offsetTopTri += ( rectTitle.height() - mCollapseButton->height() ) / 2 ;
00336 //    offsetTopTri += rectTitle.top();
00337   }
00338   else if ( rectTitle.height() < mCollapseButton->height() ) // title text's height < triangle's, offset title
00339   {
00340     offsetTop += ( mCollapseButton->height() - rectTitle.height() ) / 2;
00341   }
00342 
00343   // calculate offset if frame overlaps triangle (oxygen theme)
00344   // using an offset of 6 pixels from frame border
00345   if ( QApplication::style()->objectName().toLower() == "oxygen" )
00346   {
00347     QStyleOptionGroupBox box;
00348     initStyleOption( &box );
00349     QRect rectFrame = style()->subControlRect( QStyle::CC_GroupBox, &box,
00350                       QStyle::SC_GroupBoxFrame, this );
00351     QRect rectCheckBox = style()->subControlRect( QStyle::CC_GroupBox, &box,
00352                          QStyle::SC_GroupBoxCheckBox, this );
00353     if ( rectFrame.left() <= 0 )
00354       offsetLeft = 6 + rectFrame.left();
00355     if ( rectFrame.top() <= 0 )
00356     {
00357       if ( isCheckable() )
00358       {
00359         // if is checkable align with checkbox
00360         offsetTop = ( rectCheckBox.height() / 2 ) -
00361                     ( mCollapseButton->height() / 2 ) + rectCheckBox.top();
00362         offsetTopTri = offsetTop + 1;
00363       }
00364       else
00365       {
00366         offsetTop = 6 + rectFrame.top();
00367         offsetTopTri = offsetTop;
00368       }
00369     }
00370   }
00371 
00372   QgsDebugMsg( QString( "groupbox: %1 style: %2 offset: left=%3 top=%4 top2=%5" ).arg(
00373                  objectName() ).arg( QApplication::style()->objectName() ).arg( offsetLeft ).arg( offsetTop ).arg( offsetTopTri ) );
00374 
00375   // customize style sheet for collapse/expand button and force left-aligned title
00376   QString ss;
00377   if ( usingQgsStyle || QApplication::style()->objectName().contains( "macintosh" ) )
00378   {
00379     ss += "QgsCollapsibleGroupBoxBasic, QgsCollapsibleGroupBox {";
00380     ss += QString( "  margin-top: %1px;" ).arg( topBuffer + ( usingQgsStyle ? rectTitle.height() + 5 : rectFrame.top() ) );
00381     ss += "}";
00382   }
00383   ss += "QgsCollapsibleGroupBoxBasic::title, QgsCollapsibleGroupBox::title {";
00384   ss += "  subcontrol-origin: margin;";
00385   ss += "  subcontrol-position: top left;";
00386   ss += QString( "  margin-left: %1px;" ).arg( marginLeft );
00387   ss += QString( "  margin-right: %1px;" ).arg( marginRight );
00388   ss += QString( "  left: %1px;" ).arg( offsetLeft );
00389   ss += QString( "  top: %1px;" ).arg( offsetTop );
00390   if ( QApplication::style()->objectName().contains( "macintosh" ) )
00391   {
00392     ss += "  background-color: rgba(0,0,0,0)";
00393   }
00394   ss += "}";
00395   setStyleSheet( ss );
00396 
00397   // clear toolbutton default background and border and apply offset
00398   QString ssd;
00399   ssd = QString( "QgsCollapsibleGroupBoxBasic > QToolButton#%1, QgsCollapsibleGroupBox > QToolButton#%1 {" ).arg( mCollapseButton->objectName() );
00400   ssd += "  background-color: rgba(255, 255, 255, 0); border: none;";
00401   ssd += "}";
00402   mCollapseButton->setStyleSheet( ssd );
00403   if ( offsetLeft != 0 || offsetTopTri != 0 )
00404     mCollapseButton->move( offsetLeft, offsetTopTri );
00405 
00406   setUpdatesEnabled( true );
00407 }
00408 
00409 void QgsCollapsibleGroupBoxBasic::setCollapsed( bool collapse )
00410 {
00411   mCollapsed = collapse;
00412 
00413   if ( !isVisible() )
00414     return;
00415 
00416   // for consistent look/spacing across platforms when collapsed
00417   if ( ! mInitFlat ) // skip if initially set to flat in Designer
00418     setFlat( collapse );
00419 
00420   // avoid flicker in X11
00421   // NOTE: this causes app to crash when loading a project that hits a group box with
00422   //       'collapse' set via dynamic property or in code (especially if auto-launching project)
00423   // TODO: find another means of avoiding the X11 flicker
00424 //  QApplication::processEvents();
00425 
00426   // handle visual fixes for collapsing/expanding
00427   collapseExpandFixes();
00428 
00429   // set maximum height to hide contents - does this work in all envs?
00430   // setMaximumHeight( collapse ? 25 : 16777215 );
00431   setMaximumHeight( collapse ? titleRect().bottom() + 6 : 16777215 );
00432   mCollapseButton->setIcon( collapse ? mExpandIcon : mCollapseIcon );
00433 
00434   // if expanding and is in a QScrollArea, scroll down to make entire widget visible
00435   if ( mShown && mScrollOnExpand && !collapse && mParentScrollArea )
00436   {
00437     // process events so entire widget is shown
00438     QApplication::processEvents();
00439     mParentScrollArea->ensureWidgetVisible( this );
00440   }
00441   // emit signal for connections using collapsed state
00442   emit collapsedStateChanged( isCollapsed() );
00443 }
00444 
00445 void QgsCollapsibleGroupBoxBasic::collapseExpandFixes()
00446 {
00447   if ( QApplication::style()->objectName().contains( "macintosh" ) )
00448   {
00449     // handle QPushButtons in form layouts that stay partly visible on collapse (Qt bug?)
00450     // hide on collapse for fix, but only show buttons that were specifically hidden when expanding
00451     // key hiding off of this group box's object name so it does not affect child group boxes
00452     const QByteArray objKey = QString( "CollGrpBxHiddenButton_%1" ).arg( objectName() ).toUtf8();
00453     const char* pbHideKey = objKey.constData();
00454 
00455     // handle child group box widgets that don't hide their frames on collapse of parent
00456     const char* gbHideKey = "CollGrpBxHideGrpBx";
00457 
00458     if ( mCollapsed )
00459     {
00460       // first hide all child group boxes, regardless of whether they are collapsible
00461       foreach ( QGroupBox* gbx, findChildren<QGroupBox *>() )
00462       {
00463         if ( gbx->isVisible() && !gbx->property( gbHideKey ).isValid() )
00464         {
00465           gbx->setProperty( gbHideKey, QVariant( true ) );
00466           gbx->hide();
00467         }
00468       }
00469 
00470       // hide still visible push buttons belonging to this group box
00471       foreach ( QPushButton* pBtn, findChildren<QPushButton *>() )
00472       {
00473         if ( pBtn->isVisible() && !pBtn->property( pbHideKey ).isValid() )
00474         {
00475           pBtn->setProperty( pbHideKey, QVariant( true ) );
00476           pBtn->hide();
00477         }
00478       }
00479     }
00480     else // on expand
00481     {
00482       // first show push buttons belonging to this group box
00483       foreach ( QPushButton* pBtn, findChildren<QPushButton *>() )
00484       {
00485         if ( pBtn->property( pbHideKey ).isValid() ) // don't have to check bool value
00486         {
00487           pBtn->setProperty( pbHideKey, QVariant() ); // remove property
00488           pBtn->show();
00489         }
00490       }
00491 
00492       // show all hidden child group boxes
00493       foreach ( QGroupBox* gbx, findChildren<QGroupBox *>() )
00494       {
00495         if ( gbx->property( gbHideKey ).isValid() ) // don't have to check bool value
00496         {
00497           gbx->setProperty( gbHideKey, QVariant() ); // remove property
00498           gbx->show();
00499         }
00500       }
00501     }
00502   }
00503 }
00504 
00505 
00506 // ----
00507 
00508 QgsCollapsibleGroupBox::QgsCollapsibleGroupBox( QWidget *parent, QSettings* settings )
00509     : QgsCollapsibleGroupBoxBasic( parent ), mSettings( settings )
00510 {
00511   init();
00512 }
00513 
00514 QgsCollapsibleGroupBox::QgsCollapsibleGroupBox( const QString &title,
00515     QWidget *parent, QSettings* settings )
00516     : QgsCollapsibleGroupBoxBasic( title, parent ), mSettings( settings )
00517 {
00518   init();
00519 }
00520 
00521 QgsCollapsibleGroupBox::~QgsCollapsibleGroupBox()
00522 {
00523   //QgsDebugMsg( "Entered" );
00524   saveState();
00525   if ( mDelSettings ) // local settings obj to delete
00526     delete mSettings;
00527   mSettings = 0; // null the pointer (in case of outside settings obj)
00528 }
00529 
00530 void QgsCollapsibleGroupBox::setSettings( QSettings* settings )
00531 {
00532   if ( mDelSettings ) // local settings obj to delete
00533     delete mSettings;
00534   mSettings = settings;
00535   mDelSettings = false; // don't delete outside obj
00536 }
00537 
00538 
00539 void QgsCollapsibleGroupBox::init()
00540 {
00541   //QgsDebugMsg( "Entered" );
00542   // use pointer to app qsettings if no custom qsettings specified
00543   // custom qsettings object may be from Python plugin
00544   mDelSettings = false;
00545   if ( !mSettings )
00546   {
00547     mSettings = new QSettings();
00548     mDelSettings = true; // only delete obj created by class
00549   }
00550   // variables
00551   mSaveCollapsedState = true;
00552   // NOTE: only turn on mSaveCheckedState for groupboxes NOT used
00553   // in multiple places or used as options for different parent objects
00554   mSaveCheckedState = false;
00555   mSettingGroup = ""; // if not set, use window object name
00556 }
00557 
00558 void QgsCollapsibleGroupBox::showEvent( QShowEvent * event )
00559 {
00560   //QgsDebugMsg( "Entered" );
00561   // initialise widget on first show event only
00562   if ( mShown )
00563   {
00564     event->accept();
00565     return;
00566   }
00567 
00568   // check if groupbox was set to flat in Designer or in code
00569   if ( !mInitFlatChecked )
00570   {
00571     mInitFlat = isFlat();
00572     mInitFlatChecked = true;
00573   }
00574 
00575   loadState();
00576 
00577   QgsCollapsibleGroupBoxBasic::showEvent( event );
00578 }
00579 
00580 QString QgsCollapsibleGroupBox::saveKey() const
00581 {
00582   // save key for load/save state
00583   // currently QgsCollapsibleGroupBox/window()/object
00584   QString saveKey = "/" + objectName();
00585   // QObject* parentWidget = parent();
00586   // while ( parentWidget != NULL )
00587   // {
00588   //   saveKey = "/" + parentWidget->objectName() + saveKey;
00589   //   parentWidget = parentWidget->parent();
00590   // }
00591   // if ( parent() != NULL )
00592   //   saveKey = "/" + parent()->objectName() + saveKey;
00593   QString setgrp = mSettingGroup.isEmpty() ? window()->objectName() : mSettingGroup;
00594   saveKey = "/" + setgrp + saveKey;
00595   saveKey = "QgsCollapsibleGroupBox" + saveKey;
00596   return saveKey;
00597 }
00598 
00599 void QgsCollapsibleGroupBox::loadState()
00600 {
00601   //QgsDebugMsg( "Entered" );
00602   if ( !mSettings )
00603     return;
00604 
00605   if ( !isEnabled() || ( !mSaveCollapsedState && !mSaveCheckedState ) )
00606     return;
00607 
00608   setUpdatesEnabled( false );
00609 
00610   QString key = saveKey();
00611   QVariant val;
00612   if ( mSaveCheckedState )
00613   {
00614     val = mSettings->value( key + "/checked" );
00615     if ( ! val.isNull() )
00616       setChecked( val.toBool() );
00617   }
00618   if ( mSaveCollapsedState )
00619   {
00620     val = mSettings->value( key + "/collapsed" );
00621     if ( ! val.isNull() )
00622       setCollapsed( val.toBool() );
00623   }
00624 
00625   setUpdatesEnabled( true );
00626 }
00627 
00628 void QgsCollapsibleGroupBox::saveState()
00629 {
00630   //QgsDebugMsg( "Entered" );
00631   if ( !mSettings )
00632     return;
00633 
00634   if ( !isEnabled() || ( !mSaveCollapsedState && !mSaveCheckedState ) )
00635     return;
00636 
00637   QString key = saveKey();
00638 
00639   if ( mSaveCheckedState )
00640     mSettings->setValue( key + "/checked", isChecked() );
00641   if ( mSaveCollapsedState )
00642     mSettings->setValue( key + "/collapsed", isCollapsed() );
00643 }
00644 
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines