Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Fix change label map tool overwritting pre-existing non-field express…
…ions
  • Loading branch information
nirvn committed Jul 20, 2019
1 parent 6bcdf36 commit f38fbc4
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 13 deletions.
2 changes: 1 addition & 1 deletion src/app/qgsmaptoolchangelabelproperties.cpp
Expand Up @@ -71,7 +71,7 @@ void QgsMapToolChangeLabelProperties::canvasPressEvent( QgsMapMouseEvent *e )
if ( !mCurrentLabel.layer->isEditable() )
{
QgsPalIndexes indexes;
bool newAuxiliaryLayer = createAuxiliaryFields( indexes );
bool newAuxiliaryLayer = createAuxiliaryFields( indexes, false );

if ( !newAuxiliaryLayer && !mCurrentLabel.layer->auxiliaryLayer() )
{
Expand Down
16 changes: 8 additions & 8 deletions src/app/qgsmaptoollabel.cpp
Expand Up @@ -742,12 +742,12 @@ QgsMapToolLabel::LabelDetails::LabelDetails( const QgsLabelPosition &p )
}
}

bool QgsMapToolLabel::createAuxiliaryFields( QgsPalIndexes &indexes )
bool QgsMapToolLabel::createAuxiliaryFields( QgsPalIndexes &indexes, bool overwriteExpression )
{
return createAuxiliaryFields( mCurrentLabel, indexes );
return createAuxiliaryFields( mCurrentLabel, indexes, overwriteExpression );
}

bool QgsMapToolLabel::createAuxiliaryFields( LabelDetails &details, QgsPalIndexes &indexes ) const
bool QgsMapToolLabel::createAuxiliaryFields( LabelDetails &details, QgsPalIndexes &indexes, bool overwriteExpression ) const
{
bool newAuxiliaryLayer = false;
QgsVectorLayer *vlayer = details.layer;
Expand Down Expand Up @@ -778,7 +778,7 @@ bool QgsMapToolLabel::createAuxiliaryFields( LabelDetails &details, QgsPalIndexe
{
index = vlayer->fields().lookupField( prop.field() );
}
else
else if ( prop.propertyType() != QgsProperty::ExpressionBasedProperty || ( prop.propertyType() == QgsProperty::ExpressionBasedProperty && overwriteExpression ) )
{
index = QgsAuxiliaryLayer::createProperty( p, vlayer );
changed = true;
Expand All @@ -794,13 +794,13 @@ bool QgsMapToolLabel::createAuxiliaryFields( LabelDetails &details, QgsPalIndexe
return newAuxiliaryLayer;
}

bool QgsMapToolLabel::createAuxiliaryFields( QgsDiagramIndexes &indexes )
bool QgsMapToolLabel::createAuxiliaryFields( QgsDiagramIndexes &indexes, bool overwriteExpression )
{
return createAuxiliaryFields( mCurrentLabel, indexes );
return createAuxiliaryFields( mCurrentLabel, indexes, overwriteExpression );
}


bool QgsMapToolLabel::createAuxiliaryFields( LabelDetails &details, QgsDiagramIndexes &indexes )
bool QgsMapToolLabel::createAuxiliaryFields( LabelDetails &details, QgsDiagramIndexes &indexes, bool overwriteExpression )
{
bool newAuxiliaryLayer = false;
QgsVectorLayer *vlayer = details.layer;
Expand Down Expand Up @@ -830,7 +830,7 @@ bool QgsMapToolLabel::createAuxiliaryFields( LabelDetails &details, QgsDiagramIn
{
index = vlayer->fields().lookupField( prop.field() );
}
else
else if ( prop.propertyType() != QgsProperty::ExpressionBasedProperty || ( prop.propertyType() == QgsProperty::ExpressionBasedProperty && overwriteExpression ) )
{
index = QgsAuxiliaryLayer::createProperty( p, vlayer );
changed = true;
Expand Down
8 changes: 4 additions & 4 deletions src/app/qgsmaptoollabel.h
Expand Up @@ -186,10 +186,10 @@ class APP_EXPORT QgsMapToolLabel: public QgsMapTool
*/
bool isPinned();

bool createAuxiliaryFields( QgsPalIndexes &palIndexes );
bool createAuxiliaryFields( LabelDetails &details, QgsPalIndexes &palIndexes ) const;
bool createAuxiliaryFields( QgsDiagramIndexes &diagIndexes );
bool createAuxiliaryFields( LabelDetails &details, QgsDiagramIndexes &diagIndexes );
bool createAuxiliaryFields( QgsPalIndexes &palIndexes, bool overwriteExpression = true );
bool createAuxiliaryFields( LabelDetails &details, QgsPalIndexes &palIndexes, bool overwriteExpression = true ) const;
bool createAuxiliaryFields( QgsDiagramIndexes &diagIndexes, bool overwriteExpression = true );
bool createAuxiliaryFields( LabelDetails &details, QgsDiagramIndexes &diagIndexes, bool overwriteExpression = true );

QList<QgsPalLayerSettings::Property> mPalProperties;
QList<QgsDiagramLayerSettings::Property> mDiagramProperties;
Expand Down

0 comments on commit f38fbc4

Please sign in to comment.