[QGIS Commit] r12926 - in trunk/qgis/src/app: . legend

svn_qgis at osgeo.org svn_qgis at osgeo.org
Thu Feb 11 07:18:19 EST 2010


Author: jef
Date: 2010-02-11 07:18:17 -0500 (Thu, 11 Feb 2010)
New Revision: 12926

Modified:
   trunk/qgis/src/app/legend/qgslegend.cpp
   trunk/qgis/src/app/qgisapp.cpp
   trunk/qgis/src/app/qgisapp.h
Log:
use signals to mark project dirty when canvas layer or extents change (fixes #943)

Modified: trunk/qgis/src/app/legend/qgslegend.cpp
===================================================================
--- trunk/qgis/src/app/legend/qgslegend.cpp	2010-02-11 10:31:21 UTC (rev 12925)
+++ trunk/qgis/src/app/legend/qgslegend.cpp	2010-02-11 12:18:17 UTC (rev 12926)
@@ -161,6 +161,8 @@
 
   // Turn on rendering (if it was on previously)
   mMapCanvas->setRenderFlag( renderFlagState );
+
+  QgsProject::instance()->dirty( true );
 }
 
 void QgsLegend::removeGroup( int groupIndex )
@@ -1619,9 +1621,6 @@
   //zoom to bounding box
   mMapCanvas->setExtent( extent );
   mMapCanvas->refresh();
-
-  // notify the project we've made a change
-  QgsProject::instance()->dirty( true );
 }
 
 void QgsLegend::legendLayerZoomNative()
@@ -1641,9 +1640,6 @@
     mMapCanvas->refresh();
 
     QgsDebugMsg( "MapUnitsPerPixel after  : " + QString::number( mMapCanvas->mapUnitsPerPixel() ) );
-
-    // notify the project we've made a change
-    QgsProject::instance()->dirty( true );
   }
 }
 

Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2010-02-11 10:31:21 UTC (rev 12925)
+++ trunk/qgis/src/app/qgisapp.cpp	2010-02-11 12:18:17 UTC (rev 12926)
@@ -1831,6 +1831,10 @@
   connect( mMapCanvas, SIGNAL( selectionChanged( QgsMapLayer * ) ),
            this, SLOT( activateDeactivateLayerRelatedActions( QgsMapLayer * ) ) );
 
+  // track of canvas layers and extents and mark project dirty on changes
+  connect( mMapCanvas, SIGNAL( extentsChanged() ), this, SLOT( markDirty() ) );
+  connect( mMapCanvas, SIGNAL( layersChanged() ), this, SLOT( markDirty() ) );
+
   connect( mRenderSuppressionCBox, SIGNAL( toggled( bool ) ), mMapCanvas, SLOT( setRenderFlag( bool ) ) );
   //
   // Do we really need this ??? - its already connected to the esc key...TS
@@ -2397,8 +2401,6 @@
         layer->setLayerName( elements.at( 1 ) );
         // Register this layer with the layers registry
         QgsMapLayerRegistry::instance()->addMapLayer( layer );
-        // notify the project we've made a change
-        QgsProject::instance()->dirty( true );
       }
     }
     else
@@ -2553,8 +2555,6 @@
       {
         // register this layer with the central layers registry
         QgsMapLayerRegistry::instance()->addMapLayer( layer );
-        // notify the project we've made a change
-        QgsProject::instance()->dirty( true );
       }
       else
       {
@@ -2635,8 +2635,6 @@
       {
         // register this layer with the central layers registry
         QgsMapLayerRegistry::instance()->addMapLayer( layer );
-        // notify the project we've made a change
-        QgsProject::instance()->dirty( true );
       }
       else
       {
@@ -3362,8 +3360,7 @@
     mMapLegend->enableOverviewModeAllLayers( true );
   }
 
-  // notify the project we've made a change
-  QgsProject::instance()->dirty( true );
+  markDirty();
 }
 
 //reimplements method from base (gui) class
@@ -3374,8 +3371,7 @@
     mMapLegend->enableOverviewModeAllLayers( false );
   }
 
-  // notify the project we've made a change
-  QgsProject::instance()->dirty( true );
+  markDirty();
 }
 
 void QgisApp::toggleFullScreen()
