Update vector layer edits rollback method and app rollback actions

- Make optional whether edit buffer is deleted
- Returns optional functionality where rollback was similar to setting undo stack to index 0
This commit is contained in:
Larry Shaffer 2013-02-10 13:44:33 -07:00
parent ba2082ef86
commit 8feb84af46
3 changed files with 12 additions and 6 deletions

View File

@ -5449,7 +5449,7 @@ void QgisApp::cancelEdits( QgsMapLayer *layer, bool leaveEditable, bool triggerR
mSaveRollbackInProgress = true;
mMapCanvas->freeze( true );
if ( !vlayer->rollBack() )
if ( !vlayer->rollBack( !leaveEditable ) )
{
mSaveRollbackInProgress = false;
QMessageBox::information( 0,

View File

@ -3326,7 +3326,7 @@ const QStringList &QgsVectorLayer::commitErrors()
return mCommitErrors;
}
bool QgsVectorLayer::rollBack()
bool QgsVectorLayer::rollBack( bool deleteBuffer )
{
if ( !mEditBuffer )
{
@ -3344,8 +3344,12 @@ bool QgsVectorLayer::rollBack()
updateFields();
delete mEditBuffer;
mEditBuffer = 0;
if ( deleteBuffer )
{
delete mEditBuffer;
mEditBuffer = 0;
undoStack()->clear();
}
emit editingStopped();
// invalidate the cache so the layer updates properly to show its original

View File

@ -713,8 +713,10 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer
bool commitChanges();
const QStringList &commitErrors();
/** Stop editing and discard the edits */
bool rollBack();
/** Stop editing and discard the edits
* @param deleteBuffer whether to delete editing buffer (added in 1.9)
*/
bool rollBack( bool deleteBuffer = true );
/**get edit type*/
EditType editType( int idx );