QGIS API Documentation
3.2.0-Bonn (bc43194)
|
Manages joined fields for a vector layer. More...
#include <qgsvectorlayerjoinbuffer.h>
Signals | |
void | joinedFieldsChanged () |
Emitted whenever the list of joined fields changes (e.g. More... | |
Public Member Functions | |
QgsVectorLayerJoinBuffer (QgsVectorLayer *layer=nullptr) | |
bool | addFeatures (QgsFeatureList &features, QgsFeatureSink::Flags flags=nullptr) override |
Adds a list of features in joined layers. More... | |
bool | addJoin (const QgsVectorLayerJoinInfo &joinInfo) |
Joins another vector layer to this layer. More... | |
bool | changeAttributeValue (QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant()) |
Changes attribute value in joined layers. More... | |
bool | changeAttributeValues (QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues=QgsAttributeMap()) |
Changes attributes' values in joined layers. More... | |
QgsVectorLayerJoinBuffer * | clone () const |
Create a copy of the join buffer. More... | |
bool | containsJoins () const |
Quick way to test if there is any join at all. More... | |
void | createJoinCaches () |
Calls cacheJoinLayer() for all vector joins. More... | |
bool | deleteFeature (QgsFeatureId fid) const |
Deletes a feature from joined layers. More... | |
bool | deleteFeatures (const QgsFeatureIds &fids) const |
Deletes a list of features from joined layers. More... | |
bool | isAuxiliaryJoin (const QgsVectorLayerJoinInfo &info) const |
Returns true if the join information is about auxiliary layer, false otherwise. More... | |
QgsFeature | joinedFeatureOf (const QgsVectorLayerJoinInfo *info, const QgsFeature &feature) const |
Returns the joined feature corresponding to the feature. More... | |
int | joinedFieldsOffset (const QgsVectorLayerJoinInfo *info, const QgsFields &fields) |
Find out what is the first index of the join within fields. More... | |
const QgsVectorLayerJoinInfo * | joinForFieldIndex (int index, const QgsFields &fields, int &sourceFieldIndex) const |
Finds the vector join for a layer field index. More... | |
QList< const QgsVectorLayerJoinInfo * > | joinsWhereFieldIsId (const QgsField &field) const |
Returns joins where the field of a target layer is considered as an id. More... | |
void | readXml (const QDomNode &layer_node) |
Reads joins from project file. More... | |
bool | removeJoin (const QString &joinLayerId) |
Removes a vector layer join. More... | |
void | resolveReferences (QgsProject *project) |
Resolves layer IDs of joined layers using given project's available layers. More... | |
QgsFeature | targetedFeatureOf (const QgsVectorLayerJoinInfo *info, const QgsFeature &feature) const |
Returns the targeted feature corresponding to the joined feature. More... | |
void | updateFields (QgsFields &fields) |
Updates field map with joined attributes. More... | |
const QgsVectorJoinList & | vectorJoins () const |
void | writeXml (QDomNode &layer_node, QDomDocument &document) const |
Saves mVectorJoins to xml under the layer node. More... | |
Public Member Functions inherited from QgsFeatureSink | |
virtual | ~QgsFeatureSink ()=default |
virtual bool | addFeature (QgsFeature &feature, QgsFeatureSink::Flags flags=nullptr) |
Adds a single feature to the sink. More... | |
virtual bool | addFeatures (QgsFeatureIterator &iterator, QgsFeatureSink::Flags flags=nullptr) |
Adds all features from the specified iterator to the sink. More... | |
virtual bool | flushBuffer () |
Flushes any internal buffer which may exist in the sink, causing any buffered features to be added to the sink's destination. More... | |
Static Public Member Functions | |
static QVector< int > | joinSubsetIndices (QgsVectorLayer *joinLayer, const QStringList &joinFieldsSubset) |
Returns a vector of indices for use in join based on field names from the layer. More... | |
Additional Inherited Members | |
Public Types inherited from QgsFeatureSink | |
enum | Flag { FastInsert = 1 << 1 } |
Flags controlling how features are added to a sink. More... | |
Manages joined fields for a vector layer.
Definition at line 35 of file qgsvectorlayerjoinbuffer.h.
QgsVectorLayerJoinBuffer::QgsVectorLayerJoinBuffer | ( | QgsVectorLayer * | layer = nullptr | ) |
Definition at line 28 of file qgsvectorlayerjoinbuffer.cpp.
|
overridevirtual |
Adds a list of features in joined layers.
Features given in parameter are those added in target layer. If a corresponding joined feature yet exists in a joined layer, then this feature is just updated. Note that if a corresponding joined feature has only empty fields, then it's not created nor added.
features | The list of features added in the target layer |
flags | Unused parameter |
Implements QgsFeatureSink.
Definition at line 527 of file qgsvectorlayerjoinbuffer.cpp.
bool QgsVectorLayerJoinBuffer::addJoin | ( | const QgsVectorLayerJoinInfo & | joinInfo | ) |
Joins another vector layer to this layer.
joinInfo | join object containing join layer id, target and source field |
Definition at line 62 of file qgsvectorlayerjoinbuffer.cpp.
bool QgsVectorLayerJoinBuffer::changeAttributeValue | ( | QgsFeatureId | fid, |
int | field, | ||
const QVariant & | newValue, | ||
const QVariant & | oldValue = QVariant() |
||
) |
Changes attribute value in joined layers.
The feature id given in parameter is the one added in target layer. If the corresponding joined feature does not exist in a joined layer, then it's automatically created if its fields are not empty.
fid | The feature id |
field | The field to update |
newValue | The new value of the attribute |
oldValue | The old value of the attribute |
Definition at line 612 of file qgsvectorlayerjoinbuffer.cpp.
bool QgsVectorLayerJoinBuffer::changeAttributeValues | ( | QgsFeatureId | fid, |
const QgsAttributeMap & | newValues, | ||
const QgsAttributeMap & | oldValues = QgsAttributeMap() |
||
) |
Changes attributes' values in joined layers.
The feature id given in parameter is the one added in target layer. If the corresponding joined feature does not exist in a joined layer, then it's automatically created if its fields are not empty.
fid | The feature id |
newValues | The new values for attributes |
oldValues | The old values for attributes |
Definition at line 640 of file qgsvectorlayerjoinbuffer.cpp.
QgsVectorLayerJoinBuffer * QgsVectorLayerJoinBuffer::clone | ( | ) | const |
Create a copy of the join buffer.
Definition at line 469 of file qgsvectorlayerjoinbuffer.cpp.
|
inline |
Quick way to test if there is any join at all.
Definition at line 77 of file qgsvectorlayerjoinbuffer.h.
void QgsVectorLayerJoinBuffer::createJoinCaches | ( | ) |
Calls cacheJoinLayer() for all vector joins.
Definition at line 252 of file qgsvectorlayerjoinbuffer.cpp.
bool QgsVectorLayerJoinBuffer::deleteFeature | ( | QgsFeatureId | fid | ) | const |
Deletes a feature from joined layers.
The feature id given in parameter is the one coming from the target layer.
fid | The feature id from the target layer to delete |
Definition at line 659 of file qgsvectorlayerjoinbuffer.cpp.
bool QgsVectorLayerJoinBuffer::deleteFeatures | ( | const QgsFeatureIds & | fids | ) | const |
Deletes a list of features from joined layers.
Feature ids given in a parameter are those coming from the target layer.
fids | Feature ids from the target layer to delete |
Definition at line 664 of file qgsvectorlayerjoinbuffer.cpp.
bool QgsVectorLayerJoinBuffer::isAuxiliaryJoin | ( | const QgsVectorLayerJoinInfo & | info | ) | const |
Returns true if the join information is about auxiliary layer, false otherwise.
info | The join information |
Definition at line 685 of file qgsvectorlayerjoinbuffer.cpp.
QgsFeature QgsVectorLayerJoinBuffer::joinedFeatureOf | ( | const QgsVectorLayerJoinInfo * | info, |
const QgsFeature & | feature | ||
) | const |
Returns the joined feature corresponding to the feature.
info | the vector join information |
feature | the feature of the target layer |
Definition at line 425 of file qgsvectorlayerjoinbuffer.cpp.
|
signal |
Emitted whenever the list of joined fields changes (e.g.
added join or joined layer's fields change)
int QgsVectorLayerJoinBuffer::joinedFieldsOffset | ( | const QgsVectorLayerJoinInfo * | info, |
const QgsFields & | fields | ||
) |
Find out what is the first index of the join within fields.
Returns -1 if join is not present
Definition at line 374 of file qgsvectorlayerjoinbuffer.cpp.
const QgsVectorLayerJoinInfo * 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 394 of file qgsvectorlayerjoinbuffer.cpp.
|
static |
Returns a vector of indices for use in join based on field names from the layer.
Definition at line 181 of file qgsvectorlayerjoinbuffer.cpp.
QList< const QgsVectorLayerJoinInfo * > QgsVectorLayerJoinBuffer::joinsWhereFieldIsId | ( | const QgsField & | field | ) | const |
Returns joins where the field of a target layer is considered as an id.
field | the field of a target layer |
Definition at line 409 of file qgsvectorlayerjoinbuffer.cpp.
void QgsVectorLayerJoinBuffer::readXml | ( | const QDomNode & | layer_node | ) |
Reads joins from project file.
Does not resolve layer IDs to layers - call resolveReferences() afterwards
Definition at line 312 of file qgsvectorlayerjoinbuffer.cpp.
bool QgsVectorLayerJoinBuffer::removeJoin | ( | const QString & | joinLayerId | ) |
Removes a vector layer join.
Definition at line 99 of file qgsvectorlayerjoinbuffer.cpp.
void QgsVectorLayerJoinBuffer::resolveReferences | ( | QgsProject * | project | ) |
Resolves layer IDs of joined layers using given project's available layers.
Definition at line 354 of file qgsvectorlayerjoinbuffer.cpp.
QgsFeature QgsVectorLayerJoinBuffer::targetedFeatureOf | ( | const QgsVectorLayerJoinInfo * | info, |
const QgsFeature & | feature | ||
) | const |
Returns the targeted feature corresponding to the joined feature.
info | the vector join information |
feature | the feature of the joined layer |
Definition at line 449 of file qgsvectorlayerjoinbuffer.cpp.
void QgsVectorLayerJoinBuffer::updateFields | ( | QgsFields & | fields | ) |
Updates field map with joined attributes.
fields | map to append joined attributes |
Definition at line 202 of file qgsvectorlayerjoinbuffer.cpp.
|
inline |
Definition at line 79 of file qgsvectorlayerjoinbuffer.h.
void QgsVectorLayerJoinBuffer::writeXml | ( | QDomNode & | layer_node, |
QDomDocument & | document | ||
) | const |
Saves mVectorJoins to xml under the layer node.
Definition at line 264 of file qgsvectorlayerjoinbuffer.cpp.