QGIS API Documentation  2.99.0-Master (5d67572)
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 "qgis.h"
22 #include <QMap>
23 #include "qgseditorwidgetfactory.h"
26 #include "qgis_gui.h"
27 
28 class QgsMapLayer;
29 class QDomNode;
30 class QgsMapCanvas;
31 class QgsMessageBar;
35 class QgsVectorLayer;
36 
37 
45 class GUI_EXPORT QgsEditorWidgetRegistry : public QObject
46 {
47  Q_OBJECT
48 
49  public:
50 
55  QgsEditorWidgetRegistry() = default;
56 
67  void initEditors( QgsMapCanvas *mapCanvas = nullptr, QgsMessageBar *messageBar = nullptr );
68 
75 
84  QgsEditorWidgetSetup findBest( const QgsVectorLayer *vl, const QString &fieldName ) const;
85 
100  QgsEditorWidgetWrapper *create( const QString &widgetId,
101  QgsVectorLayer *vl,
102  int fieldIdx,
103  const QVariantMap &config,
104  QWidget *editor,
105  QWidget *parent SIP_TRANSFERTHIS,
107 
121  int fieldIdx,
122  QWidget *editor,
123  QWidget *parent SIP_TRANSFERTHIS,
125 
126  QgsSearchWidgetWrapper *createSearchWidget( const QString &widgetId,
127  QgsVectorLayer *vl,
128  int fieldIdx,
129  const QVariantMap &config,
130  QWidget *parent SIP_TRANSFERTHIS,
132 
143  QgsEditorConfigWidget *createConfigWidget( const QString &widgetId, QgsVectorLayer *vl, int fieldIdx, QWidget *parent SIP_TRANSFERTHIS ) SIP_FACTORY;
144 
152  QString name( const QString &widgetId );
153 
159  QMap<QString, QgsEditorWidgetFactory *> factories();
160 
166  QgsEditorWidgetFactory *factory( const QString &widgetId );
167 
176  bool registerWidget( const QString &widgetId, QgsEditorWidgetFactory *widgetFactory SIP_TRANSFER );
177 
183  void registerAutoConfPlugin( QgsEditorWidgetAutoConfPlugin *plugin ) { mAutoConf.registerPlugin( plugin ); }
184 
185  private:
186  QString findSuitableWrapper( QWidget *editor, const QString &defaultWidget );
187 
188  QMap<QString, QgsEditorWidgetFactory *> mWidgetFactories;
189  QMap<const char *, QPair<int, QString> > mFactoriesByType;
190  QgsEditorWidgetAutoConf mAutoConf;
191 };
192 
193 #endif // QGSEDITORWIDGETREGISTRY_H
void registerAutoConfPlugin(QgsEditorWidgetAutoConfPlugin *plugin)
Register a new auto-conf plugin.
Manages an editor widget Widget and wrapper share the same parent.
Base class for all map layer types.
Definition: qgsmaplayer.h:56
#define SIP_TRANSFERTHIS
Definition: qgis_sip.h:46
This class should be subclassed for every configurable editor widget type.
This class manages all known edit widget factories.
This class contains context information for attribute editor widgets.
Manages an editor widget Widget and wrapper share the same parent.
A bar for displaying non-blocking messages to the user.
Definition: qgsmessagebar.h:45
Base class for plugins allowing to pick automatically a widget type for editing fields.
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:74
Every attribute editor widget needs a factory, which inherits this class.
#define SIP_TRANSFER
Definition: qgis_sip.h:36
#define SIP_FACTORY
Definition: qgis_sip.h:69
#define SIP_PYARGREMOVE
Definition: qgis_sip.h:139
Holder for the widget type and its configuration for a field.
Represents a vector layer which manages a vector based data sets.