30#include "moc_qgseditorwidgetregistry.cpp"
32using namespace Qt::StringLiterals;
57 mFallbackWidgetFactory = std::make_unique<QgsTextEditWidgetFactory>( tr(
"Text Edit" ) );
85 qDeleteAll( mWidgetFactories );
91 const int index = fields.
indexOf( fieldName );
99 return mAutoConf.editorWidgetSetup( vl, fieldName );
106 return create( setup.
type(), vl, fieldIdx, setup.
config(), editor, parent, context );
111 if ( mWidgetFactories.contains( widgetId ) )
127 const QString wid = findSuitableWrapper( editor, u
"TextEdit"_s );
128 ww = mWidgetFactories[wid]->create( vl, fieldIdx, editor, parent );
142 if ( mWidgetFactories.contains( widgetId ) )
162 if ( mWidgetFactories.contains( widgetId ) )
164 return mWidgetFactories[widgetId]->configWidget( vl, fieldIdx, parent );
171 if ( mWidgetFactories.contains( widgetId ) )
173 return mWidgetFactories[widgetId]->name();
181 if ( mWidgetFactories.contains( widgetId ) )
183 return mWidgetFactories[widgetId]->icon();
191 if ( mWidgetFactories.contains( widgetId ) )
193 return mWidgetFactories[widgetId]->isReadOnly();
201 return mWidgetFactories;
206 return mWidgetFactories.value( widgetId, mFallbackWidgetFactory.get() );
211 if ( !widgetFactory )
216 else if ( mWidgetFactories.contains( widgetId ) )
223 mWidgetFactories.insert( widgetId, widgetFactory );
227 QHash<const char *, int>::ConstIterator it;
228 it = types.constBegin();
230 for ( ; it != types.constEnd(); ++it )
232 if ( it.value() > mFactoriesByType[it.key()].first )
234 mFactoriesByType[it.key()] = qMakePair( it.value(), widgetId );
242QString QgsEditorWidgetRegistry::findSuitableWrapper( QWidget *editor,
const QString &defaultWidget )
244 QMap<const char *, QPair<int, QString>>::ConstIterator it;
253 it = mFactoriesByType.constBegin();
254 for ( ; it != mFactoriesByType.constEnd(); ++it )
256 if ( QWidget::staticMetaObject.className() == it.key() )
259 return it.value().second;
261 else if ( editor->inherits( it.key() ) )
264 if ( it.value().first > weight )
266 weight = it.value().first;
267 widgetid = it.value().second;
273 if ( widgetid.isNull() )
274 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.