Skip to content

Commit

Permalink
Fix sublayer group name handling for sources which are directories
Browse files Browse the repository at this point in the history
not files (e.g. .gdb databases)

Fixes #44181
  • Loading branch information
nyalldawson committed Jul 19, 2021
1 parent 0dc4870 commit cfbc227
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 5 deletions.
8 changes: 4 additions & 4 deletions src/app/qgsprovidersublayersdialog.cpp
Expand Up @@ -99,14 +99,14 @@ QgsProviderSublayersDialog::QgsProviderSublayersDialog( const QString &uri, cons
QgsGui::enableAutoGeometryRestore( this );

const QFileInfo fileInfo( filePath );
mFilePath = fileInfo.isFile() && fileInfo.exists() ? filePath : QString();
mFileName = !mFilePath.isEmpty() ? fileInfo.fileName() : QString();
mFilePath = ( fileInfo.isFile() || fileInfo.isDir() ) && fileInfo.exists() ? filePath : QString();
const QString fileName = !mFilePath.isEmpty() ? QgsProviderUtils::suggestLayerNameFromFilePath( mFilePath ) : QString();

setWindowTitle( mFileName.isEmpty() ? tr( "Select Items to Add" ) : QStringLiteral( "%1 | %2" ).arg( tr( "Select Items to Add" ), mFileName ) );
setWindowTitle( fileName.isEmpty() ? tr( "Select Items to Add" ) : QStringLiteral( "%1 | %2" ).arg( tr( "Select Items to Add" ), fileName ) );

mLblFilePath->setText( QStringLiteral( "<a href=\"%1\">%2</a>" )
.arg( QUrl::fromLocalFile( mFilePath ).toString(), QDir::toNativeSeparators( QFileInfo( mFilePath ).canonicalFilePath() ) ) );
mLblFilePath->setVisible( !mFileName.isEmpty() );
mLblFilePath->setVisible( !mFilePath.isEmpty() );
mLblFilePath->setWordWrap( true );
mLblFilePath->setTextInteractionFlags( Qt::TextBrowserInteraction );
connect( mLblFilePath, &QLabel::linkActivated, this, [ = ]( const QString & link )
Expand Down
1 change: 0 additions & 1 deletion src/app/qgsprovidersublayersdialog.h
Expand Up @@ -78,7 +78,6 @@ class QgsProviderSublayersDialog : public QDialog, private Ui::QgsProviderSublay
QgsProviderSublayerProxyModel *mProxyModel = nullptr;
QPointer< QgsProviderSublayerTask > mTask;
QString mFilePath;
QString mFileName;
bool mBlockSelectionChanges = false;

};
Expand Down

0 comments on commit cfbc227

Please sign in to comment.