Skip to content

Commit

Permalink
Source select signals: remove duplicate code and rely to the base class
Browse files Browse the repository at this point in the history
  • Loading branch information
elpaso committed Aug 5, 2017
1 parent b0c29da commit 8463ddb
Show file tree
Hide file tree
Showing 6 changed files with 16 additions and 21 deletions.
22 changes: 11 additions & 11 deletions src/gui/qgsdatasourcemanagerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,7 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QWidget *parent, QgsMapC
// Add data provider dialogs
QWidget *dlg = nullptr;

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

if ( dlg )
{
connect( dlg, SIGNAL( addVectorLayer( QString, QString, QString ) ), this, SLOT( vectorLayerAdded( QString, QString, QString ) ) );
}
addVectorProviderDialog( QStringLiteral( "delimitedtext" ), tr( "Delimited Text" ), QStringLiteral( "/mActionAddDelimitedTextLayer.svg" ) );

#ifdef HAVE_POSTGRESQL
addDbProviderDialog( QStringLiteral( "postgres" ), tr( "PostgreSQL" ), QStringLiteral( "/mActionAddPostgisLayer.svg" ) );
Expand All @@ -97,11 +92,13 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QWidget *parent, QgsMapC
addDbProviderDialog( QStringLiteral( "oracle" ), tr( "Oracle" ), QStringLiteral( "/mActionAddOracleLayer.svg" ) );
#endif

dlg = providerDialog( QStringLiteral( "virtual" ), tr( "Virtual Layer" ), QStringLiteral( "/mActionAddVirtualLayer.svg" ) );
dlg = addVectorProviderDialog( QStringLiteral( "virtual" ), tr( "Virtual Layer" ), QStringLiteral( "/mActionAddVirtualLayer.svg" ) );

// Apparently this is the only provider using replaceVectorLayer, we should
// move this in to the base abstract class when it is used by at least one
// additional provider.
if ( dlg )
{
connect( dlg, SIGNAL( addVectorLayer( QString, QString, QString ) ), this, SLOT( vectorLayerAdded( QString, QString, QString ) ) );
connect( dlg, SIGNAL( replaceVectorLayer( QString, QString, QString, QString ) ), this, SIGNAL( replaceSelectedVectorLayer( QString, QString, QString, QString ) ) );
}

Expand Down Expand Up @@ -197,7 +194,7 @@ QgsAbstractDataSourceWidget *QgsDataSourceManagerDialog::providerDialog( const Q
}
}

void QgsDataSourceManagerDialog::addDbProviderDialog( const QString providerKey, const QString providerName, const QString icon, QString title )
QgsAbstractDataSourceWidget *QgsDataSourceManagerDialog::addDbProviderDialog( const QString providerKey, const QString providerName, const QString icon, QString title )
{
QgsAbstractDataSourceWidget *dlg = providerDialog( providerKey, providerName, icon, title );
if ( dlg )
Expand All @@ -211,9 +208,10 @@ void QgsDataSourceManagerDialog::addDbProviderDialog( const QString providerKey,
connect( dlg, SIGNAL( connectionsChanged() ), this, SIGNAL( connectionsChanged() ) );
connect( this, SIGNAL( providerDialogsRefreshRequested() ), dlg, SLOT( refresh() ) );
}
return dlg;
}

void QgsDataSourceManagerDialog::addRasterProviderDialog( const QString providerKey, const QString providerName, const QString icon, QString title )
QgsAbstractDataSourceWidget *QgsDataSourceManagerDialog::addRasterProviderDialog( const QString providerKey, const QString providerName, const QString icon, QString title )
{
QgsAbstractDataSourceWidget *dlg = providerDialog( providerKey, providerName, icon, title );
if ( dlg )
Expand All @@ -223,9 +221,10 @@ void QgsDataSourceManagerDialog::addRasterProviderDialog( const QString provider
connect( dlg, SIGNAL( connectionsChanged() ), this, SIGNAL( connectionsChanged() ) );
connect( this, SIGNAL( providerDialogsRefreshRequested() ), dlg, SLOT( refresh() ) );
}
return dlg;
}

