QGIS API Documentation
2.2.0-Valmiera
|
Manages joined fields for a vector layer. More...
#include <qgsvectorlayerjoinbuffer.h>
Public Member Functions | |
QgsVectorLayerJoinBuffer () | |
~QgsVectorLayerJoinBuffer () | |
void | addJoin (const QgsVectorJoinInfo &joinInfo) |
Joins another vector layer to this layer. | |
void | removeJoin (const QString &joinLayerId) |
Removes a vector layer join. | |
void | updateFields (QgsFields &fields) |
Updates field map with 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. | |
const QList< QgsVectorJoinInfo > & | vectorJoins () const |
const QgsVectorJoinInfo * | joinForFieldIndex (int index, const QgsFields &fields, int &sourceFieldIndex) const |
Finds the vector join for a layer field index. |
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) |
Private Attributes | |
QList< QgsVectorJoinInfo > | mVectorJoins |
Joined vector layers. |
Manages joined fields for a vector layer.
Definition at line 31 of file qgsvectorlayerjoinbuffer.h.
QgsVectorLayerJoinBuffer::QgsVectorLayerJoinBuffer | ( | ) |
Definition at line 25 of file qgsvectorlayerjoinbuffer.cpp.
QgsVectorLayerJoinBuffer::~QgsVectorLayerJoinBuffer | ( | ) |
Definition at line 29 of file qgsvectorlayerjoinbuffer.cpp.
void QgsVectorLayerJoinBuffer::addJoin | ( | const QgsVectorJoinInfo & | joinInfo | ) |
Joins another vector layer to this layer.
joinInfo | join object containing join layer id, target and source field |
Definition at line 33 of file qgsvectorlayerjoinbuffer.cpp.
References cacheJoinLayer(), QgsVectorJoinInfo::memoryCache, and mVectorJoins.
Referenced by QgsVectorLayer::addJoin(), and readXml().
|
private |
Caches attributes of join layer in memory if QgsVectorJoinInfo.memoryCache is true (and the cache is not already there)
Definition at line 55 of file qgsvectorlayerjoinbuffer.cpp.
References QgsFeature::attributes(), QgsVectorJoinInfo::cachedAttributes, QgsVectorLayer::getFeatures(), QgsFields::indexFromName(), QgsMapLayerRegistry::instance(), QgsVectorJoinInfo::joinFieldIndex, QgsVectorJoinInfo::joinFieldName, QgsVectorJoinInfo::joinLayerId, QgsMapLayerRegistry::mapLayer(), QgsVectorJoinInfo::memoryCache, QgsFeatureIterator::nextFeature(), QgsFeatureRequest::NoGeometry, and QgsVectorLayer::pendingFields().
Referenced by addJoin(), and createJoinCaches().
|
inline |
Quick way to test if there is any join at all.
Definition at line 59 of file qgsvectorlayerjoinbuffer.h.
Referenced by QgsVectorLayer::createJoinCaches(), QgsVectorLayerFeatureIterator::QgsVectorLayerFeatureIterator(), and QgsVectorLayer::updateFields().
void QgsVectorLayerJoinBuffer::createJoinCaches | ( | ) |
Calls cacheJoinLayer() for all vector joins.
Definition at line 115 of file qgsvectorlayerjoinbuffer.cpp.
References cacheJoinLayer(), and mVectorJoins.
Referenced by QgsVectorLayer::createJoinCaches().
const QgsVectorJoinInfo * QgsVectorLayerJoinBuffer::joinForFieldIndex | ( | int | index, |
const QgsFields & | fields, | ||
int & | sourceFieldIndex | ||
) | const |
Finds the vector join for a layer field index.
index | this layers attribute index |
fields | fields of the vector layer (including joined fields) |
sourceFieldIndex | Output: field's index in source layer |
Definition at line 174 of file qgsvectorlayerjoinbuffer.cpp.
References QgsFields::fieldOrigin(), QgsFields::fieldOriginIndex(), mVectorJoins, and QgsFields::OriginJoin.
Referenced by QgsVectorLayer::maximumValue(), QgsVectorLayer::minimumValue(), QgsVectorLayerFeatureIterator::prepareJoins(), and QgsVectorLayer::uniqueValues().
void QgsVectorLayerJoinBuffer::readXml | ( | const QDomNode & | layer_node | ) |
Reads joins from project file.
Definition at line 150 of file qgsvectorlayerjoinbuffer.cpp.
References addJoin(), QgsVectorJoinInfo::joinFieldIndex, QgsVectorJoinInfo::joinFieldName, QgsVectorJoinInfo::joinLayerId, QgsVectorJoinInfo::memoryCache, mVectorJoins, QgsVectorJoinInfo::targetFieldIndex, and QgsVectorJoinInfo::targetFieldName.
Referenced by QgsVectorLayer::readXml().
void QgsVectorLayerJoinBuffer::removeJoin | ( | const QString & | joinLayerId | ) |
Removes a vector layer join.
Definition at line 44 of file qgsvectorlayerjoinbuffer.cpp.
References mVectorJoins.
Referenced by QgsVectorLayer::removeJoin().
void QgsVectorLayerJoinBuffer::updateFields | ( | QgsFields & | fields | ) |
Updates field map with joined attributes.
fields | map to append joined attributes |
Definition at line 84 of file qgsvectorlayerjoinbuffer.cpp.
References QgsFields::append(), QgsFields::count(), QgsFields::field(), QgsMapLayerRegistry::instance(), QgsMapLayerRegistry::mapLayer(), mVectorJoins, QgsField::name(), QgsMapLayer::name(), QgsFields::OriginJoin, QgsVectorLayer::pendingFields(), and QgsField::setName().
Referenced by QgsVectorLayer::updateFields().
|
inline |
Definition at line 61 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 125 of file qgsvectorlayerjoinbuffer.cpp.
References mVectorJoins.
Referenced by QgsVectorLayer::writeXml().
|
private |
Joined vector layers.
Definition at line 72 of file qgsvectorlayerjoinbuffer.h.
Referenced by addJoin(), createJoinCaches(), joinForFieldIndex(), readXml(), removeJoin(), updateFields(), and writeXml().