Quantum GIS API Documentation  1.7.5-Wroclaw
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator 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 
28 class CORE_EXPORT QgsVectorLayerJoinBuffer
29 {
30  public:
33 
36  void addJoin( QgsVectorJoinInfo joinInfo );
37 
39  void removeJoin( const QString& joinLayerId );
40 
42  void select( const QgsAttributeList& fetchAttributes,
43  QgsAttributeList& sourceJoinFields, int maxProviderIndex );
44 
48  void updateFieldMap( QgsFieldMap& fields, int& maxIndex );
49 
51  void updateFeatureAttributes( QgsFeature &f, int maxProviderIndex, bool all = false );
52 
54  void createJoinCaches();
55 
57  void writeXml( QDomNode& layer_node, QDomDocument& document ) const;
58 
60  void readXml( QDomNode& layer_node );
61 
63  bool containsJoins() const { return ( mVectorJoins.size() > 0 ); }
65  bool containsFetchJoins() const { return ( mFetchJoinInfos.size() > 0 ); }
66 
67  const QList< QgsVectorJoinInfo >& vectorJoins() const { return mVectorJoins; }
68 
74  const QgsVectorJoinInfo* joinForFieldIndex( int index, int maxProviderIndex, int& indexOffset ) const;
75 
78  static bool maximumIndex( const QgsFieldMap& fMap, int& index );
79 
80  private:
81 
83  QList< QgsVectorJoinInfo > mVectorJoins;
84 
87  QMap<QgsVectorLayer*, QgsFetchJoinInfo> mFetchJoinInfos;
88 
90  void cacheJoinLayer( QgsVectorJoinInfo& joinInfo );
91 
99  void addJoinedFeatureAttributes( QgsFeature& f, const QgsVectorJoinInfo& joinInfo, const QString& joinFieldName, const QVariant& joinValue,
100  const QgsAttributeList& attributes, int attributeIndexOffset );
101 };
102 
103 #endif // QGSVECTORLAYERJOINBUFFER_H