QGIS API Documentation 3.99.0-Master (2fe06baccd8)
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
98 QgsEditorWidgetWrapper *create( const QString &widgetId, QgsVectorLayer *vl, int fieldIdx, const QVariantMap &config, QWidget *editor, QWidget *parent SIP_TRANSFERTHIS, const QgsAttributeEditorContext &context SIP_PYARGREMOVE = QgsAttributeEditorContext() ) SIP_FACTORY;
99
113
114 QgsSearchWidgetWrapper *createSearchWidget( const QString &widgetId, QgsVectorLayer *vl, int fieldIdx, const QVariantMap &config, QWidget *parent SIP_TRANSFERTHIS, const QgsAttributeEditorContext &context SIP_PYARGREMOVE = QgsAttributeEditorContext() ) SIP_FACTORY;
115
126 QgsEditorConfigWidget *createConfigWidget( const QString &widgetId, QgsVectorLayer *vl, int fieldIdx, QWidget *parent SIP_TRANSFERTHIS ) SIP_FACTORY;
127
135 QString name( const QString &widgetId );
136
146 QIcon icon( const QString &widgetId );
147
155 bool isReadOnly( const QString &widgetId );
156
162 QMap<QString, QgsEditorWidgetFactory *> factories();
163
169 QgsEditorWidgetFactory *factory( const QString &widgetId );
170
179 bool registerWidget( const QString &widgetId, QgsEditorWidgetFactory *widgetFactory SIP_TRANSFER );
180
186 void registerAutoConfPlugin( QgsEditorWidgetAutoConfPlugin *plugin ) { mAutoConf.registerPlugin( plugin ); }
187
188 private:
189 QString findSuitableWrapper( QWidget *editor, const QString &defaultWidget );
190
191 QMap<QString, QgsEditorWidgetFactory *> mWidgetFactories;
192 QMap<const char *, QPair<int, QString>> mFactoriesByType;
193 QgsEditorWidgetAutoConf mAutoConf;
194 std::unique_ptr<QgsEditorWidgetFactory> mFallbackWidgetFactory = nullptr;
195};
196
197#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:80
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:53
#define SIP_PYARGREMOVE
Definition qgis_sip.h:159
#define SIP_TRANSFER
Definition qgis_sip.h:36
#define SIP_FACTORY
Definition qgis_sip.h:84