fix browser handling of auxiliary metadata files (*.shp.xml and *.tif.xml) (#10697)

This commit is contained in:
Etienne Tourigny 2014-06-24 14:33:31 -03:00
parent 1949fd7585
commit b261f57d06
3 changed files with 23 additions and 6 deletions

View File

@ -551,8 +551,11 @@ void QgsBrowserDockWidget::showProperties( )
QgsRasterLayer* layer = new QgsRasterLayer( layerItem->uri(), layerItem->uri(), layerItem->providerKey() );
if ( layer != NULL )
{
layerCrs = layer->crs();
layerMetadata = layer->metadata();
if ( layer->isValid() )
{
layerCrs = layer->crs();
layerMetadata = layer->metadata();
}
delete layer;
}
}
@ -562,8 +565,11 @@ void QgsBrowserDockWidget::showProperties( )
QgsVectorLayer* layer = new QgsVectorLayer( layerItem->uri(), layerItem->name(), layerItem->providerKey() );
if ( layer != NULL )
{
layerCrs = layer->crs();
layerMetadata = layer->metadata();
if ( layer->isValid() )
{
layerCrs = layer->crs();
layerMetadata = layer->metadata();
}
delete layer;
}
}

View File

@ -191,11 +191,18 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
QgsDebugMsgLevel( "wildcards: " + wildcards.join( " " ), 2 );
}
// skip *.aux.xml files (GDAL auxilary metadata files)
// 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 ) )

View File

@ -280,7 +280,8 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
QStringList myExtensions = fileExtensions();
// skip *.aux.xml files (GDAL auxilary metadata files) and .shp.xml files (ESRI metadata)
// 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 ) &&
!myExtensions.contains( "aux.xml" ) )
@ -288,6 +289,9 @@ QGISEXTERN QgsDataItem * dataItem( QString thePath, QgsDataItem* parentItem )
if ( thePath.endsWith( ".shp.xml", Qt::CaseInsensitive ) &&
!myExtensions.contains( "shp.xml" ) )
return 0;
if ( thePath.endsWith( ".tif.xml", Qt::CaseInsensitive ) &&
!myExtensions.contains( "tif.xml" ) )
return 0;
// We have to filter by extensions, otherwise e.g. all Shapefile files are displayed
// because OGR drive can open also .dbf, .shx.