QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
Public Member Functions | Static Public Member Functions | Protected Attributes | Friends | List of all members
QgsVectorLayerJoinInfo Class Reference

Defines left outer join from our vector layer to some other vector layer. More...

#include <qgsvectorlayerjoininfo.h>

Public Member Functions

 QgsVectorLayerJoinInfo ()=default
 Constructor for QgsVectorLayerJoinInfo. More...
 
QgsFeature extractJoinedFeature (const QgsFeature &feature) const
 Extract the join feature from the target feature for the current join layer information. More...
 
bool hasCascadedDelete () const
 Returns whether a feature deleted on the target layer has to impact the joined layer by deleting the corresponding joined feature. More...
 
bool hasSubset (bool blocklisted=true) const
 Returns true if blocklisted fields is not empty or if a subset of names has been set. More...
 
bool hasUpsertOnEdit () const
 Returns whether a feature created on the target layer has to impact the joined layer by creating a new feature if necessary. More...
 
bool isDynamicFormEnabled () const
 Returns whether the form has to be dynamically updated with joined fields when a feature is being created in the target layer. More...
 
bool isEditable () const
 Returns whether joined fields may be edited through the form of the target layer. More...
 
bool isUsingMemoryCache () const
 Returns whether values from the joined layer should be cached in memory to speed up lookups. More...
 
QString joinFieldName () const
 Returns name of the field of joined layer that will be used for join. More...
 
Q_DECL_DEPRECATED QStringList joinFieldNamesBlackList () const
 Returns the list of fields to ignore. More...
 
QStringList joinFieldNamesBlockList () const
 Returns the list of fields to ignore. More...
 
QStringList * joinFieldNamesSubset () const
 Returns the subset of fields to be used from joined layer. More...
 
QgsVectorLayerjoinLayer () const
 Returns joined layer (may be nullptr if the reference was set by layer ID and not resolved yet) More...
 
QString joinLayerId () const
 ID of the joined layer - may be used to resolve reference to the joined layer. More...
 
bool operator== (const QgsVectorLayerJoinInfo &other) const
 
QString prefix () const
 Returns prefix of fields from the joined layer. If nullptr, joined layer's name will be used. More...
 
QString prefixedFieldName (const QgsField &field) const
 Returns the prefixed name of the field. More...
 
void setCascadedDelete (bool enabled)
 Sets whether a feature deleted on the target layer has to impact the joined layer by deleting the corresponding joined feature. More...
 
void setDynamicFormEnabled (bool enabled)
 Sets whether the form has to be dynamically updated with joined fields when a feature is being created in the target layer. More...
 
void setEditable (bool enabled)
 Sets whether the form of the target layer allows editing joined fields. More...
 
void setJoinFieldName (const QString &fieldName)
 Sets name of the field of joined layer that will be used for join. More...
 
Q_DECL_DEPRECATED void setJoinFieldNamesBlackList (const QStringList &blackList)
 Sets a list of fields to ignore whatever happens. More...
 
void setJoinFieldNamesBlockList (const QStringList &list)
 Sets a list of fields to ignore whatever happens. More...
 
void setJoinFieldNamesSubset (QStringList *fieldNamesSubset)
 Sets the subset of fields to be used from joined layer. More...
 
void setJoinLayer (QgsVectorLayer *layer)
 Sets weak reference to the joined layer. More...
 
void setJoinLayerId (const QString &layerId)
 Sets ID of the joined layer. It will need to be overwritten by setJoinLayer() to a reference to real layer. More...
 
void setPrefix (const QString &prefix)
 Sets prefix of fields from the joined layer. If nullptr, joined layer's name will be used. More...
 
void setTargetFieldName (const QString &fieldName)
 Sets name of the field of our layer that will be used for join. More...
 
void setUpsertOnEdit (bool enabled)
 Sets whether a feature created on the target layer has to impact the joined layer by creating a new feature if necessary. More...
 
void setUsingMemoryCache (bool enabled)
 Sets whether values from the joined layer should be cached in memory to speed up lookups. More...
 
QString targetFieldName () const
 Returns name of the field of our layer that will be used for join. More...
 

Static Public Member Functions

static QStringList joinFieldNamesSubset (const QgsVectorLayerJoinInfo &info, bool blocklisted=true)
 Returns the list of field names to use for joining considering blocklisted fields and subset. More...
 

Protected Attributes

QHash< QString, QgsAttributescachedAttributes
 Cache for joined attributes to provide fast lookup (size is 0 if no memory caching) More...
 
bool cacheDirty = true
 True if the cached join attributes need to be updated. More...
 
QStringList mBlockList
 
bool mCascadedDelete = false
 
