Skip to content

Commit f4c5106

Browse files
committed
Switch some for-based loops over fields to Q_FOREACH
1 parent f27d36c commit f4c5106

File tree

5 files changed

+10
-13
lines changed

5 files changed

+10
-13
lines changed

src/analysis/vector/qgsoverlayanalyzer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -184,8 +184,8 @@ void QgsOverlayAnalyzer::intersectFeature( QgsFeature& f, QgsVectorFileWriter* v
184184
void QgsOverlayAnalyzer::combineFieldLists( QgsFields& fieldListA, const QgsFields& fieldListB )
185185
{
186186
QList<QString> names;
187-
for ( int idx = 0; idx < fieldListA.count(); ++idx )
188-
names.append( fieldListA.at( idx ).name() );
187+
Q_FOREACH ( const QgsField& field, fieldListA )
188+
names.append( field.name() );
189189

190190
for ( int idx = 0; idx < fieldListB.count(); ++idx )
191191
{

src/app/qgsattributeactiondialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -68,8 +68,8 @@ QgsAttributeActionDialog::QgsAttributeActionDialog( QgsAttributeAction* actions,
6868
// Populate the combo box with the field names. Will the field names
6969
// change? If so, they need to be passed into the init() call, or
7070
// some access to them retained in this class.
71-
for ( int idx = 0; idx < fields.count(); ++idx )
72-
fieldComboBox->addItem( fields[idx].name() );
71+
Q_FOREACH ( const QgsField& field, fields )
72+
fieldComboBox->addItem( field.name() );
7373
}
7474

7575
void QgsAttributeActionDialog::init()

src/app/qgsclipboard.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,9 +91,9 @@ void QgsClipboard::setSystemClipboard()
9191
textFields += "wkt_geom";
9292
}
9393

94-
for ( int idx = 0; idx < mFeatureFields.count(); ++idx )
94+
Q_FOREACH ( const QgsField& field, mFeatureFields )
9595
{
96-
textFields += mFeatureFields.at( idx ).name();
96+
textFields += field.name();
9797
}
9898
textLines += textFields.join( "\t" );
9999
textFields.clear();

src/app/qgsjoindialog.cpp

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -146,10 +146,9 @@ void QgsJoinDialog::joinedLayerChanged( QgsMapLayer* layer )
146146

147147
mUseJoinFieldsSubset->setChecked( false );
148148
QStandardItemModel* subsetModel = new QStandardItemModel( this );
149-
const QgsFields& layerFields = vLayer->fields();
150-
for ( int idx = 0; idx < layerFields.count(); ++idx )
149+
Q_FOREACH ( const QgsField& field, vLayer->fields() )
151150
{
152-
QStandardItem* subsetItem = new QStandardItem( layerFields[idx].name() );
151+
QStandardItem* subsetItem = new QStandardItem( field.name() );
153152
subsetItem->setCheckable( true );
154153
//subsetItem->setFlags( subsetItem->flags() | Qt::ItemIsUserCheckable );
155154
subsetModel->appendRow( subsetItem );

src/core/qgsvectordataprovider.cpp

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -226,11 +226,9 @@ QString QgsVectorDataProvider::capabilitiesString() const
226226

227227
int QgsVectorDataProvider::fieldNameIndex( const QString& fieldName ) const
228228
{
229-
const QgsFields &theFields = fields();
230-
231-
for ( int i = 0; i < theFields.count(); ++i )
229+
Q_FOREACH ( const QgsField& field, fields() )
232230
{
233-
if ( QString::compare( theFields[i].name(), fieldName, Qt::CaseInsensitive ) == 0 )
231+
if ( QString::compare( field.name(), fieldName, Qt::CaseInsensitive ) == 0 )
234232
{
235233
return i;
236234
}

0 commit comments

Comments
 (0)