22 , mNotSetString( tr(
"Not set" ) )
24 connect(
this,
static_cast<void ( QComboBox::* )(
int )
>( &QComboBox::currentIndexChanged ),
this, [ = ]
26 if ( mLayer && mLayer->isValid() )
28 const int newBand = currentIndex() >= 0 ? currentData().toInt() : -1 ;
29 if ( newBand != mPrevBand )
31 emit bandChanged( currentIndex() >= 0 ? currentData().toInt() : -1 );
37 connect(
this, &QComboBox::currentTextChanged,
this, [ = ](
const QString & value )
39 if ( !mLayer || !mLayer->isValid() )
42 const int band = value.toInt( &ok );
43 if ( ok && band != mPrevBand )
45 emit bandChanged( band );
48 else if ( mShowNotSet && mPrevBand != -1 )
50 emit bandChanged( -1 );
67 if ( !mLayer || !mLayer->dataProvider() || !mLayer->isValid() )
70 const int band = currentText().toInt( &ok );
77 if ( currentIndex() < 0 )
80 return currentData().toInt();
95 addItem( mNotSetString, -1 );
100 if ( provider && mLayer->isValid() )
102 setEditable(
false );
104 const int nBands = provider->
bandCount();
105 for (
int i = 1; i <= nBands; ++i )
123 setCurrentIndex( 0 );
125 blockSignals(
false );
134 if ( !mLayer || !mLayer->dataProvider() || !mLayer->isValid() )
138 setCurrentIndex( -1 );
139 if ( mPrevBand != -1 )
143 setCurrentText( QString::number(
band ) );
147 setCurrentIndex( findData(
band ) );
160 mNotSetString =
string.isEmpty() ? tr(
"Not set" ) : string;