Skip to content

Commit 1969e09

Browse files
committed
Also avoid detaching QgsFields and QgsAttributes where possible
1 parent 9a94132 commit 1969e09

File tree

62 files changed

+206
-206
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

62 files changed

+206
-206
lines changed

src/analysis/vector/qgsgeometryanalyzer.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -485,8 +485,8 @@ bool QgsGeometryAnalyzer::convexHull( QgsVectorLayer* layer, const QString& shap
485485
values = simpleMeasure( dissolveGeometry );
486486
QgsAttributes attributes( 3 );
487487
attributes[0] = QVariant( currentKey );
488-
attributes[1] = values[ 0 ];
489-
attributes[2] = values[ 1 ];
488+
attributes[1] = values.at( 0 );
489+
attributes[2] = values.at( 1 );
490490
QgsFeature dissolveFeature;
491491
dissolveFeature.setAttributes( attributes );
492492
dissolveFeature.setGeometry( dissolveGeometry );

src/analysis/vector/qgsoverlayanalyzer.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -185,7 +185,7 @@ void QgsOverlayAnalyzer::combineFieldLists( QgsFields& fieldListA, const QgsFiel
185185
{
186186
QList<QString> names;
187187
for ( int idx = 0; idx < fieldListA.count(); ++idx )
188-
names.append( fieldListA[idx].name() );
188+
names.append( fieldListA.at( idx ).name() );
189189

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

src/app/qgisapp.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -6164,14 +6164,14 @@ void QgisApp::mergeAttributesOfSelectedFeatures()
61646164

61656165
QVariant val = merged.at( i );
61666166
// convert to destination data type
6167-
if ( ! vl->fields()[i].convertCompatible( val ) )
6167+
if ( ! vl->fields().at( i ).convertCompatible( val ) )
61686168
{
61696169
if ( firstFeature )
61706170
{
61716171
//only warn on first feature
61726172
messageBar()->pushMessage(
61736173
tr( "Invalid result" ),
6174-
tr( "Could not store value '%1' in field of type %2" ).arg( merged.at( i ).toString(), vl->fields()[i].typeName() ),
6174+
tr( "Could not store value '%1' in field of type %2" ).arg( merged.at( i ).toString(), vl->fields().at( i ).typeName() ),
61756175
QgsMessageBar::WARNING );
61766176
}
61776177
}
@@ -6301,11 +6301,11 @@ void QgisApp::mergeSelectedFeatures()
63016301
{
63026302
QVariant val = attrs.at( i );
63036303
// convert to destination data type
6304-
if ( ! vl->fields()[i].convertCompatible( val ) )
6304+
if ( ! vl->fields().at( i ).convertCompatible( val ) )
63056305
{
63066306
messageBar()->pushMessage(
63076307
tr( "Invalid result" ),
6308-
tr( "Could not store value '%1' in field of type %2" ).arg( attrs.at( i ).toString(), vl->fields()[i].typeName() ),
6308+
tr( "Could not store value '%1' in field of type %2" ).arg( attrs.at( i ).toString(), vl->fields().at( i ).typeName() ),
63096309
QgsMessageBar::WARNING );
63106310
}
63116311
attrs[i] = val;
@@ -6527,13 +6527,13 @@ void QgisApp::editPaste( QgsMapLayer *destinationLayer )
65276527
if ( pkAttrList.contains( dst ) )
65286528
{
65296529
dstAttr[ dst ] = pasteVectorLayer->dataProvider()->defaultValue( dst );
6530-
if ( !dstAttr[ dst ].isNull() )
6530+
if ( !dstAttr.at( dst ).isNull() )
65316531
continue;
65326532
else if ( pasteVectorLayer->providerType() == "spatialite" )
65336533
continue;
65346534
}
65356535

6536-
dstAttr[ dst ] = srcAttr[ src ];
6536+
dstAttr[ dst ] = srcAttr.at( src );
65376537
}
65386538

65396539
featureIt->setAttributes( dstAttr );

src/app/qgsattributetabledialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -389,7 +389,7 @@ void QgsAttributeTableDialog::runFieldCalculation( QgsVectorLayer* layer, const
389389
<< QgsExpressionContextUtils::projectScope()
390390
<< QgsExpressionContextUtils::layerScope( layer );
391391

392-
QgsField fld = layer->fields()[ fieldindex ];
392+
QgsField fld = layer->fields().at( fieldindex );
393393

394394
//go through all the features and change the new attributes
395395
QgsFeatureIterator fit = layer->getFeatures( request );

src/app/qgsattributetypedialog.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ QgsAttributeTypeDialog::QgsAttributeTypeDialog( QgsVectorLayer *vl, int fieldIdx
4343
, mFieldIdx( fieldIdx )
4444
{
4545
setupUi( this );
46-
setWindowTitle( tr( "Edit Widget Properties - %1 (%2)" ).arg( vl->fields()[fieldIdx].name(), vl->name() ) );
46+
setWindowTitle( tr( "Edit Widget Properties - %1 (%2)" ).arg( vl->fields().at( fieldIdx ).name(), vl->name() ) );
4747

4848
connect( selectionListWidget, SIGNAL( currentRowChanged( int ) ), this, SLOT( setStackPage( int ) ) );
4949

src/app/qgsclipboard.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -91,7 +91,7 @@ void QgsClipboard::setSystemClipboard()
9191

9292
for ( int idx = 0; idx < mFeatureFields.count(); ++idx )
9393
{
94-
textFields += mFeatureFields[idx].name();
94+
textFields += mFeatureFields.at( idx ).name();
9595
}
9696
textLines += textFields.join( "\t" );
9797
textFields.clear();
@@ -116,7 +116,7 @@ void QgsClipboard::setSystemClipboard()
116116
for ( int idx = 0; idx < attributes.count(); ++idx )
117117
{
118118
// QgsDebugMsg(QString("inspecting field '%1'.").arg(it2->toString()));
119-
textFields += attributes[idx].toString();
119+
textFields += attributes.at( idx ).toString();
120120
}
121121

122122
textLines += textFields.join( "\t" );

src/app/qgsdxfexportdialog.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ void FieldSelectorDelegate::setEditorData( QWidget *editor, const QModelIndex &i
7272

7373
int idx = m->attributeIndex( vl );
7474
if ( vl->fields().exists( idx ) )
75-
fcb->setField( vl->fields()[ idx ].name() );
75+
fcb->setField( vl->fields().at( idx ).name() );
7676
}
7777

7878
void FieldSelectorDelegate::setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const
@@ -217,7 +217,7 @@ QVariant QgsVectorLayerAndAttributeModel::data( const QModelIndex& idx, int role
217217
if ( role == Qt::DisplayRole )
218218
{
219219
if ( vl->fields().exists( idx ) )
220-
return vl->fields()[ idx ].name();
220+
return vl->fields().at( idx ).name();
221221
else
222222
return vl->name();
223223
}

src/app/qgsfeatureaction.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -231,10 +231,10 @@ void QgsFeatureAction::onFeatureSaved( const QgsFeature& feature )
231231
{
232232
QgsAttributes newValues = feature.attributes();
233233
QgsAttributeMap origValues = sLastUsedValues[ mLayer ];
234-
if ( origValues[idx] != newValues[idx] )
234+
if ( origValues[idx] != newValues.at( idx ) )
235235
{
236236
QgsDebugMsg( QString( "saving %1 for %2" ).arg( sLastUsedValues[ mLayer ][idx].toString() ).arg( idx ) );
237-
sLastUsedValues[ mLayer ][idx] = newValues[idx];
237+
sLastUsedValues[ mLayer ][idx] = newValues.at( idx );
238238
}
239239
}
240240
}

src/app/qgsfieldcalculator.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -252,7 +252,7 @@ void QgsFieldCalculator::accept()
252252
bool useGeometry = exp.needsGeometry();
253253
int rownum = 1;
254254

255-
QgsField field = mVectorLayer->fields()[mAttributeId];
255+
QgsField field = mVectorLayer->fields().at( mAttributeId );
256256

257257
bool newField = !mUpdateExistingGroupBox->isChecked();
258258
QVariant emptyAttribute;

src/app/qgsidentifyresultsdialog.cpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -471,7 +471,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat
471471
if ( i >= fields.count() )
472472
continue;
473473

474-
QString value = fields[i].displayString( attrs[i] );
474+
QString value = fields.at( i ).displayString( attrs.at( i ) );
475475
QTreeWidgetItem *attrItem = new QTreeWidgetItem( QStringList() << QString::number( i ) << value );
476476

477477
attrItem->setData( 0, Qt::DisplayRole, vlayer->attributeDisplayName( i ) );
@@ -486,7 +486,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat
486486
continue;
487487
}
488488

489-
value = representValue( vlayer, fields[i].name(), attrs[i] );
489+
value = representValue( vlayer, fields[i].name(), attrs.at( i ) );
490490

491491
attrItem->setData( 1, Qt::DisplayRole, value );
492492

@@ -513,8 +513,8 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat
513513
if ( i >= fields.count() )
514514
continue;
515515

516-
QString value = fields[i].displayString( attrs[i] );
517-
QString value2 = representValue( vlayer, fields[i].name(), value );
516+
QString value = fields.at( i ).displayString( attrs.at( i ) );
517+
QString value2 = representValue( vlayer, fields.at( i ).name(), value );
518518

519519
tblResults->setRowCount( j + 1 );
520520

@@ -734,11 +734,11 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer,
734734
if ( i >= fields.count() )
735735
continue;
736736

737-
QTreeWidgetItem *attrItem = new QTreeWidgetItem( QStringList() << QString::number( i ) << attrs[i].toString() );
737+
QTreeWidgetItem *attrItem = new QTreeWidgetItem( QStringList() << QString::number( i ) << attrs.at( i ).toString() );
738738

739739
attrItem->setData( 0, Qt::DisplayRole, fields[i].name() );
740740

741-
QVariant value = attrs[i];
741+
QVariant value = attrs.at( i );
742742
attrItem->setData( 1, Qt::DisplayRole, value );
743743
featItem->addChild( attrItem );
744744
}

0 commit comments

Comments
 (0)