Skip to content

Commit 57d3293

Browse files
committedJan 25, 2019
Field calculator: provide a list of default field types
in case the provider does not (WFS is one of them). Rationale: consider that there is not such a thing like a list of supported types for WFS and parsing the particular describeFeatureType for the layer would restrict the types to only those actually existing in the layer, but we are dealing with virtual fields here (because WFS has no column add capabilities) so let's give the users a minimal set of useful types to play with. Fixes #21086
1 parent a90fb87 commit 57d3293

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed
 

‎src/app/qgsfieldcalculator.cpp

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -348,7 +348,17 @@ void QgsFieldCalculator::populateOutputFieldTypes()
348348
}
349349

350350
mOutputFieldTypeComboBox->blockSignals( true );
351-
const QList< QgsVectorDataProvider::NativeType > &typelist = provider->nativeTypes();
351+
352+
// Not all providers have a native types list (WFS), provide default
353+
// Integer|Real|Character|Date|Boolean
354+
const QList< QgsVectorDataProvider::NativeType > &typelist { provider->nativeTypes().isEmpty() ? ( QList< QgsVectorDataProvider::NativeType >()
355+
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), QStringLiteral( "integer" ), QVariant::Int, 0, 10 )
356+
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), QStringLiteral( "double precision" ), QVariant::Double, -1, -1, -1, -1 )
357+
<< QgsVectorDataProvider::NativeType( tr( "Text (string)" ), QStringLiteral( "string" ), QVariant::String )
358+
<< QgsVectorDataProvider::NativeType( tr( "Date" ), QStringLiteral( "date" ), QVariant::Date, -1, -1, -1, -1 )
359+
<< QgsVectorDataProvider::NativeType( tr( "Boolean (bool)" ), QStringLiteral( "bool" ), QVariant::Bool ) )
360+
: provider->nativeTypes() };
361+
352362
for ( int i = 0; i < typelist.size(); i++ )
353363
{
354364
mOutputFieldTypeComboBox->addItem( typelist[i].mTypeDesc );

0 commit comments

Comments
 (0)
Please sign in to comment.