QGIS API Documentation  2.0.1-Dufour
 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 nextFeature( QgsFeature& feature );
37 
39  virtual bool rewind();
40 
42  virtual bool close();
43 
44  protected:
46 
49 
50 #if 0
51  // general stuff
52  bool mFetching;
53  QgsRectangle mFetchRect;
54  QgsAttributeList mFetchAttributes;
55  QgsAttributeList mFetchProvAttributes;
56  bool mFetchGeometry;
57 #endif
58 
59  // only related to editing
60  QSet<QgsFeatureId> mFetchConsidered;
61  QgsGeometryMap::ConstIterator mFetchChangedGeomIt;
62  QgsFeatureMap::ConstIterator mFetchAddedFeaturesIt;
63 
64  bool mFetchedFid; // when iterating by FID: indicator whether it has been fetched yet or not
65 
66  void rewindEditBuffer();
67  void prepareJoins();
68  bool fetchNextAddedFeature( QgsFeature& f );
69  bool fetchNextChangedGeomFeature( QgsFeature& f );
70  void useAddedFeature( const QgsFeature& src, QgsFeature& f );
71  void useChangedAttributeFeature( QgsFeatureId fid, const QgsGeometry& geom, QgsFeature& f );
72  bool nextFeatureFid( QgsFeature& f );
73  void addJoinedAttributes( QgsFeature &f );
74 
76  void updateChangedAttributes( QgsFeature& f );
77 
79  void updateFeatureGeometry( QgsFeature& f );
80 
85  {
91  int joinField;
92 
93  void addJoinedAttributesCached( QgsFeature& f, const QVariant& joinValue ) const;
94  void addJoinedAttributesDirect( QgsFeature& f, const QVariant& joinValue ) const;
95  };
96 
97  // A deep-copy is only performed, if the original maps change
98  // see here https://github.com/qgis/Quantum-GIS/pull/673
99  // for explanation
103  QList<QgsField> mAddedAttributes;
106 
109  QMap<QgsVectorLayer*, FetchJoinInfo> mFetchJoinInfo;
110 };
111 
112 #endif // QGSVECTORLAYERFEATUREITERATOR_H