QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
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"
22#include "qgsfeature.h"
23#include "qgsgeometry.h"
25
26#include <QObject>
27
29class QgsVectorLayer;
30class QgsProject;
31
43class CORE_EXPORT QgsVectorLayerTools : public QObject
44{
45 Q_OBJECT
46
47 public:
49
50 // TODO QGIS 5: remove const qualifier
51
66 virtual bool addFeature(
67 QgsVectorLayer *layer,
68 const QgsAttributeMap &defaultValues = QgsAttributeMap(),
69 const QgsGeometry &defaultGeometry = QgsGeometry(),
70 QgsFeature *feature SIP_OUT = nullptr,
71 QWidget *parentWidget = nullptr,
72 bool showModal = true,
73 bool hideParent = false
74 ) const
75 {
77 context.setParentWidget( parentWidget );
78 context.setShowModal( showModal );
79 context.setHideParent( hideParent );
80 return addFeatureV2( layer, defaultValues, defaultGeometry, feature, context );
81 }
82
96 virtual bool addFeatureV2(
97 QgsVectorLayer *layer,
98 const QgsAttributeMap &defaultValues = QgsAttributeMap(),
99 const QgsGeometry &defaultGeometry = QgsGeometry(),
100 QgsFeature *feature SIP_OUT = nullptr,
102 ) const
103 {
104 Q_UNUSED( context )
105 return addFeature( layer, defaultValues, defaultGeometry, feature, context.parentWidget(), context.showModal(), context.hideParent() );
106 }
107
108 // TODO QGIS 5: remove const qualifier
109
120 virtual bool startEditing( QgsVectorLayer *layer ) const = 0;
121
122 // TODO QGIS 5: remove const qualifier
123
133 virtual bool stopEditing( QgsVectorLayer *layer, bool allowCancel = true ) const = 0;
134
135 // TODO QGIS 5: remove const qualifier
136
144 virtual bool saveEdits( QgsVectorLayer *layer ) const = 0;
145
146 // TODO QGIS 5: remove const qualifier
147
163 virtual bool copyMoveFeatures(
164 QgsVectorLayer *layer,
166 double dx = 0,
167 double dy = 0,
168 QString *errorMsg SIP_OUT = nullptr,
169 const bool topologicalEditing = false,
170 QgsVectorLayer *topologicalLayer = nullptr,
171 QString *childrenInfoMsg = nullptr
172 ) const;
173
180 bool forceSuppressFormPopup() const;
181
191
197 void setProject( QgsProject *project ) { mProject = project; }
198
204 QgsProject *project() const { return mProject; }
205
206 private:
207 QgsProject *mProject = nullptr;
208 bool mForceSuppressFormPopup { false };
209};
210
211#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:60
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:113
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.
bool forceSuppressFormPopup() const
Returns force suppress form popup status.
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 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.
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.
void setForceSuppressFormPopup(bool forceSuppressFormPopup)
Sets force suppress form popup status to forceSuppressFormPopup.
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:57
#define SIP_INOUT
Definition qgis_sip.h:78
QMap< int, QVariant > QgsAttributeMap