Skip to content

Commit 5f5be25

Browse files
authored
Merge pull request #5124 from boundlessgeo/providers_gui_config
Providers gui config
2 parents 1d0de60 + 59aaa27 commit 5f5be25

35 files changed

+1198
-115
lines changed

python/gui/gui_auto.sip

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,8 @@
2121
%Include qgsvertexmarker.sip
2222
%Include qgsfiledownloader.sip
2323
%Include qgsabstractdatasourcewidget.sip
24+
%Include qgssourceselectprovider.sip
25+
%Include qgssourceselectproviderregistry.sip
2426
%Include attributetable/qgsfeaturemodel.sip
2527
%Include auth/qgsauthauthoritieseditor.sip
2628
%Include auth/qgsauthcertificateinfo.sip

python/gui/qgsabstractdatasourcewidget.sip

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -90,6 +90,16 @@ Emitted when a vector layer has been selected for addition
9090
\param dataSourceType string (can be "file" or "database")
9191
%End
9292

93+
void replaceVectorLayer( const QString &oldId, const QString &source, const QString &name, const QString &provider );
94+
%Docstring
95+
Emitted when a layer needs to be replaced
96+
\param oldId old layer ID
97+
\param source URI of the layer
98+
\param name of the layer
99+
\param provider key
100+
%End
101+
102+
93103
void progress( int, int );
94104
%Docstring
95105
Emitted when a progress dialog is shown by the provider dialog

python/gui/qgsgui.sip

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -38,6 +38,12 @@ class QgsGui
3838
:rtype: QgsEditorWidgetRegistry
3939
%End
4040

