@@ -1280,7 +1280,6 @@ QVector<QgsDataItem*> QgsZipItem::createChildren()
1280
1280
{
1281
1281
QVector<QgsDataItem*> children;
1282
1282
QString tmpPath;
1283
- QString childPath;
1284
1283
QSettings settings;
1285
1284
QString scanZipSetting = settings.value ( " /qgis/scanZipInBrowser2" , " basic" ).toString ();
1286
1285
@@ -1330,7 +1329,6 @@ QVector<QgsDataItem*> QgsZipItem::createChildren()
1330
1329
if ( item )
1331
1330
{
1332
1331
QgsDebugMsgLevel ( " loaded item" , 3 );
1333
- childPath = tmpPath;
1334
1332
children.append ( item );
1335
1333
break ;
1336
1334
}
@@ -1343,12 +1341,6 @@ QVector<QgsDataItem*> QgsZipItem::createChildren()
1343
1341
1344
1342
}
1345
1343
1346
- if ( children.size () == 1 )
1347
- {
1348
- // save the name of the only child so we can get a normal data item from it
1349
- mPath = childPath;
1350
- }
1351
-
1352
1344
return children;
1353
1345
}
1354
1346
@@ -1361,7 +1353,6 @@ QgsDataItem* QgsZipItem::itemFromPath( QgsDataItem* parent, QString filePath, QS
1361
1353
{
1362
1354
QSettings settings;
1363
1355
QString scanZipSetting = settings.value ( " /qgis/scanZipInBrowser2" , " basic" ).toString ();
1364
- QString vsiPath = path;
1365
1356
int zipFileCount = 0 ;
1366
1357
QStringList zipFileList;
1367
1358
QFileInfo fileInfo ( filePath );
@@ -1416,14 +1407,21 @@ QgsDataItem* QgsZipItem::itemFromPath( QgsDataItem* parent, QString filePath, QS
1416
1407
// if 1 or 0 child found, create a single data item using the normal path or the full path given by QgsZipItem
1417
1408
else
1418
1409
{
1410
+ QString vsiPath = vsiPrefix + filePath;
1419
1411
if ( zipItem )
1420
1412
{
1421
- vsiPath = zipItem->path ();
1413
+ if ( zipItem->children ().size () == 1 )
1414
+ {
1415
+ // take the name of the only child so we can get a normal data item from it
1416
+ QgsLayerItem *layerItem = qobject_cast<QgsLayerItem*>( zipItem->children ().first () );
1417
+ if ( layerItem )
1418
+ vsiPath = layerItem->uri ();
1419
+ }
1422
1420
zipFileCount = zipFileList.count ();
1423
1421
delete zipItem;
1424
1422
}
1425
1423
1426
- QgsDebugMsgLevel ( QString ( " will try to create a normal dataItem from path = %2 or %3" ).arg ( path ).arg ( vsiPath ), 3 );
1424
+ QgsDebugMsgLevel ( QString ( " will try to create a normal dataItem from filePath = %2 or vsiPath = %3" ).arg ( filePath ).arg ( vsiPath ), 3 );
1427
1425
1428
1426
// try to open using registered providers (gdal and ogr)
1429
1427
for ( int i = 0 ; i < mProviderNames .size (); i++ )
@@ -1437,7 +1435,7 @@ QgsDataItem* QgsZipItem::itemFromPath( QgsDataItem* parent, QString filePath, QS
1437
1435
// (e.g. testZipItemVectorTransparency(), second test)
1438
1436
if (( mProviderNames [i] == " ogr" ) ||
1439
1437
( mProviderNames [i] == " gdal" && zipFileCount == 1 ) )
1440
- item = dataItem ( path , parent );
1438
+ item = dataItem ( filePath , parent );
1441
1439
// try with /vsizip/
1442
1440
if ( ! item )
1443
1441
item = dataItem ( vsiPath, parent );
0 commit comments