28#include "moc_qgseditorwidgetregistry.cpp"
53 mFallbackWidgetFactory = std::make_unique<QgsTextEditWidgetFactory>( tr(
"Text Edit" ) );
81 qDeleteAll( mWidgetFactories );
87 const int index = fields.
indexOf( fieldName );
95 return mAutoConf.editorWidgetSetup( vl, fieldName );
102 return create( setup.
type(), vl, fieldIdx, setup.
config(), editor, parent, context );
107 if ( mWidgetFactories.contains( widgetId ) )
123 const QString wid = findSuitableWrapper( editor, QStringLiteral(
"TextEdit" ) );
124 ww = mWidgetFactories[wid]->create( vl, fieldIdx, editor, parent );
138 if ( mWidgetFactories.contains( widgetId ) )
158 if ( mWidgetFactories.contains( widgetId ) )
160 return mWidgetFactories[widgetId]->configWidget( vl, fieldIdx, parent );
167 if ( mWidgetFactories.contains( widgetId ) )
169 return mWidgetFactories[widgetId]->name();
177 if ( mWidgetFactories.contains( widgetId ) )
179 return mWidgetFactories[widgetId]->icon();
187 if ( mWidgetFactories.contains( widgetId ) )
189 return mWidgetFactories[widgetId]->isReadOnly();
197 return mWidgetFactories;
202 return mWidgetFactories.value( widgetId, mFallbackWidgetFactory.get() );
207 if ( !widgetFactory )
212 else if ( mWidgetFactories.contains( widgetId ) )
219 mWidgetFactories.insert( widgetId, widgetFactory );
223 QHash<const char *, int>::ConstIterator it;
224 it = types.constBegin();
226 for ( ; it != types.constEnd(); ++it )
228 if ( it.value() > mFactoriesByType[it.key()].first )
230 mFactoriesByType[it.key()] = qMakePair( it.value(), widgetId );
238QString QgsEditorWidgetRegistry::findSuitableWrapper( QWidget *editor,
const QString &defaultWidget )
240 QMap<const char *, QPair<int, QString>>::ConstIterator it;
249 it = mFactoriesByType.constBegin();
250 for ( ; it != mFactoriesByType.constEnd(); ++it )
252 if ( QWidget::staticMetaObject.className() == it.key() )
255 return it.value().second;
257 else if ( editor->inherits( it.key() ) )
260 if ( it.value().first > weight )
262 weight = it.value().first;
263 widgetid = it.value().second;
269 if ( widgetid.isNull() )
270 widgetid = defaultWidget;
static QIcon getThemeIcon(const QString &name, const QColor &fillColor=QColor(), const QColor &strokeColor=QColor())
Helper to get a theme icon.
Contains context information for attribute editor widgets.
Editor widget factory for datetime 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, const char *file=__builtin_FILE(), const char *function=__builtin_FUNCTION(), int line=__builtin_LINE())
Adds a message to the log instance (and creates it if necessary).
Editor widget factory for relation reference widgets.
Editor widget factory for text editor widgets.
Represents a vector layer which manages a vector based dataset.