Skip to content
Permalink
Browse files
Nicer initialization of diagram property map
  • Loading branch information
nyalldawson committed Jan 23, 2017
1 parent 746034b commit 1e0c62bc3a081feffaf500018dbfd809576c0a5f
Showing with 18 additions and 32 deletions.
  1. +16 −28 src/core/qgsdiagramrenderer.cpp
  2. +2 −4 src/core/qgsdiagramrenderer.h
@@ -25,12 +25,21 @@
#include <QDomElement>
#include <QPainter>

QMap< int, QString > QgsDiagramLayerSettings::sPropertyNameMap;

QgsDiagramLayerSettings::QgsDiagramLayerSettings()
{
init();
}
const QMap< int, QString > QgsDiagramLayerSettings::sPropertyNameMap
{
{ QgsDiagramLayerSettings::BackgroundColor, "backgroundColor" },
{ QgsDiagramLayerSettings::OutlineColor, "outlineColor" },
{ QgsDiagramLayerSettings::OutlineWidth, "outlineWidth" },
{ QgsDiagramLayerSettings::PositionX, "positionX" },
{ QgsDiagramLayerSettings::PositionY, "positionY" },
{ QgsDiagramLayerSettings::Distance, "distance" },
{ QgsDiagramLayerSettings::Priority, "priority" },
{ QgsDiagramLayerSettings::ZIndex, "zIndex" },
{ QgsDiagramLayerSettings::IsObstacle, "isObstacle" },
{ QgsDiagramLayerSettings::Show, "show" },
{ QgsDiagramLayerSettings::AlwaysShow, "alwaysShow" },
{ QgsDiagramLayerSettings::StartAngle, "startAngle" }
};

QgsDiagramLayerSettings::QgsDiagramLayerSettings( const QgsDiagramLayerSettings& rh )
: mCt( rh.mCt )
@@ -43,9 +52,7 @@ QgsDiagramLayerSettings::QgsDiagramLayerSettings( const QgsDiagramLayerSettings&
, mRenderer( rh.mRenderer ? rh.mRenderer->clone() : nullptr )
, mShowAll( rh.mShowAll )
, mProperties( rh.mProperties )
{
init();
}
{}

QgsDiagramLayerSettings&QgsDiagramLayerSettings::operator=( const QgsDiagramLayerSettings & rh )
{
@@ -148,25 +155,6 @@ bool QgsDiagramLayerSettings::prepare( const QgsExpressionContext& context ) con
return mProperties.prepare( context );
}

void QgsDiagramLayerSettings::init()
{
if ( sPropertyNameMap.isEmpty() )
{
sPropertyNameMap.insert( BackgroundColor, "backgroundColor" );
sPropertyNameMap.insert( OutlineColor, "outlineColor" );
sPropertyNameMap.insert( OutlineWidth, "outlineWidth" );
sPropertyNameMap.insert( PositionX, "positionX" );
sPropertyNameMap.insert( PositionY, "positionY" );
sPropertyNameMap.insert( Distance, "distance" );
sPropertyNameMap.insert( Priority, "priority" );
sPropertyNameMap.insert( ZIndex, "zIndex" );
sPropertyNameMap.insert( IsObstacle, "isObstacle" );
sPropertyNameMap.insert( Show, "show" );
sPropertyNameMap.insert( AlwaysShow, "alwaysShow" );
sPropertyNameMap.insert( StartAngle, "startAngle" );
}
}

QSet<QString> QgsDiagramLayerSettings::referencedFields( const QgsExpressionContext &context ) const
{
QSet< QString > referenced;
@@ -95,7 +95,7 @@ class CORE_EXPORT QgsDiagramLayerSettings
StartAngle, //! Angle offset for pie diagram
};

QgsDiagramLayerSettings();
QgsDiagramLayerSettings() = default;

//! Copy constructor
QgsDiagramLayerSettings( const QgsDiagramLayerSettings& rh );
@@ -308,9 +308,7 @@ class CORE_EXPORT QgsDiagramLayerSettings
//! Property collection for data defined diagram settings
QgsPropertyCollection mProperties;

static QMap< int, QString > sPropertyNameMap;

void init();
static const QMap< int, QString > sPropertyNameMap;
};

/** \ingroup core

0 comments on commit 1e0c62b

Please sign in to comment.