Skip to content

Commit

Permalink
recurse svg directories
Browse files Browse the repository at this point in the history
git-svn-id: http://svn.osgeo.org/qgis/trunk/qgis@11853 c8812cc2-4d05-0410-92ff-de0c093fc19c
  • Loading branch information
jef committed Oct 26, 2009
1 parent 8bb6da6 commit 9add8e2
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 35 deletions.
7 changes: 6 additions & 1 deletion python/core/qgsapplication.sip
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand Down
34 changes: 7 additions & 27 deletions src/core/symbology/qgsmarkercatalogue.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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 );
}
}

Expand Down
11 changes: 4 additions & 7 deletions src/core/symbology/qgssymbol.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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() )
{
Expand Down

0 comments on commit 9add8e2

Please sign in to comment.