QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
Public Types | Public Slots | Public Member Functions | Protected Member Functions | Properties | Friends | List of all members
QgsRelationEditorWidget Class Reference

The default relation widget in QGIS. More...

#include <qgsrelationeditorwidget.h>

Inheritance diagram for QgsRelationEditorWidget:
Inheritance graph
[legend]

Public Types

enum  Button {
  NoButton = 0 , Link = 1 << 1 , Unlink = 1 << 2 , SaveChildEdits = 1 << 3 ,
  AddChildFeature = 1 << 4 , DuplicateChildFeature = 1 << 5 , DeleteChildFeature = 1 << 6 , ZoomToChildFeature = 1 << 7 ,
  AllButtons = Link | Unlink | SaveChildEdits | AddChildFeature | DuplicateChildFeature | DeleteChildFeature | ZoomToChildFeature
}
 Possible buttons shown in the relation editor. More...
 
typedef QFlags< ButtonButtons
 

Public Slots

void parentFormValueChanged (const QString &attribute, const QVariant &newValue) override
 
- Public Slots inherited from QgsAbstractRelationEditorWidget
virtual void parentFormValueChanged (const QString &attribute, const QVariant &newValue)=0
 Called when an attribute value in the parent widget has changed to newValue.
 

Public Member Functions

 QgsRelationEditorWidget (const QVariantMap &config, QWidget *parent=nullptr)
 Constructor.
 
QVariantMap config () const override
 Returns the current configuration.
 
void deleteSelectedFeatures ()
 Deletes the currently selected features.
 
Q_DECL_DEPRECATED void duplicateFeature ()
 Duplicates a feature.
 
void duplicateSelectedFeatures ()
 Duplicates the selected features.
 
QgsIFeatureSelectionManagerfeatureSelectionManager ()
 The feature selection manager is responsible for the selected features which are currently being edited.
 
void setConfig (const QVariantMap &config) override
 Defines the current configuration.
 
void setEditorContext (const QgsAttributeEditorContext &context) override
 Sets the editor context.
 
void setViewMode (QgsDualView::ViewMode mode)
 Define the view mode for the dual view.
 
void setVisibleButtons (const Buttons &buttons)
 Defines the buttons which are shown.
 
void unlinkSelectedFeatures ()
 Unlinks the selected features from the relation.
 
QgsDualView::ViewMode viewMode ()
 Gets the view mode for the dual view.
 
Buttons visibleButtons () const
 Returns the buttons which are shown.
 
void zoomToSelectedFeatures ()
 Zooms to the selected features.
 
- Public Member Functions inherited from QgsAbstractRelationEditorWidget
 QgsAbstractRelationEditorWidget (const QVariantMap &config, QWidget *parent=nullptr)
 Constructor.
 
QgsAttributeEditorContext editorContext () const
 Returns the attribute editor context.
 
QgsFeature feature () const
 Returns the widget's current feature If the widget is in multiedit mode only the first is returned.
 
QList< QgsFeaturefeatures () const
 Returns the widget's current features.
 
bool forceSuppressFormPopup () const
 Determines the force suppress form popup status that is configured for this widget.
 
Q_DECL_DEPRECATED QString label () const
 Determines the label of this element.
 
bool multiEditModeActive () const
 Returns true if editing multiple features at a time.
 
QgsRelation nmRelation () const
 Returns the nm relation.
 
QVariant nmRelationId () const
 Determines the relation id of the second relation involved in an N:M relation.
 
QgsRelation relation () const
 Returns the relation.
 
void setFeature (const QgsFeature &feature, bool update=true)
 Sets the feature being edited and updates the UI unless update is set to false.
 
void setForceSuppressFormPopup (bool forceSuppressFormPopup)
 Sets force suppress form popup status with forceSuppressFormPopup configured for this widget.
 
void setLabel (const QString &label=QString())
 Sets label for this element If it's empty it takes the relation id as label.
 
void setMultiEditFeatureIds (const QgsFeatureIds &fids)
 Set multiple feature to edit simultaneously.
 
void setNmRelationId (const QVariant &nmRelationId=QVariant())
 Sets nmRelationId for the relation id of the second relation involved in an N:M relation.
 
void setRelationFeature (const QgsRelation &relation, const QgsFeature &feature)
 Sets the relation and the feature.
 
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.
 
Q_DECL_DEPRECATED void setShowLabel (bool showLabel)
 Defines if a title label should be shown for this widget.
 
Q_DECL_DEPRECATED bool showLabel () const
 Defines if a title label should be shown for this widget.
 

Protected Member Functions

void afterSetRelationFeature () override
 A hook called right after setRelationFeature() is executed, but before updateUi() is called.
 
