Skip to content
Permalink
Browse files

Merge pull request #4962 from boundlessgeo/unified-layer-dialog-mods

Unified layer dialog mods
  • Loading branch information
elpaso committed Aug 4, 2017
2 parents 5e2b17a + fef3bc0 commit 04059ebccf697ea5e55fbf64a30bca6a9e6d2466
Showing with 195 additions and 239 deletions.
  1. +31 −1 python/gui/qgsabstractdatasourcewidget.sip
  2. +0 −6 python/gui/qgsowssourceselect.sip
  3. +8 −22 src/gui/ogr/qgsopenvectorlayerdialog.cpp
  4. +5 −5 src/gui/ogr/qgsopenvectorlayerdialog.h
  5. +33 −1 src/gui/qgsabstractdatasourcewidget.cpp
  6. +24 −3 src/gui/qgsabstractdatasourcewidget.h
  7. +2 −1 src/gui/qgsdatasourcemanagerdialog.cpp
  8. +1 −16 src/gui/qgsowssourceselect.cpp
  9. +0 −5 src/gui/qgsowssourceselect.h
  10. +1 −6 src/providers/arcgisrest/qgsafssourceselect.cpp
  11. +1 −5 src/providers/arcgisrest/qgsamssourceselect.cpp
  12. +3 −6 src/providers/arcgisrest/qgsarcgisservicesourceselect.cpp
  13. +1 −2 src/providers/arcgisrest/qgsarcgisservicesourceselect.h
  14. +4 −11 src/providers/db2/qgsdb2sourceselect.cpp
  15. +1 −2 src/providers/db2/qgsdb2sourceselect.h
  16. +3 −13 src/providers/delimitedtext/qgsdelimitedtextsourceselect.cpp
  17. +1 −2 src/providers/delimitedtext/qgsdelimitedtextsourceselect.h
  18. +4 −9 src/providers/mssql/qgsmssqlsourceselect.cpp
  19. +1 −2 src/providers/mssql/qgsmssqlsourceselect.h
  20. +7 −1 src/providers/ogr/CMakeLists.txt
  21. +4 −10 src/providers/oracle/qgsoraclesourceselect.cpp
  22. +1 −1 src/providers/oracle/qgsoraclesourceselect.h
  23. +4 −10 src/providers/postgres/qgspgsourceselect.cpp
  24. +1 −2 src/providers/postgres/qgspgsourceselect.h
  25. +3 −14 src/providers/spatialite/qgsspatialitesourceselect.cpp
  26. +1 −4 src/providers/spatialite/qgsspatialitesourceselect.h
  27. +5 −7 src/providers/virtual/qgsvirtuallayersourceselect.cpp
  28. +1 −1 src/providers/virtual/qgsvirtuallayersourceselect.h
  29. +1 −1 src/providers/virtual/qgsvirtuallayersourceselectbase.ui
  30. +4 −3 src/providers/wcs/qgswcssourceselect.cpp
  31. +1 −1 src/providers/wcs/qgswcssourceselect.h
  32. +5 −13 src/providers/wfs/qgswfssourceselect.cpp
  33. +1 −2 src/providers/wfs/qgswfssourceselect.h
  34. +11 −25 src/providers/wms/qgswmssourceselect.cpp
  35. +1 −3 src/providers/wms/qgswmssourceselect.h
  36. +2 −2 src/ui/qgsarcgisservicesourceselectbase.ui
  37. +1 −1 src/ui/qgsdbsourceselectbase.ui
  38. +2 −2 src/ui/qgsdelimitedtextsourceselectbase.ui
  39. +2 −5 src/ui/qgsopenvectorlayerdialogbase.ui
  40. +1 −1 src/ui/qgsowssourceselectbase.ui
  41. +10 −10 src/ui/qgswfssourceselectbase.ui
  42. +2 −2 src/ui/qgswmssourceselectbase.ui
@@ -46,6 +46,19 @@ Destructor
The default implementation does nothing
%End

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 okButtonClicked();
%Docstring
Triggered when the dialog is accepted, call addButtonClicked() and
emit the accepted() signal
%End

signals:

void connectionsChanged();
@@ -79,6 +92,12 @@ Emitted when a progress dialog is shown by the provider dialog
Emitted when a progress dialog is shown by the provider dialog
%End

void enableButtons( bool enable );
%Docstring
Emitted when the ok/add buttons should be enabled/disabled
%End


protected:

QgsAbstractDataSourceWidget( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
@@ -94,10 +113,21 @@ Return the widget mode

const QgsMapCanvas *mapCanvas() const;
%Docstring
Return the map canvas (can be null)
Return the map canvas (can be null)
:rtype: QgsMapCanvas
%End

void setupButtons( QDialogButtonBox *buttonBox );
%Docstring
Connect the ok and apply/add buttons to the slots
%End

QPushButton *addButton( ) const;
%Docstring
Return the add Button
:rtype: QPushButton
%End

};

/************************************************************************
@@ -75,11 +75,6 @@ Loads connections from the file
Once connected, available layers are displayed.
%End

virtual void addClicked();
%Docstring
Determines the layers the user selected
%End

void searchFinished();

void on_mChangeCRSButton_clicked();
@@ -214,7 +209,6 @@ Returns a textual description for the authority id




void addWmsListRow( const QDomElement &item, int row );
%Docstring
layer name derived from latest layer selection (updated as long it's not edited manually)
@@ -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 );
@@ -17,12 +17,12 @@
***************************************************************************/

