Skip to content

Commit

Permalink
Allow QgsAbstractDataSourceWidget subclasses to add vector layers
Browse files Browse the repository at this point in the history
with a specific provider key
  • Loading branch information
nyalldawson committed Sep 12, 2017
1 parent e51a0d4 commit 239e353
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 23 deletions.
7 changes: 0 additions & 7 deletions python/gui/geonode/qgsgeonodesourceselect.sip
Expand Up @@ -44,13 +44,6 @@ class QgsGeoNodeSourceSelect: QgsAbstractDataSourceWidget
virtual void addButtonClicked();


signals:

void addWfsLayer(
const QString &uri,
const QString &layerName,
const QString &providerKey );

};


Expand Down
7 changes: 5 additions & 2 deletions python/gui/qgsabstractdatasourcewidget.sip
Expand Up @@ -77,9 +77,12 @@ Emitted when a DB layer has been selected for addition
Emitted when a raster layer has been selected for addition
%End

void addVectorLayer( const QString &uri, const QString &layerName );
void addVectorLayer( const QString &uri, const QString &layerName, const QString &providerKey = QString() );
%Docstring
Emitted when a vector layer has been selected for addition
Emitted when a vector layer has been selected for addition.

If ``providerKey`` is not specified, the default provider key associated with the source
will be used.
%End

void addVectorLayers( const QStringList &layerList, const QString &encoding, const QString &dataSourceType );
Expand Down
4 changes: 1 addition & 3 deletions src/gui/geonode/qgsgeonodesourceselect.cpp
Expand Up @@ -72,8 +72,6 @@ QgsGeoNodeSourceSelect::QgsGeoNodeSourceSelect( QWidget *parent, Qt::WindowFlags
treeView->setModel( mModelProxy );
}

QgsGeoNodeSourceSelect::~QgsGeoNodeSourceSelect() {}

void QgsGeoNodeSourceSelect::addConnectionsEntryList()
{
QgsGeoNodeNewConnection *nc = new QgsGeoNodeNewConnection( this );
Expand Down Expand Up @@ -474,7 +472,7 @@ void QgsGeoNodeSourceSelect::addButtonClicked()
uri += QStringLiteral( " sql=" );

QgsDebugMsg( "Add WFS from GeoNode : " + uri + " and typename: " + typeName );
emit addWfsLayer( uri, typeName, "WFS" );
emit addVectorLayer( uri, typeName, QStringLiteral( "WFS" ) );
}
else if ( webServiceType == "XYZ" )
{
Expand Down
7 changes: 0 additions & 7 deletions src/gui/geonode/qgsgeonodesourceselect.h
Expand Up @@ -45,13 +45,6 @@ class GUI_EXPORT QgsGeoNodeSourceSelect: public QgsAbstractDataSourceWidget, pri

void addButtonClicked() override;

signals:

void addWfsLayer(
const QString &uri,
const QString &layerName,
const QString &providerKey );

private:

/** Stores the available CRS for a server connections.
Expand Down
9 changes: 7 additions & 2 deletions src/gui/qgsabstractdatasourcewidget.h
Expand Up @@ -83,8 +83,13 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
//! Emitted when a raster layer has been selected for addition
void addRasterLayer( const QString &rasterLayerPath, const QString &baseName, const QString &providerKey );

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

/** Emitted when one or more OGR supported layers are selected for addition
* \param layerList list of layers protocol URIs
Expand Down
5 changes: 3 additions & 2 deletions src/gui/qgsdatasourcemanagerdialog.cpp
Expand Up @@ -168,9 +168,10 @@ void QgsDataSourceManagerDialog::makeConnections( QgsAbstractDataSourceWidget *d
connect( dlg, SIGNAL( progressMessage( QString ) ),
this, SIGNAL( showStatusMessage( QString ) ) );
// Vector
connect( dlg, &QgsAbstractDataSourceWidget::addVectorLayer, this, [ = ]( const QString & vectorLayerPath, const QString & baseName )
connect( dlg, &QgsAbstractDataSourceWidget::addVectorLayer, this, [ = ]( const QString & vectorLayerPath, const QString & baseName, const QString & specifiedProvider )
{
this->vectorLayerAdded( vectorLayerPath, baseName, providerKey );
QString key = specifiedProvider.isEmpty() ? providerKey : specifiedProvider;
this->vectorLayerAdded( vectorLayerPath, baseName, key );
}
);
connect( dlg, &QgsAbstractDataSourceWidget::addVectorLayers,
Expand Down

0 comments on commit 239e353

Please sign in to comment.