Origin in QgsProperty is a string and pal is replaced by labeling

This commit is contained in:
Blottiere Paul 2017-08-30 15:15:43 +01:00
parent c22bfdc8de
commit fcdf20df95
6 changed files with 17 additions and 54 deletions

View File

@ -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.
@ -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.
@ -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

View File

@ -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() );
@ -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 );

View File

@ -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() )
@ -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 );

View File

@ -34,7 +34,7 @@ void QgsDiagramLayerSettings::initPropertyDefinitions()
if ( !sPropertyDefinitions.isEmpty() )
return;
QgsPropertyDefinition::Origin origin = QgsPropertyDefinition::Diagram;
const QString origin = QStringLiteral( "diagram" );
sPropertyDefinitions = QgsPropertiesDefinition
{

View File

@ -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 )
@ -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 )

View File

@ -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.
*/
@ -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.
@ -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.
@ -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.
@ -191,7 +184,7 @@ class CORE_EXPORT QgsPropertyDefinition
DataType mTypes = DataTypeString;
QString mHelpText;
StandardPropertyTemplate mStandardType = Custom;
Origin mOrigin;
QString mOrigin;
static QString trString();
};