Skip to content

Commit e868599

Browse files
committed
Remove all specialized methods for adding the source selects
We now have a unified interface for all dialogs.
1 parent fa71bc3 commit e868599

File tree

2 files changed

+37
-66
lines changed

2 files changed

+37
-66
lines changed

src/gui/qgsdatasourcemanagerdialog.cpp

Lines changed: 36 additions & 63 deletions
Original file line numberDiff line numberDiff line change
@@ -56,47 +56,38 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QWidget *parent, QgsMapC
5656
connect( this, &QgsDataSourceManagerDialog::updateProjectHome, mBrowserWidget, &QgsBrowserDockWidget::updateProjectHome );
5757

5858
// Add data provider dialogs
59-
QWidget *dlg = nullptr;
6059

61-
addVectorProviderDialog( QStringLiteral( "ogr" ), tr( "Vector" ), QStringLiteral( "/mActionAddOgrLayer.svg" ) );
60+
providerDialog( QStringLiteral( "ogr" ), tr( "Vector" ), QStringLiteral( "/mActionAddOgrLayer.svg" ) );
6261

63-
addRasterProviderDialog( QStringLiteral( "gdal" ), tr( "Raster" ), QStringLiteral( "/mActionAddRasterLayer.svg" ) );
62+
providerDialog( QStringLiteral( "gdal" ), tr( "Raster" ), QStringLiteral( "/mActionAddRasterLayer.svg" ) );
6463

65-
addVectorProviderDialog( QStringLiteral( "delimitedtext" ), tr( "Delimited Text" ), QStringLiteral( "/mActionAddDelimitedTextLayer.svg" ) );
64+
providerDialog( QStringLiteral( "delimitedtext" ), tr( "Delimited Text" ), QStringLiteral( "/mActionAddDelimitedTextLayer.svg" ) );
6665

6766
#ifdef HAVE_POSTGRESQL
68-
addDbProviderDialog( QStringLiteral( "postgres" ), tr( "PostgreSQL" ), QStringLiteral( "/mActionAddPostgisLayer.svg" ) );
67+
providerDialog( QStringLiteral( "postgres" ), tr( "PostgreSQL" ), QStringLiteral( "/mActionAddPostgisLayer.svg" ) );
6968
#endif
7069

71-
addDbProviderDialog( QStringLiteral( "spatialite" ), tr( "SpatiaLite" ), QStringLiteral( "/mActionAddSpatiaLiteLayer.svg" ) );
70+
providerDialog( QStringLiteral( "spatialite" ), tr( "SpatiaLite" ), QStringLiteral( "/mActionAddSpatiaLiteLayer.svg" ) );
7271

73-
addDbProviderDialog( QStringLiteral( "mssql" ), tr( "MSSQL" ), QStringLiteral( "/mActionAddMssqlLayer.svg" ) );
72+
providerDialog( QStringLiteral( "mssql" ), tr( "MSSQL" ), QStringLiteral( "/mActionAddMssqlLayer.svg" ) );
7473

75-
addDbProviderDialog( QStringLiteral( "DB2" ), tr( "DB2" ), QStringLiteral( "/mActionAddDb2Layer.svg" ) );
74+
providerDialog( QStringLiteral( "DB2" ), tr( "DB2" ), QStringLiteral( "/mActionAddDb2Layer.svg" ) );
7675

7776
#ifdef HAVE_ORACLE
78-
addDbProviderDialog( QStringLiteral( "oracle" ), tr( "Oracle" ), QStringLiteral( "/mActionAddOracleLayer.svg" ) );
77+
providerDialog( QStringLiteral( "oracle" ), tr( "Oracle" ), QStringLiteral( "/mActionAddOracleLayer.svg" ) );
7978
#endif
8079

81-
dlg = addVectorProviderDialog( QStringLiteral( "virtual" ), tr( "Virtual Layer" ), QStringLiteral( "/mActionAddVirtualLayer.svg" ) );
80+
providerDialog( QStringLiteral( "virtual" ), tr( "Virtual Layer" ), QStringLiteral( "/mActionAddVirtualLayer.svg" ) );
8281

