summaryrefslogtreecommitdiffstats
path: root/src/gui/util
diff options
context:
space:
mode:
authorOlivier Goffart <olivier.goffart@nokia.com>2010-10-13 09:00:29 (GMT)
committerOlivier Goffart <olivier.goffart@nokia.com>2010-10-13 09:28:41 (GMT)
commitc416ec00e7c859a844a5bcb24c7a31147aed974c (patch)
treea36a589cfec92f28ae0db005a24bc052f121150f /src/gui/util
parent40b5c05b9921b5fa3ceae7f723c0b26c4861bda7 (diff)
downloadQt-c416ec00e7c859a844a5bcb24c7a31147aed974c.zip
Qt-c416ec00e7c859a844a5bcb24c7a31147aed974c.tar.gz
Qt-c416ec00e7c859a844a5bcb24c7a31147aed974c.tar.bz2
QCompleter: do not auto complete when directory is changed.
Fixed regression for QCompleter associated with a QFileSystemModel. It would popup a popup each time the directory is changed. This was a regression in Qt 4.7.0, introduced with 319b0262418d74cc416a7d Task-number: QTBUG-14292 Reviewed-by: Thierry
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 e718212..bcd601b 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);