Skip to content

Commit

Permalink
Reimplement QgsOptionsDialogBase::optionsStackedWidget_CurrentChanged…
Browse files Browse the repository at this point in the history
… in derived classes rather than duplicate it
  • Loading branch information
borysiasty committed Nov 6, 2017
1 parent 6b76c2b commit c315eb3
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 16 deletions.
7 changes: 4 additions & 3 deletions src/app/qgsoptions.cpp
Expand Up @@ -95,7 +95,6 @@ QgsOptions::QgsOptions( QWidget *parent, Qt::WindowFlags fl, const QList<QgsOpti
connect( mProxyTypeComboBox, static_cast<void ( QComboBox::* )( int )>( &QComboBox::currentIndexChanged ), this, &QgsOptions::mProxyTypeComboBox_currentIndexChanged );
connect( mCustomVariablesChkBx, &QCheckBox::toggled, this, &QgsOptions::mCustomVariablesChkBx_toggled );
connect( mCurrentVariablesQGISChxBx, &QCheckBox::toggled, this, &QgsOptions::mCurrentVariablesQGISChxBx_toggled );
connect( mOptionsStackedWidget, &QStackedWidget::currentChanged, this, &QgsOptions::mOptionsStackedWidget_currentChanged );
connect( buttonBox, &QDialogButtonBox::helpRequested, this, &QgsOptions::showHelp );

// QgsOptionsDialogBase handles saving/restoring of geometry, splitter and current tab states,
Expand Down Expand Up @@ -1998,9 +1997,11 @@ void QgsOptions::clearAccessCache()
QMessageBox::information( this, tr( "Cache cleared" ), tr( "Connection authentication cache has been cleared" ) );
}

void QgsOptions::mOptionsStackedWidget_currentChanged( int indx )
void QgsOptions::optionsStackedWidget_CurrentChanged( int index )
{
Q_UNUSED( indx );
QgsOptionsDialogBase::optionsStackedWidget_CurrentChanged( index );

Q_UNUSED( index );
// load gdal driver list when gdal tab is first opened
if ( mOptionsStackedWidget->currentWidget()->objectName() == QLatin1String( "mOptionsPageGDAL" )
&& ! mLoadedGdalDriverList )
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsoptions.h
Expand Up @@ -216,7 +216,7 @@ class APP_EXPORT QgsOptions : public QgsOptionsDialogBase, private Ui::QgsOption
void exportScales();

//! Auto slot executed when the active page in the option section widget is changed
void mOptionsStackedWidget_currentChanged( int indx );
void optionsStackedWidget_CurrentChanged( int index ) override;

//! A scale in the list of predefined scales changed
void scaleItemChanged( QListWidgetItem *changedScaleItem );
Expand Down
12 changes: 6 additions & 6 deletions src/app/qgsrasterlayerproperties.cpp
Expand Up @@ -122,8 +122,6 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer *lyr, QgsMapCanv

connect( buttonBox->button( QDialogButtonBox::Apply ), &QAbstractButton::clicked, this, &QgsRasterLayerProperties::apply );

connect( mOptionsStackedWidget, &QStackedWidget::currentChanged, this, &QgsRasterLayerProperties::mOptionsStackedWidget_CurrentChanged );

// brightness/contrast controls
connect( mSliderBrightness, &QAbstractSlider::valueChanged, mBrightnessSpinBox, &QSpinBox::setValue );
connect( mBrightnessSpinBox, static_cast < void ( QSpinBox::* )( int ) > ( &QSpinBox::valueChanged ), mSliderBrightness, &QAbstractSlider::setValue );
Expand Down Expand Up @@ -1483,21 +1481,23 @@ void QgsRasterLayerProperties::setTransparencyToEdited( int row )
mTransparencyToEdited[row] = true;
}

void QgsRasterLayerProperties::mOptionsStackedWidget_CurrentChanged( int indx )
void QgsRasterLayerProperties::optionsStackedWidget_CurrentChanged( int index )
{
QgsOptionsDialogBase::optionsStackedWidget_CurrentChanged( index );

if ( !mHistogramWidget )
return;

if ( indx == 5 )
if ( index == 5 )
{
mHistogramWidget->setActive( true );
mHistogramWidget->setActive( false );
}
else
{
mHistogramWidget->setActive( false );
}

if ( indx == mOptStackedWidget->indexOf( mOptsPage_Information ) || !mMetadataFilled )
if ( index == mOptStackedWidget->indexOf( mOptsPage_Information ) || !mMetadataFilled )
//set the metadata contents (which can be expensive)
teMetadataViewer->clear();
teMetadataViewer->setHtml( mRasterLayer->htmlMetadata() );
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsrasterlayerproperties.h
Expand Up @@ -79,7 +79,7 @@ class APP_EXPORT QgsRasterLayerProperties : public QgsOptionsDialogBase, private
//! \brief slot executed when user wishes to export transparency values
void pbnExportTransparentPixelValues_clicked();
//! \brief auto slot executed when the active page in the main widget stack is changed
void mOptionsStackedWidget_CurrentChanged( int indx );
void optionsStackedWidget_CurrentChanged( int index ) override;
//! \brief slow executed when user wishes to import transparency values
void pbnImportTransparentPixelValues_clicked();
//! \brief slot executed when user presses "Remove Selected Row" button on the transparency page
Expand Down
8 changes: 4 additions & 4 deletions src/app/qgsvectorlayerproperties.cpp
Expand Up @@ -122,8 +122,6 @@ QgsVectorLayerProperties::QgsVectorLayerProperties(
connect( this, &QDialog::accepted, this, &QgsVectorLayerProperties::apply );
connect( this, &QDialog::rejected, this, &QgsVectorLayerProperties::onCancel );

connect( mOptionsStackedWidget, &QStackedWidget::currentChanged, this, &QgsVectorLayerProperties::mOptionsStackedWidget_CurrentChanged );

mContext << QgsExpressionContextUtils::globalScope()
<< QgsExpressionContextUtils::projectScope( QgsProject::instance() )
<< QgsExpressionContextUtils::atlasScope( nullptr )
Expand Down Expand Up @@ -1447,9 +1445,11 @@ void QgsVectorLayerProperties::pbnUpdateExtents_clicked()
mMetadataFilled = false;
}

void QgsVectorLayerProperties::mOptionsStackedWidget_CurrentChanged( int indx )
void QgsVectorLayerProperties::optionsStackedWidget_CurrentChanged( int index )
{
if ( indx != mOptStackedWidget->indexOf( mOptsPage_Information ) || mMetadataFilled )
QgsOptionsDialogBase::optionsStackedWidget_CurrentChanged( index );

if ( index != mOptStackedWidget->indexOf( mOptsPage_Information ) || mMetadataFilled )
return;

//set the metadata contents (which can be expensive)
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgsvectorlayerproperties.h
Expand Up @@ -116,7 +116,7 @@ class APP_EXPORT QgsVectorLayerProperties : public QgsOptionsDialogBase, private
void saveDefaultStyle_clicked();
void loadStyle_clicked();
void saveStyleAs_clicked();
void mOptionsStackedWidget_CurrentChanged( int indx );
void optionsStackedWidget_CurrentChanged( int index ) override;
void pbnUpdateExtents_clicked();

void mButtonAddJoin_clicked();
Expand Down

0 comments on commit c315eb3

Please sign in to comment.