QGIS API Documentation  2.7.0-Master
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules 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, QWidget* parent,
84 
95  QgsEditorConfigWidget* createConfigWidget( const QString& widgetId, QgsVectorLayer* vl, int fieldIdx, QWidget* parent );
96 
104  QString name( const QString& widgetId );
105 
111  const QMap<QString, QgsEditorWidgetFactory*>& factories();
112 
118  QgsEditorWidgetFactory* factory( const QString& widgetId );
119 
128  bool registerWidget( const QString& widgetId, QgsEditorWidgetFactory* widgetFactory );
129 
130  protected:
132 
133  private slots:
139  void readMapLayer( QgsMapLayer* mapLayer, const QDomElement& layerElem );
140 
150  Q_DECL_DEPRECATED const QString readLegacyConfig( QgsVectorLayer* vl, const QDomElement& layerElem, QgsEditorWidgetConfig& cfg );
151 
159  void writeMapLayer( QgsMapLayer* mapLayer, QDomElement& layerElem, QDomDocument& doc ) const;
160 
166  void mapLayerAdded( QgsMapLayer* mapLayer );
167 
175  void readSymbology( const QDomElement& element, QString& errorMessage );
176 
185  void writeSymbology( QDomElement& element, QDomDocument& doc, QString& errorMessage );
186 
187  private:
188  QMap<QString, QgsEditorWidgetFactory*> mWidgetFactories;
189 };
190 
191 #endif // QGSEDITORWIDGETREGISTRY_H
Base class for all map layer types.
Definition: qgsmaplayer.h:48
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:104
Every attribute editor widget needs a factory, which inherits this class.
QMap< QString, QVariant > QgsEditorWidgetConfig
Holds a set of configuration parameters for a editor widget wrapper.
Represents a vector layer which manages a vector based data sets.