Skip to content

Commit

Permalink
[browser] Gpkg and other container types can be dragged to the map
Browse files Browse the repository at this point in the history
to allow layers to be added from them

Otherwise it's impossible to select multiple gpkg files from the
browser to add them all at once, and users have to add them
one-by-one
  • Loading branch information
nyalldawson committed Sep 16, 2020
1 parent 7e8c7b3 commit 0234d4e
Show file tree
Hide file tree
Showing 4 changed files with 33 additions and 0 deletions.
14 changes: 14 additions & 0 deletions src/core/providers/ogr/qgsgeopackagedataitems.cpp
Expand Up @@ -394,3 +394,17 @@ bool QgsGeoPackageCollectionItem::layerCollection() const
{
return true;
}

bool QgsGeoPackageCollectionItem::hasDragEnabled() const
{
return true;
}

QgsMimeDataUtils::Uri QgsGeoPackageCollectionItem::mimeUri() const
{
QgsMimeDataUtils::Uri u;
u.providerKey = QStringLiteral( "ogr" );
u.uri = path();
u.layerType = QStringLiteral( "vector" );
return u;
}
2 changes: 2 additions & 0 deletions src/core/providers/ogr/qgsgeopackagedataitems.h
Expand Up @@ -65,6 +65,8 @@ class CORE_EXPORT QgsGeoPackageCollectionItem : public QgsDataCollectionItem
// QgsDataItem interface
public:
bool layerCollection() const override;
bool hasDragEnabled() const override;
QgsMimeDataUtils::Uri mimeUri() const override;
};


Expand Down
14 changes: 14 additions & 0 deletions src/core/providers/ogr/qgsogrdataitems.cpp
Expand Up @@ -442,6 +442,20 @@ bool QgsOgrDataCollectionItem::createConnection( const QString &name, const QStr
return saveConnection( path, ogrDriverName );
}

bool QgsOgrDataCollectionItem::hasDragEnabled() const
{
return true;
}

QgsMimeDataUtils::Uri QgsOgrDataCollectionItem::mimeUri() const
{
QgsMimeDataUtils::Uri u;
u.providerKey = QStringLiteral( "ogr" );
u.uri = path();
u.layerType = QStringLiteral( "vector" );
return u;
}

// ---------------------------------------------------------------------------

QString QgsOgrDataItemProvider::name()
Expand Down
3 changes: 3 additions & 0 deletions src/core/providers/ogr/qgsogrdataitems.h
Expand Up @@ -129,6 +129,9 @@ class CORE_EXPORT QgsOgrDataCollectionItem final: public QgsDataCollectionItem
* \param ogrDriverName the OGR/GDAL driver name (e.g. "GPKG")
*/
static bool createConnection( const QString &name, const QString &extensions, const QString &ogrDriverName );

bool hasDragEnabled() const override;
QgsMimeDataUtils::Uri mimeUri() const override;
};

//! Provider for OGR root data item
Expand Down

0 comments on commit 0234d4e

Please sign in to comment.