QGIS API Documentation 3.99.0-Master (26c88405ac0)
Loading...
Searching...
No Matches
QgsRelationReferenceWidget Class Reference

A widget which shows related features. More...

#include <qgsrelationreferencewidget.h>

Inheritance diagram for QgsRelationReferenceWidget:

Public Types

enum  CanvasExtent { Fixed , Pan , Scale }

Public Slots

void deleteForeignKeys ()
 unset the currently related feature
void mapIdentification ()
 activate the map tool to select a new related feature on the map
void openForm ()
 open the form of the related feature in a new dialog
bool saveReferencedAttributeForm ()
 Trigger save of the embedded referenced attribute form.

Signals

Q_DECL_DEPRECATED void foreignKeyChanged (const QVariant &key)
 Emitted when the foreign key changed.
void foreignKeysChanged (const QVariantList &keys)
 Emitted when the foreign keys changed.

Public Member Functions

 QgsRelationReferenceWidget (QWidget *parent)
 ~QgsRelationReferenceWidget () override
bool allowAddFeatures () const
 Determines if a button for adding new features should be shown.
bool allowMapIdentification () const
 determines if the widget offers the possibility to select the related feature on the map (using a dedicated map tool)
bool chainFilters () const
 Determines if the filters are chained.
bool embedForm () const
 determines if the form of the related feature will be shown
int fetchLimit () const
 Returns the limit of fetched features (0 means all features).
QString filterExpression () const
 Returns the currently set filter expression.
Q_DECL_DEPRECATED QVariant foreignKey () const
 returns the related feature foreign key
QVariantList foreignKeys () const
 returns the related feature foreign key
bool openFormButtonVisible () const
 determines the open form button is visible in the widget
QString orderExpression () const
 Returns the string of the order expression The order expression will be used for sort values in the combobox.
bool readOnlySelector () const
 determines if the drop-down is enabled
QgsFeature referencedFeature () const
 Returns the related feature (from the referenced layer) if no feature is related, it returns an invalid feature.
QString referencedLayerDataSource () const
 Returns the public data source of the referenced layer.
QString referencedLayerId () const
 Returns the id of the referenced layer.
QString referencedLayerName () const
 Returns the name of the referenced layer.
QString referencedLayerProviderKey () const
 Returns the data provider key of the referenced layer.
QgsRelation relation () const
 Returns the current relation, which might be invalid.
void setAllowAddFeatures (bool allowAddFeatures)
 Determines if a button for adding new features should be shown.
void setAllowMapIdentification (bool allowMapIdentification)
void setChainFilters (bool chainFilters)
 Set if filters are chained.
void setEditorContext (const QgsAttributeEditorContext &context, QgsMapCanvas *canvas, QgsMessageBar *messageBar)
 Sets the editor context.
void setEmbedForm (bool display)
void setFetchLimit (int fetchLimit)
 Set the limit of fetched features (0 means all features).
void setFilterExpression (const QString &filterExpression)
 If not empty, will be used as filter expression.
void setFilterFields (const QStringList &filterFields)
 Sets the fields for which filter comboboxes will be created.
Q_DECL_DEPRECATED void setForeignKey (const QVariant &value)
 this sets the related feature using from the foreign key
void setForeignKeys (const QVariantList &values)
 Sets the related feature using the foreign keys.
void setFormFeature (const QgsFeature &formFeature)
 Set the current form feature (from the referencing layer).
void setOpenFormButtonVisible (bool openFormButtonVisible)
void setOrderExpression (const QString &orderExpression)
 Set the string of the order expression The order expression will be used for sort values in the combobox.
void setParentFormFeature (const QgsFeature &parentFormFeature)
 Set the current parent form feature.
void setReadOnlySelector (bool readOnly)
void setReferencedLayerDataSource (const QString &referencedLayerDataSource)
 Set the public data source of the referenced layer to referencedLayerDataSource.
void setReferencedLayerId (const QString &referencedLayerId)
 Set the id of the referenced layer to referencedLayerId.
void setReferencedLayerName (const QString &referencedLayerName)
 Set the name of the referenced layer to referencedLayerName.
void setReferencedLayerProviderKey (const QString &referencedLayerProviderKey)
 Set the data provider key of the referenced layer to referencedLayerProviderKey.
void setRelation (const QgsRelation &relation, bool allowNullValue)
void setRelationEditable (bool editable)
void setSortOrder (const Qt::SortOrder sortOrder)
 Set the order direction The order direction will be used for sort values in the combobox.
