Class: 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

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: str
delimiter: str
field: QgsField
source: str
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