QGIS API Documentation  3.18.1-Zürich (202f1bf7e5)
Public Slots | Public Member Functions | Protected Slots | Protected Member Functions | Protected Attributes | List of all members
QgsAbstractRelationEditorWidget Class Referenceabstract

Base class to build new relation widgets. More...

#include <qgsabstractrelationeditorwidget.h>

Inheritance diagram for QgsAbstractRelationEditorWidget:
Inheritance graph
[legend]

Public Slots

virtual void parentFormValueChanged (const QString &attribute, const QVariant &newValue)=0
 Called when an attribute value in the parent widget has changed to newValue. More...
 

Public Member Functions

 QgsAbstractRelationEditorWidget (const QVariantMap &config, QWidget *parent=nullptr)
 Constructor. More...
 
virtual QVariantMap config () const =0
 Returns the widget configuration. More...
 
QgsAttributeEditorContext editorContext () const
 Returns the attribute editor context. More...
 
QgsFeature feature () const
 Returns the widget's current feature. More...
 
bool forceSuppressFormPopup () const
 Determines the force suppress form popup status that is configured for this widget. More...
 
QString label () const
 Determines the label of this element. More...
 
QVariant nmRelationId () const
 Determines the relation id of the second relation involved in an N:M relation. More...
 
QgsRelation relation () const
 Returns the relation. More...
 
virtual void setConfig (const QVariantMap &config)=0
 Defines the widget configuration. More...
 
virtual void setEditorContext (const QgsAttributeEditorContext &context)
 Sets the editor context. More...
 
void setFeature (const QgsFeature &feature, bool update=true)
 Sets the feature being edited and updates the UI unless update is set to false. More...
 
void setForceSuppressFormPopup (bool forceSuppressFormPopup)
 Sets force suppress form popup status with forceSuppressFormPopup configured for this widget. More...
 
void setLabel (const QString &label=QString())
 Sets label for this element If it's empty it takes the relation id as label. More...
 
void setNmRelationId (const QVariant &nmRelationId=QVariant())
 Sets nmRelationId for the relation id of the second relation involved in an N:M relation. More...
 
void setRelationFeature (const QgsRelation &relation, const QgsFeature &feature)
 Sets the relation and the feature. More...
 
void setRelations (const QgsRelation &relation, const QgsRelation &nmrelation)
 Sets the relation(s) for this widget If only one relation is set, it will act as a simple 1:N relation widget If both relations are set, it will act as an N:M relation widget inserting and deleting entries on the intermediate table as required. More...
 
void setShowLabel (bool showLabel)
 Defines if a title label should be shown for this widget. More...
 
bool showLabel () const
 Defines if a title label should be shown for this widget. More...
 

Protected Slots

void addFeature (const QgsGeometry &geometry=QgsGeometry())
 Adds a new feature with given geometry. More...
 
void deleteFeature (QgsFeatureId fid=QgsFeatureId())
 Delete a feature with given fid. More...
 
void duplicateFeature (const QgsFeatureId &fid)
 Duplicates a feature. More...
 
void duplicateFeatures (const QgsFeatureIds &fids)
 Duplicates features. More...
 
void linkFeature ()
 Links a new feature to the relation. More...
 
void onLinkFeatureDlgAccepted ()
 Called when the link feature dialog is confirmed by the user. More...
 
void saveEdits ()
 Saves the current modifications in the relation. More...
 
void toggleEditing (bool state)
 Toggles editing state of the widget. More...
 
void unlinkFeature (QgsFeatureId fid=QgsFeatureId())
 Unlinks a feature with given fid. More...
 

Protected Member Functions

virtual void afterSetRelationFeature ()
 A hook called right after setRelationFeature() is executed, but before updateUi() is called. More...
 
virtual void afterSetRelations ()
 A hook called right after setRelations() is executed, but before updateUi() is called. More...
 
virtual void beforeSetRelationFeature (const QgsRelation &newRelation, const QgsFeature &newFeature)
 A hook called right before setRelationFeature() is executed. More...
 
virtual void beforeSetRelations (const QgsRelation &newRelation, const QgsRelation &newNmRelation)
 A hook called right before setRelations() is executed. More...
 
void deleteFeatures (const QgsFeatureIds &fids)
 Deletes the features with fids. More...
 
virtual void setTitle (const QString &title)
 Sets the title of the widget, if it is wrapped within a QgsCollapsibleGroupBox Check QgsRealationEditorWidget as an example. More...
 
