Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix browser handling of auxiliary metadata files (*.shp.xml and *.tif…
….xml) (#10697)
  • Loading branch information
etiennesky committed Jun 24, 2014
1 parent 1949fd7 commit b261f57
Show file tree
Hide file tree
Showing 3 changed files with 23 additions and 6 deletions.
14 changes: 10 additions & 4 deletions src/app/qgsbrowserdockwidget.cpp
Expand Up @@ -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;
}
}
Expand All @@ -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;
}
}
Expand Down
9 changes: 8 additions & 1 deletion src/providers/gdal/qgsgdaldataitems.cpp
Expand Up @@ -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 ) )
Expand Down
6 changes: 5 additions & 1 deletion src/providers/ogr/qgsogrdataitems.cpp
Expand Up @@ -280,14 +280,18 @@ 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" ) )
return 0;
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.
Expand Down

0 comments on commit b261f57

Please sign in to comment.