QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
Classes | Public Types | Public Member Functions | Protected Member Functions | Friends | List of all members
QgsEditFormConfig Class Reference

#include <qgseditformconfig.h>

Inheritance diagram for QgsEditFormConfig:
Inheritance graph
[legend]

Classes

struct  GroupData
 
struct  TabData
 

Public Types

enum  EditorLayout { GeneratedLayout = 0, TabLayout = 1, UiFileLayout = 2 }
 The different types to layout the attribute editor. More...
 
enum  FeatureFormSuppress { SuppressDefault = 0, SuppressOn = 1, SuppressOff = 2 }
 Types of feature form suppression after feature creation. More...
 
enum  PythonInitCodeSource { CodeSourceNone = 0, CodeSourceFile = 1, CodeSourceDialog = 2, CodeSourceEnvironment = 3 }
 The python init code source options. More...
 

Public Member Functions

void addTab (QgsAttributeEditorElement *data)
 This is only useful in combination with EditorLayout::TabLayout. More...
 
QgsAttributeEditorElementattributeEditorElementFromDomElement (QDomElement &elem, QObject *parent)
 Deserialize drag and drop designer elements. More...
 
void clearTabs ()
 Clears all the tabs for the attribute editor form with EditorLayout::TabLayout. More...
 
QString expression (int idx) const
 Returns the constraint expression of a specific field. More...
 
QString expressionDescription (int idx) const
 Returns the constraint expression description of a specific filed. More...
 
QString initCode () const
 Get python code for edit form initialization. More...
 
PythonInitCodeSource initCodeSource () const
 Return 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) More...
 
QString initFilePath () const
 Get python external file path for edit form initialization. More...
 
QString initFunction () const
 Get python function for edit form initialization. More...
 
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. More...
 
EditorLayout layout () const
 Get the active layout style for the attribute editor for this layer. More...
 
bool notNull (int fieldidx) const
 Returns if the field at fieldidx should be treated as NOT NULL value. More...
 
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. More...
 
void readXml (const QDomNode &node)
 Read XML information Deserialize on project load. More...
 
bool removeWidgetConfig (int fieldIdx)
 Remove the configuration for the editor widget used to represent the field at the given index. More...
 
bool removeWidgetConfig (const QString &widgetName)
 Remove the configuration for the editor widget used to represent the field with the given name. More...
 
void setExpression (int idx, const QString &str)
 Set the constraint expression for a specific field. More...
 
void setExpressionDescription (int idx, const QString &descr)
 Set the constraint expression description for a specific field. More...
 
void setInitCode (const QString &code)
 Set python code for edit form initialization. More...
 
void setInitCodeSource (const PythonInitCodeSource initCodeSource)
 Set if python code shall be used for edit form initialization and its origin. More...
 
void setInitFilePath (const QString &filePath)
 Set python external file path for edit form initialization. More...
 
void setInitFunction (const QString &function)
 Set python function for edit form initialization. More...
 
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. More...
 
void setLayout (EditorLayout editorLayout)
 Set the active layout style for the attribute editor for this layer. More...
 
void setNotNull (int idx, bool notnull=true)
 Set if the field at fieldidx should be treated as NOT NULL value. More...
 
void setReadOnly (int idx, bool readOnly=true)
 If set to false, the widget at the given index will be read-only. More...
 
void setSuppress (FeatureFormSuppress s)
 Set type of feature form pop-up suppression after feature creation (overrides app setting) More...
 
void setUiForm (const QString &ui)
 Set path to the .ui form. More...
 
void setWidgetConfig (int attrIdx, const QgsEditorWidgetConfig &config)
 Set the editor widget config for a field. More...
 
void setWidgetConfig (const QString &widgetName, const QgsEditorWidgetConfig &config)
 Set the editor widget config for a widget. More...
 
void setWidgetType (int fieldIdx, const QString &widgetType)
 Set the editor widget type for a field. More...
 
FeatureFormSuppress suppress () const
 Type of feature form pop-up suppression after feature creation (overrides app setting) More...
 
QList< QgsAttributeEditorElement *> tabs () const
 Returns a list of tabs for EditorLayout::TabLayout. More...
 
QString uiForm () const
 Get path to the .ui form. More...
 
QgsEditorWidgetConfig widgetConfig (int fieldIdx) const
 Get the configuration for the editor widget used to represent the field at the given index. More...
 
QgsEditorWidgetConfig widgetConfig (const QString &widgetName) const
 Get the configuration for the editor widget used to represent the field with the given name. More...
 
QString widgetType (int fieldIdx) const
 Get the id for the editor widget used to represent the field at the given index. More...
 
QString widgetType (const QString &fieldName) const
 Get the id for the editor widget used to represent the field at the given index. More...
 
