Skip to content

Commit 7f3edb8

Browse files
committedMay 27, 2016
QgsRasterPyramidsOptionsWidget: cleanup to avoid use of hard-coded constants
1 parent 1ce34c3 commit 7f3edb8

File tree

2 files changed

+33
-8
lines changed

2 files changed

+33
-8
lines changed
 

‎src/gui/qgsrasterpyramidsoptionswidget.cpp

Lines changed: 24 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,6 @@
2727
#include <QMenu>
2828
#include <QCheckBox>
2929

30-
3130
QgsRasterPyramidsOptionsWidget::QgsRasterPyramidsOptionsWidget( QWidget* parent, const QString& provider )
3231
: QWidget( parent )
3332
, mProvider( provider )
@@ -55,11 +54,11 @@ void QgsRasterPyramidsOptionsWidget::updateUi()
5554
// keep it in sync with qgsrasterlayerproperties.cpp
5655
tmpStr = mySettings.value( prefix + "format", "external" ).toString();
5756
if ( tmpStr == "internal" )
58-
cbxPyramidsFormat->setCurrentIndex( 1 );
57+
cbxPyramidsFormat->setCurrentIndex( Format::INTERNAL );
5958
else if ( tmpStr == "external_erdas" )
60-
cbxPyramidsFormat->setCurrentIndex( 2 );
59+
cbxPyramidsFormat->setCurrentIndex( Format::ERDAS );
6160
else
62-
cbxPyramidsFormat->setCurrentIndex( 0 );
61+
cbxPyramidsFormat->setCurrentIndex( Format::GTIFF );
6362

6463
// initialize resampling methods
6564
cboResamplingMethod->clear();
@@ -127,9 +126,9 @@ void QgsRasterPyramidsOptionsWidget::apply()
127126
QString tmpStr;
128127

129128
// mySettings.setValue( prefix + "internal", cbxPyramidsInternal->isChecked() );
130-
if ( cbxPyramidsFormat->currentIndex() == 1 )
129+
if ( cbxPyramidsFormat->currentIndex() == Format::INTERNAL )
131130
tmpStr = "internal";
132-
else if ( cbxPyramidsFormat->currentIndex() == 2 )
131+
else if ( cbxPyramidsFormat->currentIndex() == Format::ERDAS )
133132
tmpStr = "external_erdas";
134133
else
135134
tmpStr = "external";
@@ -166,8 +165,25 @@ void QgsRasterPyramidsOptionsWidget::on_cbxPyramidsLevelsCustom_toggled( bool to
166165

167166
void QgsRasterPyramidsOptionsWidget::on_cbxPyramidsFormat_currentIndexChanged( int index )
168167
{
169-
mSaveOptionsWidget->setEnabled( index != 2 );
170-
mSaveOptionsWidget->setPyramidsFormat(( QgsRaster::RasterPyramidsFormat ) index );
168+
mSaveOptionsWidget->setEnabled( index != Format::ERDAS );
169+
QgsRaster::RasterPyramidsFormat format;
170+
switch ( index )
171+
{
172+
case Format::GTIFF:
173+
format = QgsRaster::PyramidsGTiff;
174+
break;
175+
case Format::INTERNAL:
176+
format = QgsRaster::PyramidsInternal;
177+
break;
178+
case Format::ERDAS:
179+
format = QgsRaster::PyramidsErdas;
180+
break;
181+
default:
182+
QgsDebugMsg( "Should not happen !" );
183+
format = QgsRaster::PyramidsGTiff;
184+
break;
185+
}
186+
mSaveOptionsWidget->setPyramidsFormat( format );
171187
}
172188

173189
void QgsRasterPyramidsOptionsWidget::setOverviewList()

‎src/gui/qgsrasterpyramidsoptionswidget.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,15 @@ class GUI_EXPORT QgsRasterPyramidsOptionsWidget: public QWidget,
6363

6464
private:
6565

66+
// Must be in the same order as in the .ui file
67+
typedef enum
68+
{
69+
GTIFF = 0,
70+
INTERNAL = 1,
71+
ERDAS = 2
72+
} Format;
73+
74+
6675
QString mProvider;
6776
QList< int > mOverviewList;
6877
QMap< int, QCheckBox* > mOverviewCheckBoxes;

0 commit comments

Comments
 (0)
Please sign in to comment.