void showIndeterminateState ()
 Sets the widget to display in an indeterminate "mixed value" state.
Qt::SortOrder sortOrder () const
 Returns the order direction The order direction will be used for sort values in the combobox.

Protected Member Functions

void init ()
void showEvent (QShowEvent *e) override

Properties

bool openFormButtonVisible

Friends

class TestQgsRelationReferenceWidget

Detailed Description

A widget which shows related features.

Definition at line 58 of file qgsrelationreferencewidget.h.

Member Enumeration Documentation

◆ CanvasExtent

Enumerator
Fixed 
Pan 
Scale 

Definition at line 73 of file qgsrelationreferencewidget.h.

Constructor & Destructor Documentation

◆ QgsRelationReferenceWidget()

QgsRelationReferenceWidget::QgsRelationReferenceWidget ( QWidget * parent)
explicit

Definition at line 57 of file qgsrelationreferencewidget.cpp.

◆ ~QgsRelationReferenceWidget()

QgsRelationReferenceWidget::~QgsRelationReferenceWidget ( )
override

Definition at line 157 of file qgsrelationreferencewidget.cpp.

Member Function Documentation

◆ allowAddFeatures()

bool QgsRelationReferenceWidget::allowAddFeatures ( ) const

Determines if a button for adding new features should be shown.

Definition at line 662 of file qgsrelationreferencewidget.cpp.

◆ allowMapIdentification()

bool QgsRelationReferenceWidget::allowMapIdentification ( ) const
inline

determines if the widget offers the possibility to select the related feature on the map (using a dedicated map tool)

Definition at line 130 of file qgsrelationreferencewidget.h.

◆ chainFilters()

bool QgsRelationReferenceWidget::chainFilters ( ) const
inline

Determines if the filters are chained.

Returns
true if filters are chained

Definition at line 145 of file qgsrelationreferencewidget.h.

◆ deleteForeignKeys

void QgsRelationReferenceWidget::deleteForeignKeys ( )
slot

unset the currently related feature

Definition at line 281 of file qgsrelationreferencewidget.cpp.

◆ embedForm()

bool QgsRelationReferenceWidget::embedForm ( ) const
inline

determines if the form of the related feature will be shown

Definition at line 122 of file qgsrelationreferencewidget.h.

◆ fetchLimit()

int QgsRelationReferenceWidget::fetchLimit ( ) const
inline

Returns the limit of fetched features (0 means all features).

Since
QGIS 3.32

Definition at line 261 of file qgsrelationreferencewidget.h.

◆ filterExpression()

QString QgsRelationReferenceWidget::filterExpression ( ) const
inline

Returns the currently set filter expression.

Definition at line 158 of file qgsrelationreferencewidget.h.

◆ foreignKey()

QVariant QgsRelationReferenceWidget::foreignKey ( ) const

returns the related feature foreign key

Deprecated
QGIS 3.10

Definition at line 324 of file qgsrelationreferencewidget.cpp.

◆ foreignKeyChanged

Q_DECL_DEPRECATED void QgsRelationReferenceWidget::foreignKeyChanged ( const QVariant & key)
signal

Emitted when the foreign key changed.

Deprecated
QGIS 3.10

◆ foreignKeys()

QVariantList QgsRelationReferenceWidget::foreignKeys ( ) const

returns the related feature foreign key

Returns the related feature foreign keys

Since
QGIS 3.10

Definition at line 333 of file qgsrelationreferencewidget.cpp.

◆ foreignKeysChanged

void QgsRelationReferenceWidget::foreignKeysChanged ( const QVariantList & keys)
signal

Emitted when the foreign keys changed.

Since
QGIS 3.10

◆ init()

void QgsRelationReferenceWidget::init ( )
protected

Definition at line 411 of file qgsrelationreferencewidget.cpp.

◆ mapIdentification

void QgsRelationReferenceWidget::mapIdentification ( )
slot

activate the map tool to select a new related feature on the map

Definition at line 611 of file qgsrelationreferencewidget.cpp.

◆ openForm

void QgsRelationReferenceWidget::openForm ( )
slot

open the form of the related feature in a new dialog

Definition at line 536 of file qgsrelationreferencewidget.cpp.

◆ openFormButtonVisible()

bool QgsRelationReferenceWidget::openFormButtonVisible ( ) const
inline

determines the open form button is visible in the widget

Definition at line 137 of file qgsrelationreferencewidget.h.

◆ orderExpression()

QString QgsRelationReferenceWidget::orderExpression ( ) const
inline