bool mDynamicForm = false
 
bool mEditable = false
 
QString mJoinFieldName
 Join field in the source layer. More...
 
std::shared_ptr< QStringList > mJoinFieldsSubset
 Subset of fields to use from joined layer. nullptr = use all fields. More...
 
QgsVectorLayerRef mJoinLayerRef
 Weak reference to the joined layer. More...
 
bool mMemoryCache = false
 True if the join is cached in virtual memory. More...
 
QString mPrefix
 An optional prefix. More...
 
QString mTargetFieldName
 Join field in the target layer. More...
 
bool mUpsertOnEdit = false
 

Friends

class QgsVectorLayerFeatureIterator
 
class QgsVectorLayerJoinBuffer
 

Detailed Description

Defines left outer join from our vector layer to some other vector layer.

The join is done based on [our layer].targetField = [join layer].joinField

Since
QGIS 3.0

Definition at line 33 of file qgsvectorlayerjoininfo.h.

Constructor & Destructor Documentation

◆ QgsVectorLayerJoinInfo()

QgsVectorLayerJoinInfo::QgsVectorLayerJoinInfo ( )
default

Constructor for QgsVectorLayerJoinInfo.

Member Function Documentation

◆ extractJoinedFeature()

QgsFeature QgsVectorLayerJoinInfo::extractJoinedFeature ( const QgsFeature feature) const

Extract the join feature from the target feature for the current join layer information.

Parameters
featureA feature from the target layer
Returns
the corresponding joined feature
Since
QGIS 3.0

Definition at line 62 of file qgsvectorlayerjoininfo.cpp.

◆ hasCascadedDelete()

bool QgsVectorLayerJoinInfo::hasCascadedDelete ( ) const
inline

Returns whether a feature deleted on the target layer has to impact the joined layer by deleting the corresponding joined feature.

Since
QGIS 3.0

Definition at line 122 of file qgsvectorlayerjoininfo.h.

◆ hasSubset()

bool QgsVectorLayerJoinInfo::hasSubset ( bool  blocklisted = true) const

Returns true if blocklisted fields is not empty or if a subset of names has been set.

Since
QGIS 3.0

Definition at line 127 of file qgsvectorlayerjoininfo.cpp.

◆ hasUpsertOnEdit()

bool QgsVectorLayerJoinInfo::hasUpsertOnEdit ( ) const
inline

Returns whether a feature created on the target layer has to impact the joined layer by creating a new feature if necessary.

Since
QGIS 3.0

Definition at line 108 of file qgsvectorlayerjoininfo.h.

◆ isDynamicFormEnabled()

bool QgsVectorLayerJoinInfo::isDynamicFormEnabled ( ) const
inline

Returns whether the form has to be dynamically updated with joined fields when a feature is being created in the target layer.

Since
QGIS 3.0

Definition at line 81 of file qgsvectorlayerjoininfo.h.

◆ isEditable()

bool QgsVectorLayerJoinInfo::isEditable ( ) const
inline

Returns whether joined fields may be edited through the form of the target layer.

Since
QGIS 3.0

Definition at line 95 of file qgsvectorlayerjoininfo.h.

◆ isUsingMemoryCache()

bool QgsVectorLayerJoinInfo::isUsingMemoryCache ( ) const

Returns whether values from the joined layer should be cached in memory to speed up lookups.

Will return false if upsertOnEdit is enabled.

Definition at line 43 of file qgsvectorlayerjoininfo.cpp.

◆ joinFieldName()

QString QgsVectorLayerJoinInfo::joinFieldName ( ) const
inline

Returns name of the field of joined layer that will be used for join.

Definition at line 60 of file qgsvectorlayerjoininfo.h.

◆ joinFieldNamesBlackList()

Q_DECL_DEPRECATED QStringList QgsVectorLayerJoinInfo::joinFieldNamesBlackList ( ) const
inline

Returns the list of fields to ignore.

Deprecated:
use joinFieldNamesBlockList() instead

Definition at line 160 of file qgsvectorlayerjoininfo.h.

◆ joinFieldNamesBlockList()

QStringList QgsVectorLayerJoinInfo::joinFieldNamesBlockList ( ) const
inline

Returns the list of fields to ignore.

See also
setJoinFieldNamesBlockList()
Since
QGIS 3.14

Definition at line 176 of file qgsvectorlayerjoininfo.h.

◆ joinFieldNamesSubset() [1/2]

QStringList* QgsVectorLayerJoinInfo::joinFieldNamesSubset ( ) const
inline

Returns the subset of fields to be used from joined layer.

All fields will be used if nullptr is returned.

See also
setJoinFieldNamesSubset()
Since
QGIS 2.6

