88 qDeleteAll( mWidgetFactories );
93 if ( mWidgetFactories.
contains( widgetId ) )
109 QString wid = findSuitableWrapper( editor,
"TextEdit" );
110 ww = mWidgetFactories[wid]->create( vl, fieldIdx, editor, parent );
124 if ( mWidgetFactories.
contains( widgetId ) )
144 if ( mWidgetFactories.
contains( widgetId ) )
146 return mWidgetFactories[widgetId]->configWidget( vl, fieldIdx, parent );
153 if ( mWidgetFactories.
contains( widgetId ) )
155 return mWidgetFactories[widgetId]->name();
163 return mWidgetFactories;
168 return mWidgetFactories.
value( widgetId );
173 if ( !widgetFactory )
178 else if ( mWidgetFactories.
contains( widgetId ) )
185 mWidgetFactories.
insert( widgetId, widgetFactory );
192 for ( ; it != types.
constEnd(); ++it )
194 if ( it.
value() > mFactoriesByType[it.
key()].first )
196 mFactoriesByType[it.
key()] = qMakePair( it.
value(), widgetId );
212 Q_ASSERT( vectorLayer );
216 for (
int i = 0; i < editTypeNodes.
size(); i++ )
218 QDomNode editTypeNode = editTypeNodes.
at( i );
237 ewv2Type = readLegacyConfig( vectorLayer, editTypeElement, cfg );
241 ewv2Type = editTypeElement.
attribute(
"widgetv2type" );
243 if ( mWidgetFactories.
contains( ewv2Type ) )
248 if ( !ewv2CfgElem.
isNull() )
250 cfg = mWidgetFactories[ewv2Type]->readEditorConfig( ewv2CfgElem, vectorLayer, idx );
295 for (
int idx = 0; idx < fields.
count(); ++idx )
299 if ( !mWidgetFactories.
contains( widgetType ) )
308 editTypeElement.
setAttribute(
"widgetv2type", widgetType );
310 if ( mWidgetFactories.
contains( widgetType ) )
319 mWidgetFactories[widgetType]->writeConfig( vectorLayer->
editFormConfig()->
widgetConfig( idx ), ewv2CfgElem, doc, vectorLayer, idx );
330 void QgsEditorWidgetRegistry::mapLayerWillBeRemoved(
QgsMapLayer* mapLayer )
341 void QgsEditorWidgetRegistry::mapLayerAdded(
QgsMapLayer* mapLayer )
352 void QgsEditorWidgetRegistry::readSymbology(
const QDomElement& element,
QString& errorMessage )
354 Q_UNUSED( errorMessage )
359 readMapLayer( vl, element );
364 Q_UNUSED( errorMessage )
369 writeMapLayer( vl, element, doc );
372 QString QgsEditorWidgetRegistry::findSuitableWrapper(
QWidget* editor,
const QString& defaultWidget )
384 for ( ; it != mFactoriesByType.
constEnd(); ++it )
389 return it.
value().second;
394 if ( it.
value().first > weight )
396 weight = it.
value().first;
397 widgetid = it.
value().second;
404 widgetid = defaultWidget;
const char * className() const
Base class for all map layer types.
bool contains(const Key &key) const
QDomNode appendChild(const QDomNode &newChild)
QString attribute(const QString &name, const QString &defValue) const
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.
bool disconnect(const QObject *sender, const char *signal, const QObject *receiver, const char *method)
QDomNodeList childNodes() const
QgsMapLayer::LayerType type() const
Get the type of the layer.
int count() const
Return number of items.
QString tr(const char *sourceText, const char *disambiguation, int n)
Map canvas is a class for displaying all GIS data types on a canvas.
const QgsField & at(int i) const
Get field at particular index (must be in range 0..N-1)
QgsEditFormConfig * editFormConfig() const
Get the configuration of the form used to represent this vector layer.
QgsFields fields() const
Returns the list of fields of this layer.
QDomElement toElement() const
const char * name() const
QVariantMap QgsEditorWidgetConfig
Holds a set of configuration parameters for a editor widget wrapper.
bool inherits(const char *className) const
void setAttribute(const QString &name, const QString &value)
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)
Encapsulate a field in an attribute table or data source.
QDomNode namedItem(const QString &name) const
#define Q_NOWARN_DEPRECATED_POP
const Key key(const T &value) const
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()
Returns the QgsProject singleton instance.
iterator insert(const Key &key, const T &value)
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