use quotes in hstore list items

This commit is contained in:
David Signer 2019-07-08 14:20:01 +02:00
parent 5bf300e758
commit ebfce4f55b
2 changed files with 19 additions and 1 deletions

View File

@ -204,6 +204,8 @@ QStringList QgsValueRelationFieldFormatter::valueToStringList( const QVariant &v
catch ( json::parse_error &ex )
{
qDebug() << QString::fromStdString( ex.what() );
//fallback for wrongly stored data
checkList = value.toString().remove( QChar( '{' ) ).remove( QChar( '}' ) ).split( ',' );
}
}
}

View File

@ -100,8 +100,24 @@ QVariant QgsValueRelationWidgetWrapper::value() const
}
else
{
QStringList sl;
for ( const QString &s : qgis::as_const( selection ) )
{
// Convert to proper type
const QVariant::Type type { fkType() };
switch ( type )
{
case QVariant::Type::Int:
case QVariant::Type::LongLong:
sl.push_back( s );
break;
default:
sl.push_back( "\"" + s + "\"" );
break;
}
}
//store as a formatted string because the fields supports only string
v = selection.join( ',' ).prepend( '{' ).append( '}' );
v = sl.join( ',' ).prepend( '{' ).append( '}' );
}
}