QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
Loading...
Searching...
No Matches
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 "qgis_gui.h"
20#include "qgis_sip.h"
24
25#include <QMap>
26#include <QObject>
27
28class QgsMapLayer;
29class QDomNode;
30class QgsMapCanvas;
31class QgsMessageBar;
35class QgsVectorLayer;
36
37
45class GUI_EXPORT QgsEditorWidgetRegistry : public QObject
46{
47 Q_OBJECT
48
49 public:
55
65 void initEditors( QgsMapCanvas *mapCanvas = nullptr, QgsMessageBar *messageBar = nullptr );
66
72 ~QgsEditorWidgetRegistry() override;
73
82 QgsEditorWidgetSetup findBest( const QgsVectorLayer *vl, const QString &fieldName ) const;
83
99 const QString &widgetId,
100 QgsVectorLayer *vl,
101 int fieldIdx,
102 const QVariantMap &config,
103 QWidget *editor,
104 QWidget *parent SIP_TRANSFERTHIS,
106 ) SIP_FACTORY;
107
120 // clang-format off
122 // clang-format on
123
125 const QString &widgetId,
126 QgsVectorLayer *vl,
127 int fieldIdx,
128 const QVariantMap &config,
129 QWidget *parent SIP_TRANSFERTHIS,
131 ) SIP_FACTORY;
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
163 QIcon icon( const QString &widgetId );
164
172 bool isReadOnly( const QString &widgetId );
173
179 QMap<QString, QgsEditorWidgetFactory *> factories();
180
186 QgsEditorWidgetFactory *factory( const QString &widgetId );
187
196 bool registerWidget( const QString &widgetId, QgsEditorWidgetFactory *widgetFactory SIP_TRANSFER );
197
203 void registerAutoConfPlugin( QgsEditorWidgetAutoConfPlugin *plugin ) { mAutoConf.registerPlugin( plugin ); }
204
205 private:
206 QString findSuitableWrapper( QWidget *editor, const QString &defaultWidget );
207
208 QMap<QString, QgsEditorWidgetFactory *> mWidgetFactories;
209 QMap<const char *, QPair<int, QString>> mFactoriesByType;
210 QgsEditorWidgetAutoConf mAutoConf;
211 std::unique_ptr<QgsEditorWidgetFactory> mFallbackWidgetFactory = nullptr;
212};
213
214#endif // QGSEDITORWIDGETREGISTRY_H
Contains context information for attribute editor widgets.
Base class for widgets which configure editor widget types.
Base class for plugins allowing to pick automatically a widget type for editing fields.
Every attribute editor widget needs a factory, which inherits this class.
bool isReadOnly(const QString &widgetId)
Gets the widget's read-only flag.
QString name(const QString &widgetId)
Returns the human readable name for a widget type.
QgsEditorConfigWidget * createConfigWidget(const QString &widgetId, QgsVectorLayer *vl, int fieldIdx, QWidget *parent)
Creates a configuration widget.
QMap< QString, QgsEditorWidgetFactory * > factories()
Gets access to all registered factories.
void initEditors(QgsMapCanvas *mapCanvas=nullptr, QgsMessageBar *messageBar=nullptr)
Registers all the default widgets.
QgsEditorWidgetSetup findBest(const QgsVectorLayer *vl, const QString &fieldName) const
Find the best editor widget and its configuration for a given field.
QIcon icon(const QString &widgetId)
Returns the icon for a widget type.
QgsEditorWidgetWrapper * create(const QString &widgetId, QgsVectorLayer *vl, int fieldIdx, const QVariantMap &config, QWidget *editor, QWidget *parent, const QgsAttributeEditorContext &context=QgsAttributeEditorContext())
Create an attribute editor widget wrapper of a given type for a given field.
QgsEditorWidgetFactory * factory(const QString &widgetId)
Gets a factory for the given widget type id.
void registerAutoConfPlugin(QgsEditorWidgetAutoConfPlugin *plugin)
Register a new auto-conf plugin.
QgsSearchWidgetWrapper * createSearchWidget(const QString &widgetId, QgsVectorLayer *vl, int fieldIdx, const QVariantMap &config, QWidget *parent, const QgsAttributeEditorContext &context=QgsAttributeEditorContext())
QgsEditorWidgetRegistry()
Constructor for QgsEditorWidgetRegistry.
bool registerWidget(const QString &widgetId, QgsEditorWidgetFactory *widgetFactory)
Register a new widget factory with the given id.
Holder for the widget type and its configuration for a field.
Manages an editor widget.
Map canvas is a class for displaying all GIS data types on a canvas.
Base class for all map layer types.
Definition qgsmaplayer.h:83
A bar for displaying non-blocking messages to the user.
Shows a search widget on a filter form.
Represents a vector layer which manages a vector based dataset.
#define SIP_TRANSFERTHIS
Definition qgis_sip.h:52
#define SIP_PYARGREMOVE
Definition qgis_sip.h:158
#define SIP_TRANSFER
Definition qgis_sip.h:35
#define SIP_FACTORY
Definition qgis_sip.h:83