41+
static QgsSourceSelectProviderRegistry *sourceSelectProviderRegistry();
42+
%Docstring
43+
Returns the global source select provider registry, used for managing all known source select widget factories.
44+
:rtype: QgsSourceSelectProviderRegistry
45+
%End
46+
4147
static QgsShortcutsManager *shortcutsManager();
4248
%Docstring
4349
Returns the global shortcuts manager, used for managing a QAction and QShortcut sequences.
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/gui/qgssourceselectprovider.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
12+
class QgsSourceSelectProvider
13+
{
14+
%Docstring
15+
This is the interface for those who want to add entries to the QgsDataSourceManagerDialog
16+
17+
.. versionadded:: 3.0
18+
%End
19+
20+
%TypeHeaderCode
21+
#include "qgssourceselectprovider.h"
22+
%End
23+
public:
24+
virtual ~QgsSourceSelectProvider();
25+
26+
virtual QString providerKey() const = 0;
27+
%Docstring
28+
Data Provider key
29+
:rtype: str
30+
%End
31+
32+
virtual QString name() const;
33+
%Docstring
34+
Source select provider name, this is useful to retrieve
35+
a particular source select in case the provider has more
36+
than one, it should be unique among all providers.
37+
38+
The default implementation returns the providerKey()
39+
:rtype: str
40+
%End
41+
42+
virtual QString text() const = 0;
43+
%Docstring
44+
Text for the menu item entry, it will be visible to the user so make sure it's translatable
45+
:rtype: str
46+
%End
47+
48+
virtual QString toolTip() const;
49+
%Docstring
50+
Text for the tooltip menu item entry, it will be visible to the user so make sure it's translatable
51+
52+
The default implementation returns an empty string.
53+
:rtype: str
54+
%End
55+
56+
virtual QIcon icon() const = 0;
57+
%Docstring
58+
Creates a new instance of an QIcon for the menu item entry
59+
:rtype: QIcon
60+
%End
61+
62+
virtual int ordering( ) const;
63+
%Docstring
64+
Ordering: the source select provider registry will be able to sort
65+
the source selects (ascending) using this integer value
66+
:rtype: int
67+
%End
68+
69+
virtual QgsAbstractDataSourceWidget *createDataSourceWidget( QWidget *parent = 0, Qt::WindowFlags fl = Qt::Widget, QgsProviderRegistry::WidgetMode widgetMode = QgsProviderRegistry::WidgetMode::Embedded ) const = 0 /Factory/;
70+
%Docstring
71+
Create a new instance of QgsAbstractDataSourceWidget (or null).
72+
Caller takes responsibility of deleting created.
73+
:rtype: QgsAbstractDataSourceWidget
74+
%End
75+
76+
};
77+
78+
79+
/************************************************************************
80+
* This file has been generated automatically from *
81+
* *
82+
* src/gui/qgssourceselectprovider.h *
83+
* *
84+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
85+
************************************************************************/
Lines changed: 78 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,78 @@
1+
/************************************************************************
2+
* This file has been generated automatically from *
3+
* *
4+
* src/gui/qgssourceselectproviderregistry.h *
5+
* *
6+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
7+
************************************************************************/
8+
9+
10+
11+
class QgsSourceSelectProviderRegistry
12+
{
13+
%Docstring
14+
This class keeps a list of source select providers that may add items to the QgsDataSourceManagerDialog
15+
When created, it automatically adds providers from data provider plugins (e.g. PostGIS, WMS, ...)
16+
17+
QgsSourceSelectProviderRegistry is not usually directly created, but rather accessed through
18+
QgsGui.sourceSelectProviderRegistry().
19+
20+
.. note::
21+
22+
This class access to QgsProviderRegistry instance to initialize, but QgsProviderRegistry is
23+
typically initialized after QgsGui is constructed, for this reason a delayed initialization has been
24+
implemented in the class.
25+
26+
.. versionadded:: 3.0
27+
%End
28+
29+
%TypeHeaderCode
30+
#include "qgssourceselectproviderregistry.h"
31+
%End
32+
public:
33+
QgsSourceSelectProviderRegistry();
34+
35+
~QgsSourceSelectProviderRegistry();
36+
37+
38+
QList< QgsSourceSelectProvider *> providers();
39+
%Docstring
40+
Get list of available providers
41+
:rtype: list of QgsSourceSelectProvider
42+
%End
43+
44+
void addProvider( QgsSourceSelectProvider *provider /Transfer/ );
45+
%Docstring
46+
Add a ``provider`` implementation. Takes ownership of the object.
47+
%End
48+
49+
bool removeProvider( QgsSourceSelectProvider *provider /Transfer/ );
50+
%Docstring
51+
:return: true if the provider was actually removed and deleted
52+
:rtype: bool
53+
%End
54+
55+
QgsSourceSelectProvider *providerByName( const QString &name );
56+
%Docstring
57+
Return a provider by ``name`` or None if not found
58+
:rtype: QgsSourceSelectProvider
59+
%End
60+
61+
QList<QgsSourceSelectProvider *> providersByKey( const QString &providerKey );
62+
%Docstring
63+
Return a (possibly empty) list of providers by data ``providerkey``
64+
:rtype: list of QgsSourceSelectProvider
65+
%End
66+
67+
68+
private:
69+
QgsSourceSelectProviderRegistry( const QgsSourceSelectProviderRegistry &rh );
70+
};
71+
72+
/************************************************************************
73+
* This file has been generated automatically from *
74+
* *
75+
* src/gui/qgssourceselectproviderregistry.h *
76+
* *
77+
* Do not edit manually ! Edit header and run scripts/sipify.pl again *
78+
************************************************************************/

src/gui/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -349,6 +349,8 @@ SET(QGIS_GUI_SRCS
349349
qgsfiledownloader.cpp
350350
qgsdatasourcemanagerdialog.cpp
351351
qgsabstractdatasourcewidget.cpp
352+
qgssourceselectprovider.cpp
353+
qgssourceselectproviderregistry.cpp
352354
)
353355

354356
SET(QGIS_GUI_MOC_HDRS
@@ -711,6 +713,8 @@ SET(QGIS_GUI_HDRS
711713
qgsfiledownloader.h
712714
qgsdatasourcemanagerdialog.h
713715
qgsabstractdatasourcewidget.h
716+
qgssourceselectprovider.h
717+
qgssourceselectproviderregistry.h
714718

715719
ogr/qgsogrhelperfunctions.h
716720
ogr/qgsnewogrconnection.h

src/gui/qgsabstractdatasourcewidget.h

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,15 @@ class GUI_EXPORT QgsAbstractDataSourceWidget : public QDialog
9393
*/
9494
void addVectorLayers( const QStringList &layerList, const QString &encoding, const QString &dataSourceType );
9595

96+
/** Emitted when a layer needs to be replaced
97+
* \param oldId old layer ID
98+
* \param source URI of the layer
99+
* \param name of the layer
100+
* \param provider key
101+
*/
102+
void replaceVectorLayer( const QString &oldId, const QString &source, const QString &name, const QString &provider );
103+
104+
96105
//! Emitted when a progress dialog is shown by the provider dialog
97106
void progress( int, int );
98107

0 commit comments

Comments
 (0)