summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets/qcombobox.cpp
diff options
context:
space:
mode:
authorLiang Qi <liang.qi@qt.io>2017-10-04 10:41:19 +0200
committerLiang Qi <liang.qi@qt.io>2017-10-04 13:41:04 +0200
commitbc5f45052fd8f9a5481a37a6a4d55c7f6cbf037d (patch)
tree2c20e6c42ccd008e431a8d485450713883eacbb5 /src/widgets/widgets/qcombobox.cpp
parentb8947e9194f0f88f464448ac51f6a05113d36a33 (diff)
parent3faf8f4d48abd982be8470786cc5f61372519722 (diff)
Merge remote-tracking branch 'origin/5.9' into 5.10
Conflicts: src/corelib/global/qconfig-bootstrapped.h src/corelib/global/qglobal.h src/corelib/tools/qcryptographichash.cpp src/corelib/tools/qcryptographichash.h src/corelib/tools/qmessageauthenticationcode.cpp src/plugins/platforms/windows/qwindowswindow.h tests/auto/gui/kernel/qwindow/BLACKLIST tests/auto/widgets/itemviews/qitemdelegate/BLACKLIST Change-Id: Ib68112de985a3d714c2071f47c10e907e4f0229a
Diffstat (limited to 'src/widgets/widgets/qcombobox.cpp')
-rw-r--r--src/widgets/widgets/qcombobox.cpp38
1 files changed, 29 insertions, 9 deletions
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index cd2e20694e..1338a496e6 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -72,6 +72,7 @@
#include <private/qabstractitemmodel_p.h>
#include <private/qabstractscrollarea_p.h>
#include <private/qlineedit_p.h>
+#include <private/qcompleter_p.h>
#include <qdebug.h>
#if QT_CONFIG(effects)
# include <private/qeffects_p.h>
@@ -1227,8 +1228,27 @@ Qt::MatchFlags QComboBoxPrivate::matchFlags() const
void QComboBoxPrivate::_q_editingFinished()
{
Q_Q(QComboBox);
- if (lineEdit && !lineEdit->text().isEmpty() && itemText(currentIndex) != lineEdit->text()) {
- const int index = q_func()->findText(lineEdit->text(), matchFlags());
+ if (!lineEdit)
+ return;
+ const auto leText = lineEdit->text();
+ if (!leText.isEmpty() && itemText(currentIndex) != leText) {
+#if QT_CONFIG(completer)
+ const auto *leCompleter = lineEdit->completer();
+ const auto *popup = leCompleter ? QCompleterPrivate::get(leCompleter)->popup : nullptr;
+ if (popup && popup->isVisible()) {
+ // QLineEdit::editingFinished() will be emitted before the code flow returns
+ // to QCompleter::eventFilter(), where QCompleter::activated() may be emitted.
+ // We know that the completer popup will still be visible at this point, and
+ // that any selection should be valid.
+ const QItemSelectionModel *selModel = popup->selectionModel();
+ const QModelIndex curIndex = popup->currentIndex();
+ const bool completerIsActive = selModel && selModel->selectedIndexes().contains(curIndex);
+
+ if (completerIsActive)
+ return;
+ }
+#endif
+ const int index = q_func()->findText(leText, matchFlags());
if (index != -1) {
q->setCurrentIndex(index);
emitActivated(currentIndex);
@@ -3163,13 +3183,13 @@ void QComboBox::keyPressEvent(QKeyEvent *e)
Q_D(QComboBox);
#if QT_CONFIG(completer)
- if (d->lineEdit
- && d->lineEdit->completer()
- && d->lineEdit->completer()->popup()
- && d->lineEdit->completer()->popup()->isVisible()) {
- // provide same autocompletion support as line edit
- d->lineEdit->event(e);
- return;
+ if (const auto *cmpltr = completer()) {
+ const auto *popup = QCompleterPrivate::get(cmpltr)->popup;
+ if (popup && popup->isVisible()) {
+ // provide same autocompletion support as line edit
+ d->lineEdit->event(e);
+ return;
+ }
}
#endif