Skip to content
Permalink
Browse files

Added tooltip, icon and custom name to the svg groups tree

.

.
  • Loading branch information
tecoholic committed Jul 9, 2012
1 parent b9b70f6 commit bb0b6e4f47941e65bd9ca4f69e56da059a204271
Showing with 46 additions and 4 deletions.
  1. +15 −3 src/core/symbology-ng/qgsmarkersymbollayerv2.cpp
  2. +31 −1 src/gui/symbology-ng/qgssymbollayerv2widget.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;
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 )
@@ -536,6 +536,7 @@ QgsSvgMarkerSymbolLayerV2Widget::QgsSvgMarkerSymbolLayerV2Widget( const QgsVecto
#include <QTime>
#include <QAbstractListModel>
#include <QPixmapCache>
#include <QStyle>

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 );

0 comments on commit bb0b6e4

Please sign in to comment.
You can’t perform that action at this time.