Skip to content
Permalink
Browse files

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
  • Loading branch information
elpaso committed Jan 25, 2019
1 parent a90fb87 commit 57d32939363073bafe6d54016813c75c9964adc2
Showing with 11 additions and 1 deletion.
  1. +11 −1 src/app/qgsfieldcalculator.cpp
@@ -348,7 +348,17 @@ void QgsFieldCalculator::populateOutputFieldTypes()
}

mOutputFieldTypeComboBox->blockSignals( true );
const QList< QgsVectorDataProvider::NativeType > &typelist = provider->nativeTypes();

// Not all providers have a native types list (WFS), provide default
// Integer|Real|Character|Date|Boolean
const QList< QgsVectorDataProvider::NativeType > &typelist { provider->nativeTypes().isEmpty() ? ( QList< QgsVectorDataProvider::NativeType >()
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), QStringLiteral( "integer" ), QVariant::Int, 0, 10 )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), QStringLiteral( "double precision" ), QVariant::Double, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Text (string)" ), QStringLiteral( "string" ), QVariant::String )
<< QgsVectorDataProvider::NativeType( tr( "Date" ), QStringLiteral( "date" ), QVariant::Date, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Boolean (bool)" ), QStringLiteral( "bool" ), QVariant::Bool ) )
: provider->nativeTypes() };

for ( int i = 0; i < typelist.size(); i++ )
{
mOutputFieldTypeComboBox->addItem( typelist[i].mTypeDesc );

0 comments on commit 57d3293

Please sign in to comment.
You can’t perform that action at this time.