Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Added tooltip, icon and custom name to the svg groups tree
.

.
  • Loading branch information
Arunmozhi committed Jul 9, 2012
1 parent b9b70f6 commit bb0b6e4
Show file tree
Hide file tree
Showing 2 changed files with 46 additions and 4 deletions.
18 changes: 15 additions & 3 deletions src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
Expand Up @@ -798,14 +798,26 @@ QStringList QgsSvgMarkerSymbolLayerV2::listSvgFiles()
QStringList QgsSvgMarkerSymbolLayerV2::listSvgFilesAt( QString directory )
{
// TODO anything that applies for the listSvgFiles() applies this also

QStringList list;
QStringList svgPaths;
svgPaths.append( directory );

QDir dir( directory );
foreach( QString item, dir.entryList( QStringList( "*.svg" ), QDir::Files ) )
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 )
Expand Down
32 changes: 31 additions & 1 deletion src/gui/symbology-ng/qgssymbollayerv2widget.cpp
Expand Up @@ -536,6 +536,7 @@ QgsSvgMarkerSymbolLayerV2Widget::QgsSvgMarkerSymbolLayerV2Widget( const QgsVecto
#include <QTime>
#include <QAbstractListModel>
#include <QPixmapCache>
#include <QStyle>

class QgsSvgListModel : public QAbstractListModel
{
Expand Down Expand Up @@ -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() ) );
Expand All @@ -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 );
}
Expand All @@ -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 );
Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit bb0b6e4

Please sign in to comment.