QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
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 dot kuhn at gmx 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 = 0, QgsMessageBar* messageBar = 0 );
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 
96  QgsEditorConfigWidget* createConfigWidget( const QString& widgetId, QgsVectorLayer* vl, int fieldIdx, QWidget* parent );
97 
105  QString name( const QString& widgetId );
106 
112  const QMap<QString, QgsEditorWidgetFactory*>& factories();
113 
119  QgsEditorWidgetFactory* factory( const QString& widgetId );
120 
129  bool registerWidget( const QString& widgetId, QgsEditorWidgetFactory* widgetFactory );
130 
131  protected:
133 
134  private slots:
140  void readMapLayer( QgsMapLayer* mapLayer, const QDomElement& layerElem );
141 
151  Q_DECL_DEPRECATED const QString readLegacyConfig( QgsVectorLayer* vl, const QDomElement& layerElem, QgsEditorWidgetConfig& cfg );
152 
160  void writeMapLayer( QgsMapLayer* mapLayer, QDomElement& layerElem, QDomDocument& doc ) const;
161 
167  void mapLayerAdded( QgsMapLayer* mapLayer );
168 
176  void readSymbology( const QDomElement& element, QString& errorMessage );
177 
186  void writeSymbology( QDomElement& element, QDomDocument& doc, QString& errorMessage );
187 
188  private:
189  QMap<QString, QgsEditorWidgetFactory*> mWidgetFactories;
190 };
191 
192 #endif // QGSEDITORWIDGETREGISTRY_H