QgsCollapsibleGroupBox: rename mSaveState to mSaveCollapsedState and update saveState/restoreState, update raster save dialog

This commit is contained in:
Etienne Tourigny 2012-09-25 18:18:11 -03:00
parent cf398ca130
commit fef272e1a1
4 changed files with 35 additions and 16 deletions

View File

@ -11,16 +11,19 @@ class QgsCollapsibleGroupBox : QGroupBox
bool isCollapsed() const;
void setCollapsed( bool collapse );
//! set this to false to not save/restore check and collapse state
void setSaveState( bool save );
//! set this to true to save/restore checked state
/** @note only turn on mSaveCheckedState for groupboxes NOT used
//! set this to false to not save/restore collapsed state
void setSaveCollapsedState( bool save );
/** set this to true to save/restore checked state
* @note only turn on mSaveCheckedState for groupboxes NOT used
* in multiple places or used as options for different parent objects */
void setSaveCheckedState( bool save );
bool saveCollapsedState();
bool saveCheckedState();
//! set this to a defined string to share save/restore collapsed state across dialogs
void setSettingGroup( const QString &group );
QString settingGroup() const;
//! set this to false to not automatically scroll parent QScrollArea to this widget's contents when expanded
void setScrollOnExpand( bool scroll );

View File

@ -51,7 +51,7 @@ void QgsCollapsibleGroupBox::init()
{
// variables
mCollapsed = false;
mSaveState = true;
mSaveCollapsedState = true;
// NOTE: only turn on mSaveCheckedState for groupboxes NOT used
// in multiple places or used as options for different parent objects
mSaveCheckedState = false;
@ -179,7 +179,7 @@ QString QgsCollapsibleGroupBox::saveKey() const
void QgsCollapsibleGroupBox::loadState()
{
if ( ! mSaveState )
if ( !isEnabled() || ( !mSaveCollapsedState && !mSaveCheckedState ) )
return;
setUpdatesEnabled( false );
@ -193,22 +193,28 @@ void QgsCollapsibleGroupBox::loadState()
if ( ! val.isNull() )
setChecked( val.toBool() );
}
val = settings.value( key + "/collapsed" );
if ( ! val.isNull() )
setCollapsed( val.toBool() );
if ( mSaveCollapsedState )
{
val = settings.value( key + "/collapsed" );
if ( ! val.isNull() )
setCollapsed( val.toBool() );
}
setUpdatesEnabled( true );
}
void QgsCollapsibleGroupBox::saveState()
{
if ( ! mSaveState )
if ( !isEnabled() || ( !mSaveCollapsedState && !mSaveCheckedState ) )
return;
QSettings settings;
QString key = saveKey();
if ( mSaveCheckedState )
settings.setValue( key + "/checked", isChecked() );
settings.setValue( key + "/collapsed", isCollapsed() );
if ( mSaveCollapsedState )
settings.setValue( key + "/collapsed", isCollapsed() );
}
void QgsCollapsibleGroupBox::checkToggled( bool chkd )

View File

@ -42,16 +42,19 @@ class GUI_EXPORT QgsCollapsibleGroupBox : public QGroupBox
bool isCollapsed() const { return mCollapsed; }
void setCollapsed( bool collapse );
//! set this to false to not save/restore check and collapse state
void setSaveState( bool save ) { mSaveState = save; }
//! set this to true to save/restore checked state
/** @note only turn on mSaveCheckedState for groupboxes NOT used
//! set this to false to not save/restore collapsed state
void setSaveCollapsedState( bool save ) { mSaveCollapsedState = save; }
/** set this to true to save/restore checked state
* @note only turn on mSaveCheckedState for groupboxes NOT used
* in multiple places or used as options for different parent objects */
void setSaveCheckedState( bool save ) { mSaveCheckedState = save; }
bool saveCollapsedState() { return mSaveCollapsedState; }
bool saveCheckedState() { return mSaveCheckedState; }
//! set this to a defined string to share save/restore collapsed state across dialogs
void setSettingGroup( const QString &group ) { mSettingGroup = group; }
QString settingGroup() const { return mSettingGroup; }
//! set this to false to not automatically scroll parent QScrollArea to this widget's contents when expanded
void setScrollOnExpand( bool scroll ) { mScrollOnExpand = scroll; }
@ -78,7 +81,7 @@ class GUI_EXPORT QgsCollapsibleGroupBox : public QGroupBox
QString saveKey() const;
bool mCollapsed;
bool mSaveState;
bool mSaveCollapsedState;
bool mSaveCheckedState;
QString mSettingGroup;
bool mInitFlat;

View File

@ -100,6 +100,13 @@ QgsRasterLayerSaveAsDialog::QgsRasterLayerSaveAsDialog( QgsRasterLayer* rasterLa
mPyramidsGroupBox->setEnabled( false );
}
// restore checked state for most groupboxes (default is to restore collapsed state)
// create options and pyramids will be preset, if user has selected defaults in the gdal options dlg
mCreateOptionsGroupBox->setSaveCheckedState( true );
mTilesGroupBox->setSaveCheckedState( true );
// don't restore nodata, it needs user input
// pyramids are not necessarily built every time
updateCrsGroup();
QPushButton* okButton = mButtonBox->button( QDialogButtonBox::Ok );