28   d = 
new QgsTextBackgroundSettingsPrivate();
 
   62   if ( !d->enabled == other.
enabled()
 
   63        || d->type != other.
type()
 
   64        || d->svgFile != other.
svgFile()
 
   66        || d->size != other.
size()
 
   71        || d->offset != other.
offset()
 
   74        || d->radii != other.
radii()
 
   80        || d->opacity != other.
opacity()
 
   87   if ( 
static_cast< bool >( d->paintEffect ) != 
static_cast< bool >( other.
paintEffect() )
 
   91   if ( 
static_cast< bool >( d->markerSymbol ) != 
static_cast< bool >( other.
markerSymbol() )
 
   95   if ( 
static_cast< bool >( d->fillSymbol ) != 
static_cast< bool >( other.
fillSymbol() )
 
  104   return !( *
this == other );
 
  139   return d->markerSymbol.get();
 
  144   d->markerSymbol.reset( symbol );
 
  149   return d->fillSymbol.get();
 
  154   d->fillSymbol.reset( symbol );
 
  189   return d->sizeMapUnitScale;
 
  194   d->sizeMapUnitScale = scale;
 
  199   return d->rotationType;
 
  204   d->rotationType = 
type;
 
  229   return d->offsetUnits;
 
  234   d->offsetUnits = units;
 
  239   return d->offsetMapUnitScale;
 
  244   d->offsetMapUnitScale = scale;
 
  259   return d->radiiUnits;
 
  264   d->radiiUnits = units;
 
  269   return d->radiiMapUnitScale;
 
  274   d->radiiMapUnitScale = scale;
 
  304   d->fillColor = color;
 
  305   if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() == QLatin1String( 
"SimpleFill" ) )
 
  307     qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) )->setColor( color );
 
  313   return d->strokeColor;
 
  318   d->strokeColor = color;
 
  319   if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() == QLatin1String( 
"SimpleFill" ) )
 
  321     qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) )->setStrokeColor( color );
 
  327   return d->strokeWidth;
 
  332   d->strokeWidth = width;
 
  333   if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() == QLatin1String( 
"SimpleFill" ) )
 
  335     QgsSimpleFillSymbolLayer *fill = qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) );
 
  343   return d->strokeWidthUnits;
 
  348   d->strokeWidthUnits = units;
 
  349   if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() == QLatin1String( 
"SimpleFill" ) )
 
  351     qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) )->setStrokeWidthUnit( units );
 
  357   return d->strokeWidthMapUnitScale;
 
  362   d->strokeWidthMapUnitScale = scale;
 
  363   if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() == QLatin1String( 
"SimpleFill" ) )
 
  365     qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) )->setStrokeWidthMapUnitScale( scale );
 
  376   d->joinStyle = style;
 
  377   if ( d->fillSymbol && d->fillSymbol->symbolLayers().at( 0 )->layerType() == QLatin1String( 
"SimpleFill" ) )
 
  379     qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) )->setPenJoinStyle( style );
 
  385   return d->paintEffect.get();
 
  390   d->paintEffect.reset( effect );
 
  395   d->enabled = layer->
customProperty( QStringLiteral( 
"labeling/shapeDraw" ), QVariant( 
false ) ).toBool();
 
  397   d->svgFile = layer->
customProperty( QStringLiteral( 
"labeling/shapeSVGFile" ), QVariant( 
"" ) ).toString();
 
  399   d->size = QSizeF( layer->
customProperty( QStringLiteral( 
"labeling/shapeSizeX" ), QVariant( 0.0 ) ).toDouble(),
 
  400                     layer->
customProperty( QStringLiteral( 
"labeling/shapeSizeY" ), QVariant( 0.0 ) ).toDouble() );
 
  402   if ( layer->
customProperty( QStringLiteral( 
"labeling/shapeSizeUnit" ) ).toString().isEmpty() )
 
  411   if ( layer->
customProperty( QStringLiteral( 
"labeling/shapeSizeMapUnitScale" ) ).toString().isEmpty() )
 
  414     const double oldMin = layer->
