[QGIS Commit] r8665 - in trunk/qgis: python/gui src/app src/gui

svn_qgis at osgeo.org svn_qgis at osgeo.org
Sat Jun 21 11:34:02 EDT 2008


Author: jef
Date: 2008-06-21 11:34:01 -0400 (Sat, 21 Jun 2008)
New Revision: 8665

Modified:
   trunk/qgis/python/gui/qgsmapcanvas.sip
   trunk/qgis/python/gui/qgsmaptool.sip
   trunk/qgis/src/app/qgisapp.cpp
   trunk/qgis/src/app/qgisapp.h
   trunk/qgis/src/gui/qgsmapcanvas.cpp
   trunk/qgis/src/gui/qgsmapcanvas.h
   trunk/qgis/src/gui/qgsmaptool.h
Log:
update sip binding after r8656:
replaces QgsMapCanvas::restoreMapTool(), which shouldn't be public, with a
signal and handles it in QgisApp.



Modified: trunk/qgis/python/gui/qgsmapcanvas.sip
===================================================================
--- trunk/qgis/python/gui/qgsmapcanvas.sip	2008-06-21 10:07:01 UTC (rev 8664)
+++ trunk/qgis/python/gui/qgsmapcanvas.sip	2008-06-21 15:34:01 UTC (rev 8665)
@@ -211,7 +211,7 @@
     //! called to write map canvas settings to project
     void writeProject(QDomDocument &);
     
-signals:
+  signals:
     /** Let the owner know how far we are with render operations */
     void setProgress(int,int);
     /** emits current mouse position */
@@ -242,8 +242,10 @@
     //! Emit key release event
     void keyReleased(QKeyEvent * e);
    
+    //! Emit map tool changed event
+    void mapToolSet(QgsMapTool *tool);
 
-protected:
+  protected:
 
     //! Overridden key press event
     void keyPressEvent(QKeyEvent * e);

Modified: trunk/qgis/python/gui/qgsmaptool.sip
===================================================================
--- trunk/qgis/python/gui/qgsmaptool.sip	2008-06-21 10:07:01 UTC (rev 8664)
+++ trunk/qgis/python/gui/qgsmaptool.sip	2008-06-21 15:34:01 UTC (rev 8665)
@@ -58,6 +58,11 @@
      * If it does, we will be able to perform the zoom  and then 
      * resume operations with the original / previously used tool.*/
     virtual bool isZoomTool();
+
+    /** Check whether this MapTool performs an edit operation.
+     * If it does, we will deactivate it when editing is turned off 
+     */
+    virtual bool isEditTool();
     
     //! called when set as currently active map tool
     virtual void activate();

Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2008-06-21 10:07:01 UTC (rev 8664)
+++ trunk/qgis/src/app/qgisapp.cpp	2008-06-21 15:34:01 UTC (rev 8665)
@@ -1356,6 +1356,9 @@
   connect(mMapCanvas, SIGNAL(scaleChanged(double)), this, SLOT(showScale(double)));
   connect(mMapCanvas, SIGNAL(scaleChanged(double)), this, SLOT(updateMouseCoordinatePrecision()));
 
+  mNonEditMapTool=NULL;
+  connect(mMapCanvas, SIGNAL(mapToolSet(QgsMapTool *)), this, SLOT(mapToolChanged(QgsMapTool *)));
+
   connect(mRenderSuppressionCBox, SIGNAL(toggled(bool )), mMapCanvas, SLOT(setRenderFlag(bool)));
   //
   // Do we really need this ??? - its already connected to the esc key...TS
@@ -4677,6 +4680,14 @@
 
 }
 
+void QgisApp::mapToolChanged(QgsMapTool *tool)
+{
+  if( tool && !tool->isEditTool() )
+  {
+    mNonEditMapTool = tool;
+  }
+}
+
 void QgisApp::showExtents()
 {
   // update the statusbar with the current extents.
@@ -4847,8 +4858,6 @@
     return;
   }
 
-  mMapCanvas->restoreMapTool();
-
   mActionToggleEditing->setEnabled(true);
   mActionRemoveLayer->setEnabled(true);
   mActionInOverview->setEnabled(true);
@@ -4864,6 +4873,11 @@
     const QgsVectorLayer* vlayer = dynamic_cast<const QgsVectorLayer*>(layer);
     const QgsVectorDataProvider* dprovider = vlayer->getDataProvider();
 
