QGIS API Documentation  2.18.3-Las Palmas (77b8c3d)
Signals | Public Member Functions | Static Public Member Functions | Protected Member Functions | Protected Attributes | List of all members
QgsTransaction Class Referenceabstract

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>

Inheritance diagram for QgsTransaction:
Inheritance graph
[legend]

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)
 
QObjectchild (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< QByteArraydynamicPropertyNames () const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) 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 QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
const char * name () const
 
const char * name (const char *defaultName) const
 
QString objectName () const
 
QObjectparent () 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)
 
QThreadthread () const
 

Static Public Member Functions

static QgsTransactioncreate (const QString &connString, const QString &providerKey)
 Creates a transaction for the specified connection string and provider. More...
 
static QgsTransactioncreate (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
 
QObjectsender () 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
 

Detailed Description

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.

Constructor & Destructor Documentation

QgsTransaction::~QgsTransaction ( )
virtual

Definition at line 80 of file qgstransaction.cpp.

QgsTransaction::QgsTransaction ( const QString connString)
protected

Definition at line 74 of file qgstransaction.cpp.

Member Function Documentation

bool QgsTransaction::addLayer ( const QString layerId)

Add layer to the transaction.

The layer must not be in edit mode.

Definition at line 85 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 91 of file qgstransaction.cpp.

void QgsTransaction::afterRollback ( )
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 124 of file qgstransaction.cpp.

bool QgsTransaction::commit ( QString errorMsg)

Commit transaction.

Definition at line 138 of file qgstransaction.cpp.

QgsTransaction * QgsTransaction::create ( const QString connString,
const QString providerKey 
)
static

Creates a transaction for the specified connection string and provider.

Definition at line 29 of file qgstransaction.cpp.

QgsTransaction * QgsTransaction::create ( const QStringList layerIds)
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.

virtual bool QgsTransaction::executeSql ( const QString sql,
QString error 
)
pure virtual

Executes sql.

bool QgsTransaction::rollback ( QString errorMsg)

Roll back transaction.

Definition at line 151 of file qgstransaction.cpp.

bool QgsTransaction::supportsTransaction ( const QgsVectorLayer layer)
static

Checks if a the provider of a give layer supports transactions.

Definition at line 167 of file qgstransaction.cpp.

Member Data Documentation

QString QgsTransaction::mConnString
protected

Definition at line 105 of file qgstransaction.h.


The documentation for this class was generated from the following files: