Skip to content

Commit 9e809f3

Browse files
committedNov 2, 2011
Remove option for multiline; Code always uses multiline; Direction symbol now works for multiline
1 parent 0a1cef9 commit 9e809f3

File tree

3 files changed

+73
-101
lines changed

3 files changed

+73
-101
lines changed
 

‎src/app/qgslabelinggui.cpp

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -138,7 +138,6 @@ QgsLabelingGui::QgsLabelingGui( QgsPalLabeling* lbl, QgsVectorLayer* layer, QgsM
138138
chkNoObstacle->setChecked( !lyr.obstacle );
139139
chkLabelPerFeaturePart->setChecked( lyr.labelPerPart );
140140
chkMergeLines->setChecked( lyr.mergeLines );
141-
chkMultiLine->setChecked( lyr.multiLineLabels );
142141
mMinSizeSpinBox->setValue( lyr.minFeatureSize );
143142
chkAddDirectionSymbol->setChecked( lyr.addDirectionSymbol );
144143

@@ -282,7 +281,6 @@ QgsPalLayerSettings QgsLabelingGui::layerSettings()
282281
lyr.obstacle = !chkNoObstacle->isChecked();
283282
lyr.labelPerPart = chkLabelPerFeaturePart->isChecked();
284283
lyr.mergeLines = chkMergeLines->isChecked();
285-
lyr.multiLineLabels = chkMultiLine->isChecked();
286284
if ( chkScaleBasedVisibility->isChecked() )
287285
{
288286
lyr.scaleMin = spinScaleMin->value();

‎src/core/qgspallabeling.cpp

Lines changed: 12 additions & 31 deletions
Original file line numberDiff line numberDiff line change
@@ -152,7 +152,6 @@ QgsPalLayerSettings::QgsPalLayerSettings()
152152
plusSign = false;
153153
labelPerPart = false;
154154
mergeLines = false;
155-
multiLineLabels = true;
156155
minFeatureSize = 0.0;
157156
vectorScaleFactor = 1.0;
158157
rasterCompressFactor = 1.0;
@@ -183,7 +182,6 @@ QgsPalLayerSettings::QgsPalLayerSettings( const QgsPalLayerSettings& s )
183182
plusSign = s.plusSign;
184183
labelPerPart = s.labelPerPart;
185184
mergeLines = s.mergeLines;
186-
multiLineLabels = s.multiLineLabels;
187185
minFeatureSize = s.minFeatureSize;
188186
vectorScaleFactor = s.vectorScaleFactor;
189187
rasterCompressFactor = s.rasterCompressFactor;
@@ -328,7 +326,6 @@ void QgsPalLayerSettings::readFromLayer( QgsVectorLayer* layer )
328326
plusSign = layer->customProperty( "labeling/plussign" ).toInt();
329327
labelPerPart = layer->customProperty( "labeling/labelPerPart" ).toBool();
330328
mergeLines = layer->customProperty( "labeling/mergeLines" ).toBool();
331-
multiLineLabels = layer->customProperty( "labeling/multiLineLabels" ).toBool();
332329
addDirectionSymbol = layer->customProperty( "labeling/addDirectionSymbol" ).toBool();
333330
minFeatureSize = layer->customProperty( "labeling/minFeatureSize" ).toDouble();
334331
fontSizeInMapUnits = layer->customProperty( "labeling/fontSizeInMapUnits" ).toBool();
@@ -367,7 +364,6 @@ void QgsPalLayerSettings::writeToLayer( QgsVectorLayer* layer )
367364
layer->setCustomProperty( "labeling/plussign", plusSign );
368365
layer->setCustomProperty( "labeling/labelPerPart", labelPerPart );
369366
layer->setCustomProperty( "labeling/mergeLines", mergeLines );
370-
layer->setCustomProperty( "labeling/multiLineLabels", multiLineLabels );
371367
layer->setCustomProperty( "labeling/addDirectionSymbol", addDirectionSymbol );
372368
layer->setCustomProperty( "labeling/minFeatureSize", minFeatureSize );
373369
layer->setCustomProperty( "labeling/fontSizeInMapUnits", fontSizeInMapUnits );
@@ -430,33 +426,25 @@ void QgsPalLayerSettings::calculateLabelSize( const QFontMetricsF* fm, QString t
430426
return;
431427
}
432428

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 )
434431
{
435432
text.append( ">" );
436433
}
437434

438435
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 )
440440
{
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 )
451443
{
452-
double width = fm->width( multiLineSplit.at( i ) );
453-
if ( width > w )
454-
{
455-
w = width;
456-
}
444+
w = width;
457445
}
458-
w /= rasterCompressFactor;
459446
}
447+
w /= rasterCompressFactor;
460448
QgsPoint ptSize = xform->toMapCoordinatesF( w, h );
461449

