Skip to content

Commit

Permalink
Origin in QgsProperty is a string and pal is replaced by labeling
Browse files Browse the repository at this point in the history
  • Loading branch information
pblottiere committed Oct 9, 2017
1 parent c22bfdc commit fcdf20d
Show file tree
Hide file tree
Showing 6 changed files with 17 additions and 54 deletions.
16 changes: 5 additions & 11 deletions python/core/qgsproperty.sip
Original file line number Diff line number Diff line change
Expand Up @@ -67,18 +67,12 @@ class QgsPropertyDefinition
DataTypeBoolean,
};

enum Origin
{
Diagram,
Pal
};

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

QgsPropertyDefinition( const QString &name, const QString &description, StandardPropertyTemplate type, Origin origin = QgsPropertyDefinition::Pal );
QgsPropertyDefinition( const QString &name, const QString &description, StandardPropertyTemplate type, const QString &origin = QStringLiteral( "labeling" ) );
%Docstring
Constructor for QgsPropertyDefinition, using a standard property template.
\param name is used internally and should be a unique, alphanumeric string.
Expand All @@ -87,7 +81,7 @@ class QgsPropertyDefinition
\param origin The origin of the property
%End

QgsPropertyDefinition( const QString &name, DataType dataType, const QString &description, const QString &helpText, Origin origin = QgsPropertyDefinition::Pal );
QgsPropertyDefinition( const QString &name, DataType dataType, const QString &description, const QString &helpText, const QString &origin = QStringLiteral( "labeling" ) );
%Docstring
Constructor for custom QgsPropertyDefinitions.
\param name is used internally and should be a unique, alphanumeric string.
Expand All @@ -109,13 +103,13 @@ class QgsPropertyDefinition
Sets the name of the property
%End

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

void setOrigin( Origin origin );
void setOrigin( const QString &origin );
%Docstring
Sets origin of the property
%End
Expand Down
15 changes: 2 additions & 13 deletions src/app/qgsvectorlayerproperties.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1528,13 +1528,7 @@ void QgsVectorLayerProperties::updateAuxiliaryStoragePage( bool reset )
const QgsPropertyDefinition prop = field.propertyDefinition();
QTreeWidgetItem *item = new QTreeWidgetItem();

if ( prop.origin() == QgsPropertyDefinition::Pal )
item->setText( 0, "Pal" );
else if ( prop.origin() == QgsPropertyDefinition::Diagram )
item->setText( 0, "Diagram" );
else
item->setText( 0, "Unknown" );

item->setText( 0, prop.origin() );
item->setText( 1, prop.name() );
item->setText( 2, field.typeName() );

Expand Down Expand Up @@ -1648,12 +1642,7 @@ void QgsVectorLayerProperties::onAuxiliaryLayerDeleteField()
// get auxiliary field name and index from item
const QTreeWidgetItem *item = items[0];
QgsPropertyDefinition def;

if ( item->text( 0 ).compare( "pal", Qt::CaseInsensitive ) == 0 )
def.setOrigin( QgsPropertyDefinition::Pal );
else
def.setOrigin( QgsPropertyDefinition::Diagram );

def.setOrigin( item->text( 0 ) );
def.setName( item->text( 1 ) );

const QString fieldName = QgsAuxiliaryField::name( def );
Expand Down
17 changes: 2 additions & 15 deletions src/core/qgsauxiliarystorage.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ QgsAuxiliaryField::QgsAuxiliaryField( const QgsField &f )
const QString propertyName = parts[1];
QgsPropertyDefinition def;

if ( origin.compare( "pal", Qt::CaseInsensitive ) == 0 )
if ( origin.compare( "labeling", Qt::CaseInsensitive ) == 0 )
{
const QgsPropertiesDefinition props = QgsPalLayerSettings::propertyDefinitions();
Q_FOREACH ( const QgsPropertyDefinition p, props.values() )
Expand Down Expand Up @@ -126,20 +126,7 @@ bool QgsAuxiliaryLayer::clear()

QString QgsAuxiliaryField::name( const QgsPropertyDefinition &def, bool joined )
{
QString origin;
switch ( def.origin() )
{
case QgsPropertyDefinition::Pal:
origin = "pal";
break;
case QgsPropertyDefinition::Diagram:
origin = "diagram";
break;
default:
break;
}

QString fieldName = QString( "%2_%3" ).arg( origin, def.name().toLower() );
QString fieldName = QString( "%2_%3" ).arg( def.origin(), def.name().toLower() );

if ( joined )
fieldName = QString( "%1%2" ).arg( AS_JOINPREFIX, fieldName );
Expand Down
2 changes: 1 addition & 1 deletion src/core/qgsdiagramrenderer.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@ void QgsDiagramLayerSettings::initPropertyDefinitions()
if ( !sPropertyDefinitions.isEmpty() )
return;

QgsPropertyDefinition::Origin origin = QgsPropertyDefinition::Diagram;
const QString origin = QStringLiteral( "diagram" );

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

QgsPropertyDefinition::QgsPropertyDefinition( const QString &name, const QString &description, QgsPropertyDefinition::StandardPropertyTemplate type, Origin origin )
QgsPropertyDefinition::QgsPropertyDefinition( const QString &name, const QString &description, QgsPropertyDefinition::StandardPropertyTemplate type, const QString &origin )
: mName( name )
, mDescription( description )
, mStandardType( type )
Expand Down Expand Up @@ -170,7 +170,7 @@ QgsPropertyDefinition::QgsPropertyDefinition( const QString &name, const QString
}
}

QgsPropertyDefinition::QgsPropertyDefinition( const QString &name, DataType dataType, const QString &description, const QString &helpText, Origin origin )
QgsPropertyDefinition::QgsPropertyDefinition( const QString &name, DataType dataType, const QString &description, const QString &helpText, const QString &origin )
: mName( name )
, mDescription( description )
, mTypes( dataType )
Expand Down
17 changes: 5 additions & 12 deletions src/core/qgsproperty.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,13 +105,6 @@ class CORE_EXPORT QgsPropertyDefinition
DataTypeBoolean,
};

//! Indicates for which settings the property has been set
enum Origin
{
Diagram,
Pal
};

/**
* Constructs an empty property.
*/
Expand All @@ -124,7 +117,7 @@ class CORE_EXPORT QgsPropertyDefinition
* \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, Origin origin = QgsPropertyDefinition::Pal );
QgsPropertyDefinition( const QString &name, const QString &description, StandardPropertyTemplate type, const QString &origin = QStringLiteral( "labeling" ) );

/**
* Constructor for custom QgsPropertyDefinitions.
Expand All @@ -135,7 +128,7 @@ class CORE_EXPORT QgsPropertyDefinition
* 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, Origin origin = QgsPropertyDefinition::Pal );
QgsPropertyDefinition( const QString &name, DataType dataType, const QString &description, const QString &helpText, const QString &origin = QStringLiteral( "labeling" ) );

/**
* Returns the name of the property. This is used internally and should be a unique, alphanumeric string.
Expand All @@ -150,12 +143,12 @@ class CORE_EXPORT QgsPropertyDefinition
/**
* Returns the origin of the property
*/
Origin origin() const { return mOrigin; }
QString origin() const { return mOrigin; }

/**
* Sets origin of the property
*/
void setOrigin( Origin origin ) { mOrigin = origin; }
void setOrigin( const QString &origin ) { mOrigin = origin; }

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

static QString trString();
};
Expand Down

0 comments on commit fcdf20d

Please sign in to comment.