Skip to content

Commit

Permalink
fix r14798: label tools work independently from current layer. Thanks…
Browse files Browse the repository at this point in the history
… Marco!

git-svn-id: http://svn.osgeo.org/qgis/trunk@14803 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Nov 30, 2010
1 parent a205e67 commit ca410c0
Showing 1 changed file with 32 additions and 20 deletions.
52 changes: 32 additions & 20 deletions src/app/qgisapp.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -3956,14 +3956,14 @@ void QgisApp::labeling()
// alter labeling - save the changes
labelGui.layerSettings().writeToLayer( vlayer );

activateDeactivateLayerRelatedActions( layer );

// trigger refresh
if ( mMapCanvas )
{
mMapCanvas->refresh();
}
}

activateDeactivateLayerRelatedActions( layer );
}

void QgisApp::attributeTable()
Expand Down Expand Up @@ -6129,6 +6129,36 @@ void QgisApp::legendLayerSelectionChanged( void )

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 );
Expand Down Expand Up @@ -6254,29 +6284,11 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
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
Expand Down

0 comments on commit ca410c0

Please sign in to comment.