QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
qgskeyvaluefieldformatter.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgskeyvaluefieldformatter.cpp - QgsKeyValueFieldFormatter
3
4 ---------------------
5 begin : 3.12.2016
6 copyright : (C) 2016 by Matthias Kuhn
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 ***************************************************************************/
17#include "qgsapplication.h"
18#include "qgsvariantutils.h"
19
20#include <QSettings>
21
23{
24 return QStringLiteral( "KeyValue" );
25}
26
27QString QgsKeyValueFieldFormatter::representValue( QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config, const QVariant &cache, const QVariant &value ) const
28{
29 Q_UNUSED( layer )
30 Q_UNUSED( fieldIndex )
31 Q_UNUSED( config )
32 Q_UNUSED( cache )
33
34 if ( QgsVariantUtils::isNull( value ) )
35 {
37 }
38
39 QString result;
40 const QVariantMap map = value.toMap();
41 for ( QVariantMap::const_iterator i = map.constBegin(); i != map.constEnd(); ++i )
42 {
43 if ( !result.isEmpty() )
44 result.append( ", " );
45 result.append( i.key() ).append( ": " ).append( i.value().toString() );
46 }
47 return result;
48}
static QString nullRepresentation()
Returns the string used to represent the value NULL throughout QGIS.
QString id() const override
Returns a unique id for this field formatter.
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.
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
Represents a vector layer which manages a vector based data sets.