QGIS API Documentation  2.99.0-Master (ef89a62)
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.h"
23 #include "qgsvectorlayerjoininfo.h"
24 
25 #include <QHash>
26 #include <QString>
27 
28 
29 typedef QList< QgsVectorLayerJoinInfo > QgsVectorJoinList;
30 
31 
34 class CORE_EXPORT QgsVectorLayerJoinBuffer : public QObject
35 {
36  Q_OBJECT
37  public:
38  QgsVectorLayerJoinBuffer( QgsVectorLayer *layer = nullptr );
39 
43  bool addJoin( const QgsVectorLayerJoinInfo &joinInfo );
44 
47  bool removeJoin( const QString &joinLayerId );
48 
52  void updateFields( QgsFields &fields );
53 
55  void createJoinCaches();
56 
58  void writeXml( QDomNode &layer_node, QDomDocument &document ) const;
59 
62  void readXml( const QDomNode &layer_node );
63 
66  void resolveReferences( QgsProject *project );
67 
69  bool containsJoins() const { return !mVectorJoins.isEmpty(); }
70 
71  const QgsVectorJoinList &vectorJoins() const { return mVectorJoins; }
72 
77  const QgsVectorLayerJoinInfo *joinForFieldIndex( int index, const QgsFields &fields, int &sourceFieldIndex SIP_OUT ) const;
78 
81  int joinedFieldsOffset( const QgsVectorLayerJoinInfo *info, const QgsFields &fields );
82 
85  static QVector<int> joinSubsetIndices( QgsVectorLayer *joinLayer, const QStringList &joinFieldsSubset );
86 
92  QList<const QgsVectorLayerJoinInfo *> joinsWhereFieldIsId( const QgsField &field ) const;
93 
99  QgsFeature joinedFeatureOf( const QgsVectorLayerJoinInfo *info, const QgsFeature &feature ) const;
100 
103  QgsVectorLayerJoinBuffer *clone() const SIP_FACTORY;
104 
105  signals:
108  void joinedFieldsChanged();
109 
110  private slots:
111  void joinedLayerUpdatedFields();
112 
113  void joinedLayerModified();
114 
115  void joinedLayerWillBeDeleted();
116 
117  private:
118  void connectJoinedLayer( QgsVectorLayer *vl );
119 
120  private:
121 
122  QgsVectorLayer *mLayer = nullptr;
123 
125  QgsVectorJoinList mVectorJoins;
126 
128  void cacheJoinLayer( QgsVectorLayerJoinInfo &joinInfo );
129 
131  QMutex mMutex;
132 };
133 
134 #endif // QGSVECTORLAYERJOINBUFFER_H
bool containsJoins() const
Quick way to test if there is any join at all.
Container of fields for a vector layer.
Definition: qgsfields.h:41
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:61
Manages joined fields for a vector layer.
Defines left outer join from our vector layer to some other vector layer.
Reads and writes project states.
Definition: qgsproject.h:79
const QgsVectorJoinList & vectorJoins() const
#define SIP_FACTORY
Definition: qgis_sip.h:69
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:46
#define SIP_OUT
Definition: qgis_sip.h:51
QList< QgsVectorLayerJoinInfo > QgsVectorJoinList
Represents a vector layer which manages a vector based data sets.