QGIS API Documentation  2.0.1-Dufour
 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 
23 #include <QList>
24 typedef QList<int> QgsAttributeList;
25 
55 class CORE_EXPORT QgsFeatureRequest
56 {
57  public:
58  enum Flag
59  {
60  NoFlags = 0,
61  NoGeometry = 1,
62  SubsetOfAttributes = 2,
63  ExactIntersect = 4
64  };
65  Q_DECLARE_FLAGS( Flags, Flag )
66 
68  {
71  FilterFid
72  };
73 
77  explicit QgsFeatureRequest( QgsFeatureId fid );
79  explicit QgsFeatureRequest( const QgsRectangle& rect );
82 
83  FilterType filterType() const { return mFilter; }
84 
87  QgsFeatureRequest& setFilterRect( const QgsRectangle& rect );
88  const QgsRectangle& filterRect() const { return mFilterRect; }
89 
91  QgsFeatureRequest& setFilterFid( QgsFeatureId fid );
92  const QgsFeatureId& filterFid() const { return mFilterFid; }
93 
95  QgsFeatureRequest& setFlags( Flags flags );
96  const Flags& flags() const { return mFlags; }
97 
100  QgsFeatureRequest& setSubsetOfAttributes( const QgsAttributeList& attrs );
101  const QgsAttributeList& subsetOfAttributes() const { return mAttrs; }
102 
104  QgsFeatureRequest& setSubsetOfAttributes( const QStringList& attrNames, const QgsFields& fields );
105 
106  // TODO: in future
107  // void setFilterExpression(const QString& expression); // using QgsExpression
108  // void setFilterNativeExpression(con QString& expr); // using provider's SQL (if supported)
109  // void setLimit(int limit);
110 
111  protected:
115  Flags mFlags;
117 };
118 
119 Q_DECLARE_OPERATORS_FOR_FLAGS( QgsFeatureRequest::Flags )
120 
121 
122 #endif // QGSFEATUREREQUEST_H