Skip to content
Permalink
Browse files
Show helpful warning message when labels cannot be moved because
they are set to store in a column which no longer exists on the layer
  • Loading branch information
nyalldawson committed Aug 27, 2021
1 parent 204af6f commit 442e16cc6c4f995715f89783d51c49f0eb6075e9
Showing with 10 additions and 0 deletions.
  1. +10 −0 src/app/labeling/qgsmaptoolmovelabel.cpp
@@ -193,7 +193,17 @@ void QgsMapToolMoveLabel::cadCanvasPressEvent( QgsMapMouseEvent *e )
return;

if ( !labelMoveable( vlayer, mCurrentLabel.settings, xCol, yCol ) )
{
QString xColName = dataDefinedColumnName( QgsPalLayerSettings::PositionX, mCurrentLabel.settings, vlayer );
QString yColName = dataDefinedColumnName( QgsPalLayerSettings::PositionY, mCurrentLabel.settings, vlayer );
if ( xCol < 0 && yCol < 0 )
QgisApp::instance()->messageBar()->pushWarning( tr( "Move Label" ), tr( "The label X/Y columns “%1” and “%2” do not exist in the layer" ).arg( xColName, yColName ) );
else if ( xCol < 0 )
QgisApp::instance()->messageBar()->pushWarning( tr( "Move Label" ), tr( "The label X column “%1” does not exist in the layer" ).arg( xColName ) );
else if ( yCol < 0 )
QgisApp::instance()->messageBar()->pushWarning( tr( "Move Label" ), tr( "The label Y column “%1” does not exist in the layer" ).arg( yColName ) );
return;
}

xCol = indexes[ QgsPalLayerSettings::PositionX ];
yCol = indexes[ QgsPalLayerSettings::PositionY ];

0 comments on commit 442e16c

Please sign in to comment.