diff --git a/python/PyQt6/core/auto_generated/symbology/qgssymbol.sip.in b/python/PyQt6/core/auto_generated/symbology/qgssymbol.sip.in index 95197f0cf6d..db508b4390d 100644 --- a/python/PyQt6/core/auto_generated/symbology/qgssymbol.sip.in +++ b/python/PyQt6/core/auto_generated/symbology/qgssymbol.sip.in @@ -731,6 +731,13 @@ clockwise for exterior rings and counter-clockwise for interior rings. %Docstring Retrieve a cloned list of all layers that make up this symbol. Ownership is transferred to the caller. +%End + + void copyCommonProperties( const QgsSymbol *other ); +%Docstring +Copies common properties from an ``other`` symbol to this symbol. + +.. versionadded:: 3.40 %End void renderUsingLayer( QgsSymbolLayer *layer, QgsSymbolRenderContext &context, Qgis::GeometryType geometryType = Qgis::GeometryType::Unknown, const QPolygonF *points = 0, const QVector *rings = 0 ); diff --git a/python/core/auto_generated/symbology/qgssymbol.sip.in b/python/core/auto_generated/symbology/qgssymbol.sip.in index 30e0d693733..cac0d23055f 100644 --- a/python/core/auto_generated/symbology/qgssymbol.sip.in +++ b/python/core/auto_generated/symbology/qgssymbol.sip.in @@ -731,6 +731,13 @@ clockwise for exterior rings and counter-clockwise for interior rings. %Docstring Retrieve a cloned list of all layers that make up this symbol. Ownership is transferred to the caller. +%End + + void copyCommonProperties( const QgsSymbol *other ); +%Docstring +Copies common properties from an ``other`` symbol to this symbol. + +.. versionadded:: 3.40 %End void renderUsingLayer( QgsSymbolLayer *layer, QgsSymbolRenderContext &context, Qgis::GeometryType geometryType = Qgis::GeometryType::Unknown, const QPolygonF *points = 0, const QVector *rings = 0 ); diff --git a/src/core/symbology/qgsfillsymbol.cpp b/src/core/symbology/qgsfillsymbol.cpp index a9f7ac335bd..62601d20503 100644 --- a/src/core/symbology/qgsfillsymbol.cpp +++ b/src/core/symbology/qgsfillsymbol.cpp @@ -144,15 +144,7 @@ QVector *QgsFillSymbol::translateRings( const QVector *rin QgsFillSymbol *QgsFillSymbol::clone() const { QgsFillSymbol *cloneSymbol = new QgsFillSymbol( cloneLayers() ); - cloneSymbol->setOpacity( mOpacity ); - Q_NOWARN_DEPRECATED_PUSH - cloneSymbol->setLayer( mLayer ); - Q_NOWARN_DEPRECATED_POP - cloneSymbol->setClipFeaturesToExtent( mClipFeaturesToExtent ); - cloneSymbol->setForceRHR( mForceRHR ); - cloneSymbol->setDataDefinedProperties( dataDefinedProperties() ); - cloneSymbol->setFlags( mSymbolFlags ); - cloneSymbol->setAnimationSettings( mAnimationSettings ); + cloneSymbol->copyCommonProperties( this ); return cloneSymbol; } @@ -170,5 +162,3 @@ void QgsFillSymbol::setAngle( double angle ) const fillLayer->setAngle( angle ); } } - - diff --git a/src/core/symbology/qgslinesymbol.cpp b/src/core/symbology/qgslinesymbol.cpp index a33c2f8cc2e..c90902df5f3 100644 --- a/src/core/symbology/qgslinesymbol.cpp +++ b/src/core/symbology/qgslinesymbol.cpp @@ -303,14 +303,6 @@ void QgsLineSymbol::renderPolylineUsingLayer( QgsLineSymbolLayer *layer, const Q QgsLineSymbol *QgsLineSymbol::clone() const { QgsLineSymbol *cloneSymbol = new QgsLineSymbol( cloneLayers() ); - cloneSymbol->setOpacity( mOpacity ); - Q_NOWARN_DEPRECATED_PUSH - cloneSymbol->setLayer( mLayer ); - Q_NOWARN_DEPRECATED_POP - cloneSymbol->setClipFeaturesToExtent( mClipFeaturesToExtent ); - cloneSymbol->setForceRHR( mForceRHR ); - cloneSymbol->setDataDefinedProperties( dataDefinedProperties() ); - cloneSymbol->setFlags( mSymbolFlags ); - cloneSymbol->setAnimationSettings( mAnimationSettings ); + cloneSymbol->copyCommonProperties( this ); return cloneSymbol; } diff --git a/src/core/symbology/qgsmarkersymbol.cpp b/src/core/symbology/qgsmarkersymbol.cpp index 30c15b48699..cf496a7d2cd 100644 --- a/src/core/symbology/qgsmarkersymbol.cpp +++ b/src/core/symbology/qgsmarkersymbol.cpp @@ -523,14 +523,6 @@ QRectF QgsMarkerSymbol::bounds( QPointF point, QgsRenderContext &context, const QgsMarkerSymbol *QgsMarkerSymbol::clone() const { QgsMarkerSymbol *cloneSymbol = new QgsMarkerSymbol( cloneLayers() ); - cloneSymbol->setOpacity( mOpacity ); - Q_NOWARN_DEPRECATED_PUSH - cloneSymbol->setLayer( mLayer ); - Q_NOWARN_DEPRECATED_POP - cloneSymbol->setClipFeaturesToExtent( mClipFeaturesToExtent ); - cloneSymbol->setForceRHR( mForceRHR ); - cloneSymbol->setDataDefinedProperties( dataDefinedProperties() ); - cloneSymbol->setFlags( mSymbolFlags ); - cloneSymbol->setAnimationSettings( mAnimationSettings ); + cloneSymbol->copyCommonProperties( this ); return cloneSymbol; } diff --git a/src/core/symbology/qgssymbol.cpp b/src/core/symbology/qgssymbol.cpp index 1c7f909b060..ef8132f045d 100644 --- a/src/core/symbology/qgssymbol.cpp +++ b/src/core/symbology/qgssymbol.cpp @@ -1972,3 +1972,17 @@ void QgsSymbol::stopFeatureRender( const QgsFeature &feature, QgsRenderContext & } } } + +void QgsSymbol::copyCommonProperties( const QgsSymbol *other ) +{ + mOpacity = other->mOpacity; + mClipFeaturesToExtent = other->mClipFeaturesToExtent; + mForceRHR = other->mForceRHR; + mDataDefinedProperties = other->mDataDefinedProperties; + mSymbolFlags = other->mSymbolFlags; + mAnimationSettings = other->mAnimationSettings; + + Q_NOWARN_DEPRECATED_PUSH + mLayer = other->mLayer; + Q_NOWARN_DEPRECATED_POP +} diff --git a/src/core/symbology/qgssymbol.h b/src/core/symbology/qgssymbol.h index 4bac791d9c1..c5707a0f1cd 100644 --- a/src/core/symbology/qgssymbol.h +++ b/src/core/symbology/qgssymbol.h @@ -759,6 +759,13 @@ class CORE_EXPORT QgsSymbol */ QgsSymbolLayerList cloneLayers() const SIP_FACTORY; + /** + * Copies common properties from an \a other symbol to this symbol. + * + * \since QGIS 3.40 + */ + void copyCommonProperties( const QgsSymbol *other ); + /** * Renders a context using a particular symbol layer without passing in a * geometry. This is used as fallback, if the symbol being rendered is not