mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-15 00:04:00 -04:00
Also avoid detaching QgsFields and QgsAttributes where possible
This commit is contained in:
parent
9a94132fb4
commit
1969e09b6f
@ -485,8 +485,8 @@ bool QgsGeometryAnalyzer::convexHull( QgsVectorLayer* layer, const QString& shap
|
||||
values = simpleMeasure( dissolveGeometry );
|
||||
QgsAttributes attributes( 3 );
|
||||
attributes[0] = QVariant( currentKey );
|
||||
attributes[1] = values[ 0 ];
|
||||
attributes[2] = values[ 1 ];
|
||||
attributes[1] = values.at( 0 );
|
||||
attributes[2] = values.at( 1 );
|
||||
QgsFeature dissolveFeature;
|
||||
dissolveFeature.setAttributes( attributes );
|
||||
dissolveFeature.setGeometry( dissolveGeometry );
|
||||
|
@ -185,7 +185,7 @@ void QgsOverlayAnalyzer::combineFieldLists( QgsFields& fieldListA, const QgsFiel
|
||||
{
|
||||
QList<QString> names;
|
||||
for ( int idx = 0; idx < fieldListA.count(); ++idx )
|
||||
names.append( fieldListA[idx].name() );
|
||||
names.append( fieldListA.at( idx ).name() );
|
||||
|
||||
for ( int idx = 0; idx < fieldListB.count(); ++idx )
|
||||
{
|
||||
|
@ -6164,14 +6164,14 @@ void QgisApp::mergeAttributesOfSelectedFeatures()
|
||||
|
||||
QVariant val = merged.at( i );
|
||||
// convert to destination data type
|
||||
if ( ! vl->fields()[i].convertCompatible( val ) )
|
||||
if ( ! vl->fields().at( i ).convertCompatible( val ) )
|
||||
{
|
||||
if ( firstFeature )
|
||||
{
|
||||
//only warn on first feature
|
||||
messageBar()->pushMessage(
|
||||
tr( "Invalid result" ),
|
||||
tr( "Could not store value '%1' in field of type %2" ).arg( merged.at( i ).toString(), vl->fields()[i].typeName() ),
|
||||
tr( "Could not store value '%1' in field of type %2" ).arg( merged.at( i ).toString(), vl->fields().at( i ).typeName() ),
|
||||
QgsMessageBar::WARNING );
|
||||
}
|
||||
}
|
||||
@ -6301,11 +6301,11 @@ void QgisApp::mergeSelectedFeatures()
|
||||
{
|
||||
QVariant val = attrs.at( i );
|
||||
// convert to destination data type
|
||||
if ( ! vl->fields()[i].convertCompatible( val ) )
|
||||
if ( ! vl->fields().at( i ).convertCompatible( val ) )
|
||||
{
|
||||
messageBar()->pushMessage(
|
||||
tr( "Invalid result" ),
|
||||
tr( "Could not store value '%1' in field of type %2" ).arg( attrs.at( i ).toString(), vl->fields()[i].typeName() ),
|
||||
tr( "Could not store value '%1' in field of type %2" ).arg( attrs.at( i ).toString(), vl->fields().at( i ).typeName() ),
|
||||
QgsMessageBar::WARNING );
|
||||
}
|
||||
attrs[i] = val;
|
||||
@ -6527,13 +6527,13 @@ void QgisApp::editPaste( QgsMapLayer *destinationLayer )
|
||||
if ( pkAttrList.contains( dst ) )
|
||||
{
|
||||
dstAttr[ dst ] = pasteVectorLayer->dataProvider()->defaultValue( dst );
|
||||
if ( !dstAttr[ dst ].isNull() )
|
||||
if ( !dstAttr.at( dst ).isNull() )
|
||||
continue;
|
||||
else if ( pasteVectorLayer->providerType() == "spatialite" )
|
||||
continue;
|
||||
}
|
||||
|
||||
dstAttr[ dst ] = srcAttr[ src ];
|
||||
dstAttr[ dst ] = srcAttr.at( src );
|
||||
}
|
||||
|
||||
featureIt->setAttributes( dstAttr );
|
||||
|
@ -389,7 +389,7 @@ void QgsAttributeTableDialog::runFieldCalculation( QgsVectorLayer* layer, const
|
||||
<< QgsExpressionContextUtils::projectScope()
|
||||
<< QgsExpressionContextUtils::layerScope( layer );
|
||||
|
||||
QgsField fld = layer->fields()[ fieldindex ];
|
||||
QgsField fld = layer->fields().at( fieldindex );
|
||||
|
||||
//go through all the features and change the new attributes
|
||||
QgsFeatureIterator fit = layer->getFeatures( request );
|
||||
|
@ -43,7 +43,7 @@ QgsAttributeTypeDialog::QgsAttributeTypeDialog( QgsVectorLayer *vl, int fieldIdx
|
||||
, mFieldIdx( fieldIdx )
|
||||
{
|
||||
setupUi( this );
|
||||
setWindowTitle( tr( "Edit Widget Properties - %1 (%2)" ).arg( vl->fields()[fieldIdx].name(), vl->name() ) );
|
||||
setWindowTitle( tr( "Edit Widget Properties - %1 (%2)" ).arg( vl->fields().at( fieldIdx ).name(), vl->name() ) );
|
||||
|
||||
connect( selectionListWidget, SIGNAL( currentRowChanged( int ) ), this, SLOT( setStackPage( int ) ) );
|
||||
|
||||
|
@ -91,7 +91,7 @@ void QgsClipboard::setSystemClipboard()
|
||||
|
||||
for ( int idx = 0; idx < mFeatureFields.count(); ++idx )
|
||||
{
|
||||
textFields += mFeatureFields[idx].name();
|
||||
textFields += mFeatureFields.at( idx ).name();
|
||||
}
|
||||
textLines += textFields.join( "\t" );
|
||||
textFields.clear();
|
||||
@ -116,7 +116,7 @@ void QgsClipboard::setSystemClipboard()
|
||||
for ( int idx = 0; idx < attributes.count(); ++idx )
|
||||
{
|
||||
// QgsDebugMsg(QString("inspecting field '%1'.").arg(it2->toString()));
|
||||
textFields += attributes[idx].toString();
|
||||
textFields += attributes.at( idx ).toString();
|
||||
}
|
||||
|
||||
textLines += textFields.join( "\t" );
|
||||
|
@ -72,7 +72,7 @@ void FieldSelectorDelegate::setEditorData( QWidget *editor, const QModelIndex &i
|
||||
|
||||
int idx = m->attributeIndex( vl );
|
||||
if ( vl->fields().exists( idx ) )
|
||||
fcb->setField( vl->fields()[ idx ].name() );
|
||||
fcb->setField( vl->fields().at( idx ).name() );
|
||||
}
|
||||
|
||||
void FieldSelectorDelegate::setModelData( QWidget *editor, QAbstractItemModel *model, const QModelIndex &index ) const
|
||||
@ -217,7 +217,7 @@ QVariant QgsVectorLayerAndAttributeModel::data( const QModelIndex& idx, int role
|
||||
if ( role == Qt::DisplayRole )
|
||||
{
|
||||
if ( vl->fields().exists( idx ) )
|
||||
return vl->fields()[ idx ].name();
|
||||
return vl->fields().at( idx ).name();
|
||||
else
|
||||
return vl->name();
|
||||
}
|
||||
|
@ -231,10 +231,10 @@ void QgsFeatureAction::onFeatureSaved( const QgsFeature& feature )
|
||||
{
|
||||
QgsAttributes newValues = feature.attributes();
|
||||
QgsAttributeMap origValues = sLastUsedValues[ mLayer ];
|
||||
if ( origValues[idx] != newValues[idx] )
|
||||
if ( origValues[idx] != newValues.at( idx ) )
|
||||
{
|
||||
QgsDebugMsg( QString( "saving %1 for %2" ).arg( sLastUsedValues[ mLayer ][idx].toString() ).arg( idx ) );
|
||||
sLastUsedValues[ mLayer ][idx] = newValues[idx];
|
||||
sLastUsedValues[ mLayer ][idx] = newValues.at( idx );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -252,7 +252,7 @@ void QgsFieldCalculator::accept()
|
||||
bool useGeometry = exp.needsGeometry();
|
||||
int rownum = 1;
|
||||
|
||||
QgsField field = mVectorLayer->fields()[mAttributeId];
|
||||
QgsField field = mVectorLayer->fields().at( mAttributeId );
|
||||
|
||||
bool newField = !mUpdateExistingGroupBox->isChecked();
|
||||
QVariant emptyAttribute;
|
||||
|
@ -471,7 +471,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat
|
||||
if ( i >= fields.count() )
|
||||
continue;
|
||||
|
||||
QString value = fields[i].displayString( attrs[i] );
|
||||
QString value = fields.at( i ).displayString( attrs.at( i ) );
|
||||
QTreeWidgetItem *attrItem = new QTreeWidgetItem( QStringList() << QString::number( i ) << value );
|
||||
|
||||
attrItem->setData( 0, Qt::DisplayRole, vlayer->attributeDisplayName( i ) );
|
||||
@ -486,7 +486,7 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat
|
||||
continue;
|
||||
}
|
||||
|
||||
value = representValue( vlayer, fields[i].name(), attrs[i] );
|
||||
value = representValue( vlayer, fields[i].name(), attrs.at( i ) );
|
||||
|
||||
attrItem->setData( 1, Qt::DisplayRole, value );
|
||||
|
||||
@ -513,8 +513,8 @@ void QgsIdentifyResultsDialog::addFeature( QgsVectorLayer *vlayer, const QgsFeat
|
||||
if ( i >= fields.count() )
|
||||
continue;
|
||||
|
||||
QString value = fields[i].displayString( attrs[i] );
|
||||
QString value2 = representValue( vlayer, fields[i].name(), value );
|
||||
QString value = fields.at( i ).displayString( attrs.at( i ) );
|
||||
QString value2 = representValue( vlayer, fields.at( i ).name(), value );
|
||||
|
||||
tblResults->setRowCount( j + 1 );
|
||||
|
||||
@ -734,11 +734,11 @@ void QgsIdentifyResultsDialog::addFeature( QgsRasterLayer *layer,
|
||||
if ( i >= fields.count() )
|
||||
continue;
|
||||
|
||||
QTreeWidgetItem *attrItem = new QTreeWidgetItem( QStringList() << QString::number( i ) << attrs[i].toString() );
|
||||
QTreeWidgetItem *attrItem = new QTreeWidgetItem( QStringList() << QString::number( i ) << attrs.at( i ).toString() );
|
||||
|
||||
attrItem->setData( 0, Qt::DisplayRole, fields[i].name() );
|
||||
|
||||
QVariant value = attrs[i];
|
||||
QVariant value = attrs.at( i );
|
||||
attrItem->setData( 1, Qt::DisplayRole, value );
|
||||
featItem->addChild( attrItem );
|
||||
}
|
||||
|
@ -96,7 +96,7 @@ void QgsLabelPropertyDialog::init( const QString& layerId, int featureId, const
|
||||
mCurLabelField = vlayer->fieldNameIndex( labelFieldName );
|
||||
if ( mCurLabelField >= 0 )
|
||||
{
|
||||
mLabelTextLineEdit->setText( attributeValues[mCurLabelField].toString() );
|
||||
mLabelTextLineEdit->setText( attributeValues.at( mCurLabelField ).toString() );
|
||||
const QgsFields& layerFields = vlayer->fields();
|
||||
switch ( layerFields[mCurLabelField].type() )
|
||||
{
|
||||
|
@ -484,10 +484,10 @@ bool QgsMapToolLabel::dataDefinedPosition( QgsVectorLayer* vlayer, const QgsFeat
|
||||
}
|
||||
|
||||
QgsAttributes attributes = f.attributes();
|
||||
if ( !attributes[xCol].isNull() )
|
||||
x = attributes[xCol].toDouble( &xSuccess );
|
||||
if ( !attributes[yCol].isNull() )
|
||||
y = attributes[yCol].toDouble( &ySuccess );
|
||||
if ( !attributes.at( xCol ).isNull() )
|
||||
x = attributes.at( xCol ).toDouble( &xSuccess );
|
||||
if ( !attributes.at( yCol ).isNull() )
|
||||
y = attributes.at( yCol ).toDouble( &ySuccess );
|
||||
|
||||
return true;
|
||||
}
|
||||
|
@ -127,10 +127,10 @@ void QgsMergeAttributesDialog::createTableWidgetContents()
|
||||
{
|
||||
int idx = mTableWidget->horizontalHeaderItem( j )->data( Qt::UserRole ).toInt();
|
||||
|
||||
QTableWidgetItem* attributeValItem = new QTableWidgetItem( attrs[idx].toString() );
|
||||
QTableWidgetItem* attributeValItem = new QTableWidgetItem( attrs.at( idx ).toString() );
|
||||
attributeValItem->setFlags( Qt::ItemIsEnabled | Qt::ItemIsSelectable );
|
||||
mTableWidget->setItem( i + 1, j, attributeValItem );
|
||||
mTableWidget->setCellWidget( i + 1, j, QgsAttributeEditor::createAttributeEditor( mTableWidget, NULL, mVectorLayer, idx, attrs[idx] ) );
|
||||
mTableWidget->setCellWidget( i + 1, j, QgsAttributeEditor::createAttributeEditor( mTableWidget, NULL, mVectorLayer, idx, attrs.at( idx ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -307,7 +307,7 @@ QVariant QgsMergeAttributesDialog::featureAttribute( int featureId, int col )
|
||||
}
|
||||
else
|
||||
{
|
||||
return QVariant( mVectorLayer->fields()[col].type() );
|
||||
return QVariant( mVectorLayer->fields().at( col ).type() );
|
||||
}
|
||||
}
|
||||
|
||||
@ -333,7 +333,7 @@ QVariant QgsMergeAttributesDialog::minimumAttribute( int col )
|
||||
|
||||
if ( numberOfConsideredFeatures < 1 )
|
||||
{
|
||||
return QVariant( mVectorLayer->fields()[col].type() );
|
||||
return QVariant( mVectorLayer->fields().at( col ).type() );
|
||||
}
|
||||
|
||||
return QVariant( minimumValue );
|
||||
@ -361,7 +361,7 @@ QVariant QgsMergeAttributesDialog::maximumAttribute( int col )
|
||||
|
||||
if ( numberOfConsideredFeatures < 1 )
|
||||
{
|
||||
return QVariant( mVectorLayer->fields()[col].type() );
|
||||
return QVariant( mVectorLayer->fields().at( col ).type() );
|
||||
}
|
||||
|
||||
return QVariant( maximumValue );
|
||||
@ -386,7 +386,7 @@ QVariant QgsMergeAttributesDialog::meanAttribute( int col )
|
||||
|
||||
if ( numberOfConsideredFeatures < 1 )
|
||||
{
|
||||
return QVariant( mVectorLayer->fields()[col].type() );
|
||||
return QVariant( mVectorLayer->fields().at( col ).type() );
|
||||
}
|
||||
|
||||
double mean = sum / numberOfConsideredFeatures;
|
||||
@ -417,7 +417,7 @@ QVariant QgsMergeAttributesDialog::medianAttribute( int col )
|
||||
|
||||
if ( size < 1 )
|
||||
{
|
||||
return QVariant( mVectorLayer->fields()[col].type() );
|
||||
return QVariant( mVectorLayer->fields().at( col ).type() );
|
||||
}
|
||||
|
||||
bool even = ( size % 2 ) < 1;
|
||||
|
@ -93,11 +93,11 @@ QSizeF QgsHistogramDiagram::diagramSize( const QgsAttributes& attributes, const
|
||||
return QSizeF(); //zero size if no attributes
|
||||
}
|
||||
|
||||
double maxValue = attributes[0].toDouble();
|
||||
double maxValue = attributes.at( 0 ).toDouble();
|
||||
|
||||
for ( int i = 0; i < attributes.count(); ++i )
|
||||
{
|
||||
maxValue = qMax( attributes[i].toDouble(), maxValue );
|
||||
maxValue = qMax( attributes.at( i ).toDouble(), maxValue );
|
||||
}
|
||||
|
||||
switch ( s.diagramOrientation )
|
||||
|
@ -2637,7 +2637,7 @@ QString QgsExpression::replaceExpressionText( const QString &action, const QgsFe
|
||||
QgsVectorLayer *layer,
|
||||
const QMap<QString, QVariant> *substitutionMap, const QgsDistanceArea *distanceArea )
|
||||
{
|
||||
QgsExpressionContext context = QgsExpressionContextUtils::createFeatureBasedContext( feat ? *feat : QgsFeature(), layer ? layer->pendingFields() : QgsFields() );
|
||||
QgsExpressionContext context = QgsExpressionContextUtils::createFeatureBasedContext( feat ? *feat : QgsFeature(), layer ? layer->fields() : QgsFields() );
|
||||
return replaceExpressionText( action, &context, substitutionMap, distanceArea );
|
||||
}
|
||||
|
||||
@ -3353,7 +3353,7 @@ bool QgsExpression::NodeColumnRef::prepare( QgsExpression *parent, const QgsExpr
|
||||
|
||||
for ( int i = 0; i < fields.count(); ++i )
|
||||
{
|
||||
if ( QString::compare( fields[i].name(), mName, Qt::CaseInsensitive ) == 0 )
|
||||
if ( QString::compare( fields.at( i ).name(), mName, Qt::CaseInsensitive ) == 0 )
|
||||
{
|
||||
mIndex = i;
|
||||
return true;
|
||||
|
@ -231,7 +231,7 @@ QVariant QgsFeature::attribute( int fieldIdx ) const
|
||||
if ( fieldIdx < 0 || fieldIdx >= d->attributes.count() )
|
||||
return QVariant();
|
||||
|
||||
return d->attributes[fieldIdx];
|
||||
return d->attributes.at( fieldIdx );
|
||||
}
|
||||
|
||||
|
||||
@ -241,7 +241,7 @@ QVariant QgsFeature::attribute( const QString& name ) const
|
||||
if ( fieldIdx == -1 )
|
||||
return QVariant();
|
||||
|
||||
return d->attributes[fieldIdx];
|
||||
return d->attributes.at( fieldIdx );
|
||||
}
|
||||
|
||||
int QgsFeature::fieldNameIndex( const QString& fieldName ) const
|
||||
|
@ -716,7 +716,7 @@ bool QgsLabel::readLabelField( QDomElement &el, int attr, const QString& prefix
|
||||
int idx = 0;
|
||||
for ( ; idx < mFields.count(); ++idx )
|
||||
{
|
||||
if ( mFields[idx].name() == name )
|
||||
if ( mFields.at( idx ).name() == name )
|
||||
{
|
||||
break;
|
||||
}
|
||||
|
@ -622,7 +622,7 @@ QgsVectorLayer* QgsOfflineEditing::copyVectorLayer( QgsVectorLayer* layer, sqlit
|
||||
QgsAttributes newAttrs( attrs.count() );
|
||||
for ( int it = 0; it < attrs.count(); ++it )
|
||||
{
|
||||
newAttrs[column++] = attrs[it];
|
||||
newAttrs[column++] = attrs.at( it );
|
||||
}
|
||||
f.setAttributes( newAttrs );
|
||||
|
||||
@ -747,15 +747,15 @@ void QgsOfflineEditing::applyFeaturesAdded( QgsVectorLayer* offlineLayer, QgsVec
|
||||
QgsAttributes attrs = f.attributes();
|
||||
for ( int it = 0; it < attrs.count(); ++it )
|
||||
{
|
||||
newAttrs[ attrLookup[ it ] ] = attrs[ it ];
|
||||
newAttrs[ attrLookup[ it ] ] = attrs.at( it );
|
||||
}
|
||||
|
||||
// try to use default value from the provider
|
||||
// (important especially e.g. for postgis primary key generated from a sequence)
|
||||
for ( int k = 0; k < newAttrs.count(); ++k )
|
||||
{
|
||||
if ( newAttrs[k].isNull() && !defaultValues[k].isNull() )
|
||||
newAttrs[k] = defaultValues[k];
|
||||
if ( newAttrs.at( k ).isNull() && !defaultValues.at( k ).isNull() )
|
||||
newAttrs[k] = defaultValues.at( k );
|
||||
}
|
||||
|
||||
f.setAttributes( newAttrs );
|
||||
|
@ -355,7 +355,7 @@ void QgsProjectFileTransform::transform0110to1000()
|
||||
int fieldNumber = classificationFieldElem.text().toInt();
|
||||
if ( fieldNumber >= 0 && fieldNumber < theFields.count() )
|
||||
{
|
||||
QDomText fieldName = mDom.createTextNode( theFields[fieldNumber].name() );
|
||||
QDomText fieldName = mDom.createTextNode( theFields.at( fieldNumber ).name() );
|
||||
QDomNode nameNode = classificationFieldElem.firstChild();
|
||||
classificationFieldElem.replaceChild( fieldName, nameNode );
|
||||
}
|
||||
|
@ -193,12 +193,12 @@ QgsFeatureRequest QgsRelation::getReferencedFeatureRequest( const QgsAttributes&
|
||||
if ( referencedField.type() == QVariant::String )
|
||||
{
|
||||
// Use quotes
|
||||
conditions << QString( "\"%1\" = '%2'" ).arg( fieldPair.referencedField(), attributes[referencingIdx].toString() );
|
||||
conditions << QString( "\"%1\" = '%2'" ).arg( fieldPair.referencedField(), attributes.at( referencingIdx ).toString() );
|
||||
}
|
||||
else
|
||||
{
|
||||
// No quotes
|
||||
conditions << QString( "\"%1\" = %2" ).arg( fieldPair.referencedField(), attributes[referencingIdx].toString() );
|
||||
conditions << QString( "\"%1\" = %2" ).arg( fieldPair.referencedField(), attributes.at( referencingIdx ).toString() );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -410,7 +410,7 @@ void QgsVectorDataProvider::fillMinMaxCache()
|
||||
QgsAttributes attrs = f.attributes();
|
||||
for ( QgsAttributeList::const_iterator it = keys.begin(); it != keys.end(); ++it )
|
||||
{
|
||||
const QVariant& varValue = attrs[*it];
|
||||
const QVariant& varValue = attrs.at( *it );
|
||||
|
||||
if ( varValue.isNull() )
|
||||
continue;
|
||||
|
@ -1709,7 +1709,7 @@ OGRFeatureH QgsVectorFileWriter::createFeature( QgsFeature& feature )
|
||||
break;
|
||||
default:
|
||||
mErrorMessage = QObject::tr( "Invalid variant type for field %1[%2]: received %3 with type %4" )
|
||||
.arg( mFields[fldIdx].name() )
|
||||
.arg( mFields.at( fldIdx ).name() )
|
||||
.arg( ogrField )
|
||||
.arg( attrValue.typeName(),
|
||||
attrValue.toString() );
|
||||
@ -1934,7 +1934,7 @@ QgsVectorFileWriter::WriterError QgsVectorFileWriter::writeAsVectorFormat( QgsVe
|
||||
{
|
||||
for ( int i = 0; i < fields.size(); i++ )
|
||||
{
|
||||
if ( fields[i].type() == QVariant::LongLong )
|
||||
if ( fields.at( i ).type() == QVariant::LongLong )
|
||||
{
|
||||
QVariant min = layer->minimumValue( i );
|
||||
QVariant max = layer->maximumValue( i );
|
||||
|
@ -257,7 +257,7 @@ void QgsVectorLayer::setDisplayField( const QString& fldName )
|
||||
|
||||
for ( int idx = 0; idx < mUpdatedFields.count(); ++idx )
|
||||
{
|
||||
QString fldName = mUpdatedFields[idx].name();
|
||||
QString fldName = mUpdatedFields.at( idx ).name();
|
||||
QgsDebugMsg( "Checking field " + fldName + " of " + QString::number( fieldsSize ) + " total" );
|
||||
|
||||
// Check the fields and keep the first one that matches.
|
||||
@ -303,7 +303,7 @@ void QgsVectorLayer::setDisplayField( const QString& fldName )
|
||||
}
|
||||
else
|
||||
{
|
||||
mDisplayField = mUpdatedFields[0].name();
|
||||
mDisplayField = mUpdatedFields.at( 0 ).name();
|
||||
}
|
||||
}
|
||||
|
||||
@ -984,9 +984,9 @@ bool QgsVectorLayer::updateFeature( QgsFeature &f )
|
||||
|
||||
for ( int attr = 0; attr < fa.count(); ++attr )
|
||||
{
|
||||
if ( fa[attr] != ca[attr] )
|
||||
if ( fa.at( attr ) != ca.at( attr ) )
|
||||
{
|
||||
if ( !changeAttributeValue( f.id(), attr, fa[attr], ca[attr] ) )
|
||||
if ( !changeAttributeValue( f.id(), attr, fa.at( attr ), ca.at( attr ) ) )
|
||||
{
|
||||
QgsDebugMsg( QString( "attribute %1 of feature %2 could not be changed." ).arg( attr ).arg( f.id() ) );
|
||||
return false;
|
||||
@ -1820,7 +1820,7 @@ bool QgsVectorLayer::readSymbology( const QDomNode& node, QString& errorMessage
|
||||
int index = aliasElem.attribute( "index" ).toInt();
|
||||
|
||||
if ( index >= 0 && index < fields().count() )
|
||||
field = fields()[ index ].name();
|
||||
field = fields().at( index ).name();
|
||||
}
|
||||
|
||||
mAttributeAliasMap.insert( field, aliasElem.attribute( "name" ) );
|
||||
@ -2220,7 +2220,7 @@ void QgsVectorLayer::remAttributeAlias( int attIndex )
|
||||
if ( attIndex < 0 || attIndex >= fields().count() )
|
||||
return;
|
||||
|
||||
QString name = fields()[ attIndex ].name();
|
||||
QString name = fields().at( attIndex ).name();
|
||||
if ( mAttributeAliasMap.contains( name ) )
|
||||
{
|
||||
mAttributeAliasMap.remove( name );
|
||||
@ -2233,7 +2233,7 @@ void QgsVectorLayer::addAttributeAlias( int attIndex, const QString& aliasString
|
||||
if ( attIndex < 0 || attIndex >= fields().count() )
|
||||
return;
|
||||
|
||||
QString name = fields()[ attIndex ].name();
|
||||
QString name = fields().at( attIndex ).name();
|
||||
|
||||
mAttributeAliasMap.insert( name, aliasString );
|
||||
emit layerModified(); // TODO[MD]: should have a different signal?
|
||||
@ -2275,7 +2275,7 @@ QString QgsVectorLayer::attributeAlias( int attributeIndex ) const
|
||||
if ( attributeIndex < 0 || attributeIndex >= fields().count() )
|
||||
return "";
|
||||
|
||||
QString name = fields()[ attributeIndex ].name();
|
||||
QString name = fields().at( attributeIndex ).name();
|
||||
|
||||
return mAttributeAliasMap.value( name, "" );
|
||||
}
|
||||
@ -2787,7 +2787,7 @@ void QgsVectorLayer::setEditorWidgetV2( int attrIdx, const QString& widgetType )
|
||||
if ( attrIdx < 0 || attrIdx >= mUpdatedFields.count() )
|
||||
return;
|
||||
|
||||
mEditorWidgetV2Types[ mUpdatedFields[ attrIdx ].name()] = widgetType;
|
||||
mEditorWidgetV2Types[ mUpdatedFields.at( attrIdx ).name()] = widgetType;
|
||||
}
|
||||
|
||||
void QgsVectorLayer::setEditorWidgetV2Config( int attrIdx, const QgsEditorWidgetConfig& config )
|
||||
@ -2795,7 +2795,7 @@ void QgsVectorLayer::setEditorWidgetV2Config( int attrIdx, const QgsEditorWidget
|
||||
if ( attrIdx < 0 || attrIdx >= mUpdatedFields.count() )
|
||||
return;
|
||||
|
||||
mEditorWidgetV2Configs[ mUpdatedFields[ attrIdx ].name()] = config;
|
||||
mEditorWidgetV2Configs[ mUpdatedFields.at( attrIdx ).name()] = config;
|
||||
}
|
||||
|
||||
QString QgsVectorLayer::editForm()
|
||||
@ -2864,7 +2864,7 @@ bool QgsVectorLayer::fieldEditable( int idx )
|
||||
if ( mUpdatedFields.fieldOrigin( idx ) == QgsFields::OriginJoin
|
||||
|| mUpdatedFields.fieldOrigin( idx ) == QgsFields::OriginExpression )
|
||||
return false;
|
||||
return mFieldEditables.value( mUpdatedFields[idx].name(), true );
|
||||
return mFieldEditables.value( mUpdatedFields.at( idx ).name(), true );
|
||||
}
|
||||
else
|
||||
return true;
|
||||
@ -2873,7 +2873,7 @@ bool QgsVectorLayer::fieldEditable( int idx )
|
||||
bool QgsVectorLayer::labelOnTop( int idx )
|
||||
{
|
||||
if ( idx >= 0 && idx < mUpdatedFields.count() )
|
||||
return mLabelOnTop.value( mUpdatedFields[idx].name(), false );
|
||||
return mLabelOnTop.value( mUpdatedFields.at( idx ).name(), false );
|
||||
else
|
||||
return false;
|
||||
}
|
||||
@ -2881,13 +2881,13 @@ bool QgsVectorLayer::labelOnTop( int idx )
|
||||
void QgsVectorLayer::setFieldEditable( int idx, bool editable )
|
||||
{
|
||||
if ( idx >= 0 && idx < mUpdatedFields.count() )
|
||||
mFieldEditables[ mUpdatedFields[idx].name()] = editable;
|
||||
mFieldEditables[ mUpdatedFields.at( idx ).name()] = editable;
|
||||
}
|
||||
|
||||
void QgsVectorLayer::setLabelOnTop( int idx, bool onTop )
|
||||
{
|
||||
if ( idx >= 0 && idx < mUpdatedFields.count() )
|
||||
mLabelOnTop[ mUpdatedFields[idx].name()] = onTop;
|
||||
mLabelOnTop[ mUpdatedFields.at( idx ).name()] = onTop;
|
||||
}
|
||||
|
||||
void QgsVectorLayer::setRendererV2( QgsFeatureRendererV2 *r )
|
||||
@ -3714,7 +3714,7 @@ QString QgsVectorLayer::metadata()
|
||||
myMetadata += "<p>";
|
||||
Q_FOREACH ( int idx, pkAttrList )
|
||||
{
|
||||
myMetadata += fields()[ idx ].name() + " ";
|
||||
myMetadata += fields().at( idx ).name() + " ";
|
||||
}
|
||||
myMetadata += "</p>\n";
|
||||
}
|
||||
|
@ -304,7 +304,7 @@ bool QgsVectorLayerEditBuffer::commitChanges( QStringList& commitErrors )
|
||||
QString list = "ERROR: Pending attribute deletes:";
|
||||
Q_FOREACH ( int idx, mDeletedAttributeIds )
|
||||
{
|
||||
list.append( " " + L->pendingFields()[idx].name() );
|
||||
list.append( " " + L->pendingFields().at( idx ).name() );
|
||||
}
|
||||
commitErrors << list;
|
||||
#endif
|
||||
@ -358,8 +358,8 @@ bool QgsVectorLayerEditBuffer::commitChanges( QStringList& commitErrors )
|
||||
|
||||
for ( int i = 0; i < qMin( oldFields.count(), newFields.count() ); ++i )
|
||||
{
|
||||
const QgsField& oldField = oldFields[i];
|
||||
const QgsField& newField = newFields[i];
|
||||
const QgsField& oldField = oldFields.at( i );
|
||||
const QgsField& newField = newFields.at( i );
|
||||
if ( attributeChangesOk && oldField != newField )
|
||||
{
|
||||
commitErrors
|
||||
@ -410,7 +410,7 @@ bool QgsVectorLayerEditBuffer::commitChanges( QStringList& commitErrors )
|
||||
list.append( "\n " + FID_TO_STRING( id ) + "[" );
|
||||
Q_FOREACH ( int idx, mChangedAttributeValues[ id ].keys() )
|
||||
{
|
||||
list.append( QString( " %1:%2" ).arg( L->pendingFields()[idx].name() ).arg( mChangedAttributeValues[id][idx].toString() ) );
|
||||
list.append( QString( " %1:%2" ).arg( L->pendingFields().at( idx ).name() ).arg( mChangedAttributeValues[id][idx].toString() ) );
|
||||
}
|
||||
list.append( " ]" );
|
||||
}
|
||||
@ -501,7 +501,7 @@ bool QgsVectorLayerEditBuffer::commitChanges( QStringList& commitErrors )
|
||||
list.append( " " + FID_TO_STRING( f.id() ) + "[" );
|
||||
for ( int i = 0; i < L->pendingFields().size(); i++ )
|
||||
{
|
||||
list.append( QString( " %1:%2" ).arg( L->pendingFields()[i].name() ).arg( f.attributes()[i].toString() ) );
|
||||
list.append( QString( " %1:%2" ).arg( L->pendingFields().at( i ).name() ).arg( f.attributes()[i].toString() ) );
|
||||
}
|
||||
list.append( " ]" );
|
||||
}
|
||||
|
@ -639,7 +639,7 @@ void QgsVectorLayerFeatureIterator::FetchJoinInfo::addJoinedAttributesCached( Qg
|
||||
const QgsAttributes& featureAttributes = it.value();
|
||||
for ( int i = 0; i < featureAttributes.count(); ++i )
|
||||
{
|
||||
f.setAttribute( index++, featureAttributes[i] );
|
||||
f.setAttribute( index++, featureAttributes.at( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -710,7 +710,7 @@ void QgsVectorLayerFeatureIterator::FetchJoinInfo::addJoinedAttributesDirect( Qg
|
||||
if ( hasSubset )
|
||||
{
|
||||
for ( int i = 0; i < subsetIndices.count(); ++i )
|
||||
f.setAttribute( index++, attr[ subsetIndices[i] ] );
|
||||
f.setAttribute( index++, attr.at( subsetIndices.at( i ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -720,7 +720,7 @@ void QgsVectorLayerFeatureIterator::FetchJoinInfo::addJoinedAttributesDirect( Qg
|
||||
if ( i == joinField )
|
||||
continue;
|
||||
|
||||
f.setAttribute( index++, attr[i] );
|
||||
f.setAttribute( index++, attr.at( i ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -150,7 +150,7 @@ bool QgsVectorLayerImport::addFeature( QgsFeature& feat )
|
||||
continue;
|
||||
|
||||
QgsDebugMsgLevel( QString( "moving field from pos %1 to %2" ).arg( i ).arg( dstIdx ), 3 );
|
||||
newFeat.setAttribute( dstIdx, attrs[i] );
|
||||
newFeat.setAttribute( dstIdx, attrs.at( i ) );
|
||||
}
|
||||
|
||||
mFeatureBuffer.append( newFeat );
|
||||
@ -252,7 +252,7 @@ QgsVectorLayerImport::importLayer( QgsVectorLayer* layer,
|
||||
// convert field names to lowercase
|
||||
for ( int fldIdx = 0; fldIdx < fields.count(); ++fldIdx )
|
||||
{
|
||||
fields[fldIdx].setName( fields[fldIdx].name().toLower() );
|
||||
fields[fldIdx].setName( fields.at( fldIdx ).name().toLower() );
|
||||
}
|
||||
|
||||
if ( !forceSinglePartGeom )
|
||||
|
@ -153,12 +153,12 @@ void QgsVectorLayerJoinBuffer::cacheJoinLayer( QgsVectorJoinInfo& joinInfo )
|
||||
while ( fit.nextFeature( f ) )
|
||||
{
|
||||
QgsAttributes attrs = f.attributes();
|
||||
QString key = attrs[joinFieldIndex].toString();
|
||||
QString key = attrs.at( joinFieldIndex ).toString();
|
||||
if ( hasSubset )
|
||||
{
|
||||
QgsAttributes subsetAttrs( subsetIndices.count() );
|
||||
for ( int i = 0; i < subsetIndices.count(); ++i )
|
||||
subsetAttrs[i] = attrs[ subsetIndices[i] ];
|
||||
subsetAttrs[i] = attrs.at( subsetIndices.at( i ) );
|
||||
joinInfo.cachedAttributes.insert( key, subsetAttrs );
|
||||
}
|
||||
else
|
||||
|
@ -360,7 +360,7 @@ QgsSymbolV2* QgsGraduatedSymbolRendererV2::originalSymbolForFeature( QgsFeature&
|
||||
}
|
||||
else
|
||||
{
|
||||
value = attrs[mAttrNum];
|
||||
value = attrs.at( mAttrNum );
|
||||
}
|
||||
|
||||
// Null values should not be categorized
|
||||
|
@ -464,7 +464,7 @@ QString QgsPointDisplacementRenderer::getLabel( const QgsFeature& f )
|
||||
QgsAttributes attrs = f.attributes();
|
||||
if ( mLabelIndex >= 0 && mLabelIndex < attrs.count() )
|
||||
{
|
||||
attribute = attrs[mLabelIndex].toString();
|
||||
attribute = attrs.at( mLabelIndex ).toString();
|
||||
}
|
||||
return attribute;
|
||||
}
|
||||
|
@ -511,7 +511,7 @@ QVariant QgsAttributeTableModel::headerData( int section, Qt::Orientation orient
|
||||
QString attributeName = layer()->attributeAlias( mAttributes[section] );
|
||||
if ( attributeName.isEmpty() )
|
||||
{
|
||||
QgsField field = layer()->fields()[ mAttributes[section] ];
|
||||
QgsField field = layer()->fields().at( mAttributes[section] );
|
||||
attributeName = field.name();
|
||||
}
|
||||
return QVariant( attributeName );
|
||||
|
@ -285,7 +285,7 @@ void QgsEditorWidgetRegistry::writeMapLayer( QgsMapLayer* mapLayer, QDomElement&
|
||||
QgsFields fields = vectorLayer->fields();
|
||||
for ( int idx = 0; idx < fields.count(); ++idx )
|
||||
{
|
||||
const QgsField &field = fields[ idx ];
|
||||
const QgsField &field = fields.at( idx );
|
||||
const QString& widgetType = vectorLayer->editorWidgetV2( idx );
|
||||
if ( !mWidgetFactories.contains( widgetType ) )
|
||||
{
|
||||
|
@ -34,7 +34,7 @@ int QgsEditorWidgetWrapper::fieldIdx()
|
||||
QgsField QgsEditorWidgetWrapper::field()
|
||||
{
|
||||
if ( mFieldIdx < layer()->fields().count() )
|
||||
return layer()->fields()[mFieldIdx];
|
||||
return layer()->fields().at( mFieldIdx );
|
||||
else
|
||||
return QgsField();
|
||||
}
|
||||
|
@ -52,12 +52,12 @@ void QgsDefaultSearchWidgetWrapper::setCaseString( int caseSensitiveCheckState )
|
||||
|
||||
void QgsDefaultSearchWidgetWrapper::setExpression( QString exp )
|
||||
{
|
||||
QVariant::Type fldType = layer()->fields()[mFieldIdx].type();
|
||||
QVariant::Type fldType = layer()->fields().at( mFieldIdx ).type();
|
||||
bool numeric = ( fldType == QVariant::Int || fldType == QVariant::Double || fldType == QVariant::LongLong );
|
||||
|
||||
QSettings settings;
|
||||
QString nullValue = settings.value( "qgis/nullValue", "NULL" ).toString();
|
||||
QString fieldName = layer()->fields()[mFieldIdx].name();
|
||||
QString fieldName = layer()->fields().at( mFieldIdx ).name();
|
||||
QString str;
|
||||
if ( exp == nullValue )
|
||||
{
|
||||
|
@ -24,13 +24,13 @@ QgsRangeConfigDlg::QgsRangeConfigDlg( QgsVectorLayer* vl, int fieldIdx, QWidget
|
||||
|
||||
QString text;
|
||||
|
||||
switch ( vl->fields()[fieldIdx].type() )
|
||||
switch ( vl->fields().at( fieldIdx ).type() )
|
||||
{
|
||||
case QVariant::Int:
|
||||
case QVariant::LongLong:
|
||||
case QVariant::Double:
|
||||
{
|
||||
rangeStackedWidget->setCurrentIndex( vl->fields()[fieldIdx].type() == QVariant::Double ? 1 : 0 );
|
||||
rangeStackedWidget->setCurrentIndex( vl->fields().at( fieldIdx ).type() == QVariant::Double ? 1 : 0 );
|
||||
|
||||
rangeWidget->clear();
|
||||
rangeWidget->addItem( tr( "Editable" ), "SpinBox" );
|
||||
@ -58,7 +58,7 @@ QgsEditorWidgetConfig QgsRangeConfigDlg::config()
|
||||
{
|
||||
QgsEditorWidgetConfig cfg;
|
||||
|
||||
switch ( layer()->fields()[field()].type() )
|
||||
switch ( layer()->fields().at( field() ).type() )
|
||||
{
|
||||
case QVariant::Int:
|
||||
case QVariant::LongLong:
|
||||
|
@ -73,7 +73,7 @@ void QgsRangeWidgetFactory::writeConfig( const QgsEditorWidgetConfig& config, QD
|
||||
|
||||
bool QgsRangeWidgetFactory::isFieldSupported( QgsVectorLayer* vl, int fieldIdx )
|
||||
{
|
||||
switch ( vl->fields()[fieldIdx].type() )
|
||||
switch ( vl->fields().at( fieldIdx ).type() )
|
||||
{
|
||||
case QVariant::LongLong:
|
||||
case QVariant::Double:
|
||||
|
@ -45,8 +45,8 @@ QWidget* QgsRangeWidgetWrapper::createWidget( QWidget* parent )
|
||||
}
|
||||
else
|
||||
{
|
||||
QgsDebugMsg( QString( "%1" ).arg(( int )layer()->fields()[fieldIdx()].type() ) );
|
||||
switch ( layer()->fields()[fieldIdx()].type() )
|
||||
QgsDebugMsg( QString( "%1" ).arg(( int )layer()->fields().at( fieldIdx() ).type() ) );
|
||||
switch ( layer()->fields().at( fieldIdx() ).type() )
|
||||
{
|
||||
case QVariant::Double:
|
||||
{
|
||||
@ -82,10 +82,10 @@ void QgsRangeWidgetWrapper::initWidget( QWidget* editor )
|
||||
if ( mDoubleSpinBox )
|
||||
{
|
||||
// set the precision if field is integer
|
||||
int precision = layer()->fields()[fieldIdx()].precision();
|
||||
int precision = layer()->fields().at( fieldIdx() ).precision();
|
||||
if ( precision > 0 )
|
||||
{
|
||||
mDoubleSpinBox->setDecimals( layer()->fields()[fieldIdx()].precision() );
|
||||
mDoubleSpinBox->setDecimals( layer()->fields().at( fieldIdx() ).precision() );
|
||||
}
|
||||
|
||||
double minval = min.toDouble();
|
||||
|
@ -447,7 +447,7 @@ void QgsRelationReferenceWidget::init()
|
||||
mReferencedLayer->uniqueValues( idx, uniqueValues );
|
||||
cb->addItem( mReferencedLayer->attributeAlias( idx ).isEmpty() ? fieldName : mReferencedLayer->attributeAlias( idx ) );
|
||||
QVariant nullValue = QSettings().value( "qgis/nullValue", "NULL" );
|
||||
cb->addItem( nullValue.toString(), QVariant( mReferencedLayer->fields()[idx].type() ) );
|
||||
cb->addItem( nullValue.toString(), QVariant( mReferencedLayer->fields().at( idx ).type() ) );
|
||||
|
||||
Q_FOREACH ( const QVariant& v, uniqueValues )
|
||||
{
|
||||
|
@ -113,10 +113,10 @@ void QgsValueRelationSearchWidgetWrapper::initWidget( QWidget* editor )
|
||||
|
||||
if ( mComboBox )
|
||||
{
|
||||
mComboBox->addItem( tr( "Please select" ), QVariant( layer()->fields()[mFieldIdx].type() ) );
|
||||
mComboBox->addItem( tr( "Please select" ), QVariant( layer()->fields().at( mFieldIdx ).type() ) );
|
||||
if ( config( "AllowNull" ).toBool() )
|
||||
{
|
||||
mComboBox->addItem( tr( "(no selection)" ), QVariant( layer()->fields()[mFieldIdx].type() ) );
|
||||
mComboBox->addItem( tr( "(no selection)" ), QVariant( layer()->fields().at( mFieldIdx ).type() ) );
|
||||
}
|
||||
|
||||
Q_FOREACH ( const ValueRelationItem& element, mCache )
|
||||
|
@ -171,7 +171,7 @@ bool QgsAttributeForm::save()
|
||||
QgsEditorWidgetWrapper* eww = qobject_cast<QgsEditorWidgetWrapper*>( ww );
|
||||
if ( eww )
|
||||
{
|
||||
QVariant dstVar = dst[eww->fieldIdx()];
|
||||
QVariant dstVar = dst.at( eww->fieldIdx() );
|
||||
QVariant srcVar = eww->value();
|
||||
// need to check dstVar.isNull() != srcVar.isNull()
|
||||
// otherwise if dstVar=NULL and scrVar=0, then dstVar = srcVar
|
||||
@ -218,8 +218,8 @@ bool QgsAttributeForm::save()
|
||||
int n = 0;
|
||||
for ( int i = 0; i < dst.count(); ++i )
|
||||
{
|
||||
if (( dst[i] == src[i] && dst[i].isNull() == src[i].isNull() ) // If field is not changed...
|
||||
|| !dst[i].isValid() // or the widget returns invalid (== do not change)
|
||||
if (( dst.at( i ) == src.at( i ) && dst.at( i ).isNull() == src.at( i ).isNull() ) // If field is not changed...
|
||||
|| !dst.at( i ).isValid() // or the widget returns invalid (== do not change)
|
||||
|| !mLayer->fieldEditable( i ) ) // or the field cannot be edited ...
|
||||
{
|
||||
continue;
|
||||
@ -227,11 +227,11 @@ bool QgsAttributeForm::save()
|
||||
|
||||
QgsDebugMsg( QString( "Updating field %1" ).arg( i ) );
|
||||
QgsDebugMsg( QString( "dst:'%1' (type:%2, isNull:%3, isValid:%4)" )
|
||||
.arg( dst[i].toString(), dst[i].typeName() ).arg( dst[i].isNull() ).arg( dst[i].isValid() ) );
|
||||
.arg( dst.at( i ).toString(), dst.at( i ).typeName() ).arg( dst.at( i ).isNull() ).arg( dst.at( i ).isValid() ) );
|
||||
QgsDebugMsg( QString( "src:'%1' (type:%2, isNull:%3, isValid:%4)" )
|
||||
.arg( src[i].toString(), src[i].typeName() ).arg( src[i].isNull() ).arg( src[i].isValid() ) );
|
||||
.arg( src.at( i ).toString(), src.at( i ).typeName() ).arg( src.at( i ).isNull() ).arg( src.at( i ).isValid() ) );
|
||||
|
||||
success &= mLayer->changeAttributeValue( mFeature.id(), i, dst[i], src[i] );
|
||||
success &= mLayer->changeAttributeValue( mFeature.id(), i, dst.at( i ), src.at( i ) );
|
||||
n++;
|
||||
}
|
||||
|
||||
@ -287,7 +287,7 @@ void QgsAttributeForm::onAttributeAdded( int idx )
|
||||
if ( mFeature.isValid() )
|
||||
{
|
||||
QgsAttributes attrs = mFeature.attributes();
|
||||
attrs.insert( idx, QVariant( layer()->fields()[idx].type() ) );
|
||||
attrs.insert( idx, QVariant( layer()->fields().at( idx ).type() ) );
|
||||
mFeature.setFields( layer()->fields() );
|
||||
mFeature.setAttributes( attrs );
|
||||
}
|
||||
@ -317,18 +317,18 @@ void QgsAttributeForm::onUpdatedFields()
|
||||
QgsAttributes attrs( layer()->fields().size() );
|
||||
for ( int i = 0; i < layer()->fields().size(); i++ )
|
||||
{
|
||||
int idx = mFeature.fields()->indexFromName( layer()->fields()[i].name() );
|
||||
int idx = mFeature.fields()->indexFromName( layer()->fields().at( i ).name() );
|
||||
if ( idx != -1 )
|
||||
{
|
||||
attrs[i] = mFeature.attributes().at( idx );
|
||||
if ( mFeature.attributes().at( idx ).type() != layer()->fields()[i].type() )
|
||||
if ( mFeature.attributes().at( idx ).type() != layer()->fields().at( i ).type() )
|
||||
{
|
||||
attrs[i].convert( layer()->fields()[i].type() );
|
||||
attrs[i].convert( layer()->fields().at( i ).type() );
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
attrs[i] = QVariant( layer()->fields()[i].type() );
|
||||
attrs[i] = QVariant( layer()->fields().at( i ).type() );
|
||||
}
|
||||
}
|
||||
mFeature.setFields( layer()->fields() );
|
||||
@ -649,7 +649,7 @@ QWidget* QgsAttributeForm::createWidgetFromDef( const QgsAttributeEditorElement
|
||||
newWidget = eww->widget();
|
||||
addWidgetWrapper( eww );
|
||||
|
||||
newWidget->setObjectName( mLayer->fields()[ fldIdx ].name() );
|
||||
newWidget->setObjectName( mLayer->fields().at( fldIdx ).name() );
|
||||
}
|
||||
|
||||
labelOnTop = mLayer->labelOnTop( fieldDef->idx() );
|
||||
|
@ -102,7 +102,7 @@ QWidget* QgsFormAnnotationItem::createDesignerWidget( const QString& filePath )
|
||||
QWidget* attWidget = widget->findChild<QWidget*>( fields[i].name() );
|
||||
if ( attWidget )
|
||||
{
|
||||
QgsAttributeEditor::createAttributeEditor( widget, attWidget, mVectorLayer, i, attrs[i] );
|
||||
QgsAttributeEditor::createAttributeEditor( widget, attWidget, mVectorLayer, i, attrs.at( i ) );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -325,7 +325,7 @@ void QgsQueryBuilder::on_lstFields_clicked( const QModelIndex &index )
|
||||
|
||||
void QgsQueryBuilder::on_lstFields_doubleClicked( const QModelIndex &index )
|
||||
{
|
||||
txtSQL->insertText( "\"" + mLayer->fields()[ mModelFields->data( index, Qt::UserRole+1 ).toInt()].name() + "\"" );
|
||||
txtSQL->insertText( "\"" + mLayer->fields().at( mModelFields->data( index, Qt::UserRole + 1 ).toInt() ).name() + "\"" );
|
||||
txtSQL->setFocus();
|
||||
}
|
||||
|
||||
|
@ -114,7 +114,7 @@ void QgsSearchQueryBuilder::getFieldValues( int limit )
|
||||
// determine the field type
|
||||
QString fieldName = mModelFields->data( lstFields->currentIndex() ).toString();
|
||||
int fieldIndex = mFieldMap[fieldName];
|
||||
QgsField field = mLayer->fields()[fieldIndex];//provider->fields()[fieldIndex];
|
||||
QgsField field = mLayer->fields().at( fieldIndex );//provider->fields().at( fieldIndex );
|
||||
bool numeric = ( field.type() == QVariant::Int || field.type() == QVariant::Double );
|
||||
|
||||
QgsFeature feat;
|
||||
|
@ -601,23 +601,23 @@ void eVisGenericEventBrowserGui::loadRecord()
|
||||
{
|
||||
QStringList myValues;
|
||||
QString fieldName = myFields[i].name();
|
||||
myValues << fieldName << myAttrs[i].toString();
|
||||
myValues << fieldName << myAttrs.at( i ).toString();
|
||||
QTreeWidgetItem* myItem = new QTreeWidgetItem( myValues );
|
||||
if ( fieldName == myEventImagePathField )
|
||||
{
|
||||
mEventImagePath = myAttrs[i].toString();
|
||||
mEventImagePath = myAttrs.at( i ).toString();
|
||||
}
|
||||
|
||||
if ( fieldName == myCompassBearingField )
|
||||
{
|
||||
mCompassBearing = myAttrs[i].toDouble();
|
||||
mCompassBearing = myAttrs.at( i ).toDouble();
|
||||
}
|
||||
|
||||
if ( mConfiguration.isAttributeCompassOffsetSet() )
|
||||
{
|
||||
if ( fieldName == myCompassOffsetField )
|
||||
{
|
||||
mCompassOffset = myAttrs[i].toDouble();
|
||||
mCompassOffset = myAttrs.at( i ).toDouble();
|
||||
}
|
||||
}
|
||||
else
|
||||
@ -629,7 +629,7 @@ void eVisGenericEventBrowserGui::loadRecord()
|
||||
int myIterator = 0;
|
||||
while ( myIterator < tableFileTypeAssociations->rowCount() )
|
||||
{
|
||||
if ( tableFileTypeAssociations->item( myIterator, 0 ) && ( myAttrs[i].toString().startsWith( tableFileTypeAssociations->item( myIterator, 0 )->text() + ":", Qt::CaseInsensitive ) || myAttrs[i].toString().endsWith( tableFileTypeAssociations->item( myIterator, 0 )->text(), Qt::CaseInsensitive ) ) )
|
||||
if ( tableFileTypeAssociations->item( myIterator, 0 ) && ( myAttrs.at( i ).toString().startsWith( tableFileTypeAssociations->item( myIterator, 0 )->text() + ":", Qt::CaseInsensitive ) || myAttrs.at( i ).toString().endsWith( tableFileTypeAssociations->item( myIterator, 0 )->text(), Qt::CaseInsensitive ) ) )
|
||||
{
|
||||
myItem->setBackground( 1, QBrush( QColor( 183, 216, 125, 255 ) ) );
|
||||
break;
|
||||
@ -845,9 +845,9 @@ void eVisGenericEventBrowserGui::on_cboxEventImagePathField_currentIndexChanged(
|
||||
QgsAttributes myAttrs = myFeature->attributes();
|
||||
for ( int i = 0 ; i < myAttrs.count(); ++i )
|
||||
{
|
||||
if ( myFields[i].name() == cboxEventImagePathField->currentText() )
|
||||
if ( myFields.at( i ).name() == cboxEventImagePathField->currentText() )
|
||||
{
|
||||
mEventImagePath = myAttrs[i].toString();
|
||||
mEventImagePath = myAttrs.at( i ).toString();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -875,7 +875,7 @@ void eVisGenericEventBrowserGui::on_cboxCompassBearingField_currentIndexChanged(
|
||||
{
|
||||
if ( myFields[i].name() == cboxCompassBearingField->currentText() )
|
||||
{
|
||||
mCompassBearing = myAttrs[i].toDouble();
|
||||
mCompassBearing = myAttrs.at( i ).toDouble();
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -903,7 +903,7 @@ void eVisGenericEventBrowserGui::on_cboxCompassOffsetField_currentIndexChanged(
|
||||
{
|
||||
if ( myFields[i].name() == cboxCompassOffsetField->currentText() )
|
||||
{
|
||||
mCompassOffset = myAttrs[i].toDouble();
|
||||
mCompassOffset = myAttrs.at( i ).toDouble();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -46,9 +46,9 @@ QgsGeometryCheckerResultTab::QgsGeometryCheckerResultTab( QgisInterface* iface,
|
||||
mCloseable = true;
|
||||
mAttribTableDialog = 0;
|
||||
|
||||
for ( int i = 0, n = mFeaturePool->getLayer()->pendingFields().count(); i < n; ++i )
|
||||
for ( int i = 0, n = mFeaturePool->getLayer()->fields().count(); i < n; ++i )
|
||||
{
|
||||
ui.comboBoxMergeAttribute->addItem( mFeaturePool->getLayer()->pendingFields()[i].name() );
|
||||
ui.comboBoxMergeAttribute->addItem( mFeaturePool->getLayer()->fields().at( i ).name() );
|
||||
}
|
||||
|
||||
connect( checker, SIGNAL( errorAdded( QgsGeometryCheckError* ) ), this, SLOT( addError( QgsGeometryCheckError* ) ) );
|
||||
@ -261,7 +261,7 @@ bool QgsGeometryCheckerResultTab::exportErrorsDo( const QString& file )
|
||||
{
|
||||
QgsGeometryCheckError* error = ui.tableWidgetErrors->item( row, 0 )->data( Qt::UserRole ).value<QgsGeometryCheckError*>();
|
||||
|
||||
QgsFeature f( layer->pendingFields() );
|
||||
QgsFeature f( layer->fields() );
|
||||
f.setAttribute( fieldFeatureId, error->featureId() );
|
||||
f.setAttribute( fieldErrDesc, error->description() );
|
||||
f.setGeometry( new QgsGeometry( error->location().clone() ) );
|
||||
|
@ -1150,10 +1150,10 @@ void QgsGrassModuleVectorField::updateFields()
|
||||
|
||||
for ( int i = 0; i < fields.size(); i++ )
|
||||
{
|
||||
if ( mType.contains( fields[i].typeName() ) )
|
||||
if ( mType.contains( fields.at( i ).typeName() ) )
|
||||
{
|
||||
mFieldComboBox->addItem( fields[i].name() );
|
||||
if ( fields[i].name() == current )
|
||||
mFieldComboBox->addItem( fields.at( i ).name() );
|
||||
if ( fields.at( i ).name() == current )
|
||||
{
|
||||
mFieldComboBox->setItemText( mFieldComboBox->currentIndex(), current );
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ QVariant RgSpeedProperter::property( double distance, const QgsFeature& f ) cons
|
||||
if ( mAttributeId < 0 || mAttributeId >= attrs.count() )
|
||||
return QVariant( distance / ( mDefaultValue*mToMetricFactor ) );
|
||||
|
||||
double val = distance / ( attrs[mAttributeId].toDouble() * mToMetricFactor );
|
||||
double val = distance / ( attrs.at( mAttributeId ).toDouble() * mToMetricFactor );
|
||||
if ( val <= 0.0 )
|
||||
return QVariant( distance / ( mDefaultValue / mToMetricFactor ) );
|
||||
|
||||
|
@ -421,7 +421,7 @@ void QgsDelimitedTextFeatureIterator::fetchAttribute( QgsFeature& feature, int f
|
||||
if ( column < 0 || column >= tokens.count() ) return;
|
||||
const QString &value = tokens[column];
|
||||
QVariant val;
|
||||
switch ( mSource->mFields[fieldIdx].type() )
|
||||
switch ( mSource->mFields.at( fieldIdx ).type() )
|
||||
{
|
||||
case QVariant::Int:
|
||||
{
|
||||
@ -431,7 +431,7 @@ void QgsDelimitedTextFeatureIterator::fetchAttribute( QgsFeature& feature, int f
|
||||
if ( ok )
|
||||
val = QVariant( ivalue );
|
||||
else
|
||||
val = QVariant( mSource->mFields[fieldIdx].type() );
|
||||
val = QVariant( mSource->mFields.at( fieldIdx ).type() );
|
||||
break;
|
||||
}
|
||||
case QVariant::Double:
|
||||
@ -455,7 +455,7 @@ void QgsDelimitedTextFeatureIterator::fetchAttribute( QgsFeature& feature, int f
|
||||
}
|
||||
else
|
||||
{
|
||||
val = QVariant( mSource->mFields[fieldIdx].type() );
|
||||
val = QVariant( mSource->mFields.at( fieldIdx ).type() );
|
||||
}
|
||||
break;
|
||||
}
|
||||
|
@ -767,7 +767,7 @@ void QgsDelimitedTextProvider::rescanFile()
|
||||
|
||||
for ( int i = 0; i < attributeFields.size(); i++ )
|
||||
{
|
||||
attributeColumns[i] = mFile->fieldIndex( attributeFields[i].name() );
|
||||
attributeColumns[i] = mFile->fieldIndex( attributeFields.at( i ).name() );
|
||||
}
|
||||
|
||||
// Scan through the features in the file
|
||||
|
@ -237,13 +237,13 @@ bool QgsGPXProvider::addFeature( QgsFeature& f )
|
||||
if ( indexToAttr[i] == EleAttr )
|
||||
{
|
||||
bool eleIsOK;
|
||||
double ele = attrs[i].toDouble( &eleIsOK );
|
||||
double ele = attrs.at( i ).toDouble( &eleIsOK );
|
||||
if ( eleIsOK )
|
||||
wpt.ele = ele;
|
||||
}
|
||||
else if ( indexToAttr[i] == SymAttr )
|
||||
{
|
||||
wpt.sym = attrs[i].toString();
|
||||
wpt.sym = attrs.at( i ).toString();
|
||||
}
|
||||
}
|
||||
|
||||
@ -288,7 +288,7 @@ bool QgsGPXProvider::addFeature( QgsFeature& f )
|
||||
if ( indexToAttr[i] == NumAttr )
|
||||
{
|
||||
bool numIsOK;
|
||||
long num = attrs[i].toInt( &numIsOK );
|
||||
long num = attrs.at( i ).toInt( &numIsOK );
|
||||
if ( numIsOK )
|
||||
rte.number = num;
|
||||
}
|
||||
@ -336,7 +336,7 @@ bool QgsGPXProvider::addFeature( QgsFeature& f )
|
||||
if ( indexToAttr[i] == NumAttr )
|
||||
{
|
||||
bool numIsOK;
|
||||
long num = attrs[i].toInt( &numIsOK );
|
||||
long num = attrs.at( i ).toInt( &numIsOK );
|
||||
if ( numIsOK )
|
||||
trk.number = num;
|
||||
}
|
||||
@ -356,12 +356,12 @@ bool QgsGPXProvider::addFeature( QgsFeature& f )
|
||||
{
|
||||
switch ( indexToAttr[i] )
|
||||
{
|
||||
case NameAttr: obj->name = attrs[i].toString(); break;
|
||||
case CmtAttr: obj->cmt = attrs[i].toString(); break;
|
||||
case DscAttr: obj->desc = attrs[i].toString(); break;
|
||||
case SrcAttr: obj->src = attrs[i].toString(); break;
|
||||
case URLAttr: obj->url = attrs[i].toString(); break;
|
||||
case URLNameAttr: obj->urlname = attrs[i].toString(); break;
|
||||
case NameAttr: obj->name = attrs.at( i ).toString(); break;
|
||||
case CmtAttr: obj->cmt = attrs.at( i ).toString(); break;
|
||||
case DscAttr: obj->desc = attrs.at( i ).toString(); break;
|
||||
case SrcAttr: obj->src = attrs.at( i ).toString(); break;
|
||||
case URLAttr: obj->url = attrs.at( i ).toString(); break;
|
||||
case URLNameAttr: obj->urlname = attrs.at( i ).toString(); break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1667,7 +1667,7 @@ void QgsGrassProvider::onAttributeValueChanged( QgsFeatureId fid, int idx, const
|
||||
QgsDebugMsg( "index out of range" );
|
||||
return;
|
||||
}
|
||||
QgsField field = mEditLayer->fields()[idx];
|
||||
QgsField field = mEditLayer->fields().at( idx );
|
||||
|
||||
QgsDebugMsg( "field.name() = " + field.name() + " keyColumnName() = " + mLayer->keyColumnName() );
|
||||
// TODO: Changing existing category is currently disabled (read only widget set on layer)
|
||||
@ -1762,7 +1762,7 @@ void QgsGrassProvider::onAttributeAdded( int idx )
|
||||
QgsDebugMsg( "index out of range" );
|
||||
}
|
||||
QString error;
|
||||
mLayer->addColumn( mEditLayer->fields()[idx], error );
|
||||
mLayer->addColumn( mEditLayer->fields().at( idx ), error );
|
||||
if ( !error.isEmpty() )
|
||||
{
|
||||
QgsDebugMsg( error );
|
||||
|
@ -348,7 +348,7 @@ QStringList QgsGrassVectorMapLayer::fieldNames( QgsFields & fields )
|
||||
QStringList list;
|
||||
for ( int i = 0; i < fields.size(); i++ )
|
||||
{
|
||||
list << fields[i].name();
|
||||
list << fields.at( i ).name();
|
||||
}
|
||||
return list;
|
||||
}
|
||||
@ -360,7 +360,7 @@ void QgsGrassVectorMapLayer::updateFields()
|
||||
// update fields to pass layer/buffer check when commiting
|
||||
for ( int i = mFields.size() - 1; i >= 0; i-- )
|
||||
{
|
||||
QgsField field = mFields[i];
|
||||
QgsField field = mFields.at( i );
|
||||
if ( field.name() == QgsGrassVectorMap::topoSymbolFieldName() )
|
||||
{
|
||||
continue;
|
||||
@ -372,7 +372,7 @@ void QgsGrassVectorMapLayer::updateFields()
|
||||
}
|
||||
for ( int i = 0; i < mTableFields.size(); i++ )
|
||||
{
|
||||
QgsField field = mTableFields[i];
|
||||
QgsField field = mTableFields.at( i );
|
||||
if ( mFields.indexFromName( field.name() ) == -1 )
|
||||
{
|
||||
mFields.append( field );
|
||||
@ -742,7 +742,7 @@ void QgsGrassVectorMapLayer::deleteColumn( const QgsField &field, QString &error
|
||||
QStringList columns;
|
||||
for ( int i = 0; i < mTableFields.size(); i++ )
|
||||
{
|
||||
QgsField f = mTableFields[i];
|
||||
QgsField f = mTableFields.at( i );
|
||||
if ( f.name() != field.name() )
|
||||
{
|
||||
columns << f.name();
|
||||
|
@ -70,7 +70,7 @@ void QgsMssqlFeatureIterator::BuildStatement( const QgsFeatureRequest& request )
|
||||
bool subsetOfAttributes = mRequest.flags() & QgsFeatureRequest::SubsetOfAttributes;
|
||||
Q_FOREACH ( int i, subsetOfAttributes ? mRequest.subsetOfAttributes() : mSource->mFields.allAttributesList() )
|
||||
{
|
||||
QString fieldname = mSource->mFields[i].name();
|
||||
QString fieldname = mSource->mFields.at( i ).name();
|
||||
if ( mSource->mFidColName == fieldname )
|
||||
continue;
|
||||
|
||||
|
@ -479,7 +479,7 @@ QString QgsMssqlProvider::storageType() const
|
||||
QVariant QgsMssqlProvider::minimumValue( int index )
|
||||
{
|
||||
// get the field name
|
||||
QgsField fld = mAttributeFields[ index ];
|
||||
QgsField fld = mAttributeFields.at( index );
|
||||
QString sql = QString( "select min([%1]) from " )
|
||||
.arg( fld.name() );
|
||||
|
||||
@ -511,7 +511,7 @@ QVariant QgsMssqlProvider::minimumValue( int index )
|
||||
QVariant QgsMssqlProvider::maximumValue( int index )
|
||||
{
|
||||
// get the field name
|
||||
QgsField fld = mAttributeFields[ index ];
|
||||
QgsField fld = mAttributeFields.at( index );
|
||||
QString sql = QString( "select max([%1]) from " )
|
||||
.arg( fld.name() );
|
||||
|
||||
@ -545,7 +545,7 @@ void QgsMssqlProvider::uniqueValues( int index, QList<QVariant> &uniqueValues, i
|
||||
uniqueValues.clear();
|
||||
|
||||
// get the field name
|
||||
QgsField fld = mAttributeFields[ index ];
|
||||
QgsField fld = mAttributeFields.at( index );
|
||||
QString sql = QString( "select distinct " );
|
||||
|
||||
if ( limit > 0 )
|
||||
@ -769,7 +769,7 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList & flist )
|
||||
|
||||
for ( int i = 0; i < attrs.count(); ++i )
|
||||
{
|
||||
QgsField fld = mAttributeFields[i];
|
||||
QgsField fld = mAttributeFields.at( i );
|
||||
|
||||
if ( fld.typeName().endsWith( " identity", Qt::CaseInsensitive ) )
|
||||
continue; // skip identity field
|
||||
@ -777,7 +777,7 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList & flist )
|
||||
if ( fld.name().isEmpty() )
|
||||
continue; // invalid
|
||||
|
||||
if ( mDefaultValues.contains( i ) && mDefaultValues[i] == attrs[i] )
|
||||
if ( mDefaultValues.contains( i ) && mDefaultValues[i] == attrs.at( i ) )
|
||||
continue; // skip fields having default values
|
||||
|
||||
if ( !first )
|
||||
@ -842,7 +842,7 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList & flist )
|
||||
|
||||
for ( int i = 0; i < attrs.count(); ++i )
|
||||
{
|
||||
QgsField fld = mAttributeFields[i];
|
||||
QgsField fld = mAttributeFields.at( i );
|
||||
|
||||
if ( fld.typeName().endsWith( " identity", Qt::CaseInsensitive ) )
|
||||
continue; // skip identity field
|
||||
@ -850,11 +850,11 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList & flist )
|
||||
if ( fld.name().isEmpty() )
|
||||
continue; // invalid
|
||||
|
||||
if ( mDefaultValues.contains( i ) && mDefaultValues[i] == attrs[i] )
|
||||
if ( mDefaultValues.contains( i ) && mDefaultValues[i] == attrs.at( i ) )
|
||||
continue; // skip fields having default values
|
||||
|
||||
QVariant::Type type = fld.type();
|
||||
if ( attrs[i].isNull() || !attrs[i].isValid() )
|
||||
if ( attrs.at( i ).isNull() || !attrs.at( i ).isValid() )
|
||||
{
|
||||
// binding null values
|
||||
if ( type == QVariant::Date || type == QVariant::DateTime )
|
||||
@ -865,36 +865,36 @@ bool QgsMssqlProvider::addFeatures( QgsFeatureList & flist )
|
||||
else if ( type == QVariant::Int )
|
||||
{
|
||||
// binding an INTEGER value
|
||||
query.addBindValue( attrs[i].toInt() );
|
||||
query.addBindValue( attrs.at( i ).toInt() );
|
||||
}
|
||||
else if ( type == QVariant::Double )
|
||||
{
|
||||
// binding a DOUBLE value
|
||||
query.addBindValue( attrs[i].toDouble() );
|
||||
query.addBindValue( attrs.at( i ).toDouble() );
|
||||
}
|
||||
else if ( type == QVariant::String )
|
||||
{
|
||||
// binding a TEXT value
|
||||
query.addBindValue( attrs[i].toString() );
|
||||
query.addBindValue( attrs.at( i ).toString() );
|
||||
}
|
||||
else if ( type == QVariant::Time )
|
||||
{
|
||||
// binding a TIME value
|
||||
query.addBindValue( attrs[i].toTime().toString( Qt::ISODate ) );
|
||||
query.addBindValue( attrs.at( i ).toTime().toString( Qt::ISODate ) );
|
||||
}
|
||||
else if ( type == QVariant::Date )
|
||||
{
|
||||
// binding a DATE value
|
||||
query.addBindValue( attrs[i].toDate().toString( Qt::ISODate ) );
|
||||
query.addBindValue( attrs.at( i ).toDate().toString( Qt::ISODate ) );
|
||||
}
|
||||
else if ( type == QVariant::DateTime )
|
||||
{
|
||||
// binding a DATETIME value
|
||||
query.addBindValue( attrs[i].toDateTime().toString( Qt::ISODate ) );
|
||||
query.addBindValue( attrs.at( i ).toDateTime().toString( Qt::ISODate ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
query.addBindValue( attrs[i] );
|
||||
query.addBindValue( attrs.at( i ) );
|
||||
}
|
||||
}
|
||||
|
||||
@ -1015,7 +1015,7 @@ bool QgsMssqlProvider::deleteAttributes( const QgsAttributeIds &attributes )
|
||||
else
|
||||
statement += ",";
|
||||
|
||||
statement += QString( "[%1]" ).arg( mAttributeFields[*it].name() );
|
||||
statement += QString( "[%1]" ).arg( mAttributeFields.at( *it ).name() );
|
||||
}
|
||||
|
||||
if ( !mDatabase.isOpen() )
|
||||
@ -1071,7 +1071,7 @@ bool QgsMssqlProvider::changeAttributeValues( const QgsChangedAttributesMap &att
|
||||
|
||||
for ( QgsAttributeMap::const_iterator it2 = attrs.begin(); it2 != attrs.end(); ++it2 )
|
||||
{
|
||||
QgsField fld = mAttributeFields[it2.key()];
|
||||
QgsField fld = mAttributeFields.at( it2.key() );
|
||||
|
||||
if ( fld.typeName().endsWith( " identity", Qt::CaseInsensitive ) )
|
||||
continue; // skip identity field
|
||||
@ -1103,7 +1103,7 @@ bool QgsMssqlProvider::changeAttributeValues( const QgsChangedAttributesMap &att
|
||||
|
||||
for ( QgsAttributeMap::const_iterator it2 = attrs.begin(); it2 != attrs.end(); ++it2 )
|
||||
{
|
||||
QgsField fld = mAttributeFields[it2.key()];
|
||||
QgsField fld = mAttributeFields.at( it2.key() );
|
||||
|
||||
if ( fld.typeName().endsWith( " identity", Qt::CaseInsensitive ) )
|
||||
continue; // skip identity field
|
||||
@ -1341,7 +1341,7 @@ bool QgsMssqlProvider::createAttributeIndex( int field )
|
||||
}
|
||||
|
||||
statement = QString( "CREATE NONCLUSTERED INDEX [qgs_%1_idx] ON [%2].[%3] ( [%4] )" ).arg(
|
||||
mGeometryColName, mSchemaName, mTableName, mAttributeFields[field].name() );
|
||||
mGeometryColName, mSchemaName, mTableName, mAttributeFields.at( field ).name() );
|
||||
|
||||
if ( !query.exec( statement ) )
|
||||
{
|
||||
|
@ -239,7 +239,7 @@ void QgsOgrFeatureIterator::getFeatureAttribute( OGRFeatureH ogrFet, QgsFeature
|
||||
|
||||
if ( OGR_F_IsFieldSet( ogrFet, attindex ) )
|
||||
{
|
||||
switch ( mSource->mFields[attindex].type() )
|
||||
switch ( mSource->mFields.at( attindex ).type() )
|
||||
{
|
||||
case QVariant::String: value = QVariant( mSource->mEncoding->toUnicode( OGR_F_GetFieldAsString( ogrFet, attindex ) ) ); break;
|
||||
case QVariant::Int: value = QVariant( OGR_F_GetFieldAsInteger( ogrFet, attindex ) ); break;
|
||||
@ -250,7 +250,7 @@ void QgsOgrFeatureIterator::getFeatureAttribute( OGRFeatureH ogrFet, QgsFeature
|
||||
int year, month, day, hour, minute, second, tzf;
|
||||
|
||||
OGR_F_GetFieldAsDateTime( ogrFet, attindex, &year, &month, &day, &hour, &minute, &second, &tzf );
|
||||
if ( mSource->mFields[attindex].type() == QVariant::Date )
|
||||
if ( mSource->mFields.at( attindex ).type() == QVariant::Date )
|
||||
value = QDate( year, month, day );
|
||||
else
|
||||
value = QDateTime( QDate( year, month, day ), QTime( hour, minute, second ) );
|
||||
|
@ -1022,7 +1022,7 @@ bool QgsOgrProvider::addFeature( QgsFeature& f )
|
||||
OGRFieldDefnH fldDef = OGR_FD_GetFieldDefn( fdef, targetAttributeId );
|
||||
OGRFieldType type = OGR_Fld_GetType( fldDef );
|
||||
|
||||
QVariant attrVal = attrs[targetAttributeId];
|
||||
QVariant attrVal = attrs.at( targetAttributeId );
|
||||
if ( attrVal.isNull() || ( type != OFTString && attrVal.toString().isEmpty() ) )
|
||||
{
|
||||
OGR_F_UnsetField( feature, targetAttributeId );
|
||||
@ -2314,7 +2314,7 @@ void QgsOgrProvider::uniqueValues( int index, QList<QVariant> &uniqueValues, int
|
||||
if ( index < 0 || index >= mAttributeFields.count() )
|
||||
return;
|
||||
|
||||
const QgsField& fld = mAttributeFields[index];
|
||||
const QgsField& fld = mAttributeFields.at( index );
|
||||
if ( fld.name().isNull() )
|
||||
{
|
||||
return; //not a provider field
|
||||
@ -2362,7 +2362,7 @@ QVariant QgsOgrProvider::minimumValue( int index )
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
const QgsField& fld = mAttributeFields[index];
|
||||
const QgsField& fld = mAttributeFields.at( index );
|
||||
|
||||
// Don't quote column name (see https://trac.osgeo.org/gdal/ticket/5799#comment:9)
|
||||
QByteArray sql = "SELECT MIN(" + mEncoding->fromUnicode( fld.name() );
|
||||
@ -2401,7 +2401,7 @@ QVariant QgsOgrProvider::maximumValue( int index )
|
||||
{
|
||||
return QVariant();
|
||||
}
|
||||
const QgsField& fld = mAttributeFields[index];
|
||||
const QgsField& fld = mAttributeFields.at( index );
|
||||
|
||||
// Don't quote column name (see https://trac.osgeo.org/gdal/ticket/5799#comment:9)
|
||||
QByteArray sql = "SELECT MAX(" + mEncoding->fromUnicode( fld.name() );
|
||||
|
@ -391,14 +391,14 @@ bool QgsPostgresFeatureIterator::declareCursor( const QString& whereClause )
|
||||
break;
|
||||
|
||||
case pktInt:
|
||||
query += delim + QgsPostgresConn::quotedIdentifier( mSource->mFields[ mSource->mPrimaryKeyAttrs[0] ].name() );
|
||||
query += delim + QgsPostgresConn::quotedIdentifier( mSource->mFields.at( mSource->mPrimaryKeyAttrs.at( 0 ) ).name() );
|
||||
delim = ",";
|
||||
break;
|
||||
|
||||
case pktFidMap:
|
||||
Q_FOREACH ( int idx, mSource->mPrimaryKeyAttrs )
|
||||
{
|
||||
query += delim + mConn->fieldExpression( mSource->mFields[idx] );
|
||||
query += delim + mConn->fieldExpression( mSource->mFields.at( idx ) );
|
||||
delim = ",";
|
||||
}
|
||||
break;
|
||||
@ -415,7 +415,7 @@ bool QgsPostgresFeatureIterator::declareCursor( const QString& whereClause )
|
||||
if ( mSource->mPrimaryKeyAttrs.contains( idx ) )
|
||||
continue;
|
||||
|
||||
query += delim + mConn->fieldExpression( mSource->mFields[idx] );
|
||||
query += delim + mConn->fieldExpression( mSource->mFields.at( idx ) );
|
||||
}
|
||||
|
||||
query += " FROM " + mSource->mQuery;
|
||||
@ -538,7 +538,7 @@ bool QgsPostgresFeatureIterator::getFeature( QgsPostgresResult &queryResult, int
|
||||
|
||||
Q_FOREACH ( int idx, mSource->mPrimaryKeyAttrs )
|
||||
{
|
||||
const QgsField &fld = mSource->mFields[idx];
|
||||
const QgsField &fld = mSource->mFields.at( idx );
|
||||
|
||||
QVariant v = QgsPostgresProvider::convertValue( fld.type(), queryResult.PQgetvalue( row, col ) );
|
||||
primaryKeyVals << v;
|
||||
@ -582,7 +582,7 @@ void QgsPostgresFeatureIterator::getFeatureAttribute( int idx, QgsPostgresResult
|
||||
if ( mSource->mPrimaryKeyAttrs.contains( idx ) )
|
||||
return;
|
||||
|
||||
QVariant v = QgsPostgresProvider::convertValue( mSource->mFields[idx].type(), queryResult.PQgetvalue( row, col ) );
|
||||
QVariant v = QgsPostgresProvider::convertValue( mSource->mFields.at( idx ).type(), queryResult.PQgetvalue( row, col ) );
|
||||
feature.setAttribute( idx, v );
|
||||
|
||||
col++;
|
||||
|
@ -189,14 +189,14 @@ QgsPostgresProvider::QgsPostgresProvider( QString const & uri )
|
||||
case pktInt:
|
||||
Q_ASSERT( mPrimaryKeyAttrs.size() == 1 );
|
||||
Q_ASSERT( mPrimaryKeyAttrs[0] >= 0 && mPrimaryKeyAttrs[0] < mAttributeFields.count() );
|
||||
key = mAttributeFields[ mPrimaryKeyAttrs[0] ].name();
|
||||
key = mAttributeFields.at( mPrimaryKeyAttrs.at( 0 ) ).name();
|
||||
break;
|
||||
case pktFidMap:
|
||||
{
|
||||
QString delim;
|
||||
Q_FOREACH ( int idx, mPrimaryKeyAttrs )
|
||||
{
|
||||
key += delim + mAttributeFields[ idx ].name();
|
||||
key += delim + mAttributeFields.at( idx ).name();
|
||||
delim = ",";
|
||||
}
|
||||
}
|
||||
@ -1204,7 +1204,7 @@ bool QgsPostgresProvider::determinePrimaryKey()
|
||||
QgsDebugMsg( "Skipping " + name );
|
||||
continue;
|
||||
}
|
||||
const QgsField& fld = mAttributeFields[idx];
|
||||
const QgsField& fld = mAttributeFields.at( idx );
|
||||
|
||||
if ( isInt &&
|
||||
fld.type() != QVariant::Int &&
|
||||
@ -1296,7 +1296,7 @@ void QgsPostgresProvider::determinePrimaryKeyFromUriKeyColumn()
|
||||
{
|
||||
if ( mUseEstimatedMetadata || uniqueData( mQuery, primaryKey ) )
|
||||
{
|
||||
mPrimaryKeyType = ( mPrimaryKeyAttrs.size() == 1 && ( mAttributeFields[ mPrimaryKeyAttrs[0] ].type() == QVariant::Int || mAttributeFields[ mPrimaryKeyAttrs[0] ].type() == QVariant::LongLong ) ) ? pktInt : pktFidMap;
|
||||
mPrimaryKeyType = ( mPrimaryKeyAttrs.size() == 1 && ( mAttributeFields.at( mPrimaryKeyAttrs.at( 0 ) ).type() == QVariant::Int || mAttributeFields.at( mPrimaryKeyAttrs[0] ).type() == QVariant::LongLong ) ) ? pktInt : pktFidMap;
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1408,8 +1408,8 @@ void QgsPostgresProvider::enumValues( int index, QStringList& enumList )
|
||||
return;
|
||||
|
||||
//find out type of index
|
||||
QString fieldName = mAttributeFields[index].name();
|
||||
QString typeName = mAttributeFields[index].typeName();
|
||||
QString fieldName = mAttributeFields.at( index ).name();
|
||||
QString typeName = mAttributeFields.at( index ).typeName();
|
||||
|
||||
//is type an enum?
|
||||
QString typeSql = QString( "SELECT typtype FROM pg_type WHERE typname=%1" ).arg( quotedValue( typeName ) );
|
||||
@ -1731,15 +1731,15 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist )
|
||||
// e.g. for defaults
|
||||
for ( int idx = 0; idx < attributevec.count(); ++idx )
|
||||
{
|
||||
QVariant v = attributevec[idx];
|
||||
QVariant v = attributevec.at( idx );
|
||||
if ( fieldId.contains( idx ) )
|
||||
continue;
|
||||
|
||||
if ( idx >= mAttributeFields.count() )
|
||||
continue;
|
||||
|
||||
QString fieldname = mAttributeFields[idx].name();
|
||||
QString fieldTypeName = mAttributeFields[idx].typeName();
|
||||
QString fieldname = mAttributeFields.at( idx ).name();
|
||||
QString fieldTypeName = mAttributeFields.at( idx ).typeName();
|
||||
|
||||
QgsDebugMsg( "Checking field against: " + fieldname );
|
||||
|
||||
@ -1750,7 +1750,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist )
|
||||
for ( i = 1; i < flist.size(); i++ )
|
||||
{
|
||||
QgsAttributes attrs2 = flist[i].attributes();
|
||||
QVariant v2 = attrs2[idx];
|
||||
QVariant v2 = attrs2.at( idx );
|
||||
|
||||
if ( v2 != v )
|
||||
break;
|
||||
@ -1841,7 +1841,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist )
|
||||
for ( int i = 0; i < fieldId.size(); i++ )
|
||||
{
|
||||
int attrIdx = fieldId[i];
|
||||
QVariant value = attrs[ attrIdx ];
|
||||
QVariant value = attrs.at( attrIdx );
|
||||
|
||||
QString v;
|
||||
if ( value.isNull() )
|
||||
@ -1884,7 +1884,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist )
|
||||
|
||||
if ( mPrimaryKeyType == pktInt )
|
||||
{
|
||||
features->setFeatureId( STRING_TO_FID( attrs[ mPrimaryKeyAttrs[0] ] ) );
|
||||
features->setFeatureId( STRING_TO_FID( attrs.at( mPrimaryKeyAttrs.at( 0 ) ) ) );
|
||||
}
|
||||
else
|
||||
{
|
||||
@ -1892,7 +1892,7 @@ bool QgsPostgresProvider::addFeatures( QgsFeatureList &flist )
|
||||
|
||||
Q_FOREACH ( int idx, mPrimaryKeyAttrs )
|
||||
{
|
||||
primaryKeyVals << attrs[ idx ];
|
||||
primaryKeyVals << attrs.at( idx );
|
||||
}
|
||||
|
||||
features->setFeatureId( mShared->lookupFid( QVariant( primaryKeyVals ) ) );
|
||||
@ -2076,7 +2076,7 @@ bool QgsPostgresProvider::deleteAttributes( const QgsAttributeIds& ids )
|
||||
if ( index < 0 || index >= mAttributeFields.count() )
|
||||
continue;
|
||||
|
||||
QString column = mAttributeFields[index].name();
|
||||
QString column = mAttributeFields.at( index ).name();
|
||||
QString sql = QString( "ALTER TABLE %1 DROP COLUMN %2" )
|
||||
.arg( mQuery,
|
||||
quotedIdentifier( column ) );
|
||||
|
@ -165,7 +165,7 @@ bool QgsSpatiaLiteFeatureIterator::prepareStatement( QString whereClause )
|
||||
// fetch all attributes
|
||||
for ( int idx = 0; idx < mSource->mFields.count(); ++idx )
|
||||
{
|
||||
sql += "," + fieldName( mSource->mFields[idx] );
|
||||
sql += "," + fieldName( mSource->mFields.at( idx ) );
|
||||
colIdx++;
|
||||
}
|
||||
}
|
||||
|
@ -3421,7 +3421,7 @@ void QgsSpatiaLiteProvider::uniqueValues( int index, QList < QVariant > &uniqueV
|
||||
{
|
||||
return; //invalid field
|
||||
}
|
||||
const QgsField& fld = attributeFields[index];
|
||||
const QgsField& fld = attributeFields.at( index );
|
||||
|
||||
sql = QString( "SELECT DISTINCT %1 FROM %2" ).arg( quotedIdentifier( fld.name() ), mQuery );
|
||||
|
||||
@ -3471,7 +3471,7 @@ void QgsSpatiaLiteProvider::uniqueValues( int index, QList < QVariant > &uniqueV
|
||||
uniqueValues.append( QVariant( QString::fromUtf8(( const char * ) sqlite3_column_text( stmt, 0 ) ) ) );
|
||||
break;
|
||||
default:
|
||||
uniqueValues.append( QVariant( attributeFields[index].type() ) );
|
||||
uniqueValues.append( QVariant( attributeFields.at( index ).type() ) );
|
||||
break;
|
||||
}
|
||||
}
|
||||
@ -3568,13 +3568,13 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist )
|
||||
|
||||
for ( int i = 0; i < attributevec.count(); ++i )
|
||||
{
|
||||
if ( !attributevec[i].isValid() )
|
||||
if ( !attributevec.at( i ).isValid() )
|
||||
continue;
|
||||
|
||||
if ( i >= attributeFields.count() )
|
||||
continue;
|
||||
|
||||
QString fieldname = attributeFields[i].name();
|
||||
QString fieldname = attributeFields.at( i ).name();
|
||||
if ( fieldname.isEmpty() || fieldname == mGeometryColumn )
|
||||
continue;
|
||||
|
||||
@ -3625,7 +3625,7 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist )
|
||||
|
||||
for ( int i = 0; i < attributevec.count(); ++i )
|
||||
{
|
||||
QVariant v = attributevec[i];
|
||||
QVariant v = attributevec.at( i );
|
||||
if ( !v.isValid() )
|
||||
continue;
|
||||
|
||||
@ -3633,11 +3633,11 @@ bool QgsSpatiaLiteProvider::addFeatures( QgsFeatureList & flist )
|
||||
if ( i >= attributeFields.count() )
|
||||
break;
|
||||
|
||||
QString fieldname = attributeFields[i].name();
|
||||
QString fieldname = attributeFields.at( i ).name();
|
||||
if ( fieldname.isEmpty() || fieldname == mGeometryColumn )
|
||||
continue;
|
||||
|
||||
QVariant::Type type = attributeFields[i].type();
|
||||
QVariant::Type type = attributeFields.at( i ).type();
|
||||
|
||||
if ( v.isNull() )
|
||||
{
|
||||
|
@ -132,8 +132,8 @@ void QgsWFSFeatureIterator::copyFeature( const QgsFeature* f, QgsFeature& featur
|
||||
for ( int i = 0; i < mSource->mFields.size(); i++ )
|
||||
{
|
||||
const QVariant &v = f->attributes().value( i );
|
||||
if ( v.type() != mSource->mFields[i].type() )
|
||||
feature.setAttribute( i, QgsVectorDataProvider::convertValue( mSource->mFields[i].type(), v.toString() ) );
|
||||
if ( v.type() != mSource->mFields.at( i ).type() )
|
||||
feature.setAttribute( i, QgsVectorDataProvider::convertValue( mSource->mFields.at( i ).type(), v.toString() ) );
|
||||
else
|
||||
feature.setAttribute( i, v );
|
||||
}
|
||||
|
@ -1219,7 +1219,7 @@ int QgsWFSProvider::getFeaturesFromGML2( const QDomElement& wfsCollectionElement
|
||||
continue;
|
||||
}
|
||||
|
||||
const QgsField &fld = mFields[attr];
|
||||
const QgsField &fld = mFields.at( attr );
|
||||
QgsDebugMsg( QString( "set attribute %1: type=%2 value=%3" ).arg( attr ).arg( QVariant::typeToName( fld.type() ), currentAttributeElement.text() ) );
|
||||
f->setAttribute( attr, convertValue( fld.type(), currentAttributeElement.text() ) );
|
||||
}
|
||||
|
@ -586,7 +586,7 @@ void TestQgsExpressionContext::layerScope()
|
||||
|
||||
//check that fields were set
|
||||
QgsFields fromVar = qvariant_cast<QgsFields>( context.variable( QgsExpressionContext::EXPR_FIELDS ) );
|
||||
QCOMPARE( fromVar, vectorLayer->pendingFields() );
|
||||
QCOMPARE( fromVar, vectorLayer->fields() );
|
||||
|
||||
//test setting layer variables
|
||||
QgsExpressionContextUtils::setLayerVariable( vectorLayer.data(), "testvar", "testval" );
|
||||
|
Loading…
x
Reference in New Issue
Block a user