Skip to content

Commit

Permalink
Add api to indicate that a QgsMapLayerConfigWidgetFactory factory
Browse files Browse the repository at this point in the history
creates sub-components of a standard page instead of a top-level
page on its own
  • Loading branch information
nyalldawson committed Mar 24, 2021
1 parent e350661 commit 4faceaf
Show file tree
Hide file tree
Showing 4 changed files with 49 additions and 0 deletions.
6 changes: 6 additions & 0 deletions python/gui/auto_additions/qgsmaplayerconfigwidgetfactory.py
@@ -0,0 +1,6 @@
# The following has been generated automatically from src/gui/qgsmaplayerconfigwidgetfactory.h
# monkey patching scoped based enum
QgsMapLayerConfigWidgetFactory.ParentPage.None.__doc__ = "Factory creates pages itself, not sub-components"
QgsMapLayerConfigWidgetFactory.ParentPage.Temporal.__doc__ = "Factory creates sub-components of the temporal properties page"
QgsMapLayerConfigWidgetFactory.ParentPage.__doc__ = 'Available parent pages, for factories which create a widget which is a sub-component\nof a standard page.\n\n.. versionadded:: 3.20\n\n' + '* ``None``: ' + QgsMapLayerConfigWidgetFactory.ParentPage.None.__doc__ + '\n' + '* ``Temporal``: ' + QgsMapLayerConfigWidgetFactory.ParentPage.Temporal.__doc__
# --
16 changes: 16 additions & 0 deletions python/gui/auto_generated/qgsmaplayerconfigwidgetfactory.sip.in
Expand Up @@ -22,6 +22,12 @@ Factory class for creating custom map layer property pages
%End
public:

enum class ParentPage
{
None,
Temporal,
};

QgsMapLayerConfigWidgetFactory();
%Docstring
Constructor
Expand Down Expand Up @@ -120,6 +126,16 @@ Set support flag for style dock
Check if the layer is supported for this widget.

:return: ``True`` if this layer is supported for this widget
%End

virtual ParentPage parentPage() const;
%Docstring
Returns the associated parent page, for factories which create sub-components of a standard page.

The default implementation returns QgsMapLayerConfigWidgetFactory.ParentPage.None, indicating that the
factory creates top-level pages which are not subcomponents.

.. versionadded:: 3.20
%End

virtual QgsMapLayerConfigWidget *createWidget( QgsMapLayer *layer, QgsMapCanvas *canvas, bool dockWidget = true, QWidget *parent = 0 ) const = 0 /Factory/;
Expand Down
5 changes: 5 additions & 0 deletions src/gui/qgsmaplayerconfigwidgetfactory.cpp
Expand Up @@ -31,3 +31,8 @@ bool QgsMapLayerConfigWidgetFactory::supportsLayer( QgsMapLayer *layer ) const
Q_UNUSED( layer )
return true;
}

QgsMapLayerConfigWidgetFactory::ParentPage QgsMapLayerConfigWidgetFactory::parentPage() const
{
return ParentPage::None;
}
22 changes: 22 additions & 0 deletions src/gui/qgsmaplayerconfigwidgetfactory.h
Expand Up @@ -34,6 +34,18 @@ class GUI_EXPORT QgsMapLayerConfigWidgetFactory
{
public:

/**
* Available parent pages, for factories which create a widget which is a sub-component
* of a standard page.
*
* \since QGIS 3.20
*/
enum class ParentPage : int
{
None, //!< Factory creates pages itself, not sub-components
Temporal, //!< Factory creates sub-components of the temporal properties page
};

//! Constructor
QgsMapLayerConfigWidgetFactory() = default;

Expand Down Expand Up @@ -115,6 +127,16 @@ class GUI_EXPORT QgsMapLayerConfigWidgetFactory
*/
virtual bool supportsLayer( QgsMapLayer *layer ) const;

/**
* Returns the associated parent page, for factories which create sub-components of a standard page.
*
* The default implementation returns QgsMapLayerConfigWidgetFactory::ParentPage::None, indicating that the
* factory creates top-level pages which are not subcomponents.
*
* \since QGIS 3.20
*/
virtual ParentPage parentPage() const;

/**
* \brief Factory function to create the widget on demand as needed by the dock.
* \param layer The active layer in the dock.
Expand Down

0 comments on commit 4faceaf

Please sign in to comment.