QGIS API Documentation  2.6.0-Brighton
 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 
30 class GUI_EXPORT QgsEditorWidgetRegistry : public QObject
31 {
32  Q_OBJECT
33 
34  public:
41  static QgsEditorWidgetRegistry* instance();
43 
58  QgsEditorWidgetWrapper* create( const QString& widgetId,
59  QgsVectorLayer* vl,
60  int fieldIdx,
61  const QgsEditorWidgetConfig& config,
62  QWidget* editor, QWidget* parent,
64 
75  QgsEditorConfigWidget* createConfigWidget( const QString& widgetId, QgsVectorLayer* vl, int fieldIdx, QWidget* parent );
76 
84  QString name( const QString& widgetId );
85 
91  const QMap<QString, QgsEditorWidgetFactory*>& factories();
92 
98  QgsEditorWidgetFactory* factory( const QString& widgetId );
99 
108  bool registerWidget( const QString& widgetId, QgsEditorWidgetFactory* widgetFactory );
109 
110  protected:
112 
113  private slots:
119  void readMapLayer( QgsMapLayer* mapLayer, const QDomElement& layerElem );
120 
130  Q_DECL_DEPRECATED const QString readLegacyConfig( QgsVectorLayer* vl, const QDomElement& layerElem, QgsEditorWidgetConfig& cfg );
131 
139  void writeMapLayer( QgsMapLayer* mapLayer, QDomElement& layerElem, QDomDocument& doc ) const;
140 
146  void mapLayerAdded( QgsMapLayer* mapLayer );
147 
155  void readSymbology( const QDomElement& element, QString& errorMessage );
156 
165  void writeSymbology( QDomElement& element, QDomDocument& doc, QString& errorMessage );
166 
167  private:
168  QMap<QString, QgsEditorWidgetFactory*> mWidgetFactories;
169 };
170 
171 #endif // QGSEDITORWIDGETREGISTRY_H