QGIS/python/core/auto_generated/qgstransaction.sip.in

173 lines
5.0 KiB
Plaintext
Raw Normal View History

2017-05-05 15:31:16 +02:00
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgstransaction.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/
2015-12-01 11:45:30 +01:00
class QgsTransaction : QObject /Abstract/
{
2017-05-05 15:31:16 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
This class allows including a set of layers in a database-side transaction,
provided the layer data providers support transactions and are compatible
with each other.
2017-05-05 15:31:16 +02:00
2017-12-15 10:36:55 -04:00
Only layers which are not in edit mode can be included in a transaction,
and all layers need to be in read-only mode for a transaction to be committed
or rolled back.
2017-05-05 15:31:16 +02:00
2017-12-15 10:36:55 -04:00
Layers can only be included in one transaction at a time.
2017-05-05 15:31:16 +02:00
2017-12-15 10:36:55 -04:00
When editing layers which are part of a transaction group, all changes are
sent directly to the data provider (bypassing the undo/redo stack), and the
changes can either be committed or rolled back on the database side via the
QgsTransaction.commit and QgsTransaction.rollback methods.
2017-05-05 15:31:16 +02:00
2017-12-15 10:36:55 -04:00
As long as the transaction is active, the state of all layer features reflects
the current state in the transaction.
2017-05-05 15:31:16 +02:00
2017-12-15 10:36:55 -04:00
Edits on features can get rejected if another conflicting transaction is active.
2017-05-05 15:31:16 +02:00
%End
%TypeHeaderCode
2017-05-05 15:31:16 +02:00
#include "qgstransaction.h"
%End
public:
2017-05-05 15:31:16 +02:00
static QgsTransaction *create( const QString &connString, const QString &providerKey ) /Factory/;
2017-05-05 15:31:16 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Create a transaction for the specified connection string ``connString``
and provider with ``providerKey``.
2017-05-05 15:31:16 +02:00
%End
static QgsTransaction *create( const QSet<QgsVectorLayer *> &layers ) /Factory/;
2017-05-05 15:31:16 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Create a transaction which includes the ``layers``.
All layers are expected to have the same connection string and data
provider.
2017-05-05 15:31:16 +02:00
%End
~QgsTransaction();
bool addLayer( QgsVectorLayer *layer );
2017-05-05 15:31:16 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Add the ``layer`` to the transaction. The layer must not be
in edit mode and the connection string must match.
2017-05-05 15:31:16 +02:00
%End
2015-12-01 09:20:00 +01:00
bool begin( QString &errorMsg /Out/, int statementTimeout = 20 );
2017-05-05 15:31:16 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Begin transaction
The ``statementTimeout`` (in seconds) specifies how long an sql statement
is allowed to block QGIS before it is aborted.
Statements can block, if multiple transactions are active and a
statement would produce a conflicting state. In these cases, the
statements block until the conflicting transaction is committed or
rolled back.
Some providers might not honour the statement timeout.
2017-05-05 15:31:16 +02:00
%End
bool commit( QString &errorMsg /Out/ );
2017-05-05 15:31:16 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Commit transaction.
2017-05-05 15:31:16 +02:00
%End
bool rollback( QString &errorMsg /Out/ );
2017-05-05 15:31:16 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Roll back transaction.
2017-05-05 15:31:16 +02:00
%End
2017-11-10 16:16:15 +00:00
virtual bool executeSql( const QString &sql, QString &error /Out/, bool isDirty = false, const QString &name = QString() ) = 0;
2017-05-05 15:31:16 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Execute the ``sql`` string.
:param sql: The sql query to execute
:param error: The error message
:param isDirty: Flag to indicate if the underlying data will be modified
2017-11-10 16:16:15 +00:00
:param name: Name of the transaction ( only used if `isDirty` is true)
2017-12-15 10:36:55 -04:00
:return: true if everything is OK, false otherwise
2017-05-05 15:31:16 +02:00
%End
2015-12-01 10:27:25 +01:00
static bool supportsTransaction( const QgsVectorLayer *layer );
2017-05-05 15:31:16 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Checks if the provider of a given ``layer`` supports transactions.
2017-05-05 15:31:16 +02:00
%End
2016-01-15 09:31:19 +01:00
[FEATURE] Add undo and redo on transaction groups (#4765) * [FEATURE] adds undo/redo for transaction groups [needs-docs] the undo/redo now works with transcation groups. Just check that there is no restriction in the transaction groups doc concerning undo. related to #14799 The undo/redo is implemented using SAVEPOINT. The QgsTransaction interface has been enlarged to allow savepoints creation and management. The savepoint is destroyed on rollbackToSavepoint to have the same behavior has the sql ROLLBACK TO SAVEPPOINT. To avoid the creation of a savepoint for each feature modified in bulk editing (e.g. paste, field calculator) the logic is a bit complicated: the savepoint is created on QgsVectorLayer::editCommandStarted and the first actual undo command (QgsVectorLayerUndoPassthroughCommand) is responsible for the re-creation of the savepoint in case of undo-redo. Since the behavior must be different in case edition doesn't take place inside an edit command, a member function has been added to QgsVectorLayer to expose the mEditCommandActive state. Another (commented) tricky bit is the modification of the database structure on add/delete attributes. On undo, the attribute is removed before the rollback to savepoint, i.e. there is a useless ALTER TABLE issued to restore the structure just before restoring it with the ROLLBACK TO SAVEPOINT. This is necessary to make the provider aware of the change of structure. It could be nicer/cleaner to have a way to reload providers metadata. The editPaste function has also been modified to use addFeatures instead of addFeature (plural/singular), this is at the expense of an additional "cpy" of the clipboard in memory, but it should improve perf with postgis provider. * fixup operator aliases
2017-09-15 14:55:43 +02:00
QString createSavepoint( QString &error /Out/ );
%Docstring
2017-12-15 10:36:55 -04:00
creates a save point
returns empty string on error
returns the last created savepoint if it's not dirty
[FEATURE] Add undo and redo on transaction groups (#4765) * [FEATURE] adds undo/redo for transaction groups [needs-docs] the undo/redo now works with transcation groups. Just check that there is no restriction in the transaction groups doc concerning undo. related to #14799 The undo/redo is implemented using SAVEPOINT. The QgsTransaction interface has been enlarged to allow savepoints creation and management. The savepoint is destroyed on rollbackToSavepoint to have the same behavior has the sql ROLLBACK TO SAVEPPOINT. To avoid the creation of a savepoint for each feature modified in bulk editing (e.g. paste, field calculator) the logic is a bit complicated: the savepoint is created on QgsVectorLayer::editCommandStarted and the first actual undo command (QgsVectorLayerUndoPassthroughCommand) is responsible for the re-creation of the savepoint in case of undo-redo. Since the behavior must be different in case edition doesn't take place inside an edit command, a member function has been added to QgsVectorLayer to expose the mEditCommandActive state. Another (commented) tricky bit is the modification of the database structure on add/delete attributes. On undo, the attribute is removed before the rollback to savepoint, i.e. there is a useless ALTER TABLE issued to restore the structure just before restoring it with the ROLLBACK TO SAVEPOINT. This is necessary to make the provider aware of the change of structure. It could be nicer/cleaner to have a way to reload providers metadata. The editPaste function has also been modified to use addFeatures instead of addFeature (plural/singular), this is at the expense of an additional "cpy" of the clipboard in memory, but it should improve perf with postgis provider. * fixup operator aliases
2017-09-15 14:55:43 +02:00
.. versionadded:: 3.0
%End
QString createSavepoint( const QString &savePointId, QString &error /Out/ );
%Docstring
2017-12-15 10:36:55 -04:00
creates a save point
returns empty string on error
[FEATURE] Add undo and redo on transaction groups (#4765) * [FEATURE] adds undo/redo for transaction groups [needs-docs] the undo/redo now works with transcation groups. Just check that there is no restriction in the transaction groups doc concerning undo. related to #14799 The undo/redo is implemented using SAVEPOINT. The QgsTransaction interface has been enlarged to allow savepoints creation and management. The savepoint is destroyed on rollbackToSavepoint to have the same behavior has the sql ROLLBACK TO SAVEPPOINT. To avoid the creation of a savepoint for each feature modified in bulk editing (e.g. paste, field calculator) the logic is a bit complicated: the savepoint is created on QgsVectorLayer::editCommandStarted and the first actual undo command (QgsVectorLayerUndoPassthroughCommand) is responsible for the re-creation of the savepoint in case of undo-redo. Since the behavior must be different in case edition doesn't take place inside an edit command, a member function has been added to QgsVectorLayer to expose the mEditCommandActive state. Another (commented) tricky bit is the modification of the database structure on add/delete attributes. On undo, the attribute is removed before the rollback to savepoint, i.e. there is a useless ALTER TABLE issued to restore the structure just before restoring it with the ROLLBACK TO SAVEPOINT. This is necessary to make the provider aware of the change of structure. It could be nicer/cleaner to have a way to reload providers metadata. The editPaste function has also been modified to use addFeatures instead of addFeature (plural/singular), this is at the expense of an additional "cpy" of the clipboard in memory, but it should improve perf with postgis provider. * fixup operator aliases
2017-09-15 14:55:43 +02:00
.. versionadded:: 3.0
%End
bool rollbackToSavepoint( const QString &name, QString &error /Out/ );
%Docstring
2017-12-15 10:36:55 -04:00
rollback to save point, the save point is maintained and is "undertied"
[FEATURE] Add undo and redo on transaction groups (#4765) * [FEATURE] adds undo/redo for transaction groups [needs-docs] the undo/redo now works with transcation groups. Just check that there is no restriction in the transaction groups doc concerning undo. related to #14799 The undo/redo is implemented using SAVEPOINT. The QgsTransaction interface has been enlarged to allow savepoints creation and management. The savepoint is destroyed on rollbackToSavepoint to have the same behavior has the sql ROLLBACK TO SAVEPPOINT. To avoid the creation of a savepoint for each feature modified in bulk editing (e.g. paste, field calculator) the logic is a bit complicated: the savepoint is created on QgsVectorLayer::editCommandStarted and the first actual undo command (QgsVectorLayerUndoPassthroughCommand) is responsible for the re-creation of the savepoint in case of undo-redo. Since the behavior must be different in case edition doesn't take place inside an edit command, a member function has been added to QgsVectorLayer to expose the mEditCommandActive state. Another (commented) tricky bit is the modification of the database structure on add/delete attributes. On undo, the attribute is removed before the rollback to savepoint, i.e. there is a useless ALTER TABLE issued to restore the structure just before restoring it with the ROLLBACK TO SAVEPOINT. This is necessary to make the provider aware of the change of structure. It could be nicer/cleaner to have a way to reload providers metadata. The editPaste function has also been modified to use addFeatures instead of addFeature (plural/singular), this is at the expense of an additional "cpy" of the clipboard in memory, but it should improve perf with postgis provider. * fixup operator aliases
2017-09-15 14:55:43 +02:00
.. versionadded:: 3.0
%End
void dirtyLastSavePoint();
%Docstring
2017-12-15 10:36:55 -04:00
dirty save point such that next call to createSavepoint will create a new one
[FEATURE] Add undo and redo on transaction groups (#4765) * [FEATURE] adds undo/redo for transaction groups [needs-docs] the undo/redo now works with transcation groups. Just check that there is no restriction in the transaction groups doc concerning undo. related to #14799 The undo/redo is implemented using SAVEPOINT. The QgsTransaction interface has been enlarged to allow savepoints creation and management. The savepoint is destroyed on rollbackToSavepoint to have the same behavior has the sql ROLLBACK TO SAVEPPOINT. To avoid the creation of a savepoint for each feature modified in bulk editing (e.g. paste, field calculator) the logic is a bit complicated: the savepoint is created on QgsVectorLayer::editCommandStarted and the first actual undo command (QgsVectorLayerUndoPassthroughCommand) is responsible for the re-creation of the savepoint in case of undo-redo. Since the behavior must be different in case edition doesn't take place inside an edit command, a member function has been added to QgsVectorLayer to expose the mEditCommandActive state. Another (commented) tricky bit is the modification of the database structure on add/delete attributes. On undo, the attribute is removed before the rollback to savepoint, i.e. there is a useless ALTER TABLE issued to restore the structure just before restoring it with the ROLLBACK TO SAVEPOINT. This is necessary to make the provider aware of the change of structure. It could be nicer/cleaner to have a way to reload providers metadata. The editPaste function has also been modified to use addFeatures instead of addFeature (plural/singular), this is at the expense of an additional "cpy" of the clipboard in memory, but it should improve perf with postgis provider. * fixup operator aliases
2017-09-15 14:55:43 +02:00
.. versionadded:: 3.0
%End
QList< QString > savePoints() const;
%Docstring
2017-12-15 10:36:55 -04:00
returns savepoints
[FEATURE] Add undo and redo on transaction groups (#4765) * [FEATURE] adds undo/redo for transaction groups [needs-docs] the undo/redo now works with transcation groups. Just check that there is no restriction in the transaction groups doc concerning undo. related to #14799 The undo/redo is implemented using SAVEPOINT. The QgsTransaction interface has been enlarged to allow savepoints creation and management. The savepoint is destroyed on rollbackToSavepoint to have the same behavior has the sql ROLLBACK TO SAVEPPOINT. To avoid the creation of a savepoint for each feature modified in bulk editing (e.g. paste, field calculator) the logic is a bit complicated: the savepoint is created on QgsVectorLayer::editCommandStarted and the first actual undo command (QgsVectorLayerUndoPassthroughCommand) is responsible for the re-creation of the savepoint in case of undo-redo. Since the behavior must be different in case edition doesn't take place inside an edit command, a member function has been added to QgsVectorLayer to expose the mEditCommandActive state. Another (commented) tricky bit is the modification of the database structure on add/delete attributes. On undo, the attribute is removed before the rollback to savepoint, i.e. there is a useless ALTER TABLE issued to restore the structure just before restoring it with the ROLLBACK TO SAVEPOINT. This is necessary to make the provider aware of the change of structure. It could be nicer/cleaner to have a way to reload providers metadata. The editPaste function has also been modified to use addFeatures instead of addFeature (plural/singular), this is at the expense of an additional "cpy" of the clipboard in memory, but it should improve perf with postgis provider. * fixup operator aliases
2017-09-15 14:55:43 +02:00
.. versionadded:: 3.0
%End
bool lastSavePointIsDirty() const;
%Docstring
2017-12-15 10:36:55 -04:00
returns the last created savepoint
[FEATURE] Add undo and redo on transaction groups (#4765) * [FEATURE] adds undo/redo for transaction groups [needs-docs] the undo/redo now works with transcation groups. Just check that there is no restriction in the transaction groups doc concerning undo. related to #14799 The undo/redo is implemented using SAVEPOINT. The QgsTransaction interface has been enlarged to allow savepoints creation and management. The savepoint is destroyed on rollbackToSavepoint to have the same behavior has the sql ROLLBACK TO SAVEPPOINT. To avoid the creation of a savepoint for each feature modified in bulk editing (e.g. paste, field calculator) the logic is a bit complicated: the savepoint is created on QgsVectorLayer::editCommandStarted and the first actual undo command (QgsVectorLayerUndoPassthroughCommand) is responsible for the re-creation of the savepoint in case of undo-redo. Since the behavior must be different in case edition doesn't take place inside an edit command, a member function has been added to QgsVectorLayer to expose the mEditCommandActive state. Another (commented) tricky bit is the modification of the database structure on add/delete attributes. On undo, the attribute is removed before the rollback to savepoint, i.e. there is a useless ALTER TABLE issued to restore the structure just before restoring it with the ROLLBACK TO SAVEPOINT. This is necessary to make the provider aware of the change of structure. It could be nicer/cleaner to have a way to reload providers metadata. The editPaste function has also been modified to use addFeatures instead of addFeature (plural/singular), this is at the expense of an additional "cpy" of the clipboard in memory, but it should improve perf with postgis provider. * fixup operator aliases
2017-09-15 14:55:43 +02:00
.. versionadded:: 3.0
%End
2015-12-01 10:27:25 +01:00
signals:
2017-05-05 15:31:16 +02:00
2015-12-01 10:27:25 +01:00
void afterRollback();
2017-05-05 15:31:16 +02:00
%Docstring
2017-12-15 10:36:55 -04:00
Emitted after a rollback
2017-05-05 15:31:16 +02:00
%End
2017-11-10 16:16:15 +00:00
void dirtied( const QString &sql, const QString &name );
%Docstring
2017-12-15 10:36:55 -04:00
Emitted if a sql query is executed and the underlying data is modified
%End
2017-05-05 15:31:16 +02:00
protected:
};
2017-05-05 15:31:16 +02:00
/************************************************************************
* This file has been generated automatically from *
* *
* src/core/qgstransaction.h *
* *
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
************************************************************************/