Returns the string of the order expression The order expression will be used for sort values in the combobox.

Since
QGIS 4.0

Definition at line 274 of file qgsrelationreferencewidget.h.

◆ readOnlySelector()

bool QgsRelationReferenceWidget::readOnlySelector ( ) const
inline

determines if the drop-down is enabled

Definition at line 126 of file qgsrelationreferencewidget.h.

◆ referencedFeature()

QgsFeature QgsRelationReferenceWidget::referencedFeature ( ) const

Returns the related feature (from the referenced layer) if no feature is related, it returns an invalid feature.

Definition at line 307 of file qgsrelationreferencewidget.cpp.

◆ referencedLayerDataSource()

QString QgsRelationReferenceWidget::referencedLayerDataSource ( ) const

Returns the public data source of the referenced layer.

Since
QGIS 3.12

Definition at line 1010 of file qgsrelationreferencewidget.cpp.

◆ referencedLayerId()

QString QgsRelationReferenceWidget::referencedLayerId ( ) const

Returns the id of the referenced layer.

Since
QGIS 3.12

Definition at line 990 of file qgsrelationreferencewidget.cpp.

◆ referencedLayerName()

QString QgsRelationReferenceWidget::referencedLayerName ( ) const

Returns the name of the referenced layer.

Since
QGIS 3.12

Definition at line 980 of file qgsrelationreferencewidget.cpp.

◆ referencedLayerProviderKey()

QString QgsRelationReferenceWidget::referencedLayerProviderKey ( ) const

Returns the data provider key of the referenced layer.

Since
QGIS 3.12

Definition at line 1000 of file qgsrelationreferencewidget.cpp.

◆ relation()

QgsRelation QgsRelationReferenceWidget::relation ( ) const

Returns the current relation, which might be invalid.

Since
QGIS 3.10

Definition at line 673 of file qgsrelationreferencewidget.cpp.

◆ saveReferencedAttributeForm

bool QgsRelationReferenceWidget::saveReferencedAttributeForm ( )
slot

Trigger save of the embedded referenced attribute form.

Returns true on success or if no embedded form is present.

Since
QGIS 3.42

Definition at line 298 of file qgsrelationreferencewidget.cpp.

◆ setAllowAddFeatures()

void QgsRelationReferenceWidget::setAllowAddFeatures ( bool allowAddFeatures)

Determines if a button for adding new features should be shown.

Definition at line 667 of file qgsrelationreferencewidget.cpp.

◆ setAllowMapIdentification()

void QgsRelationReferenceWidget::setAllowMapIdentification ( bool allowMapIdentification)

Definition at line 374 of file qgsrelationreferencewidget.cpp.

◆ setChainFilters()

void QgsRelationReferenceWidget::setChainFilters ( bool chainFilters)

Set if filters are chained.

Chained filters restrict the option of subsequent filters based on the selection of a previous filter.

Parameters
chainFiltersIf chaining should be enabled

Definition at line 392 of file qgsrelationreferencewidget.cpp.

◆ setEditorContext()

void QgsRelationReferenceWidget::setEditorContext ( const QgsAttributeEditorContext & context,
QgsMapCanvas * canvas,
QgsMessageBar * messageBar )

Sets the editor context.

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

Definition at line 338 of file qgsrelationreferencewidget.cpp.

◆ setEmbedForm()

void QgsRelationReferenceWidget::setEmbedForm ( bool display)

Definition at line 355 of file qgsrelationreferencewidget.cpp.

◆ setFetchLimit()

void QgsRelationReferenceWidget::setFetchLimit ( int fetchLimit)
inline

Set the limit of fetched features (0 means all features).

Since
QGIS 3.32

Definition at line 267 of file qgsrelationreferencewidget.h.

◆ setFilterExpression()

void QgsRelationReferenceWidget::setFilterExpression ( const QString & filterExpression)

If not empty, will be used as filter expression.

Only if this evaluates to true, the value will be shown.

Definition at line 397 of file qgsrelationreferencewidget.cpp.

◆ setFilterFields()

void QgsRelationReferenceWidget::setFilterFields ( const QStringList & filterFields)

Sets the fields for which filter comboboxes will be created.

Definition at line 381 of file qgsrelationreferencewidget.cpp.

◆ setForeignKey()

void QgsRelationReferenceWidget::setForeignKey ( const QVariant & value)

this sets the related feature using from the foreign key

Deprecated
QGIS 3.10. Use setForeignKeys.

Definition at line 235 of file qgsrelationreferencewidget.cpp.

