QGIS API Documentation
2.14.0-Essen
|
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. More...
#include <qgstransaction.h>
Signals | |
void | afterRollback () |
Emitted after a rollback. More... | |
Public Member Functions | |
virtual | ~QgsTransaction () |
bool | addLayer (const QString &layerId) |
Add layer to the transaction. More... | |
bool | addLayer (QgsVectorLayer *layer) |
Add layer to the transaction. More... | |
bool | begin (QString &errorMsg, int statementTimeout=20) |
Begin transaction The statement timeout, in seconds, specifies how long an sql statement is allowed to block QGIS before it is aborted. More... | |
bool | commit (QString &errorMsg) |
Commit transaction. More... | |
virtual bool | executeSql (const QString &sql, QString &error)=0 |
Executes sql. More... | |
bool | rollback (QString &errorMsg) |
Roll back transaction. More... | |
Public Member Functions inherited from QObject | |
QObject (QObject *parent) | |
QObject (QObject *parent, const char *name) | |
virtual | ~QObject () |
bool | blockSignals (bool block) |
QObject * | child (const char *objName, const char *inheritsClass, bool recursiveSearch) const |
const QObjectList & | children () const |
const char * | className () const |
bool | connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const |
void | deleteLater () |
void | destroyed (QObject *obj) |
bool | disconnect (const QObject *receiver, const char *method) |
bool | disconnect (const char *signal, const QObject *receiver, const char *method) |
void | dumpObjectInfo () |
void | dumpObjectTree () |
QList< QByteArray > | dynamicPropertyNames () const |
virtual bool | event (QEvent *e) |
virtual bool | eventFilter (QObject *watched, QEvent *event) |
T | findChild (const QString &name) const |
QList< T > | findChildren (const QRegExp ®Exp) const |
QList< T > | findChildren (const QString &name) const |
bool | inherits (const char *className) const |
void | insertChild (QObject *object) |
void | installEventFilter (QObject *filterObj) |
bool | isA (const char *className) const |
bool | isWidgetType () const |
void | killTimer (int id) |
virtual const QMetaObject * | metaObject () const |
void | moveToThread (QThread *targetThread) |
const char * | name () const |
const char * | name (const char *defaultName) const |
QString | objectName () const |
QObject * | parent () const |
QVariant | property (const char *name) const |
void | removeChild (QObject *object) |
void | removeEventFilter (QObject *obj) |
void | setName (const char *name) |
void | setObjectName (const QString &name) |
void | setParent (QObject *parent) |
bool | setProperty (const char *name, const QVariant &value) |
bool | signalsBlocked () const |
int | startTimer (int interval) |
QThread * | thread () const |
Static Public Member Functions | |
static QgsTransaction * | create (const QString &connString, const QString &providerKey) |
Creates a transaction for the specified connection string and provider. More... | |
static QgsTransaction * | create (const QStringList &layerIds) |
Creates a transaction which includes the specified layers. More... | |
static bool | supportsTransaction (const QgsVectorLayer *layer) |
Checks if a the provider of a give layer supports transactions. More... | |
Static Public Member Functions inherited from QObject | |
bool | connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type) |
bool | connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type) |
bool | disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method) |
bool | disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method) |
QString | tr (const char *sourceText, const char *disambiguation, int n) |
QString | trUtf8 (const char *sourceText, const char *disambiguation, int n) |
Protected Member Functions | |
QgsTransaction (const QString &connString) | |
Protected Member Functions inherited from QObject | |
bool | checkConnectArgs (const char *signal, const QObject *object, const char *method) |
virtual void | childEvent (QChildEvent *event) |
virtual void | connectNotify (const char *signal) |
virtual void | customEvent (QEvent *event) |
virtual void | disconnectNotify (const char *signal) |
int | receivers (const char *signal) const |
QObject * | sender () const |
int | senderSignalIndex () const |
virtual void | timerEvent (QTimerEvent *event) |
Protected Attributes | |
QString | mConnString |
Additional Inherited Members | |
Static Protected Member Functions inherited from QObject | |
QByteArray | normalizeSignalSlot (const char *signalSlot) |
Properties inherited from QObject | |
objectName | |
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.
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.
Layers cannot only be included in one transaction at a time.
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.
As long as the transaction is active, the state of all layer features reflects the current state in the transaction.
Edits on features can get rejected if another conflicting transaction is active.
Definition at line 49 of file qgstransaction.h.
|
virtual |
Definition at line 79 of file qgstransaction.cpp.
|
protected |
Definition at line 74 of file qgstransaction.cpp.
bool QgsTransaction::addLayer | ( | const QString & | layerId | ) |
Add layer to the transaction.
The layer must not be in edit mode.
Definition at line 84 of file qgstransaction.cpp.
bool QgsTransaction::addLayer | ( | QgsVectorLayer * | layer | ) |
Add layer to the transaction.
The layer must not be in edit mode.
Definition at line 90 of file qgstransaction.cpp.
|
signal |
Emitted after a rollback.
bool QgsTransaction::begin | ( | QString & | errorMsg, |
int | statementTimeout = 20 |
||
) |
Begin transaction The statement timeout, in seconds, specifies how long an sql statement is allowed to block QGIS before it is aborted.
Statements can block, depending on the provider, 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.
Definition at line 123 of file qgstransaction.cpp.
bool QgsTransaction::commit | ( | QString & | errorMsg | ) |
Commit transaction.
Definition at line 137 of file qgstransaction.cpp.
|
static |
Creates a transaction for the specified connection string and provider.
Definition at line 29 of file qgstransaction.cpp.
|
static |
Creates a transaction which includes the specified layers.
Connection string and data provider are taken from the first layer
Definition at line 47 of file qgstransaction.cpp.
Executes sql.
bool QgsTransaction::rollback | ( | QString & | errorMsg | ) |
Roll back transaction.
Definition at line 150 of file qgstransaction.cpp.
|
static |
Checks if a the provider of a give layer supports transactions.
Definition at line 166 of file qgstransaction.cpp.
|
protected |
Definition at line 105 of file qgstransaction.h.