@@ -903,34 +903,44 @@ QString QgsExpression::formatPreviewString( const QVariant &value )
903
903
}
904
904
else if ( value.type () == QVariant::Map )
905
905
{
906
- QString mapStr;
906
+ QString mapStr = QStringLiteral ( " { " ) ;
907
907
const QVariantMap map = value.toMap ();
908
+ QString separator;
908
909
for ( QVariantMap::const_iterator it = map.constBegin (); it != map.constEnd (); ++it )
909
910
{
910
- if ( !mapStr.isEmpty () ) mapStr.append ( " , " );
911
+ mapStr.append ( separator );
912
+ if ( separator.isEmpty () )
913
+ separator = QStringLiteral ( " , " );
914
+
911
915
mapStr.append ( it.key () ).append ( " : " ).append ( formatPreviewString ( it.value () ) );
912
- if ( mapStr.length () > MAX_PREVIEW + 3 )
916
+ if ( mapStr.length () > MAX_PREVIEW + 5 )
913
917
{
914
- mapStr = QString ( tr ( " %1…" ) ).arg ( mapStr.left ( MAX_PREVIEW ) );
918
+ mapStr = tr ( " %1…" ).arg ( mapStr.left ( MAX_PREVIEW ) );
915
919
break ;
916
920
}
917
921
}
922
+ mapStr += QStringLiteral ( " }" );
918
923
return tr ( " <i><map: %1></i>" ).arg ( mapStr );
919
924
}
920
925
else if ( value.type () == QVariant::List || value.type () == QVariant::StringList )
921
926
{
922
- QString listStr;
927
+ QString listStr = QStringLiteral ( " [ " ) ;
923
928
const QVariantList list = value.toList ();
924
- for ( QVariantList::const_iterator it = list.constBegin (); it != list.constEnd (); ++it )
929
+ QString separator;
930
+ for ( const QVariant &arrayValue : list )
925
931
{
926
- if ( !listStr.isEmpty () ) listStr.append ( " , " );
927
- listStr.append ( formatPreviewString ( *it ) );
928
- if ( listStr.length () > MAX_PREVIEW + 3 )
932
+ listStr.append ( separator );
933
+ if ( separator.isEmpty () )
934
+ separator = QStringLiteral ( " , " );
935
+
936
+ listStr.append ( formatPreviewString ( arrayValue ) );
937
+ if ( listStr.length () > MAX_PREVIEW + 5 )
929
938
{
930
939
listStr = QString ( tr ( " %1…" ) ).arg ( listStr.left ( MAX_PREVIEW ) );
931
940
break ;
932
941
}
933
942
}
943
+ listStr += QStringLiteral ( " ]" );
934
944
return tr ( " <i><array: %1></i>" ).arg ( listStr );
935
945
}
936
946
else
0 commit comments