Skip to content

Commit 67cff3d

Browse files
committed
Auxiliary fields are linked to data defined for all subproviders
1 parent 9cb3ff3 commit 67cff3d

File tree

4 files changed

+17
-13
lines changed

4 files changed

+17
-13
lines changed

python/core/qgsauxiliarystorage.sip

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,14 +183,13 @@ class QgsAuxiliaryLayer : QgsVectorLayer
183183
:rtype: QgsPropertyDefinition
184184
%End
185185

186-
static int createProperty( QgsPalLayerSettings::Property property, QgsVectorLayer *vlayer, const QString &providerId = QString() );
186+
static int createProperty( QgsPalLayerSettings::Property property, QgsVectorLayer *vlayer );
187187
%Docstring
188188
Creates if necessary a new auxiliary field for a PAL property and
189189
activate this property in settings.
190190

191191
\param property The property to create
192192
\param vlayer The vector layer
193-
\param providerId The id of the provider to use
194193

195194
:return: The index of the auxiliary field or -1
196195
:rtype: int

src/app/qgsmaptoollabel.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -744,7 +744,7 @@ bool QgsMapToolLabel::createAuxiliaryFields( LabelDetails &details, QgsPalIndexe
744744
}
745745
else
746746
{
747-
index = QgsAuxiliaryLayer::createProperty( p, vlayer, providerId );
747+
index = QgsAuxiliaryLayer::createProperty( p, vlayer );
748748
}
749749

750750
indexes[p] = index;

src/core/qgsauxiliarystorage.cpp

Lines changed: 14 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -215,26 +215,32 @@ bool QgsAuxiliaryLayer::save()
215215
return rc;
216216
}
217217

218-
int QgsAuxiliaryLayer::createProperty( QgsPalLayerSettings::Property property, QgsVectorLayer *layer, const QString &providerId )
218+
int QgsAuxiliaryLayer::createProperty( QgsPalLayerSettings::Property property, QgsVectorLayer *layer )
219219
{
220220
int index = -1;
221221

222222
if ( layer && layer->labeling() && layer->auxiliaryLayer() )
223223
{
224-
const QgsPropertyDefinition def = layer->labeling()->settings( providerId ).propertyDefinitions()[property];
224+
// property definition are identical whatever the provider id
225+
const QgsPropertyDefinition def = layer->labeling()->settings().propertyDefinitions()[property];
225226
const QString fieldName = nameFromProperty( def, true );
226227

227-
if ( layer->auxiliaryLayer()->addAuxiliaryField( def ) )
228+
layer->auxiliaryLayer()->addAuxiliaryField( def );
229+
230+
if ( layer->auxiliaryLayer()->indexOfPropertyDefinition( def ) >= 0 )
228231
{
229232
const QgsProperty prop = QgsProperty::fromField( fieldName );
230233

231-
QgsPalLayerSettings *settings = new QgsPalLayerSettings( layer->labeling()->settings( providerId ) );
234+
for ( const QString &providerId : layer->labeling()->subProviders() )
235+
{
236+
QgsPalLayerSettings *settings = new QgsPalLayerSettings( layer->labeling()->settings( providerId ) );
232237

233-
QgsPropertyCollection c = settings->dataDefinedProperties();
234-
c.setProperty( property, prop );
235-
settings->setDataDefinedProperties( c );
238+
QgsPropertyCollection c = settings->dataDefinedProperties();
239+
c.setProperty( property, prop );
240+
settings->setDataDefinedProperties( c );
236241

237-
layer->labeling()->setSettings( settings, providerId );
242+
layer->labeling()->setSettings( settings, providerId );
243+
}
238244
}
239245

240246
index = layer->fields().lookupField( fieldName );

src/core/qgsauxiliarystorage.h

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -200,11 +200,10 @@ class CORE_EXPORT QgsAuxiliaryLayer : public QgsVectorLayer
200200
*
201201
* \param property The property to create
202202
* \param vlayer The vector layer
203-
* \param providerId The id of the provider to use
204203
*
205204
* \returns The index of the auxiliary field or -1
206205
*/
207-
static int createProperty( QgsPalLayerSettings::Property property, QgsVectorLayer *vlayer, const QString &providerId = QString() );
206+
static int createProperty( QgsPalLayerSettings::Property property, QgsVectorLayer *vlayer );
208207

209208
/**
210209
* Creates if necessary a new auxiliary field for a diagram's property and

0 commit comments

Comments
 (0)