Skip to content
Permalink
Browse files

Change QgsProcessingAlgorithm::supportInPlaceEdit to use QgsMapLayer,…

… not QgsVectorLayer

Because at some stage in the future we may allow in-place edits to raster layers,
and we don't want to have to break API for this.
  • Loading branch information
nyalldawson committed Sep 21, 2018
1 parent e2068b8 commit 4b245520974418a02712fd37db7a0ab43b9a4f56
Showing with 91 additions and 42 deletions.
  1. +3 −2 python/core/auto_generated/processing/qgsprocessingalgorithm.sip.in
  2. +1 −1 src/analysis/processing/qgsalgorithmaddincrementalfield.cpp
  3. +1 −1 src/analysis/processing/qgsalgorithmaddincrementalfield.h
  4. +1 −1 src/analysis/processing/qgsalgorithmassignprojection.cpp
  5. +1 −1 src/analysis/processing/qgsalgorithmassignprojection.h
  6. +7 −3 src/analysis/processing/qgsalgorithmclip.cpp
  7. +1 −1 src/analysis/processing/qgsalgorithmclip.h
  8. +10 −2 src/analysis/processing/qgsalgorithmdrape.cpp
  9. +2 −2 src/analysis/processing/qgsalgorithmdrape.h
  10. +1 −1 src/analysis/processing/qgsalgorithmdropmzvalues.cpp
  11. +1 −1 src/analysis/processing/qgsalgorithmdropmzvalues.h
  12. +11 −3 src/analysis/processing/qgsalgorithmfiltervertices.cpp
  13. +2 −2 src/analysis/processing/qgsalgorithmfiltervertices.h
  14. +6 −2 src/analysis/processing/qgsalgorithmfixgeometries.cpp
  15. +1 −1 src/analysis/processing/qgsalgorithmfixgeometries.h
  16. +5 −1 src/analysis/processing/qgsalgorithmminimumenclosingcircle.cpp
  17. +1 −1 src/analysis/processing/qgsalgorithmminimumenclosingcircle.h
  18. +5 −1 src/analysis/processing/qgsalgorithmmultiringconstantbuffer.cpp
  19. +1 −1 src/analysis/processing/qgsalgorithmmultiringconstantbuffer.h
  20. +5 −1 src/analysis/processing/qgsalgorithmorientedminimumboundingbox.cpp
  21. +1 −1 src/analysis/processing/qgsalgorithmorientedminimumboundingbox.h
  22. +5 −1 src/analysis/processing/qgsalgorithmpromotetomultipart.cpp
  23. +1 −1 src/analysis/processing/qgsalgorithmpromotetomultipart.h
  24. +2 −2 src/analysis/processing/qgsalgorithmsegmentize.cpp
  25. +2 −2 src/analysis/processing/qgsalgorithmsegmentize.h
  26. +5 −1 src/analysis/processing/qgsalgorithmtranslate.cpp
  27. +1 −1 src/analysis/processing/qgsalgorithmtranslate.h
  28. +6 −2 src/core/processing/qgsprocessingalgorithm.cpp
  29. +2 −2 src/core/processing/qgsprocessingalgorithm.h
@@ -812,7 +812,7 @@ should correspond to the invalid source parameter name.
.. versionadded:: 3.2
%End

virtual bool supportInPlaceEdit( const QgsVectorLayer *layer ) const;
virtual bool supportInPlaceEdit( const QgsMapLayer *layer ) const;
%Docstring
Checks whether this algorithm supports in-place editing on the given ``layer``
Default implementation returns false.
@@ -976,7 +976,8 @@ Returns the feature request used for fetching features to process from the
source layer. The default implementation requests all attributes and geometry.
%End

virtual bool supportInPlaceEdit( const QgsVectorLayer *layer ) const;
virtual bool supportInPlaceEdit( const QgsMapLayer *layer ) const;

%Docstring
Checks whether this algorithm supports in-place editing on the given ``layer``
Default implementation for feature based algorithms run some basic compatibility
@@ -162,7 +162,7 @@ QgsFeatureList QgsAddIncrementalFieldAlgorithm::processFeature( const QgsFeature
return QgsFeatureList() << f;
}

