37 if ( !createTransaction )
62 Q_FOREACH (
const QString& layerId, layerIds )
76 , mTransactionActive( false )
82 setLayerTransactionIds(
nullptr );
109 QgsDebugMsg(
QString(
"Couldn't start transaction because connection string for layer %1 : '%2' does not match '%3'" ).arg(
118 if ( mTransactionActive )
126 if ( mTransactionActive )
130 if ( !beginTransaction( errorMsg, statementTimeout ) )
133 setLayerTransactionIds(
this );
134 mTransactionActive =
true;
140 if ( !mTransactionActive )
143 if ( !commitTransaction( errorMsg ) )
146 setLayerTransactionIds(
nullptr );
147 mTransactionActive =
false;
153 if ( !mTransactionActive )
156 if ( !rollbackTransaction( errorMsg ) )
159 setLayerTransactionIds(
nullptr );
160 mTransactionActive =
false;
173 return lib->
resolve(
"createTransaction" );
176 void QgsTransaction::onLayersDeleted(
const QStringList& layerids )
178 Q_FOREACH (
const QString& layerid, layerids )
180 if ( l->
id() == layerid )
184 void QgsTransaction::setLayerTransactionIds(
QgsTransaction* transaction )
static QgsTransaction * create(const QString &connString, const QString &providerKey)
Creates a transaction for the specified connection string and provider.
static QgsProviderRegistry * instance(const QString &pluginPath=QString::null)
Means of accessing canonical single instance.
virtual ~QgsTransaction()
QgsMapLayer * mapLayer(const QString &theLayerId) const
Retrieve a pointer to a registered layer by layer ID.
QLibrary * providerLibrary(const QString &providerKey) const
QgsTransaction * createTransaction_t(const QString &connString)
const_iterator insert(const T &value)
virtual bool isEditable() const override
Returns true if the provider is in editing mode.
bool commit(QString &errorMsg)
Commit transaction.
virtual QString name() const =0
Return a provider name.
QString id() const
Get this layer's unique ID, this ID is used to access this layer from map layer registry.
bool addLayer(const QString &layerId)
Add layer to the transaction.
static bool supportsTransaction(const QgsVectorLayer *layer)
Checks if a the provider of a give layer supports transactions.
virtual int capabilities() const
Returns a bitmask containing the supported capabilities Note, some capabilities may change depending ...
void afterRollback()
Emitted after a rollback.
Class for storing the component parts of a PostgreSQL/RDBMS datasource URI.
virtual QgsTransaction * transaction() const
Returns the transaction this data provider is included in, if any.
QgsTransaction(const QString &connString)
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
bool remove(const T &value)
void * resolve(const char *symbol)
QString source() const
Returns the source for the layer.
This class allows including a set of layers in a database-side transaction, provided the layer data p...
bool rollback(QString &errorMsg)
Roll back transaction.
void(*)() cast_to_fptr(void *p)
QgsVectorDataProvider * dataProvider()
Returns the data provider.
QString providerType() const
Return the provider type for this layer.
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Represents a vector layer which manages a vector based data sets.
bool begin(QString &errorMsg, int statementTimeout=20)
Begin transaction The statement timeout, in seconds, specifies how long an sql statement is allowed t...