QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 <QUndoCommand>
20 
21 #include <QVariant>
22 #include <QSet>
23 #include <QList>
24 
25 #include "qgsfield.h"
26 #include "qgsfeature.h"
27 
28 class QgsGeometry;
29 class QgsGeometryCache;
30 
31 #include "qgsvectorlayer.h"
33 
34 
35 class CORE_EXPORT QgsVectorLayerUndoCommand : public QUndoCommand
36 {
37  public:
39  : QUndoCommand()
40  , mBuffer( buffer )
41  {}
42  inline QgsVectorLayer *layer() { return mBuffer->L; }
43  inline QgsGeometryCache *cache() { return mBuffer->L->cache(); }
44 
45  virtual int id() const override { return -1; }
46  virtual bool mergeWith( const QUndoCommand * ) override { return false; }
47 
48  protected:
50 };
51 
52 
54 {
55  public:
57 
58  virtual void undo() override;
59  virtual void redo() override;
60 
61  private:
62  QgsFeature mFeature;
63 };
64 
65 
67 {
68  public:
70 
71  virtual void undo() override;
72  virtual void redo() override;
73 
74  private:
75  QgsFeatureId mFid;
76  QgsFeature mOldAddedFeature;
77 };
78 
79 
81 {
82  public:
85 
86  virtual void undo() override;
87  virtual void redo() override;
88  virtual int id() const override;
89  virtual bool mergeWith( const QUndoCommand * ) override;
90 
91  private:
92  QgsFeatureId mFid;
93  QgsGeometry* mOldGeom;
94  mutable QgsGeometry* mNewGeom;
95 };
96 
97 
99 {
100  public:
101  QgsVectorLayerUndoCommandChangeAttribute( QgsVectorLayerEditBuffer* buffer, QgsFeatureId fid, int fieldIndex, const QVariant &newValue, const QVariant &oldValue );
102  virtual void undo() override;
103  virtual void redo() override;
104 
105  private:
106  QgsFeatureId mFid;
107  int mFieldIndex;
108  QVariant mOldValue;
109  QVariant mNewValue;
110  bool mFirstChange;
111 };
112 
113 
115 {
116  public:
118 
119  virtual void undo() override;
120  virtual void redo() override;
121 
122  private:
123  QgsField mField;
124  int mFieldIndex;
125 };
126 
127 
129 {
130  public:
132 
133  virtual void undo() override;
134  virtual void redo() override;
135 
136  private:
137  int mFieldIndex;
138  bool mProviderField;
139  int mOriginIndex;
140  QgsField mOldField;
141 
142  QMap<QgsFeatureId, QVariant> mDeletedValues;
143 };
144 
145 
146 #endif