17#include "moc_qgseditorwidgetregistry.cpp"
78 qDeleteAll( mWidgetFactories );
84 const int index = fields.
indexOf( fieldName );
92 return mAutoConf.editorWidgetSetup( vl, fieldName );
99 return create( setup.
type(), vl, fieldIdx, setup.
config(), editor, parent, context );
104 if ( mWidgetFactories.contains( widgetId ) )
120 const QString wid = findSuitableWrapper( editor, QStringLiteral(
"TextEdit" ) );
121 ww = mWidgetFactories[wid]->create( vl, fieldIdx, editor, parent );
135 if ( mWidgetFactories.contains( widgetId ) )
155 if ( mWidgetFactories.contains( widgetId ) )
157 return mWidgetFactories[widgetId]->configWidget( vl, fieldIdx, parent );
164 if ( mWidgetFactories.contains( widgetId ) )
166 return mWidgetFactories[widgetId]->name();
174 return mWidgetFactories;
179 return mWidgetFactories.value( widgetId, mFallbackWidgetFactory.get() );
184 if ( !widgetFactory )
189 else if ( mWidgetFactories.contains( widgetId ) )
196 mWidgetFactories.insert( widgetId, widgetFactory );
200 QHash<const char *, int>::ConstIterator it;
201 it = types.constBegin();
203 for ( ; it != types.constEnd(); ++it )
205 if ( it.value() > mFactoriesByType[it.key()].first )
207 mFactoriesByType[it.key()] = qMakePair( it.value(), widgetId );
215QString QgsEditorWidgetRegistry::findSuitableWrapper( QWidget *editor,
const QString &defaultWidget )
217 QMap<const char *, QPair<int, QString>>::ConstIterator it;
226 it = mFactoriesByType.constBegin();
227 for ( ; it != mFactoriesByType.constEnd(); ++it )
229 if ( QWidget::staticMetaObject.className() == it.key() )
232 return it.value().second;
234 else if ( editor->inherits( it.key() ) )
237 if ( it.value().first > weight )
239 weight = it.value().first;
240 widgetid = it.value().second;
246 if ( widgetid.isNull() )
247 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.
Q_INVOKABLE 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.