Skip to content

Commit

Permalink
Move QgsLegendStyle::Style enum to Qgis, rename to LegendComponent
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Feb 20, 2025
1 parent b2f27a8 commit 8911a5b
Show file tree
Hide file tree
Showing 30 changed files with 458 additions and 381 deletions.
40 changes: 40 additions & 0 deletions python/PyQt6/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -7749,6 +7749,46 @@
Qgis.LayerTreeFilterFlags = lambda flags=0: Qgis.LayerTreeFilterFlag(flags)
Qgis.LayerTreeFilterFlags.baseClass = Qgis
LayerTreeFilterFlags = Qgis # dirty hack since SIP seems to introduce the flags in module
QgsLegendStyle.Style = Qgis.LegendComponent
# monkey patching scoped based enum
QgsLegendStyle.Undefined = Qgis.LegendComponent.Undefined
QgsLegendStyle.Undefined.is_monkey_patched = True
QgsLegendStyle.Undefined.__doc__ = "Should not happen, only if corrupted project file"
QgsLegendStyle.Hidden = Qgis.LegendComponent.Hidden
QgsLegendStyle.Hidden.is_monkey_patched = True
QgsLegendStyle.Hidden.__doc__ = "Special style, item is hidden including margins around"
QgsLegendStyle.Title = Qgis.LegendComponent.Title
QgsLegendStyle.Title.is_monkey_patched = True
QgsLegendStyle.Title.__doc__ = "Legend title"
QgsLegendStyle.Group = Qgis.LegendComponent.Group
QgsLegendStyle.Group.is_monkey_patched = True
QgsLegendStyle.Group.__doc__ = "Legend group title"
QgsLegendStyle.Subgroup = Qgis.LegendComponent.Subgroup
QgsLegendStyle.Subgroup.is_monkey_patched = True
QgsLegendStyle.Subgroup.__doc__ = "Legend subgroup title"
QgsLegendStyle.Symbol = Qgis.LegendComponent.Symbol
QgsLegendStyle.Symbol.is_monkey_patched = True
QgsLegendStyle.Symbol.__doc__ = "Symbol icon (excluding label)"
QgsLegendStyle.SymbolLabel = Qgis.LegendComponent.SymbolLabel
QgsLegendStyle.SymbolLabel.is_monkey_patched = True
QgsLegendStyle.SymbolLabel.__doc__ = "Symbol label (excluding icon)"
Qgis.LegendComponent.__doc__ = """Component of legends which can be styled.

Prior to QGIS 3.42 this was available as :py:class:`QgsLegendStyle`.Style

.. versionadded:: 3.42

* ``Undefined``: Should not happen, only if corrupted project file
* ``Hidden``: Special style, item is hidden including margins around
* ``Title``: Legend title
* ``Group``: Legend group title
* ``Subgroup``: Legend subgroup title
* ``Symbol``: Symbol icon (excluding label)
* ``SymbolLabel``: Symbol label (excluding icon)

"""
# --
Qgis.LegendComponent.baseClass = Qgis
# monkey patching scoped based enum
Qgis.LegendJsonRenderFlag.ShowRuleDetails.__doc__ = "If set, the rule expression of a rule based renderer legend item will be added to the JSON"
Qgis.LegendJsonRenderFlag.__doc__ = """Legend JSON export flags.
Expand Down
7 changes: 0 additions & 7 deletions python/PyQt6/core/auto_additions/qgslegendstyle.py
Original file line number Diff line number Diff line change
@@ -1,11 +1,4 @@
# The following has been generated automatically from src/core/qgslegendstyle.h
QgsLegendStyle.Undefined = QgsLegendStyle.Style.Undefined
QgsLegendStyle.Hidden = QgsLegendStyle.Style.Hidden
QgsLegendStyle.Title = QgsLegendStyle.Style.Title
QgsLegendStyle.Group = QgsLegendStyle.Style.Group
QgsLegendStyle.Subgroup = QgsLegendStyle.Style.Subgroup
QgsLegendStyle.Symbol = QgsLegendStyle.Style.Symbol
QgsLegendStyle.SymbolLabel = QgsLegendStyle.Style.SymbolLabel
QgsLegendStyle.Top = QgsLegendStyle.Side.Top
QgsLegendStyle.Bottom = QgsLegendStyle.Side.Bottom
QgsLegendStyle.Left = QgsLegendStyle.Side.Left
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -196,22 +196,22 @@ Sets the ``alignment`` of the legend title.
.. seealso:: :py:func:`titleAlignment`
%End

QgsLegendStyle &rstyle( QgsLegendStyle::Style s );
QgsLegendStyle &rstyle( Qgis::LegendComponent s );
%Docstring
Returns reference to modifiable legend style.
%End

QgsLegendStyle style( QgsLegendStyle::Style s ) const;
QgsLegendStyle style( Qgis::LegendComponent s ) const;
%Docstring
Returns legend style.
%End

void setStyle( QgsLegendStyle::Style component, const QgsLegendStyle &style );
void setStyle( Qgis::LegendComponent component, const QgsLegendStyle &style );
%Docstring
Sets the style of ``component`` to ``style`` for the legend.
%End

QFont styleFont( QgsLegendStyle::Style component ) const /Deprecated="Since 3.40. Use QgsLegendStyle.textFormat() from style() instead."/;
QFont styleFont( Qgis::LegendComponent component ) const /Deprecated="Since 3.40. Use QgsLegendStyle.textFormat() from style() instead."/;
%Docstring
Returns the font settings for a legend ``component``.

Expand All @@ -222,7 +222,7 @@ Returns the font settings for a legend ``component``.
Use :py:func:`QgsLegendStyle.textFormat()` from :py:func:`~QgsLayoutItemLegend.style` instead.
%End

void setStyleFont( QgsLegendStyle::Style component, const QFont &font ) /Deprecated="Since 3.40. Use QgsLegendStyle.setTextFormat() from style() instead."/;
void setStyleFont( Qgis::LegendComponent component, const QFont &font ) /Deprecated="Since 3.40. Use QgsLegendStyle.setTextFormat() from style() instead."/;
%Docstring
Sets the style ``font`` for a legend ``component``.

Expand All @@ -233,12 +233,12 @@ Sets the style ``font`` for a legend ``component``.
Use :py:func:`QgsLegendStyle.setTextFormat()` from :py:func:`~QgsLayoutItemLegend.style` instead.
%End

void setStyleMargin( QgsLegendStyle::Style component, double margin );
void setStyleMargin( Qgis::LegendComponent component, double margin );
%Docstring
Set the ``margin`` for a legend ``component``.
%End

void setStyleMargin( QgsLegendStyle::Style component, QgsLegendStyle::Side side, double margin );
void setStyleMargin( Qgis::LegendComponent component, QgsLegendStyle::Side side, double margin );
%Docstring
Set the ``margin`` for a particular ``side`` of a legend ``component``.
%End
Expand Down
10 changes: 10 additions & 0 deletions python/PyQt6/core/auto_generated/qgis.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -2432,6 +2432,16 @@ The development version
typedef QFlags<Qgis::LayerTreeFilterFlag> LayerTreeFilterFlags;


enum class LegendComponent /BaseType=IntEnum/
{
Undefined,
Hidden,
Title,
Group,
Subgroup,
Symbol,
SymbolLabel,
};

enum class LegendJsonRenderFlag /BaseType=IntFlag/
{
Expand Down
4 changes: 2 additions & 2 deletions python/PyQt6/core/auto_generated/qgslegendrenderer.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ Renders the legend in a ``json`` object.
.. versionadded:: 3.8
%End

static void setNodeLegendStyle( QgsLayerTreeNode *node, QgsLegendStyle::Style style );
static void setNodeLegendStyle( QgsLayerTreeNode *node, Qgis::LegendComponent style );
%Docstring
Sets the ``style`` of a ``node``.

.. seealso:: :py:func:`nodeLegendStyle`
%End

static QgsLegendStyle::Style nodeLegendStyle( QgsLayerTreeNode *node, QgsLayerTreeModel *model );
static Qgis::LegendComponent nodeLegendStyle( QgsLayerTreeNode *node, QgsLayerTreeModel *model );
%Docstring
Returns the style for the given ``node``, within the specified ``model``.

Expand Down
4 changes: 2 additions & 2 deletions python/PyQt6/core/auto_generated/qgslegendsettings.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ Sets the ``alignment`` of the legend title.
%End


QgsLegendStyle style( QgsLegendStyle::Style s ) const;
QgsLegendStyle style( Qgis::LegendComponent s ) const;
%Docstring
Returns the style for a legend component.

.. seealso:: :py:func:`setStyle`
%End

void setStyle( QgsLegendStyle::Style s, const QgsLegendStyle &style );
void setStyle( Qgis::LegendComponent s, const QgsLegendStyle &style );
%Docstring
Sets the ``style`` for a legend component.

Expand Down
17 changes: 3 additions & 14 deletions python/PyQt6/core/auto_generated/qgslegendstyle.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ Contains detailed styling information relating to how a layout legend should be
%End
public:

enum Style /BaseType=IntEnum/
{
Undefined,
Hidden,
Title,
Group,
Subgroup,
Symbol,
SymbolLabel,
};


enum Side /BaseType=IntEnum/
{
Expand Down Expand Up @@ -171,7 +160,7 @@ render ``context``.
.. versionadded:: 3.42
%End

static QString styleName( Style s );
static QString styleName( Qgis::LegendComponent s );
%Docstring
Returns the name for a style component as a string.

Expand All @@ -182,14 +171,14 @@ This is a non-localised version, for internal use.
.. seealso:: :py:func:`styleLabel`
%End

static Style styleFromName( const QString &styleName );
static Qgis::LegendComponent styleFromName( const QString &styleName );
%Docstring
Returns the style from name string.

.. seealso:: :py:func:`styleName`
%End

static QString styleLabel( Style s );
static QString styleLabel( Qgis::LegendComponent s );
%Docstring
Returns a translated string representing a style component, for use in UI.

Expand Down
40 changes: 40 additions & 0 deletions python/core/auto_additions/qgis.py
Original file line number Diff line number Diff line change
Expand Up @@ -7675,6 +7675,46 @@
Qgis.LayerTreeFilterFlag.baseClass = Qgis
Qgis.LayerTreeFilterFlags.baseClass = Qgis
LayerTreeFilterFlags = Qgis # dirty hack since SIP seems to introduce the flags in module
QgsLegendStyle.Style = Qgis.LegendComponent
# monkey patching scoped based enum
QgsLegendStyle.Undefined = Qgis.LegendComponent.Undefined
QgsLegendStyle.Undefined.is_monkey_patched = True
QgsLegendStyle.Undefined.__doc__ = "Should not happen, only if corrupted project file"
QgsLegendStyle.Hidden = Qgis.LegendComponent.Hidden
QgsLegendStyle.Hidden.is_monkey_patched = True
QgsLegendStyle.Hidden.__doc__ = "Special style, item is hidden including margins around"
QgsLegendStyle.Title = Qgis.LegendComponent.Title
QgsLegendStyle.Title.is_monkey_patched = True
QgsLegendStyle.Title.__doc__ = "Legend title"
QgsLegendStyle.Group = Qgis.LegendComponent.Group
QgsLegendStyle.Group.is_monkey_patched = True
QgsLegendStyle.Group.__doc__ = "Legend group title"
QgsLegendStyle.Subgroup = Qgis.LegendComponent.Subgroup
QgsLegendStyle.Subgroup.is_monkey_patched = True
QgsLegendStyle.Subgroup.__doc__ = "Legend subgroup title"
QgsLegendStyle.Symbol = Qgis.LegendComponent.Symbol
QgsLegendStyle.Symbol.is_monkey_patched = True
QgsLegendStyle.Symbol.__doc__ = "Symbol icon (excluding label)"
QgsLegendStyle.SymbolLabel = Qgis.LegendComponent.SymbolLabel
QgsLegendStyle.SymbolLabel.is_monkey_patched = True
QgsLegendStyle.SymbolLabel.__doc__ = "Symbol label (excluding icon)"
Qgis.LegendComponent.__doc__ = """Component of legends which can be styled.

