Skip to content

Commit 3f1ba81

Browse files
committedMay 27, 2019
Address PR comments (minor changes)
1 parent 564fd50 commit 3f1ba81

File tree

3 files changed

+3
-7
lines changed

3 files changed

+3
-7
lines changed
 

‎python/core/auto_generated/fieldformatter/qgsvaluerelationfieldformatter.sip.in

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ Constructor for QgsValueRelationFieldFormatter.
5959

6060
static QStringList valueToStringList( const QVariant &value );
6161
%Docstring
62-
Utility to convert an array or a string representation of an (C style: {1,2...}) array in the form ``value`` to a string list
62+
Utility to convert a list or a string representation of an (hstore style: {1,2...}) list in ``value`` to a string list
6363

6464
.. versionadded:: 3.2
6565
%End

‎src/core/fieldformatter/qgsvaluerelationfieldformatter.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -168,10 +168,6 @@ QgsValueRelationFieldFormatter::ValueRelationCache QgsValueRelationFieldFormatte
168168

169169
QStringList QgsValueRelationFieldFormatter::valueToStringList( const QVariant &value )
170170
{
171-
// Note: the recommended way to pass a value is QVariant::StringList but
172-
// for back compatibility a string representation either in the form
173-
// of a JSON array or in the form of {"quoted_str", 1, ... } is
174-
// also accepted
175171
QStringList checkList;
176172
if ( value.type() == QVariant::StringList )
177173
{
@@ -183,7 +179,7 @@ QStringList QgsValueRelationFieldFormatter::valueToStringList( const QVariant &v
183179
auto newVal { value };
184180
if ( newVal.toString().trimmed().startsWith( '{' ) )
185181
{
186-
newVal = QVariant( newVal.toString().trimmed().mid( 1 ).chopped( 1 ).prepend( '[' ).append( ']' ) );
182+
newVal = QVariant( newVal.toString().trimmed().mid( 1 ).mid( 0, newVal.toString().length() - 2 ).prepend( '[' ).append( ']' ) );
187183
}
188184
if ( newVal.toString().trimmed().startsWith( '[' ) )
189185
{

‎src/core/fieldformatter/qgsvaluerelationfieldformatter.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -66,7 +66,7 @@ class CORE_EXPORT QgsValueRelationFieldFormatter : public QgsFieldFormatter
6666
QVariant createCache( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config ) const override;
6767

6868
/**
69-
* Utility to convert an array or a string representation of an (C style: {1,2...}) array in the form \a value to a string list
69+
* Utility to convert a list or a string representation of an (hstore style: {1,2...}) list in \a value to a string list
7070
* \since QGIS 3.2
7171
*/
7272
static QStringList valueToStringList( const QVariant &value );

0 commit comments

Comments
 (0)
Please sign in to comment.