QgsValueMapFieldFormatter class
Field formatter for a ValueMap field.
Contents
A value relation field formatter looks up the values a map.
The map is defined in the configuration as dictionary under the key "map".
{ "map": { 1: "one", 2: "two", 3: "three" } }
Values that are not on the map will be wrapped in parentheses. So with the above configuration:
- 3 => "three"
- 5 => "(5)"
Base classes
- class QgsFieldFormatter
- A field formatter helps to handle and display values for a field.
Public static variables
- static const QString NULL_VALUE
- Will be saved in the configuration when a value is NULL.
Constructors, destructors, conversion operators
- QgsValueMapFieldFormatter() defaulted
- Default constructor of field formatter for a value map field.
Public functions
- auto id() const -> QString override
- Returns a unique id for this field formatter.
- auto representValue(QgsVectorLayer* layer, int fieldIndex, const QVariantMap& config, const QVariant& cache, const QVariant& value) const -> QString override
- Create a pretty String representation of the value.
- auto sortValue(QgsVectorLayer* layer, int fieldIndex, const QVariantMap& config, const QVariant& cache, const QVariant& value) const -> QVariant override
- If the default sort order should be overwritten for this widget, you can transform the value in here.
Function documentation
QString QgsValueMapFieldFormatter:: id() const override
Returns a unique id for this field formatter.
This id will later be used to identify this field formatter in the registry with QgsFieldFormatterRegistry::
This id matches the id of a QgsEditorWidgetFactory.
QString QgsValueMapFieldFormatter:: representValue(QgsVectorLayer* layer,
int fieldIndex,
const QVariantMap& config,
const QVariant& cache,
const QVariant& value) const override
Create a pretty String representation of the value.
| Returns | By default the string representation of the provided value as implied by the field definition is returned. |
|---|
QVariant QgsValueMapFieldFormatter:: sortValue(QgsVectorLayer* layer,
int fieldIndex,
const QVariantMap& config,
const QVariant& cache,
const QVariant& value) const override
If the default sort order should be overwritten for this widget, you can transform the value in here.
| Returns | an unmodified value by default. |
|---|
Variable documentation
static const QString QgsValueMapFieldFormatter:: NULL_VALUE
Will be saved in the configuration when a value is NULL.
It's the magic UUID {2839923C-8B7D-419E-B84B-CA2FE9B80EC7}