Prior to QGIS 3.42 this was available as :py:class:`QgsLegendStyle`.Style

.. versionadded:: 3.42

* ``Undefined``: Should not happen, only if corrupted project file
* ``Hidden``: Special style, item is hidden including margins around
* ``Title``: Legend title
* ``Group``: Legend group title
* ``Subgroup``: Legend subgroup title
* ``Symbol``: Symbol icon (excluding label)
* ``SymbolLabel``: Symbol label (excluding icon)

"""
# --
Qgis.LegendComponent.baseClass = Qgis
# monkey patching scoped based enum
Qgis.LegendJsonRenderFlag.ShowRuleDetails.__doc__ = "If set, the rule expression of a rule based renderer legend item will be added to the JSON"
Qgis.LegendJsonRenderFlag.__doc__ = """Legend JSON export flags.
Expand Down
14 changes: 7 additions & 7 deletions python/core/auto_generated/layout/qgslayoutitemlegend.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -196,22 +196,22 @@ Sets the ``alignment`` of the legend title.
.. seealso:: :py:func:`titleAlignment`
%End

QgsLegendStyle &rstyle( QgsLegendStyle::Style s );
QgsLegendStyle &rstyle( Qgis::LegendComponent s );
%Docstring
Returns reference to modifiable legend style.
%End

