Skip to content
Permalink
Browse files

Renamed button slots and make ogr dialog inherit from the abstract base

  • Loading branch information
elpaso committed Aug 4, 2017
1 parent dc6017d commit fef3bc099d4bd1e5365dcd7bc19202a721a8e4c3
Showing with 68 additions and 93 deletions.
  1. +5 −4 python/gui/qgsabstractdatasourcewidget.sip
  2. +8 −22 src/gui/ogr/qgsopenvectorlayerdialog.cpp
  3. +5 −5 src/gui/ogr/qgsopenvectorlayerdialog.h
  4. +5 −5 src/gui/qgsabstractdatasourcewidget.cpp
  5. +5 −4 src/gui/qgsabstractdatasourcewidget.h
  6. +1 −1 src/gui/qgsdatasourcemanagerdialog.cpp
  7. +1 −6 src/providers/arcgisrest/qgsafssourceselect.cpp
  8. +1 −5 src/providers/arcgisrest/qgsamssourceselect.cpp
  9. +1 −2 src/providers/arcgisrest/qgsarcgisservicesourceselect.cpp
  10. +1 −1 src/providers/arcgisrest/qgsarcgisservicesourceselect.h
  11. +2 −2 src/providers/db2/qgsdb2sourceselect.cpp
  12. +1 −1 src/providers/db2/qgsdb2sourceselect.h
  13. +1 −1 src/providers/delimitedtext/qgsdelimitedtextsourceselect.cpp
  14. +1 −1 src/providers/delimitedtext/qgsdelimitedtextsourceselect.h
  15. +2 −2 src/providers/mssql/qgsmssqlsourceselect.cpp
  16. +1 −1 src/providers/mssql/qgsmssqlsourceselect.h
  17. +7 −1 src/providers/ogr/CMakeLists.txt
  18. +4 −10 src/providers/oracle/qgsoraclesourceselect.cpp
  19. +1 −1 src/providers/oracle/qgsoraclesourceselect.h
  20. +2 −2 src/providers/postgres/qgspgsourceselect.cpp
  21. +1 −1 src/providers/postgres/qgspgsourceselect.h
  22. +1 −1 src/providers/spatialite/qgsspatialitesourceselect.cpp
  23. +1 −1 src/providers/spatialite/qgsspatialitesourceselect.h
  24. +1 −1 src/providers/virtual/qgsvirtuallayersourceselect.cpp
  25. +1 −1 src/providers/virtual/qgsvirtuallayersourceselect.h
  26. +1 −1 src/providers/wcs/qgswcssourceselect.cpp
  27. +1 −1 src/providers/wcs/qgswcssourceselect.h
  28. +1 −1 src/providers/wfs/qgswfssourceselect.cpp
  29. +1 −1 src/providers/wfs/qgswfssourceselect.h
  30. +1 −1 src/providers/wms/qgswmssourceselect.cpp
  31. +1 −1 src/providers/wms/qgswmssourceselect.h
  32. +2 −5 src/ui/qgsopenvectorlayerdialogbase.ui
@@ -46,16 +46,17 @@ Destructor
The default implementation does nothing
%End

virtual void addClicked();
virtual void addButtonClicked();
%Docstring
Triggered when the add button is clicked, the add layer signal is emitted
Concrete classes should implement the right behavior depending on the layer
being added.
%End

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

signals:
@@ -121,7 +122,7 @@ Return the map canvas (can be null)
Connect the ok and apply/add buttons to the slots
%End

const QPushButton *addButton( );
QPushButton *addButton( ) const;
%Docstring
Return the add Button
:rtype: QPushButton
@@ -32,22 +32,10 @@
#include "qgsapplication.h"

QgsOpenVectorLayerDialog::QgsOpenVectorLayerDialog( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode )
: QDialog( parent, fl ),
mWidgetMode( widgetMode ),
mAddButton( nullptr )
: QgsAbstractDataSourceWidget( parent, fl, widgetMode )
{
setupUi( this );

if ( mWidgetMode != QgsProviderRegistry::WidgetMode::None )
{
this->layout()->setSizeConstraint( QLayout::SetNoConstraint );
buttonBox->removeButton( buttonBox->button( QDialogButtonBox::Cancel ) );
}

mAddButton = new QPushButton( tr( "&Add" ) );
// TODO: enable/disable according to valid selection
mAddButton->setEnabled( true );
buttonBox->addButton( mAddButton, QDialogButtonBox::AcceptRole );
setupButtons( buttonBox );

cmbDatabaseTypes->blockSignals( true );
cmbConnections->blockSignals( true );
@@ -287,7 +275,7 @@ void QgsOpenVectorLayerDialog::on_buttonSelectSrc_clicked()
if ( !selected.isEmpty() )
{
inputSrcDataset->setText( selected.join( QStringLiteral( ";" ) ) );
mAddButton->setFocus();
addButton()->setFocus();
}
}
else if ( radioSrcDirectory->isChecked() )
@@ -302,8 +290,7 @@ void QgsOpenVectorLayerDialog::on_buttonSelectSrc_clicked()



