Skip to content

Commit 73b66fa

Browse files
committedJul 18, 2017
Homogenize signals from different source select dialogs, move to base class
1 parent f6c8ef3 commit 73b66fa

19 files changed

+188
-200
lines changed
 

‎python/gui/gui_auto.sip

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@
158158
%Include qgsoptionswidgetfactory.sip
159159
%Include qgsorderbydialog.sip
160160
%Include qgsowssourceselect.sip
161-
%Include qgsarcgisservicesourceselect.sip
162161
%Include qgspanelwidget.sip
163162
%Include qgspanelwidgetstack.sip
164163
%Include qgspasswordlineedit.sip

‎python/gui/qgsabstractdatasourcewidget.sip

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class QgsAbstractDataSourceWidget : QDialog
1414
{
1515
%Docstring
1616
Abstract base Data Source Widget to create connections and add layers
17-
This class must provide common functionality and the interface for all
17+
This class provides common functionality and the interface for all
1818
source select dialogs used by data providers to configure data sources
1919
and add layers.
2020
.. versionadded:: 3.0
@@ -25,34 +25,79 @@ class QgsAbstractDataSourceWidget : QDialog
2525
%End
2626
public:
2727

28-
QgsAbstractDataSourceWidget( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
28+
~QgsAbstractDataSourceWidget( );
2929
%Docstring
30-
Constructor
30+
Destructor
3131
%End
3232

33-
virtual ~QgsAbstractDataSourceWidget( ) = 0;
33+
QgsProviderRegistry::WidgetMode widgetMode( ) const;
3434
%Docstring
35-
Pure Virtual Destructor
35+
Return the widget mode
36+
:rtype: QgsProviderRegistry.WidgetMode
3637
%End
3738

38-
QgsProviderRegistry::WidgetMode widgetMode( );
39+
void setCurrentCrs( const QgsCoordinateReferenceSystem &crs );
3940
%Docstring
40-
Return the widget mode
41-
:rtype: QgsProviderRegistry.WidgetMode
41+
Set the current CRS
42+
The CRS is normally the CRS of the map canvas, and it can be used
43+
by the provider dialog to transform the extent and constraint the service
44+
%End
45+
46+
void setCurrentExtent( const QgsRectangle &extent );
47+
%Docstring
48+
Set the current extent
49+
The extent is normally the extent of the map canvas, and it can be used
50+
by the provider dialog to constraint the service
51+
%End
52+
53+
QgsRectangle currentExtent( ) const;
54+
%Docstring
55+
Return the current extent
56+
:rtype: QgsRectangle
57+
%End
58+
59+
QgsCoordinateReferenceSystem currentCrs( ) const;
60+
%Docstring
61+
Return the current CRS
62+
:rtype: QgsCoordinateReferenceSystem
4263
%End
4364

4465
public slots:
4566

4667
virtual void refresh( );
4768
%Docstring
48-
The default implementation does nothing
69+
Triggered when the provider's connections need to be refreshed
70+
The default implementation does nothing
4971
%End
5072

5173
signals:
5274

5375
void connectionsChanged();
5476
%Docstring
55-
This signal is normally forwarded the app and used to refresh browser items
77+
Emitted when the provider's connections have changed
78+
This signal is normally forwarded the app and used to refresh browser items
79+
%End
80+
81+
void addDatabaseLayers( const QStringList &paths, const QString &providerKey );
82+
%Docstring
83+
Emitted when a DB layer has been selected for addition
84+
%End
85+
86+
void addRasterLayer( const QString &rasterLayerPath, const QString &baseName, const QString &providerKey );
87+
%Docstring
88+
Emitted when a raster layer has been selected for addition
89+
%End
90+
91+
void addVectorLayer( const QString &uri, const QString &layerName );
92+
%Docstring
93+
Emitted when a vector layer has been selected for addition
94+
%End
95+
96+
protected:
97+
98+
QgsAbstractDataSourceWidget( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
99+
%Docstring
100+
Constructor
56101
%End
57102

58103
};

‎python/gui/qgsarcgisservicesourceselect.sip

Lines changed: 0 additions & 91 deletions
This file was deleted.

‎python/gui/qgsowssourceselect.sip

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,7 @@ Stores the selected datasource whenerver it is changed
112112
Add some default wms servers to the list
113113
%End
114114

115-
signals:
116-
void addRasterLayer( const QString &rasterLayerPath,
117-
const QString &baseName,
118-
const QString &providerKey );
115+
void on_mDialogButtonBox_helpRequested();
119116

120117
protected:
121118

@@ -256,6 +253,7 @@ Returns currently selected cache load control
256253

257254

258255

256+
259257
};
260258

261259
/************************************************************************

‎src/app/qgisapp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,7 @@ void QgisApp::dataSourceManager( QString pageName )
15961596
{
15971597
if ( ! mDataSourceManagerDialog )
15981598
{
1599-
mDataSourceManagerDialog = new QgsDataSourceManagerDialog( mapCanvas( ), this );
1599+
mDataSourceManagerDialog = new QgsDataSourceManagerDialog( this, mapCanvas( ) );
16001600
// Forward signals to this
16011601
connect( this, &QgisApp::connectionsChanged, mDataSourceManagerDialog, &QgsDataSourceManagerDialog::refresh );
16021602
connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::connectionsChanged, this, &QgisApp::connectionsChanged );

‎src/gui/qgsabstractdatasourcewidget.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
qgsabstractdatasourcewidget.cpp - base class for source selector widgets
33
-------------------
44
begin : 10 July 2017
5-
original : (C) 2017 by Alessandro Pasotti email : apasotti at boundlessgeo dot com
5+
original : (C) 2017 by Alessandro Pasotti
6+
email : apasotti at boundlessgeo dot com
67
78
***************************************************************************/
89

@@ -24,7 +25,27 @@ QgsAbstractDataSourceWidget::QgsAbstractDataSourceWidget( QWidget *parent, Qt::W
2425

2526
}
2627

27-
QgsAbstractDataSourceWidget::~QgsAbstractDataSourceWidget()
28+
QgsProviderRegistry::WidgetMode QgsAbstractDataSourceWidget::widgetMode() const
2829
{
30+
return mWidgetMode;
31+
}
32+
33+
void QgsAbstractDataSourceWidget::setCurrentCrs( const QgsCoordinateReferenceSystem &crs )
34+
{
35+
mCurrentCrs = crs;
36+
}
2937

38+
void QgsAbstractDataSourceWidget::setCurrentExtent( const QgsRectangle &extent )
39+
{
40+
mCurrentExtent = extent;
41+
}
42+
43+
QgsRectangle QgsAbstractDataSourceWidget::currentExtent() const
44+
{
45+
return mCurrentExtent;
46+
}
47+
48+
QgsCoordinateReferenceSystem QgsAbstractDataSourceWidget::currentCrs() const
49+
{
50+
return mCurrentCrs;
3051
}

‎src/gui/qgsabstractdatasourcewidget.h

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
qgsabstractdatasourcewidget.h - base class for source selector widgets
33
-------------------
44
begin : 10 July 2017
5-
original : (C) 2017 by Alessandro Pasotti email : apasotti at boundlessgeo dot com
5+
original : (C) 2017 by Alessandro Pasotti
6+
email : apasotti at boundlessgeo dot com
67
78
***************************************************************************/
89

@@ -17,18 +18,20 @@
1718

1819
#ifndef QGSABSTRACTDATASOURCEWIDGET_H
1920
#define QGSABSTRACTDATASOURCEWIDGET_H
21+
2022
#include "qgis_sip.h"
2123
#include "qgis.h"
2224
#include "qgis_gui.h"
2325

2426
#include "qgsproviderregistry.h"
2527
#include "qgsguiutils.h"
26-
28+
#include "qgsrectangle.h"
29+
#include "qgscoordinatereferencesystem.h"
2730
#include <QDialog>
2831

2932
/** \ingroup gui
3033
* \brief Abstract base Data Source Widget to create connections and add layers
31-
* This class must provide common functionality and the interface for all
34+
* This class provides common functionality and the interface for all
3235
* source select dialogs used by data providers to configure data sources
3336
* and add layers.
3437
* \since QGIS 3.0
@@ -39,30 +42,64 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
3942

4043
public:
4144

42-
//! Constructor
43-
QgsAbstractDataSourceWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
44-
45-
//! Pure Virtual Destructor
46-
virtual ~QgsAbstractDataSourceWidget( ) = 0;
45+
//! Destructor
46+
~QgsAbstractDataSourceWidget( ) = default;
4747

4848
//! Return the widget mode
49-
QgsProviderRegistry::WidgetMode widgetMode( ) { return mWidgetMode; }
49+
QgsProviderRegistry::WidgetMode widgetMode( ) const;
50+
51+
/** Set the current CRS
52+
* The CRS is normally the CRS of the map canvas, and it can be used
53+
* by the provider dialog to transform the extent and constraint the service
54+
*/
55+
void setCurrentCrs( const QgsCoordinateReferenceSystem &crs );
56+
57+
/** Set the current extent
58+
* The extent is normally the extent of the map canvas, and it can be used
59+
* by the provider dialog to constraint the service
60+
*/
61+
void setCurrentExtent( const QgsRectangle &extent );
62+
63+
//! Return the current extent
64+
QgsRectangle currentExtent( ) const;
65+
66+
//! Return the current CRS
67+
QgsCoordinateReferenceSystem currentCrs( ) const;
5068

5169
public slots:
5270

53-
//! Triggered when the provider's connections need to be refreshed
54-
//! The default implementation does nothing
71+
/** Triggered when the provider's connections need to be refreshed
72+
* The default implementation does nothing
73+
*/
5574
virtual void refresh( ) {}
5675

5776
signals:
5877

59-
//! Emitted when the provider's connections have changed
60-
//! This signal is normally forwarded the app and used to refresh browser items
78+
/** Emitted when the provider's connections have changed
79+
* This signal is normally forwarded the app and used to refresh browser items
80+
*/
6181
void connectionsChanged();
6282

83+
//! Emitted when a DB layer has been selected for addition
84+
void addDatabaseLayers( const QStringList &paths, const QString &providerKey );
85+
86+
//! Emitted when a raster layer has been selected for addition
87+
void addRasterLayer( const QString &rasterLayerPath, const QString &baseName, const QString &providerKey );
88+
89+
//! Emitted when a vector layer has been selected for addition
90+
void addVectorLayer( const QString &uri, const QString &layerName );
91+
92+
protected:
93+
94+
//! Constructor
95+
QgsAbstractDataSourceWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
96+
6397
private:
6498

6599
QgsProviderRegistry::WidgetMode mWidgetMode;
100+
QgsCoordinateReferenceSystem mCurrentCrs;
101+
QgsRectangle mCurrentExtent;
102+
66103
};
67104

