Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #1830 from manisandro/transaction
[FEATURE] Transactional editing for postgres layers
- Loading branch information
Showing
26 changed files
with
1,074 additions
and
201 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,51 @@ | ||
/** | ||
* This class allows to include a set of layers in a database-side transaction, | ||
* provided the layer data providers support transactions and are compatible | ||
* with each other. | ||
* | ||
* Only layers which are not in edit mode can be included in a transaction, | ||
* and all layers need to be in read-only mode for a transaction to be committed | ||
* or rolled back. | ||
* | ||
* Layers cannot only be included in one transaction at a time. | ||
* | ||
* When editing layers which are part of a transaction group, all changes are | ||
* sent directly to the data provider (bypassing the undo/redo stack), and the | ||
* changes can either be committed or rolled back on the database side via the | ||
* QgsTransaction::commit and QgsTransaction::rollback methods. | ||
* | ||
* As long as the transaction is active, the state of all layer features reflects | ||
* the current state in the transaction. | ||
* | ||
* Edits on features can get rejected if another conflicting transaction is active. | ||
*/ | ||
class QgsTransaction /Abstract/ | ||
{ | ||
%TypeHeaderCode | ||
#include <qgstransaction.h> | ||
%End | ||
public: | ||
/** Creates a transaction for the specified connection string and provider */ | ||
static QgsTransaction* create( const QString& connString, const QString& providerKey ) /Factory/; | ||
|
||
/** Creates a transaction which includes the specified layers. Connection string | ||
* and data provider are taken from the first layer */ | ||
static QgsTransaction* create( const QStringList& layerIds ) /Factory/; | ||
|
||
virtual ~QgsTransaction(); | ||
|
||
/** Add layer to the transaction. The layer must not be in edit mode. The transaction must not be active. */ | ||
bool addLayer( const QString& layerId ); | ||
|
||
/** Begin transaction */ | ||
bool begin( QString& errorMsg ); | ||
|
||
/** Commit transaction. All layers need to be in read-only mode. */ | ||
bool commit( QString& errorMsg ); | ||
|
||
/** Roll back transaction. All layers need to be in read-only mode. */ | ||
bool rollback( QString& errorMsg ); | ||
|
||
/** Executes sql */ | ||
virtual bool executeSql( const QString& sql, QString& error ) = 0; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.