QgsLegendStyle style( QgsLegendStyle::Style s ) const;
QgsLegendStyle style( Qgis::LegendComponent s ) const;
%Docstring
Returns legend style.
%End

void setStyle( QgsLegendStyle::Style component, const QgsLegendStyle &style );
void setStyle( Qgis::LegendComponent component, const QgsLegendStyle &style );
%Docstring
Sets the style of ``component`` to ``style`` for the legend.
%End

QFont styleFont( QgsLegendStyle::Style component ) const /Deprecated="Since 3.40. Use QgsLegendStyle.textFormat() from style() instead."/;
QFont styleFont( Qgis::LegendComponent component ) const /Deprecated="Since 3.40. Use QgsLegendStyle.textFormat() from style() instead."/;
%Docstring
Returns the font settings for a legend ``component``.

Expand All @@ -222,7 +222,7 @@ Returns the font settings for a legend ``component``.
Use :py:func:`QgsLegendStyle.textFormat()` from :py:func:`~QgsLayoutItemLegend.style` instead.
%End

void setStyleFont( QgsLegendStyle::Style component, const QFont &font ) /Deprecated="Since 3.40. Use QgsLegendStyle.setTextFormat() from style() instead."/;
void setStyleFont( Qgis::LegendComponent component, const QFont &font ) /Deprecated="Since 3.40. Use QgsLegendStyle.setTextFormat() from style() instead."/;
%Docstring
Sets the style ``font`` for a legend ``component``.

