Skip to content

Commit

Permalink
Revert "Revert "[API] Remove specific deprecated QgsVectorLayer::setD…
Browse files Browse the repository at this point in the history
…ataSource""

This reverts commit 2524f96.
  • Loading branch information
rldhont committed Apr 29, 2021
1 parent 809e000 commit b60f5a4
Show file tree
Hide file tree
Showing 6 changed files with 5 additions and 50 deletions.
1 change: 1 addition & 0 deletions doc/api_break.dox
Expand Up @@ -22,6 +22,7 @@ QGIS 3.20 {#qgis_api_break_3_20}
setDataSource {#qgis_api_break_3_20_setdatasource}
-------------

- QgsVectorLayer::setDataSource deprecated and specific method without ProviderOptions has been removed
- QgsMapLayer::setDataSource is no longer virtual. If has been replaced with QgsMapLayer::setDataSourcePrivate. This is only relevant for subclassing QgsMapLayer, for code that only uses the subclasses (QgsVectorLayer, QgsRasterLayer, ...) this has no effect.

QGIS 3.4 {#qgis_api_break_3_4}
Expand Down
16 changes: 0 additions & 16 deletions python/core/auto_generated/vector/qgsvectorlayer.sip.in
Expand Up @@ -1082,22 +1082,6 @@ Determines if this vector layer has features.
.. versionadded:: 3.4
%End

void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag = false ) /Deprecated/;
%Docstring
Update the data source of the layer. The layer's renderer and legend will be preserved only
if the geometry type of the new data source matches the current geometry type of the layer.

:param dataSource: new layer data source
:param baseName: base name of the layer
:param provider: provider string
:param loadDefaultStyleFlag: set to ``True`` to reset the layer's style to the default for the
data source

.. versionadded:: 2.10

.. deprecated::
Use version with ProviderOptions argument instead
%End

virtual QString loadDefaultStyle( bool &resultFlag /Out/ ) ${SIP_FINAL};

Expand Down
5 changes: 2 additions & 3 deletions src/app/qgisapp.cpp
Expand Up @@ -8251,8 +8251,7 @@ void QgisApp::changeDataSource( QgsMapLayer *layer )
subsetString = vlayer->subsetString();
}

layer->setDataSource( uri.uri, layer->name(), uri.providerKey,
QgsDataProvider::ProviderOptions(), QgsDataProvider::ReadFlags() );
layer->setDataSource( uri.uri, layer->name(), uri.providerKey, QgsDataProvider::ProviderOptions() );
// Re-apply original style and subset string when fixing bad layers
if ( !( layerWasValid || layer->originalXmlProperties().isEmpty() ) )
{
Expand Down Expand Up @@ -8821,7 +8820,7 @@ void QgisApp::makeMemoryLayerPermanent( QgsVectorLayer *layer )
QString source = newFilename;
if ( ! newLayerName.isEmpty() )
source += QStringLiteral( "|layername=%1" ).arg( newLayerName );
vl->QgsMapLayer::setDataSource( source, vl->name(), QStringLiteral( "ogr" ), options );
vl->setDataSource( source, vl->name(), QStringLiteral( "ogr" ), options );
vl->triggerRepaint();
this->visibleMessageBar()->pushMessage( tr( "Layer Saved" ),
tr( "Successfully saved scratch layer to <a href=\"%1\">%2</a>" ).arg( QUrl::fromLocalFile( newFilename ).toString(), QDir::toNativeSeparators( newFilename ) ),
Expand Down
17 changes: 0 additions & 17 deletions src/core/vector/qgsvectorlayer.cpp
Expand Up @@ -1634,23 +1634,6 @@ bool QgsVectorLayer::readXml( const QDomNode &layer_node, QgsReadWriteContext &c

} // void QgsVectorLayer::readXml

void QgsVectorLayer::setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag )
{
QgsDataProvider::ProviderOptions options;

QgsDataProvider::ReadFlags flags = QgsDataProvider::ReadFlags();
if ( loadDefaultStyleFlag )
{
flags |= QgsDataProvider::FlagLoadDefaultStyle;
}

if ( mReadFlags & QgsMapLayer::FlagTrustLayerMetadata )
{
flags |= QgsDataProvider::FlagTrustDataSource;
}
setDataSourcePrivate( dataSource, baseName, provider, options, flags );
}

void QgsVectorLayer::setDataSourcePrivate( const QString &dataSource, const QString &baseName, const QString &provider,
const QgsDataProvider::ProviderOptions &options, QgsDataProvider::ReadFlags flags )
{
Expand Down
12 changes: 0 additions & 12 deletions src/core/vector/qgsvectorlayer.h
Expand Up @@ -1131,18 +1131,6 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
*/
FeatureAvailability hasFeatures() const FINAL;

/**
* Update the data source of the layer. The layer's renderer and legend will be preserved only
* if the geometry type of the new data source matches the current geometry type of the layer.
* \param dataSource new layer data source
* \param baseName base name of the layer
* \param provider provider string
* \param loadDefaultStyleFlag set to TRUE to reset the layer's style to the default for the
* data source
* \since QGIS 2.10
* \deprecated Use version with ProviderOptions argument instead
*/
Q_DECL_DEPRECATED void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag = false ) SIP_DEPRECATED;

QString loadDefaultStyle( bool &resultFlag SIP_OUT ) FINAL;

Expand Down
4 changes: 2 additions & 2 deletions src/gui/vector/qgsvectorlayerproperties.cpp
Expand Up @@ -635,8 +635,8 @@ void QgsVectorLayerProperties::apply()
const QString newSource = mSourceWidget->sourceUri();
if ( newSource != mLayer->source() )
{
mLayer->QgsMapLayer::setDataSource( newSource, mLayer->name(), mLayer->providerType(),
QgsDataProvider::ProviderOptions(), QgsDataProvider::ReadFlags() );
mLayer->setDataSource( newSource, mLayer->name(), mLayer->providerType(),
QgsDataProvider::ProviderOptions(), QgsDataProvider::ReadFlags() );
}
}

Expand Down

0 comments on commit b60f5a4

Please sign in to comment.