37 if ( mConnString.isEmpty() )
47 mLayers.insert( layer );
50 connect( layer, &QgsVectorLayer::destroyed,
this, &QgsTransactionGroup::onLayerDeleted );
62 const auto constMLayers = mLayers;
65 if ( layer->isModified() )
71 void QgsTransactionGroup::onEditingStarted()
81 mTransaction->begin( errorMsg );
83 const auto constMLayers = mLayers;
86 mTransaction->addLayer( layer );
87 layer->startEditing();
93 void QgsTransactionGroup::onLayerDeleted()
98 void QgsTransactionGroup::onCommitChanges()
100 if ( mEditingStopping )
103 mEditingStopping =
true;
105 QgsVectorLayer *triggeringLayer = qobject_cast<QgsVectorLayer *>( sender() );
108 if ( mTransaction->commit( errMsg ) )
110 const auto constMLayers = mLayers;
113 if ( layer != sender() )
114 layer->commitChanges();
117 disableTransaction();
125 mEditingStopping =
false;
128 void QgsTransactionGroup::onRollback()
130 if ( mEditingStopping )
133 mEditingStopping =
true;
135 QgsVectorLayer *triggeringLayer = qobject_cast<QgsVectorLayer *>( sender() );
138 if ( mTransaction->rollback( errMsg ) )
140 const auto constMLayers = mLayers;
143 if ( layer != triggeringLayer )
146 disableTransaction();
153 mEditingStopping =
false;
156 void QgsTransactionGroup::disableTransaction()
158 mTransaction.reset();
160 const auto constMLayers = mLayers;
175 return mLayers.isEmpty();