Skip to content

Commit 73b66fa

Browse files
committedJul 18, 2017
Homogenize signals from different source select dialogs, move to base class
1 parent f6c8ef3 commit 73b66fa

19 files changed

+188
-200
lines changed
 

‎python/gui/gui_auto.sip

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -158,7 +158,6 @@
158158
%Include qgsoptionswidgetfactory.sip
159159
%Include qgsorderbydialog.sip
160160
%Include qgsowssourceselect.sip
161-
%Include qgsarcgisservicesourceselect.sip
162161
%Include qgspanelwidget.sip
163162
%Include qgspanelwidgetstack.sip
164163
%Include qgspasswordlineedit.sip

‎python/gui/qgsabstractdatasourcewidget.sip

Lines changed: 55 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,7 @@ class QgsAbstractDataSourceWidget : QDialog
1414
{
1515
%Docstring
1616
Abstract base Data Source Widget to create connections and add layers
17-
This class must provide common functionality and the interface for all
17+
This class provides common functionality and the interface for all
1818
source select dialogs used by data providers to configure data sources
1919
and add layers.
2020
.. versionadded:: 3.0
@@ -25,34 +25,79 @@ class QgsAbstractDataSourceWidget : QDialog
2525
%End
2626
public:
2727

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

33-
virtual ~QgsAbstractDataSourceWidget( ) = 0;
33+
QgsProviderRegistry::WidgetMode widgetMode( ) const;
3434
%Docstring
35-
Pure Virtual Destructor
35+
Return the widget mode
36+
:rtype: QgsProviderRegistry.WidgetMode
3637
%End
3738

38-
QgsProviderRegistry::WidgetMode widgetMode( );
39+
void setCurrentCrs( const QgsCoordinateReferenceSystem &crs );
3940
%Docstring
40-
Return the widget mode
41-
:rtype: QgsProviderRegistry.WidgetMode
41+
Set the current CRS
42+
The CRS is normally the CRS of the map canvas, and it can be used
43+
by the provider dialog to transform the extent and constraint the service
44+
%End
45+
46+
void setCurrentExtent( const QgsRectangle &extent );
47+
%Docstring
48+
Set the current extent
49+
The extent is normally the extent of the map canvas, and it can be used
50+
by the provider dialog to constraint the service
51+
%End
52+
53+
QgsRectangle currentExtent( ) const;
54+
%Docstring
55+
Return the current extent
56+
:rtype: QgsRectangle
57+
%End
58+
59+
QgsCoordinateReferenceSystem currentCrs( ) const;
60+
%Docstring
61+
Return the current CRS
62+
:rtype: QgsCoordinateReferenceSystem
4263
%End
4364

4465
public slots:
4566

4667
virtual void refresh( );
4768
%Docstring
48-
The default implementation does nothing
69+
Triggered when the provider's connections need to be refreshed
70+
The default implementation does nothing
4971
%End
5072

5173
signals:
5274

5375
void connectionsChanged();
5476
%Docstring
55-
This signal is normally forwarded the app and used to refresh browser items
77+
Emitted when the provider's connections have changed
78+
This signal is normally forwarded the app and used to refresh browser items
79+
%End
80+
81+
void addDatabaseLayers( const QStringList &paths, const QString &providerKey );
82+
%Docstring
83+
Emitted when a DB layer has been selected for addition
84+
%End
85+
86+
void addRasterLayer( const QString &rasterLayerPath, const QString &baseName, const QString &providerKey );
87+
%Docstring
88+
Emitted when a raster layer has been selected for addition
89+
%End
90+
91+
void addVectorLayer( const QString &uri, const QString &layerName );
92+
%Docstring
93+
Emitted when a vector layer has been selected for addition
94+
%End
95+
96+
protected:
97+
98+
QgsAbstractDataSourceWidget( QWidget *parent /TransferThis/ = 0, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
99+
%Docstring
100+
Constructor
56101
%End
57102

58103
};

‎python/gui/qgsarcgisservicesourceselect.sip

Lines changed: 0 additions & 91 deletions
This file was deleted.

‎python/gui/qgsowssourceselect.sip

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -112,10 +112,7 @@ Stores the selected datasource whenerver it is changed
112112
Add some default wms servers to the list
113113
%End
114114

115-
signals:
116-
void addRasterLayer( const QString &rasterLayerPath,
117-
const QString &baseName,
118-
const QString &providerKey );
115+
void on_mDialogButtonBox_helpRequested();
119116

120117
protected:
121118

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

257254

258255

256+
259257
};
260258

261259
/************************************************************************

‎src/app/qgisapp.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1596,7 +1596,7 @@ void QgisApp::dataSourceManager( QString pageName )
15961596
{
15971597
if ( ! mDataSourceManagerDialog )
15981598
{
1599-
mDataSourceManagerDialog = new QgsDataSourceManagerDialog( mapCanvas( ), this );
1599+
mDataSourceManagerDialog = new QgsDataSourceManagerDialog( this, mapCanvas( ) );
16001600
// Forward signals to this
16011601
connect( this, &QgisApp::connectionsChanged, mDataSourceManagerDialog, &QgsDataSourceManagerDialog::refresh );
16021602
connect( mDataSourceManagerDialog, &QgsDataSourceManagerDialog::connectionsChanged, this, &QgisApp::connectionsChanged );

‎src/gui/qgsabstractdatasourcewidget.cpp

Lines changed: 23 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
qgsabstractdatasourcewidget.cpp - base class for source selector widgets
33
-------------------
44
begin : 10 July 2017
5-
original : (C) 2017 by Alessandro Pasotti email : apasotti at boundlessgeo dot com
5+
original : (C) 2017 by Alessandro Pasotti
6+
email : apasotti at boundlessgeo dot com
67
78
***************************************************************************/
89

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

