QGIS/python/core/qgsvectorlayer.sip
2017-07-07 01:26:38 +02:00

2078 lines
66 KiB
Plaintext
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsvectorlayer.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
typedef QList<int> QgsAttributeList;
typedef QSet<int> QgsAttributeIds;
class QgsVectorLayer : QgsMapLayer, QgsExpressionContextGenerator, QgsFeatureSink, QgsFeatureSource
{
%Docstring
Represents a vector layer which manages a vector based data sets.
The QgsVectorLayer is instantiated by specifying the name of a data provider,
such as postgres or wfs, and url defining the specific data set to connect to.
The vector layer constructor in turn instantiates a QgsVectorDataProvider subclass
corresponding to the provider type, and passes it the url. The data provider
connects to the data source.
The QgsVectorLayer provides a common interface to the different data types. It also
manages editing transactions.
Sample usage of the QgsVectorLayer class:
\code
QString uri = "point?crs=epsg:4326&field=id:integer";
QgsVectorLayer *scratchLayer = new QgsVectorLayer(uri, "Scratch point layer", "memory");
\endcode
The main data providers supported by QGIS are listed below.
\section providers Vector data providers
\subsection memory Memory data providerType (memory)
The memory data provider is used to construct in memory data, for example scratch
data or data generated from spatial operations such as contouring. There is no
inherent persistent storage of the data. The data source uri is constructed. The
url specifies the geometry type ("point", "linestring", "polygon",
"multipoint","multilinestring","multipolygon"), optionally followed by url parameters
as follows:
- crs=definition
Defines the coordinate reference system to use for the layer.
definition is any string accepted by QgsCoordinateReferenceSystem.createFromString()
- index=yes
Specifies that the layer will be constructed with a spatial index
- field=name:type(length,precision)
Defines an attribute of the layer. Multiple field parameters can be added
to the data provider definition. type is one of "integer", "double", "string".
An example url is "Point?crs=epsg:4326&field=id:integer&field=name:string(20)&index=yes"
\subsection ogr OGR data provider (ogr)
Accesses data using the OGR drivers (http://www.gdal.org/ogr/ogr_formats.html). The url
is the OGR connection string. A wide variety of data formats can be accessed using this
driver, including file based formats used by many GIS systems, database formats, and
web services. Some of these formats are also supported by custom data providers listed
below.
\subsection spatialite SpatiaLite data provider (spatialite)
Access data in a SpatiaLite database. The url defines the connection parameters, table,
geometry column, and other attributes. The url can be constructed using the
QgsDataSourceUri class.
\subsection postgres PostgreSQL data provider (postgres)
Connects to a PostgreSQL database. The url defines the connection parameters, table,
geometry column, and other attributes. The url can be constructed using the
QgsDataSourceUri class.
\subsection mssql Microsoft SQL server data provider (mssql)
Connects to a Microsoft SQL server database. The url defines the connection parameters, table,
geometry column, and other attributes. The url can be constructed using the
QgsDataSourceUri class.
\subsection wfs WFS (web feature service) data provider (wfs)
Used to access data provided by a web feature service.
The url can be a HTTP url to a WFS server (legacy, e.g. http://foobar/wfs?TYPENAME=xxx&SRSNAME=yyy[&FILTER=zzz]), or,
starting with QGIS 2.16, a URI constructed using the QgsDataSourceUri class with the following parameters :
- url=string (mandatory): HTTP url to a WFS server endpoint. e.g http://foobar/wfs
- typename=string (mandatory): WFS typename
- srsname=string (recommended): SRS like 'EPSG:XXXX'
- username=string
- password=string
- authcfg=string
- version=auto/1.0.0/1.1.0/2.0.0
-sql=string: full SELECT SQL statement with optional WHERE, ORDER BY and possibly with JOIN if supported on server
- filter=string: QGIS expression or OGC/FES filter
- restrictToRequestBBOX=1: to download only features in the view extent (or more generally
in the bounding box of the feature iterator)
- maxNumFeatures=number
- IgnoreAxisOrientation=1: to ignore EPSG axis order for WFS 1.1 or 2.0
- InvertAxisOrientation=1: to invert axis order
- hideDownloadProgressDialog=1: to hide the download progress dialog
The FILTER query string parameter can be used to filter
the WFS feature type. The FILTER key value can either be a QGIS expression
or an OGC XML filter. If the value is set to a QGIS expression the driver will
turn it into OGC XML filter before passing it to the WFS server. Beware the
QGIS expression filter only supports” =, !=, <, >, <=, >=, AND, OR, NOT, LIKE, IS NULL”
attribute operators, “BBOX, Disjoint, Intersects, Touches, Crosses, Contains, Overlaps, Within”
spatial binary operators and the QGIS local “geomFromWKT, geomFromGML”
geometry constructor functions.
Also note:
- You can use various functions available in the QGIS Expression list,
however the function must exist server side and have the same name and arguments to work.
- Use the special $geometry parameter to provide the layer geometry column as input
into the spatial binary operators e.g intersects($geometry, geomFromWKT('POINT (5 6)'))
\subsection delimitedtext Delimited text file data provider (delimitedtext)
Accesses data in a delimited text file, for example CSV files generated by
spreadsheets. The contents of the file are split into columns based on specified
delimiter characters. Each record may be represented spatially either by an
X and Y coordinate column, or by a WKT (well known text) formatted columns.
The url defines the filename, the formatting options (how the
text in the file is divided into data fields, and which fields contain the
X,Y coordinates or WKT text definition. The options are specified as url query
items.
At its simplest the url can just be the filename, in which case it will be loaded
as a CSV formatted file.
The url may include the following items:
- encoding=UTF-8
Defines the character encoding in the file. The default is UTF-8. To use
the default encoding for the operating system use "System".
- type=(csv|regexp|whitespace|plain)
Defines the algorithm used to split records into columns. Records are
defined by new lines, except for csv format files for which quoted fields
may span multiple records. The default type is csv.
- "csv" splits the file based on three sets of characters:
delimiter characters, quote characters,
and escape characters. Delimiter characters mark the end
of a field. Quote characters enclose a field which can contain
delimiter characters, and newlines. Escape characters cause the
following character to be treated literally (including delimiter,
quote, and newline characters). Escape and quote characters must
be different from delimiter characters. Escape characters that are
also quote characters are treated specially - they can only
escape themselves within quotes. Elsewhere they are treated as
quote characters. The defaults for delimiter, quote, and escape
are ',', '"', '"'.
- "regexp" splits each record using a regular expression (see QRegExp
documentation for details).
- "whitespace" splits each record based on whitespace (on or more whitespace
characters. Leading whitespace in the record is ignored.
- "plain" is provided for backwards compatibility. It is equivalent to
CSV except that the default quote characters are single and double quotes,
and there is no escape characters.
- delimiter=characters
Defines the delimiter characters used for csv and plain type files, or the
regular expression for regexp type files. It is a literal string of characters
except that "\t" may be used to represent a tab character.
- quote=characters
Defines the characters that are used as quote characters for csv and plain type
files.
- escape=characters
Defines the characters used to escape delimiter, quote, and newline characters.
- skipLines=n
Defines the number of lines to ignore at the beginning of the file (default 0)
- useHeader=(yes|no)
Defines whether the first record in the file (after skipped lines) contains
column names (default yes)
- trimFields=(yes|no)
If yes then leading and trailing whitespace will be removed from fields
- skipEmptyFields=(yes|no)
If yes then empty fields will be discarded (equivalent to concatenating consecutive
delimiters)
- maxFields=#
Specifies the maximum number of fields to load for each record. Additional
fields will be discarded. Default is 0 - load all fields.
- decimalPoint=c
Defines a character that is used as a decimal point in the numeric columns
The default is '.'.
- xField=column yField=column
Defines the name of the columns holding the x and y coordinates for XY point geometries.
If the useHeader is no (ie there are no column names), then this is the column
number (with the first column as 1).
- xyDms=(yes|no)
If yes then the X and Y coordinates are interpreted as
degrees/minutes/seconds format (fairly permissively),
or degree/minutes format.
- wktField=column
Defines the name of the columns holding the WKT geometry definition for WKT geometries.
If the useHeader is no (ie there are no column names), then this is the column
number (with the first column as 1).
- geomType=(point|line|polygon|none)
Defines the geometry type for WKT type geometries. QGIS will only display one
type of geometry for the layer - any others will be ignored when the file is
loaded. By default the provider uses the type of the first geometry in the file.
Use geomType to override this type.
geomType can also be set to none, in which case the layer is loaded without
geometries.
- subset=expression
Defines an expression that will identify a subset of records to display
- crs=crsstring
Defines the coordinate reference system used for the layer. This can be
any string accepted by QgsCoordinateReferenceSystem.createFromString()
-subsetIndex=(yes|no)
Determines whether the provider generates an index to improve the efficiency
of subsets. The default is yes
-spatialIndex=(yes|no)
Determines whether the provider generates a spatial index. The default is no.
-watchFile=(yes|no)
Defines whether the file will be monitored for changes. The default is
to monitor for changes.
- quiet
Errors encountered loading the file will not be reported in a user dialog if
quiet is included (They will still be shown in the output log).
\subsection gpx GPX data provider (gpx)
Provider reads tracks, routes, and waypoints from a GPX file. The url
defines the name of the file, and the type of data to retrieve from it
("track", "route", or "waypoint").
An example url is "/home/user/data/holiday.gpx?type=route"
\subsection grass Grass data provider (grass)
Provider to display vector data in a GRASS GIS layer.
TODO QGIS3: Remove virtual from non-inherited methods (like isModified)
.. seealso:: QgsVectorLayerUtils()
%End
%TypeHeaderCode
#include "qgsvectorlayer.h"
%End
public:
enum EditResult
{
Success,
EmptyGeometry,
EditFailed,
FetchFeatureFailed,
InvalidLayer,
};
enum SelectBehavior
{
SetSelection,
AddToSelection,
IntersectSelection,
RemoveFromSelection,
};
QgsVectorLayer( const QString &path = QString(), const QString &baseName = QString(),
const QString &providerLib = "ogr", bool loadDefaultStyleFlag = true );
%Docstring
Constructor - creates a vector layer
The QgsVectorLayer is constructed by instantiating a data provider. The provider
interprets the supplied path (url) of the data source to connect to and access the
data.
\param path The path or url of the parameter. Typically this encodes
parameters used by the data provider as url query items.
\param baseName The name used to represent the layer in the legend
\param providerLib The name of the data provider, e.g., "memory", "postgres"
\param loadDefaultStyleFlag whether to load the default style
%End
virtual ~QgsVectorLayer();
virtual QgsVectorLayer *clone() const /Factory/;
%Docstring
Returns a new instance equivalent to this one. A new provider is
created for the same data source and renderers for features and diagrams
are cloned too. Moreover, each attributes (transparency, extent, selected
features and so on) are identicals.
:return: a new layer instance
.. versionadded:: 3.0
:rtype: QgsVectorLayer
%End
QString storageType() const;
%Docstring
Returns the permanent storage type for this layer as a friendly name.
:rtype: str
%End
QString capabilitiesString() const;
%Docstring
Capabilities for this layer in a friendly format.
:rtype: str
%End
QString dataComment() const;
%Docstring
Returns a comment for the data in the layer
:rtype: str
%End
QString displayField() const;
%Docstring
This is a shorthand for accessing the displayExpression if it is a simple field.
If the displayExpression is more complex than a simple field, a null string will
be returned.
.. seealso:: displayExpression
:rtype: str
%End
void setDisplayExpression( const QString &displayExpression );
%Docstring
Set the preview expression, used to create a human readable preview string.
Used e.g. in the attribute table feature list. Uses QgsExpression.
\param displayExpression The expression which will be used to preview features
for this layer
%End
QString displayExpression() const;
%Docstring
Get the preview expression, used to create a human readable preview string.
Uses QgsExpression
:return: The expression which will be used to preview features for this layer
:rtype: str
%End
virtual QgsVectorDataProvider *dataProvider();
void setProviderEncoding( const QString &encoding );
%Docstring
Sets the textencoding of the data provider
%End
void setCoordinateSystem();
%Docstring
Setup the coordinate system transformation for the layer
%End
bool addJoin( const QgsVectorLayerJoinInfo &joinInfo );
%Docstring
Joins another vector layer to this layer
\param joinInfo join object containing join layer id, target and source field
.. note::
since 2.6 returns bool indicating whether the join can be added *
:rtype: bool
%End
bool removeJoin( const QString &joinLayerId );
%Docstring
Removes a vector layer join
:return: true if join was found and successfully removed *
:rtype: bool
%End
QgsVectorLayerJoinBuffer *joinBuffer();
%Docstring
Accessor to the join buffer object
.. versionadded:: 2.14.7
:rtype: QgsVectorLayerJoinBuffer
%End
const QList<QgsVectorLayerJoinInfo> vectorJoins() const;
%Docstring
:rtype: list of QgsVectorLayerJoinInfo
%End
virtual bool setDependencies( const QSet<QgsMapLayerDependency> &layers );
%Docstring
Sets the list of dependencies.
.. seealso:: dependencies()
\param layers set of QgsMapLayerDependency. Only user-defined dependencies will be added
:return: false if a dependency cycle has been detected
.. versionadded:: 3.0
:rtype: bool
%End
virtual QSet<QgsMapLayerDependency> dependencies() const;
%Docstring
.. seealso:: setDataDependencies)
as well as dependencies given by the provider
:return: a set of QgsMapLayerDependency
.. versionadded:: 3.0
:rtype: set of QgsMapLayerDependency
%End
int addExpressionField( const QString &exp, const QgsField &fld );
%Docstring
Add a new field which is calculated by the expression specified
\param exp The expression which calculates the field
\param fld The field to calculate
:return: The index of the new field
.. versionadded:: 2.9
:rtype: int
%End
void removeExpressionField( int index );
%Docstring
Remove an expression field
\param index The index of the field
.. versionadded:: 2.6
%End
QString expressionField( int index ) const;
%Docstring
Returns the expression used for a given expression field
\param index An index of an epxression based (virtual) field
:return: The expression for the field at index
.. versionadded:: 2.9
:rtype: str
%End
void updateExpressionField( int index, const QString &exp );
%Docstring
Changes the expression used to define an expression based (virtual) field
\param index The index of the expression to change
\param exp The new expression to set
.. versionadded:: 2.9
%End
QgsActionManager *actions();
%Docstring
Get all layer actions defined on this layer.
The pointer which is returned directly points to the actions object
which is used by the layer, so any changes are immediately applied.
:rtype: QgsActionManager
%End
int selectedFeatureCount() const;
%Docstring
The number of features that are selected in this layer
:return: See description
:rtype: int
%End
void selectByRect( QgsRectangle &rect, SelectBehavior behavior = SetSelection );
%Docstring
Select features found within the search rectangle (in layer's coordinates)
\param rect search rectangle
\param behavior selection type, allows adding to current selection, removing
from selection, etc.
.. seealso:: invertSelectionInRectangle(QgsRectangle & rect)
.. seealso:: selectByExpression()
.. seealso:: selectByIds()
%End
void selectByExpression( const QString &expression, SelectBehavior behavior = SetSelection );
%Docstring
Select matching features using an expression.
\param expression expression to evaluate to select features
\param behavior selection type, allows adding to current selection, removing
from selection, etc.
.. versionadded:: 2.16
.. seealso:: selectByRect()
.. seealso:: selectByIds()
%End
void selectByIds( const QgsFeatureIds &ids, SelectBehavior behavior = SetSelection );
%Docstring
Select matching features using a list of feature IDs. Will emit the
selectionChanged() signal with the clearAndSelect flag set.
\param ids feature IDs to select
\param behavior selection type, allows adding to current selection, removing
from selection, etc.
.. versionadded:: 2.16
.. seealso:: selectByRect()
.. seealso:: selectByExpression()
%End
void modifySelection( const QgsFeatureIds &selectIds, const QgsFeatureIds &deselectIds );
%Docstring
Modifies the current selection on this layer
\param selectIds Select these ids
\param deselectIds Deselect these ids
.. seealso:: select(QgsFeatureIds)
.. seealso:: select(QgsFeatureId)
.. seealso:: deselect(QgsFeatureIds)
.. seealso:: deselect(QgsFeatureId)
.. seealso:: selectByExpression()
%End
void invertSelection();
%Docstring
Select not selected features and deselect selected ones
%End
void selectAll();
%Docstring
Select all the features
%End
QgsFeatureIds allFeatureIds() const;
%Docstring
Get all feature Ids
:rtype: QgsFeatureIds
%End
void invertSelectionInRectangle( QgsRectangle &rect );
%Docstring
Invert selection of features found within the search rectangle (in layer's coordinates)
\param rect The rectangle in which the selection of features will be inverted
.. seealso:: invertSelection()
%End
QgsFeatureList selectedFeatures() const;
%Docstring
Get a copy of the user-selected features
:return: A list of QgsFeature
.. seealso:: selectedFeatureIds()
.. seealso:: getSelectedFeatures() which is more memory friendly when handling large selections
:rtype: QgsFeatureList
%End
QgsFeatureIterator getSelectedFeatures( QgsFeatureRequest request = QgsFeatureRequest() ) const;
%Docstring
Get an iterator of the selected features
\param request You may specify a request, e.g. to limit the set of requested attributes.
Any filter on the request will be discarded.
:return: Iterator over the selected features
.. seealso:: selectedFeatureIds()
.. seealso:: selectedFeatures()
:rtype: QgsFeatureIterator
%End
const QgsFeatureIds &selectedFeatureIds() const;
%Docstring
Return reference to identifiers of selected features
:return: A list of QgsFeatureId
.. seealso:: selectedFeatures()
:rtype: QgsFeatureIds
%End
QgsRectangle boundingBoxOfSelected() const;
%Docstring
Returns the bounding box of the selected features. If there is no selection, QgsRectangle(0,0,0,0) is returned
:rtype: QgsRectangle
%End
bool labelsEnabled() const;
%Docstring
Returns whether the layer contains labels which are enabled and should be drawn.
:return: true if layer contains enabled labels
.. versionadded:: 2.9
:rtype: bool
%End
bool diagramsEnabled() const;
%Docstring
Returns whether the layer contains diagrams which are enabled and should be drawn.
:return: true if layer contains enabled diagrams
.. versionadded:: 2.9
:rtype: bool
%End
void setDiagramRenderer( QgsDiagramRenderer *r /Transfer/ );
%Docstring
Sets diagram rendering object (takes ownership)
%End
const QgsDiagramRenderer *diagramRenderer() const;
%Docstring
:rtype: QgsDiagramRenderer
%End
void setDiagramLayerSettings( const QgsDiagramLayerSettings &s );
const QgsDiagramLayerSettings *diagramLayerSettings() const;
%Docstring
:rtype: QgsDiagramLayerSettings
%End
QgsFeatureRenderer *renderer();
%Docstring
Return renderer.
:rtype: QgsFeatureRenderer
%End
void setRenderer( QgsFeatureRenderer *r /Transfer/ );
%Docstring
Set renderer which will be invoked to represent this layer.
Ownership is transferred.
%End
QgsWkbTypes::GeometryType geometryType() const;
%Docstring
Returns point, line or polygon
:rtype: QgsWkbTypes.GeometryType
%End
virtual QgsWkbTypes::Type wkbType() const;
%Docstring
Returns the WKBType or WKBUnknown in case of error
:rtype: QgsWkbTypes.Type
%End
QString providerType() const;
%Docstring
Return the provider type for this layer
:rtype: str
%End
virtual QgsCoordinateReferenceSystem sourceCrs() const;
virtual QString sourceName() const;
virtual bool readXml( const QDomNode &layer_node, const QgsReadWriteContext &context );
%Docstring
Reads vector layer specific state from project file Dom node.
.. note::
Called by QgsMapLayer.readXml().
:rtype: bool
%End
virtual bool writeXml( QDomNode &layer_node, QDomDocument &doc, const QgsReadWriteContext &context ) const;
%Docstring
Write vector layer specific state to project file Dom node.
.. note::
Called by QgsMapLayer.writeXml().
:rtype: bool
%End
void resolveReferences( QgsProject *project );
%Docstring
Resolve references to other layers (kept as layer IDs after reading XML) into layer objects.
.. versionadded:: 3.0
%End
virtual void saveStyleToDatabase( const QString &name, const QString &description,
bool useAsDefault, const QString &uiFileContent,
QString &msgError /Out/ );
%Docstring
Save named and sld style of the layer to the style table in the db.
\param name
\param description
\param useAsDefault
\param uiFileContent
\param msgError
%End
virtual int listStylesInDatabase( QStringList &ids /Out/, QStringList &names /Out/,
QStringList &descriptions /Out/, QString &msgError /Out/ );
%Docstring
Lists all the style in db split into related to the layer and not related to
\param ids the list in which will be stored the style db ids
\param names the list in which will be stored the style names
\param descriptions the list in which will be stored the style descriptions
\param msgError
:return: the number of styles related to current layer
:rtype: int
%End
virtual QString getStyleFromDatabase( const QString &styleId, QString &msgError /Out/ );
%Docstring
Will return the named style corresponding to style id provided
:rtype: str
%End
virtual bool deleteStyleFromDatabase( const QString &styleId, QString &msgError /Out/ );
%Docstring
Delete a style from the database
.. versionadded:: 3.0
\param styleId the provider's layer_styles table id of the style to delete
\param msgError reference to string that will be updated with any error messages
:return: true in case of success
:rtype: bool
%End
virtual QString loadNamedStyle( const QString &theURI, bool &resultFlag /Out/, bool loadFromLocalDb );
%Docstring
Load a named style from file/local db/datasource db
\param theURI the URI of the style or the URI of the layer
\param resultFlag will be set to true if a named style is correctly loaded
\param loadFromLocalDb if true forces to load from local db instead of datasource one
:rtype: str
%End
virtual QString loadNamedStyle( const QString &theURI, bool &resultFlag /Out/ );
%Docstring
Calls loadNamedStyle( theURI, resultFlag, false );
Retained for backward compatibility
:rtype: str
%End
virtual bool readSymbology( const QDomNode &layerNode, QString &errorMessage, const QgsReadWriteContext &context );
%Docstring
Read the symbology for the current layer from the Dom node supplied.
\param layerNode node that will contain the symbology definition for this layer.
\param errorMessage reference to string that will be updated with any error messages
\param context reading context (used for transform from relative to absolute paths)
:return: true in case of success.
:rtype: bool
%End
virtual bool readStyle( const QDomNode &node, QString &errorMessage, const QgsReadWriteContext &context );
%Docstring
Read the style for the current layer from the Dom node supplied.
\param node node that will contain the style definition for this layer.
\param errorMessage reference to string that will be updated with any error messages
\param context reading context (used for transform from relative to absolute paths)
:return: true in case of success.
:rtype: bool
%End
virtual bool writeSymbology( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context ) const;
%Docstring
Write the symbology for the layer into the docment provided.
\param node the node that will have the style element added to it.
\param doc the document that will have the QDomNode added.
\param errorMessage reference to string that will be updated with any error messages
\param context writing context (used for transform from absolute to relative paths)
:return: true in case of success.
:rtype: bool
%End
virtual bool writeStyle( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsReadWriteContext &context ) const;
%Docstring
Write just the style information for the layer into the document
\param node the node that will have the style element added to it.
\param doc the document that will have the QDomNode added.
\param errorMessage reference to string that will be updated with any error messages
\param context writing context (used for transform from absolute to relative paths)
:return: true in case of success.
:rtype: bool
%End
bool writeSld( QDomNode &node, QDomDocument &doc, QString &errorMessage, const QgsStringMap &props = QgsStringMap() ) const;
%Docstring
Writes the symbology of the layer into the document provided in SLD 1.1 format
\param node the node that will have the style element added to it.
\param doc the document that will have the QDomNode added.
\param errorMessage reference to string that will be updated with any error messages
\param props a open ended set of properties that can drive/inform the SLD encoding
:return: true in case of success
:rtype: bool
%End
virtual bool readSld( const QDomNode &node, QString &errorMessage );
long featureCount( const QString &legendKey ) const;
%Docstring
Number of features rendered with specified legend key. Features must be first
calculated by countSymbolFeatures()
:return: number of features rendered by symbol or -1 if failed or counts are not available
:rtype: long
%End
void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag = false );
%Docstring
Update the data source of the layer. The layer's renderer and legend will be preserved only
if the geometry type of the new data source matches the current geometry type of the layer.
\param dataSource new layer data source
\param baseName base name of the layer
\param provider provider string
\param loadDefaultStyleFlag set to true to reset the layer's style to the default for the
data source
.. versionadded:: 2.10
%End
bool countSymbolFeatures();
%Docstring
Count features for symbols.
The method will return immediately. You will need to connect to the
symbolFeatureCountMapChanged() signal to be notified when the freshly updated
feature counts are ready.
.. note::
If you need to wait for the results, create and start your own QgsVectorLayerFeatureCounter
task and call waitForFinished().
.. versionadded:: 3.0
:rtype: bool
%End
virtual bool setSubsetString( const QString &subset );
%Docstring
Set the string (typically sql) used to define a subset of the layer
\param subset The subset string. This may be the where clause of a sql statement
or other definition string specific to the underlying dataprovider
and data store.
:return: true, when setting the subset string was successful, false otherwise
:rtype: bool
%End
virtual QString subsetString() const;
%Docstring
Get the string (typically sql) used to define a subset of the layer
:return: The subset string or null QString if not implemented by the provider
:rtype: str
%End
virtual QgsFeatureIterator getFeatures( const QgsFeatureRequest &request = QgsFeatureRequest() ) const;
%Docstring
Query the layer for features specified in request.
\param request feature request describing parameters of features to return
:return: iterator for matching features from provider
:rtype: QgsFeatureIterator
%End
QgsFeatureIterator getFeatures( const QString &expression );
%Docstring
Query the layer for features matching a given expression.
:rtype: QgsFeatureIterator
%End
QgsFeature getFeature( QgsFeatureId fid );
%Docstring
Query the layer for the feature with the given id.
If there is no such feature, the returned feature will be invalid.
:rtype: QgsFeature
%End
QgsFeatureIterator getFeatures( const QgsFeatureIds &fids );
%Docstring
Query the layer for the features with the given ids.
:rtype: QgsFeatureIterator
%End
QgsFeatureIterator getFeatures( const QgsRectangle &rectangle );
%Docstring
Query the layer for the features which intersect the specified rectangle.
:rtype: QgsFeatureIterator
%End
virtual bool addFeature( QgsFeature &feature, QgsFeatureSink::Flags flags = 0 );
bool updateFeature( QgsFeature &f );
%Docstring
Updates an existing feature. This method needs to query the datasource
on every call. Consider using changeAttributeValue() or
changeGeometry() instead.
\param f Feature to update
:return: True in case of success and False in case of error
:rtype: bool
%End
bool insertVertex( double x, double y, QgsFeatureId atFeatureId, int beforeVertex );
%Docstring
Insert a new vertex before the given vertex number,
in the given ring, item (first number is index 0), and feature
Not meaningful for Point geometries
:rtype: bool
%End
bool insertVertex( const QgsPoint &point, QgsFeatureId atFeatureId, int beforeVertex );
%Docstring
Insert a new vertex before the given vertex number,
in the given ring, item (first number is index 0), and feature
Not meaningful for Point geometries
:rtype: bool
%End
bool moveVertex( double x, double y, QgsFeatureId atFeatureId, int atVertex );
%Docstring
Moves the vertex at the given position number,
ring and item (first number is index 0), and feature
to the given coordinates
:rtype: bool
%End
bool moveVertex( const QgsPoint &p, QgsFeatureId atFeatureId, int atVertex ) /PyName=moveVertexV2/;
%Docstring
Moves the vertex at the given position number,
ring and item (first number is index 0), and feature
to the given coordinates
.. note::
available in Python as moveVertexV2
:rtype: bool
%End
EditResult deleteVertex( QgsFeatureId featureId, int vertex );
%Docstring
Deletes a vertex from a feature.
\param featureId ID of feature to remove vertex from
\param vertex index of vertex to delete
.. versionadded:: 2.14
:rtype: EditResult
%End
bool deleteSelectedFeatures( int *deletedCount = 0 );
%Docstring
Deletes the selected features
:return: true in case of success and false otherwise
:rtype: bool
%End
int addRing( const QList<QgsPointXY> &ring, QgsFeatureId *featureId = 0 );
%Docstring
:rtype: int
%End
int addRing( QgsCurve *ring /Transfer/, QgsFeatureId *featureId = 0 ) /PyName=addCurvedRing/;
%Docstring
:rtype: int
%End
int addPart( const QList<QgsPointXY> &ring );
%Docstring
:rtype: int
%End
int addPart( const QgsPointSequence &ring ) /PyName=addPartV2/;
%Docstring
:rtype: int
%End
int addPart( QgsCurve *ring /Transfer/ ) /PyName=addCurvedPart/;
%Docstring
.. note::
available in Python as addCurvedPart
:rtype: int
%End
int translateFeature( QgsFeatureId featureId, double dx, double dy );
%Docstring
Translates feature by dx, dy
\param featureId id of the feature to translate
\param dx translation of x-coordinate
\param dy translation of y-coordinate
:return: 0 in case of success
:rtype: int
%End
int splitParts( const QList<QgsPointXY> &splitLine, bool topologicalEditing = false );
%Docstring
:rtype: int
%End
int splitFeatures( const QList<QgsPointXY> &splitLine, bool topologicalEditing = false );
%Docstring
:rtype: int
%End
int addTopologicalPoints( const QgsGeometry &geom );
%Docstring
Adds topological points for every vertex of the geometry.
\param geom the geometry where each vertex is added to segments of other features
.. note::
geom is not going to be modified by the function
:return: 0 in case of success
:rtype: int
%End
int addTopologicalPoints( const QgsPointXY &p );
%Docstring
Adds a vertex to segments which intersect point p but don't
already have a vertex there. If a feature already has a vertex at position p,
no additional vertex is inserted. This method is useful for topological
editing.
\param p position of the vertex
:return: 0 in case of success
:rtype: int
%End
const QgsAbstractVectorLayerLabeling *labeling() const;
%Docstring
Access to labeling configuration. May be null if labeling is not used.
.. versionadded:: 3.0
:rtype: QgsAbstractVectorLayerLabeling
%End
void setLabeling( QgsAbstractVectorLayerLabeling *labeling /Transfer/ );
%Docstring
Set labeling configuration. Takes ownership of the object.
.. versionadded:: 3.0
%End
virtual bool isEditable() const;
%Docstring
Returns true if the provider is in editing mode
:rtype: bool
%End
virtual bool isSpatial() const;
%Docstring
Returns true if this is a geometry layer and false in case of NoGeometry (table only) or UnknownGeometry
:rtype: bool
%End
virtual bool isModified() const;
%Docstring
Returns true if the provider has been modified since the last commit
:rtype: bool
%End
virtual void reload();
%Docstring
Synchronises with changes in the datasource
%End
virtual QgsMapLayerRenderer *createMapRenderer( QgsRenderContext &rendererContext ) /Factory/;
%Docstring
Return new instance of QgsMapLayerRenderer that will be used for rendering of given context
.. versionadded:: 2.4
:rtype: QgsMapLayerRenderer
%End
virtual QgsRectangle extent() const;
virtual QgsRectangle sourceExtent() const;
virtual QgsFields fields() const;
%Docstring
Returns the list of fields of this layer.
This also includes fields which have not yet been saved to the provider.
:return: A list of fields
:rtype: QgsFields
%End
QgsFields pendingFields() const;
%Docstring
Returns the list of fields of this layer.
This also includes fields which have not yet been saved to the provider.
Alias for fields()
:return: A list of fields
:rtype: QgsFields
%End
QgsAttributeList pendingAllAttributesList() const;
%Docstring
Returns list of attribute indexes. i.e. a list from 0 ... fieldCount()
Alias for attributeList()
:rtype: QgsAttributeList
%End
QgsAttributeList attributeList() const;
%Docstring
Returns list of attribute indexes. i.e. a list from 0 ... fieldCount()
Alias for attributeList()
:rtype: QgsAttributeList
%End
QgsAttributeList pendingPkAttributesList() const;
%Docstring
Returns list of attributes making up the primary key
Alias for pkAttributeList()
:rtype: QgsAttributeList
%End
QgsAttributeList pkAttributeList() const;
%Docstring
Returns list of attributes making up the primary key
:rtype: QgsAttributeList
%End
long pendingFeatureCount() const;
%Docstring
Returns feature count including changes which have not yet been committed
Alias for featureCount()
:rtype: long
%End
virtual long featureCount() const;
%Docstring
Returns feature count including changes which have not yet been committed
If you need only the count of committed features call this method on this layer's provider.
:rtype: long
%End
bool setReadOnly( bool readonly = true );
%Docstring
Make layer read-only (editing disabled) or not
:return: false if the layer is in editing yet
:rtype: bool
%End
bool changeGeometry( QgsFeatureId fid, const QgsGeometry &geom );
%Docstring
Change feature's geometry
:rtype: bool
%End
bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() );
%Docstring
Changes an attribute value (but does not commit it)
\param fid The feature id of the feature to be changed
\param field The index of the field to be updated
\param newValue The value which will be assigned to the field
\param oldValue The previous value to restore on undo (will otherwise be retrieved)
:return: true in case of success
:rtype: bool
%End
bool addAttribute( const QgsField &field );
%Docstring
Add an attribute field (but does not commit it)
returns true if the field was added
:rtype: bool
%End
void setFieldAlias( int index, const QString &aliasString );
%Docstring
Sets an alias (a display name) for attributes to display in dialogs
.. versionadded:: 3.0
%End
void removeFieldAlias( int index );
%Docstring
Removes an alias (a display name) for attributes to display in dialogs
.. versionadded:: 3.0
%End
bool renameAttribute( int index, const QString &newName );
%Docstring
Renames an attribute field (but does not commit it).
\param index attribute index
\param newName new name of field
.. versionadded:: 2.16
:rtype: bool
%End
QString attributeAlias( int index ) const;
%Docstring
Returns the alias of an attribute name or a null string if there is no alias.
.. seealso:: {attributeDisplayName( int attributeIndex )} which returns the field name
if no alias is defined.
:rtype: str
%End
QString attributeDisplayName( int index ) const;
%Docstring
Convenience function that returns the attribute alias if defined or the field name else
:rtype: str
%End
QgsStringMap attributeAliases() const;
%Docstring
Returns a map of field name to attribute alias
:rtype: QgsStringMap
%End
QSet<QString> excludeAttributesWms() const;
%Docstring
A set of attributes that are not advertised in WMS requests with QGIS server.
:rtype: set of str
%End
void setExcludeAttributesWms( const QSet<QString> &att );
%Docstring
A set of attributes that are not advertised in WMS requests with QGIS server.
%End
QSet<QString> excludeAttributesWfs() const;
%Docstring
A set of attributes that are not advertised in WFS requests with QGIS server.
:rtype: set of str
%End
void setExcludeAttributesWfs( const QSet<QString> &att );
%Docstring
A set of attributes that are not advertised in WFS requests with QGIS server.
%End
bool deleteAttribute( int attr );
%Docstring
Delete an attribute field (but does not commit it)
:rtype: bool
%End
bool deleteAttributes( QList<int> attrs );
%Docstring
Deletes a list of attribute fields (but does not commit it)
\param attrs the indices of the attributes to delete
:return: true if at least one attribute has been deleted
:rtype: bool
%End
virtual bool addFeatures( QgsFeatureList &features, QgsFeatureSink::Flags flags = 0 );
bool deleteFeature( QgsFeatureId fid );
%Docstring
Delete a feature from the layer (but does not commit it)
:rtype: bool
%End
bool deleteFeatures( const QgsFeatureIds &fids );
%Docstring
Deletes a set of features from the layer (but does not commit it)
\param fids The feature ids to delete
:return: false if the layer is not in edit mode or does not support deleting
in case of an active transaction depends on the provider implementation
:rtype: bool
%End
bool commitChanges();
%Docstring
Attempts to commit any changes to disk. Returns the result of the attempt.
If a commit fails, the in-memory changes are left alone.
This allows editing to continue if the commit failed on e.g. a
disallowed value in a Postgres database - the user can re-edit and try
again.
The commits occur in distinct stages,
(add attributes, add features, change attribute values, change
geometries, delete features, delete attributes)
so if a stage fails, it's difficult to roll back cleanly.
Therefore any error message also includes which stage failed so
that the user has some chance of repairing the damage cleanly.
.. seealso:: commitErrors()
:rtype: bool
%End
QStringList commitErrors() const;
%Docstring
Returns a list containing any error messages generated when attempting
to commit changes to the layer.
.. seealso:: commitChanges()
:rtype: list of str
%End
bool rollBack( bool deleteBuffer = true );
%Docstring
Stop editing and discard the edits
\param deleteBuffer whether to delete editing buffer
:rtype: bool
%End
QList<QgsRelation> referencingRelations( int idx ) const;
%Docstring
Get relations, where the foreign key is on this layer
\param idx Only get relations, where idx forms part of the foreign key
:return: A list of relations
:rtype: list of QgsRelation
%End
QgsVectorLayerEditBuffer *editBuffer();
%Docstring
Buffer with uncommitted editing operations. Only valid after editing has been turned on.
:rtype: QgsVectorLayerEditBuffer
%End
void beginEditCommand( const QString &text );
%Docstring
Create edit command for undo/redo operations
\param text text which is to be displayed in undo window
%End
void endEditCommand();
%Docstring
Finish edit command and add it to undo/redo stack
%End
void destroyEditCommand();
%Docstring
Destroy active command and reverts all changes in it
%End
enum VertexMarkerType
{
SemiTransparentCircle,
Cross,
NoMarker
};
static void drawVertexMarker( double x, double y, QPainter &p, QgsVectorLayer::VertexMarkerType type, int vertexSize );
%Docstring
Draws a vertex symbol at (screen) coordinates x, y. (Useful to assist vertex editing.)
%End
void updateFields();
%Docstring
Assembles mUpdatedFields considering provider fields, joined fields and added fields
%End
QVariant defaultValue( int index, const QgsFeature &feature = QgsFeature(),
QgsExpressionContext *context = 0 ) const;
%Docstring
Returns the calculated default value for the specified field index. The default
value may be taken from a client side default value expression (see setDefaultValueExpression())
or taken from the underlying data provider.
\param index field index
\param feature optional feature to use for default value evaluation. If passed,
then properties from the feature (such as geometry) can be used when calculating
the default value.
\param context optional expression context to evaluate expressions again. If not
specified, a default context will be created
:return: calculated default value
.. versionadded:: 3.0
.. seealso:: setDefaultValueExpression()
:rtype: QVariant
%End
void setDefaultValueExpression( int index, const QString &expression );
%Docstring
Sets an expression to use when calculating the default value for a field.
\param index field index
\param expression expression to evaluate when calculating default values for field. Pass
an empty expression to clear the default.
.. versionadded:: 3.0
.. seealso:: defaultValue()
.. seealso:: defaultValueExpression()
%End
QString defaultValueExpression( int index ) const;
%Docstring
Returns the expression used when calculating the default value for a field.
\param index field index
:return: expression evaluated when calculating default values for field, or an
empty string if no default is set
.. versionadded:: 3.0
.. seealso:: defaultValue()
.. seealso:: setDefaultValueExpression()
:rtype: str
%End
QgsFieldConstraints::Constraints fieldConstraints( int fieldIndex ) const;
%Docstring
Returns any constraints which are present for a specified
field index. These constraints may be inherited from the layer's data provider
or may be set manually on the vector layer from within QGIS.
.. versionadded:: 3.0
.. seealso:: setFieldConstraint()
:rtype: QgsFieldConstraints.Constraints
%End
QMap< QgsFieldConstraints::Constraint, QgsFieldConstraints::ConstraintStrength> fieldConstraintsAndStrength( int fieldIndex ) const;
%Docstring
Returns a map of constraint with their strength for a specific field of the layer.
\param fieldIndex field index
.. versionadded:: 3.0
:rtype: QMap< QgsFieldConstraints.Constraint, QgsFieldConstraints.ConstraintStrength>
%End
void setFieldConstraint( int index, QgsFieldConstraints::Constraint constraint, QgsFieldConstraints::ConstraintStrength strength = QgsFieldConstraints::ConstraintStrengthHard );
%Docstring
Sets a constraint for a specified field index. Any constraints inherited from the layer's
data provider will be kept intact and cannot be modified. Ie, calling this method only allows for new
constraints to be added on top of the existing provider constraints.
.. versionadded:: 3.0
.. seealso:: fieldConstraints()
.. seealso:: removeFieldConstraint()
%End
void removeFieldConstraint( int index, QgsFieldConstraints::Constraint constraint );
%Docstring
Removes a constraint for a specified field index. Any constraints inherited from the layer's
data provider will be kept intact and cannot be removed.
.. versionadded:: 3.0
.. seealso:: fieldConstraints()
.. seealso:: setFieldConstraint()
%End
QString constraintExpression( int index ) const;
%Docstring
Returns the constraint expression for for a specified field index, if set.
.. versionadded:: 3.0
.. seealso:: fieldConstraints()
.. seealso:: constraintDescription()
.. seealso:: setConstraintExpression()
:rtype: str
%End
QString constraintDescription( int index ) const;
%Docstring
Returns the descriptive name for the constraint expression for a specified field index.
.. versionadded:: 3.0
.. seealso:: constraints()
.. seealso:: constraintExpression()
.. seealso:: setConstraintExpression()
:rtype: str
%End
void setConstraintExpression( int index, const QString &expression, const QString &description = QString() );
%Docstring
Set the constraint expression for the specified field index. An optional descriptive name for the constraint
can also be set. Setting an empty expression will clear any existing expression constraint.
.. versionadded:: 3.0
.. seealso:: constraintExpression()
.. seealso:: constraintDescription()
.. seealso:: constraints()
%End
void setEditorWidgetSetup( int index, const QgsEditorWidgetSetup &setup );
%Docstring
\copydoc editorWidgetSetup
%End
QgsEditorWidgetSetup editorWidgetSetup( int index ) const;
%Docstring
The editor widget setup defines which QgsFieldFormatter and editor widget will be used
for the field at `index`.
.. versionadded:: 3.0
:rtype: QgsEditorWidgetSetup
%End
virtual QSet<QVariant> uniqueValues( int fieldIndex, int limit = -1 ) const;
%Docstring
Calculates a list of unique values contained within an attribute in the layer. Note that
in some circumstances when unsaved changes are present for the layer then the returned list
may contain outdated values (for instance when the attribute value in a saved feature has
been changed inside the edit buffer then the previous saved value will be included in the
returned list).
\param fieldIndex column index for attribute
\param limit maximum number of values to return (or -1 if unlimited)
.. seealso:: minimumValue()
.. seealso:: maximumValue()
:rtype: set of QVariant
%End
QStringList uniqueStringsMatching( int index, const QString &substring, int limit = -1,
QgsFeedback *feedback = 0 ) const;
%Docstring
Returns unique string values of an attribute which contain a specified subset string. Subset
matching is done in a case-insensitive manner. Note that
in some circumstances when unsaved changes are present for the layer then the returned list
may contain outdated values (for instance when the attribute value in a saved feature has
been changed inside the edit buffer then the previous saved value will be included in the
returned list).
\param index column index for attribute
\param substring substring to match (case insensitive)
\param limit maxmum number of the values to return, or -1 to return all unique values
\param feedback optional feedback object for canceling request
:return: list of unique strings containing substring
:rtype: list of str
%End
QVariant minimumValue( int index ) const;
%Docstring
Returns the minimum value for an attribute column or an invalid variant in case of error.
Note that in some circumstances when unsaved changes are present for the layer then the
returned value may be outdated (for instance when the attribute value in a saved feature has
been changed inside the edit buffer then the previous saved value may be returned as the minimum).
.. seealso:: maximumValue()
.. seealso:: uniqueValues()
:rtype: QVariant
%End
QVariant maximumValue( int index ) const;
%Docstring
Returns the maximum value for an attribute column or an invalid variant in case of error.
Note that in some circumstances when unsaved changes are present for the layer then the
returned value may be outdated (for instance when the attribute value in a saved feature has
been changed inside the edit buffer then the previous saved value may be returned as the maximum).
.. seealso:: minimumValue()
.. seealso:: uniqueValues()
:rtype: QVariant
%End
QVariant aggregate( QgsAggregateCalculator::Aggregate aggregate,
const QString &fieldOrExpression,
const QgsAggregateCalculator::AggregateParameters &parameters = QgsAggregateCalculator::AggregateParameters(),
QgsExpressionContext *context = 0,
bool *ok = 0 ) const;
%Docstring
Calculates an aggregated value from the layer's features.
\param aggregate aggregate to calculate
\param fieldOrExpression source field or expression to use as basis for aggregated values.
\param parameters parameters controlling aggregate calculation
\param context expression context for expressions and filters
\param ok if specified, will be set to true if aggregate calculation was successful
:return: calculated aggregate value
.. versionadded:: 2.16
:rtype: QVariant
%End
QList< QVariant > getValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false, QgsFeedback *feedback = 0 ) const;
%Docstring
Fetches all values from a specified field name or expression.
\param fieldOrExpression field name or an expression string
\param ok will be set to false if field or expression is invalid, otherwise true
\param selectedOnly set to true to get values from selected features only
\param feedback optional feedback object to allow cancelation
:return: list of fetched values
.. versionadded:: 2.9
.. seealso:: getDoubleValues
:rtype: list of QVariant
%End
QList< double > getDoubleValues( const QString &fieldOrExpression, bool &ok, bool selectedOnly = false, int *nullCount = 0, QgsFeedback *feedback = 0 ) const;
%Docstring
Fetches all double values from a specified field name or expression. Null values or
invalid expression results are skipped.
\param fieldOrExpression field name or an expression string evaluating to a double value
\param ok will be set to false if field or expression is invalid, otherwise true
\param selectedOnly set to true to get values from selected features only
\param nullCount optional pointer to integer to store number of null values encountered in
\param feedback optional feedback object to allow cancelation
:return: list of fetched values
.. versionadded:: 2.9
.. seealso:: getValues
:rtype: list of float
%End
void setFeatureBlendMode( QPainter::CompositionMode blendMode );
%Docstring
Set the blending mode used for rendering each feature
%End
QPainter::CompositionMode featureBlendMode() const;
%Docstring
Returns the current blending mode for features
:rtype: QPainter.CompositionMode
%End
void setOpacity( double opacity );
%Docstring
Sets the ``opacity`` for the vector layer, where ``opacity`` is a value between 0 (totally transparent)
and 1.0 (fully opaque).
.. seealso:: opacity()
.. seealso:: opacityChanged()
.. versionadded:: 3.0
%End
double opacity() const;
%Docstring
Returns the opacity for the vector layer, where opacity is a value between 0 (totally transparent)
and 1.0 (fully opaque).
.. seealso:: setOpacity()
.. seealso:: opacityChanged()
.. versionadded:: 3.0
:rtype: float
%End
virtual QString htmlMetadata() const;
void setSimplifyMethod( const QgsVectorSimplifyMethod &simplifyMethod );
%Docstring
Set the simplification settings for fast rendering of features
.. versionadded:: 2.2
%End
const QgsVectorSimplifyMethod &simplifyMethod() const;
%Docstring
Returns the simplification settings for fast rendering of features
.. versionadded:: 2.2
:rtype: QgsVectorSimplifyMethod
%End
bool simplifyDrawingCanbeApplied( const QgsRenderContext &renderContext, QgsVectorSimplifyMethod::SimplifyHint simplifyHint ) const;
%Docstring
Returns whether the VectorLayer can apply the specified simplification hint
.. note::
Do not use in 3rd party code - may be removed in future version!
.. versionadded:: 2.2
:rtype: bool
%End
QgsConditionalLayerStyles *conditionalStyles() const;
%Docstring
Return the conditional styles that are set for this layer. Style information is
used to render conditional formatting in the attribute table.
:return: Return a QgsConditionalLayerStyles object holding the conditional attribute
style information. Style information is generic and can be used for anything.
.. versionadded:: 2.12
:rtype: QgsConditionalLayerStyles
%End
QgsAttributeTableConfig attributeTableConfig() const;
%Docstring
Get the attribute table configuration object.
This defines the appearance of the attribute table.
:rtype: QgsAttributeTableConfig
%End
void setAttributeTableConfig( const QgsAttributeTableConfig &attributeTableConfig );
%Docstring
Set the attribute table configuration object.
This defines the appearance of the attribute table.
%End
QString mapTipTemplate() const;
%Docstring
The mapTip is a pretty, html representation for feature information.
It may also contain embedded expressions.
.. versionadded:: 3.0
:rtype: str
%End
void setMapTipTemplate( const QString &mapTipTemplate );
%Docstring
The mapTip is a pretty, html representation for feature information.
It may also contain embedded expressions.
.. versionadded:: 3.0
%End
virtual QgsExpressionContext createExpressionContext() const;
QgsEditFormConfig editFormConfig() const;
%Docstring
Get the configuration of the form used to represent this vector layer.
This is a writable configuration that can directly be changed in place.
:return: The configuration of this layers' form
.. versionadded:: 2.14
:rtype: QgsEditFormConfig
%End
void setEditFormConfig( const QgsEditFormConfig &editFormConfig );
%Docstring
Get the configuration of the form used to represent this vector layer.
This is a writable configuration that can directly be changed in place.
:return: The configuration of this layers' form
.. versionadded:: 3.0
%End
public slots:
void select( QgsFeatureId featureId );
%Docstring
Select feature by its ID
\param featureId The id of the feature to select
.. seealso:: select(QgsFeatureIds)
%End
void select( const QgsFeatureIds &featureIds );
%Docstring
Select features by their ID
\param featureIds The ids of the features to select
.. seealso:: select(QgsFeatureId)
%End
void deselect( const QgsFeatureId featureId );
%Docstring
Deselect feature by its ID
\param featureId The id of the feature to deselect
.. seealso:: deselect(QgsFeatureIds)
%End
void deselect( const QgsFeatureIds &featureIds );
%Docstring
Deselect features by their ID
\param featureIds The ids of the features to deselect
.. seealso:: deselect(QgsFeatureId)
%End
void removeSelection();
%Docstring
Clear selection
.. seealso:: selectByIds()
%End
virtual void updateExtents();
%Docstring
Update the extents for the layer. This is necessary if features are
added/deleted or the layer has been subsetted.
%End
bool startEditing();
%Docstring
Make layer editable.
This starts an edit session on this layer. Changes made in this edit session will not
be made persistent until commitChanges() is called and can be reverted by calling
rollBack().
:rtype: bool
%End
protected slots:
void invalidateSymbolCountedFlag();
signals:
void selectionChanged( const QgsFeatureIds &selected, const QgsFeatureIds &deselected, const bool clearAndSelect );
%Docstring
This signal is emitted when selection was changed
\param selected Newly selected feature ids
\param deselected Ids of all features which have previously been selected but are not any more
\param clearAndSelect In case this is set to true, the old selection was dismissed and the new selection corresponds to selected
%End
void layerModified();
%Docstring
This signal is emitted when modifications has been done on layer
%End
void beforeModifiedCheck() const;
%Docstring
Is emitted, when layer is checked for modifications. Use for last-minute additions
%End
void beforeEditingStarted();
%Docstring
Is emitted, before editing on this layer is started
%End
void editingStarted();
%Docstring
Is emitted, when editing on this layer has started
%End
void editingStopped();
%Docstring
Is emitted, when edited changes successfully have been written to the data provider
%End
void beforeCommitChanges();
%Docstring
Is emitted, before changes are committed to the data provider
%End
void beforeRollBack();
%Docstring
Is emitted, before changes are rolled back
%End
void attributeAdded( int idx );
%Docstring
Will be emitted, when a new attribute has been added to this vector layer.
Applies only to types QgsFields.OriginEdit, QgsFields.OriginProvider and QgsFields.OriginExpression
\param idx The index of the new attribute
.. seealso:: updatedFields()
%End
void beforeAddingExpressionField( const QString &fieldName );
%Docstring
Will be emitted, when an expression field is going to be added to this vector layer.
Applies only to types QgsFields.OriginExpression
\param fieldName The name of the attribute to be added
%End
void attributeDeleted( int idx );
%Docstring
Will be emitted, when an attribute has been deleted from this vector layer.
Applies only to types QgsFields.OriginEdit, QgsFields.OriginProvider and QgsFields.OriginExpression
\param idx The index of the deleted attribute
.. seealso:: updatedFields()
%End
void beforeRemovingExpressionField( int idx );
%Docstring
Will be emitted, when an expression field is going to be deleted from this vector layer.
Applies only to types QgsFields.OriginExpression
\param idx The index of the attribute to be deleted
%End
void featureAdded( QgsFeatureId fid );
%Docstring
Emitted when a new feature has been added to the layer
\param fid The id of the new feature
%End
void featureDeleted( QgsFeatureId fid );
%Docstring
Emitted when a feature has been deleted.
If you do expensive operations in a slot connected to this, you should prefer to use
featuresDeleted( const QgsFeatureIds& ).
\param fid The id of the feature which has been deleted
%End
void featuresDeleted( const QgsFeatureIds &fids );
%Docstring
Emitted when features have been deleted.
If features are deleted within an edit command, this will only be emitted once at the end
to allow connected slots to minimize the overhead.
If features are deleted outside of an edit command, this signal will be emitted once per feature.
\param fids The feature ids that have been deleted.
%End
void updatedFields();
%Docstring
Is emitted, whenever the fields available from this layer have been changed.
This can be due to manually adding attributes or due to a join.
%End
void attributeValueChanged( QgsFeatureId fid, int idx, const QVariant &value );
%Docstring
Is emitted whenever an attribute value change is done in the edit buffer.
Note that at this point the attribute change is not yet saved to the provider.
\param fid The id of the changed feature
\param idx The attribute index of the changed attribute
\param value The new value of the attribute
%End
void geometryChanged( QgsFeatureId fid, const QgsGeometry &geometry );
%Docstring
Is emitted whenever a geometry change is done in the edit buffer.
Note that at this point the geometry change is not yet saved to the provider.
\param fid The id of the changed feature
\param geometry The new geometry
%End
void committedAttributesDeleted( const QString &layerId, const QgsAttributeList &deletedAttributes );
%Docstring
This signal is emitted, when attributes are deleted from the provider
%End
void committedAttributesAdded( const QString &layerId, const QList<QgsField> &addedAttributes );
%Docstring
This signal is emitted, when attributes are added to the provider
%End
void committedFeaturesAdded( const QString &layerId, const QgsFeatureList &addedFeatures );
%Docstring
This signal is emitted, when features are added to the provider
%End
void committedFeaturesRemoved( const QString &layerId, const QgsFeatureIds &deletedFeatureIds );
%Docstring
This signal is emitted, when features are deleted from the provider
%End
void committedAttributeValuesChanges( const QString &layerId, const QgsChangedAttributesMap &changedAttributesValues );
%Docstring
This signal is emitted, when attribute value changes are saved to the provider
%End
void committedGeometriesChanges( const QString &layerId, const QgsGeometryMap &changedGeometries );
%Docstring
This signal is emitted, when geometry changes are saved to the provider
%End
void labelingFontNotFound( QgsVectorLayer *layer, const QString &fontfamily );
%Docstring
Emitted when the font family defined for labeling layer is not found on system
%End
void featureBlendModeChanged( QPainter::CompositionMode blendMode );
%Docstring
Signal emitted when setFeatureBlendMode() is called
%End
void opacityChanged( double opacity );
%Docstring
Emitted when the layer's opacity is changed, where ``opacity`` is a value between 0 (transparent)
and 1 (opaque).
.. versionadded:: 3.0
.. seealso:: setOpacity()
.. seealso:: opacity()
%End
void editCommandStarted( const QString &text );
%Docstring
Signal emitted when a new edit command has been started
\param text Description for this edit command
%End
void editCommandEnded();
%Docstring
Signal emitted, when an edit command successfully ended
.. note::
This does not mean it is also committed, only that it is written
to the edit buffer. See beforeCommitChanges()
%End
void editCommandDestroyed();
%Docstring
Signal emitted, whan an edit command is destroyed
.. note::
This is not a rollback, it is only related to the current edit command.
See beforeRollBack()
%End
void readCustomSymbology( const QDomElement &element, QString &errorMessage );
%Docstring
Signal emitted whenever the symbology (QML-file) for this layer is being read.
If there is custom style information saved in the file, you can connect to this signal
and update the layer style accordingly.
\param element The XML layer style element.
\param errorMessage Write error messages into this string.
%End
void writeCustomSymbology( QDomElement &element, QDomDocument &doc, QString &errorMessage ) const;
%Docstring
Signal emitted whenever the symbology (QML-file) for this layer is being written.
If there is custom style information you want to save to the file, you can connect
to this signal and update the element accordingly.
\param element The XML element where you can add additional style information to.
\param doc The XML document that you can use to create new XML nodes.
\param errorMessage Write error messages into this string.
%End
void mapTipTemplateChanged();
%Docstring
Emitted when the map tip changes
.. versionadded:: 3.0
%End
void displayExpressionChanged();
%Docstring
Emitted when the display expression changes
.. versionadded:: 3.0
%End
void raiseError( const QString &msg );
%Docstring
Signals an error related to this vector layer.
%End
void editFormConfigChanged();
%Docstring
Will be emitted whenever the edit form configuration of this layer changes.
.. versionadded:: 3.0
%End
void readOnlyChanged();
%Docstring
Emitted when the read only state of this layer is changed.
Only applies to manually set readonly state, not to the edit mode.
.. versionadded:: 3.0
%End
void symbolFeatureCountMapChanged();
%Docstring
Emitted when the feature count for symbols on this layer has been recalculated.
.. versionadded:: 3.0
%End
protected:
virtual void setExtent( const QgsRectangle &rect );
%Docstring
Set the extent
%End
private: // Private methods
QgsVectorLayer( const QgsVectorLayer &rhs );
};
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgsvectorlayer.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/