Skip to content
Permalink
Browse files

More Q_FOREACH removal

  • Loading branch information
elpaso committed Sep 8, 2017
1 parent 8abf6dc commit 9d7273dadc3fd42d103fbe64b7640d1fe0e5aa11
Showing with 8 additions and 7 deletions.
  1. +6 −6 src/providers/ogr/qgsgeopackagedataitems.cpp
  2. +2 −1 src/providers/ogr/qgsogrdataitems.cpp
@@ -197,8 +197,8 @@ bool QgsGeoPackageConnectionItem::handleDrop( const QMimeData *data, Qt::DropAct
QStringList importResults;
bool hasError = false;

QgsMimeDataUtils::UriList lst = QgsMimeDataUtils::decodeUriList( data );
Q_FOREACH ( const QgsMimeDataUtils::Uri &dropUri, lst )
const QgsMimeDataUtils::UriList lst = QgsMimeDataUtils::decodeUriList( data );
for ( const QgsMimeDataUtils::Uri &dropUri : lst )
{
// Check that we are not copying over self
if ( dropUri.uri.startsWith( mPath ) )
@@ -239,8 +239,7 @@ bool QgsGeoPackageConnectionItem::handleDrop( const QMimeData *data, Qt::DropAct

// check if the destination layer already exists
bool exists = false;
// Q_FOREACH won't detach ...
const QVector< QgsDataItem *> c = children();
const QVector< QgsDataItem *> c( children() );
for ( const auto child : c )
{
if ( child->name() == dropUri.name )
@@ -380,7 +379,7 @@ bool QgsGeoPackageConnectionItem::deleteGeoPackageRasterLayer( const QString uri
QStringList optionalTables;
optionalTables << QStringLiteral( "gpkg_extensions" )
<< QStringLiteral( "gpkg_metadata_reference" );
Q_FOREACH ( const QString &tableName, optionalTables )
for ( const QString &tableName : qgsAsConst( optionalTables ) )
{
char *sql = sqlite3_mprintf( "DELETE FROM %w WHERE table_name = '%q'",
tableName.toUtf8().constData(),
@@ -496,7 +495,8 @@ void QgsGeoPackageAbstractLayerItem::deleteLayer()
{
// Check if the layer is in the registry
const QgsMapLayer *projectLayer = nullptr;
Q_FOREACH ( const QgsMapLayer *layer, QgsProject::instance()->mapLayers() )
const QMap<QString, QgsMapLayer *> mapLayers( QgsProject::instance()->mapLayers() );
for ( const QgsMapLayer *layer : mapLayers )
{
if ( layer->publicSource() == mUri )
{
@@ -217,7 +217,8 @@ QList<QgsOgrDbLayerInfo *> QgsOgrLayerItem::subLayers( const QString &path, cons
QgsRasterLayer rlayer( path, QStringLiteral( "gdal_tmp" ), QStringLiteral( "gdal" ), false );
if ( rlayer.dataProvider()->subLayers( ).size() > 0 )
{
Q_FOREACH ( const QString &uri, rlayer.dataProvider()->subLayers( ) )
const QStringList layers( rlayer.dataProvider()->subLayers( ) );
for ( const QString &uri : layers )
{
QStringList pieces = uri.split( ':' );
QString name = pieces.value( pieces.length() - 1 );

0 comments on commit 9d7273d

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