Skip to content

Commit add188b

Browse files
committedAug 24, 2014
Where possible, maintain properties of symbol layer when changing symbol layer type (fix #8389)
1 parent 847fd2e commit add188b

File tree

5 files changed

+268
-28
lines changed

5 files changed

+268
-28
lines changed
 

‎src/core/symbology-ng/qgsellipsesymbollayerv2.cpp

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -82,26 +82,47 @@ QgsSymbolLayerV2* QgsEllipseSymbolLayerV2::create( const QgsStringMap& propertie
8282
{
8383
layer->setOutlineStyle( QgsSymbolLayerV2Utils::decodePenStyle( properties["outline_style"] ) );
8484
}
85+
else if ( properties.contains( "line_style" ) )
86+
{
87+
layer->setOutlineStyle( QgsSymbolLayerV2Utils::decodePenStyle( properties["line_style"] ) );
88+
}
8589
if ( properties.contains( "outline_width" ) )
8690
{
8791
layer->setOutlineWidth( properties["outline_width"].toDouble() );
8892
}
93+
else if ( properties.contains( "line_width" ) )
94+
{
95+
layer->setOutlineWidth( properties["line_width"].toDouble() );
96+
}
8997
if ( properties.contains( "outline_width_unit" ) )
9098
{
9199
layer->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["outline_width_unit"] ) );
92100
}
101+
else if ( properties.contains( "line_width_unit" ) )
102+
{
103+
layer->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["line_width_unit"] ) );
104+
}
93105
if ( properties.contains( "outline_width_map_unit_scale" ) )
94106
{
95107
layer->setOutlineWidthMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( properties["outline_width_map_unit_scale"] ) );
96108
}
97109
if ( properties.contains( "fill_color" ) )
98110
{
111+
//pre 2.5 projects used "fill_color"
99112
layer->setFillColor( QgsSymbolLayerV2Utils::decodeColor( properties["fill_color"] ) );
100113
}
114+
else if ( properties.contains( "color" ) )
115+
{
116+
layer->setFillColor( QgsSymbolLayerV2Utils::decodeColor( properties["color"] ) );
117+
}
101118
if ( properties.contains( "outline_color" ) )
102119
{
103120
layer->setOutlineColor( QgsSymbolLayerV2Utils::decodeColor( properties["outline_color"] ) );
104121
}
122+
else if ( properties.contains( "line_color" ) )
123+
{
124+
layer->setOutlineColor( QgsSymbolLayerV2Utils::decodeColor( properties["line_color"] ) );
125+
}
105126
if ( properties.contains( "size" ) )
106127
{
107128
layer->setSize( properties["size"].toDouble() );
@@ -441,7 +462,7 @@ QgsStringMap QgsEllipseSymbolLayerV2::properties() const
441462
map["outline_width"] = QString::number( mOutlineWidth );
442463
map["outline_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOutlineWidthUnit );
443464
map["outline_width_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOutlineWidthMapUnitScale );
444-
map["fill_color"] = QgsSymbolLayerV2Utils::encodeColor( mFillColor );
465+
map["color"] = QgsSymbolLayerV2Utils::encodeColor( mFillColor );
445466
map["outline_color"] = QgsSymbolLayerV2Utils::encodeColor( mOutlineColor );
446467
map["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset );
447468
map["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit );

‎src/core/symbology-ng/qgsfillsymbollayerv2.cpp

Lines changed: 127 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -113,11 +113,45 @@ QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::create( const QgsStringMap& props
113113
if ( props.contains( "style" ) )
114114
style = QgsSymbolLayerV2Utils::decodeBrushStyle( props["style"] );
115115
if ( props.contains( "color_border" ) )
116+
{
117+
//pre 2.5 projects used "color_border"
116118
borderColor = QgsSymbolLayerV2Utils::decodeColor( props["color_border"] );
119+
}
120+
else if ( props.contains( "outline_color" ) )
121+
{
122+
borderColor = QgsSymbolLayerV2Utils::decodeColor( props["outline_color"] );
123+
}
124+
else if ( props.contains( "line_color" ) )
125+
{
126+
borderColor = QgsSymbolLayerV2Utils::decodeColor( props["line_color"] );
127+
}
128+
117129
if ( props.contains( "style_border" ) )
130+
{
131+
//pre 2.5 projects used "style_border"
118132
borderStyle = QgsSymbolLayerV2Utils::decodePenStyle( props["style_border"] );
133+
}
134+
else if ( props.contains( "outline_style" ) )
135+
{
136+
borderStyle = QgsSymbolLayerV2Utils::decodePenStyle( props["outline_style"] );
137+
}
138+
else if ( props.contains( "line_style" ) )
139+
{
140+
borderStyle = QgsSymbolLayerV2Utils::decodePenStyle( props["line_style"] );
141+
}
119142
if ( props.contains( "width_border" ) )
143+
{
144+
//pre 2.5 projects used "width_border"
120145
borderWidth = props["width_border"].toDouble();
146+
}
147+
else if ( props.contains( "outline_width" ) )
148+
{
149+
borderWidth = props["outline_width"].toDouble();
150+
}
151+
else if ( props.contains( "line_width" ) )
152+
{
153+
borderWidth = props["line_width"].toDouble();
154+
}
121155
if ( props.contains( "offset" ) )
122156
offset = QgsSymbolLayerV2Utils::decodePoint( props["offset"] );
123157
if ( props.contains( "joinstyle" ) )
@@ -126,7 +160,17 @@ QgsSymbolLayerV2* QgsSimpleFillSymbolLayerV2::create( const QgsStringMap& props
126160
QgsSimpleFillSymbolLayerV2* sl = new QgsSimpleFillSymbolLayerV2( color, style, borderColor, borderStyle, borderWidth, penJoinStyle );
127161
sl->setOffset( offset );
128162
if ( props.contains( "border_width_unit" ) )
163+
{
129164
sl->setBorderWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["border_width_unit"] ) );
165+
}
166+
else if ( props.contains( "outline_width_unit" ) )
167+
{
168+
sl->setBorderWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["outline_width_unit"] ) );
169+
}
170+
else if ( props.contains( "line_width_unit" ) )
171+
{
172+
sl->setBorderWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["line_width_unit"] ) );
173+
}
130174
if ( props.contains( "offset_unit" ) )
131175
sl->setOffsetUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["offset_unit"] ) );
132176

