Skip to content
Permalink
Browse files

Rename edit buffer methods to is..., add tests

  • Loading branch information
nyalldawson committed Jul 14, 2016
1 parent dc10c8f commit 0736bf726da55f834f145a6597a61092b3f1c5db
@@ -70,42 +70,70 @@ class QgsVectorLayerEditBuffer : QObject
/** Stop editing and discard the edits */
virtual void rollBack();

/** Returns a map of new features which are not committed. */
/** Returns a map of new features which are not committed.
* @see isFeatureAdded()
*/
QgsFeatureMap addedFeatures() const;

/** Returns true if the specified feature ID has been added but not committed.
* @param id feature ID
* @note added in QGIS 3.0
* @see addedFeatures()
*/
bool featureIsAdded( QgsFeatureId id ) const;
bool isFeatureAdded( QgsFeatureId id ) const;

/** Returns a map of features with changed attributes values which are not committed */
/** Returns a map of features with changed attributes values which are not committed.
* @see isFeatureAttributesChanged()
*/
QgsChangedAttributesMap changedAttributeValues() const;

/** Returns true if the specified feature ID has had an attribute changed but not committed.
* @param id feature ID
* @note added in QGIS 3.0
* @see changedAttributeValues()
*/
bool featureHasAttributeChanges( QgsFeatureId id ) const;
bool isFeatureAttributesChanged( QgsFeatureId id ) const;

/** Returns a list of deleted attributes fields which are not committed. The list is kept sorted. */
/** Returns a list of deleted attributes fields which are not committed. The list is kept sorted.
* @see isAttributeDeleted()
*/
QgsAttributeList deletedAttributeIds() const;

/** Returns true if the specified attribute has been deleted but not committed.
* @param index attribute index
* @note added in QGIS 3.0
* @see deletedAttributeIds()
*/
bool isAttributeDeleted( int index ) const;

/** Returns a list of added attributes fields which are not committed */
QList<QgsField> addedAttributes() const;

/** Returns a map of features with changed geometries which are not committed. */
/** Returns a map of features with changed geometries which are not committed.
* @see hasFeatureGeometryChange()
*/
QgsGeometryMap changedGeometries() const;

/** Returns true if the specified feature ID has had its geometry changed but not committed.
* @param id feature ID
* @note added in QGIS 3.0
* @see changedGeometries()
*/
bool featureHasGeometryChange( QgsFeatureId id ) const;
bool isFeatureGeometryChanged( QgsFeatureId id ) const;

/** Returns a list of deleted feature IDs which are not committed. */
/** Returns a list of deleted feature IDs which are not committed.
* @see isFeatureDeleted()
*/
QgsFeatureIds deletedFeatureIds() const;

/** Returns true if the specified feature ID has been deleted but not committed.
* @param id feature ID
* @note added in QGIS 3.0
* @see deletedFeatureIds()
*/
bool isFeatureDeleted( QgsFeatureId id ) const;


//QString dumpEditBuffer();

protected slots:
@@ -99,42 +99,70 @@ class CORE_EXPORT QgsVectorLayerEditBuffer : public QObject
/** Stop editing and discard the edits */
virtual void rollBack();

/** Returns a map of new features which are not committed. */
/** Returns a map of new features which are not committed.
* @see isFeatureAdded()
*/
QgsFeatureMap addedFeatures() const { return mAddedFeatures; }

/** Returns true if the specified feature ID has been added but not committed.
* @param id feature ID
* @note added in QGIS 3.0
* @see addedFeatures()
*/
bool featureIsAdded( QgsFeatureId id ) const { return mAddedFeatures.contains( id ); }
bool isFeatureAdded( QgsFeatureId id ) const { return mAddedFeatures.contains( id ); }

/** Returns a map of features with changed attributes values which are not committed */
/** Returns a map of features with changed attributes values which are not committed.
* @see isFeatureAttributesChanged()
*/
QgsChangedAttributesMap changedAttributeValues() const { return mChangedAttributeValues; }

/** Returns true if the specified feature ID has had an attribute changed but not committed.
* @param id feature ID
* @note added in QGIS 3.0
* @see changedAttributeValues()
*/
bool featureHasAttributeChanges( QgsFeatureId id ) const { return mChangedAttributeValues.contains( id ); }
bool isFeatureAttributesChanged( QgsFeatureId id ) const { return mChangedAttributeValues.contains( id ); }

