Skip to content

Commit ce2436d

Browse files
committedOct 9, 2017
Some cleanup in maptool
1 parent df02157 commit ce2436d

File tree

1 file changed

+5
-56
lines changed

1 file changed

+5
-56
lines changed
 

‎src/app/qgsmaptoollabel.cpp

Lines changed: 5 additions & 56 deletions
Original file line numberDiff line numberDiff line change
@@ -470,7 +470,7 @@ bool QgsMapToolLabel::currentLabelDataDefinedPosition( double &x, bool &xSuccess
470470

471471
bool QgsMapToolLabel::layerIsRotatable( QgsVectorLayer *vlayer, int &rotationCol ) const
472472
{
473-
if ( !vlayer || !vlayer->labeling() )
473+
if ( !vlayer || !vlayer->isEditable() || !vlayer->labeling() )
474474
{
475475
return false;
476476
}
@@ -488,23 +488,7 @@ bool QgsMapToolLabel::labelIsRotatable( QgsVectorLayer *layer, const QgsPalLayer
488488
{
489489
QString rColName = dataDefinedColumnName( QgsPalLayerSettings::LabelRotation, settings );
490490
rotationCol = layer->fields().lookupField( rColName );
491-
492-
if ( rotationCol >= 0 )
493-
{
494-
bool auxiliaryField = layer->isAuxiliaryField( rotationCol );
495-
496-
if ( !auxiliaryField )
497-
{
498-
if ( layer->isEditable() )
499-
return true;
500-
else
501-
return false;
502-
}
503-
else
504-
return true;
505-
}
506-
507-
return false;
491+
return rotationCol != -1;
508492
}
509493

510494

@@ -599,26 +583,7 @@ bool QgsMapToolLabel::diagramMoveable( QgsVectorLayer *vlayer, int &xCol, int &y
599583
yCol = vlayer->fields().lookupField( ddY.field() );
600584
}
601585
}
602-
603-
// diagrams may be moveable even if layer is not editable when data
604-
// defined columns come from auxiliary storage
605-
if ( xCol >= 0 && yCol >= 0 )
606-
{
607-
bool xAuxiliaryField = vlayer->isAuxiliaryField( xCol );
608-
bool yAuxiliaryField = vlayer->isAuxiliaryField( yCol );
609-
610-
if ( ! xAuxiliaryField || ! yAuxiliaryField )
611-
{
612-
if ( vlayer->isEditable() )
613-
return true;
614-
else
615-
return false;
616-
}
617-
else
618-
return true;
619-
}
620-
621-
return false;
586+
return xCol >= 0 && yCol >= 0;
622587
}
623588
}
624589
return false;
@@ -644,7 +609,6 @@ bool QgsMapToolLabel::labelMoveable( QgsVectorLayer *vlayer, const QgsPalLayerSe
644609
{
645610
QString xColName = dataDefinedColumnName( QgsPalLayerSettings::PositionX, settings );
646611
QString yColName = dataDefinedColumnName( QgsPalLayerSettings::PositionY, settings );
647-
648612
//return !xColName.isEmpty() && !yColName.isEmpty();
649613
xCol = vlayer->fields().lookupField( xColName );
650614
yCol = vlayer->fields().lookupField( yColName );
@@ -704,7 +668,7 @@ bool QgsMapToolLabel::diagramCanShowHide( QgsVectorLayer *vlayer, int &showCol )
704668
{
705669
showCol = -1;
706670

707-
if ( vlayer && vlayer->diagramsEnabled() )
671+
if ( vlayer && vlayer->isEditable() && vlayer->diagramsEnabled() )
708672
{
709673
if ( const QgsDiagramLayerSettings *dls = vlayer->diagramLayerSettings() )
710674
{
@@ -718,22 +682,7 @@ bool QgsMapToolLabel::diagramCanShowHide( QgsVectorLayer *vlayer, int &showCol )
718682
}
719683
}
720684

721-
if ( showCol >= 0 )
722-
{
723-
bool auxiliaryField = vlayer->isAuxiliaryField( showCol );
724-
725-
if ( !auxiliaryField )
726-
{
727-
if ( vlayer->isEditable() )
728-
return true;
729-
else
730-
return false;
731-
}
732-
else
733-
return true;
734-
}
735-
736-
return false;
685+
return showCol >= 0;
737686
}
738687

739688
//

0 commit comments

Comments
 (0)
Please sign in to comment.