Skip to content

Commit 876e54b

Browse files
committedApr 23, 2015
[GRASS] use always forward slash as dir separator
1 parent 95e5a4f commit 876e54b

File tree

1 file changed

+11
-9
lines changed

1 file changed

+11
-9
lines changed
 

‎src/providers/grass/qgsgrassprovidermodule.cpp

Lines changed: 11 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -39,7 +39,7 @@ QgsGrassLocationItem::~QgsGrassLocationItem() {}
3939
bool QgsGrassLocationItem::isLocation( QString path )
4040
{
4141
//QgsDebugMsg( "path = " + path );
42-
return QFile::exists( path + QDir::separator() + "PERMANENT" + QDir::separator() + "DEFAULT_WIND" );
42+
return QFile::exists( path + "/" + "PERMANENT" + "/" + "DEFAULT_WIND" );
4343
}
4444

4545
QVector<QgsDataItem*>QgsGrassLocationItem::createChildren()
@@ -55,7 +55,7 @@ QVector<QgsDataItem*>QgsGrassLocationItem::createChildren()
5555

5656
if ( QgsGrassMapsetItem::isMapset( path ) )
5757
{
58-
QgsGrassMapsetItem * mapset = new QgsGrassMapsetItem( this, path, mPath + QDir::separator() + name );
58+
QgsGrassMapsetItem * mapset = new QgsGrassMapsetItem( this, path, mPath + "/" + name );
5959
mapsets.append( mapset );
6060
}
6161
}
@@ -79,7 +79,7 @@ QgsGrassMapsetItem::~QgsGrassMapsetItem() {}
7979

8080
bool QgsGrassMapsetItem::isMapset( QString path )
8181
{
82-
return QFile::exists( path + QDir::separator() + "WIND" );
82+
return QFile::exists( path + "/WIND" );
8383
}
8484

8585
QVector<QgsDataItem*> QgsGrassMapsetItem::createChildren()
@@ -94,7 +94,7 @@ QVector<QgsDataItem*> QgsGrassMapsetItem::createChildren()
9494
{
9595
QStringList layerNames = QgsGrass::vectorLayers( mGisdbase, mLocation, mName, name );
9696

97-
QString mapPath = mPath + QDir::separator() + "vector" + QDir::separator() + name;
97+
QString mapPath = mPath + "/vector/" + name;
9898

9999
QgsDataCollectionItem *map = 0;
100100
if ( layerNames.size() > 1 )
@@ -104,7 +104,9 @@ QVector<QgsDataItem*> QgsGrassMapsetItem::createChildren()
104104
}
105105
foreach ( QString layerName, layerNames )
106106
{
107-
QString uri = mDirPath + QDir::separator() + name + QDir::separator() + layerName;
107+
// don't use QDir::separator(), windows work with '/' and backslash may be lost if
108+
// somewhere not properly escaped (there was bug in QgsMimeDataUtils for example)
109+
QString uri = mDirPath + "/" + name + "/" + layerName;
108110
QgsLayerItem::LayerType layerType = QgsLayerItem::Vector;
109111
QString typeName = layerName.split( "_" )[1];
110112
QString baseLayerName = layerName.split( "_" )[0];
@@ -116,7 +118,7 @@ QVector<QgsDataItem*> QgsGrassMapsetItem::createChildren()
116118
else if ( typeName == "polygon" )
117119
layerType = QgsLayerItem::Polygon;
118120

119-
QString layerPath = mapPath + QDir::separator() + layerName;
121+
QString layerPath = mapPath + "/" + layerName;
120122
if ( !map )
121123
{
122124
/* This may happen (one layer only) in GRASS 7 with points (no topo layers) */
@@ -141,8 +143,8 @@ QVector<QgsDataItem*> QgsGrassMapsetItem::createChildren()
141143

142144
foreach ( QString name, rasterNames )
143145
{
144-
QString path = mPath + QDir::separator() + "raster" + QDir::separator() + name;
145-
QString uri = mDirPath + QDir::separator() + "cellhd" + QDir::separator() + name;
146+
QString path = mPath + "/" + "raster" + "/" + name;
147+
QString uri = mDirPath + "/" + "cellhd" + "/" + name;
146148
QgsDebugMsg( "uri = " + uri );
147149

148150
QgsLayerItem *layer = new QgsLayerItem( this, name, path, uri, QgsLayerItem::Raster, "grassraster" );
@@ -188,7 +190,7 @@ QGISEXTERN QgsDataItem * dataItem( QString theDirPath, QgsDataItem* parentItem )
188190
dir.cdUp();
189191
path = dir.path();
190192
}
191-
path = path + QDir::separator() + "grass:" + dirName;
193+
path = path + "/" + "grass:" + dirName;
192194
QgsGrassLocationItem * location = new QgsGrassLocationItem( parentItem, theDirPath, path );
193195
return location;
194196
}

0 commit comments

Comments
 (0)
Please sign in to comment.