QGIS API Documentation  3.14.0-Pi (9f7028fd23)
qgsvectorlayereditpassthrough.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgsvectorlayereditpassthrough.h
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 #ifndef QGSVECTORLAYEREDITPASSTHROUGH_H
16 #define QGSVECTORLAYEREDITPASSTHROUGH_H
17 
18 #include "qgis_core.h"
20 
21 class QgsVectorLayer;
23 class QgsTransaction;
24 
25 #ifdef SIP_RUN
26 % ModuleHeaderCode
28 % End
29 #endif
30 
36 {
37 
38 #ifdef SIP_RUN
40  if ( qobject_cast<QgsVectorLayerEditPassthrough *>( sipCpp ) )
41  sipType = sipType_QgsVectorLayerEditPassthrough;
42  else
43  sipType = nullptr;
44  SIP_END
45 #endif
46 
47  Q_OBJECT
48  public:
50  bool isModified() const override;
51  bool addFeature( QgsFeature &f ) override;
52  bool addFeatures( QgsFeatureList &features ) override;
53  bool deleteFeature( QgsFeatureId fid ) override;
54  bool deleteFeatures( const QgsFeatureIds &fids ) override;
55  bool changeGeometry( QgsFeatureId fid, const QgsGeometry &geom ) override;
56  bool changeAttributeValue( QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue = QVariant() ) override;
57 
63  bool changeAttributeValues( QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues ) override;
64 
65  bool addAttribute( const QgsField &field ) override;
66  bool deleteAttribute( int attr ) override;
67  bool renameAttribute( int attr, const QString &newName ) override;
68  bool commitChanges( QStringList &commitErrors ) override;
69  void rollBack() override;
70 
82  bool update( QgsTransaction *transaction, const QString &sql, const QString &name );
83 
84  private:
85  bool mModified;
86 
87  // utility function to avoid cpy/paste
88  bool modify( QgsVectorLayerUndoPassthroughCommand *cmd );
89 
90 };
91 
92 #endif // QGSVECTORLAYEREDITPASSTHROUGH_H
QgsVectorLayerEditBuffer::isModified
virtual bool isModified() const
Returns true if the provider has been modified since the last commit.
Definition: qgsvectorlayereditbuffer.cpp:46
QgsVectorLayerEditBuffer::addAttribute
virtual bool addAttribute(const QgsField &field)
Add an attribute field (but does not commit it) returns true if the field was added.
Definition: qgsvectorlayereditbuffer.cpp:260
QgsVectorLayerEditBuffer::addFeature
virtual bool addFeature(QgsFeature &f)
Adds a feature.
Definition: qgsvectorlayereditbuffer.cpp:117
QgsTransaction
Definition: qgstransaction.h:56
QgsVectorLayerUndoPassthroughCommand
Undo command for vector layer in transaction group mode.
Definition: qgsvectorlayerundopassthroughcommand.h:33
QgsVectorLayerEditBuffer::deleteAttribute
virtual bool deleteAttribute(int attr)
Delete an attribute field (but does not commit it)
Definition: qgsvectorlayereditbuffer.cpp:283
QgsVectorLayerEditBuffer::changeGeometry
virtual bool changeGeometry(QgsFeatureId fid, const QgsGeometry &geom)
Change feature's geometry.
Definition: qgsvectorlayereditbuffer.cpp:199
SIP_CONVERT_TO_SUBCLASS_CODE
#define SIP_CONVERT_TO_SUBCLASS_CODE(code)
Definition: qgis_sip.h:172
QgsVectorLayerEditBuffer::deleteFeature
virtual bool deleteFeature(QgsFeatureId fid)
Delete a feature from the layer (but does not commit it)
Definition: qgsvectorlayereditbuffer.cpp:153
QgsFeatureList
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:572
QgsAttributeMap
QMap< int, QVariant > QgsAttributeMap
Definition: qgsattributes.h:38
QgsVectorLayerEditBuffer::rollBack
virtual void rollBack()
Stop editing and discard the edits.
Definition: qgsvectorlayereditbuffer.cpp:702
QgsVectorLayerEditBuffer::renameAttribute
virtual bool renameAttribute(int attr, const QString &newName)
Renames an attribute field (but does not commit it)
Definition: qgsvectorlayereditbuffer.cpp:305
QgsFeatureIds
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:34
QgsVectorLayerEditPassthrough
Definition: qgsvectorlayereditpassthrough.h:35
QgsGeometry
Definition: qgsgeometry.h:122
QgsVectorLayerEditBuffer
Definition: qgsvectorlayereditbuffer.h:36
QgsVectorLayer
Definition: qgsvectorlayer.h:385
QgsVectorLayerEditBuffer::changeAttributeValue
virtual bool changeAttributeValue(QgsFeatureId fid, int field, const QVariant &newValue, const QVariant &oldValue=QVariant())
Changed an attribute value (but does not commit it)
Definition: qgsvectorlayereditbuffer.cpp:238
QgsVectorLayerEditBuffer::commitChanges
virtual bool commitChanges(QStringList &commitErrors)
Attempts to commit any changes to disk.
Definition: qgsvectorlayereditbuffer.cpp:328
QgsFeature
Definition: qgsfeature.h:55
QgsVectorLayerEditBuffer::deleteFeatures
virtual bool deleteFeatures(const QgsFeatureIds &fid)
Deletes a set of features from the layer (but does not commit it)
Definition: qgsvectorlayereditbuffer.cpp:182
SIP_END
#define SIP_END
Definition: qgis_sip.h:189
QgsVectorLayerEditBuffer::changeAttributeValues
virtual bool changeAttributeValues(QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues)
Changes values of attributes (but does not commit it).
Definition: qgsvectorlayereditbuffer.cpp:220
qgsvectorlayereditbuffer.h
QgsVectorLayerEditBuffer::addFeatures
virtual bool addFeatures(QgsFeatureList &features)
Insert a copy of the given features into the layer (but does not commit it)
Definition: qgsvectorlayereditbuffer.cpp:136
qgsvectorlayereditpassthrough.h
QgsFeatureId
qint64 QgsFeatureId
Definition: qgsfeatureid.h:25
QgsField
Definition: qgsfield.h:49