Skip to content

Commit

Permalink
Try to shortcut some labeling data defined routines
Browse files Browse the repository at this point in the history
  • Loading branch information
nyalldawson committed Sep 9, 2015
1 parent dbded4d commit 98fea4d
Showing 1 changed file with 13 additions and 1 deletion.
14 changes: 13 additions & 1 deletion src/core/qgspallabeling.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -1137,6 +1137,9 @@ QString QgsPalLayerSettings::updateDataDefinedString( const QString& value )

QgsDataDefined* QgsPalLayerSettings::dataDefinedProperty( DataDefinedProperties p )
{
if ( dataDefinedProperties.isEmpty() )
return 0;

QMap< QgsPalLayerSettings::DataDefinedProperties, QgsDataDefined* >::const_iterator it = dataDefinedProperties.find( p );
if ( it != dataDefinedProperties.constEnd() )
{
Expand All @@ -1158,7 +1161,7 @@ QMap<QString, QString> QgsPalLayerSettings::dataDefinedMap( DataDefinedPropertie

QVariant QgsPalLayerSettings::dataDefinedValue( DataDefinedProperties p, QgsFeature& f, const QgsFields& fields, const QgsExpressionContext *context ) const
{
if ( !dataDefinedProperties.contains( p ) )
if ( dataDefinedProperties.isEmpty() || !dataDefinedProperties.contains( p ) )
{
return QVariant();
}
Expand Down Expand Up @@ -1227,6 +1230,8 @@ bool QgsPalLayerSettings::dataDefinedEvaluate( DataDefinedProperties p, QVariant
{
// null passed-around QVariant
exprVal.clear();
if ( dataDefinedProperties.isEmpty() )
return false;

//try to keep < 2.12 API - handle no passed expression context
QScopedPointer< QgsExpressionContext > scopedEc;
Expand Down Expand Up @@ -1254,7 +1259,11 @@ bool QgsPalLayerSettings::dataDefinedEvaluate( DataDefinedProperties p, QVariant

bool QgsPalLayerSettings::dataDefinedIsActive( DataDefinedProperties p ) const
{
if ( dataDefinedProperties.isEmpty() )
return false;

bool isActive = false;

QMap< DataDefinedProperties, QgsDataDefined* >::const_iterator it = dataDefinedProperties.find( p );
if ( it != dataDefinedProperties.constEnd() )
{
Expand All @@ -1266,6 +1275,9 @@ bool QgsPalLayerSettings::dataDefinedIsActive( DataDefinedProperties p ) const

bool QgsPalLayerSettings::dataDefinedUseExpression( DataDefinedProperties p ) const
{
if ( dataDefinedProperties.isEmpty() )
return false;

bool useExpression = false;
QMap< DataDefinedProperties, QgsDataDefined* >::const_iterator it = dataDefinedProperties.find( p );
if ( it != dataDefinedProperties.constEnd() )
Expand Down

0 comments on commit 98fea4d

Please sign in to comment.