Skip to content

Commit

Permalink
Spelling and documentation
Browse files Browse the repository at this point in the history
  • Loading branch information
mhugent committed May 7, 2021
1 parent 8da3d11 commit fc2a0d6
Show file tree
Hide file tree
Showing 5 changed files with 57 additions and 6 deletions.
Expand Up @@ -677,18 +677,42 @@ Produces legend node for a labeling text symbol
#include "qgslayertreemodellegendnode.h"
%End
public:

QgsVectorLabelLegendNode( QgsLayerTreeLayer *nodeLayer, const QgsPalLayerSettings &labelSettings, QObject *parent = 0 );
%Docstring
QgsVectorLabelLegendNode
@param nodeLayer the parent node
@param labelSettings setting of the label class
@param parent the parent object
%End
~QgsVectorLabelLegendNode();

virtual QVariant data( int role ) const;

%Docstring
Returns data associated with the item.
data Returns data associated with the item
@param role the data role
@return variant containing the data for the role
%End

virtual QSizeF drawSymbol( const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight ) const;

%Docstring
drawSymbol
@param settings the legend settings
@param ctx context for the item
@param itemHeight the height of the item
@return size of the item
%End

virtual QJsonObject exportSymbolToJson( const QgsLegendSettings &settings, const QgsRenderContext &context ) const;

%Docstring
exportSymbolToJson
@param settings the legend settings
@param context the item context
@return the json object
%End

};

Expand Down
2 changes: 1 addition & 1 deletion python/core/auto_generated/qgsmaplayerlegend.sip.in
Expand Up @@ -263,7 +263,7 @@ by :py:func:`~QgsDefaultVectorLayerLegend.textOnSymbolContent` and :py:func:`~Qg

bool showLabelLegend() const;
%Docstring
Returns wether the legend for the labeling is shown
Returns whether the legend for the labeling is shown

.. versionadded:: 3.20
%End
Expand Down
5 changes: 3 additions & 2 deletions src/core/layertree/qgslayertreemodellegendnode.cpp
Expand Up @@ -1480,13 +1480,14 @@ QSizeF QgsVectorLabelLegendNode::drawSymbol( const QgsLegendSettings &settings,
p->setPen( textColor );
settings.drawText( p, xOffset + settings.symbolSize().width() / 2.0 - textWidth / 2.0, yOffset + settings.symbolSize().height() / 2.0 + textHeight / 2.0, "Aa", f );
}
double symbolWidth = qMax( textWidth, settings.symbolSize().width() );
double symbolHeight = qMax( textHeight, settings.symbolSize().height() );
double symbolWidth = std::max( textWidth, settings.symbolSize().width() );
double symbolHeight = std::max( textHeight, settings.symbolSize().height() );
return QSizeF( symbolWidth, symbolHeight );
}

QJsonObject QgsVectorLabelLegendNode::exportSymbolToJson( const QgsLegendSettings &settings, const QgsRenderContext &context ) const
{
Q_UNUSED( context );
QColor textColor;
QFont f = font( textColor );

Expand Down
28 changes: 27 additions & 1 deletion src/core/layertree/qgslayertreemodellegendnode.h
Expand Up @@ -731,12 +731,38 @@ class CORE_EXPORT QgsDataDefinedSizeLegendNode : public QgsLayerTreeModelLegendN
class CORE_EXPORT QgsVectorLabelLegendNode : public QgsLayerTreeModelLegendNode
{
public:

/**
* @brief QgsVectorLabelLegendNode
* @param nodeLayer the parent node
* @param labelSettings setting of the label class
* @param parent the parent object
*/
QgsVectorLabelLegendNode( QgsLayerTreeLayer *nodeLayer, const QgsPalLayerSettings &labelSettings, QObject *parent = 0 );
~QgsVectorLabelLegendNode() override;

//! Returns data associated with the item.
/**
* @brief data Returns data associated with the item
* @param role the data role
* @return variant containing the data for the role
*/
QVariant data( int role ) const override;

/**
* @brief drawSymbol
* @param settings the legend settings
* @param ctx context for the item
* @param itemHeight the height of the item
* @return size of the item
*/
QSizeF drawSymbol( const QgsLegendSettings &settings, ItemContext *ctx, double itemHeight ) const override;

/**
* @brief exportSymbolToJson
* @param settings the legend settings
* @param context the item context
* @return the json object
*/
QJsonObject exportSymbolToJson( const QgsLegendSettings &settings, const QgsRenderContext &context ) const override;

private:
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsmaplayerlegend.h
Expand Up @@ -257,7 +257,7 @@ class CORE_EXPORT QgsDefaultVectorLayerLegend : public QgsMapLayerLegend
void setTextOnSymbolEnabled( bool enabled ) { mTextOnSymbolEnabled = enabled; }

/**
* Returns wether the legend for the labeling is shown
* Returns whether the legend for the labeling is shown
* \since QGIS 3.20
*/
bool showLabelLegend() const { return mShowLabelLegend; }
Expand Down

0 comments on commit fc2a0d6

Please sign in to comment.