@@ -56,47 +56,38 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QWidget *parent, QgsMapC
56
56
connect ( this , &QgsDataSourceManagerDialog::updateProjectHome, mBrowserWidget , &QgsBrowserDockWidget::updateProjectHome );
57
57
58
58
// Add data provider dialogs
59
- QWidget *dlg = nullptr ;
60
59
61
- addVectorProviderDialog ( QStringLiteral ( " ogr" ), tr ( " Vector" ), QStringLiteral ( " /mActionAddOgrLayer.svg" ) );
60
+ providerDialog ( QStringLiteral ( " ogr" ), tr ( " Vector" ), QStringLiteral ( " /mActionAddOgrLayer.svg" ) );
62
61
63
- addRasterProviderDialog ( QStringLiteral ( " gdal" ), tr ( " Raster" ), QStringLiteral ( " /mActionAddRasterLayer.svg" ) );
62
+ providerDialog ( QStringLiteral ( " gdal" ), tr ( " Raster" ), QStringLiteral ( " /mActionAddRasterLayer.svg" ) );
64
63
65
- addVectorProviderDialog ( QStringLiteral ( " delimitedtext" ), tr ( " Delimited Text" ), QStringLiteral ( " /mActionAddDelimitedTextLayer.svg" ) );
64
+ providerDialog ( QStringLiteral ( " delimitedtext" ), tr ( " Delimited Text" ), QStringLiteral ( " /mActionAddDelimitedTextLayer.svg" ) );
66
65
67
66
#ifdef HAVE_POSTGRESQL
68
- addDbProviderDialog ( QStringLiteral ( " postgres" ), tr ( " PostgreSQL" ), QStringLiteral ( " /mActionAddPostgisLayer.svg" ) );
67
+ providerDialog ( QStringLiteral ( " postgres" ), tr ( " PostgreSQL" ), QStringLiteral ( " /mActionAddPostgisLayer.svg" ) );
69
68
#endif
70
69
71
- addDbProviderDialog ( QStringLiteral ( " spatialite" ), tr ( " SpatiaLite" ), QStringLiteral ( " /mActionAddSpatiaLiteLayer.svg" ) );
70
+ providerDialog ( QStringLiteral ( " spatialite" ), tr ( " SpatiaLite" ), QStringLiteral ( " /mActionAddSpatiaLiteLayer.svg" ) );
72
71
73
- addDbProviderDialog ( QStringLiteral ( " mssql" ), tr ( " MSSQL" ), QStringLiteral ( " /mActionAddMssqlLayer.svg" ) );
72
+ providerDialog ( QStringLiteral ( " mssql" ), tr ( " MSSQL" ), QStringLiteral ( " /mActionAddMssqlLayer.svg" ) );
74
73
75
- addDbProviderDialog ( QStringLiteral ( " DB2" ), tr ( " DB2" ), QStringLiteral ( " /mActionAddDb2Layer.svg" ) );
74
+ providerDialog ( QStringLiteral ( " DB2" ), tr ( " DB2" ), QStringLiteral ( " /mActionAddDb2Layer.svg" ) );
76
75
77
76
#ifdef HAVE_ORACLE
78
- addDbProviderDialog ( QStringLiteral ( " oracle" ), tr ( " Oracle" ), QStringLiteral ( " /mActionAddOracleLayer.svg" ) );
77
+ providerDialog ( QStringLiteral ( " oracle" ), tr ( " Oracle" ), QStringLiteral ( " /mActionAddOracleLayer.svg" ) );
79
78
#endif
80
79
81
- dlg = addVectorProviderDialog ( QStringLiteral ( " virtual" ), tr ( " Virtual Layer" ), QStringLiteral ( " /mActionAddVirtualLayer.svg" ) );
80
+ providerDialog ( QStringLiteral ( " virtual" ), tr ( " Virtual Layer" ), QStringLiteral ( " /mActionAddVirtualLayer.svg" ) );
82
81
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" ) );
90
83
91
- addRasterProviderDialog ( QStringLiteral ( " wms " ), tr ( " WMS " ), QStringLiteral ( " /mActionAddWmsLayer .svg" ) );
84
+ providerDialog ( QStringLiteral ( " wcs " ), tr ( " WCS " ), QStringLiteral ( " /mActionAddWcsLayer .svg" ) );
92
85
93
- addRasterProviderDialog ( QStringLiteral ( " wcs " ), tr ( " WCS " ), QStringLiteral ( " /mActionAddWcsLayer .svg" ) );
86
+ providerDialog ( QStringLiteral ( " WFS " ), tr ( " WFS " ), QStringLiteral ( " /mActionAddWfsLayer .svg" ) );
94
87
95
- addVectorProviderDialog ( QStringLiteral ( " WFS " ), tr ( " WFS " ), QStringLiteral ( " /mActionAddWfsLayer .svg" ) );
88
+ providerDialog ( QStringLiteral ( " arcgismapserver " ), tr ( " ArcGIS Map Server " ), QStringLiteral ( " /mActionAddAmsLayer .svg" ) );
96
89
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" ) );
100
91
101
92
}
102
93
@@ -171,51 +162,33 @@ QgsAbstractDataSourceWidget *QgsDataSourceManagerDialog::providerDialog( const Q
171
162
}
172
163
connect ( dlg, &QgsAbstractDataSourceWidget::rejected, this , &QgsDataSourceManagerDialog::reject );
173
164
connect ( dlg, &QgsAbstractDataSourceWidget::accepted, this , &QgsDataSourceManagerDialog::accept );
165
+ makeConnections ( dlg, providerKey );
174
166
return dlg;
175
167
}
176
168
}
177
169
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 )
196
171
{
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 () ) );
219
192
}
220
193
221
194
void QgsDataSourceManagerDialog::showEvent ( QShowEvent *e )
0 commit comments