QGIS API Documentation
2.8.2-Wien
Main Page
Related Pages
Modules
Namespaces
Classes
Files
File List
File Members
•
All
Classes
Namespaces
Files
Functions
Variables
Typedefs
Enumerations
Enumerator
Properties
Friends
Macros
Groups
Pages
src
core
qgsvectorlayereditpassthrough.cpp
Go to the documentation of this file.
1
/***************************************************************************
2
qgsvectorlayereditpassthrough.cpp
3
---------------------
4
begin : Jan 12 2015
5
copyright : (C) 2015 by Sandro Mani
6
email : manisandro at gmail dot com
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
#include "
qgsvectorlayereditpassthrough.h
"
17
#include "
qgsvectorlayer.h
"
18
#include "
qgsvectordataprovider.h
"
19
20
bool
QgsVectorLayerEditPassthrough::addFeature
(
QgsFeature
& f )
21
{
22
23
if
(
L
->
dataProvider
()->
addFeatures
(
QgsFeatureList
() << f ) )
24
{
25
emit
featureAdded
( f.
id
() );
26
return
true
;
27
}
28
return
false
;
29
}
30
31
bool
QgsVectorLayerEditPassthrough::addFeatures
(
QgsFeatureList
& features )
32
{
33
if
(
L
->
dataProvider
()->
addFeatures
( features ) )
34
{
35
foreach
(
const
QgsFeature
& f, features )
36
{
37
emit
featureAdded
( f.
id
() );
38
}
39
return
true
;
40
}
41
return
false
;
42
}
43
44
bool
QgsVectorLayerEditPassthrough::deleteFeature
(
QgsFeatureId
fid )
45
{
46
if
(
L
->
dataProvider
()->
deleteFeatures
(
QgsFeatureIds
() << fid ) )
47
{
48
emit
featureDeleted
( fid );
49
return
true
;
50
}
51
return
false
;
52
}
53
54
bool
QgsVectorLayerEditPassthrough::changeGeometry
(
QgsFeatureId
fid,
QgsGeometry
* geom )
55
{
56
QgsGeometryMap
geomMap;
57
geomMap.insert( fid, *geom );
58
if
(
L
->
dataProvider
()->
changeGeometryValues
( geomMap ) )
59
{
60
emit
geometryChanged
( fid, *geom );
61
return
true
;
62
}
63
return
false
;
64
}
65
66
bool
QgsVectorLayerEditPassthrough::changeAttributeValue
(
QgsFeatureId
fid,
int
field,
const
QVariant &newValue,
const
QVariant &
/*oldValue*/
)
67
{
68
QgsAttributeMap
map;
69
map.insert( field, newValue );
70
QgsChangedAttributesMap
attribMap;
71
attribMap.insert( fid, map );
72
if
(
L
->
dataProvider
()->
changeAttributeValues
( attribMap ) )
73
{
74
emit
attributeValueChanged
( fid, field, newValue );
75
return
true
;
76
}
77
return
false
;
78
}
79
80
bool
QgsVectorLayerEditPassthrough::addAttribute
(
const
QgsField
&field )
81
{
82
if
(
L
->
dataProvider
()->
addAttributes
( QList<QgsField>() << field ) )
83
{
84
emit
attributeAdded
(
L
->
dataProvider
()->
fieldNameIndex
( field.
name
() ) );
85
return
true
;
86
}
87
return
false
;
88
}
89
90
bool
QgsVectorLayerEditPassthrough::deleteAttribute
(
int
attr )
91
{
92
if
(
L
->
dataProvider
()->
deleteAttributes
(
QgsAttributeIds
() << attr ) )
93
{
94
emit
attributeDeleted
( attr );
95
return
true
;
96
}
97
return
false
;
98
}
99
100
bool
QgsVectorLayerEditPassthrough::commitChanges
( QStringList&
/*commitErrors*/
)
101
{
102
return
true
;
103
}
104
105
void
QgsVectorLayerEditPassthrough::rollBack
()
106
{
107
}
Generated on Sun May 10 2015 16:33:25 for QGIS API Documentation by
1.8.1.2