qgis-svg-markers-custom-dirs.patch

Patch for custom SVG marker dirs support in symbology-ng - jekhor -, 2009-11-30 03:43 AM

Download (2.75 KB)

View differences:

src/gui/symbology-ng/qgssymbollayerv2widget.cpp (working copy)
372 372
  QStandardItemModel* m = new QStandardItemModel( viewImages );
373 373
  viewImages->setModel( m );
374 374

  
375
  QStringList svgPaths = QgsApplication::svgPaths();
375 376
  QString svgPath = QgsApplication::svgPath();
377
  QDir svgBaseDir( svgPath );
376 378
  QSvgRenderer renderer;
377 379
  QPainter painter;
378 380

  
379
  QDir dir( svgPath );
380 381

  
381
  QStringList dl = dir.entryList( QDir::Dirs );
382

  
383
  for ( QStringList::iterator it = dl.begin(); it != dl.end(); ++it )
382
  for ( int i = 0; i < svgPaths.size(); i++ )
384 383
  {
385
    if ( *it == "." || *it == ".." ) continue;
384
    QDir dir( svgPaths[i] );
385
    QString path( svgPaths[i] );
386 386

  
387
    QDir dir2( svgPath + *it );
387
    foreach( QString item, dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
388
    {
389
      svgPaths.insert( i + 1, dir.path() + "/" + item );
390
    }
388 391

  
389
    QStringList dl2 = dir2.entryList( QStringList( "*.svg" ), QDir::Files );
392
    if (svgPaths[i].startsWith(svgPath))
393
    {
394
      path = svgBaseDir.relativeFilePath( svgPaths[i] );
395
    }
390 396

  
391
    for ( QStringList::iterator it2 = dl2.begin(); it2 != dl2.end(); ++it2 )
397
    foreach( QString entry, dir.entryList( QStringList( "*.svg" ), QDir::Files ) )
392 398
    {
393 399
      // TODO test if it is correct SVG
394
      QString entry = *it2;
395 400

  
396 401
      // render SVG file
397
      renderer.load( dir2.filePath( *it2 ) );
402
      renderer.load( dir.filePath( entry ) );
398 403
      QPixmap pixmap( renderer.defaultSize() );
399 404
      pixmap.fill();
400 405
      painter.begin( &pixmap );
......
402 407
      painter.end();
403 408

  
404 409
      // add item
405
      QStandardItem* item = new QStandardItem( QIcon( pixmap ), *it + "/" + entry );
410
      QStandardItem* item = new QStandardItem( QIcon( pixmap ), path + "/" + entry );
406 411
      m->appendRow( item );
407 412
    }
408 413
  }
src/core/symbology-ng/qgsmarkersymbollayerv2.cpp (working copy)
8 8

  
9 9
#include <QPainter>
10 10
#include <QSvgRenderer>
11
#include <QDir>
11 12

  
12 13
#include <cmath>
13 14

  
......
283 284
void QgsSvgMarkerSymbolLayerV2::startRender( QgsRenderContext& context )
284 285
{
285 286
  QString svgPath = QgsApplication::svgPath();
286
  QString file = svgPath + "/" + mName;
287
  QString file = mName;
287 288

  
289
  if ( QDir::isRelativePath( file ) )
290
  {
291
    file = svgPath + "/" + file;
292
  }
293

  
288 294
  QRectF rect( QPointF( -mSize / 2.0, -mSize / 2.0 ), QSizeF( mSize, mSize ) );
289 295
  QSvgRenderer renderer( file );
290 296
  QPainter painter( &mPicture );