2526
}
2627

27-
QgsAbstractDataSourceWidget::~QgsAbstractDataSourceWidget()
28+
QgsProviderRegistry::WidgetMode QgsAbstractDataSourceWidget::widgetMode() const
2829
{
30+
return mWidgetMode;
31+
}
32+
33+
void QgsAbstractDataSourceWidget::setCurrentCrs( const QgsCoordinateReferenceSystem &crs )
34+
{
35+
mCurrentCrs = crs;
36+
}
2937

38+
void QgsAbstractDataSourceWidget::setCurrentExtent( const QgsRectangle &extent )
39+
{
40+
mCurrentExtent = extent;
41+
}
42+
43+
QgsRectangle QgsAbstractDataSourceWidget::currentExtent() const
44+
{
45+
return mCurrentExtent;
46+
}
47+
48+
QgsCoordinateReferenceSystem QgsAbstractDataSourceWidget::currentCrs() const
49+
{
50+
return mCurrentCrs;
3051
}

‎src/gui/qgsabstractdatasourcewidget.h

Lines changed: 50 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,8 @@
22
qgsabstractdatasourcewidget.h - base class for source selector widgets
33
-------------------
44
begin : 10 July 2017
5-
original : (C) 2017 by Alessandro Pasotti email : apasotti at boundlessgeo dot com
5+
original : (C) 2017 by Alessandro Pasotti
6+
email : apasotti at boundlessgeo dot com
67
78
***************************************************************************/
89

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

1819
#ifndef QGSABSTRACTDATASOURCEWIDGET_H
1920
#define QGSABSTRACTDATASOURCEWIDGET_H
21+
2022
#include "qgis_sip.h"
2123
#include "qgis.h"
2224
#include "qgis_gui.h"
2325

2426
#include "qgsproviderregistry.h"
2527
#include "qgsguiutils.h"
26-
28+
#include "qgsrectangle.h"
29+
#include "qgscoordinatereferencesystem.h"
2730
#include <QDialog>
2831

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

4043
public:
4144

42-
//! Constructor
43-
QgsAbstractDataSourceWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
44-
45-
//! Pure Virtual Destructor
46-
virtual ~QgsAbstractDataSourceWidget( ) = 0;
45+
//! Destructor
46+
~QgsAbstractDataSourceWidget( ) = default;
4747

4848
//! Return the widget mode
49-
QgsProviderRegistry::WidgetMode widgetMode( ) { return mWidgetMode; }
49+
QgsProviderRegistry::WidgetMode widgetMode( ) const;
50+
51+
/** Set the current CRS
52+
* The CRS is normally the CRS of the map canvas, and it can be used
53+
* by the provider dialog to transform the extent and constraint the service
54+
*/
55+
void setCurrentCrs( const QgsCoordinateReferenceSystem &crs );
56+
57+
/** Set the current extent
58+
* The extent is normally the extent of the map canvas, and it can be used
59+
* by the provider dialog to constraint the service
60+
*/
61+
void setCurrentExtent( const QgsRectangle &extent );
62+
63+
//! Return the current extent
64+
QgsRectangle currentExtent( ) const;
65+
66+
//! Return the current CRS
67+
QgsCoordinateReferenceSystem currentCrs( ) const;
5068

5169
public slots:
5270

53-
//! Triggered when the provider's connections need to be refreshed
54-
//! The default implementation does nothing
71+
/** Triggered when the provider's connections need to be refreshed
72+
* The default implementation does nothing
73+
*/
5574
virtual void refresh( ) {}
5675

5776
signals:
5877

59-
//! Emitted when the provider's connections have changed
60-
//! This signal is normally forwarded the app and used to refresh browser items
78+
/** Emitted when the provider's connections have changed
79+
* This signal is normally forwarded the app and used to refresh browser items
80+
*/
6181
void connectionsChanged();
6282

83+
//! Emitted when a DB layer has been selected for addition
84+
void addDatabaseLayers( const QStringList &paths, const QString &providerKey );
85+
86+
//! Emitted when a raster layer has been selected for addition
87+
void addRasterLayer( const QString &rasterLayerPath, const QString &baseName, const QString &providerKey );
88+
89+
//! Emitted when a vector layer has been selected for addition
90+
void addVectorLayer( const QString &uri, const QString &layerName );
91+
92+
protected:
93+
94+
//! Constructor
95+
QgsAbstractDataSourceWidget( QWidget *parent SIP_TRANSFERTHIS = nullptr, Qt::WindowFlags fl = QgsGuiUtils::ModalDialogFlags, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::None );
96+
6397
private:
6498

6599
QgsProviderRegistry::WidgetMode mWidgetMode;
100+
QgsCoordinateReferenceSystem mCurrentCrs;
101+
QgsRectangle mCurrentExtent;
102+
66103
};
67104

68105
#endif // QGSABSTRACTDATASOURCEWIDGET_H

‎src/gui/qgsarcgisservicesourceselect.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,10 @@
2525
#include "qgscoordinatereferencesystem.h"
2626
#include "qgscoordinatetransform.h"
2727
#include "qgslogger.h"
28-
#include "qgsmapcanvas.h"
2928
#include "qgsmanageconnectionsdialog.h"
3029
#include "qgsexception.h"
3130
#include "qgssettings.h"
31+
#include "qgsmapcanvas.h"
3232

3333
#include <QItemDelegate>
3434
#include <QListWidgetItem>

0 commit comments

Comments
 (0)