Skip to content

Commit 642bfde

Browse files
alexbruynyalldawson
authored andcommittedApr 24, 2023
fix displaying of the enum parameter options when static strings mode is
active and multiple selection is enabled. Also improve conversion to Python string
1 parent 8a23a76 commit 642bfde

File tree

2 files changed

+14
-3
lines changed

2 files changed

+14
-3
lines changed
 

‎src/core/processing/qgsprocessingparameters.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4911,7 +4911,7 @@ QString QgsProcessingParameterEnum::valueAsPythonString( const QVariant &value,
49114911

49124912
if ( mUsesStaticStrings )
49134913
{
4914-
if ( value.type() == QVariant::StringList )
4914+
if ( value.type() == QVariant::List || value.type() == QVariant::StringList )
49154915
{
49164916
QStringList parts;
49174917
const QStringList constList = value.toStringList();

‎src/gui/processing/qgsprocessingwidgetwrapperimpl.cpp

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2445,8 +2445,19 @@ void QgsProcessingEnumPanelWidget::showDialog()
24452445
if ( mParam )
24462446
{
24472447
availableOptions.reserve( mParam->options().size() );
2448-
for ( int i = 0; i < mParam->options().count(); ++i )
2449-
availableOptions << i;
2448+
2449+
if ( mParam->usesStaticStrings() )
2450+
{
2451+
for ( QString o : mParam->options() )
2452+
{
2453+
availableOptions << o;
2454+
}
2455+
}
2456+
else
2457+
{
2458+
for ( int i = 0; i < mParam->options().count(); ++i )
2459+
availableOptions << i;
2460+
}
24502461
}
24512462

24522463
const QStringList options = mParam ? mParam->options() : QStringList();

0 commit comments

Comments
 (0)