Skip to content

Commit a88ad39

Browse files
author
jef
committedNov 29, 2010
activate/deactivate labeling tools
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@14798 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent cf3077d commit a88ad39

File tree

3 files changed

+33
-7
lines changed

3 files changed

+33
-7
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -584,6 +584,7 @@ QgisApp::~QgisApp()
584584
delete mMapTools.mAddIsland;
585585
delete mMapTools.mNodeTool;
586586
delete mMapTools.mMoveLabel;
587+
delete mMapTools.mRotateLabel;
587588
delete mMapTools.mChangeLabelProperties;
588589

589590
delete mPythonUtils;
@@ -3955,6 +3956,8 @@ void QgisApp::labeling()
39553956
// alter labeling - save the changes
39563957
labelGui.layerSettings().writeToLayer( vlayer );
39573958

3959+
activateDeactivateLayerRelatedActions( layer );
3960+
39583961
// trigger refresh
39593962
if ( mMapCanvas )
39603963
{
@@ -6171,6 +6174,10 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
61716174
mActionCaptureLine->setVisible( false );
61726175
mActionCapturePolygon->setVisible( false );
61736176

6177+
mActionMoveLabel->setEnabled( false );
6178+
mActionRotateLabel->setEnabled( false );
6179+
mActionChangeLabelProperties->setEnabled( false );
6180+
61746181
return;
61756182
}
61766183

@@ -6247,11 +6254,29 @@ void QgisApp::activateDeactivateLayerRelatedActions( QgsMapLayer* layer )
62476254
dprovider->capabilities() & QgsVectorDataProvider::AddFeatures );
62486255

62496256
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+
}
62506271
}
62516272
else
62526273
{
62536274
mActionMergeFeatures->setEnabled( false );
62546275
mActionMergeFeatureAttributes->setEnabled( false );
6276+
6277+
mActionMoveLabel->setEnabled( false );
6278+
mActionRotateLabel->setEnabled( false );
6279+
mActionChangeLabelProperties->setEnabled( false );
62556280
}
62566281

62576282
// moving enabled if geometry changes are supported

‎src/app/qgsmaptoolmovelabel.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -35,6 +35,12 @@ class QgsMapToolMoveLabel: public QgsMapToolLabel
3535

3636
virtual void canvasReleaseEvent( QMouseEvent * e );
3737

38+
/**Returns true if layer move can be applied to a layer
39+
@param xCol out: index of the attribute for data defined x coordinate
40+
@param yCol out: index of the attribute for data defined y coordinate
41+
@return true if labels of layer can be moved*/
42+
bool layerIsMoveable( const QgsMapLayer* ml, int& xCol, int& yCol ) const;
43+
3844
protected:
3945
/**Get data defined position of a feature
4046
@param layerId layer identification string
@@ -47,12 +53,6 @@ class QgsMapToolMoveLabel: public QgsMapToolLabel
4753
@return false if layer does not have data defined label position enabled*/
4854
bool dataDefinedPosition( QgsVectorLayer* vlayer, int featureId, double& x, bool& xSuccess, double& y, bool& ySuccess, int& xCol, int& yCol ) const;
4955

50-
/**Returns true if layer move can be applied to a layer
51-
@param xCol out: index of the attribute for data defined x coordinate
52-
@param yCol out: index of the attribute for data defined y coordinate
53-
@return true if labels of layer can be moved*/
54-
bool layerIsMoveable( const QgsMapLayer* ml, int& xCol, int& yCol ) const;
55-
5656
/**Start point of the move in map coordinates*/
5757
QgsPoint mStartPointMapCoords;
5858

‎src/app/qgsmaptoolrotatelabel.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,10 +33,11 @@ class QgsMapToolRotateLabel: public QgsMapToolLabel
3333
virtual void canvasMoveEvent( QMouseEvent * e );
3434
virtual void canvasReleaseEvent( QMouseEvent * e );
3535

36-
protected:
3736
/**Checks if labels in a layer can be rotated
3837
@param rotationCol out: attribute column for data defined label rotation*/
3938
bool layerIsRotatable( const QgsMapLayer* layer, int& rotationCol ) const;
39+
40+
protected:
4041
/**Returns data defined rotation of a feature.
4142
@param rotation out: rotation value
4243
@param rotationSuccess out: false if rotation value is NULL

0 commit comments

Comments
 (0)