#include "qgsabstractdatasourcewidget.h"
#include <QPushButton>

QgsAbstractDataSourceWidget::QgsAbstractDataSourceWidget( QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode ):
QDialog( parent, fl ),
mWidgetMode( widgetMode )
{

}

QgsProviderRegistry::WidgetMode QgsAbstractDataSourceWidget::widgetMode() const
@@ -35,8 +35,40 @@ const QgsMapCanvas *QgsAbstractDataSourceWidget::mapCanvas() const
return mMapCanvas;
}

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 );

}


void QgsAbstractDataSourceWidget::setMapCanvas( const QgsMapCanvas *mapCanvas )
{
mMapCanvas = mapCanvas;
}

void QgsAbstractDataSourceWidget::okButtonClicked()
{
addButtonClicked();
emit accepted();
}
@@ -26,6 +26,7 @@
#include "qgsproviderregistry.h"
#include "qgsguiutils.h"
#include <QDialog>
#include <QDialogButtonBox>

class QgsMapCanvas;

@@ -58,6 +59,17 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
*/
virtual void refresh() {}

/** 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.
*/
virtual void addButtonClicked() { }

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

signals:

/** Emitted when the provider's connections have changed
@@ -80,6 +92,10 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
//! Emitted when a progress dialog is shown by the provider dialog
void progressMessage( QString message );

//! Emitted when the ok/add buttons should be enabled/disabled
void enableButtons( bool enable );


protected:

//! Constructor
@@ -88,12 +104,17 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
//! Return the widget mode
QgsProviderRegistry::WidgetMode widgetMode() const;

/** Return the map canvas (can be null)
*/
//! Return the map canvas (can be null)
const QgsMapCanvas *mapCanvas() const;

private:
//! Connect the ok and apply/add buttons to the slots
void setupButtons( QDialogButtonBox *buttonBox );

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

private:
QPushButton *mAddButton = nullptr;
QgsProviderRegistry::WidgetMode mWidgetMode;
QgsMapCanvas const *mMapCanvas = nullptr;

@@ -192,6 +192,7 @@ QgsAbstractDataSourceWidget *QgsDataSourceManagerDialog::providerDialog( const Q
dlg->setMapCanvas( mMapCanvas );
}
connect( dlg, &QgsAbstractDataSourceWidget::rejected, this, &QgsDataSourceManagerDialog::reject );
connect( dlg, &QgsAbstractDataSourceWidget::accepted, this, &QgsDataSourceManagerDialog::accept );
return dlg;
}
}
@@ -208,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() ) );
}
}

@@ -60,20 +60,11 @@ QgsOWSSourceSelect::QgsOWSSourceSelect( const QString &service, QWidget *parent,
, mCurrentTileset( nullptr )
{
setupUi( this );

if ( widgetMode() != QgsProviderRegistry::WidgetMode::None )
{
buttonBox->removeButton( buttonBox->button( QDialogButtonBox::Close ) );
}
setupButtons( buttonBox );


setWindowTitle( tr( "Add Layer(s) from a %1 Server" ).arg( service ) );

mAddButton = buttonBox->button( QDialogButtonBox::Apply );
mAddButton->setText( tr( "&Add" ) );
mAddButton->setToolTip( tr( "Add selected layers to map" ) );
mAddButton->setEnabled( false );

clearCrs();

mTileWidthLineEdit->setValidator( new QIntValidator( 0, 9999, this ) );
@@ -90,7 +81,6 @@ QgsOWSSourceSelect::QgsOWSSourceSelect( const QString &service, QWidget *parent,

if ( widgetMode() != QgsProviderRegistry::WidgetMode::Manager )
{
connect( mAddButton, &QAbstractButton::clicked, this, &QgsOWSSourceSelect::addClicked );
//set the current project CRS if available
QgsCoordinateReferenceSystem currentRefSys = QgsProject::instance()->crs();
//convert CRS id to epsg
@@ -106,7 +96,6 @@ QgsOWSSourceSelect::QgsOWSSourceSelect( const QString &service, QWidget *parent,
mTimeWidget->hide();
mFormatWidget->hide();
mCRSWidget->hide();
mAddButton->hide();
mCacheWidget->hide();
}

@@ -361,10 +350,6 @@ void QgsOWSSourceSelect::on_mConnectButton_clicked()
QApplication::restoreOverrideCursor();
}

void QgsOWSSourceSelect::addClicked()
{
}

void QgsOWSSourceSelect::enableLayersForCrs( QTreeWidgetItem * )
{
}
@@ -87,9 +87,6 @@ class GUI_EXPORT QgsOWSSourceSelect : public QgsAbstractDataSourceWidget, protec
*/
void on_mConnectButton_clicked();

//! Determines the layers the user selected
virtual void addClicked();

void searchFinished();

//! Opens the Spatial Reference System dialog.
@@ -187,8 +184,6 @@ class GUI_EXPORT QgsOWSSourceSelect : public QgsAbstractDataSourceWidget, protec
//! layer name derived from latest layer selection (updated as long it's not edited manually)
QString mLastLayerName;

QPushButton *mAddButton = nullptr;

QMap<QString, QString> mCrsNames;

void addWmsListRow( const QDomElement &item, int row );
@@ -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();

0 comments on commit 04059eb

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