Skip to content

Commit 2dd5507

Browse files
committedFeb 8, 2019
Modernize code FOREACH -> range for
1 parent 7f61dc4 commit 2dd5507

File tree

1 file changed

+7
-7
lines changed

1 file changed

+7
-7
lines changed
 

‎src/providers/spatialite/qgsspatialiteprovider.cpp

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -462,8 +462,8 @@ QgsSpatiaLiteProvider::QgsSpatiaLiteProvider( QString const &uri, const Provider
462462
mSqliteHandle = mHandle->handle();
463463
if ( mSqliteHandle )
464464
{
465-
QStringList pragmaList = anUri.params( QStringLiteral( "pragma" ) );
466-
Q_FOREACH ( const QString &pragma, pragmaList )
465+
const QStringList pragmaList = anUri.params( QStringLiteral( "pragma" ) );
466+
for ( const auto &pragma : pragmaList )
467467
{
468468
char *errMsg = nullptr;
469469
int ret = sqlite3_exec( mSqliteHandle, ( "PRAGMA " + pragma ).toUtf8(), nullptr, nullptr, &errMsg );
@@ -882,8 +882,8 @@ void QgsSpatiaLiteProvider::fetchConstraints()
882882
QRegularExpressionMatch match = re.match( sqlDef );
883883
if ( match.hasMatch() )
884884
{
885-
QString matched = match.captured( 1 );
886-
Q_FOREACH ( QString field, matched.split( ',' ) )
885+
const QString matched = match.captured( 1 );
886+
for ( auto &field : matched.split( ',' ) )
887887
{
888888
field = field.trimmed();
889889
QString fieldName = field.left( field.indexOf( ' ' ) );
@@ -904,7 +904,7 @@ void QgsSpatiaLiteProvider::fetchConstraints()
904904
}
905905
sqlite3_free_table( results );
906906

907-
Q_FOREACH ( int fieldIdx, mPrimaryKeyAttrs )
907+
for ( const auto fieldIdx : qgis::as_const( mPrimaryKeyAttrs ) )
908908
{
909909
QgsFieldConstraints constraints = mAttributeFields.at( fieldIdx ).constraints();
910910
constraints.setConstraint( QgsFieldConstraints::ConstraintUnique, QgsFieldConstraints::ConstraintOriginProvider );
@@ -5682,7 +5682,7 @@ QgsAttributeList QgsSpatiaLiteProvider::pkAttributeIndexes() const
56825682
QList<QgsVectorLayer *> QgsSpatiaLiteProvider::searchLayers( const QList<QgsVectorLayer *> &layers, const QString &connectionInfo, const QString &tableName )
56835683
{
56845684
QList<QgsVectorLayer *> result;
5685-
Q_FOREACH ( QgsVectorLayer *layer, layers )
5685+
for ( auto *layer : layers )
56865686
{
56875687
const QgsSpatiaLiteProvider *slProvider = qobject_cast<QgsSpatiaLiteProvider *>( layer->dataProvider() );
56885688
if ( slProvider && slProvider->mSqlitePath == connectionInfo && slProvider->mTableName == tableName )
@@ -5717,7 +5717,7 @@ QList<QgsRelation> QgsSpatiaLiteProvider::discoverRelations( const QgsVectorLaye
57175717
{
57185718
// first reference field => try to find if we have layers for the referenced table
57195719
const QList<QgsVectorLayer *> foundLayers = searchLayers( layers, mSqlitePath, refTable );
5720-
Q_FOREACH ( const QgsVectorLayer *foundLayer, foundLayers )
5720+
for ( const auto *foundLayer : foundLayers )
57215721
{
57225722
QgsRelation relation;
57235723
relation.setName( name );

0 commit comments

Comments
 (0)
Please sign in to comment.