Quantum GIS API Documentation
1.8
|
Manages joined fields for a vector layer. More...
#include <qgsvectorlayerjoinbuffer.h>
Public Member Functions | |
QgsVectorLayerJoinBuffer () | |
~QgsVectorLayerJoinBuffer () | |
void | addJoin (QgsVectorJoinInfo joinInfo) |
Joins another vector layer to this layer. | |
void | removeJoin (const QString &joinLayerId) |
Removes a vector layer join. | |
void | select (const QgsAttributeList &fetchAttributes, QgsAttributeList &sourceJoinFields, int maxProviderIndex) |
Creates QgsVectorLayerJoinBuffer for the joins containing attributes to fetch. | |
void | updateFieldMap (QgsFieldMap &fields, int &maxIndex) |
Updates field map with joined attributes. | |
void | updateFeatureAttributes (QgsFeature &f, int maxProviderIndex, bool all=false) |
Update feature with uncommited attribute updates and joined attributes. | |
void | createJoinCaches () |
Calls cacheJoinLayer() for all vector joins. | |
void | writeXml (QDomNode &layer_node, QDomDocument &document) const |
Saves mVectorJoins to xml under the layer node. | |
void | readXml (const QDomNode &layer_node) |
Reads joins from project file. | |
bool | containsJoins () const |
Quick way to test if there is any join at all. | |
bool | containsFetchJoins () const |
Quick way to test if there is a join to be fetched. | |
const QList< QgsVectorJoinInfo > & | vectorJoins () const |
const QgsVectorJoinInfo * | joinForFieldIndex (int index, int maxProviderIndex, int &indexOffset) const |
Finds the vector join for a layer field index. | |
Static Public Member Functions | |
static bool | maximumIndex (const QgsFieldMap &fMap, int &index) |
Helper function to find out the maximum index of a field map. | |
Private Member Functions | |
void | cacheJoinLayer (QgsVectorJoinInfo &joinInfo) |
Caches attributes of join layer in memory if QgsVectorJoinInfo.memoryCache is true (and the cache is not already there) | |
void | addJoinedFeatureAttributes (QgsFeature &f, const QgsVectorJoinInfo &joinInfo, const QString &joinFieldName, const QVariant &joinValue, const QgsAttributeList &attributes, int attributeIndexOffset) |
Adds joined attributes to a feature. | |
Private Attributes | |
QList< QgsVectorJoinInfo > | mVectorJoins |
Joined vector layers. | |
QMap< QgsVectorLayer *, QgsFetchJoinInfo > | mFetchJoinInfos |
Informations about joins used in the current select() statement. |
Manages joined fields for a vector layer.
Definition at line 28 of file qgsvectorlayerjoinbuffer.h.
Definition at line 24 of file qgsvectorlayerjoinbuffer.cpp.
Definition at line 28 of file qgsvectorlayerjoinbuffer.cpp.
void QgsVectorLayerJoinBuffer::addJoin | ( | QgsVectorJoinInfo | joinInfo | ) |
Joins another vector layer to this layer.
joinInfo | join object containing join layer id, target and source field |
Definition at line 32 of file qgsvectorlayerjoinbuffer.cpp.
References cacheJoinLayer(), QgsVectorJoinInfo::memoryCache, and mVectorJoins.
Referenced by QgsVectorLayer::addJoin(), and readXml().
void QgsVectorLayerJoinBuffer::addJoinedFeatureAttributes | ( | QgsFeature & | f, |
const QgsVectorJoinInfo & | joinInfo, | ||
const QString & | joinFieldName, | ||
const QVariant & | joinValue, | ||
const QgsAttributeList & | attributes, | ||
int | attributeIndexOffset | ||
) | [private] |
Adds joined attributes to a feature.
f | the feature to add the attributes |
joinInfo | vector join |
joinFieldName | name of the (source) join Field |
joinValue | lookup value for join |
attributes | (join layer) attribute indices to add |
attributeIndexOffset | index offset to get from join layer attribute index to layer index |
Definition at line 213 of file qgsvectorlayerjoinbuffer.cpp.
References QgsFeature::addAttribute(), QgsFeature::attributeMap(), QgsVectorJoinInfo::cachedAttributes, QgsVectorLayer::dataProvider(), QgsMapLayerRegistry::instance(), QgsVectorJoinInfo::joinField, QgsVectorJoinInfo::joinLayerId, QgsMapLayerRegistry::mapLayer(), QgsVectorLayer::nextFeature(), QgsVectorLayer::select(), QgsDataProvider::setSubsetString(), and QgsDataProvider::subsetString().
Referenced by updateFeatureAttributes().
void QgsVectorLayerJoinBuffer::cacheJoinLayer | ( | QgsVectorJoinInfo & | joinInfo | ) | [private] |
Caches attributes of join layer in memory if QgsVectorJoinInfo.memoryCache is true (and the cache is not already there)
Definition at line 60 of file qgsvectorlayerjoinbuffer.cpp.
References QgsFeature::attributeMap(), QgsVectorJoinInfo::cachedAttributes, QgsMapLayerRegistry::instance(), QgsVectorJoinInfo::joinField, QgsVectorJoinInfo::joinLayerId, QgsMapLayerRegistry::mapLayer(), QgsVectorJoinInfo::memoryCache, QgsVectorLayer::nextFeature(), QgsVectorLayer::pendingAllAttributesList(), and QgsVectorLayer::select().
Referenced by addJoin(), and createJoinCaches().
bool QgsVectorLayerJoinBuffer::containsFetchJoins | ( | ) | const [inline] |
Quick way to test if there is a join to be fetched.
Definition at line 65 of file qgsvectorlayerjoinbuffer.h.
Referenced by QgsVectorLayer::updateFeatureAttributes().
bool QgsVectorLayerJoinBuffer::containsJoins | ( | ) | const [inline] |
Quick way to test if there is any join at all.
Definition at line 63 of file qgsvectorlayerjoinbuffer.h.
Referenced by QgsVectorLayer::createJoinCaches(), QgsVectorLayer::select(), and QgsVectorLayer::updateFieldMap().
Calls cacheJoinLayer() for all vector joins.
Definition at line 113 of file qgsvectorlayerjoinbuffer.cpp.
References cacheJoinLayer(), and mVectorJoins.
Referenced by QgsVectorLayer::createJoinCaches().
const QgsVectorJoinInfo * QgsVectorLayerJoinBuffer::joinForFieldIndex | ( | int | index, |
int | maxProviderIndex, | ||
int & | indexOffset | ||
) | const |
Finds the vector join for a layer field index.
index | this layers attribute index |
maxProviderIndex | maximum attribute index of the vectorlayer provider |
indexOffset | out: offset between layer index and original provider index |
Definition at line 322 of file qgsvectorlayerjoinbuffer.cpp.
References QgsMapLayerRegistry::instance(), QgsMapLayerRegistry::mapLayer(), maximumIndex(), mVectorJoins, and QgsVectorLayer::pendingFields().
Referenced by QgsVectorLayer::maximumValue(), QgsVectorLayer::minimumValue(), select(), and QgsVectorLayer::uniqueValues().
bool QgsVectorLayerJoinBuffer::maximumIndex | ( | const QgsFieldMap & | fMap, |
int & | index | ||
) | [static] |
Helper function to find out the maximum index of a field map.
Definition at line 351 of file qgsvectorlayerjoinbuffer.cpp.
Referenced by joinForFieldIndex(), QgsVectorLayer::maximumValue(), QgsVectorLayer::minimumValue(), QgsVectorLayer::select(), QgsVectorLayer::uniqueValues(), updateFeatureAttributes(), QgsVectorLayer::updateFeatureAttributes(), updateFieldMap(), and QgsVectorLayer::updateFieldMap().
void QgsVectorLayerJoinBuffer::readXml | ( | const QDomNode & | layer_node | ) |
Reads joins from project file.
Definition at line 302 of file qgsvectorlayerjoinbuffer.cpp.
References addJoin(), QgsVectorJoinInfo::joinField, QgsVectorJoinInfo::joinLayerId, QgsVectorJoinInfo::memoryCache, mVectorJoins, and QgsVectorJoinInfo::targetField.
Referenced by QgsVectorLayer::readXml().
void QgsVectorLayerJoinBuffer::removeJoin | ( | const QString & | joinLayerId | ) |
Removes a vector layer join.
Definition at line 43 of file qgsvectorlayerjoinbuffer.cpp.
References QgsMapLayerRegistry::instance(), QgsMapLayerRegistry::mapLayer(), mFetchJoinInfos, and mVectorJoins.
Referenced by QgsVectorLayer::removeJoin().
void QgsVectorLayerJoinBuffer::select | ( | const QgsAttributeList & | fetchAttributes, |
QgsAttributeList & | sourceJoinFields, | ||
int | maxProviderIndex | ||
) |
Creates QgsVectorLayerJoinBuffer for the joins containing attributes to fetch.
Definition at line 122 of file qgsvectorlayerjoinbuffer.cpp.
References QgsMapLayerRegistry::instance(), joinForFieldIndex(), QgsVectorJoinInfo::joinLayerId, QgsMapLayerRegistry::mapLayer(), mFetchJoinInfos, and QgsVectorJoinInfo::targetField.
Referenced by QgsVectorLayer::select().
void QgsVectorLayerJoinBuffer::updateFeatureAttributes | ( | QgsFeature & | f, |
int | maxProviderIndex, | ||
bool | all = false |
||
) |
Update feature with uncommited attribute updates and joined attributes.
Definition at line 151 of file qgsvectorlayerjoinbuffer.cpp.
References addJoinedFeatureAttributes(), QgsFeature::attributeMap(), QgsMapLayerRegistry::instance(), QgsMapLayerRegistry::mapLayer(), maximumIndex(), mFetchJoinInfos, mVectorJoins, QgsVectorLayer::pendingAllAttributesList(), and QgsVectorLayer::pendingFields().
Referenced by QgsVectorLayer::updateFeatureAttributes().
void QgsVectorLayerJoinBuffer::updateFieldMap | ( | QgsFieldMap & | fields, |
int & | maxIndex | ||
) |
Updates field map with joined attributes.
fields | map to append joined attributes |
maxIndex | in/out: maximum attribute index |
Definition at line 82 of file qgsvectorlayerjoinbuffer.cpp.
References QgsMapLayerRegistry::instance(), QgsMapLayerRegistry::mapLayer(), maximumIndex(), mVectorJoins, and QgsVectorLayer::pendingFields().
Referenced by QgsVectorLayer::updateFieldMap().
const QList< QgsVectorJoinInfo >& QgsVectorLayerJoinBuffer::vectorJoins | ( | ) | const [inline] |
Definition at line 67 of file qgsvectorlayerjoinbuffer.h.
Referenced by QgsVectorLayer::vectorJoins().
void QgsVectorLayerJoinBuffer::writeXml | ( | QDomNode & | layer_node, |
QDomDocument & | document | ||
) | const |
Saves mVectorJoins to xml under the layer node.
Definition at line 286 of file qgsvectorlayerjoinbuffer.cpp.
References mVectorJoins.
Referenced by QgsVectorLayer::writeXml().
QMap<QgsVectorLayer*, QgsFetchJoinInfo> QgsVectorLayerJoinBuffer::mFetchJoinInfos [private] |
Informations about joins used in the current select() statement.
Allows faster mapping of attribute ids compared to mVectorJoins
Definition at line 87 of file qgsvectorlayerjoinbuffer.h.
Referenced by removeJoin(), select(), and updateFeatureAttributes().
QList< QgsVectorJoinInfo > QgsVectorLayerJoinBuffer::mVectorJoins [private] |
Joined vector layers.
Definition at line 83 of file qgsvectorlayerjoinbuffer.h.
Referenced by addJoin(), createJoinCaches(), joinForFieldIndex(), readXml(), removeJoin(), updateFeatureAttributes(), updateFieldMap(), and writeXml().