QGIS API Documentation  2.99.0-Master (009e47e)
Public Member Functions | List of all members
QgsEditorWidgetRegistry Class Reference

This class manages all known edit widget factories. More...

#include <qgseditorwidgetregistry.h>

Inheritance diagram for QgsEditorWidgetRegistry:
Inheritance graph
[legend]

Public Member Functions

 QgsEditorWidgetRegistry ()
 Constructor for QgsEditorWidgetRegistry. More...
 
 ~QgsEditorWidgetRegistry ()
 Destructor. More...
 
QgsEditorWidgetWrappercreate (const QString &widgetId, QgsVectorLayer *vl, int fieldIdx, const QVariantMap &config, QWidget *editor, QWidget *parent, const QgsAttributeEditorContext &context=QgsAttributeEditorContext())
 Create an attribute editor widget wrapper of a given type for a given field. More...
 
QgsEditorWidgetWrappercreate (QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent, const QgsAttributeEditorContext &context=QgsAttributeEditorContext())
 Create an attribute editor widget wrapper of the best type for a given field. More...
 
QgsEditorConfigWidgetcreateConfigWidget (const QString &widgetId, QgsVectorLayer *vl, int fieldIdx, QWidget *parent)
 Creates a configuration widget. More...
 
QgsSearchWidgetWrappercreateSearchWidget (const QString &widgetId, QgsVectorLayer *vl, int fieldIdx, const QVariantMap &config, QWidget *parent, const QgsAttributeEditorContext &context=QgsAttributeEditorContext())
 
QMap< QString, QgsEditorWidgetFactory * > factories ()
 Get access to all registered factories. More...
 
QgsEditorWidgetFactoryfactory (const QString &widgetId)
 Get a factory for the given widget type id. More...
 
QgsEditorWidgetSetup findBest (const QgsVectorLayer *vl, const QString &fieldName) const
 Find the best editor widget and its configuration for a given field. More...
 
void initEditors (QgsMapCanvas *mapCanvas=nullptr, QgsMessageBar *messageBar=nullptr)
 Registers all the default widgets. More...
 
QString name (const QString &widgetId)
 Get the human readable name for a widget type. More...
 
void registerAutoConfPlugin (QgsEditorWidgetAutoConfPlugin *plugin)
 Register a new auto-conf plugin. More...
 
bool registerWidget (const QString &widgetId, QgsEditorWidgetFactory *widgetFactory)
 Register a new widget factory with the given id. More...
 

Detailed Description

This class manages all known edit widget factories.

QgsEditorWidgetRegistry is not usually directly created, but rather accessed through QgsGui::editorWidgetRegistry().

Definition at line 44 of file qgseditorwidgetregistry.h.

Constructor & Destructor Documentation

◆ QgsEditorWidgetRegistry()

QgsEditorWidgetRegistry::QgsEditorWidgetRegistry ( )

Constructor for QgsEditorWidgetRegistry.

QgsEditorWidgetRegistry is not usually directly created, but rather accessed through QgsGui::editorWidgetRegistry().

Definition at line 63 of file qgseditorwidgetregistry.cpp.

◆ ~QgsEditorWidgetRegistry()

QgsEditorWidgetRegistry::~QgsEditorWidgetRegistry ( )

Destructor.

Deletes all the registered widgets

Definition at line 67 of file qgseditorwidgetregistry.cpp.

Member Function Documentation

◆ create() [1/2]

QgsEditorWidgetWrapper * QgsEditorWidgetRegistry::create ( const QString &  widgetId,
QgsVectorLayer vl,
int  fieldIdx,
const QVariantMap &  config,
QWidget *  editor,
QWidget *  parent,
const QgsAttributeEditorContext context = QgsAttributeEditorContext() 
)

Create an attribute editor widget wrapper of a given type for a given field.

The editor may be NULL if you want the widget wrapper to create a default widget.

Parameters
widgetIdThe id of the widget type to create an attribute editor for
vlThe vector layer for which this widget will be created
fieldIdxThe field index on the specified layer for which this widget will be created
configA configuration which should be used for the widget creation
editorAn editor widget which will be used instead of an autocreated widget
parentThe parent which will be used for the created wrapper and the created widget
contextThe editor context (not available in Python bindings)
Returns
A new widget wrapper

Definition at line 93 of file qgseditorwidgetregistry.cpp.

◆ create() [2/2]

