QGIS API Documentation  2.99.0-Master (b698612)
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 
90 
91  signals:
94  void joinedFieldsChanged();
95 
96  private slots:
97  void joinedLayerUpdatedFields();
98 
99  void joinedLayerModified();
100 
101  void joinedLayerWillBeDeleted();
102 
103  private:
104  void connectJoinedLayer( QgsVectorLayer *vl );
105 
106  private:
107 
108  QgsVectorLayer *mLayer = nullptr;
109 
111  QgsVectorJoinList mVectorJoins;
112 
114  void cacheJoinLayer( QgsVectorLayerJoinInfo &joinInfo );
115 
117  QMutex mMutex;
118 };
119 
120 #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
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:78
const QgsVectorJoinList & vectorJoins() const
#define SIP_FACTORY
Definition: qgis_sip.h:57
#define SIP_OUT
Definition: qgis_sip.h:39
QList< QgsVectorLayerJoinInfo > QgsVectorJoinList
Represents a vector layer which manages a vector based data sets.