Skip to content

Commit 8911a5b

Browse files
committed
Move QgsLegendStyle::Style enum to Qgis, rename to LegendComponent
1 parent b2f27a8 commit 8911a5b

30 files changed

+458
-381
lines changed

python/PyQt6/core/auto_additions/qgis.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7749,6 +7749,46 @@
77497749
Qgis.LayerTreeFilterFlags = lambda flags=0: Qgis.LayerTreeFilterFlag(flags)
77507750
Qgis.LayerTreeFilterFlags.baseClass = Qgis
77517751
LayerTreeFilterFlags = Qgis # dirty hack since SIP seems to introduce the flags in module
7752+
QgsLegendStyle.Style = Qgis.LegendComponent
7753+
# monkey patching scoped based enum
7754+
QgsLegendStyle.Undefined = Qgis.LegendComponent.Undefined
7755+
QgsLegendStyle.Undefined.is_monkey_patched = True
7756+
QgsLegendStyle.Undefined.__doc__ = "Should not happen, only if corrupted project file"
7757+
QgsLegendStyle.Hidden = Qgis.LegendComponent.Hidden
7758+
QgsLegendStyle.Hidden.is_monkey_patched = True
7759+
QgsLegendStyle.Hidden.__doc__ = "Special style, item is hidden including margins around"
7760+
QgsLegendStyle.Title = Qgis.LegendComponent.Title
7761+
QgsLegendStyle.Title.is_monkey_patched = True
7762+
QgsLegendStyle.Title.__doc__ = "Legend title"
7763+
QgsLegendStyle.Group = Qgis.LegendComponent.Group
7764+
QgsLegendStyle.Group.is_monkey_patched = True
7765+
QgsLegendStyle.Group.__doc__ = "Legend group title"
7766+
QgsLegendStyle.Subgroup = Qgis.LegendComponent.Subgroup
7767+
QgsLegendStyle.Subgroup.is_monkey_patched = True
7768+
QgsLegendStyle.Subgroup.__doc__ = "Legend subgroup title"
7769+
QgsLegendStyle.Symbol = Qgis.LegendComponent.Symbol
7770+
QgsLegendStyle.Symbol.is_monkey_patched = True
7771+
QgsLegendStyle.Symbol.__doc__ = "Symbol icon (excluding label)"
7772+
QgsLegendStyle.SymbolLabel = Qgis.LegendComponent.SymbolLabel
7773+
QgsLegendStyle.SymbolLabel.is_monkey_patched = True
7774+
QgsLegendStyle.SymbolLabel.__doc__ = "Symbol label (excluding icon)"
7775+
Qgis.LegendComponent.__doc__ = """Component of legends which can be styled.
7776+
7777+
Prior to QGIS 3.42 this was available as :py:class:`QgsLegendStyle`.Style
7778+
7779+
.. versionadded:: 3.42
7780+
7781+
* ``Undefined``: Should not happen, only if corrupted project file
7782+
* ``Hidden``: Special style, item is hidden including margins around
7783+
* ``Title``: Legend title
7784+
* ``Group``: Legend group title
7785+
* ``Subgroup``: Legend subgroup title
7786+
* ``Symbol``: Symbol icon (excluding label)
7787+
* ``SymbolLabel``: Symbol label (excluding icon)
7788+
7789+
"""
7790+
# --
7791+
Qgis.LegendComponent.baseClass = Qgis
77527792
# monkey patching scoped based enum
77537793
Qgis.LegendJsonRenderFlag.ShowRuleDetails.__doc__ = "If set, the rule expression of a rule based renderer legend item will be added to the JSON"
77547794
Qgis.LegendJsonRenderFlag.__doc__ = """Legend JSON export flags.

python/PyQt6/core/auto_additions/qgslegendstyle.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,4 @@
11
# The following has been generated automatically from src/core/qgslegendstyle.h
2-
QgsLegendStyle.Undefined = QgsLegendStyle.Style.Undefined
3-
QgsLegendStyle.Hidden = QgsLegendStyle.Style.Hidden
4-
QgsLegendStyle.Title = QgsLegendStyle.Style.Title
5-
QgsLegendStyle.Group = QgsLegendStyle.Style.Group
6-
QgsLegendStyle.Subgroup = QgsLegendStyle.Style.Subgroup
7-
QgsLegendStyle.Symbol = QgsLegendStyle.Style.Symbol
8-
QgsLegendStyle.SymbolLabel = QgsLegendStyle.Style.SymbolLabel
92
QgsLegendStyle.Top = QgsLegendStyle.Side.Top
103
QgsLegendStyle.Bottom = QgsLegendStyle.Side.Bottom
114
QgsLegendStyle.Left = QgsLegendStyle.Side.Left

python/PyQt6/core/auto_generated/layout/qgslayoutitemlegend.sip.in

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,22 +196,22 @@ Sets the ``alignment`` of the legend title.
196196
.. seealso:: :py:func:`titleAlignment`
197197
%End
198198

199-
QgsLegendStyle &rstyle( QgsLegendStyle::Style s );
199+
QgsLegendStyle &rstyle( Qgis::LegendComponent s );
200200
%Docstring
201201
Returns reference to modifiable legend style.
202202
%End
203203

204-
QgsLegendStyle style( QgsLegendStyle::Style s ) const;
204+
QgsLegendStyle style( Qgis::LegendComponent s ) const;
205205
%Docstring
206206
Returns legend style.
207207
%End
208208

209-
void setStyle( QgsLegendStyle::Style component, const QgsLegendStyle &style );
209+
void setStyle( Qgis::LegendComponent component, const QgsLegendStyle &style );
210210
%Docstring
211211
Sets the style of ``component`` to ``style`` for the legend.
212212
%End
213213

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

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

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

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

236-
void setStyleMargin( QgsLegendStyle::Style component, double margin );
236+
void setStyleMargin( Qgis::LegendComponent component, double margin );
237237
%Docstring
238238
Set the ``margin`` for a legend ``component``.
239239
%End
240240

241-
void setStyleMargin( QgsLegendStyle::Style component, QgsLegendStyle::Side side, double margin );
241+
void setStyleMargin( Qgis::LegendComponent component, QgsLegendStyle::Side side, double margin );
242242
%Docstring
243243
Set the ``margin`` for a particular ``side`` of a legend ``component``.
244244
%End

python/PyQt6/core/auto_generated/qgis.sip.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,6 +2432,16 @@ The development version
24322432
typedef QFlags<Qgis::LayerTreeFilterFlag> LayerTreeFilterFlags;
24332433

24342434

2435+
enum class LegendComponent /BaseType=IntEnum/
2436+
{
2437+
Undefined,
2438+
Hidden,
2439+
Title,
2440+
Group,
2441+
Subgroup,
2442+
Symbol,
2443+
SymbolLabel,
2444+
};
24352445

24362446
enum class LegendJsonRenderFlag /BaseType=IntFlag/
24372447
{

python/PyQt6/core/auto_generated/qgslegendrenderer.sip.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -100,14 +100,14 @@ Renders the legend in a ``json`` object.
100100
.. versionadded:: 3.8
101101
%End
102102

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

107107
.. seealso:: :py:func:`nodeLegendStyle`
108108
%End
109109

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

python/PyQt6/core/auto_generated/qgslegendsettings.sip.in

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -63,14 +63,14 @@ Sets the ``alignment`` of the legend title.
6363
%End
6464

6565

66-
QgsLegendStyle style( QgsLegendStyle::Style s ) const;
66+
QgsLegendStyle style( Qgis::LegendComponent s ) const;
6767
%Docstring
6868
Returns the style for a legend component.
6969

7070
.. seealso:: :py:func:`setStyle`
7171
%End
7272

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

python/PyQt6/core/auto_generated/qgslegendstyle.sip.in

Lines changed: 3 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,6 @@ Contains detailed styling information relating to how a layout legend should be
2121
%End
2222
public:
2323

24-
enum Style /BaseType=IntEnum/
25-
{
26-
Undefined,
27-
Hidden,
28-
Title,
29-
Group,
30-
Subgroup,
31-
Symbol,
32-
SymbolLabel,
33-
};
34-
3524

3625
enum Side /BaseType=IntEnum/
3726
{
@@ -171,7 +160,7 @@ render ``context``.
171160
.. versionadded:: 3.42
172161
%End
173162

174-
static QString styleName( Style s );
163+
static QString styleName( Qgis::LegendComponent s );
175164
%Docstring
176165
Returns the name for a style component as a string.
177166

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

185-
static Style styleFromName( const QString &styleName );
174+
static Qgis::LegendComponent styleFromName( const QString &styleName );
186175
%Docstring
187176
Returns the style from name string.
188177

189178
.. seealso:: :py:func:`styleName`
190179
%End
191180

192-
static QString styleLabel( Style s );
181+
static QString styleLabel( Qgis::LegendComponent s );
193182
%Docstring
194183
Returns a translated string representing a style component, for use in UI.
195184

python/core/auto_additions/qgis.py

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7675,6 +7675,46 @@
76757675
Qgis.LayerTreeFilterFlag.baseClass = Qgis
76767676
Qgis.LayerTreeFilterFlags.baseClass = Qgis
76777677
LayerTreeFilterFlags = Qgis # dirty hack since SIP seems to introduce the flags in module
7678+
QgsLegendStyle.Style = Qgis.LegendComponent
7679+
# monkey patching scoped based enum
7680+
QgsLegendStyle.Undefined = Qgis.LegendComponent.Undefined
7681+
QgsLegendStyle.Undefined.is_monkey_patched = True
7682+
QgsLegendStyle.Undefined.__doc__ = "Should not happen, only if corrupted project file"
7683+
QgsLegendStyle.Hidden = Qgis.LegendComponent.Hidden
7684+
QgsLegendStyle.Hidden.is_monkey_patched = True
7685+
QgsLegendStyle.Hidden.__doc__ = "Special style, item is hidden including margins around"
7686+
QgsLegendStyle.Title = Qgis.LegendComponent.Title
7687+
QgsLegendStyle.Title.is_monkey_patched = True
7688+
QgsLegendStyle.Title.__doc__ = "Legend title"
7689+
QgsLegendStyle.Group = Qgis.LegendComponent.Group
7690+
QgsLegendStyle.Group.is_monkey_patched = True
7691+
QgsLegendStyle.Group.__doc__ = "Legend group title"
7692+
QgsLegendStyle.Subgroup = Qgis.LegendComponent.Subgroup
7693+
QgsLegendStyle.Subgroup.is_monkey_patched = True
7694+
QgsLegendStyle.Subgroup.__doc__ = "Legend subgroup title"
7695+
QgsLegendStyle.Symbol = Qgis.LegendComponent.Symbol
7696+
QgsLegendStyle.Symbol.is_monkey_patched = True
7697+
QgsLegendStyle.Symbol.__doc__ = "Symbol icon (excluding label)"
7698+
QgsLegendStyle.SymbolLabel = Qgis.LegendComponent.SymbolLabel
7699+
QgsLegendStyle.SymbolLabel.is_monkey_patched = True
7700+
QgsLegendStyle.SymbolLabel.__doc__ = "Symbol label (excluding icon)"
7701+
Qgis.LegendComponent.__doc__ = """Component of legends which can be styled.
7702+
7703+
Prior to QGIS 3.42 this was available as :py:class:`QgsLegendStyle`.Style
7704+
7705+
.. versionadded:: 3.42
7706+
7707+
* ``Undefined``: Should not happen, only if corrupted project file
7708+
* ``Hidden``: Special style, item is hidden including margins around
7709+
* ``Title``: Legend title
7710+
* ``Group``: Legend group title
7711+
* ``Subgroup``: Legend subgroup title
7712+
* ``Symbol``: Symbol icon (excluding label)
7713+
* ``SymbolLabel``: Symbol label (excluding icon)
7714+
7715+
"""
7716+
# --
7717+
Qgis.LegendComponent.baseClass = Qgis
76787718
# monkey patching scoped based enum
76797719
Qgis.LegendJsonRenderFlag.ShowRuleDetails.__doc__ = "If set, the rule expression of a rule based renderer legend item will be added to the JSON"
76807720
Qgis.LegendJsonRenderFlag.__doc__ = """Legend JSON export flags.

