Skip to content
Permalink
Browse files

Source select signals: remove duplicate code and rely to the base class

  • Loading branch information
elpaso committed Aug 5, 2017
1 parent b0c29da commit 8463ddba703d13bbf8c017e5a2b82d561796397a
@@ -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" ) );
@@ -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 ) ) );
}

@@ -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 )
@@ -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 )
@@ -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 )
@@ -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 )
@@ -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;
@@ -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();
@@ -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
@@ -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 )
{
@@ -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 );

0 comments on commit 8463ddb

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