Class: QgsFieldMappingModel¶
Holds mapping information for mapping from one set of
QgsFields
to another.
For each set of “destination” fields an expression defines how to obtain the values of the “destination” fields.
The model can be optionally set “editable” allowing to modify all the fields, by default only the mapping expression is editable.
Added in version 3.14.
Class Hierarchy¶
Base classes¶
Enums
The ColumnDataIndex enum represents the column index for the view |
Methods
Appends a new field to the model, with an optional expression |
|
Returns the context generator with the source fields |
|
Returns a static map of supported data types |
|
Returns |
|
Returns a map of destination field name to |
|
Returns a list of Field objects representing the current status of the model |
|
Moves up the field at index |
|
Moves down the field at index |
|
Removes the field at index from the model, returns |
|
Sets the base expression context generator, which will generate the expression contexts for expression based widgets used by the model. |
|
Sets the destination fields editable state to editable |
|
Set destination fields to destinationFields, initial values for the expressions can be optionally specified through expressions which is a map from the original field name to the corresponding expression. |
|
Sets a map of destination field name to |
|
Sets the list of nativeTypes supported by a data provider. |
|
Set source fields to sourceFields |
|
Returns a list of source fields |
|
Returns a static list of supported data types |
- class qgis.gui.QgsFieldMappingModel[source]¶
Bases:
QAbstractTableModel
- __init__(sourceFields: QgsFields = QgsFields(), destinationFields: QgsFields = QgsFields(), expressions: Dict[str | None, str | None] = {}, parent: QObject | None = None)
Constructs a QgsFieldMappingModel from a set of
sourceFields
anddestinationFields
, initial values for the expressions can be optionally specified throughexpressions
which is a map from the original field name to the corresponding expression. Aparent
object can be also specified.
- class ColumnDataIndex(*values)¶
Bases:
IntEnum
The ColumnDataIndex enum represents the column index for the view
SourceExpression
: ExpressionDestinationName
: Destination field nameDestinationType
: Destination field type stringDestinationLength
: Destination field lengthDestinationPrecision
: Destination field precisionDestinationConstraints
: Destination field constraintsDestinationAlias
: Destination aliasDestinationComment
: Destination comment
- DestinationAlias = 6¶
- DestinationComment = 7¶
- DestinationConstraints = 5¶
- DestinationLength = 3¶
- DestinationName = 1¶
- DestinationPrecision = 4¶
- DestinationType = 2¶
- SourceExpression = 0¶
- class Field¶
Bases:
object
The Field struct holds information about a mapped field
- expression: str¶
The expression for the mapped field from the source fields
- originalName: str¶
The original name of the field
- appendField(self, field: QgsField, expression: str | None = '')[source]¶
Appends a new
field
to the model, with an optionalexpression
- Parameters:
field (QgsField)
expression (Optional[str] = '')
- contextGenerator(self) QgsExpressionContextGenerator | None [source]¶
Returns the context generator with the source fields
- Return type:
Optional[QgsExpressionContextGenerator]
- dataTypes() Dict[QMetaType.Type, str] ¶
Returns a static map of supported data types
Deprecated since version 3.24: Use
supportedDataTypes()
instead.- Return type:
Dict[QMetaType.Type, str]
- destinationEditable(self) bool [source]¶
Returns
True
if the destination fields are editable- Return type:
bool
- fieldPropertyMap(self) Dict[str, QgsProperty] ¶
Returns a map of destination field name to
QgsProperty
definition for field value, representing the current status of the model.See also
- Return type:
Dict[str, QgsProperty]
- mapping(self) List[QgsFieldMappingModel.Field] ¶
Returns a list of Field objects representing the current status of the model
- Return type:
- moveDown(self, index: QModelIndex) bool [source]¶
Moves up the field at
index
- Parameters:
index (QModelIndex)
- Return type:
bool
- moveUp(self, index: QModelIndex) bool [source]¶
Moves down the field at
index
- Parameters:
index (QModelIndex)
- Return type:
bool
- removeField(self, index: QModelIndex) bool [source]¶
Removes the field at
index
from the model, returnsTrue
on success- Parameters:
index (QModelIndex)
- Return type:
bool
- setBaseExpressionContextGenerator(self, generator: QgsExpressionContextGenerator | None)[source]¶
Sets the base expression context
generator
, which will generate the expression contexts for expression based widgets used by the model.- Parameters:
generator (Optional[QgsExpressionContextGenerator])
- setDestinationEditable(self, editable: bool)[source]¶
Sets the destination fields editable state to
editable
- Parameters:
editable (bool)
- setDestinationFields(self, destinationFields: QgsFields, expressions: Dict[str | None, str | None] = {})[source]¶
Set destination fields to
destinationFields
, initial values for the expressions can be optionally specified throughexpressions
which is a map from the original field name to the corresponding expression.- Parameters:
destinationFields (QgsFields)
expressions (Dict[Optional[str], Optional[str]] = {})
- setFieldPropertyMap(self, map: Dict[str | None, QgsProperty])[source]¶
Sets a map of destination field name to
QgsProperty
definition for field value.See also
- Parameters:
map (Dict[Optional[str], QgsProperty])
- setNativeTypes(self, nativeTypes: Iterable[QgsVectorDataProvider.NativeType])[source]¶
Sets the list of
nativeTypes
supported by a data provider.If this list is non-empty, then the destination field types will be populated accordingly. If the list is empty, then a set of default native types will be used instead.
Added in version 3.44.
- Parameters:
nativeTypes (Iterable[QgsVectorDataProvider.NativeType])
- setSourceFields(self, sourceFields: QgsFields)[source]¶
Set source fields to
sourceFields
- Parameters:
sourceFields (QgsFields)
- supportedDataTypes() List[QgsVectorDataProvider.NativeType] ¶
Returns a static list of supported data types
Added in version 3.24.
- Return type: