Skip to content

Commit e1781b9

Browse files
committedOct 9, 2017
Button to store data in project activates the property if it exists in auxiliary layer
1 parent 0c21e51 commit e1781b9

File tree

3 files changed

+14
-9
lines changed

3 files changed

+14
-9
lines changed
 

‎src/app/qgsdiagramproperties.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1069,8 +1069,9 @@ void QgsDiagramProperties::createAuxiliaryField()
10691069
const QgsDiagramLayerSettings::Property key = static_cast< QgsDiagramLayerSettings::Property >( button->propertyKey() );
10701070
const QgsPropertyDefinition def = QgsDiagramLayerSettings::propertyDefinitions()[key];
10711071

1072-
// create property in auxiliary storage
1073-
mLayer->auxiliaryLayer()->addAuxiliaryField( def );
1072+
// create property in auxiliary storage if necessary
1073+
if ( !mLayer->auxiliaryLayer()->exists( def ) )
1074+
mLayer->auxiliaryLayer()->addAuxiliaryField( def );
10741075

10751076
// update property with join field name from auxiliary storage
10761077
QgsProperty property = button->toProperty();

‎src/app/qgslabelinggui.cpp

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -639,8 +639,9 @@ void QgsLabelingGui::createAuxiliaryField()
639639
const QgsPalLayerSettings::Property key = static_cast< QgsPalLayerSettings::Property >( button->propertyKey() );
640640
const QgsPropertyDefinition def = QgsPalLayerSettings::propertyDefinitions()[key];
641641

642-
// create property in auxiliary storage
643-
mLayer->auxiliaryLayer()->addAuxiliaryField( def );
642+
// create property in auxiliary storage if necessary
643+
if ( !mLayer->auxiliaryLayer()->exists( def ) )
644+
mLayer->auxiliaryLayer()->addAuxiliaryField( def );
644645

645646
// update property with join field name from auxiliary storage
646647
QgsProperty property = button->toProperty();

‎src/gui/qgspropertyoverridebutton.cpp

Lines changed: 8 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,6 +68,7 @@ QgsPropertyOverrideButton::QgsPropertyOverrideButton( QWidget *parent,
6868
mActionDescription = new QAction( tr( "Description..." ), this );
6969

7070
mActionCreateAuxiliaryField = new QAction( tr( "Store data in the project" ), this );
71+
mActionCreateAuxiliaryField->setCheckable( true );
7172

7273
mActionExpDialog = new QAction( tr( "Edit..." ), this );
7374
mActionExpression = nullptr;
@@ -337,13 +338,15 @@ void QgsPropertyOverrideButton::aboutToShowMenu()
337338

338339
const QgsAuxiliaryLayer *alayer = mVectorLayer->auxiliaryLayer();
339340

341+
mActionCreateAuxiliaryField->setEnabled( true );
342+
mActionCreateAuxiliaryField->setChecked( false );
340343
if ( alayer && alayer->exists( mDefinition ) )
341344
{
342-
mActionCreateAuxiliaryField->setEnabled( false );
343-
}
344-
else
345-
{
346-
mActionCreateAuxiliaryField->setEnabled( true );
345+
if ( mProperty.field() == QgsAuxiliaryField::name( mDefinition, true ) )
346+
{
347+
mActionCreateAuxiliaryField->setEnabled( false );
348+
mActionCreateAuxiliaryField->setChecked( true );
349+
}
347350
}
348351

349352
bool fieldActive = false;

0 commit comments

Comments
 (0)
Please sign in to comment.