QGIS API Documentation  3.26.3-Buenos Aires (65e4edfdad)
qgslistfieldformatter.cpp
Go to the documentation of this file.
1 /***************************************************************************
2  qgslistfieldformatter.cpp - QgsListFieldFormatter
3 
4  ---------------------
5  begin : 3.12.2016
6  copyright : (C) 2016 by Matthias Kuhn
7  email : [email protected]
8  ***************************************************************************
9  * *
10  * This program is free software; you can redistribute it and/or modify *
11  * it under the terms of the GNU General Public License as published by *
12  * the Free Software Foundation; either version 2 of the License, or *
13  * (at your option) any later version. *
14  * *
15  ***************************************************************************/
16 #include "qgslistfieldformatter.h"
17 #include "qgsapplication.h"
18 #include <QSettings>
19 
21 {
22  return QStringLiteral( "List" );
23 }
24 
25 QString QgsListFieldFormatter::representValue( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config, const QVariant &cache, const QVariant &value ) const
26 {
27  Q_UNUSED( layer )
28  Q_UNUSED( fieldIndex )
29  Q_UNUSED( config )
30  Q_UNUSED( cache )
31 
32  if ( value.isNull() )
33  {
35  }
36 
37  QString result;
38  const QVariantList list = value.toList();
39  for ( const QVariant &val : list )
40  {
41  if ( !result.isEmpty() )
42  result.append( ", " );
43  result.append( val.toString() );
44  }
45  return result;
46 }
QgsListFieldFormatter::id
QString id() const override
Returns a unique id for this field formatter.
Definition: qgslistfieldformatter.cpp:20
qgsapplication.h
QgsListFieldFormatter::representValue
QString representValue(QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config, const QVariant &cache, const QVariant &value) const override
Create a pretty String representation of the value.
Definition: qgslistfieldformatter.cpp:25
QgsApplication::nullRepresentation
static QString nullRepresentation()
This string is used to represent the value NULL throughout QGIS.
Definition: qgsapplication.cpp:2018
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:391
qgslistfieldformatter.h