Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
store and restore layer extents in projects
  • Loading branch information
jef-n committed Mar 30, 2016
1 parent 402ee9d commit d690d72
Showing 1 changed file with 12 additions and 0 deletions.
12 changes: 12 additions & 0 deletions src/core/qgsmaplayer.cpp
Expand Up @@ -48,6 +48,7 @@
#include "qgsvectorlayer.h"
#include "qgsvectordataprovider.h"
#include "qgsmaplayerregistry.h"
#include "qgsxmlutils.h"


QgsMapLayer::QgsMapLayer( QgsMapLayer::LayerType type,
Expand Down Expand Up @@ -531,6 +532,11 @@ bool QgsMapLayer::writeLayerXML( QDomElement& layerElement, QDomDocument& docume
layerElement.setAttribute( "minimumScale", QString::number( minimumScale() ) );
layerElement.setAttribute( "maximumScale", QString::number( maximumScale() ) );

if ( !mExtent.isNull() )
{
layerElement.appendChild( QgsXmlUtils::writeRectangle( mExtent, document ) );
}

// ID
QDomElement layerId = document.createElement( "id" );
QDomText layerIdText = document.createTextNode( id() );
Expand Down Expand Up @@ -1212,6 +1218,12 @@ bool QgsMapLayer::importNamedStyle( QDomDocument& myDocument, QString& myErrorMe
setMinimumScale( myRoot.attribute( "minimumScale" ).toDouble() );
setMaximumScale( myRoot.attribute( "maximumScale" ).toDouble() );

QDomNode extentNode = myRoot.namedItem( "extent" );
if ( !extentNode.isNull() )
{
setExtent( QgsXmlUtils::readRectangle( extentNode.toElement() ) );
}

#if 0
//read transparency level
QDomNode transparencyNode = myRoot.namedItem( "transparencyLevelInt" );
Expand Down

2 comments on commit d690d72

@rldhont
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can we backport this code to 2.14 ?

Can we add read extent in readLayerXml and not only in importNamedStyle ?

@nirvn
Copy link
Contributor

@nirvn nirvn commented on d690d72 Jun 14, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@jef-n , this created the following regression: http://hub.qgis.org/issues/15026

Basically, copy / pasting style for raster layers broken as a pasting a style onto a raster layer leads to that layer getting extent of the copied style's raster.

Please sign in to comment.