@@ -137,7 +137,8 @@ void QgsDb2ConnectionItem::refresh()
137
137
QVector<QgsDataItem *> items = createChildren ();
138
138
139
139
// Add new items
140
- Q_FOREACH ( QgsDataItem *item, items )
140
+ const auto constItems = items;
141
+ for ( QgsDataItem *item : constItems )
141
142
{
142
143
// Is it present in children?
143
144
int index = findItem ( mChildren , item );
@@ -202,7 +203,8 @@ QVector<QgsDataItem *> QgsDb2ConnectionItem::createChildren()
202
203
while ( db2GC.populateLayerProperty ( layer ) )
203
204
{
204
205
QgsDb2SchemaItem *schemaItem = nullptr ;
205
- Q_FOREACH ( QgsDataItem *child, children )
206
+ const auto constChildren = children;
207
+ for ( QgsDataItem *child : constChildren )
206
208
{
207
209
if ( child->name () == layer.schemaName )
208
210
{
@@ -325,7 +327,8 @@ bool QgsDb2ConnectionItem::handleDrop( const QMimeData *data, const QString &toS
325
327
bool hasError = false ;
326
328
327
329
QgsMimeDataUtils::UriList lst = QgsMimeDataUtils::decodeUriList ( data );
328
- Q_FOREACH ( const QgsMimeDataUtils::Uri &u, lst )
330
+ const auto constLst = lst;
331
+ for ( const QgsMimeDataUtils::Uri &u : constLst )
329
332
{
330
333
if ( u.layerType != QLatin1String ( " vector" ) )
331
334
{
@@ -415,7 +418,8 @@ QVector<QgsDataItem *> QgsDb2RootItem::createChildren()
415
418
QVector<QgsDataItem *> connections;
416
419
QgsSettings settings;
417
420
settings.beginGroup ( QStringLiteral ( " /DB2/connections" ) );
418
- Q_FOREACH ( const QString &connName, settings.childGroups () )
421
+ const auto constChildGroups = settings.childGroups ();
422
+ for ( const QString &connName : constChildGroups )
419
423
{
420
424
connections << new QgsDb2ConnectionItem ( this , connName, mPath + " /" + connName );
421
425
}
@@ -498,7 +502,8 @@ QVector<QgsDataItem *> QgsDb2SchemaItem::createChildren()
498
502
499
503
QVector<QgsDataItem *>items;
500
504
501
- Q_FOREACH ( QgsDataItem *child, this ->children () )
505
+ const auto constChildren = this ->children ();
506
+ for ( QgsDataItem *child : constChildren )
502
507
{
503
508
items.append ( ( ( QgsDb2LayerItem * )child )->createClone () );
504
509
}
@@ -508,7 +513,8 @@ QVector<QgsDataItem *> QgsDb2SchemaItem::createChildren()
508
513
void QgsDb2SchemaItem::addLayers ( QgsDataItem *newLayers )
509
514
{
510
515
// Add new items
511
- Q_FOREACH ( QgsDataItem *child, newLayers->children () )
516
+ const auto constChildren = newLayers->children ();
517
+ for ( QgsDataItem *child : constChildren )
512
518
{
513
519
// Is it present in children?
514
520
if ( findItem ( mChildren , child ) >= 0 )
0 commit comments