Skip to content

Commit 4848b31

Browse files
committedMar 24, 2023
Fix missing shortcut to open folders in change data source dialog for some layer types
1 parent bd53161 commit 4848b31

File tree

1 file changed

+15
-2
lines changed

1 file changed

+15
-2
lines changed
 

‎src/app/qgisapp.cpp

Lines changed: 15 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7521,8 +7521,21 @@ void QgisApp::changeDataSource( QgsMapLayer *layer )
75217521
const QString path = sourceParts.value( QStringLiteral( "path" ) ).toString();
75227522
const QString closestPath = QFile::exists( path ) ? path : QgsFileUtils::findClosestExistingPath( path );
75237523
dlg.expandPath( closestPath );
7524-
source.replace( path, QStringLiteral( "<a href=\"%1\">%2</a>" ).arg( QUrl::fromLocalFile( closestPath ).toString(),
7525-
path ) );
7524+
if ( source.contains( path ) )
7525+
{
7526+
source.replace( path, QStringLiteral( "<a href=\"%1\">%2</a>" ).arg( QUrl::fromLocalFile( closestPath ).toString(),
7527+
path ) );
7528+
}
7529+
else
7530+
{
7531+
// source might contain the original path using a "QUrl::FullyEncoded" encoding
7532+
const QString uriEncodedPath = QUrl( path ).toString( QUrl::FullyEncoded );
7533+
if ( source.contains( uriEncodedPath ) )
7534+
{
7535+
source.replace( uriEncodedPath, QStringLiteral( "<a href=\"%1\">%2</a>" ).arg( QUrl::fromLocalFile( closestPath ).toString(),
7536+
uriEncodedPath ) );
7537+
}
7538+
}
75267539
}
75277540
dlg.setDescription( tr( "Original source URI: %1" ).arg( source ) );
75287541

0 commit comments

Comments
 (0)
Please sign in to comment.