+    if( !vlayer->isEditable() && mMapCanvas->mapTool() && mMapCanvas->mapTool()->isEditTool() )
+    {
+	mMapCanvas->setMapTool(mNonEditMapTool);
+    }
+
     if (dprovider)
     {
       //start editing/stop editing

Modified: trunk/qgis/src/app/qgisapp.h
===================================================================
--- trunk/qgis/src/app/qgisapp.h	2008-06-21 10:07:01 UTC (rev 8664)
+++ trunk/qgis/src/app/qgisapp.h	2008-06-21 15:34:01 UTC (rev 8665)
@@ -318,6 +318,9 @@
   //! starts/stops editing mode of the current layer
   void toggleEditing();
 
+  //! map tool changed
+  void mapToolChanged(QgsMapTool *tool);
+
   /** Activates or deactivates actions depending on the current maplayer type.
   Is called from the legend when the current legend item has changed*/
   void activateDeactivateLayerRelatedActions(QgsMapLayer* layer);
@@ -583,6 +586,8 @@
       QgsMapTool* mAddRing;
       QgsMapTool* mAddIsland;
   } mMapTools;
+
+  QgsMapTool *mNonEditMapTool;
   
   //!The name of the active theme
   QString mThemeName;

Modified: trunk/qgis/src/gui/qgsmapcanvas.cpp
===================================================================
--- trunk/qgis/src/gui/qgsmapcanvas.cpp	2008-06-21 10:07:01 UTC (rev 8664)
+++ trunk/qgis/src/gui/qgsmapcanvas.cpp	2008-06-21 15:34:01 UTC (rev 8665)
@@ -87,7 +87,6 @@
   mMapOverview = NULL;
   mMapTool = NULL;
   mLastNonZoomMapTool = NULL;
-  mNonEditMapTool = NULL;
   
   mDrawing = false;
   mFrozen = false;
@@ -966,32 +965,16 @@
   if (mMapTool)
     mMapTool->activate();
 
+  emit mapToolSet(mMapTool);
 } // setMapTool
 
-void QgsMapCanvas::restoreMapTool()
-{
-  if( !mMapTool )
-    return;
-  
-  if( !mMapTool->isEditTool() )
-  {
-    mNonEditMapTool = mMapTool;
-    return;
-  }
-
-  if ( mCurrentLayer && !mCurrentLayer->isEditable() )
-  {
-    setMapTool(mNonEditMapTool);
-  }
-}
-
-
 void QgsMapCanvas::unsetMapTool(QgsMapTool* tool)
 {
   if (mMapTool && mMapTool == tool)
   {
     mMapTool->deactivate();
     mMapTool = NULL;
+    emit mapToolSet(NULL);
     setCursor(Qt::ArrowCursor);
   }
 

Modified: trunk/qgis/src/gui/qgsmapcanvas.h
===================================================================
--- trunk/qgis/src/gui/qgsmapcanvas.h	2008-06-21 10:07:01 UTC (rev 8664)
+++ trunk/qgis/src/gui/qgsmapcanvas.h	2008-06-21 15:34:01 UTC (rev 8665)
@@ -234,9 +234,6 @@
     //! zooms with the factor supplied. Factor > 1 zooms in
     void zoom(double scaleFactor);
 
-    //! restore tool on toggle editing
-    void restoreMapTool();
-
   public slots:
 
     /**Repaints the canvas map*/
@@ -271,7 +268,7 @@
     //! called to write map canvas settings to project
     void writeProject(QDomDocument &);
     
-signals:
+  signals:
     /** Let the owner know how far we are with render operations */
     void setProgress(int,int);
     /** emits current mouse position */
@@ -302,7 +299,10 @@
     //! Emit key release event
     void keyReleased(QKeyEvent * e);
 
-protected:
+    //! Emit map tool changed event
+    void mapToolSet(QgsMapTool *tool);
+
+  protected:
     //! Overridden key press event
     void keyPressEvent(QKeyEvent * e);
 
@@ -383,10 +383,10 @@
        the last entry in case a lot of resize events arrive in short time*/
     QList< QPair<int, int> > mResizeQueue;
     
-  /** debugging member
-      invoked when a connect() is made to this object
-  */
-  void connectNotify( const char * signal );
+    /**debugging member
+       invoked when a connect() is made to this object
+    */
+    void connectNotify( const char * signal );
 
     //! current layer in legend
     QgsMapLayer* mCurrentLayer;
@@ -400,9 +400,6 @@
     //! previous tool if current is for zooming/panning
     QgsMapTool* mLastNonZoomMapTool;
 
-    //! tool to restore when editing is toggled.
-    QgsMapTool* mNonEditMapTool;
-
     //! recently used extent
     QgsRect mLastExtent;
     

Modified: trunk/qgis/src/gui/qgsmaptool.h
===================================================================
--- trunk/qgis/src/gui/qgsmaptool.h	2008-06-21 10:07:01 UTC (rev 8664)
+++ trunk/qgis/src/gui/qgsmaptool.h	2008-06-21 15:34:01 UTC (rev 8665)
@@ -80,8 +80,7 @@
     virtual bool isZoomTool();
  
     /** Check whether this MapTool performs an edit operation.
-     * If it does, we will deactivate it when editing is turned off and
-     * reactivate it when editing is turned back on.
+     * If it does, we will deactivate it when editing is turned off
      */
     virtual bool isEditTool();
 



More information about the QGIS-commit mailing list