|
25 | 25 | #include "qgsmaplayerregistry.h" |
26 | 26 | #include "qgsmslayercache.h" |
27 | 27 | #include "qgsrasterlayer.h" |
| 28 | +#include "qgsvectorlayerjoinbuffer.h" |
28 | 29 | #include "qgseditorwidgetregistry.h" |
29 | 30 | #include "qgslayertreegroup.h" |
30 | 31 |
|
@@ -237,7 +238,8 @@ QgsMapLayer* QgsServerProjectParser::createLayerFromElement( const QDomElement& |
237 | 238 | { |
238 | 239 | QgsVectorLayer* vlayer = qobject_cast<QgsVectorLayer *>( layer ); |
239 | 240 | addValueRelationLayersForLayer( vlayer ); |
240 | | - addJoinsToLayer( const_cast<QDomElement&>( elem ), vlayer ); |
| 241 | + QgsVectorLayerJoinBuffer* joinBuffer = vlayer->joinBuffer(); |
| 242 | + joinBuffer->readXml( const_cast<QDomElement&>( elem ) ); |
241 | 243 | } |
242 | 244 |
|
243 | 245 | return layer; |
@@ -1546,50 +1548,6 @@ void QgsServerProjectParser::addJoinLayersForElement( const QDomElement& layerEl |
1546 | 1548 | } |
1547 | 1549 | } |
1548 | 1550 |
|
1549 | | -// Based on QgsVectorLayerJoinBuffer::readXml |
1550 | | -void QgsServerProjectParser::addJoinsToLayer( const QDomElement& layerElem, QgsVectorLayer *vl ) const |
1551 | | -{ |
1552 | | - if ( !vl ) |
1553 | | - return; |
1554 | | - |
1555 | | - QDomElement vectorJoinsElem = layerElem.firstChildElement( "vectorjoins" ); |
1556 | | - if ( vectorJoinsElem.isNull() ) |
1557 | | - { |
1558 | | - return; |
1559 | | - } |
1560 | | - |
1561 | | - QDomNodeList joinList = vectorJoinsElem.elementsByTagName( "join" ); |
1562 | | - for ( int i = 0; i < joinList.size(); ++i ) |
1563 | | - { |
1564 | | - QDomElement infoElem = joinList.at( i ).toElement(); |
1565 | | - QgsVectorJoinInfo info; |
1566 | | - info.joinFieldName = infoElem.attribute( "joinFieldName" ); |
1567 | | - info.joinLayerId = infoElem.attribute( "joinLayerId" ); |
1568 | | - info.targetFieldName = infoElem.attribute( "targetFieldName" ); |
1569 | | - info.memoryCache = infoElem.attribute( "memoryCache" ).toInt(); |
1570 | | - |
1571 | | - info.joinFieldIndex = infoElem.attribute( "joinField" ).toInt(); //for compatibility with 1.x |
1572 | | - info.targetFieldIndex = infoElem.attribute( "targetField" ).toInt(); //for compatibility with 1.x |
1573 | | - |
1574 | | - QDomElement subsetElem = infoElem.firstChildElement( "joinFieldsSubset" ); |
1575 | | - if ( !subsetElem.isNull() ) |
1576 | | - { |
1577 | | - QStringList* fieldNames = new QStringList; |
1578 | | - QDomNodeList fieldNodes = infoElem.elementsByTagName( "field" ); |
1579 | | - for ( int i = 0; i < fieldNodes.count(); ++i ) |
1580 | | - *fieldNames << fieldNodes.at( i ).toElement().attribute( "name" ); |
1581 | | - info.setJoinFieldNamesSubset( fieldNames ); |
1582 | | - } |
1583 | | - |
1584 | | - if ( infoElem.attribute( "hasCustomPrefix" ).toInt() ) |
1585 | | - info.prefix = infoElem.attribute( "customPrefix" ); |
1586 | | - else |
1587 | | - info.prefix = QString::null; |
1588 | | - |
1589 | | - vl->addJoin( info ); |
1590 | | - } |
1591 | | -} |
1592 | | - |
1593 | 1551 | void QgsServerProjectParser::addValueRelationLayersForLayer( const QgsVectorLayer *vl ) const |
1594 | 1552 | { |
1595 | 1553 | if ( !vl ) |
|
0 commit comments