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
Wrapper for iterator of features from vector data provider or vector layer.
QMap< QgsFeatureId, QgsGeometry > QgsGeometryMap
Definition: qgsfeature.h:319
virtual bool close()=0
end of iterating: free the resources / lock
A rectangle specified with double values.
Definition: qgsrectangle.h:35
QgsFeatureMap::ConstIterator mFetchAddedFeaturesIt
QgsGeometryMap::ConstIterator mFetchChangedGeomIt
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeature.h:321
QMap< QgsFeatureId, QgsFeature > QgsFeatureMap
virtual bool rewind()=0
reset the iterator to the starting position
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:72
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:114
QgsVectorLayer * joinLayer
resolved pointer to the joined layer
int joinField
index of field (of the joined layer) must have equal value
QMap< QgsVectorLayer *, FetchJoinInfo > mFetchJoinInfo
Informations about joins used in the current select() statement.
virtual bool nextFeature(QgsFeature &f)=0
fetch next feature, return true on success
const QgsVectorJoinInfo * joinInfo
cannonical source of information about the join
Internal feature iterator to be implemented within data providers.
This class wraps a request for features to a vector layer (or directly its vector data provider)...
QList< int > QgsAttributeList
int indexOffset
at what position the joined fields start
QMap< QgsFeatureId, QgsFeature > QgsFeatureMap
int targetField
index of field (of this layer) that drives the join
QMap< QgsFeatureId, QgsAttributeMap > QgsChangedAttributesMap
Definition: qgsfeature.h:316
Join information prepared for fast attribute id mapping in QgsVectorLayerJoinBuffer::updateFeatureAtt...
qint64 QgsFeatureId
Definition: qgsfeature.h:30
Represents a vector layer which manages a vector based data sets.