Skip to content

Commit 3b4edb8

Browse files
committedMar 2, 2014
automatic otfr:
* notify on message bar when CRS and OTFR kicks in (refs #9644) * don't automatically change settings of loaded projects
1 parent 5d6fc3d commit 3b4edb8

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed
 

‎src/app/legend/qgslegend.cpp

Lines changed: 17 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
#include "qgsgenericprojectionselector.h"
3535
#include "qgsclipboard.h"
3636
#include "qgsmessagelog.h"
37+
#include "qgsmessagebar.h"
3738

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

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

104108
// connect map layer registry signal to legend
105109
connect( QgsMapLayerRegistry::instance(),
@@ -1162,22 +1166,26 @@ void QgsLegend::addLayers( QList<QgsMapLayer *> theLayerList )
11621166
updateMapCanvasLayerSet();
11631167
emit itemAdded( indexFromItem( llayer ) );
11641168
}
1169+
11651170
// first layer?
11661171
if ( myFirstLayerFlag )
11671172
{
11681173
QgsMapLayer * myFirstLayer = theLayerList.at( 0 );
1169-
if ( !mMapCanvas->mapSettings().hasCrsTransformEnabled() )
1174+
if ( !mMapCanvas->mapSettings().hasCrsTransformEnabled() && !mLoadingLayers )
11701175
{
11711176
mMapCanvas->setDestinationCrs( myFirstLayer->crs() );
11721177
mMapCanvas->setMapUnits( myFirstLayer->crs().mapUnits() );
1178+
1179+
QgisApp::instance()->messageBar()->pushMessage( tr( "Destination CRS set to %1" ).arg( myFirstLayer->crs().authid() ), QgsMessageBar::INFO, QgisApp::instance()->messageTimeout() );
11731180
}
11741181
mMapCanvas->zoomToFullExtent();
11751182
mMapCanvas->clearExtentHistory();
11761183
}
11771184
else
11781185
{
11791186
if ( settings.value( "/Projections/otfTransformAutoEnable", true ).toBool() &&
1180-
!mMapCanvas->mapSettings().hasCrsTransformEnabled() )
1187+
!mMapCanvas->mapSettings().hasCrsTransformEnabled() &&
1188+
!mLoadingLayers )
11811189
{
11821190
// Verify if all layers have the same CRS
11831191
foreach ( QgsMapLayer *l, layers() )
@@ -1187,6 +1195,8 @@ void QgsLegend::addLayers( QList<QgsMapLayer *> theLayerList )
11871195
// Set to the previous de facto used so that extent does not change
11881196
mMapCanvas->setDestinationCrs( myPreviousCrs );
11891197
mMapCanvas->setCrsTransformEnabled( true );
1198+
1199+
QgisApp::instance()->messageBar()->pushMessage( tr( "On the fly reprojection enabled." ), QgsMessageBar::INFO, QgisApp::instance()->messageTimeout() );
11901200
break;
11911201
}
11921202
}
@@ -3270,3 +3280,8 @@ QImage QgsLegend::getWmsLegendPixmap( QTreeWidgetItem *item )
32703280
return rasterLayer->dataProvider()->getLegendGraphic( canvas()->scale() );
32713281
}
32723282

3283+
3284+
void QgsLegend::layerLoaded( int i, int n )
3285+
{
3286+
mLoadingLayers = i < n;
3287+
}

‎src/app/legend/qgslegend.h

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -386,6 +386,9 @@ class QgsLegend : public QTreeWidget
386386
*/
387387
void updateLegendItemSymbologies();
388388

389+
/** Slot to catch if layers are being loaded */
390+
void layerLoaded( int i, int n );
391+
389392
protected:
390393

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

599+
bool mLoadingLayers;
600+
596601
signals:
597602
void itemAdded( QModelIndex index );
598603
void itemMoved( QModelIndex oldIndex, QModelIndex newIndex );

0 commit comments

Comments
 (0)
Please sign in to comment.