python/core/auto_generated/layout/qgslayoutitemlegend.sip.in

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -196,22 +196,22 @@ Sets the ``alignment`` of the legend title.
196196
.. seealso:: :py:func:`titleAlignment`
197197
%End
198198

199-
QgsLegendStyle &rstyle( QgsLegendStyle::Style s );
199+
QgsLegendStyle &rstyle( Qgis::LegendComponent s );
200200
%Docstring
201201
Returns reference to modifiable legend style.
202202
%End
203203

204-
QgsLegendStyle style( QgsLegendStyle::Style s ) const;
204+
QgsLegendStyle style( Qgis::LegendComponent s ) const;
205205
%Docstring
206206
Returns legend style.
207207
%End
208208

209-
void setStyle( QgsLegendStyle::Style component, const QgsLegendStyle &style );
209+
void setStyle( Qgis::LegendComponent component, const QgsLegendStyle &style );
210210
%Docstring
211211
Sets the style of ``component`` to ``style`` for the legend.
212212
%End
213213

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

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

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

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

236-
void setStyleMargin( QgsLegendStyle::Style component, double margin );
236+
void setStyleMargin( Qgis::LegendComponent component, double margin );
237237
%Docstring
238238
Set the ``margin`` for a legend ``component``.
239239
%End
240240

241-
void setStyleMargin( QgsLegendStyle::Style component, QgsLegendStyle::Side side, double margin );
241+
void setStyleMargin( Qgis::LegendComponent component, QgsLegendStyle::Side side, double margin );
242242
%Docstring
243243
Set the ``margin`` for a particular ``side`` of a legend ``component``.
244244
%End

python/core/auto_generated/qgis.sip.in

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2432,6 +2432,16 @@ The development version
24322432
typedef QFlags<Qgis::LayerTreeFilterFlag> LayerTreeFilterFlags;
24332433

24342434

2435+
enum class LegendComponent
2436+
{
2437+
Undefined,
2438+
Hidden,
2439+
Title,
2440+
Group,
2441+
Subgroup,
2442+
Symbol,
2443+
SymbolLabel,
2444+
};
24352445

24362446
enum class LegendJsonRenderFlag
24372447
{

0 commit comments

Comments
 (0)