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 ) )
143 if ( mWidgetFactories.
contains( widgetId ) )
145 return mWidgetFactories[widgetId]->configWidget( vl, fieldIdx, parent );
152 if ( mWidgetFactories.
contains( widgetId ) )
154 return mWidgetFactories[widgetId]->name();
162 return mWidgetFactories;
167 return mWidgetFactories.
value( widgetId );
172 if ( !widgetFactory )
177 else if ( mWidgetFactories.
contains( widgetId ) )
184 mWidgetFactories.
insert( widgetId, widgetFactory );
191 for ( ; it != types.
constEnd(); ++it )
193 if ( it.
value() > mFactoriesByType[it.
key()].first )
195 mFactoriesByType[it.
key()] = qMakePair( it.
value(), widgetId );
211 Q_ASSERT( vectorLayer );
215 for (
int i = 0; i < editTypeNodes.
size(); i++ )
217 QDomNode editTypeNode = editTypeNodes.
at( i );
236 ewv2Type = readLegacyConfig( vectorLayer, editTypeElement, cfg );
240 ewv2Type = editTypeElement.
attribute(
"widgetv2type" );
242 if ( mWidgetFactories.
contains( ewv2Type ) )
247 if ( !ewv2CfgElem.
isNull() )
249 cfg = mWidgetFactories[ewv2Type]->readEditorConfig( ewv2CfgElem, vectorLayer, idx );
290 for (
int idx = 0; idx < fields.
count(); ++idx )
294 if ( !mWidgetFactories.
contains( widgetType ) )
303 editTypeElement.
setAttribute(
"widgetv2type", widgetType );
305 if ( mWidgetFactories.
contains( widgetType ) )
311 mWidgetFactories[widgetType]->writeConfig( vectorLayer->
editFormConfig()->
widgetConfig( idx ), ewv2CfgElem, doc, vectorLayer, idx );
322 void QgsEditorWidgetRegistry::mapLayerWillBeRemoved(
QgsMapLayer* mapLayer )
333 void QgsEditorWidgetRegistry::mapLayerAdded(
QgsMapLayer* mapLayer )
344 void QgsEditorWidgetRegistry::readSymbology(
const QDomElement& element,
QString& errorMessage )
346 Q_UNUSED( errorMessage )
351 readMapLayer( vl, element );
356 Q_UNUSED( errorMessage )
361 writeMapLayer( vl, element, doc );
364 QString QgsEditorWidgetRegistry::findSuitableWrapper(
QWidget* editor,
const QString& defaultWidget )
376 for ( ; it != mFactoriesByType.
constEnd(); ++it )
381 return it.
value().second;
386 if ( it.
value().first > weight )
388 weight = it.
value().first;
389 widgetid = it.
value().second;
396 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.
QString name() const
Gets the name of the field.
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
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()
access to canonical QgsProject 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