Skip to content
Permalink
Browse files
Special handling for aigrid base/group names
  • Loading branch information
nyalldawson committed Jul 12, 2021
1 parent ecd185f commit e01dc5d769ef58138a307e1291b6931a0db3250a
Showing with 26 additions and 14 deletions.
  1. +8 −13 src/app/qgisapp.cpp
  2. +7 −0 src/app/qgsprovidersublayersdialog.cpp
  3. +11 −1 src/providers/mdal/qgsmdalprovider.cpp
@@ -7619,6 +7619,14 @@ bool QgisApp::openLayer( const QString &fileName, bool allowInteractive )

const QFileInfo info( fileName );
QString base = info.completeBaseName();

// special handling for .adf files -- use directory as base name, not the unhelpful .adf file name
if ( info.suffix().compare( QLatin1String( "adf" ), Qt::CaseInsensitive ) == 0 )
{
const QString dirName = info.path();
base = QFileInfo( dirName ).completeBaseName();
}

if ( settings.value( QStringLiteral( "qgis/formatLayerName" ), false ).toBool() )
{
base = QgsMapLayer::formatLayerName( base );
@@ -7631,19 +7639,6 @@ bool QgisApp::openLayer( const QString &fileName, bool allowInteractive )
CPLPopErrorHandler();

#if 0
// try to load it as raster
if ( QgsRasterLayer::isValidRasterFileName( fileName ) )
{
// open .adf as a directory
if ( fileName.endsWith( QLatin1String( ".adf" ), Qt::CaseInsensitive ) )
{
QString dirName = fileInfo.path();
ok = addRasterLayer( dirName, QFileInfo( dirName ).completeBaseName() );
}
else
ok = addRasterLayer( fileName, fileInfo.completeBaseName() );
}

// try as a vector
if ( !ok || fileName.endsWith( QLatin1String( ".gpkg" ), Qt::CaseInsensitive ) )
{
@@ -207,6 +207,13 @@ QString QgsProviderSublayersDialog::groupName() const
const QFileInfo fi( mFilePath );
QString res = fi.completeBaseName();

// special handling for .adf files -- use directory as group name, not the unhelpful .adf file name
if ( fi.suffix().compare( QLatin1String( "adf" ), Qt::CaseInsensitive ) == 0 )
{
const QString dirName = fi.path();
res = QFileInfo( dirName ).completeBaseName();
}

QgsSettings settings;
if ( settings.value( QStringLiteral( "qgis/formatLayerName" ), false ).toBool() )
{
@@ -1090,7 +1090,17 @@ QList<QgsProviderSublayerDetails> QgsMdalProviderMetadata::querySublayers( const
if ( details.name().isEmpty() )
{
// use file name as layer name if no layer name available from mdal
details.setName( info.completeBaseName() );

// special handling for .adf files -- use directory as group name, not the unhelpful .adf file name
if ( info.suffix().compare( QLatin1String( "adf" ), Qt::CaseInsensitive ) == 0 )
{
const QString dirName = info.path();
details.setName( QFileInfo( dirName ).completeBaseName() );
}
else
{
details.setName( info.completeBaseName() );
}
}

res << details;

0 comments on commit e01dc5d

Please sign in to comment.