QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgsvectorlayerjoinbuffer.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectorlayerjoinbuffer.h
3 ---------------------------
4 begin : Feb 09, 2011
5 copyright : (C) 2011 by Marco Hugentobler
6 email : marco dot hugentobler at sourcepole dot ch
7 ***************************************************************************/
8
9/***************************************************************************
10 * *
11 * This program is free software; you can redistribute it and/or modify *
12 * it under the terms of the GNU General Public License as published by *
13 * the Free Software Foundation; either version 2 of the License, or *
14 * (at your option) any later version. *
15 * *
16 ***************************************************************************/
17
18#ifndef QGSVECTORLAYERJOINBUFFER_H
19#define QGSVECTORLAYERJOINBUFFER_H
20
21#include "qgis_core.h"
22#include "qgis_sip.h"
24#include "qgsfeaturesink.h"
25
26#include <QHash>
27#include <QString>
28
29
30typedef QList< QgsVectorLayerJoinInfo > QgsVectorJoinList;
31
32
37class CORE_EXPORT QgsVectorLayerJoinBuffer : public QObject, public QgsFeatureSink
38{
39 Q_OBJECT
40 public:
41 QgsVectorLayerJoinBuffer( QgsVectorLayer *layer = nullptr );
42
48 bool addJoin( const QgsVectorLayerJoinInfo &joinInfo );
49
54 bool removeJoin( const QString &joinLayerId );
55
60 void updateFields( QgsFields &fields );
61
63 void createJoinCaches();
64
66 void writeXml( QDomNode &layer_node, QDomDocument &document ) const;
67
72 void readXml( const QDomNode &layer_node );
73
77 void resolveReferences( QgsProject *project );
78
80 bool containsJoins() const { return !mVectorJoins.isEmpty(); }
81
82 const QgsVectorJoinList &vectorJoins() const { return mVectorJoins; }
83
91 const QgsVectorLayerJoinInfo *joinForFieldIndex( int index, const QgsFields &fields, int &sourceFieldIndex SIP_OUT ) const;
92
96 int joinedFieldsOffset( const QgsVectorLayerJoinInfo *info, const QgsFields &fields );
97
101 static QVector<int> joinSubsetIndices( QgsVectorLayer *joinLayer, const QStringList &joinFieldsSubset );
102
107 static QVector<int> joinSubsetIndices( const QgsFields &joinLayerFields, const QStringList &joinFieldsSubset );
108
114 QList<const QgsVectorLayerJoinInfo *> joinsWhereFieldIsId( const QgsField &field ) const;
115
121 QgsFeature joinedFeatureOf( const QgsVectorLayerJoinInfo *info, const QgsFeature &feature ) const;
122
128 QgsFeature targetedFeatureOf( const QgsVectorLayerJoinInfo *info, const QgsFeature &feature ) const;
129
138 bool isAuxiliaryJoin( const QgsVectorLayerJoinInfo &info ) const;
139
144
158 bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) override;
159
174 bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );
175
189 bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues = QgsAttributeMap() );
190
201 bool deleteFeature( QgsFeatureId fid, QgsVectorLayer::DeleteContext *context = nullptr ) const;
202
213 bool deleteFeatures( const QgsFeatureIds &fids, QgsVectorLayer::DeleteContext *context = nullptr ) const;
214
215 signals:
216
220 void joinedFieldsChanged();
221
222 private slots:
223 void joinedLayerUpdatedFields();
224
225 void joinedLayerModified();
226
227 void joinedLayerWillBeDeleted();
228
229 private:
230 void connectJoinedLayer( QgsVectorLayer *vl );
231
232 private:
233
234 QgsVectorLayer *mLayer = nullptr;
235
237 QgsVectorJoinList mVectorJoins;
238
240 void cacheJoinLayer( QgsVectorLayerJoinInfo &joinInfo );
241
243 QMutex mMutex;
244};
245
246#endif // QGSVECTORLAYERJOINBUFFER_H
An interface for objects which accept features via addFeature(s) methods.
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition: qgsfeature.h:56
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:53
Container of fields for a vector layer.
Definition: qgsfields.h:45
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition: qgsproject.h:107
Manages joined fields for a vector layer.
bool containsJoins() const
Quick way to test if there is any join at all.
const QgsVectorJoinList & vectorJoins() const
Defines left outer join from our vector layer to some other vector layer.
Represents a vector layer which manages a vector based data sets.
#define SIP_OUT
Definition: qgis_sip.h:58
#define SIP_FACTORY
Definition: qgis_sip.h:76
QMap< int, QVariant > QgsAttributeMap
Definition: qgsattributes.h:42
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:917
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:37
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28
QList< QgsVectorLayerJoinInfo > QgsVectorJoinList