mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-13 00:03:09 -04:00
Remove the deep copy functionality
This commit is contained in:
parent
8aa2e9bd9f
commit
8a6137247a
@ -67,10 +67,10 @@ class QgsMapLayer : QObject
|
||||
virtual ~QgsMapLayer();
|
||||
|
||||
|
||||
virtual QgsMapLayer *clone( bool deep ) const = 0;
|
||||
virtual QgsMapLayer *clone() const = 0;
|
||||
%Docstring
|
||||
Returns a new instance equivalent to this one.
|
||||
\param deep If true, a deep copy is done
|
||||
Returns a new instance equivalent to this one except for the id which
|
||||
is still unique.
|
||||
:return: a new layer instance
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QgsMapLayer
|
||||
@ -1045,12 +1045,10 @@ Signal emitted when the blend mode is changed, through QgsMapLayer.setBlendMode(
|
||||
|
||||
protected:
|
||||
|
||||
void clone( QgsMapLayer *layer, bool deep = false ) const;
|
||||
void clone( QgsMapLayer *layer ) const;
|
||||
%Docstring
|
||||
Copies attributes like name, short name, ... into another layer. The
|
||||
unique ID is copied too if deep parameter is true.
|
||||
Copies attributes like name, short name, ... into another layer.
|
||||
\param layer The copy recipient
|
||||
\param deep To copy the unique ID or not
|
||||
.. versionadded:: 3.0
|
||||
%End
|
||||
|
||||
|
@ -26,7 +26,7 @@ In order to be readable from project files, they should set these attributes in
|
||||
QgsPluginLayer( const QString &layerType, const QString &layerName = QString() );
|
||||
~QgsPluginLayer();
|
||||
|
||||
virtual QgsPluginLayer *clone( bool deep ) const = 0;
|
||||
virtual QgsPluginLayer *clone() const = 0;
|
||||
%Docstring
|
||||
Returns a new instance equivalent to this one.
|
||||
\param deep If true, a deep copy is done
|
||||
|
@ -334,13 +334,12 @@ class QgsVectorLayer : QgsMapLayer, QgsExpressionContextGenerator, QgsFeatureSin
|
||||
virtual ~QgsVectorLayer();
|
||||
|
||||
|
||||
virtual QgsVectorLayer *clone( bool deep = false ) const /Factory/;
|
||||
virtual QgsVectorLayer *clone() const /Factory/;
|
||||
%Docstring
|
||||
Returns a new instance equivalent to this one. A new provider is
|
||||
created for the same data source and renderers for features and diagrams
|
||||
are cloned too. Moreover, each attributes (transparency, extent, selected
|
||||
features and so on) are identicals.
|
||||
\param deep If true, a deep copy is done (unique ID is copied too)
|
||||
:return: a new layer instance
|
||||
.. versionadded:: 3.0
|
||||
:rtype: QgsVectorLayer
|
||||
|
@ -43,11 +43,10 @@ class QgsRasterLayer : QgsMapLayer
|
||||
|
||||
/** Returns a new instance equivalent to this one. A new provider is
|
||||
* created for the same data source and renderer is cloned too.
|
||||
* \param deep If true, a deep copy is done (unique ID is copy too)
|
||||
* \returns a new layer instance
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
virtual QgsRasterLayer *clone( bool deep = true ) const /Factory/;
|
||||
virtual QgsRasterLayer *clone() const /Factory/;
|
||||
|
||||
/** \brief This enumerator describes the types of shading that can be used */
|
||||
enum ColorShadingAlgorithm
|
||||
|
@ -94,7 +94,7 @@ QgsMapLayer::~QgsMapLayer()
|
||||
delete mStyleManager;
|
||||
}
|
||||
|
||||
void QgsMapLayer::clone( QgsMapLayer *layer, bool deep ) const
|
||||
void QgsMapLayer::clone( QgsMapLayer *layer ) const
|
||||
{
|
||||
layer->setBlendMode( blendMode() );
|
||||
|
||||
@ -123,11 +123,6 @@ void QgsMapLayer::clone( QgsMapLayer *layer, bool deep ) const
|
||||
layer->setDependencies( dependencies() );
|
||||
layer->setCrs( crs() );
|
||||
layer->setCustomProperties( mCustomProperties );
|
||||
|
||||
if ( deep )
|
||||
{
|
||||
layer->setId( id() );
|
||||
}
|
||||
}
|
||||
|
||||
QgsMapLayer::LayerType QgsMapLayer::type() const
|
||||
@ -140,11 +135,6 @@ QString QgsMapLayer::id() const
|
||||
return mID;
|
||||
}
|
||||
|
||||
void QgsMapLayer::setId( const QString &id )
|
||||
{
|
||||
mID = id;
|
||||
}
|
||||
|
||||
void QgsMapLayer::setName( const QString &name )
|
||||
{
|
||||
QString newName = capitalizeLayerName( name );
|
||||
|
@ -110,12 +110,12 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
||||
//! QgsMapLayer cannot be copied
|
||||
QgsMapLayer &operator=( QgsMapLayer const & ) = delete;
|
||||
|
||||
/** Returns a new instance equivalent to this one.
|
||||
* \param deep If true, a deep copy is done
|
||||
/** Returns a new instance equivalent to this one except for the id which
|
||||
* is still unique.
|
||||
* \returns a new layer instance
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
virtual QgsMapLayer *clone( bool deep ) const = 0;
|
||||
virtual QgsMapLayer *clone() const = 0;
|
||||
|
||||
/** Returns the type of the layer.
|
||||
*/
|
||||
@ -930,13 +930,11 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
||||
|
||||
protected:
|
||||
|
||||
/** Copies attributes like name, short name, ... into another layer. The
|
||||
* unique ID is copied too if deep parameter is true.
|
||||
/** Copies attributes like name, short name, ... into another layer.
|
||||
* \param layer The copy recipient
|
||||
* \param deep To copy the unique ID or not
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
void clone( QgsMapLayer *layer, bool deep = false ) const;
|
||||
void clone( QgsMapLayer *layer ) const;
|
||||
|
||||
//! Set the extent
|
||||
virtual void setExtent( const QgsRectangle &rect );
|
||||
@ -1031,11 +1029,6 @@ class CORE_EXPORT QgsMapLayer : public QObject
|
||||
|
||||
private:
|
||||
|
||||
/** Set the unique id of the layer.
|
||||
* /param id the new unique id of the layer
|
||||
*/
|
||||
void setId( const QString &id );
|
||||
|
||||
/**
|
||||
* This method returns true by default but can be overwritten to specify
|
||||
* that a certain layer is writable.
|
||||
|
@ -41,7 +41,7 @@ class CORE_EXPORT QgsPluginLayer : public QgsMapLayer
|
||||
* \returns a new layer instance
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
virtual QgsPluginLayer *clone( bool deep ) const override = 0;
|
||||
virtual QgsPluginLayer *clone() const override = 0;
|
||||
|
||||
//! Return plugin layer type (the same as used in QgsPluginLayerRegistry)
|
||||
QString pluginLayerType();
|
||||
|
@ -202,10 +202,10 @@ QgsVectorLayer::~QgsVectorLayer()
|
||||
delete mConditionalStyles;
|
||||
}
|
||||
|
||||
QgsVectorLayer *QgsVectorLayer::clone( bool deep ) const
|
||||
QgsVectorLayer *QgsVectorLayer::clone() const
|
||||
{
|
||||
QgsVectorLayer *layer = new QgsVectorLayer( source(), originalName(), mProviderKey );
|
||||
QgsMapLayer::clone( layer, deep );
|
||||
QgsMapLayer::clone( layer );
|
||||
|
||||
QList<QgsVectorLayerJoinInfo> joins = vectorJoins();
|
||||
Q_FOREACH ( QgsVectorLayerJoinInfo join, joins )
|
||||
|
@ -404,11 +404,10 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
|
||||
* created for the same data source and renderers for features and diagrams
|
||||
* are cloned too. Moreover, each attributes (transparency, extent, selected
|
||||
* features and so on) are identicals.
|
||||
* \param deep If true, a deep copy is done (unique ID is copied too)
|
||||
* \returns a new layer instance
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
virtual QgsVectorLayer *clone( bool deep = false ) const override SIP_FACTORY;
|
||||
virtual QgsVectorLayer *clone() const override SIP_FACTORY;
|
||||
|
||||
//! Returns the permanent storage type for this layer as a friendly name.
|
||||
QString storageType() const;
|
||||
|
@ -144,10 +144,10 @@ QgsRasterLayer::~QgsRasterLayer()
|
||||
// Note: provider and other interfaces are owned and deleted by pipe
|
||||
}
|
||||
|
||||
QgsRasterLayer *QgsRasterLayer::clone( bool deep ) const
|
||||
QgsRasterLayer *QgsRasterLayer::clone() const
|
||||
{
|
||||
QgsRasterLayer *layer = new QgsRasterLayer( source(), originalName(), mProviderKey );
|
||||
QgsMapLayer::clone( layer, deep );
|
||||
QgsMapLayer::clone( layer );
|
||||
layer->setRenderer( renderer()->clone() );
|
||||
return layer;
|
||||
}
|
||||
|
@ -190,11 +190,10 @@ class CORE_EXPORT QgsRasterLayer : public QgsMapLayer
|
||||
|
||||
/** Returns a new instance equivalent to this one. A new provider is
|
||||
* created for the same data source and renderer is cloned too.
|
||||
* \param deep If true, a deep copy is done (unique ID is copy too)
|
||||
* \returns a new layer instance
|
||||
* \since QGIS 3.0
|
||||
*/
|
||||
virtual QgsRasterLayer *clone( bool deep = false ) const override SIP_FACTORY;
|
||||
virtual QgsRasterLayer *clone() const override SIP_FACTORY;
|
||||
|
||||
//! \brief This enumerator describes the types of shading that can be used
|
||||
enum ColorShadingAlgorithm
|
||||
|
@ -2195,16 +2195,9 @@ class TestQgsVectorLayer(unittest.TestCase):
|
||||
def testCloneId(self):
|
||||
layer = createLayerWithFivePoints()
|
||||
|
||||
# deep clone by default
|
||||
clone = layer.clone()
|
||||
self.assertFalse(clone.id() == layer.id())
|
||||
|
||||
clone = layer.clone(False)
|
||||
self.assertFalse(clone.id() == layer.id())
|
||||
|
||||
clone = layer.clone(True)
|
||||
self.assertEqual(clone.id(), layer.id())
|
||||
|
||||
def testCloneVectorLayerAttributes(self):
|
||||
# init layer
|
||||
layer = createLayerWithFivePoints()
|
||||
|
Loading…
x
Reference in New Issue
Block a user