/usr/include/qgis/qgsfeaturerequest.h is in libqgis-dev 2.0.1-2build2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 | /***************************************************************************
qgsfeaturerequest.h
---------------------
begin : Mai 2012
copyright : (C) 2012 by Martin Dobias
email : wonder dot sk at gmail dot com
***************************************************************************
* *
* This program is free software; you can redistribute it and/or modify *
* it under the terms of the GNU General Public License as published by *
* the Free Software Foundation; either version 2 of the License, or *
* (at your option) any later version. *
* *
***************************************************************************/
#ifndef QGSFEATUREREQUEST_H
#define QGSFEATUREREQUEST_H
#include <QFlags>
#include "qgsfeature.h"
#include "qgsrectangle.h"
#include <QList>
typedef QList<int> QgsAttributeList;
/**
* This class wraps a request for features to a vector layer (or directly its vector data provider).
* The request may apply a filter to fetch only a particular subset of features. Currently supported filters:
* - no filter - all features are returned
* - feature id - only feature that matches given feature id is returned
* - rectangle - only features that intersect given rectangle should be fetched. For the sake of speed,
* the intersection is often done only using feature's bounding box. There is a flag
* ExactIntersect that makes sure that only intersecting features will be returned.
*
* For efficiency, it is also possible to tell provider that some data is not required:
* - NoGeometry flag
* - SubsetOfAttributes flag
*
* The options may be chained, e.g.:
* QgsFeatureRequest().setFilterRect(QgsRectangle(0,0,1,1)).setFlags(QgsFeatureRequest::ExactIntersect)
*
* Examples:
* - fetch all features:
* QgsFeatureRequest()
* - fetch all features, only one attribute
* QgsFeatureRequest().setSubsetOfAttributes(QStringList("myfield"), provider->fieldMap())
* - fetch all features, without geometries
* QgsFeatureRequest().setFlags(QgsFeatureRequest::NoGeometry)
* - fetch only features from particular extent
* QgsFeatureRequest().setFilterRect(QgsRectangle(0,0,1,1))
* - fetch only one feature
* QgsFeatureRequest().setFilterFid(45)
*
*/
class CORE_EXPORT QgsFeatureRequest
{
public:
enum Flag
{
NoFlags = 0,
NoGeometry = 1, //!< Do not fetch geometry
SubsetOfAttributes = 2, //!< Fetch only a subset of attributes (setSubsetOfAttributes sets this flag)
ExactIntersect = 4 //!< Use exact geometry intersection (slower) instead of bounding boxes
};
Q_DECLARE_FLAGS( Flags, Flag )
enum FilterType
{
FilterNone, //!< No filter is applied
FilterRect, //!< Filter using a rectangle
FilterFid //!< Filter using feature ID
};
//! 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 );
//! copy constructor
QgsFeatureRequest( const QgsFeatureRequest& rh );
FilterType filterType() const { return mFilter; }
//! Set rectangle from which features will be taken. Empty rectangle removes the filter.
//!
QgsFeatureRequest& setFilterRect( const QgsRectangle& rect );
const QgsRectangle& filterRect() const { return mFilterRect; }
//! Set feature ID that should be fetched.
QgsFeatureRequest& setFilterFid( QgsFeatureId fid );
const QgsFeatureId& filterFid() const { return mFilterFid; }
//! Set flags that affect how features will be fetched
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 );
const QgsAttributeList& subsetOfAttributes() const { return mAttrs; }
//! Set a subset of attributes by names that will be fetched
QgsFeatureRequest& setSubsetOfAttributes( const QStringList& attrNames, const QgsFields& fields );
// TODO: in future
// void setFilterExpression(const QString& expression); // using QgsExpression
// void setFilterNativeExpression(con QString& expr); // using provider's SQL (if supported)
// void setLimit(int limit);
protected:
FilterType mFilter;
QgsRectangle mFilterRect;
QgsFeatureId mFilterFid;
Flags mFlags;
QgsAttributeList mAttrs;
};
Q_DECLARE_OPERATORS_FOR_FLAGS( QgsFeatureRequest::Flags )
#endif // QGSFEATUREREQUEST_H
|