Quantum GIS API Documentation  1.7.4
Public Member Functions | Static Public Member Functions | Private Member Functions | Private Attributes
QgsVectorLayerJoinBuffer Class Reference

Manages joined field for a vector layer. More...

#include <qgsvectorlayerjoinbuffer.h>

List of all members.

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 (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 QgsVectorJoinInfojoinForFieldIndex (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< QgsVectorJoinInfomVectorJoins
 Joined vector layers.
QMap< QgsVectorLayer
*, QgsFetchJoinInfo
mFetchJoinInfos
 Informations about joins used in the current select() statement.

Detailed Description

Manages joined field for a vector layer.

Definition at line 28 of file qgsvectorlayerjoinbuffer.h.


Constructor & Destructor Documentation

Definition at line 24 of file qgsvectorlayerjoinbuffer.cpp.

Definition at line 28 of file qgsvectorlayerjoinbuffer.cpp.


Member Function Documentation

Joins another vector layer to this layer.

Parameters:
joinInfojoin 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.

Parameters:
fthe feature to add the attributes
joinInfovector join
joinFieldNamename of the (source) join Field
joinValuelookup value for join
attributes(join layer) attribute indices to add
attributeIndexOffsetindex offset to get from join layer attribute index to layer index

Definition at line 209 of file qgsvectorlayerjoinbuffer.cpp.

References QgsFeature::addAttribute(), QgsFeature::attributeMap(), QgsVectorJoinInfo::cachedAttributes, QgsVectorLayer::dataProvider(), QgsMapLayerRegistry::instance(), QgsVectorJoinInfo::joinLayerId, QgsMapLayerRegistry::mapLayer(), QgsVectorLayer::nextFeature(), QgsVectorLayer::select(), QgsDataProvider::setSubsetString(), and QgsDataProvider::subsetString().

Referenced by updateFeatureAttributes().

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 109 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.

Parameters:
indexthis layers attribute index
maxProviderIndexmaximum attribute index of the vectorlayer provider
indexOffsetout: offset between layer index and original provider index
Returns:
pointer to the join if the index belongs to a joined field, otherwise 0 (possibily provider field or added field)

Definition at line 312 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.

Returns:
true in case of success, otherwise false (e.g. empty map)

Definition at line 341 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 ( QDomNode &  layer_node)
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 
)
void QgsVectorLayerJoinBuffer::updateFeatureAttributes ( QgsFeature f,
int  maxProviderIndex,
bool  all = false 
)
void QgsVectorLayerJoinBuffer::updateFieldMap ( QgsFieldMap fields,
int &  maxIndex 
)

Updates field map with joined attributes.

Parameters:
fieldsmap to append joined attributes
maxIndexin/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 276 of file qgsvectorlayerjoinbuffer.cpp.

References mVectorJoins.

Referenced by QgsVectorLayer::writeXml().


Member Data Documentation

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().


The documentation for this class was generated from the following files:
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Defines