/** Returns a list of deleted attributes fields which are not committed. The list is kept sorted. */
/** Returns a list of deleted attributes fields which are not committed. The list is kept sorted.
* @see isAttributeDeleted()
*/
QgsAttributeList deletedAttributeIds() const { return mDeletedAttributeIds; }

/** Returns a list of added attributes fields which are not committed */
/** Returns true if the specified attribute has been deleted but not committed.
* @param index attribute index
* @note added in QGIS 3.0
* @see deletedAttributeIds()
*/
bool isAttributeDeleted( int index ) const { return mDeletedAttributeIds.contains( index ); }

/** Returns a list of added attributes fields which are not committed.
*/
QList<QgsField> addedAttributes() const { return mAddedAttributes; }

/** Returns a map of features with changed geometries which are not committed. */
/** Returns a map of features with changed geometries which are not committed.
* @see hasFeatureGeometryChange()
*/
QgsGeometryMap changedGeometries() const { return mChangedGeometries; }

/** Returns true if the specified feature ID has had its geometry changed but not committed.
* @param id feature ID
* @note added in QGIS 3.0
* @see changedGeometries()
*/
bool featureHasGeometryChange( QgsFeatureId id ) const { return mChangedGeometries.contains( id ); }
bool isFeatureGeometryChanged( QgsFeatureId id ) const { return mChangedGeometries.contains( id ); }

/** Returns a list of deleted feature IDs which are not committed. */
/** Returns a list of deleted feature IDs which are not committed.
* @see isFeatureDeleted()
*/
QgsFeatureIds deletedFeatureIds() const { return mDeletedFeatureIds; }

/** Returns true if the specified feature ID has been deleted but not committed.
* @param id feature ID
* @note added in QGIS 3.0
* @see deletedFeatureIds()
*/
bool isFeatureDeleted( QgsFeatureId id ) const { return mDeletedFeatureIds.contains( id ); }

//QString dumpEditBuffer();

protected slots:
@@ -326,13 +326,13 @@ bool QgsAttributeTableFilterModel::filterAcceptsRow( int sourceRow, const QModel
{
QgsFeatureId fid = masterModel()->rowToId( sourceRow );

if ( editBuffer->featureIsAdded( fid ) )
if ( editBuffer->isFeatureAdded( fid ) )
return true;

if ( editBuffer->featureHasAttributeChanges( fid ) )
if ( editBuffer->isFeatureAttributesChanged( fid ) )
return true;

if ( editBuffer->featureHasGeometryChange( fid ) )
if ( editBuffer->isFeatureGeometryChanged( fid ) )
return true;

return false;
@@ -111,11 +111,11 @@ QVariant QgsFeatureListModel::data( const QModelIndex &index, int role ) const

if ( editBuffer )
{
if ( editBuffer->featureIsAdded( feat.id() ) )
if ( editBuffer->isFeatureAdded( feat.id() ) )
{
featInfo.isNew = true;
}
if ( editBuffer->featureHasAttributeChanges( feat.id() ) )
if ( editBuffer->isFeatureAttributesChanged( feat.id() ) )
{
featInfo.isEdited = true;
}
@@ -1219,7 +1219,7 @@ void QgsGrassProvider::onFeatureAdded( QgsFeatureId fid )
}
// geometry
const QgsAbstractGeometryV2 *geometry = 0;
if ( !mEditBuffer->featureIsAdded( fid ) )
if ( !mEditBuffer->isFeatureAdded( fid ) )
{
#ifdef QGISDEBUG
QgsDebugMsg( "the feature is missing in buffer addedFeatures :" );
@@ -94,6 +94,7 @@ ADD_PYTHON_TEST(PyQgsUnitTypes test_qgsunittypes.py)
ADD_PYTHON_TEST(PyQgsVectorColorRamp test_qgsvectorcolorramp.py)
ADD_PYTHON_TEST(PyQgsVectorFileWriter test_qgsvectorfilewriter.py)
ADD_PYTHON_TEST(PyQgsVectorLayer test_qgsvectorlayer.py)
ADD_PYTHON_TEST(PyQgsVectorLayerEditBuffer test_qgsvectorlayereditbuffer.py)
ADD_PYTHON_TEST(PyQgsZonalStatistics test_qgszonalstatistics.py)
ADD_PYTHON_TEST(PyQgsMapLayerRegistry test_qgsmaplayerregistry.py)
ADD_PYTHON_TEST(PyQgsVirtualLayerProvider test_provider_virtual.py)

0 comments on commit 0736bf7

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