QGIS API Documentation 3.37.0-Master (fdefdf9c27f)
qgsvectorlayerundopassthroughcommand.h
Go to the documentation of this file.
1/***************************************************************************
2 qgsvectorlayerundopassthroughcommand.h
3 ---------------------
4 begin : June 2017
5 copyright : (C) 2017 by Vincent Mora
6 email : vincent dot mora at osalndia 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 QGSVECTORLAYERUNDOPASSTHROUGHCOMMAND_H
17#define QGSVECTORLAYERUNDOPASSTHROUGHCOMMAND_H
18
20
22
23class QgsTransaction;
24
33{
34 public:
35
42 QgsVectorLayerUndoPassthroughCommand( QgsVectorLayerEditBuffer *buffer, const QString &text, bool autocreate = true );
43
47 bool hasError() const { return mHasError; }
48
49 protected:
50
56 bool rollBackToSavePoint();
57
64 bool setSavePoint( const QString &savePointId = QString() );
65
69 void setError();
70
75 void setErrorMessage( const QString &errorMessage );
76
81 QString errorMessage() const;
82
83 private:
84 QString mError;
85 QString mSavePointId;
86 bool mHasError;
87 bool mRecreateSavePoint;
88};
89
97{
98 public:
99
106
107 void undo() override;
108 void redo() override;
109
113 QgsFeatureList features() const { return mFeatures; }
114
115 private:
116 QgsFeatureList mFeatures;
117 QgsFeatureList mInitialFeatures;
118};
119
120
128{
129 public:
130
137
138 void undo() override;
139 void redo() override;
140
141 private:
142 const QgsFeatureIds mFids;
143 // Keeps track of the deleted features that belong to the added pool
144 QgsFeatureMap mDeletedNewFeatures;
145};
146
154{
155 public:
156
164
165 void undo() override;
166 void redo() override;
167
168 int id() const override { return 1; }
169 bool mergeWith( const QUndoCommand *other ) override;
170
171 private:
172 QgsFeatureId mFid;
173 mutable QgsGeometry mNewGeom;
174 QgsGeometry mOldGeom;
175 bool mFirstChange = true;
176};
177
185{
186 public:
187
196
197 void undo() override;
198 void redo() override;
199
200 private:
201 QgsFeatureId mFid;
202 const int mFieldIndex;
203 const QVariant mNewValue;
204 QVariant mOldValue;
205 bool mFirstChange;
206};
207
215{
216 public:
217
226
227 void undo() override;
228 void redo() override;
229
230 private:
231 QgsFeatureId mFid;
232 const QgsAttributeMap mNewValues;
233 QgsAttributeMap mOldValues;
234 QMap<int, bool> mFirstChanges;
235};
236
244{
245 public:
246
253
254 void undo() override;
255 void redo() override;
256
257 private:
258 const QgsField mField;
259};
260
268{
269 public:
270
277
278 void undo() override;
279 void redo() override;
280
281 private:
282 const QgsField mField;
283 const int mOriginalFieldIndex;
284};
285
293{
294 public:
295
303
304 void undo() override;
305 void redo() override;
306
307 private:
308 const int mAttr;
309 const QString mNewName;
310 const QString mOldName;
311};
312
320{
321 public:
322
330 QgsVectorLayerUndoPassthroughCommandUpdate( QgsVectorLayerEditBuffer *buffer SIP_TRANSFER, QgsTransaction *transaction, const QString &sql, const QString &name );
331
332 void undo() override;
333 void redo() override;
334
335 private:
336 QgsTransaction *mTransaction = nullptr;
337 QString mSql;
338 bool mUndone = false;
339};
340
341#endif
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:53
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:162
This class allows including a set of layers in a database-side transaction, provided the layer data p...
Base class for undo commands within a QgsVectorLayerEditBuffer.
bool mergeWith(const QUndoCommand *) override
Undo command for adding attri to a vector layer in transaction group.
Undo command for adding a feature to a vector layer in transaction group mode.
QgsFeatureList features() const
List of features (added feaures can be modified by default values from database)
Undo command for changing attr value from a vector layer in transaction group.
Undo command for changing attributes' values from a vector layer in transaction group.
Undo command for changing feature geometry from a vector layer in transaction group.
Undo command for deleting attri of a vector layer in transaction group.
Undo command for deleting features from a vector layer in transaction group.
Undo command for deleting attri of a vector layer in transaction group.
Undo command for running a specific sql query in transaction group.
Undo command for vector layer in transaction group mode.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QMap< int, QVariant > QgsAttributeMap
Definition: qgsattributes.h:42
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:917
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:37
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28
QMap< QgsFeatureId, QgsFeature > QgsFeatureMap