QGIS API Documentation  3.2.0-Bonn (bc43194)
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.h"
21 #include <QUndoCommand>
22 
23 #include <QVariant>
24 #include <QSet>
25 #include <QList>
26 
27 #include "qgsfields.h"
28 #include "qgsfeature.h"
29 
30 class QgsGeometry;
31 
32 #include "qgsvectorlayer.h"
34 
41 class CORE_EXPORT QgsVectorLayerUndoCommand : public QUndoCommand
42 {
43  public:
44 
50  : mBuffer( buffer )
51  {}
52 
54  inline QgsVectorLayer *layer() { return mBuffer->L; }
55 
56  int id() const override { return -1; }
57  bool mergeWith( const QUndoCommand * ) override { return false; }
58 
59  protected:
61  QgsVectorLayerEditBuffer *mBuffer = nullptr;
62 };
63 
64 
72 {
73  public:
74 
81 
82  void undo() override;
83  void redo() override;
84 
85  private:
86  QgsFeature mFeature;
87 };
88 
89 
97 {
98  public:
99 
106 
107  void undo() override;
108  void redo() override;
109 
110  private:
111  QgsFeatureId mFid;
112  QgsFeature mOldAddedFeature;
113 };
114 
122 {
123  public:
124 
132 
133  void undo() override;
134  void redo() override;
135  int id() const override;
136  bool mergeWith( const QUndoCommand * ) override;
137 
138  private:
139  QgsFeatureId mFid;
140  QgsGeometry mOldGeom;
141  mutable QgsGeometry mNewGeom;
142 };
143 
144 
152 {
153  public:
154 
163  QgsVectorLayerUndoCommandChangeAttribute( QgsVectorLayerEditBuffer *buffer SIP_TRANSFER, QgsFeatureId fid, int fieldIndex, const QVariant &newValue, const QVariant &oldValue );
164  void undo() override;
165  void redo() override;
166 
167  private:
168  QgsFeatureId mFid;
169  int mFieldIndex;
170  QVariant mOldValue;
171  QVariant mNewValue;
172  bool mFirstChange;
173 };
174 
182 {
183  public:
184 
191 
192  void undo() override;
193  void redo() override;
194 
195  private:
196  QgsField mField;
197  int mFieldIndex;
198 };
199 
207 {
208  public:
209 
216 
217  void undo() override;
218  void redo() override;
219 
220  private:
221  int mFieldIndex;
222  QString mFieldName;
223  bool mProviderField;
224  int mOriginIndex;
225  QgsField mOldField;
226  QVariantMap mOldEditorWidgetConfig;
227 
228  QMap<QgsFeatureId, QVariant> mDeletedValues;
229  QString mOldName;
230 };
231 
232 
241 {
242  public:
243 
250  QgsVectorLayerUndoCommandRenameAttribute( QgsVectorLayerEditBuffer *buffer SIP_TRANSFER, int fieldIndex, const QString &newName );
251 
252  void undo() override;
253  void redo() override;
254 
255  private:
256  int mFieldIndex;
257  QString mOldName;
258  QString mNewName;
259 };
260 
261 #endif
Undo command for removing an existing attribute from a vector layer.
Undo command for deleting a feature from a vector layer.
Base class for undo commands within a QgsVectorLayerEditBuffer.
Undo command for modifying an attribute of a feature from a vector layer.
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:104
The feature class encapsulates a single feature including its id, geometry and a list of field/values...
Definition: qgsfeature.h:62
Undo command for adding a feature to a vector layer.
Undo command for modifying the geometry of a feature from a vector layer.
bool mergeWith(const QUndoCommand *) override
QgsVectorLayer * layer()
Returns the layer associated with the undo command.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
Undo command for renaming an existing attribute of a vector layer.
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:48
Undo command for adding a new attribute to a vector layer.
QgsVectorLayerUndoCommand(QgsVectorLayerEditBuffer *buffer)
Constructor for QgsVectorLayerUndoCommand.
qint64 QgsFeatureId
Definition: qgsfeature.h:37
Represents a vector layer which manages a vector based data sets.