83-
// Apparently this is the only provider using replaceVectorLayer, we should
84-
// move this in to the base abstract class when it is used by at least one
85-
// additional provider.
86-
if ( dlg )
87-
{
88-
connect( dlg, SIGNAL( replaceVectorLayer( QString, QString, QString, QString ) ), this, SIGNAL( replaceSelectedVectorLayer( QString, QString, QString, QString ) ) );
89-
}
82+
providerDialog( QStringLiteral( "wms" ), tr( "WMS" ), QStringLiteral( "/mActionAddWmsLayer.svg" ) );
9083

91-
addRasterProviderDialog( QStringLiteral( "wms" ), tr( "WMS" ), QStringLiteral( "/mActionAddWmsLayer.svg" ) );
84+
providerDialog( QStringLiteral( "wcs" ), tr( "WCS" ), QStringLiteral( "/mActionAddWcsLayer.svg" ) );
9285

93-
addRasterProviderDialog( QStringLiteral( "wcs" ), tr( "WCS" ), QStringLiteral( "/mActionAddWcsLayer.svg" ) );
86+
providerDialog( QStringLiteral( "WFS" ), tr( "WFS" ), QStringLiteral( "/mActionAddWfsLayer.svg" ) );
9487

95-
addVectorProviderDialog( QStringLiteral( "WFS" ), tr( "WFS" ), QStringLiteral( "/mActionAddWfsLayer.svg" ) );
88+
providerDialog( QStringLiteral( "arcgismapserver" ), tr( "ArcGIS Map Server" ), QStringLiteral( "/mActionAddAmsLayer.svg" ) );
9689

97-
addRasterProviderDialog( QStringLiteral( "arcgismapserver" ), tr( "ArcGIS Map Server" ), QStringLiteral( "/mActionAddAmsLayer.svg" ) );
98-
99-
addVectorProviderDialog( QStringLiteral( "arcgisfeatureserver" ), tr( "ArcGIS Feature Server" ), QStringLiteral( "/mActionAddAfsLayer.svg" ) );
90+
providerDialog( QStringLiteral( "arcgisfeatureserver" ), tr( "ArcGIS Feature Server" ), QStringLiteral( "/mActionAddAfsLayer.svg" ) );
10091

10192
}
10293

@@ -171,51 +162,33 @@ QgsAbstractDataSourceWidget *QgsDataSourceManagerDialog::providerDialog( const Q
171162
}
172163
connect( dlg, &QgsAbstractDataSourceWidget::rejected, this, &QgsDataSourceManagerDialog::reject );
173164
connect( dlg, &QgsAbstractDataSourceWidget::accepted, this, &QgsDataSourceManagerDialog::accept );
165+
makeConnections( dlg, providerKey );
174166
return dlg;
175167
}
176168
}
177169