void unlinkFeatures (const QgsFeatureIds &fids)
 Unlinks the features with fids. More...
 
void updateTitle ()
 Updates the title contents to reflect the current state of the widget. More...
 
virtual void updateUi ()
 A hook called every time the state of the relation editor widget has changed via calling its set* methods or slots, e.g. More...
 

Protected Attributes

QgsAttributeEditorContext mEditorContext
 
QgsFeature mFeature
 
bool mForceSuppressFormPopup = false
 
QString mLabel
 
bool mLayerInSameTransactionGroup = false
 
QgsRelation mNmRelation
 
QVariant mNmRelationId
 
QgsRelation mRelation
 
bool mShowLabel = true
 

Detailed Description

Base class to build new relation widgets.

Since
QGIS 3.18

Definition at line 45 of file qgsabstractrelationeditorwidget.h.

Constructor & Destructor Documentation

◆ QgsAbstractRelationEditorWidget()

QgsAbstractRelationEditorWidget::QgsAbstractRelationEditorWidget ( const QVariantMap &  config,
QWidget *  parent = nullptr 
)

Constructor.

Definition at line 35 of file qgsabstractrelationeditorwidget.cpp.

Member Function Documentation

◆ addFeature

void QgsAbstractRelationEditorWidget::addFeature ( const QgsGeometry geometry = QgsGeometry())
protectedslot

Adds a new feature with given geometry.

Definition at line 205 of file qgsabstractrelationeditorwidget.cpp.

◆ afterSetRelationFeature()

void QgsAbstractRelationEditorWidget::afterSetRelationFeature ( )
protectedvirtual

A hook called right after setRelationFeature() is executed, but before updateUi() is called.

Used to update the UI once setting the relation feature is done. Check QgsRealationEditorWidget as an example.

Reimplemented in QgsRelationEditorWidget.

Definition at line 603 of file qgsabstractrelationeditorwidget.cpp.

◆ afterSetRelations()

void QgsAbstractRelationEditorWidget::afterSetRelations ( )
protectedvirtual

A hook called right after setRelations() is executed, but before updateUi() is called.

Used to update the UI once setting the relations is done. Check QgsRealationEditorWidget as an example.

Reimplemented in QgsRelationEditorWidget.

Definition at line 612 of file qgsabstractrelationeditorwidget.cpp.

◆ beforeSetRelationFeature()

void QgsAbstractRelationEditorWidget::beforeSetRelationFeature ( const QgsRelation newRelation,
const QgsFeature newFeature 
)
protectedvirtual

A hook called right before setRelationFeature() is executed.

Used to update the UI once setting the relation feature is done. Check QgsRealationEditorWidget as an example.

Reimplemented in QgsRelationEditorWidget.

Definition at line 597 of file qgsabstractrelationeditorwidget.cpp.

◆ beforeSetRelations()

void QgsAbstractRelationEditorWidget::beforeSetRelations ( const QgsRelation newRelation,
const QgsRelation newNmRelation 
)
protectedvirtual

A hook called right before setRelations() is executed.

Used to manipulate UI once setting the relations is done. Check QgsRealationEditorWidget as an example.

Reimplemented in QgsRelationEditorWidget.

Definition at line 606 of file qgsabstractrelationeditorwidget.cpp.

◆ config()

virtual QVariantMap QgsAbstractRelationEditorWidget::config ( ) const
pure virtual

Returns the widget configuration.

Implemented in QgsRelationEditorWidget.

◆ deleteFeature

void QgsAbstractRelationEditorWidget::deleteFeature ( QgsFeatureId  fid = QgsFeatureId())
protectedslot

Delete a feature with given fid.

Definition at line 267 of file qgsabstractrelationeditorwidget.cpp.

◆ deleteFeatures()

void QgsAbstractRelationEditorWidget::deleteFeatures ( const QgsFeatureIds fids)
protected

Deletes the features with fids.

Definition at line 272 of file qgsabstractrelationeditorwidget.cpp.

◆ duplicateFeature

void QgsAbstractRelationEditorWidget::duplicateFeature ( const QgsFeatureId fid)
protectedslot

Duplicates a feature.

Definition at line 615 of file qgsabstractrelationeditorwidget.cpp.

◆ duplicateFeatures

void QgsAbstractRelationEditorWidget::duplicateFeatures ( const QgsFeatureIds fids)
protectedslot

Duplicates features.

Definition at line 620 of file qgsabstractrelationeditorwidget.cpp.

◆ editorContext()

