Skip to content

Commit 44630b4

Browse files
committed
Add QgsDataProvider::ProviderOptions struct to constructors
for data providers Allows a way to pass generic settings to providers, e.g. passing a datum transform context for use in provider's constructors.
1 parent 1098b39 commit 44630b4

File tree

76 files changed

+373
-201
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

76 files changed

+373
-201
lines changed

python/core/auto_generated/mesh/qgsmeshdataprovider.sip.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -266,7 +266,7 @@ Responsible for reading native mesh data
266266
#include "qgsmeshdataprovider.h"
267267
%End
268268
public:
269-
QgsMeshDataProvider( const QString &uri = QString() );
269+
QgsMeshDataProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options );
270270
%Docstring
271271
Ctor
272272
%End

python/core/auto_generated/mesh/qgsmeshlayer.sip.in

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,13 @@ is the MDAL connection string. QGIS must be built with MDAL support to allow thi
7777
%End
7878
public:
7979

80-
explicit QgsMeshLayer( const QString &path = QString(), const QString &baseName = QString(), const QString &providerLib = "mesh_memory" );
80+
struct LayerOptions
81+
{
82+
83+
};
84+
85+
explicit QgsMeshLayer( const QString &path = QString(), const QString &baseName = QString(), const QString &providerLib = "mesh_memory",
86+
const QgsMeshLayer::LayerOptions &options = QgsMeshLayer::LayerOptions() );
8187
%Docstring
8288
Constructor - creates a mesh layer
8389

python/core/auto_generated/qgsdataprovider.sip.in

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -64,9 +64,17 @@ to generic QgsVectorDataProvider's) depends on it.
6464
CustomData
6565
};
6666

67-
QgsDataProvider( const QString &uri = QString() );
67+
68+
struct ProviderOptions
69+
{
70+
71+
};
72+
73+
QgsDataProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options );
6874
%Docstring
6975
Create a new dataprovider with the specified in the ``uri``.
76+
77+
Additional creation options are specified within the ``options`` value.
7078
%End
7179

7280
virtual QgsCoordinateReferenceSystem crs() const = 0;

python/core/auto_generated/qgsprovidermetadata.sip.in

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,6 @@
1010

1111

1212

13-
1413
class QgsProviderMetadata
1514
{
1615
%Docstring

python/core/auto_generated/qgsproviderregistry.sip.in

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -73,12 +73,14 @@ Set library directory where to search for plugins
7373
%End
7474

7575
QgsDataProvider *createProvider( const QString &providerKey,
76-
const QString &dataSource ) /Factory/;
76+
const QString &dataSource,
77+
const QgsDataProvider::ProviderOptions &options ) /Factory/;
7778
%Docstring
7879
Creates a new instance of a provider.
7980

8081
:param providerKey: identificator of the provider
8182
:param dataSource: string containing data source for the provider
83+
:param options: provider options
8284

8385
:return: new instance of provider or NULL on error
8486
%End

python/core/auto_generated/qgsvectordataprovider.sip.in

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -67,11 +67,13 @@ of feature and attribute information from a spatial datasource.
6767
UnknownCount,
6868
};
6969

70-
QgsVectorDataProvider( const QString &uri = QString() );
70+
QgsVectorDataProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options );
7171
%Docstring
72-
Constructor of the vector provider
72+
Constructor for a vector data provider.
7373

74-
:param uri: uniform resource locator (URI) for a dataset
74+
The ``uri`` argument specifies the uniform resource locator (URI) for the associated dataset.
75+
76+
Additional creation options are specified within the ``options`` value.
7577
%End
7678

7779
virtual QgsAbstractFeatureSource *featureSource() const = 0 /Factory/;

python/core/auto_generated/qgsvectorlayer.sip.in

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -925,7 +925,7 @@ calculated by countSymbolFeatures()
925925
:return: number of features rendered by symbol or -1 if failed or counts are not available
926926
%End
927927

928-
void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag = false );
928+
void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, bool loadDefaultStyleFlag = false ) /Deprecated/;
929929
%Docstring
930930
Update the data source of the layer. The layer's renderer and legend will be preserved only
931931
if the geometry type of the new data source matches the current geometry type of the layer.
@@ -937,6 +937,23 @@ if the geometry type of the new data source matches the current geometry type of
937937
data source
938938

939939
.. versionadded:: 2.10
940+
941+
.. deprecated:: Use version with ProviderOptions argument instead
942+
%End
943+
944+
void setDataSource( const QString &dataSource, const QString &baseName, const QString &provider, const QgsDataProvider::ProviderOptions &options, bool loadDefaultStyleFlag = false );
945+
%Docstring
946+
Updates the data source of the layer. The layer's renderer and legend will be preserved only
947+
if the geometry type of the new data source matches the current geometry type of the layer.
948+
949+
:param dataSource: new layer data source
950+
:param baseName: base name of the layer
951+
:param provider: provider string
952+
:param options: provider options
953+
:param loadDefaultStyleFlag: set to true to reset the layer's style to the default for the
954+
data source
955+
956+
.. versionadded:: 3.2
940957
%End
941958

942959
virtual QString loadDefaultStyle( bool &resultFlag /Out/ );

python/core/auto_generated/raster/qgsrasterdataprovider.sip.in

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,15 @@ Base class for raster data providers.
8282

8383
QgsRasterDataProvider();
8484

85-
QgsRasterDataProvider( const QString &uri );
85+
QgsRasterDataProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options );
86+
%Docstring
87+
Constructor for QgsRasterDataProvider.
88+
89+
The ``uri`` argument gives a provider-specific uri indicating the underlying data
90+
source and it's parameters.
91+
92+
The ``options`` argument specifies generic provider options.
93+
%End
8694

8795
virtual QgsRasterInterface *clone() const = 0;
8896

python/core/auto_generated/raster/qgsrasterlayer.sip.in

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -180,9 +180,21 @@ returned in ``retError``.
180180
Return time stamp for given file name
181181
%End
182182

183-
void setDataProvider( const QString &provider );
183+
void setDataProvider( const QString &provider ) /Deprecated/;
184184
%Docstring
185-
[ data provider interface ] Set the data provider
185+
Set the data provider.
186+
187+
.. deprecated:: Use the version with ProviderOptions instead.
188+
%End
189+
190+
void setDataProvider( const QString &provider, const QgsDataProvider::ProviderOptions &options );
191+
%Docstring
192+
Set the data provider.
193+
194+
:param provider: provider key string, must match a valid QgsRasterDataProvider key. E.g. "gdal", "wms", etc.
195+
:param options: provider options
196+
197+
.. versionadded:: 3.2
186198
%End
187199

188200
LayerType rasterType();

src/core/mesh/qgsmeshdataprovider.cpp

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -18,8 +18,8 @@
1818
#include "qgsmeshdataprovider.h"
1919
#include "qgis.h"
2020

21-
QgsMeshDataProvider::QgsMeshDataProvider( const QString &uri )
22-
: QgsDataProvider( uri )
21+
QgsMeshDataProvider::QgsMeshDataProvider( const QString &uri, const QgsDataProvider::ProviderOptions &options )
22+
: QgsDataProvider( uri, options )
2323
{
2424
}
2525

0 commit comments

Comments
 (0)