Skip to content

Commit

Permalink
QgsRasterPyramidsOptionsWidget: cleanup to avoid use of hard-coded co…
Browse files Browse the repository at this point in the history
…nstants
  • Loading branch information
rouault committed May 27, 2016
1 parent 1ce34c3 commit 7f3edb8
Show file tree
Hide file tree
Showing 2 changed files with 33 additions and 8 deletions.
32 changes: 24 additions & 8 deletions src/gui/qgsrasterpyramidsoptionswidget.cpp
Expand Up @@ -27,7 +27,6 @@
#include <QMenu>
#include <QCheckBox>


QgsRasterPyramidsOptionsWidget::QgsRasterPyramidsOptionsWidget( QWidget* parent, const QString& provider )
: QWidget( parent )
, mProvider( provider )
Expand Down Expand Up @@ -55,11 +54,11 @@ void QgsRasterPyramidsOptionsWidget::updateUi()
// keep it in sync with qgsrasterlayerproperties.cpp
tmpStr = mySettings.value( prefix + "format", "external" ).toString();
if ( tmpStr == "internal" )
cbxPyramidsFormat->setCurrentIndex( 1 );
cbxPyramidsFormat->setCurrentIndex( Format::INTERNAL );
else if ( tmpStr == "external_erdas" )
cbxPyramidsFormat->setCurrentIndex( 2 );
cbxPyramidsFormat->setCurrentIndex( Format::ERDAS );
else
cbxPyramidsFormat->setCurrentIndex( 0 );
cbxPyramidsFormat->setCurrentIndex( Format::GTIFF );

// initialize resampling methods
cboResamplingMethod->clear();
Expand Down Expand Up @@ -127,9 +126,9 @@ void QgsRasterPyramidsOptionsWidget::apply()
QString tmpStr;

// mySettings.setValue( prefix + "internal", cbxPyramidsInternal->isChecked() );
if ( cbxPyramidsFormat->currentIndex() == 1 )
if ( cbxPyramidsFormat->currentIndex() == Format::INTERNAL )
tmpStr = "internal";
else if ( cbxPyramidsFormat->currentIndex() == 2 )
else if ( cbxPyramidsFormat->currentIndex() == Format::ERDAS )
tmpStr = "external_erdas";
else
tmpStr = "external";
Expand Down Expand Up @@ -166,8 +165,25 @@ void QgsRasterPyramidsOptionsWidget::on_cbxPyramidsLevelsCustom_toggled( bool to

void QgsRasterPyramidsOptionsWidget::on_cbxPyramidsFormat_currentIndexChanged( int index )
{
mSaveOptionsWidget->setEnabled( index != 2 );
mSaveOptionsWidget->setPyramidsFormat(( QgsRaster::RasterPyramidsFormat ) index );
mSaveOptionsWidget->setEnabled( index != Format::ERDAS );
QgsRaster::RasterPyramidsFormat format;
switch ( index )
{
case Format::GTIFF:
format = QgsRaster::PyramidsGTiff;
break;
case Format::INTERNAL:
format = QgsRaster::PyramidsInternal;
break;
case Format::ERDAS:
format = QgsRaster::PyramidsErdas;
break;
default:
QgsDebugMsg( "Should not happen !" );
format = QgsRaster::PyramidsGTiff;
break;
}
mSaveOptionsWidget->setPyramidsFormat( format );
}

void QgsRasterPyramidsOptionsWidget::setOverviewList()
Expand Down
9 changes: 9 additions & 0 deletions src/gui/qgsrasterpyramidsoptionswidget.h
Expand Up @@ -63,6 +63,15 @@ class GUI_EXPORT QgsRasterPyramidsOptionsWidget: public QWidget,

private:

// Must be in the same order as in the .ui file
typedef enum
{
GTIFF = 0,
INTERNAL = 1,
ERDAS = 2
} Format;


QString mProvider;
QList< int > mOverviewList;
QMap< int, QCheckBox* > mOverviewCheckBoxes;
Expand Down

0 comments on commit 7f3edb8

Please sign in to comment.