void QgsProjectFileTransform::transform1800to1900() { if ( mDom.isNull() ) { return; } QDomNodeList layerItemList = mDom.elementsByTagName( QStringLiteral( "rasterproperties" ) ); for ( int i = 0; i < layerItemList.size(); ++i ) { QDomElement rasterPropertiesElem = layerItemList.at( i ).toElement(); QDomNode layerNode = rasterPropertiesElem.parentNode(); QDomElement dataSourceElem = layerNode.firstChildElement( QStringLiteral( "datasource" ) ); QDomElement layerNameElem = layerNode.firstChildElement( QStringLiteral( "layername" ) ); QgsRasterLayer rasterLayer; // TODO: We have to use more data from project file to read the layer it correctly, // OTOH, we should not read it until it was converted rasterLayer.readLayerXml( layerNode.toElement() ); convertRasterProperties( mDom, layerNode, rasterPropertiesElem, &rasterLayer ); } //composer: replace mGridAnnotationPosition with mLeftGridAnnotationPosition & co. // and mGridAnnotationDirection with mLeftGridAnnotationDirection & co. QDomNodeList composerMapList = mDom.elementsByTagName( QStringLiteral( "ComposerMap" ) ); for ( int i = 0; i < composerMapList.size(); ++i ) { QDomNodeList gridList = composerMapList.at( i ).toElement().elementsByTagName( QStringLiteral( "Grid" ) ); for ( int j = 0; j < gridList.size(); ++j ) { QDomNodeList annotationList = gridList.at( j ).toElement().elementsByTagName( QStringLiteral( "Annotation" ) ); for ( int k = 0; k < annotationList.size(); ++k ) { QDomElement annotationElem = annotationList.at( k ).toElement(); //position if ( annotationElem.hasAttribute( QStringLiteral( "position" ) ) ) { int pos = annotationElem.attribute( QStringLiteral( "position" ) ).toInt(); annotationElem.setAttribute( QStringLiteral( "leftPosition" ), pos ); annotationElem.setAttribute( QStringLiteral( "rightPosition" ), pos ); annotationElem.setAttribute( QStringLiteral( "topPosition" ), pos ); annotationElem.setAttribute( QStringLiteral( "bottomPosition" ), pos ); annotationElem.removeAttribute( QStringLiteral( "position" ) ); } //direction if ( annotationElem.hasAttribute( QStringLiteral( "direction" ) ) ) { int dir = annotationElem.attribute( QStringLiteral( "direction" ) ).toInt(); if ( dir == 2 ) { annotationElem.setAttribute( QStringLiteral( "leftDirection" ), 0 ); annotationElem.setAttribute( QStringLiteral( "rightDirection" ), 0 ); annotationElem.setAttribute( QStringLiteral( "topDirection" ), 1 ); annotationElem.setAttribute( QStringLiteral( "bottomDirection" ), 1 ); } else if ( dir == 3 ) { annotationElem.setAttribute( QStringLiteral( "leftDirection" ), 1 ); annotationElem.setAttribute( QStringLiteral( "rightDirection" ), 1 ); annotationElem.setAttribute( QStringLiteral( "topDirection" ), 0 ); annotationElem.setAttribute( QStringLiteral( "bottomDirection" ), 0 ); } else { annotationElem.setAttribute( QStringLiteral( "leftDirection" ), dir ); annotationElem.setAttribute( QStringLiteral( "rightDirection" ), dir ); annotationElem.setAttribute( QStringLiteral( "topDirection" ), dir ); annotationElem.setAttribute( QStringLiteral( "bottomDirection" ), dir ); } annotationElem.removeAttribute( QStringLiteral( "direction" ) ); } } } } //Composer: move all items under Composition element QDomNodeList composerList = mDom.elementsByTagName( QStringLiteral( "Composer" ) ); for ( int i = 0; i < composerList.size(); ++i ) { QDomElement composerElem = composerList.at( i ).toElement(); //find <QgsComposition element QDomElement compositionElem = composerElem.firstChildElement( QStringLiteral( "Composition" ) ); if ( compositionElem.isNull() ) { continue; } QDomNodeList composerChildren = composerElem.childNodes(); if ( composerChildren.size() < 1 ) { continue; } for ( int j = composerChildren.size() - 1; j >= 0; --j ) { QDomElement childElem = composerChildren.at( j ).toElement(); if ( childElem.tagName() == QLatin1String( "Composition" ) ) { continue; } composerElem.removeChild( childElem ); compositionElem.appendChild( childElem ); } } // SimpleFill symbol layer v2: avoid double transparency // replacing alpha value of symbol layer's color with 255 (the // transparency value is already stored as symbol transparency). QDomNodeList rendererList = mDom.elementsByTagName( QStringLiteral( "renderer-v2" ) ); for ( int i = 0; i < rendererList.size(); ++i ) { QDomNodeList layerList = rendererList.at( i ).toElement().elementsByTagName( QStringLiteral( "layer" ) ); for ( int j = 0; j < layerList.size(); ++j ) { QDomElement layerElem = layerList.at( j ).toElement(); if ( layerElem.attribute( QStringLiteral( "class" ) ) == QLatin1String( "SimpleFill" ) ) { QDomNodeList propList = layerElem.elementsByTagName( QStringLiteral( "prop" ) ); for ( int k = 0; k < propList.size(); ++k ) { QDomElement propElem = propList.at( k ).toElement(); if ( propElem.attribute( QStringLiteral( "k" ) ) == QLatin1String( "color" ) || propElem.attribute( QStringLiteral( "k" ) ) == QLatin1String( "color_border" ) ) { propElem.setAttribute( QStringLiteral( "v" ), propElem.attribute( QStringLiteral( "v" ) ).section( ',', 0, 2 ) + ",255" ); } } } } } QgsDebugMsg( mDom.toString() ); }