Skip to content
Permalink
Browse files

Homogenize signals from different source select dialogs, move to base…

… class
  • Loading branch information
elpaso committed Jul 17, 2017
1 parent f6c8ef3 commit 73b66fa1f5003aae7e9bca96c703eadf88f838d0
@@ -158,7 +158,6 @@
%Include qgsoptionswidgetfactory.sip
%Include qgsorderbydialog.sip
%Include qgsowssourceselect.sip
%Include qgsarcgisservicesourceselect.sip
%Include qgspanelwidget.sip
%Include qgspanelwidgetstack.sip
%Include qgspasswordlineedit.sip
@@ -14,7 +14,7 @@ class QgsAbstractDataSourceWidget : QDialog
{
%Docstring
Abstract base Data Source Widget to create connections and add layers
This class must provide common functionality and the interface for all
This class provides common functionality and the interface for all
source select dialogs used by data providers to configure data sources
and add layers.
.. versionadded:: 3.0
@@ -25,34 +25,79 @@ class QgsAbstractDataSourceWidget : QDialog
%End
public:

QgsAbstractDataSourceWidget( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
~QgsAbstractDataSourceWidget( );
%Docstring
Constructor
Destructor
%End

virtual ~QgsAbstractDataSourceWidget( ) = 0;
QgsProviderRegistry::WidgetMode widgetMode( ) const;
%Docstring
Pure Virtual Destructor
Return the widget mode
:rtype: QgsProviderRegistry.WidgetMode
%End

QgsProviderRegistry::WidgetMode widgetMode( );
void setCurrentCrs( const QgsCoordinateReferenceSystem &crs );
%Docstring
Return the widget mode
:rtype: QgsProviderRegistry.WidgetMode
Set the current CRS
The CRS is normally the CRS of the map canvas, and it can be used
by the provider dialog to transform the extent and constraint the service
%End

void setCurrentExtent( const QgsRectangle &extent );
%Docstring
Set the current extent
The extent is normally the extent of the map canvas, and it can be used
by the provider dialog to constraint the service
%End

QgsRectangle currentExtent( ) const;
%Docstring
Return the current extent
:rtype: QgsRectangle
%End

QgsCoordinateReferenceSystem currentCrs( ) const;
%Docstring
Return the current CRS
:rtype: QgsCoordinateReferenceSystem
%End

public slots:

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

signals:

void connectionsChanged();
%Docstring
This signal is normally forwarded the app and used to refresh browser items
Emitted when the provider's connections have changed
This signal is normally forwarded the app and used to refresh browser items
%End

void addDatabaseLayers( const QStringList &paths, const QString &providerKey );
%Docstring
Emitted when a DB layer has been selected for addition
%End

void addRasterLayer( const QString &rasterLayerPath, const QString &baseName, const QString &providerKey );
%Docstring
Emitted when a raster layer has been selected for addition
%End

void addVectorLayer( const QString &uri, const QString &layerName );
%Docstring
Emitted when a vector layer has been selected for addition
%End

protected:

QgsAbstractDataSourceWidget( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
%Docstring
Constructor
%End

};

This file was deleted.

@@ -112,10 +112,7 @@ Stores the selected datasource whenerver it is changed
Add some default wms servers to the list
%End

signals:
void addRasterLayer( const QString &rasterLayerPath,
const QString &baseName,
const QString &providerKey );
void on_mDialogButtonBox_helpRequested();

protected:

@@ -256,6 +253,7 @@ Returns currently selected cache load control




};

/************************************************************************
@@ -1596,7 +1596,7 @@ void QgisApp::dataSourceManager( QString pageName )
{
if ( ! mDataSourceManagerDialog )
{
mDataSourceManagerDialog = new QgsDataSourceManagerDialog( mapCanvas( ), this );
mDataSourceManagerDialog = new QgsDataSourceManagerDialog( this, mapCanvas( ) );
// Forward signals to this
connect( this, &QgisApp::connectionsChanged, mDataSourceManagerDialog, &QgsDataSourceManagerDialog::refresh );
connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::connectionsChanged, this, &QgisApp::connectionsChanged );
@@ -2,7 +2,8 @@
qgsabstractdatasourcewidget.cpp - base class for source selector widgets
-------------------
begin : 10 July 2017
original : (C) 2017 by Alessandro Pasotti email : apasotti at boundlessgeo dot com
original : (C) 2017 by Alessandro Pasotti
email : apasotti at boundlessgeo dot com
***************************************************************************/

@@ -24,7 +25,27 @@ QgsAbstractDataSourceWidget::QgsAbstractDataSourceWidget( QWidget *parent, Qt::W

}

QgsAbstractDataSourceWidget::~QgsAbstractDataSourceWidget()
QgsProviderRegistry::WidgetMode QgsAbstractDataSourceWidget::widgetMode() const
{
return mWidgetMode;
}

void QgsAbstractDataSourceWidget::setCurrentCrs( const QgsCoordinateReferenceSystem &crs )
{
mCurrentCrs = crs;
}

void QgsAbstractDataSourceWidget::setCurrentExtent( const QgsRectangle &extent )
{
mCurrentExtent = extent;
}

QgsRectangle QgsAbstractDataSourceWidget::currentExtent() const
{
return mCurrentExtent;
}

QgsCoordinateReferenceSystem QgsAbstractDataSourceWidget::currentCrs() const
{
return mCurrentCrs;
}
@@ -2,7 +2,8 @@
qgsabstractdatasourcewidget.h - base class for source selector widgets
-------------------
begin : 10 July 2017
original : (C) 2017 by Alessandro Pasotti email : apasotti at boundlessgeo dot com
original : (C) 2017 by Alessandro Pasotti
email : apasotti at boundlessgeo dot com
***************************************************************************/

@@ -17,18 +18,20 @@

#ifndef QGSABSTRACTDATASOURCEWIDGET_H
#define QGSABSTRACTDATASOURCEWIDGET_H

#include "qgis_sip.h"
#include "qgis.h"
#include "qgis_gui.h"

#include "qgsproviderregistry.h"
#include "qgsguiutils.h"

#include "qgsrectangle.h"
#include "qgscoordinatereferencesystem.h"
#include <QDialog>

/** \ingroup gui
* \brief Abstract base Data Source Widget to create connections and add layers
* This class must provide common functionality and the interface for all
* This class provides common functionality and the interface for all
* source select dialogs used by data providers to configure data sources
* and add layers.
* \since QGIS 3.0
@@ -39,30 +42,64 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog

public:

//! Constructor
QgsAbstractDataSourceWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );

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

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

/** Set the current CRS
* The CRS is normally the CRS of the map canvas, and it can be used
* by the provider dialog to transform the extent and constraint the service
*/
void setCurrentCrs( const QgsCoordinateReferenceSystem &crs );

/** Set the current extent
* The extent is normally the extent of the map canvas, and it can be used
* by the provider dialog to constraint the service
*/
void setCurrentExtent( const QgsRectangle &extent );

//! Return the current extent
QgsRectangle currentExtent( ) const;

//! Return the current CRS
QgsCoordinateReferenceSystem currentCrs( ) const;

public slots:

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

signals:

//! Emitted when the provider's connections have changed
//! This signal is normally forwarded the app and used to refresh browser items
/** Emitted when the provider's connections have changed
* This signal is normally forwarded the app and used to refresh browser items
*/
void connectionsChanged();

//! Emitted when a DB layer has been selected for addition
void addDatabaseLayers( const QStringList &paths, const QString &providerKey );

//! Emitted when a raster layer has been selected for addition
void addRasterLayer( const QString &rasterLayerPath, const QString &baseName, const QString &providerKey );

//! Emitted when a vector layer has been selected for addition
void addVectorLayer( const QString &uri, const QString &layerName );

protected:

//! Constructor
QgsAbstractDataSourceWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );

