Skip to content
Permalink
Browse files

Merge pull request #5220 from nyalldawson/open_folder

[FEATURE] Add 'open directory' action to right click menu for folders in browser dock
  • Loading branch information
nyalldawson committed Sep 20, 2017
2 parents 825a323 + 21fc2e1 commit e6169d85181a2899424b9097222e06fe0c7784b4
Showing with 22 additions and 3 deletions.
  1. +3 −0 python/core/qgsdataitem.sip
  2. +16 −2 src/core/qgsdataitem.cpp
  3. +2 −0 src/core/qgsdataitem.h
  4. +1 −1 src/gui/qgsbrowserdockwidget_p.cpp
@@ -533,6 +533,9 @@ Check if the given path is hidden from the browser model
:rtype: bool
%End

virtual QList<QAction *> actions();



public slots:
virtual void childrenCreated();
@@ -27,6 +27,7 @@
#include <QTreeWidgetItem>
#include <QVector>
#include <QStyle>
#include <QDesktopServices>

#include "qgis.h"
#include "qgsdataitem.h"
@@ -669,7 +670,7 @@ QgsDataCollectionItem::~QgsDataCollectionItem()
//-----------------------------------------------------------------------

QgsDirectoryItem::QgsDirectoryItem( QgsDataItem *parent, const QString &name, const QString &path )
: QgsDataCollectionItem( parent, name, path )
: QgsDataCollectionItem( parent, QDir::toNativeSeparators( name ), path )
, mDirPath( path )
, mRefreshLater( false )
{
@@ -678,7 +679,7 @@ QgsDirectoryItem::QgsDirectoryItem( QgsDataItem *parent, const QString &name, co
}

QgsDirectoryItem::QgsDirectoryItem( QgsDataItem *parent, const QString &name, const QString &dirPath, const QString &path )
: QgsDataCollectionItem( parent, name, path )
: QgsDataCollectionItem( parent, QDir::toNativeSeparators( name ), path )
, mDirPath( dirPath )
, mRefreshLater( false )
{
@@ -688,6 +689,7 @@ QgsDirectoryItem::QgsDirectoryItem( QgsDataItem *parent, const QString &name, co

void QgsDirectoryItem::init()
{
setToolTip( QDir::toNativeSeparators( mDirPath ) );
}

QIcon QgsDirectoryItem::icon()
@@ -852,6 +854,18 @@ bool QgsDirectoryItem::hiddenPath( const QString &path )
return ( idx > -1 );
}

QList<QAction *> QgsDirectoryItem::actions()
{
QList<QAction *> 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()
{
@@ -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<QAction *> actions() override;


public slots:
virtual void childrenCreated() override;
@@ -234,7 +234,7 @@ void QgsBrowserDirectoryProperties::setItem( QgsDataItem *item )
if ( !item )
return;

mPathLabel->setText( directoryItem->dirPath() );
mPathLabel->setText( QDir::toNativeSeparators( directoryItem->dirPath() ) );
mDirectoryWidget = new QgsDirectoryParamWidget( directoryItem->dirPath(), this );
mLayout->addWidget( mDirectoryWidget );
}

0 comments on commit e6169d8

Please sign in to comment.
You can’t perform that action at this time.