Skip to content

Commit

Permalink
Add an origin (PAL or Diagram) to QgsProperty
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Oct 9, 2017
1 parent 37783f7 commit fa4777e
Show file tree
Hide file tree
Showing 4 changed files with 50 additions and 18 deletions.
18 changes: 16 additions & 2 deletions python/core/qgsproperty.sip
Original file line number Diff line number Diff line change
Expand Up @@ -67,27 +67,35 @@ class QgsPropertyDefinition
DataTypeBoolean,
};

enum Origin
{
Diagram,
Pal
};

QgsPropertyDefinition();
%Docstring
Constructs an empty property.
%End

QgsPropertyDefinition( const QString &name, const QString &description, StandardPropertyTemplate type );
QgsPropertyDefinition( const QString &name, const QString &description, StandardPropertyTemplate type, Origin origin = QgsPropertyDefinition::Pal );
%Docstring
Constructor for QgsPropertyDefinition, using a standard property template.
\param name is used internally and should be a unique, alphanumeric string.
\param description can be any localised string describing what the property is used for.
\param type one of the predefined standard property template
\param origin The origin of the property
%End

QgsPropertyDefinition( const QString &name, DataType dataType, const QString &description, const QString &helpText );
QgsPropertyDefinition( const QString &name, DataType dataType, const QString &description, const QString &helpText, Origin origin = QgsPropertyDefinition::Pal );
%Docstring
Constructor for custom QgsPropertyDefinitions.
\param name is used internally and should be a unique, alphanumeric string.
\param dataType the data type for the property
\param description can be any localised string describing what the property is used for.
\param helpText parameter should specify a descriptive string for users outlining the types
of value acceptable by the property (eg 'dashed' or 'solid' for a line style property).
\param origin The origin of the property
%End

QString name() const;
Expand All @@ -96,6 +104,12 @@ class QgsPropertyDefinition
:rtype: str
%End

Origin origin() const;
%Docstring
Returns the origin of the property
:rtype: Origin
%End

QString description() const;
%Docstring
Descriptive name of the property.
Expand Down
26 changes: 14 additions & 12 deletions src/core/qgsdiagramrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,20 +34,22 @@ void QgsDiagramLayerSettings::initPropertyDefinitions()
if ( !sPropertyDefinitions.isEmpty() )
return;

QgsPropertyDefinition::Origin origin = QgsPropertyDefinition::Diagram;

sPropertyDefinitions = QgsPropertiesDefinition
{
{ QgsDiagramLayerSettings::BackgroundColor, QgsPropertyDefinition( "backgroundColor", QObject::tr( "Background color" ), QgsPropertyDefinition::ColorWithAlpha ) },
{ QgsDiagramLayerSettings::StrokeColor, QgsPropertyDefinition( "strokeColor", QObject::tr( "Stroke color" ), QgsPropertyDefinition::ColorWithAlpha ) },
{ QgsDiagramLayerSettings::StrokeWidth, QgsPropertyDefinition( "strokeWidth", QObject::tr( "Stroke width" ), QgsPropertyDefinition::StrokeWidth ) },
{ QgsDiagramLayerSettings::PositionX, QgsPropertyDefinition( "positionX", QObject::tr( "Position (X)" ), QgsPropertyDefinition::Double ) },
{ QgsDiagramLayerSettings::PositionY, QgsPropertyDefinition( "positionY", QObject::tr( "Position (Y)" ), QgsPropertyDefinition::Double ) },
{ QgsDiagramLayerSettings::Distance, QgsPropertyDefinition( "distance", QObject::tr( "Placement distance" ), QgsPropertyDefinition::DoublePositive ) },
{ QgsDiagramLayerSettings::Priority, QgsPropertyDefinition( "priority", QObject::tr( "Placement priority" ), QgsPropertyDefinition::DoublePositive ) },
{ QgsDiagramLayerSettings::ZIndex, QgsPropertyDefinition( "zIndex", QObject::tr( "Placement z-index" ), QgsPropertyDefinition::Double ) },
{ QgsDiagramLayerSettings::IsObstacle, QgsPropertyDefinition( "isObstacle", QObject::tr( "Diagram is an obstacle" ), QgsPropertyDefinition::Boolean ) },
{ QgsDiagramLayerSettings::Show, QgsPropertyDefinition( "show", QObject::tr( "Show diagram" ), QgsPropertyDefinition::Boolean ) },
{ QgsDiagramLayerSettings::AlwaysShow, QgsPropertyDefinition( "alwaysShow", QObject::tr( "Always show diagram" ), QgsPropertyDefinition::Boolean ) },
{ QgsDiagramLayerSettings::StartAngle, QgsPropertyDefinition( "startAngle", QObject::tr( "Pie chart start angle" ), QgsPropertyDefinition::Rotation ) },
{ QgsDiagramLayerSettings::BackgroundColor, QgsPropertyDefinition( "backgroundColor", QObject::tr( "Background color" ), QgsPropertyDefinition::ColorWithAlpha, origin ) },
{ QgsDiagramLayerSettings::StrokeColor, QgsPropertyDefinition( "strokeColor", QObject::tr( "Stroke color" ), QgsPropertyDefinition::ColorWithAlpha, origin ) },
{ QgsDiagramLayerSettings::StrokeWidth, QgsPropertyDefinition( "strokeWidth", QObject::tr( "Stroke width" ), QgsPropertyDefinition::StrokeWidth, origin ) },
{ QgsDiagramLayerSettings::PositionX, QgsPropertyDefinition( "positionX", QObject::tr( "Position (X)" ), QgsPropertyDefinition::Double, origin ) },
{ QgsDiagramLayerSettings::PositionY, QgsPropertyDefinition( "positionY", QObject::tr( "Position (Y)" ), QgsPropertyDefinition::Double, origin ) },
{ QgsDiagramLayerSettings::Distance, QgsPropertyDefinition( "distance", QObject::tr( "Placement distance" ), QgsPropertyDefinition::DoublePositive, origin ) },
{ QgsDiagramLayerSettings::Priority, QgsPropertyDefinition( "priority", QObject::tr( "Placement priority" ), QgsPropertyDefinition::DoublePositive, origin ) },
{ QgsDiagramLayerSettings::ZIndex, QgsPropertyDefinition( "zIndex", QObject::tr( "Placement z-index" ), QgsPropertyDefinition::Double, origin ) },
{ QgsDiagramLayerSettings::IsObstacle, QgsPropertyDefinition( "isObstacle", QObject::tr( "Diagram is an obstacle" ), QgsPropertyDefinition::Boolean, origin ) },
{ QgsDiagramLayerSettings::Show, QgsPropertyDefinition( "show", QObject::tr( "Show diagram" ), QgsPropertyDefinition::Boolean, origin ) },
{ QgsDiagramLayerSettings::AlwaysShow, QgsPropertyDefinition( "alwaysShow", QObject::tr( "Always show diagram" ), QgsPropertyDefinition::Boolean, origin ) },
{ QgsDiagramLayerSettings::StartAngle, QgsPropertyDefinition( "startAngle", QObject::tr( "Pie chart start angle" ), QgsPropertyDefinition::Rotation, origin ) },
};
}

