Skip to content

Commit f87777e

Browse files
committed
make band names consistent
1 parent 87bdff9 commit f87777e

File tree

2 files changed

+14
-21
lines changed

2 files changed

+14
-21
lines changed

src/app/qgsrasterlayerproperties.cpp

+9-13
Original file line numberDiff line numberDiff line change
@@ -244,29 +244,25 @@ QgsRasterLayerProperties::QgsRasterLayerProperties( QgsMapLayer* lyr, QgsMapCanv
244244
cboxTransparencyBand->addItem( tr( "None" ), -1 );
245245
int nBands = provider->bandCount();
246246
QString bandName;
247-
248-
if ( nBands == 1 )
249-
{
250-
/* Color interpretation name only makes sense for 1-band rasters */
251-
bandName = provider->colorInterpretationName( 1 );
252-
if ( bandName == "Undefined" )
253-
bandName = provider->generateBandName( 1 );
254-
cboxTransparencyBand->addItem( bandName, 1 );
255-
}
256-
else if ( nBands > 1 )
247+
for ( int i = 1; i <= nBands; ++i ) //band numbering seem to start at 1
257248
{
258-
for ( int i = 1; i <= nBands; ++i ) //band numbering seem to start at 1
249+
bandName = provider->generateBandName( i );
250+
251+
QString colorInterp = provider->colorInterpretationName( i );
252+
if ( colorInterp != "Undefined" )
259253
{
260-
bandName = provider->generateBandName( i );
261-
cboxTransparencyBand->addItem( bandName, i );
254+
bandName.append( QString( " (%1)" ).arg( colorInterp ) );
262255
}
256+
cboxTransparencyBand->addItem( bandName, i );
263257
}
258+
264259
if ( renderer )
265260
{
266261
cboxTransparencyBand->setCurrentIndex( cboxTransparencyBand->findData( renderer->alphaBand() ) );
267262
}
268263
}
269264

265+
270266
//insert renderer widgets into registry
271267
QgsRasterRendererRegistry::instance()->insertWidgetFunction( "paletted", QgsPalettedRendererWidget::create );
272268
QgsRasterRendererRegistry::instance()->insertWidgetFunction( "multibandcolor", QgsMultiBandColorRendererWidget::create );

src/gui/raster/qgsrasterrendererwidget.cpp

+5-8
Original file line numberDiff line numberDiff line change
@@ -34,16 +34,13 @@ QString QgsRasterRendererWidget::displayBandName( int band ) const
3434
return name;
3535
}
3636

37-
/* Color interpretation name only makes sense for 1-band rasters */
38-
if ( provider->bandCount() <= 1 )
39-
{
40-
name = provider->colorInterpretationName( band );
41-
if ( name != "Undefined" )
42-
return name;
43-
}
44-
4537
name = provider->generateBandName( band );
4638

39+
QString colorInterp = provider->colorInterpretationName( band );
40+
if ( colorInterp != "Undefined" )
41+
{
42+
name.append( QString( " (%1)" ).arg( colorInterp ) );
43+
}
4744
return name;
4845
}
4946

0 commit comments

Comments
 (0)