Skip to content

Commit d2e7cf0

Browse files
author
jef
committedNov 30, 2010
fix r14798: label tools work independently from current layer. Thanks Marco!
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14803 c8812cc2-4d05-0410-92ff-de0c093fc19c

File tree

1 file changed

+32
-20
lines changed

1 file changed

+32
-20
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 32 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -3956,14 +3956,14 @@ void QgisApp::labeling()
39563956
// alter labeling - save the changes
39573957
labelGui.layerSettings().writeToLayer( vlayer );
39583958

3959-
activateDeactivateLayerRelatedActions( layer );
3960-
39613959
// trigger refresh
39623960
if ( mMapCanvas )
39633961
{
39643962
mMapCanvas->refresh();
39653963
}
39663964
}
3965+
3966+
activateDeactivateLayerRelatedActions( layer );
39673967
}
39683968

39693969
void QgisApp::attributeTable()
@@ -6129,6 +6129,36 @@ void QgisApp::legendLayerSelectionChanged( void )
61296129

61306130
void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
61316131
{
6132+
bool enableMove = false, enableRotate = false, enableChange = false;
6133+
6134+
QMap<QString, QgsMapLayer*> layers = QgsMapLayerRegistry::instance()->mapLayers();
6135+
for ( QMap<QString, QgsMapLayer*>::iterator it = layers.begin(); it != layers.end(); it++ )
6136+
{
6137+
QgsVectorLayer *vlayer = qobject_cast<QgsVectorLayer *>( it.value() );
6138+
if ( !vlayer || !vlayer->isEditable() || vlayer->customProperty( "labeling" ).toString() != QString( "pal" ) )
6139+
continue;
6140+
6141+
int colX, colY, colAng;
6142+
enableMove =
6143+
enableMove ||
6144+
( qobject_cast<QgsMapToolMoveLabel*>( mMapTools.mMoveLabel ) &&
6145+
qobject_cast<QgsMapToolMoveLabel*>( mMapTools.mMoveLabel )->layerIsMoveable( vlayer, colX, colY ) );
6146+
6147+
enableRotate =
6148+
enableRotate ||
6149+
( qobject_cast<QgsMapToolRotateLabel*>( mMapTools.mRotateLabel ) &&
6150+
qobject_cast<QgsMapToolRotateLabel*>( mMapTools.mRotateLabel )->layerIsRotatable( vlayer, colAng ) );
6151+
6152+
enableChange = true;
6153+
6154+
if ( enableMove && enableRotate && enableChange )
6155+
break;
6156+
}
6157+
6158+
mActionMoveLabel->setEnabled( enableMove );
6159+
mActionRotateLabel->setEnabled( enableRotate );
6160+
mActionChangeLabelProperties->setEnabled( enableChange );
6161+
61326162
if ( !layer )
61336163
{
61346164
mActionSelect->setEnabled( false );
@@ -6254,29 +6284,11 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
62546284
dprovider->capabilities() & QgsVectorDataProvider::AddFeatures );
62556285

62566286
mActionMergeFeatureAttributes->setEnabled( layerHasSelection );
6257-
6258-
if ( layer->customProperty( "labeling" ).toString() == QString( "pal" ) )
6259-
{
6260-
int colX, colY, colAng;
6261-
mActionMoveLabel->setEnabled( qobject_cast<QgsMapToolMoveLabel*>( mMapTools.mMoveLabel ) && qobject_cast<QgsMapToolMoveLabel*>( mMapTools.mMoveLabel )->layerIsMoveable( layer, colX, colY ) );
6262-
mActionRotateLabel->setEnabled( qobject_cast<QgsMapToolRotateLabel*>( mMapTools.mRotateLabel ) && qobject_cast<QgsMapToolRotateLabel*>( mMapTools.mMoveLabel )->layerIsRotatable( layer, colAng ) );
6263-
mActionChangeLabelProperties->setEnabled( true );
6264-
}
6265-
else
6266-
{
6267-
mActionMoveLabel->setEnabled( false );
6268-
mActionRotateLabel->setEnabled( false );
6269-
mActionChangeLabelProperties->setEnabled( false );
6270-
}
62716287
}
62726288
else
62736289
{
62746290
mActionMergeFeatures->setEnabled( false );
62756291
mActionMergeFeatureAttributes->setEnabled( false );
6276-
6277-
mActionMoveLabel->setEnabled( false );
6278-
mActionRotateLabel->setEnabled( false );
6279-
mActionChangeLabelProperties->setEnabled( false );
62806292
}
62816293

62826294
// moving enabled if geometry changes are supported

0 commit comments

Comments
 (0)
Please sign in to comment.