Skip to content
Permalink
Browse files

Expose changed attributes in QgsFeatureAction and QgsVectorLayerTools

  • Loading branch information
m-kuhn committed Nov 30, 2015
1 parent 66b9b0d commit d2b506cccc0fe4b6c787318780b4f867d1f4b0da
@@ -13,8 +13,7 @@ class QgsVectorLayerTools
* @param defaultGeometry A default geometry to add to the feature
* @return True in case of success, False if the operation failed/was aborted
*/
virtual bool addFeature( QgsVectorLayer* layer, const QgsAttributeMap& defaultValues = QgsAttributeMap(), const QgsGeometry& defaultGeometry = QgsGeometry() ) const = 0;

virtual bool addFeature( QgsVectorLayer* laye, const QgsAttributeMap& defaultValues = QgsAttributeMap(), const QgsGeometry& defaultGeometry = QgsGeometry(), QgsFeature* feature /Out/ = 0 ) const = 0;

/**
* This will be called, whenever a vector layer should be switched to edit mode. Check the providers
@@ -218,6 +218,9 @@ void QgsFeatureAction::onFeatureSaved( const QgsFeature& feature )
Q_UNUSED( form ) // only used for Q_ASSERT
Q_ASSERT( form );

// Assign provider generated values
mFeature = feature;

mFeatureSaved = true;

QSettings settings;
@@ -32,12 +32,19 @@ QgsGuiVectorLayerTools::QgsGuiVectorLayerTools()
: QObject( NULL )
{}

bool QgsGuiVectorLayerTools::addFeature( QgsVectorLayer* layer, const QgsAttributeMap& defaultValues, const QgsGeometry& defaultGeometry ) const
bool QgsGuiVectorLayerTools::addFeature( QgsVectorLayer* layer, const QgsAttributeMap& defaultValues, const QgsGeometry& defaultGeometry, QgsFeature* feat ) const
{
QgsFeature f;
f.setGeometry( defaultGeometry );
QgsFeatureAction a( tr( "Add feature" ), f, layer );
return a.addFeature( defaultValues );
QgsFeature* f = feat;
if ( !feat )
f = new QgsFeature();

feat->setGeometry( defaultGeometry );
QgsFeatureAction a( tr( "Add feature" ), *f, layer );
bool added = a.addFeature( defaultValues );
if ( !feat )
delete f;

return added;
}

bool QgsGuiVectorLayerTools::startEditing( QgsVectorLayer* layer ) const
@@ -39,7 +39,7 @@ class QgsGuiVectorLayerTools : public QObject, public QgsVectorLayerTools
*
* @return True in case of success, False if the operation failed/was aborted
*/
bool addFeature( QgsVectorLayer *layer, const QgsAttributeMap& defaultValues, const QgsGeometry &defaultGeometry ) const override;
bool addFeature( QgsVectorLayer *layer, const QgsAttributeMap& defaultValues, const QgsGeometry &defaultGeometry, QgsFeature* feat = 0 ) const override;

/**
* This should be called, whenever a vector layer should be switched to edit mode. If successful
@@ -45,10 +45,10 @@ class GUI_EXPORT QgsVectorLayerTools
* @param layer The layer to which the feature should be added
* @param defaultValues Default values for the feature to add
* @param defaultGeometry A default geometry to add to the feature
* @param feature Updated feature after adding will be written back to this
* @return True in case of success, False if the operation failed/was aborted
*/
virtual bool addFeature( QgsVectorLayer* layer, const QgsAttributeMap& defaultValues = QgsAttributeMap(), const QgsGeometry& defaultGeometry = QgsGeometry() ) const = 0;

virtual bool addFeature( QgsVectorLayer* layer, const QgsAttributeMap& defaultValues = QgsAttributeMap(), const QgsGeometry& defaultGeometry = QgsGeometry(), QgsFeature* feature = 0 ) const = 0;

/**
* This will be called, whenever a vector layer should be switched to edit mode. Check the providers

0 comments on commit d2b506c

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