Skip to content

Commit

Permalink
avoid forward declaration of QgsDataDefinedSizeLegend (fixes windows …
Browse files Browse the repository at this point in the history
…build)
  • Loading branch information
jef-n committed Jun 25, 2017
1 parent d79b18f commit 1c1e771
Show file tree
Hide file tree
Showing 6 changed files with 31 additions and 13 deletions.
5 changes: 5 additions & 0 deletions src/core/layertree/qgslayertreemodellegendnode.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -729,6 +729,11 @@ QgsDataDefinedSizeLegendNode::QgsDataDefinedSizeLegendNode( QgsLayerTreeLayer *n
{
}

QgsDataDefinedSizeLegendNode::~QgsDataDefinedSizeLegendNode()
{
delete mSettings;
}

QVariant QgsDataDefinedSizeLegendNode::data( int role ) const
{
if ( role == Qt::DecorationRole )
Expand Down
4 changes: 2 additions & 2 deletions src/core/layertree/qgslayertreemodellegendnode.h
Original file line number Diff line number Diff line change
Expand Up @@ -391,15 +391,15 @@ class CORE_EXPORT QgsDataDefinedSizeLegendNode : public QgsLayerTreeModelLegendN
public:
//! Construct the node using QgsDataDefinedSizeLegend as definition of the node's appearance
QgsDataDefinedSizeLegendNode( QgsLayerTreeLayer *nodeLayer, const QgsDataDefinedSizeLegend &settings, QObject *parent SIP_TRANSFERTHIS = nullptr );
~QgsDataDefinedSizeLegendNode();

virtual QVariant data( int role ) const override;

ItemMetrics draw( const QgsLegendSettings &settings, ItemContext *ctx ) override;

private:
void cacheImage() const;

std::unique_ptr<QgsDataDefinedSizeLegend> mSettings;
QgsDataDefinedSizeLegend *mSettings = nullptr;
mutable QImage mImage;
};

Expand Down
18 changes: 13 additions & 5 deletions src/core/qgsdiagramrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -613,6 +613,11 @@ QgsLinearlyInterpolatedDiagramRenderer::QgsLinearlyInterpolatedDiagramRenderer(
{
}

QgsLinearlyInterpolatedDiagramRenderer::~QgsLinearlyInterpolatedDiagramRenderer()
{
delete mDataDefinedSizeLegend;
}

QgsLinearlyInterpolatedDiagramRenderer *QgsLinearlyInterpolatedDiagramRenderer::clone() const
{
return new QgsLinearlyInterpolatedDiagramRenderer( *this );
Expand Down Expand Up @@ -683,17 +688,19 @@ void QgsLinearlyInterpolatedDiagramRenderer::readXml( const QDomElement &elem, c
mSettings.readXml( settingsElem );
}

delete mDataDefinedSizeLegend;

QDomElement ddsLegendSizeElem = elem.firstChildElement( "data-defined-size-legend" );
if ( !ddsLegendSizeElem.isNull() )
{
mDataDefinedSizeLegend.reset( QgsDataDefinedSizeLegend::readXml( ddsLegendSizeElem, context ) );
mDataDefinedSizeLegend = QgsDataDefinedSizeLegend::readXml( ddsLegendSizeElem, context );
}
else
{
// pre-3.0 projects
if ( elem.attribute( QStringLiteral( "sizeLegend" ), QStringLiteral( "0" ) ) != QLatin1String( "0" ) )
{
mDataDefinedSizeLegend.reset( new QgsDataDefinedSizeLegend() );
mDataDefinedSizeLegend = new QgsDataDefinedSizeLegend();
QDomElement sizeLegendSymbolElem = elem.firstChildElement( QStringLiteral( "symbol" ) );
if ( !sizeLegendSymbolElem.isNull() && sizeLegendSymbolElem.attribute( QStringLiteral( "name" ) ) == QLatin1String( "sizeSymbol" ) )
{
Expand All @@ -702,7 +709,7 @@ void QgsLinearlyInterpolatedDiagramRenderer::readXml( const QDomElement &elem, c
}
else
{
mDataDefinedSizeLegend.reset( nullptr );
mDataDefinedSizeLegend = nullptr;
}
}

Expand Down Expand Up @@ -808,10 +815,11 @@ QList< QgsLayerTreeModelLegendNode * > QgsLinearlyInterpolatedDiagramRenderer::l

void QgsLinearlyInterpolatedDiagramRenderer::setDataDefinedSizeLegend( QgsDataDefinedSizeLegend *settings )
{
mDataDefinedSizeLegend.reset( settings );
delete settings;
mDataDefinedSizeLegend = settings;
}

QgsDataDefinedSizeLegend *QgsLinearlyInterpolatedDiagramRenderer::dataDefinedSizeLegend() const
{
return mDataDefinedSizeLegend.get();
return mDataDefinedSizeLegend;
}
3 changes: 2 additions & 1 deletion src/core/qgsdiagramrenderer.h
Original file line number Diff line number Diff line change
Expand Up @@ -646,6 +646,7 @@ class CORE_EXPORT QgsLinearlyInterpolatedDiagramRenderer : public QgsDiagramRend
{
public:
QgsLinearlyInterpolatedDiagramRenderer();
~QgsLinearlyInterpolatedDiagramRenderer();

QgsLinearlyInterpolatedDiagramRenderer *clone() const override SIP_FACTORY;

Expand Down Expand Up @@ -722,7 +723,7 @@ class CORE_EXPORT QgsLinearlyInterpolatedDiagramRenderer : public QgsDiagramRend
QgsDiagramInterpolationSettings mInterpolationSettings;

//! Stores more settings about how legend for varying size of symbols should be rendered
std::unique_ptr<QgsDataDefinedSizeLegend> mDataDefinedSizeLegend;
QgsDataDefinedSizeLegend *mDataDefinedSizeLegend = nullptr;
};

#endif // QGSDIAGRAMRENDERERV2_H
9 changes: 6 additions & 3 deletions src/core/symbology-ng/qgslegendsymbolitem.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ QgsLegendSymbolItem::QgsLegendSymbolItem( const QgsLegendSymbolItem &other )
QgsLegendSymbolItem::~QgsLegendSymbolItem()
{
delete mSymbol;
delete mDataDefinedSizeLegendSettings;
}

QgsLegendSymbolItem &QgsLegendSymbolItem::operator=( const QgsLegendSymbolItem &other )
Expand All @@ -62,7 +63,8 @@ QgsLegendSymbolItem &QgsLegendSymbolItem::operator=( const QgsLegendSymbolItem &
mLabel = other.mLabel;
mKey = other.mKey;
mCheckable = other.mCheckable;
mDataDefinedSizeLegendSettings.reset( other.mDataDefinedSizeLegendSettings.get() ? new QgsDataDefinedSizeLegend( *other.mDataDefinedSizeLegendSettings.get() ) : nullptr );
delete mDataDefinedSizeLegendSettings;
mDataDefinedSizeLegendSettings = other.mDataDefinedSizeLegendSettings ? new QgsDataDefinedSizeLegend( *other.mDataDefinedSizeLegendSettings ) : nullptr;
mOriginalSymbolPointer = other.mOriginalSymbolPointer;
mScaleMinDenom = other.mScaleMinDenom;
mScaleMaxDenom = other.mScaleMaxDenom;
Expand Down Expand Up @@ -94,10 +96,11 @@ void QgsLegendSymbolItem::setSymbol( QgsSymbol *s )

void QgsLegendSymbolItem::setDataDefinedSizeLegendSettings( QgsDataDefinedSizeLegend *settings )
{
mDataDefinedSizeLegendSettings.reset( settings );
delete settings;
mDataDefinedSizeLegendSettings = settings;
}

QgsDataDefinedSizeLegend *QgsLegendSymbolItem::dataDefinedSizeLegendSettings() const
{
return mDataDefinedSizeLegendSettings.get();
return mDataDefinedSizeLegendSettings;
}
5 changes: 3 additions & 2 deletions src/core/symbology-ng/qgslegendsymbolitem.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,8 +18,8 @@

#include <memory>
#include <QString>
#include "qgis.h"

#include "qgis.h"
#include "qgis_core.h"

class QgsDataDefinedSizeLegend;
Expand All @@ -40,6 +40,7 @@ class CORE_EXPORT QgsLegendSymbolItem
//! \since QGIS 2.8
QgsLegendSymbolItem( QgsSymbol *symbol, const QString &label, const QString &ruleKey, bool checkable = false, int scaleMinDenom = -1, int scaleMaxDenom = -1, int level = 0, const QString &parentRuleKey = QString() );
~QgsLegendSymbolItem();

QgsLegendSymbolItem( const QgsLegendSymbolItem &other );
QgsLegendSymbolItem &operator=( const QgsLegendSymbolItem &other );

Expand Down Expand Up @@ -103,7 +104,7 @@ class CORE_EXPORT QgsLegendSymbolItem

//! optional pointer to data-defined legend size settings - if set, the output legend
//! node should be QgsDataDefinedSizeLegendNode rather than ordinary QgsSymbolLegendNode
std::unique_ptr<QgsDataDefinedSizeLegend> mDataDefinedSizeLegendSettings;
QgsDataDefinedSizeLegend *mDataDefinedSizeLegendSettings = nullptr;

// additional data that may be used for filtering

Expand Down

0 comments on commit 1c1e771

Please sign in to comment.