void afterSetRelations () override
 A hook called right after setRelations() is executed, but before updateUi() is called.
 
void beforeSetRelationFeature (const QgsRelation &newRelation, const QgsFeature &newFeature) override
 A hook called right before setRelationFeature() is executed.
 
void beforeSetRelations (const QgsRelation &newRelation, const QgsRelation &newNmRelation) override
 A hook called right before setRelations() is executed.
 
virtual void updateUi () override
 A hook called every time the state of the relation editor widget has changed via calling its set* methods or slots, e.g.
 
- Protected Member Functions inherited from QgsAbstractRelationEditorWidget
void deleteFeatures (const QgsFeatureIds &fids)
 Deletes the features with fids.
 
virtual Q_DECL_DEPRECATED void setTitle (const QString &title)
 Sets the title of the widget, if it is wrapped within a QgsCollapsibleGroupBox.
 
void showEvent (QShowEvent *)
 Refresh the UI when the widget becomes visible.
 
void unlinkFeatures (const QgsFeatureIds &fids)
 Unlinks the features with fids.
 
Q_DECL_DEPRECATED void updateTitle ()
 Updates the title contents to reflect the current state of the widget.
 

Properties

QgsDualView::ViewMode viewMode
 
Buttons visibleButtons
 

Friends

class TestQgsRelationEditorWidget
 

Additional Inherited Members

- Signals inherited from QgsAbstractRelationEditorWidget
void relatedFeaturesChanged ()
 Emit this signal, whenever the related features changed.
 
- Protected Slots inherited from QgsAbstractRelationEditorWidget
QgsFeatureIds addFeature (const QgsGeometry &geometry=QgsGeometry())
 Adds new features with given geometry Returns the Id of added features.
 
void deleteFeature (QgsFeatureId fid=QgsFeatureId())
 Delete a feature with given fid.
 
void duplicateFeature (const QgsFeatureId &fid)
 Duplicates a feature.
 
void duplicateFeatures (const QgsFeatureIds &fids)
 Duplicates features.
 
void linkFeature (const QString &filterExpression=QString())
 Links a new feature to the relation.
 
void onLinkFeatureDlgAccepted ()
 Called when the link feature dialog is confirmed by the user.
 
void saveEdits ()
 Saves the current modifications in the relation.
 
void toggleEditing (bool state)
 Toggles editing state of the widget.
 
void unlinkFeature (QgsFeatureId fid=QgsFeatureId())
 Unlinks a feature with given fid.
 
- Protected Attributes inherited from QgsAbstractRelationEditorWidget
QgsAttributeEditorContext mEditorContext
 
QgsFeatureList mFeatureList
 
bool mForceSuppressFormPopup = false
 
bool mLayerInSameTransactionGroup = false
 
QgsRelation mNmRelation
 
QgsRelation mRelation
 

Detailed Description

The default relation widget in QGIS.

Since
QGIS 3.18

Definition at line 89 of file qgsrelationeditorwidget.h.

Member Typedef Documentation

◆ Buttons

Definition at line 115 of file qgsrelationeditorwidget.h.

Member Enumeration Documentation

◆ Button

Possible buttons shown in the relation editor.

Since
QGIS 3.18
Enumerator
NoButton 

No button.

Since
QGIS 3.20
Link 

Link button.

Unlink 

Unlink button.

SaveChildEdits 

Save child edits button.

AddChildFeature 

Add child feature (as in some projects we only want to allow linking/unlinking existing features)

DuplicateChildFeature 

Duplicate child feature.

DeleteChildFeature 

Delete child feature button.

ZoomToChildFeature 

Zoom to child feature.

AllButtons 

All buttons.

Definition at line 102 of file qgsrelationeditorwidget.h.

Constructor & Destructor Documentation

◆ QgsRelationEditorWidget()

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

Constructor.

Parameters
configwidget configuration
parentparent widget

Definition at line 94 of file qgsrelationeditorwidget.cpp.

Member Function Documentation

◆ afterSetRelationFeature()

void QgsRelationEditorWidget::afterSetRelationFeature ( )
overrideprotectedvirtual

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 from QgsAbstractRelationEditorWidget.

Definition at line 867 of file qgsrelationeditorwidget.cpp.

◆ afterSetRelations()

void QgsRelationEditorWidget::afterSetRelations ( )
overrideprotectedvirtual

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 from QgsAbstractRelationEditorWidget.

Definition at line 903 of file qgsrelationeditorwidget.cpp.

◆ beforeSetRelationFeature()

void QgsRelationEditorWidget::beforeSetRelationFeature ( const QgsRelation newRelation,
const QgsFeature newFeature 
)
overrideprotectedvirtual

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 from QgsAbstractRelationEditorWidget.

