Skip to content
Permalink
Browse files

Restore default ctor for options and layer

  • Loading branch information
elpaso authored and nyalldawson committed Apr 8, 2019
1 parent 0d7ccea commit 7b6f9c0dbcd9a138931772c2400703149cc7deda
Showing with 100 additions and 204 deletions.
  1. +6 −33 python/core/auto_generated/mesh/qgsmeshlayer.sip.in
  2. +8 −30 python/core/auto_generated/qgsvectorlayer.sip.in
  3. +1 −1 src/app/browser/qgsinbuiltdataitemproviders.cpp
  4. +3 −3 src/app/dwg/qgsdwgimportdialog.cpp
  5. +7 −7 src/app/qgisapp.cpp
  6. +2 −2 src/app/qgsappscreenshots.cpp
  7. +2 −2 src/app/qgsnewspatialitelayerdialog.cpp
  8. +6 −6 src/app/qgsstatusbarcoordinateswidget.cpp
  9. +1 −1 src/core/layout/qgslayoutitemmapoverview.cpp
  10. +2 −9 src/core/mesh/qgsmeshlayer.cpp
  11. +5 −34 src/core/mesh/qgsmeshlayer.h
  12. +2 −2 src/core/processing/qgsprocessingutils.cpp
  13. +1 −1 src/core/providers/memory/qgsmemoryproviderutils.cpp
  14. +2 −3 src/core/qgsauxiliarystorage.cpp
  15. +1 −2 src/core/qgslayerdefinition.cpp
  16. +1 −1 src/core/qgsmimedatautils.cpp
  17. +4 −4 src/core/qgsofflineediting.cpp
  18. +1 −1 src/core/qgsprojectfiletransform.cpp
  19. +2 −2 src/core/qgsvectorlayer.cpp
  20. +16 −36 src/core/qgsvectorlayer.h
  21. +1 −1 src/core/qgsvirtuallayertask.cpp
  22. +3 −2 src/gui/qgsbrowserdockwidget_p.cpp
  23. +1 −1 src/gui/qgsnewgeopackagelayerdialog.cpp
  24. +1 −2 src/gui/qgsprojectionselectiontreewidget.cpp
  25. +1 −1 src/gui/qgsrasterlayersaveasdialog.cpp
  26. +5 −2 src/gui/symbology/qgsdatadefinedsizelegendwidget.cpp
  27. +1 −1 src/plugins/geometry_checker/qgsgeometrycheckerresulttab.cpp
  28. +1 −1 src/plugins/geometry_checker/qgsgeometrycheckersetuptab.cpp
  29. +1 −1 src/providers/db2/qgsdb2dataitems.cpp
  30. +1 −1 src/providers/db2/qgsdb2sourceselect.cpp
  31. +1 −1 src/providers/mssql/qgsmssqldataitems.cpp
  32. +1 −1 src/providers/mssql/qgsmssqlsourceselect.cpp
  33. +1 −1 src/providers/ogr/qgsogrdataitems.cpp
  34. +1 −1 src/providers/ogr/qgsogrdbsourceselect.cpp
  35. +1 −1 src/providers/postgres/qgspgsourceselect.cpp
  36. +1 −1 src/providers/spatialite/qgsspatialitesourceselect.cpp
  37. +1 −1 src/providers/virtual/qgsvirtuallayersourceselect.cpp
  38. +1 −1 src/server/services/wms/qgswmsrenderer.cpp
  39. +2 −2 tests/src/core/testqgsvectordataprovider.cpp
  40. +1 −1 tests/src/core/testziplayer.cpp
@@ -78,26 +78,20 @@ is the MDAL connection string. QGIS must be built with MDAL support to allow thi
struct LayerOptions
{

explicit LayerOptions( ) /Deprecated/;
explicit LayerOptions( const QgsCoordinateTransformContext &transformContext = QgsCoordinateTransformContext( ) );
%Docstring
Constructor for LayerOptions.
Constructor for LayerOptions with optional ``transformContext``.

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


explicit LayerOptions( const QgsCoordinateTransformContext &transformContext );
%Docstring
Constructor for LayerOptions.
.. note::

.. versionadded:: 3.10
transformContext argument was added in QGIS 3.10
%End

QgsCoordinateTransformContext transformContext;
};

