Skip to content
Permalink
Browse files

automatic otfr:

* notify on message bar when CRS and OTFR kicks in (refs #9644)
* don't automatically change settings of loaded projects
  • Loading branch information
jef-n committed Mar 2, 2014
1 parent 5d6fc3d commit 3b4edb8fa8b14c3fb2f37a825c5771b76b60b6f3
Showing with 22 additions and 2 deletions.
  1. +17 −2 src/app/legend/qgslegend.cpp
  2. +5 −0 src/app/legend/qgslegend.h
@@ -34,6 +34,7 @@
#include "qgsgenericprojectionselector.h"
#include "qgsclipboard.h"
#include "qgsmessagelog.h"
#include "qgsmessagebar.h"

#include <QFont>
#include <QDomDocument>
@@ -83,6 +84,7 @@ QgsLegend::QgsLegend( QgsMapCanvas *canvas, QWidget * parent, const char *name )
, mChanging( false )
, mUpdateDrawingOrder( true )
, mGetLegendGraphicPopup( 0 )
, mLoadingLayers( false )
{
setObjectName( name );

@@ -100,6 +102,8 @@ QgsLegend::QgsLegend( QgsMapCanvas *canvas, QWidget * parent, const char *name )
this, SLOT( readProject( const QDomDocument & ) ) );
connect( QgsProject::instance(), SIGNAL( writeProject( QDomDocument & ) ),
this, SLOT( writeProject( QDomDocument & ) ) );
connect( QgsProject::instance(), SIGNAL( layerLoaded( int, int ) ),
this, SLOT( layerLoaded( int, int ) ) );

// connect map layer registry signal to legend
connect( QgsMapLayerRegistry::instance(),
@@ -1162,22 +1166,26 @@ void QgsLegend::addLayers( QList<QgsMapLayer *> theLayerList )
updateMapCanvasLayerSet();
emit itemAdded( indexFromItem( llayer ) );
}

// first layer?
if ( myFirstLayerFlag )
{
QgsMapLayer * myFirstLayer = theLayerList.at( 0 );
if ( !mMapCanvas->mapSettings().hasCrsTransformEnabled() )
if ( !mMapCanvas->mapSettings().hasCrsTransformEnabled() && !mLoadingLayers )
{
mMapCanvas->setDestinationCrs( myFirstLayer->crs() );
mMapCanvas->setMapUnits( myFirstLayer->crs().mapUnits() );

QgisApp::instance()->messageBar()->pushMessage( tr( "Destination CRS set to %1" ).arg( myFirstLayer->crs().authid() ), QgsMessageBar::INFO, QgisApp::instance()->messageTimeout() );
}
mMapCanvas->zoomToFullExtent();
mMapCanvas->clearExtentHistory();
}
else
{
if ( settings.value( "/Projections/otfTransformAutoEnable", true ).toBool() &&
!mMapCanvas->mapSettings().hasCrsTransformEnabled() )
!mMapCanvas->mapSettings().hasCrsTransformEnabled() &&
!mLoadingLayers )
{
// Verify if all layers have the same CRS
foreach ( QgsMapLayer *l, layers() )
@@ -1187,6 +1195,8 @@ void QgsLegend::addLayers( QList<QgsMapLayer *> theLayerList )
// Set to the previous de facto used so that extent does not change
mMapCanvas->setDestinationCrs( myPreviousCrs );
mMapCanvas->setCrsTransformEnabled( true );

QgisApp::instance()->messageBar()->pushMessage( tr( "On the fly reprojection enabled." ), QgsMessageBar::INFO, QgisApp::instance()->messageTimeout() );
break;
}
}
@@ -3270,3 +3280,8 @@ QImage QgsLegend::getWmsLegendPixmap( QTreeWidgetItem *item )
return rasterLayer->dataProvider()->getLegendGraphic( canvas()->scale() );
}


void QgsLegend::layerLoaded( int i, int n )
{
mLoadingLayers = i < n;
}
@@ -386,6 +386,9 @@ class QgsLegend : public QTreeWidget
*/
void updateLegendItemSymbologies();

/** Slot to catch if layers are being loaded */
void layerLoaded( int i, int n );

protected:

/*!Event handler for mouse movements.
@@ -593,6 +596,8 @@ class QgsLegend : public QTreeWidget
//! popup QFrame containing WMS getLegendGraphic pixmap
QFrame *mGetLegendGraphicPopup;

bool mLoadingLayers;

signals:
void itemAdded( QModelIndex index );
void itemMoved( QModelIndex oldIndex, QModelIndex newIndex );

0 comments on commit 3b4edb8

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