QGIS API Documentation
4.3.0-Master (16eddb2670e)
Toggle main menu visibility
Loading...
Searching...
No Matches
src
core
fieldformatter
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
7
email : matthias@opengis.ch
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 "
qgskeyvaluefieldformatter.h
"
17
18
#include "
qgsapplication.h
"
19
#include "
qgsvariantutils.h
"
20
21
#include <QSettings>
22
#include <QString>
23
24
using namespace
Qt::StringLiterals;
25
26
QString
QgsKeyValueFieldFormatter::id
()
const
27
{
28
return
u
"KeyValue"
_s;
29
}
30
31
QString
QgsKeyValueFieldFormatter::representValue
(
QgsVectorLayer
*layer,
int
fieldIndex,
const
QVariantMap &config,
const
QVariant &cache,
const
QVariant &value )
const
32
{
33
Q_UNUSED( layer )
34
Q_UNUSED( fieldIndex )
35
Q_UNUSED( config )
36
Q_UNUSED( cache )
37
38
if
(
QgsVariantUtils::isNull
( value ) )
39
{
40
return
QgsApplication::nullRepresentation
();
41
}
42
43
QString result;
44
const
QVariantMap map = value.toMap();
45
for
( QVariantMap::const_iterator i = map.constBegin(); i != map.constEnd(); ++i )
46
{
47
if
( !result.isEmpty() )
48
result.append(
", "
);
49
result.append( i.key() ).append(
": "
).append( i.value().toString() );
50
}
51
return
result;
52
}
QgsApplication::nullRepresentation
static QString nullRepresentation()
Returns the string used to represent the value NULL throughout QGIS.
Definition
qgsapplication.cpp:2227
QgsKeyValueFieldFormatter::id
QString id() const override
Returns a unique id for this field formatter.
Definition
qgskeyvaluefieldformatter.cpp:26
QgsKeyValueFieldFormatter::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
qgskeyvaluefieldformatter.cpp:31
QgsVariantUtils::isNull
static bool isNull(const QVariant &variant, bool silenceNullWarnings=false)
Returns true if the specified variant should be considered a NULL value.
Definition
qgsvariantutils.cpp:176
QgsVectorLayer
Represents a vector layer which manages a vector based dataset.
Definition
qgsvectorlayer.h:414
qgsapplication.h
qgskeyvaluefieldformatter.h
qgsvariantutils.h
Generated on
for QGIS API Documentation by
1.17.0