Skip to content
Permalink
Browse files

Remove layer edit state restrictions from transactions

  • Loading branch information
m-kuhn committed Jan 15, 2016
1 parent 0b96621 commit 82071612db1e84f4b6c2aab99379502c0ef52d95
Showing with 8 additions and 26 deletions.
  1. +4 −22 src/core/qgstransaction.cpp
  2. +4 −4 src/core/qgstransaction.h
@@ -83,18 +83,12 @@ QgsTransaction::~QgsTransaction()

bool QgsTransaction::addLayer( const QString& layerId )
{
if ( mTransactionActive )
return false;

QgsVectorLayer* layer = qobject_cast<QgsVectorLayer*>( QgsMapLayerRegistry::instance()->mapLayer( layerId ) );
return addLayer( layer );
}

bool QgsTransaction::addLayer( QgsVectorLayer* layer )
{
if ( mTransactionActive )
return false;

if ( !layer )
return false;

@@ -119,6 +113,10 @@ bool QgsTransaction::addLayer( QgsVectorLayer* layer )
connect( this, SIGNAL( afterRollback() ), layer->dataProvider(), SIGNAL( dataChanged() ) );
connect( QgsMapLayerRegistry::instance(), SIGNAL( layersWillBeRemoved( QStringList ) ), this, SLOT( onLayersDeleted( QStringList ) ) );
mLayers.insert( layer );

if ( mTransactionActive )
layer->dataProvider()->setTransaction( this );

return true;
}

@@ -141,14 +139,6 @@ bool QgsTransaction::commit( QString& errorMsg )
if ( !mTransactionActive )
return false;

Q_FOREACH ( QgsVectorLayer* l, mLayers )
{
if ( !l || l->isEditable() )
{
return false;
}
}

if ( !commitTransaction( errorMsg ) )
return false;

@@ -162,14 +152,6 @@ bool QgsTransaction::rollback( QString& errorMsg )
if ( !mTransactionActive )
return false;

Q_FOREACH ( QgsVectorLayer* l, mLayers )
{
if ( l->isEditable() )
{
return false;
}
}

if ( !rollbackTransaction( errorMsg ) )
return false;

@@ -60,10 +60,10 @@ class CORE_EXPORT QgsTransaction : public QObject

virtual ~QgsTransaction();

/** Add layer to the transaction. The layer must not be in edit mode. The transaction must not be active. */
/** Add layer to the transaction. The layer must not be in edit mode.*/
bool addLayer( const QString& layerId );

/** Add layer to the transaction. The layer must not be in edit mode. The transaction must not be active. */
/** Add layer to the transaction. The layer must not be in edit mode.*/
bool addLayer( QgsVectorLayer* layer );

/** Begin transaction
@@ -76,10 +76,10 @@ class CORE_EXPORT QgsTransaction : public QObject
* Some providers might not honour the statement timeout. */
bool begin( QString& errorMsg, int statementTimeout = 20 );

/** Commit transaction. All layers need to be in read-only mode. */
/** Commit transaction. */
bool commit( QString& errorMsg );

/** Roll back transaction. All layers need to be in read-only mode. */
/** Roll back transaction. */
bool rollback( QString& errorMsg );

/** Executes sql */

0 comments on commit 8207161

Please sign in to comment.
You can’t perform that action at this time.