Skip to content

Commit

Permalink
Merge pull request #5616 from boundlessgeo/datasource-manager-add-close
Browse files Browse the repository at this point in the history
[gui] Datasource manager remove Ok and add Close
  • Loading branch information
elpaso authored Nov 15, 2017
2 parents b95588c + f177ba3 commit 340f7ab
Show file tree
Hide file tree
Showing 4 changed files with 5 additions and 29 deletions.
5 changes: 0 additions & 5 deletions python/gui/qgsabstractdatasourcewidget.sip
Original file line number Diff line number Diff line change
Expand Up @@ -53,11 +53,6 @@ Destructor
being added.
%End

virtual void okButtonClicked();
%Docstring
Triggered when the dialog is accepted, call addButtonClicked() and
emit the accepted() signal
%End

signals:

Expand Down
22 changes: 4 additions & 18 deletions src/gui/qgsabstractdatasourcewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,26 +38,17 @@ const QgsMapCanvas *QgsAbstractDataSourceWidget::mapCanvas() const
void QgsAbstractDataSourceWidget::setupButtons( QDialogButtonBox *buttonBox )
{

if ( mWidgetMode == QgsProviderRegistry::WidgetMode::None )
{
QPushButton *closeButton = new QPushButton( tr( "&Close" ) );
buttonBox->addButton( closeButton, QDialogButtonBox::ApplyRole );
connect( closeButton, &QPushButton::clicked, this, &QgsAbstractDataSourceWidget::addButtonClicked );
}

mAddButton = new QPushButton( tr( "&Add" ) );
mAddButton->setToolTip( tr( "Add selected layers to map" ) );
mAddButton->setEnabled( false );
buttonBox->addButton( mAddButton, QDialogButtonBox::ApplyRole );
connect( mAddButton, &QPushButton::clicked, this, &QgsAbstractDataSourceWidget::addButtonClicked );
connect( this, &QgsAbstractDataSourceWidget::enableButtons, mAddButton, &QPushButton::setEnabled );

QPushButton *okButton = new QPushButton( tr( "&Ok" ) );
okButton->setToolTip( tr( "Add selected layers to map and close this dialog" ) );
okButton->setEnabled( false );
buttonBox->addButton( okButton, QDialogButtonBox::AcceptRole );
connect( okButton, &QPushButton::clicked, this, &QgsAbstractDataSourceWidget::okButtonClicked );
connect( this, &QgsAbstractDataSourceWidget::enableButtons, okButton, &QPushButton::setEnabled );
QPushButton *closeButton = new QPushButton( tr( "&Close" ) );
closeButton->setToolTip( tr( "Close this dialog without adding any layer" ) );
buttonBox->addButton( closeButton, QDialogButtonBox::RejectRole );
connect( closeButton, &QPushButton::clicked, this, &QgsAbstractDataSourceWidget::reject );

}

Expand All @@ -67,8 +58,3 @@ void QgsAbstractDataSourceWidget::setMapCanvas( const QgsMapCanvas *mapCanvas )
mMapCanvas = mapCanvas;
}

void QgsAbstractDataSourceWidget::okButtonClicked()
{
addButtonClicked();
emit accepted();
}
5 changes: 0 additions & 5 deletions src/gui/qgsabstractdatasourcewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,11 +69,6 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
*/
virtual void addButtonClicked() { }

/**
* Triggered when the dialog is accepted, call addButtonClicked() and
* emit the accepted() signal
*/
virtual void okButtonClicked();

signals:

Expand Down
2 changes: 1 addition & 1 deletion src/gui/qgsdatasourcemanagerdialog.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -60,7 +60,7 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QgsBrowserModel *browser

// Add provider dialogs
const QList<QgsSourceSelectProvider *> sourceSelectProviders = QgsGui::sourceSelectProviderRegistry()->providers( );
for ( const auto provider : sourceSelectProviders )
for ( const auto &provider : sourceSelectProviders )
{
QgsAbstractDataSourceWidget *dlg = provider->createDataSourceWidget( this );
if ( !dlg )
Expand Down

0 comments on commit 340f7ab

Please sign in to comment.