◆ setForeignKeys()

void QgsRelationReferenceWidget::setForeignKeys ( const QVariantList & values)

Sets the related feature using the foreign keys.

Since
QGIS 3.10

Definition at line 240 of file qgsrelationreferencewidget.cpp.

◆ setFormFeature()

void QgsRelationReferenceWidget::setFormFeature ( const QgsFeature & formFeature)

Set the current form feature (from the referencing layer).

Since
QGIS 3.10

Definition at line 1021 of file qgsrelationreferencewidget.cpp.

◆ setOpenFormButtonVisible()

void QgsRelationReferenceWidget::setOpenFormButtonVisible ( bool openFormButtonVisible)

Definition at line 386 of file qgsrelationreferencewidget.cpp.

◆ setOrderExpression()

void QgsRelationReferenceWidget::setOrderExpression ( const QString & orderExpression)
inline

Set the string of the order expression The order expression will be used for sort values in the combobox.

Since
QGIS 4.0

Definition at line 281 of file qgsrelationreferencewidget.h.

◆ setParentFormFeature()

void QgsRelationReferenceWidget::setParentFormFeature ( const QgsFeature & parentFormFeature)

Set the current parent form feature.

Since
QGIS 3.42.2

Definition at line 1026 of file qgsrelationreferencewidget.cpp.

◆ setReadOnlySelector()

void QgsRelationReferenceWidget::setReadOnlySelector ( bool readOnly)

Definition at line 367 of file qgsrelationreferencewidget.cpp.

◆ setReferencedLayerDataSource()

void QgsRelationReferenceWidget::setReferencedLayerDataSource ( const QString & referencedLayerDataSource)

Set the public data source of the referenced layer to referencedLayerDataSource.

Since
QGIS 3.12

Definition at line 1015 of file qgsrelationreferencewidget.cpp.

◆ setReferencedLayerId()

void QgsRelationReferenceWidget::setReferencedLayerId ( const QString & referencedLayerId)

Set the id of the referenced layer to referencedLayerId.

Since
QGIS 3.12

Definition at line 995 of file qgsrelationreferencewidget.cpp.

◆ setReferencedLayerName()

void QgsRelationReferenceWidget::setReferencedLayerName ( const QString & referencedLayerName)

Set the name of the referenced layer to referencedLayerName.

Since
QGIS 3.12

Definition at line 985 of file qgsrelationreferencewidget.cpp.

◆ setReferencedLayerProviderKey()

void QgsRelationReferenceWidget::setReferencedLayerProviderKey ( const QString & referencedLayerProviderKey)

Set the data provider key of the referenced layer to referencedLayerProviderKey.

Since
QGIS 3.12

Definition at line 1005 of file qgsrelationreferencewidget.cpp.

◆ setRelation()

void QgsRelationReferenceWidget::setRelation ( const QgsRelation & relation,
bool allowNullValue )

Definition at line 163 of file qgsrelationreferencewidget.cpp.

◆ setRelationEditable()

void QgsRelationReferenceWidget::setRelationEditable ( bool editable)

Definition at line 220 of file qgsrelationreferencewidget.cpp.

◆ setSortOrder()

void QgsRelationReferenceWidget::setSortOrder ( const Qt::SortOrder sortOrder)
inline

Set the order direction The order direction will be used for sort values in the combobox.

Ascending or descending

Since
QGIS 4.0

Definition at line 295 of file qgsrelationreferencewidget.h.

◆ showEvent()

void QgsRelationReferenceWidget::showEvent ( QShowEvent * e)
overrideprotected

Definition at line 402 of file qgsrelationreferencewidget.cpp.

◆ showIndeterminateState()

void QgsRelationReferenceWidget::showIndeterminateState ( )

Sets the widget to display in an indeterminate "mixed value" state.

Definition at line 317 of file qgsrelationreferencewidget.cpp.

◆ sortOrder()

Qt::SortOrder QgsRelationReferenceWidget::sortOrder ( ) const
inline

Returns the order direction The order direction will be used for sort values in the combobox.

Ascending or descending

Since
QGIS 4.0

Definition at line 288 of file qgsrelationreferencewidget.h.

◆ TestQgsRelationReferenceWidget

friend class TestQgsRelationReferenceWidget
friend

Definition at line 415 of file qgsrelationreferencewidget.h.

Property Documentation

◆ openFormButtonVisible

bool QgsRelationReferenceWidget::openFormButtonVisible
readwrite

Definition at line 70 of file qgsrelationreferencewidget.h.


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