22 , mNotSetString( tr(
"Not set" ) )
24 connect(
this,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [ = ]
26 emit
bandChanged( currentIndex() >= 0 ? currentData().toInt() : -1 );
37 return currentIndex() >= 0 ? currentData().toInt() : -1;
50 addItem( mNotSetString, -1 );
59 for (
int i = 1; i <= nBands; ++i )
61 addItem( displayBandName( provider, i ), i );
67 setCurrentIndex( findData( oldBand ) >= 0 ? findData( oldBand ) : 0 );
69 blockSignals(
false );
70 emit
bandChanged( currentIndex() >= 0 ? currentData().toInt() : -1 );
75 setCurrentIndex( findData( band ) );
86 mNotSetString =
string.isEmpty() ? tr(
"Not set" ) : string;
98 if ( colorInterp != QLatin1String(
"Undefined" ) )
100 name.append( QStringLiteral(
" (%1)" ).arg( colorInterp ) );
virtual int bandCount() const =0
Get number of bands.
int currentBand() const
Returns the current band number selected in the combobox, or -1 if no band is selected.
Base class for all map layer types.
void setLayer(QgsMapLayer *layer)
Sets the raster layer for which the bands are listed in the combobox.
This class provides qgis with the ability to render raster datasets onto the mapcanvas.
void setShowNotSetOption(bool show, const QString &string=QString())
Sets whether the combo box should show the "not set" option.
void bandChanged(int band)
This signal is emitted when the currently selected band changes.
QgsRasterBandComboBox(QWidget *parent=nullptr)
Constructor for QgsRasterBandComboBox.
virtual QString colorInterpretationName(int bandNo) const
bool isShowingNotSetOption() const
Returns true if the combo box is showing the "not set" option.
void setBand(int band)
Sets the current band number selected in the combobox.
virtual QString generateBandName(int bandNumber) const
helper function to create zero padded band names
Base class for raster data providers.
QgsRasterLayer * layer() const
Returns the layer currently associated with the combobox.