QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
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 };
149 
158 {
159  public:
160 
168 
169  void undo() override;
170  void redo() override;
171 
172  private:
173  QgsFeatureId mFid;
174  const QgsGeometry mNewGeom;
175  const QgsGeometry mOldGeom;
176 };
177 
186 {
187  public:
188 
197 
198  void undo() override;
199  void redo() override;
200 
201  private:
202  QgsFeatureId mFid;
203  const int mField;
204  const QVariant mNewValue;
205  const QVariant mOldValue;
206 };
207 
216 {
217  public:
218 
227 
228  void undo() override;
229  void redo() override;
230 
231  private:
232  QgsFeatureId mFid;
233  const QgsAttributeMap mNewValues;
234  const QgsAttributeMap mOldValues;
235 };
236 
245 {
246  public:
247 
254 
255  void undo() override;
256  void redo() override;
257 
258  private:
259  const QgsField mField;
260 };
261 
270 {
271  public:
272 
279 
280  void undo() override;
281  void redo() override;
282 
283  private:
284  const QgsField mField;
285 };
286 
295 {
296  public:
297 
305 
306  void undo() override;
307  void redo() override;
308 
309  private:
310  const int mAttr;
311  const QString mNewName;
312  const QString mOldName;
313 };
314 
323 {
324  public:
325 
333  QgsVectorLayerUndoPassthroughCommandUpdate( QgsVectorLayerEditBuffer *buffer SIP_TRANSFER, QgsTransaction *transaction, const QString &sql, const QString &name );
334 
335  void undo() override;
336  void redo() override;
337 
338  private:
339  QgsTransaction *mTransaction = nullptr;
340  QString mSql;
341  bool mUndone = false;
342 };
343 
344 #endif
QgsVectorLayerUndoPassthroughCommandChangeAttributes
Undo command for changing attributes' values from a vector layer in transaction group.
Definition: qgsvectorlayerundopassthroughcommand.h:216
qgsvectorlayerundocommand.h
QgsVectorLayerUndoPassthroughCommandChangeGeometry
Undo command for changing feature geometry from a vector layer in transaction group.
Definition: qgsvectorlayerundopassthroughcommand.h:158
QgsVectorLayerUndoPassthroughCommandAddFeatures::features
QgsFeatureList features() const
List of features (added feaures can be modified by default values from database)
Definition: qgsvectorlayerundopassthroughcommand.h:117
QgsTransaction
This class allows including a set of layers in a database-side transaction, provided the layer data p...
Definition: qgstransaction.h:57
QgsVectorLayerUndoPassthroughCommand
Undo command for vector layer in transaction group mode.
Definition: qgsvectorlayerundopassthroughcommand.h:34
field
const QgsField & field
Definition: qgsfield.h:456
QgsVectorLayerUndoPassthroughCommand::hasError
bool hasError() const
Returns error status.
Definition: qgsvectorlayerundopassthroughcommand.h:48
QgsVectorLayerUndoPassthroughCommandAddAttribute
Undo command for adding attri to a vector layer in transaction group.
Definition: qgsvectorlayerundopassthroughcommand.h:245
QgsVectorLayerUndoPassthroughCommandAddFeatures
Undo command for adding a feature to a vector layer in transaction group mode.
Definition: qgsvectorlayerundopassthroughcommand.h:101
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsFeatureList
QList< QgsFeature > QgsFeatureList
Definition: qgsfeature.h:583
QgsAttributeMap
QMap< int, QVariant > QgsAttributeMap
Definition: qgsattributes.h:38
QgsVectorLayerUndoPassthroughCommandDeleteFeatures
Undo command for deleting features from a vector layer in transaction group.
Definition: qgsvectorlayerundopassthroughcommand.h:133
QgsVectorLayerUndoPassthroughCommandRenameAttribute
Undo command for deleting attri of a vector layer in transaction group.
Definition: qgsvectorlayerundopassthroughcommand.h:295
QgsFeatureIds
QSet< QgsFeatureId > QgsFeatureIds
Definition: qgsfeatureid.h:37
QgsVectorLayerUndoCommand
Base class for undo commands within a QgsVectorLayerEditBuffer.
Definition: qgsvectorlayerundocommand.h:41
QgsGeometry
A geometry is the spatial representation of a feature.
Definition: qgsgeometry.h:124
QgsVectorLayerEditBuffer
Definition: qgsvectorlayereditbuffer.h:37
QgsVectorLayerUndoPassthroughCommandUpdate
Undo command for running a specific sql query in transaction group.
Definition: qgsvectorlayerundopassthroughcommand.h:323
QgsVectorLayerUndoPassthroughCommandDeleteAttribute
Undo command for deleting attri of a vector layer in transaction group.
Definition: qgsvectorlayerundopassthroughcommand.h:270
QgsVectorLayerUndoPassthroughCommandChangeAttribute
Undo command for changing attr value from a vector layer in transaction group.
Definition: qgsvectorlayerundopassthroughcommand.h:186
qgsvectorlayereditbuffer.h
QgsFeatureId
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition: qgsfeatureid.h:28
QgsField
Encapsulate a field in an attribute table or data source.
Definition: qgsfield.h:50