labeling: consider configure representation for NULL values (fixes #9998)

This commit is contained in:
Juergen E. Fischer 2014-04-19 22:57:45 +02:00
parent 8e6c043937
commit e497a5c0f6
2 changed files with 9 additions and 3 deletions

View File

@ -449,6 +449,9 @@ 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 )
@ -456,6 +459,7 @@ QgsPalLayerSettings::QgsPalLayerSettings( const QgsPalLayerSettings& s )
// copy only permanent stuff
enabled = s.enabled;
mNullValue = s.mNullValue;
// text style
fieldName = s.fieldName;
@ -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?
@ -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 )

View File

@ -550,6 +550,7 @@ class CORE_EXPORT QgsPalLayerSettings
QMap<QgsPalLayerSettings::DataDefinedProperties, QPair<QString, int> > mDataDefinedNames;
QFontDatabase mFontDB;
QString mNullValue;
};
class CORE_EXPORT QgsLabelCandidate