Skip to content

Commit

Permalink
Switch some for-based loops over fields to Q_FOREACH
Browse files Browse the repository at this point in the history
  • Loading branch information
m-kuhn committed Mar 9, 2016
1 parent f27d36c commit f4c5106
Show file tree
Hide file tree
Showing 5 changed files with 10 additions and 13 deletions.
4 changes: 2 additions & 2 deletions src/analysis/vector/qgsoverlayanalyzer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,8 +184,8 @@ void QgsOverlayAnalyzer::intersectFeature( QgsFeature& f, QgsVectorFileWriter* v
void QgsOverlayAnalyzer::combineFieldLists( QgsFields& fieldListA, const QgsFields& fieldListB )
{
QList<QString> names;
for ( int idx = 0; idx < fieldListA.count(); ++idx )
names.append( fieldListA.at( idx ).name() );
Q_FOREACH ( const QgsField& field, fieldListA )
names.append( field.name() );

for ( int idx = 0; idx < fieldListB.count(); ++idx )
{
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsattributeactiondialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -68,8 +68,8 @@ QgsAttributeActionDialog::QgsAttributeActionDialog( QgsAttributeAction* actions,
// Populate the combo box with the field names. Will the field names
// change? If so, they need to be passed into the init() call, or
// some access to them retained in this class.
for ( int idx = 0; idx < fields.count(); ++idx )
fieldComboBox->addItem( fields[idx].name() );
Q_FOREACH ( const QgsField& field, fields )
fieldComboBox->addItem( field.name() );
}

void QgsAttributeActionDialog::init()
Expand Down
4 changes: 2 additions & 2 deletions src/app/qgsclipboard.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -91,9 +91,9 @@ void QgsClipboard::setSystemClipboard()
textFields += "wkt_geom";
}

for ( int idx = 0; idx < mFeatureFields.count(); ++idx )
Q_FOREACH ( const QgsField& field, mFeatureFields )
{
textFields += mFeatureFields.at( idx ).name();
textFields += field.name();
}
textLines += textFields.join( "\t" );
textFields.clear();
Expand Down
5 changes: 2 additions & 3 deletions src/app/qgsjoindialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -146,10 +146,9 @@ void QgsJoinDialog::joinedLayerChanged( QgsMapLayer* layer )

mUseJoinFieldsSubset->setChecked( false );
QStandardItemModel* subsetModel = new QStandardItemModel( this );
const QgsFields& layerFields = vLayer->fields();
for ( int idx = 0; idx < layerFields.count(); ++idx )
Q_FOREACH ( const QgsField& field, vLayer->fields() )
{
QStandardItem* subsetItem = new QStandardItem( layerFields[idx].name() );
QStandardItem* subsetItem = new QStandardItem( field.name() );
subsetItem->setCheckable( true );
//subsetItem->setFlags( subsetItem->flags() | Qt::ItemIsUserCheckable );
subsetModel->appendRow( subsetItem );
Expand Down
6 changes: 2 additions & 4 deletions src/core/qgsvectordataprovider.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -226,11 +226,9 @@ QString QgsVectorDataProvider::capabilitiesString() const

int QgsVectorDataProvider::fieldNameIndex( const QString& fieldName ) const
{
const QgsFields &theFields = fields();

for ( int i = 0; i < theFields.count(); ++i )
Q_FOREACH ( const QgsField& field, fields() )
{
if ( QString::compare( theFields[i].name(), fieldName, Qt::CaseInsensitive ) == 0 )
if ( QString::compare( field.name(), fieldName, Qt::CaseInsensitive ) == 0 )
{
return i;
}
Expand Down

0 comments on commit f4c5106

Please sign in to comment.