Class: QgsAggregateMappingModel

The QgsAggregateMappingModel holds mapping information for defining sets of aggregates of fields from a QgsFields object.

Added in version 3.14.

Class Hierarchy

Inheritance diagram of qgis.gui.QgsAggregateMappingModel

Base classes

QAbstractTableModel

QAbstractItemModel

QObject

Enums

ColumnDataIndex

The ColumnDataIndex enum represents the column index for the view

Methods

appendField

Appends a new field to the model, with an optional source and aggregate

contextGenerator

Returns the context generator with the source fields

mapping

Returns a list of Aggregate objects representing the current status of the model

moveDown

Moves up the field at index

moveUp

Moves down the field at index

removeField

Removes the field at index from the model, returns True on success

setBaseExpressionContextGenerator

Sets the base expression context generator, which will generate the expression contexts for expression based widgets used by the model.

setMapping

Sets the mapping to show in the model.

setSourceFields

Set source fields to sourceFields

sourceFields

Returns a list of source fields

class qgis.gui.QgsAggregateMappingModel[source]

Bases: QAbstractTableModel

__init__(sourceFields: QgsFields = QgsFields(), parent: QObject | None = None)

Constructs a QgsAggregateMappingModel from a set of sourceFields. A parent object can be also specified.

Parameters:
  • sourceFields (QgsFields = QgsFields())

  • parent (Optional[QObject] = None)

class Aggregate

Bases: object

The Aggregate struct holds information about an aggregate column

aggregate

Aggregate name

delimiter

Delimiter string

field

The field in its current status (it might have been renamed)

source

The source expression used as the input for the aggregate calculation

class ColumnDataIndex(*values)

Bases: IntEnum

The ColumnDataIndex enum represents the column index for the view

  • SourceExpression: Expression

  • Aggregate: Aggregate name

  • Delimiter: Delimiter

  • DestinationName: Destination field name

  • DestinationType: Destination field type string

  • DestinationLength: Destination field length

  • DestinationPrecision: Destination field precision

Aggregate = 1
Delimiter = 2
DestinationLength = 5
DestinationName = 3
DestinationPrecision = 6
DestinationType = 4
SourceExpression = 0
appendField(self, field: QgsField, source: str | None = '', aggregate: str | None = '')[source]

Appends a new field to the model, with an optional source and aggregate

Parameters:
  • field (QgsField)

  • source (Optional[str] = '')

  • aggregate (Optional[str] = '')

contextGenerator(self) QgsExpressionContextGenerator | None[source]

Returns the context generator with the source fields

Return type:

Optional[QgsExpressionContextGenerator]

mapping(self) List[QgsAggregateMappingModel.Aggregate]

Returns a list of Aggregate objects representing the current status of the model

Return type:

List[QgsAggregateMappingModel.Aggregate]

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, returns True 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])

setMapping(self, mapping: Iterable[QgsAggregateMappingModel.Aggregate])[source]

Sets the mapping to show in the model.

Parameters:

mapping (Iterable[QgsAggregateMappingModel.Aggregate])

setSourceFields(self, sourceFields: QgsFields)[source]

Set source fields to sourceFields

Parameters:

sourceFields (QgsFields)

sourceFields(self) QgsFields[source]

Returns a list of source fields

Return type:

QgsFields