QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
qgstrackedvectorlayertools.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgstrackedvectorlayertools.cpp - QgsTrackedVectorLayerTools
3
4 ---------------------
5 begin : 16.5.2016
6 copyright : (C) 2016 by Matthias Kuhn, OPENGIS.ch
7 email : matthias@opengis.ch
8 ***************************************************************************
9 * *
10 * This program is free software; you can redistribute it and/or modify *
11 * it under the terms of the GNU General Public License as published by *
12 * the Free Software Foundation; either version 2 of the License, or *
13 * (at your option) any later version. *
14 * *
15 ***************************************************************************/
16
18#include "moc_qgstrackedvectorlayertools.cpp"
19#include "qgsvectorlayer.h"
21
22
23bool QgsTrackedVectorLayerTools::addFeatureV2( QgsVectorLayer *layer, const QgsAttributeMap &defaultValues, const QgsGeometry &defaultGeometry, QgsFeature *feature, const QgsVectorLayerToolsContext &context ) const
24{
25 QgsFeature *f = feature;
26 if ( !feature )
27 f = new QgsFeature();
28
30 if ( mBackend->addFeatureV2( layer, defaultValues, defaultGeometry, f, context ) )
31 {
32 mAddedFeatures[layer].insert( f->id() );
33 if ( !feature )
34 delete f;
35 return true;
36 }
37 else
38 {
39 if ( !feature )
40 delete f;
41 return false;
42 }
43}
44
46{
47 return mBackend->startEditing( layer );
48}
49
50bool QgsTrackedVectorLayerTools::stopEditing( QgsVectorLayer *layer, bool allowCancel ) const
51{
52 return mBackend->stopEditing( layer, allowCancel );
53}
54
56{
57 return mBackend->saveEdits( layer );
58}
59
60bool QgsTrackedVectorLayerTools::copyMoveFeatures( QgsVectorLayer *layer, QgsFeatureRequest &request, double dx, double dy, QString *errorMsg, const bool topologicalEditing, QgsVectorLayer *topologicalLayer, QString *childrenInfoMsg ) const
61{
62 return mBackend->copyMoveFeatures( layer, request, dx, dy, errorMsg, topologicalEditing, topologicalLayer, childrenInfoMsg );
63}
64
66{
67 mBackend = tools;
68}
69
71{
72 QMapIterator<QgsVectorLayer *, QgsFeatureIds> it( mAddedFeatures );
73 while ( it.hasNext() )
74 {
75 it.next();
76 it.key()->deleteFeatures( it.value() );
77 }
78
79 mAddedFeatures.clear();
80}
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
QgsFeatureId id
Definition qgsfeature.h:66
A geometry is the spatial representation of a feature.
bool startEditing(QgsVectorLayer *layer) const override
This will be called, whenever a vector layer should be switched to edit mode.
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 override
Copy and move features with defined translation.
bool addFeatureV2(QgsVectorLayer *layer, const QgsAttributeMap &defaultValues, const QgsGeometry &defaultGeometry, QgsFeature *feature, const QgsVectorLayerToolsContext &context) const override
This method calls the addFeature method of the backend QgsVectorLayerTools.
void setVectorLayerTools(const QgsVectorLayerTools *tools)
Set the vector layer tools that will be used to interact with the data.
void rollback()
Delete all features which have been added via this object.
bool stopEditing(QgsVectorLayer *layer, bool allowCancel) const override
Will be called, when an editing session is ended and the features should be committed.
bool saveEdits(QgsVectorLayer *layer) const override
Should be called, when the features should be committed but the editing session is not ended.
Contains settings which reflect the context in which vector layer tool operations should consider.
Methods in this class are used to handle basic operations on vector layers.
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 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.
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.
QMap< int, QVariant > QgsAttributeMap