68105
#endif // QGSABSTRACTDATASOURCEWIDGET_H

‎src/gui/qgsarcgisservicesourceselect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
#include "qgscoordinatereferencesystem.h"
2626
#include "qgscoordinatetransform.h"
2727
#include "qgslogger.h"
28-
#include "qgsmapcanvas.h"
2928
#include "qgsmanageconnectionsdialog.h"
3029
#include "qgsexception.h"
3130
#include "qgssettings.h"
31+
#include "qgsmapcanvas.h"
3232

3333
#include <QItemDelegate>
3434
#include <QListWidgetItem>

‎src/gui/qgsarcgisservicesourceselect.h

Lines changed: 10 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,8 @@
1313
* *
1414
***************************************************************************/
1515

16-
#ifndef QGSARCGISSERVICESOURCESELECTDIALOG_H
17-
#define QGSARCGISSERVICESOURCESELECTDIALOG_H
16+
#ifndef QGSARCGISSERVICESOURCESELECT_H
17+
#define QGSARCGISSERVICESOURCESELECT_H
1818

1919
/// @cond PRIVATE
2020

@@ -27,6 +27,9 @@
2727
// version without notice, or even be removed.
2828
//
2929

30+
31+
#define SIP_NO_FILE
32+
3033
#include "ui_qgsarcgisservicesourceselectbase.h"
3134
#include "qgsrectangle.h"
3235
#include "qgscoordinatereferencesystem.h"
@@ -52,9 +55,8 @@ class GUI_EXPORT QgsArcGisServiceSourceSelect : public QgsAbstractDataSourceWidg
5255
//! Constructor
5356
QgsArcGisServiceSourceSelect( const QString &serviceName, ServiceType serviceType, QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
5457

55-
~QgsArcGisServiceSourceSelect();
56-
//! Sets the current extent and CRS. Used to select an appropriate CRS and possibly to retrieve data only in the current extent
57-
void setCurrentExtentAndCrs( const QgsRectangle &canvasExtent, const QgsCoordinateReferenceSystem &canvasCrs );
58+
//! Destructor
59+
~QgsArcGisServiceSourceSelect() override;
5860

5961
signals:
6062
//! Emitted when a layer is added from the dialog
@@ -89,6 +91,8 @@ class GUI_EXPORT QgsArcGisServiceSourceSelect : public QgsAbstractDataSourceWidg
8991
void populateImageEncodings( const QStringList &availableEncodings );
9092
//! Returns the selected image encoding.
9193
QString getSelectedImageEncoding() const;
94+
//! Sets the current extent and CRS. Used to select an appropriate CRS and possibly to retrieve data only in the current extent
95+
void setCurrentExtentAndCrs( const QgsRectangle &canvasExtent, const QgsCoordinateReferenceSystem &canvasCrs );
9296

9397
private:
9498
void populateConnectionList();
@@ -122,4 +126,4 @@ class GUI_EXPORT QgsArcGisServiceSourceSelect : public QgsAbstractDataSourceWidg
122126
};
123127

