Skip to content

Commit

Permalink
Never ever show .txt files as datasets in browser
Browse files Browse the repository at this point in the history
They are only used for geospatial data in extremely rare cases
and are predominantly just noise in the browser
  • Loading branch information
nyalldawson committed Mar 9, 2021
1 parent ec6aa20 commit 5a467e1
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 1 deletion.
8 changes: 8 additions & 0 deletions src/core/providers/gdal/qgsgdaldataitems.cpp
Expand Up @@ -183,6 +183,14 @@ QgsDataItem *QgsGdalDataItemProvider::createDataItem( const QString &pathIn, Qgs
tmpPath.chop( 3 );
QFileInfo info( tmpPath );
QString suffix = info.suffix().toLower();

if ( suffix == QLatin1String( "txt" ) )
{
// never ever show .txt files as datasets in browser -- they are only used for geospatial data in extremely rare cases
// and are predominantly just noise in the browser
return nullptr;
}

// extract basename with extension
info.setFile( path );
QString name = info.fileName();
Expand Down
9 changes: 8 additions & 1 deletion src/core/providers/ogr/qgsogrdataitems.cpp
Expand Up @@ -577,7 +577,14 @@ QgsDataItem *QgsOgrDataItemProvider::createDataItem( const QString &pathIn, QgsD
QFileInfo info( tmpPath );
QString suffix = info.suffix().toLower();

// GDAL 3.1 Shapefile driver directly handles .shp.zip files
if ( suffix == QLatin1String( "txt" ) )
{
// never ever show .txt files as datasets in browser -- they are only used for geospatial data in extremely rare cases
// and are predominantly just noise in the browser
return nullptr;
}

// GDAL 3.1 Shapefile driver directly handles .shp.zip files
if ( path.endsWith( QLatin1String( ".shp.zip" ), Qt::CaseInsensitive ) &&
GDALIdentifyDriver( path.toUtf8().constData(), nullptr ) )
{
Expand Down

0 comments on commit 5a467e1

Please sign in to comment.