27 , mEditingStarting( false )
28 , mEditingStopping( false )
49 else if ( mConnString != connString || mProviderKey != layer->
providerType() )
56 connect( layer, SIGNAL( beforeEditingStarted() ),
this, SLOT( onEditingStarted() ) );
57 connect( layer, SIGNAL( layerDeleted() ),
this, SLOT( onLayerDeleted() ) );
77 void QgsTransactionGroup::onEditingStarted()
79 if ( !mTransaction.
isNull() )
85 mTransaction->begin( errorMsg );
89 mTransaction->addLayer( layer );
91 connect( layer, SIGNAL( beforeCommitChanges() ),
this, SLOT( onCommitChanges() ) );
92 connect( layer, SIGNAL( beforeRollBack() ),
this, SLOT( onRollback() ) );
96 void QgsTransactionGroup::onLayerDeleted()
98 mLayers.
remove( qobject_cast<QgsVectorLayer*>(
sender() ) );
101 void QgsTransactionGroup::onCommitChanges()
103 if ( mEditingStopping )
106 mEditingStopping =
true;
111 if ( mTransaction->commit( errMsg ) )
119 disableTransaction();
127 mEditingStopping =
false;
130 void QgsTransactionGroup::onRollback()
132 if ( mEditingStopping )
135 mEditingStopping =
true;
140 if ( mTransaction->rollback( errMsg ) )
144 if ( layer != triggeringLayer )
147 disableTransaction();
154 mEditingStopping =
false;
157 void QgsTransactionGroup::disableTransaction()
159 mTransaction.
reset();
163 disconnect( layer, SIGNAL( beforeCommitChanges() ),
this, SLOT( onCommitChanges() ) );
164 disconnect( layer, SIGNAL( beforeRollBack() ),
this, SLOT( onRollback() ) );
QSet< QgsVectorLayer * > layers() const
Get the set of layers currently managed by this transaction group.
static QgsTransaction * create(const QString &connString, const QString &providerKey)
Creates a transaction for the specified connection string and provider.
bool commitChanges()
Attempts to commit any changes to disk.
bool startEditing()
Make layer editable.
QString source() const
Returns the source for the layer.
QString connString() const
Return the connection string used by this transaction group.
const_iterator insert(const T &value)
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
bool isEmpty() const
Returns true if there are no layers in this transaction group.
bool rollBack(bool deleteBuffer=true)
Stop editing and discard the edits.
bool addLayer(QgsVectorLayer *layer)
Add a layer to this transaction group.
QString providerKey() const
Return the provider key used by this transaction group.
virtual bool isModified() const
Returns true if the provider has been modified since the last commit.
static bool supportsTransaction(const QgsVectorLayer *layer)
Checks if a the provider of a give layer supports transactions.
Class for storing the component parts of a PostgreSQL/RDBMS datasource URI.
QString providerType() const
Return the provider type for this layer.
QgsTransactionGroup(QObject *parent=0)
bool remove(const T &value)
bool modified() const
Returns true if any of the layers in this group reports a modification.
void commitError(const QString &msg)
Will be emitted whenever there is a commit error.
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.