462450
labelX = qAbs( ptSize.x() - ptZero.x() );
@@ -1337,7 +1325,7 @@ void QgsPalLabeling::drawLabel( pal::LabelPosition* label, QPainter* painter, co
13371325

13381326
//add the direction symbol if needed
13391327
if ( !txt.isEmpty() && lyr.placement == QgsPalLayerSettings::Line &&
1340-
lyr.addDirectionSymbol && !lyr.multiLineLabels )
1328+
lyr.addDirectionSymbol )
13411329
{
13421330
if ( label->getReversed() )
13431331
{
@@ -1352,14 +1340,7 @@ void QgsPalLabeling::drawLabel( pal::LabelPosition* label, QPainter* painter, co
13521340
//QgsDebugMsg( "drawLabel " + QString::number( drawBuffer ) + " " + txt );
13531341

13541342
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" );
13631344

13641345
for ( int i = 0; i < multiLineList.size(); ++i )
13651346
{

‎src/ui/qgslabelingguibase.ui

Lines changed: 61 additions & 68 deletions
Original file line numberDiff line numberDiff line change
@@ -63,10 +63,64 @@
6363
</item>
6464
</layout>
6565
</item>
66+
<item row="3" column="0">
67+
<widget class="QDialogButtonBox" name="buttonBox">
68+
<property name="orientation">
69+
<enum>Qt::Horizontal</enum>
70+
</property>
71+
<property name="standardButtons">
72+
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
73+
</property>
74+
</widget>
75+
</item>
76+
<item row="0" column="0">
77+
<layout class="QHBoxLayout" name="horizontalLayout_3">
78+
<item>
79+
<widget class="QCheckBox" name="chkEnableLabeling">
80+
<property name="text">
81+
<string>Label this layer with</string>
82+
</property>
83+
</widget>
84+
</item>
85+
<item>
86+
<widget class="QComboBox" name="cboFieldName">
87+
<property name="enabled">
88+
<bool>false</bool>
89+
</property>
90+
<property name="editable">
91+
<bool>false</bool>
92+
</property>
93+
</widget>
94+
</item>
95+
<item>
96+
<widget class="QToolButton" name="btnExpression">
97+
<property name="enabled">
98+
<bool>false</bool>
99+
</property>
100+
<property name="text">
101+
<string>...</string>
102+
</property>
103+
</widget>
104+
</item>
105+
<item>
106+
<spacer name="horizontalSpacer_5">
107+
<property name="orientation">
108+
<enum>Qt::Horizontal</enum>
109+
</property>
110+
<property name="sizeHint" stdset="0">
111+
<size>
112+
<width>40</width>
113+
<height>20</height>
114+
</size>
115+
</property>
116+
</spacer>
117+
</item>
118+
</layout>
119+
</item>
66120
<item row="2" column="0">
67121
<widget class="QTabWidget" name="mTabWidget">
68122
<property name="enabled">
69-
<bool>false</bool>
123+
<bool>true</bool>
70124
</property>
71125
<property name="currentIndex">
72126
<number>0</number>
@@ -419,8 +473,8 @@
419473
<rect>
420474
<x>0</x>
421475
<y>0</y>
422-
<width>647</width>
423-
<height>487</height>
476+
<width>646</width>
477+
<height>451</height>
424478
</rect>
425479
</property>
426480
<layout class="QGridLayout" name="gridLayout_13">
@@ -487,20 +541,13 @@
487541
</widget>
488542
</item>
489543
<item row="2" column="0">
490-
<widget class="QCheckBox" name="chkMultiLine">
491-
<property name="text">
492-
<string>Multiline labels</string>
493-
</property>
494-
</widget>
495-
</item>
496-
<item row="3" column="0">
497544
<widget class="QCheckBox" name="chkAddDirectionSymbol">
498545
<property name="text">
499546
<string>Add direction symbol</string>
500547
</property>
501548
</widget>
502549
</item>
503-
<item row="4" column="0">
550+
<item row="3" column="0">
504551
<layout class="QHBoxLayout" name="horizontalLayout_2">
505552
<item>
506553
<widget class="QLabel" name="label_19">
@@ -518,7 +565,7 @@
518565
</item>
519566
</layout>
520567
</item>
521-
<item row="5" column="0">
568+
<item row="4" column="0">
522569
<layout class="QHBoxLayout" name="horizontalLayout_20">
523570
<item>
524571
<widget class="QCheckBox" name="chkNoObstacle">
@@ -876,8 +923,8 @@
876923
<rect>
877924
<x>0</x>
878925
<y>0</y>
879-
<width>647</width>
880-
<height>615</height>
926+
<width>646</width>
927+
<height>585</height>
881928
</rect>
882929
</property>
883930
<layout class="QGridLayout" name="gridLayout_11">
@@ -1072,60 +1119,6 @@
10721119
</widget>
10731120
</widget>
10741121
</item>
1075-
<item row="3" column="0">
1076-
<widget class="QDialogButtonBox" name="buttonBox">
1077-
<property name="orientation">
1078-
<enum>Qt::Horizontal</enum>
1079-
</property>
1080-
<property name="standardButtons">
1081-
<set>QDialogButtonBox::Apply|QDialogButtonBox::Cancel|QDialogButtonBox::Ok</set>
1082-
</property>
1083-
</widget>
1084-
</item>
1085-
<item row="0" column="0">
1086-
<layout class="QHBoxLayout" name="horizontalLayout_3">
1087-
<item>
1088-
<widget class="QCheckBox" name="chkEnableLabeling">
1089-
<property name="text">
1090-
<string>Label this layer with</string>
1091-
</property>
1092-
</widget>
1093-
</item>
1094-
<item>
1095-
<widget class="QComboBox" name="cboFieldName">
1096-
<property name="enabled">
1097-
<bool>false</bool>
1098-
</property>
1099-
<property name="editable">
1100-
<bool>false</bool>
1101-
</property>
1102-
</widget>
1103-
</item>
1104-
<item>
1105-
<widget class="QToolButton" name="btnExpression">
1106-
<property name="enabled">
1107-
<bool>false</bool>
1108-
</property>
1109-
<property name="text">
1110-
<string>...</string>
1111-
</property>
1112-
</widget>
1113-
</item>
1114-
<item>
1115-
<spacer name="horizontalSpacer_5">
1116-
<property name="orientation">
1117-
<enum>Qt::Horizontal</enum>
1118-
</property>
1119-
<property name="sizeHint" stdset="0">
1120-
<size>
1121-
<width>40</width>
1122-
<height>20</height>
1123-
</size>
1124-
</property>
1125-
</spacer>
1126-
</item>
1127-
</layout>
1128-
</item>
11291122
</layout>
11301123
</widget>
11311124
<layoutdefault spacing="6" margin="11"/>

0 commit comments

Comments
 (0)
Please sign in to comment.