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 |
}
|