bool QgsAddIncrementalFieldAlgorithm::supportInPlaceEdit( const QgsVectorLayer *layer ) const
bool QgsAddIncrementalFieldAlgorithm::supportInPlaceEdit( const QgsMapLayer *layer ) const
{
Q_UNUSED( layer );
return false;
@@ -53,7 +53,7 @@ class QgsAddIncrementalFieldAlgorithm : public QgsProcessingFeatureBasedAlgorith
bool prepareAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
QgsFeatureRequest request() const override;
QgsFeatureList processFeature( const QgsFeature &feature, QgsProcessingContext &context, QgsProcessingFeedback *feedback ) override;
bool supportInPlaceEdit( const QgsVectorLayer *layer ) const override;
bool supportInPlaceEdit( const QgsMapLayer *layer ) const override;

private:

@@ -62,7 +62,7 @@ QgsAssignProjectionAlgorithm *QgsAssignProjectionAlgorithm::createInstance() con
return new QgsAssignProjectionAlgorithm();
}

bool QgsAssignProjectionAlgorithm::supportInPlaceEdit( const QgsVectorLayer *layer ) const
bool QgsAssignProjectionAlgorithm::supportInPlaceEdit( const QgsMapLayer *layer ) const
{
Q_UNUSED( layer );
return false;
@@ -41,7 +41,7 @@ class QgsAssignProjectionAlgorithm : public QgsProcessingFeatureBasedAlgorithm
QString groupId() const override;
QString shortHelpString() const override;
QgsAssignProjectionAlgorithm *createInstance() const override SIP_FACTORY;
bool supportInPlaceEdit( const QgsVectorLayer *layer ) const override;
bool supportInPlaceEdit( const QgsMapLayer *layer ) const override;

protected:

@@ -18,6 +18,7 @@
#include "qgsalgorithmclip.h"
#include "qgsgeometryengine.h"
#include "qgsoverlayutils.h"
#include "qgsvectorlayer.h"

///@cond PRIVATE

@@ -76,10 +77,13 @@ QgsClipAlgorithm *QgsClipAlgorithm::createInstance() const
return new QgsClipAlgorithm();
}

bool QgsClipAlgorithm::supportInPlaceEdit( const QgsVectorLayer *layer ) const
bool QgsClipAlgorithm::supportInPlaceEdit( const QgsMapLayer *l ) const
{
Q_UNUSED( layer );
return true;
const QgsVectorLayer *layer = qobject_cast< const QgsVectorLayer * >( l );
if ( !layer )
return false;

return layer->isSpatial();
}

QVariantMap QgsClipAlgorithm::processAlgorithm( const QVariantMap &parameters, QgsProcessingContext &context, QgsProcessingFeedback *feedback )
@@ -44,7 +44,7 @@ class QgsClipAlgorithm : public QgsProcessingAlgorithm
QString groupId() const override;
QString shortHelpString() const override;
QgsClipAlgorithm *createInstance() const override SIP_FACTORY;
bool supportInPlaceEdit( const QgsVectorLayer *layer ) const override;
bool supportInPlaceEdit( const QgsMapLayer *layer ) const override;

QgsProcessingAlgorithm::Flags flags() const override;
protected:
@@ -196,8 +196,12 @@ QgsDrapeToZAlgorithm *QgsDrapeToZAlgorithm::createInstance() const
return new QgsDrapeToZAlgorithm();
}

bool QgsDrapeToZAlgorithm::supportInPlaceEdit( const QgsVectorLayer *layer ) const
bool QgsDrapeToZAlgorithm::supportInPlaceEdit( const QgsMapLayer *l ) const
{
const QgsVectorLayer *layer = qobject_cast< const QgsVectorLayer * >( l );
if ( !layer )
return false;

if ( ! QgsDrapeAlgorithmBase::supportInPlaceEdit( layer ) )
return false;
return QgsWkbTypes::hasZ( layer->wkbType() );
@@ -255,8 +259,12 @@ QgsDrapeToMAlgorithm *QgsDrapeToMAlgorithm::createInstance() const
return new QgsDrapeToMAlgorithm();
}

