QGIS API Documentation  2.14.0-Essen
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 
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  private:
94 
95  QgsVectorLayer* mLayer;
96 
98  QgsVectorJoinList mVectorJoins;
99 
101  void cacheJoinLayer( QgsVectorJoinInfo& joinInfo );
102 };
103 
104 #endif // QGSVECTORLAYERJOINBUFFER_H
static unsigned index
const QgsVectorJoinList & vectorJoins() const
Container of fields for a vector layer.
Definition: qgsfield.h:187
Manages joined fields for a vector layer.
bool containsJoins() const
Quick way to test if there is any join at all.
QList< QgsVectorJoinInfo > QgsVectorJoinList
Represents a vector layer which manages a vector based data sets.