QGIS API Documentation 3.41.0-Master (45a0abf3bec)
Loading...
Searching...
No Matches
Classes | Public Types | Public Member Functions | Static Public Member Functions | Friends | List of all members
QgsEditFormConfig Class Reference

Contains configuration settings for an editor form. More...

#include <qgseditformconfig.h>

Classes

struct  GroupData
 
struct  TabData
 

Public Types

enum class  DataDefinedProperty : int { NoProperty = 0 , AllProperties = 1 , Alias = 2 , Editable = 3 }
 Data defined properties. More...
 

Public Member Functions

 QgsEditFormConfig ()
 Create a new edit form config.
 
 QgsEditFormConfig (const QgsEditFormConfig &o)
 
 ~QgsEditFormConfig ()
 
void addTab (QgsAttributeEditorElement *data)
 Adds a new element to the invisible root container in the layout.
 
Q_DECL_DEPRECATED QgsAttributeEditorElementattributeEditorElementFromDomElement (QDomElement &elem, QgsAttributeEditorElement *parent, const QString &layerId=QString(), const QgsReadWriteContext &context=QgsReadWriteContext())
 Deserialize drag and drop designer elements.
 
void clearTabs ()
 Clears all the tabs for the attribute editor form with EditorLayout::TabLayout.
 
QgsPropertyCollection dataDefinedFieldProperties (const QString &fieldName) const
 Returns data defined properties for fieldName.
 
QString initCode () const
 Gets Python code for edit form initialization.
 
Qgis::AttributeFormPythonInitCodeSource initCodeSource () const
 Returns Python code source for edit form initialization (if it shall be loaded from a file, read from the provided dialog editor or inherited from the environment)
 
QString initFilePath () const
 Gets Python external file path for edit form initialization.
 
QString initFunction () const
 Gets Python function for edit form initialization.
 
QgsAttributeEditorContainerinvisibleRootContainer ()
 Gets the invisible root container for the drag and drop designer form (EditorLayout::TabLayout).
 
bool labelOnTop (int idx) const
 If this returns true, the widget at the given index will receive its label on the previous line while if it returns false, the widget will receive its label on the left hand side.
 
Qgis::AttributeFormLayout layout () const
 Gets the active layout style for the attribute editor for this layer.
 
QgsEditFormConfigoperator= (const QgsEditFormConfig &o)
 
bool operator== (const QgsEditFormConfig &o) const
 
bool readOnly (int idx) const
 This returns true if the field is manually set to read only or if the field does not support editing like joins or virtual fields.
 
void readXml (const QDomNode &node, QgsReadWriteContext &context)
 Read XML information Deserialize on project load.
 
bool removeWidgetConfig (const QString &widgetName)
 Remove the configuration for the editor widget with the given name.
 
bool reuseLastValue (int index) const
 If this returns true, the widget at the given index will remember the previously entered value from this QGIS session when creating new features.
 
void setDataDefinedFieldProperties (const QString &fieldName, const QgsPropertyCollection &properties)
 Set data defined properties for fieldName to properties.
 
void setInitCode (const QString &code)
 Set Python code for edit form initialization.
 
void setInitCodeSource (Qgis::AttributeFormPythonInitCodeSource initCodeSource)
 Sets if Python code shall be used for edit form initialization and its origin.
 
void setInitFilePath (const QString &filePath)
 Set Python external file path for edit form initialization.
 
void setInitFunction (const QString &function)
 Set Python function for edit form initialization.
 
void setLabelOnTop (int idx, bool onTop)
 If this is set to true, the widget at the given index will receive its label on the previous line while if it is set to false, the widget will receive its label on the left hand side.
 
void setLayout (Qgis::AttributeFormLayout editorLayout)
 Sets the active layout style for the attribute editor for this layer.
 
void setReadOnly (int idx, bool readOnly=true)
 If set to false, the widget at the given index will be read-only.
 
void setReuseLastValue (int index, bool reuse)
 Sets whether the widget at the given index will remember the previously entered value from this QGIS session when creating new features.
 
void setSuppress (Qgis::AttributeFormSuppression s)
 Sets type of feature form pop-up suppression after feature creation (overrides app setting)
 
