|
19 | 19 | #include "qgsreadwritecontext.h"
|
20 | 20 | #include "qgsrelationmanager.h"
|
21 | 21 | #include "qgslogger.h"
|
| 22 | +#include "qgsxmlutils.h" |
22 | 23 |
|
23 | 24 | //#include "qgseditorwidgetregistry.h"
|
24 | 25 |
|
@@ -337,6 +338,16 @@ void QgsEditFormConfig::readXml( const QDomNode &node, const QgsReadWriteContext
|
337 | 338 | }
|
338 | 339 | }
|
339 | 340 |
|
| 341 | + QDomNodeList widgetsNodeList = node.namedItem( QStringLiteral( "widgets" ) ).toElement().childNodes(); |
| 342 | + |
| 343 | + for ( int i = 0; i < widgetsNodeList.size(); ++i ) |
| 344 | + { |
| 345 | + QDomElement widgetElement = widgetsNodeList.at( i ).toElement(); |
| 346 | + QVariant config = QgsXmlUtils::readVariant( widgetElement.firstChildElement( "config" ) ); |
| 347 | + |
| 348 | + d->mWidgetConfigs[widgetElement.attribute( QStringLiteral( "name" ) )] = config.toMap(); |
| 349 | + } |
| 350 | + |
340 | 351 | // tabs and groups display info
|
341 | 352 | QDomNode attributeEditorFormNode = node.namedItem( QStringLiteral( "attributeEditorForm" ) );
|
342 | 353 | if ( !attributeEditorFormNode.isNull() )
|
@@ -428,37 +439,20 @@ void QgsEditFormConfig::writeXml( QDomNode &node, const QgsReadWriteContext &con
|
428 | 439 | node.appendChild( tabsElem );
|
429 | 440 | }
|
430 | 441 |
|
431 |
| - //// TODO: MAKE THIS MORE GENERIC, SO INDIVIDUALL WIDGETS CAN NOT ONLY SAVE STRINGS |
432 |
| - /// SEE QgsEditorWidgetFactory::writeConfig |
433 |
| - |
434 | 442 | QDomElement widgetsElem = doc.createElement( QStringLiteral( "widgets" ) );
|
435 | 443 |
|
436 | 444 | QMap<QString, QVariantMap >::ConstIterator configIt( d->mWidgetConfigs.constBegin() );
|
437 | 445 |
|
438 | 446 | while ( configIt != d->mWidgetConfigs.constEnd() )
|
439 | 447 | {
|
440 |
| - if ( d->mFields.indexFromName( configIt.key() ) == -1 ) |
441 |
| - { |
442 |
| - QDomElement widgetElem = doc.createElement( QStringLiteral( "widget" ) ); |
443 |
| - widgetElem.setAttribute( QStringLiteral( "name" ), configIt.key() ); |
444 |
| - // widgetElem.setAttribute( "notNull", ); |
445 |
| - |
446 |
| - QDomElement configElem = doc.createElement( QStringLiteral( "config" ) ); |
447 |
| - widgetElem.appendChild( configElem ); |
448 |
| - |
449 |
| - QVariantMap::ConstIterator cfgIt( configIt.value().constBegin() ); |
450 |
| - |
451 |
| - while ( cfgIt != configIt.value().constEnd() ) |
452 |
| - { |
453 |
| - QDomElement optionElem = doc.createElement( QStringLiteral( "option" ) ); |
454 |
| - optionElem.setAttribute( QStringLiteral( "key" ), cfgIt.key() ); |
455 |
| - optionElem.setAttribute( QStringLiteral( "value" ), cfgIt.value().toString() ); |
456 |
| - configElem.appendChild( optionElem ); |
457 |
| - ++cfgIt; |
458 |
| - } |
459 |
| - |
460 |
| - widgetsElem.appendChild( widgetElem ); |
461 |
| - } |
| 448 | + QDomElement widgetElem = doc.createElement( QStringLiteral( "widget" ) ); |
| 449 | + widgetElem.setAttribute( QStringLiteral( "name" ), configIt.key() ); |
| 450 | + // widgetElem.setAttribute( "notNull", ); |
| 451 | + |
| 452 | + QDomElement configElem = QgsXmlUtils::writeVariant( configIt.value(), doc ); |
| 453 | + configElem.setTagName( QStringLiteral( "config" ) ); |
| 454 | + widgetElem.appendChild( configElem ); |
| 455 | + widgetsElem.appendChild( widgetElem ); |
462 | 456 | ++configIt;
|
463 | 457 | }
|
464 | 458 |
|
|
0 commit comments