summaryrefslogtreecommitdiffstats
path: root/src/gui/util/qcompleter.cpp
diff options
context:
space:
mode:
authorAlexis Menard <alexis.menard@nokia.com>2010-01-14 10:33:56 (GMT)
committerAlexis Menard <alexis.menard@nokia.com>2010-01-14 10:37:39 (GMT)
commitc5a226dc46110848eb874212cf4bb2257ada0c84 (patch)
tree3e0d5d3df9dcbafba7fd5006d86e78c6547f36c5 /src/gui/util/qcompleter.cpp
parent54d1ad11a4f35c0484418e5d18537daaccc2c6ab (diff)
downloadQt-c5a226dc46110848eb874212cf4bb2257ada0c84.zip
Qt-c5a226dc46110848eb874212cf4bb2257ada0c84.tar.gz
Qt-c5a226dc46110848eb874212cf4bb2257ada0c84.tar.bz2
Implement showing the volume name for drives on Windows.
Also fix a bug with QCompleter and QFileSystemModel when the popup was shown even if there was nothing to complete. Task-number:QTBUG-5376 Reviewed-by:janarve
Diffstat (limited to 'src/gui/util/qcompleter.cpp')
-rw-r--r--src/gui/util/qcompleter.cpp13
1 files changed, 9 insertions, 4 deletions
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());