diff --git a/python/core/qgsdataitem.sip b/python/core/qgsdataitem.sip index bf1484bffc5..f7ac491fc5e 100644 --- a/python/core/qgsdataitem.sip +++ b/python/core/qgsdataitem.sip @@ -533,6 +533,9 @@ Check if the given path is hidden from the browser model :rtype: bool %End + virtual QList actions(); + + public slots: virtual void childrenCreated(); diff --git a/src/core/qgsdataitem.cpp b/src/core/qgsdataitem.cpp index a4e76a68a16..991b62ed93c 100644 --- a/src/core/qgsdataitem.cpp +++ b/src/core/qgsdataitem.cpp @@ -27,6 +27,7 @@ #include #include #include +#include #include "qgis.h" #include "qgsdataitem.h" @@ -852,6 +853,18 @@ bool QgsDirectoryItem::hiddenPath( const QString &path ) return ( idx > -1 ); } +QList QgsDirectoryItem::actions() +{ + QList result; + QAction *openFolder = new QAction( tr( "Open Directory…" ), this ); + connect( openFolder, &QAction::triggered, this, [ = ] + { + QDesktopServices::openUrl( QUrl::fromLocalFile( mDirPath ) ); + } ); + result << openFolder; + return result; +} + void QgsDirectoryItem::childrenCreated() { diff --git a/src/core/qgsdataitem.h b/src/core/qgsdataitem.h index 94cc92df1bb..14c9ccf22c0 100644 --- a/src/core/qgsdataitem.h +++ b/src/core/qgsdataitem.h @@ -476,6 +476,8 @@ class CORE_EXPORT QgsDirectoryItem : public QgsDataCollectionItem //! Check if the given path is hidden from the browser model static bool hiddenPath( const QString &path ); + QList actions() override; + public slots: virtual void childrenCreated() override;