QGIS API Documentation 3.41.0-Master (3440c17df1d)
Loading...
Searching...
No Matches
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 bool addFeature (QgsVectorLayer *layer, const QgsAttributeMap &defaultValues=QgsAttributeMap(), const QgsGeometry &defaultGeometry=QgsGeometry(), QgsFeature *feature=nullptr, QWidget *parentWidget=nullptr, bool showModal=true, bool hideParent=false) const
 This method should/will be called, whenever a new feature will be added to the layer.
 
virtual bool addFeatureV2 (QgsVectorLayer *layer, const QgsAttributeMap &defaultValues=QgsAttributeMap(), const QgsGeometry &defaultGeometry=QgsGeometry(), QgsFeature *feature=nullptr, const QgsVectorLayerToolsContext &context=QgsVectorLayerToolsContext()) const
 This method should/will be called, whenever a new feature will be added to the layer.
 
virtual bool copyMoveFeatures (QgsVectorLayer *layer, QgsFeatureRequest &request, double dx=0, double dy=0, QString *errorMsg=nullptr, const bool topologicalEditing=false, QgsVectorLayer *topologicalLayer=nullptr, QString *childrenInfoMsg=nullptr) const
 Copy and move features with defined translation.
 
bool forceSuppressFormPopup () const
 Returns force suppress form popup status.
 
QgsProjectproject () const
 Returns the project to be used by operations when needed.
 
virtual bool saveEdits (QgsVectorLayer *layer) const =0
 Should be called, when the features should be committed but the editing session is not ended.
 
void setForceSuppressFormPopup (bool forceSuppressFormPopup)
 Sets force suppress form popup status to forceSuppressFormPopup.
 
void setProject (QgsProject *project)
 Sets the project to be used by operations when needed.
 
virtual bool startEditing (QgsVectorLayer *layer) const =0
 This will be called, whenever a vector layer should be switched to edit mode.
 
virtual bool stopEditing (QgsVectorLayer *layer, bool allowCancel=true) const =0
 Will be called, when an editing session is ended and the features should be committed.
 

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 42 of file qgsvectorlayertools.h.

Constructor & Destructor Documentation

◆ QgsVectorLayerTools()

QgsVectorLayerTools::QgsVectorLayerTools ( )

Definition at line 26 of file qgsvectorlayertools.cpp.

Member Function Documentation

◆ addFeature()

virtual bool QgsVectorLayerTools::addFeature ( QgsVectorLayer layer,
const QgsAttributeMap defaultValues = QgsAttributeMap(),
const QgsGeometry defaultGeometry = QgsGeometry(),
QgsFeature feature = nullptr,
QWidget *  parentWidget = nullptr,
bool  showModal = true,
bool  hideParent = false 
) const
inlinevirtual

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
parentWidgetThe widget calling this function to be passed to the used dialog
showModalIf the used dialog should be modal or not
hideParentIf the parent widget should be hidden, when the used dialog is opened
Returns
true in case of success, false if the operation failed/was aborted
Note
addFeature or addFeatureV2 must be overwritten when implementing a class inheriting from QgsVectorLayerTools

Definition at line 65 of file qgsvectorlayertools.h.

◆ addFeatureV2()

virtual bool QgsVectorLayerTools::addFeatureV2 ( QgsVectorLayer layer,
const QgsAttributeMap defaultValues = QgsAttributeMap(),
const QgsGeometry defaultGeometry = QgsGeometry(),
QgsFeature feature = nullptr,
const QgsVectorLayerToolsContext context = QgsVectorLayerToolsContext() 
) const
inlinevirtual

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
contextA context object to be used for e.g. to calculate feature expression-based values (since QGIS 3.38)
Returns
true in case of success, false if the operation failed/was aborted
Note
addFeature or addFeatureV2 must be overwritten when implementing a class inheriting from QgsVectorLayerTools
Since
QGIS 3.38

Reimplemented in QgsTrackedVectorLayerTools.

Definition at line 87 of file qgsvectorlayertools.h.

◆ copyMoveFeatures()

bool QgsVectorLayerTools::copyMoveFeatures ( QgsVectorLayer layer,
QgsFeatureRequest request,
double  dx = 0,
double  dy = 0,
QString *  errorMsg = nullptr,
const bool  topologicalEditing = false,
QgsVectorLayer topologicalLayer = nullptr,
QString *  childrenInfoMsg = nullptr 
) const
virtual

Copy and move features with defined translation.

Parameters
layerThe layer
requestThe request for the features to be moved. It will be assigned to a new feature request with the newly copied features.
dxThe translation on x
dyThe translation on y
errorMsgIf given, it will contain the error message
topologicalEditingIf true, the function will perform topological editing of the vertices of layer on layer and topologicalLayer
topologicalLayerThe layer where vertices from the moved features of layer will be added
childrenInfoMsgIf given, it will contain messages related to the creation of child features
Returns
true if all features could be copied.

Reimplemented in QgsTrackedVectorLayerTools.

Definition at line 30 of file qgsvectorlayertools.cpp.

◆ forceSuppressFormPopup()

bool QgsVectorLayerTools::forceSuppressFormPopup ( ) const

Returns force suppress form popup status.

Returns
true if force suppress form popup is set.
Since
QGIS 3.14

Definition at line 155 of file qgsvectorlayertools.cpp.

◆ project()

QgsProject * QgsVectorLayerTools::project ( ) const
inline

Returns the project to be used by operations when needed.

Since
QGIS 3.34

Definition at line 180 of file qgsvectorlayertools.h.

◆ saveEdits()

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

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

Parameters
layerThe layer to commit
Returns
true if successful

Implemented in QgsTrackedVectorLayerTools.

◆ setForceSuppressFormPopup()

void QgsVectorLayerTools::setForceSuppressFormPopup ( bool  forceSuppressFormPopup)

Sets force suppress form popup status to forceSuppressFormPopup.

This flag will override the layer and general settings regarding the automatic opening of the attribute form dialog when digitizing is completed.

Since
QGIS 3.14

Definition at line 160 of file qgsvectorlayertools.cpp.

◆ setProject()

void QgsVectorLayerTools::setProject ( QgsProject project)
inline

Sets the project to be used by operations when needed.

Since
QGIS 3.34

Definition at line 173 of file qgsvectorlayertools.h.

◆ 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

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 committed.

Appropriate dialogs should be shown like

Parameters
layerThe layer to commit
allowCanceltrue if a cancel button should be offered
Returns
true if successful

Implemented in QgsTrackedVectorLayerTools.


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