void setUiForm (const QString &ui)
 Set path to the .ui form.
 
bool setWidgetConfig (const QString &widgetName, const QVariantMap &config)
 Set the editor widget config for a widget which is not for a simple field.
 
Qgis::AttributeFormSuppression suppress () const
 Type of feature form pop-up suppression after feature creation (overrides app setting)
 
QList< QgsAttributeEditorElement * > tabs () const
 Returns a list of tabs for EditorLayout::TabLayout obtained from the invisible root container.
 
QString uiForm () const
 Returns the path or URL to the .ui form.
 
QVariantMap widgetConfig (const QString &widgetName) const
 Gets the configuration for the editor widget with the given name.
 
void writeXml (QDomNode &node, const QgsReadWriteContext &context) const
 Write XML information Serialize on project save.
 

Static Public Member Functions

static const QgsPropertiesDefinitionpropertyDefinitions ()
 Returns data defined property definitions.
 

Friends

class QgsVectorLayer
 

Detailed Description

Contains configuration settings for an editor form.

Definition at line 40 of file qgseditformconfig.h.

Member Enumeration Documentation

◆ DataDefinedProperty

enum class QgsEditFormConfig::DataDefinedProperty : int
strong

Data defined properties.

Form data defined overrides are stored in a property collection and they can be retrieved using the indexes specified in this enum.

Since
QGIS 3.14
Enumerator
NoProperty 

No property.

AllProperties 

All properties for item.

Alias 

Alias.

Editable 

Editable state.

Since
QGIS 3.30

Definition at line 80 of file qgseditformconfig.h.

Constructor & Destructor Documentation

◆ QgsEditFormConfig() [1/2]

QgsEditFormConfig::QgsEditFormConfig ( const QgsEditFormConfig o)

Definition at line 156 of file qgseditformconfig.cpp.

◆ ~QgsEditFormConfig()

QgsEditFormConfig::~QgsEditFormConfig ( )

Definition at line 161 of file qgseditformconfig.cpp.

◆ QgsEditFormConfig() [2/2]

QgsEditFormConfig::QgsEditFormConfig ( )
explicit

Create a new edit form config.

Normally invoked by QgsVectorLayer

Definition at line 33 of file qgseditformconfig.cpp.

Member Function Documentation

◆ addTab()

void QgsEditFormConfig::addTab ( QgsAttributeEditorElement data)

Adds a new element to the invisible root container in the layout.

This is only useful in combination with EditorLayout::TabLayout.

Definition at line 175 of file qgseditformconfig.cpp.

◆ attributeEditorElementFromDomElement()

QgsAttributeEditorElement * QgsEditFormConfig::attributeEditorElementFromDomElement ( QDomElement &  elem,
QgsAttributeEditorElement parent,
const QString &  layerId = QString(),
const QgsReadWriteContext context = QgsReadWriteContext() 
)

Deserialize drag and drop designer elements.

Deprecated:
QGIS 3.18. Use QgsAttributeEditorElement::create instead.

Definition at line 674 of file qgseditformconfig.cpp.

◆ clearTabs()

void QgsEditFormConfig::clearTabs ( )

Clears all the tabs for the attribute editor form with EditorLayout::TabLayout.

Definition at line 186 of file qgseditformconfig.cpp.

◆ dataDefinedFieldProperties()

QgsPropertyCollection QgsEditFormConfig::dataDefinedFieldProperties ( const QString &  fieldName) const

Returns data defined properties for fieldName.

Since
QGIS 3.14

Definition at line 44 of file qgseditformconfig.cpp.

◆ initCode()

QString QgsEditFormConfig::initCode ( ) const

Gets Python code for edit form initialization.

Definition at line 304 of file qgseditformconfig.cpp.

◆ initCodeSource()

Qgis::AttributeFormPythonInitCodeSource QgsEditFormConfig::initCodeSource ( ) const

Returns Python code source for edit form initialization (if it shall be loaded from a file, read from the provided dialog editor or inherited from the environment)

Definition at line 333 of file qgseditformconfig.cpp.

◆ initFilePath()

QString QgsEditFormConfig::initFilePath ( ) const

Gets Python external file path for edit form initialization.

Definition at line 315 of file qgseditformconfig.cpp.