Definition at line 223 of file qgsvectorlayerjoininfo.h.

◆ joinFieldNamesSubset() [2/2]

QStringList QgsVectorLayerJoinInfo::joinFieldNamesSubset ( const QgsVectorLayerJoinInfo info,
bool  blocklisted = true 
)
static

Returns the list of field names to use for joining considering blocklisted fields and subset.

Since
QGIS 3.0

Definition at line 86 of file qgsvectorlayerjoininfo.cpp.

◆ joinLayer()

QgsVectorLayer* QgsVectorLayerJoinInfo::joinLayer ( ) const
inline

Returns joined layer (may be nullptr if the reference was set by layer ID and not resolved yet)

Definition at line 45 of file qgsvectorlayerjoininfo.h.

◆ joinLayerId()

QString QgsVectorLayerJoinInfo::joinLayerId ( ) const
inline

ID of the joined layer - may be used to resolve reference to the joined layer.

Definition at line 50 of file qgsvectorlayerjoininfo.h.

◆ operator==()

bool QgsVectorLayerJoinInfo::operator== ( const QgsVectorLayerJoinInfo other) const
inline

Definition at line 194 of file qgsvectorlayerjoininfo.h.

◆ prefix()

QString QgsVectorLayerJoinInfo::prefix ( ) const
inline

Returns prefix of fields from the joined layer. If nullptr, joined layer's name will be used.

Definition at line 65 of file qgsvectorlayerjoininfo.h.

◆ prefixedFieldName()

QString QgsVectorLayerJoinInfo::prefixedFieldName ( const QgsField field) const

Returns the prefixed name of the field.

Parameters
fieldthe field
Returns
the prefixed name of the field
Since
QGIS 3.0

Definition at line 21 of file qgsvectorlayerjoininfo.cpp.

◆ setCascadedDelete()

void QgsVectorLayerJoinInfo::setCascadedDelete ( bool  enabled)
inline

Sets whether a feature deleted on the target layer has to impact the joined layer by deleting the corresponding joined feature.

Since
QGIS 3.0

Definition at line 129 of file qgsvectorlayerjoininfo.h.

◆ setDynamicFormEnabled()

void QgsVectorLayerJoinInfo::setDynamicFormEnabled ( bool  enabled)
inline

Sets whether the form has to be dynamically updated with joined fields when a feature is being created in the target layer.

Since
QGIS 3.0

Definition at line 88 of file qgsvectorlayerjoininfo.h.

◆ setEditable()

void QgsVectorLayerJoinInfo::setEditable ( bool  enabled)

Sets whether the form of the target layer allows editing joined fields.

Since
QGIS 3.0

Definition at line 51 of file qgsvectorlayerjoininfo.cpp.

◆ setJoinFieldName()

void QgsVectorLayerJoinInfo::setJoinFieldName ( const QString &  fieldName)
inline

Sets name of the field of joined layer that will be used for join.

Definition at line 58 of file qgsvectorlayerjoininfo.h.

◆ setJoinFieldNamesBlackList()

Q_DECL_DEPRECATED void QgsVectorLayerJoinInfo::setJoinFieldNamesBlackList ( const QStringList &  blackList)
inline

Sets a list of fields to ignore whatever happens.

Deprecated:
use setJoinFieldNamesBlockList() instead

Definition at line 153 of file qgsvectorlayerjoininfo.h.

◆ setJoinFieldNamesBlockList()

void QgsVectorLayerJoinInfo::setJoinFieldNamesBlockList ( const QStringList &  list)
inline

Sets a list of fields to ignore whatever happens.

See also
joinFieldNamesBlockList()
Since
QGIS 3.14

Definition at line 168 of file qgsvectorlayerjoininfo.h.

◆ setJoinFieldNamesSubset()

void QgsVectorLayerJoinInfo::setJoinFieldNamesSubset ( QStringList *  fieldNamesSubset)
inline

Sets the subset of fields to be used from joined layer.

Ownership of fileNamesSubset is transferred. A fieldNameSubset of nullptr indicates that all fields should be used.

See also
joinFieldNamesSubset()
Since
QGIS 2.6

Definition at line 212 of file qgsvectorlayerjoininfo.h.

◆ setJoinLayer()

void QgsVectorLayerJoinInfo::setJoinLayer ( QgsVectorLayer layer)
inline

Sets weak reference to the joined layer.

Definition at line 43 of file qgsvectorlayerjoininfo.h.

◆ setJoinLayerId()

void QgsVectorLayerJoinInfo::setJoinLayerId ( const QString &  layerId)
inline

Sets ID of the joined layer. It will need to be overwritten by setJoinLayer() to a reference to real layer.

