Skip to content
Permalink
Browse files

Always use the same subset of field types for virtual fields

  • Loading branch information
elpaso committed Jan 28, 2019
1 parent 57d3293 commit 9faf07d0bc634840e1bfe07061a9782a58a53508
Showing with 15 additions and 6 deletions.
  1. +15 −6 src/app/qgsfieldcalculator.cpp
@@ -349,16 +349,24 @@ void QgsFieldCalculator::populateOutputFieldTypes()

mOutputFieldTypeComboBox->blockSignals( true );

// 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 >()
// Standard subset of fields in case of virtual
const QList< QgsVectorDataProvider::NativeType > &typelist { mCreateVirtualFieldCheckbox->isChecked() ? ( 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 )
// date time
<< QgsVectorDataProvider::NativeType( tr( "Date" ), QStringLiteral( "date" ), QVariant::Date, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Boolean (bool)" ), QStringLiteral( "bool" ), QVariant::Bool ) )
: provider->nativeTypes() };

<< QgsVectorDataProvider::NativeType( tr( "Time" ), QStringLiteral( "time" ), QVariant::Time, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Date & Time" ), QStringLiteral( "datetime" ), QVariant::DateTime, -1, -1, -1, -1 )
// string types
<< QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (text)" ), QStringLiteral( "text" ), QVariant::String, -1, -1, -1, -1 )
// boolean
<< QgsVectorDataProvider::NativeType( tr( "Boolean" ), QStringLiteral( "bool" ), QVariant::Bool )
// blob
<< QgsVectorDataProvider::NativeType( tr( "Binary object (BLOB)" ), QStringLiteral( "binary" ), QVariant::ByteArray ) ) :
provider->nativeTypes() };

mOutputFieldTypeComboBox->clear();
for ( int i = 0; i < typelist.size(); i++ )
{
mOutputFieldTypeComboBox->addItem( typelist[i].mTypeDesc );
@@ -427,6 +435,7 @@ void QgsFieldCalculator::mCreateVirtualFieldCheckbox_stateChanged( int state )
{
mEditModeAutoTurnOnLabel->setVisible( true );
}
populateOutputFieldTypes();
mInfoIcon->setVisible( mOnlyVirtualFieldsInfoLabel->isVisible() || mEditModeAutoTurnOnLabel->isVisible() );
}

0 comments on commit 9faf07d

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