From 8911a5b726e0e5975b8a634c03ffdd29674d5bf7 Mon Sep 17 00:00:00 2001 From: Nyall Dawson Date: Tue, 18 Feb 2025 11:26:12 +1000 Subject: [PATCH] Move QgsLegendStyle::Style enum to Qgis, rename to LegendComponent --- python/PyQt6/core/auto_additions/qgis.py | 40 ++++++ .../core/auto_additions/qgslegendstyle.py | 7 - .../layout/qgslayoutitemlegend.sip.in | 14 +- python/PyQt6/core/auto_generated/qgis.sip.in | 10 ++ .../auto_generated/qgslegendrenderer.sip.in | 4 +- .../auto_generated/qgslegendsettings.sip.in | 4 +- .../core/auto_generated/qgslegendstyle.sip.in | 17 +-- python/core/auto_additions/qgis.py | 40 ++++++ .../layout/qgslayoutitemlegend.sip.in | 14 +- python/core/auto_generated/qgis.sip.in | 10 ++ .../auto_generated/qgslegendrenderer.sip.in | 4 +- .../auto_generated/qgslegendsettings.sip.in | 4 +- .../core/auto_generated/qgslegendstyle.sip.in | 17 +-- src/core/layertree/qgscolorramplegendnode.cpp | 24 ++-- .../layertree/qgslayertreemodellegendnode.cpp | 20 +-- src/core/layout/qgscompositionconverter.cpp | 20 +-- src/core/layout/qgslayoutitemlegend.cpp | 60 ++++----- src/core/layout/qgslayoutitemlegend.h | 14 +- src/core/qgis.h | 18 +++ src/core/qgslegendrenderer.cpp | 88 ++++++------- src/core/qgslegendrenderer.h | 6 +- src/core/qgslegendsettings.cpp | 72 +++++------ src/core/qgslegendsettings.h | 8 +- src/core/qgslegendstyle.cpp | 48 +++---- src/core/qgslegendstyle.h | 18 +-- src/gui/layout/qgslayoutguiutils.cpp | 22 ++-- src/gui/layout/qgslayoutlegendwidget.cpp | 88 ++++++------- .../services/wms/qgswmsgetlegendgraphics.cpp | 2 +- src/server/services/wms/qgswmsparameters.cpp | 24 ++-- tests/src/core/testqgslegendrenderer.cpp | 120 +++++++++--------- 30 files changed, 457 insertions(+), 380 deletions(-) diff --git a/python/PyQt6/core/auto_additions/qgis.py b/python/PyQt6/core/auto_additions/qgis.py index f0ab7f5f9e9..1eb26cc557b 100644 --- a/python/PyQt6/core/auto_additions/qgis.py +++ b/python/PyQt6/core/auto_additions/qgis.py @@ -7749,6 +7749,46 @@ Qgis.LayerTreeFilterFlag.baseClass = Qgis 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. diff --git a/python/PyQt6/core/auto_additions/qgslegendstyle.py b/python/PyQt6/core/auto_additions/qgslegendstyle.py index 0a8e8ed08f0..f0116d43c88 100644 --- a/python/PyQt6/core/auto_additions/qgslegendstyle.py +++ b/python/PyQt6/core/auto_additions/qgslegendstyle.py @@ -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 diff --git a/python/PyQt6/core/auto_generated/layout/qgslayoutitemlegend.sip.in b/python/PyQt6/core/auto_generated/layout/qgslayoutitemlegend.sip.in index 2befc3ad9a4..d4d741670de 100644 --- a/python/PyQt6/core/auto_generated/layout/qgslayoutitemlegend.sip.in +++ b/python/PyQt6/core/auto_generated/layout/qgslayoutitemlegend.sip.in @@ -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``. @@ -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``. @@ -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 diff --git a/python/PyQt6/core/auto_generated/qgis.sip.in b/python/PyQt6/core/auto_generated/qgis.sip.in index a92b4b6f57f..65d64b7d651 100644 --- a/python/PyQt6/core/auto_generated/qgis.sip.in +++ b/python/PyQt6/core/auto_generated/qgis.sip.in @@ -2432,6 +2432,16 @@ The development version typedef QFlags LayerTreeFilterFlags; + enum class LegendComponent /BaseType=IntEnum/ + { + Undefined, + Hidden, + Title, + Group, + Subgroup, + Symbol, + SymbolLabel, + }; enum class LegendJsonRenderFlag /BaseType=IntFlag/ { diff --git a/python/PyQt6/core/auto_generated/qgslegendrenderer.sip.in b/python/PyQt6/core/auto_generated/qgslegendrenderer.sip.in index 0fd06fd7df9..c715b1755b3 100644 --- a/python/PyQt6/core/auto_generated/qgslegendrenderer.sip.in +++ b/python/PyQt6/core/auto_generated/qgslegendrenderer.sip.in @@ -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``. diff --git a/python/PyQt6/core/auto_generated/qgslegendsettings.sip.in b/python/PyQt6/core/auto_generated/qgslegendsettings.sip.in index a0cbd59f6c5..61ba81d2c46 100644 --- a/python/PyQt6/core/auto_generated/qgslegendsettings.sip.in +++ b/python/PyQt6/core/auto_generated/qgslegendsettings.sip.in @@ -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. diff --git a/python/PyQt6/core/auto_generated/qgslegendstyle.sip.in b/python/PyQt6/core/auto_generated/qgslegendstyle.sip.in index 9dec540ae5f..ed9a209efc4 100644 --- a/python/PyQt6/core/auto_generated/qgslegendstyle.sip.in +++ b/python/PyQt6/core/auto_generated/qgslegendstyle.sip.in @@ -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/ { @@ -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. @@ -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. diff --git a/python/core/auto_additions/qgis.py b/python/core/auto_additions/qgis.py index 0efffaf04d6..c31969e3c17 100644 --- a/python/core/auto_additions/qgis.py +++ b/python/core/auto_additions/qgis.py @@ -7675,6 +7675,46 @@ Qgis.LayerTreeFilterFlag.__doc__ = """Layer tree filter flags. 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. diff --git a/python/core/auto_generated/layout/qgslayoutitemlegend.sip.in b/python/core/auto_generated/layout/qgslayoutitemlegend.sip.in index 2befc3ad9a4..d4d741670de 100644 --- a/python/core/auto_generated/layout/qgslayoutitemlegend.sip.in +++ b/python/core/auto_generated/layout/qgslayoutitemlegend.sip.in @@ -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``. @@ -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``. @@ -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 diff --git a/python/core/auto_generated/qgis.sip.in b/python/core/auto_generated/qgis.sip.in index 1c1985ae424..599e4e2af85 100644 --- a/python/core/auto_generated/qgis.sip.in +++ b/python/core/auto_generated/qgis.sip.in @@ -2432,6 +2432,16 @@ The development version typedef QFlags LayerTreeFilterFlags; + enum class LegendComponent + { + Undefined, + Hidden, + Title, + Group, + Subgroup, + Symbol, + SymbolLabel, + }; enum class LegendJsonRenderFlag { diff --git a/python/core/auto_generated/qgslegendrenderer.sip.in b/python/core/auto_generated/qgslegendrenderer.sip.in index 0fd06fd7df9..c715b1755b3 100644 --- a/python/core/auto_generated/qgslegendrenderer.sip.in +++ b/python/core/auto_generated/qgslegendrenderer.sip.in @@ -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``. diff --git a/python/core/auto_generated/qgslegendsettings.sip.in b/python/core/auto_generated/qgslegendsettings.sip.in index a0cbd59f6c5..61ba81d2c46 100644 --- a/python/core/auto_generated/qgslegendsettings.sip.in +++ b/python/core/auto_generated/qgslegendsettings.sip.in @@ -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. diff --git a/python/core/auto_generated/qgslegendstyle.sip.in b/python/core/auto_generated/qgslegendstyle.sip.in index 6a92699aa9e..8b4df61103a 100644 --- a/python/core/auto_generated/qgslegendstyle.sip.in +++ b/python/core/auto_generated/qgslegendstyle.sip.in @@ -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 { @@ -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. @@ -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. diff --git a/src/core/layertree/qgscolorramplegendnode.cpp b/src/core/layertree/qgscolorramplegendnode.cpp index c966b7133f7..3943cefb843 100644 --- a/src/core/layertree/qgscolorramplegendnode.cpp +++ b/src/core/layertree/qgscolorramplegendnode.cpp @@ -222,7 +222,7 @@ QSizeF QgsColorRampLegendNode::drawSymbol( const QgsLegendSettings &settings, It context = tempRenderContext.get(); } - const QgsTextFormat format = mSettings.textFormat().isValid() ? mSettings.textFormat() : settings.style( QgsLegendStyle::SymbolLabel ).textFormat(); + const QgsTextFormat format = mSettings.textFormat().isValid() ? mSettings.textFormat() : settings.style( Qgis::LegendComponent::SymbolLabel ).textFormat(); const QString minLabel = labelForMinimum(); const QString maxLabel = labelForMaximum(); @@ -351,8 +351,8 @@ QSizeF QgsColorRampLegendNode::drawSymbol( const QgsLegendSettings &settings, It // NOTE -- while the below calculations use the flipped margins from the style, that's only done because // those are the only margins we expose and use for now! (and we expose them as generic margins, not side-specific // ones) TODO when/if we expose other margin settings, these should be reversed... - const double labelYMin = currentYCoord + rampHeight + settings.style( QgsLegendStyle::Symbol ).margin( QgsLegendStyle::Right ) - + settings.style( QgsLegendStyle::SymbolLabel ).margin( QgsLegendStyle::Left ); + const double labelYMin = currentYCoord + rampHeight + settings.style( Qgis::LegendComponent::Symbol ).margin( QgsLegendStyle::Right ) + + settings.style( Qgis::LegendComponent::SymbolLabel ).margin( QgsLegendStyle::Left ); const double labelHeight = std::max( QgsTextRenderer::textHeight( *context, format, QStringList() << minLabel ), QgsTextRenderer::textHeight( *context, format, QStringList() << maxLabel ) ) / dotsPerMM; switch ( settings.symbolAlignment() ) @@ -382,8 +382,8 @@ QSizeF QgsColorRampLegendNode::drawSymbol( const QgsLegendSettings &settings, It // we only need this when we are calculating the size of the node, not at render time labelHeight = std::max( QgsTextRenderer::textHeight( *context, format, QStringList() << minLabel ), QgsTextRenderer::textHeight( *context, format, QStringList() << maxLabel ) ) / context->scaleFactor() - + settings.style( QgsLegendStyle::Symbol ).margin( QgsLegendStyle::Right ) - + settings.style( QgsLegendStyle::SymbolLabel ).margin( QgsLegendStyle::Left ); + + settings.style( Qgis::LegendComponent::Symbol ).margin( QgsLegendStyle::Right ) + + settings.style( Qgis::LegendComponent::SymbolLabel ).margin( QgsLegendStyle::Left ); } } @@ -422,7 +422,7 @@ QSizeF QgsColorRampLegendNode::drawSymbolText( const QgsLegendSettings &settings context = tempRenderContext.get(); } - const QgsTextFormat format = mSettings.textFormat().isValid() ? mSettings.textFormat() : settings.style( QgsLegendStyle::SymbolLabel ).textFormat(); + const QgsTextFormat format = mSettings.textFormat().isValid() ? mSettings.textFormat() : settings.style( Qgis::LegendComponent::SymbolLabel ).textFormat(); const QString minLabel = labelForMinimum(); const QString maxLabel = labelForMaximum(); @@ -452,8 +452,8 @@ QSizeF QgsColorRampLegendNode::drawSymbolText( const QgsLegendSettings &settings case Qt::AlignLeft: default: labelXMin = ctx->columnLeft + std::max( rampWidth, ctx->maxSiblingSymbolWidth ) - + settings.style( QgsLegendStyle::Symbol ).margin( QgsLegendStyle::Right ) - + settings.style( QgsLegendStyle::SymbolLabel ).margin( QgsLegendStyle::Left ); + + settings.style( Qgis::LegendComponent::Symbol ).margin( QgsLegendStyle::Right ) + + settings.style( Qgis::LegendComponent::SymbolLabel ).margin( QgsLegendStyle::Left ); labelXMax = ctx->columnRight; break; @@ -463,16 +463,16 @@ QSizeF QgsColorRampLegendNode::drawSymbolText( const QgsLegendSettings &settings // those are the only margins we expose and use for now! (and we expose them as generic margins, not side-specific // ones) TODO when/if we expose other margin settings, these should be reversed... labelXMax = ctx->columnRight - std::max( rampWidth, ctx->maxSiblingSymbolWidth ) - - settings.style( QgsLegendStyle::Symbol ).margin( QgsLegendStyle::Right ) - - settings.style( QgsLegendStyle::SymbolLabel ).margin( QgsLegendStyle::Left ); + - settings.style( Qgis::LegendComponent::Symbol ).margin( QgsLegendStyle::Right ) + - settings.style( Qgis::LegendComponent::SymbolLabel ).margin( QgsLegendStyle::Left ); break; } const QRectF textRect( labelXMin * dotsPerMM, currentYCoord * dotsPerMM, ( labelXMax - labelXMin ) * dotsPerMM, rampHeight * dotsPerMM ); - QgsTextRenderer::drawText( textRect, 0, QgsTextRenderer::convertQtHAlignment( settings.style( QgsLegendStyle::SymbolLabel ).alignment() ), + QgsTextRenderer::drawText( textRect, 0, QgsTextRenderer::convertQtHAlignment( settings.style( Qgis::LegendComponent::SymbolLabel ).alignment() ), QStringList() << ( mSettings.direction() == QgsColorRampLegendNodeSettings::MinimumToMaximum ? maxLabel : minLabel ), *context, format, true, Qgis::TextVerticalAlignment::Top ); - QgsTextRenderer::drawText( textRect, 0, QgsTextRenderer::convertQtHAlignment( settings.style( QgsLegendStyle::SymbolLabel ).alignment() ), + QgsTextRenderer::drawText( textRect, 0, QgsTextRenderer::convertQtHAlignment( settings.style( Qgis::LegendComponent::SymbolLabel ).alignment() ), QStringList() << ( mSettings.direction() == QgsColorRampLegendNodeSettings::MinimumToMaximum ? minLabel : maxLabel ), *context, format, true, Qgis::TextVerticalAlignment::Bottom ); } diff --git a/src/core/layertree/qgslayertreemodellegendnode.cpp b/src/core/layertree/qgslayertreemodellegendnode.cpp index 483d101cd9d..7c442e8d90a 100644 --- a/src/core/layertree/qgslayertreemodellegendnode.cpp +++ b/src/core/layertree/qgslayertreemodellegendnode.cpp @@ -87,7 +87,7 @@ void QgsLayerTreeModelLegendNode::setUserPatchSize( QSizeF size ) QgsLayerTreeModelLegendNode::ItemMetrics QgsLayerTreeModelLegendNode::draw( const QgsLegendSettings &settings, ItemContext *ctx ) { - const QgsTextFormat f = settings.style( QgsLegendStyle::SymbolLabel ).textFormat(); + const QgsTextFormat f = settings.style( Qgis::LegendComponent::SymbolLabel ).textFormat(); const QStringList lines = settings.evaluateItemText( data( Qt::DisplayRole ).toString(), ctx->context->expressionContext() ); @@ -195,7 +195,7 @@ QSizeF QgsLayerTreeModelLegendNode::drawSymbolText( const QgsLegendSettings &set context = tempContext.get(); } - const QgsTextFormat format = settings.style( QgsLegendStyle::SymbolLabel ).textFormat(); + const QgsTextFormat format = settings.style( Qgis::LegendComponent::SymbolLabel ).textFormat(); // TODO QGIS 4.0 -- make these all mandatory std::optional< QgsTextDocument > tempDocument; @@ -231,8 +231,8 @@ QSizeF QgsLayerTreeModelLegendNode::drawSymbolText( const QgsLegendSettings &set case Qt::AlignLeft: default: labelXMin = ctx->columnLeft + std::max( static_cast< double >( symbolSizeMM.width() ), ctx->maxSiblingSymbolWidth ) - + settings.style( QgsLegendStyle::Symbol ).margin( QgsLegendStyle::Right ) - + settings.style( QgsLegendStyle::SymbolLabel ).margin( QgsLegendStyle::Left ); + + settings.style( Qgis::LegendComponent::Symbol ).margin( QgsLegendStyle::Right ) + + settings.style( Qgis::LegendComponent::SymbolLabel ).margin( QgsLegendStyle::Left ); labelXMax = ctx->columnRight; break; @@ -242,8 +242,8 @@ QSizeF QgsLayerTreeModelLegendNode::drawSymbolText( const QgsLegendSettings &set // those are the only margins we expose and use for now! (and we expose them as generic margins, not side-specific // ones) TODO when/if we expose other margin settings, these should be reversed... labelXMax = ctx->columnRight - std::max( static_cast< double >( symbolSizeMM.width() ), ctx->maxSiblingSymbolWidth ) - - settings.style( QgsLegendStyle::Symbol ).margin( QgsLegendStyle::Right ) - - settings.style( QgsLegendStyle::SymbolLabel ).margin( QgsLegendStyle::Left ); + - settings.style( Qgis::LegendComponent::Symbol ).margin( QgsLegendStyle::Right ) + - settings.style( Qgis::LegendComponent::SymbolLabel ).margin( QgsLegendStyle::Left ); break; } @@ -256,8 +256,8 @@ QSizeF QgsLayerTreeModelLegendNode::drawSymbolText( const QgsLegendSettings &set if ( context->painter() ) { - Qgis::TextHorizontalAlignment halign = settings.style( QgsLegendStyle::SymbolLabel ).alignment() == Qt::AlignLeft ? Qgis::TextHorizontalAlignment::Left : - settings.style( QgsLegendStyle::SymbolLabel ).alignment() == Qt::AlignRight ? Qgis::TextHorizontalAlignment::Right : Qgis::TextHorizontalAlignment::Center; + Qgis::TextHorizontalAlignment halign = settings.style( Qgis::LegendComponent::SymbolLabel ).alignment() == Qt::AlignLeft ? Qgis::TextHorizontalAlignment::Left : + settings.style( Qgis::LegendComponent::SymbolLabel ).alignment() == Qt::AlignRight ? Qgis::TextHorizontalAlignment::Right : Qgis::TextHorizontalAlignment::Center; QgsTextRenderer::drawDocument( QRectF( labelXMin * dotsPerMM, std::round( labelYMM * dotsPerMM ), @@ -1550,8 +1550,8 @@ QgsLayerTreeModelLegendNode::ItemMetrics QgsDataDefinedSizeLegendNode::draw( con } QgsDataDefinedSizeLegend ddsLegend( *mSettings ); - ddsLegend.setFont( settings.style( QgsLegendStyle::SymbolLabel ).textFormat().toQFont() ); - ddsLegend.setTextColor( settings.style( QgsLegendStyle::SymbolLabel ).textFormat().color() ); + ddsLegend.setFont( settings.style( Qgis::LegendComponent::SymbolLabel ).textFormat().toQFont() ); + ddsLegend.setTextColor( settings.style( Qgis::LegendComponent::SymbolLabel ).textFormat().color() ); QSizeF contentSize; double labelXOffset; diff --git a/src/core/layout/qgscompositionconverter.cpp b/src/core/layout/qgscompositionconverter.cpp index 710fed0228e..e6af17055ce 100644 --- a/src/core/layout/qgscompositionconverter.cpp +++ b/src/core/layout/qgscompositionconverter.cpp @@ -1278,12 +1278,12 @@ bool QgsCompositionConverter::readLegendXml( QgsLayoutItemLegend *layoutItem, co QgsLegendStyle style; style.readXml( styleElem, QDomDocument() ); const QString name = styleElem.attribute( QStringLiteral( "name" ) ); - QgsLegendStyle::Style s; - if ( name == QLatin1String( "title" ) ) s = QgsLegendStyle::Title; - else if ( name == QLatin1String( "group" ) ) s = QgsLegendStyle::Group; - else if ( name == QLatin1String( "subgroup" ) ) s = QgsLegendStyle::Subgroup; - else if ( name == QLatin1String( "symbol" ) ) s = QgsLegendStyle::Symbol; - else if ( name == QLatin1String( "symbolLabel" ) ) s = QgsLegendStyle::SymbolLabel; + Qgis::LegendComponent s; + if ( name == QLatin1String( "title" ) ) s = Qgis::LegendComponent::Title; + else if ( name == QLatin1String( "group" ) ) s = Qgis::LegendComponent::Group; + else if ( name == QLatin1String( "subgroup" ) ) s = Qgis::LegendComponent::Subgroup; + else if ( name == QLatin1String( "symbol" ) ) s = Qgis::LegendComponent::Symbol; + else if ( name == QLatin1String( "symbolLabel" ) ) s = Qgis::LegendComponent::SymbolLabel; else continue; layoutItem->setStyle( s, style ); } @@ -1292,10 +1292,10 @@ bool QgsCompositionConverter::readLegendXml( QgsLayoutItemLegend *layoutItem, co //font color QColor fontClr; fontClr.setNamedColor( itemElem.attribute( QStringLiteral( "fontColor" ), QStringLiteral( "#000000" ) ) ); - layoutItem->rstyle( QgsLegendStyle::Title ).textFormat().setColor( fontClr ); - layoutItem->rstyle( QgsLegendStyle::Group ).textFormat().setColor( fontClr ); - layoutItem->rstyle( QgsLegendStyle::Subgroup ).textFormat().setColor( fontClr ); - layoutItem->rstyle( QgsLegendStyle::SymbolLabel ).textFormat().setColor( fontClr ); + layoutItem->rstyle( Qgis::LegendComponent::Title ).textFormat().setColor( fontClr ); + layoutItem->rstyle( Qgis::LegendComponent::Group ).textFormat().setColor( fontClr ); + layoutItem->rstyle( Qgis::LegendComponent::Subgroup ).textFormat().setColor( fontClr ); + layoutItem->rstyle( Qgis::LegendComponent::SymbolLabel ).textFormat().setColor( fontClr ); //spaces layoutItem->setBoxSpace( itemElem.attribute( QStringLiteral( "boxSpace" ), QStringLiteral( "2.0" ) ).toDouble() ); diff --git a/src/core/layout/qgslayoutitemlegend.cpp b/src/core/layout/qgslayoutitemlegend.cpp index 34d3b5fd3b7..9afe202b79e 100644 --- a/src/core/layout/qgslayoutitemlegend.cpp +++ b/src/core/layout/qgslayoutitemlegend.cpp @@ -408,41 +408,41 @@ void QgsLayoutItemLegend::setTitleAlignment( Qt::AlignmentFlag alignment ) mSettings.setTitleAlignment( alignment ); } -QgsLegendStyle &QgsLayoutItemLegend::rstyle( QgsLegendStyle::Style s ) +QgsLegendStyle &QgsLayoutItemLegend::rstyle( Qgis::LegendComponent s ) { return mSettings.rstyle( s ); } -QgsLegendStyle QgsLayoutItemLegend::style( QgsLegendStyle::Style s ) const +QgsLegendStyle QgsLayoutItemLegend::style( Qgis::LegendComponent s ) const { return mSettings.style( s ); } -void QgsLayoutItemLegend::setStyle( QgsLegendStyle::Style s, const QgsLegendStyle &style ) +void QgsLayoutItemLegend::setStyle( Qgis::LegendComponent s, const QgsLegendStyle &style ) { mSettings.setStyle( s, style ); } -QFont QgsLayoutItemLegend::styleFont( QgsLegendStyle::Style s ) const +QFont QgsLayoutItemLegend::styleFont( Qgis::LegendComponent s ) const { Q_NOWARN_DEPRECATED_PUSH return mSettings.style( s ).font(); Q_NOWARN_DEPRECATED_POP } -void QgsLayoutItemLegend::setStyleFont( QgsLegendStyle::Style s, const QFont &f ) +void QgsLayoutItemLegend::setStyleFont( Qgis::LegendComponent s, const QFont &f ) { Q_NOWARN_DEPRECATED_PUSH rstyle( s ).setFont( f ); Q_NOWARN_DEPRECATED_POP } -void QgsLayoutItemLegend::setStyleMargin( QgsLegendStyle::Style s, double margin ) +void QgsLayoutItemLegend::setStyleMargin( Qgis::LegendComponent s, double margin ) { rstyle( s ).setMargin( margin ); } -void QgsLayoutItemLegend::setStyleMargin( QgsLegendStyle::Style s, QgsLegendStyle::Side side, double margin ) +void QgsLayoutItemLegend::setStyleMargin( Qgis::LegendComponent s, QgsLegendStyle::Side side, double margin ) { rstyle( s ).setMargin( side, margin ); } @@ -696,11 +696,11 @@ bool QgsLayoutItemLegend::writePropertiesToElement( QDomElement &legendElem, QDo QDomElement legendStyles = doc.createElement( QStringLiteral( "styles" ) ); legendElem.appendChild( legendStyles ); - style( QgsLegendStyle::Title ).writeXml( QStringLiteral( "title" ), legendStyles, doc, context ); - style( QgsLegendStyle::Group ).writeXml( QStringLiteral( "group" ), legendStyles, doc, context ); - style( QgsLegendStyle::Subgroup ).writeXml( QStringLiteral( "subgroup" ), legendStyles, doc, context ); - style( QgsLegendStyle::Symbol ).writeXml( QStringLiteral( "symbol" ), legendStyles, doc, context ); - style( QgsLegendStyle::SymbolLabel ).writeXml( QStringLiteral( "symbolLabel" ), legendStyles, doc, context ); + style( Qgis::LegendComponent::Title ).writeXml( QStringLiteral( "title" ), legendStyles, doc, context ); + style( Qgis::LegendComponent::Group ).writeXml( QStringLiteral( "group" ), legendStyles, doc, context ); + style( Qgis::LegendComponent::Subgroup ).writeXml( QStringLiteral( "subgroup" ), legendStyles, doc, context ); + style( Qgis::LegendComponent::Symbol ).writeXml( QStringLiteral( "symbol" ), legendStyles, doc, context ); + style( Qgis::LegendComponent::SymbolLabel ).writeXml( QStringLiteral( "symbolLabel" ), legendStyles, doc, context ); if ( mCustomLayerTree ) { @@ -743,12 +743,12 @@ bool QgsLayoutItemLegend::readPropertiesFromElement( const QDomElement &itemElem QgsLegendStyle style; style.readXml( styleElem, doc, context ); const QString name = styleElem.attribute( QStringLiteral( "name" ) ); - QgsLegendStyle::Style s; - if ( name == QLatin1String( "title" ) ) s = QgsLegendStyle::Title; - else if ( name == QLatin1String( "group" ) ) s = QgsLegendStyle::Group; - else if ( name == QLatin1String( "subgroup" ) ) s = QgsLegendStyle::Subgroup; - else if ( name == QLatin1String( "symbol" ) ) s = QgsLegendStyle::Symbol; - else if ( name == QLatin1String( "symbolLabel" ) ) s = QgsLegendStyle::SymbolLabel; + Qgis::LegendComponent s; + if ( name == QLatin1String( "title" ) ) s = Qgis::LegendComponent::Title; + else if ( name == QLatin1String( "group" ) ) s = Qgis::LegendComponent::Group; + else if ( name == QLatin1String( "subgroup" ) ) s = Qgis::LegendComponent::Subgroup; + else if ( name == QLatin1String( "symbol" ) ) s = Qgis::LegendComponent::Symbol; + else if ( name == QLatin1String( "symbolLabel" ) ) s = Qgis::LegendComponent::SymbolLabel; else continue; setStyle( s, style ); } @@ -759,10 +759,10 @@ bool QgsLayoutItemLegend::readPropertiesFromElement( const QDomElement &itemElem { QColor fontClr; fontClr.setNamedColor( itemElem.attribute( QStringLiteral( "fontColor" ), QStringLiteral( "#000000" ) ) ); - rstyle( QgsLegendStyle::Title ).textFormat().setColor( fontClr ); - rstyle( QgsLegendStyle::Group ).textFormat().setColor( fontClr ); - rstyle( QgsLegendStyle::Subgroup ).textFormat().setColor( fontClr ); - rstyle( QgsLegendStyle::SymbolLabel ).textFormat().setColor( fontClr ); + rstyle( Qgis::LegendComponent::Title ).textFormat().setColor( fontClr ); + rstyle( Qgis::LegendComponent::Group ).textFormat().setColor( fontClr ); + rstyle( Qgis::LegendComponent::Subgroup ).textFormat().setColor( fontClr ); + rstyle( Qgis::LegendComponent::SymbolLabel ).textFormat().setColor( fontClr ); } //spaces @@ -781,26 +781,26 @@ bool QgsLayoutItemLegend::readPropertiesFromElement( const QDomElement &itemElem { const double spacing = itemElem.attribute( QStringLiteral( "lineSpacing" ), QStringLiteral( "1.0" ) ).toDouble(); // line spacing *was* a fixed amount (in mm) added between each line of text. - QgsTextFormat f = rstyle( QgsLegendStyle::Title ).textFormat(); + QgsTextFormat f = rstyle( Qgis::LegendComponent::Title ).textFormat(); // assume font sizes in points, since that was what we always had from before this method was deprecated f.setLineHeight( f.size() * 0.352778 + spacing ); f.setLineHeightUnit( Qgis::RenderUnit::Millimeters ); - rstyle( QgsLegendStyle::Title ).setTextFormat( f ); + rstyle( Qgis::LegendComponent::Title ).setTextFormat( f ); - f = rstyle( QgsLegendStyle::Group ).textFormat(); + f = rstyle( Qgis::LegendComponent::Group ).textFormat(); f.setLineHeight( f.size() * 0.352778 + spacing ); f.setLineHeightUnit( Qgis::RenderUnit::Millimeters ); - rstyle( QgsLegendStyle::Group ).setTextFormat( f ); + rstyle( Qgis::LegendComponent::Group ).setTextFormat( f ); - f = rstyle( QgsLegendStyle::Subgroup ).textFormat(); + f = rstyle( Qgis::LegendComponent::Subgroup ).textFormat(); f.setLineHeight( f.size() * 0.352778 + spacing ); f.setLineHeightUnit( Qgis::RenderUnit::Millimeters ); - rstyle( QgsLegendStyle::Subgroup ).setTextFormat( f ); + rstyle( Qgis::LegendComponent::Subgroup ).setTextFormat( f ); - f = rstyle( QgsLegendStyle::SymbolLabel ).textFormat(); + f = rstyle( Qgis::LegendComponent::SymbolLabel ).textFormat(); f.setLineHeight( f.size() * 0.352778 + spacing ); f.setLineHeightUnit( Qgis::RenderUnit::Millimeters ); - rstyle( QgsLegendStyle::SymbolLabel ).setTextFormat( f ); + rstyle( Qgis::LegendComponent::SymbolLabel ).setTextFormat( f ); } mSettings.setDrawRasterStroke( itemElem.attribute( QStringLiteral( "rasterBorder" ), QStringLiteral( "1" ) ) != QLatin1String( "0" ) ); diff --git a/src/core/layout/qgslayoutitemlegend.h b/src/core/layout/qgslayoutitemlegend.h index 10dea4bd2e4..1f3439d267e 100644 --- a/src/core/layout/qgslayoutitemlegend.h +++ b/src/core/layout/qgslayoutitemlegend.h @@ -231,17 +231,17 @@ class CORE_EXPORT QgsLayoutItemLegend : public QgsLayoutItem /** * Returns reference to modifiable legend style. */ - QgsLegendStyle &rstyle( QgsLegendStyle::Style s ); + QgsLegendStyle &rstyle( Qgis::LegendComponent s ); /** * Returns legend style. */ - QgsLegendStyle style( QgsLegendStyle::Style s ) const; + QgsLegendStyle style( Qgis::LegendComponent s ) const; /** * Sets the style of \a component to \a style for the legend. */ - void setStyle( QgsLegendStyle::Style component, const QgsLegendStyle &style ); + void setStyle( Qgis::LegendComponent component, const QgsLegendStyle &style ); /** * Returns the font settings for a legend \a component. @@ -249,7 +249,7 @@ class CORE_EXPORT QgsLayoutItemLegend : public QgsLayoutItem * * \deprecated QGIS 3.40. Use QgsLegendStyle::textFormat() from style() instead. */ - Q_DECL_DEPRECATED QFont styleFont( QgsLegendStyle::Style component ) const SIP_DEPRECATED; + Q_DECL_DEPRECATED QFont styleFont( Qgis::LegendComponent component ) const SIP_DEPRECATED; /** * Sets the style \a font for a legend \a component. @@ -257,17 +257,17 @@ class CORE_EXPORT QgsLayoutItemLegend : public QgsLayoutItem * * \deprecated QGIS 3.40. Use QgsLegendStyle::setTextFormat() from style() instead. */ - Q_DECL_DEPRECATED void setStyleFont( QgsLegendStyle::Style component, const QFont &font ) SIP_DEPRECATED; + Q_DECL_DEPRECATED void setStyleFont( Qgis::LegendComponent component, const QFont &font ) SIP_DEPRECATED; /** * Set the \a margin for a legend \a component. */ - void setStyleMargin( QgsLegendStyle::Style component, double margin ); + void setStyleMargin( Qgis::LegendComponent component, double margin ); /** * Set the \a margin for a particular \a side of a legend \a component. */ - void setStyleMargin( QgsLegendStyle::Style component, QgsLegendStyle::Side side, double margin ); + void setStyleMargin( Qgis::LegendComponent component, QgsLegendStyle::Side side, double margin ); /** * Returns the spacing in-between lines in layout units. diff --git a/src/core/qgis.h b/src/core/qgis.h index 6cc6bae2eb7..6a3a5c3d505 100644 --- a/src/core/qgis.h +++ b/src/core/qgis.h @@ -4331,6 +4331,24 @@ class CORE_EXPORT Qgis Q_DECLARE_FLAGS( LayerTreeFilterFlags, LayerTreeFilterFlag ) Q_FLAG( LayerTreeFilterFlags ) + /** + * Component of legends which can be styled. + * + * Prior to QGIS 3.42 this was available as QgsLegendStyle::Style + * + * \since QGIS 3.42 + */ + enum class LegendComponent SIP_MONKEYPATCH_SCOPEENUM_UNNEST( QgsLegendStyle, Style ) : int + { + 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) + }; + Q_ENUM( LegendComponent ) /** * Legend JSON export flags. diff --git a/src/core/qgslegendrenderer.cpp b/src/core/qgslegendrenderer.cpp index 4f5d74ac7b1..19810556791 100644 --- a/src/core/qgslegendrenderer.cpp +++ b/src/core/qgslegendrenderer.cpp @@ -120,7 +120,7 @@ QJsonObject QgsLegendRenderer::exportLegendToJson( const QgsRenderContext &conte QgsLayerTreeLayer *nodeLayer = QgsLayerTree::toLayer( node ); QString text; - if ( nodeLegendStyle( nodeLayer ) != QgsLegendStyle::Hidden ) + if ( nodeLegendStyle( nodeLayer ) != Qgis::LegendComponent::Hidden ) { const QModelIndex idx = mLegendModel->node2index( nodeLayer ); text = mLegendModel->data( idx, Qt::DisplayRole ).toString(); @@ -243,7 +243,7 @@ QSizeF QgsLegendRenderer::paintAndDetermineSize( QgsRenderContext &context ) QSizeF titleSize = drawTitle( context, 0 ); //add title margin to size of title text titleSize.rwidth() += mSettings.boxSpace() * 2.0; - double columnTop = mSettings.boxSpace() + titleSize.height() + mSettings.style( QgsLegendStyle::Title ).margin( QgsLegendStyle::Bottom ); + double columnTop = mSettings.boxSpace() + titleSize.height() + mSettings.style( Qgis::LegendComponent::Title ).margin( QgsLegendStyle::Bottom ); noPainter.reset(); @@ -347,11 +347,11 @@ QList QgsLegendRenderer::createComponen double newIndent = indent; if ( style == QLatin1String( "subgroup" ) ) { - newIndent += mSettings.style( QgsLegendStyle::Subgroup ).indent( ); + newIndent += mSettings.style( Qgis::LegendComponent::Subgroup ).indent( ); } else { - newIndent += mSettings.style( QgsLegendStyle::Group ).indent( ); + newIndent += mSettings.style( Qgis::LegendComponent::Group ).indent( ); } // Group subitems @@ -359,7 +359,7 @@ QList QgsLegendRenderer::createComponen bool hasSubItems = !subgroups.empty(); - if ( nodeLegendStyle( nodeGroup ) != QgsLegendStyle::Hidden ) + if ( nodeLegendStyle( nodeGroup ) != Qgis::LegendComponent::Hidden ) { LegendComponent component; component.item = node; @@ -399,7 +399,7 @@ QList QgsLegendRenderer::createComponen else if ( QgsLayerTree::isLayer( node ) ) { QgsLayerTreeLayer *nodeLayer = QgsLayerTree::toLayer( node ); - QgsLegendStyle::Style layerStyle = nodeLegendStyle( nodeLayer ); + Qgis::LegendComponent layerStyle = nodeLegendStyle( nodeLayer ); bool allowColumnSplit = false; switch ( nodeLayer->legendSplitBehavior() ) { @@ -417,7 +417,7 @@ QList QgsLegendRenderer::createComponen LegendComponentGroup group; group.placeColumnBreakBeforeGroup = nodeLayer->customProperty( QStringLiteral( "legend/column-break" ) ).toInt(); - if ( layerStyle != QgsLegendStyle::Hidden ) + if ( layerStyle != Qgis::LegendComponent::Hidden ) { LegendComponent component; component.item = node; @@ -443,8 +443,8 @@ QList QgsLegendRenderer::createComponen double symbolIndent = indent; switch ( layerStyle ) { - case QgsLegendStyle::Subgroup: - case QgsLegendStyle::Group: + case Qgis::LegendComponent::Subgroup: + case Qgis::LegendComponent::Group: symbolIndent += mSettings.style( layerStyle ).indent( ); break; default: @@ -479,7 +479,7 @@ QList QgsLegendRenderer::createComponen if ( !group.components.isEmpty() ) { // TODO: for now we keep Symbol and SymbolLabel Top margin in sync - group.size.rheight() += mSettings.style( QgsLegendStyle::Symbol ).margin( QgsLegendStyle::Top ); + group.size.rheight() += mSettings.style( Qgis::LegendComponent::Symbol ).margin( QgsLegendStyle::Top ); } group.size.rheight() += symbolComponent.size.height(); symbolComponent.indent = symbolIndent; @@ -744,8 +744,8 @@ int QgsLegendRenderer::setColumns( QList &componentGroups if ( QgsLayerTreeModelLegendNode *legendNode = qobject_cast( group.components.at( j ).item ) ) { QString key = QStringLiteral( "%1-%2" ).arg( reinterpret_cast< qulonglong >( legendNode->layerNode() ) ).arg( group.column ); - double space = mSettings.style( QgsLegendStyle::Symbol ).margin( QgsLegendStyle::Right ) + - mSettings.style( QgsLegendStyle::SymbolLabel ).margin( QgsLegendStyle::Left ); + double space = mSettings.style( Qgis::LegendComponent::Symbol ).margin( QgsLegendStyle::Right ) + + mSettings.style( Qgis::LegendComponent::SymbolLabel ).margin( QgsLegendStyle::Left ); group.components[j].labelXOffset = maxSymbolWidth[key] + space; group.components[j].maxSiblingSymbolWidth = maxSymbolWidth[key]; group.components[j].size.rwidth() = maxSymbolWidth[key] + space + group.components.at( j ).labelSize.width(); @@ -770,7 +770,7 @@ QSizeF QgsLegendRenderer::drawTitle( QgsRenderContext &context, double top, Qt:: double textBoxLeft; widthAndOffsetForTitleText( halignment, legendWidth, textBoxWidth, textBoxLeft ); - const QgsTextFormat titleFormat = mSettings.style( QgsLegendStyle::Title ).textFormat(); + const QgsTextFormat titleFormat = mSettings.style( Qgis::LegendComponent::Title ).textFormat(); const double dotsPerMM = context.scaleFactor(); double overallTextHeight = 0; @@ -818,7 +818,7 @@ double QgsLegendRenderer::spaceAboveGroup( const LegendComponentGroup &group ) else if ( qobject_cast( component.item ) ) { // TODO: use Symbol or SymbolLabel Top margin - return mSettings.style( QgsLegendStyle::Symbol ).margin( QgsLegendStyle::Top ); + return mSettings.style( Qgis::LegendComponent::Symbol ).margin( QgsLegendStyle::Top ); } return 0; @@ -833,8 +833,8 @@ QSizeF QgsLegendRenderer::drawGroup( const LegendComponentGroup &group, QgsRende { if ( QgsLayerTreeGroup *groupItem = qobject_cast( component.item ) ) { - QgsLegendStyle::Style s = nodeLegendStyle( groupItem ); - if ( s != QgsLegendStyle::Hidden ) + Qgis::LegendComponent s = nodeLegendStyle( groupItem ); + if ( s != Qgis::LegendComponent::Hidden ) { if ( !first ) { @@ -843,21 +843,21 @@ QSizeF QgsLegendRenderer::drawGroup( const LegendComponentGroup &group, QgsRende QSizeF groupSize; ColumnContext columnContextForItem = columnContext; double indentWidth = component.indent; - if ( s == QgsLegendStyle::Subgroup ) + if ( s == Qgis::LegendComponent::Subgroup ) { // Remove indent - the subgroup items should be indented, not the subgroup title - indentWidth -= mSettings.style( QgsLegendStyle::Subgroup ).indent( ); + indentWidth -= mSettings.style( Qgis::LegendComponent::Subgroup ).indent( ); } else { // Remove indent - the group items should be indented, not the group title - indentWidth -= mSettings.style( QgsLegendStyle::Group ).indent( ); + indentWidth -= mSettings.style( Qgis::LegendComponent::Group ).indent( ); } - if ( mSettings.style( QgsLegendStyle::SymbolLabel ).alignment() == Qt::AlignLeft ) + if ( mSettings.style( Qgis::LegendComponent::SymbolLabel ).alignment() == Qt::AlignLeft ) { columnContextForItem.left += indentWidth; } - if ( mSettings.style( QgsLegendStyle::SymbolLabel ).alignment() == Qt::AlignRight ) + if ( mSettings.style( Qgis::LegendComponent::SymbolLabel ).alignment() == Qt::AlignRight ) { columnContextForItem.right -= indentWidth; } @@ -867,8 +867,8 @@ QSizeF QgsLegendRenderer::drawGroup( const LegendComponentGroup &group, QgsRende } else if ( QgsLayerTreeLayer *layerItem = qobject_cast( component.item ) ) { - QgsLegendStyle::Style s = nodeLegendStyle( layerItem ); - if ( s != QgsLegendStyle::Hidden ) + Qgis::LegendComponent s = nodeLegendStyle( layerItem ); + if ( s != Qgis::LegendComponent::Hidden ) { if ( !first ) { @@ -887,17 +887,17 @@ QSizeF QgsLegendRenderer::drawGroup( const LegendComponentGroup &group, QgsRende { if ( !first ) { - currentY += mSettings.style( QgsLegendStyle::Symbol ).margin( QgsLegendStyle::Top ); + currentY += mSettings.style( Qgis::LegendComponent::Symbol ).margin( QgsLegendStyle::Top ); } ColumnContext columnContextForItem = columnContext; double indentWidth = 0; indentWidth = component.indent; - if ( mSettings.style( QgsLegendStyle::SymbolLabel ).alignment() == Qt::AlignLeft ) + if ( mSettings.style( Qgis::LegendComponent::SymbolLabel ).alignment() == Qt::AlignLeft ) { columnContextForItem.left += indentWidth; } - if ( mSettings.style( QgsLegendStyle::SymbolLabel ).alignment() == Qt::AlignRight ) + if ( mSettings.style( Qgis::LegendComponent::SymbolLabel ).alignment() == Qt::AlignRight ) { columnContextForItem.right -= indentWidth; } @@ -940,11 +940,11 @@ QgsLegendRenderer::LegendComponent QgsLegendRenderer::drawSymbolItem( QgsLayerTr { case Qt::AlignLeft: default: - ctx.columnLeft += mSettings.style( QgsLegendStyle::Symbol ).margin( QgsLegendStyle::Left ); + ctx.columnLeft += mSettings.style( Qgis::LegendComponent::Symbol ).margin( QgsLegendStyle::Left ); break; case Qt::AlignRight: - ctx.columnRight -= mSettings.style( QgsLegendStyle::Symbol ).margin( QgsLegendStyle::Left ); + ctx.columnRight -= mSettings.style( Qgis::LegendComponent::Symbol ).margin( QgsLegendStyle::Left ); break; } @@ -977,9 +977,9 @@ QgsLegendRenderer::LegendComponent QgsLegendRenderer::drawSymbolItem( QgsLayerTr // ideally we could (should?) expose all these margins as settings, and then adapt the below to respect the current symbol/text alignment // and consider the correct margin sides... double width = std::max( static_cast< double >( im.symbolSize.width() ), maxSiblingSymbolWidth ) - + mSettings.style( QgsLegendStyle::Symbol ).margin( QgsLegendStyle::Left ) - + mSettings.style( QgsLegendStyle::Symbol ).margin( QgsLegendStyle::Right ) - + mSettings.style( QgsLegendStyle::SymbolLabel ).margin( QgsLegendStyle::Left ) + + mSettings.style( Qgis::LegendComponent::Symbol ).margin( QgsLegendStyle::Left ) + + mSettings.style( Qgis::LegendComponent::Symbol ).margin( QgsLegendStyle::Right ) + + mSettings.style( Qgis::LegendComponent::SymbolLabel ).margin( QgsLegendStyle::Left ) + im.labelSize.width(); double height = std::max( im.symbolSize.height(), im.labelSize.height() ); @@ -1082,30 +1082,30 @@ QSizeF QgsLegendRenderer::drawGroupTitle( QgsLayerTreeGroup *nodeGroup, QgsRende return size; } -QgsLegendStyle::Style QgsLegendRenderer::nodeLegendStyle( QgsLayerTreeNode *node, QgsLayerTreeModel *model ) +Qgis::LegendComponent QgsLegendRenderer::nodeLegendStyle( QgsLayerTreeNode *node, QgsLayerTreeModel *model ) { QString style = node->customProperty( QStringLiteral( "legend/title-style" ) ).toString(); if ( style == QLatin1String( "hidden" ) ) - return QgsLegendStyle::Hidden; + return Qgis::LegendComponent::Hidden; else if ( style == QLatin1String( "group" ) ) - return QgsLegendStyle::Group; + return Qgis::LegendComponent::Group; else if ( style == QLatin1String( "subgroup" ) ) - return QgsLegendStyle::Subgroup; + return Qgis::LegendComponent::Subgroup; // use a default otherwise if ( QgsLayerTree::isGroup( node ) ) - return QgsLegendStyle::Group; + return Qgis::LegendComponent::Group; else if ( QgsLayerTree::isLayer( node ) ) { if ( model->legendNodeEmbeddedInParent( QgsLayerTree::toLayer( node ) ) ) - return QgsLegendStyle::Hidden; - return QgsLegendStyle::Subgroup; + return Qgis::LegendComponent::Hidden; + return Qgis::LegendComponent::Subgroup; } - return QgsLegendStyle::Undefined; // should not happen, only if corrupted project file + return Qgis::LegendComponent::Undefined; // should not happen, only if corrupted project file } -QgsLegendStyle::Style QgsLegendRenderer::nodeLegendStyle( QgsLayerTreeNode *node ) +Qgis::LegendComponent QgsLegendRenderer::nodeLegendStyle( QgsLayerTreeNode *node ) { return nodeLegendStyle( node, mLegendModel ); } @@ -1115,18 +1115,18 @@ QgsLayerTreeFilterProxyModel *QgsLegendRenderer::proxyModel() return mProxyModel.get(); } -void QgsLegendRenderer::setNodeLegendStyle( QgsLayerTreeNode *node, QgsLegendStyle::Style style ) +void QgsLegendRenderer::setNodeLegendStyle( QgsLayerTreeNode *node, Qgis::LegendComponent style ) { QString str; switch ( style ) { - case QgsLegendStyle::Hidden: + case Qgis::LegendComponent::Hidden: str = QStringLiteral( "hidden" ); break; - case QgsLegendStyle::Group: + case Qgis::LegendComponent::Group: str = QStringLiteral( "group" ); break; - case QgsLegendStyle::Subgroup: + case Qgis::LegendComponent::Subgroup: str = QStringLiteral( "subgroup" ); break; default: diff --git a/src/core/qgslegendrenderer.h b/src/core/qgslegendrenderer.h index 9b3e9c863df..aa5415b27a9 100644 --- a/src/core/qgslegendrenderer.h +++ b/src/core/qgslegendrenderer.h @@ -125,14 +125,14 @@ class CORE_EXPORT QgsLegendRenderer * * \see nodeLegendStyle() */ - static void setNodeLegendStyle( QgsLayerTreeNode *node, QgsLegendStyle::Style style ); + static void setNodeLegendStyle( QgsLayerTreeNode *node, Qgis::LegendComponent style ); /** * Returns the style for the given \a node, within the specified \a model. * * \see setNodeLegendStyle() */ - static QgsLegendStyle::Style nodeLegendStyle( QgsLayerTreeNode *node, QgsLayerTreeModel *model ); + static Qgis::LegendComponent nodeLegendStyle( QgsLayerTreeNode *node, QgsLayerTreeModel *model ); private: @@ -311,7 +311,7 @@ class CORE_EXPORT QgsLegendRenderer /** * Returns the style of the given \a node. */ - QgsLegendStyle::Style nodeLegendStyle( QgsLayerTreeNode *node ); + Qgis::LegendComponent nodeLegendStyle( QgsLayerTreeNode *node ); QgsLayerTreeModel *mLegendModel = nullptr; std::unique_ptr< QgsLayerTreeFilterProxyModel >mProxyModel; diff --git a/src/core/qgslegendsettings.cpp b/src/core/qgslegendsettings.cpp index 85aca0a578c..617b8fe50cb 100644 --- a/src/core/qgslegendsettings.cpp +++ b/src/core/qgslegendsettings.cpp @@ -25,75 +25,75 @@ QgsLegendSettings::QgsLegendSettings() , mWmsLegendSize( 50, 25 ) , mRasterStrokeColor( Qt::black ) { - rstyle( QgsLegendStyle::Title ).setMargin( QgsLegendStyle::Bottom, 3.5 ); - rstyle( QgsLegendStyle::Group ).setMargin( QgsLegendStyle::Top, 3 ); - rstyle( QgsLegendStyle::Subgroup ).setMargin( QgsLegendStyle::Top, 3 ); - rstyle( QgsLegendStyle::Symbol ).setMargin( QgsLegendStyle::Top, 2.5 ); - rstyle( QgsLegendStyle::SymbolLabel ).setMargin( QgsLegendStyle::Top, 2 ); - rstyle( QgsLegendStyle::SymbolLabel ).setMargin( QgsLegendStyle::Left, 2 ); - rstyle( QgsLegendStyle::Group ).setIndent( 0.0 ); - rstyle( QgsLegendStyle::Subgroup ).setIndent( 0.0 ); + rstyle( Qgis::LegendComponent::Title ).setMargin( QgsLegendStyle::Bottom, 3.5 ); + rstyle( Qgis::LegendComponent::Group ).setMargin( QgsLegendStyle::Top, 3 ); + rstyle( Qgis::LegendComponent::Subgroup ).setMargin( QgsLegendStyle::Top, 3 ); + rstyle( Qgis::LegendComponent::Symbol ).setMargin( QgsLegendStyle::Top, 2.5 ); + rstyle( Qgis::LegendComponent::SymbolLabel ).setMargin( QgsLegendStyle::Top, 2 ); + rstyle( Qgis::LegendComponent::SymbolLabel ).setMargin( QgsLegendStyle::Left, 2 ); + rstyle( Qgis::LegendComponent::Group ).setIndent( 0.0 ); + rstyle( Qgis::LegendComponent::Subgroup ).setIndent( 0.0 ); - QgsTextFormat f = rstyle( QgsLegendStyle::Title ).textFormat(); + QgsTextFormat f = rstyle( Qgis::LegendComponent::Title ).textFormat(); f.setSize( 16.0 ); f.setSizeUnit( Qgis::RenderUnit::Points ); // these default line heights are not ideal, but needed to maintain api f.setLineHeight( 1.1 ); f.setLineHeightUnit( Qgis::RenderUnit::Percentage ); - rstyle( QgsLegendStyle::Title ).setTextFormat( f ); + rstyle( Qgis::LegendComponent::Title ).setTextFormat( f ); - f = rstyle( QgsLegendStyle::Group ).textFormat(); + f = rstyle( Qgis::LegendComponent::Group ).textFormat(); f.setSize( 14.0 ); f.setSizeUnit( Qgis::RenderUnit::Points ); f.setLineHeight( 1.1 ); f.setLineHeightUnit( Qgis::RenderUnit::Percentage ); - rstyle( QgsLegendStyle::Group ).setTextFormat( f ); + rstyle( Qgis::LegendComponent::Group ).setTextFormat( f ); - f = rstyle( QgsLegendStyle::Subgroup ).textFormat(); + f = rstyle( Qgis::LegendComponent::Subgroup ).textFormat(); f.setSize( 12.0 ); f.setSizeUnit( Qgis::RenderUnit::Points ); f.setLineHeight( 1.1 ); f.setLineHeightUnit( Qgis::RenderUnit::Percentage ); - rstyle( QgsLegendStyle::Subgroup ).setTextFormat( f ); + rstyle( Qgis::LegendComponent::Subgroup ).setTextFormat( f ); - f = rstyle( QgsLegendStyle::SymbolLabel ).textFormat(); + f = rstyle( Qgis::LegendComponent::SymbolLabel ).textFormat(); f.setSize( 12.0 ); f.setSizeUnit( Qgis::RenderUnit::Points ); f.setLineHeight( 1.1 ); f.setLineHeightUnit( Qgis::RenderUnit::Percentage ); - rstyle( QgsLegendStyle::SymbolLabel ).setTextFormat( f ); + rstyle( Qgis::LegendComponent::SymbolLabel ).setTextFormat( f ); } void QgsLegendSettings::updateDataDefinedProperties( QgsRenderContext &context ) { - rstyle( QgsLegendStyle::Title ).updateDataDefinedProperties( context ); - rstyle( QgsLegendStyle::Group ).updateDataDefinedProperties( context ); - rstyle( QgsLegendStyle::Subgroup ).updateDataDefinedProperties( context ); - rstyle( QgsLegendStyle::SymbolLabel ).updateDataDefinedProperties( context ); + rstyle( Qgis::LegendComponent::Title ).updateDataDefinedProperties( context ); + rstyle( Qgis::LegendComponent::Group ).updateDataDefinedProperties( context ); + rstyle( Qgis::LegendComponent::Subgroup ).updateDataDefinedProperties( context ); + rstyle( Qgis::LegendComponent::SymbolLabel ).updateDataDefinedProperties( context ); } QColor QgsLegendSettings::fontColor() const { - return style( QgsLegendStyle::SymbolLabel ).textFormat().color(); + return style( Qgis::LegendComponent::SymbolLabel ).textFormat().color(); } void QgsLegendSettings::setFontColor( const QColor &c ) { - rstyle( QgsLegendStyle::Title ).textFormat().setColor( c ); - rstyle( QgsLegendStyle::Group ).textFormat().setColor( c ); - rstyle( QgsLegendStyle::Subgroup ).textFormat().setColor( c ); - rstyle( QgsLegendStyle::SymbolLabel ).textFormat().setColor( c ); + rstyle( Qgis::LegendComponent::Title ).textFormat().setColor( c ); + rstyle( Qgis::LegendComponent::Group ).textFormat().setColor( c ); + rstyle( Qgis::LegendComponent::Subgroup ).textFormat().setColor( c ); + rstyle( Qgis::LegendComponent::SymbolLabel ).textFormat().setColor( c ); } QColor QgsLegendSettings::layerFontColor() const { - return style( QgsLegendStyle::Subgroup ).textFormat().color(); + return style( Qgis::LegendComponent::Subgroup ).textFormat().color(); } void QgsLegendSettings::setLayerFontColor( const QColor &fontColor ) { - rstyle( QgsLegendStyle::Group ).textFormat().setColor( fontColor ); - rstyle( QgsLegendStyle::Subgroup ).textFormat().setColor( fontColor ); + rstyle( Qgis::LegendComponent::Group ).textFormat().setColor( fontColor ); + rstyle( Qgis::LegendComponent::Subgroup ).textFormat().setColor( fontColor ); } void QgsLegendSettings::setLineSpacing( double s ) SIP_DEPRECATED @@ -101,26 +101,26 @@ void QgsLegendSettings::setLineSpacing( double s ) SIP_DEPRECATED // line spacing *was* a fixed amount (in mm) added between each line of text. mLineSpacing = s; - QgsTextFormat f = rstyle( QgsLegendStyle::Title ).textFormat(); + QgsTextFormat f = rstyle( Qgis::LegendComponent::Title ).textFormat(); // assume font sizes in points, since that was what we always had from before this method was deprecated f.setLineHeight( f.size() * 0.352778 + s ); f.setLineHeightUnit( Qgis::RenderUnit::Millimeters ); - rstyle( QgsLegendStyle::Title ).setTextFormat( f ); + rstyle( Qgis::LegendComponent::Title ).setTextFormat( f ); - f = rstyle( QgsLegendStyle::Group ).textFormat(); + f = rstyle( Qgis::LegendComponent::Group ).textFormat(); f.setLineHeight( f.size() * 0.352778 + s ); f.setLineHeightUnit( Qgis::RenderUnit::Millimeters ); - rstyle( QgsLegendStyle::Group ).setTextFormat( f ); + rstyle( Qgis::LegendComponent::Group ).setTextFormat( f ); - f = rstyle( QgsLegendStyle::Subgroup ).textFormat(); + f = rstyle( Qgis::LegendComponent::Subgroup ).textFormat(); f.setLineHeight( f.size() * 0.352778 + s ); f.setLineHeightUnit( Qgis::RenderUnit::Millimeters ); - rstyle( QgsLegendStyle::Subgroup ).setTextFormat( f ); + rstyle( Qgis::LegendComponent::Subgroup ).setTextFormat( f ); - f = rstyle( QgsLegendStyle::SymbolLabel ).textFormat(); + f = rstyle( Qgis::LegendComponent::SymbolLabel ).textFormat(); f.setLineHeight( f.size() * 0.352778 + s ); f.setLineHeightUnit( Qgis::RenderUnit::Millimeters ); - rstyle( QgsLegendStyle::SymbolLabel ).setTextFormat( f ); + rstyle( Qgis::LegendComponent::SymbolLabel ).setTextFormat( f ); } double QgsLegendSettings::mmPerMapUnit() const diff --git a/src/core/qgslegendsettings.h b/src/core/qgslegendsettings.h index a516f73accd..2d1ee7bb5af 100644 --- a/src/core/qgslegendsettings.h +++ b/src/core/qgslegendsettings.h @@ -78,21 +78,21 @@ class CORE_EXPORT QgsLegendSettings * * \note Not available in Python bindings. */ - SIP_SKIP QgsLegendStyle &rstyle( QgsLegendStyle::Style s ) SIP_SKIP { return mStyleMap[s]; } + SIP_SKIP QgsLegendStyle &rstyle( Qgis::LegendComponent s ) SIP_SKIP { return mStyleMap[s]; } /** * Returns the style for a legend component. * * \see setStyle() */ - QgsLegendStyle style( QgsLegendStyle::Style s ) const { return mStyleMap.value( s ); } + QgsLegendStyle style( Qgis::LegendComponent s ) const { return mStyleMap.value( s ); } /** * Sets the \a style for a legend component. * * \see style() */ - void setStyle( QgsLegendStyle::Style s, const QgsLegendStyle &style ) { mStyleMap[s] = style; } + void setStyle( Qgis::LegendComponent s, const QgsLegendStyle &style ) { mStyleMap[s] = style; } /** * Returns the legend box space (in millimeters), which is the empty margin around the inside of the legend's @@ -579,7 +579,7 @@ class CORE_EXPORT QgsLegendSettings QColor mRasterStrokeColor; double mRasterStrokeWidth = 0.0; - QMap mStyleMap; + QMap mStyleMap; //! Conversion ratio between millimeters and map units - for symbols with size given in map units double mMmPerMapUnit = 1; diff --git a/src/core/qgslegendstyle.cpp b/src/core/qgslegendstyle.cpp index 267a076c0a8..d45724a71d4 100644 --- a/src/core/qgslegendstyle.cpp +++ b/src/core/qgslegendstyle.cpp @@ -118,62 +118,62 @@ void QgsLegendStyle::updateDataDefinedProperties( QgsRenderContext &context ) } -QString QgsLegendStyle::styleName( Style s ) +QString QgsLegendStyle::styleName( Qgis::LegendComponent s ) { switch ( s ) { - case Undefined: + case Qgis::LegendComponent::Undefined: return QString(); - case Hidden: + case Qgis::LegendComponent::Hidden: return QStringLiteral( "hidden" ); - case Title: + case Qgis::LegendComponent::Title: return QStringLiteral( "title" ); - case Group: + case Qgis::LegendComponent::Group: return QStringLiteral( "group" ); - case Subgroup: + case Qgis::LegendComponent::Subgroup: return QStringLiteral( "subgroup" ); - case Symbol: + case Qgis::LegendComponent::Symbol: return QStringLiteral( "symbol" ); - case SymbolLabel: + case Qgis::LegendComponent::SymbolLabel: return QStringLiteral( "symbolLabel" ); } return QString(); } -QgsLegendStyle::Style QgsLegendStyle::styleFromName( const QString &styleName ) +Qgis::LegendComponent QgsLegendStyle::styleFromName( const QString &styleName ) { if ( styleName == QLatin1String( "hidden" ) ) - return Hidden; + return Qgis::LegendComponent::Hidden; else if ( styleName == QLatin1String( "title" ) ) - return Title; + return Qgis::LegendComponent::Title; else if ( styleName == QLatin1String( "group" ) ) - return Group; + return Qgis::LegendComponent::Group; else if ( styleName == QLatin1String( "subgroup" ) ) - return Subgroup; + return Qgis::LegendComponent::Subgroup; else if ( styleName == QLatin1String( "symbol" ) ) - return Symbol; + return Qgis::LegendComponent::Symbol; else if ( styleName == QLatin1String( "symbolLabel" ) ) - return SymbolLabel; - return Undefined; + return Qgis::LegendComponent::SymbolLabel; + return Qgis::LegendComponent::Undefined; } -QString QgsLegendStyle::styleLabel( Style s ) +QString QgsLegendStyle::styleLabel( Qgis::LegendComponent s ) { switch ( s ) { - case Undefined: + case Qgis::LegendComponent::Undefined: return QObject::tr( "Undefined" ); - case Hidden: + case Qgis::LegendComponent::Hidden: return QObject::tr( "Hidden" ); - case Title: + case Qgis::LegendComponent::Title: return QObject::tr( "Title" ); - case Group: + case Qgis::LegendComponent::Group: return QObject::tr( "Group" ); - case Subgroup: + case Qgis::LegendComponent::Subgroup: return QObject::tr( "Subgroup" ); - case Symbol: + case Qgis::LegendComponent::Symbol: return QObject::tr( "Symbol" ); - case SymbolLabel: + case Qgis::LegendComponent::SymbolLabel: return QObject::tr( "Symbol label" ); } return QString(); diff --git a/src/core/qgslegendstyle.h b/src/core/qgslegendstyle.h index 8c3fe9cb5d7..911020fb894 100644 --- a/src/core/qgslegendstyle.h +++ b/src/core/qgslegendstyle.h @@ -37,18 +37,6 @@ class CORE_EXPORT QgsLegendStyle { public: - //! Component of legends which can be styled - enum Style - { - 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) - }; - // TODO QGIS 4.0 - use Qt enum instead //! Margin sides @@ -181,19 +169,19 @@ class CORE_EXPORT QgsLegendStyle * \see styleFromName() * \see styleLabel() */ - static QString styleName( Style s ); + static QString styleName( Qgis::LegendComponent s ); /** * Returns the style from name string. * \see styleName() */ - static Style styleFromName( const QString &styleName ); + static Qgis::LegendComponent styleFromName( const QString &styleName ); /** * Returns a translated string representing a style component, for use in UI. * \see styleName() */ - static QString styleLabel( Style s ); + static QString styleLabel( Qgis::LegendComponent s ); private: QgsTextFormat mTextFormat; diff --git a/src/gui/layout/qgslayoutguiutils.cpp b/src/gui/layout/qgslayoutguiutils.cpp index eb0bcd2cfa5..df57e4feb03 100644 --- a/src/gui/layout/qgslayoutguiutils.cpp +++ b/src/gui/layout/qgslayoutguiutils.cpp @@ -251,9 +251,9 @@ void QgsLayoutGuiUtils::registerGuiForKnownItemTypes( QgsMapCanvas *mapCanvas ) { // for right-to-left locales, use an appropriate default layout legend->setSymbolAlignment( Qt::AlignRight ); - legend->rstyle( QgsLegendStyle::Group ).setAlignment( Qt::AlignRight ); - legend->rstyle( QgsLegendStyle::Subgroup ).setAlignment( Qt::AlignRight ); - legend->rstyle( QgsLegendStyle::SymbolLabel ).setAlignment( Qt::AlignRight ); + legend->rstyle( Qgis::LegendComponent::Group ).setAlignment( Qt::AlignRight ); + legend->rstyle( Qgis::LegendComponent::Subgroup ).setAlignment( Qt::AlignRight ); + legend->rstyle( Qgis::LegendComponent::SymbolLabel ).setAlignment( Qt::AlignRight ); legend->setTitleAlignment( Qt::AlignRight ); } @@ -265,21 +265,21 @@ void QgsLayoutGuiUtils::registerGuiForKnownItemTypes( QgsMapCanvas *mapCanvas ) QFont font; QgsFontUtils::setFontFamily( font, defaultFontString ); - QgsTextFormat f = legend->rstyle( QgsLegendStyle::Title ).textFormat(); + QgsTextFormat f = legend->rstyle( Qgis::LegendComponent::Title ).textFormat(); f.setFont( font ); - legend->rstyle( QgsLegendStyle::Title ).setTextFormat( f ); + legend->rstyle( Qgis::LegendComponent::Title ).setTextFormat( f ); - f = legend->rstyle( QgsLegendStyle::Group ).textFormat(); + f = legend->rstyle( Qgis::LegendComponent::Group ).textFormat(); f.setFont( font ); - legend->rstyle( QgsLegendStyle::Group ).setTextFormat( f ); + legend->rstyle( Qgis::LegendComponent::Group ).setTextFormat( f ); - f = legend->rstyle( QgsLegendStyle::Subgroup ).textFormat(); + f = legend->rstyle( Qgis::LegendComponent::Subgroup ).textFormat(); f.setFont( font ); - legend->rstyle( QgsLegendStyle::Subgroup ).setTextFormat( f ); + legend->rstyle( Qgis::LegendComponent::Subgroup ).setTextFormat( f ); - f = legend->rstyle( QgsLegendStyle::SymbolLabel ).textFormat(); + f = legend->rstyle( Qgis::LegendComponent::SymbolLabel ).textFormat(); f.setFont( font ); - legend->rstyle( QgsLegendStyle::SymbolLabel ).setTextFormat( f ); + legend->rstyle( Qgis::LegendComponent::SymbolLabel ).setTextFormat( f ); } legend->updateLegend(); diff --git a/src/gui/layout/qgslayoutlegendwidget.cpp b/src/gui/layout/qgslayoutlegendwidget.cpp index aed33447846..a18a4b6fc27 100644 --- a/src/gui/layout/qgslayoutlegendwidget.cpp +++ b/src/gui/layout/qgslayoutlegendwidget.cpp @@ -262,9 +262,9 @@ void QgsLayoutLegendWidget::setGuiElements() blockAllSignals( true ); mTitleLineEdit->setText( mLegend->title() ); whileBlocking( mTitleAlignCombo )->setCurrentAlignment( mLegend->titleAlignment() ); - whileBlocking( mGroupAlignCombo )->setCurrentAlignment( mLegend->style( QgsLegendStyle::Group ).alignment() ); - whileBlocking( mSubgroupAlignCombo )->setCurrentAlignment( mLegend->style( QgsLegendStyle::Subgroup ).alignment() ); - whileBlocking( mItemAlignCombo )->setCurrentAlignment( mLegend->style( QgsLegendStyle::SymbolLabel ).alignment() ); + whileBlocking( mGroupAlignCombo )->setCurrentAlignment( mLegend->style( Qgis::LegendComponent::Group ).alignment() ); + whileBlocking( mSubgroupAlignCombo )->setCurrentAlignment( mLegend->style( Qgis::LegendComponent::Subgroup ).alignment() ); + whileBlocking( mItemAlignCombo )->setCurrentAlignment( mLegend->style( Qgis::LegendComponent::SymbolLabel ).alignment() ); whileBlocking( mArrangementCombo )->setCurrentAlignment( mLegend->symbolAlignment() ); mFilterByMapCheckBox->setChecked( mLegend->legendFilterByMapEnabled() ); mButtonLinkedMaps->setEnabled( mLegend->legendFilterByMapEnabled() ); @@ -277,19 +277,19 @@ void QgsLayoutLegendWidget::setGuiElements() mMinSymbolSizeSpinBox->setValue( mLegend->minimumSymbolSize() ); mWmsLegendWidthSpinBox->setValue( mLegend->wmsLegendWidth() ); mWmsLegendHeightSpinBox->setValue( mLegend->wmsLegendHeight() ); - mTitleSpaceBottomSpinBox->setValue( mLegend->style( QgsLegendStyle::Title ).margin( QgsLegendStyle::Bottom ) ); - mGroupSpaceSpinBox->setValue( mLegend->style( QgsLegendStyle::Group ).margin( QgsLegendStyle::Top ) ); - mGroupIndentSpinBox->setValue( mLegend->style( QgsLegendStyle::Group ).indent() ); - mSubgroupIndentSpinBox->setValue( mLegend->style( QgsLegendStyle::Subgroup ).indent() ); - mGroupSideSpinBox->setValue( mLegend->style( QgsLegendStyle::Group ).margin( QgsLegendStyle::Left ) ); - mSpaceBelowGroupHeadingSpinBox->setValue( mLegend->style( QgsLegendStyle::Group ).margin( QgsLegendStyle::Bottom ) ); - mLayerSpaceSpinBox->setValue( mLegend->style( QgsLegendStyle::Subgroup ).margin( QgsLegendStyle::Top ) ); - mSpaceBelowSubgroupHeadingSpinBox->setValue( mLegend->style( QgsLegendStyle::Subgroup ).margin( QgsLegendStyle::Bottom ) ); - mSubgroupSideSpinBox->setValue( mLegend->style( QgsLegendStyle::Subgroup ).margin( QgsLegendStyle::Left ) ); + mTitleSpaceBottomSpinBox->setValue( mLegend->style( Qgis::LegendComponent::Title ).margin( QgsLegendStyle::Bottom ) ); + mGroupSpaceSpinBox->setValue( mLegend->style( Qgis::LegendComponent::Group ).margin( QgsLegendStyle::Top ) ); + mGroupIndentSpinBox->setValue( mLegend->style( Qgis::LegendComponent::Group ).indent() ); + mSubgroupIndentSpinBox->setValue( mLegend->style( Qgis::LegendComponent::Subgroup ).indent() ); + mGroupSideSpinBox->setValue( mLegend->style( Qgis::LegendComponent::Group ).margin( QgsLegendStyle::Left ) ); + mSpaceBelowGroupHeadingSpinBox->setValue( mLegend->style( Qgis::LegendComponent::Group ).margin( QgsLegendStyle::Bottom ) ); + mLayerSpaceSpinBox->setValue( mLegend->style( Qgis::LegendComponent::Subgroup ).margin( QgsLegendStyle::Top ) ); + mSpaceBelowSubgroupHeadingSpinBox->setValue( mLegend->style( Qgis::LegendComponent::Subgroup ).margin( QgsLegendStyle::Bottom ) ); + mSubgroupSideSpinBox->setValue( mLegend->style( Qgis::LegendComponent::Subgroup ).margin( QgsLegendStyle::Left ) ); // We keep Symbol and SymbolLabel Top in sync for now - mSymbolSpaceSpinBox->setValue( mLegend->style( QgsLegendStyle::Symbol ).margin( QgsLegendStyle::Top ) ); - mIconLabelSpaceSpinBox->setValue( mLegend->style( QgsLegendStyle::SymbolLabel ).margin( QgsLegendStyle::Left ) ); - mSymbolSideSpaceSpinBox->setValue( mLegend->style( QgsLegendStyle::Symbol ).margin( QgsLegendStyle::Left ) ); + mSymbolSpaceSpinBox->setValue( mLegend->style( Qgis::LegendComponent::Symbol ).margin( QgsLegendStyle::Top ) ); + mIconLabelSpaceSpinBox->setValue( mLegend->style( Qgis::LegendComponent::SymbolLabel ).margin( QgsLegendStyle::Left ) ); + mSymbolSideSpaceSpinBox->setValue( mLegend->style( Qgis::LegendComponent::Symbol ).margin( QgsLegendStyle::Left ) ); mBoxSpaceSpinBox->setValue( mLegend->boxSpace() ); mColumnSpaceSpinBox->setValue( mLegend->columnSpace() ); @@ -305,10 +305,10 @@ void QgsLayoutLegendWidget::setGuiElements() QgsLayoutItemMap *map = mLegend->linkedMap(); mMapComboBox->setItem( map ); - mTitleFontButton->setTextFormat( mLegend->style( QgsLegendStyle::Title ).textFormat() ); - mGroupFontButton->setTextFormat( mLegend->style( QgsLegendStyle::Group ).textFormat() ); - mLayerFontButton->setTextFormat( mLegend->style( QgsLegendStyle::Subgroup ).textFormat() ); - mItemFontButton->setTextFormat( mLegend->style( QgsLegendStyle::SymbolLabel ).textFormat() ); + mTitleFontButton->setTextFormat( mLegend->style( Qgis::LegendComponent::Title ).textFormat() ); + mGroupFontButton->setTextFormat( mLegend->style( Qgis::LegendComponent::Group ).textFormat() ); + mLayerFontButton->setTextFormat( mLegend->style( Qgis::LegendComponent::Subgroup ).textFormat() ); + mItemFontButton->setTextFormat( mLegend->style( Qgis::LegendComponent::SymbolLabel ).textFormat() ); blockAllSignals( false ); @@ -358,7 +358,7 @@ void QgsLayoutLegendWidget::groupAlignmentChanged() if ( mLegend ) { mLegend->beginCommand( tr( "Change Group Alignment" ) ); - mLegend->rstyle( QgsLegendStyle::Group ).setAlignment( mGroupAlignCombo->currentAlignment() ); + mLegend->rstyle( Qgis::LegendComponent::Group ).setAlignment( mGroupAlignCombo->currentAlignment() ); mLegend->update(); mLegend->endCommand(); } @@ -369,7 +369,7 @@ void QgsLayoutLegendWidget::subgroupAlignmentChanged() if ( mLegend ) { mLegend->beginCommand( tr( "Change Subgroup Alignment" ) ); - mLegend->rstyle( QgsLegendStyle::Subgroup ).setAlignment( mSubgroupAlignCombo->currentAlignment() ); + mLegend->rstyle( Qgis::LegendComponent::Subgroup ).setAlignment( mSubgroupAlignCombo->currentAlignment() ); mLegend->update(); mLegend->endCommand(); } @@ -380,7 +380,7 @@ void QgsLayoutLegendWidget::itemAlignmentChanged() if ( mLegend ) { mLegend->beginCommand( tr( "Change Item Alignment" ) ); - mLegend->rstyle( QgsLegendStyle::SymbolLabel ).setAlignment( mItemAlignCombo->currentAlignment() ); + mLegend->rstyle( Qgis::LegendComponent::SymbolLabel ).setAlignment( mItemAlignCombo->currentAlignment() ); mLegend->update(); mLegend->endCommand(); } @@ -513,7 +513,7 @@ void QgsLayoutLegendWidget::mTitleSpaceBottomSpinBox_valueChanged( double d ) if ( mLegend ) { mLegend->beginCommand( tr( "Change Title Space" ), QgsLayoutItem::UndoLegendTitleSpaceBottom ); - mLegend->rstyle( QgsLegendStyle::Title ).setMargin( QgsLegendStyle::Bottom, d ); + mLegend->rstyle( Qgis::LegendComponent::Title ).setMargin( QgsLegendStyle::Bottom, d ); mLegend->adjustBoxSize(); mLegend->update(); mLegend->endCommand(); @@ -525,7 +525,7 @@ void QgsLayoutLegendWidget::mGroupSpaceSpinBox_valueChanged( double d ) if ( mLegend ) { mLegend->beginCommand( tr( "Change Group Space" ), QgsLayoutItem::UndoLegendGroupSpace ); - mLegend->rstyle( QgsLegendStyle::Group ).setMargin( QgsLegendStyle::Top, d ); + mLegend->rstyle( Qgis::LegendComponent::Group ).setMargin( QgsLegendStyle::Top, d ); mLegend->adjustBoxSize(); mLegend->update(); mLegend->endCommand(); @@ -537,7 +537,7 @@ void QgsLayoutLegendWidget::mGroupIndentSpinBox_valueChanged( double d ) if ( mLegend ) { mLegend->beginCommand( tr( "Change Group Indent" ), QgsLayoutItem::UndoLegendGroupIndent ); - mLegend->rstyle( QgsLegendStyle::Group ).setIndent( d ); + mLegend->rstyle( Qgis::LegendComponent::Group ).setIndent( d ); mLegend->adjustBoxSize(); mLegend->update(); mLegend->endCommand(); @@ -549,7 +549,7 @@ void QgsLayoutLegendWidget::mSubgroupIndentSpinBox_valueChanged( double d ) if ( mLegend ) { mLegend->beginCommand( tr( "Change Subgroup Indent" ), QgsLayoutItem::UndoLegendSubgroupIndent ); - mLegend->rstyle( QgsLegendStyle::Subgroup ).setIndent( d ); + mLegend->rstyle( Qgis::LegendComponent::Subgroup ).setIndent( d ); mLegend->adjustBoxSize(); mLegend->update(); mLegend->endCommand(); @@ -561,7 +561,7 @@ void QgsLayoutLegendWidget::spaceBelowGroupHeadingChanged( double space ) if ( mLegend ) { mLegend->beginCommand( tr( "Change Group Space" ), QgsLayoutItem::UndoLegendGroupSpace ); - mLegend->rstyle( QgsLegendStyle::Group ).setMargin( QgsLegendStyle::Bottom, space ); + mLegend->rstyle( Qgis::LegendComponent::Group ).setMargin( QgsLegendStyle::Bottom, space ); mLegend->adjustBoxSize(); mLegend->update(); mLegend->endCommand(); @@ -573,7 +573,7 @@ void QgsLayoutLegendWidget::spaceGroupSideChanged( double space ) if ( mLegend ) { mLegend->beginCommand( tr( "Change Side of Group Space" ), QgsLayoutItem::UndoLegendGroupSpace ); - mLegend->rstyle( QgsLegendStyle::Group ).setMargin( QgsLegendStyle::Left, space ); + mLegend->rstyle( Qgis::LegendComponent::Group ).setMargin( QgsLegendStyle::Left, space ); mLegend->adjustBoxSize(); mLegend->update(); mLegend->endCommand(); @@ -585,7 +585,7 @@ void QgsLayoutLegendWidget::spaceSubGroupSideChanged( double space ) if ( mLegend ) { mLegend->beginCommand( tr( "Change Side of Subgroup Space" ), QgsLayoutItem::UndoLegendLayerSpace ); - mLegend->rstyle( QgsLegendStyle::Subgroup ).setMargin( QgsLegendStyle::Left, space ); + mLegend->rstyle( Qgis::LegendComponent::Subgroup ).setMargin( QgsLegendStyle::Left, space ); mLegend->adjustBoxSize(); mLegend->update(); mLegend->endCommand(); @@ -597,7 +597,7 @@ void QgsLayoutLegendWidget::spaceSymbolSideChanged( double space ) if ( mLegend ) { mLegend->beginCommand( tr( "Change Side of Symbol Space" ), QgsLayoutItem::UndoLegendSymbolSpace ); - mLegend->rstyle( QgsLegendStyle::Symbol ).setMargin( QgsLegendStyle::Left, space ); + mLegend->rstyle( Qgis::LegendComponent::Symbol ).setMargin( QgsLegendStyle::Left, space ); mLegend->adjustBoxSize(); mLegend->update(); mLegend->endCommand(); @@ -609,7 +609,7 @@ void QgsLayoutLegendWidget::mLayerSpaceSpinBox_valueChanged( double d ) if ( mLegend ) { mLegend->beginCommand( tr( "Change Subgroup Space" ), QgsLayoutItem::UndoLegendLayerSpace ); - mLegend->rstyle( QgsLegendStyle::Subgroup ).setMargin( QgsLegendStyle::Top, d ); + mLegend->rstyle( Qgis::LegendComponent::Subgroup ).setMargin( QgsLegendStyle::Top, d ); mLegend->adjustBoxSize(); mLegend->update(); mLegend->endCommand(); @@ -622,8 +622,8 @@ void QgsLayoutLegendWidget::mSymbolSpaceSpinBox_valueChanged( double d ) { mLegend->beginCommand( tr( "Change Symbol Space" ), QgsLayoutItem::UndoLegendSymbolSpace ); // We keep Symbol and SymbolLabel Top in sync for now - mLegend->rstyle( QgsLegendStyle::Symbol ).setMargin( QgsLegendStyle::Top, d ); - mLegend->rstyle( QgsLegendStyle::SymbolLabel ).setMargin( QgsLegendStyle::Top, d ); + mLegend->rstyle( Qgis::LegendComponent::Symbol ).setMargin( QgsLegendStyle::Top, d ); + mLegend->rstyle( Qgis::LegendComponent::SymbolLabel ).setMargin( QgsLegendStyle::Top, d ); mLegend->adjustBoxSize(); mLegend->update(); mLegend->endCommand(); @@ -635,7 +635,7 @@ void QgsLayoutLegendWidget::mIconLabelSpaceSpinBox_valueChanged( double d ) if ( mLegend ) { mLegend->beginCommand( tr( "Change Label Space" ), QgsLayoutItem::UndoLegendIconSymbolSpace ); - mLegend->rstyle( QgsLegendStyle::SymbolLabel ).setMargin( QgsLegendStyle::Left, d ); + mLegend->rstyle( Qgis::LegendComponent::SymbolLabel ).setMargin( QgsLegendStyle::Left, d ); mLegend->adjustBoxSize(); mLegend->update(); mLegend->endCommand(); @@ -647,7 +647,7 @@ void QgsLayoutLegendWidget::titleFontChanged() if ( mLegend ) { mLegend->beginCommand( tr( "Change Title Font" ), QgsLayoutItem::UndoLegendTitleFont ); - mLegend->rstyle( QgsLegendStyle::Title ).setTextFormat( mTitleFontButton->textFormat() ); + mLegend->rstyle( Qgis::LegendComponent::Title ).setTextFormat( mTitleFontButton->textFormat() ); mLegend->adjustBoxSize(); mLegend->update(); mLegend->endCommand(); @@ -659,7 +659,7 @@ void QgsLayoutLegendWidget::groupFontChanged() if ( mLegend ) { mLegend->beginCommand( tr( "Change Group Font" ), QgsLayoutItem::UndoLegendGroupFont ); - mLegend->rstyle( QgsLegendStyle::Group ).setTextFormat( mGroupFontButton->textFormat() ); + mLegend->rstyle( Qgis::LegendComponent::Group ).setTextFormat( mGroupFontButton->textFormat() ); mLegend->adjustBoxSize(); mLegend->update(); mLegend->endCommand(); @@ -671,7 +671,7 @@ void QgsLayoutLegendWidget::layerFontChanged() if ( mLegend ) { mLegend->beginCommand( tr( "Change Layer Font" ), QgsLayoutItem::UndoLegendLayerFont ); - mLegend->rstyle( QgsLegendStyle::Subgroup ).setTextFormat( mLayerFontButton->textFormat() ); + mLegend->rstyle( Qgis::LegendComponent::Subgroup ).setTextFormat( mLayerFontButton->textFormat() ); mLegend->adjustBoxSize(); mLegend->update(); mLegend->endCommand(); @@ -683,7 +683,7 @@ void QgsLayoutLegendWidget::itemFontChanged() if ( mLegend ) { mLegend->beginCommand( tr( "Change Item Font" ), QgsLayoutItem::UndoLegendItemFont ); - mLegend->rstyle( QgsLegendStyle::SymbolLabel ).setTextFormat( mItemFontButton->textFormat() ); + mLegend->rstyle( Qgis::LegendComponent::SymbolLabel ).setTextFormat( mItemFontButton->textFormat() ); mLegend->adjustBoxSize(); mLegend->update(); mLegend->endCommand(); @@ -695,7 +695,7 @@ void QgsLayoutLegendWidget::spaceBelowSubGroupHeadingChanged( double space ) if ( mLegend ) { mLegend->beginCommand( tr( "Change Subgroup Space" ), QgsLayoutItem::UndoLegendLayerSpace ); - mLegend->rstyle( QgsLegendStyle::Subgroup ).setMargin( QgsLegendStyle::Bottom, space ); + mLegend->rstyle( Qgis::LegendComponent::Subgroup ).setMargin( QgsLegendStyle::Bottom, space ); mLegend->adjustBoxSize(); mLegend->update(); mLegend->endCommand(); @@ -1404,7 +1404,7 @@ void QgsLayoutLegendWidget::setCurrentNodeStyleFromAction() if ( !a || !mItemTreeView->currentNode() ) return; - QgsLegendRenderer::setNodeLegendStyle( mItemTreeView->currentNode(), static_cast( a->data().toInt() ) ); + QgsLegendRenderer::setNodeLegendStyle( mItemTreeView->currentNode(), static_cast( a->data().toInt() ) ); mLegend->update(); } @@ -1481,14 +1481,14 @@ QMenu *QgsLayoutLegendMenuProvider::createContextMenu() menu->addSeparator(); } - QgsLegendStyle::Style currentStyle = QgsLegendRenderer::nodeLegendStyle( mView->currentNode(), mView->layerTreeModel() ); + Qgis::LegendComponent currentStyle = QgsLegendRenderer::nodeLegendStyle( mView->currentNode(), mView->layerTreeModel() ); QActionGroup *styleGroup = new QActionGroup { mWidget }; styleGroup->setExclusive( true ); - QList lst; - lst << QgsLegendStyle::Hidden << QgsLegendStyle::Group << QgsLegendStyle::Subgroup; - for ( QgsLegendStyle::Style style : std::as_const( lst ) ) + QList lst; + lst << Qgis::LegendComponent::Hidden << Qgis::LegendComponent::Group << Qgis::LegendComponent::Subgroup; + for ( Qgis::LegendComponent style : std::as_const( lst ) ) { QAction *action = menu->addAction( QgsLegendStyle::styleLabel( style ), mWidget, &QgsLayoutLegendWidget::setCurrentNodeStyleFromAction ); action->setActionGroup( styleGroup ); diff --git a/src/server/services/wms/qgswmsgetlegendgraphics.cpp b/src/server/services/wms/qgswmsgetlegendgraphics.cpp index 48e3bb552be..dbc19e437ea 100644 --- a/src/server/services/wms/qgswmsgetlegendgraphics.cpp +++ b/src/server/services/wms/qgswmsgetlegendgraphics.cpp @@ -293,7 +293,7 @@ namespace QgsWms QgsLayerTreeLayer *nodeLayer = QgsLayerTree::toLayer( node ); // layer titles - hidden or not - QgsLegendRenderer::setNodeLegendStyle( nodeLayer, parameters.layerTitleAsBool() ? QgsLegendStyle::Subgroup : QgsLegendStyle::Hidden ); + QgsLegendRenderer::setNodeLegendStyle( nodeLayer, parameters.layerTitleAsBool() ? Qgis::LegendComponent::Subgroup : Qgis::LegendComponent::Hidden ); // rule item titles if ( !parameters.ruleLabelAsBool() ) { diff --git a/src/server/services/wms/qgswmsparameters.cpp b/src/server/services/wms/qgswmsparameters.cpp index 1a3c1776471..401d93a7001 100644 --- a/src/server/services/wms/qgswmsparameters.cpp +++ b/src/server/services/wms/qgswmsparameters.cpp @@ -1207,19 +1207,19 @@ namespace QgsWms settings.setBoxSpace( boxSpaceAsDouble() ); settings.setSymbolSize( QSizeF( symbolWidthAsDouble(), symbolHeightAsDouble() ) ); - settings.rstyle( QgsLegendStyle::Style::Subgroup ).setMargin( QgsLegendStyle::Side::Top, layerSpaceAsDouble() ); - settings.rstyle( QgsLegendStyle::Style::Subgroup ).setMargin( QgsLegendStyle::Side::Bottom, layerTitleSpaceAsDouble() ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).setMargin( QgsLegendStyle::Side::Top, layerSpaceAsDouble() ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).setMargin( QgsLegendStyle::Side::Bottom, layerTitleSpaceAsDouble() ); // text format must be set before setting the format's colors - settings.rstyle( QgsLegendStyle::Style::Subgroup ).setTextFormat( QgsTextFormat::fromQFont( layerFont() ) ); - settings.rstyle( QgsLegendStyle::Style::SymbolLabel ).setTextFormat( QgsTextFormat::fromQFont( itemFont() ) ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).setTextFormat( QgsTextFormat::fromQFont( layerFont() ) ); + settings.rstyle( Qgis::LegendComponent::SymbolLabel ).setTextFormat( QgsTextFormat::fromQFont( itemFont() ) ); if ( !itemFontColor().isEmpty() ) { - settings.rstyle( QgsLegendStyle::Title ).textFormat().setColor( itemFontColorAsColor() ); - settings.rstyle( QgsLegendStyle::Group ).textFormat().setColor( itemFontColorAsColor() ); - settings.rstyle( QgsLegendStyle::Subgroup ).textFormat().setColor( itemFontColorAsColor() ); - settings.rstyle( QgsLegendStyle::SymbolLabel ).textFormat().setColor( itemFontColorAsColor() ); + settings.rstyle( Qgis::LegendComponent::Title ).textFormat().setColor( itemFontColorAsColor() ); + settings.rstyle( Qgis::LegendComponent::Group ).textFormat().setColor( itemFontColorAsColor() ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).textFormat().setColor( itemFontColorAsColor() ); + settings.rstyle( Qgis::LegendComponent::SymbolLabel ).textFormat().setColor( itemFontColorAsColor() ); } // Ok, this is tricky: because QgsLegendSettings's layerFontColor was added to the API after @@ -1227,11 +1227,11 @@ namespace QgsWms // for the whole legend we need to preserve that behavior. // But, the 2.18 server parameters ITEMFONTCOLOR did not have effect on the layer titles too, so // we set explicitly layerFontColor to black if it's not overridden by LAYERFONTCOLOR argument. - settings.rstyle( QgsLegendStyle::Group ).textFormat().setColor( layerFontColor().isEmpty() ? QColor( Qt::black ) : layerFontColorAsColor() ); - settings.rstyle( QgsLegendStyle::Subgroup ).textFormat().setColor( layerFontColor().isEmpty() ? QColor( Qt::black ) : layerFontColorAsColor() ); + settings.rstyle( Qgis::LegendComponent::Group ).textFormat().setColor( layerFontColor().isEmpty() ? QColor( Qt::black ) : layerFontColorAsColor() ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).textFormat().setColor( layerFontColor().isEmpty() ? QColor( Qt::black ) : layerFontColorAsColor() ); - settings.rstyle( QgsLegendStyle::Style::Symbol ).setMargin( QgsLegendStyle::Side::Top, symbolSpaceAsDouble() ); - settings.rstyle( QgsLegendStyle::Style::SymbolLabel ).setMargin( QgsLegendStyle::Side::Left, iconLabelSpaceAsDouble() ); + settings.rstyle( Qgis::LegendComponent::Symbol ).setMargin( QgsLegendStyle::Side::Top, symbolSpaceAsDouble() ); + settings.rstyle( Qgis::LegendComponent::SymbolLabel ).setMargin( QgsLegendStyle::Side::Left, iconLabelSpaceAsDouble() ); // When processing a request involving an upstream WMS server, any responses from such a remote // server must be awaited. This was not the case for GetLegendGraphic requests (#42063). If not, diff --git a/tests/src/core/testqgslegendrenderer.cpp b/tests/src/core/testqgslegendrenderer.cpp index 45bdcf0e1be..04be8e21ef3 100644 --- a/tests/src/core/testqgslegendrenderer.cpp +++ b/tests/src/core/testqgslegendrenderer.cpp @@ -172,12 +172,12 @@ class TestQgsLegendRenderer : public QgsTest static void setStandardTestFont( QgsLegendSettings &settings, const QString &style = QStringLiteral( "Roman" ) ) { - for ( const QgsLegendStyle::Style st : + for ( const Qgis::LegendComponent st : { - QgsLegendStyle::Title, - QgsLegendStyle::Group, - QgsLegendStyle::Subgroup, - QgsLegendStyle::SymbolLabel + Qgis::LegendComponent::Title, + Qgis::LegendComponent::Group, + Qgis::LegendComponent::Subgroup, + Qgis::LegendComponent::SymbolLabel } ) { QFont font( QgsFontUtils::getStandardTestFont( style ) ); @@ -463,8 +463,8 @@ void TestQgsLegendRenderer::testOverrideSizeSmall() legendModel.refreshLayerLegend( layer ); QgsLegendSettings settings; - settings.rstyle( QgsLegendStyle::Symbol ).setMargin( QgsLegendStyle::Top, 0 ); - settings.rstyle( QgsLegendStyle::Symbol ).setMargin( QgsLegendStyle::Bottom, 0 ); + settings.rstyle( Qgis::LegendComponent::Symbol ).setMargin( QgsLegendStyle::Top, 0 ); + settings.rstyle( Qgis::LegendComponent::Symbol ).setMargin( QgsLegendStyle::Bottom, 0 ); settings.setMinimumSymbolSize( 5 ); settings.setMaximumSymbolSize( 9 ); setStandardTestFont( settings, QStringLiteral( "Bold" ) ); @@ -485,20 +485,20 @@ void TestQgsLegendRenderer::testSpacing() QgsLayerTreeModel legendModel( mRoot ); QgsLegendSettings settings; - settings.rstyle( QgsLegendStyle::Group ).setMargin( QgsLegendStyle::Left, 7 ); - settings.rstyle( QgsLegendStyle::Subgroup ).setMargin( QgsLegendStyle::Left, 11 ); - settings.rstyle( QgsLegendStyle::Symbol ).setMargin( QgsLegendStyle::Left, 5 ); + settings.rstyle( Qgis::LegendComponent::Group ).setMargin( QgsLegendStyle::Left, 7 ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).setMargin( QgsLegendStyle::Left, 11 ); + settings.rstyle( Qgis::LegendComponent::Symbol ).setMargin( QgsLegendStyle::Left, 5 ); setStandardTestFont( settings, QStringLiteral( "Bold" ) ); - settings.rstyle( QgsLegendStyle::Group ).setAlignment( Qt::AlignLeft ); - settings.rstyle( QgsLegendStyle::Subgroup ).setAlignment( Qt::AlignLeft ); - settings.rstyle( QgsLegendStyle::SymbolLabel ).setAlignment( Qt::AlignLeft ); + settings.rstyle( Qgis::LegendComponent::Group ).setAlignment( Qt::AlignLeft ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).setAlignment( Qt::AlignLeft ); + settings.rstyle( Qgis::LegendComponent::SymbolLabel ).setAlignment( Qt::AlignLeft ); QImage res = renderLegend( &legendModel, settings ); QVERIFY( _verifyImage( res, QStringLiteral( "legend_left_align_side_space" ) ) ); - settings.rstyle( QgsLegendStyle::Group ).setAlignment( Qt::AlignRight ); - settings.rstyle( QgsLegendStyle::Subgroup ).setAlignment( Qt::AlignRight ); + settings.rstyle( Qgis::LegendComponent::Group ).setAlignment( Qt::AlignRight ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).setAlignment( Qt::AlignRight ); settings.setSymbolAlignment( Qt::AlignRight ); res = renderLegend( &legendModel, settings ); @@ -648,9 +648,9 @@ void TestQgsLegendRenderer::testCenterAlignText() QgsLayerTreeModel legendModel( mRoot ); QgsLegendSettings settings; - settings.rstyle( QgsLegendStyle::Group ).setAlignment( Qt::AlignHCenter ); - settings.rstyle( QgsLegendStyle::Subgroup ).setAlignment( Qt::AlignHCenter ); - settings.rstyle( QgsLegendStyle::SymbolLabel ).setAlignment( Qt::AlignHCenter ); + settings.rstyle( Qgis::LegendComponent::Group ).setAlignment( Qt::AlignHCenter ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).setAlignment( Qt::AlignHCenter ); + settings.rstyle( Qgis::LegendComponent::SymbolLabel ).setAlignment( Qt::AlignHCenter ); setStandardTestFont( settings, QStringLiteral( "Bold" ) ); QImage res = renderLegend( &legendModel, settings ); @@ -673,9 +673,9 @@ void TestQgsLegendRenderer::testLeftAlignTextRightAlignSymbol() QgsLayerTreeModel legendModel( mRoot ); QgsLegendSettings settings; - settings.rstyle( QgsLegendStyle::Group ).setAlignment( Qt::AlignLeft ); - settings.rstyle( QgsLegendStyle::Subgroup ).setAlignment( Qt::AlignLeft ); - settings.rstyle( QgsLegendStyle::SymbolLabel ).setAlignment( Qt::AlignLeft ); + settings.rstyle( Qgis::LegendComponent::Group ).setAlignment( Qt::AlignLeft ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).setAlignment( Qt::AlignLeft ); + settings.rstyle( Qgis::LegendComponent::SymbolLabel ).setAlignment( Qt::AlignLeft ); settings.setSymbolAlignment( Qt::AlignRight ); setStandardTestFont( settings, QStringLiteral( "Bold" ) ); @@ -699,9 +699,9 @@ void TestQgsLegendRenderer::testCenterAlignTextRightAlignSymbol() QgsLayerTreeModel legendModel( mRoot ); QgsLegendSettings settings; - settings.rstyle( QgsLegendStyle::Group ).setAlignment( Qt::AlignHCenter ); - settings.rstyle( QgsLegendStyle::Subgroup ).setAlignment( Qt::AlignHCenter ); - settings.rstyle( QgsLegendStyle::SymbolLabel ).setAlignment( Qt::AlignHCenter ); + settings.rstyle( Qgis::LegendComponent::Group ).setAlignment( Qt::AlignHCenter ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).setAlignment( Qt::AlignHCenter ); + settings.rstyle( Qgis::LegendComponent::SymbolLabel ).setAlignment( Qt::AlignHCenter ); settings.setSymbolAlignment( Qt::AlignRight ); setStandardTestFont( settings, QStringLiteral( "Bold" ) ); @@ -725,9 +725,9 @@ void TestQgsLegendRenderer::testRightAlignTextRightAlignSymbol() QgsLayerTreeModel legendModel( mRoot ); QgsLegendSettings settings; - settings.rstyle( QgsLegendStyle::Group ).setAlignment( Qt::AlignRight ); - settings.rstyle( QgsLegendStyle::Subgroup ).setAlignment( Qt::AlignRight ); - settings.rstyle( QgsLegendStyle::SymbolLabel ).setAlignment( Qt::AlignRight ); + settings.rstyle( Qgis::LegendComponent::Group ).setAlignment( Qt::AlignRight ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).setAlignment( Qt::AlignRight ); + settings.rstyle( Qgis::LegendComponent::SymbolLabel ).setAlignment( Qt::AlignRight ); settings.setSymbolAlignment( Qt::AlignRight ); setStandardTestFont( settings, QStringLiteral( "Bold" ) ); @@ -753,17 +753,17 @@ void TestQgsLegendRenderer::testDataDefinedTextFormat() QgsLegendSettings settings; setStandardTestFont( settings, QStringLiteral( "Bold" ) ); - QgsTextFormat format = settings.style( QgsLegendStyle::Group ).textFormat(); + QgsTextFormat format = settings.style( Qgis::LegendComponent::Group ).textFormat(); format.dataDefinedProperties().setProperty( QgsPalLayerSettings::Property::Color, QgsProperty::fromExpression( "@text_color_group" ) ); - settings.rstyle( QgsLegendStyle::Group ).setTextFormat( format ); + settings.rstyle( Qgis::LegendComponent::Group ).setTextFormat( format ); - format = settings.style( QgsLegendStyle::Subgroup ).textFormat(); + format = settings.style( Qgis::LegendComponent::Subgroup ).textFormat(); format.dataDefinedProperties().setProperty( QgsPalLayerSettings::Property::Color, QgsProperty::fromExpression( "@text_color_subgroup" ) ); - settings.rstyle( QgsLegendStyle::Subgroup ).setTextFormat( format ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).setTextFormat( format ); - format = settings.style( QgsLegendStyle::SymbolLabel ).textFormat(); + format = settings.style( Qgis::LegendComponent::SymbolLabel ).textFormat(); format.dataDefinedProperties().setProperty( QgsPalLayerSettings::Property::Color, QgsProperty::fromExpression( "@text_color_symbol_label" ) ); - settings.rstyle( QgsLegendStyle::SymbolLabel ).setTextFormat( format ); + settings.rstyle( Qgis::LegendComponent::SymbolLabel ).setTextFormat( format ); QgsExpressionContext context; QgsExpressionContextScope *scope = new QgsExpressionContextScope(); @@ -791,10 +791,10 @@ void TestQgsLegendRenderer::testGroupHeadingSpacing() QgsLayerTreeModel legendModel( mRoot ); QgsLegendSettings settings; - settings.rstyle( QgsLegendStyle::Group ).setMargin( QgsLegendStyle::Top, 5 ); - settings.rstyle( QgsLegendStyle::Group ).setMargin( QgsLegendStyle::Bottom, 17 ); - settings.rstyle( QgsLegendStyle::Subgroup ).setMargin( QgsLegendStyle::Top, 13 ); - settings.rstyle( QgsLegendStyle::Subgroup ).setMargin( QgsLegendStyle::Bottom, 9 ); + settings.rstyle( Qgis::LegendComponent::Group ).setMargin( QgsLegendStyle::Top, 5 ); + settings.rstyle( Qgis::LegendComponent::Group ).setMargin( QgsLegendStyle::Bottom, 17 ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).setMargin( QgsLegendStyle::Top, 13 ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).setMargin( QgsLegendStyle::Bottom, 9 ); settings.setSymbolAlignment( Qt::AlignRight ); setStandardTestFont( settings, QStringLiteral( "Bold" ) ); @@ -829,8 +829,8 @@ void TestQgsLegendRenderer::testGroupIndentDefault() catRenderer->updateCategorySymbol( 0, sym ); QgsLayerTreeModel legendModel( mRoot ); QgsLegendSettings settings; - settings.rstyle( QgsLegendStyle::Group ).setIndent( 10 ); - settings.rstyle( QgsLegendStyle::Subgroup ).setIndent( 5 ); + settings.rstyle( Qgis::LegendComponent::Group ).setIndent( 10 ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).setIndent( 5 ); setStandardTestFont( settings, QStringLiteral( "Bold" ) ); QImage res = renderLegend( &legendModel, settings ); @@ -848,12 +848,12 @@ void TestQgsLegendRenderer::testGroupIndentRT() catRenderer->updateCategorySymbol( 0, sym ); QgsLayerTreeModel legendModel( mRoot ); QgsLegendSettings settings; - settings.rstyle( QgsLegendStyle::Group ).setIndent( 10 ); - settings.rstyle( QgsLegendStyle::Subgroup ).setIndent( 5 ); + settings.rstyle( Qgis::LegendComponent::Group ).setIndent( 10 ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).setIndent( 5 ); setStandardTestFont( settings, QStringLiteral( "Bold" ) ); - settings.rstyle( QgsLegendStyle::Group ).setAlignment( Qt::AlignRight ); - settings.rstyle( QgsLegendStyle::Subgroup ).setAlignment( Qt::AlignRight ); - settings.rstyle( QgsLegendStyle::SymbolLabel ).setAlignment( Qt::AlignRight ); + settings.rstyle( Qgis::LegendComponent::Group ).setAlignment( Qt::AlignRight ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).setAlignment( Qt::AlignRight ); + settings.rstyle( Qgis::LegendComponent::SymbolLabel ).setAlignment( Qt::AlignRight ); QImage res = renderLegend( &legendModel, settings ); QVERIFY( _verifyImage( res, QStringLiteral( "legend_group_indent_right_align_text" ) ) ); @@ -870,12 +870,12 @@ void TestQgsLegendRenderer::testGroupIndentRS() catRenderer->updateCategorySymbol( 0, sym ); QgsLayerTreeModel legendModel( mRoot ); QgsLegendSettings settings; - settings.rstyle( QgsLegendStyle::Group ).setIndent( 10 ); - settings.rstyle( QgsLegendStyle::Subgroup ).setIndent( 5 ); + settings.rstyle( Qgis::LegendComponent::Group ).setIndent( 10 ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).setIndent( 5 ); setStandardTestFont( settings, QStringLiteral( "Bold" ) ); - settings.rstyle( QgsLegendStyle::Group ).setAlignment( Qt::AlignLeft ); - settings.rstyle( QgsLegendStyle::Subgroup ).setAlignment( Qt::AlignLeft ); - settings.rstyle( QgsLegendStyle::SymbolLabel ).setAlignment( Qt::AlignLeft ); + settings.rstyle( Qgis::LegendComponent::Group ).setAlignment( Qt::AlignLeft ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).setAlignment( Qt::AlignLeft ); + settings.rstyle( Qgis::LegendComponent::SymbolLabel ).setAlignment( Qt::AlignLeft ); settings.setSymbolAlignment( Qt::AlignRight ); QImage res = renderLegend( &legendModel, settings ); @@ -893,12 +893,12 @@ void TestQgsLegendRenderer::testGroupIndentRSRT() catRenderer->updateCategorySymbol( 0, sym ); QgsLayerTreeModel legendModel( mRoot ); QgsLegendSettings settings; - settings.rstyle( QgsLegendStyle::Group ).setIndent( 10 ); - settings.rstyle( QgsLegendStyle::Subgroup ).setIndent( 5 ); + settings.rstyle( Qgis::LegendComponent::Group ).setIndent( 10 ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).setIndent( 5 ); setStandardTestFont( settings, QStringLiteral( "Bold" ) ); - settings.rstyle( QgsLegendStyle::Group ).setAlignment( Qt::AlignRight ); - settings.rstyle( QgsLegendStyle::Subgroup ).setAlignment( Qt::AlignRight ); - settings.rstyle( QgsLegendStyle::SymbolLabel ).setAlignment( Qt::AlignRight ); + settings.rstyle( Qgis::LegendComponent::Group ).setAlignment( Qt::AlignRight ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).setAlignment( Qt::AlignRight ); + settings.rstyle( Qgis::LegendComponent::SymbolLabel ).setAlignment( Qt::AlignRight ); settings.setSymbolAlignment( Qt::AlignRight ); QImage res = renderLegend( &legendModel, settings ); @@ -916,9 +916,9 @@ void TestQgsLegendRenderer::testRightAlignText() QgsLayerTreeModel legendModel( mRoot ); QgsLegendSettings settings; - settings.rstyle( QgsLegendStyle::Group ).setAlignment( Qt::AlignRight ); - settings.rstyle( QgsLegendStyle::Subgroup ).setAlignment( Qt::AlignRight ); - settings.rstyle( QgsLegendStyle::SymbolLabel ).setAlignment( Qt::AlignRight ); + settings.rstyle( Qgis::LegendComponent::Group ).setAlignment( Qt::AlignRight ); + settings.rstyle( Qgis::LegendComponent::Subgroup ).setAlignment( Qt::AlignRight ); + settings.rstyle( Qgis::LegendComponent::SymbolLabel ).setAlignment( Qt::AlignRight ); setStandardTestFont( settings, QStringLiteral( "Bold" ) ); QImage res = renderLegend( &legendModel, settings ); @@ -1158,7 +1158,7 @@ bool TestQgsLegendRenderer::_testLegendColumns( int itemCount, int columnCount, QgsLayerTreeModel legendModel( root.get() ); QgsLegendSettings settings; settings.setColumnCount( columnCount ); - settings.rstyle( QgsLegendStyle::Style::Symbol ).setMargin( QgsLegendStyle::Side::Top, symbolSpacing ); + settings.rstyle( Qgis::LegendComponent::Symbol ).setMargin( QgsLegendStyle::Side::Top, symbolSpacing ); setStandardTestFont( settings, QStringLiteral( "Bold" ) ); const QImage res = renderLegend( &legendModel, settings ); const bool result = _verifyImage( res, testName ); @@ -1983,7 +1983,7 @@ void TestQgsLegendRenderer::testColumnsMixedSymbolSize() QgsLayerTreeModel legendModel( root.get() ); QgsLegendSettings settings; settings.setColumnCount( 2 ); - settings.rstyle( QgsLegendStyle::Style::Symbol ).setMargin( QgsLegendStyle::Side::Top, 9 ); + settings.rstyle( Qgis::LegendComponent::Symbol ).setMargin( QgsLegendStyle::Side::Top, 9 ); setStandardTestFont( settings, QStringLiteral( "Bold" ) ); const QImage res = renderLegend( &legendModel, settings ); @@ -2204,7 +2204,7 @@ void TestQgsLegendRenderer::testHeatmap() QgsLayerTreeModel legendModel( root.get() ); QgsLegendSettings settings; - settings.rstyle( QgsLegendStyle::Style::Symbol ).setMargin( QgsLegendStyle::Side::Top, 9 ); + settings.rstyle( Qgis::LegendComponent::Symbol ).setMargin( QgsLegendStyle::Side::Top, 9 ); setStandardTestFont( settings, QStringLiteral( "Bold" ) ); const QImage res = renderLegend( &legendModel, settings );