Skip to content
Permalink
Browse files
Show drive labels in browser for drive items whenever available
Refs #44021
  • Loading branch information
nyalldawson committed Jul 1, 2021
1 parent 998c6c1 commit e972e78331da2c38e1c4f8d4732006c7ea370d9a
Showing with 9 additions and 2 deletions.
  1. +9 −2 src/core/browser/qgsbrowsermodel.cpp
@@ -17,6 +17,7 @@
#include <QStyle>
#include <QtConcurrentMap>
#include <QUrl>
#include <QStorageInfo>

#include "qgis.h"
#include "qgsapplication.h"
@@ -120,7 +121,10 @@ void QgsBrowserModel::addRootItems()
if ( QgsDirectoryItem::hiddenPath( path ) )
continue;

QgsDirectoryItem *item = new QgsDirectoryItem( nullptr, path, path, path, QStringLiteral( "special:Drives" ) );
const QString driveName = QStorageInfo( path ).displayName();
const QString name = driveName.isEmpty() ? path : QStringLiteral( "%1 (%2)" ).arg( path, driveName );

QgsDirectoryItem *item = new QgsDirectoryItem( nullptr, name, path, path, QStringLiteral( "special:Drives" ) );
item->setSortKey( QStringLiteral( " 3 %1" ).arg( path ) );
mDriveItems.insert( path, item );

@@ -502,7 +506,10 @@ void QgsBrowserModel::refreshDrives()
// does an item for this drive already exist?
if ( !mDriveItems.contains( path ) )
{
QgsDirectoryItem *item = new QgsDirectoryItem( nullptr, path, path, path, QStringLiteral( "special:Drives" ) );
const QString driveName = QStorageInfo( path ).displayName();
const QString name = driveName.isEmpty() ? path : QStringLiteral( "%1 (%2)" ).arg( path, driveName );

QgsDirectoryItem *item = new QgsDirectoryItem( nullptr, name, path, path, QStringLiteral( "special:Drives" ) );
item->setSortKey( QStringLiteral( " 3 %1" ).arg( path ) );

mDriveItems.insert( path, item );

0 comments on commit e972e78

Please sign in to comment.