void writeXml (QDomNode &node) const
 Write XML information Serialize on project save. More...
 
- Public Member Functions inherited from QObject
 QObject (QObject *parent)
 
 QObject (QObject *parent, const char *name)
 
virtual ~QObject ()
 
bool blockSignals (bool block)
 
QObjectchild (const char *objName, const char *inheritsClass, bool recursiveSearch) const
 
const QObjectList & children () const
 
const char * className () const
 
bool connect (const QObject *sender, const char *signal, const char *method, Qt::ConnectionType type) const
 
void deleteLater ()
 
void destroyed (QObject *obj)
 
bool disconnect (const QObject *receiver, const char *method)
 
bool disconnect (const char *signal, const QObject *receiver, const char *method)
 
void dumpObjectInfo ()
 
void dumpObjectTree ()
 
QList< QByteArraydynamicPropertyNames () const
 
virtual bool event (QEvent *e)
 
virtual bool eventFilter (QObject *watched, QEvent *event)
 
findChild (const QString &name) const
 
QList< T > findChildren (const QRegExp &regExp) const
 
QList< T > findChildren (const QString &name) const
 
bool inherits (const char *className) const
 
void insertChild (QObject *object)
 
void installEventFilter (QObject *filterObj)
 
bool isA (const char *className) const
 
bool isWidgetType () const
 
void killTimer (int id)
 
virtual const QMetaObjectmetaObject () const
 
void moveToThread (QThread *targetThread)
 
const char * name () const
 
const char * name (const char *defaultName) const
 
QString objectName () const
 
QObjectparent () const
 
QVariant property (const char *name) const
 
void removeChild (QObject *object)
 
void removeEventFilter (QObject *obj)
 
void setName (const char *name)
 
void setObjectName (const QString &name)
 
void setParent (QObject *parent)
 
bool setProperty (const char *name, const QVariant &value)
 
bool signalsBlocked () const
 
int startTimer (int interval)
 
QThreadthread () const
 

Protected Member Functions

 QgsEditFormConfig (QObject *parent=nullptr)
 Create a new edit form config. More...
 
- Protected Member Functions inherited from QObject
bool checkConnectArgs (const char *signal, const QObject *object, const char *method)
 
virtual void childEvent (QChildEvent *event)
 
virtual void connectNotify (const char *signal)
 
virtual void customEvent (QEvent *event)
 
virtual void disconnectNotify (const char *signal)
 
int receivers (const char *signal) const
 
QObjectsender () const
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *event)
 

Friends

class QgsVectorLayer
 

Additional Inherited Members

- Static Public Member Functions inherited from QObject
bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
 
bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type)
 
bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *method)
 
bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method)
 
QString tr (const char *sourceText, const char *disambiguation, int n)
 
QString trUtf8 (const char *sourceText, const char *disambiguation, int n)
 
- Static Protected Member Functions inherited from QObject
QByteArray normalizeSignalSlot (const char *signalSlot)
 
- Properties inherited from QObject
 objectName
 

Detailed Description

Definition at line 355 of file qgseditformconfig.h.

Member Enumeration Documentation

◆ EditorLayout

The different types to layout the attribute editor.

Enumerator
GeneratedLayout 

Autogenerate a simple tabular layout for the form.

TabLayout 

Use a layout with tabs and group boxes. Needs to be configured.

UiFileLayout 

Load a .ui file for the layout. Needs to be configured.

Definition at line 362 of file qgseditformconfig.h.

◆ FeatureFormSuppress

Types of feature form suppression after feature creation.

Enumerator
SuppressDefault 

Use the application-wide setting.

SuppressOn 

Suppress feature form.

SuppressOff 

Do not suppress feature form.

Definition at line 396 of file qgseditformconfig.h.

◆ PythonInitCodeSource

The python init code source options.

Enumerator
CodeSourceNone 

Do not use python code at all.

CodeSourceFile 

Load the python code from an external file.

CodeSourceDialog 

Use the python code provided in the dialog.

CodeSourceEnvironment 

Use the python code available in the python environment.

Definition at line 406 of file qgseditformconfig.h.

Constructor & Destructor Documentation

◆ QgsEditFormConfig()

QgsEditFormConfig::QgsEditFormConfig ( QObject parent = nullptr)
explicitprotected

Create a new edit form config.

Normally invoked by QgsVectorLayer

Definition at line 18 of file qgseditformconfig.cpp.

Member Function Documentation

◆ addTab()

void QgsEditFormConfig::addTab ( QgsAttributeEditorElement data)
inline

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

Adds a new element to the layout.

Definition at line 419 of file qgseditformconfig.h.

◆ attributeEditorElementFromDomElement()

