QGIS API Documentation  2.2.0-Valmiera
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsvectorlayerfeatureiterator.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorlayerfeatureiterator.h
3  ---------------------
4  begin : Dezember 2012
5  copyright : (C) 2012 by Martin Dobias
6  email : wonder dot sk at gmail dot com
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 #ifndef QGSVECTORLAYERFEATUREITERATOR_H
16 #define QGSVECTORLAYERFEATUREITERATOR_H
17 
18 #include "qgsfeatureiterator.h"
19 
20 #include <QSet>
21 
22 typedef QMap<QgsFeatureId, QgsFeature> QgsFeatureMap;
23 
24 class QgsVectorLayer;
26 struct QgsVectorJoinInfo;
27 
29 {
30  public:
32 
34 
36  virtual bool rewind();
37 
39  virtual bool close();
40 
41  protected:
43  virtual bool fetchFeature( QgsFeature& feature );
44 
47  inline virtual bool nextFeatureFilterExpression( QgsFeature &f ) { return fetchFeature( f ); }
48 
50  virtual bool prepareSimplification( const QgsSimplifyMethod& simplifyMethod );
51 
53 
58 
59 #if 0
60  // general stuff
61  bool mFetching;
62  QgsRectangle mFetchRect;
63  QgsAttributeList mFetchAttributes;
64  QgsAttributeList mFetchProvAttributes;
65  bool mFetchGeometry;
66 #endif
67 
68  // only related to editing
69  QSet<QgsFeatureId> mFetchConsidered;
70  QgsGeometryMap::ConstIterator mFetchChangedGeomIt;
71  QgsFeatureMap::ConstIterator mFetchAddedFeaturesIt;
72 
73  bool mFetchedFid; // when iterating by FID: indicator whether it has been fetched yet or not
74 
75  void rewindEditBuffer();
76  void prepareJoins();
77  bool fetchNextAddedFeature( QgsFeature& f );
78  bool fetchNextChangedGeomFeature( QgsFeature& f );
79  bool fetchNextChangedAttributeFeature( QgsFeature& f );
80  void useAddedFeature( const QgsFeature& src, QgsFeature& f );
81  void useChangedAttributeFeature( QgsFeatureId fid, const QgsGeometry& geom, QgsFeature& f );
82  bool nextFeatureFid( QgsFeature& f );
83  void addJoinedAttributes( QgsFeature &f );
84 
86  void updateChangedAttributes( QgsFeature& f );
87 
89  void updateFeatureGeometry( QgsFeature& f );
90 
95  {
101  int joinField;
102 
103  void addJoinedAttributesCached( QgsFeature& f, const QVariant& joinValue ) const;
104  void addJoinedAttributesDirect( QgsFeature& f, const QVariant& joinValue ) const;
105  };
106 
107  // A deep-copy is only performed, if the original maps change
108  // see here https://github.com/qgis/Quantum-GIS/pull/673
109  // for explanation
113  QList<QgsField> mAddedAttributes;
116 
119  QMap<QgsVectorLayer*, FetchJoinInfo> mFetchJoinInfo;
120 
121  private:
124 
126  virtual bool providerCanSimplify( QgsSimplifyMethod::MethodType methodType ) const;
127 };
128 
129 #endif // QGSVECTORLAYERFEATUREITERATOR_H