QGIS API Documentation  2.18.21-Las Palmas (9fba24a)
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 <QMap>
21 
22 #include "qgseditorwidgetfactory.h"
23 
24 class QgsMapLayer;
25 class QDomNode;
26 class QgsMapCanvas;
27 class QgsMessageBar;
28 
32 class GUI_EXPORT QgsEditorWidgetRegistry : public QObject
33 {
34  Q_OBJECT
35 
36  public:
43  static QgsEditorWidgetRegistry* instance();
44 
55  static void initEditors( QgsMapCanvas* mapCanvas = nullptr, QgsMessageBar* messageBar = nullptr );
56 
63 
78  QgsEditorWidgetWrapper* create( const QString& widgetId,
79  QgsVectorLayer* vl,
80  int fieldIdx,
81  const QgsEditorWidgetConfig& config,
82  QWidget* editor,
83  QWidget* parent,
85 
86  QgsSearchWidgetWrapper* createSearchWidget( const QString& widgetId,
87  QgsVectorLayer* vl,
88  int fieldIdx,
89  const QgsEditorWidgetConfig& config,
90  QWidget* parent,
92 
103  QgsEditorConfigWidget* createConfigWidget( const QString& widgetId, QgsVectorLayer* vl, int fieldIdx, QWidget* parent );
104 
112  QString name( const QString& widgetId );
113 
119  const QMap<QString, QgsEditorWidgetFactory*>& factories();
120 
126  QgsEditorWidgetFactory* factory( const QString& widgetId );
127 
136  bool registerWidget( const QString& widgetId, QgsEditorWidgetFactory* widgetFactory );
137 
138  protected:
140 
141  private slots:
147  void readMapLayer( QgsMapLayer* mapLayer, const QDomElement& layerElem );
148 
158  Q_DECL_DEPRECATED const QString readLegacyConfig( QgsVectorLayer* vl, const QDomElement& layerElem, QgsEditorWidgetConfig& cfg );
159 
167  void writeMapLayer( QgsMapLayer* mapLayer, QDomElement& layerElem, QDomDocument& doc ) const;
168 
174  void mapLayerAdded( QgsMapLayer* mapLayer );
175 
181  void mapLayerWillBeRemoved( QgsMapLayer* mapLayer );
182 
190  void readSymbology( const QDomElement& element, QString& errorMessage );
191 
200  void writeSymbology( QDomElement& element, QDomDocument& doc, QString& errorMessage );
201 
202  private:
203  QString findSuitableWrapper( QWidget* editor , const QString& defaultWidget );
204 
206  QMap<const char*, QPair<int, QString> > mFactoriesByType;
207 };
208 
209 #endif // QGSEDITORWIDGETREGISTRY_H
Manages an editor widget Widget and wrapper share the same parent.
Base class for all map layer types.
Definition: qgsmaplayer.h:49
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:42
Map canvas is a class for displaying all GIS data types on a canvas.
Definition: qgsmapcanvas.h:109
const char * name() const
QVariantMap QgsEditorWidgetConfig
Holds a set of configuration parameters for a editor widget wrapper.
Every attribute editor widget needs a factory, which inherits this class.
Represents a vector layer which manages a vector based data sets.