QGIS API Documentation 3.30.0-'s-Hertogenbosch (f186b8efe0)
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
78 void resolveReferences( QgsProject *project );
79
81 bool containsJoins() const { return !mVectorJoins.isEmpty(); }
82
83 const QgsVectorJoinList &vectorJoins() const { return mVectorJoins; }
84
92 const QgsVectorLayerJoinInfo *joinForFieldIndex( int index, const QgsFields &fields, int &sourceFieldIndex SIP_OUT ) const;
93
98 int joinedFieldsOffset( const QgsVectorLayerJoinInfo *info, const QgsFields &fields );
99
104 static QVector<int> joinSubsetIndices( QgsVectorLayer *joinLayer, const QStringList &joinFieldsSubset );
105
110 static QVector<int> joinSubsetIndices( const QgsFields &joinLayerFields, const QStringList &joinFieldsSubset );
111
118 QList<const QgsVectorLayerJoinInfo *> joinsWhereFieldIsId( const QgsField &field ) const;
119
126 QgsFeature joinedFeatureOf( const QgsVectorLayerJoinInfo *info, const QgsFeature &feature ) const;
127
134 QgsFeature targetedFeatureOf( const QgsVectorLayerJoinInfo *info, const QgsFeature &feature ) const;
135
145 bool isAuxiliaryJoin( const QgsVectorLayerJoinInfo &info ) const;
146
152
167 bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = QgsFeatureSink::Flags() ) override;
168
184 bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );
185
200 bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues = QgsAttributeMap() );
201
213 bool deleteFeature( QgsFeatureId fid, QgsVectorLayer::DeleteContext *context = nullptr ) const;
214
226 bool deleteFeatures( const QgsFeatureIds &fids, QgsVectorLayer::DeleteContext *context = nullptr ) const;
227
228 signals:
229
234 void joinedFieldsChanged();
235
236 private slots:
237 void joinedLayerUpdatedFields();
238
239 void joinedLayerModified();
240
241 void joinedLayerWillBeDeleted();
242
243 private:
244 void connectJoinedLayer( QgsVectorLayer *vl );
245
246 private:
247
248 QgsVectorLayer *mLayer = nullptr;
249
251 QgsVectorJoinList mVectorJoins;
252
254 void cacheJoinLayer( QgsVectorLayerJoinInfo &joinInfo );
255
257 QMutex mMutex;
258};
259
260#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:52
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:105
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:920
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
const QgsField & field
Definition: qgsfield.h:501
QList< QgsVectorLayerJoinInfo > QgsVectorJoinList