QGIS API Documentation  3.21.0-Master (5b68dc587e)
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 
23 class QgsTransaction;
24 
34 {
35  public:
36 
43  QgsVectorLayerUndoPassthroughCommand( QgsVectorLayerEditBuffer *buffer, const QString &text, bool autocreate = true );
44 
48  bool hasError() const { return mHasError; }
49 
50  protected:
51 
57  bool rollBackToSavePoint();
58 
65  bool setSavePoint( const QString &savePointId = QString() );
66 
70  void setError();
71 
77  void setErrorMessage( const QString &errorMessage );
78 
84  QString errorMessage() const;
85 
86  private:
87  QString mError;
88  QString mSavePointId;
89  bool mHasError;
90  bool mRecreateSavePoint;
91 };
92 
101 {
102  public:
103 
110 
111  void undo() override;
112  void redo() override;
113 
117  QgsFeatureList features() const { return mFeatures; }
118 
119  private:
120  QgsFeatureList mFeatures;
121  QgsFeatureList mInitialFeatures;
122 };
123 
124 
133 {
134  public:
135 
142 
143  void undo() override;
144  void redo() override;
145 
146  private:
147  const QgsFeatureIds mFids;
148  // Keeps track of the deleted features that belong to the added pool
149  QgsFeatureMap mDeletedNewFeatures;
150 };
151 
160 {
161  public:
162 
170 
171  void undo() override;
172  void redo() override;
173 
174  int id() const override { return 1; }
175  bool mergeWith( const QUndoCommand *other ) override;
176 
177  private:
178  QgsFeatureId mFid;
179  mutable QgsGeometry mNewGeom;
180  QgsGeometry mOldGeom;
181  bool mFirstChange = true;
182 };
183 
192 {
193  public:
194 
203 
204  void undo() override;
205  void redo() override;
206 
207  private:
208  QgsFeatureId mFid;
209  const int mFieldIndex;
210  const QVariant mNewValue;
211  QVariant mOldValue;
212  bool mFirstChange;
213 };
214 
223 {
224  public:
225 
234 
235  void undo() override;
236  void redo() override;
237 
238  private:
239  QgsFeatureId mFid;
240  const QgsAttributeMap mNewValues;
241  QgsAttributeMap mOldValues;
242  QMap<int, bool> mFirstChanges;
243 };
244 
253 {
254  public:
255 
262 
263  void undo() override;
264  void redo() override;
265 
266  private:
267  const QgsField mField;
268 };
269 
278 {
279  public:
280 
287 
288  void undo() override;
289  void redo() override;
290 
291  private:
292  const QgsField mField;
293  const int mOriginalFieldIndex;
294 };
295 
304 {
305  public:
306 
314 
315  void undo() override;
316  void redo() override;
317 
318  private:
319  const int mAttr;
320  const QString mNewName;
321  const QString mOldName;
322 };
323 
332 {
333  public:
334 
342  QgsVectorLayerUndoPassthroughCommandUpdate( QgsVectorLayerEditBuffer *buffer SIP_TRANSFER, QgsTransaction *transaction, const QString &sql, const QString &name );
343 
344  void undo() override;
345  void redo() override;
346 
347  private:
348  QgsTransaction *mTransaction = nullptr;
349  QString mSql;
350  bool mUndone = false;
351 };
352 
353 #endif
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:51
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
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:38
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:834
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
const QgsField & field
Definition: qgsfield.h:463
QMap< QgsFeatureId, QgsFeature > QgsFeatureMap