QGIS API Documentation 3.39.0-Master (47f7b3a4989)
Loading...
Searching...
No Matches
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
42class CORE_EXPORT QgsVectorLayerTools : public QObject
43{
44 Q_OBJECT
45
46 public:
48
49 // TODO QGIS 4: remove const qualifier
50
65 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
66 {
68 context.setParentWidget( parentWidget );
69 context.setShowModal( showModal );
70 context.setHideParent( hideParent );
71 return addFeatureV2( layer, defaultValues, defaultGeometry, feature, context );
72 }
73
87 virtual bool addFeatureV2( QgsVectorLayer *layer, const QgsAttributeMap &defaultValues = QgsAttributeMap(), const QgsGeometry &defaultGeometry = QgsGeometry(), QgsFeature *feature SIP_OUT = nullptr, const QgsVectorLayerToolsContext &context = QgsVectorLayerToolsContext() ) const
88 {
89 Q_UNUSED( context )
90 return addFeature( layer, defaultValues, defaultGeometry, feature, context.parentWidget(), context.showModal(), context.hideParent() );
91 }
92
93 // TODO QGIS 4: remove const qualifier
94
105 virtual bool startEditing( QgsVectorLayer *layer ) const = 0;
106
107 // TODO QGIS 4: remove const qualifier
108
118 virtual bool stopEditing( QgsVectorLayer *layer, bool allowCancel = true ) const = 0;
119
120 // TODO QGIS 4: remove const qualifier
121
129 virtual bool saveEdits( QgsVectorLayer *layer ) const = 0;
130
131 // TODO QGIS 4: remove const qualifier
132
148 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;
149
156 bool forceSuppressFormPopup() const;
157
166 void setForceSuppressFormPopup( bool forceSuppressFormPopup );
167
173 void setProject( QgsProject *project ) { mProject = project; }
174
180 QgsProject *project() const { return mProject; }
181
182 private:
183
184 QgsProject *mProject = nullptr;
185 bool mForceSuppressFormPopup { false };
186
187
188};
189
190#endif // QGSVECTORLAYERTOOLS_H
This class 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 consider.
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.
Methods in this class are used to handle basic 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 data sets.
#define SIP_OUT
Definition qgis_sip.h:58
#define SIP_INOUT
Definition qgis_sip.h:71
QMap< int, QVariant > QgsAttributeMap