Skip to content
Permalink
Browse files
When Stopping Editing and Saving Changes, if the commit was *unsucces…
…sful*, retain the in-memory edits. Previously the in-memory edits would be erased anyway.

Note this is not a complete solution as commits are currently a 3- or 4-stage process, and if one stage fails the chain cannot always be rolled-back easily.  If this is the case then a detailed error message is given to the user to assist their understanding of the discrepency.

This commit should be a bug fix for trac #131, but I don't have the environment to test it fully - the bug submitter will have to assist there.

Bonus feature: Tidied up some variable names in QgsVectorLayer - makes it clearer what they contain.



git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@5591 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
morb_au committed Jul 14, 2006
1 parent ae747bf commit 38dabe58301095461643f866131292dc5f3ae05c
Showing with 241 additions and 94 deletions.
  1. +17 −13 src/gui/qgsattributetable.cpp
  2. +17 −3 src/gui/qgsattributetable.h
  3. +159 −67 src/gui/qgsvectorlayer.cpp
  4. +48 −11 src/gui/qgsvectorlayer.h
@@ -369,6 +369,8 @@ void QgsAttributeTable::deleteAttribute(const QString& name)
mEdited=true;
}


/* Deprecated: See QgisApp::editCopy() instead */
void QgsAttributeTable::copySelectedRows()
{
// Copy selected rows to the clipboard
@@ -413,21 +415,23 @@ void QgsAttributeTable::copySelectedRows()

bool QgsAttributeTable::commitChanges(QgsVectorLayer* layer)
{
bool returnvalue=true;
if(layer)
{
if(!layer->commitAttributeChanges(mDeletedAttributes, mAddedAttributes, mChangedValues))
{
returnvalue=false;
}
}
else
{
returnvalue=false;
}
bool isSuccessful = FALSE;

if(layer)
{
isSuccessful = layer->commitAttributeChanges(
mDeletedAttributes,
mAddedAttributes,
mChangedValues);
}

if (isSuccessful)
{
mEdited=false;
clearEditingStructures();
return returnvalue;
}

return isSuccessful;
}

bool QgsAttributeTable::rollBack(QgsVectorLayer* layer)
@@ -70,11 +70,25 @@ class QgsAttributeTable:public Q3Table
/**Deletes an attribute (but does not commit it)
@param name attribute name*/
void deleteAttribute(const QString& name);
/**Copies the selected rows to the clipboard */

/** Copies the selected rows to the clipboard
Deprecated: See QgisApp::editCopy() instead */
void copySelectedRows();
/**Delegates to QgsVectorLayer to decide, which changes
belong to not commited features or to commited ones*/

/**
Attempts to commit any changes to disk. Returns the result of the attempt.
If a commit fails, the in-memory changes are left alone.
This allows editing to continue if the commit failed on e.g. a
disallowed value in a Postgres database - the user can re-edit and try
again.
Delegates to QgsVectorLayer to decide, which changes
belong to not commited features or to commited ones.
*/
bool commitChanges(QgsVectorLayer* layer);

/**Discard all changes and restore
the state before editing was started*/
bool rollBack(QgsVectorLayer* layer);

0 comments on commit 38dabe5

Please sign in to comment.