QgsAttributeEditorContext class

This class contains context information for attribute editor widgets.

It will be passed to embedded widgets whenever this occurs (e.g. when showing an embedded form due to relations)

Public types

enum FormMode { Embed, StandaloneDialog, Popup }
enum Mode { SingleEditMode, AddFeatureMode, MultiEditMode, SearchMode, AggregateSearchMode, IdentifyMode }
modes
enum RelationMode { Undefined, Multiple, Single }
Determines in which direction a relation was resolved.

Constructors, destructors, conversion operators

QgsAttributeEditorContext() defaulted
Constructor for QgsAttributeEditorContext.

Public functions

auto allowCustomUi() const -> bool
Returns true if the attribute editor should permit use of custom UI forms.
auto attributeFormMode() const -> Mode
Returns current attributeFormMode.
auto attributeFormModeString() const -> QString
Returns given attributeFormMode as string.
auto distanceArea() const -> const QgsDistanceArea&
Returns the distance area object used for area/length calculations.
auto formFeature() const -> QgsFeature
Returns current feature from the currently edited form or table row.
auto formMode() const -> FormMode
Returns the form mode.
auto mapCanvas() const -> QgsMapCanvas*
Returns the associated map canvas (e.g.
auto relation() const -> const QgsRelation&
Returns the attribute relation.
auto relationMode() const -> RelationMode
Returns the attribute relation mode.
void setAllowCustomUi(bool allow)
Sets whether the attribute editor should permit use of custom UI forms.
void setAttributeFormMode(const Mode& attributeFormMode)
Set attributeFormMode for the edited form.
void setDistanceArea(const QgsDistanceArea& distanceArea)
Sets distance area object, distanceArea, for area/length calculations.
void setFormFeature(const QgsFeature& feature)
Set current feature for the currently edited form or table row.
void setFormMode(FormMode mode)
Sets the form mode.
void setMapCanvas(QgsMapCanvas* mapCanvas)
Sets the associated map canvas, mapCanvas, (e.g.
void setRelation(const QgsRelation& relation, RelationMode mode)
Set attribute relation and mode.
void setVectorLayerTools(QgsVectorLayerTools* vlTools)
Sets the associated vector layer tools.
auto vectorLayerTools() const -> const QgsVectorLayerTools*
Returns the associated vector layer tools.

Enum documentation

enum QgsAttributeEditorContext::FormMode

Enumerators
Embed

A form was embedded as a widget on another form.

StandaloneDialog

A form was opened as a new dialog.

Popup

A widget was opened as a popup (e.g. attribute table editor widget)

enum QgsAttributeEditorContext::Mode

modes

Enumerators
SingleEditMode

Single edit mode, for editing a single feature.

AddFeatureMode

Add feature mode, for setting attributes for a new feature. In this mode the dialog will be editable even with an invalid feature and will add a new feature when the form is accepted.

MultiEditMode

Multi edit mode, for editing fields of multiple features at once.

SearchMode

Form values are used for searching/filtering the layer.

AggregateSearchMode

Form is in aggregate search mode, show each widget in this mode.

IdentifyMode

Identify the feature.

enum QgsAttributeEditorContext::RelationMode

Determines in which direction a relation was resolved.

Enumerators
Undefined

This context is not defined by a relation.

Multiple

When showing a list of features (e.g. houses as an embedded form in a district form)

Single

When showing a single feature (e.g. district information when looking at the form of a house)

Function documentation

bool QgsAttributeEditorContext::allowCustomUi() const

Returns true if the attribute editor should permit use of custom UI forms.

Mode QgsAttributeEditorContext::attributeFormMode() const

Returns current attributeFormMode.

QString QgsAttributeEditorContext::attributeFormModeString() const

Returns given attributeFormMode as string.

const QgsDistanceArea& QgsAttributeEditorContext::distanceArea() const

Returns the distance area object used for area/length calculations.

QgsFeature QgsAttributeEditorContext::formFeature() const

Returns current feature from the currently edited form or table row.

FormMode QgsAttributeEditorContext::formMode() const

Returns the form mode.

QgsMapCanvas* QgsAttributeEditorContext::mapCanvas() const

Returns the associated map canvas (e.g.

to zoom to related features).

const QgsRelation& QgsAttributeEditorContext::relation() const

Returns the attribute relation.

RelationMode QgsAttributeEditorContext::relationMode() const

Returns the attribute relation mode.

void QgsAttributeEditorContext::setAllowCustomUi(bool allow)

Sets whether the attribute editor should permit use of custom UI forms.

Parameters
allow set to true to allow custom UI forms, or false to disable them and use default generated QGIS forms

void QgsAttributeEditorContext::setAttributeFormMode(const Mode& attributeFormMode)

Set attributeFormMode for the edited form.

void QgsAttributeEditorContext::setDistanceArea(const QgsDistanceArea& distanceArea)

Sets distance area object, distanceArea, for area/length calculations.

void QgsAttributeEditorContext::setFormFeature(const QgsFeature& feature)

Set current feature for the currently edited form or table row.

void QgsAttributeEditorContext::setFormMode(FormMode mode)

Sets the form mode.

Parameters
mode form mode

void QgsAttributeEditorContext::setMapCanvas(QgsMapCanvas* mapCanvas)

Sets the associated map canvas, mapCanvas, (e.g.

to zoom to related features).

void QgsAttributeEditorContext::setRelation(const QgsRelation& relation, RelationMode mode)

Set attribute relation and mode.

Parameters
relation relation
mode relation mode

void QgsAttributeEditorContext::setVectorLayerTools(QgsVectorLayerTools* vlTools)

Sets the associated vector layer tools.

Parameters
vlTools vector layer tools

const QgsVectorLayerTools* QgsAttributeEditorContext::vectorLayerTools() const

Returns the associated vector layer tools.