QgsVectorLayerJoinInfo class
Defines left outer join from our vector layer to some other vector layer.
Contents
The join is done based on [our layer].targetField = [join layer].joinField
Public static functions
- static auto joinFieldNamesSubset(const QgsVectorLayerJoinInfo& info, bool blacklisted = true) -> QStringList
- Returns the list of field names to use for joining considering blacklisted fields and subset.
Constructors, destructors, conversion operators
- QgsVectorLayerJoinInfo() defaulted
- Constructor for QgsVectorLayerJoinInfo.
Public functions
- auto extractJoinedFeature(const QgsFeature& feature) const -> QgsFeature
- Extract the join feature from the target feature for the current join layer information.
- auto hasCascadedDelete() const -> bool
- Returns whether a feature deleted on the target layer has to impact the joined layer by deleting the corresponding joined feature.
- auto hasSubset(bool blacklisted = true) const -> bool
- Returns true if blacklisted fields is not empty or if a subset of names has been set.
- auto hasUpsertOnEdit() const -> bool
- Returns whether a feature created on the target layer has to impact the joined layer by creating a new feature if necessary.
- auto isDynamicFormEnabled() const -> bool
- Returns whether the form has to be dynamically updated with joined fields when a feature is being created in the target layer.
- auto isEditable() const -> bool
- Returns whether joined fields may be edited through the form of the target layer.
- auto isUsingMemoryCache() const -> bool
- Returns whether values from the joined layer should be cached in memory to speed up lookups.
- auto joinFieldName() const -> QString
- Returns name of the field of joined layer that will be used for join.
- auto joinFieldNamesBlackList() const -> QStringList
- Returns the list of fields to ignore.
- auto joinFieldNamesSubset() const -> QStringList*
- Gets subset of fields to be used from joined layer.
- auto joinLayer() const -> QgsVectorLayer*
- Returns joined layer (may be null if the reference was set by layer ID and not resolved yet)
- auto joinLayerId() const -> QString
- ID of the joined layer - may be used to resolve reference to the joined layer.
- auto prefix() const -> QString
- Returns prefix of fields from the joined layer. If null, joined layer's name will be used.
- auto prefixedFieldName(const QgsField& field) const -> QString
- Returns the prefixed name of the field.
- 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.
- 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.
- void setEditable(bool enabled)
- Sets whether the form of the target layer allows editing joined fields.
- void setJoinFieldName(const QString& fieldName)
- Sets name of the field of joined layer that will be used for join.
- void setJoinFieldNamesBlackList(const QStringList& blackList)
- Sets a list of fields to ignore whatever happens.
- void setJoinFieldNamesSubset(QStringList* fieldNamesSubset)
- Set subset of fields to be used from joined layer.
- void setJoinLayer(QgsVectorLayer* layer)
- Sets weak reference to the joined layer.
- 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.
- void setPrefix(const QString& prefix)
- Sets prefix of fields from the joined layer. If null, joined layer's name will be used.
- void setTargetFieldName(const QString& fieldName)
- Sets name of the field of our layer that will be used for join.
- 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.
- void setUsingMemoryCache(bool enabled)
- Sets whether values from the joined layer should be cached in memory to speed up lookups.
- auto targetFieldName() const -> QString
- Returns name of the field of our layer that will be used for join.
Protected variables
- QHash<QString, QgsAttributes> cachedAttributes
- Cache for joined attributes to provide fast lookup (size is 0 if no memory caching)
- bool cacheDirty
- True if the cached join attributes need to be updated.
- QString mJoinFieldName
- Join field in the source layer.
- std::shared_ptr<QStringList> mJoinFieldsSubset
- Subset of fields to use from joined layer. null = use all fields.
- QgsVectorLayerRef mJoinLayerRef
- Weak reference to the joined layer.
- bool mMemoryCache
- True if the join is cached in virtual memory.
- QString mPrefix
- An optional prefix.
- QString mTargetFieldName
- Join field in the target layer.
Function documentation
static QStringList QgsVectorLayerJoinInfo:: joinFieldNamesSubset(const QgsVectorLayerJoinInfo& info,
bool blacklisted = true)
Returns the list of field names to use for joining considering blacklisted fields and subset.
QgsFeature QgsVectorLayerJoinInfo:: extractJoinedFeature(const QgsFeature& feature) const
Extract the join feature from the target feature for the current join layer information.
| Parameters | |
|---|---|
| feature | A feature from the target layer |
| Returns | the corresponding joined feature |
bool QgsVectorLayerJoinInfo:: hasCascadedDelete() const
Returns whether a feature deleted on the target layer has to impact the joined layer by deleting the corresponding joined feature.
bool QgsVectorLayerJoinInfo:: hasSubset(bool blacklisted = true) const
Returns true if blacklisted fields is not empty or if a subset of names has been set.
bool QgsVectorLayerJoinInfo:: hasUpsertOnEdit() const
Returns whether a feature created on the target layer has to impact the joined layer by creating a new feature if necessary.
bool QgsVectorLayerJoinInfo:: isDynamicFormEnabled() const
Returns whether the form has to be dynamically updated with joined fields when a feature is being created in the target layer.
bool QgsVectorLayerJoinInfo:: isEditable() const
Returns whether joined fields may be edited through the form of the target layer.
QStringList QgsVectorLayerJoinInfo:: joinFieldNamesBlackList() const
Returns the list of fields to ignore.
QStringList* QgsVectorLayerJoinInfo:: joinFieldNamesSubset() const
Gets subset of fields to be used from joined layer.
All fields will be used if null is returned.
QString QgsVectorLayerJoinInfo:: prefixedFieldName(const QgsField& field) const
Returns the prefixed name of the field.
| Parameters | |
|---|---|
| field | the field |
| Returns | the prefixed name of the field |
void QgsVectorLayerJoinInfo:: setCascadedDelete(bool enabled)
Sets whether a feature deleted on the target layer has to impact the joined layer by deleting the corresponding joined feature.
void QgsVectorLayerJoinInfo:: 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.
void QgsVectorLayerJoinInfo:: setEditable(bool enabled)
Sets whether the form of the target layer allows editing joined fields.
void QgsVectorLayerJoinInfo:: setJoinFieldNamesBlackList(const QStringList& blackList)
Sets a list of fields to ignore whatever happens.
void QgsVectorLayerJoinInfo:: setJoinFieldNamesSubset(QStringList* fieldNamesSubset)
Set subset of fields to be used from joined layer.
Takes ownership of the passed pointer. Null pointer tells to use all fields.
void QgsVectorLayerJoinInfo:: 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.
Variable documentation
QString QgsVectorLayerJoinInfo:: mPrefix protected
An optional prefix.
If it is a Null string "{layername}_" will be used