Class: QgsValueRelationFieldFormatter¶
- class qgis.core.QgsValueRelationFieldFormatter¶
Bases:
QgsFieldFormatter
Constructor for QgsValueRelationFieldFormatter.
QgsValueRelationFieldFormatter(
QgsValueRelationFieldFormatter
)Field formatter for a value relation field.
A value relation field formatter looks up the values from features on another layer.
Methods
- param config
createCache(config: Dict[str, Any], formFeature:
QgsFeature
= QgsFeature(), parentFormFeature:QgsFeature
= QgsFeature()) -> List[QgsValueRelationFieldFormatter.ValueRelationItem] Create a cache for a value relation field.Returns a list of attributes required by the form context
expression
Returns a list of variables required by the form context
expression
Check whether the
feature
has all values required by theexpression
, optionally checks forparentFeature
Returns a list of attributes required by the parent form’s form context
expression
Returns a list of variables required by the parent form’s form context
expression
Check if the
expression
requires a form scope (i.e.Check if the
expression
requires a parent form scope (i.e.- rtype
str
- param layer
Returns the (possibly NULL) layer from the widget’s
config
andproject
- param layer
Utility to convert a list or a string representation of an (hstore style: {1,2…}) list in
value
to a string list- class ValueRelationItem(key: Any, value: str, description: str = '')¶
Bases:
sip.wrapper
Constructor for ValueRelationItem
QgsValueRelationFieldFormatter.ValueRelationItem() Constructor for ValueRelationItem
QgsValueRelationFieldFormatter.ValueRelationItem(QgsValueRelationFieldFormatter.ValueRelationItem)
- description¶
- key¶
- value¶
- availableValues(self, config: Dict[str, Any], countLimit: int, context: QgsFieldFormatterContext) → List[Any]¶
- Parameters
config (Dict[str) –
countLimit (int) –
context (QgsFieldFormatterContext) –
- Return type
List[Any]
- createCache(self, layer: QgsVectorLayer, fieldIndex: int, config: Dict[str, Any]) → Any¶
createCache(config: Dict[str, Any], formFeature:
QgsFeature
= QgsFeature(), parentFormFeature:QgsFeature
= QgsFeature()) -> List[QgsValueRelationFieldFormatter.ValueRelationItem] Create a cache for a value relation field. This can be used to keep the value map in the local memory if doing multiple lookups in a loop.- Parameters
config (Dict[str) – The widget configuration
formFeature – The feature currently being edited with current attribute values
parentFormFeature – For embedded forms only, the feature currently being edited in the parent form with current attribute values
- Return type
Any
- Returns
A kvp list of values for the widget
New in version 3.0.
- Parameters
layer (QgsVectorLayer) –
fieldIndex (int) –
- expressionFormAttributes(expression: str) → Set[str]¶
Returns a list of attributes required by the form context
expression
- Parameters
expression (str) – Form filter expression
- Return type
Set[str]
- Returns
list of attributes required by the expression
New in version 3.2.
- expressionFormVariables(expression: str) → Set[str]¶
Returns a list of variables required by the form context
expression
- Parameters
expression (str) – Form filter expression
- Return type
Set[str]
- Returns
list of variables required by the expression
New in version 3.2.
- expressionIsUsable(expression: str, feature: QgsFeature, parentFeature: QgsFeature = QgsFeature()) → bool¶
Check whether the
feature
has all values required by theexpression
, optionally checks forparentFeature
- Return type
bool
- Returns
True
if the expression can be used
New in version 3.2.
- Parameters
expression (str) –
feature (QgsFeature) –
parentFeature (
QgsFeature
= QgsFeature()) –
- expressionParentFormAttributes(expression: str) → Set[str]¶
Returns a list of attributes required by the parent form’s form context
expression
- Parameters
expression (str) – Form filter expression
- Return type
Set[str]
- Returns
list of parent attributes required by the expression
New in version 3.14.
- expressionParentFormVariables(expression: str) → Set[str]¶
Returns a list of variables required by the parent form’s form context
expression
- Parameters
expression (str) – Form filter expression
- Return type
Set[str]
- Returns
list of parent variables required by the expression
New in version 3.14.
- expressionRequiresFormScope(expression: str) → bool¶
Check if the
expression
requires a form scope (i.e. if it uses fields or geometry of the currently edited feature).- Parameters
expression (str) – The widget’s filter expression
- Return type
bool
- Returns
True
if the expression requires a form scope
New in version 3.2.
- expressionRequiresParentFormScope(expression: str) → bool¶
Check if the
expression
requires a parent form scope (i.e. if it uses fields or geometry of the parent form’s currently edited feature).- Parameters
expression (str) – The widget’s filter expression
- Return type
bool
- Returns
True
if the expression requires a parent form scope
New in version 3.14.
- id(self) → str¶
- Return type
str
- representValue(self, layer: QgsVectorLayer, fieldIndex: int, config: Dict[str, Any], cache: Any, value: Any) → str¶
- Parameters
layer (QgsVectorLayer) –
fieldIndex (int) –
config (Dict[str) –
cache (Any) –
value (Any) –
- Return type
str
- resolveLayer(config: Dict[str, Any], project: QgsProject) → QgsVectorLayer¶
Returns the (possibly NULL) layer from the widget’s
config
andproject
New in version 3.8.
- Parameters
config (Dict[str) –
project (QgsProject) –
- Return type
- sortValue(self, layer: QgsVectorLayer, fieldIndex: int, config: Dict[str, Any], cache: Any, value: Any) → Any¶
- Parameters
layer (QgsVectorLayer) –
fieldIndex (int) –
config (Dict[str) –
cache (Any) –
value (Any) –
- Return type
Any
- valueToStringList(value: Any) → List[str]¶
Utility to convert a list or a string representation of an (hstore style: {1,2…}) list in
value
to a string listNew in version 3.2.
- Parameters
value (Any) –
- Return type
List[str]