QGIS API Documentation 3.41.0-Master (3440c17df1d)
|
A field formatter helps to handle and display values for a field. More...
#include <qgsfieldformatter.h>
Public Types | |
typedef QFlags< Flag > | Flags |
Public Member Functions | |
QgsFieldFormatter ()=default | |
virtual | ~QgsFieldFormatter ()=default |
virtual Qt::AlignmentFlag | alignmentFlag (QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config) const |
Returns the alignment for a particular field. | |
virtual QVariantList | availableValues (const QVariantMap &config, int countLimit, const QgsFieldFormatterContext &context) const |
Returns a list of the values that would be possible to select with this widget type On a RelationReference that would be the parents ids or on ValueMap all the configured keys according to the settings in the config. | |
virtual QVariant | createCache (QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config) const |
Create a cache for a given field. | |
Flags | flags () const |
Returns the flags. | |
virtual QString | id () const =0 |
Returns a unique id for this field formatter. | |
virtual QList< QgsVectorLayerRef > | layerDependencies (const QVariantMap &config) const SIP_SKIP |
Returns a list of weak layer references to other layers required by this formatter for the given config. | |
virtual QString | representValue (QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config, const QVariant &cache, const QVariant &value) const |
Create a pretty String representation of the value. | |
void | setFlags (const Flags &flags) |
Sets the flags. | |
enum Flag | SIP_ENUM_BASETYPE (IntFlag) |
Flags for the abilities of the formatter. | |
virtual QVariant | sortValue (QgsVectorLayer *layer, int fieldIndex, const QVariantMap &config, const QVariant &cache, const QVariant &value) const |
If the default sort order should be overwritten for this widget, you can transform the value in here. | |
A field formatter helps to handle and display values for a field.
It allows for using a shared configuration with the editor widgets for representation of attribute values. Field kits normally have one single instance which is managed by the QgsFieldFormatterRegistry. Custom field formatters should be registered there and field formatters for use within code should normally be obtained from there.
This is an abstract base class and will always need to be subclassed.
Definition at line 68 of file qgsfieldformatter.h.
typedef QFlags< Flag > QgsFieldFormatter::Flags |
Definition at line 85 of file qgsfieldformatter.h.
|
default |
|
virtualdefault |
|
virtual |
Returns the alignment for a particular field.
By default this will consider the field type but can be overwritten if mapped values are represented.
Definition at line 60 of file qgsfieldformatter.cpp.
|
virtual |
Returns a list of the values that would be possible to select with this widget type On a RelationReference that would be the parents ids or on ValueMap all the configured keys according to the settings in the config.
Reimplemented in QgsRelationReferenceFieldFormatter, QgsValueMapFieldFormatter, and QgsValueRelationFieldFormatter.
Definition at line 86 of file qgsfieldformatter.cpp.
|
virtual |
Create a cache for a given field.
This will be used in situations where a field is being represented various times in a loop. And will be passed to other methods on QgsFieldKit and QgsEditorWidgetWrapper.
For example, the attribute table will create a cache once for each field and then use this cache for representation. The QgsValueRelationFieldFormatter and QgsValueRelationEditorWidget implement this functionality to create a lookuptable once (a QVariantMap / dict) and are make use of a cache if present.
Reimplemented in QgsRelationReferenceFieldFormatter, and QgsValueRelationFieldFormatter.
Definition at line 71 of file qgsfieldformatter.cpp.
|
inline |
|
pure virtual |
Returns a unique id for this field formatter.
This id will later be used to identify this field formatter in the registry with QgsFieldFormatterRegistry::fieldFormatter().
This id matches the id of a QgsEditorWidgetFactory.
Implemented in QgsCheckBoxFieldFormatter, QgsDateTimeFieldFormatter, QgsFallbackFieldFormatter, QgsKeyValueFieldFormatter, QgsListFieldFormatter, QgsRangeFieldFormatter, QgsRelationReferenceFieldFormatter, QgsValueMapFieldFormatter, and QgsValueRelationFieldFormatter.
|
virtual |
Returns a list of weak layer references to other layers required by this formatter for the given config.
The default implementation returns an empty list.
This method should be reimplemented by formatters that handle relations with other layers, (e.g. ValueRelation) and can be used by client code to warn the user about missing required dependencies or to add some resolution logic in order to load the missing dependency.
Reimplemented in QgsValueRelationFieldFormatter, and QgsRelationReferenceFieldFormatter.
Definition at line 80 of file qgsfieldformatter.cpp.
|
virtual |
Create a pretty String representation of the value.
Reimplemented in QgsCheckBoxFieldFormatter, QgsDateTimeFieldFormatter, QgsKeyValueFieldFormatter, QgsListFieldFormatter, QgsRangeFieldFormatter, QgsRelationReferenceFieldFormatter, QgsValueMapFieldFormatter, and QgsValueRelationFieldFormatter.
Definition at line 24 of file qgsfieldformatter.cpp.
void QgsFieldFormatter::setFlags | ( | const Flags & | flags | ) |
|
inline |
Flags for the abilities of the formatter.
< Can provide possible values
Definition at line 81 of file qgsfieldformatter.h.
|
virtual |
If the default sort order should be overwritten for this widget, you can transform the value in here.
Reimplemented in QgsRelationReferenceFieldFormatter, QgsValueMapFieldFormatter, and QgsValueRelationFieldFormatter.
Definition at line 50 of file qgsfieldformatter.cpp.