Navigation Menu

Skip to content

Commit

Permalink
Show helpful warning message when labels cannot be moved because
Browse files Browse the repository at this point in the history
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 442e16c
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/app/labeling/qgsmaptoolmovelabel.cpp
Expand Up @@ -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 ];
Expand Down

0 comments on commit 442e16c

Please sign in to comment.