QGIS API Documentation  2.99.0-Master (6a61179)
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 "qgsvectorlayer.h"
22 
23 #include <QHash>
24 #include <QString>
25 
26 
27 typedef QList< QgsVectorJoinInfo > QgsVectorJoinList;
28 
29 
32 class CORE_EXPORT QgsVectorLayerJoinBuffer : public QObject
33 {
34  Q_OBJECT
35  public:
36  QgsVectorLayerJoinBuffer( QgsVectorLayer* layer = nullptr );
38 
42  bool addJoin( const QgsVectorJoinInfo& 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 
60  void readXml( const QDomNode& layer_node );
61 
63  bool containsJoins() const { return !mVectorJoins.isEmpty(); }
64 
65  const QgsVectorJoinList& vectorJoins() const { return mVectorJoins; }
66 
71  const QgsVectorJoinInfo* joinForFieldIndex( int index, const QgsFields& fields, int& sourceFieldIndex ) const;
72 
75  int joinedFieldsOffset( const QgsVectorJoinInfo* info, const QgsFields& fields );
76 
79  static QVector<int> joinSubsetIndices( QgsVectorLayer* joinLayer, const QStringList& joinFieldsSubset );
80 
83  QgsVectorLayerJoinBuffer* clone() const;
84 
85  signals:
88  void joinedFieldsChanged();
89 
90  private slots:
91  void joinedLayerUpdatedFields();
92 
93  void joinedLayerModified();
94 
95  private:
96 
97  QgsVectorLayer* mLayer;
98 
100  QgsVectorJoinList mVectorJoins;
101 
103  void cacheJoinLayer( QgsVectorJoinInfo& joinInfo );
104 
106  QMutex mMutex;
107 };
108 
109 #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:36
Manages joined fields for a vector layer.
const QgsVectorJoinList & vectorJoins() const
QList< QgsVectorJoinInfo > QgsVectorJoinList
Represents a vector layer which manages a vector based data sets.