QgsAttributeEditorContext QgsAbstractRelationEditorWidget::editorContext ( ) const

Returns the attribute editor context.

Definition at line 102 of file qgsabstractrelationeditorwidget.cpp.

◆ feature()

QgsFeature QgsAbstractRelationEditorWidget::feature ( ) const

Returns the widget's current feature.

Definition at line 177 of file qgsabstractrelationeditorwidget.cpp.

◆ forceSuppressFormPopup()

bool QgsAbstractRelationEditorWidget::forceSuppressFormPopup ( ) const

Determines the force suppress form popup status that is configured for this widget.

Definition at line 156 of file qgsabstractrelationeditorwidget.cpp.

◆ label()

QString QgsAbstractRelationEditorWidget::label ( ) const

Determines the label of this element.

Definition at line 127 of file qgsabstractrelationeditorwidget.cpp.

◆ linkFeature

void QgsAbstractRelationEditorWidget::linkFeature ( )
protectedslot

Links a new feature to the relation.

Definition at line 389 of file qgsabstractrelationeditorwidget.cpp.

◆ nmRelationId()

QVariant QgsAbstractRelationEditorWidget::nmRelationId ( ) const

Determines the relation id of the second relation involved in an N:M relation.

Definition at line 122 of file qgsabstractrelationeditorwidget.cpp.

◆ onLinkFeatureDlgAccepted

void QgsAbstractRelationEditorWidget::onLinkFeatureDlgAccepted ( )
protectedslot

Called when the link feature dialog is confirmed by the user.

Definition at line 413 of file qgsabstractrelationeditorwidget.cpp.

◆ parentFormValueChanged

virtual void QgsAbstractRelationEditorWidget::parentFormValueChanged ( const QString &  attribute,
const QVariant &  newValue 
)
pure virtualslot

Called when an attribute value in the parent widget has changed to newValue.

◆ relation()

QgsRelation QgsAbstractRelationEditorWidget::relation ( ) const
inline

Returns the relation.

Since
QGIS 3.18

Definition at line 87 of file qgsabstractrelationeditorwidget.h.

◆ saveEdits

void QgsAbstractRelationEditorWidget::saveEdits ( )
protectedslot

Saves the current modifications in the relation.

Definition at line 198 of file qgsabstractrelationeditorwidget.cpp.

◆ setConfig()

virtual void QgsAbstractRelationEditorWidget::setConfig ( const QVariantMap &  config)
pure virtual

Defines the widget configuration.

Implemented in QgsRelationEditorWidget.

◆ setEditorContext()

void QgsAbstractRelationEditorWidget::setEditorContext ( const QgsAttributeEditorContext context)
virtual

Sets the editor context.

Note
if context cadDockWidget is null, it won't be possible to digitize the geometry of a referencing feature from this widget

Reimplemented in QgsRelationEditorWidget.

Definition at line 97 of file qgsabstractrelationeditorwidget.cpp.

◆ setFeature()

void QgsAbstractRelationEditorWidget::setFeature ( const QgsFeature feature,
bool  update = true 
)

Sets the feature being edited and updates the UI unless update is set to false.

Definition at line 107 of file qgsabstractrelationeditorwidget.cpp.

◆ setForceSuppressFormPopup()

void QgsAbstractRelationEditorWidget::setForceSuppressFormPopup ( bool  forceSuppressFormPopup)

Sets force suppress form popup status with forceSuppressFormPopup configured for this widget.

Definition at line 151 of file qgsabstractrelationeditorwidget.cpp.

◆ setLabel()

void QgsAbstractRelationEditorWidget::setLabel ( const QString &  label = QString())

Sets label for this element If it's empty it takes the relation id as label.

Definition at line 132 of file qgsabstractrelationeditorwidget.cpp.

◆ setNmRelationId()

void QgsAbstractRelationEditorWidget::setNmRelationId ( const QVariant &  nmRelationId = QVariant())

Sets nmRelationId for the relation id of the second relation involved in an N:M relation.

If it's empty, then it's considered as a 1:M relationship.

Definition at line 117 of file qgsabstractrelationeditorwidget.cpp.

◆ setRelationFeature()

void QgsAbstractRelationEditorWidget::setRelationFeature ( const QgsRelation relation,
const QgsFeature feature 
)

Sets the relation and the feature.

Definition at line 41 of file qgsabstractrelationeditorwidget.cpp.

◆ setRelations()

