QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 
28 typedef QList< QgsVectorJoinInfo > QgsVectorJoinList;
29 
30 
32 class CORE_EXPORT QgsVectorLayerJoinBuffer : public QObject
33 {
34  Q_OBJECT
35  public:
38 
42  bool addJoin( const QgsVectorJoinInfo& joinInfo );
43 
45  void removeJoin( const QString& joinLayerId );
46 
50  void updateFields( QgsFields& fields );
51 
53  void createJoinCaches();
54 
56  void writeXml( QDomNode& layer_node, QDomDocument& document ) const;
57 
59  void readXml( const QDomNode& layer_node );
60 
62  bool containsJoins() const { return !mVectorJoins.isEmpty(); }
63 
64  const QgsVectorJoinList& vectorJoins() const { return mVectorJoins; }
65 
70  const QgsVectorJoinInfo* joinForFieldIndex( int index, const QgsFields& fields, int& sourceFieldIndex ) const;
71 
74  int joinedFieldsOffset( const QgsVectorJoinInfo* info, const QgsFields& fields );
75 
78  static QVector<int> joinSubsetIndices( QgsVectorLayer* joinLayer, const QStringList& joinFieldsSubset );
79 
82  QgsVectorLayerJoinBuffer* clone() const;
83 
84  signals:
87  void joinedFieldsChanged();
88 
89  private slots:
90  void joinedLayerUpdatedFields();
91 
92  private:
93 
94  QgsVectorLayer* mLayer;
95 
97  QgsVectorJoinList mVectorJoins;
98 
100  void cacheJoinLayer( QgsVectorJoinInfo& joinInfo );
101 };
102 
103 #endif // QGSVECTORLAYERJOINBUFFER_H