summaryrefslogtreecommitdiffstats
path: root/src/gui/util
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-10-25 09:36:57 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-10-25 09:36:57 (GMT)
commita24157b75fad4dd05cf8370152e16158ef1f229b (patch)
tree64b4c68f2b861f88983deee23256d54e12b976b7 /src/gui/util
parent8894515ad3e5c0c61bb1ac0b8c4f93985f8aff24 (diff)
parent62dc9c9602987f4381481cc5642e3ea0782bb418 (diff)
downloadQt-a24157b75fad4dd05cf8370152e16158ef1f229b.zip
Qt-a24157b75fad4dd05cf8370152e16158ef1f229b.tar.gz
Qt-a24157b75fad4dd05cf8370152e16158ef1f229b.tar.bz2
Merge commit '9f766c977a329c84023a15fc66f52d26ff03447b^' into qt-master-from-4.7
Diffstat (limited to 'src/gui/util')
-rw-r--r--src/gui/util/qcompleter.cpp18
-rw-r--r--src/gui/util/qcompleter_p.h1
2 files changed, 13 insertions, 6 deletions
diff --git a/src/gui/util/qcompleter.cpp b/src/gui/util/qcompleter.cpp
index fdd0fc5..71a0171 100644
--- a/src/gui/util/qcompleter.cpp
+++ b/src/gui/util/qcompleter.cpp
@@ -782,7 +782,8 @@ QMatchData QUnsortedModelEngine::filter(const QString& part, const QModelIndex&
///////////////////////////////////////////////////////////////////////////////
QCompleterPrivate::QCompleterPrivate()
: widget(0), proxy(0), popup(0), cs(Qt::CaseSensitive), role(Qt::EditRole), column(0),
- maxVisibleItems(7), sorting(QCompleter::UnsortedModel), wrap(true), eatFocusOut(true)
+ maxVisibleItems(7), sorting(QCompleter::UnsortedModel), wrap(true), eatFocusOut(true),
+ hiddenBecauseNoMatch(false)
{
}
@@ -921,12 +922,14 @@ void QCompleterPrivate::showPopup(const QRect& rect)
void QCompleterPrivate::_q_fileSystemModelDirectoryLoaded(const QString &path)
{
Q_Q(QCompleter);
-#ifndef QT_NO_LINEEDIT
- QLineEdit *lineEdit = qobject_cast<QLineEdit *>(widget);
- //the path given by QFileSystemModel does not end with /
- if (lineEdit && !lineEdit->text().isEmpty() && !q->completionPrefix().isEmpty() && q->completionPrefix() != path + QLatin1Char('/'))
+ // Slot called when QFileSystemModel has finished loading.
+ // If we hide the popup because there was no match because the model was not loaded yet,
+ // we re-start the completion when we get the results
+ if (hiddenBecauseNoMatch
+ && prefix.startsWith(path) && prefix != (path + '/')
+ && widget) {
q->complete();
-#endif
+ }
}
/*!
@@ -1200,6 +1203,7 @@ bool QCompleter::eventFilter(QObject *o, QEvent *e)
Q_D(QCompleter);
if (d->eatFocusOut && o == d->widget && e->type() == QEvent::FocusOut) {
+ d->hiddenBecauseNoMatch = false;
if (d->popup && d->popup->isVisible())
return true;
}
@@ -1378,6 +1382,7 @@ void QCompleter::complete(const QRect& rect)
{
Q_D(QCompleter);
QModelIndex idx = d->proxy->currentIndex(false);
+ d->hiddenBecauseNoMatch = false;
if (d->mode == QCompleter::InlineCompletion) {
if (idx.isValid())
d->_q_complete(idx, true);
@@ -1389,6 +1394,7 @@ void QCompleter::complete(const QRect& rect)
|| (d->mode == QCompleter::UnfilteredPopupCompletion && d->proxy->rowCount() == 0)) {
if (d->popup)
d->popup->hide(); // no suggestion, hide
+ d->hiddenBecauseNoMatch = true;
return;
}
diff --git a/src/gui/util/qcompleter_p.h b/src/gui/util/qcompleter_p.h
index 8f00793..19b76e5 100644
--- a/src/gui/util/qcompleter_p.h
+++ b/src/gui/util/qcompleter_p.h
@@ -93,6 +93,7 @@ public:
bool eatFocusOut;
QRect popupRect;
+ bool hiddenBecauseNoMatch;
void showPopup(const QRect&);
void _q_complete(QModelIndex, bool = false);