QGIS API Documentation 3.99.0-Master (2fe06baccd8)
Loading...
Searching...
No Matches
qgseditorwidgetfactory.h
Go to the documentation of this file.
1/***************************************************************************
2 qgseditorwidgetfactory.h
3 --------------------------------------
4 Date : 21.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 QGSEDITORWIDGETFACTORY_H
17#define QGSEDITORWIDGETFACTORY_H
18
19#include "qgis_gui.h"
20#include "qgis_sip.h"
21
22#include <QDomNode>
23#include <QIcon>
24#include <QMap>
25#include <QString>
26#include <QVariant>
27
30class QgsVectorLayer;
31class QWidget;
33
44class GUI_EXPORT QgsEditorWidgetFactory
45{
46 public:
53 QgsEditorWidgetFactory( const QString &name, const QIcon &icon = QIcon() );
54
55 virtual ~QgsEditorWidgetFactory() = default;
56
69 virtual QgsEditorWidgetWrapper *create( QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent ) const = 0 SIP_FACTORY;
70
71 virtual QgsSearchWidgetWrapper *createSearchWidget( QgsVectorLayer *vl, int fieldIdx, QWidget *parent ) const SIP_FACTORY;
72
78 QString name() const;
79
84 QIcon icon() const;
85
90 virtual bool isReadOnly() const { return false; }
91
102 virtual QgsEditorConfigWidget *configWidget( QgsVectorLayer *vl, int fieldIdx, QWidget *parent ) const = 0 SIP_FACTORY;
103
113 inline bool supportsField( const QgsVectorLayer *vl, int fieldIdx ) const { return fieldScore( vl, fieldIdx ) > 0; }
114
123 virtual QHash<const char *, int> supportedWidgetTypes() SIP_SKIP
124 {
125 return QHash<const char *, int>();
126 }
127
147 virtual unsigned int fieldScore( const QgsVectorLayer *vl, int fieldIdx ) const;
148
149 private:
150 QString mName;
151 QIcon mIcon;
152};
153
154#endif // QGSEDITORWIDGETFACTORY_H
Base class for widgets which configure editor widget types.
virtual QgsEditorConfigWidget * configWidget(QgsVectorLayer *vl, int fieldIdx, QWidget *parent) const =0
Override this in your implementation.
virtual QgsEditorWidgetWrapper * create(QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent) const =0
Override this in your implementation.
virtual unsigned int fieldScore(const QgsVectorLayer *vl, int fieldIdx) const
This method allows disabling this editor widget type for a certain field.
virtual QgsSearchWidgetWrapper * createSearchWidget(QgsVectorLayer *vl, int fieldIdx, QWidget *parent) const
By default a simple QgsFilterLineEdit is returned as search widget.
virtual bool isReadOnly() const
Returns true if this widget is a read-only widget.
QgsEditorWidgetFactory(const QString &name, const QIcon &icon=QIcon())
Constructor.
virtual ~QgsEditorWidgetFactory()=default
QIcon icon() const
Returns the icon of this widget type.
virtual QHash< const char *, int > supportedWidgetTypes()
Returns a list of widget types which this editor widget supports.
QString name() const
Returns the human readable identifier name of this widget type.
bool supportsField(const QgsVectorLayer *vl, int fieldIdx) const
Check if this editor widget type supports a certain field.
Manages an editor widget.
Shows a search widget on a filter form.
Represents a vector layer which manages a vector based dataset.
#define SIP_SKIP
Definition qgis_sip.h:134
#define SIP_FACTORY
Definition qgis_sip.h:84