QgsAttributeEditorElement * QgsEditFormConfig::attributeEditorElementFromDomElement ( QDomElement elem,
QObject parent 
)

Deserialize drag and drop designer elements.

Definition at line 413 of file qgseditformconfig.cpp.

◆ clearTabs()

void QgsEditFormConfig::clearTabs ( )
inline

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

Definition at line 429 of file qgseditformconfig.h.

◆ expression()

QString QgsEditFormConfig::expression ( int  idx) const

Returns the constraint expression of a specific field.

Parameters
idxThe index of the field
Returns
the expression
Note
added in QGIS 2.16

Definition at line 122 of file qgseditformconfig.cpp.

◆ expressionDescription()

QString QgsEditFormConfig::expressionDescription ( int  idx) const

Returns the constraint expression description of a specific filed.

Parameters
idxThe index of the field
Returns
the expression description
Note
added in QGIS 2.16

Definition at line 138 of file qgseditformconfig.cpp.

◆ initCode()

QString QgsEditFormConfig::initCode ( ) const
inline

Get python code for edit form initialization.

Definition at line 658 of file qgseditformconfig.h.

◆ initCodeSource()

PythonInitCodeSource QgsEditFormConfig::initCodeSource ( ) const
inline

Return 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 683 of file qgseditformconfig.h.

◆ initFilePath()

QString QgsEditFormConfig::initFilePath ( ) const
inline

Get python external file path for edit form initialization.

Definition at line 670 of file qgseditformconfig.h.

◆ initFunction()

QString QgsEditFormConfig::initFunction ( ) const
inline

Get 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 645 of file qgseditformconfig.h.

◆ 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 114 of file qgseditformconfig.cpp.

◆ layout()

EditorLayout QgsEditFormConfig::layout ( ) const
inline

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

Definition at line 432 of file qgseditformconfig.h.

◆ notNull()

bool QgsEditFormConfig::notNull ( int  fieldidx) const

Returns if the field at fieldidx should be treated as NOT NULL value.

Definition at line 154 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 101 of file qgseditformconfig.cpp.

◆ readXml()

void QgsEditFormConfig::readXml ( const QDomNode node)

Read XML information Deserialize on project load.

TODO: MAKE THIS MORE GENERIC, SO INDIVIDUALL WIDGETS CAN NOT ONLY SAVE STRINGS SEE QgsEditorWidgetFactory::writeConfig

Definition at line 180 of file qgseditformconfig.cpp.

◆ removeWidgetConfig() [1/2]

bool QgsEditFormConfig::removeWidgetConfig ( int  fieldIdx)

Remove the configuration for the editor widget used to represent the field at the given index.

Parameters
fieldIdxThe index of the field
Returns
true if successful, false if the field does not exist

Definition at line 80 of file qgseditformconfig.cpp.

◆ removeWidgetConfig() [2/2]

bool QgsEditFormConfig::removeWidgetConfig ( const QString widgetName)

Remove the configuration for the editor widget used to represent the field with the given name.

Parameters
widgetNameThe name of the widget. This can be a field name or the name of an additional widget.
Returns
true if successful, false if the field does not exist

Definition at line 75 of file qgseditformconfig.cpp.

◆ setExpression()

void QgsEditFormConfig::setExpression ( int  idx,
const QString str 
)

Set the constraint expression for a specific field.

Parameters
idxthe field index
strthe constraint expression
Note
added in QGIS 2.16

Definition at line 132 of file qgseditformconfig.cpp.

◆ setExpressionDescription()

void QgsEditFormConfig::setExpressionDescription ( int  idx,
const QString descr 
)

Set the constraint expression description for a specific field.

Parameters
idxThe index of the field
descrThe description of the expression
Note
added in QGIS 2.16

Definition at line 148 of file qgseditformconfig.cpp.

◆ setInitCode()

void QgsEditFormConfig::setInitCode ( const QString code)
inline

Set python code for edit form initialization.

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

Definition at line 665 of file qgseditformconfig.h.

◆ setInitCodeSource()

void QgsEditFormConfig::setInitCodeSource ( const PythonInitCodeSource  initCodeSource)
inline

Set if python code shall be used for edit form initialization and its origin.

Definition at line 686 of file qgseditformconfig.h.

◆ setInitFilePath()

void QgsEditFormConfig::setInitFilePath ( const QString filePath)
inline

Set python external file path for edit form initialization.

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

Definition at line 677 of file qgseditformconfig.h.

◆ setInitFunction()

void QgsEditFormConfig::setInitFunction ( const QString function)
inline

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 653 of file qgseditformconfig.h.

◆ 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 168 of file qgseditformconfig.cpp.

◆ setLayout()