customProperty( QStringLiteral( 
"labeling/shapeSizeMapUnitMinScale" ), 0.0 ).toDouble();
 
  415     d->sizeMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
 
  416     const double oldMax = layer->
customProperty( QStringLiteral( 
"labeling/shapeSizeMapUnitMaxScale" ), 0.0 ).toDouble();
 
  417     d->sizeMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
 
  424   d->rotation = layer->
customProperty( QStringLiteral( 
"labeling/shapeRotation" ), QVariant( 0.0 ) ).toDouble();
 
  425   d->offset = QPointF( layer->
customProperty( QStringLiteral( 
"labeling/shapeOffsetX" ), QVariant( 0.0 ) ).toDouble(),
 
  426                        layer->
customProperty( QStringLiteral( 
"labeling/shapeOffsetY" ), QVariant( 0.0 ) ).toDouble() );
 
  428   if ( layer->
customProperty( QStringLiteral( 
"labeling/shapeOffsetUnit" ) ).toString().isEmpty() )
 
  437   if ( layer->
customProperty( QStringLiteral( 
"labeling/shapeOffsetMapUnitScale" ) ).toString().isEmpty() )
 
  440     const double oldMin = layer->
customProperty( QStringLiteral( 
"labeling/shapeOffsetMapUnitMinScale" ), 0.0 ).toDouble();
 
  441     d->offsetMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
 
  442     const double oldMax = layer->
customProperty( QStringLiteral( 
"labeling/shapeOffsetMapUnitMaxScale" ), 0.0 ).toDouble();
 
  443     d->offsetMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
 
  449   d->radii = QSizeF( layer->
customProperty( QStringLiteral( 
"labeling/shapeRadiiX" ), QVariant( 0.0 ) ).toDouble(),
 
  450                      layer->
customProperty( QStringLiteral( 
"labeling/shapeRadiiY" ), QVariant( 0.0 ) ).toDouble() );
 
  453   if ( layer->
customProperty( QStringLiteral( 
"labeling/shapeRadiiUnit" ) ).toString().isEmpty() )
 
  462   if ( layer->
customProperty( QStringLiteral( 
"labeling/shapeRadiiMapUnitScale" ) ).toString().isEmpty() )
 
  465     const double oldMin = layer->
customProperty( QStringLiteral( 
"labeling/shapeRadiiMapUnitMinScale" ), 0.0 ).toDouble();
 
  466     d->radiiMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
 
  467     const double oldMax = layer->
customProperty( QStringLiteral( 
"labeling/shapeRadiiMapUnitMaxScale" ), 0.0 ).toDouble();
 
  468     d->radiiMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
 
  476   d->strokeWidth = layer->
customProperty( QStringLiteral( 
"labeling/shapeBorderWidth" ), QVariant( .0 ) ).toDouble();
 
  477   if ( layer->
customProperty( QStringLiteral( 
"labeling/shapeBorderWidthUnit" ) ).toString().isEmpty() )
 
  485   if ( layer->
customProperty( QStringLiteral( 
"labeling/shapeBorderWidthMapUnitScale" ) ).toString().isEmpty() )
 
  488     const double oldMin = layer->
customProperty( QStringLiteral( 
"labeling/shapeBorderWidthMapUnitMinScale" ), 0.0 ).toDouble();
 
  489     d->strokeWidthMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
 
  490     const double oldMax = layer->
customProperty( QStringLiteral( 
"labeling/shapeBorderWidthMapUnitMaxScale" ), 0.0 ).toDouble();
 
  491     d->strokeWidthMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
 
  497   d->joinStyle = 
