@@ -74,7 +74,7 @@ QgsSvgCache::QgsSvgCache(): mTotalSize( 0 )
74
74
QgsSvgCache::~QgsSvgCache ()
75
75
{
76
76
QMultiHash< QString, QgsSvgCacheEntry* >::iterator it = mEntryLookup .begin ();
77
- for ( ; it != mEntryLookup .end (); ++it )
77
+ for ( ; it != mEntryLookup .end (); ++it )
78
78
{
79
79
delete it.value ();
80
80
}
@@ -94,7 +94,7 @@ const QImage& QgsSvgCache::svgAsImage( const QString& file, double size, const Q
94
94
}
95
95
96
96
// debug: display current cache usage
97
- QgsDebugMsg (" cache size: " + QString::number ( mTotalSize ) );
97
+ QgsDebugMsg ( " cache size: " + QString::number ( mTotalSize ) );
98
98
99
99
// set entry timestamp to current time
100
100
currentEntry->lastUsed = QDateTime::currentDateTime ();
@@ -115,7 +115,7 @@ const QPicture& QgsSvgCache::svgAsPicture( const QString& file, double size, con
115
115
}
116
116
117
117
// debug: display current cache usage
118
- QgsDebugMsg (" cache size: " + QString::number ( mTotalSize ) );
118
+ QgsDebugMsg ( " cache size: " + QString::number ( mTotalSize ) );
119
119
120
120
// set entry timestamp to current time
121
121
currentEntry->lastUsed = QDateTime::currentDateTime ();
@@ -155,15 +155,15 @@ void QgsSvgCache::containsParams( const QString& path, bool& hasFillParam, bool&
155
155
156
156
// there are surely faster ways to get this information
157
157
QString content = svgDoc.toString ();
158
- if ( content.contains (" param(fill" ) )
158
+ if ( content.contains ( " param(fill" ) )
159
159
{
160
160
hasFillParam = true ;
161
161
}
162
- if ( content.contains (" param(outline" ) )
162
+ if ( content.contains ( " param(outline" ) )
163
163
{
164
164
hasOutlineParam = true ;
165
165
}
166
- if ( content.contains (" param(outline-width)" ) )
166
+ if ( content.contains ( " param(outline-width)" ) )
167
167
{
168
168
hasOutlineWidthParam = true ;
169
169
}
@@ -215,7 +215,7 @@ void QgsSvgCache::cacheImage( QgsSvgCacheEntry* entry )
215
215
r.render ( &p );
216
216
217
217
entry->image = image;
218
- mTotalSize += (image->width () * image->height () * 32 );
218
+ mTotalSize += ( image->width () * image->height () * 32 );
219
219
}
220
220
221
221
void QgsSvgCache::cachePicture ( QgsSvgCacheEntry *entry )
@@ -284,18 +284,54 @@ void QgsSvgCache::replaceElemParams( QDomElement& elem, const QColor& fill, cons
284
284
for ( int i = 0 ; i < nAttributes; ++i )
285
285
{
286
286
QDomAttr attribute = attributes.item ( i ).toAttr ();
287
- QString value = attribute. value ();
288
- if ( value. startsWith ( " param(fill) " ) )
287
+ // e.g. style="fill:param(fill);param(stroke)"
288
+ if ( attribute. name (). compare ( " style " , Qt::CaseInsensitive ) == 0 )
289
289
{
290
- elem.setAttribute ( attribute.name (), fill.name () );
290
+ // entries separated by ';'
291
+ QString newAttributeString;
292
+
293
+ QStringList entryList = attribute.value ().split ( ' ;' );
294
+ QStringList::const_iterator entryIt = entryList.constBegin ();
295
+ for ( ; entryIt != entryList.constEnd (); ++entryIt )
296
+ {
297
+ QStringList keyValueSplit = entryIt->split ( ' :' );
298
+ if ( keyValueSplit.size () < 2 )
299
+ {
300
+ continue ;
301
+ }
302
+ QString key = keyValueSplit.at ( 0 );
303
+ QString value = keyValueSplit.at ( 1 );
304
+ if ( value.startsWith ( " param(fill" ) )
305
+ {
306
+ value = fill.name ();
307
+ }
308
+ else if ( value.startsWith ( " param(outline)" ) )
309
+ {
310
+ value = outline.name ();
311
+ }
312
+ else if ( value.startsWith ( " param(outline-width)" ) )
313
+ {
314
+ value = QString::number ( outlineWidth );
315
+ }
316
+ newAttributeString.append ( key + " :" + value + " ;" );
317
+ }
318
+ elem.setAttribute ( attribute.name (), newAttributeString );
291
319
}
292
- else if ( value. startsWith ( " param(outline) " ) )
320
+ else
293
321
{
294
- elem.setAttribute ( attribute.name (), outline.name () );
295
- }
296
- else if ( value.startsWith ( " param(outline-width)" ) )
297
- {
298
- elem.setAttribute ( attribute.name (), QString::number ( outlineWidth ) );
322
+ QString value = attribute.value ();
323
+ if ( value.startsWith ( " param(fill)" ) )
324
+ {
325
+ elem.setAttribute ( attribute.name (), fill.name () );
326
+ }
327
+ else if ( value.startsWith ( " param(outline)" ) )
328
+ {
329
+ elem.setAttribute ( attribute.name (), outline.name () );
330
+ }
331
+ else if ( value.startsWith ( " param(outline-width)" ) )
332
+ {
333
+ elem.setAttribute ( attribute.name (), QString::number ( outlineWidth ) );
334
+ }
299
335
}
300
336
}
301
337
0 commit comments