bool QgsDrapeToMAlgorithm::supportInPlaceEdit( const QgsVectorLayer *layer ) const
bool QgsDrapeToMAlgorithm::supportInPlaceEdit( const QgsMapLayer *l ) const
{
const QgsVectorLayer *layer = qobject_cast< const QgsVectorLayer * >( l );
if ( !layer )
return false;

if ( ! QgsDrapeAlgorithmBase::supportInPlaceEdit( layer ) )
return false;
return QgsWkbTypes::hasM( layer->wkbType() );
@@ -73,7 +73,7 @@ class QgsDrapeToZAlgorithm : public QgsDrapeAlgorithmBase
QString shortHelpString() const override;
QString shortDescription() const override;
QgsDrapeToZAlgorithm *createInstance() const override SIP_FACTORY;
bool supportInPlaceEdit( const QgsVectorLayer *layer ) const override;
bool supportInPlaceEdit( const QgsMapLayer *layer ) const override;

protected:

@@ -97,7 +97,7 @@ class QgsDrapeToMAlgorithm : public QgsDrapeAlgorithmBase
QString shortHelpString() const override;
QString shortDescription() const override;
QgsDrapeToMAlgorithm *createInstance() const override SIP_FACTORY;
bool supportInPlaceEdit( const QgsVectorLayer *layer ) const override;
bool supportInPlaceEdit( const QgsMapLayer *layer ) const override;

protected:

@@ -59,7 +59,7 @@ QgsDropMZValuesAlgorithm *QgsDropMZValuesAlgorithm::createInstance() const
return new QgsDropMZValuesAlgorithm();
}

bool QgsDropMZValuesAlgorithm::supportInPlaceEdit( const QgsVectorLayer *layer ) const
bool QgsDropMZValuesAlgorithm::supportInPlaceEdit( const QgsMapLayer *layer ) const
{
Q_UNUSED( layer );
return false;
@@ -41,7 +41,7 @@ class QgsDropMZValuesAlgorithm : public QgsProcessingFeatureBasedAlgorithm
QString groupId() const override;
QString shortHelpString() const override;
QgsDropMZValuesAlgorithm *createInstance() const override SIP_FACTORY;
bool supportInPlaceEdit( const QgsVectorLayer *layer ) const override;
bool supportInPlaceEdit( const QgsMapLayer *layer ) const override;

protected:

@@ -136,8 +136,12 @@ QgsFilterVerticesByM *QgsFilterVerticesByM::createInstance() const
return new QgsFilterVerticesByM();
}

bool QgsFilterVerticesByM::supportInPlaceEdit( const QgsVectorLayer *layer ) const
bool QgsFilterVerticesByM::supportInPlaceEdit( const QgsMapLayer *l ) const
{
const QgsVectorLayer *layer = qobject_cast< const QgsVectorLayer * >( l );
if ( !layer )
return false;

if ( ! QgsFilterVerticesAlgorithmBase::supportInPlaceEdit( layer ) )
return false;
return QgsWkbTypes::hasM( layer->wkbType() );
@@ -182,10 +186,14 @@ QgsFilterVerticesByZ *QgsFilterVerticesByZ::createInstance() const
return new QgsFilterVerticesByZ();
}

bool QgsFilterVerticesByZ::supportInPlaceEdit( const QgsVectorLayer *layer ) const
bool QgsFilterVerticesByZ::supportInPlaceEdit( const QgsMapLayer *l ) const
{
const QgsVectorLayer *layer = qobject_cast< const QgsVectorLayer * >( l );
if ( !layer )
return false;

if ( ! QgsFilterVerticesAlgorithmBase::supportInPlaceEdit( layer ) )
return false;
return false;
return QgsWkbTypes::hasZ( layer->wkbType() );
}

@@ -72,7 +72,7 @@ class QgsFilterVerticesByM : public QgsFilterVerticesAlgorithmBase
QString displayName() const override;
QStringList tags() const override;
QgsFilterVerticesByM *createInstance() const override SIP_FACTORY;
bool supportInPlaceEdit( const QgsVectorLayer *layer ) const override;
bool supportInPlaceEdit( const QgsMapLayer *layer ) const override;

private:

@@ -95,7 +95,7 @@ class QgsFilterVerticesByZ : public QgsFilterVerticesAlgorithmBase
QString displayName() const override;
QStringList tags() const override;
QgsFilterVerticesByZ *createInstance() const override SIP_FACTORY;
bool supportInPlaceEdit( const QgsVectorLayer *layer ) const override;
bool supportInPlaceEdit( const QgsMapLayer *layer ) const override;

private:

@@ -73,9 +73,13 @@ QgsFixGeometriesAlgorithm *QgsFixGeometriesAlgorithm::createInstance() const
return new QgsFixGeometriesAlgorithm();
}