124128

125-
#endif // QGSARCGISSERVICESOURCESELECTDIALOG_H
129+
#endif // QGSARCGISSERVICESOURCESELECT_H

‎src/gui/qgsdatasourcemanagerdialog.cpp

Lines changed: 29 additions & 37 deletions
Original file line numberDiff line numberDiff line change
@@ -23,15 +23,14 @@
2323
#include "qgssettings.h"
2424
#include "qgsproviderregistry.h"
2525
#include "qgsopenvectorlayerdialog.h"
26-
#include "qgsarcgisservicesourceselect.h"
26+
#include "qgsabstractdatasourcewidget.h"
2727
#include "qgsmapcanvas.h"
2828

29-
30-
QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QgsMapCanvas *mapCanvas, QWidget *parent, Qt::WindowFlags fl ) :
29+
QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QWidget *parent, QgsMapCanvas *canvas, Qt::WindowFlags fl ) :
3130
QgsOptionsDialogBase( QStringLiteral( "Data Source Manager" ), parent, fl ),
3231
ui( new Ui::QgsDataSourceManagerDialog ),
33-
mMapCanvas( mapCanvas ),
34-
mPreviousRow( -1 )
32+
mPreviousRow( -1 ),
33+
mMapCanvas( canvas )
3534
{
3635

3736
ui->setupUi( this );
@@ -71,7 +70,7 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QgsMapCanvas *mapCanvas,
7170
mPageNames.append( QStringLiteral( "raster" ) );
7271

7372
// Add data provider dialogs
74-
QDialog *dlg = nullptr;
73+
QWidget *dlg = nullptr;
7574

7675
dlg = providerDialog( QStringLiteral( "delimitedtext" ), tr( "Delimited Text" ), QStringLiteral( "/mActionAddDelimitedTextLayer.svg" ) );
7776

@@ -106,35 +105,11 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QgsMapCanvas *mapCanvas,
106105

107106
addRasterProviderDialog( QStringLiteral( "wcs" ), tr( "WCS" ), QStringLiteral( "/mActionAddWcsLayer.svg" ) );
108107

109-
dlg = providerDialog( QStringLiteral( "WFS" ), tr( "WFS" ), QStringLiteral( "/mActionAddWfsLayer.svg" ) );
110-
111-
if ( dlg )
112-
{
113-
// Forward (if only a common interface for the signals had been used in the providers ...)
114-
connect( dlg, SIGNAL( addWfsLayer( QString, QString ) ), this, SIGNAL( addWfsLayer( QString, QString ) ) );
115-
connect( this, &QgsDataSourceManagerDialog::addWfsLayer, this, [ = ]( const QString & vectorLayerPath, const QString & baseName )
116-
{
117-
this->vectorLayerAdded( vectorLayerPath, baseName, QStringLiteral( "WFS" ) );
118-
} );
119-
connect( dlg, SIGNAL( connectionsChanged( ) ), this, SIGNAL( connectionsChanged( ) ) );
120-
connect( this, SIGNAL( providerDialogsRefreshRequested( ) ), dlg, SLOT( refresh( ) ) );
121-
}
108+
addVectorProviderDialog( QStringLiteral( "WFS" ), tr( "WFS" ), QStringLiteral( "/mActionAddWfsLayer.svg" ) );
122109

123110
addRasterProviderDialog( QStringLiteral( "arcgismapserver" ), tr( "ArcGIS Map Server" ), QStringLiteral( "/mActionAddAmsLayer.svg" ) );
124111

125-
QgsArcGisServiceSourceSelect *afss = dynamic_cast<QgsArcGisServiceSourceSelect *>( providerDialog( QStringLiteral( "arcgisfeatureserver" ),
126-
tr( "ArcGIS Feature Server" ),
127-
QStringLiteral( "/mActionAddAfsLayer.svg" ) ) );
128-
if ( afss && mMapCanvas )
129-
{
130-
afss->setCurrentExtentAndCrs( mMapCanvas->extent(), mMapCanvas->mapSettings().destinationCrs() );
131-
// Forward (if only a common interface for the signals had been used in the providers ...)
132-
connect( afss, SIGNAL( addLayer( QString, QString ) ), this, SIGNAL( addAfsLayer( QString, QString ) ) );
133-
connect( this, SIGNAL( providerDialogsRefreshRequested( ) ), afss, SLOT( refresh( ) ) );
134-
connect( this, &QgsDataSourceManagerDialog::addAfsLayer,
135-
this, [ = ]( const QString & vectorLayerPath, const QString & baseName )
136-
{ this->vectorLayerAdded( vectorLayerPath, baseName, QStringLiteral( "arcgisfeatureserver" ) ); } );
137-
}
112+
addVectorProviderDialog( QStringLiteral( "arcgisfeatureserver" ), tr( "ArcGIS Feature Server" ), QStringLiteral( "/mActionAddAfsLayer.svg" ) );
138113

139114
}
140115

