Skip to content

Commit

Permalink
Don't prompt multiple times to add vector/raster sublayers from a gpkg
Browse files Browse the repository at this point in the history
dragged from the browser

Instead just prompt once with a unified dialog showing all sublayers
  • Loading branch information
nyalldawson committed Jul 19, 2021
1 parent 2ac6672 commit cc17c90
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 17 deletions.
6 changes: 5 additions & 1 deletion src/app/qgisapp.cpp
Expand Up @@ -2012,7 +2012,11 @@ void QgisApp::handleDropUriList( const QgsMimeDataUtils::UriList &lst )

QString uri = crsAndFormatAdjustedLayerUri( u.uri, u.supportedCrs, u.supportedFormats );

if ( u.layerType == QLatin1String( "vector" ) )
if ( u.layerType == QLatin1String( "collection" ) )
{
openLayer( uri, true );
}
else if ( u.layerType == QLatin1String( "vector" ) )
{
addVectorLayer( uri, u.name, u.providerKey );
}
Expand Down
12 changes: 4 additions & 8 deletions src/core/providers/ogr/qgsgeopackagedataitems.cpp
Expand Up @@ -399,12 +399,8 @@ bool QgsGeoPackageCollectionItem::hasDragEnabled() const

QgsMimeDataUtils::UriList QgsGeoPackageCollectionItem::mimeUris() const
{
QgsMimeDataUtils::Uri vectorUri;
vectorUri.providerKey = QStringLiteral( "ogr" );
vectorUri.uri = path().replace( QLatin1String( "gpkg:/" ), QString() );
vectorUri.layerType = QStringLiteral( "vector" );
QgsMimeDataUtils::Uri rasterUri { vectorUri };
rasterUri.layerType = QStringLiteral( "raster" );
rasterUri.providerKey = QStringLiteral( "gdal" );
return { vectorUri, rasterUri };
QgsMimeDataUtils::Uri collectionUri;
collectionUri.uri = path().replace( QLatin1String( "gpkg:/" ), QString() );
collectionUri.layerType = QStringLiteral( "collection" );
return { collectionUri };
}
12 changes: 4 additions & 8 deletions src/core/providers/ogr/qgsogrdataitems.cpp
Expand Up @@ -457,14 +457,10 @@ bool QgsOgrDataCollectionItem::hasDragEnabled() const

QgsMimeDataUtils::UriList QgsOgrDataCollectionItem::mimeUris() const
{
QgsMimeDataUtils::Uri vectorUri;
vectorUri.providerKey = QStringLiteral( "ogr" );
vectorUri.uri = path();
vectorUri.layerType = QStringLiteral( "vector" );
QgsMimeDataUtils::Uri rasterUri { vectorUri };
rasterUri.layerType = QStringLiteral( "raster" );
rasterUri.providerKey = QStringLiteral( "gdal" );
return { vectorUri, rasterUri };
QgsMimeDataUtils::Uri collectionUri;
collectionUri.uri = path();
collectionUri.layerType = QStringLiteral( "collection" );
return { collectionUri };
}

QgsAbstractDatabaseProviderConnection *QgsOgrDataCollectionItem::databaseConnection() const
Expand Down

0 comments on commit cc17c90

Please sign in to comment.