QGIS API Documentation 3.43.0-Master (b60ef06885e)
qgsvectorlayertools.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectorlayertools.h
3 --------------------------------------
4 Date : 29.5.2013
5 Copyright : (C) 2013 Matthias Kuhn
6 Email : matthias at opengis dot ch
7 ***************************************************************************
8 * *
9 * This program is free software; you can redistribute it and/or modify *
10 * it under the terms of the GNU General Public License as published by *
11 * the Free Software Foundation; either version 2 of the License, or *
12 * (at your option) any later version. *
13 * *
14 ***************************************************************************/
15
16#ifndef QGSVECTORLAYERTOOLS_H
17#define QGSVECTORLAYERTOOLS_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21#include <QObject>
22
24#include "qgsfeature.h"
25#include "qgsgeometry.h"
27
29class QgsVectorLayer;
30class QgsProject;
31
43class CORE_EXPORT QgsVectorLayerTools : public QObject
44{
45 Q_OBJECT
46
47 public:
49
50 // TODO QGIS 4: remove const qualifier
51
66 virtual bool addFeature( QgsVectorLayer *layer, const QgsAttributeMap &defaultValues = QgsAttributeMap(), const QgsGeometry &defaultGeometry = QgsGeometry(), QgsFeature *feature SIP_OUT = nullptr, QWidget *parentWidget = nullptr, bool showModal = true, bool hideParent = false ) const
67 {
69 context.setParentWidget( parentWidget );
70 context.setShowModal( showModal );
71 context.setHideParent( hideParent );
72 return addFeatureV2( layer, defaultValues, defaultGeometry, feature, context );
73 }
74
88 virtual bool addFeatureV2( QgsVectorLayer *layer, const QgsAttributeMap &defaultValues = QgsAttributeMap(), const QgsGeometry &defaultGeometry = QgsGeometry(), QgsFeature *feature SIP_OUT = nullptr, const QgsVectorLayerToolsContext &context = QgsVectorLayerToolsContext() ) const
89 {
90 Q_UNUSED( context )
91 return addFeature( layer, defaultValues, defaultGeometry, feature, context.parentWidget(), context.showModal(), context.hideParent() );
92 }
93
94 // TODO QGIS 4: remove const qualifier
95
106 virtual bool startEditing( QgsVectorLayer *layer ) const = 0;
107
108 // TODO QGIS 4: remove const qualifier
109
119 virtual bool stopEditing( QgsVectorLayer *layer, bool allowCancel = true ) const = 0;
120
121 // TODO QGIS 4: remove const qualifier
122
130 virtual bool saveEdits( QgsVectorLayer *layer ) const = 0;
131
132 // TODO QGIS 4: remove const qualifier
133
149 virtual bool copyMoveFeatures( QgsVectorLayer *layer, QgsFeatureRequest &request SIP_INOUT, double dx = 0, double dy = 0, QString *errorMsg SIP_OUT = nullptr, const bool topologicalEditing = false, QgsVectorLayer *topologicalLayer = nullptr, QString *childrenInfoMsg = nullptr ) const;
150
157 bool forceSuppressFormPopup() const;
158
167 void setForceSuppressFormPopup( bool forceSuppressFormPopup );
168
174 void setProject( QgsProject *project ) { mProject = project; }
175
181 QgsProject *project() const { return mProject; }
182
183 private:
184
185 QgsProject *mProject = nullptr;
186 bool mForceSuppressFormPopup { false };
187
188
189};
190
191#endif // QGSVECTORLAYERTOOLS_H
Wraps a request for features to a vector layer (or directly its vector data provider).
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
A geometry is the spatial representation of a feature.
Encapsulates a QGIS project, including sets of map layers and their styles, layouts,...
Definition qgsproject.h:107
Contains settings which reflect the context in which vector layer tool operations should be considere...
void setParentWidget(QWidget *parent)
Sets the widget which should be parented to tools' dialogues.
void setHideParent(bool hide)
Sets whether the parent widget should be hidden when showing tools' dialogues.
void setShowModal(bool modal)
Sets whether tools' dialogues should be modal.
Used to handle basic editing operations on vector layers.
virtual bool startEditing(QgsVectorLayer *layer) const =0
This will be called, whenever a vector layer should be switched to edit mode.
virtual bool saveEdits(QgsVectorLayer *layer) const =0
Should be called, when the features should be committed but the editing session is not ended.
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.
QgsProject * project() const
Returns the project to be used by operations when needed.
void setProject(QgsProject *project)
Sets the project to be used by operations when needed.
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.
Represents a vector layer which manages a vector based dataset.
#define SIP_OUT
Definition qgis_sip.h:58
#define SIP_INOUT
Definition qgis_sip.h:71
QMap< int, QVariant > QgsAttributeMap