◆ initFunction()

QString QgsEditFormConfig::initFunction ( ) const

Gets Python function for edit form initialization.

Will be looked up in a Python file relative to the project folder if it includes a module name or if it's a pure function name it will searched in the Python code set with setInitCode().

Definition at line 293 of file qgseditformconfig.cpp.

◆ invisibleRootContainer()

QgsAttributeEditorContainer * QgsEditFormConfig::invisibleRootContainer ( )

Gets the invisible root container for the drag and drop designer form (EditorLayout::TabLayout).

Since
QGIS 3

Definition at line 192 of file qgseditformconfig.cpp.

◆ labelOnTop()

bool QgsEditFormConfig::labelOnTop ( int  idx) const

If this returns true, the widget at the given index will receive its label on the previous line while if it returns false, the widget will receive its label on the left hand side.

Labeling on top leaves more horizontal space for the widget itself.

Definition at line 250 of file qgseditformconfig.cpp.

◆ layout()

Qgis::AttributeFormLayout QgsEditFormConfig::layout ( ) const

Gets the active layout style for the attribute editor for this layer.

Definition at line 197 of file qgseditformconfig.cpp.

◆ operator=()

QgsEditFormConfig & QgsEditFormConfig::operator= ( const QgsEditFormConfig o)

Definition at line 164 of file qgseditformconfig.cpp.

◆ operator==()

bool QgsEditFormConfig::operator== ( const QgsEditFormConfig o) const

Definition at line 170 of file qgseditformconfig.cpp.

◆ propertyDefinitions()

const QgsPropertiesDefinition & QgsEditFormConfig::propertyDefinitions ( )
static

Returns data defined property definitions.

Since
QGIS 3.14

Definition at line 49 of file qgseditformconfig.cpp.

◆ readOnly()

bool QgsEditFormConfig::readOnly ( int  idx) const

This returns true if the field is manually set to read only or if the field does not support editing like joins or virtual fields.

Definition at line 235 of file qgseditformconfig.cpp.

◆ readXml()

void QgsEditFormConfig::readXml ( const QDomNode &  node,
QgsReadWriteContext context 
)

Read XML information Deserialize on project load.

Definition at line 355 of file qgseditformconfig.cpp.

◆ removeWidgetConfig()

bool QgsEditFormConfig::removeWidgetConfig ( const QString &  widgetName)

Remove the configuration for the editor widget with the given name.

Parameters
widgetNameThe name of the widget.
Returns
true if a configuration has been removed

Definition at line 150 of file qgseditformconfig.cpp.

◆ reuseLastValue()

bool QgsEditFormConfig::reuseLastValue ( int  index) const

If this returns true, the widget at the given index will remember the previously entered value from this QGIS session when creating new features.

See also
setReuseLastValue()
Since
QGIS 3.20

Definition at line 276 of file qgseditformconfig.cpp.

◆ setDataDefinedFieldProperties()

void QgsEditFormConfig::setDataDefinedFieldProperties ( const QString &  fieldName,
const QgsPropertyCollection properties 
)

Set data defined properties for fieldName to properties.

Since
QGIS 3.14

Definition at line 38 of file qgseditformconfig.cpp.

◆ setInitCode()

void QgsEditFormConfig::setInitCode ( const QString &  code)

Set Python code for edit form initialization.

Make sure that you also set the appropriate function name in setInitFunction().

Definition at line 309 of file qgseditformconfig.cpp.

◆ setInitCodeSource()

void QgsEditFormConfig::setInitCodeSource ( Qgis::AttributeFormPythonInitCodeSource  initCodeSource)

Sets if Python code shall be used for edit form initialization and its origin.

Definition at line 338 of file qgseditformconfig.cpp.

◆ setInitFilePath()

void QgsEditFormConfig::setInitFilePath ( const QString &  filePath)

Set Python external file path for edit form initialization.

Make sure that you also set the appropriate function name in setInitFunction().

Definition at line 320 of file qgseditformconfig.cpp.

◆ setInitFunction()

void QgsEditFormConfig::setInitFunction ( const QString &  function)

Set Python function for edit form initialization.

Will be looked up in a Python file relative to the project folder if it includes a module name or if it's a pure function name it will searched in the Python code set with setInitCode().

