QGIS API Documentation  master-3f58142
src/core/qgsvectorlayerfeatureiterator.h
Go to the documentation of this file.
00001 /***************************************************************************
00002     qgsvectorlayerfeatureiterator.h
00003     ---------------------
00004     begin                : Dezember 2012
00005     copyright            : (C) 2012 by Martin Dobias
00006     email                : wonder dot sk at gmail dot com
00007  ***************************************************************************
00008  *                                                                         *
00009  *   This program is free software; you can redistribute it and/or modify  *
00010  *   it under the terms of the GNU General Public License as published by  *
00011  *   the Free Software Foundation; either version 2 of the License, or     *
00012  *   (at your option) any later version.                                   *
00013  *                                                                         *
00014  ***************************************************************************/
00015 #ifndef QGSVECTORLAYERFEATUREITERATOR_H
00016 #define QGSVECTORLAYERFEATUREITERATOR_H
00017 
00018 #include "qgsfeatureiterator.h"
00019 
00020 #include <QSet>
00021 
00022 typedef QMap<QgsFeatureId, QgsFeature> QgsFeatureMap;
00023 
00024 class QgsVectorLayer;
00025 struct QgsVectorJoinInfo;
00026 
00027 class CORE_EXPORT QgsVectorLayerFeatureIterator : public QgsAbstractFeatureIterator
00028 {
00029   public:
00030     QgsVectorLayerFeatureIterator( QgsVectorLayer* layer, const QgsFeatureRequest& request );
00031 
00032     ~QgsVectorLayerFeatureIterator();
00033 
00035     virtual bool nextFeature( QgsFeature& feature );
00036 
00038     virtual bool rewind();
00039 
00041     virtual bool close();
00042 
00043   protected:
00044     QgsVectorLayer* L;
00045 
00046     QgsFeatureRequest mProviderRequest;
00047     QgsFeatureIterator mProviderIterator;
00048 
00049     // general stuff
00050     //bool mFetching;
00051     //QgsRectangle mFetchRect;
00052     //QgsAttributeList mFetchAttributes;
00053     //QgsAttributeList mFetchProvAttributes;
00054     //bool mFetchGeometry;
00055 
00056     // only related to editing
00057     QSet<QgsFeatureId> mFetchConsidered;
00058     QgsGeometryMap::iterator mFetchChangedGeomIt;
00059     QgsFeatureMap::iterator mFetchAddedFeaturesIt;
00060 
00061     bool mFetchedFid; // when iterating by FID: indicator whether it has been fetched yet or not
00062 
00063     void rewindEditBuffer();
00064     void prepareJoins();
00065     bool fetchNextAddedFeature( QgsFeature& f );
00066     bool fetchNextChangedGeomFeature( QgsFeature& f );
00067     void useAddedFeature( const QgsFeature& src, QgsFeature& f );
00068     void useChangedAttributeFeature( QgsFeatureId fid, const QgsGeometry& geom, QgsFeature& f );
00069     bool nextFeatureFid( QgsFeature& f );
00070     void addJoinedAttributes( QgsFeature &f );
00071 
00075     struct FetchJoinInfo
00076     {
00077       const QgsVectorJoinInfo* joinInfo;
00078       QgsAttributeList attributes;      
00079       int indexOffset;                  
00080       QgsVectorLayer* joinLayer;        
00081       int targetField;                  
00082       int joinField;                    
00083 
00084       void addJoinedAttributesCached( QgsFeature& f, const QVariant& joinValue ) const;
00085       void addJoinedAttributesDirect( QgsFeature& f, const QVariant& joinValue ) const;
00086     };
00087 
00088 
00091     QMap<QgsVectorLayer*, FetchJoinInfo> mFetchJoinInfo;
00092 
00093 };
00094 
00095 #endif // QGSVECTORLAYERFEATUREITERATOR_H
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Defines