void QgsDataSourceManagerDialog::addVectorProviderDialog( const QString providerKey, const QString providerName, const QString icon, QString title )
QgsAbstractDataSourceWidget *QgsDataSourceManagerDialog::addVectorProviderDialog( const QString providerKey, const QString providerName, const QString icon, QString title )
{
QgsAbstractDataSourceWidget *dlg = providerDialog( providerKey, providerName, icon, title );
if ( dlg )
Expand All @@ -234,6 +233,7 @@ void QgsDataSourceManagerDialog::addVectorProviderDialog( const QString provider
{ this->vectorLayerAdded( vectorLayerPath, baseName, providerKey ); } );
connect( this, SIGNAL( providerDialogsRefreshRequested() ), dlg, SLOT( refresh() ) );
}
return dlg;
}

void QgsDataSourceManagerDialog::showEvent( QShowEvent *e )
Expand Down
6 changes: 3 additions & 3 deletions src/gui/qgsdatasourcemanagerdialog.h
Original file line number Diff line number Diff line change
Expand Up @@ -116,9 +116,9 @@ class GUI_EXPORT QgsDataSourceManagerDialog : public QgsOptionsDialogBase, priva
private:
// Return the dialog from the provider
QgsAbstractDataSourceWidget *providerDialog( const QString providerKey, const QString providerName, const QString icon, QString title = QString() );
void addDbProviderDialog( QString const providerKey, QString const providerName, QString const icon, QString title = QString() );
void addRasterProviderDialog( QString const providerKey, QString const providerName, QString const icon, QString title = QString() );
void addVectorProviderDialog( QString const providerKey, QString const providerName, QString const icon, QString title = QString() );
QgsAbstractDataSourceWidget *addDbProviderDialog( QString const providerKey, QString const providerName, QString const icon, QString title = QString() );
QgsAbstractDataSourceWidget *addRasterProviderDialog( QString const providerKey, QString const providerName, QString const icon, QString title = QString() );
QgsAbstractDataSourceWidget *addVectorProviderDialog( QString const providerKey, QString const providerName, QString const icon, QString title = QString() );
Ui::QgsDataSourceManagerDialog *ui;
QgsBrowserDockWidget *mBrowserWidget = nullptr;
int mPreviousRow;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -193,7 +193,7 @@ void QgsDelimitedTextSourceSelect::addButtonClicked()


// add the layer to the map
emit addVectorLayer( QString::fromAscii( url.toEncoded() ), txtLayerName->text(), QStringLiteral( "delimitedtext" ) );
emit addVectorLayer( QString::fromAscii( url.toEncoded() ), txtLayerName->text() );
if ( widgetMode() == QgsProviderRegistry::WidgetMode::None )
{
accept();
Expand Down
3 changes: 0 additions & 3 deletions src/providers/delimitedtext/qgsdelimitedtextsourceselect.h
Original file line number Diff line number Diff line change
Expand Up @@ -72,9 +72,6 @@ class QgsDelimitedTextSourceSelect : public QgsAbstractDataSourceWidget, private
void updateFieldsAndEnable();
void enableAccept();
bool validate();

signals:
void addVectorLayer( const QString &, const QString &, const QString & );
};

#endif // QGSDELIMITEDTEXTSOURCESELECT_H
2 changes: 1 addition & 1 deletion src/providers/virtual/qgsvirtuallayersourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ void QgsVirtualLayerSourceSelect::addButtonClicked()
}
else
{
emit addVectorLayer( def.toString(), layerName, QStringLiteral( "virtual" ) );
emit addVectorLayer( def.toString(), layerName );
}
if ( widgetMode() == QgsProviderRegistry::WidgetMode::None )
{
Expand Down
2 changes: 0 additions & 2 deletions src/providers/virtual/qgsvirtuallayersourceselect.h
Original file line number Diff line number Diff line change
Expand Up @@ -54,8 +54,6 @@ class QgsVirtualLayerSourceSelect : public QgsAbstractDataSourceWidget, private
void updateLayersList();

signals:
//! Source, name, provider
void addVectorLayer( QString, QString, QString );
//! Old_id, source, name, provider
void replaceVectorLayer( QString, QString, QString, QString );

Expand Down

0 comments on commit 8463ddb

Please sign in to comment.