Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
Show drive labels in browser for drive items whenever available
Refs #44021
  • Loading branch information
nyalldawson committed Jul 1, 2021
1 parent 998c6c1 commit e972e78
Showing 1 changed file with 9 additions and 2 deletions.
11 changes: 9 additions & 2 deletions src/core/browser/qgsbrowsermodel.cpp
Expand Up @@ -17,6 +17,7 @@
#include <QStyle>
#include <QtConcurrentMap>
#include <QUrl>
#include <QStorageInfo>

#include "qgis.h"
#include "qgsapplication.h"
Expand Down Expand Up @@ -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 );

Expand Down Expand Up @@ -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 );
Expand Down

0 comments on commit e972e78

Please sign in to comment.