summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorck <qt-info@nokia.com>2010-01-14 14:37:39 (GMT)
committerck <qt-info@nokia.com>2010-01-14 14:37:39 (GMT)
commit9b59e3a664ef1162e0f90ba7e7fe9356bae05d74 (patch)
tree33747444930903c2fd93aea1aeaad79c9a676056
parent90563926e2d68a468bb9accdbad9760da21d5ba3 (diff)
parentc5a226dc46110848eb874212cf4bb2257ada0c84 (diff)
downloadQt-9b59e3a664ef1162e0f90ba7e7fe9356bae05d74.zip
Qt-9b59e3a664ef1162e0f90ba7e7fe9356bae05d74.tar.gz
Qt-9b59e3a664ef1162e0f90ba7e7fe9356bae05d74.tar.bz2
Merge branch 'master' of scm.dev.nokia.troll.no:qt/qt
-rw-r--r--src/gui/dialogs/qfilesystemmodel.cpp28
-rw-r--r--src/gui/dialogs/qfilesystemmodel_p.h4
-rw-r--r--src/gui/util/qcompleter.cpp13
3 files changed, 39 insertions, 6 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);
diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp
index 0a070b6..b7be967 100644
--- a/src/gui/util/qcompleter.cpp
+++ b/src/gui/util/qcompleter.cpp
@@ -903,12 +903,12 @@ void QCompleterPrivate::showPopup(const QRect& rect)
popup->show();
}
-
void QCompleterPrivate::_q_fileSystemModelDirectoryLoaded(const QString &path)
{
Q_Q(QCompleter);
- Q_UNUSED(path);
- q->complete();
+ //the path given by QFileSystemModel does not end with /
+ if (q->completionPrefix() != path + QLatin1Char('/'))
+ q->complete();
}
/*!
@@ -1023,6 +1023,7 @@ void QCompleter::setModel(QAbstractItemModel *model)
#else
setCaseSensitivity(Qt::CaseSensitive);
#endif
+ setCompletionRole(QFileSystemModel::FileNameRole);
connect(fsModel, SIGNAL(directoryLoaded(QString)), this, SLOT(_q_fileSystemModelDirectoryLoaded(QString)));
}
#endif // QT_NO_FILESYSTEMMODEL
@@ -1685,7 +1686,11 @@ QString QCompleter::pathFromIndex(const QModelIndex& index) const
QModelIndex idx = index;
QStringList list;
do {
- QString t = sourceModel->data(idx, Qt::EditRole).toString();
+ QString t;
+ if (isDirModel)
+ t = sourceModel->data(idx, Qt::EditRole).toString();
+ else
+ t = sourceModel->data(idx, QFileSystemModel::FileNameRole).toString();
list.prepend(t);
QModelIndex parent = idx.parent();
idx = parent.sibling(parent.row(), index.column());