explicit QgsMeshLayer( const QString &path = QString(), const QString &baseName = QString(), const QString &providerLib = "mesh_memory",
const QgsMeshLayer::LayerOptions &options = QgsMeshLayer::LayerOptions() ) /Deprecated/;
explicit QgsMeshLayer( const QString &path = QString(), const QString &baseName = QString(), const QString &providerLib = "mesh_memory",
const QgsMeshLayer::LayerOptions &options = QgsMeshLayer::LayerOptions() );
%Docstring
Constructor - creates a mesh layer

@@ -110,29 +104,8 @@ data.
:param baseName: The name used to represent the layer in the legend
:param providerLib: The name of the data provider, e.g., "mesh_memory", "mdal"
:param options: general mesh layer options

.. deprecated:: Use version with layer options as a first argument instead
%End

explicit QgsMeshLayer( const QgsMeshLayer::LayerOptions &options, const QString &path = QString(),
const QString &baseName = QString(), const QString &providerLib = "mesh_memory" );
%Docstring
Constructor - creates a mesh layer

The QgsMeshLayer 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: general mesh layer 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., "mesh_memory", "mdal"

.. versionadded:: 3.10
%End


~QgsMeshLayer();


@@ -326,18 +326,16 @@ TODO QGIS3: Remove virtual from non-inherited methods (like isModified)
struct LayerOptions
{

explicit LayerOptions( bool loadDefaultStyle = true,
bool readExtentFromXml = false );
explicit LayerOptions( bool loadDefaultStyle = true,
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
);
explicit LayerOptions( const QgsCoordinateTransformContext &transformContext,
bool loadDefaultStyle = true,
bool readExtentFromXml = false
);
%Docstring
Constructor for LayerOptions.

@@ -353,8 +351,8 @@ Constructor for LayerOptions.
};


explicit QgsVectorLayer( const QString &path = QString(), const QString &baseName = QString(),
const QString &providerLib = "ogr", const QgsVectorLayer::LayerOptions &options = QgsVectorLayer::LayerOptions() ) /Deprecated/;
explicit QgsVectorLayer( const QString &path = QString(), const QString &baseName = QString(),
const QString &providerLib = "ogr", const QgsVectorLayer::LayerOptions &options = QgsVectorLayer::LayerOptions() );
%Docstring
Constructor - creates a vector layer

@@ -371,26 +369,6 @@ data.
.. 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


~QgsVectorLayer();