Definition at line 48 of file qgsvectorlayerjoininfo.h.

◆ setPrefix()

void QgsVectorLayerJoinInfo::setPrefix ( const QString &  prefix)
inline

Sets prefix of fields from the joined layer. If nullptr, joined layer's name will be used.

Definition at line 63 of file qgsvectorlayerjoininfo.h.

◆ setTargetFieldName()

void QgsVectorLayerJoinInfo::setTargetFieldName ( const QString &  fieldName)
inline

Sets name of the field of our layer that will be used for join.

Definition at line 53 of file qgsvectorlayerjoininfo.h.

◆ setUpsertOnEdit()

void QgsVectorLayerJoinInfo::setUpsertOnEdit ( bool  enabled)
inline

Sets whether a feature created on the target layer has to impact the joined layer by creating a new feature if necessary.

Since
QGIS 3.0

Definition at line 115 of file qgsvectorlayerjoininfo.h.

◆ setUsingMemoryCache()

void QgsVectorLayerJoinInfo::setUsingMemoryCache ( bool  enabled)

Sets whether values from the joined layer should be cached in memory to speed up lookups.

Definition at line 38 of file qgsvectorlayerjoininfo.cpp.

◆ targetFieldName()

QString QgsVectorLayerJoinInfo::targetFieldName ( ) const
inline

Returns name of the field of our layer that will be used for join.

Definition at line 55 of file qgsvectorlayerjoininfo.h.

Friends And Related Function Documentation

◆ QgsVectorLayerFeatureIterator

friend class QgsVectorLayerFeatureIterator
friend

Definition at line 248 of file qgsvectorlayerjoininfo.h.

◆ QgsVectorLayerJoinBuffer

friend class QgsVectorLayerJoinBuffer
friend

Definition at line 247 of file qgsvectorlayerjoininfo.h.

Member Data Documentation

◆ cachedAttributes

QHash< QString, QgsAttributes> QgsVectorLayerJoinInfo::cachedAttributes
protected

Cache for joined attributes to provide fast lookup (size is 0 if no memory caching)

Definition at line 264 of file qgsvectorlayerjoininfo.h.

◆ cacheDirty

bool QgsVectorLayerJoinInfo::cacheDirty = true
protected

True if the cached join attributes need to be updated.

Definition at line 251 of file qgsvectorlayerjoininfo.h.

◆ mBlockList

QStringList QgsVectorLayerJoinInfo::mBlockList
protected

Definition at line 261 of file qgsvectorlayerjoininfo.h.

◆ mCascadedDelete

bool QgsVectorLayerJoinInfo::mCascadedDelete = false
protected

Definition at line 259 of file qgsvectorlayerjoininfo.h.

◆ mDynamicForm

bool QgsVectorLayerJoinInfo::mDynamicForm = false
protected

Definition at line 253 of file qgsvectorlayerjoininfo.h.

◆ mEditable

bool QgsVectorLayerJoinInfo::mEditable = false
protected

Definition at line 255 of file qgsvectorlayerjoininfo.h.

◆ mJoinFieldName

QString QgsVectorLayerJoinInfo::mJoinFieldName
protected

Join field in the source layer.

Definition at line 231 of file qgsvectorlayerjoininfo.h.

◆ mJoinFieldsSubset

std::shared_ptr<QStringList> QgsVectorLayerJoinInfo::mJoinFieldsSubset
protected

Subset of fields to use from joined layer. nullptr = use all fields.

Definition at line 243 of file qgsvectorlayerjoininfo.h.

◆ mJoinLayerRef

QgsVectorLayerRef QgsVectorLayerJoinInfo::mJoinLayerRef
protected

Weak reference to the joined layer.

Definition at line 229 of file qgsvectorlayerjoininfo.h.

◆ mMemoryCache

bool QgsVectorLayerJoinInfo::mMemoryCache = false
protected

True if the join is cached in virtual memory.

Definition at line 240 of file qgsvectorlayerjoininfo.h.

◆ mPrefix

QString QgsVectorLayerJoinInfo::mPrefix
protected

An optional prefix.

If it is a Null string "{layername}_" will be used

Since
QGIS 2.8

Definition at line 237 of file qgsvectorlayerjoininfo.h.

◆ mTargetFieldName

QString QgsVectorLayerJoinInfo::mTargetFieldName
protected

Join field in the target layer.

Definition at line 227 of file qgsvectorlayerjoininfo.h.

◆ mUpsertOnEdit

bool QgsVectorLayerJoinInfo::mUpsertOnEdit = false
protected

Definition at line 257 of file qgsvectorlayerjoininfo.h.


The documentation for this class was generated from the following files: