37 if ( mConnString.isEmpty() )
42 else if ( mConnString != connString || mProviderKey != layer->
providerType() )
47 mLayers.insert( layer );
50 connect( layer, &QgsVectorLayer::destroyed,
this, &QgsTransactionGroup::onLayerDeleted );
70 void QgsTransactionGroup::onEditingStarted()
80 mTransaction->begin( errorMsg );
84 mTransaction->addLayer( layer );
91 void QgsTransactionGroup::onLayerDeleted()
93 mLayers.remove( static_cast<QgsVectorLayer *>( sender() ) );
96 void QgsTransactionGroup::onCommitChanges()
98 if ( mEditingStopping )
101 mEditingStopping =
true;
106 if ( mTransaction->commit( errMsg ) )
110 if ( layer != sender() )
114 disableTransaction();
122 mEditingStopping =
false;
125 void QgsTransactionGroup::onRollback()
127 if ( mEditingStopping )
130 mEditingStopping =
true;
135 if ( mTransaction->rollback( errMsg ) )
139 if ( layer != triggeringLayer )
142 disableTransaction();
149 mEditingStopping =
false;
152 void QgsTransactionGroup::disableTransaction()
154 mTransaction.reset();
170 return mLayers.isEmpty();
static QgsTransaction * create(const QString &connString, const QString &providerKey)
Create a transaction for the specified connection string connString and provider with providerKey...
void beforeRollBack()
Is emitted, before changes are rolled back.
bool commitChanges()
Attempts to commit to the underlying data provider any buffered changes made since the last to call t...
QString providerType() const
Returns the provider type (provider key) for this layer.
bool startEditing()
Makes the layer editable.
QSet< QgsVectorLayer * > layers() const
Gets the set of layers currently managed by this transaction group.
void beforeCommitChanges()
Is emitted, before changes are committed to the data provider.
QString providerKey() const
Returns the provider key used by this transaction group.
bool rollBack(bool deleteBuffer=true)
Stops a current editing operation and discards any uncommitted edits.
void beforeEditingStarted()
Is emitted, before editing on this layer is started.
bool addLayer(QgsVectorLayer *layer)
Add a layer to this transaction group.
static bool supportsTransaction(const QgsVectorLayer *layer)
Checks if the provider of a given layer supports transactions.
QgsTransactionGroup(QObject *parent=nullptr)
Constructor for QgsTransactionGroup.
QString source() const
Returns the source for the layer.
virtual bool isModified() const
Returns true if the provider has been modified since the last commit.
bool isEmpty() const
Returns true if there are no layers in this transaction group.
void commitError(const QString &msg)
Will be emitted whenever there is a commit error.
Represents a vector layer which manages a vector based data sets.
QString connString() const
Returns the connection string used by this transaction group.
bool modified() const
Returns true if any of the layers in this group reports a modification.