mirror of
https://github.com/qgis/QGIS.git
synced 2025-10-06 00:07:29 -04:00
Don't overwrite existing data defined property expressions when
an interactive map tool is used to move/rotate/edit labels But instead automatically upgrade this property to use a coalesce("aux field", 'existing' || 'property' || 'expression') type expression, so that the tool will place the interactively edited position/rotation/etc in the auxiliary field but default to using the expression for all other features Fixes #44475
This commit is contained in:
parent
9db24c26bf
commit
b30c17f07d
@ -884,9 +884,9 @@ bool QgsMapToolLabel::createAuxiliaryFields( LabelDetails &details, QgsPalIndexe
|
||||
{
|
||||
index = vlayer->fields().lookupField( prop.field() );
|
||||
}
|
||||
else if ( prop.propertyType() != QgsProperty::ExpressionBasedProperty || overwriteExpression )
|
||||
else
|
||||
{
|
||||
index = QgsAuxiliaryLayer::createProperty( p, vlayer );
|
||||
index = QgsAuxiliaryLayer::createProperty( p, vlayer, overwriteExpression );
|
||||
changed = true;
|
||||
}
|
||||
|
||||
@ -935,9 +935,9 @@ bool QgsMapToolLabel::createAuxiliaryFields( LabelDetails &details, QgsDiagramIn
|
||||
{
|
||||
index = vlayer->fields().lookupField( prop.field() );
|
||||
}
|
||||
else if ( prop.propertyType() != QgsProperty::ExpressionBasedProperty || overwriteExpression )
|
||||
else
|
||||
{
|
||||
index = QgsAuxiliaryLayer::createProperty( p, vlayer );
|
||||
index = QgsAuxiliaryLayer::createProperty( p, vlayer, overwriteExpression );
|
||||
changed = true;
|
||||
}
|
||||
|
||||
@ -985,12 +985,11 @@ bool QgsMapToolLabel::createAuxiliaryFields( QgsCalloutPosition &details, QgsCal
|
||||
{
|
||||
index = vlayer->fields().lookupField( prop.field() );
|
||||
}
|
||||
else if ( prop.propertyType() != QgsProperty::ExpressionBasedProperty || overwriteExpression )
|
||||
else
|
||||
{
|
||||
index = QgsAuxiliaryLayer::createProperty( p, vlayer );
|
||||
index = QgsAuxiliaryLayer::createProperty( p, vlayer, overwriteExpression );
|
||||
changed = true;
|
||||
}
|
||||
|
||||
calloutIndexes[p] = index;
|
||||
}
|
||||
if ( changed )
|
||||
|
@ -111,7 +111,7 @@ void QgsMapToolMoveLabel::cadCanvasPressEvent( QgsMapMouseEvent *e )
|
||||
{
|
||||
QgsCalloutIndexes indexes;
|
||||
|
||||
if ( createAuxiliaryFields( calloutPosition, indexes ) )
|
||||
if ( createAuxiliaryFields( calloutPosition, indexes, false ) )
|
||||
return;
|
||||
|
||||
if ( !canModifyCallout( calloutPosition, mCurrentCalloutMoveOrigin, xCol, yCol ) )
|
||||
@ -188,7 +188,7 @@ void QgsMapToolMoveLabel::cadCanvasPressEvent( QgsMapMouseEvent *e )
|
||||
{
|
||||
QgsPalIndexes indexes;
|
||||
|
||||
if ( createAuxiliaryFields( indexes ) )
|
||||
if ( createAuxiliaryFields( indexes, false ) )
|
||||
return;
|
||||
|
||||
if ( !labelMoveable( vlayer, mCurrentLabel.settings, xCol, yCol ) )
|
||||
@ -211,7 +211,7 @@ void QgsMapToolMoveLabel::cadCanvasPressEvent( QgsMapMouseEvent *e )
|
||||
{
|
||||
QgsDiagramIndexes indexes;
|
||||
|
||||
if ( createAuxiliaryFields( indexes ) )
|
||||
if ( createAuxiliaryFields( indexes, false ) )
|
||||
return;
|
||||
|
||||
if ( !diagramMoveable( vlayer, xCol, yCol ) )
|
||||
|
@ -117,7 +117,7 @@ void QgsMapToolRotateLabel::canvasPressEvent( QgsMapMouseEvent *e )
|
||||
if ( !labelIsRotatable( mCurrentLabel.layer, mCurrentLabel.settings, rotationCol ) )
|
||||
{
|
||||
QgsPalIndexes indexes;
|
||||
if ( createAuxiliaryFields( indexes ) )
|
||||
if ( createAuxiliaryFields( indexes, false ) )
|
||||
return;
|
||||
|
||||
if ( !labelIsRotatable( mCurrentLabel.layer, mCurrentLabel.settings, rotationCol ) )
|
||||
|
@ -331,7 +331,7 @@ bool QgsMapToolShowHideLabels::showHide( const QgsLabelPosition &pos, bool show
|
||||
if ( !diagramCanShowHide( vlayer, showCol ) )
|
||||
{
|
||||
QgsDiagramIndexes indexes;
|
||||
createAuxiliaryFields( details, indexes );
|
||||
createAuxiliaryFields( details, indexes, false );
|
||||
|
||||
showCol = indexes[ QgsDiagramLayerSettings::Show ];
|
||||
}
|
||||
@ -341,7 +341,7 @@ bool QgsMapToolShowHideLabels::showHide( const QgsLabelPosition &pos, bool show
|
||||
if ( !labelCanShowHide( vlayer, showCol ) )
|
||||
{
|
||||
QgsPalIndexes indexes;
|
||||
createAuxiliaryFields( details, indexes );
|
||||
createAuxiliaryFields( details, indexes, false );
|
||||
|
||||
showCol = indexes[ QgsPalLayerSettings::Show ];
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user