QGIS API Documentation  2.8.2-Wien
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
qgsmapcanvassnappingutils.cpp
Go to the documentation of this file.
2 
3 #include "qgsmapcanvas.h"
4 #include "qgsvectorlayer.h"
5 
6 #include <QApplication>
7 #include <QProgressDialog>
8 
10  : QgsSnappingUtils( parent )
11  , mCanvas( canvas )
12  , mProgress( NULL )
13 {
14  connect( canvas, SIGNAL( extentsChanged() ), this, SLOT( canvasMapSettingsChanged() ) );
15  connect( canvas, SIGNAL( destinationCrsChanged() ), this, SLOT( canvasMapSettingsChanged() ) );
16  connect( canvas, SIGNAL( layersChanged() ), this, SLOT( canvasMapSettingsChanged() ) );
17  connect( canvas, SIGNAL( currentLayerChanged( QgsMapLayer* ) ), this, SLOT( canvasCurrentLayerChanged() ) );
18  canvasMapSettingsChanged();
19  canvasCurrentLayerChanged();
20 }
21 
22 void QgsMapCanvasSnappingUtils::canvasMapSettingsChanged()
23 {
24  setMapSettings( mCanvas->mapSettings() );
25 }
26 
27 void QgsMapCanvasSnappingUtils::canvasCurrentLayerChanged()
28 {
29  setCurrentLayer( qobject_cast<QgsVectorLayer*>( mCanvas->currentLayer() ) );
30 }
31 
33 {
34  QApplication::setOverrideCursor( Qt::WaitCursor );
35  mProgress = new QProgressDialog( tr( "Indexing data..." ), QString(), 0, count, mCanvas->topLevelWidget() );
36  mProgress->setWindowModality( Qt::WindowModal );
37 }
38 
40 {
41  mProgress->setValue( index );
42  if ( index == mProgress->maximum() )
43  {
44  delete mProgress;
45  mProgress = 0;
46  QApplication::restoreOverrideCursor();
47  }
48 }