00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015
00016
00017
00018 #ifndef QGSVECTORLAYERJOINBUFFER_H
00019 #define QGSVECTORLAYERJOINBUFFER_H
00020
00021 #include "qgsfeature.h"
00022 #include "qgsvectorlayer.h"
00023
00024 #include <QHash>
00025 #include <QString>
00026
00028 class CORE_EXPORT QgsVectorLayerJoinBuffer
00029 {
00030 public:
00031 QgsVectorLayerJoinBuffer();
00032 ~QgsVectorLayerJoinBuffer();
00033
00036 void addJoin( QgsVectorJoinInfo joinInfo );
00037
00039 void removeJoin( const QString& joinLayerId );
00040
00042 void select( const QgsAttributeList& fetchAttributes,
00043 QgsAttributeList& sourceJoinFields, int maxProviderIndex );
00044
00048 void updateFieldMap( QgsFieldMap& fields, int& maxIndex );
00049
00051 void updateFeatureAttributes( QgsFeature &f, int maxProviderIndex, bool all = false );
00052
00054 void createJoinCaches();
00055
00057 void writeXml( QDomNode& layer_node, QDomDocument& document ) const;
00058
00060 void readXml( const QDomNode& layer_node );
00061
00063 bool containsJoins() const { return ( mVectorJoins.size() > 0 ); }
00065 bool containsFetchJoins() const { return ( mFetchJoinInfos.size() > 0 ); }
00066
00067 const QList< QgsVectorJoinInfo >& vectorJoins() const { return mVectorJoins; }
00068
00074 const QgsVectorJoinInfo* joinForFieldIndex( int index, int maxProviderIndex, int& indexOffset ) const;
00075
00078 static bool maximumIndex( const QgsFieldMap& fMap, int& index );
00079
00080 private:
00081
00083 QList< QgsVectorJoinInfo > mVectorJoins;
00084
00087 QMap<QgsVectorLayer*, QgsFetchJoinInfo> mFetchJoinInfos;
00088
00090 void cacheJoinLayer( QgsVectorJoinInfo& joinInfo );
00091
00099 void addJoinedFeatureAttributes( QgsFeature& f, const QgsVectorJoinInfo& joinInfo, const QString& joinFieldName, const QVariant& joinValue,
00100 const QgsAttributeList& attributes, int attributeIndexOffset );
00101 };
00102
00103 #endif // QGSVECTORLAYERJOINBUFFER_H