private:

QgsProviderRegistry::WidgetMode mWidgetMode;
QgsCoordinateReferenceSystem mCurrentCrs;
QgsRectangle mCurrentExtent;

};

#endif // QGSABSTRACTDATASOURCEWIDGET_H
@@ -25,10 +25,10 @@
#include "qgscoordinatereferencesystem.h"
#include "qgscoordinatetransform.h"
#include "qgslogger.h"
#include "qgsmapcanvas.h"
#include "qgsmanageconnectionsdialog.h"
#include "qgsexception.h"
#include "qgssettings.h"
#include "qgsmapcanvas.h"

#include <QItemDelegate>
#include <QListWidgetItem>

3 comments on commit 73b66fa

@tomkralidis

This comment has been minimized.

Copy link
Contributor

@tomkralidis tomkralidis replied Jul 19, 2017

@elpaso as per https://lists.osgeo.org/pipermail/qgis-developer/2017-July/049366.html, any info how to interact with WFS provider via Python plugins given addWfsLayer has gone away?

@tomkralidis

This comment has been minimized.

Copy link
Contributor

@tomkralidis tomkralidis replied Jul 19, 2017

(note that grep -R addWfsLayer yields the remaining affected areas in the codebase)

@elpaso

This comment has been minimized.

Copy link
Contributor Author

@elpaso elpaso replied Jul 19, 2017

@tomkralidis I've answered on gitter and on the mailling list, I'll have a look to the other addWfsLayer instances.

PS: can we please stick to a single channel for this thread? Answering three times to the same question is a waste of time.

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