Skip to content
Permalink
Browse files

Refactored all providers to use the new base class

Also use refreshConnections from the data items when
a refresh is required, this function also emits
the signal to update the other GUI elements.
  • Loading branch information
elpaso committed Jul 14, 2017
1 parent 1e6a4ab commit aba9da5bc4b8d975389d6c8e8daeb8133565a63d
Showing with 213 additions and 148 deletions.
  1. +12 −8 python/gui/qgsarcgisservicesourceselect.sip
  2. +9 −6 python/gui/qgsowssourceselect.sip
  3. +5 −5 python/gui/qgssourceselect.sip
  4. +13 −8 src/gui/qgsarcgisservicesourceselect.cpp
  5. +21 −8 src/gui/qgsarcgisservicesourceselect.h
  6. +1 −1 src/gui/qgsbrowserdockwidget_p.h
  7. +2 −1 src/gui/qgsdatasourcemanagerdialog.cpp
  8. +8 −4 src/gui/qgsowssourceselect.cpp
  9. +7 −8 src/gui/qgsowssourceselect.h
  10. +5 −4 src/gui/qgssourceselect.h
  11. +3 −3 src/providers/arcgisrest/qgsamsdataitems.cpp
  12. +3 −3 src/providers/db2/qgsdb2dataitems.cpp
  13. +8 −4 src/providers/db2/qgsdb2sourceselect.cpp
  14. +5 −6 src/providers/db2/qgsdb2sourceselect.h
  15. +4 −4 src/providers/delimitedtext/qgsdelimitedtextsourceselect.cpp
  16. +3 −3 src/providers/delimitedtext/qgsdelimitedtextsourceselect.h
  17. +3 −3 src/providers/mssql/qgsmssqldataitems.cpp
  18. +8 −4 src/providers/mssql/qgsmssqlsourceselect.cpp
  19. +7 −5 src/providers/mssql/qgsmssqlsourceselect.h
  20. +3 −3 src/providers/oracle/qgsoracledataitems.cpp
  21. +2 −3 src/providers/oracle/qgsoraclesourceselect.cpp
  22. +3 −6 src/providers/oracle/qgsoraclesourceselect.h
  23. +3 −3 src/providers/ows/qgsowsdataitems.cpp
  24. +9 −5 src/providers/postgres/qgspgsourceselect.cpp
  25. +4 −5 src/providers/postgres/qgspgsourceselect.h
  26. +8 −3 src/providers/postgres/qgspostgresdataitems.cpp
  27. +2 −2 src/providers/spatialite/qgsspatialitedataitems.cpp
  28. +8 −4 src/providers/spatialite/qgsspatialitesourceselect.cpp
  29. +6 −4 src/providers/spatialite/qgsspatialitesourceselect.h
  30. +9 −4 src/providers/virtual/qgsvirtuallayersourceselect.cpp
  31. +7 −3 src/providers/virtual/qgsvirtuallayersourceselect.h
  32. +3 −3 src/providers/wcs/qgswcsdataitems.cpp
  33. +3 −3 src/providers/wfs/qgswfsdataitems.cpp
  34. +8 −4 src/providers/wfs/qgswfssourceselect.cpp
  35. +8 −5 src/providers/wfs/qgswfssourceselect.h
@@ -10,11 +10,11 @@



class QgsArcGisServiceSourceSelect : QDialog, protected Ui::QgsArcGisServiceSourceSelectBase

