QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
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
17
#include "
qgstrackedvectorlayertools.h
"
18
19
#include "
qgsvectorlayer.h
"
20
#include "
qgsvectorlayertoolscontext.h
"
21
22
#include "moc_qgstrackedvectorlayertools.cpp"
23
24
bool
QgsTrackedVectorLayerTools::addFeatureV2
(
25
QgsVectorLayer
*layer,
const
QgsAttributeMap
&defaultValues,
const
QgsGeometry
&defaultGeometry,
QgsFeature
*feature,
const
QgsVectorLayerToolsContext
&context
26
)
const
27
{
28
QgsFeature
*f = feature;
29
if
( !feature )
30
f =
new
QgsFeature
();
31
32
const_cast<
QgsVectorLayerTools
*
>
( mBackend )->
setForceSuppressFormPopup
(
forceSuppressFormPopup
() );
33
if
( mBackend->addFeatureV2( layer, defaultValues, defaultGeometry, f, context ) )
34
{
35
mAddedFeatures[layer].insert( f->
id
() );
36
if
( !feature )
37
delete
f;
38
return
true
;
39
}
40
else
41
{
42
if
( !feature )
43
delete
f;
44
return
false
;
45
}
46
}
47
48
bool
QgsTrackedVectorLayerTools::startEditing
(
QgsVectorLayer
*layer )
const
49
{
50
return
mBackend->startEditing( layer );
51
}
52
53
bool
QgsTrackedVectorLayerTools::stopEditing
(
QgsVectorLayer
*layer,
bool
allowCancel )
const
54
{
55
return
mBackend->stopEditing( layer, allowCancel );
56
}
57
58
bool
QgsTrackedVectorLayerTools::saveEdits
(
QgsVectorLayer
*layer )
const
59
{
60
return
mBackend->saveEdits( layer );
61
}
62
63
bool
QgsTrackedVectorLayerTools::copyMoveFeatures
(
64
QgsVectorLayer
*layer,
QgsFeatureRequest
&request,
double
dx,
double
dy, QString *errorMsg,
const
bool
topologicalEditing,
QgsVectorLayer
*topologicalLayer, QString *childrenInfoMsg
65
)
const
66
{
67
return
mBackend->copyMoveFeatures( layer, request, dx, dy, errorMsg, topologicalEditing, topologicalLayer, childrenInfoMsg );
68
}
69
70
void
QgsTrackedVectorLayerTools::setVectorLayerTools
(
const
QgsVectorLayerTools
*tools )
71
{
72
mBackend = tools;
73
}
74
75
void
QgsTrackedVectorLayerTools::rollback
()
76
{
77
QMapIterator<QgsVectorLayer *, QgsFeatureIds> it( mAddedFeatures );
78
while
( it.hasNext() )
79
{
80
it.next();
81
it.key()->deleteFeatures( it.value() );
82
}
83
84
mAddedFeatures.clear();
85
}
QgsFeatureRequest
Wraps a request for features to a vector layer (or directly its vector data provider).
Definition
qgsfeaturerequest.h:85
QgsFeature
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition
qgsfeature.h:60
QgsFeature::id
QgsFeatureId id
Definition
qgsfeature.h:63
QgsGeometry
A geometry is the spatial representation of a feature.
Definition
qgsgeometry.h:267
QgsTrackedVectorLayerTools::startEditing
bool startEditing(QgsVectorLayer *layer) const override
This will be called, whenever a vector layer should be switched to edit mode.
Definition
qgstrackedvectorlayertools.cpp:48
QgsTrackedVectorLayerTools::copyMoveFeatures
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.
Definition
qgstrackedvectorlayertools.cpp:63
QgsTrackedVectorLayerTools::addFeatureV2
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.
Definition
qgstrackedvectorlayertools.cpp:24
QgsTrackedVectorLayerTools::setVectorLayerTools
void setVectorLayerTools(const QgsVectorLayerTools *tools)
Set the vector layer tools that will be used to interact with the data.
Definition
qgstrackedvectorlayertools.cpp:70
QgsTrackedVectorLayerTools::rollback
void rollback()
Delete all features which have been added via this object.
Definition
qgstrackedvectorlayertools.cpp:75
QgsTrackedVectorLayerTools::stopEditing
bool stopEditing(QgsVectorLayer *layer, bool allowCancel) const override
Will be called, when an editing session is ended and the features should be committed.
Definition
qgstrackedvectorlayertools.cpp:53
QgsTrackedVectorLayerTools::saveEdits
bool saveEdits(QgsVectorLayer *layer) const override
Should be called, when the features should be committed but the editing session is not ended.
Definition
qgstrackedvectorlayertools.cpp:58
QgsVectorLayerToolsContext
Contains settings which reflect the context in which vector layer tool operations should be considere...
Definition
qgsvectorlayertoolscontext.h:32
QgsVectorLayerTools::forceSuppressFormPopup
bool forceSuppressFormPopup() const
Returns force suppress form popup status.
Definition
qgsvectorlayertools.cpp:162
QgsVectorLayerTools::QgsVectorLayerTools
QgsVectorLayerTools()
Definition
qgsvectorlayertools.cpp:31
QgsVectorLayerTools::setForceSuppressFormPopup
void setForceSuppressFormPopup(bool forceSuppressFormPopup)
Sets force suppress form popup status to forceSuppressFormPopup.
Definition
qgsvectorlayertools.cpp:167
QgsVectorLayer
Represents a vector layer which manages a vector based dataset.
Definition
qgsvectorlayer.h:414
QgsAttributeMap
QMap< int, QVariant > QgsAttributeMap
Definition
qgsattributes.h:40
qgstrackedvectorlayertools.h
qgsvectorlayer.h
qgsvectorlayertoolscontext.h
Generated on
for QGIS API Documentation by
1.17.0