178-
QgsAbstractDataSourceWidget *QgsDataSourceManagerDialog::addDbProviderDialog( const QString providerKey, const QString providerName, const QString icon, QString title )
179-
{
180-
QgsAbstractDataSourceWidget *dlg = providerDialog( providerKey, providerName, icon, title );
181-
if ( dlg )
182-
{
183-
connect( dlg, SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
184-
this, SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ) );
185-
connect( dlg, SIGNAL( progress( int, int ) ),
186-
this, SIGNAL( showProgress( int, int ) ) );
187-
connect( dlg, SIGNAL( progressMessage( QString ) ),
188-
this, SIGNAL( showStatusMessage( QString ) ) );
189-
connect( dlg, SIGNAL( connectionsChanged() ), this, SIGNAL( connectionsChanged() ) );
190-
connect( this, SIGNAL( providerDialogsRefreshRequested() ), dlg, SLOT( refresh() ) );
191-
}
192-
return dlg;
193-
}
194-
195-
QgsAbstractDataSourceWidget *QgsDataSourceManagerDialog::addRasterProviderDialog( const QString providerKey, const QString providerName, const QString icon, QString title )
170+
void QgsDataSourceManagerDialog::makeConnections( QgsAbstractDataSourceWidget *dlg, const QString &providerKey )
196171
{
197-
QgsAbstractDataSourceWidget *dlg = providerDialog( providerKey, providerName, icon, title );
198-
if ( dlg )
199-
{
200-
connect( dlg, SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ),
201-
this, SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ) );
202-
connect( dlg, SIGNAL( connectionsChanged() ), this, SIGNAL( connectionsChanged() ) );
203-
connect( this, SIGNAL( providerDialogsRefreshRequested() ), dlg, SLOT( refresh() ) );
204-
}
205-
return dlg;
206-
}
207-
208-
QgsAbstractDataSourceWidget *QgsDataSourceManagerDialog::addVectorProviderDialog( const QString providerKey, const QString providerName, const QString icon, QString title )
209-
{
210-
QgsAbstractDataSourceWidget *dlg = providerDialog( providerKey, providerName, icon, title );
211-
if ( dlg )
212-
{
213-
connect( dlg, &QgsAbstractDataSourceWidget::addVectorLayer, this, [ = ]( const QString & vectorLayerPath, const QString & baseName )
214-
{ this->vectorLayerAdded( vectorLayerPath, baseName, providerKey ); } );
215-
connect( dlg, &QgsAbstractDataSourceWidget::addVectorLayers, this, &QgsDataSourceManagerDialog::vectorLayersAdded );
216-
connect( this, SIGNAL( providerDialogsRefreshRequested() ), dlg, SLOT( refresh() ) );
217-
}
218-
return dlg;
172+
// DB
173+
connect( dlg, SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ),
174+
this, SIGNAL( addDatabaseLayers( QStringList const &, QString const & ) ) );
175+
connect( dlg, SIGNAL( progress( int, int ) ),
176+
this, SIGNAL( showProgress( int, int ) ) );
177+
connect( dlg, SIGNAL( progressMessage( QString ) ),
178+
this, SIGNAL( showStatusMessage( QString ) ) );
179+
// Vector
180+
connect( dlg, &QgsAbstractDataSourceWidget::addVectorLayer, this, [ = ]( const QString & vectorLayerPath, const QString & baseName )
181+
{ this->vectorLayerAdded( vectorLayerPath, baseName, providerKey ); } );
182+
connect( dlg, &QgsAbstractDataSourceWidget::addVectorLayers, this, &QgsDataSourceManagerDialog::vectorLayersAdded ); connect( dlg, SIGNAL( connectionsChanged() ), this, SIGNAL( connectionsChanged() ) );
183+
// Raster
184+
connect( dlg, SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ),
185+
this, SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ) );
186+
187+
// Virtual
188+
connect( dlg, SIGNAL( replaceVectorLayer( QString, QString, QString, QString ) ), this, SIGNAL( replaceSelectedVectorLayer( QString, QString, QString, QString ) ) );
189+
// Common
190+
connect( dlg, SIGNAL( connectionsChanged() ), this, SIGNAL( connectionsChanged() ) );
191+
connect( this, SIGNAL( providerDialogsRefreshRequested() ), dlg, SLOT( refresh() ) );
219192
}
220193

221194
void QgsDataSourceManagerDialog::showEvent( QShowEvent *e )

src/gui/qgsdatasourcemanagerdialog.h

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -116,9 +116,7 @@ class GUI_EXPORT QgsDataSourceManagerDialog : public QgsOptionsDialogBase, priva
116116
private:
117117
// Return the dialog from the provider
118118
QgsAbstractDataSourceWidget *providerDialog( const QString providerKey, const QString providerName, const QString icon, QString title = QString() );
119-
QgsAbstractDataSourceWidget *addDbProviderDialog( QString const providerKey, QString const providerName, QString const icon, QString title = QString() );
120-
QgsAbstractDataSourceWidget *addRasterProviderDialog( QString const providerKey, QString const providerName, QString const icon, QString title = QString() );
121-
QgsAbstractDataSourceWidget *addVectorProviderDialog( QString const providerKey, QString const providerName, QString const icon, QString title = QString() );
119+
void makeConnections( QgsAbstractDataSourceWidget *dlg, const QString &providerKey );
122120
Ui::QgsDataSourceManagerDialog *ui;
123121
QgsBrowserDockWidget *mBrowserWidget = nullptr;
124122
int mPreviousRow;

0 commit comments

Comments
 (0)