37 if ( !createTransaction )
62 Q_FOREACH (
const QString& layerId, layerIds )
75 :
mConnString( connString ), mTransactionActive( false )
81 setLayerTransactionIds(
nullptr );
108 QgsDebugMsg(
QString(
"Couldn't start transaction because connection string for layer %1 : '%2' does not match '%3'" ).arg(
117 if ( mTransactionActive )
125 if ( mTransactionActive )
129 if ( !beginTransaction( errorMsg, statementTimeout ) )
132 setLayerTransactionIds(
this );
133 mTransactionActive =
true;
139 if ( !mTransactionActive )
142 if ( !commitTransaction( errorMsg ) )
145 setLayerTransactionIds(
nullptr );
146 mTransactionActive =
false;
152 if ( !mTransactionActive )
155 if ( !rollbackTransaction( errorMsg ) )
158 setLayerTransactionIds(
nullptr );
159 mTransactionActive =
false;
172 return lib->
resolve(
"createTransaction" );
175 void QgsTransaction::onLayersDeleted(
const QStringList& layerids )
177 Q_FOREACH (
const QString& layerid, layerids )
179 if ( l->
id() == layerid )
183 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()
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.
QgsMapLayer * mapLayer(const QString &theLayerId)
Retrieve a pointer to a loaded layer by id.
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...