@@ -152,7 +152,6 @@ QgsPalLayerSettings::QgsPalLayerSettings()
152
152
plusSign = false ;
153
153
labelPerPart = false ;
154
154
mergeLines = false ;
155
- multiLineLabels = true ;
156
155
minFeatureSize = 0.0 ;
157
156
vectorScaleFactor = 1.0 ;
158
157
rasterCompressFactor = 1.0 ;
@@ -183,7 +182,6 @@ QgsPalLayerSettings::QgsPalLayerSettings( const QgsPalLayerSettings& s )
183
182
plusSign = s.plusSign ;
184
183
labelPerPart = s.labelPerPart ;
185
184
mergeLines = s.mergeLines ;
186
- multiLineLabels = s.multiLineLabels ;
187
185
minFeatureSize = s.minFeatureSize ;
188
186
vectorScaleFactor = s.vectorScaleFactor ;
189
187
rasterCompressFactor = s.rasterCompressFactor ;
@@ -328,7 +326,6 @@ void QgsPalLayerSettings::readFromLayer( QgsVectorLayer* layer )
328
326
plusSign = layer->customProperty ( " labeling/plussign" ).toInt ();
329
327
labelPerPart = layer->customProperty ( " labeling/labelPerPart" ).toBool ();
330
328
mergeLines = layer->customProperty ( " labeling/mergeLines" ).toBool ();
331
- multiLineLabels = layer->customProperty ( " labeling/multiLineLabels" ).toBool ();
332
329
addDirectionSymbol = layer->customProperty ( " labeling/addDirectionSymbol" ).toBool ();
333
330
minFeatureSize = layer->customProperty ( " labeling/minFeatureSize" ).toDouble ();
334
331
fontSizeInMapUnits = layer->customProperty ( " labeling/fontSizeInMapUnits" ).toBool ();
@@ -367,7 +364,6 @@ void QgsPalLayerSettings::writeToLayer( QgsVectorLayer* layer )
367
364
layer->setCustomProperty ( " labeling/plussign" , plusSign );
368
365
layer->setCustomProperty ( " labeling/labelPerPart" , labelPerPart );
369
366
layer->setCustomProperty ( " labeling/mergeLines" , mergeLines );
370
- layer->setCustomProperty ( " labeling/multiLineLabels" , multiLineLabels );
371
367
layer->setCustomProperty ( " labeling/addDirectionSymbol" , addDirectionSymbol );
372
368
layer->setCustomProperty ( " labeling/minFeatureSize" , minFeatureSize );
373
369
layer->setCustomProperty ( " labeling/fontSizeInMapUnits" , fontSizeInMapUnits );
@@ -430,33 +426,25 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF* fm, QString t
430
426
return ;
431
427
}
432
428
433
- if ( addDirectionSymbol && !multiLineLabels && placement == QgsPalLayerSettings::Line ) // consider the space needed for the direction symbol
429
+ // consider the space needed for the direction symbol
430
+ if ( addDirectionSymbol && placement == QgsPalLayerSettings::Line )
434
431
{
435
432
text.append ( " >" );
436
433
}
437
434
438
435
double w, h;
439
- if ( !multiLineLabels )
436
+ QStringList multiLineSplit = text.split ( " \n " );
437
+ h = fm->height () * multiLineSplit.size () / rasterCompressFactor;
438
+ w = 0 ;
439
+ for ( int i = 0 ; i < multiLineSplit.size (); ++i )
440
440
{
441
- QRectF labelRect = fm->boundingRect ( text );
442
- w = labelRect.width () / rasterCompressFactor;
443
- h = labelRect.height () / rasterCompressFactor;
444
- }
445
- else
446
- {
447
- QStringList multiLineSplit = text.split ( " \n " );
448
- h = fm->height () * multiLineSplit.size () / rasterCompressFactor;
449
- w = 0 ;
450
- for ( int i = 0 ; i < multiLineSplit.size (); ++i )
441
+ double width = fm->width ( multiLineSplit.at ( i ) );
442
+ if ( width > w )
451
443
{
452
- double width = fm->width ( multiLineSplit.at ( i ) );
453
- if ( width > w )
454
- {
455
- w = width;
456
- }
444
+ w = width;
457
445
}
458
- w /= rasterCompressFactor;
459
446
}
447
+ w /= rasterCompressFactor;
460
448
QgsPoint ptSize = xform->toMapCoordinatesF ( w, h );
461
449
462
450
labelX = qAbs ( ptSize.x () - ptZero.x () );
@@ -1337,7 +1325,7 @@ void QgsPalLabeling::drawLabel( pal::LabelPosition* label, QPainter* painter, co
1337
1325
1338
1326
// add the direction symbol if needed
1339
1327
if ( !txt.isEmpty () && lyr.placement == QgsPalLayerSettings::Line &&
1340
- lyr.addDirectionSymbol && !lyr. multiLineLabels )
1328
+ lyr.addDirectionSymbol )
1341
1329
{
1342
1330
if ( label->getReversed () )
1343
1331
{
@@ -1352,14 +1340,7 @@ void QgsPalLabeling::drawLabel( pal::LabelPosition* label, QPainter* painter, co
1352
1340
// QgsDebugMsg( "drawLabel " + QString::number( drawBuffer ) + " " + txt );
1353
1341
1354
1342
QStringList multiLineList;
1355
- if ( lyr.multiLineLabels )
1356
- {
1357
- multiLineList = txt.split ( " \n " );
1358
- }
1359
- else
1360
- {
1361
- multiLineList << txt;
1362
- }
1343
+ multiLineList = txt.split ( " \n " );
1363
1344
1364
1345
for ( int i = 0 ; i < multiLineList.size (); ++i )
1365
1346
{
0 commit comments