[QGIS Commit] r14798 - trunk/qgis/src/app

svn_qgis at osgeo.org svn_qgis at osgeo.org
Mon Nov 29 15:40:51 EST 2010


Author: jef
Date: 2010-11-29 12:40:51 -0800 (Mon, 29 Nov 2010)
New Revision: 14798

Modified:
   trunk/qgis/src/app/qgisapp.cpp
   trunk/qgis/src/app/qgsmaptoolmovelabel.h
   trunk/qgis/src/app/qgsmaptoolrotatelabel.h
Log:
activate/deactivate labeling tools

Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2010-11-29 20:40:42 UTC (rev 14797)
+++ trunk/qgis/src/app/qgisapp.cpp	2010-11-29 20:40:51 UTC (rev 14798)
@@ -584,6 +584,7 @@
   delete mMapTools.mAddIsland;
   delete mMapTools.mNodeTool;
   delete mMapTools.mMoveLabel;
+  delete mMapTools.mRotateLabel;
   delete mMapTools.mChangeLabelProperties;
 
   delete mPythonUtils;
@@ -3955,6 +3956,8 @@
     // alter labeling - save the changes
     labelGui.layerSettings().writeToLayer( vlayer );
 
+    activateDeactivateLayerRelatedActions( layer );
+
     // trigger refresh
     if ( mMapCanvas )
     {
@@ -6171,6 +6174,10 @@
     mActionCaptureLine->setVisible( false );
     mActionCapturePolygon->setVisible( false );
 
+    mActionMoveLabel->setEnabled( false );
+    mActionRotateLabel->setEnabled( false );
+    mActionChangeLabelProperties->setEnabled( false );
+
     return;
   }
 
@@ -6247,11 +6254,29 @@
                                           dprovider->capabilities() & QgsVectorDataProvider::AddFeatures );
 
         mActionMergeFeatureAttributes->setEnabled( layerHasSelection );
+
+        if ( layer->customProperty( "labeling" ).toString() == QString( "pal" ) )
+        {
+          int colX, colY, colAng;
+          mActionMoveLabel->setEnabled( qobject_cast<QgsMapToolMoveLabel*>( mMapTools.mMoveLabel ) && qobject_cast<QgsMapToolMoveLabel*>( mMapTools.mMoveLabel )->layerIsMoveable( layer, colX, colY ) );
+          mActionRotateLabel->setEnabled( qobject_cast<QgsMapToolRotateLabel*>( mMapTools.mRotateLabel ) && qobject_cast<QgsMapToolRotateLabel*>( mMapTools.mMoveLabel )->layerIsRotatable( layer, colAng ) );
+          mActionChangeLabelProperties->setEnabled( true );
+        }
+        else
+        {
+          mActionMoveLabel->setEnabled( false );
+          mActionRotateLabel->setEnabled( false );
+          mActionChangeLabelProperties->setEnabled( false );
+        }
       }
       else
       {
         mActionMergeFeatures->setEnabled( false );
         mActionMergeFeatureAttributes->setEnabled( false );
+
+        mActionMoveLabel->setEnabled( false );
+        mActionRotateLabel->setEnabled( false );
+        mActionChangeLabelProperties->setEnabled( false );
       }
 
       // moving enabled if geometry changes are supported

Modified: trunk/qgis/src/app/qgsmaptoolmovelabel.h
===================================================================
--- trunk/qgis/src/app/qgsmaptoolmovelabel.h	2010-11-29 20:40:42 UTC (rev 14797)
+++ trunk/qgis/src/app/qgsmaptoolmovelabel.h	2010-11-29 20:40:51 UTC (rev 14798)
@@ -35,6 +35,12 @@
 
     virtual void canvasReleaseEvent( QMouseEvent * e );
 
+    /**Returns true if layer move can be applied to a layer
+        @param xCol out: index of the attribute for data defined x coordinate
+        @param yCol out: index of the attribute for data defined y coordinate
+        @return true if labels of layer can be moved*/
+    bool layerIsMoveable( const QgsMapLayer* ml, int& xCol, int& yCol ) const;
+
   protected:
     /**Get data defined position of a feature
       @param layerId layer identification string
@@ -47,12 +53,6 @@
       @return false if layer does not have data defined label position enabled*/
     bool dataDefinedPosition( QgsVectorLayer* vlayer, int featureId, double& x, bool& xSuccess, double& y, bool& ySuccess, int& xCol, int& yCol ) const;
 
-    /**Returns true if layer move can be applied to a layer
-      @param xCol out: index of the attribute for data defined x coordinate
-      @param yCol out: index of the attribute for data defined y coordinate
-      @return true if labels of layer can be moved*/
-    bool layerIsMoveable( const QgsMapLayer* ml, int& xCol, int& yCol ) const;
-
     /**Start point of the move in map coordinates*/
     QgsPoint mStartPointMapCoords;
 

Modified: trunk/qgis/src/app/qgsmaptoolrotatelabel.h
===================================================================
--- trunk/qgis/src/app/qgsmaptoolrotatelabel.h	2010-11-29 20:40:42 UTC (rev 14797)
+++ trunk/qgis/src/app/qgsmaptoolrotatelabel.h	2010-11-29 20:40:51 UTC (rev 14798)
@@ -33,10 +33,11 @@
     virtual void canvasMoveEvent( QMouseEvent * e );
     virtual void canvasReleaseEvent( QMouseEvent * e );
 
-  protected:
     /**Checks if labels in a layer can be rotated
       @param rotationCol out: attribute column for data defined label rotation*/
     bool layerIsRotatable( const QgsMapLayer* layer, int& rotationCol ) const;
+
+  protected:
     /**Returns data defined rotation of a feature.
       @param rotation out: rotation value
       @param rotationSuccess out: false if rotation value is NULL



More information about the QGIS-commit mailing list