Skip to content

Commit da8e398

Browse files
author
jef
committed
recurse svg directories
git-svn-id: http://svn.osgeo.org/qgis/trunk@11853 c8812cc2-4d05-0410-92ff-de0c093fc19c
1 parent 47be6dc commit da8e398

3 files changed

Lines changed: 17 additions & 35 deletions

File tree

‎python/core/qgsapplication.sip‎

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -148,7 +148,12 @@ static void qtgui_UpdatePyArgv(PyObject *argvlist, int argc, char **argv)
148148
//! Returns the path to the srs.db file.
149149
static const QString srsDbFilePath();
150150

151-
//! Returns the path to the svg directory.
151+
//! Returns the paths to the svg directories.
152+
//! @note added in 1.4
153+
static const QStringList svgPaths();
154+
155+
//! Returns the path to the applications svg paths
156+
//! @note deprecated
152157
static const QString svgPath();
153158

154159
//! Returns the path to the application prefix directory.

‎src/core/symbology/qgsmarkercatalogue.cpp‎

Lines changed: 7 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -74,38 +74,18 @@ void QgsMarkerCatalogue::refreshList()
7474

7575
for(int i=0; i<svgPaths.size(); i++)
7676
{
77-
// TODO recursive ?
7877
QDir dir( svgPaths[i] );
79-
80-
//
81-
// First check the root dir of this path for svgs
82-
//
83-
QStringList dl1 = dir.entryList( QStringList( "*.svg" ), QDir::Files );
84-
for ( QStringList::iterator it1 = dl1.begin(); it1 != dl1.end(); ++it1 )
78+
foreach(QString item, dir.entryList( QDir::Dirs | QDir::NoDotAndDotDot ) )
8579
{
86-
// TODO test if it is correct SVG
87-
mList.append( "svg:" + dir.path() + "/" + *it1 );
80+
svgPaths.insert(i+1, dir.path() + "/" + item);
8881
}
8982

90-
//
91-
// Now check in any nested dirs for svgs
92-
//
93-
QStringList dl = dir.entryList( QDir::Dirs );
94-
for ( QStringList::iterator it = dl.begin(); it != dl.end(); ++it )
83+
QgsDebugMsg( QString( "Looking for svgs in %1" ).arg( dir.path() ) );
84+
85+
foreach(QString item, dir.entryList( QStringList( "*.svg" ), QDir::Files ) )
9586
{
96-
QgsDebugMsg( QString( "Looking for svgs in %1" ).arg( svgPaths[i] + *it ) );
97-
98-
if ( *it == "." || *it == ".." ) continue;
99-
100-
QDir dir2( svgPaths[i] + *it );
101-
102-
QStringList dl2 = dir2.entryList( QStringList( "*.svg" ), QDir::Files );
103-
104-
for ( QStringList::iterator it2 = dl2.begin(); it2 != dl2.end(); ++it2 )
105-
{
106-
// TODO test if it is correct SVG
107-
mList.append( "svg:" + svgPaths[i] + *it + "/" + *it2 );
108-
}
87+
// TODO test if it is correct SVG
88+
mList.append( "svg:" + dir.path() + "/" + item );
10989
}
11090
}
11191

‎src/core/symbology/qgssymbol.cpp‎

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -217,20 +217,17 @@ void QgsSymbol::setNamedPointSymbol( QString name )
217217
QgsDebugMsg( "\n\n\n *** Svg Symbol not found on fs ***" );
218218
QgsDebugMsg( "Name: " + name );
219219
//see if we can resolve the problem...
220-
//by using the qgis svg dir from this local machine
221-
//one day when user specified svg are allowed we need
222-
//to adjust this logic probably...
220+
//
221+
223222
QStringList svgPaths = QgsApplication::svgPaths();
224-
225223
for( int i=0; i<svgPaths.size(); i++)
226224
{
227225
QgsDebugMsg( "SvgPath: " + svgPaths[i] );
228226
QFileInfo myInfo( myTempName );
229227
QString myFileName = myInfo.fileName(); // foo.svg
230228
QString myLowestDir = myInfo.dir().dirName();
231-
QString myLocalPath = svgPaths[i] + QDir::separator() +
232-
myLowestDir + QDir::separator() +
233-
myFileName;
229+
QString myLocalPath = svgPaths[i] + "/" + myLowestDir + "/" + myFileName;
230+
234231
QgsDebugMsg( "Alternative svg path: " + myLocalPath );
235232
if ( QFile( myLocalPath ).exists() )
236233
{

0 commit comments

Comments
 (0)