QGIS API Documentation  2.99.0-Master (a18066b)
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 "qgsvectorlayerjoininfo.h"
23 
24 #include <QHash>
25 #include <QString>
26 
27 
28 typedef QList< QgsVectorLayerJoinInfo > QgsVectorJoinList;
29 
30 
33 class CORE_EXPORT QgsVectorLayerJoinBuffer : public QObject
34 {
35  Q_OBJECT
36  public:
37  QgsVectorLayerJoinBuffer( QgsVectorLayer* layer = nullptr );
38 
42  bool addJoin( const QgsVectorLayerJoinInfo& joinInfo );
43 
46  bool removeJoin( const QString& joinLayerId );
47 
51  void updateFields( QgsFields& fields );
52 
54  void createJoinCaches();
55 
57  void writeXml( QDomNode& layer_node, QDomDocument& document ) const;
58 
61  void readXml( const QDomNode& layer_node );
62 
65  void resolveReferences( QgsProject* project );
66 
68  bool containsJoins() const { return !mVectorJoins.isEmpty(); }
69 
70  const QgsVectorJoinList& vectorJoins() const { return mVectorJoins; }
71 
76  const QgsVectorLayerJoinInfo* joinForFieldIndex( int index, const QgsFields& fields, int& sourceFieldIndex ) const;
77 
80  int joinedFieldsOffset( const QgsVectorLayerJoinInfo* info, const QgsFields& fields );
81 
84  static QVector<int> joinSubsetIndices( QgsVectorLayer* joinLayer, const QStringList& joinFieldsSubset );
85 
88  QgsVectorLayerJoinBuffer* clone() const;
89 
90  signals:
93  void joinedFieldsChanged();
94 
95  private slots:
96  void joinedLayerUpdatedFields();
97 
98  void joinedLayerModified();
99 
100  void joinedLayerWillBeDeleted();
101 
102  private:
103  void connectJoinedLayer( QgsVectorLayer* vl );
104 
105  private:
106 
107  QgsVectorLayer* mLayer = nullptr;
108 
110  QgsVectorJoinList mVectorJoins;
111 
113  void cacheJoinLayer( QgsVectorLayerJoinInfo& joinInfo );
114 
116  QMutex mMutex;
117 };
118 
119 #endif // QGSVECTORLAYERJOINBUFFER_H
static unsigned index
bool containsJoins() const
Quick way to test if there is any join at all.
Container of fields for a vector layer.
Definition: qgsfields.h:39
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:74
const QgsVectorJoinList & vectorJoins() const
QList< QgsVectorLayerJoinInfo > QgsVectorJoinList
Represents a vector layer which manages a vector based data sets.