summaryrefslogtreecommitdiffstats
path: root/src/gui/dialogs
diff options
context:
space:
mode:
Diffstat (limited to 'src/gui/dialogs')
-rw-r--r--src/gui/dialogs/qfilesystemmodel.cpp28
-rw-r--r--src/gui/dialogs/qfilesystemmodel_p.h4
2 files changed, 30 insertions, 2 deletions
diff --git a/src/gui/dialogs/qfilesystemmodel.cpp b/src/gui/dialogs/qfilesystemmodel.cpp
index 517c3ab..ae75126 100644
--- a/src/gui/dialogs/qfilesystemmodel.cpp
+++ b/src/gui/dialogs/qfilesystemmodel.cpp
@@ -681,7 +681,7 @@ QVariant QFileSystemModel::data(const QModelIndex &index, int role) const
case Qt::EditRole:
case Qt::DisplayRole:
switch (index.column()) {
- case 0: return d->name(index);
+ case 0: return d->displayName(index);
case 1: return d->size(index);
case 2: return d->type(index);
case 3: return d->time(index);
@@ -797,13 +797,25 @@ QString QFileSystemModelPrivate::name(const QModelIndex &index) const
if (resolvedSymLinks.contains(fullPath))
return resolvedSymLinks[fullPath];
}
- // ### TODO it would be nice to grab the volume name if dirNode->parent == root
return dirNode->fileName;
}
/*!
\internal
*/
+QString QFileSystemModelPrivate::displayName(const QModelIndex &index) const
+{
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+ QFileSystemNode *dirNode = node(index);
+ if (!dirNode->volumeName.isNull())
+ return dirNode->volumeName + QLatin1String(" (") + name(index) + QLatin1Char(')');
+#endif
+ return name(index);
+}
+
+/*!
+ \internal
+*/
QIcon QFileSystemModelPrivate::icon(const QModelIndex &index) const
{
if (!index.isValid())
@@ -1648,6 +1660,18 @@ QFileSystemModelPrivate::QFileSystemNode* QFileSystemModelPrivate::addNode(QFile
#ifndef QT_NO_FILESYSTEMWATCHER
node->populate(info);
#endif
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+ //The parentNode is "" so we are listing the drives
+ if (parentNode->fileName.isEmpty()) {
+ wchar_t name[MAX_PATH + 1];
+ //GetVolumeInformation requires to add trailing backslash
+ const QString nodeName = fileName + QLatin1String("\\");
+ BOOL success = ::GetVolumeInformation((wchar_t *)(nodeName.utf16()),
+ name, ARRAYSIZE(name), NULL, 0, NULL, NULL, 0);
+ if (success && name[0])
+ node->volumeName = QString::fromWCharArray(name);
+ }
+#endif
parentNode->children.insert(fileName, node);
return node;
}
diff --git a/src/gui/dialogs/qfilesystemmodel_p.h b/src/gui/dialogs/qfilesystemmodel_p.h
index 6c85a7c..03e0bfb 100644
--- a/src/gui/dialogs/qfilesystemmodel_p.h
+++ b/src/gui/dialogs/qfilesystemmodel_p.h
@@ -97,6 +97,9 @@ public:
}
QString fileName;
+#if defined(Q_OS_WIN) && !defined(Q_OS_WINCE)
+ QString volumeName;
+#endif
inline qint64 size() const { if (info && !info->isDir()) return info->size(); return 0; }
inline QString type() const { if (info) return info->displayType; return QLatin1String(""); }
@@ -278,6 +281,7 @@ public:
QIcon icon(const QModelIndex &index) const;
QString name(const QModelIndex &index) const;
+ QString displayName(const QModelIndex &index) const;
QString filePath(const QModelIndex &index) const;
QString size(const QModelIndex &index) const;
static QString size(qint64 bytes);