QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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:
42
50
52 inline QgsVectorLayer *layer() { return mBuffer->L; }
53
54 int id() const override { return -1; }
55 bool mergeWith( const QUndoCommand * ) override { return false; }
56
57 protected:
60};
61
62
68
70{
71 public:
72
79
80 void undo() override;
81 void redo() override;
82
83 private:
84 QgsFeature mFeature;
85};
86
87
93
95{
96 public:
97
104
105 void undo() override;
106 void redo() override;
107
108 private:
109 QgsFeatureId mFid;
110 QgsFeature mOldAddedFeature;
111};
112
118
120{
121 public:
122
130
131 void undo() override;
132 void redo() override;
133 int id() const override { return 1; }
134 bool mergeWith( const QUndoCommand *other ) override;
135
136 private:
137 QgsFeatureId mFid;
138 QgsGeometry mOldGeom;
139 mutable QgsGeometry mNewGeom;
140};
141
142
148
150{
151 public:
152
161 QgsVectorLayerUndoCommandChangeAttribute( QgsVectorLayerEditBuffer *buffer SIP_TRANSFER, QgsFeatureId fid, int fieldIndex, const QVariant &newValue, const QVariant &oldValue );
162 void undo() override;
163 void redo() override;
164
165 private:
166 QgsFeatureId mFid;
167 int mFieldIndex;
168 QVariant mOldValue;
169 QVariant mNewValue;
170 bool mFirstChange = true;
171};
172
178
180{
181 public:
182
189
190 void undo() override;
191 void redo() override;
192
193 private:
194 QgsField mField;
195 int mFieldIndex;
196};
197
203
205{
206 public:
207
214
215 void undo() override;
216 void redo() override;
217
218 private:
219 int mFieldIndex;
220 QString mFieldName;
221 bool mProviderField;
222 int mOriginIndex;
223 QgsField mOldField;
224 QVariantMap mOldEditorWidgetConfig;
225
226 QMap<QgsFeatureId, QVariant> mDeletedValues;
227 QString mOldName;
228};
229
230
236
238{
239 public:
240
247 QgsVectorLayerUndoCommandRenameAttribute( QgsVectorLayerEditBuffer *buffer SIP_TRANSFER, int fieldIndex, const QString &newName );
248
249 void undo() override;
250 void redo() override;
251
252 private:
253 int mFieldIndex;
254 bool mProviderField;
255 int mOriginIndex;
256 QString mOldName;
257 QString mNewName;
258};
259
260#endif
The feature class encapsulates a single feature including its unique ID, geometry and a list of field...
Definition qgsfeature.h:58
Encapsulate a field in an attribute table or data source.
Definition qgsfield.h:54
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:36
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features