QGIS API Documentation  2.0.1-Dufour
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsfeaturerequest.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgsfeaturerequest.cpp
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 #include "qgsfeaturerequest.h"
16 
17 #include "qgsfield.h"
18 
19 #include <QStringList>
20 
22  : mFilter( FilterNone )
23  , mFlags( 0 )
24 {
25 }
26 
28  : mFilter( FilterFid )
29  , mFilterFid( fid )
30  , mFlags( 0 )
31 {
32 }
33 
35  : mFilter( FilterRect )
36  , mFilterRect( rect )
37  , mFlags( 0 )
38 {
39 }
40 
42 {
43  mFlags = rh.mFlags;
44  mFilter = rh.mFilter;
47  mAttrs = rh.mAttrs;
48 }
49 
50 
52 {
54  mFilterRect = rect;
55  return *this;
56 }
57 
59 {
61  mFilterFid = fid;
62  return *this;
63 }
64 
65 QgsFeatureRequest& QgsFeatureRequest::setFlags( QgsFeatureRequest::Flags flags )
66 {
67  mFlags = flags;
68  return *this;
69 }
70 
72 {
74  mAttrs = attrs;
75  return *this;
76 }
77 
78 
79 QgsFeatureRequest& QgsFeatureRequest::setSubsetOfAttributes( const QStringList& attrNames, const QgsFields& fields )
80 {
82  mAttrs.clear();
83 
84  for ( int idx = 0; idx < fields.count(); ++idx )
85  {
86  if ( attrNames.contains( fields[idx].name() ) )
87  mAttrs.append( idx );
88  }
89 
90  return *this;
91 }