QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
Public Member Functions | List of all members
QgsVectorLayerTools Class Referenceabstract

Methods in this class are used to handle basic operations on vector layers. More...

#include <qgsvectorlayertools.h>

Inheritance diagram for QgsVectorLayerTools:
Inheritance graph
[legend]

Public Member Functions

 QgsVectorLayerTools ()
 
virtual ~QgsVectorLayerTools ()
 
virtual bool addFeature (QgsVectorLayer *layer, const QgsAttributeMap &defaultValues=QgsAttributeMap(), const QgsGeometry &defaultGeometry=QgsGeometry(), QgsFeature *feature=nullptr) const =0
 This method should/will be called, whenever a new feature will be added to the layer. More...
 
virtual bool saveEdits (QgsVectorLayer *layer) const =0
 Should be called, when the features should be commited but the editing session is not ended. More...
 
virtual bool startEditing (QgsVectorLayer *layer) const =0
 This will be called, whenever a vector layer should be switched to edit mode. More...
 
virtual bool stopEditing (QgsVectorLayer *layer, bool allowCancel=true) const =0
 Will be called, when an editing session is ended and the features should be commited. More...
 

Detailed Description

Methods in this class are used to handle basic operations on vector layers.

With an implementation of this class, parts of the application can ask for an operation to be done and the implementation will then take care of it.

Reimplement this class, if you need to have custom checks or GUI elements in your application.

Definition at line 33 of file qgsvectorlayertools.h.

Constructor & Destructor Documentation

◆ QgsVectorLayerTools()

QgsVectorLayerTools::QgsVectorLayerTools ( )
inline

Definition at line 36 of file qgsvectorlayertools.h.

◆ ~QgsVectorLayerTools()

virtual QgsVectorLayerTools::~QgsVectorLayerTools ( )
inlinevirtual

Definition at line 38 of file qgsvectorlayertools.h.

Member Function Documentation

◆ addFeature()

virtual bool QgsVectorLayerTools::addFeature ( QgsVectorLayer layer,
const QgsAttributeMap defaultValues = QgsAttributeMap(),
const QgsGeometry defaultGeometry = QgsGeometry(),
QgsFeature feature = nullptr 
) const
pure virtual

This method should/will be called, whenever a new feature will be added to the layer.

Parameters
layerThe layer to which the feature should be added
defaultValuesDefault values for the feature to add
defaultGeometryA default geometry to add to the feature
featureUpdated feature after adding will be written back to this
Returns
True in case of success, False if the operation failed/was aborted

TODO QGIS 3: remove const qualifier

Implemented in QgsTrackedVectorLayerTools.

◆ saveEdits()

virtual bool QgsVectorLayerTools::saveEdits ( QgsVectorLayer layer) const
pure virtual

Should be called, when the features should be commited but the editing session is not ended.

Parameters
layerThe layer to commit
Returns
True if successful

TODO QGIS 3: remove const qualifier

Implemented in QgsTrackedVectorLayerTools.

◆ startEditing()

virtual bool QgsVectorLayerTools::startEditing ( QgsVectorLayer layer) const
pure virtual

This will be called, whenever a vector layer should be switched to edit mode.

Check the providers capability to edit in here. If successful layer->startEditing() will be called and true returned.

Parameters
layerThe layer on which to start an edit session
Returns
True, if the editing session was started

TODO QGIS 3: remove const qualifier

Implemented in QgsTrackedVectorLayerTools.

◆ stopEditing()

virtual bool QgsVectorLayerTools::stopEditing ( QgsVectorLayer layer,
bool  allowCancel = true 
) const
pure virtual

Will be called, when an editing session is ended and the features should be commited.

Appropriate dialogs should be shown like

Parameters
layerThe layer to commit
allowCancelTrue if a cancel button should be offered
Returns
True if successful

TODO QGIS 3: remove const qualifier

Implemented in QgsTrackedVectorLayerTools.


The documentation for this class was generated from the following file: