Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
[browser] Provide mime data for directory items
Allows them to be dragged and dropped to file widgets
  • Loading branch information
nyalldawson committed Feb 8, 2019
1 parent 2857f58 commit 35ddb3b
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 0 deletions.
3 changes: 3 additions & 0 deletions python/core/auto_generated/qgsdataitem.sip.in
Expand Up @@ -599,6 +599,9 @@ Constructor.

virtual QWidget *paramWidget() /Factory/;

virtual bool hasDragEnabled() const;
virtual QgsMimeDataUtils::Uri mimeUri() const;


static bool hiddenPath( const QString &path );
%Docstring
Expand Down
9 changes: 9 additions & 0 deletions src/core/qgsdataitem.cpp
Expand Up @@ -1021,6 +1021,15 @@ QWidget *QgsDirectoryItem::paramWidget()
return new QgsDirectoryParamWidget( mPath );
}

QgsMimeDataUtils::Uri QgsDirectoryItem::mimeUri() const
{
QgsMimeDataUtils::Uri u;
u.layerType = QStringLiteral( "directory" );
u.name = mName;
u.uri = mDirPath;
return u;
}

QgsDirectoryParamWidget::QgsDirectoryParamWidget( const QString &path, QWidget *parent )
: QTreeWidget( parent )
{
Expand Down
2 changes: 2 additions & 0 deletions src/core/qgsdataitem.h
Expand Up @@ -611,6 +611,8 @@ class CORE_EXPORT QgsDirectoryItem : public QgsDataCollectionItem
bool equal( const QgsDataItem *other ) override;
QIcon icon() override;
QWidget *paramWidget() override SIP_FACTORY;
bool hasDragEnabled() const override { return true; }
QgsMimeDataUtils::Uri mimeUri() const override;

//! Check if the given path is hidden from the browser model
static bool hiddenPath( const QString &path );
Expand Down

0 comments on commit 35ddb3b

Please sign in to comment.