QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem ) { if ( thePath.isEmpty() ) return 0; QFileInfo info( thePath ); if ( info.isFile() ) { // Filter files by extension if ( extensions.isEmpty() ) { QString filterString; buildSupportedRasterFileFilterAndExtensions( filterString, extensions, wildcards ); QgsDebugMsg( "extensions: " + extensions.join( " " ) ); QgsDebugMsg( "wildcards: " + wildcards.join( " " ) ); } if ( extensions.indexOf( info.suffix().toLower() ) < 0 ) { bool matches = false; foreach( QString wildcard, wildcards ) { QRegExp rx( wildcard, Qt::CaseInsensitive, QRegExp::Wildcard ); if ( rx.exactMatch( info.fileName() ) ) { matches = true; break; } } if ( !matches ) return 0; }
QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem ) { if ( thePath.isEmpty() ) return 0; QgsDebugMsgLevel( "thePath = " + thePath, 2 ); // zip settings + info QSettings settings; QString scanZipSetting = settings.value( "/qgis/scanZipInBrowser", "basic" ).toString(); QString vsiPrefix = QgsZipItem::vsiPrefix( thePath ); bool is_vsizip = ( vsiPrefix == "/vsizip/" ); bool is_vsigzip = ( vsiPrefix == "/vsigzip/" ); bool is_vsitar = ( vsiPrefix == "/vsitar/" ); // get suffix, removing .gz if present QString tmpPath = thePath; //path used for testing, not for layer creation if ( is_vsigzip ) tmpPath.chop( 3 ); QFileInfo info( tmpPath ); QString suffix = info.suffix().toLower(); // extract basename with extension info.setFile( thePath ); QString name = info.fileName(); QgsDebugMsgLevel( "thePath= " + thePath + " tmpPath= " + tmpPath + " name= " + name + " suffix= " + suffix + " vsiPrefix= " + vsiPrefix, 3 ); // allow only normal files or VSIFILE items to continue if ( !info.isFile() && vsiPrefix == "" ) return 0; // get supported extensions if ( extensions.isEmpty() ) { buildSupportedRasterFileFilterAndExtensions( filterString, extensions, wildcards ); QgsDebugMsgLevel( "extensions: " + extensions.join( " " ), 2 ); QgsDebugMsgLevel( "wildcards: " + wildcards.join( " " ), 2 ); } // skip *.aux.xml files (GDAL auxilary metadata files) // unless that extension is in the list (*.xml might be though) if ( thePath.endsWith( ".aux.xml", Qt::CaseInsensitive ) && !extensions.contains( "aux.xml" ) ) return 0; // Filter files by extension if ( !extensions.contains( suffix ) ) { bool matches = false; foreach ( QString wildcard, wildcards ) { QRegExp rx( wildcard, Qt::CaseInsensitive, QRegExp::Wildcard ); if ( rx.exactMatch( info.fileName() ) ) { matches = true; break; } }
QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem ) { if ( thePath.isEmpty() ) return 0; QgsDebugMsgLevel( "thePath = " + thePath, 2 ); // zip settings + info QSettings settings; QString scanZipSetting = settings.value( "/qgis/scanZipInBrowser2", "basic" ).toString(); QString vsiPrefix = QgsZipItem::vsiPrefix( thePath ); bool is_vsizip = ( vsiPrefix == "/vsizip/" ); bool is_vsigzip = ( vsiPrefix == "/vsigzip/" ); bool is_vsitar = ( vsiPrefix == "/vsitar/" ); // should we check ext. only? // check if scanItemsInBrowser2 == extension or parent dir in scanItemsFastScanUris // TODO - do this in dir item, but this requires a way to inform which extensions are supported by provider // maybe a callback function or in the provider registry? bool scanExtSetting = false; if (( settings.value( "/qgis/scanItemsInBrowser2", "extension" ).toString() == "extension" ) || ( settings.value( "/qgis/scanItemsFastScanUris", QStringList() ).toStringList().contains( parentItem->path() ) ) || (( is_vsizip || is_vsitar ) && parentItem && parentItem->parent() && settings.value( "/qgis/scanItemsFastScanUris", QStringList() ).toStringList().contains( parentItem->parent()->path() ) ) ) { scanExtSetting = true; } // get suffix, removing .gz if present QString tmpPath = thePath; //path used for testing, not for layer creation if ( is_vsigzip ) tmpPath.chop( 3 ); QFileInfo info( tmpPath ); QString suffix = info.suffix().toLower(); // extract basename with extension info.setFile( thePath ); QString name = info.fileName(); QgsDebugMsgLevel( "thePath= " + thePath + " tmpPath= " + tmpPath + " name= " + name + " suffix= " + suffix + " vsiPrefix= " + vsiPrefix, 3 ); // allow only normal files or VSIFILE items to continue if ( !info.isFile() && vsiPrefix == "" ) return 0; // get supported extensions if ( extensions.isEmpty() ) { buildSupportedRasterFileFilterAndExtensions( filterString, extensions, wildcards ); QgsDebugMsgLevel( "extensions: " + extensions.join( " " ), 2 ); QgsDebugMsgLevel( "wildcards: " + wildcards.join( " " ), 2 ); } // skip *.aux.xml files (GDAL auxilary metadata files), // *.shp.xml files (ESRI metadata) and *.tif.xml files (TIFF metadata) // unless that extension is in the list (*.xml might be though) if ( thePath.endsWith( ".aux.xml", Qt::CaseInsensitive ) && !extensions.contains( "aux.xml" ) ) return 0; if ( thePath.endsWith( ".shp.xml", Qt::CaseInsensitive ) && !extensions.contains( "shp.xml" ) ) return 0; if ( thePath.endsWith( ".tif.xml", Qt::CaseInsensitive ) && !extensions.contains( "tif.xml" ) ) return 0; // Filter files by extension if ( !extensions.contains( suffix ) ) { bool matches = false; foreach ( QString wildcard, wildcards ) { QRegExp rx( wildcard, Qt::CaseInsensitive, QRegExp::Wildcard ); if ( rx.exactMatch( info.fileName() ) ) { matches = true; break; } }