QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 "qgsfeature.h"
22 #include "qgsvectorlayer.h"
23 
24 #include <QHash>
25 #include <QString>
26 
27 
29 
30 
33 class CORE_EXPORT QgsVectorLayerJoinBuffer : public QObject
34 {
35  Q_OBJECT
36  public:
37  QgsVectorLayerJoinBuffer( QgsVectorLayer* layer = nullptr );
39 
43  bool addJoin( const QgsVectorJoinInfo& 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 
61  void readXml( const QDomNode& layer_node );
62 
64  bool containsJoins() const { return !mVectorJoins.isEmpty(); }
65 
66  const QgsVectorJoinList& vectorJoins() const { return mVectorJoins; }
67 
72  const QgsVectorJoinInfo* joinForFieldIndex( int index, const QgsFields& fields, int& sourceFieldIndex ) const;
73 
76  int joinedFieldsOffset( const QgsVectorJoinInfo* info, const QgsFields& fields );
77 
80  static QVector<int> joinSubsetIndices( QgsVectorLayer* joinLayer, const QStringList& joinFieldsSubset );
81 
84  QgsVectorLayerJoinBuffer* clone() const;
85 
86  signals:
89  void joinedFieldsChanged();
90 
91  private slots:
92  void joinedLayerUpdatedFields();
93 
94  void joinedLayerModified();
95 
96  private:
97 
98  QgsVectorLayer* mLayer;
99 
101  QgsVectorJoinList mVectorJoins;
102 
104  void cacheJoinLayer( QgsVectorJoinInfo& joinInfo );
105 
107  QMutex mMutex;
108 };
109 
110 #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: qgsfield.h:252
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.