QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
vector
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
19
#include "
qgsvectorlayereditbuffer.h
"
20
#include "
qgsvectorlayerundocommand.h
"
21
22
class
QgsTransaction
;
23
29
30
31
class
CORE_EXPORT
QgsVectorLayerUndoPassthroughCommand
:
public
QgsVectorLayerUndoCommand
32
{
33
public
:
40
QgsVectorLayerUndoPassthroughCommand
(
QgsVectorLayerEditBuffer
*buffer,
const
QString &text,
bool
autocreate =
true
);
41
45
bool
hasError
()
const
{
return
mHasError; }
46
47
protected
:
53
bool
rollBackToSavePoint();
54
61
bool
setSavePoint(
const
QString &savePointId = QString() );
62
66
void
setError();
67
72
void
setErrorMessage(
const
QString &errorMessage );
73
78
QString errorMessage()
const
;
79
80
private
:
81
QString mError;
82
QString mSavePointId;
83
bool
mHasError;
84
bool
mRecreateSavePoint;
85
};
86
92
93
class
CORE_EXPORT
QgsVectorLayerUndoPassthroughCommandAddFeatures
:
public
QgsVectorLayerUndoPassthroughCommand
94
{
95
public
:
101
QgsVectorLayerUndoPassthroughCommandAddFeatures
(
QgsVectorLayerEditBuffer
*buffer
SIP_TRANSFER
,
QgsFeatureList
&
features
);
102
103
void
undo
()
override
;
104
void
redo
()
override
;
105
109
QgsFeatureList
features
()
const
{
return
mFeatures; }
110
111
private
:
112
QgsFeatureList
mFeatures;
113
QgsFeatureList
mInitialFeatures;
114
};
115
116
122
123
class
CORE_EXPORT
QgsVectorLayerUndoPassthroughCommandDeleteFeatures
:
public
QgsVectorLayerUndoPassthroughCommand
124
{
125
public
:
131
QgsVectorLayerUndoPassthroughCommandDeleteFeatures
(
QgsVectorLayerEditBuffer
*buffer
SIP_TRANSFER
,
const
QgsFeatureIds
&fids );
132
133
void
undo
()
override
;
134
void
redo
()
override
;
135
136
private
:
137
const
QgsFeatureIds
mFids;
138
// Keeps track of the deleted features that belong to the added pool
139
QgsFeatureMap
mDeletedNewFeatures;
140
};
141
147
148
class
CORE_EXPORT
QgsVectorLayerUndoPassthroughCommandChangeGeometry
:
public
QgsVectorLayerUndoPassthroughCommand
149
{
150
public
:
157
QgsVectorLayerUndoPassthroughCommandChangeGeometry
(
QgsVectorLayerEditBuffer
*buffer
SIP_TRANSFER
,
QgsFeatureId
fid,
const
QgsGeometry
&geom );
158
159
void
undo
()
override
;
160
void
redo
()
override
;
161
162
int
id
()
const override
{
return
1; }
163
bool
mergeWith
(
const
QUndoCommand *other )
override
;
164
165
private
:
166
QgsFeatureId
mFid;
167
mutable
QgsGeometry
mNewGeom;
168
QgsGeometry
mOldGeom;
169
bool
mFirstChange =
true
;
170
};
171
177
178
class
CORE_EXPORT
QgsVectorLayerUndoPassthroughCommandChangeAttribute
:
public
QgsVectorLayerUndoPassthroughCommand
179
{
180
public
:
188
QgsVectorLayerUndoPassthroughCommandChangeAttribute
(
QgsVectorLayerEditBuffer
*buffer
SIP_TRANSFER
,
QgsFeatureId
fid,
int
field,
const
QVariant &newValue );
189
190
void
undo
()
override
;
191
void
redo
()
override
;
192
193
private
:
194
QgsFeatureId
mFid;
195
const
int
mFieldIndex;
196
const
QVariant mNewValue;
197
QVariant mOldValue;
198
bool
mFirstChange =
true
;
199
};
200
206
207
class
CORE_EXPORT
QgsVectorLayerUndoPassthroughCommandChangeAttributes
:
public
QgsVectorLayerUndoPassthroughCommand
208
{
209
public
:
217
QgsVectorLayerUndoPassthroughCommandChangeAttributes
(
218
QgsVectorLayerEditBuffer
*buffer
SIP_TRANSFER
,
QgsFeatureId
fid,
const
QgsAttributeMap
&newValues,
const
QgsAttributeMap
&oldValues =
QgsAttributeMap
()
219
);
220
221
void
undo
()
override
;
222
void
redo
()
override
;
223
224
private
:
225
QgsFeatureId
mFid;
226
const
QgsAttributeMap
mNewValues;
227
QgsAttributeMap
mOldValues;
228
QMap<int, bool> mFirstChanges;
229
};
230
236
237
class
CORE_EXPORT
QgsVectorLayerUndoPassthroughCommandAddAttribute
:
public
QgsVectorLayerUndoPassthroughCommand
238
{
239
public
:
245
QgsVectorLayerUndoPassthroughCommandAddAttribute
(
QgsVectorLayerEditBuffer
*buffer
SIP_TRANSFER
,
const
QgsField
&field );
246
247
void
undo
()
override
;
248
void
redo
()
override
;
249
250
private
:
251
const
QgsField
mField;
252
};
253
259
260
class
CORE_EXPORT
QgsVectorLayerUndoPassthroughCommandDeleteAttribute
:
public
QgsVectorLayerUndoPassthroughCommand
261
{
262
public
:
268
QgsVectorLayerUndoPassthroughCommandDeleteAttribute
(
QgsVectorLayerEditBuffer
*buffer
SIP_TRANSFER
,
int
attr );
269
270
void
undo
()
override
;
271
void
redo
()
override
;
272
273
private
:
274
const
QgsField
mField;
275
const
int
mOriginalFieldIndex;
276
};
277
283
284
class
CORE_EXPORT
QgsVectorLayerUndoPassthroughCommandRenameAttribute
:
public
QgsVectorLayerUndoPassthroughCommand
285
{
286
public
:
293
QgsVectorLayerUndoPassthroughCommandRenameAttribute
(
QgsVectorLayerEditBuffer
*buffer
SIP_TRANSFER
,
int
attr,
const
QString &newName );
294
295
void
undo
()
override
;
296
void
redo
()
override
;
297
298
private
:
299
const
int
mAttr;
300
const
QString mNewName;
301
const
QString mOldName;
302
};
303
309
310
class
CORE_EXPORT
QgsVectorLayerUndoPassthroughCommandUpdate
:
public
QgsVectorLayerUndoPassthroughCommand
311
{
312
public
:
320
QgsVectorLayerUndoPassthroughCommandUpdate
(
QgsVectorLayerEditBuffer
*buffer
SIP_TRANSFER
,
QgsTransaction
*transaction,
const
QString &sql,
const
QString &name );
321
322
void
undo
()
override
;
323
void
redo
()
override
;
324
325
private
:
326
QgsTransaction
*mTransaction =
nullptr
;
327
QString mSql;
328
bool
mUndone =
false
;
329
};
330
331
#endif
QgsField
Encapsulate a field in an attribute table or data source.
Definition
qgsfield.h:56
QgsGeometry
A geometry is the spatial representation of a feature.
Definition
qgsgeometry.h:267
QgsTransaction
Allows creation of a multi-layer database-side transaction.
Definition
qgstransaction.h:58
QgsVectorLayerEditBuffer
Stores queued vector layer edit operations prior to committing changes to the layer's data provider.
Definition
qgsvectorlayereditbuffer.h:39
QgsVectorLayerUndoCommand::mergeWith
bool mergeWith(const QUndoCommand *) override
Definition
qgsvectorlayerundocommand.h:54
QgsVectorLayerUndoCommand::QgsVectorLayerUndoCommand
QgsVectorLayerUndoCommand(QgsVectorLayerEditBuffer *buffer)
Constructor for QgsVectorLayerUndoCommand.
Definition
qgsvectorlayerundocommand.h:46
QgsVectorLayerUndoPassthroughCommandAddAttribute::undo
void undo() override
Definition
qgsvectorlayerundopassthroughcommand.cpp:379
QgsVectorLayerUndoPassthroughCommandAddAttribute::QgsVectorLayerUndoPassthroughCommandAddAttribute
QgsVectorLayerUndoPassthroughCommandAddAttribute(QgsVectorLayerEditBuffer *buffer, const QgsField &field)
Constructor for QgsVectorLayerUndoPassthroughCommandAddAttribute.
Definition
qgsvectorlayerundopassthroughcommand.cpp:374
QgsVectorLayerUndoPassthroughCommandAddAttribute::redo
void redo() override
Definition
qgsvectorlayerundopassthroughcommand.cpp:403
QgsVectorLayerUndoPassthroughCommandAddFeatures::features
QgsFeatureList features() const
List of features (added feaures can be modified by default values from database).
Definition
qgsvectorlayerundopassthroughcommand.h:109
QgsVectorLayerUndoPassthroughCommandAddFeatures::undo
void undo() override
Definition
qgsvectorlayerundopassthroughcommand.cpp:117
QgsVectorLayerUndoPassthroughCommandAddFeatures::redo
void redo() override
Definition
qgsvectorlayerundopassthroughcommand.cpp:130
QgsVectorLayerUndoPassthroughCommandAddFeatures::QgsVectorLayerUndoPassthroughCommandAddFeatures
QgsVectorLayerUndoPassthroughCommandAddFeatures(QgsVectorLayerEditBuffer *buffer, QgsFeatureList &features)
Constructor for QgsVectorLayerUndoPassthroughCommandAddFeatures.
Definition
qgsvectorlayerundopassthroughcommand.cpp:103
QgsVectorLayerUndoPassthroughCommandChangeAttribute::QgsVectorLayerUndoPassthroughCommandChangeAttribute
QgsVectorLayerUndoPassthroughCommandChangeAttribute(QgsVectorLayerEditBuffer *buffer, QgsFeatureId fid, int field, const QVariant &newValue)
Constructor for QgsVectorLayerUndoPassthroughCommandChangeAttribute.
Definition
qgsvectorlayerundopassthroughcommand.cpp:274
QgsVectorLayerUndoPassthroughCommandChangeAttribute::undo
void undo() override
Definition
qgsvectorlayerundopassthroughcommand.cpp:299
QgsVectorLayerUndoPassthroughCommandChangeAttribute::redo
void redo() override
Definition
qgsvectorlayerundopassthroughcommand.cpp:341
QgsVectorLayerUndoPassthroughCommandChangeAttributes::QgsVectorLayerUndoPassthroughCommandChangeAttributes
QgsVectorLayerUndoPassthroughCommandChangeAttributes(QgsVectorLayerEditBuffer *buffer, QgsFeatureId fid, const QgsAttributeMap &newValues, const QgsAttributeMap &oldValues=QgsAttributeMap())
Constructor for QgsVectorLayerUndoPassthroughCommandChangeAttributes.
Definition
qgsvectorlayerundopassthroughcommand.cpp:579
QgsVectorLayerUndoPassthroughCommandChangeAttributes::redo
void redo() override
Definition
qgsvectorlayerundopassthroughcommand.cpp:646
QgsVectorLayerUndoPassthroughCommandChangeAttributes::undo
void undo() override
Definition
qgsvectorlayerundopassthroughcommand.cpp:613
QgsVectorLayerUndoPassthroughCommandChangeGeometry::redo
void redo() override
Definition
qgsvectorlayerundopassthroughcommand.cpp:232
QgsVectorLayerUndoPassthroughCommandChangeGeometry::QgsVectorLayerUndoPassthroughCommandChangeGeometry
QgsVectorLayerUndoPassthroughCommandChangeGeometry(QgsVectorLayerEditBuffer *buffer, QgsFeatureId fid, const QgsGeometry &geom)
Constructor for QgsVectorLayerUndoPassthroughCommandChangeGeometry.
Definition
qgsvectorlayerundopassthroughcommand.cpp:195
QgsVectorLayerUndoPassthroughCommandChangeGeometry::undo
void undo() override
Definition
qgsvectorlayerundopassthroughcommand.cpp:212
QgsVectorLayerUndoPassthroughCommandChangeGeometry::id
int id() const override
Definition
qgsvectorlayerundopassthroughcommand.h:162
QgsVectorLayerUndoPassthroughCommandDeleteAttribute::undo
void undo() override
Definition
qgsvectorlayerundopassthroughcommand.cpp:425
QgsVectorLayerUndoPassthroughCommandDeleteAttribute::QgsVectorLayerUndoPassthroughCommandDeleteAttribute
QgsVectorLayerUndoPassthroughCommandDeleteAttribute(QgsVectorLayerEditBuffer *buffer, int attr)
Constructor for QgsVectorLayerUndoCommandDeleteAttribute.
Definition
qgsvectorlayerundopassthroughcommand.cpp:419
QgsVectorLayerUndoPassthroughCommandDeleteAttribute::redo
void redo() override
Definition
qgsvectorlayerundopassthroughcommand.cpp:457
QgsVectorLayerUndoPassthroughCommandDeleteFeatures::QgsVectorLayerUndoPassthroughCommandDeleteFeatures
QgsVectorLayerUndoPassthroughCommandDeleteFeatures(QgsVectorLayerEditBuffer *buffer, const QgsFeatureIds &fids)
Constructor for QgsVectorLayerUndoPassthroughCommandDeleteFeatures.
Definition
qgsvectorlayerundopassthroughcommand.cpp:148
QgsVectorLayerUndoPassthroughCommandDeleteFeatures::undo
void undo() override
Definition
qgsvectorlayerundopassthroughcommand.cpp:153
QgsVectorLayerUndoPassthroughCommandDeleteFeatures::redo
void redo() override
Definition
qgsvectorlayerundopassthroughcommand.cpp:169
QgsVectorLayerUndoPassthroughCommandRenameAttribute::undo
void undo() override
Definition
qgsvectorlayerundopassthroughcommand.cpp:479
QgsVectorLayerUndoPassthroughCommandRenameAttribute::redo
void redo() override
Definition
qgsvectorlayerundopassthroughcommand.cpp:512
QgsVectorLayerUndoPassthroughCommandRenameAttribute::QgsVectorLayerUndoPassthroughCommandRenameAttribute
QgsVectorLayerUndoPassthroughCommandRenameAttribute(QgsVectorLayerEditBuffer *buffer, int attr, const QString &newName)
Constructor for QgsVectorLayerUndoCommandRenameAttribute.
Definition
qgsvectorlayerundopassthroughcommand.cpp:472
QgsVectorLayerUndoPassthroughCommandUpdate::undo
void undo() override
Definition
qgsvectorlayerundopassthroughcommand.cpp:534
QgsVectorLayerUndoPassthroughCommandUpdate::redo
void redo() override
Definition
qgsvectorlayerundopassthroughcommand.cpp:547
QgsVectorLayerUndoPassthroughCommandUpdate::QgsVectorLayerUndoPassthroughCommandUpdate
QgsVectorLayerUndoPassthroughCommandUpdate(QgsVectorLayerEditBuffer *buffer, QgsTransaction *transaction, const QString &sql, const QString &name)
Constructor for QgsVectorLayerUndoCommandUpdate.
Definition
qgsvectorlayerundopassthroughcommand.cpp:528
QgsVectorLayerUndoPassthroughCommand::QgsVectorLayerUndoPassthroughCommand
QgsVectorLayerUndoPassthroughCommand(QgsVectorLayerEditBuffer *buffer, const QString &text, bool autocreate=true)
Constructor for QgsVectorLayerUndoPassthroughCommand.
Definition
qgsvectorlayerundopassthroughcommand.cpp:31
QgsVectorLayerUndoPassthroughCommand::hasError
bool hasError() const
Returns error status.
Definition
qgsvectorlayerundopassthroughcommand.h:45
SIP_TRANSFER
#define SIP_TRANSFER
Definition
qgis_sip.h:35
QgsAttributeMap
QMap< int, QVariant > QgsAttributeMap
Definition
qgsattributes.h:40
QgsFeatureList
QList< QgsFeature > QgsFeatureList
Definition
qgsfeature.h:1289
QgsFeatureIds
QSet< QgsFeatureId > QgsFeatureIds
Definition
qgsfeatureid.h:41
QgsFeatureId
qint64 QgsFeatureId
64 bit feature ids negative numbers are used for uncommitted/newly added features
Definition
qgsfeatureid.h:32
qgsvectorlayereditbuffer.h
QgsFeatureMap
QMap< QgsFeatureId, QgsFeature > QgsFeatureMap
Definition
qgsvectorlayereditbuffer.h:31
qgsvectorlayerundocommand.h
Generated on
for QGIS API Documentation by
1.17.0