@@ -227,10 +271,10 @@ QgsStringMap QgsSimpleFillSymbolLayerV2::properties() const
227271
QgsStringMap map;
228272
map["color"] = QgsSymbolLayerV2Utils::encodeColor( mColor );
229273
map["style"] = QgsSymbolLayerV2Utils::encodeBrushStyle( mBrushStyle );
230-
map["color_border"] = QgsSymbolLayerV2Utils::encodeColor( mBorderColor );
231-
map["style_border"] = QgsSymbolLayerV2Utils::encodePenStyle( mBorderStyle );
232-
map["width_border"] = QString::number( mBorderWidth );
233-
map["border_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mBorderWidthUnit );
274+
map["outline_color"] = QgsSymbolLayerV2Utils::encodeColor( mBorderColor );
275+
map["outline_style"] = QgsSymbolLayerV2Utils::encodePenStyle( mBorderStyle );
276+
map["outline_width"] = QString::number( mBorderWidth );
277+
map["outline_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mBorderWidthUnit );
234278
map["border_width_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mBorderWidthMapUnitScale );
235279
map["joinstyle"] = QgsSymbolLayerV2Utils::encodePenJoinStyle( mPenJoinStyle );
236280
map["offset"] = QgsSymbolLayerV2Utils::encodePoint( mOffset );
@@ -404,9 +448,19 @@ QgsSymbolLayerV2* QgsGradientFillSymbolLayerV2::create( const QgsStringMap& prop
404448
if ( props.contains( "color_type" ) )
405449
colorType = ( GradientColorType )props["color_type"].toInt();
406450
if ( props.contains( "gradient_color" ) )
451+
{
452+
//pre 2.5 projects used "gradient_color"
407453
color = QgsSymbolLayerV2Utils::decodeColor( props["gradient_color"] );
454+
}
455+
else if ( props.contains( "color" ) )
456+
{
457+
color = QgsSymbolLayerV2Utils::decodeColor( props["color"] );
458+
}
408459
if ( props.contains( "gradient_color2" ) )
460+
{
409461
color2 = QgsSymbolLayerV2Utils::decodeColor( props["gradient_color2"] );
462+
}
463+
410464
if ( props.contains( "reference_point1" ) )
411465
referencePoint1 = QgsSymbolLayerV2Utils::decodePoint( props["reference_point1"] );
412466
if ( props.contains( "reference_point1_iscentroid" ) )
@@ -417,6 +471,7 @@ QgsSymbolLayerV2* QgsGradientFillSymbolLayerV2::create( const QgsStringMap& prop
417471
refPoint2IsCentroid = props["reference_point2_iscentroid"].toInt();
418472
if ( props.contains( "angle" ) )
419473
angle = props["angle"].toDouble();
474+
420475
if ( props.contains( "offset" ) )
421476
offset = QgsSymbolLayerV2Utils::decodePoint( props["offset"] );
422477

@@ -764,7 +819,7 @@ void QgsGradientFillSymbolLayerV2::renderPolygon( const QPolygonF& points, QList
764819
QgsStringMap QgsGradientFillSymbolLayerV2::properties() const
765820
{
766821
QgsStringMap map;
767-
map["gradient_color"] = QgsSymbolLayerV2Utils::encodeColor( mColor );
822+
map["color"] = QgsSymbolLayerV2Utils::encodeColor( mColor );
768823
map["gradient_color2"] = QgsSymbolLayerV2Utils::encodeColor( mColor2 );
769824
map["color_type"] = QString::number( mGradientColorType );
770825
map["type"] = QString::number( mGradientType );
@@ -870,12 +925,23 @@ QgsSymbolLayerV2* QgsShapeburstFillSymbolLayerV2::create( const QgsStringMap& pr
870925
}
871926
if ( props.contains( "shapeburst_color" ) )
872927
{
928+
//pre 2.5 projects used "shapeburst_color"
873929
color = QgsSymbolLayerV2Utils::decodeColor( props["shapeburst_color"] );
874930
}
931+
else if ( props.contains( "color" ) )
932+
{
933+
color = QgsSymbolLayerV2Utils::decodeColor( props["color"] );
934+
}
935+
875936
if ( props.contains( "shapeburst_color2" ) )
876937
{
938+
//pre 2.5 projects used "shapeburst_color2"
877939
color2 = QgsSymbolLayerV2Utils::decodeColor( props["shapeburst_color2"] );
878940
}
941+
else if ( props.contains( "gradient_color2" ) )
942+
{
943+
color2 = QgsSymbolLayerV2Utils::decodeColor( props["gradient_color2"] );
944+
}
879945
if ( props.contains( "blur_radius" ) )
880946
{
881947
blurRadius = props["blur_radius"].toInt();
@@ -1328,8 +1394,8 @@ void QgsShapeburstFillSymbolLayerV2::dtArrayToQImage( double * array, QImage *im
13281394
QgsStringMap QgsShapeburstFillSymbolLayerV2::properties() const
13291395
{
13301396
QgsStringMap map;
1331-
map["shapeburst_color"] = QgsSymbolLayerV2Utils::encodeColor( mColor );
1332-
map["shapeburst_color2"] = QgsSymbolLayerV2Utils::encodeColor( mColor2 );
1397+
map["color"] = QgsSymbolLayerV2Utils::encodeColor( mColor );
1398+
map["gradient_color2"] = QgsSymbolLayerV2Utils::encodeColor( mColor2 );
13331399
map["color_type"] = QString::number( mColorType );
13341400
map["blur_radius"] = QString::number( mBlurRadius );
13351401
map["use_whole_shape"] = QString::number( mUseWholeShape );
@@ -1677,16 +1743,39 @@ QgsSymbolLayerV2* QgsSVGFillSymbolLayer::create( const QgsStringMap& properties
16771743
//svg parameters
16781744
if ( properties.contains( "svgFillColor" ) )
16791745
{
1746+
//pre 2.5 projects used "svgFillColor"
16801747
symbolLayer->setSvgFillColor( QgsSymbolLayerV2Utils::decodeColor( properties["svgFillColor"] ) );
16811748
}
1749+
else if ( properties.contains( "color" ) )
1750+
{
1751+
symbolLayer->setSvgFillColor( QgsSymbolLayerV2Utils::decodeColor( properties["color"] ) );
1752+
}
16821753
if ( properties.contains( "svgOutlineColor" ) )
16831754
{
1755+
//pre 2.5 projects used "svgOutlineColor"
16841756
symbolLayer->setSvgOutlineColor( QgsSymbolLayerV2Utils::decodeColor( properties["svgOutlineColor"] ) );
16851757
}
1758+
else if ( properties.contains( "outline_color" ) )
1759+
{
1760+
symbolLayer->setSvgOutlineColor( QgsSymbolLayerV2Utils::decodeColor( properties["outline_color"] ) );
1761+
}
1762+
else if ( properties.contains( "line_color" ) )
1763+
{
1764+
symbolLayer->setSvgOutlineColor( QgsSymbolLayerV2Utils::decodeColor( properties["line_color"] ) );
1765+
}
16861766
if ( properties.contains( "svgOutlineWidth" ) )
16871767
{
1768+
//pre 2.5 projects used "svgOutlineWidth"
16881769
symbolLayer->setSvgOutlineWidth( properties["svgOutlineWidth"].toDouble() );
16891770
}
1771+
else if ( properties.contains( "outline_width" ) )
1772+
{
1773+
symbolLayer->setSvgOutlineWidth( properties["outline_width"].toDouble() );
1774+
}
1775+
else if ( properties.contains( "line_width" ) )
1776+
{
1777+
symbolLayer->setSvgOutlineWidth( properties["line_width"].toDouble() );
1778+
}
16901779

16911780
//units
16921781
if ( properties.contains( "pattern_width_unit" ) )
@@ -1829,9 +1918,9 @@ QgsStringMap QgsSVGFillSymbolLayer::properties() const
18291918
map.insert( "angle", QString::number( mAngle ) );
18301919

18311920
//svg parameters
1832-
map.insert( "svgFillColor", QgsSymbolLayerV2Utils::encodeColor( mSvgFillColor ) );
1833-
map.insert( "svgOutlineColor", QgsSymbolLayerV2Utils::encodeColor( mSvgOutlineColor ) );
1834-
map.insert( "svgOutlineWidth", QString::number( mSvgOutlineWidth ) );
1921+
map.insert( "color", QgsSymbolLayerV2Utils::encodeColor( mSvgFillColor ) );
1922+
map.insert( "outline_color", QgsSymbolLayerV2Utils::encodeColor( mSvgOutlineColor ) );
1923+
map.insert( "outline_width", QString::number( mSvgOutlineWidth ) );
18351924

18361925
//units
18371926
map.insert( "pattern_width_unit", QgsSymbolLayerV2Utils::encodeOutputUnit( mPatternWidthUnit ) );
@@ -2195,8 +2284,13 @@ QgsSymbolLayerV2* QgsLinePatternFillSymbolLayer::create( const QgsStringMap& pro
21952284

21962285
if ( properties.contains( "lineangle" ) )
21972286
{
2287+
//pre 2.5 projects used "lineangle"
21982288
lineAngle = properties["lineangle"].toDouble();
21992289
}
2290+
else if ( properties.contains( "angle" ) )
2291+
{
2292+
lineAngle = properties["angle"].toDouble();
2293+
}
22002294
patternLayer->setLineAngle( lineAngle );
22012295

22022296
if ( properties.contains( "distance" ) )
@@ -2207,14 +2301,31 @@ QgsSymbolLayerV2* QgsLinePatternFillSymbolLayer::create( const QgsStringMap& pro
22072301

22082302
if ( properties.contains( "linewidth" ) )
22092303
{
2304+
//pre 2.5 projects used "linewidth"
22102305
lineWidth = properties["linewidth"].toDouble();
22112306
}
2307+
else if ( properties.contains( "outline_width" ) )
2308+
{
2309+
lineWidth = properties["outline_width"].toDouble();
2310+
}
2311+
else if ( properties.contains( "line_width" ) )
2312+
{
2313+
lineWidth = properties["line_width"].toDouble();
2314+
}
22122315
patternLayer->setLineWidth( lineWidth );
22132316

22142317
if ( properties.contains( "color" ) )
22152318
{
22162319
color = QgsSymbolLayerV2Utils::decodeColor( properties["color"] );
22172320
}
2321+
else if ( properties.contains( "outline_color" ) )
2322+
{
2323+
color = QgsSymbolLayerV2Utils::decodeColor( properties["outline_color"] );
2324+
}
2325+
else if ( properties.contains( "line_color" ) )
2326+
{
2327+
color = QgsSymbolLayerV2Utils::decodeColor( properties["line_color"] );
2328+
}
22182329
patternLayer->setColor( color );
22192330

22202331
if ( properties.contains( "offset" ) )
@@ -2236,6 +2347,10 @@ QgsSymbolLayerV2* QgsLinePatternFillSymbolLayer::create( const QgsStringMap& pro
22362347
{
22372348
patternLayer->setLineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["line_width_unit"] ) );
22382349
}
2350+
else if ( properties.contains( "outline_width_unit" ) )
2351+
{
2352+
patternLayer->setLineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( properties["outline_width_unit"] ) );
2353+
}
22392354
if ( properties.contains( "line_width_map_unit_scale" ) )
22402355
{
22412356
patternLayer->setLineWidthMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( properties["line_width_map_unit_scale"] ) );
@@ -2590,9 +2705,9 @@ void QgsLinePatternFillSymbolLayer::stopRender( QgsSymbolV2RenderContext & )
25902705
QgsStringMap QgsLinePatternFillSymbolLayer::properties() const
25912706
{
25922707
QgsStringMap map;
2593-
map.insert( "lineangle", QString::number( mLineAngle ) );
2708+
map.insert( "angle", QString::number( mLineAngle ) );
25942709
map.insert( "distance", QString::number( mDistance ) );
2595-
map.insert( "linewidth", QString::number( mLineWidth ) );
2710+
map.insert( "line_width", QString::number( mLineWidth ) );
25962711
map.insert( "color", QgsSymbolLayerV2Utils::encodeColor( mColor ) );
25972712
map.insert( "offset", QString::number( mOffset ) );
25982713
map.insert( "distance_unit", QgsSymbolLayerV2Utils::encodeOutputUnit( mDistanceUnit ) );

‎src/core/symbology-ng/qgslinesymbollayerv2.cpp

Lines changed: 51 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -80,17 +80,59 @@ QgsSymbolLayerV2* QgsSimpleLineSymbolLayerV2::create( const QgsStringMap& props
8080
double width = DEFAULT_SIMPLELINE_WIDTH;
8181
Qt::PenStyle penStyle = DEFAULT_SIMPLELINE_PENSTYLE;
8282

83-
if ( props.contains( "color" ) )
83+
if ( props.contains( "line_color" ) )
84+
{
85+
color = QgsSymbolLayerV2Utils::decodeColor( props["line_color"] );
86+
}
87+
else if ( props.contains( "outline_color" ) )
88+
{
89+
color = QgsSymbolLayerV2Utils::decodeColor( props["outline_color"] );
90+
}
91+
else if ( props.contains( "color" ) )
92+
{
93+
//pre 2.5 projects used "color"
8494
color = QgsSymbolLayerV2Utils::decodeColor( props["color"] );
85-
if ( props.contains( "width" ) )
95+
}
96+
if ( props.contains( "line_width" ) )
97+
{
98+
width = props["line_width"].toDouble();
99+
}
100+
else if ( props.contains( "outline_width" ) )
101+
{
102+
width = props["outline_width"].toDouble();
103+
}
104+
else if ( props.contains( "width" ) )
105+
{
106+
//pre 2.5 projects used "width"
86107
width = props["width"].toDouble();
87-
if ( props.contains( "penstyle" ) )
108+
}
109+
if ( props.contains( "line_style" ) )
110+
{
111+
penStyle = QgsSymbolLayerV2Utils::decodePenStyle( props["line_style"] );
112+
}
113+
else if ( props.contains( "outline_style" ) )
114+
{
115+
penStyle = QgsSymbolLayerV2Utils::decodePenStyle( props["outline_style"] );
116+
}
117+
else if ( props.contains( "penstyle" ) )
118+
{
88119
penStyle = QgsSymbolLayerV2Utils::decodePenStyle( props["penstyle"] );
89-
120+
}
90121

91122
QgsSimpleLineSymbolLayerV2* l = new QgsSimpleLineSymbolLayerV2( color, width, penStyle );
92-
if ( props.contains( "width_unit" ) )
123+
if ( props.contains( "line_width_unit" ) )
124+
{
125+
l->setWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["line_width_unit"] ) );
126+
}
127+
else if ( props.contains( "outline_width_unit" ) )
128+
{
129+
l->setWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["outline_width_unit"] ) );
130+
}
131+
else if ( props.contains( "width_unit" ) )
132+
{
133+
//pre 2.5 projects used "width_unit"
93134
l->setWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["width_unit"] ) );
135+
}
94136
if ( props.contains( "offset" ) )
95137
l->setOffset( props["offset"].toDouble() );
96138
if ( props.contains( "offset_unit" ) )
@@ -285,11 +327,11 @@ void QgsSimpleLineSymbolLayerV2::renderPolyline( const QPolygonF& points, QgsSym
285327
QgsStringMap QgsSimpleLineSymbolLayerV2::properties() const
286328
{
287329
QgsStringMap map;
288-
map["color"] = QgsSymbolLayerV2Utils::encodeColor( mColor );
289-
map["width"] = QString::number( mWidth );
290-
map["width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mWidthUnit );
330+
map["line_color"] = QgsSymbolLayerV2Utils::encodeColor( mColor );
331+
map["line_width"] = QString::number( mWidth );
332+
map["line_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mWidthUnit );
291333
map["width_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mWidthMapUnitScale );
292-
map["penstyle"] = QgsSymbolLayerV2Utils::encodePenStyle( mPenStyle );
334+
map["line_style"] = QgsSymbolLayerV2Utils::encodePenStyle( mPenStyle );
293335
map["joinstyle"] = QgsSymbolLayerV2Utils::encodePenJoinStyle( mPenJoinStyle );
294336
map["capstyle"] = QgsSymbolLayerV2Utils::encodePenCapStyle( mPenCapStyle );
295337
map["offset"] = QString::number( mOffset );

‎src/core/symbology-ng/qgsmarkersymbollayerv2.cpp

Lines changed: 66 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -77,7 +77,18 @@ QgsSymbolLayerV2* QgsSimpleMarkerSymbolLayerV2::create( const QgsStringMap& prop
7777
if ( props.contains( "color" ) )
7878
color = QgsSymbolLayerV2Utils::decodeColor( props["color"] );
7979
if ( props.contains( "color_border" ) )
80+
{
81+
//pre 2.5 projects use "color_border"
8082
borderColor = QgsSymbolLayerV2Utils::decodeColor( props["color_border"] );
83+
}
84+
else if ( props.contains( "outline_color" ) )
85+
{
86+
borderColor = QgsSymbolLayerV2Utils::decodeColor( props["outline_color"] );
87+
}
88+
else if ( props.contains( "line_color" ) )
89+
{
90+
borderColor = QgsSymbolLayerV2Utils::decodeColor( props["line_color"] );
91+
}
8192
if ( props.contains( "size" ) )
8293
size = props["size"].toDouble();
8394
if ( props.contains( "angle" ) )
@@ -101,14 +112,26 @@ QgsSymbolLayerV2* QgsSimpleMarkerSymbolLayerV2::create( const QgsStringMap& prop
101112
{
102113
m->setOutlineStyle( QgsSymbolLayerV2Utils::decodePenStyle( props["outline_style"] ) );
103114
}
115+
else if ( props.contains( "line_style" ) )
116+
{
117+
m->setOutlineStyle( QgsSymbolLayerV2Utils::decodePenStyle( props["line_style"] ) );
118+
}
104119
if ( props.contains( "outline_width" ) )
105120
{
106121
m->setOutlineWidth( props["outline_width"].toDouble() );
107122
}
123+
else if ( props.contains( "line_width" ) )
124+
{
125+
m->setOutlineWidth( props["line_width"].toDouble() );
126+
}
108127
if ( props.contains( "outline_width_unit" ) )
109128
{
110129
m->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["outline_width_unit"] ) );
111130
}
131+
if ( props.contains( "line_width_unit" ) )
132+
{
133+
m->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["line_width_unit"] ) );
134+
}
112135
if ( props.contains( "outline_width_map_unit_scale" ) )
113136
{
114137
m->setOutlineWidthMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["outline_width_map_unit_scale"] ) );
@@ -588,7 +611,7 @@ QgsStringMap QgsSimpleMarkerSymbolLayerV2::properties() const
588611
QgsStringMap map;
589612
map["name"] = mName;
590613
map["color"] = QgsSymbolLayerV2Utils::encodeColor( mColor );
591-
map["color_border"] = QgsSymbolLayerV2Utils::encodeColor( mBorderColor );
614+
map["outline_color"] = QgsSymbolLayerV2Utils::encodeColor( mBorderColor );
592615
map["size"] = QString::number( mSize );
593616
map["size_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mSizeUnit );
594617
map["size_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mSizeMapUnitScale );
@@ -1009,7 +1032,8 @@ QgsSymbolLayerV2* QgsSvgMarkerSymbolLayerV2::create( const QgsStringMap& props )
10091032
QgsSvgMarkerSymbolLayerV2* m = new QgsSvgMarkerSymbolLayerV2( name, size, angle, scaleMethod );
10101033

10111034
//we only check the svg default parameters if necessary, since it could be expensive
1012-
if ( !props.contains( "fill" ) && !props.contains( "outline" ) && !props.contains( "outline-width" ) )
1035+
if ( !props.contains( "fill" ) && !props.contains( "color" ) && !props.contains( "outline" ) &&
1036+
!props.contains( "outline_color" ) && !props.contains( "outline-width" ) && !props.contains( "outline_width" ) )
10131037
{
10141038
QColor fillColor, outlineColor;
10151039
double outlineWidth;
@@ -1040,13 +1064,50 @@ QgsSymbolLayerV2* QgsSvgMarkerSymbolLayerV2::create( const QgsStringMap& props )
10401064
if ( props.contains( "offset_map_unit_scale" ) )
10411065
m->setOffsetMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["offset_map_unit_scale"] ) );
10421066
if ( props.contains( "fill" ) )
1067+
{
1068+
//pre 2.5 projects used "fill"
10431069
m->setFillColor( QColor( props["fill"] ) );
1070+
}
1071+
else if ( props.contains( "color" ) )
1072+
{
1073+
m->setFillColor( QColor( props["color"] ) );
1074+
}
10441075
if ( props.contains( "outline" ) )
1076+
{
1077+
//pre 2.5 projects used "outline"
10451078
m->setOutlineColor( QColor( props["outline"] ) );
1079+
}
1080+
else if ( props.contains( "outline_color" ) )
1081+
{
1082+
m->setOutlineColor( QColor( props["outline_color"] ) );
1083+
}
1084+
else if ( props.contains( "line_color" ) )
1085+
{
1086+
m->setOutlineColor( QColor( props["line_color"] ) );
1087+
}
1088+
10461089
if ( props.contains( "outline-width" ) )
1090+
{
1091+
//pre 2.5 projects used "outline-width"
10471092
m->setOutlineWidth( props["outline-width"].toDouble() );
1093+
}
1094+
else if ( props.contains( "outline_width" ) )
1095+
{
1096+
m->setOutlineWidth( props["outline_width"].toDouble() );
1097+
}
1098+
else if ( props.contains( "line_width" ) )
1099+
{
1100+
m->setOutlineWidth( props["line_width"].toDouble() );
1101+
}
1102+
10481103
if ( props.contains( "outline_width_unit" ) )
1104+
{
10491105
m->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["outline_width_unit"] ) );
1106+
}
1107+
else if ( props.contains( "line_width_unit" ) )
1108+
{
1109+
m->setOutlineWidthUnit( QgsSymbolLayerV2Utils::decodeOutputUnit( props["line_width_unit"] ) );
1110+
}
10501111
if ( props.contains( "outline_width_map_unit_scale" ) )
10511112
m->setOutlineWidthMapUnitScale( QgsSymbolLayerV2Utils::decodeMapUnitScale( props["outline_width_map_unit_scale"] ) );
10521113

@@ -1302,9 +1363,9 @@ QgsStringMap QgsSvgMarkerSymbolLayerV2::properties() const
13021363
map["offset_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOffsetUnit );
13031364
map["offset_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOffsetMapUnitScale );
13041365
map["scale_method"] = QgsSymbolLayerV2Utils::encodeScaleMethod( mScaleMethod );
1305-
map["fill"] = mFillColor.name();
1306-
map["outline"] = mOutlineColor.name();
1307-
map["outline-width"] = QString::number( mOutlineWidth );
1366+
map["color"] = mFillColor.name();
1367+
map["outline_color"] = mOutlineColor.name();
1368+
map["outline_width"] = QString::number( mOutlineWidth );
13081369
map["outline_width_unit"] = QgsSymbolLayerV2Utils::encodeOutputUnit( mOutlineWidthUnit );
13091370
map["outline_width_map_unit_scale"] = QgsSymbolLayerV2Utils::encodeMapUnitScale( mOutlineWidthMapUnitScale );
13101371
map["horizontal_anchor_point"] = QString::number( mHorizontalAnchorPoint );

‎src/gui/symbology-ng/qgslayerpropertieswidget.cpp

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -176,7 +176,8 @@ void QgsLayerPropertiesWidget::layerTypeChanged()
176176
return;
177177

178178
// change layer to a new (with different type)
179-
QgsSymbolLayerV2* newLayer = am->createSymbolLayer( QgsStringMap() );
179+
// base new layer on existing layer's properties
180+
QgsSymbolLayerV2* newLayer = am->createSymbolLayer( layer->properties() );
180181
if ( newLayer == NULL )
181182
return;
182183

0 commit comments

Comments
 (0)
Please sign in to comment.