void QgsProjectFileTransform::transform1800to1900()
{
  if ( mDom.isNull() )
  {
    return;
  }

  QDomNodeList layerItemList = mDom.elementsByTagName( "rasterproperties" );
  for ( int i = 0; i < layerItemList.size(); ++i )
  {
    QDomElement rasterPropertiesElem = layerItemList.at( i ).toElement();
    QDomNode layerNode = rasterPropertiesElem.parentNode();
    QDomElement dataSourceElem = layerNode.firstChildElement( "datasource" );
    QDomElement layerNameElem = layerNode.firstChildElement( "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.readXML( layerNode );
    convertRasterProperties( mDom, layerNode, rasterPropertiesElem, &rasterLayer );
  }

  //composer: replace mGridAnnotationPosition with mLeftGridAnnotationPosition & co.
  // and mGridAnnotationDirection with mLeftGridAnnotationDirection & co.
  QDomNodeList composerMapList = mDom.elementsByTagName( "ComposerMap" );
  for ( int i = 0; i < composerMapList.size(); ++i )
  {
    QDomNodeList gridList = composerMapList.at( i ).toElement().elementsByTagName( "Grid" );
    for ( int j = 0; j < gridList.size(); ++j )
    {
      QDomNodeList annotationList = gridList.at( j ).toElement().elementsByTagName( "Annotation" );
      for ( int k = 0; k < annotationList.size(); ++k )
      {
        QDomElement annotationElem = annotationList.at( k ).toElement();

        //position
        if ( annotationElem.hasAttribute( "position" ) )
        {
          int pos = annotationElem.attribute( "position" ).toInt();
          annotationElem.setAttribute( "leftPosition", pos );
          annotationElem.setAttribute( "rightPosition", pos );
          annotationElem.setAttribute( "topPosition", pos );
          annotationElem.setAttribute( "bottomPosition", pos );
          annotationElem.removeAttribute( "position" );
        }

        //direction
        if ( annotationElem.hasAttribute( "direction" ) )
        {
          int dir = annotationElem.attribute( "direction" ).toInt();
          if ( dir == 2 )
          {
            annotationElem.setAttribute( "leftDirection", 0 );
            annotationElem.setAttribute( "rightDirection", 0 );
            annotationElem.setAttribute( "topDirection", 1 );
            annotationElem.setAttribute( "bottomDirection", 1 );
          }
          else if ( dir == 3 )
          {
            annotationElem.setAttribute( "leftDirection", 1 );
            annotationElem.setAttribute( "rightDirection", 1 );
            annotationElem.setAttribute( "topDirection", 0 );
            annotationElem.setAttribute( "bottomDirection", 0 );
          }
          else
          {
            annotationElem.setAttribute( "leftDirection", dir );
            annotationElem.setAttribute( "rightDirection", dir );
            annotationElem.setAttribute( "topDirection", dir );
            annotationElem.setAttribute( "bottomDirection", dir );
          }
          annotationElem.removeAttribute( "direction" );
        }
      }
    }
  }

  //Composer: move all items under Composition element
  QDomNodeList composerList = mDom.elementsByTagName( "Composer" );
  for ( int i = 0; i < composerList.size(); ++i )
  {
    QDomElement composerElem = composerList.at( i ).toElement();

    //find <QgsComposition element
    QDomElement compositionElem = composerElem.firstChildElement( "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() == "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( "renderer-v2" );
  for ( int i = 0; i < rendererList.size(); ++i )
  {
    QDomNodeList layerList = rendererList.at( i ).toElement().elementsByTagName( "layer" );
    for ( int j = 0; j < layerList.size(); ++j )
    {
      QDomElement layerElem = layerList.at( j ).toElement();
      if ( layerElem.attribute( "class" ) == "SimpleFill" )
      {
        QDomNodeList propList = layerElem.elementsByTagName( "prop" );
        for ( int k = 0; k < propList.size(); ++k )
        {
          QDomElement propElem = propList.at( k ).toElement();
          if ( propElem.attribute( "k" ) == "color" || propElem.attribute( "k" ) == "color_border" )
          {
            propElem.setAttribute( "v", propElem.attribute( "v" ).section( ",", 0, 2 ) + ",255" );
          }
        }
      }
    }
  }

  QgsDebugMsg( mDom.toString() );
}
void QgsProjectFileTransform::transform1800to1900()
{
  if ( mDom.isNull() )
  {
    return;
  }

  QDomNodeList layerItemList = mDom.elementsByTagName( "rasterproperties" );
  for ( int i = 0; i < layerItemList.size(); ++i )
  {
    QDomElement rasterPropertiesElem = layerItemList.at( i ).toElement();
    QDomNode layerNode = rasterPropertiesElem.parentNode();
    QDomElement dataSourceElem = layerNode.firstChildElement( "datasource" );
    QDomElement layerNameElem = layerNode.firstChildElement( "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.readXML( layerNode );
    convertRasterProperties( mDom, layerNode, rasterPropertiesElem, &rasterLayer );
  }

  //composer: replace mGridAnnotationPosition with mLeftGridAnnotationPosition & co.
  // and mGridAnnotationDirection with mLeftGridAnnotationDirection & co.
  QDomNodeList composerMapList = mDom.elementsByTagName( "ComposerMap" );
  for ( int i = 0; i < composerMapList.size(); ++i )
  {
    QDomNodeList gridList = composerMapList.at( i ).toElement().elementsByTagName( "Grid" );
    for ( int j = 0; j < gridList.size(); ++j )
    {
      QDomNodeList annotationList = gridList.at( j ).toElement().elementsByTagName( "Annotation" );
      for ( int k = 0; k < annotationList.size(); ++k )
      {
        QDomElement annotationElem = annotationList.at( k ).toElement();

        //position
        if ( annotationElem.hasAttribute( "position" ) )
        {
          int pos = annotationElem.attribute( "position" ).toInt();
          annotationElem.setAttribute( "leftPosition", pos );
          annotationElem.setAttribute( "rightPosition", pos );
          annotationElem.setAttribute( "topPosition", pos );
          annotationElem.setAttribute( "bottomPosition", pos );
          annotationElem.removeAttribute( "position" );
        }

        //direction
        if ( annotationElem.hasAttribute( "direction" ) )
        {
          int dir = annotationElem.attribute( "direction" ).toInt();
          if ( dir == 2 )
          {
            annotationElem.setAttribute( "leftDirection", 0 );
            annotationElem.setAttribute( "rightDirection", 0 );
            annotationElem.setAttribute( "topDirection", 1 );
            annotationElem.setAttribute( "bottomDirection", 1 );
          }
          else if ( dir == 3 )
          {
            annotationElem.setAttribute( "leftDirection", 1 );
            annotationElem.setAttribute( "rightDirection", 1 );
            annotationElem.setAttribute( "topDirection", 0 );
            annotationElem.setAttribute( "bottomDirection", 0 );
          }
          else
          {
            annotationElem.setAttribute( "leftDirection", dir );
            annotationElem.setAttribute( "rightDirection", dir );
            annotationElem.setAttribute( "topDirection", dir );
            annotationElem.setAttribute( "bottomDirection", dir );
          }
          annotationElem.removeAttribute( "direction" );
        }
      }
    }
  }

  QgsDebugMsg( mDom.toString() );
}