mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Deprecate vector layer ctor with default constructed options
replaced by QgsVectorLayer( const QgsVectorLayer::LayerOptions &options, ...
This commit is contained in:
parent
f5bc1c7196
commit
6813a55fce
@ -327,10 +327,21 @@ TODO QGIS3: Remove virtual from non-inherited methods (like isModified)
|
||||
{
|
||||
|
||||
explicit LayerOptions( bool loadDefaultStyle = true,
|
||||
bool readExtentFromXml = false,
|
||||
const QgsCoordinateTransformContext &transformContext = QgsCoordinateTransformContext() );
|
||||
bool readExtentFromXml = false );
|
||||
%Docstring
|
||||
Constructor for LayerOptions.
|
||||
|
||||
.. deprecated:: Use version with transformContext argument instead
|
||||
%End
|
||||
|
||||
explicit LayerOptions( const QgsCoordinateTransformContext & transformContext,
|
||||
bool loadDefaultStyle = true,
|
||||
bool readExtentFromXml = false
|
||||
);
|
||||
%Docstring
|
||||
Constructor for LayerOptions.
|
||||
|
||||
.. versionadded:: 3.10
|
||||
%End
|
||||
|
||||
bool loadDefaultStyle;
|
||||
@ -342,7 +353,7 @@ Constructor for LayerOptions.
|
||||
};
|
||||
|
||||
explicit QgsVectorLayer( const QString &path = QString(), const QString &baseName = QString(),
|
||||
const QString &providerLib = "ogr", const QgsVectorLayer::LayerOptions &options = QgsVectorLayer::LayerOptions() );
|
||||
const QString &providerLib = "ogr", const QgsVectorLayer::LayerOptions &options = QgsVectorLayer::LayerOptions() ) /Deprecated/;
|
||||
%Docstring
|
||||
Constructor - creates a vector layer
|
||||
|
||||
@ -355,6 +366,27 @@ data.
|
||||
:param baseName: The name used to represent the layer in the legend
|
||||
:param providerLib: The name of the data provider, e.g., "memory", "postgres"
|
||||
:param options: layer load options
|
||||
|
||||
.. deprecated:: Use version with options as mandatory argument instead
|
||||
%End
|
||||
|
||||
|
||||
explicit QgsVectorLayer( const QgsVectorLayer::LayerOptions &options, const QString &path = QString(), const QString &baseName = QString(),
|
||||
const QString &providerLib = "ogr" );
|
||||
%Docstring
|
||||
Constructor - creates a vector layer
|
||||
|
||||
The QgsVectorLayer is constructed by instantiating a data provider. The provider
|
||||
interprets the supplied path (url) of the data source to connect to and access the
|
||||
data.
|
||||
|
||||
:param options: layer load options
|
||||
:param path: The path or url of the parameter. Typically this encodes
|
||||
parameters used by the data provider as url query items.
|
||||
:param baseName: The name used to represent the layer in the legend
|
||||
:param providerLib: The name of the data provider, e.g., "memory", "postgres"
|
||||
|
||||
.. versionadded:: 3.10
|
||||
%End
|
||||
|
||||
|
||||
|
@ -4708,7 +4708,7 @@ bool QgisApp::addVectorLayersPrivate( const QStringList &layerQStringList, const
|
||||
const bool isRemoteUrl { scheme.startsWith( QStringLiteral( "http" ) ) || scheme == QStringLiteral( "ftp" ) };
|
||||
|
||||
// create the layer
|
||||
QgsVectorLayer::LayerOptions options;
|
||||
QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
|
||||
options.loadDefaultStyle = false;
|
||||
if ( isVsiCurl || isRemoteUrl )
|
||||
{
|
||||
@ -5254,7 +5254,7 @@ QList<QgsMapLayer *> QgisApp::askUserForOGRSublayers( QgsVectorLayer *layer )
|
||||
|
||||
QgsDebugMsg( "Creating new vector layer using " + composedURI );
|
||||
QString name = fileName + " " + def.layerName;
|
||||
QgsVectorLayer::LayerOptions options;
|
||||
QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
|
||||
options.loadDefaultStyle = false;
|
||||
QgsVectorLayer *layer = new QgsVectorLayer( composedURI, name, QStringLiteral( "ogr" ), options );
|
||||
if ( layer && layer->isValid() )
|
||||
@ -5318,7 +5318,7 @@ void QgisApp::addDatabaseLayers( QStringList const &layerPathList, QString const
|
||||
// create the layer
|
||||
QgsDataSourceUri uri( layerPath );
|
||||
|
||||
QgsVectorLayer::LayerOptions options;
|
||||
QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
|
||||
options.loadDefaultStyle = false;
|
||||
QgsVectorLayer *layer = new QgsVectorLayer( uri.uri( false ), uri.table(), providerKey, options );
|
||||
Q_CHECK_PTR( layer );
|
||||
@ -11108,7 +11108,7 @@ QgsVectorLayer *QgisApp::addVectorLayerPrivate( const QString &vectorLayerPath,
|
||||
}
|
||||
|
||||
// create the layer
|
||||
QgsVectorLayer::LayerOptions options;
|
||||
QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
|
||||
// Default style is loaded later in this method
|
||||
options.loadDefaultStyle = false;
|
||||
QgsVectorLayer *layer = new QgsVectorLayer( vectorLayerPath, baseName, providerKey, options );
|
||||
|
@ -139,6 +139,7 @@ typedef bool deleteStyleById_t(
|
||||
);
|
||||
|
||||
|
||||
|
||||
QgsVectorLayer::QgsVectorLayer( const QString &vectorLayerPath,
|
||||
const QString &baseName,
|
||||
const QString &providerKey,
|
||||
@ -148,7 +149,6 @@ QgsVectorLayer::QgsVectorLayer( const QString &vectorLayerPath,
|
||||
, mAuxiliaryLayerKey( QString() )
|
||||
, mReadExtentFromXml( options.readExtentFromXml )
|
||||
{
|
||||
|
||||
setProviderType( providerKey );
|
||||
|
||||
mGeometryOptions = qgis::make_unique<QgsGeometryOptions>();
|
||||
@ -179,8 +179,8 @@ QgsVectorLayer::QgsVectorLayer( const QString &vectorLayerPath,
|
||||
mSimplifyMethod.setThreshold( settings.value( QStringLiteral( "qgis/simplifyDrawingTol" ), mSimplifyMethod.threshold() ).toFloat() );
|
||||
mSimplifyMethod.setForceLocalOptimization( settings.value( QStringLiteral( "qgis/simplifyLocal" ), mSimplifyMethod.forceLocalOptimization() ).toBool() );
|
||||
mSimplifyMethod.setMaximumScale( settings.value( QStringLiteral( "qgis/simplifyMaxScale" ), mSimplifyMethod.maximumScale() ).toFloat() );
|
||||
} // QgsVectorLayer ctor
|
||||
|
||||
} // QgsVectorLayer ctor
|
||||
|
||||
|
||||
QgsVectorLayer::~QgsVectorLayer()
|
||||
|
@ -400,10 +400,22 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
|
||||
|
||||
/**
|
||||
* Constructor for LayerOptions.
|
||||
* \deprecated Use version with transformContext argument instead
|
||||
*/
|
||||
explicit LayerOptions( bool loadDefaultStyle = true,
|
||||
bool readExtentFromXml = false,
|
||||
const QgsCoordinateTransformContext &transformContext = QgsCoordinateTransformContext() )
|
||||
Q_DECL_DEPRECATED explicit LayerOptions( bool loadDefaultStyle = true,
|
||||
bool readExtentFromXml = false )
|
||||
: loadDefaultStyle( loadDefaultStyle )
|
||||
, readExtentFromXml( readExtentFromXml ) SIP_DEPRECATED
|
||||
{}
|
||||
|
||||
/**
|
||||
* Constructor for LayerOptions.
|
||||
* \since QGIS 3.10
|
||||
*/
|
||||
explicit LayerOptions( const QgsCoordinateTransformContext & transformContext,
|
||||
bool loadDefaultStyle = true,
|
||||
bool readExtentFromXml = false
|
||||
)
|
||||
: loadDefaultStyle( loadDefaultStyle )
|
||||
, readExtentFromXml( readExtentFromXml )
|
||||
, transformContext( transformContext )
|
||||
@ -438,9 +450,28 @@ class CORE_EXPORT QgsVectorLayer : public QgsMapLayer, public QgsExpressionConte
|
||||
* \param baseName The name used to represent the layer in the legend
|
||||
* \param providerLib The name of the data provider, e.g., "memory", "postgres"
|
||||
* \param options layer load options
|
||||
* \deprecated Use version with options as mandatory argument instead
|
||||
*/
|
||||
explicit QgsVectorLayer( const QString &path = QString(), const QString &baseName = QString(),
|
||||
const QString &providerLib = "ogr", const QgsVectorLayer::LayerOptions &options = QgsVectorLayer::LayerOptions() );
|
||||
Q_DECL_DEPRECATED explicit QgsVectorLayer( const QString &path = QString(), const QString &baseName = QString(),
|
||||
const QString &providerLib = "ogr", const QgsVectorLayer::LayerOptions &options = QgsVectorLayer::LayerOptions() ) SIP_DEPRECATED;
|
||||
|
||||
|
||||
/**
|
||||
* Constructor - creates a vector layer
|
||||
*
|
||||
* The QgsVectorLayer is constructed by instantiating a data provider. The provider
|
||||
* interprets the supplied path (url) of the data source to connect to and access the
|
||||
* data.
|
||||
*
|
||||
* \param options layer load options
|
||||
* \param path The path or url of the parameter. Typically this encodes
|
||||
* parameters used by the data provider as url query items.
|
||||
* \param baseName The name used to represent the layer in the legend
|
||||
* \param providerLib The name of the data provider, e.g., "memory", "postgres"
|
||||
* \since QGIS 3.10
|
||||
*/
|
||||
explicit QgsVectorLayer( const QgsVectorLayer::LayerOptions &options, const QString &path = QString(), const QString &baseName = QString(),
|
||||
const QString &providerLib = "ogr" );
|
||||
|
||||
|
||||
~QgsVectorLayer() override;
|
||||
|
Loading…
x
Reference in New Issue
Block a user