Skip to content
Permalink
Browse files

Drop QgsVectorLayer::pendingFields()

Use QgsVectorLayer::fields() instead.
  • Loading branch information
nyalldawson committed Jan 12, 2018
1 parent 3b3d901 commit 068d51c3bef6e4f8e219a7fcb6b3d8f607d02e09
@@ -2431,6 +2431,7 @@ displayExpression instead. For the map tip use mapTipTemplate() instead.
- addPart() now returns QgsGeometry::OperationResult enum, integer representation of returned values may have changed
- splitParts() now returns QgsGeometry::OperationResult enum, integer representation of returned values may have changed
- splitFeatured() now returns QgsGeometry::OperationResult enum, integer representation of returned values may have changed
- pendingFields() was dropped. Use fields() instead.


QgsVectorLayerEditBuffer {#qgis_api_break_3_0_QgsVectorLayerEditBuffer}
@@ -1391,15 +1391,6 @@ Return new instance of QgsMapLayerRenderer that will be used for rendering of gi
Returns the list of fields of this layer.
This also includes fields which have not yet been saved to the provider.

:return: A list of fields
%End

QgsFields pendingFields() const;
%Docstring
Returns the list of fields of this layer.
This also includes fields which have not yet been saved to the provider.
Alias for fields()

:return: A list of fields
%End

@@ -1186,7 +1186,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature &f, QgsRenderContext &cont
return;
}

// mCurFields = &layer->pendingFields();
// mCurFields = &layer->fields();

// store data defined-derived values for later adding to label feature for use during rendering
dataDefinedValues.clear();
2 src/core/qgsvectorlayer.cpp 100755 → 100644
@@ -4093,7 +4093,7 @@ QString QgsVectorLayer::htmlMetadata() const
myMetadata += QLatin1String( "</td></tr>\n" );
}

const QgsFields &myFields = pendingFields();
const QgsFields myFields = fields();

// count fields
myMetadata += QStringLiteral( "<tr><td class=\"highlight\">" ) + tr( "Count" ) + QStringLiteral( "</td><td>" ) + QString::number( myFields.size() ) + QStringLiteral( "</td></tr>\n" );
@@ -1302,15 +1302,6 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
*/
inline QgsFields fields() const override { return mFields; }

/**
* Returns the list of fields of this layer.
* This also includes fields which have not yet been saved to the provider.
* Alias for fields()
*
* \returns A list of fields
*/
inline QgsFields pendingFields() const { return mFields; }