class QgsArcGisServiceSourceSelect : QgsSourceSelect, protected Ui::QgsArcGisServiceSourceSelectBase
{
%Docstring
Generic class listing layers available from a remote service.
.. versionadded:: 3.0
Base class for listing ArcGis layers available from a remote service.
%End

%TypeHeaderCode
@@ -23,7 +23,7 @@ class QgsArcGisServiceSourceSelect : QDialog, protected Ui::QgsArcGisServiceSour
public:
enum ServiceType { MapService, FeatureService };

QgsArcGisServiceSourceSelect( const QString &serviceName, ServiceType serviceType, QWidget *parent, Qt::WindowFlags fl );
QgsArcGisServiceSourceSelect( const QString &serviceName, ServiceType serviceType, QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
%Docstring
Constructor
%End
@@ -38,10 +38,6 @@ Sets the current extent and CRS. Used to select an appropriate CRS and possibly
void addLayer( QString uri, QString typeName );
%Docstring
Emitted when a layer is added from the dialog
%End
void connectionsChanged();
%Docstring
Emitted when the connections for the service were changed
%End

protected:
@@ -75,6 +71,14 @@ Returns the selected image encoding.
:rtype: str
%End

public slots:

virtual void refresh( );

%Docstring
Triggered when the provider's connections need to be refreshed
%End

};


@@ -11,16 +11,16 @@



class QgsOWSSourceSelect : QDialog, protected Ui::QgsOWSSourceSelectBase
class QgsOWSSourceSelect : QgsSourceSelect, protected Ui::QgsOWSSourceSelectBase
{
%Docstring
Dialog to create connections and add layers from WMS, WFS, WCS etc.
Dialog to create connections and add layers WCS etc.

This dialog allows the user to define and save connection information
for WMS servers, etc.

The user can then connect and add
layers from the WMS server to the map canvas.
layers from the WCS server to the map canvas.
%End

%TypeHeaderCode
@@ -42,6 +42,12 @@ Constructor

public slots:

virtual void refresh( );

%Docstring
Triggered when the provider's connections need to be refreshed
%End

void on_mNewButton_clicked();
%Docstring
Opens the create connection dialog to build a new connection
@@ -110,7 +116,6 @@ Add some default wms servers to the list
void addRasterLayer( const QString &rasterLayerPath,
const QString &baseName,
const QString &providerKey );
void connectionsChanged();

protected:

@@ -198,8 +203,6 @@ Add a few example servers to the list.
%End




virtual void populateLayerList();
%Docstring
Populate the layer list.
@@ -13,7 +13,7 @@
class QgsSourceSelect : QDialog
{
%Docstring
Abstract base Dialog to create connections and add layers
Abstract base Data Source Widget to create connections and add layers
This class must provide common functionality and the interface for all
source select dialogs used by data providers to configure data sources
and add layers.
@@ -30,9 +30,9 @@ class QgsSourceSelect : QDialog
Constructor
%End

~QgsSourceSelect( );
virtual ~QgsSourceSelect( ) = 0;
%Docstring
Destructor
Pure Virtual Destructor
%End

QgsProviderRegistry::WidgetMode widgetMode( );
@@ -43,9 +43,9 @@ Return the widget mode

public slots:

virtual void refresh( ) = 0;
virtual void refresh( );
%Docstring
Triggered when the provider's connections need to be refreshed
The default implementation does nothing
%End

signals:
@@ -37,9 +37,9 @@
#include <QRadioButton>
#include <QImageReader>

/** \ingroup gui
/**
* Item delegate with tweaked sizeHint.
* @note not available in Python bindings */
*/
class QgsSourceSelectItemDelegate : public QItemDelegate
{
public:
@@ -49,12 +49,12 @@ class QgsSourceSelectItemDelegate : public QItemDelegate
};


QgsArcGisServiceSourceSelect::QgsArcGisServiceSourceSelect( const QString &serviceName, ServiceType serviceType, QWidget *parent, Qt::WindowFlags fl )
: QDialog( parent, fl ),
mServiceName( serviceName ),
mServiceType( serviceType ),
mBuildQueryButton( 0 ),
mImageEncodingGroup( 0 )
QgsArcGisServiceSourceSelect::QgsArcGisServiceSourceSelect( const QString &serviceName, ServiceType serviceType, QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode ):
QgsSourceSelect( parent, fl, widgetMode ),
mServiceName( serviceName ),
mServiceType( serviceType ),
mBuildQueryButton( 0 ),
mImageEncodingGroup( 0 )
{
setupUi( this );
setWindowTitle( QStringLiteral( "Add %1 Layer from a Server" ).arg( mServiceName ) );
@@ -221,6 +221,11 @@ QString QgsArcGisServiceSourceSelect::getPreferredCrs( const QSet<QString> &crsS
return *( crsSet.constBegin() );
}

void QgsArcGisServiceSourceSelect::refresh()
{
populateConnectionList();
}

void QgsArcGisServiceSourceSelect::addEntryToServerList()
{

@@ -16,22 +16,32 @@
#ifndef QGSARCGISSERVICESOURCESELECTDIALOG_H
#define QGSARCGISSERVICESOURCESELECTDIALOG_H

/// @cond PRIVATE

//
// W A R N I N G
// -------------
//
// This file is not part of the QGIS API. It exists purely as an
// implementation detail. This header file may change from version to
// version without notice, or even be removed.
//

#include "ui_qgsarcgisservicesourceselectbase.h"
#include "qgsrectangle.h"
#include "qgscoordinatereferencesystem.h"

#include "qgssourceselect.h"
#include "qgis_gui.h"

class QStandardItemModel;
class QSortFilterProxyModel;
class QgsProjectionSelectionDialog;
class QgsOwsConnection;

/** \ingroup gui
* Generic class listing layers available from a remote service.
* \since QGIS 3.0
/**
* Base class for listing ArcGis layers available from a remote service.
*/
class GUI_EXPORT QgsArcGisServiceSourceSelect : public QDialog, protected Ui::QgsArcGisServiceSourceSelectBase
class GUI_EXPORT QgsArcGisServiceSourceSelect : public QgsSourceSelect, protected Ui::QgsArcGisServiceSourceSelectBase
{
Q_OBJECT

@@ -40,7 +50,7 @@ class GUI_EXPORT QgsArcGisServiceSourceSelect : public QDialog, protected Ui::Qg
enum ServiceType { MapService, FeatureService };

//! Constructor
QgsArcGisServiceSourceSelect( const QString &serviceName, ServiceType serviceType, QWidget *parent, Qt::WindowFlags fl );
QgsArcGisServiceSourceSelect( const QString &serviceName, ServiceType serviceType, QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );

~QgsArcGisServiceSourceSelect();
//! Sets the current extent and CRS. Used to select an appropriate CRS and possibly to retrieve data only in the current extent
@@ -49,8 +59,6 @@ class GUI_EXPORT QgsArcGisServiceSourceSelect : public QDialog, protected Ui::Qg
signals:
//! Emitted when a layer is added from the dialog
void addLayer( QString uri, QString typeName );
//! Emitted when the connections for the service were changed
void connectionsChanged();

protected:
QString mServiceName;
@@ -92,6 +100,11 @@ class GUI_EXPORT QgsArcGisServiceSourceSelect : public QDialog, protected Ui::Qg
\returns the authority id of the crs or an empty string in case of error*/
QString getPreferredCrs( const QSet<QString> &crsSet ) const;

public slots:

//! Triggered when the provider's connections need to be refreshed
void refresh( ) override;

private slots:
void addEntryToServerList();
void deleteEntryOfServerList();
@@ -50,7 +50,7 @@ class QgsLayerItem;
class QgsDataItem;
class QgsBrowserTreeFilterProxyModel;

SIP_NO_FILE
#define SIP_NO_FILE

/**
* Hack to show wrapped text without spaces
@@ -117,6 +117,7 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QgsMapCanvas *mapCanvas,
this->vectorLayerAdded( vectorLayerPath, baseName, QStringLiteral( "WFS" ) );
} );
connect( dlg, SIGNAL( connectionsChanged( ) ), this, SIGNAL( connectionsChanged( ) ) );
connect( this, SIGNAL( providerDialogsRefreshRequested( ) ), dlg, SLOT( refresh( ) ) );
}

addRasterProviderDialog( QStringLiteral( "arcgismapserver" ), tr( "ArcGIS Map Server" ), QStringLiteral( "/mActionAddAmsLayer.svg" ) );
@@ -129,6 +130,7 @@ QgsDataSourceManagerDialog::QgsDataSourceManagerDialog( QgsMapCanvas *mapCanvas,
afss->setCurrentExtentAndCrs( mMapCanvas->extent(), mMapCanvas->mapSettings().destinationCrs() );
// Forward (if only a common interface for the signals had been used in the providers ...)
connect( afss, SIGNAL( addLayer( QString, QString ) ), this, SIGNAL( addAfsLayer( QString, QString ) ) );
connect( this, SIGNAL( providerDialogsRefreshRequested( ) ), afss, SLOT( refresh( ) ) );
connect( this, &QgsDataSourceManagerDialog::addAfsLayer,
this, [ = ]( const QString & vectorLayerPath, const QString & baseName )
{ this->vectorLayerAdded( vectorLayerPath, baseName, QStringLiteral( "arcgisfeatureserver" ) ); } );
@@ -234,6 +236,5 @@ void QgsDataSourceManagerDialog::addRasterProviderDialog( const QString provider
connect( dlg, SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ),
this, SIGNAL( addRasterLayer( QString const &, QString const &, QString const & ) ) );
connect( dlg, SIGNAL( connectionsChanged( ) ), this, SIGNAL( connectionsChanged( ) ) );
connect( this, SIGNAL( providerDialogsRefreshRequested( ) ), dlg, SLOT( refresh( ) ) );
}
}
@@ -55,14 +55,13 @@
#include <QNetworkReply>

QgsOWSSourceSelect::QgsOWSSourceSelect( const QString &service, QWidget *parent, Qt::WindowFlags fl, QgsProviderRegistry::WidgetMode widgetMode )
: QDialog( parent, fl )
: QgsSourceSelect( parent, fl, widgetMode )
, mService( service )
, mWidgetMode( widgetMode )
, mCurrentTileset( nullptr )
{
setupUi( this );

if ( mWidgetMode != QgsProviderRegistry::WidgetMode::None )
if ( QgsSourceSelect::widgetMode( ) != QgsProviderRegistry::WidgetMode::None )
{
buttonBox->removeButton( buttonBox->button( QDialogButtonBox::Close ) );
}
@@ -89,7 +88,7 @@ QgsOWSSourceSelect::QgsOWSSourceSelect( const QString &service, QWidget *parent,
// 'Prefer network' is the default noted in the combobox's tool tip
mCacheComboBox->setCurrentIndex( mCacheComboBox->findData( QNetworkRequest::PreferNetwork ) );

if ( mWidgetMode != QgsProviderRegistry::WidgetMode::Manager )
if ( QgsSourceSelect::widgetMode( ) != QgsProviderRegistry::WidgetMode::Manager )
{
connect( mAddButton, &QAbstractButton::clicked, this, &QgsOWSSourceSelect::addClicked );
//set the current project CRS if available
@@ -126,6 +125,11 @@ QgsOWSSourceSelect::~QgsOWSSourceSelect()
settings.setValue( QStringLiteral( "Windows/WMSSourceSelect/geometry" ), saveGeometry() );
}

void QgsOWSSourceSelect::refresh()
{
populateConnectionList();
}

void QgsOWSSourceSelect::clearFormats()
{
mFormatComboBox->clear();
@@ -26,6 +26,7 @@
#include "qgsguiutils.h"
#include "qgscontexthelp.h"
#include "qgsproviderregistry.h"
#include "qgssourceselect.h"

#include <QStringList>
#include <QPushButton>
@@ -40,15 +41,15 @@ class QDomElement;


/** \ingroup gui
* \brief Dialog to create connections and add layers from WMS, WFS, WCS etc.
* \brief Dialog to create connections and add layers WCS etc.
*
* This dialog allows the user to define and save connection information
* for WMS servers, etc.
*
* The user can then connect and add
* layers from the WMS server to the map canvas.
* layers from the WCS server to the map canvas.
*/
class GUI_EXPORT QgsOWSSourceSelect : public QDialog, protected Ui::QgsOWSSourceSelectBase
class GUI_EXPORT QgsOWSSourceSelect : public QgsSourceSelect, protected Ui::QgsOWSSourceSelectBase
{
Q_OBJECT

@@ -67,6 +68,9 @@ class GUI_EXPORT QgsOWSSourceSelect : public QDialog, protected Ui::QgsOWSSource

public slots:

//! Triggered when the provider's connections need to be refreshed
void refresh( ) override;

//! Opens the create connection dialog to build a new connection
void on_mNewButton_clicked();
//! Opens a dialog to edit an existing connection
@@ -110,7 +114,6 @@ class GUI_EXPORT QgsOWSSourceSelect : public QDialog, protected Ui::QgsOWSSource
void addRasterLayer( const QString &rasterLayerPath,
const QString &baseName,
const QString &providerKey );
void connectionsChanged();

protected:

@@ -167,10 +170,6 @@ class GUI_EXPORT QgsOWSSourceSelect : public QDialog, protected Ui::QgsOWSSource
//! Service name
QString mService;

//! Embedded mode, without 'Close'
QgsProviderRegistry::WidgetMode mWidgetMode = QgsProviderRegistry::WidgetMode::None;


/**
* \brief Populate the layer list.
*
@@ -27,7 +27,7 @@
#include <QDialog>

/** \ingroup gui
* \brief Abstract base Dialog to create connections and add layers
* \brief Abstract base Data Source Widget to create connections and add layers
* This class must provide common functionality and the interface for all
* source select dialogs used by data providers to configure data sources
* and add layers.
@@ -42,16 +42,17 @@ class GUI_EXPORT QgsSourceSelect : public QDialog
//! Constructor
QgsSourceSelect( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );

//! Destructor
~QgsSourceSelect( );
//! Pure Virtual Destructor
virtual ~QgsSourceSelect( ) = 0;

//! Return the widget mode
QgsProviderRegistry::WidgetMode widgetMode( ) { return mWidgetMode; }

public slots:

//! Triggered when the provider's connections need to be refreshed
virtual void refresh( ) = 0;
//! The default implementation does nothing
virtual void refresh( ) {}

signals:

0 comments on commit aba9da5

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