void QgsEditFormConfig::setLayout ( EditorLayout  editorLayout)
inline

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

Definition at line 435 of file qgseditformconfig.h.

◆ setNotNull()

void QgsEditFormConfig::setNotNull ( int  idx,
bool  notnull = true 
)

Set if the field at fieldidx should be treated as NOT NULL value.

Definition at line 174 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 162 of file qgseditformconfig.cpp.

◆ setSuppress()

void QgsEditFormConfig::setSuppress ( FeatureFormSuppress  s)
inline

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

Definition at line 691 of file qgseditformconfig.h.

◆ setUiForm()

void QgsEditFormConfig::setUiForm ( const QString ui)

Set path to the .ui form.

When a string is provided, 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.

Definition at line 88 of file qgseditformconfig.cpp.

◆ setWidgetConfig() [1/2]

void QgsEditFormConfig::setWidgetConfig ( int  attrIdx,
const QgsEditorWidgetConfig config 
)

Set the editor widget config for a field.

Python: Will accept a map.

Example:

layer.setWidgetConfig( 1, { 'Layer': 'otherlayerid_1234', 'Key': 'Keyfield', 'Value': 'ValueField' } )
Parameters
attrIdxIndex of the field
configThe config to set for this field
See also
setWidgetType() for a list of widgets and choose the widget to see the available options.

Definition at line 64 of file qgseditformconfig.cpp.

◆ setWidgetConfig() [2/2]

void QgsEditFormConfig::setWidgetConfig ( const QString widgetName,
const QgsEditorWidgetConfig config 
)

Set the editor widget config for a widget.

Example:

layer.setWidgetConfig( 'relation_id', { 'nm-rel': 'other_relation' } )
Parameters
widgetNameThe name of the widget or field to configure
configThe config to set for this field
See also
setWidgetType() for a list of widgets and choose the widget to see the available options.
Note
not available in python bindings

Definition at line 70 of file qgseditformconfig.cpp.

◆ setWidgetType()

void QgsEditFormConfig::setWidgetType ( int  fieldIdx,
const QString widgetType 
)

Set the editor widget type for a field.

QGIS ships the following widget types, additional types may be available depending on plugins.

Parameters
fieldIdxIndex of the field
widgetTypeType id of the editor widget to use

Definition at line 58 of file qgseditformconfig.cpp.

◆ suppress()

FeatureFormSuppress QgsEditFormConfig::suppress ( ) const
inline

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

Definition at line 689 of file qgseditformconfig.h.

◆ tabs()

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

Returns a list of tabs for EditorLayout::TabLayout.

Definition at line 424 of file qgseditformconfig.h.

◆ uiForm()

QString QgsEditFormConfig::uiForm ( ) const
inline

Get path to the .ui form.

Only meaningful with EditorLayout::UiFileLayout.

Definition at line 438 of file qgseditformconfig.h.

◆ widgetConfig() [1/2]

QgsEditorWidgetConfig QgsEditFormConfig::widgetConfig ( int  fieldIdx) const

Get the configuration for the editor widget used to represent the field at the given index.

Parameters
fieldIdxThe index of the field
Returns
The configuration for the editor widget or an empty config if the field does not exist

Definition at line 40 of file qgseditformconfig.cpp.

◆ widgetConfig() [2/2]

QgsEditorWidgetConfig QgsEditFormConfig::widgetConfig ( const QString widgetName) const

Get the configuration for the editor widget used to represent the field with the given name.

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

Definition at line 48 of file qgseditformconfig.cpp.

◆ widgetType() [1/2]

QString QgsEditFormConfig::widgetType ( int  fieldIdx) const

Get the id for the editor widget used to represent the field at the given index.

Parameters
fieldIdxThe index of the field
Returns
The id for the editor widget or a NULL string if not applicable

Definition at line 27 of file qgseditformconfig.cpp.

◆ widgetType() [2/2]

QString QgsEditFormConfig::widgetType ( const QString fieldName) const

Get the id for the editor widget used to represent the field at the given index.

Parameters
fieldNameThe name of the field
Returns
The id for the editor widget or a NULL string if not applicable

Definition at line 35 of file qgseditformconfig.cpp.

◆ writeXml()

void QgsEditFormConfig::writeXml ( QDomNode node) const

Write XML information Serialize on project save.

TODO: MAKE THIS MORE GENERIC, SO INDIVIDUALL WIDGETS CAN NOT ONLY SAVE STRINGS SEE QgsEditorWidgetFactory::writeConfig

Definition at line 309 of file qgseditformconfig.cpp.

Friends And Related Function Documentation

◆ QgsVectorLayer

friend class QgsVectorLayer
friend

Definition at line 768 of file qgseditformconfig.h.


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