Skip to content
Permalink
Browse files

Allow QgsAbstractDataSourceWidget subclasses to add vector layers

with a specific provider key
  • Loading branch information
nyalldawson committed Sep 5, 2017
1 parent e51a0d4 commit 239e353155e03884ac669052173e28fc6539af02
@@ -44,13 +44,6 @@ class QgsGeoNodeSourceSelect: QgsAbstractDataSourceWidget
virtual void addButtonClicked();


signals:

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

};


@@ -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 );
@@ -72,8 +72,6 @@ QgsGeoNodeSourceSelect::QgsGeoNodeSourceSelect( QWidget *parent, Qt::WindowFlags
treeView->setModel( mModelProxy );
}

QgsGeoNodeSourceSelect::~QgsGeoNodeSourceSelect() {}

void QgsGeoNodeSourceSelect::addConnectionsEntryList()
{
QgsGeoNodeNewConnection *nc = new QgsGeoNodeNewConnection( this );
@@ -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" )
{
@@ -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.
@@ -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
@@ -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,

0 comments on commit 239e353

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