QGIS API Documentation 3.99.0-Master (26c88405ac0)
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:
47
54 QgsEditorWidgetFactory( const QString &name, const QIcon &icon = QIcon() );
55
56 virtual ~QgsEditorWidgetFactory() = default;
57
70 virtual QgsEditorWidgetWrapper *create( QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent ) const = 0 SIP_FACTORY;
71
72 virtual QgsSearchWidgetWrapper *createSearchWidget( QgsVectorLayer *vl, int fieldIdx, QWidget *parent ) const SIP_FACTORY;
73
79 QString name() const;
80
85 QIcon icon() const;
86
91 virtual bool isReadOnly() const { return false; }
92
103 virtual QgsEditorConfigWidget *configWidget( QgsVectorLayer *vl, int fieldIdx, QWidget *parent ) const = 0 SIP_FACTORY;
104
114 inline bool supportsField( const QgsVectorLayer *vl, int fieldIdx ) const { return fieldScore( vl, fieldIdx ) > 0; }
115
124 virtual QHash<const char *, int> supportedWidgetTypes() SIP_SKIP
125 {
126 return QHash<const char *, int>();
127 }
128
148 virtual unsigned int fieldScore( const QgsVectorLayer *vl, int fieldIdx ) const;
149
150 private:
151 QString mName;
152 QIcon mIcon;
153};
154
155#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