37   const QString 
connString = QgsTransaction::connectionString( layer->
source() );
 
   38   if ( mConnString.isEmpty() )
 
   48   mLayers.insert( layer );
 
   51   connect( layer, &QgsVectorLayer::destroyed, 
this, &QgsTransactionGroup::onLayerDeleted );
 
   63   const auto constMLayers = mLayers;
 
   66     if ( layer->isModified() )
 
   72 void QgsTransactionGroup::onEditingStarted()
 
   82   mTransaction->begin( errorMsg );
 
   84   const auto constMLayers = mLayers;
 
   87     mTransaction->addLayer( layer );
 
   88     layer->startEditing();
 
   94 void QgsTransactionGroup::onLayerDeleted()
 
   99 void QgsTransactionGroup::onBeforeCommitChanges( 
bool stopEditing )
 
  101   if ( mEditingStopping )
 
  104   mEditingStopping = 
true;
 
  106   const QgsVectorLayer *triggeringLayer = qobject_cast<QgsVectorLayer *>( sender() );
 
  109   if ( mTransaction->commit( errMsg ) )
 
  111     const auto constMLayers = mLayers;
 
  114       if ( layer != triggeringLayer )
 
  116         layer->commitChanges( stopEditing );
 
  122       disableTransaction();
 
  126       if ( ! mTransaction->begin( errMsg ) )
 
  128         QgsDebugMsg( QStringLiteral( 
"Could not restart a transaction for %1: %2" ).arg( triggeringLayer->
name() ).arg( errMsg ) );
 
  136     restartTransaction( triggeringLayer );
 
  138   mEditingStopping = 
false;
 
  141 void QgsTransactionGroup::onRollback()
 
  143   if ( mEditingStopping )
 
  146   mEditingStopping = 
true;
 
  148   QgsVectorLayer *triggeringLayer = qobject_cast<QgsVectorLayer *>( sender() );
 
  151   if ( mTransaction->rollback( errMsg ) )
 
  153     const auto constMLayers = mLayers;
 
  156       if ( layer != triggeringLayer )
 
  159     disableTransaction();
 
  163     restartTransaction( triggeringLayer );
 
  165   mEditingStopping = 
false;
 
  168 void QgsTransactionGroup::disableTransaction()
 
  170   mTransaction.reset();
 
  172   const auto constMLayers = mLayers;
 
  180 void QgsTransactionGroup::restartTransaction( 
const QgsVectorLayer *layer )
 
  193   return mLayers.isEmpty();
 
QString source() const
Returns the source for the layer.
QString providerType() const
Returns the provider type (provider key) for this layer.
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.
QgsTransactionGroup(QObject *parent=nullptr)
Constructor for QgsTransactionGroup.
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.
QString providerKey() const
Returns the provider key used by this transaction group.
bool addLayer(QgsVectorLayer *layer)
Add a layer to this transaction group.
QSet< QgsVectorLayer * > layers() const
Gets the set of layers currently managed by this transaction group.
static bool supportsTransaction(const QgsVectorLayer *layer)
Checks if the provider of a given layer supports transactions.
static QgsTransaction * create(const QString &connString, const QString &providerKey)
Create a transaction for the specified connection string connString and provider with providerKey.
Represents a vector layer which manages a vector based data sets.
void beforeCommitChanges(bool stopEditing)
Emitted before changes are committed to the data provider.
Q_INVOKABLE bool startEditing()
Makes the layer editable.
void beforeEditingStarted()
Emitted before editing on this layer is started.
void beforeRollBack()
Emitted before changes are rolled back.