Skip to content

Commit

Permalink
allow users to unhide paths directly from browser (fix #22290)
Browse files Browse the repository at this point in the history
  • Loading branch information
alexbruy committed Aug 18, 2020
1 parent 97fd45a commit e4b7076
Showing 1 changed file with 45 additions and 0 deletions.
45 changes: 45 additions & 0 deletions src/app/browser/qgsinbuiltdataitemproviders.cpp
Expand Up @@ -174,6 +174,51 @@ void QgsAppDirectoryItemGuiProvider::populateContextMenu( QgsDataItem *item, QMe
} );
menu->addAction( hideAction );

QMenu *hiddenMenu = new QMenu( tr( "Hidden items" ), menu );
int count = 0;
const QStringList hiddenPathList = settings.value( QStringLiteral( "/browser/hiddenPaths" ) ).toStringList();
for ( const QString &path : hiddenPathList )
{
QAction *action = new QAction( path, hiddenMenu );
connect( action, &QAction::triggered, this, [ = ]
{
QString path = qobject_cast<QAction *>( sender() )->text();
QgsSettings s;
QStringList pathsList = s.value( QStringLiteral( "/browser/hiddenPaths" ) ).toStringList();
pathsList.removeAll( path );
s.setValue( QStringLiteral( "/browser/hiddenPaths" ), pathsList );

// get parent path and refresh corresponding node
int idx = path.lastIndexOf( QStringLiteral( "/" ) );
if ( idx != -1 && path.count( QStringLiteral( "/" ) ) > 1 )
{
path = path.left( idx );
QgisApp::instance()->browserModel()->refresh( path );
}
else
{
// top-level (drive or root) node
QgisApp::instance()->browserModel()->refreshDrives();
}
} );
hiddenMenu->addAction( action );
count += 1;
if ( count == 5 )
{
break;
}
}
QAction *moreAction = new QAction( tr( "Show More…" ), hiddenMenu );
connect( moreAction, &QAction::triggered, this, [ = ]
{
QgisApp::instance()->showOptionsDialog( QgisApp::instance(), QStringLiteral( "mOptionsPageDataSources" ) );
} );
hiddenMenu->addAction( moreAction );
if ( count > 0 )
{
menu->addMenu( hiddenMenu );
}

QAction *fastScanAction = new QAction( tr( "Fast Scan this Directory" ), menu );
connect( fastScanAction, &QAction::triggered, this, [ = ]
{
Expand Down

0 comments on commit e4b7076

Please sign in to comment.