QGIS API Documentation  2.2.0-Valmiera
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsfeaturerequest.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfeaturerequest.h
3  ---------------------
4  begin : Mai 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 QGSFEATUREREQUEST_H
16 #define QGSFEATUREREQUEST_H
17 
18 #include <QFlags>
19 
20 #include "qgsfeature.h"
21 #include "qgsrectangle.h"
22 #include "qgsexpression.h"
23 #include "qgssimplifymethod.h"
24 
25 #include <QList>
26 typedef QList<int> QgsAttributeList;
27 
58 class CORE_EXPORT QgsFeatureRequest
59 {
60  public:
61  enum Flag
62  {
63  NoFlags = 0,
64  NoGeometry = 1,
65  SubsetOfAttributes = 2,
66  ExactIntersect = 4
67  };
68  Q_DECLARE_FLAGS( Flags, Flag )
69 
71  {
76  FilterFids
77  };
78 
82  explicit QgsFeatureRequest( QgsFeatureId fid );
84  explicit QgsFeatureRequest( const QgsRectangle& rect );
86  explicit QgsFeatureRequest( const QgsExpression& expr );
89 
90  QgsFeatureRequest& operator=( const QgsFeatureRequest& rh );
91 
93 
94  FilterType filterType() const { return mFilter; }
95 
98  QgsFeatureRequest& setFilterRect( const QgsRectangle& rect );
99  const QgsRectangle& filterRect() const { return mFilterRect; }
100 
102  QgsFeatureRequest& setFilterFid( QgsFeatureId fid );
103  const QgsFeatureId& filterFid() const { return mFilterFid; }
104 
106  QgsFeatureRequest& setFilterFids( QgsFeatureIds fids );
107  const QgsFeatureIds& filterFids() const { return mFilterFids; }
108 
110  QgsFeatureRequest& setFilterExpression( const QString& expression );
111  QgsExpression* filterExpression() const { return mFilterExpression; }
112 
114  QgsFeatureRequest& setFlags( Flags flags );
115  const Flags& flags() const { return mFlags; }
116 
119  QgsFeatureRequest& setSubsetOfAttributes( const QgsAttributeList& attrs );
120  const QgsAttributeList& subsetOfAttributes() const { return mAttrs; }
121 
123  QgsFeatureRequest& setSubsetOfAttributes( const QStringList& attrNames, const QgsFields& fields );
124 
127  QgsFeatureRequest& setSimplifyMethod( const QgsSimplifyMethod& simplifyMethod );
130  const QgsSimplifyMethod& simplifyMethod() const { return mSimplifyMethod; }
131 
141  bool acceptFeature( const QgsFeature& feature );
142 
143  // TODO: in future
144  // void setFilterNativeExpression(con QString& expr); // using provider's SQL (if supported)
145  // void setLimit(int limit);
146 
147  protected:
153  Flags mFlags;
156 };
157 
158 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsFeatureRequest::Flags )
159 
160 
161 #endif // QGSFEATUREREQUEST_H