/**
* Returns list of attribute indexes. i.e. a list from 0 ... fieldCount()
* Alias for attributeList()
@@ -385,7 +385,7 @@ bool QgsVectorLayerEditBuffer::commitChanges( QStringList &commitErrors )
QString list = "ERROR: Pending attribute deletes:";
Q_FOREACH ( int idx, mDeletedAttributeIds )
{
list.append( ' ' + L->pendingFields().at( idx ).name() );
list.append( ' ' + L->fields().at( idx ).name() );
}
commitErrors << list;
#endif
@@ -529,7 +529,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().at( idx ).name() ).arg( mChangedAttributeValues[id][idx].toString() ) );
list.append( QString( " %1:%2" ).arg( L->fields().at( idx ).name() ).arg( mChangedAttributeValues[id][idx].toString() ) );
}
list.append( " ]" );
}
@@ -619,9 +619,9 @@ bool QgsVectorLayerEditBuffer::commitChanges( QStringList &commitErrors )
Q_FOREACH ( QgsFeature f, mAddedFeatures )
{
list.append( ' ' + FID_TO_STRING( f.id() ) + '[' );
for ( int i = 0; i < L->pendingFields().size(); i++ )
for ( int i = 0; i < L->fields().size(); i++ )
{
list.append( QString( " %1:%2" ).arg( L->pendingFields().at( i ).name() ).arg( f.attributes()[i].toString() ) );
list.append( QString( " %1:%2" ).arg( L->fields().at( i ).name() ).arg( f.attributes()[i].toString() ) );
}
list.append( " ]" );
}
@@ -63,7 +63,7 @@ void QgsGlobeFeatureSource::initialize( const osgDB::Options *dbOptions )
}
QgsRectangle ext = mLayer->extent();
osgEarth::GeoExtent geoext( ref, ext.xMinimum(), ext.yMinimum(), ext.xMaximum(), ext.yMaximum() );
mSchema = QgsGlobeFeatureUtils::schemaForFields( mLayer->pendingFields() );
mSchema = QgsGlobeFeatureUtils::schemaForFields( mLayer->fields() );
#if OSGEARTH_VERSION_GREATER_OR_EQUAL(2, 8, 0)
setFeatureProfile( new osgEarth::Features::FeatureProfile( geoext ) );
return osgEarth::Status( osgEarth::Status::NoError );
@@ -139,7 +139,7 @@ void QgsGlobeFeatureSource::attributeValueChanged( const QgsFeatureId &featureId
if ( it != mFeatures.end() )
{
osgEarth::Features::Feature *feature = it->second.get();
QgsGlobeFeatureUtils::setFeatureField( feature, mLayer->pendingFields().at( idx ), value );
QgsGlobeFeatureUtils::setFeatureField( feature, mLayer->fields().at( idx ), value );
}
}

@@ -159,7 +159,7 @@ class QgsGlobeFeatureUtils
osgEarth::SpatialReference *ref = osgEarth::SpatialReference::create( layer->crs().toWkt().toStdString() );
osgEarth::Features::Feature *retFeat = new osgEarth::Features::Feature( nGeom, ref, osgEarth::Style(), feat.id() );

const QgsFields &fields = layer->pendingFields();
const QgsFields fields = layer->fields();
const QgsAttributes &attrs = feat.attributes();

for ( int idx = 0, numFlds = fields.size(); idx < numFlds; ++idx )
@@ -248,7 +248,7 @@ namespace QgsWfs
sequenceElem.appendChild( geomElem );

//Attributes
const QgsFields &fields = layer->pendingFields();
QgsFields fields = layer->fields();
//hidden attributes for this layer
const QSet<QString> &layerExcludedAttributes = layer->excludeAttributesWfs();
for ( int idx = 0; idx < fields.count(); ++idx )
@@ -247,7 +247,7 @@ namespace QgsWfs
withGeom = false;
QStringList::const_iterator plstIt;
QList<int> idxList;
QgsFields fields = vlayer->pendingFields();
QgsFields fields = vlayer->fields();
QString fieldName;
for ( plstIt = propertyList.begin(); plstIt != propertyList.end(); ++plstIt )
{
@@ -294,11 +294,11 @@ namespace QgsWfs
QStringList attributes = QStringList();
Q_FOREACH ( int idx, attrIndexes )
{
attributes.append( vlayer->pendingFields().field( idx ).name() );
attributes.append( vlayer->fields().field( idx ).name() );
}
featureRequest.setSubsetOfAttributes(
accessControl->layerAttributes( vlayer, attributes ),
vlayer->pendingFields() );
vlayer->fields() );
}

if ( onlyOneLayer )
@@ -1663,7 +1663,7 @@ namespace QgsWms

//attributes
QDomElement attributesElem = doc.createElement( QStringLiteral( "Attributes" ) );
const QgsFields &layerFields = vLayer->pendingFields();
const QgsFields layerFields = vLayer->fields();
for ( int idx = 0; idx < layerFields.count(); ++idx )
{
QgsField field = layerFields.at( idx );
@@ -266,7 +266,7 @@ namespace QgsWms
{
std::unique_ptr< QgsFeatureRenderer > r( vl->renderer()->clone() );
bool moreSymbolsPerFeature = r->capabilities() & QgsFeatureRenderer::MoreSymbolsPerFeature;
r->startRender( context, vl->pendingFields() );
r->startRender( context, vl->fields() );
QgsFeature f;
QgsFeatureRequest request( context.extent() );
request.setFlags( QgsFeatureRequest::ExactIntersect );
@@ -821,7 +821,7 @@ namespace QgsWms
int layerAttribute = -1;
if ( layerAttributes.size() > layerIdx )
{
layerAttribute = vlayer->pendingFields().indexFromName( layerAttributes.at( layerIdx ) );
layerAttribute = vlayer->fields().indexFromName( layerAttributes.at( layerIdx ) );
}

dxfLayers.append( qMakePair( vlayer, layerAttribute ) );
@@ -1401,7 +1401,7 @@ namespace QgsWms
QgsAttributes featureAttributes;
int featureCounter = 0;
layer->updateFields();
const QgsFields &fields = layer->pendingFields();
const QgsFields fields = layer->fields();
bool addWktGeometry = ( QgsServerProjectUtils::wmsFeatureInfoAddWktGeometry( *mProject ) && mWmsParameters.withGeometry() );
bool segmentizeWktGeometry = QgsServerProjectUtils::wmsFeatureInfoSegmentizeWktGeometry( *mProject );
const QSet<QString> &excludedAttributes = layer->excludeAttributesWms();
@@ -1429,19 +1429,19 @@ namespace QgsWms

QStringList attributes;
QgsField field;
Q_FOREACH ( field, layer->pendingFields().toList() )
Q_FOREACH ( field, layer->fields().toList() )
{
attributes.append( field.name() );
}
attributes = mAccessControl->layerAttributes( layer, attributes );
fReq.setSubsetOfAttributes( attributes, layer->pendingFields() );
fReq.setSubsetOfAttributes( attributes, layer->fields() );
#endif

QgsFeatureIterator fit = layer->getFeatures( fReq );
std::unique_ptr< QgsFeatureRenderer > r2( layer->renderer() ? layer->renderer()->clone() : nullptr );
if ( r2 )
{
r2->startRender( renderContext, layer->pendingFields() );
r2->startRender( renderContext, layer->fields() );
}

bool featureBBoxInitialized = false;
@@ -2432,7 +2432,7 @@ namespace QgsWms
}

// create feature with label if necessary
QgsFeature fet( layer->pendingFields() );
QgsFeature fet( layer->fields() );
if ( ! param.mLabel.isEmpty() )
{
fet.setAttribute( 0, param.mLabel );
@@ -67,7 +67,7 @@ def _setUp(self):
layer = self._getLayer('test_point')
assert layer.startEditing()
for id, name, geom in TEST_FEATURES:
f = QgsFeature(layer.pendingFields())
f = QgsFeature(layer.fields())
f['id'] = id
f['name'] = name
f.setGeometry(QgsGeometry.fromPointXY(geom))
@@ -271,7 +271,7 @@ def test_InsertFeatures(self):
self.assertTrue(offline_layer.startEditing())
features = []
for id, name, geom in TEST_FEATURES_INSERT:
f = QgsFeature(offline_layer.pendingFields())
f = QgsFeature(offline_layer.fields())
f['id'] = id
f['name'] = name
f.setGeometry(QgsGeometry.fromPointXY(geom))
@@ -32,13 +32,13 @@ def createReferencingLayer():
"referencinglayer", "memory")
pr = layer.dataProvider()
f1 = QgsFeature()
f1.setFields(layer.pendingFields())
f1.setFields(layer.fields())
f1.setAttributes(["test1", 123])
f2 = QgsFeature()
f2.setFields(layer.pendingFields())
f2.setFields(layer.fields())
f2.setAttributes(["test2", 123])
f3 = QgsFeature()
f3.setFields(layer.pendingFields())
f3.setFields(layer.fields())
f3.setAttributes(["foobar'bar", 124])
assert pr.addFeatures([f1, f2, f3])
return layer
@@ -50,13 +50,13 @@ def createReferencedLayer():
"referencedlayer", "memory")
pr = layer.dataProvider()
f1 = QgsFeature()
f1.setFields(layer.pendingFields())
f1.setFields(layer.fields())
f1.setAttributes(["foo", 123, 321])
f2 = QgsFeature()
f2.setFields(layer.pendingFields())
f2.setFields(layer.fields())
f2.setAttributes(["bar", 456, 654])
f3 = QgsFeature()
f3.setFields(layer.pendingFields())
f3.setFields(layer.fields())
f3.setAttributes(["foobar'bar", 789, 554])
assert pr.addFeatures([f1, f2, f3])
return layer
@@ -103,13 +103,13 @@ def test_FilterFids(self):

def addFeatures(self, vl):
feat = QgsFeature()
fields = vl.pendingFields()
fields = vl.fields()
feat.setFields(fields)
feat['Staff'] = 4
vl.addFeature(feat)

feat = QgsFeature()
fields = vl.pendingFields()
fields = vl.fields()
feat.setFields(fields)
feat['Staff'] = 2
vl.addFeature(feat)
@@ -149,7 +149,7 @@ def test_ExpressionFieldNestedCircular(self):
layer = QgsVectorLayer(myShpFile, 'Points', 'ogr')
self.assertTrue(layer.isValid())

cnt = layer.pendingFields().count() # NOQA
cnt = layer.fields().count() # NOQA
idx = layer.addExpressionField('"exp3"*2', QgsField('exp1', QVariant.LongLong)) # NOQA
idx = layer.addExpressionField('"exp1"-1', QgsField('exp2', QVariant.LongLong)) # NOQA
idx = layer.addExpressionField('"exp2"*3', QgsField('exp3', QVariant.LongLong)) # NOQA
@@ -570,7 +570,7 @@ def rotation_test(self):
# rotate the map and test that the bounding rectangle
# is smaller than the bounds without rotation.
polygonLayer = QgsVectorLayer('Polygon', 'test_polygon', 'memory')
poly = QgsFeature(polygonLayer.pendingFields())
poly = QgsFeature(polygonLayer.fields())
points = [(10, 15), (15, 10), (45, 40), (40, 45)]
poly.setGeometry(QgsGeometry.fromPolygonXY([[QgsPointXY(x[0], x[1]) for x in points]]))
polygonLayer.dataProvider().addFeatures([poly])
@@ -34,15 +34,15 @@ def createReferencingLayer():
"referencinglayer", "memory")
pr = layer.dataProvider()
f1 = QgsFeature()
f1.setFields(layer.pendingFields())
f1.setFields(layer.fields())
f1.setAttributes(["test1", 123])
f1.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(100, 200)))
f2 = QgsFeature()
f2.setFields(layer.pendingFields())
f2.setFields(layer.fields())
f2.setAttributes(["test2", 123])
f2.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(101, 201)))
f3 = QgsFeature()
f3.setFields(layer.pendingFields())
f3.setFields(layer.fields())
f3.setAttributes(["foobar'bar", 124])
f3.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(101, 201)))
assert pr.addFeatures([f1, f2, f3])
@@ -55,15 +55,15 @@ def createReferencedLayer():
"referencedlayer", "memory")
pr = layer.dataProvider()
f1 = QgsFeature()
f1.setFields(layer.pendingFields())
f1.setFields(layer.fields())
f1.setAttributes(["foo", 123, 321])
f1.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(1, 1)))
f2 = QgsFeature()
f2.setFields(layer.pendingFields())
f2.setFields(layer.fields())
f2.setAttributes(["bar", 456, 654])
f2.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(2, 2)))
f3 = QgsFeature()
f3.setFields(layer.pendingFields())
f3.setFields(layer.fields())
f3.setAttributes(["foobar'bar", 789, 554])
f3.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(2, 3)))
assert pr.addFeatures([f1, f2, f3])
@@ -31,11 +31,11 @@ def createReferencingLayer():
"referencinglayer", "memory")
pr = layer.dataProvider()
f1 = QgsFeature()
f1.setFields(layer.pendingFields())
f1.setFields(layer.fields())
f1.setAttributes(["test1", 123])
f1.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(100, 200)))
f2 = QgsFeature()
f2.setFields(layer.pendingFields())
f2.setFields(layer.fields())
f2.setAttributes(["test2", 123])
f2.setGeometry(QgsGeometry.fromPointXY(QgsPointXY(101, 201)))
assert pr.addFeatures([f1, f2])

0 comments on commit 068d51c

Please sign in to comment.
You can’t perform that action at this time.