51 int nPendingFields = pendingFields.
count();
52 for (
int i = 0; i < subset.count(); ++i )
54 int attrIndex = subset[i];
55 if ( attrIndex < 0 || attrIndex >= nPendingFields )
continue;
298 for ( QgsAttributeList::const_iterator attIt = fetchAttributes.constBegin(); attIt != fetchAttributes.constEnd(); ++attIt )
303 int sourceLayerIndex;
305 Q_ASSERT( joinInfo );
308 Q_ASSERT( joinLayer );
331 if ( !fetchAttributes.contains( info.
targetField ) )
338 mFetchJoinInfo[ joinLayer ].attributes.push_back( sourceLayerIndex );
352 QMap<QgsVectorLayer*, FetchJoinInfo>::const_iterator joinIt =
mFetchJoinInfo.constBegin();
356 Q_ASSERT( joinIt.key() );
359 if ( !targetFieldValue.isValid() )
363 if ( memoryCache.isEmpty() )
375 QHash<QString, QgsAttributes>::const_iterator it = memoryCache.find( joinValue.toString() );
376 if ( it == memoryCache.constEnd() )
382 for (
int i = 0; i < featureAttributes.count(); ++i )
397 QString subsetString = joinLayer->dataProvider()->subsetString();
398 QString bkSubsetString = subsetString;
399 if ( !subsetString.isEmpty() )
401 subsetString.prepend(
"(" ).append(
") AND " );
404 QString joinFieldName;
405 if ( joinInfo->joinFieldName.isEmpty() && joinInfo->joinFieldIndex >= 0 && joinInfo->joinFieldIndex < joinLayer->pendingFields().count() )
406 joinFieldName = joinLayer->pendingFields().field( joinInfo->joinFieldIndex ).name();
408 joinFieldName = joinInfo->joinFieldName;
410 subsetString.append( QString(
"\"%1\"" ).arg( joinFieldName ) );
412 if ( joinValue.isNull() )
414 subsetString +=
" IS NULL";
418 QString v = joinValue.toString();
419 switch ( joinValue.type() )
422 case QVariant::LongLong:
423 case QVariant::Double:
427 case QVariant::String:
428 v.replace(
"'",
"''" );
429 v.prepend(
"'" ).append(
"'" );
432 subsetString +=
"=" + v;
435 joinLayer->dataProvider()->setSubsetString( subsetString,
false );
447 int index = indexOffset;
449 for (
int i = 0; i < attr.count(); ++i )
451 if ( i == joinField )
462 joinLayer->dataProvider()->setSubsetString( bkSubsetString,
false );
486 if ( iter->id() == featureId )
525 for ( QgsAttributeMap::const_iterator it = map.begin(); it != map.end(); it++ )
526 attrs[it.key()] = it.value();
QgsFeatureId id() const
Get the feature id for this feature.
const QgsGeometryMap & changedGeometries()
Changed geometries which are not commited.
Wrapper for iterator of features from vector data provider or vector layer.
void addJoinedAttributesDirect(QgsFeature &f, const QVariant &joinValue) const
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
bool fetchNextAddedFeature(QgsFeature &f)
const Flags & flags() const
QString joinFieldName
Join field in the source layer.
field comes from a joined layer (originIndex / 1000 = index of the join, originIndex % 1000 = index w...
bool fetchNextChangedGeomFeature(QgsFeature &f)
QString targetFieldName
Join field in the target layer.
QgsFeatureIterator mProviderIterator
QMap< int, QVariant > QgsAttributeMap
void addJoinedAttributes(QgsFeature &f)
QgsFeatureMap::ConstIterator mFetchAddedFeaturesIt
QgsGeometryMap::ConstIterator mFetchChangedGeomIt
const QgsRectangle & filterRect() const
QgsChangedAttributesMap mChangedAttributeValues
QSet< QgsFeatureId > QgsFeatureIds
int joinFieldIndex
Join field index in the source layer.
QgsGeometry * geometry() const
Get the geometry object associated with this feature.
const QgsChangedAttributesMap & changedAttributeValues()
Changed attributes values which are not commited.
virtual bool nextFeature(QgsFeature &feature)
fetch next feature, return true on success
QgsFeatureRequest & setSubsetOfAttributes(const QgsAttributeList &attrs)
Set a subset of attributes that will be fetched.
QList< QgsField > mAddedAttributes
Container of fields for a vector layer.
A geometry is the spatial representation of a feature.
const QgsAttributeList & subsetOfAttributes() const
void setAttributes(const QgsAttributes &attrs)
bool setAttribute(int field, const QVariant &attr)
Set an attribute by id.
~QgsVectorLayerFeatureIterator()
field comes from the underlying data provider of the vector layer (originIndex = index in provider's ...
int targetFieldIndex
Join field index in the target layer.
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
QgsAttributeList mDeletedAttributeIds
QgsVectorLayer * joinLayer
resolved pointer to the joined layer
Manages joined fields for a vector layer.
const QgsVectorJoinInfo * joinForFieldIndex(int index, const QgsFields &fields, int &sourceFieldIndex) const
Finds the vector join for a layer field index.
int joinField
index of field (of the joined layer) must have equal value
QMap< QgsVectorLayer *, FetchJoinInfo > mFetchJoinInfo
Informations about joins used in the current select() statement.
bool containsJoins() const
Quick way to test if there is any join at all.
void updateChangedAttributes(QgsFeature &f)
Update feature with uncommited attribute updates.
QgsFeatureRequest & setFilterFid(QgsFeatureId fid)
Set feature ID that should be fetched.
void setGeometry(const QgsGeometry &geom)
Set this feature's geometry from another QgsGeometry object (deep copy)
QgsVectorLayerEditBuffer * editBuffer()
Buffer with uncommitted editing operations. Only valid after editing has been turned on...
void useAddedFeature(const QgsFeature &src, QgsFeature &f)
void setFeatureId(QgsFeatureId id)
Set the feature id for this feature.
const QgsVectorJoinInfo * joinInfo
cannonical source of information about the join
QgsGeometryMap mChangedGeometries
Internal feature iterator to be implemented within data providers.
void updateFeatureGeometry(QgsFeature &f)
Update feature with uncommited geometry updates.
int fieldOriginIndex(int fieldIdx) const
Get field's origin index (its meaning is specific to each type of origin)
virtual bool close()
end of iterating: free the resources / lock
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QList< int > QgsAttributeList
QgsFeatureRequest mProviderRequest
const QgsFeatureIds deletedFeatureIds()
const QgsAttributes & attributes() const
virtual QgsFeatureIterator getFeatures(const QgsFeatureRequest &request=QgsFeatureRequest())=0
Query the provider for features specified in request.
QgsFeatureIds mDeletedFeatureIds
Filter using a rectangle.
int count() const
Return number of items.
virtual bool rewind()
reset the iterator to the starting position
FilterType filterType() const
Fetch only a subset of attributes (setSubsetOfAttributes sets this flag)
void setFields(const QgsFields *fields, bool initAttributes=false)
Assign a field map with the feature to allow attribute access by attribute name.
const QList< QgsField > & addedAttributes()
added attributes fields which are not commited
int indexFromName(const QString &name) const
Look up field's index from name. Returns -1 on error.
QSet< QgsFeatureId > mFetchConsidered
bool nextFeatureFid(QgsFeature &f)
const QgsFeatureId & filterFid() const
int indexOffset
at what position the joined fields start
void useChangedAttributeFeature(QgsFeatureId fid, const QgsGeometry &geom, QgsFeature &f)
const QgsFeatureMap & addedFeatures()
New features which are not commited.
void setValid(bool validity)
Set the validity of the feature.
QMap< QgsFeatureId, QgsFeature > QgsFeatureMap
QgsFeatureRequest mRequest
int targetField
index of field (of this layer) that drives the join
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
QHash< QString, QgsAttributes > cachedAttributes
Cache for joined attributes to provide fast lookup (size is 0 if no memory caching) ...
QVariant attribute(const QString &name) const
Lookup attribute value from attribute name.
QgsAttributeList pendingAllAttributesList()
returns list of attributes
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
QgsVectorLayerJoinBuffer * mJoinBuffer
QVector< QVariant > QgsAttributes
FieldOrigin fieldOrigin(int fieldIdx) const
Get field's origin (value from an enumeration)
QgsFeatureMap mAddedFeatures
Join information prepared for fast attribute id mapping in QgsVectorLayerJoinBuffer::updateFeatureAtt...
QgsMapLayer * mapLayer(QString theLayerId)
Retrieve a pointer to a loaded layer by id.
void addJoinedAttributesCached(QgsFeature &f, const QVariant &joinValue) const
const QgsFields & pendingFields() const
returns field list in the to-be-committed state
QgsVectorDataProvider * dataProvider()
Returns the data provider.
bool nextFeature(QgsFeature &f)
QgsFields mUpdatedFields
field map to commit
Represents a vector layer which manages a vector based data sets.
QgsVectorLayerFeatureIterator(QgsVectorLayer *layer, const QgsFeatureRequest &request)
const QgsAttributeList & deletedAttributeIds()
deleted attributes fields which are not commited.
QgsFeatureRequest & setFlags(Flags flags)
Set flags that affect how features will be fetched.
QString joinLayerId
Source layer.