QGIS API Documentation 4.0.0-Norrköping (1ddcee3d0e4)
Loading...
Searching...
No Matches
qgsvectorlayerundocommand.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectorlayerundocommand.h
3 ---------------------
4 begin : June 2009
5 copyright : (C) 2009 by Martin Dobias
6 email : wonder dot sk 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#ifndef QGSVECTORLAYERUNDOCOMMAND_H
17#define QGSVECTORLAYERUNDOCOMMAND_H
18
19#include "qgis_core.h"
20#include "qgis_sip.h"
21#include "qgsfeature.h"
22#include "qgsfields.h"
23
24#include <QList>
25#include <QSet>
26#include <QUndoCommand>
27#include <QVariant>
28
29class QgsGeometry;
30
32
38
39class CORE_EXPORT QgsVectorLayerUndoCommand : public QUndoCommand
40{
41 public:
49
51 inline QgsVectorLayer *layer() { return mBuffer->L; }
52
53 int id() const override { return -1; }
54 bool mergeWith( const QUndoCommand * ) override { return false; }
55
56 protected:
59};
60
61
67
69{
70 public:
77
78 void undo() override;
79 void redo() override;
80
81 private:
82 QgsFeature mFeature;
83};
84
85
91
93{
94 public:
101
102 void undo() override;
103 void redo() override;
104
105 private:
106 QgsFeatureId mFid;
107 QgsFeature mOldAddedFeature;
108};
109
115
117{
118 public:
126
127 void undo() override;
128 void redo() override;
129 int id() const override { return 1; }
130 bool mergeWith( const QUndoCommand *other ) override;
131
132 private:
133 QgsFeatureId mFid;
134 QgsGeometry mOldGeom;
135 mutable QgsGeometry mNewGeom;
136};
137
138
144
146{
147 public:
156 QgsVectorLayerUndoCommandChangeAttribute( QgsVectorLayerEditBuffer *buffer SIP_TRANSFER, QgsFeatureId fid, int fieldIndex, const QVariant &newValue, const QVariant &oldValue );
157 void undo() override;
158 void redo() override;
159
160 private:
161 QgsFeatureId mFid;
162 int mFieldIndex;
163 QVariant mOldValue;
164 QVariant mNewValue;
165 bool mFirstChange = true;
166};
167
173
175{
176 public:
183
184 void undo() override;
185 void redo() override;
186
187 private:
188 QgsField mField;
189 int mFieldIndex;
190};
191
197
199{
200 public:
207
208 void undo() override;
209 void redo() override;
210
211 private:
212 int mFieldIndex;
213 QString mFieldName;
214 bool mProviderField;
215 int mOriginIndex;
216 QgsField mOldField;
217 QVariantMap mOldEditorWidgetConfig;
218
219 QMap<QgsFeatureId, QVariant> mDeletedValues;
220 QString mOldName;
221};
222
223
229
231{
232 public:
239 QgsVectorLayerUndoCommandRenameAttribute( QgsVectorLayerEditBuffer *buffer SIP_TRANSFER, int fieldIndex, const QString &newName );
240
241 void undo() override;
242 void redo() override;
243
244 private:
245 int mFieldIndex;
246 bool mProviderField;
247 int mOriginIndex;
248 QString mOldName;
249 QString mNewName;
250};
251
252#endif
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:60
Encapsulate a field in an attribute table or data source.
Definition qgsfield.h:56
A geometry is the spatial representation of a feature.
Stores queued vector layer edit operations prior to committing changes to the layer's data provider.
QgsVectorLayerUndoCommandAddAttribute(QgsVectorLayerEditBuffer *buffer, const QgsField &field)
Constructor for QgsVectorLayerUndoCommandAddAttribute.
QgsVectorLayerUndoCommandAddFeature(QgsVectorLayerEditBuffer *buffer, QgsFeature &f)
Constructor for QgsVectorLayerUndoCommandAddFeature.
QgsVectorLayerUndoCommandChangeAttribute(QgsVectorLayerEditBuffer *buffer, QgsFeatureId fid, int fieldIndex, const QVariant &newValue, const QVariant &oldValue)
Constructor for QgsVectorLayerUndoCommandChangeAttribute.
QgsVectorLayerUndoCommandChangeGeometry(QgsVectorLayerEditBuffer *buffer, QgsFeatureId fid, const QgsGeometry &newGeom)
Constructor for QgsVectorLayerUndoCommandChangeGeometry.
QgsVectorLayerUndoCommandDeleteAttribute(QgsVectorLayerEditBuffer *buffer, int fieldIndex)
Constructor for QgsVectorLayerUndoCommandDeleteAttribute.
QgsVectorLayerUndoCommandDeleteFeature(QgsVectorLayerEditBuffer *buffer, QgsFeatureId fid)
Constructor for QgsVectorLayerUndoCommandDeleteFeature.
QgsVectorLayerUndoCommandRenameAttribute(QgsVectorLayerEditBuffer *buffer, int fieldIndex, const QString &newName)
Constructor for QgsVectorLayerUndoCommandRenameAttribute.
QgsVectorLayer * layer()
Returns the layer associated with the undo command.
bool mergeWith(const QUndoCommand *) override
QgsVectorLayerUndoCommand(QgsVectorLayerEditBuffer *buffer)
Constructor for QgsVectorLayerUndoCommand.
QgsVectorLayerEditBuffer * mBuffer
Associated edit buffer.
Represents a vector layer which manages a vector based dataset.
#define SIP_TRANSFER
Definition qgis_sip.h:35
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features