Skip to content

Commit

Permalink
Field calculator: provide a list of default field types
Browse files Browse the repository at this point in the history
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 57d3293
Showing 1 changed file with 11 additions and 1 deletion.
12 changes: 11 additions & 1 deletion src/app/qgsfieldcalculator.cpp
Expand Up @@ -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 );
Expand Down

0 comments on commit 57d3293

Please sign in to comment.