QGIS API Documentation 4.1.0-Master (5bf3c20f3c9)
Loading...
Searching...
No Matches
qgsenumerationwidgetfactory.cpp
Go to the documentation of this file.
1/***************************************************************************
2 qgsenumerationwidgetfactory.cpp
3 --------------------------------------
4 Date : 5.1.2014
5 Copyright : (C) 2014 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
17
18#include "qgsdummyconfigdlg.h"
21#include "qgsvectorlayer.h"
22
26
27QgsEditorWidgetWrapper *QgsEnumerationWidgetFactory::create( QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent ) const
28{
29 return new QgsEnumerationWidgetWrapper( vl, fieldIdx, editor, parent );
30}
31
33{
34 return new QgsDummyConfigDlg( vl, fieldIdx, parent, QObject::tr( "Combo box with values that can be used within the column's type. Must be supported by the provider." ) );
35}
36
37
38unsigned int QgsEnumerationWidgetFactory::fieldScore( const QgsVectorLayer *vl, int fieldIdx ) const
39{
40 QStringList list;
41 vl->dataProvider()->enumValues( fieldIdx, list );
42 if ( !list.isEmpty() )
43 return 20;
44 else
45 return 0;
46}
Configuration widget for dummy widgets.
Base class for widgets which configure editor widget types.
QgsEditorWidgetFactory(const QString &name, const QIcon &icon=QIcon())
Constructor.
QIcon icon() const
Returns the icon of this widget type.
QString name() const
Returns the human readable identifier name of this widget type.
Manages an editor widget.
QgsEnumerationWidgetFactory(const QString &name, const QIcon &icon=QIcon())
Constructor for QgsEnumerationWidgetFactory, where name is a human-readable name for the factory and ...
unsigned int fieldScore(const QgsVectorLayer *vl, int fieldIdx) const override
This method allows disabling this editor widget type for a certain field.
QgsEditorWidgetWrapper * create(QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent) const override
Override this in your implementation.
QgsEditorConfigWidget * configWidget(QgsVectorLayer *vl, int fieldIdx, QWidget *parent) const override
Override this in your implementation.
Widget wrapper for enumeration widgets.
virtual void enumValues(int index, QStringList &enumList) const
Returns the possible enum values of an attribute.
Represents a vector layer which manages a vector based dataset.
QgsVectorDataProvider * dataProvider() final
Returns the layer's data provider, it may be nullptr.