Skip to content

Commit

Permalink
Better fix for situations like #7602
Browse files Browse the repository at this point in the history
- In base class, auto-remove corresponding list widget item when stack widget is removed
- Minimize band rendering group box stretching if there probably is no combo box choice (e.g. WMS layer)
  • Loading branch information
dakcarto committed Apr 14, 2013
1 parent 833ae95 commit 611f77b
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 5 deletions.
18 changes: 14 additions & 4 deletions src/app/qgsrasterlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -553,29 +553,40 @@ void QgsRasterLayerProperties::sync()
mOptionsStackedWidget->setCurrentWidget( mOptsPage_Metadata );
}

// TODO: Wouldn't it be better to just disable the tabs than delete them? [LS]
bool fixBandStretch = false;
// TODO: Wouldn't it be better to just removeWidget() the tabs than delete them? [LS]
if ( !( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::BuildPyramids ) )
{
fixBandStretch = true;
if ( mOptsPage_Pyramids != NULL )
{
delete mOptListWidget->item( mOptStackedWidget->indexOf( mOptsPage_Pyramids ) );
delete mOptsPage_Pyramids;
mOptsPage_Pyramids = NULL;
}
}

if ( !( mRasterLayer->dataProvider()->capabilities() & QgsRasterDataProvider::Histogram ) )
{
fixBandStretch = ( fixBandStretch && true );
if ( mOptsPage_Histogram != NULL )
{
delete mOptListWidget->item( mOptStackedWidget->indexOf( mOptsPage_Histogram ) );
delete mOptsPage_Histogram;
mOptsPage_Histogram = NULL;
delete mHistogramWidget;
mHistogramWidget = NULL;
}
}

if ( fixBandStretch )
{
// probably no band rendering choices, so minimize group box
QSizePolicy sizep = mBandRenderingGrpBx->sizePolicy();
sizep.setVerticalStretch( 0 );
sizep.setVerticalPolicy( QSizePolicy::Maximum );
mBandRenderingGrpBx->setSizePolicy( sizep );
mBandRenderingGrpBx->updateGeometry();
}

QgsDebugMsg( "populate transparency tab" );

/*
Expand Down Expand Up @@ -1689,7 +1700,6 @@ void QgsRasterLayerProperties::updatePipeList()
QgsDebugMsg( "Entered" );

#ifndef QGISDEBUG
delete mOptListWidget->item( mOptStackedWidget->indexOf( mOptsPage_Pipe ) );
mOptionsStackedWidget->removeWidget( mOptsPage_Pipe ); // just delete instead?
#else
mPipeTreeWidget->clear();
Expand Down
7 changes: 7 additions & 0 deletions src/gui/qgsoptionsdialogbase.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -72,6 +72,7 @@ void QgsOptionsDialogBase::initOptionsBase( bool restoreUi )
}
connect( mOptSplitter, SIGNAL( splitterMoved( int, int ) ), this, SLOT( updateOptionsListVerticalTabs() ) );
connect( mOptStackedWidget, SIGNAL( currentChanged( int ) ), this, SLOT( optionsStackedWidget_CurrentChanged( int ) ) );
connect( mOptStackedWidget, SIGNAL( widgetRemoved( int ) ), this, SLOT( optionsStackedWidget_WidgetRemoved( int ) ) );

if ( restoreUi )
restoreOptionsBaseUi();
Expand Down Expand Up @@ -164,6 +165,12 @@ void QgsOptionsDialogBase::optionsStackedWidget_CurrentChanged( int indx )
mOptListWidget->blockSignals( false );
}

void QgsOptionsDialogBase::optionsStackedWidget_WidgetRemoved( int indx )
{
// will need to take item first, if widgets are set for item in future
delete mOptListWidget->item( indx );
}

void QgsOptionsDialogBase::warnAboutMissingObjects()
{
QMessageBox::warning( 0, tr( "Missing objects" ),
Expand Down
1 change: 1 addition & 0 deletions src/gui/qgsoptionsdialogbase.h
Original file line number Diff line number Diff line change
Expand Up @@ -70,6 +70,7 @@ class GUI_EXPORT QgsOptionsDialogBase : public QDialog
protected slots:
void updateOptionsListVerticalTabs();
void optionsStackedWidget_CurrentChanged( int indx );
void optionsStackedWidget_WidgetRemoved( int indx );
void warnAboutMissingObjects();

protected:
Expand Down
2 changes: 1 addition & 1 deletion src/ui/qgsrasterlayerpropertiesbase.ui
Original file line number Diff line number Diff line change
Expand Up @@ -828,7 +828,7 @@
<number>0</number>
</property>
<item>
<widget class="QgsCollapsibleGroupBox" name="groupBox">
<widget class="QgsCollapsibleGroupBox" name="mBandRenderingGrpBx">
<property name="sizePolicy">
<sizepolicy hsizetype="Preferred" vsizetype="Preferred">
<horstretch>0</horstretch>
Expand Down

0 comments on commit 611f77b

Please sign in to comment.