18#ifndef QGSTRANSACTION_H
19#define QGSTRANSACTION_H
103 bool begin( QString &errorMsg
SIP_OUT,
int statementTimeout = 20 );
125 virtual bool executeSql(
const QString &sql, QString &error
SIP_OUT,
bool isDirty =
false,
const QString &name = QString() ) = 0;
167 static QString connectionString(
const QString &layerUri )
SIP_SKIP;
186 void dirtied(
const QString &sql,
const QString &name );
197 void onLayerDeleted();
201 QSet<QgsVectorLayer *> mLayers;
205 static QString cleanupConnectionString(
const QString &str );
207 virtual bool beginTransaction( QString &error,
int statementTimeout ) = 0;
208 virtual bool commitTransaction( QString &error ) = 0;
209 virtual bool rollbackTransaction( QString &error ) = 0;
QStack< QString > mSavepoints
void afterRollbackToSavepoint(const QString &savepointName)
Emitted after a rollback to savepoint.
bool mLastSavePointIsDirty
void afterRollback()
Emitted after a rollback.
bool rollback(QString &errorMsg)
Roll back transaction.
bool addLayer(QgsVectorLayer *layer, bool addLayersInEditMode=false)
Add the layer to the transaction.
QList< QString > savePoints() const
returns savepoints
bool begin(QString &errorMsg, int statementTimeout=20)
Begin transaction The statementTimeout (in seconds) specifies how long an sql statement is allowed to...
static bool supportsTransaction(const QgsVectorLayer *layer)
Checks if the provider of a given layer supports transactions.
virtual bool rollbackToSavepoint(const QString &name, QString &error)
rollback to save point, the save point is maintained and is "undertied"
virtual bool executeSql(const QString &sql, QString &error, bool isDirty=false, const QString &name=QString())=0
Execute the sql string.
QgsTransaction(const QString &connString)
QString connectionString() const
Returns the connection string of the transaction.
bool commit(QString &errorMsg)
Commit transaction.
static QgsTransaction * create(const QString &connString, const QString &providerKey)
Create a transaction for the specified connection string connString and provider with providerKey.
bool lastSavePointIsDirty() const
returns the last created savepoint
QString createSavepoint(QString &error)
creates a save point returns empty string on error returns the last created savepoint if it's not dir...
void dirtyLastSavePoint()
dirty save point such that next call to createSavepoint will create a new one
void dirtied(const QString &sql, const QString &name)
Emitted if a sql query is executed and the underlying data is modified.
Base class for vector data providers.
Represents a vector layer which manages a vector based dataset.