//********************auto connected slots *****************/
void QgsOpenVectorLayerDialog::accept()
void QgsOpenVectorLayerDialog::addButtonClicked()
{
QgsSettings settings;
QgsDebugMsg( "dialog button accepted" );
@@ -395,16 +382,15 @@ void QgsOpenVectorLayerDialog::accept()
// Save the used encoding
settings.setValue( QStringLiteral( "UI/encoding" ), encoding() );

if ( mWidgetMode == QgsProviderRegistry::WidgetMode::None )
{
QDialog::accept();
}
else if ( ! mDataSources.isEmpty() )
if ( ! mDataSources.isEmpty() )
{
emit addVectorLayers( mDataSources, encoding(), dataSourceType() );
}
}


//********************auto connected slots *****************/

void QgsOpenVectorLayerDialog::on_radioSrcFile_toggled( bool checked )
{
if ( checked )
@@ -23,6 +23,7 @@
#include <QDialog>
#include "qgshelp.h"
#include "qgsproviderregistry.h"
#include "qgsabstractdatasourcewidget.h"
#include "qgis_gui.h"

#define SIP_NO_FILE
@@ -32,7 +33,7 @@
* file, database, directory and protocol sources.
* \note not available in Python bindings
*/
class GUI_EXPORT QgsOpenVectorLayerDialog : public QDialog, private Ui::QgsOpenVectorLayerDialogBase
class GUI_EXPORT QgsOpenVectorLayerDialog : public QgsAbstractDataSourceWidget, private Ui::QgsOpenVectorLayerDialogBase
{
Q_OBJECT

@@ -60,8 +61,9 @@ class GUI_EXPORT QgsOpenVectorLayerDialog : public QDialog, private Ui::QgsOpenV
QString mDataSourceType;
//! Embedded dialog (do not call parent's accept) and emit signals
QgsProviderRegistry::WidgetMode mWidgetMode = QgsProviderRegistry::WidgetMode::None;
//! Add layer button
QPushButton *mAddButton = nullptr;

public slots:
void addButtonClicked() override;

private slots:
//! Opens the create connection dialog to build a new connection
@@ -81,8 +83,6 @@ class GUI_EXPORT QgsOpenVectorLayerDialog : public QDialog, private Ui::QgsOpenV
//! Sets the selected connection
void setSelectedConnection();

void accept() override;

void on_buttonSelectSrc_clicked();
void on_radioSrcFile_toggled( bool checked );
void on_radioSrcDirectory_toggled( bool checked );
@@ -42,21 +42,21 @@ void QgsAbstractDataSourceWidget::setupButtons( QDialogButtonBox *buttonBox )
{
QPushButton *closeButton = new QPushButton( tr( "&Close" ) );
buttonBox->addButton( closeButton, QDialogButtonBox::ApplyRole );
connect( closeButton, &QPushButton::clicked, this, &QgsAbstractDataSourceWidget::addClicked );
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::addClicked );
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::okClicked );
connect( okButton, &QPushButton::clicked, this, &QgsAbstractDataSourceWidget::okButtonClicked );
connect( this, &QgsAbstractDataSourceWidget::enableButtons, okButton, &QPushButton::setEnabled );

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

void QgsAbstractDataSourceWidget::okClicked()
void QgsAbstractDataSourceWidget::okButtonClicked()
{
addClicked();
addButtonClicked();
emit accepted();
}
@@ -63,11 +63,12 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
* Concrete classes should implement the right behavior depending on the layer
* being added.
*/
virtual void addClicked() { }
virtual void addButtonClicked() { }

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

signals:

@@ -110,7 +111,7 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
void setupButtons( QDialogButtonBox *buttonBox );

//! Return the add Button
const QPushButton *addButton( ) { return mAddButton; }
QPushButton *addButton( ) const { return mAddButton; }

private:
QPushButton *mAddButton = nullptr;
@@ -209,7 +209,7 @@ void QgsDataSourceManagerDialog::addDbProviderDialog( const QString providerKey,
connect( dlg, SIGNAL( progressMessage( QString ) ),
this, SIGNAL( showStatusMessage( QString ) ) );
connect( dlg, SIGNAL( connectionsChanged() ), this, SIGNAL( connectionsChanged() ) );
connect( this, SIGNAL( providerDialogsRefreshRequested() ), dlg, SLOT( refresh() ) );
connect( this, SIGNAL( providerDialogsRefreshRequested() ), dlg, SLOT( refresh() ) );
}
}

