Skip to content

Commit

Permalink
labeling: consider configure representation for NULL values (fixes #9998
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jef-n committed Apr 19, 2014
1 parent 8e6c043 commit e497a5c
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/core/qgspallabeling.cpp
Expand Up @@ -449,13 +449,17 @@ QgsPalLayerSettings::QgsPalLayerSettings()

// temp stuff for when drawing label components (don't copy)
showingShadowRects = false;

QSettings settings;
mNullValue = settings.value( "qgis/nullValue", "NULL" ).toString();
}

QgsPalLayerSettings::QgsPalLayerSettings( const QgsPalLayerSettings& s )
{
// copy only permanent stuff

enabled = s.enabled;
mNullValue = s.mNullValue;

// text style
fieldName = s.fieldName;
Expand Down Expand Up @@ -1702,11 +1706,12 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, const QgsRenderContext
QgsDebugMsgLevel( QString( "Expression parser eval error:%1" ).arg( exp->evalErrorString() ), 4 );
return;
}
labelText = result.toString();
labelText = result.isNull() ? mNullValue : result.toString();
}
else
{
labelText = f.attribute( fieldIndex ).toString();
const QVariant &v = f.attribute( fieldIndex );
labelText = v.isNull() ? mNullValue : v.toString();
}

// data defined format numbers?
Expand Down Expand Up @@ -1741,7 +1746,7 @@ void QgsPalLayerSettings::registerFeature( QgsFeature& f, const QgsRenderContext
QgsDebugMsgLevel( QString( "exprVal NumPlusSign:%1" ).arg( signPlus ? "true" : "false" ), 4 );
}

QVariant textV = QVariant( labelText );
QVariant textV( labelText );
bool ok;
double d = textV.toDouble( &ok );
if ( ok )
Expand Down
1 change: 1 addition & 0 deletions src/core/qgspallabeling.h
Expand Up @@ -550,6 +550,7 @@ class CORE_EXPORT QgsPalLayerSettings
QMap<QgsPalLayerSettings::DataDefinedProperties, QPair<QString, int> > mDataDefinedNames;

QFontDatabase mFontDB;
QString mNullValue;
};

class CORE_EXPORT QgsLabelCandidate
Expand Down

0 comments on commit e497a5c

Please sign in to comment.