mirror of
https://github.com/qgis/QGIS.git
synced 2025-04-14 00:07:35 -04:00
Remove editor widget project loading code from gui
This commit is contained in:
parent
9fd0802939
commit
c9f8ac2afe
@ -67,28 +67,6 @@ class QgsEditorWidgetFactory
|
||||
*/
|
||||
virtual QgsEditorConfigWidget* configWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const = 0 /Factory/;
|
||||
|
||||
/**
|
||||
* Read the config from an XML file and map it to a proper {@link QVariantMap}.
|
||||
*
|
||||
* @param configElement The configuration element from the project file
|
||||
* @param layer The layer for which this configuration applies
|
||||
* @param fieldIdx The field on the layer for which this configuration applies
|
||||
*
|
||||
* @return A configuration object. This will be passed to your widget wrapper later on
|
||||
*/
|
||||
QVariantMap readEditorConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx );
|
||||
|
||||
/**
|
||||
* Serialize your configuration and save it in a xml doc.
|
||||
*
|
||||
* @param config The configuration to serialize
|
||||
* @param configElement The element, where you can write your configuration into
|
||||
* @param doc The document. You can use this to create new nodes
|
||||
* @param layer The layer for which this configuration applies
|
||||
* @param fieldIdx The field on the layer for which this configuration applies
|
||||
*/
|
||||
virtual void writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx );
|
||||
|
||||
/**
|
||||
* Check if this editor widget type supports a certain field.
|
||||
*
|
||||
@ -110,17 +88,6 @@ class QgsEditorWidgetFactory
|
||||
*/
|
||||
//virtual QHash<const char*, int> supportedWidgetTypes();
|
||||
|
||||
/**
|
||||
* Read the config from an XML file and map it to a proper {@link QVariantMap}.
|
||||
*
|
||||
* @param configElement The configuration element from the project file
|
||||
* @param layer The layer for which this configuration applies
|
||||
* @param fieldIdx The field on the layer for which this configuration applies
|
||||
*
|
||||
* @return A configuration object. This will be passed to your widget wrapper later on
|
||||
*/
|
||||
virtual QVariantMap readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx );
|
||||
|
||||
/**
|
||||
* This method allows disabling this editor widget type for a certain field.
|
||||
* By default, it returns 5 for every fields.
|
||||
@ -140,16 +107,4 @@ class QgsEditorWidgetFactory
|
||||
* @see supportsField( QgsVectorLayer* vl, fieldIdx )
|
||||
*/
|
||||
virtual unsigned int fieldScore( const QgsVectorLayer* vl, int fieldIdx ) const;
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Copy the given config element to a XML attribute.
|
||||
*/
|
||||
static void config2xml( const QVariantMap& config, QDomElement& configElement, const QString& fieldName );
|
||||
|
||||
/**
|
||||
* Copy the given XML attribute to the configuration element.
|
||||
*/
|
||||
static void xml2config( const QDomElement& configElement, QVariantMap& config, const QString& fieldName );
|
||||
};
|
||||
|
@ -1977,9 +1977,8 @@ bool QgsVectorLayer::writeSymbology( QDomNode& node, QDomDocument& doc, QString&
|
||||
{
|
||||
( void )writeStyle( node, doc, errorMessage );
|
||||
|
||||
QgsFields dataProviderFields = mDataProvider->fields();
|
||||
|
||||
QDomElement fieldConfigurationElement = doc.createElement( QStringLiteral( "fieldConfiguration" ) );
|
||||
node.appendChild( fieldConfigurationElement );
|
||||
|
||||
int index = 0;
|
||||
Q_FOREACH ( const QgsField& field, mFields )
|
||||
|
@ -46,57 +46,9 @@ QString QgsEditorWidgetFactory::name()
|
||||
return mName;
|
||||
}
|
||||
|
||||
QVariantMap QgsEditorWidgetFactory::readEditorConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
return readConfig( configElement, layer, fieldIdx );
|
||||
}
|
||||
|
||||
void QgsEditorWidgetFactory::writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( config );
|
||||
Q_UNUSED( configElement );
|
||||
Q_UNUSED( doc );
|
||||
Q_UNUSED( layer );
|
||||
Q_UNUSED( fieldIdx );
|
||||
}
|
||||
|
||||
QVariantMap QgsEditorWidgetFactory::readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( configElement );
|
||||
Q_UNUSED( layer );
|
||||
Q_UNUSED( fieldIdx );
|
||||
|
||||
return QVariantMap();
|
||||
}
|
||||
|
||||
unsigned int QgsEditorWidgetFactory::fieldScore( const QgsVectorLayer* vl, int fieldIdx ) const
|
||||
{
|
||||
Q_UNUSED( vl )
|
||||
Q_UNUSED( fieldIdx )
|
||||
return 5;
|
||||
}
|
||||
|
||||
void QgsEditorWidgetFactory::config2xml( const QVariantMap& config, QDomElement& configElement, const QString& fieldName )
|
||||
{
|
||||
const QVariant value = config.value( fieldName );
|
||||
if ( value.isValid() )
|
||||
{
|
||||
if ( value.type() == QVariant::Bool )
|
||||
{
|
||||
configElement.setAttribute( fieldName, value.toBool() ? "1" : "0" );
|
||||
}
|
||||
else
|
||||
{
|
||||
configElement.setAttribute( fieldName, value.toString() );
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
void QgsEditorWidgetFactory::xml2config( const QDomElement& configElement, QVariantMap& config, const QString& fieldName )
|
||||
{
|
||||
const QString value = configElement.attribute( fieldName );
|
||||
if ( !value.isNull() )
|
||||
{
|
||||
config.insert( fieldName, value );
|
||||
}
|
||||
}
|
||||
|
@ -84,28 +84,6 @@ class GUI_EXPORT QgsEditorWidgetFactory
|
||||
*/
|
||||
virtual QgsEditorConfigWidget* configWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const = 0;
|
||||
|
||||
/**
|
||||
* Read the config from an XML file and map it to a proper {@link QVariantMap}.
|
||||
*
|
||||
* @param configElement The configuration element from the project file
|
||||
* @param layer The layer for which this configuration applies
|
||||
* @param fieldIdx The field on the layer for which this configuration applies
|
||||
*
|
||||
* @return A configuration object. This will be passed to your widget wrapper later on
|
||||
*/
|
||||
QVariantMap readEditorConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx );
|
||||
|
||||
/**
|
||||
* Serialize your configuration and save it in a xml doc.
|
||||
*
|
||||
* @param config The configuration to serialize
|
||||
* @param configElement The element, where you can write your configuration into
|
||||
* @param doc The document. You can use this to create new nodes
|
||||
* @param layer The layer for which this configuration applies
|
||||
* @param fieldIdx The field on the layer for which this configuration applies
|
||||
*/
|
||||
virtual void writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx );
|
||||
|
||||
/**
|
||||
* Check if this editor widget type supports a certain field.
|
||||
*
|
||||
@ -127,17 +105,6 @@ class GUI_EXPORT QgsEditorWidgetFactory
|
||||
*/
|
||||
virtual QHash<const char*, int> supportedWidgetTypes() { return QHash<const char*, int>(); }
|
||||
|
||||
/**
|
||||
* Read the config from an XML file and map it to a proper {@link QVariantMap}.
|
||||
*
|
||||
* @param configElement The configuration element from the project file
|
||||
* @param layer The layer for which this configuration applies
|
||||
* @param fieldIdx The field on the layer for which this configuration applies
|
||||
*
|
||||
* @return A configuration object. This will be passed to your widget wrapper later on
|
||||
*/
|
||||
virtual QVariantMap readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx );
|
||||
|
||||
/**
|
||||
* This method allows disabling this editor widget type for a certain field.
|
||||
* By default, it returns 5 for every fields.
|
||||
@ -158,18 +125,6 @@ class GUI_EXPORT QgsEditorWidgetFactory
|
||||
*/
|
||||
virtual unsigned int fieldScore( const QgsVectorLayer* vl, int fieldIdx ) const;
|
||||
|
||||
protected:
|
||||
|
||||
/**
|
||||
* Copy the given config element to a XML attribute.
|
||||
*/
|
||||
static void config2xml( const QVariantMap& config, QDomElement& configElement, const QString& fieldName );
|
||||
|
||||
/**
|
||||
* Copy the given XML attribute to the configuration element.
|
||||
*/
|
||||
static void xml2config( const QDomElement& configElement, QVariantMap& config, const QString& fieldName );
|
||||
|
||||
private:
|
||||
QString mName;
|
||||
};
|
||||
|
@ -80,11 +80,6 @@ void QgsEditorWidgetRegistry::initEditors( QgsMapCanvas *mapCanvas, QgsMessageBa
|
||||
|
||||
QgsEditorWidgetRegistry::QgsEditorWidgetRegistry()
|
||||
{
|
||||
// connect( QgsProject::instance(), SIGNAL( readMapLayer( QgsMapLayer*, const QDomElement& ) ), this, SLOT( readMapLayer( QgsMapLayer*, const QDomElement& ) ) );
|
||||
// connect( QgsProject::instance(), SIGNAL( writeMapLayer( QgsMapLayer*, QDomElement&, QDomDocument& ) ), this, SLOT( writeMapLayer( QgsMapLayer*, QDomElement&, QDomDocument& ) ) );
|
||||
|
||||
connect( QgsProject::instance(), SIGNAL( layerWillBeRemoved( QgsMapLayer* ) ), this, SLOT( mapLayerWillBeRemoved( QgsMapLayer* ) ) );
|
||||
connect( QgsProject::instance(), SIGNAL( layerWasAdded( QgsMapLayer* ) ), this, SLOT( mapLayerAdded( QgsMapLayer* ) ) );
|
||||
}
|
||||
|
||||
QgsEditorWidgetRegistry::~QgsEditorWidgetRegistry()
|
||||
@ -222,164 +217,6 @@ bool QgsEditorWidgetRegistry::registerWidget( const QString& widgetId, QgsEditor
|
||||
}
|
||||
}
|
||||
|
||||
void QgsEditorWidgetRegistry::readMapLayer( QgsMapLayer* mapLayer, const QDomElement& layerElem )
|
||||
{
|
||||
if ( mapLayer->type() != QgsMapLayer::VectorLayer )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QgsVectorLayer* vectorLayer = qobject_cast<QgsVectorLayer*>( mapLayer );
|
||||
Q_ASSERT( vectorLayer );
|
||||
|
||||
QDomNodeList editTypeNodes = layerElem.namedItem( QStringLiteral( "edittypes" ) ).childNodes();
|
||||
|
||||
QgsEditFormConfig formConfig = vectorLayer->editFormConfig();
|
||||
|
||||
for ( int i = 0; i < editTypeNodes.size(); i++ )
|
||||
{
|
||||
QDomNode editTypeNode = editTypeNodes.at( i );
|
||||
QDomElement editTypeElement = editTypeNode.toElement();
|
||||
|
||||
QString name = editTypeElement.attribute( QStringLiteral( "name" ) );
|
||||
|
||||
int idx = vectorLayer->fields().lookupField( name );
|
||||
if ( idx == -1 )
|
||||
continue;
|
||||
|
||||
QString ewv2Type = editTypeElement.attribute( QStringLiteral( "widgetv2type" ) );
|
||||
QVariantMap cfg;
|
||||
|
||||
if ( mWidgetFactories.contains( ewv2Type ) )
|
||||
{
|
||||
formConfig.setWidgetType( name, ewv2Type );
|
||||
QDomElement ewv2CfgElem = editTypeElement.namedItem( QStringLiteral( "widgetv2config" ) ).toElement();
|
||||
|
||||
if ( !ewv2CfgElem.isNull() )
|
||||
{
|
||||
cfg = mWidgetFactories[ewv2Type]->readEditorConfig( ewv2CfgElem, vectorLayer, idx );
|
||||
}
|
||||
|
||||
formConfig.setReadOnly( idx, ewv2CfgElem.attribute( QStringLiteral( "fieldEditable" ), QStringLiteral( "1" ) ) != QLatin1String( "1" ) );
|
||||
formConfig.setLabelOnTop( idx, ewv2CfgElem.attribute( QStringLiteral( "labelOnTop" ), QStringLiteral( "0" ) ) == QLatin1String( "1" ) );
|
||||
if ( ewv2CfgElem.attribute( QStringLiteral( "notNull" ), QStringLiteral( "0" ) ) == QLatin1String( "1" ) )
|
||||
{
|
||||
// upgrade from older config
|
||||
vectorLayer->setFieldConstraint( idx, QgsFieldConstraints::ConstraintNotNull );
|
||||
}
|
||||
if ( !ewv2CfgElem.attribute( QStringLiteral( "constraint" ), QString() ).isEmpty() )
|
||||
{
|
||||
// upgrade from older config
|
||||
vectorLayer->setConstraintExpression( idx, ewv2CfgElem.attribute( QStringLiteral( "constraint" ), QString() ),
|
||||
ewv2CfgElem.attribute( QStringLiteral( "constraintDescription" ), QString() ) );
|
||||
}
|
||||
|
||||
formConfig.setWidgetConfig( name, cfg );
|
||||
}
|
||||
else
|
||||
{
|
||||
QgsMessageLog::logMessage( tr( "Unknown attribute editor widget '%1'" ).arg( ewv2Type ) );
|
||||
}
|
||||
}
|
||||
|
||||
vectorLayer->setEditFormConfig( formConfig );
|
||||
}
|
||||
|
||||
void QgsEditorWidgetRegistry::writeMapLayer( QgsMapLayer* mapLayer, QDomElement& layerElem, QDomDocument& doc ) const
|
||||
{
|
||||
if ( mapLayer->type() != QgsMapLayer::VectorLayer )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QgsVectorLayer* vectorLayer = qobject_cast<QgsVectorLayer*>( mapLayer );
|
||||
if ( !vectorLayer )
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
QDomNode editTypesNode = doc.createElement( QStringLiteral( "edittypes" ) );
|
||||
|
||||
QgsFields fields = vectorLayer->fields();
|
||||
for ( int idx = 0; idx < fields.count(); ++idx )
|
||||
{
|
||||
const QgsField field = fields.at( idx );
|
||||
const QString& widgetType = vectorLayer->editFormConfig().widgetType( field.name() );
|
||||
if ( widgetType.isNull() )
|
||||
{
|
||||
// Don't save widget config if it is not manually edited
|
||||
continue;
|
||||
}
|
||||
if ( !mWidgetFactories.contains( widgetType ) )
|
||||
{
|
||||
QgsMessageLog::logMessage( tr( "Could not save unknown editor widget type '%1'." ).arg( widgetType ) );
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
QDomElement editTypeElement = doc.createElement( QStringLiteral( "edittype" ) );
|
||||
editTypeElement.setAttribute( QStringLiteral( "name" ), field.name() );
|
||||
editTypeElement.setAttribute( QStringLiteral( "widgetv2type" ), widgetType );
|
||||
|
||||
if ( mWidgetFactories.contains( widgetType ) )
|
||||
{
|
||||
QDomElement ewv2CfgElem = doc.createElement( QStringLiteral( "widgetv2config" ) );
|
||||
ewv2CfgElem.setAttribute( QStringLiteral( "fieldEditable" ), !vectorLayer->editFormConfig().readOnly( idx ) );
|
||||
ewv2CfgElem.setAttribute( QStringLiteral( "labelOnTop" ), vectorLayer->editFormConfig().labelOnTop( idx ) );
|
||||
|
||||
mWidgetFactories[widgetType]->writeConfig( vectorLayer->editFormConfig().widgetConfig( field.name() ), ewv2CfgElem, doc, vectorLayer, idx );
|
||||
|
||||
editTypeElement.appendChild( ewv2CfgElem );
|
||||
}
|
||||
|
||||
editTypesNode.appendChild( editTypeElement );
|
||||
}
|
||||
|
||||
layerElem.appendChild( editTypesNode );
|
||||
}
|
||||
|
||||
void QgsEditorWidgetRegistry::mapLayerWillBeRemoved( QgsMapLayer* mapLayer )
|
||||
{
|
||||
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( mapLayer );
|
||||
|
||||
if ( vl )
|
||||
{
|
||||
disconnect( vl, SIGNAL( readCustomSymbology( const QDomElement&, QString& ) ), this, SLOT( readSymbology( const QDomElement&, QString& ) ) );
|
||||
disconnect( vl, SIGNAL( writeCustomSymbology( QDomElement&, QDomDocument&, QString& ) ), this, SLOT( writeSymbology( QDomElement&, QDomDocument&, QString& ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsEditorWidgetRegistry::mapLayerAdded( QgsMapLayer* mapLayer )
|
||||
{
|
||||
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( mapLayer );
|
||||
|
||||
if ( vl )
|
||||
{
|
||||
connect( vl, SIGNAL( readCustomSymbology( const QDomElement&, QString& ) ), this, SLOT( readSymbology( const QDomElement&, QString& ) ) );
|
||||
connect( vl, SIGNAL( writeCustomSymbology( QDomElement&, QDomDocument&, QString& ) ), this, SLOT( writeSymbology( QDomElement&, QDomDocument&, QString& ) ) );
|
||||
}
|
||||
}
|
||||
|
||||
void QgsEditorWidgetRegistry::readSymbology( const QDomElement& element, QString& errorMessage )
|
||||
{
|
||||
Q_UNUSED( errorMessage )
|
||||
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( sender() );
|
||||
|
||||
Q_ASSERT( vl );
|
||||
|
||||
readMapLayer( vl, element );
|
||||
}
|
||||
|
||||
void QgsEditorWidgetRegistry::writeSymbology( QDomElement& element, QDomDocument& doc, QString& errorMessage )
|
||||
{
|
||||
Q_UNUSED( errorMessage )
|
||||
QgsVectorLayer* vl = qobject_cast<QgsVectorLayer*>( sender() );
|
||||
|
||||
Q_ASSERT( vl );
|
||||
|
||||
writeMapLayer( vl, element, doc );
|
||||
}
|
||||
|
||||
QString QgsEditorWidgetRegistry::findSuitableWrapper( QWidget* editor, const QString& defaultWidget )
|
||||
{
|
||||
QMap<const char*, QPair<int, QString> >::ConstIterator it;
|
||||
|
@ -180,57 +180,6 @@ class GUI_EXPORT QgsEditorWidgetRegistry : public QObject
|
||||
protected:
|
||||
QgsEditorWidgetRegistry();
|
||||
|
||||
private slots:
|
||||
|
||||
/**
|
||||
* Read all the editor widget information from a map layer XML node
|
||||
* @param mapLayer
|
||||
* @param layerElem
|
||||
*/
|
||||
void readMapLayer( QgsMapLayer* mapLayer, const QDomElement& layerElem );
|
||||
|
||||
/**
|
||||
* Write all the widget config to a layer XML node
|
||||
*
|
||||
* @param mapLayer The layer for which the config is being written
|
||||
* @param layerElem The XML element to which the config will be written
|
||||
* @param doc The document from which to create elements
|
||||
*/
|
||||
void writeMapLayer( QgsMapLayer* mapLayer, QDomElement& layerElem, QDomDocument& doc ) const;
|
||||
|
||||
/**
|
||||
* Will connect to appropriate signals from map layers to load and save style
|
||||
*
|
||||
* @param mapLayer The layer to connect
|
||||
*/
|
||||
void mapLayerAdded( QgsMapLayer* mapLayer );
|
||||
|
||||
/**
|
||||
* Will disconnect to appropriate signals from map layers to load and save style
|
||||
*
|
||||
* @param mapLayer The layer to disconnect
|
||||
*/
|
||||
void mapLayerWillBeRemoved( QgsMapLayer* mapLayer );
|
||||
|
||||
/**
|
||||
* Loads layer symbology for the layer that emitted the signal
|
||||
*
|
||||
* @param element The XML element containing the style information
|
||||
*
|
||||
* @param errorMessage Errors will be written into this string (unused)
|
||||
*/
|
||||
void readSymbology( const QDomElement& element, QString& errorMessage );
|
||||
|
||||
/**
|
||||
* Saves layer symbology for the layer that emitted the signal
|
||||
*
|
||||
* @param element The XML element where the style information be written to
|
||||
* @param doc The XML document where the style information be written to
|
||||
*
|
||||
* @param errorMessage Errors will be written into this string (unused)
|
||||
*/
|
||||
void writeSymbology( QDomElement& element, QDomDocument& doc, QString& errorMessage );
|
||||
|
||||
private:
|
||||
QString findSuitableWrapper( QWidget* editor , const QString& defaultWidget );
|
||||
|
||||
|
@ -38,29 +38,6 @@ QgsEditorConfigWidget* QgsCheckboxWidgetFactory::configWidget( QgsVectorLayer* v
|
||||
return new QgsCheckBoxConfigDlg( vl, fieldIdx, parent );
|
||||
}
|
||||
|
||||
QVariantMap QgsCheckboxWidgetFactory::readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( layer )
|
||||
Q_UNUSED( fieldIdx )
|
||||
|
||||
QVariantMap cfg;
|
||||
|
||||
xml2config( configElement, cfg, QStringLiteral( "CheckedState" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "UncheckedState" ) );
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
void QgsCheckboxWidgetFactory::writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( doc )
|
||||
Q_UNUSED( layer )
|
||||
Q_UNUSED( fieldIdx )
|
||||
|
||||
config2xml( config, configElement, QStringLiteral( "CheckedState" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "UncheckedState" ) );
|
||||
}
|
||||
|
||||
QHash<const char*, int> QgsCheckboxWidgetFactory::supportedWidgetTypes()
|
||||
{
|
||||
QHash<const char*, int> map = QHash<const char*, int>();
|
||||
|
@ -33,8 +33,6 @@ class GUI_EXPORT QgsCheckboxWidgetFactory : public QgsEditorWidgetFactory
|
||||
QgsEditorWidgetWrapper* create( QgsVectorLayer* vl, int fieldIdx, QWidget* editor, QWidget* parent ) const override;
|
||||
QgsSearchWidgetWrapper* createSearchWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const override;
|
||||
QgsEditorConfigWidget* configWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const override;
|
||||
QVariantMap readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
void writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
QHash<const char *, int> supportedWidgetTypes() override;
|
||||
unsigned int fieldScore( const QgsVectorLayer* vl, int fieldIdx ) const override;
|
||||
};
|
||||
|
@ -34,52 +34,6 @@ QgsEditorConfigWidget* QgsExternalResourceWidgetFactory::configWidget( QgsVector
|
||||
return new QgsExternalResourceConfigDlg( vl, fieldIdx, parent );
|
||||
}
|
||||
|
||||
void QgsExternalResourceWidgetFactory::writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( doc )
|
||||
Q_UNUSED( layer )
|
||||
Q_UNUSED( fieldIdx )
|
||||
|
||||
config2xml( config, configElement, QStringLiteral( "FileWidget" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "FileWidgetButton" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "UseLink" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "FullUrl" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "DefaultRoot" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "RelativeStorage" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "DocumentViewer" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "DocumentViewerWidth" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "DocumentViewerHeight" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "FileWidgetFilter" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "StorageMode" ) );
|
||||
}
|
||||
|
||||
QVariantMap QgsExternalResourceWidgetFactory::readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( layer )
|
||||
Q_UNUSED( fieldIdx )
|
||||
|
||||
QVariantMap cfg;
|
||||
|
||||
xml2config( configElement, cfg, QStringLiteral( "FileWidget" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "FileWidgetButton" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "UseLink" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "FullUrl" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "DefaultRoot" ) );
|
||||
if ( configElement.hasAttribute( QStringLiteral( "RelativeStorage" ) ) )
|
||||
{
|
||||
if (( configElement.attribute( QStringLiteral( "RelativeStorage" ) ).toInt() == QgsFileWidget::RelativeDefaultPath && configElement.hasAttribute( QStringLiteral( "DefaultRoot" ) ) ) ||
|
||||
configElement.attribute( QStringLiteral( "RelativeStorage" ) ).toInt() == QgsFileWidget::RelativeProject )
|
||||
xml2config( configElement, cfg, QStringLiteral( "RelativeStorage" ) );
|
||||
}
|
||||
xml2config( configElement, cfg, QStringLiteral( "DocumentViewer" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "DocumentViewerWidth" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "DocumentViewerHeight" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "FileWidgetFilter" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "StorageMode" ) );
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
unsigned int QgsExternalResourceWidgetFactory::fieldScore( const QgsVectorLayer* vl, int fieldIdx ) const
|
||||
{
|
||||
if ( vl->fields().at( fieldIdx ).type() == QVariant::String )
|
||||
|
@ -34,12 +34,7 @@ class GUI_EXPORT QgsExternalResourceWidgetFactory : public QgsEditorWidgetFactor
|
||||
public:
|
||||
QgsEditorWidgetWrapper* create( QgsVectorLayer* vl, int fieldIdx, QWidget* editor, QWidget* parent ) const override;
|
||||
QgsEditorConfigWidget* configWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const override;
|
||||
|
||||
void writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
unsigned int fieldScore( const QgsVectorLayer* vl, int fieldIdx ) const override;
|
||||
|
||||
private:
|
||||
QVariantMap readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
};
|
||||
|
||||
#endif // QGSEXTERNALRESOURCEWIDGETFACTORY_H
|
||||
|
@ -40,23 +40,6 @@ QgsEditorConfigWidget* QgsKeyValueWidgetFactory::configWidget( QgsVectorLayer *v
|
||||
return new QgsDummyConfigDlg( vl, fieldIdx, parent, QObject::tr( "Key/Value field" ) );
|
||||
}
|
||||
|
||||
QVariantMap QgsKeyValueWidgetFactory::readConfig( const QDomElement &configElement, QgsVectorLayer *layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( configElement );
|
||||
Q_UNUSED( layer );
|
||||
Q_UNUSED( fieldIdx );
|
||||
return QVariantMap();
|
||||
}
|
||||
|
||||
void QgsKeyValueWidgetFactory::writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( config );
|
||||
Q_UNUSED( configElement );
|
||||
Q_UNUSED( doc );
|
||||
Q_UNUSED( layer );
|
||||
Q_UNUSED( fieldIdx );
|
||||
}
|
||||
|
||||
unsigned int QgsKeyValueWidgetFactory::fieldScore( const QgsVectorLayer* vl, int fieldIdx ) const
|
||||
{
|
||||
const QgsField field = vl->fields().field( fieldIdx );
|
||||
|
@ -37,8 +37,6 @@ class GUI_EXPORT QgsKeyValueWidgetFactory : public QgsEditorWidgetFactory
|
||||
QgsEditorWidgetWrapper* create( QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent ) const override;
|
||||
//QgsSearchWidgetWrapper* createSearchWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const override;
|
||||
QgsEditorConfigWidget* configWidget( QgsVectorLayer *vl, int fieldIdx, QWidget *parent ) const override;
|
||||
QVariantMap readConfig( const QDomElement &configElement, QgsVectorLayer *layer, int fieldIdx ) override;
|
||||
void writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
unsigned int fieldScore( const QgsVectorLayer* vl, int fieldIdx ) const override;
|
||||
};
|
||||
|
||||
|
@ -41,23 +41,6 @@ QgsEditorConfigWidget* QgsListWidgetFactory::configWidget( QgsVectorLayer *vl, i
|
||||
return new QgsDummyConfigDlg( vl, fieldIdx, parent, QObject::tr( "List field" ) );
|
||||
}
|
||||
|
||||
QVariantMap QgsListWidgetFactory::readConfig( const QDomElement &configElement, QgsVectorLayer *layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( configElement );
|
||||
Q_UNUSED( layer );
|
||||
Q_UNUSED( fieldIdx );
|
||||
return QVariantMap();
|
||||
}
|
||||
|
||||
void QgsListWidgetFactory::writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( config );
|
||||
Q_UNUSED( configElement );
|
||||
Q_UNUSED( doc );
|
||||
Q_UNUSED( layer );
|
||||
Q_UNUSED( fieldIdx );
|
||||
}
|
||||
|
||||
unsigned int QgsListWidgetFactory::fieldScore( const QgsVectorLayer* vl, int fieldIdx ) const
|
||||
{
|
||||
const QgsField field = vl->fields().field( fieldIdx );
|
||||
|
@ -37,8 +37,6 @@ class GUI_EXPORT QgsListWidgetFactory : public QgsEditorWidgetFactory
|
||||
QgsEditorWidgetWrapper* create( QgsVectorLayer *vl, int fieldIdx, QWidget *editor, QWidget *parent ) const override;
|
||||
//QgsSearchWidgetWrapper* createSearchWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const override;
|
||||
QgsEditorConfigWidget* configWidget( QgsVectorLayer *vl, int fieldIdx, QWidget *parent ) const override;
|
||||
QVariantMap readConfig( const QDomElement &configElement, QgsVectorLayer *layer, int fieldIdx ) override;
|
||||
void writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
unsigned int fieldScore( const QgsVectorLayer* vl, int fieldIdx ) const override;
|
||||
};
|
||||
|
||||
|
@ -33,26 +33,3 @@ QgsEditorConfigWidget* QgsPhotoWidgetFactory::configWidget( QgsVectorLayer* vl,
|
||||
{
|
||||
return new QgsPhotoConfigDlg( vl, fieldIdx, parent );
|
||||
}
|
||||
|
||||
QVariantMap QgsPhotoWidgetFactory::readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( layer )
|
||||
Q_UNUSED( fieldIdx )
|
||||
|
||||
QVariantMap cfg;
|
||||
|
||||
xml2config( configElement, cfg, QStringLiteral( "Height" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "Width" ) );
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
void QgsPhotoWidgetFactory::writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( doc )
|
||||
Q_UNUSED( layer )
|
||||
Q_UNUSED( fieldIdx )
|
||||
|
||||
config2xml( config, configElement, QStringLiteral( "Height" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "Width" ) );
|
||||
}
|
||||
|
@ -27,14 +27,8 @@ class GUI_EXPORT QgsPhotoWidgetFactory : public QgsEditorWidgetFactory
|
||||
{
|
||||
public:
|
||||
explicit QgsPhotoWidgetFactory( const QString& name );
|
||||
|
||||
|
||||
// QgsEditorWidgetFactory interface
|
||||
public:
|
||||
QgsEditorWidgetWrapper* create( QgsVectorLayer* vl, int fieldIdx, QWidget* editor, QWidget* parent ) const override;
|
||||
QgsEditorConfigWidget* configWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const override;
|
||||
QVariantMap readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
void writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
};
|
||||
|
||||
#endif // QGSPHOTOWIDGETFACTORY_H
|
||||
|
@ -34,36 +34,6 @@ QgsEditorConfigWidget* QgsRangeWidgetFactory::configWidget( QgsVectorLayer* vl,
|
||||
return new QgsRangeConfigDlg( vl, fieldIdx, parent );
|
||||
}
|
||||
|
||||
QVariantMap QgsRangeWidgetFactory::readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( layer );
|
||||
Q_UNUSED( fieldIdx );
|
||||
QVariantMap cfg;
|
||||
|
||||
xml2config( configElement, cfg, QStringLiteral( "Style" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "Min" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "Max" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "Step" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "AllowNull" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "Suffix" ) );
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
void QgsRangeWidgetFactory::writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( doc );
|
||||
Q_UNUSED( layer );
|
||||
Q_UNUSED( fieldIdx );
|
||||
|
||||
config2xml( config, configElement, QStringLiteral( "Style" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "Min" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "Max" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "Step" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "AllowNull" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "Suffix" ) );
|
||||
}
|
||||
|
||||
unsigned int QgsRangeWidgetFactory::fieldScore( const QgsVectorLayer* vl, int fieldIdx ) const
|
||||
{
|
||||
const QgsField field = vl->fields().at( fieldIdx );
|
||||
|
@ -32,8 +32,6 @@ class GUI_EXPORT QgsRangeWidgetFactory : public QgsEditorWidgetFactory
|
||||
public:
|
||||
virtual QgsEditorWidgetWrapper* create( QgsVectorLayer* vl, int fieldIdx, QWidget* editor, QWidget* parent ) const override;
|
||||
virtual QgsEditorConfigWidget* configWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const override;
|
||||
virtual QVariantMap readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
virtual void writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
virtual QHash<const char *, int> supportedWidgetTypes() override;
|
||||
|
||||
private:
|
||||
|
@ -47,68 +47,6 @@ QgsEditorConfigWidget* QgsRelationReferenceFactory::configWidget( QgsVectorLayer
|
||||
return new QgsRelationReferenceConfigDlg( vl, fieldIdx, parent );
|
||||
}
|
||||
|
||||
QVariantMap QgsRelationReferenceFactory::readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( layer );
|
||||
Q_UNUSED( fieldIdx );
|
||||
QVariantMap cfg;
|
||||
|
||||
xml2config( configElement, cfg, QStringLiteral( "AllowNULL" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "OrderByValue" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "ShowForm" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "Relation" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "MapIdentification" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "ReadOnly" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "AllowAddFeatures" ) );
|
||||
|
||||
QDomNode filterNode = configElement.elementsByTagName( QStringLiteral( "FilterFields" ) ).at( 0 );
|
||||
if ( !filterNode.isNull() )
|
||||
{
|
||||
QStringList filterFields;
|
||||
QDomNodeList fieldNodes = filterNode.toElement().elementsByTagName( QStringLiteral( "field" ) );
|
||||
filterFields.reserve( fieldNodes.size() );
|
||||
for ( int i = 0; i < fieldNodes.size(); i++ )
|
||||
{
|
||||
QDomElement fieldElement = fieldNodes.at( i ).toElement();
|
||||
filterFields << fieldElement.attribute( QStringLiteral( "name" ) );
|
||||
}
|
||||
cfg.insert( QStringLiteral( "FilterFields" ), filterFields );
|
||||
|
||||
xml2config( configElement, cfg , QStringLiteral( "ChainFilters" ) );
|
||||
}
|
||||
return cfg;
|
||||
}
|
||||
|
||||
void QgsRelationReferenceFactory::writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( doc );
|
||||
Q_UNUSED( layer );
|
||||
Q_UNUSED( fieldIdx );
|
||||
|
||||
config2xml( config, configElement, QStringLiteral( "AllowNULL" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "OrderByValue" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "ShowForm" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "Relation" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "MapIdentification" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "ReadOnly" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "AllowAddFeatures" ) );
|
||||
|
||||
if ( config.contains( QStringLiteral( "FilterFields" ) ) )
|
||||
{
|
||||
QDomElement filterFields = doc.createElement( QStringLiteral( "FilterFields" ) );
|
||||
|
||||
Q_FOREACH ( const QString& field, config["FilterFields"].toStringList() )
|
||||
{
|
||||
QDomElement fieldElem = doc.createElement( QStringLiteral( "field" ) );
|
||||
fieldElem.setAttribute( QStringLiteral( "name" ), field );
|
||||
filterFields.appendChild( fieldElem );
|
||||
}
|
||||
configElement.appendChild( filterFields );
|
||||
|
||||
config2xml( config, configElement, QStringLiteral( "ChainFilters" ) );
|
||||
}
|
||||
}
|
||||
|
||||
QHash<const char*, int> QgsRelationReferenceFactory::supportedWidgetTypes()
|
||||
{
|
||||
QHash<const char*, int> map = QHash<const char*, int>();
|
||||
|
@ -60,28 +60,6 @@ class GUI_EXPORT QgsRelationReferenceFactory : public QgsEditorWidgetFactory
|
||||
*/
|
||||
virtual QgsEditorConfigWidget* configWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const override;
|
||||
|
||||
/**
|
||||
* Read the config from an XML file and map it to a proper {@link QVariantMap}.
|
||||
*
|
||||
* @param configElement The configuration element from the project file
|
||||
* @param layer The layer for which this configuration applies
|
||||
* @param fieldIdx The field on the layer for which this configuration applies
|
||||
*
|
||||
* @return A configuration object. This will be passed to your widget wrapper later on
|
||||
*/
|
||||
virtual QVariantMap readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
|
||||
/**
|
||||
* Serialize your configuration and save it in a xml doc.
|
||||
*
|
||||
* @param config The configuration to serialize
|
||||
* @param configElement The element, where you can write your configuration into
|
||||
* @param doc The document. You can use this to create new nodes
|
||||
* @param layer The layer for which this configuration applies
|
||||
* @param fieldIdx The field on the layer for which this configuration applies
|
||||
*/
|
||||
virtual void writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
|
||||
virtual QHash<const char *, int> supportedWidgetTypes() override;
|
||||
|
||||
virtual unsigned int fieldScore( const QgsVectorLayer* vl, int fieldIdx ) const override;
|
||||
|
@ -39,33 +39,9 @@ QgsEditorConfigWidget* QgsTextEditWidgetFactory::configWidget( QgsVectorLayer* v
|
||||
return new QgsTextEditConfigDlg( vl, fieldIdx, parent );
|
||||
}
|
||||
|
||||
|
||||
void QgsTextEditWidgetFactory::writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( doc )
|
||||
Q_UNUSED( layer )
|
||||
Q_UNUSED( fieldIdx )
|
||||
|
||||
config2xml( config, configElement, QStringLiteral( "IsMultiline" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "UseHtml" ) );
|
||||
}
|
||||
|
||||
QVariantMap QgsTextEditWidgetFactory::readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( layer )
|
||||
Q_UNUSED( fieldIdx )
|
||||
|
||||
QVariantMap cfg;
|
||||
|
||||
xml2config( configElement, cfg, QStringLiteral( "IsMultiline" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "UseHtml" ) );
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
unsigned int QgsTextEditWidgetFactory::fieldScore( const QgsVectorLayer* vl, int fieldIdx ) const
|
||||
{
|
||||
Q_UNUSED( vl )
|
||||
Q_UNUSED( fieldIdx )
|
||||
return 10;
|
||||
}
|
||||
}
|
||||
|
@ -27,18 +27,11 @@ class GUI_EXPORT QgsTextEditWidgetFactory : public QgsEditorWidgetFactory
|
||||
{
|
||||
public:
|
||||
QgsTextEditWidgetFactory( const QString& name );
|
||||
|
||||
// QgsEditorWidgetFactory interface
|
||||
public:
|
||||
QgsEditorWidgetWrapper* create( QgsVectorLayer* vl, int fieldIdx, QWidget* editor, QWidget* parent ) const override;
|
||||
QgsSearchWidgetWrapper* createSearchWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const override;
|
||||
QgsEditorConfigWidget* configWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const override;
|
||||
|
||||
void writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
unsigned int fieldScore( const QgsVectorLayer* vl, int fieldIdx ) const override;
|
||||
|
||||
private:
|
||||
QVariantMap readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
};
|
||||
|
||||
#endif // QGSTEXTEDITWIDGETFACTORY_H
|
||||
|
@ -33,23 +33,3 @@ QgsEditorConfigWidget* QgsUniqueValueWidgetFactory::configWidget( QgsVectorLayer
|
||||
{
|
||||
return new QgsUniqueValuesConfigDlg( vl, fieldIdx, parent );
|
||||
}
|
||||
|
||||
QVariantMap QgsUniqueValueWidgetFactory::readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( layer )
|
||||
Q_UNUSED( fieldIdx )
|
||||
|
||||
QVariantMap cfg;
|
||||
|
||||
xml2config( configElement, cfg, QStringLiteral( "Editable" ) );
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
void QgsUniqueValueWidgetFactory::writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( doc )
|
||||
Q_UNUSED( layer )
|
||||
Q_UNUSED( fieldIdx )
|
||||
config2xml( config, configElement, QStringLiteral( "Editable" ) );
|
||||
}
|
||||
|
@ -33,8 +33,6 @@ class GUI_EXPORT QgsUniqueValueWidgetFactory : public QgsEditorWidgetFactory
|
||||
public:
|
||||
QgsEditorWidgetWrapper* create( QgsVectorLayer* vl, int fieldIdx, QWidget* editor, QWidget* parent ) const override;
|
||||
QgsEditorConfigWidget* configWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const override;
|
||||
QVariantMap readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
void writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
};
|
||||
|
||||
#endif // QGSUNIQUEVALUEWIDGETFACTORY_H
|
||||
|
@ -44,44 +44,6 @@ QgsEditorConfigWidget* QgsValueMapWidgetFactory::configWidget( QgsVectorLayer* v
|
||||
return new QgsValueMapConfigDlg( vl, fieldIdx, parent );
|
||||
}
|
||||
|
||||
QVariantMap QgsValueMapWidgetFactory::readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( layer )
|
||||
Q_UNUSED( fieldIdx )
|
||||
|
||||
QVariantMap cfg;
|
||||
|
||||
QDomNodeList nodes = configElement.elementsByTagName( QStringLiteral( "value" ) );
|
||||
|
||||
for ( int i = 0; i < nodes.size(); ++i )
|
||||
{
|
||||
QDomElement elem = nodes.at( i ).toElement();
|
||||
cfg.insert( elem.attribute( QStringLiteral( "key" ) ), elem.attribute( QStringLiteral( "value" ) ) );
|
||||
}
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
void QgsValueMapWidgetFactory::writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( layer )
|
||||
Q_UNUSED( fieldIdx )
|
||||
|
||||
QVariantMap::ConstIterator it = config.constBegin();
|
||||
|
||||
while ( it != config.constEnd() )
|
||||
{
|
||||
QDomElement elem = doc.createElement( QStringLiteral( "value" ) );
|
||||
|
||||
elem.setAttribute( QStringLiteral( "key" ), it.key() );
|
||||
elem.setAttribute( QStringLiteral( "value" ), it.value().toString() );
|
||||
|
||||
configElement.appendChild( elem );
|
||||
|
||||
++it;
|
||||
}
|
||||
}
|
||||
|
||||
QHash<const char*, int> QgsValueMapWidgetFactory::supportedWidgetTypes()
|
||||
{
|
||||
QHash<const char*, int> map = QHash<const char*, int>();
|
||||
|
@ -27,14 +27,9 @@ class GUI_EXPORT QgsValueMapWidgetFactory : public QgsEditorWidgetFactory
|
||||
{
|
||||
public:
|
||||
QgsValueMapWidgetFactory( const QString& name );
|
||||
|
||||
// QgsEditorWidgetFactory interface
|
||||
public:
|
||||
QgsEditorWidgetWrapper* create( QgsVectorLayer* vl, int fieldIdx, QWidget* editor, QWidget* parent ) const override;
|
||||
QgsSearchWidgetWrapper* createSearchWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const override;
|
||||
QgsEditorConfigWidget* configWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const override;
|
||||
QVariantMap readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
void writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
virtual QHash<const char *, int> supportedWidgetTypes() override;
|
||||
};
|
||||
|
||||
|
@ -43,38 +43,3 @@ QgsEditorConfigWidget* QgsValueRelationWidgetFactory::configWidget( QgsVectorLay
|
||||
{
|
||||
return new QgsValueRelationConfigDlg( vl, fieldIdx, parent );
|
||||
}
|
||||
|
||||
QVariantMap QgsValueRelationWidgetFactory::readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( layer )
|
||||
Q_UNUSED( fieldIdx )
|
||||
|
||||
QVariantMap cfg;
|
||||
|
||||
xml2config( configElement, cfg, QStringLiteral( "Layer" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "Key" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "Value" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "FilterExpression" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "OrderByValue" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "AllowMulti" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "AllowNull" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "UseCompleter" ) );
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
void QgsValueRelationWidgetFactory::writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( doc )
|
||||
Q_UNUSED( layer )
|
||||
Q_UNUSED( fieldIdx )
|
||||
|
||||
config2xml( config, configElement, QStringLiteral( "Layer" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "Key" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "Value" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "FilterExpression" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "OrderByValue" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "AllowMulti" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "AllowNull" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "UseCompleter" ) );
|
||||
}
|
||||
|
@ -35,8 +35,6 @@ class GUI_EXPORT QgsValueRelationWidgetFactory : public QgsEditorWidgetFactory
|
||||
QgsEditorWidgetWrapper* create( QgsVectorLayer* vl, int fieldIdx, QWidget* editor, QWidget* parent ) const override;
|
||||
QgsSearchWidgetWrapper* createSearchWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const override;
|
||||
QgsEditorConfigWidget* configWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const override;
|
||||
QVariantMap readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
void writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
};
|
||||
|
||||
#endif // QGSVALUERELATIONWIDGETFACTORY_H
|
||||
|
@ -33,26 +33,3 @@ QgsEditorConfigWidget* QgsWebViewWidgetFactory::configWidget( QgsVectorLayer* vl
|
||||
{
|
||||
return new QgsWebViewWidgetConfigDlg( vl, fieldIdx, parent );
|
||||
}
|
||||
|
||||
QVariantMap QgsWebViewWidgetFactory::readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( layer )
|
||||
Q_UNUSED( fieldIdx )
|
||||
|
||||
QVariantMap cfg;
|
||||
|
||||
xml2config( configElement, cfg, QStringLiteral( "Height" ) );
|
||||
xml2config( configElement, cfg, QStringLiteral( "Width" ) );
|
||||
|
||||
return cfg;
|
||||
}
|
||||
|
||||
void QgsWebViewWidgetFactory::writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx )
|
||||
{
|
||||
Q_UNUSED( doc )
|
||||
Q_UNUSED( layer )
|
||||
Q_UNUSED( fieldIdx )
|
||||
|
||||
config2xml( config, configElement, QStringLiteral( "Height" ) );
|
||||
config2xml( config, configElement, QStringLiteral( "Width" ) );
|
||||
}
|
||||
|
@ -27,13 +27,8 @@ class GUI_EXPORT QgsWebViewWidgetFactory : public QgsEditorWidgetFactory
|
||||
{
|
||||
public:
|
||||
explicit QgsWebViewWidgetFactory( const QString& name );
|
||||
|
||||
// QgsEditorWidgetFactory interface
|
||||
public:
|
||||
QgsEditorWidgetWrapper* create( QgsVectorLayer* vl, int fieldIdx, QWidget* editor, QWidget* parent ) const override;
|
||||
QgsEditorConfigWidget* configWidget( QgsVectorLayer* vl, int fieldIdx, QWidget* parent ) const override;
|
||||
QVariantMap readConfig( const QDomElement& configElement, QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
void writeConfig( const QVariantMap& config, QDomElement& configElement, QDomDocument& doc, const QgsVectorLayer* layer, int fieldIdx ) override;
|
||||
};
|
||||
|
||||
#endif // QGSWEBVIEWWIDGETFACTORY_H
|
||||
|
Loading…
x
Reference in New Issue
Block a user