Skip to content
Permalink
Browse files

recurse svg directories

git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11853 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef
jef committed Oct 26, 2009
1 parent 8bb6da6 commit 9add8e2cdc36a68892441d8bd50f3994d439ed65
Showing with 17 additions and 35 deletions.
  1. +6 −1 python/core/qgsapplication.sip
  2. +7 −27 src/core/symbology/qgsmarkercatalogue.cpp
  3. +4 −7 src/core/symbology/qgssymbol.cpp
@@ -148,7 +148,12 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
//! Returns the path to the srs.db file.
static const QString srsDbFilePath();

//! Returns the path to the svg directory.
//! Returns the paths to the svg directories.
//! @note added in 1.4
static const QStringList svgPaths();

//! Returns the path to the applications svg paths
//! @note deprecated
static const QString svgPath();

//! Returns the path to the application prefix directory.
@@ -74,38 +74,18 @@ void QgsMarkerCatalogue::refreshList()

for(int i=0; i<svgPaths.size(); i++)
{
// TODO recursive ?
QDir dir( svgPaths[i] );

//
// First check the root dir of this path for svgs
//
QStringList dl1 = dir.entryList( QStringList( "*.svg" ), QDir::Files );
for ( QStringList::iterator it1 = dl1.begin(); it1 != dl1.end(); ++it1 )
foreach(QString item, dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
{
// TODO test if it is correct SVG
mList.append( "svg:" + dir.path() + "/" + *it1 );
svgPaths.insert(i+1, dir.path() + "/" + item);
}

//
// Now check in any nested dirs for svgs
//
QStringList dl = dir.entryList( QDir::Dirs );
for ( QStringList::iterator it = dl.begin(); it != dl.end(); ++it )
QgsDebugMsg( QString( "Looking for svgs in %1" ).arg( dir.path() ) );

foreach(QString item, dir.entryList( QStringList( "*.svg" ), QDir::Files ) )
{
QgsDebugMsg( QString( "Looking for svgs in %1" ).arg( svgPaths[i] + *it ) );

if ( *it == "." || *it == ".." ) continue;

QDir dir2( svgPaths[i] + *it );

QStringList dl2 = dir2.entryList( QStringList( "*.svg" ), QDir::Files );

for ( QStringList::iterator it2 = dl2.begin(); it2 != dl2.end(); ++it2 )
{
// TODO test if it is correct SVG
mList.append( "svg:" + svgPaths[i] + *it + "/" + *it2 );
}
// TODO test if it is correct SVG
mList.append( "svg:" + dir.path() + "/" + item );
}
}

@@ -217,20 +217,17 @@ void QgsSymbol::setNamedPointSymbol( QString name )
QgsDebugMsg( "\n\n\n *** Svg Symbol not found on fs ***" );
QgsDebugMsg( "Name: " + name );
//see if we can resolve the problem...
//by using the qgis svg dir from this local machine
//one day when user specified svg are allowed we need
//to adjust this logic probably...
//

QStringList svgPaths = QgsApplication::svgPaths();

for( int i=0; i<svgPaths.size(); i++)
{
QgsDebugMsg( "SvgPath: " + svgPaths[i] );
QFileInfo myInfo( myTempName );
QString myFileName = myInfo.fileName(); // foo.svg
QString myLowestDir = myInfo.dir().dirName();
QString myLocalPath = svgPaths[i] + QDir::separator() +
myLowestDir + QDir::separator() +
myFileName;
QString myLocalPath = svgPaths[i] + "/" + myLowestDir + "/" + myFileName;

QgsDebugMsg( "Alternative svg path: " + myLocalPath );
if ( QFile( myLocalPath ).exists() )
{

0 comments on commit 9add8e2

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