bool QgsFixGeometriesAlgorithm::supportInPlaceEdit( const QgsVectorLayer *layer ) const
bool QgsFixGeometriesAlgorithm::supportInPlaceEdit( const QgsMapLayer *l ) const
{
if ( ! QgsProcessingFeatureBasedAlgorithm::supportInPlaceEdit( layer ) )
const QgsVectorLayer *layer = qobject_cast< const QgsVectorLayer * >( l );
if ( !layer )
return false;

if ( !layer->isSpatial() || ! QgsProcessingFeatureBasedAlgorithm::supportInPlaceEdit( layer ) )
return false;
// The algorithm would drop M, so disable it if the layer has M
return ! QgsWkbTypes::hasM( layer->wkbType() );
@@ -41,7 +41,7 @@ class QgsFixGeometriesAlgorithm : public QgsProcessingFeatureBasedAlgorithm
QString groupId() const override;
QString shortHelpString() const override;
QgsFixGeometriesAlgorithm *createInstance() const override SIP_FACTORY;
bool supportInPlaceEdit( const QgsVectorLayer *layer ) const override;
bool supportInPlaceEdit( const QgsMapLayer *layer ) const override;

protected:
QgsProcessingFeatureSource::Flag sourceFlags() const override;
@@ -73,8 +73,12 @@ QgsMinimumEnclosingCircleAlgorithm *QgsMinimumEnclosingCircleAlgorithm::createIn
return new QgsMinimumEnclosingCircleAlgorithm();
}

bool QgsMinimumEnclosingCircleAlgorithm::supportInPlaceEdit( const QgsVectorLayer *layer ) const
bool QgsMinimumEnclosingCircleAlgorithm::supportInPlaceEdit( const QgsMapLayer *l ) const
{
const QgsVectorLayer *layer = qobject_cast< const QgsVectorLayer * >( l );
if ( !layer )
return false;

if ( ! QgsProcessingFeatureBasedAlgorithm::supportInPlaceEdit( layer ) )
return false;
// (no Z no M)
@@ -42,7 +42,7 @@ class QgsMinimumEnclosingCircleAlgorithm : public QgsProcessingFeatureBasedAlgor
QString groupId() const override;
QString shortHelpString() const override;
QgsMinimumEnclosingCircleAlgorithm *createInstance() const override SIP_FACTORY;
bool supportInPlaceEdit( const QgsVectorLayer *layer ) const override;
bool supportInPlaceEdit( const QgsMapLayer *layer ) const override;

protected:
QString outputName() const override;
@@ -78,8 +78,12 @@ void QgsMultiRingConstantBufferAlgorithm::initParameters( const QVariantMap & )
addParameter( distance.release() );
}

bool QgsMultiRingConstantBufferAlgorithm::supportInPlaceEdit( const QgsVectorLayer *layer ) const
bool QgsMultiRingConstantBufferAlgorithm::supportInPlaceEdit( const QgsMapLayer *l ) const
{
const QgsVectorLayer *layer = qobject_cast< const QgsVectorLayer * >( l );
if ( !layer )
return false;

if ( ! QgsProcessingFeatureBasedAlgorithm::supportInPlaceEdit( layer ) )
return false;
// Polygons only
@@ -42,7 +42,7 @@ class QgsMultiRingConstantBufferAlgorithm : public QgsProcessingFeatureBasedAlgo
QString shortHelpString() const override;
QgsMultiRingConstantBufferAlgorithm *createInstance() const override SIP_FACTORY;
void initParameters( const QVariantMap &configuration = QVariantMap() ) override;
bool supportInPlaceEdit( const QgsVectorLayer *layer ) const override;
bool supportInPlaceEdit( const QgsMapLayer *layer ) const override;

protected:

@@ -67,8 +67,12 @@ QgsOrientedMinimumBoundingBoxAlgorithm *QgsOrientedMinimumBoundingBoxAlgorithm::
return new QgsOrientedMinimumBoundingBoxAlgorithm();
}

bool QgsOrientedMinimumBoundingBoxAlgorithm::supportInPlaceEdit( const QgsVectorLayer *layer ) const
bool QgsOrientedMinimumBoundingBoxAlgorithm::supportInPlaceEdit( const QgsMapLayer *l ) const
{
const QgsVectorLayer *layer = qobject_cast< const QgsVectorLayer * >( l );
if ( !layer )
return false;

if ( ! QgsProcessingFeatureBasedAlgorithm::supportInPlaceEdit( layer ) )
return false;
// Polygons only
@@ -41,7 +41,7 @@ class QgsOrientedMinimumBoundingBoxAlgorithm : public QgsProcessingFeatureBasedA
QString groupId() const override;
QString shortHelpString() const override;
QgsOrientedMinimumBoundingBoxAlgorithm *createInstance() const override SIP_FACTORY;
bool supportInPlaceEdit( const QgsVectorLayer *layer ) const override;
bool supportInPlaceEdit( const QgsMapLayer *layer ) const override;

protected:
QString outputName() const override;
@@ -66,8 +66,12 @@ QgsPromoteToMultipartAlgorithm *QgsPromoteToMultipartAlgorithm::createInstance()
return new QgsPromoteToMultipartAlgorithm();
}

