1/************************************************************************ 2 * This file has been generated automatically from * 3 * * 4 * src/core/qgstransaction.h * 5 * * 6 * Do not edit manually ! Edit header and run scripts/sipify.pl again * 7 ************************************************************************/ 8 9 10 11 12 13 14 15class QgsTransaction : QObject /Abstract/ 16{ 17%Docstring 18This class allows including a set of layers in a database-side transaction, 19provided the layer data providers support transactions and are compatible 20with each other. 21 22Only layers which are not in edit mode can be included in a transaction, 23and all layers need to be in read-only mode for a transaction to be committed 24or rolled back. 25 26Layers can only be included in one transaction at a time. 27 28When editing layers which are part of a transaction group, all changes are 29sent directly to the data provider (bypassing the undo/redo stack), and the 30changes can either be committed or rolled back on the database side via the 31QgsTransaction.commit and QgsTransaction.rollback methods. 32 33As long as the transaction is active, the state of all layer features reflects 34the current state in the transaction. 35 36Edits on features can get rejected if another conflicting transaction is active. 37%End 38 39%TypeHeaderCode 40#include "qgstransaction.h" 41%End 42 public: 43 44 static QgsTransaction *create( const QString &connString, const QString &providerKey ) /Factory/; 45%Docstring 46Create a transaction for the specified connection string ``connString`` 47and provider with ``providerKey``. 48%End 49 50 static QgsTransaction *create( const QSet<QgsVectorLayer *> &layers ) /Factory/; 51%Docstring 52Create a transaction which includes the ``layers``. 53All layers are expected to have the same connection string and data 54provider. 55%End 56 57 ~QgsTransaction(); 58 59 bool addLayer( QgsVectorLayer *layer ); 60%Docstring 61Add the ``layer`` to the transaction. The layer must not be 62in edit mode and the connection string must match. 63%End 64 65 bool begin( QString &errorMsg /Out/, int statementTimeout = 20 ); 66%Docstring 67Begin transaction 68The ``statementTimeout`` (in seconds) specifies how long an sql statement 69is allowed to block QGIS before it is aborted. 70Statements can block, if multiple transactions are active and a 71statement would produce a conflicting state. In these cases, the 72statements block until the conflicting transaction is committed or 73rolled back. 74Some providers might not honour the statement timeout. 75%End 76 77 bool commit( QString &errorMsg /Out/ ); 78%Docstring 79Commit transaction. 80%End 81 82 bool rollback( QString &errorMsg /Out/ ); 83%Docstring 84Roll back transaction. 85%End 86 87 virtual bool executeSql( const QString &sql, QString &error /Out/, bool isDirty = false, const QString &name = QString() ) = 0; 88%Docstring 89Execute the ``sql`` string. 90 91:param sql: The sql query to execute 92:param isDirty: Flag to indicate if the underlying data will be modified 93:param name: Name of the transaction ( only used if `isDirty` is ``True``) 94 95:return: - ``True`` if everything is OK, ``False`` otherwise 96 - error: The error message 97%End 98 99 static bool supportsTransaction( const QgsVectorLayer *layer ); 100%Docstring 101Checks if the provider of a given ``layer`` supports transactions. 102%End 103 104 QString createSavepoint( QString &error /Out/ ); 105%Docstring 106creates a save point 107returns empty string on error 108returns the last created savepoint if it's not dirty 109 110.. versionadded:: 3.0 111%End 112 113 QString createSavepoint( const QString &savePointId, QString &error /Out/ ); 114%Docstring 115creates a save point 116returns empty string on error 117 118.. versionadded:: 3.0 119%End 120 121 bool rollbackToSavepoint( const QString &name, QString &error /Out/ ); 122%Docstring 123rollback to save point, the save point is maintained and is "undertied" 124 125.. versionadded:: 3.0 126%End 127 128 void dirtyLastSavePoint(); 129%Docstring 130dirty save point such that next call to createSavepoint will create a new one 131 132.. versionadded:: 3.0 133%End 134 135 QList< QString > savePoints() const; 136%Docstring 137returns savepoints 138 139.. versionadded:: 3.0 140%End 141 142 bool lastSavePointIsDirty() const; 143%Docstring 144returns the last created savepoint 145 146.. versionadded:: 3.0 147%End 148 149 150 signals: 151 152 void afterRollback(); 153%Docstring 154Emitted after a rollback 155%End 156 157 void dirtied( const QString &sql, const QString &name ); 158%Docstring 159Emitted if a sql query is executed and the underlying data is modified 160%End 161 162 protected: 163 164 165}; 166 167/************************************************************************ 168 * This file has been generated automatically from * 169 * * 170 * src/core/qgstransaction.h * 171 * * 172 * Do not edit manually ! Edit header and run scripts/sipify.pl again * 173 ************************************************************************/ 174