QgsEditorWidgetWrapper * QgsEditorWidgetRegistry::create ( QgsVectorLayer vl,
int  fieldIdx,
QWidget *  editor,
QWidget *  parent,
const QgsAttributeEditorContext context = QgsAttributeEditorContext() 
)

Create an attribute editor widget wrapper of the best type for a given field.

The editor may be NULL if you want the widget wrapper to create a default widget.

Parameters
vlThe vector layer for which this widget will be created
fieldIdxThe field index on the specified layer for which this widget will be created
editorAn editor widget which will be used instead of an autocreated widget
parentThe parent which will be used for the created wrapper and the created widget
contextThe editor context (not available in Python bindings)
Returns
A new widget wrapper

Definition at line 86 of file qgseditorwidgetregistry.cpp.

◆ createConfigWidget()

QgsEditorConfigWidget * QgsEditorWidgetRegistry::createConfigWidget ( const QString &  widgetId,
QgsVectorLayer vl,
int  fieldIdx,
QWidget *  parent 
)

Creates a configuration widget.

Parameters
widgetIdThe id of the widget type to create a configuration widget for
vlThe vector layer for which this widget will be created
fieldIdxThe field index on the specified layer for which this widget will be created
parentThe parent widget for the created widget
Returns
A new configuration widget

Definition at line 144 of file qgseditorwidgetregistry.cpp.

◆ createSearchWidget()

QgsSearchWidgetWrapper * QgsEditorWidgetRegistry::createSearchWidget ( const QString &  widgetId,
QgsVectorLayer vl,
int  fieldIdx,
const QVariantMap &  config,
QWidget *  parent,
const QgsAttributeEditorContext context = QgsAttributeEditorContext() 
)

Definition at line 124 of file qgseditorwidgetregistry.cpp.

◆ factories()

QMap< QString, QgsEditorWidgetFactory * > QgsEditorWidgetRegistry::factories ( )

Get access to all registered factories.

Returns
All ids and factories

Definition at line 163 of file qgseditorwidgetregistry.cpp.

◆ factory()

QgsEditorWidgetFactory * QgsEditorWidgetRegistry::factory ( const QString &  widgetId)

Get a factory for the given widget type id.

Returns
A factory or Null if not existent

Definition at line 168 of file qgseditorwidgetregistry.cpp.

◆ findBest()

QgsEditorWidgetSetup QgsEditorWidgetRegistry::findBest ( const QgsVectorLayer vl,
const QString &  fieldName 
) const

Find the best editor widget and its configuration for a given field.

Parameters
vlThe vector layer for which this widget will be created
fieldNameThe field name on the specified layer for which this widget will be created
Returns
The id of the widget type to use and its config

Definition at line 72 of file qgseditorwidgetregistry.cpp.

◆ initEditors()

void QgsEditorWidgetRegistry::initEditors ( QgsMapCanvas mapCanvas = nullptr,
QgsMessageBar messageBar = nullptr 
)

Registers all the default widgets.

Only call this once on startup of an application.

Parameters
mapCanvasSpecify a map canvas with which the widgets (relation reference) work
messageBarSpecify a message bar on which messages by widgets will be shown while working with the map canvas
Since
QGIS 2.8
Note
Not required for plugins, the QGIS application does that already

Definition at line 43 of file qgseditorwidgetregistry.cpp.

◆ name()

QString QgsEditorWidgetRegistry::name ( const QString &  widgetId)

Get the human readable name for a widget type.

Parameters
widgetIdThe widget type to get the name for
Returns
A human readable name

Definition at line 153 of file qgseditorwidgetregistry.cpp.

◆ registerAutoConfPlugin()

void QgsEditorWidgetRegistry::registerAutoConfPlugin ( QgsEditorWidgetAutoConfPlugin plugin)
inline

Register a new auto-conf plugin.

Parameters
pluginThe plugin (ownership is transferred)

Definition at line 182 of file qgseditorwidgetregistry.h.

◆ registerWidget()

bool QgsEditorWidgetRegistry::registerWidget ( const QString &  widgetId,
QgsEditorWidgetFactory widgetFactory 
)

Register a new widget factory with the given id.

Parameters
widgetIdThe id which will be used later to refer to this widget type
widgetFactoryThe factory which will create this widget type
Returns
true, if successful, false, if the widgetId is already in use or widgetFactory is NULL

Definition at line 173 of file qgseditorwidgetregistry.cpp.


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