@@ -192,9 +167,9 @@ void QgsDataSourceManagerDialog::vectorLayersAdded( const QStringList &layerQStr
192167
}
193168

194169

195-
QDialog *QgsDataSourceManagerDialog::providerDialog( const QString providerKey, const QString providerName, const QString icon, QString title )
170+
QgsAbstractDataSourceWidget *QgsDataSourceManagerDialog::providerDialog( const QString providerKey, const QString providerName, const QString icon, QString title )
196171
{
197-
QDialog *dlg = dynamic_cast<QDialog *>( QgsProviderRegistry::instance()->createSelectionWidget( providerKey, this, Qt::Widget, QgsProviderRegistry::WidgetMode::Embedded ) );
172+
QgsAbstractDataSourceWidget *dlg = dynamic_cast<QgsAbstractDataSourceWidget *>( QgsProviderRegistry::instance()->createSelectionWidget( providerKey, this, Qt::Widget, QgsProviderRegistry::WidgetMode::Embedded ) );
198173
if ( !dlg )
199174
{
200175
QMessageBox::warning( this, providerName, tr( "Cannot get %1 select dialog from provider %2." ).arg( providerName, providerKey ) );
@@ -207,13 +182,19 @@ QDialog *QgsDataSourceManagerDialog::providerDialog( const QString providerKey,
207182
QListWidgetItem *layerItem = new QListWidgetItem( providerName, ui->mOptionsListWidget );
208183
layerItem->setToolTip( title.isEmpty() ? tr( "Add %1 layer" ).arg( providerName ) : title );
209184
layerItem->setIcon( QgsApplication::getThemeIcon( icon ) );
185+
// Set crs and extent from canvas
186+
if ( mMapCanvas )
187+
{
188+
dlg->setCurrentExtent( mMapCanvas->extent() );
189+
dlg->setCurrentCrs( mMapCanvas->mapSettings().destinationCrs( ) );
190+
}
210191
return dlg;
211192
}
212193
}
213194

214195
void QgsDataSourceManagerDialog::addDbProviderDialog( const QString providerKey, const QString providerName, const QString icon, QString title )
215196
{
216-
QDialog *dlg = providerDialog( providerKey, providerName, icon, title );
197+
QgsAbstractDataSourceWidget *dlg = providerDialog( providerKey, providerName, icon, title );
217198
if ( dlg )
218199
{
219200
connect( dlg, SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
@@ -229,12 +210,23 @@ void QgsDataSourceManagerDialog::addDbProviderDialog( const QString providerKey,
229210

230211
void QgsDataSourceManagerDialog::addRasterProviderDialog( const QString providerKey, const QString providerName, const QString icon, QString title )
231212
{
232-
QDialog *dlg = providerDialog( providerKey, providerName, icon, title );
213+
QgsAbstractDataSourceWidget *dlg = providerDialog( providerKey, providerName, icon, title );
233214
if ( dlg )
234215
{
235-
// Forward
236216
connect( dlg, SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ),
237217
this, SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ) );
238218
connect( dlg, SIGNAL( connectionsChanged( ) ), this, SIGNAL( connectionsChanged( ) ) );
219+
connect( this, SIGNAL( providerDialogsRefreshRequested( ) ), dlg, SLOT( refresh( ) ) );
220+
}
221+
}
222+
223+
void QgsDataSourceManagerDialog::addVectorProviderDialog( const QString providerKey, const QString providerName, const QString icon, QString title )
224+
{
225+
QgsAbstractDataSourceWidget *dlg = providerDialog( providerKey, providerName, icon, title );
226+
if ( dlg )
227+
{
228+
connect( dlg, &QgsAbstractDataSourceWidget::addVectorLayer, this, [ = ]( const QString & vectorLayerPath, const QString & baseName )
229+
{ this->vectorLayerAdded( vectorLayerPath, baseName, providerKey ); } );
230+
connect( this, SIGNAL( providerDialogsRefreshRequested( ) ), dlg, SLOT( refresh( ) ) );
239231
}
240232
}

‎src/gui/qgsdatasourcemanagerdialog.h

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
class QgsBrowserDockWidget;
3232
class QgsRasterLayer;
3333
class QgsMapCanvas;
34+
class QgsAbstractDataSourceWidget;
3435

3536
/** \ingroup gui
3637
* The QgsDataSourceManagerDialog class embeds the browser panel and all
@@ -47,11 +48,10 @@ class GUI_EXPORT QgsDataSourceManagerDialog : public QgsOptionsDialogBase, priva
4748
public:
4849

4950
/** QgsDataSourceManagerDialog constructor
50-
* @param mapCanvas the map canvas
5151
* @param parent the object
5252
* @param fl window flags
5353
*/
54-
explicit QgsDataSourceManagerDialog( QgsMapCanvas *mapCanvas, QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );
54+
explicit QgsDataSourceManagerDialog( QWidget *parent = nullptr, QgsMapCanvas *canvas = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags );
5555
~QgsDataSourceManagerDialog();
5656

5757
/**
@@ -67,6 +67,7 @@ class GUI_EXPORT QgsDataSourceManagerDialog : public QgsOptionsDialogBase, priva
6767
void setCurrentPage( int index );
6868

6969
//! A raster layer was added: for signal forwarding to QgisApp
70+
//! TODO: use this with an internal source select dialog instead of forwarding the whole raster selection to app
7071
void rasterLayerAdded( QString const &uri, QString const &baseName, QString const &providerKey );
7172
//! A vector layer was added: for signal forwarding to QgisApp
7273
void vectorLayerAdded( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey );
@@ -79,48 +80,48 @@ class GUI_EXPORT QgsDataSourceManagerDialog : public QgsOptionsDialogBase, priva
7980

8081
signals:
8182
//! Emitted when a raster layer was selected for addition: for signal forwarding to QgisApp
82-
void addRasterLayer( QString const &uri, QString const &baseName, QString const &providerKey );
83+
void addRasterLayer( const QString &uri, const QString &baseName, const QString &providerKey );
8384
//! Emitted when the user wants to select a raster layer: for signal forwarding to QgisApp
8485
void addRasterLayer();
8586
//! Emitted when a vector layer was selected for addition: for signal forwarding to QgisApp
8687
void addVectorLayer( const QString &vectorLayerPath, const QString &baseName, const QString &providerKey );
8788
//! Replace the selected layer by a vector layer defined by uri, layer name, data source uri
8889
void replaceSelectedVectorLayer( const QString &oldId, const QString &uri, const QString &layerName, const QString &provider );
89-
//! Emitted when a WFS layer was selected for addition: for signal forwarding to QgisApp
90-
void addWfsLayer( const QString &uri, const QString &typeName );
91-
//! Emitted when a AFS layer was selected for addition: for signal forwarding to QgisApp
92-
void addAfsLayer( const QString &uri, const QString &typeName );
9390
//! Emitted when a one or more layer were selected for addition: for signal forwarding to QgisApp
9491
void addVectorLayers( const QStringList &layerQStringList, const QString &enc, const QString &dataSourceType );
9592
//! Emitted when the dialog is busy: for signal forwarding to QgisApp
9693
void showProgress( int progress, int totalSteps );
9794
//! Emitted when a status message needs to be shown: for signal forwarding to QgisApp
9895
void showStatusMessage( const QString &message );
9996
//! Emitted when a DB layer was selected for addition: for signal forwarding to QgisApp
100-
void addDatabaseLayers( QStringList const &layerPathList, QString const &providerKey );
97+
void addDatabaseLayers( const QStringList &layerPathList, const QString &providerKey );
10198
//! Emitted when a file needs to be opened
10299
void openFile( const QString & );
103100
//! Emitted when drop uri list needs to be handled from the browser
104101
void handleDropUriList( const QgsMimeDataUtils::UriList & );
105102
//! Update project home directory
106103
void updateProjectHome();
107-
//! Connections changed
104+
//! Emitted when a connection has changed inside the provider dialogs
105+
//! This signal is normally forwarded to the application to notify other
106+
//! browsers that they need to refresh their connections list
108107
void connectionsChanged( );
109108
//! One or more provider connections have changed and the
110109
//! dialogs should be refreshed
111110
void providerDialogsRefreshRequested( );
112111

113112
private:
114-
//! Return the dialog from the provider
115-
QDialog *providerDialog( QString const providerKey, QString const providerName, QString const icon, QString title = QString( ) );
113+
// Return the dialog from the provider
114+
QgsAbstractDataSourceWidget *providerDialog( const QString providerKey, const QString providerName, const QString icon, QString title = QString( ) );
116115
void addDbProviderDialog( QString const providerKey, QString const providerName, QString const icon, QString title = QString( ) );
117116
void addRasterProviderDialog( QString const providerKey, QString const providerName, QString const icon, QString title = QString( ) );
117+
void addVectorProviderDialog( QString const providerKey, QString const providerName, QString const icon, QString title = QString( ) );
118118
Ui::QgsDataSourceManagerDialog *ui;
119119
QgsBrowserDockWidget *mBrowserWidget = nullptr;
120-
//! Map canvas
121-
QgsMapCanvas *mMapCanvas = nullptr;
122120
int mPreviousRow;
123121
QStringList mPageNames;
122+
// Map canvas
123+
QgsMapCanvas *mMapCanvas = nullptr;
124+
124125

125126
};
126127

‎src/gui/qgsowssourceselect.h

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -110,10 +110,7 @@ class GUI_EXPORT QgsOWSSourceSelect : public QgsAbstractDataSourceWidget, protec
110110
//! Add some default wms servers to the list
111111
void on_mAddDefaultButton_clicked();
112112

113-
signals:
114-
void addRasterLayer( const QString &rasterLayerPath,
115-
const QString &baseName,
116-
const QString &providerKey );
113+
void on_mDialogButtonBox_helpRequested() { QgsContextHelp::run( metaObject()->className() ); }
117114

118115
protected:
119116

@@ -225,6 +222,7 @@ class GUI_EXPORT QgsOWSSourceSelect : public QgsAbstractDataSourceWidget, protec
225222
//! URI for selected connection
226223
QgsDataSourceUri mUri;
227224

225+
228226
private:
229227
//! Selected CRS
230228
QString mSelectedCRS;

‎src/providers/db2/qgsdb2sourceselect.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -109,7 +109,6 @@ class QgsDb2SourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsDb
109109
QString connectionInfo();
110110

111111
signals:
112-
void addDatabaseLayers( QStringList const &layerPathList, QString const &providerKey );
113112
void addGeometryColumn( QgsDb2LayerProperty );
114113
void progress( int, int );
115114
void progressMessage( QString );

‎src/providers/mssql/qgsmssqlsourceselect.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -79,7 +79,6 @@ class QgsMssqlSourceSelect : public QgsAbstractDataSourceWidget, private Ui::Qgs
7979
QString connectionInfo();
8080

8181
signals:
82-
void addDatabaseLayers( QStringList const &layerPathList, QString const &providerKey );
8382
void addGeometryColumn( const QgsMssqlLayerProperty & );
8483
void progress( int, int );
8584
void progressMessage( QString );

‎src/providers/postgres/qgspgsourceselect.h

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -78,7 +78,6 @@ class QgsPgSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsDbS
7878
QgsDataSourceUri dataSourceUri();
7979

8080
signals:
81-
void addDatabaseLayers( QStringList const &layerPathList, QString const &providerKey );
8281
void addGeometryColumn( const QgsPostgresLayerProperty & );
8382
void progress( int, int );
8483
void progressMessage( const QString & );

‎src/providers/spatialite/qgsspatialitesourceselect.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -98,11 +98,6 @@ class QgsSpatiaLiteSourceSelect: public QgsAbstractDataSourceWidget, private Ui:
9898

9999
void on_buttonBox_helpRequested() { QgsHelp::openHelp( QStringLiteral( "working_with_vector/supported_data.html#spatialite-layers" ) ); }
100100

101-
signals:
102-
void addDatabaseLayers( QStringList const &paths, QString const &providerKey );
103-
void progress( int, int );
104-
void progressMessage( QString );
105-
106101
private:
107102
enum Columns
108103
{

‎src/providers/wfs/qgswfssourceselect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -405,7 +405,7 @@ void QgsWFSSourceSelect::addLayer()
405405
mUri = QgsWFSDataSourceURI::build( connection.uri().uri(), typeName, pCrsString,
406406
sql, cbxFeatureCurrentViewExtent->isChecked() );
407407

408-
emit addWfsLayer( mUri, layerName );
408+
emit addVectorLayer( mUri, layerName );
409409
}
410410

411411
if ( ! mHoldDialogOpen->isChecked() && QgsAbstractDataSourceWidget::widgetMode( ) == QgsProviderRegistry::WidgetMode::None )

‎src/providers/wfs/qgswfssourceselect.h

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,9 +52,6 @@ class QgsWFSSourceSelect: public QgsAbstractDataSourceWidget, private Ui::QgsWFS
5252
QgsWFSSourceSelect( QWidget *parent = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
5353
~QgsWFSSourceSelect();
5454

55-
signals:
56-
void addWfsLayer( const QString &uri, const QString &layerName );
57-
5855
private:
5956
QgsWFSSourceSelect(); //default constructor is forbidden
6057
QgsProjectionSelectionDialog *mProjectionSelector = nullptr;

‎src/providers/wms/qgswmssourceselect.h

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -188,11 +188,6 @@ class QgsWMSSourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsWM
188188

189189
QList<QgsWmtsTileLayer> mTileLayers;
190190

191-
signals:
192-
void addRasterLayer( QString const &rasterLayerPath,
193-
QString const &baseName,
194-
QString const &providerKey );
195-
void connectionsChanged();
196191
private slots:
197192
void on_btnSearch_clicked();
198193
void on_btnAddWMS_clicked();

3 commit comments

Comments
 (3)

tomkralidis commented on Jul 19, 2017

@tomkralidis
Contributor

@elpaso as per https://lists.osgeo.org/pipermail/qgis-developer/2017-July/049366.html, any info how to interact with WFS provider via Python plugins given addWfsLayer has gone away?

tomkralidis commented on Jul 19, 2017

@tomkralidis
Contributor

(note that grep -R addWfsLayer yields the remaining affected areas in the codebase)

elpaso commented on Jul 19, 2017

@elpaso
ContributorAuthor

@tomkralidis I've answered on gitter and on the mailling list, I'll have a look to the other addWfsLayer instances.

PS: can we please stick to a single channel for this thread? Answering three times to the same question is a waste of time.

Please sign in to comment.