Definition at line 298 of file qgseditformconfig.cpp.

◆ setLabelOnTop()

void QgsEditFormConfig::setLabelOnTop ( int  idx,
bool  onTop 
)

If this is set to true, the widget at the given index will receive its label on the previous line while if it is set to false, the widget will receive its label on the left hand side.

Labeling on top leaves more horizontal space for the widget itself.

Definition at line 267 of file qgseditformconfig.cpp.

◆ setLayout()

void QgsEditFormConfig::setLayout ( Qgis::AttributeFormLayout  editorLayout)

Sets the active layout style for the attribute editor for this layer.

Definition at line 202 of file qgseditformconfig.cpp.

◆ setReadOnly()

void QgsEditFormConfig::setReadOnly ( int  idx,
bool  readOnly = true 
)

If set to false, the widget at the given index will be read-only.

Definition at line 258 of file qgseditformconfig.cpp.

◆ setReuseLastValue()

void QgsEditFormConfig::setReuseLastValue ( int  index,
bool  reuse 
)

Sets whether the widget at the given index will remember the previously entered value from this QGIS session when creating new features.

See also
reuseLastValue()
Since
QGIS 3.20

Definition at line 284 of file qgseditformconfig.cpp.

◆ setSuppress()

void QgsEditFormConfig::setSuppress ( Qgis::AttributeFormSuppression  s)

Sets type of feature form pop-up suppression after feature creation (overrides app setting)

Definition at line 349 of file qgseditformconfig.cpp.

◆ setUiForm()

void QgsEditFormConfig::setUiForm ( const QString &  ui)

Set path to the .ui form.

When a string is provided in ui, the layout style will be set to EditorLayout::UiFileLayout, if an empty or a null string is provided, the layout style will be set to EditorLayout::GeneratedLayout. If ui is a URL, a local copy of the file will be made and will be used to create the forms context is provided to save error messages

Definition at line 216 of file qgseditformconfig.cpp.

◆ setWidgetConfig()

bool QgsEditFormConfig::setWidgetConfig ( const QString &  widgetName,
const QVariantMap &  config 
)

Set the editor widget config for a widget which is not for a simple field.

Example

editFormConfig = layer.editFormConfig()
editFormConfig.setWidgetConfig( 'relation_id', { 'nm-rel': 'other_relation' } )
layer.setEditFormConfig(editFormConfig)
Parameters
widgetNameThe name of the widget to configure
configThe config to set for this widget
Returns
false if a field exists with the provided widgetName. In this case QgsVectorLayer::setEditorWidgetSetup should be used.
See also
QgsVectorLayer::setEditorWidgetSetup() for field configurations.

Definition at line 130 of file qgseditformconfig.cpp.

◆ suppress()

Qgis::AttributeFormSuppression QgsEditFormConfig::suppress ( ) const

Type of feature form pop-up suppression after feature creation (overrides app setting)

Definition at line 344 of file qgseditformconfig.cpp.

◆ tabs()

QList< QgsAttributeEditorElement * > QgsEditFormConfig::tabs ( ) const

Returns a list of tabs for EditorLayout::TabLayout obtained from the invisible root container.

Definition at line 181 of file qgseditformconfig.cpp.

◆ uiForm()

QString QgsEditFormConfig::uiForm ( ) const

Returns the path or URL to the .ui form.

Only meaningful with EditorLayout::UiFileLayout

Definition at line 211 of file qgseditformconfig.cpp.

◆ widgetConfig()

QVariantMap QgsEditFormConfig::widgetConfig ( const QString &  widgetName) const

Gets the configuration for the editor widget with the given name.

Parameters
widgetNameThe name of the widget.
Returns
The configuration for the editor widget or an empty config if the field does not exist

Definition at line 54 of file qgseditformconfig.cpp.

◆ writeXml()

void QgsEditFormConfig::writeXml ( QDomNode &  node,
const QgsReadWriteContext context 
) const

Write XML information Serialize on project save.

Definition at line 548 of file qgseditformconfig.cpp.

Friends And Related Symbol Documentation

◆ QgsVectorLayer

friend class QgsVectorLayer
friend

Definition at line 347 of file qgseditformconfig.h.


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