Skip to content

Commit

Permalink
Homogenize signals from different source select dialogs, move to base…
Browse files Browse the repository at this point in the history
… class
  • Loading branch information
elpaso committed Jul 18, 2017
1 parent f6c8ef3 commit 73b66fa
Show file tree
Hide file tree
Showing 19 changed files with 188 additions and 200 deletions.
1 change: 0 additions & 1 deletion python/gui/gui_auto.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
65 changes: 55 additions & 10 deletions python/gui/qgsabstractdatasourcewidget.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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

};
Expand Down
91 changes: 0 additions & 91 deletions python/gui/qgsarcgisservicesourceselect.sip

This file was deleted.

6 changes: 2 additions & 4 deletions python/gui/qgsowssourceselect.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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:

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




};

/************************************************************************
Expand Down
2 changes: 1 addition & 1 deletion src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
Expand Down
25 changes: 23 additions & 2 deletions src/gui/qgsabstractdatasourcewidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
***************************************************************************/

Expand All @@ -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;
}
63 changes: 50 additions & 13 deletions src/gui/qgsabstractdatasourcewidget.h
Original file line number Diff line number Diff line change
Expand Up @@ -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
***************************************************************************/

Expand All @@ -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
Expand All @@ -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
2 changes: 1 addition & 1 deletion src/gui/qgsarcgisservicesourceselect.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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>
Expand Down
Loading

3 comments on commit 73b66fa

@tomkralidis
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

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

@elpaso
Copy link
Contributor Author

@elpaso elpaso commented on 73b66fa Jul 19, 2017

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@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.