Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Browse files
Add API to allow creation of widgets for customising a layer's source
This adds api in the provider gui to allow a provider to create a custom widget which exposes options to customise and change the layer's source. E.g. a file based layer provider could expose a widget for selecting a new file path, and an online one could expose widgets for changing the host, authentication, etc.
- Loading branch information
Showing
with
785 additions
and 2 deletions.
- +7 −0 python/gui/auto_generated/qgsgui.sip.in
- +12 −1 python/gui/auto_generated/qgsproviderguimetadata.sip.in
- +11 −0 python/gui/auto_generated/qgsproviderguiregistry.sip.in
- +50 −0 python/gui/auto_generated/qgsprovidersourcewidget.sip.in
- +61 −0 python/gui/auto_generated/qgsprovidersourcewidgetprovider.sip.in
- +83 −0 python/gui/auto_generated/qgsprovidersourcewidgetproviderregistry.sip.in
- +3 −0 python/gui/gui_auto.sip
- +6 −0 src/gui/CMakeLists.txt
- +9 −0 src/gui/qgsgui.cpp
- +8 −0 src/gui/qgsgui.h
- +5 −0 src/gui/qgsproviderguimetadata.cpp
- +9 −1 src/gui/qgsproviderguimetadata.h
- +8 −0 src/gui/qgsproviderguiregistry.cpp
- +8 −0 src/gui/qgsproviderguiregistry.h
- +25 −0 src/gui/qgsprovidersourcewidget.cpp
- +56 −0 src/gui/qgsprovidersourcewidget.h
- +19 −0 src/gui/qgsprovidersourcewidgetprovider.cpp
- +66 −0 src/gui/qgsprovidersourcewidgetprovider.h
- +109 −0 src/gui/qgsprovidersourcewidgetproviderregistry.cpp
- +91 −0 src/gui/qgsprovidersourcewidgetproviderregistry.h
- +1 −0 tests/src/python/CMakeLists.txt
- +138 −0 tests/src/python/test_qgssourcewidgetproviderregistry.py
@@ -0,0 +1,50 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/qgsprovidersourcewidget.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
class QgsProviderSourceWidget : QWidget | ||
{ | ||
%Docstring | ||
Base class for widgets which allow customisation of a provider's source URI. | ||
|
||
.. versionadded:: 3.18 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsprovidersourcewidget.h" | ||
%End | ||
public: | ||
|
||
QgsProviderSourceWidget( QWidget *parent /TransferThis/ = 0 ); | ||
%Docstring | ||
Constructor for QgsProviderSourceWidget with the specified ``parent`` widget. | ||
%End | ||
|
||
virtual void setSourceUri( const QString &uri ) = 0; | ||
%Docstring | ||
Sets the source ``uri`` to show in the widget. | ||
|
||
.. seealso:: :py:func:`sourceUri` | ||
%End | ||
|
||
virtual QString sourceUri() const = 0; | ||
%Docstring | ||
Returns the source URI as currently defined by the widget. | ||
|
||
.. seealso:: :py:func:`setSourceUri` | ||
%End | ||
|
||
}; | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/qgsprovidersourcewidget.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
@@ -0,0 +1,61 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/qgsprovidersourcewidgetprovider.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
class QgsProviderSourceWidgetProvider | ||
{ | ||
%Docstring | ||
|
||
An interface for providers of widgets designed to configure a data provider's source. | ||
|
||
.. versionadded:: 3.18 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsprovidersourcewidgetprovider.h" | ||
%End | ||
public: | ||
|
||
virtual ~QgsProviderSourceWidgetProvider(); | ||
|
||
virtual QString providerKey() const = 0; | ||
%Docstring | ||
Provider key | ||
%End | ||
|
||
virtual QString name() const; | ||
%Docstring | ||
Source widget provider name, this is useful to retrieve | ||
a particular source widget provider in case the provider has more | ||
than one, it should be unique among all providers. | ||
|
||
The default implementation returns the :py:func:`~QgsProviderSourceWidgetProvider.providerKey` | ||
%End | ||
|
||
virtual bool canHandleLayer( QgsMapLayer *layer ) const = 0; | ||
%Docstring | ||
Returns ``True`` if the provider can handle the specified ``layer``. | ||
%End | ||
|
||
virtual QgsProviderSourceWidget *createWidget( QgsMapLayer *layer, QWidget *parent /TransferThis/ = 0 ) = 0 /Factory/; | ||
%Docstring | ||
Creates a new widget to configure the source of the specified ``layer``. | ||
It may return ``None`` if it cannot handle the layer. | ||
The returned object must be destroyed by the caller. | ||
%End | ||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/qgsprovidersourcewidgetprovider.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
@@ -0,0 +1,83 @@ | ||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/qgsprovidersourcewidgetproviderregistry.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ | ||
|
||
|
||
|
||
|
||
|
||
class QgsProviderSourceWidgetProviderRegistry | ||
{ | ||
%Docstring | ||
This class keeps a list of provider source widget providers. | ||
|
||
QgsProviderSourceWidgetProviderRegistry is not usually directly created, but rather accessed through | ||
QgsGui.QgsProviderSourceWidgetProviderRegistry(). | ||
|
||
.. versionadded:: 3.18 | ||
%End | ||
|
||
%TypeHeaderCode | ||
#include "qgsprovidersourcewidgetproviderregistry.h" | ||
%End | ||
public: | ||
|
||
QgsProviderSourceWidgetProviderRegistry(); | ||
~QgsProviderSourceWidgetProviderRegistry(); | ||
|
||
|
||
QList< QgsProviderSourceWidgetProvider *> providers(); | ||
%Docstring | ||
Gets list of available providers | ||
%End | ||
|
||
void addProvider( QgsProviderSourceWidgetProvider *provider /Transfer/ ); | ||
%Docstring | ||
Add a ``provider`` implementation. Takes ownership of the object. | ||
%End | ||
|
||
bool removeProvider( QgsProviderSourceWidgetProvider *provider /Transfer/ ); | ||
%Docstring | ||
Remove ``provider`` implementation from the list (``provider`` object is deleted) | ||
|
||
:return: ``True`` if the provider was actually removed and deleted | ||
%End | ||
|
||
void initializeFromProviderGuiRegistry( QgsProviderGuiRegistry *providerGuiRegistry ); | ||
%Docstring | ||
Initializes the registry. The registry needs to be passed explicitly | ||
(instead of using singleton) because this gets called from QgsGui constructor. | ||
%End | ||
|
||
QgsProviderSourceWidgetProvider *providerByName( const QString &name ); | ||
%Docstring | ||
Returns a provider by ``name`` or ``None`` if not found | ||
%End | ||
|
||
QList<QgsProviderSourceWidgetProvider *> providersByKey( const QString &providerKey ); | ||
%Docstring | ||
Returns a (possibly empty) list of providers by data ``providerkey`` | ||
%End | ||
|
||
QgsProviderSourceWidget *createWidget( QgsMapLayer *layer, QWidget *parent /TransferThis/ = 0 ) /TransferBack/; | ||
%Docstring | ||
Creates a new widget to configure the source of the specified ``layer``. | ||
It may return ``None`` if no provider was found. | ||
The returned object must be destroyed by the caller. | ||
%End | ||
|
||
private: | ||
QgsProviderSourceWidgetProviderRegistry( const QgsProviderSourceWidgetProviderRegistry &rh ); | ||
}; | ||
|
||
/************************************************************************ | ||
* This file has been generated automatically from * | ||
* * | ||
* src/gui/qgsprovidersourcewidgetproviderregistry.h * | ||
* * | ||
* Do not edit manually ! Edit header and run scripts/sipify.pl again * | ||
************************************************************************/ |
Oops, something went wrong.