@@ -3506,26 +3502,17 @@
   QgsDebugMsg( "Setting map tool to zoomIn" );
 
   mMapCanvas->setMapTool( mMapTools.mZoomIn );
-
-  // notify the project we've made a change
-  QgsProject::instance()->dirty( true );
 }
 
 
 void QgisApp::zoomOut()
 {
   mMapCanvas->setMapTool( mMapTools.mZoomOut );
-
-  // notify the project we've made a change
-  QgsProject::instance()->dirty( true );
 }
 
 void QgisApp::zoomToSelected()
 {
   mMapCanvas->zoomToSelected();
-
-  // notify the project we've made a change
-  QgsProject::instance()->dirty( true );
 }
 
 void QgisApp::pan()
@@ -3536,25 +3523,16 @@
 void QgisApp::zoomFull()
 {
   mMapCanvas->zoomToFullExtent();
-  // notify the project we've made a change
-  QgsProject::instance()->dirty( true );
-
 }
 
 void QgisApp::zoomToPrevious()
 {
   mMapCanvas->zoomToPreviousExtent();
-  // notify the project we've made a change
-  QgsProject::instance()->dirty( true );
-
 }
 
 void QgisApp::zoomToNext()
 {
   mMapCanvas->zoomToNextExtent();
-  // notify the project we've made a change
-  QgsProject::instance()->dirty( true );
-
 }
 
 void QgisApp::zoomActualSize()
@@ -3668,8 +3646,6 @@
   }
 
   vlayer->endEditCommand();
-  // notify the project we've made a change
-  QgsProject::instance()->dirty( true );
 }
 
 void QgisApp::moveFeature()
@@ -4396,8 +4372,6 @@
 void QgisApp::removeLayer()
 {
   mMapLegend->removeCurrentLayer();
-  // notify the project we've made a change
-  QgsProject::instance()->dirty( true );
 }
 
 
@@ -4420,8 +4394,6 @@
   }
 
   mMapCanvas->refresh();
-  // notify the project we've made a change
-  QgsProject::instance()->dirty( true );
 } //remove all layers
 
 void QgisApp::showGpsTool()
@@ -4783,9 +4755,6 @@
   {
     // Register this layer with the layers registry
     QgsMapLayerRegistry::instance()->addMapLayer( layer );
-    // notify the project we've made a change
-    QgsProject::instance()->dirty( true );
-
     statusBar()->showMessage( mMapCanvas->extent().toString( 2 ) );
 
   }
@@ -4830,9 +4799,6 @@
     // not necessary since adding to registry adds to canvas mMapCanvas->addLayer(theMapLayer);
 
     statusBar()->showMessage( mMapCanvas->extent().toString( 2 ) );
-    // notify the project we've made a change
-    QgsProject::instance()->dirty( true );
-
   }
   else
   {
@@ -4877,7 +4843,8 @@
   {
     // flag project as dirty since dirty state of canvas is reset if "dirty"
     // is based on a zoom or pan
-    QgsProject::instance()->dirty( true );
+    markDirty();
+
     // old code: mProjectIsDirtyFlag = true;
 
     // prompt user to save
@@ -5095,6 +5062,12 @@
   }
 }
 
+void QgisApp::markDirty()
+{
+  // notify the project that there was a change
+  QgsProject::instance()->dirty( true );
+}
+
 void QgisApp::showExtents()
 {
   if ( !mToggleExtentsViewButton->isChecked() )
@@ -5634,8 +5607,6 @@
                     SIGNAL( statusChanged( QString ) ),
                     this,
                     SLOT( showStatusMessage( QString ) ) );
-  // notify the project we've made a change
-  QgsProject::instance()->dirty( true );
 
   return true;
 }

Modified: trunk/qgis/src/app/qgisapp.h
===================================================================
--- trunk/qgis/src/app/qgisapp.h	2010-02-11 10:31:21 UTC (rev 12925)
+++ trunk/qgis/src/app/qgisapp.h	2010-02-11 12:18:17 UTC (rev 12926)
@@ -365,6 +365,9 @@
     //! Zoom to selected features
     void zoomToSelected();
 
+    //! mark project dirty
+    void markDirty();
+
     void updateUndoActions();
 
     //! cuts selected features on the active layer to the clipboard



More information about the QGIS-commit mailing list