static_cast< Qt::PenJoinStyle 
>( layer->
customProperty( QStringLiteral( 
"labeling/shapeJoinStyle" ), QVariant( Qt::BevelJoin ) ).toUInt() );
 
  499   if ( layer->
customProperty( QStringLiteral( 
"labeling/shapeOpacity" ) ).toString().isEmpty() )
 
  501     d->opacity = ( 1 - layer->
customProperty( QStringLiteral( 
"labeling/shapeTransparency" ) ).toInt() / 100.0 ); 
 
  505     d->opacity = ( layer->
customProperty( QStringLiteral( 
"labeling/shapeOpacity" ) ).toDouble() );
 
  510   if ( layer->
customProperty( QStringLiteral( 
"labeling/shapeEffect" ) ).isValid() )
 
  512     QDomDocument doc( QStringLiteral( 
"effect" ) );
 
  513     doc.setContent( layer->
customProperty( QStringLiteral( 
"labeling/shapeEffect" ) ).toString() );
 
  514     const QDomElement effectElem = doc.firstChildElement( QStringLiteral( 
"effect" ) ).firstChildElement( QStringLiteral( 
"effect" ) );
 
  523   const QDomElement backgroundElem = elem.firstChildElement( QStringLiteral( 
"background" ) );
 
  524   d->enabled = backgroundElem.attribute( QStringLiteral( 
"shapeDraw" ), QStringLiteral( 
"0" ) ).toInt();
 
  525   d->type = 
static_cast< ShapeType >( backgroundElem.attribute( QStringLiteral( 
"shapeType" ), QString::number( 
ShapeRectangle ) ).toUInt() );
 
  527   d->sizeType = 
static_cast< SizeType >( backgroundElem.attribute( QStringLiteral( 
"shapeSizeType" ), QString::number( 
SizeBuffer ) ).toUInt() );
 
  528   d->size = QSizeF( backgroundElem.attribute( QStringLiteral( 
"shapeSizeX" ), QStringLiteral( 
"0" ) ).toDouble(),
 
  529                     backgroundElem.attribute( QStringLiteral( 
"shapeSizeY" ), QStringLiteral( 
"0" ) ).toDouble() );
 
  531   if ( !backgroundElem.hasAttribute( QStringLiteral( 
"shapeSizeUnit" ) ) )
 
  540   if ( !backgroundElem.hasAttribute( QStringLiteral( 
"shapeSizeMapUnitScale" ) ) )
 
  543     const double oldMin = backgroundElem.attribute( QStringLiteral( 
"shapeSizeMapUnitMinScale" ), QStringLiteral( 
"0" ) ).toDouble();
 
  544     d->sizeMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
 
  545     const double oldMax = backgroundElem.attribute( QStringLiteral( 
"shapeSizeMapUnitMaxScale" ), QStringLiteral( 
"0" ) ).toDouble();
 
  546     d->sizeMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
 
  552   d->rotationType = 
