Skip to content
Permalink
Browse files

store and restore layer extents in projects

  • Loading branch information
jef-n authored and rldhont committed Mar 30, 2016
1 parent 5a00172 commit adf47dc700c8c4297594f6304af493293411aa1d
Showing with 12 additions and 0 deletions.
  1. +12 −0 src/core/qgsmaplayer.cpp
@@ -48,6 +48,7 @@
#include "qgsvectorlayer.h"
#include "qgsvectordataprovider.h"
#include "qgsmaplayerregistry.h"
#include "qgsxmlutils.h"


QgsMapLayer::QgsMapLayer( QgsMapLayer::LayerType type,
@@ -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() );
@@ -1216,6 +1222,12 @@ bool QgsMapLayer::importNamedStyle( QDomDocument& myDocument, QString& myErrorMe
setMinimumScale( myRoot.attribute( "minimumScale" ).toFloat() );
setMaximumScale( myRoot.attribute( "maximumScale" ).toFloat() );

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

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

0 comments on commit adf47dc

Please sign in to comment.
You can’t perform that action at this time.