QGIS API Documentation  3.14.0-Pi (9f7028fd23)
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 
19 #include "qgsdummyconfigdlg.h"
20 #include "qgsvectorlayer.h"
21 #include "qgsvectordataprovider.h"
22 
24  : QgsEditorWidgetFactory( name )
25 {
26 }
27 
28 QgsEditorWidgetWrapper *QgsEnumerationWidgetFactory::create( QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent ) const
29 {
30  return new QgsEnumerationWidgetWrapper( vl, fieldIdx, editor, parent );
31 }
32 
34 {
35  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." ) );
36 }
37 
38 
39 unsigned int QgsEnumerationWidgetFactory::fieldScore( const QgsVectorLayer *vl, int fieldIdx ) const
40 {
41  QStringList list;
42  vl->dataProvider()->enumValues( fieldIdx, list );
43  if ( !list.isEmpty() )
44  return 20;
45  else
46  return 0;
47 }
QgsEditorConfigWidget
Definition: qgseditorconfigwidget.h:38
QgsEditorWidgetFactory
Definition: qgseditorwidgetfactory.h:42
QgsVectorLayer::dataProvider
QgsVectorDataProvider * dataProvider() FINAL
Returns the layer's data provider, it may be nullptr.
Definition: qgsvectorlayer.cpp:627
QgsDummyConfigDlg
Definition: qgsdummyconfigdlg.h:32
QgsVectorDataProvider::enumValues
virtual void enumValues(int index, QStringList &enumList) const
Returns the possible enum values of an attribute.
Definition: qgsvectordataprovider.h:260
qgsenumerationwidgetfactory.h
QgsEditorWidgetWrapper
Definition: qgseditorwidgetwrapper.h:47
qgsvectordataprovider.h
qgsvectorlayer.h
QgsVectorLayer
Definition: qgsvectorlayer.h:385
QgsEnumerationWidgetFactory::configWidget
QgsEditorConfigWidget * configWidget(QgsVectorLayer *vl, int fieldIdx, QWidget *parent) const override
Override this in your implementation.
Definition: qgsenumerationwidgetfactory.cpp:33
qgsenumerationwidgetwrapper.h
QgsEnumerationWidgetFactory::fieldScore
unsigned int fieldScore(const QgsVectorLayer *vl, int fieldIdx) const override
This method allows disabling this editor widget type for a certain field.
Definition: qgsenumerationwidgetfactory.cpp:39
QgsEnumerationWidgetWrapper
Definition: qgsenumerationwidgetwrapper.h:32
qgsdummyconfigdlg.h
QgsEnumerationWidgetFactory::create
QgsEditorWidgetWrapper * create(QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent) const override
Override this in your implementation.
Definition: qgsenumerationwidgetfactory.cpp:28
QgsEnumerationWidgetFactory::QgsEnumerationWidgetFactory
QgsEnumerationWidgetFactory(const QString &name)
Constructor for QgsEnumerationWidgetFactory, where name is a human-readable name for the factory.
Definition: qgsenumerationwidgetfactory.cpp:23