Implemented variable substitution in simple print jobs.
This commit is contained in:
@@ -42,21 +42,33 @@ namespace glabels
|
||||
}
|
||||
|
||||
|
||||
QString SubstitutionField::evaluate( const merge::Record* record ) const
|
||||
QString SubstitutionField::evaluate( const merge::Record* record,
|
||||
const Variables* variables ) const
|
||||
{
|
||||
QString value = mDefaultValue;
|
||||
|
||||
if ( record && record->contains(mFieldName) && !record->value(mFieldName).isEmpty() )
|
||||
bool haveRecordField = record &&
|
||||
record->contains(mFieldName) &&
|
||||
!record->value(mFieldName).isEmpty();
|
||||
bool haveVariable = variables &&
|
||||
variables->contains(mFieldName) &&
|
||||
!(*variables)[mFieldName].value().isEmpty();
|
||||
|
||||
if ( haveRecordField )
|
||||
{
|
||||
value = record->value(mFieldName);
|
||||
}
|
||||
else if ( haveVariable )
|
||||
{
|
||||
value = (*variables)[mFieldName].value();
|
||||
}
|
||||
|
||||
if ( !mFormatType.isNull() )
|
||||
{
|
||||
value = formatValue( value );
|
||||
}
|
||||
|
||||
if ( record && record->contains(mFieldName) && !record->value(mFieldName).isEmpty() && mNewLine )
|
||||
if ( mNewLine && (haveRecordField || haveVariable) )
|
||||
{
|
||||
value = "\n" + value;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user