Expand Down
6 changes: 4 additions & 2 deletions src/core/qgsproperty.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -21,10 +21,11 @@
#include "qgssymbollayerutils.h"
#include "qgscolorramp.h"

QgsPropertyDefinition::QgsPropertyDefinition( const QString &name, const QString &description, QgsPropertyDefinition::StandardPropertyTemplate type )
QgsPropertyDefinition::QgsPropertyDefinition( const QString &name, const QString &description, QgsPropertyDefinition::StandardPropertyTemplate type, Origin origin )
: mName( name )
, mDescription( description )
, mStandardType( type )
, mOrigin( origin )
{
switch ( mStandardType )
{
Expand Down Expand Up @@ -169,11 +170,12 @@ QgsPropertyDefinition::QgsPropertyDefinition( const QString &name, const QString
}
}

QgsPropertyDefinition::QgsPropertyDefinition( const QString &name, DataType dataType, const QString &description, const QString &helpText )
QgsPropertyDefinition::QgsPropertyDefinition( const QString &name, DataType dataType, const QString &description, const QString &helpText, Origin origin )
: mName( name )
, mDescription( description )
, mTypes( dataType )
, mHelpText( helpText )
, mOrigin( origin )
{}

bool QgsPropertyDefinition::supportsAssistant() const
Expand Down
18 changes: 16 additions & 2 deletions src/core/qgsproperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,12 @@ class CORE_EXPORT QgsPropertyDefinition
DataTypeBoolean,
};

enum Origin
{
Diagram,
Pal
};

/**
* Constructs an empty property.
*/
Expand All @@ -115,8 +121,9 @@ class CORE_EXPORT QgsPropertyDefinition
* \param name is used internally and should be a unique, alphanumeric string.
* \param description can be any localised string describing what the property is used for.
* \param type one of the predefined standard property template
* \param origin The origin of the property
*/
QgsPropertyDefinition( const QString &name, const QString &description, StandardPropertyTemplate type );
QgsPropertyDefinition( const QString &name, const QString &description, StandardPropertyTemplate type, Origin origin = QgsPropertyDefinition::Pal );

/**
* Constructor for custom QgsPropertyDefinitions.
Expand All @@ -125,14 +132,20 @@ class CORE_EXPORT QgsPropertyDefinition
* \param description can be any localised string describing what the property is used for.
* \param helpText parameter should specify a descriptive string for users outlining the types
* of value acceptable by the property (eg 'dashed' or 'solid' for a line style property).
* \param origin The origin of the property
*/
QgsPropertyDefinition( const QString &name, DataType dataType, const QString &description, const QString &helpText );
QgsPropertyDefinition( const QString &name, DataType dataType, const QString &description, const QString &helpText, Origin origin = QgsPropertyDefinition::Pal );

/**
* Returns the name of the property. This is used internally and should be a unique, alphanumeric string.
*/
QString name() const { return mName; }

/**
* Returns the origin of the property
*/
Origin origin() const { return mOrigin; }

/**
* Descriptive name of the property.
*/
Expand Down Expand Up @@ -167,6 +180,7 @@ class CORE_EXPORT QgsPropertyDefinition
DataType mTypes = DataTypeString;
QString mHelpText;
StandardPropertyTemplate mStandardType = Custom;
Origin mOrigin;

static QString trString();
};
Expand Down

0 comments on commit fa4777e

Please sign in to comment.