summaryrefslogtreecommitdiffstats
path: root/src/widgets/widgets
diff options
context:
space:
mode:
authorFrederik Gladhorn <frederik.gladhorn@digia.com>2013-08-14 09:05:42 +0200
committerFrederik Gladhorn <frederik.gladhorn@digia.com>2013-08-14 09:06:31 +0200
commit5c23199d4e8ff21661dfa5aacc13149178e78cab (patch)
tree322aee61581d7c85f1ccb65e47d1e79eba1ba6c9 /src/widgets/widgets
parent252bad7c589e03d3e12df02354b00a84d8e3159a (diff)
parentc8d9b17367cfdcb034d11f8a168ca4ae3993e7c3 (diff)
Merge remote-tracking branch 'origin/stable' into dev
Conflicts: configure mkspecs/macx-xcode/Info.plist.app mkspecs/macx-xcode/Info.plist.lib qmake/doc/qmake.qdocconf src/corelib/global/qglobal.h tests/auto/other/exceptionsafety/exceptionsafety.pro tests/auto/widgets/widgets/qcombobox/tst_qcombobox.cpp Change-Id: I3c769a4a82dc2e99a12c69123fbf17613fd2ac2a
Diffstat (limited to 'src/widgets/widgets')
-rw-r--r--src/widgets/widgets/qcombobox.cpp31
-rw-r--r--src/widgets/widgets/qcombobox.h4
-rw-r--r--src/widgets/widgets/qcombobox_p.h4
-rw-r--r--src/widgets/widgets/qdockarealayout.cpp2
4 files changed, 31 insertions, 10 deletions
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp
index b89067155d..bdd06da7fc 100644
--- a/src/widgets/widgets/qcombobox.cpp
+++ b/src/widgets/widgets/qcombobox.cpp
@@ -59,6 +59,7 @@
#include <qheaderview.h>
#include <qmath.h>
#include <qmetaobject.h>
+#include <qabstractproxymodel.h>
#include <private/qguiapplication_p.h>
#include <private/qapplication_p.h>
#include <private/qcombobox_p.h>
@@ -173,18 +174,28 @@ QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewIt
return menuOption;
}
-#ifdef QT_KEYPAD_NAVIGATION
-void QComboBoxPrivate::_q_completerActivated()
+#ifndef QT_NO_COMPLETER
+void QComboBoxPrivate::_q_completerActivated(const QModelIndex &index)
{
Q_Q(QComboBox);
+ if (index.isValid() && q->completer()) {
+ QAbstractProxyModel *proxy = qobject_cast<QAbstractProxyModel *>(q->completer()->completionModel());
+ if (proxy) {
+ q->setCurrentIndex(proxy->mapToSource(index).row());
+ emitActivated(currentIndex);
+ }
+ }
+
+# ifdef QT_KEYPAD_NAVIGATION
if ( QApplication::keypadNavigationEnabled()
&& q->isEditable()
&& q->completer()
&& q->completer()->completionMode() == QCompleter::UnfilteredPopupCompletion ) {
q->setEditFocus(false);
}
+# endif // QT_KEYPAD_NAVIGATION
}
-#endif
+#endif // !QT_NO_COMPLETER
void QComboBoxPrivate::updateArrow(QStyle::StateFlag state)
{
@@ -1149,6 +1160,14 @@ void QComboBoxPrivate::_q_editingFinished()
void QComboBoxPrivate::_q_returnPressed()
{
Q_Q(QComboBox);
+
+ // The insertion code below does not apply when the policy is QComboBox::NoInsert.
+ // In case a completer is installed, item activation via the completer is handled
+ // in _q_completerActivated(). Otherwise _q_editingFinished() updates the current
+ // index as appropriate.
+ if (insertPolicy == QComboBox::NoInsert)
+ return;
+
if (lineEdit && !lineEdit->text().isEmpty()) {
if (q->count() >= maxCount && !(this->insertPolicy == QComboBox::InsertAtCurrent))
return;
@@ -1191,7 +1210,6 @@ void QComboBoxPrivate::_q_returnPressed()
break;
}
break;
- case QComboBox::NoInsert:
default:
break;
}
@@ -1393,6 +1411,7 @@ void QComboBox::setAutoCompletion(bool enable)
if (d->lineEdit->completer())
return;
d->completer = new QCompleter(d->model, d->lineEdit);
+ connect(d->completer, SIGNAL(activated(QModelIndex)), this, SLOT(_q_completerActivated(QModelIndex)));
d->completer->setCaseSensitivity(d->autoCompletionCaseSensitivity);
d->completer->setCompletionMode(QCompleter::InlineCompletion);
d->completer->setCompletionColumn(d->modelColumn);
@@ -1805,8 +1824,10 @@ void QComboBox::setCompleter(QCompleter *c)
if (!d->lineEdit)
return;
d->lineEdit->setCompleter(c);
- if (c)
+ if (c) {
+ connect(c, SIGNAL(activated(QModelIndex)), this, SLOT(_q_completerActivated(QModelIndex)));
c->setWidget(this);
+ }
}
/*!
diff --git a/src/widgets/widgets/qcombobox.h b/src/widgets/widgets/qcombobox.h
index d4aeeb9620..0002cd08cb 100644
--- a/src/widgets/widgets/qcombobox.h
+++ b/src/widgets/widgets/qcombobox.h
@@ -260,8 +260,8 @@ private:
Q_PRIVATE_SLOT(d_func(), void _q_rowsRemoved(const QModelIndex & parent, int start, int end))
Q_PRIVATE_SLOT(d_func(), void _q_modelDestroyed())
Q_PRIVATE_SLOT(d_func(), void _q_modelReset())
-#ifdef QT_KEYPAD_NAVIGATION
- Q_PRIVATE_SLOT(d_func(), void _q_completerActivated())
+#ifndef QT_NO_COMPLETER
+ Q_PRIVATE_SLOT(d_func(), void _q_completerActivated(const QModelIndex &index))
#endif
};
diff --git a/src/widgets/widgets/qcombobox_p.h b/src/widgets/widgets/qcombobox_p.h
index 14cf9e7925..07ba9b0925 100644
--- a/src/widgets/widgets/qcombobox_p.h
+++ b/src/widgets/widgets/qcombobox_p.h
@@ -348,8 +348,8 @@ public:
void _q_emitCurrentIndexChanged(const QModelIndex &index);
void _q_modelDestroyed();
void _q_modelReset();
-#ifdef QT_KEYPAD_NAVIGATION
- void _q_completerActivated();
+#ifndef QT_NO_COMPLETER
+ void _q_completerActivated(const QModelIndex &index);
#endif
void _q_resetButton();
void _q_dataChanged(const QModelIndex &topLeft, const QModelIndex &bottomRight);
diff --git a/src/widgets/widgets/qdockarealayout.cpp b/src/widgets/widgets/qdockarealayout.cpp
index ac061e7071..72a463b30b 100644
--- a/src/widgets/widgets/qdockarealayout.cpp
+++ b/src/widgets/widgets/qdockarealayout.cpp
@@ -1471,7 +1471,7 @@ QList<int> QDockAreaLayoutInfo::indexOf(QWidget *widget) const
continue;
}
- if (!(item.flags & QDockAreaLayoutItem::GapItem) && item.widgetItem->widget() == widget) {
+ if (!(item.flags & QDockAreaLayoutItem::GapItem) && item.widgetItem && item.widgetItem->widget() == widget) {
QList<int> result;
result << i;
return result;