@@ -364,7 +364,7 @@ void QgsLayerItemGuiProvider::populateContextMenu( QgsDataItem *item, QMenu *men
case QgsMapLayerType::VectorLayer:
{
const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
std::unique_ptr<QgsVectorLayer> layer( new QgsVectorLayer( options, layerItem->uri(), layerItem->name(), layerItem->providerKey() ) );
std::unique_ptr<QgsVectorLayer> layer( new QgsVectorLayer( layerItem->uri(), layerItem->name(), layerItem->providerKey(), options ) );
if ( layer && layer->isValid() )
{
QgisApp::instance()->saveAsFile( layer.get(), false, false );
@@ -150,7 +150,7 @@ void QgsDwgImportDialog::pbLoadDatabase_clicked()

QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
options.loadDefaultStyle = false;
std::unique_ptr<QgsVectorLayer> d( new QgsVectorLayer( options, QStringLiteral( "%1|layername=drawing" ).arg( mDatabaseFileWidget->filePath() ), QStringLiteral( "layers" ), QStringLiteral( "ogr" ) ) );
std::unique_ptr<QgsVectorLayer> d( new QgsVectorLayer( QStringLiteral( "%1|layername=drawing" ).arg( mDatabaseFileWidget->filePath() ), QStringLiteral( "layers" ), QStringLiteral( "ogr" ), options ) );
if ( d && d->isValid() )
{
int idxPath = d->fields().lookupField( QStringLiteral( "path" ) );
@@ -185,7 +185,7 @@ void QgsDwgImportDialog::pbLoadDatabase_clicked()

lblMessage->setVisible( lblVisible );

std::unique_ptr<QgsVectorLayer> l( new QgsVectorLayer( options, QStringLiteral( "%1|layername=layers" ).arg( mDatabaseFileWidget->filePath() ), QStringLiteral( "layers" ), QStringLiteral( "ogr" ) ) );
std::unique_ptr<QgsVectorLayer> l( new QgsVectorLayer( QStringLiteral( "%1|layername=layers" ).arg( mDatabaseFileWidget->filePath() ), QStringLiteral( "layers" ), QStringLiteral( "ogr" ), options ) );
if ( l && l->isValid() )
{
int idxName = l->fields().lookupField( QStringLiteral( "name" ) );
@@ -265,7 +265,7 @@ QgsVectorLayer *QgsDwgImportDialog::layer( QgsLayerTreeGroup *layerGroup, const
{
QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
options.loadDefaultStyle = false;
QgsVectorLayer *l = new QgsVectorLayer( options, QStringLiteral( "%1|layername=%2" ).arg( mDatabaseFileWidget->filePath(), table ), table, QStringLiteral( "ogr" ) );
QgsVectorLayer *l = new QgsVectorLayer( QStringLiteral( "%1|layername=%2" ).arg( mDatabaseFileWidget->filePath(), table ), table, QStringLiteral( "ogr" ), options );
l->setSubsetString( QStringLiteral( "%1space=0 AND block=-1" ).arg( layerFilter ) );

if ( l->featureCount() == 0 )
@@ -4638,7 +4638,7 @@ static void setupVectorLayer( const QString &vectorLayerPath,
QString composedURI( uriParts.value( QStringLiteral( "path" ) ).toString() );
composedURI += "|layername=" + rawLayerName;

auto newLayer = qgis::make_unique<QgsVectorLayer>( options, composedURI, layer->name(), QStringLiteral( "ogr" ) );
auto newLayer = qgis::make_unique<QgsVectorLayer>( composedURI, layer->name(), QStringLiteral( "ogr" ), options );
if ( newLayer && newLayer->isValid() )
{
delete layer;
@@ -4716,7 +4716,7 @@ bool QgisApp::addVectorLayersPrivate( const QStringList &layerQStringList, const
QApplication::setOverrideCursor( Qt::WaitCursor );
qApp->processEvents();
}
QgsVectorLayer *layer = new QgsVectorLayer( options, src, baseName, QStringLiteral( "ogr" ) );
QgsVectorLayer *layer = new QgsVectorLayer( src, baseName, QStringLiteral( "ogr" ), options );
Q_CHECK_PTR( layer );
if ( isVsiCurl || isRemoteUrl )
{
@@ -5256,7 +5256,7 @@ QList<QgsMapLayer *> QgisApp::askUserForOGRSublayers( QgsVectorLayer *layer )
QString name = fileName + " " + def.layerName;
QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
options.loadDefaultStyle = false;
QgsVectorLayer *layer = new QgsVectorLayer( options, composedURI, name, QStringLiteral( "ogr" ) );
QgsVectorLayer *layer = new QgsVectorLayer( composedURI, name, QStringLiteral( "ogr" ), options );
if ( layer && layer->isValid() )
{
result << layer;
@@ -5320,7 +5320,7 @@ void QgisApp::addDatabaseLayers( QStringList const &layerPathList, QString const

QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
options.loadDefaultStyle = false;
QgsVectorLayer *layer = new QgsVectorLayer( options, uri.uri( false ), uri.table(), providerKey );
QgsVectorLayer *layer = new QgsVectorLayer( uri.uri( false ), uri.table(), providerKey, options );
Q_CHECK_PTR( layer );

if ( ! layer )
@@ -5398,7 +5398,7 @@ void QgisApp::replaceSelectedVectorLayer( const QString &oldId, const QString &u
return;
QgsVectorLayer *oldLayer = static_cast<QgsVectorLayer *>( old );
const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
QgsVectorLayer *newLayer = new QgsVectorLayer( options, uri, layerName, provider );
QgsVectorLayer *newLayer = new QgsVectorLayer( uri, layerName, provider, options );
if ( !newLayer || !newLayer->isValid() )
return;

@@ -9855,7 +9855,7 @@ void QgisApp::layerSubsetString()
{
QgsVirtualLayerDefinition def = QgsVirtualLayerDefinitionUtils::fromJoinedLayer( vlayer );
const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
QgsVectorLayer *newLayer = new QgsVectorLayer( options, def.toString(), vlayer->name() + " (virtual)", QStringLiteral( "virtual" ) );
QgsVectorLayer *newLayer = new QgsVectorLayer( def.toString(), vlayer->name() + " (virtual)", QStringLiteral( "virtual" ), options );
if ( newLayer->isValid() )
{
duplicateVectorStyle( vlayer, newLayer );
@@ -11113,7 +11113,7 @@ QgsVectorLayer *QgisApp::addVectorLayerPrivate( const QString &vectorLayerPath,
QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
// Default style is loaded later in this method
options.loadDefaultStyle = false;
QgsVectorLayer *layer = new QgsVectorLayer( options, vectorLayerPath, baseName, providerKey );
QgsVectorLayer *layer = new QgsVectorLayer( vectorLayerPath, baseName, providerKey, options );

if ( authok && layer && layer->isValid() )
{
@@ -43,9 +43,9 @@ QgsAppScreenShots::QgsAppScreenShots( const QString &saveDirectory )
{
QString layerDef = QStringLiteral( "Point?crs=epsg:4326&field=pk:integer&field=my_text:string&field=fk_polygon:integer&field=my_double:double&key=pk" );
const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
mLineLayer = new QgsVectorLayer( options, layerDef, QStringLiteral( "Line Layer" ), QStringLiteral( "memory" ) );
mLineLayer = new QgsVectorLayer( layerDef, QStringLiteral( "Line Layer" ), QStringLiteral( "memory" ), options );
layerDef = QStringLiteral( "Polygon?crs=epsg:2056&field=pk:integer&field=my_text:string&field=my_integer:integer&field=height:double&key=pk" );
mPolygonLayer = new QgsVectorLayer( options, layerDef, QStringLiteral( "Polygon Layer" ), QStringLiteral( "memory" ) );
mPolygonLayer = new QgsVectorLayer( layerDef, QStringLiteral( "Polygon Layer" ), QStringLiteral( "memory" ), options );

QString dataPath( TEST_DATA_DIR ); //defined in CmakeLists.txt
mRasterLayer = new QgsRasterLayer( dataPath + "/raster/with_color_table.tif", QStringLiteral( "raster" ), QStringLiteral( "gdal" ) );
@@ -455,11 +455,11 @@ bool QgsNewSpatialiteLayerDialog::apply()
}

const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
QgsVectorLayer *layer = new QgsVectorLayer( options, QStringLiteral( "dbname='%1' table='%2'%3 sql=" )
QgsVectorLayer *layer = new QgsVectorLayer( QStringLiteral( "dbname='%1' table='%2'%3 sql=" )
.arg( mDatabaseComboBox->currentText(),
leLayerName->text(),
mGeometryTypeBox->currentIndex() != 0 ? QStringLiteral( "(%1)" ).arg( leGeometryColumn->text() ) : QString() ),
leLayerName->text(), QStringLiteral( "spatialite" ) );
leLayerName->text(), QStringLiteral( "spatialite" ), options );
if ( layer->isValid() )
{
// Reload connections to refresh browser panel
@@ -213,8 +213,8 @@ void QgsStatusBarCoordinatesWidget::contributors()
QString fileName = QgsApplication::pkgDataPath() + QStringLiteral( "/resources/data/contributors.json" );
QFileInfo fileInfo = QFileInfo( fileName );
const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
QgsVectorLayer *layer = new QgsVectorLayer( options, fileInfo.absoluteFilePath(),
tr( "QGIS Contributors" ), QStringLiteral( "ogr" ) );
QgsVectorLayer *layer = new QgsVectorLayer( fileInfo.absoluteFilePath(),
tr( "QGIS Contributors" ), QStringLiteral( "ogr" ), options );
// Register this layer with the layers registry
QgsProject::instance()->addMapLayer( layer );
layer->setAutoRefreshInterval( 500 );
@@ -230,8 +230,8 @@ void QgsStatusBarCoordinatesWidget::world()
QString fileName = QgsApplication::pkgDataPath() + QStringLiteral( "/resources/data/world_map.shp" );
QFileInfo fileInfo = QFileInfo( fileName );
const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
QgsVectorLayer *layer = new QgsVectorLayer( options, fileInfo.absoluteFilePath(),
tr( "World Map" ), QStringLiteral( "ogr" ) );
QgsVectorLayer *layer = new QgsVectorLayer( fileInfo.absoluteFilePath(),
tr( "World Map" ), QStringLiteral( "ogr" ), options );
// Register this layer with the layers registry
QgsProject::instance()->addMapLayer( layer );
}
@@ -245,8 +245,8 @@ void QgsStatusBarCoordinatesWidget::hackfests()
QString fileName = QgsApplication::pkgDataPath() + QStringLiteral( "/resources/data/qgis-hackfests.json" );
QFileInfo fileInfo = QFileInfo( fileName );
const QgsVectorLayer::LayerOptions options { QgsProject::instance()->transformContext() };
QgsVectorLayer *layer = new QgsVectorLayer( options, fileInfo.absoluteFilePath(),
tr( "QGIS Hackfests" ), QStringLiteral( "ogr" ) );
QgsVectorLayer *layer = new QgsVectorLayer( fileInfo.absoluteFilePath(),
tr( "QGIS Hackfests" ), QStringLiteral( "ogr" ), options );
// Register this layer with the layers registry
QgsProject::instance()->addMapLayer( layer );
layer->setAutoRefreshInterval( 500 );
@@ -33,7 +33,7 @@

QgsLayoutItemMapOverview::QgsLayoutItemMapOverview( const QString &name, QgsLayoutItemMap *map )
: QgsLayoutItemMapItem( name, map )
, mExtentLayer( qgis::make_unique< QgsVectorLayer >( QgsVectorLayer::LayerOptions( QgsCoordinateTransformContext() ), QStringLiteral( "Polygon?crs=EPSG:4326" ), QStringLiteral( "overview" ), QStringLiteral( "memory" ) ) )
, mExtentLayer( qgis::make_unique< QgsVectorLayer >( QStringLiteral( "Polygon?crs=EPSG:4326" ), QStringLiteral( "overview" ), QStringLiteral( "memory" ), QgsVectorLayer::LayerOptions( QgsCoordinateTransformContext() ) ) )
{
createDefaultFrameSymbol();
}
@@ -39,7 +39,7 @@
QgsMeshLayer::QgsMeshLayer( const QString &meshLayerPath,
const QString &baseName,
const QString &providerKey,
const LayerOptions &options )
const QgsMeshLayer::LayerOptions &options )
: QgsMapLayer( QgsMapLayerType::MeshLayer, baseName, meshLayerPath )
, mOptions( options )
{
@@ -55,13 +55,6 @@ QgsMeshLayer::QgsMeshLayer( const QString &meshLayerPath,
setDefaultRendererSettings();
} // QgsMeshLayer ctor

QgsMeshLayer::QgsMeshLayer( const QString &meshLayerPath,
const QString &baseName,
const QString &providerKey,
const LayerOptions &options )
: QgsMeshLayer( options, meshLayerPath, baseName, providerKey )
{
}

void QgsMeshLayer::setDefaultRendererSettings()
{
@@ -96,7 +89,7 @@ const QgsMeshDataProvider *QgsMeshLayer::dataProvider() const

QgsMeshLayer *QgsMeshLayer::clone() const
{
QgsMeshLayer *layer = new QgsMeshLayer( mOptions, source(), name(), mProviderKey );
QgsMeshLayer *layer = new QgsMeshLayer( source(), name(), mProviderKey, mOptions );
QgsMapLayer::clone( layer );
return layer;
}
@@ -99,20 +99,10 @@ class CORE_EXPORT QgsMeshLayer : public QgsMapLayer
{

/**
* Constructor for LayerOptions.
* \deprecated Use version with transformContext argument instead
*
* Constructor for LayerOptions with optional \a transformContext.
* \note transformContext argument was added in QGIS 3.10
*/
Q_DECL_DEPRECATED explicit LayerOptions( ) SIP_DEPRECATED
: transformContext( QgsCoordinateTransformContext() )
{}


/**
* Constructor for LayerOptions.
* \since QGIS 3.10
*/
explicit LayerOptions( const QgsCoordinateTransformContext &transformContext )
explicit LayerOptions( const QgsCoordinateTransformContext &transformContext = QgsCoordinateTransformContext( ) )
: transformContext( transformContext )
{}

@@ -131,28 +121,9 @@ class CORE_EXPORT QgsMeshLayer : public QgsMapLayer
* \param baseName The name used to represent the layer in the legend
* \param providerLib The name of the data provider, e.g., "mesh_memory", "mdal"
* \param options general mesh layer options
* \deprecated Use version with layer options as a first argument instead
*/
Q_DECL_DEPRECATED explicit QgsMeshLayer( const QString &path = QString(), const QString &baseName = QString(), const QString &providerLib = "mesh_memory",
const QgsMeshLayer::LayerOptions &options = QgsMeshLayer::LayerOptions() ) SIP_DEPRECATED;

/**
* Constructor - creates a mesh layer
*
* The QgsMeshLayer 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 general mesh layer 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., "mesh_memory", "mdal"
* \since QGIS 3.10
*/
explicit QgsMeshLayer( const QgsMeshLayer::LayerOptions &options, const QString &path = QString(),
const QString &baseName = QString(), const QString &providerLib = "mesh_memory" );

explicit QgsMeshLayer( const QString &path = QString(), const QString &baseName = QString(), const QString &providerLib = "mesh_memory",
const QgsMeshLayer::LayerOptions &options = QgsMeshLayer::LayerOptions() );

~QgsMeshLayer() override;

0 comments on commit 7b6f9c0

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