Skip to content

Commit

Permalink
Fix integer64 -> longlong type naming
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso authored and nyalldawson committed Nov 29, 2021
1 parent cdbb69d commit 5017cf0
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 15 deletions.
27 changes: 18 additions & 9 deletions src/providers/delimitedtext/qgsdelimitedtextprovider.cpp
Expand Up @@ -67,7 +67,7 @@ QgsDelimitedTextProvider::QgsDelimitedTextProvider( const QString &uri, const Pr
// Add supported types to enable creating expression fields in field calculator
setNativeTypes( QList< NativeType >()
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer)" ), QStringLiteral( "integer" ), QVariant::Int, 0, 10 )
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer - 64 bit)" ), QStringLiteral( "integer64" ), QVariant::LongLong )
<< QgsVectorDataProvider::NativeType( tr( "Whole number (integer - 64 bit)" ), QStringLiteral( "longlong" ), QVariant::LongLong )
<< QgsVectorDataProvider::NativeType( tr( "Decimal number (double)" ), QStringLiteral( "double" ), QVariant::Double, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Boolean" ), QStringLiteral( "bool" ), QVariant::Bool, -1, -1, -1, -1 )
<< QgsVectorDataProvider::NativeType( tr( "Text, unlimited length (text)" ), QStringLiteral( "text" ), QVariant::String, -1, -1, -1, -1 )
Expand Down Expand Up @@ -810,11 +810,23 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes, bool forceFullScan,
if ( fieldIdx < csvtTypes.size() )
{
typeName = csvtTypes[fieldIdx];
// Map XY geometries types to actual values
// Map CSVT types to provider types
if ( typeName == QStringLiteral( "coordx" ) || typeName == QStringLiteral( "coordy" ) || typeName == QStringLiteral( "point(x)" ) || typeName == QStringLiteral( "point(y)" ) )
{
typeName = QStringLiteral( "double" );
}
else if ( typeName == QStringLiteral( "long" ) || typeName == QStringLiteral( "integer64" ) )
{
typeName = QStringLiteral( "longlong" );
}
else if ( typeName == QStringLiteral( "int8" ) )
{
typeName = QStringLiteral( "integer" );
}
else if ( typeName == QStringLiteral( "real" ) )
{
typeName = QStringLiteral( "double" );
}
}
else if ( mDetectTypes && fieldIdx < couldBeInt.size() )
{
Expand All @@ -828,7 +840,7 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes, bool forceFullScan,
}
else if ( couldBeLongLong[fieldIdx] )
{
typeName = QStringLiteral( "integer64" );
typeName = QStringLiteral( "longlong" );
}
else if ( couldBeDouble[fieldIdx] )
{
Expand All @@ -854,19 +866,16 @@ void QgsDelimitedTextProvider::scanFile( bool buildIndexes, bool forceFullScan,
fieldType = QVariant::Bool;
mFieldBooleanLiterals.insert( fieldIdx, boolCandidates[fieldIdx] );
}
else if ( typeName == QLatin1String( "integer" ) || typeName == QLatin1String( "int8" ) )
else if ( typeName == QLatin1String( "integer" ) )
{
typeName = QLatin1String( "integer" );
fieldType = QVariant::Int;
}
else if ( typeName == QLatin1String( "integer64" ) || typeName == QLatin1String( "longlong" ) || typeName == QLatin1String( "long" ) )
else if ( typeName == QLatin1String( "longlong" ) )
{
typeName = QLatin1String( "longlong" );
fieldType = QVariant::LongLong;
}
else if ( typeName == QLatin1String( "real" ) || typeName == QLatin1String( "double" ) )
else if ( typeName == QLatin1String( "double" ) )
{
typeName = QStringLiteral( "double" );
fieldType = QVariant::Double;
}
else if ( typeName == QLatin1String( "datetime" ) )
Expand Down
11 changes: 5 additions & 6 deletions src/providers/delimitedtext/qgsdelimitedtextsourceselect.cpp
Expand Up @@ -504,7 +504,7 @@ void QgsDelimitedTextSourceSelect::updateFieldLists()
QComboBox *typeCombo = new QComboBox( tblSample );
typeCombo->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldText.svg" ) ), tr( "Text" ), "text" );
typeCombo->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldInteger.svg" ) ), tr( "Whole Number (integer)" ), "integer" );
typeCombo->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldInteger.svg" ) ), tr( "Whole Number (integer - 64 bit)" ), "integer64" );
typeCombo->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldInteger.svg" ) ), tr( "Whole Number (integer - 64 bit)" ), "longlong" );
typeCombo->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldFloat.svg" ) ), tr( "Decimal Number" ), "double" );
typeCombo->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldBool.svg" ) ), tr( "Boolean" ), "bool" );
typeCombo->addItem( QgsApplication::getThemeIcon( QStringLiteral( "/mIconFieldDate.svg" ) ), tr( "Date" ), "date" );
Expand Down Expand Up @@ -809,9 +809,8 @@ bool QgsDelimitedTextSourceSelect::validate()

void QgsDelimitedTextSourceSelect::updateFieldTypes( const QgsFields &fields )
{
{
mFields = fields;
}

mFields = fields;

for ( int column = 0; column < tblSample->columnCount(); column++ )
{
Expand All @@ -823,9 +822,9 @@ void QgsDelimitedTextSourceSelect::updateFieldTypes( const QgsFields &fields )
{
QComboBox *typeCombo { qobject_cast<QComboBox *>( tblSample->cellWidget( 0, column ) ) };
const QString fieldTypeName { mFields.field( fieldIdx ).typeName() };
if ( typeCombo && typeCombo->findData( fieldTypeName ) >= 0 )
if ( typeCombo && typeCombo->currentData( ) != fieldTypeName && typeCombo->findData( fieldTypeName ) >= 0 )
{
QgsDebugMsgLevel( QStringLiteral( "Setting field type %1 from %2 to %3" ).arg( fieldName, fieldTypeName, typeCombo->currentData().toString() ), 2 );
QgsDebugMsgLevel( QStringLiteral( "Setting field type %1 from %2 to %3" ).arg( fieldName, typeCombo->currentData().toString(), fieldTypeName ), 2 );
QgsSignalBlocker( typeCombo )->setCurrentIndex( typeCombo->findData( fieldTypeName ) );
}
}
Expand Down

0 comments on commit 5017cf0

Please sign in to comment.