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

svn_qgis at osgeo.org svn_qgis at osgeo.org
Tue Nov 30 04:03:17 EST 2010


Author: jef
Date: 2010-11-30 01:03:17 -0800 (Tue, 30 Nov 2010)
New Revision: 14803

Modified:
   trunk/qgis/src/app/qgisapp.cpp
Log:
fix r14798: label tools work independently from current layer. Thanks Marco!

Modified: trunk/qgis/src/app/qgisapp.cpp
===================================================================
--- trunk/qgis/src/app/qgisapp.cpp	2010-11-29 21:49:36 UTC (rev 14802)
+++ trunk/qgis/src/app/qgisapp.cpp	2010-11-30 09:03:17 UTC (rev 14803)
@@ -3956,14 +3956,14 @@
     // alter labeling - save the changes
     labelGui.layerSettings().writeToLayer( vlayer );
 
-    activateDeactivateLayerRelatedActions( layer );
-
     // trigger refresh
     if ( mMapCanvas )
     {
       mMapCanvas->refresh();
     }
   }
+
+  activateDeactivateLayerRelatedActions( layer );
 }
 
 void QgisApp::attributeTable()
@@ -6129,6 +6129,36 @@
 
 void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
 {
+  bool enableMove = false, enableRotate = false, enableChange = false;
+
+  QMap<QString, QgsMapLayer*> layers = QgsMapLayerRegistry::instance()->mapLayers();
+  for ( QMap<QString, QgsMapLayer*>::iterator it = layers.begin(); it != layers.end(); it++ )
+  {
+    QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( it.value() );
+    if ( !vlayer || !vlayer->isEditable() || vlayer->customProperty( "labeling" ).toString() != QString( "pal" ) )
+      continue;
+
+    int colX, colY, colAng;
+    enableMove =
+      enableMove ||
+      ( qobject_cast<QgsMapToolMoveLabel*>( mMapTools.mMoveLabel ) &&
+        qobject_cast<QgsMapToolMoveLabel*>( mMapTools.mMoveLabel )->layerIsMoveable( vlayer, colX, colY ) );
+
+    enableRotate =
+      enableRotate ||
+      ( qobject_cast<QgsMapToolRotateLabel*>( mMapTools.mRotateLabel ) &&
+        qobject_cast<QgsMapToolRotateLabel*>( mMapTools.mRotateLabel )->layerIsRotatable( vlayer, colAng ) );
+
+    enableChange = true;
+
+    if ( enableMove && enableRotate && enableChange )
+      break;
+  }
+
+  mActionMoveLabel->setEnabled( enableMove );
+  mActionRotateLabel->setEnabled( enableRotate );
+  mActionChangeLabelProperties->setEnabled( enableChange );
+
   if ( !layer )
   {
     mActionSelect->setEnabled( false );
@@ -6254,29 +6284,11 @@
                                           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



More information about the QGIS-commit mailing list