Expand All @@ -233,12 +233,12 @@ Sets the style ``font`` for a legend ``component``.
Use :py:func:`QgsLegendStyle.setTextFormat()` from :py:func:`~QgsLayoutItemLegend.style` instead.
%End

void setStyleMargin( QgsLegendStyle::Style component, double margin );
void setStyleMargin( Qgis::LegendComponent component, double margin );
%Docstring
Set the ``margin`` for a legend ``component``.
%End

void setStyleMargin( QgsLegendStyle::Style component, QgsLegendStyle::Side side, double margin );
void setStyleMargin( Qgis::LegendComponent component, QgsLegendStyle::Side side, double margin );
%Docstring
Set the ``margin`` for a particular ``side`` of a legend ``component``.
%End
Expand Down
10 changes: 10 additions & 0 deletions python/core/auto_generated/qgis.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -2432,6 +2432,16 @@ The development version
typedef QFlags<Qgis::LayerTreeFilterFlag> LayerTreeFilterFlags;


enum class LegendComponent
{
Undefined,
Hidden,
Title,
Group,
Subgroup,
Symbol,
SymbolLabel,
};

enum class LegendJsonRenderFlag
{
Expand Down
4 changes: 2 additions & 2 deletions python/core/auto_generated/qgslegendrenderer.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -100,14 +100,14 @@ Renders the legend in a ``json`` object.
.. versionadded:: 3.8
%End

static void setNodeLegendStyle( QgsLayerTreeNode *node, QgsLegendStyle::Style style );
static void setNodeLegendStyle( QgsLayerTreeNode *node, Qgis::LegendComponent style );
%Docstring
Sets the ``style`` of a ``node``.

.. seealso:: :py:func:`nodeLegendStyle`
%End

static QgsLegendStyle::Style nodeLegendStyle( QgsLayerTreeNode *node, QgsLayerTreeModel *model );
static Qgis::LegendComponent nodeLegendStyle( QgsLayerTreeNode *node, QgsLayerTreeModel *model );
%Docstring
Returns the style for the given ``node``, within the specified ``model``.

Expand Down
4 changes: 2 additions & 2 deletions python/core/auto_generated/qgslegendsettings.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ Sets the ``alignment`` of the legend title.
%End


QgsLegendStyle style( QgsLegendStyle::Style s ) const;
QgsLegendStyle style( Qgis::LegendComponent s ) const;
%Docstring
Returns the style for a legend component.

.. seealso:: :py:func:`setStyle`
%End

void setStyle( QgsLegendStyle::Style s, const QgsLegendStyle &style );
void setStyle( Qgis::LegendComponent s, const QgsLegendStyle &style );
%Docstring
Sets the ``style`` for a legend component.

Expand Down
17 changes: 3 additions & 14 deletions python/core/auto_generated/qgslegendstyle.sip.in
Original file line number Diff line number Diff line change
Expand Up @@ -21,17 +21,6 @@ Contains detailed styling information relating to how a layout legend should be
%End
public:

enum Style
{
Undefined,
Hidden,
Title,
Group,
Subgroup,
Symbol,
SymbolLabel,
};


enum Side
{
Expand Down Expand Up @@ -171,7 +160,7 @@ render ``context``.
.. versionadded:: 3.42
%End

static QString styleName( Style s );
static QString styleName( Qgis::LegendComponent s );
%Docstring
Returns the name for a style component as a string.

Expand All @@ -182,14 +171,14 @@ This is a non-localised version, for internal use.
.. seealso:: :py:func:`styleLabel`
%End

static Style styleFromName( const QString &styleName );
static Qgis::LegendComponent styleFromName( const QString &styleName );
%Docstring
Returns the style from name string.

.. seealso:: :py:func:`styleName`
%End

static QString styleLabel( Style s );
static QString styleLabel( Qgis::LegendComponent s );
%Docstring
Returns a translated string representing a style component, for use in UI.

Expand Down
Loading

0 comments on commit 8911a5b

Please sign in to comment.