mirror of
https://github.com/qgis/QGIS.git
synced 2025-02-28 00:17:30 -05:00
Added tooltip, icon and custom name to the svg groups tree
. .
This commit is contained in:
parent
b9b70f6fdd
commit
bb0b6e4f47
@ -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 )
|
||||
|
@ -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 );
|
||||
|
Loading…
x
Reference in New Issue
Block a user