Skip to content
Permalink
Browse files
Added convenience constructors for QgsFeatureRequest
  • Loading branch information
wonder-sk committed Mar 19, 2013
1 parent 9ed6f25 commit ff0a434852ee9a1ea11c4d714b80639404a8b988
Showing with 54 additions and 4 deletions.
  1. +4 −0 python/core/qgsfeaturerequest.sip
  2. +42 −0 src/core/qgsfeaturerequest.cpp
  3. +8 −4 src/core/qgsfeaturerequest.h
@@ -23,6 +23,10 @@ class QgsFeatureRequest

//! construct a default request: for all features get attributes and geometries
QgsFeatureRequest();
//! construct a request with feature ID filter
explicit QgsFeatureRequest( QgsFeatureId fid );
//! construct a request with rectangle filter
explicit QgsFeatureRequest( const QgsRectangle& rect );

FilterType filterType() const;

@@ -24,6 +24,48 @@ QgsFeatureRequest::QgsFeatureRequest()
{
}

QgsFeatureRequest::QgsFeatureRequest( QgsFeatureId fid )
: mFilter( FilterFid )
, mFilterFid( fid )
, mFlags( 0 )
{
}

QgsFeatureRequest::QgsFeatureRequest( const QgsRectangle& rect )
: mFilter( FilterRect )
, mFilterRect( rect )
, mFlags( 0 )
{
}


QgsFeatureRequest& QgsFeatureRequest::setFilterRect( const QgsRectangle& rect )
{
mFilter = FilterRect;
mFilterRect = rect;
return *this;
}

QgsFeatureRequest& QgsFeatureRequest::setFilterFid( QgsFeatureId fid )
{
mFilter = FilterFid;
mFilterFid = fid;
return *this;
}

QgsFeatureRequest& QgsFeatureRequest::setFlags( QgsFeatureRequest::Flags flags )
{
mFlags = flags;
return *this;
}

QgsFeatureRequest& QgsFeatureRequest::setSubsetOfAttributes( const QgsAttributeList& attrs )
{
mFlags |= SubsetOfAttributes;
mAttrs = attrs;
return *this;
}


QgsFeatureRequest& QgsFeatureRequest::setSubsetOfAttributes( const QStringList& attrNames, const QgsFields& fields )
{
@@ -73,25 +73,29 @@ class CORE_EXPORT QgsFeatureRequest

//! construct a default request: for all features get attributes and geometries
QgsFeatureRequest();
//! construct a request with feature ID filter
explicit QgsFeatureRequest( QgsFeatureId fid );
//! construct a request with rectangle filter
explicit QgsFeatureRequest( const QgsRectangle& rect );

FilterType filterType() const { return mFilter; }

//! Set rectangle from which features will be taken. Empty rectangle removes the filter.
//!
QgsFeatureRequest& setFilterRect( const QgsRectangle& rect ) { mFilter = FilterRect; mFilterRect = rect; return *this; }
QgsFeatureRequest& setFilterRect( const QgsRectangle& rect );
const QgsRectangle& filterRect() const { return mFilterRect; }

//! Set feature ID that should be fetched.
QgsFeatureRequest& setFilterFid( QgsFeatureId fid ) { mFilter = FilterFid; mFilterFid = fid; return *this; }
QgsFeatureRequest& setFilterFid( QgsFeatureId fid );
const QgsFeatureId& filterFid() const { return mFilterFid; }

//! Set flags that affect how features will be fetched
QgsFeatureRequest& setFlags( Flags flags ) { mFlags = flags; return *this; }
QgsFeatureRequest& setFlags( Flags flags );
const Flags& flags() const { return mFlags; }

//! Set a subset of attributes that will be fetched. Empty list means that all attributes are used.
//! To disable fetching attributes, reset the FetchAttributes flag (which is set by default)
QgsFeatureRequest& setSubsetOfAttributes( const QgsAttributeList& attrs ) { mFlags |= SubsetOfAttributes; mAttrs = attrs; return *this; }
QgsFeatureRequest& setSubsetOfAttributes( const QgsAttributeList& attrs );
const QgsAttributeList& subsetOfAttributes() const { return mAttrs; }

//! Set a subset of attributes by names that will be fetched

0 comments on commit ff0a434

Please sign in to comment.