diff --git a/src/core/symbology-ng/qgsmarkersymbollayerv2.cpp b/src/core/symbology-ng/qgsmarkersymbollayerv2.cpp index d102fafb713..521daff6458 100644 --- a/src/core/symbology-ng/qgsmarkersymbollayerv2.cpp +++ b/src/core/symbology-ng/qgsmarkersymbollayerv2.cpp @@ -798,14 +798,26 @@ QStringList QgsSvgMarkerSymbolLayerV2::listSvgFiles() QStringList QgsSvgMarkerSymbolLayerV2::listSvgFilesAt( QString directory ) { // TODO anything that applies for the listSvgFiles() applies this also - QStringList list; - QDir dir( directory ); - foreach( QString item, dir.entryList( QStringList( "*.svg" ), QDir::Files ) ) + QStringList list; + QStringList svgPaths; + svgPaths.append( directory ); + + for ( int i = 0; i < svgPaths.size(); i++ ) { - list.append( dir.path() + "/" + item ); + QDir dir( svgPaths[i] ); + foreach( QString item, dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) ) + { + svgPaths.insert( i + 1, dir.path() + "/" + item ); + } + + foreach( QString item, dir.entryList( QStringList( "*.svg" ), QDir::Files ) ) + { + list.append( dir.path() + "/" + item ); + } } return list; + } QString QgsSvgMarkerSymbolLayerV2::symbolNameToPath( QString name ) diff --git a/src/gui/symbology-ng/qgssymbollayerv2widget.cpp b/src/gui/symbology-ng/qgssymbollayerv2widget.cpp index 0ca61c1d4d9..4eeefe31bce 100644 --- a/src/gui/symbology-ng/qgssymbollayerv2widget.cpp +++ b/src/gui/symbology-ng/qgssymbollayerv2widget.cpp @@ -536,6 +536,7 @@ QgsSvgMarkerSymbolLayerV2Widget::QgsSvgMarkerSymbolLayerV2Widget( const QgsVecto #include #include #include +#include class QgsSvgListModel : public QAbstractListModel { @@ -602,10 +603,25 @@ class QgsSvgGroupsModel : public QStandardItemModel for ( int i = 0; i < svgPaths.size(); i++ ) { QDir dir( svgPaths[i] ); - QStandardItem *baseGroup = new QStandardItem( dir.dirName() ); + QStandardItem *baseGroup; + + if ( dir.path().contains( QgsApplication::pkgDataPath() ) ) + { + baseGroup = new QStandardItem( QString( "App Symbols" ) ); + } + else if ( dir.path().contains( QgsApplication::qgisSettingsDirPath() ) ) + { + baseGroup = new QStandardItem( QString( "User Symbols" ) ); + } + else + { + baseGroup = new QStandardItem( dir.dirName() ); + } baseGroup->setData( QVariant( svgPaths[i] ) ); baseGroup->setEditable( false ); baseGroup->setCheckable( false ); + baseGroup->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) ); + baseGroup->setToolTip( dir.path() ); parentItem->appendRow( baseGroup ); createTree( baseGroup ); QgsDebugMsg( QString( "SVG base path %1: %2" ).arg( i ).arg( baseGroup->data().toString() ) ); @@ -621,6 +637,8 @@ class QgsSvgGroupsModel : public QStandardItemModel group->setData( QVariant( parentDir.path() + "/" + item ) ); group->setEditable( false ); group->setCheckable( false ); + group->setToolTip( parentDir.path() + "/" + item ); + group->setIcon( QgsApplication::style()->standardIcon( QStyle::SP_DirIcon ) ); parentGroup->appendRow( group ); createTree( group ); } @@ -631,6 +649,12 @@ void QgsSvgMarkerSymbolLayerV2Widget::populateList() { QgsSvgGroupsModel* g = new QgsSvgGroupsModel( viewGroups ); viewGroups->setModel( g ); + // Set the tree expanded at the first level + int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) ); + for ( int i = 0; i < rows; i++ ) + { + viewGroups->setExpanded( g->indexFromItem( g->item( i ) ), true ); + } // Initally load the icons in the List view without any grouping QgsSvgListModel* m = new QgsSvgListModel( viewImages ); @@ -960,6 +984,12 @@ void QgsSVGFillSymbolLayerWidget::insertIcons() { QgsSvgGroupsModel* g = new QgsSvgGroupsModel( mSvgTreeView ); mSvgTreeView->setModel( g ); + // Set the tree expanded at the first level + int rows = g->rowCount( g->indexFromItem( g->invisibleRootItem() ) ); + for ( int i = 0; i < rows; i++ ) + { + mSvgTreeView->setExpanded( g->indexFromItem( g->item( i ) ), true ); + } QgsSvgListModel* m = new QgsSvgListModel( mSvgListView ); mSvgListView->setModel( m );