static_cast< RotationType >( backgroundElem.attribute( QStringLiteral( 
"shapeRotationType" ), QString::number( 
RotationSync ) ).toUInt() );
 
  553   d->rotation = backgroundElem.attribute( QStringLiteral( 
"shapeRotation" ), QStringLiteral( 
"0" ) ).toDouble();
 
  554   d->offset = QPointF( backgroundElem.attribute( QStringLiteral( 
"shapeOffsetX" ), QStringLiteral( 
"0" ) ).toDouble(),
 
  555                        backgroundElem.attribute( QStringLiteral( 
"shapeOffsetY" ), QStringLiteral( 
"0" ) ).toDouble() );
 
  557   if ( !backgroundElem.hasAttribute( QStringLiteral( 
"shapeOffsetUnit" ) ) )
 
  566   if ( !backgroundElem.hasAttribute( QStringLiteral( 
"shapeOffsetMapUnitScale" ) ) )
 
  569     const double oldMin = backgroundElem.attribute( QStringLiteral( 
"shapeOffsetMapUnitMinScale" ), QStringLiteral( 
"0" ) ).toDouble();
 
  570     d->offsetMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
 
  571     const double oldMax = backgroundElem.attribute( QStringLiteral( 
"shapeOffsetMapUnitMaxScale" ), QStringLiteral( 
"0" ) ).toDouble();
 
  572     d->offsetMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
 
  578   d->radii = QSizeF( backgroundElem.attribute( QStringLiteral( 
"shapeRadiiX" ), QStringLiteral( 
"0" ) ).toDouble(),
 
  579                      backgroundElem.attribute( QStringLiteral( 
"shapeRadiiY" ), QStringLiteral( 
"0" ) ).toDouble() );
 
  581   if ( !backgroundElem.hasAttribute( QStringLiteral( 
"shapeRadiiUnit" ) ) )
 
  589   if ( !backgroundElem.hasAttribute( QStringLiteral( 
"shapeRadiiMapUnitScale" ) ) )
 
  592     const double oldMin = backgroundElem.attribute( QStringLiteral( 
"shapeRadiiMapUnitMinScale" ), QStringLiteral( 
"0" ) ).toDouble();
 
  593     d->radiiMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
 
  594     const double oldMax = backgroundElem.attribute( QStringLiteral( 
"shapeRadiiMapUnitMaxScale" ), QStringLiteral( 
"0" ) ).toDouble();
 
  595     d->radiiMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
 
  603   d->strokeWidth = backgroundElem.attribute( QStringLiteral( 
"shapeBorderWidth" ), QStringLiteral( 
"0" ) ).toDouble();
 
  605   if ( !backgroundElem.hasAttribute( QStringLiteral( 
"shapeBorderWidthUnit" ) ) )
 
  613   if ( !backgroundElem.hasAttribute( QStringLiteral( 
"shapeBorderWidthMapUnitScale" ) ) )
 
  616     const double oldMin = backgroundElem.attribute( QStringLiteral( 
"shapeBorderWidthMapUnitMinScale" ), QStringLiteral( 
"0" ) ).toDouble();
 
  617     d->strokeWidthMapUnitScale.minScale = oldMin != 0 ? 1.0 / oldMin : 0;
 
  618     const double oldMax = backgroundElem.attribute( QStringLiteral( 
"shapeBorderWidthMapUnitMaxScale" ), QStringLiteral( 
"0" ) ).toDouble();
 
  619     d->strokeWidthMapUnitScale.maxScale = oldMax != 0 ? 1.0 / oldMax : 0;
 
  625   d->joinStyle = 
