QGIS API Documentation  3.16.0-Hannover (43b64b13f3)
qgseditorwidgetregistry.h
Go to the documentation of this file.
1 /***************************************************************************
2  qgseditorwidgetregistry.h
3  --------------------------------------
4  Date : 24.4.2013
5  Copyright : (C) 2013 Matthias Kuhn
6  Email : matthias at opengis dot ch
7  ***************************************************************************
8  * *
9  * This program is free software; you can redistribute it and/or modify *
10  * it under the terms of the GNU General Public License as published by *
11  * the Free Software Foundation; either version 2 of the License, or *
12  * (at your option) any later version. *
13  * *
14  ***************************************************************************/
15 
16 #ifndef QGSEDITORWIDGETREGISTRY_H
17 #define QGSEDITORWIDGETREGISTRY_H
18 
19 #include <QObject>
20 #include "qgis_sip.h"
21 #include <QMap>
22 #include "qgseditorwidgetfactory.h"
25 #include "qgis_gui.h"
26 
27 class QgsMapLayer;
28 class QDomNode;
29 class QgsMapCanvas;
30 class QgsMessageBar;
34 class QgsVectorLayer;
35 
36 
44 class GUI_EXPORT QgsEditorWidgetRegistry : public QObject
45 {
46  Q_OBJECT
47 
48  public:
49 
55 
66  void initEditors( QgsMapCanvas *mapCanvas = nullptr, QgsMessageBar *messageBar = nullptr );
67 
73  ~QgsEditorWidgetRegistry() override;
74 
83  QgsEditorWidgetSetup findBest( const QgsVectorLayer *vl, const QString &fieldName ) const;
84 
99  QgsEditorWidgetWrapper *create( const QString &widgetId,
100  QgsVectorLayer *vl,
101  int fieldIdx,
102  const QVariantMap &config,
103  QWidget *editor,
104  QWidget *parent SIP_TRANSFERTHIS,
106 
120  int fieldIdx,
121  QWidget *editor,
122  QWidget *parent SIP_TRANSFERTHIS,
124 
125  QgsSearchWidgetWrapper *createSearchWidget( const QString &widgetId,
126  QgsVectorLayer *vl,
127  int fieldIdx,
128  const QVariantMap &config,
129  QWidget *parent SIP_TRANSFERTHIS,
131 
142  QgsEditorConfigWidget *createConfigWidget( const QString &widgetId, QgsVectorLayer *vl, int fieldIdx, QWidget *parent SIP_TRANSFERTHIS ) SIP_FACTORY;
143 
151  QString name( const QString &widgetId );
152 
158  QMap<QString, QgsEditorWidgetFactory *> factories();
159 
165  QgsEditorWidgetFactory *factory( const QString &widgetId );
166 
175  bool registerWidget( const QString &widgetId, QgsEditorWidgetFactory *widgetFactory SIP_TRANSFER );
176 
182  void registerAutoConfPlugin( QgsEditorWidgetAutoConfPlugin *plugin ) { mAutoConf.registerPlugin( plugin ); }
183 
184  private:
185  QString findSuitableWrapper( QWidget *editor, const QString &defaultWidget );
186 
187  QMap<QString, QgsEditorWidgetFactory *> mWidgetFactories;
188  QMap<const char *, QPair<int, QString> > mFactoriesByType;
189  QgsEditorWidgetAutoConf mAutoConf;
190  std::unique_ptr<QgsEditorWidgetFactory> mFallbackWidgetFactory = nullptr;
191 };
192 
193 #endif // QGSEDITORWIDGETREGISTRY_H
QgsEditorConfigWidget
This class should be subclassed for every configurable editor widget type.
Definition: qgseditorconfigwidget.h:39
QgsEditorWidgetFactory
Every attribute editor widget needs a factory, which inherits this class.
Definition: qgseditorwidgetfactory.h:43
QgsEditorWidgetSetup
Holder for the widget type and its configuration for a field.
Definition: qgseditorwidgetsetup.h:29
QgsMapCanvas
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:85
QgsSearchWidgetWrapper
Shows a search widget on a filter form.
Definition: qgssearchwidgetwrapper.h:86
SIP_PYARGREMOVE
#define SIP_PYARGREMOVE
Definition: qgis_sip.h:146
QgsEditorWidgetWrapper
Manages an editor widget Widget and wrapper share the same parent.
Definition: qgseditorwidgetwrapper.h:48
SIP_FACTORY
#define SIP_FACTORY
Definition: qgis_sip.h:76
QgsEditorWidgetAutoConfPlugin
Base class for plugins allowing to pick automatically a widget type for editing fields.
Definition: qgseditorwidgetautoconf.h:33
qgis_sip.h
SIP_TRANSFER
#define SIP_TRANSFER
Definition: qgis_sip.h:36
QgsMessageBar
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:61
qgsattributeeditorcontext.h
QgsVectorLayer
Represents a vector layer which manages a vector based data sets.
Definition: qgsvectorlayer.h:387
qgseditorwidgetfactory.h
QgsMapLayer
Base class for all map layer types.
Definition: qgsmaplayer.h:83
qgseditorwidgetautoconf.h
QgsAttributeEditorContext
This class contains context information for attribute editor widgets.
Definition: qgsattributeeditorcontext.h:41
SIP_TRANSFERTHIS
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:53
QgsEditorWidgetRegistry::registerAutoConfPlugin
void registerAutoConfPlugin(QgsEditorWidgetAutoConfPlugin *plugin)
Register a new auto-conf plugin.
Definition: qgseditorwidgetregistry.h:182
QgsEditorWidgetRegistry
This class manages all known edit widget factories.
Definition: qgseditorwidgetregistry.h:45