bool QgsPromoteToMultipartAlgorithm::supportInPlaceEdit( const QgsVectorLayer *layer ) const
bool QgsPromoteToMultipartAlgorithm::supportInPlaceEdit( const QgsMapLayer *l ) const
{
const QgsVectorLayer *layer = qobject_cast< const QgsVectorLayer * >( l );
if ( !layer )
return false;

if ( ! QgsProcessingFeatureBasedAlgorithm::supportInPlaceEdit( layer ) )
return false;
return QgsWkbTypes::isMultiType( layer->wkbType() );
@@ -44,7 +44,7 @@ class QgsPromoteToMultipartAlgorithm : public QgsProcessingFeatureBasedAlgorithm
QString groupId() const override;
QString shortHelpString() const override;
QgsPromoteToMultipartAlgorithm *createInstance() const override SIP_FACTORY;
bool supportInPlaceEdit( const QgsVectorLayer *layer ) const override;
bool supportInPlaceEdit( const QgsMapLayer *layer ) const override;

protected:
QString outputName() const override;
@@ -78,7 +78,7 @@ void QgsSegmentizeByMaximumDistanceAlgorithm::initParameters( const QVariantMap
addParameter( tolerance.release() );
}

bool QgsSegmentizeByMaximumDistanceAlgorithm::supportInPlaceEdit( const QgsVectorLayer *layer ) const
bool QgsSegmentizeByMaximumDistanceAlgorithm::supportInPlaceEdit( const QgsMapLayer *layer ) const
{
Q_UNUSED( layer );
return false;
@@ -173,7 +173,7 @@ void QgsSegmentizeByMaximumAngleAlgorithm::initParameters( const QVariantMap & )
addParameter( tolerance.release() );
}

bool QgsSegmentizeByMaximumAngleAlgorithm::supportInPlaceEdit( const QgsVectorLayer *layer ) const
bool QgsSegmentizeByMaximumAngleAlgorithm::supportInPlaceEdit( const QgsMapLayer *layer ) const
{
Q_UNUSED( layer );
return false;
@@ -44,7 +44,7 @@ class QgsSegmentizeByMaximumDistanceAlgorithm : public QgsProcessingFeatureBased
QgsSegmentizeByMaximumDistanceAlgorithm *createInstance() const override SIP_FACTORY;
QList<int> inputLayerTypes() const override;
void initParameters( const QVariantMap &configuration = QVariantMap() ) override;
bool supportInPlaceEdit( const QgsVectorLayer *layer ) const override;
bool supportInPlaceEdit( const QgsMapLayer *layer ) const override;

protected:
QString outputName() const override;
@@ -78,7 +78,7 @@ class QgsSegmentizeByMaximumAngleAlgorithm : public QgsProcessingFeatureBasedAlg
QgsSegmentizeByMaximumAngleAlgorithm *createInstance() const override SIP_FACTORY;
QList<int> inputLayerTypes() const override;
void initParameters( const QVariantMap &configuration = QVariantMap() ) override;
bool supportInPlaceEdit( const QgsVectorLayer *layer ) const override;
bool supportInPlaceEdit( const QgsMapLayer *layer ) const override;

protected:
QString outputName() const override;
@@ -164,8 +164,12 @@ QgsWkbTypes::Type QgsTranslateAlgorithm::outputWkbType( QgsWkbTypes::Type inputW
}


bool QgsTranslateAlgorithm::supportInPlaceEdit( const QgsVectorLayer *layer ) const
bool QgsTranslateAlgorithm::supportInPlaceEdit( const QgsMapLayer *l ) const
{
const QgsVectorLayer *layer = qobject_cast< const QgsVectorLayer * >( l );
if ( !layer )
return false;

if ( ! QgsProcessingFeatureBasedAlgorithm::supportInPlaceEdit( layer ) )
return false;

@@ -42,7 +42,7 @@ class QgsTranslateAlgorithm : public QgsProcessingFeatureBasedAlgorithm
QString shortHelpString() const override;
QgsTranslateAlgorithm *createInstance() const override SIP_FACTORY;
void initParameters( const QVariantMap &configuration = QVariantMap() ) override;
bool supportInPlaceEdit( const QgsVectorLayer *layer ) const override;
bool supportInPlaceEdit( const QgsMapLayer *layer ) const override;

protected:
QString outputName() const override;

0 comments on commit 4b24552

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