static_cast< Qt::PenJoinStyle 
>( backgroundElem.attribute( QStringLiteral( 
"shapeJoinStyle" ), QString::number( Qt::BevelJoin ) ).toUInt() );
 
  627   if ( !backgroundElem.hasAttribute( QStringLiteral( 
"shapeOpacity" ) ) )
 
  629     d->opacity = ( 1 - backgroundElem.attribute( QStringLiteral( 
"shapeTransparency" ) ).toInt() / 100.0 ); 
 
  633     d->opacity = ( backgroundElem.attribute( QStringLiteral( 
"shapeOpacity" ) ).toDouble() );
 
  639   const QDomElement effectElem = backgroundElem.firstChildElement( QStringLiteral( 
"effect" ) );
 
  640   if ( !effectElem.isNull() )
 
  647   const QDomNodeList symbols = backgroundElem.elementsByTagName( QStringLiteral( 
"symbol" ) );
 
  648   for ( 
int i = 0; i < symbols.size(); ++i )
 
  650     if ( symbols.at( i ).isElement() )
 
  652       const QDomElement symbolElement = symbols.at( i ).toElement();
 
  653       const QString symbolElementName = symbolElement.attribute( QStringLiteral( 
"name" ) );
 
  654       if ( symbolElementName == QLatin1String( 
"markerSymbol" ) )
 
  656         setMarkerSymbol( QgsSymbolLayerUtils::loadSymbol< QgsMarkerSymbol >( symbolElement, context ) );
 
  658       else if ( symbolElementName == QLatin1String( 
"fillSymbol" ) )
 
  660         setFillSymbol( QgsSymbolLayerUtils::loadSymbol< QgsFillSymbol >( symbolElement, context ) );
 
  665   if ( !d->fillSymbol )
 
  682   QDomElement backgroundElem = doc.createElement( QStringLiteral( 
"background" ) );
 
  683   backgroundElem.setAttribute( QStringLiteral( 
"shapeDraw" ), d->enabled );
 
  684   backgroundElem.setAttribute( QStringLiteral( 
"shapeType" ), 
static_cast< unsigned int >( d->type ) );
 
  686   backgroundElem.setAttribute( QStringLiteral( 
"shapeSizeType" ), 
static_cast< unsigned int >( d->sizeType ) );
 
  687   backgroundElem.setAttribute( QStringLiteral( 
"shapeSizeX" ), d->size.width() );
 
  688   backgroundElem.setAttribute( QStringLiteral( 
"shapeSizeY" ), d->size.height() );
 
  691   backgroundElem.setAttribute( QStringLiteral( 
"shapeRotationType" ), 
static_cast< unsigned int >( d->rotationType ) );
 
  692   backgroundElem.setAttribute( QStringLiteral( 
"shapeRotation" ), d->rotation );
 
  693   backgroundElem.setAttribute( QStringLiteral( 
"shapeOffsetX" ), d->offset.x() );
 
  694   backgroundElem.setAttribute( QStringLiteral( 
"shapeOffsetY" ), d->offset.y() );
 
  697   backgroundElem.setAttribute( QStringLiteral( 
"shapeRadiiX" ), d->radii.width() );
 
  698   backgroundElem.setAttribute( QStringLiteral( 
"shapeRadiiY" ), d->radii.height() );
 
  703   backgroundElem.setAttribute( QStringLiteral( 
"shapeBorderWidth" ), d->strokeWidth );
 
  704   backgroundElem.setAttribute( QStringLiteral( 
"shapeBorderWidthUnit" ), 
QgsUnitTypes::encodeUnit( d->strokeWidthUnits ) );
 
  706   backgroundElem.setAttribute( QStringLiteral( 
"shapeJoinStyle" ), 
static_cast< unsigned int >( d->joinStyle ) );
 
  707   backgroundElem.setAttribute( QStringLiteral( 
"shapeOpacity" ), d->opacity );
 
  710     d->paintEffect->saveProperties( doc, backgroundElem );
 
  712   if ( d->markerSymbol )
 
  718   return backgroundElem;
 
  723   if ( !d->fillSymbol || d->fillSymbol->symbolLayers().at( 0 )->layerType() != QLatin1String( 
"SimpleFill" ) )
 
  725   QgsSimpleFillSymbolLayer *fill = qgis::down_cast< QgsSimpleFillSymbolLayer * >( d->fillSymbol->symbolLayers().at( 0 ) );
 
  779   if ( !exprVal.isNull() )
 
  781     const QString units = exprVal.toString();
 
  782     if ( !units.isEmpty() )
 
  792   if ( !exprVal.isNull() )
 
  794     const QString skind = exprVal.toString().trimmed();
 
  795     if ( !skind.isEmpty() )
 
  802   if ( !exprVal.isNull() )
 
  804     const QString stype = exprVal.toString().trimmed();
 
  805     if ( !stype.isEmpty() )
 
  814   if ( !exprVal.isNull() )
 
  816     const QString svgfile = exprVal.toString().trimmed();
 
  826   if ( !exprVal.isNull() )
 
  828     const QString rotstr = exprVal.toString().trimmed();
 
  829     if ( !rotstr.isEmpty() )
 
  836   if ( !exprVal.isNull() )
 
  846   if ( !exprVal.isNull() )
 
  848     const QString units = exprVal.toString();
 
  849     if ( !units.isEmpty() )
 
  854         d->offsetUnits = res;
 
  859   if ( !exprVal.isNull() )
 
  870   if ( !exprVal.isNull() )
 
  872     const QString units = exprVal.toString();
 
  873     if ( !units.isEmpty() )
 
  888       d->opacity = val.toDouble() / 100.0;
 
  911   if ( !exprVal.isNull() )
 
  913     const QString units = exprVal.toString();
 
  914     if ( !units.isEmpty() )
 
  919         d->strokeWidthUnits = res;
 
  926     const QString blendstr = exprVal.toString().trimmed();
 
  927     if ( !blendstr.isEmpty() )
 
  934     const QString joinstr = exprVal.toString().trimmed();
 
  935     if ( !joinstr.isEmpty() )
 
  944   QSet< QString > fields;
 
  945   if ( d->markerSymbol )
 
  947     fields.unite( d->markerSymbol->usedAttributes( context ) );
 
  951     fields.unite( d->fillSymbol->usedAttributes( context ) );