void QgsAbstractRelationEditorWidget::setRelations ( const QgsRelation relation,
const QgsRelation nmrelation 
)

Sets the relation(s) for this widget If only one relation is set, it will act as a simple 1:N relation widget If both relations are set, it will act as an N:M relation widget inserting and deleting entries on the intermediate table as required.

Parameters
relationRelation referencing the edited table
nmrelationOptional reference from the referencing table to a 3rd N:M table

Definition at line 55 of file qgsabstractrelationeditorwidget.cpp.

◆ setShowLabel()

void QgsAbstractRelationEditorWidget::setShowLabel ( bool  showLabel)

Defines if a title label should be shown for this widget.

Definition at line 144 of file qgsabstractrelationeditorwidget.cpp.

◆ setTitle()

void QgsAbstractRelationEditorWidget::setTitle ( const QString &  title)
protectedvirtual

Sets the title of the widget, if it is wrapped within a QgsCollapsibleGroupBox Check QgsRealationEditorWidget as an example.

Reimplemented in QgsRelationEditorWidget.

Definition at line 592 of file qgsabstractrelationeditorwidget.cpp.

◆ showLabel()

bool QgsAbstractRelationEditorWidget::showLabel ( ) const

Defines if a title label should be shown for this widget.

Definition at line 139 of file qgsabstractrelationeditorwidget.cpp.

◆ toggleEditing

void QgsAbstractRelationEditorWidget::toggleEditing ( bool  state)
protectedslot

Toggles editing state of the widget.

Definition at line 182 of file qgsabstractrelationeditorwidget.cpp.

◆ unlinkFeature

void QgsAbstractRelationEditorWidget::unlinkFeature ( QgsFeatureId  fid = QgsFeatureId())
protectedslot

Unlinks a feature with given fid.

Definition at line 502 of file qgsabstractrelationeditorwidget.cpp.

◆ unlinkFeatures()

void QgsAbstractRelationEditorWidget::unlinkFeatures ( const QgsFeatureIds fids)
protected

Unlinks the features with fids.

Definition at line 507 of file qgsabstractrelationeditorwidget.cpp.

◆ updateTitle()

void QgsAbstractRelationEditorWidget::updateTitle ( )
protected

Updates the title contents to reflect the current state of the widget.

Definition at line 161 of file qgsabstractrelationeditorwidget.cpp.

◆ updateUi()

void QgsAbstractRelationEditorWidget::updateUi ( )
protectedvirtual

A hook called every time the state of the relation editor widget has changed via calling its set* methods or slots, e.g.

changed relation, added feature, etc. Should be used to refresh the UI regarding the new data. Check QgsRealationEditorWidget as an example.

Reimplemented in QgsRelationEditorWidget.

Definition at line 589 of file qgsabstractrelationeditorwidget.cpp.

Member Data Documentation

◆ mEditorContext

QgsAttributeEditorContext QgsAbstractRelationEditorWidget::mEditorContext
protected

Definition at line 220 of file qgsabstractrelationeditorwidget.h.

◆ mFeature

QgsFeature QgsAbstractRelationEditorWidget::mFeature
protected

Definition at line 223 of file qgsabstractrelationeditorwidget.h.

◆ mForceSuppressFormPopup

bool QgsAbstractRelationEditorWidget::mForceSuppressFormPopup = false
protected

Definition at line 228 of file qgsabstractrelationeditorwidget.h.

◆ mLabel

QString QgsAbstractRelationEditorWidget::mLabel
protected

Definition at line 230 of file qgsabstractrelationeditorwidget.h.

◆ mLayerInSameTransactionGroup

bool QgsAbstractRelationEditorWidget::mLayerInSameTransactionGroup = false
protected

Definition at line 226 of file qgsabstractrelationeditorwidget.h.

◆ mNmRelation

QgsRelation QgsAbstractRelationEditorWidget::mNmRelation
protected

Definition at line 222 of file qgsabstractrelationeditorwidget.h.

◆ mNmRelationId

QVariant QgsAbstractRelationEditorWidget::mNmRelationId
protected

Definition at line 229 of file qgsabstractrelationeditorwidget.h.

◆ mRelation

QgsRelation QgsAbstractRelationEditorWidget::mRelation
protected

Definition at line 221 of file qgsabstractrelationeditorwidget.h.

◆ mShowLabel

bool QgsAbstractRelationEditorWidget::mShowLabel = true
protected

Definition at line 225 of file qgsabstractrelationeditorwidget.h.


The documentation for this class was generated from the following files: