38 if ( mConnString.isEmpty() )
43 else if ( mConnString != connString || mProviderKey != layer->
providerType() )
48 mLayers.insert( layer );
51 connect( layer, &QgsVectorLayer::destroyed,
this, &QgsTransactionGroup::onLayerDeleted );
71 void QgsTransactionGroup::onEditingStarted()
79 mTransaction->begin( errorMsg );
83 mTransaction->addLayer( layer );
90 void QgsTransactionGroup::onLayerDeleted()
92 mLayers.remove( static_cast<QgsVectorLayer *>( sender() ) );
95 void QgsTransactionGroup::onCommitChanges()
97 if ( mEditingStopping )
100 mEditingStopping =
true;
105 if ( mTransaction->commit( errMsg ) )
109 if ( layer != sender() )
113 disableTransaction();
119 QTimer::singleShot( 0, triggeringLayer, SLOT( startEditing() ) );
121 mEditingStopping =
false;
124 void QgsTransactionGroup::onRollback()
126 if ( mEditingStopping )
129 mEditingStopping =
true;
134 if ( mTransaction->rollback( errMsg ) )
138 if ( layer != triggeringLayer )
141 disableTransaction();
146 QTimer::singleShot( 0, triggeringLayer, SLOT( startEditing() ) );
148 mEditingStopping =
false;
151 void QgsTransactionGroup::disableTransaction()
153 mTransaction.reset();
169 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...
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.
QString providerType() const
Returns the provider type for this layer.
Class for storing the component parts of a PostgreSQL/RDBMS datasource URI.
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.