Skip to content
Permalink
Browse files

Fix deprecation warning

  • Loading branch information
nyalldawson committed Mar 22, 2020
1 parent a0af783 commit 1e3e205a9856a137aa580e8d678bd7f45e82ec96
@@ -39,7 +39,8 @@ Constructor for QgsNumericScaleBarRenderer.
const QgsScaleBarSettings &settings,
const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const;

virtual QSizeF calculateBoxSize( const QgsScaleBarSettings &settings,
virtual QSizeF calculateBoxSize( QgsRenderContext &context,
const QgsScaleBarSettings &settings,
const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const;

};
@@ -78,7 +78,7 @@ void QgsNumericScaleBarRenderer::draw( QgsRenderContext &context, const QgsScale
painter->restore();
}

QSizeF QgsNumericScaleBarRenderer::calculateBoxSize( const QgsScaleBarSettings &settings,
QSizeF QgsNumericScaleBarRenderer::calculateBoxSize( QgsRenderContext &, const QgsScaleBarSettings &settings,
const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const
{
QFont font = settings.textFormat().toQFont();
@@ -90,6 +90,17 @@ QSizeF QgsNumericScaleBarRenderer::calculateBoxSize( const QgsScaleBarSettings &
textHeight + 2 * settings.boxContentSpace() );
}

QSizeF QgsNumericScaleBarRenderer::calculateBoxSize( const QgsScaleBarSettings &settings, const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const
{
QFont font = settings.textFormat().toQFont();

double textWidth = QgsLayoutUtils::textWidthMM( font, scaleText( scaleContext.scale, settings ) );
double textHeight = QgsLayoutUtils::fontAscentMM( font );

return QSizeF( 2 * settings.boxContentSpace() + textWidth,
textHeight + 2 * settings.boxContentSpace() );
}

QString QgsNumericScaleBarRenderer::scaleText( double scale, const QgsScaleBarSettings &settings ) const
{
return "1:" + settings.numericFormat()->formatDouble( scale, QgsNumericFormatContext() );
@@ -45,7 +45,8 @@ class CORE_EXPORT QgsNumericScaleBarRenderer: public QgsScaleBarRenderer
const QgsScaleBarSettings &settings,
const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const override;

QSizeF calculateBoxSize( const QgsScaleBarSettings &settings,
QSizeF calculateBoxSize( QgsRenderContext &context,
const QgsScaleBarSettings &settings,
const QgsScaleBarRenderer::ScaleBarContext &scaleContext ) const override;

private:

0 comments on commit 1e3e205

Please sign in to comment.
You can’t perform that action at this time.