77 qDeleteAll( mWidgetFactories );
83 const int index = fields.
indexOf( fieldName );
91 return mAutoConf.editorWidgetSetup( vl, fieldName );
98 return create( setup.
type(), vl, fieldIdx, setup.
config(), editor, parent, context );
103 if ( mWidgetFactories.contains( widgetId ) )
119 const QString wid = findSuitableWrapper( editor, QStringLiteral(
"TextEdit" ) );
120 ww = mWidgetFactories[wid]->create( vl, fieldIdx, editor, parent );
134 if ( mWidgetFactories.contains( widgetId ) )
154 if ( mWidgetFactories.contains( widgetId ) )
156 return mWidgetFactories[widgetId]->configWidget( vl, fieldIdx, parent );
163 if ( mWidgetFactories.contains( widgetId ) )
165 return mWidgetFactories[widgetId]->name();
173 return mWidgetFactories;
178 return mWidgetFactories.value( widgetId, mFallbackWidgetFactory.get() );
183 if ( !widgetFactory )
188 else if ( mWidgetFactories.contains( widgetId ) )
195 mWidgetFactories.insert( widgetId, widgetFactory );
199 QHash<const char *, int>::ConstIterator it;
200 it = types.constBegin();
202 for ( ; it != types.constEnd(); ++it )
204 if ( it.value() > mFactoriesByType[it.key()].first )
206 mFactoriesByType[it.key()] = qMakePair( it.value(), widgetId );
214QString QgsEditorWidgetRegistry::findSuitableWrapper( QWidget *editor,
const QString &defaultWidget )
216 QMap<const char *, QPair<int, QString> >::ConstIterator it;
225 it = mFactoriesByType.constBegin();
226 for ( ; it != mFactoriesByType.constEnd(); ++it )
228 if ( QWidget::staticMetaObject.className() == it.key() )
231 return it.value().second;
233 else if ( editor->inherits( it.key() ) )
236 if ( it.value().first > weight )
238 weight = it.value().first;
239 widgetid = it.value().second;
245 if ( widgetid.isNull() )
246 widgetid = defaultWidget;
This class contains context information for attribute editor widgets.
QgsEditorWidgetSetup editorWidgetSetup() const
Gets the editor widget setup for the field.
Container of fields for a vector layer.
int indexOf(const QString &fieldName) const
Gets the field index from the field name.
QgsField field(int fieldIdx) const
Returns the field at particular index (must be in range 0..N-1).
QgsField at(int i) const
Returns the field at particular index (must be in range 0..N-1).
Map canvas is a class for displaying all GIS data types on a canvas.
A bar for displaying non-blocking messages to the user.
static void logMessage(const QString &message, const QString &tag=QString(), Qgis::MessageLevel level=Qgis::MessageLevel::Warning, bool notifyUser=true)
Adds a message to the log instance (and creates it if necessary).
Represents a vector layer which manages a vector based data sets.
QgsFields fields() const FINAL
Returns the list of fields of this layer.