84 qDeleteAll( mWidgetFactories );
89 if ( mWidgetFactories.
contains( widgetId ) )
105 QString wid = findSuitableWrapper( editor,
"TextEdit" );
106 ww = mWidgetFactories[wid]->create( vl, fieldIdx, editor, parent );
120 if ( mWidgetFactories.
contains( widgetId ) )
139 if ( mWidgetFactories.
contains( widgetId ) )
141 return mWidgetFactories[widgetId]->configWidget( vl, fieldIdx, parent );
148 if ( mWidgetFactories.
contains( widgetId ) )
150 return mWidgetFactories[widgetId]->name();
158 return mWidgetFactories;
163 return mWidgetFactories.
value( widgetId );
168 if ( !widgetFactory )
173 else if ( mWidgetFactories.
contains( widgetId ) )
180 mWidgetFactories.
insert( widgetId, widgetFactory );
187 for ( ; it != types.
constEnd(); ++it )
189 if ( it.
value() > mFactoriesByType[it.
key()].first )
191 mFactoriesByType[it.
key()] = qMakePair( it.
value(), widgetId );
207 Q_ASSERT( vectorLayer );
211 for (
int i = 0; i < editTypeNodes.
size(); i++ )
213 QDomNode editTypeNode = editTypeNodes.
at( i );
232 ewv2Type = readLegacyConfig( vectorLayer, editTypeElement, cfg );
236 ewv2Type = editTypeElement.
attribute(
"widgetv2type" );
238 if ( mWidgetFactories.
contains( ewv2Type ) )
243 if ( !ewv2CfgElem.
isNull() )
245 cfg = mWidgetFactories[ewv2Type]->readEditorConfig( ewv2CfgElem, vectorLayer, idx );
286 for (
int idx = 0; idx < fields.
count(); ++idx )
290 if ( !mWidgetFactories.
contains( widgetType ) )
299 editTypeElement.
setAttribute(
"widgetv2type", widgetType );
301 if ( mWidgetFactories.
contains( widgetType ) )
307 mWidgetFactories[widgetType]->writeConfig( vectorLayer->
editorWidgetV2Config( idx ), ewv2CfgElem, doc, vectorLayer, idx );
318 void QgsEditorWidgetRegistry::mapLayerAdded(
QgsMapLayer* mapLayer )
329 void QgsEditorWidgetRegistry::readSymbology(
const QDomElement& element,
QString& errorMessage )
331 Q_UNUSED( errorMessage )
336 readMapLayer( vl, element );
341 Q_UNUSED( errorMessage )
346 writeMapLayer( vl, element, doc );
357 for ( ; it != mFactoriesByType.
constEnd(); ++it )
359 if ( editor->staticMetaObject.className() == it.
key() )
362 return it.
value().second;
364 else if ( editor->inherits( it.
key() ) )
367 if ( it.
value().first > weight )
369 weight = it.
value().first;
370 widgetid = it.
value().second;
376 widgetid = defaultWidget;
const QgsEditorWidgetConfig editorWidgetV2Config(int fieldIdx) const
Get the configuration for the editor widget used to represent the field at the given index...
const QString & name() const
Gets the name of the field.
bool fieldEditable(int idx)
Is edit widget editable.
Base class for all map layer types.
QgsMapLayer::LayerType type() const
Get the type of the layer.
bool contains(const Key &key) const
QDomNode appendChild(const QDomNode &newChild)
QString attribute(const QString &name, const QString &defValue) const
QgsFields fields() const
Returns the list of fields of this layer.
This class contains context information for attribute editor widgets.
const_iterator constBegin() const
#define Q_NOWARN_DEPRECATED_PUSH
A bar for displaying non-blocking messages to the user.
Container of fields for a vector layer.
QDomNodeList childNodes() const
QString tr(const char *sourceText, const char *disambiguation, int n)
Map canvas is a class for displaying all GIS data types on a canvas.
QDomElement toElement() const
const char * name() const
void setAttribute(const QString &name, const QString &value)
const QString editorWidgetV2(int fieldIdx) const
Get the id for the editor widget used to represent the field at the given index.
int toInt(bool *ok, int base) const
const_iterator constEnd() const
static void logMessage(const QString &message, const QString &tag=QString::null, MessageLevel level=WARNING)
add a message to the instance (and create it if necessary)
int count() const
Return number of items.
Encapsulate a field in an attribute table or data source.
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
bool labelOnTop(int idx)
Label widget on top.
QDomNode namedItem(const QString &name) const
void setEditorWidgetV2Config(int attrIdx, const QgsEditorWidgetConfig &config)
Set the editor widget config for a field.
#define Q_NOWARN_DEPRECATED_POP
const Key key(const T &value) const
void setEditorWidgetV2(int attrIdx, const QString &widgetType)
Set the editor widget type for a field.
static QgsMapLayerRegistry * instance()
Returns the instance pointer, creating the object on the first call.
static Q_DECL_DEPRECATED const QString convertEditType(QgsVectorLayer::EditType editType, QgsEditorWidgetConfig &cfg, QgsVectorLayer *vl, const QString &name, const QDomElement &editTypeElement=QDomElement())
static QgsMessageLog * instance()
static QgsProject * instance()
access to canonical QgsProject instance
void setFieldEditable(int idx, bool editable)
Set edit widget editable.
iterator insert(const Key &key, const T &value)
void setLabelOnTop(int idx, bool onTop)
Label widget on top.
QDomElement createElement(const QString &tagName)
bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *method, Qt::ConnectionType type)
Represents a vector layer which manages a vector based data sets.
int fieldNameIndex(const QString &fieldName) const
Returns the index of a field name or -1 if the field does not exist.
QDomNode at(int index) const
const T value(const Key &key) const