@@ -27,13 +27,8 @@


QgsAfsSourceSelect::QgsAfsSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode )
: QgsArcGisServiceSourceSelect( QStringLiteral( "ArcGisFeatureServer" ), QgsArcGisServiceSourceSelect::FeatureService, parent, fl )
: QgsArcGisServiceSourceSelect( QStringLiteral( "ArcGisFeatureServer" ), QgsArcGisServiceSourceSelect::FeatureService, parent, fl, widgetMode )
{
if ( widgetMode == QgsProviderRegistry::WidgetMode::Embedded || widgetMode == QgsProviderRegistry::WidgetMode::Manager )
{
buttonBox->removeButton( buttonBox->button( QDialogButtonBox::Close ) );
}

// import/export of connections not supported yet
btnLoad->hide();
btnSave->hide();
@@ -26,12 +26,8 @@


QgsAmsSourceSelect::QgsAmsSourceSelect( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode )
: QgsArcGisServiceSourceSelect( QStringLiteral( "ArcGisMapServer" ), QgsArcGisServiceSourceSelect::MapService, parent, fl )
: QgsArcGisServiceSourceSelect( QStringLiteral( "ArcGisMapServer" ), QgsArcGisServiceSourceSelect::MapService, parent, fl, widgetMode )
{
if ( widgetMode == QgsProviderRegistry::WidgetMode::Embedded || widgetMode == QgsProviderRegistry::WidgetMode::Manager )
{
buttonBox->removeButton( buttonBox->button( QDialogButtonBox::Close ) );
}

// import/export of connections not supported yet
btnLoad->hide();
@@ -57,7 +57,6 @@ QgsArcGisServiceSourceSelect::QgsArcGisServiceSourceSelect( const QString &servi
mImageEncodingGroup( 0 )
{
setupUi( this );
// Creates and connects standard ok/apply buttons
setupButtons( buttonBox );
setWindowTitle( QStringLiteral( "Add %1 Layer from a Server" ).arg( mServiceName ) );

@@ -306,7 +305,7 @@ void QgsArcGisServiceSourceSelect::connectToServer()
btnChangeSpatialRefSys->setEnabled( haveLayers );
}

void QgsArcGisServiceSourceSelect::addClicked()
void QgsArcGisServiceSourceSelect::addButtonClicked()
{
if ( treeView->selectionModel()->selectedRows().isEmpty() )
{
@@ -104,7 +104,7 @@ class QgsArcGisServiceSourceSelect : public QgsAbstractDataSourceWidget, protect
void addEntryToServerList();
void deleteEntryOfServerList();
void modifyEntryOfServerList();
void addClicked() override;
void addButtonClicked() override;
void buildQueryButtonClicked();
void changeCrs();
void changeCrsFilter();
@@ -312,7 +312,7 @@ void QgsDb2SourceSelect::on_mTablesTreeView_doubleClicked( const QModelIndex &in
QgsSettings settings;
if ( settings.value( QStringLiteral( "qgis/addDb2DC" ), false ).toBool() )
{
addClicked();
addButtonClicked();
}
else
{
@@ -427,7 +427,7 @@ void QgsDb2SourceSelect::populateConnectionList()
}

// Slot for performing action when the Add button is clicked
void QgsDb2SourceSelect::addClicked()
void QgsDb2SourceSelect::addButtonClicked()
{
QgsDebugMsg( QString( "mConnInfo:%1" ).arg( mConnInfo ) );
mSelectedTables.clear();
@@ -113,7 +113,7 @@ class QgsDb2SourceSelect : public QgsAbstractDataSourceWidget, private Ui::QgsDb

public slots:
//! Determines the tables the user selected and closes the dialog
void addClicked() override;
void addButtonClicked() override;
void buildQuery();
//! Triggered when the provider's connections need to be refreshed
void refresh() override;
@@ -109,7 +109,7 @@ void QgsDelimitedTextSourceSelect::on_btnBrowseForFile_clicked()
getOpenFileName();
}

void QgsDelimitedTextSourceSelect::addClicked()
void QgsDelimitedTextSourceSelect::addButtonClicked()
{
// The following conditions should not be hit! OK will not be enabled...
if ( txtLayerName->text().isEmpty() )
@@ -67,7 +67,7 @@ class QgsDelimitedTextSourceSelect : public QgsAbstractDataSourceWidget, private
void on_btnBrowseForFile_clicked();

public slots:
void addClicked() override;
void addButtonClicked() override;
void updateFileName();
void updateFieldsAndEnable();
void enableAccept();
@@ -311,7 +311,7 @@ void QgsMssqlSourceSelect::on_mTablesTreeView_doubleClicked( const QModelIndex &
QgsSettings settings;
if ( settings.value( QStringLiteral( "qgis/addMSSQLDC" ), false ).toBool() )
{
addClicked();
addButtonClicked();
}
else
{
@@ -426,7 +426,7 @@ void QgsMssqlSourceSelect::populateConnectionList()
}

// Slot for performing action when the Add button is clicked
void QgsMssqlSourceSelect::addClicked()
void QgsMssqlSourceSelect::addButtonClicked()
{
QgsDebugMsg( QString( "mConnInfo:%1" ).arg( mConnInfo ) );
mSelectedTables.clear();
@@ -87,7 +87,7 @@ class QgsMssqlSourceSelect : public QgsAbstractDataSourceWidget, private Ui::Qgs
void refresh() override;

//! Determines the tables the user selected and closes the dialog
void addClicked() override;
void addButtonClicked() override;
void buildQuery();

/** Connects to the database using the stored connection parameters.
@@ -1,5 +1,11 @@

SET (OGR_SRCS qgsogrprovider.cpp qgsogrdataitems.cpp qgsogrfeatureiterator.cpp qgsogrconnpool.cpp qgsogrexpressioncompiler.cpp)
SET (OGR_SRCS
qgsogrprovider.cpp
qgsogrdataitems.cpp
qgsogrfeatureiterator.cpp
qgsogrconnpool.cpp
qgsogrexpressioncompiler.cpp
)

SET(OGR_MOC_HDRS qgsogrprovider.h qgsogrdataitems.h qgsogrconnpool.h)

@@ -172,29 +172,23 @@ QgsOracleSourceSelect::QgsOracleSourceSelect( QWidget *parent, Qt::WindowFlags f
, mIsConnected( false )
{
setupUi( this );
setupButton( buttonBox );

if ( widgetMode() != QgsProviderRegistry::WidgetMode::None )
{
buttonBox->removeButton( buttonBox->button( QDialogButtonBox::Close ) );
mHoldDialogOpen->hide();
}
else
{
setWindowTitle( tr( "Add Oracle Table(s)" ) );
}

mAddButton = new QPushButton( tr( "&Add" ) );
mAddButton->setEnabled( false );

mBuildQueryButton = new QPushButton( tr( "&Set Filter" ) );
mBuildQueryButton->setToolTip( tr( "Set Filter" ) );
mBuildQueryButton->setDisabled( true );

if ( widgetMode() != QgsProviderRegistry::WidgetMode::Manager )
{
buttonBox->addButton( mAddButton, QDialogButtonBox::ActionRole );
connect( mAddButton, &QAbstractButton::clicked, this, &QgsOracleSourceSelect::addTables );

buttonBox->addButton( mBuildQueryButton, QDialogButtonBox::ActionRole );
connect( mBuildQueryButton, &QAbstractButton::clicked, this, &QgsOracleSourceSelect::buildQuery );
}
@@ -359,7 +353,7 @@ void QgsOracleSourceSelect::on_mTablesTreeView_doubleClicked( const QModelIndex
QgsSettings settings;
if ( settings.value( QStringLiteral( "qgis/addOracleDC" ), false ).toBool() )
{
addTables();
addClicked();
}
else
{
@@ -470,7 +464,7 @@ void QgsOracleSourceSelect::populateConnectionList()
}

// Slot for performing action when the Add button is clicked
void QgsOracleSourceSelect::addTables()
void QgsOracleSourceSelect::addClicked()
{
mSelectedTables.clear();

@@ -674,5 +668,5 @@ void QgsOracleSourceSelect::loadTableFromCache()
void QgsOracleSourceSelect::treeWidgetSelectionChanged( const QItemSelection &selected, const QItemSelection &deselected )
{
Q_UNUSED( deselected )
mAddButton->setEnabled( !selected.isEmpty() );
emit enableButtons( !selected.isEmpty() );
}

0 comments on commit fef3bc0

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