Definition at line 855 of file qgsrelationeditorwidget.cpp.

◆ beforeSetRelations()

void QgsRelationEditorWidget::beforeSetRelations ( const QgsRelation newRelation,
const QgsRelation newNmRelation 
)
overrideprotectedvirtual

A hook called right before setRelations() is executed.

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

Reimplemented from QgsAbstractRelationEditorWidget.

Definition at line 885 of file qgsrelationeditorwidget.cpp.

◆ config()

QVariantMap QgsRelationEditorWidget::config ( ) const
overridevirtual

Returns the current configuration.

Implements QgsAbstractRelationEditorWidget.

Definition at line 837 of file qgsrelationeditorwidget.cpp.

◆ deleteSelectedFeatures()

void QgsRelationEditorWidget::deleteSelectedFeatures ( )

Deletes the currently selected features.

Definition at line 941 of file qgsrelationeditorwidget.cpp.

◆ duplicateFeature()

void QgsRelationEditorWidget::duplicateFeature ( )

Duplicates a feature.

Deprecated:
QGIS 3.18. Use duplicateSelectedFeatures() instead.

Definition at line 931 of file qgsrelationeditorwidget.cpp.

◆ duplicateSelectedFeatures()

void QgsRelationEditorWidget::duplicateSelectedFeatures ( )

Duplicates the selected features.

Since
QGIS 3.18

Definition at line 936 of file qgsrelationeditorwidget.cpp.

◆ featureSelectionManager()

QgsIFeatureSelectionManager * QgsRelationEditorWidget::featureSelectionManager ( )

The feature selection manager is responsible for the selected features which are currently being edited.

Definition at line 920 of file qgsrelationeditorwidget.cpp.

◆ parentFormValueChanged

void QgsRelationEditorWidget::parentFormValueChanged ( const QString &  attribute,
const QVariant &  newValue 
)
overrideslot

Definition at line 553 of file qgsrelationeditorwidget.cpp.

◆ setConfig()

void QgsRelationEditorWidget::setConfig ( const QVariantMap &  config)
overridevirtual

Defines the current configuration.

Implements QgsAbstractRelationEditorWidget.

Definition at line 846 of file qgsrelationeditorwidget.cpp.

◆ setEditorContext()

void QgsRelationEditorWidget::setEditorContext ( const QgsAttributeEditorContext context)
overridevirtual

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 from QgsAbstractRelationEditorWidget.

Definition at line 285 of file qgsrelationeditorwidget.cpp.

◆ setViewMode()

void QgsRelationEditorWidget::setViewMode ( QgsDualView::ViewMode  mode)

Define the view mode for the dual view.

Definition at line 298 of file qgsrelationeditorwidget.cpp.

◆ setVisibleButtons()

void QgsRelationEditorWidget::setVisibleButtons ( const Buttons buttons)

Defines the buttons which are shown.

Definition at line 527 of file qgsrelationeditorwidget.cpp.

◆ unlinkSelectedFeatures()

void QgsRelationEditorWidget::unlinkSelectedFeatures ( )

Unlinks the selected features from the relation.

Definition at line 925 of file qgsrelationeditorwidget.cpp.

◆ updateUi()

void QgsRelationEditorWidget::updateUi ( )
overrideprotectedvirtual

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 from QgsAbstractRelationEditorWidget.

Definition at line 513 of file qgsrelationeditorwidget.cpp.

◆ viewMode()

QgsDualView::ViewMode QgsRelationEditorWidget::viewMode ( )
inline

Gets the view mode for the dual view.

Definition at line 129 of file qgsrelationeditorwidget.h.

◆ visibleButtons()

QgsRelationEditorWidget::Buttons QgsRelationEditorWidget::visibleButtons ( ) const

Returns the buttons which are shown.

Definition at line 533 of file qgsrelationeditorwidget.cpp.

◆ zoomToSelectedFeatures()

void QgsRelationEditorWidget::zoomToSelectedFeatures ( )

Zooms to the selected features.

Definition at line 947 of file qgsrelationeditorwidget.cpp.

Friends And Related Symbol Documentation

◆ TestQgsRelationEditorWidget

friend class TestQgsRelationEditorWidget
friend

Definition at line 273 of file qgsrelationeditorwidget.h.

Property Documentation

◆ viewMode

QgsDualView::ViewMode QgsRelationEditorWidget::viewMode
readwrite

Definition at line 93 of file qgsrelationeditorwidget.h.

◆ visibleButtons

Buttons QgsRelationEditorWidget::visibleButtons
readwrite

Definition at line 94 of file qgsrelationeditorwidget.h.


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