Skip to content

Commit 239e353

Browse files
committed
Allow QgsAbstractDataSourceWidget subclasses to add vector layers
with a specific provider key
1 parent e51a0d4 commit 239e353

File tree

6 files changed

+16
-23
lines changed

6 files changed

+16
-23
lines changed

python/gui/geonode/qgsgeonodesourceselect.sip

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -44,13 +44,6 @@ class QgsGeoNodeSourceSelect: QgsAbstractDataSourceWidget
4444
virtual void addButtonClicked();
4545

4646

47-
signals:
48-
49-
void addWfsLayer(
50-
const QString &uri,
51-
const QString &layerName,
52-
const QString &providerKey );
53-
5447
};
5548

5649

python/gui/qgsabstractdatasourcewidget.sip

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,12 @@ Emitted when a DB layer has been selected for addition
7777
Emitted when a raster layer has been selected for addition
7878
%End
7979

80-
void addVectorLayer( const QString &uri, const QString &layerName );
80+
void addVectorLayer( const QString &uri, const QString &layerName, const QString &providerKey = QString() );
8181
%Docstring
82-
Emitted when a vector layer has been selected for addition
82+
Emitted when a vector layer has been selected for addition.
83+
84+
If ``providerKey`` is not specified, the default provider key associated with the source
85+
will be used.
8386
%End
8487

8588
void addVectorLayers( const QStringList &layerList, const QString &encoding, const QString &dataSourceType );

src/gui/geonode/qgsgeonodesourceselect.cpp

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,6 @@ QgsGeoNodeSourceSelect::QgsGeoNodeSourceSelect( QWidget *parent, Qt::WindowFlags
7272
treeView->setModel( mModelProxy );
7373
}
7474

75-
QgsGeoNodeSourceSelect::~QgsGeoNodeSourceSelect() {}
76-
7775
void QgsGeoNodeSourceSelect::addConnectionsEntryList()
7876
{
7977
QgsGeoNodeNewConnection *nc = new QgsGeoNodeNewConnection( this );
@@ -474,7 +472,7 @@ void QgsGeoNodeSourceSelect::addButtonClicked()
474472
uri += QStringLiteral( " sql=" );
475473

476474
QgsDebugMsg( "Add WFS from GeoNode : " + uri + " and typename: " + typeName );
477-
emit addWfsLayer( uri, typeName, "WFS" );
475+
emit addVectorLayer( uri, typeName, QStringLiteral( "WFS" ) );
478476
}
479477
else if ( webServiceType == "XYZ" )
480478
{

src/gui/geonode/qgsgeonodesourceselect.h

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -45,13 +45,6 @@ class GUI_EXPORT QgsGeoNodeSourceSelect: public QgsAbstractDataSourceWidget, pri
4545

4646
void addButtonClicked() override;
4747

48-
signals:
49-
50-
void addWfsLayer(
51-
const QString &uri,
52-
const QString &layerName,
53-
const QString &providerKey );
54-
5548
private:
5649

5750
/** Stores the available CRS for a server connections.

src/gui/qgsabstractdatasourcewidget.h

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -83,8 +83,13 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
8383
//! Emitted when a raster layer has been selected for addition
8484
void addRasterLayer( const QString &rasterLayerPath, const QString &baseName, const QString &providerKey );
8585

86-
//! Emitted when a vector layer has been selected for addition
87-
void addVectorLayer( const QString &uri, const QString &layerName );
86+
/**
87+
* Emitted when a vector layer has been selected for addition.
88+
*
89+
* If \a providerKey is not specified, the default provider key associated with the source
90+
* will be used.
91+
*/
92+
void addVectorLayer( const QString &uri, const QString &layerName, const QString &providerKey = QString() );
8893

8994
/** Emitted when one or more OGR supported layers are selected for addition
9095
* \param layerList list of layers protocol URIs

src/gui/qgsdatasourcemanagerdialog.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -168,9 +168,10 @@ void QgsDataSourceManagerDialog::makeConnections( QgsAbstractDataSourceWidget *d
168168
connect( dlg, SIGNAL( progressMessage( QString ) ),
169169
this, SIGNAL( showStatusMessage( QString ) ) );
170170
// Vector
171-
connect( dlg, &QgsAbstractDataSourceWidget::addVectorLayer, this, [ = ]( const QString & vectorLayerPath, const QString & baseName )
171+
connect( dlg, &QgsAbstractDataSourceWidget::addVectorLayer, this, [ = ]( const QString & vectorLayerPath, const QString & baseName, const QString & specifiedProvider )
172172
{
173-
this->vectorLayerAdded( vectorLayerPath, baseName, providerKey );
173+
QString key = specifiedProvider.isEmpty() ? providerKey : specifiedProvider;
174+
this->vectorLayerAdded( vectorLayerPath, baseName, key );
174175
}
175176
);
176177
connect( dlg, &QgsAbstractDataSourceWidget::addVectorLayers,

0 commit comments

Comments
 (0)