summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets/qcombobox.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-10-30 08:55:20 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-10-30 12:42:08 (GMT)
commitd025ebb1a8163cd1f03151927486cf62c5e77957 (patch)
tree0ccef8c9a9012ab63f20f100a824abb1516d9886 /src/gui/widgets/qcombobox.cpp
parent85b7896a47f9bb622b394107769cb7c1121a6995 (diff)
downloadQt-d025ebb1a8163cd1f03151927486cf62c5e77957.zip
Qt-d025ebb1a8163cd1f03151927486cf62c5e77957.tar.gz
Qt-d025ebb1a8163cd1f03151927486cf62c5e77957.tar.bz2
Fixes regression in QComboBox with keypad navigation while mouse is over the popup
The problem is that is we move the selection with the keyboard in a way that causes the view to scroll, the current selection would jump. This happends since commit 9cb231d773db6deb that fixed the emission of the enter signal when the view is scrolled. We Therefor cannot use the enter signal. Catch manually the mouse move events to update the selection instead. Reviewed-by: Thierry
Diffstat (limited to 'src/gui/widgets/qcombobox.cpp')
-rw-r--r--src/gui/widgets/qcombobox.cpp24
1 files changed, 6 insertions, 18 deletions
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index 6dbf15a..1879db4 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -489,18 +489,6 @@ void QComboBoxPrivateContainer::viewDestroyed()
}
/*
- Sets currentIndex on entered if the LeftButton is not pressed. This
- means that if mouseTracking(...) is on, we setCurrentIndex and select
- even when LeftButton is not pressed.
-*/
-void QComboBoxPrivateContainer::setCurrentIndex(const QModelIndex &index)
-{
- if (QComboBoxDelegate::isSeparator(index))
- return;
- view->setCurrentIndex(index);
-}
-
-/*
Returns the item view used for the combobox popup.
*/
QAbstractItemView *QComboBoxPrivateContainer::itemView() const
@@ -525,8 +513,6 @@ void QComboBoxPrivateContainer::setItemView(QAbstractItemView *itemView)
disconnect(view->verticalScrollBar(), SIGNAL(rangeChanged(int,int)),
this, SLOT(updateScrollers()));
#endif
- disconnect(view, SIGNAL(entered(QModelIndex)),
- this, SLOT(setCurrentIndex(QModelIndex)));
disconnect(view, SIGNAL(destroyed()),
this, SLOT(viewDestroyed()));
@@ -563,8 +549,6 @@ void QComboBoxPrivateContainer::setItemView(QAbstractItemView *itemView)
connect(view->verticalScrollBar(), SIGNAL(rangeChanged(int,int)),
this, SLOT(updateScrollers()));
#endif
- connect(view, SIGNAL(entered(QModelIndex)),
- this, SLOT(setCurrentIndex(QModelIndex)));
connect(view, SIGNAL(destroyed()),
this, SLOT(viewDestroyed()));
@@ -655,16 +639,20 @@ bool QComboBoxPrivateContainer::eventFilter(QObject *o, QEvent *e)
break;
}
break;
- case QEvent::MouseMove: {
+ case QEvent::MouseMove:
if (isVisible()) {
QMouseEvent *m = static_cast<QMouseEvent *>(e);
QWidget *widget = static_cast<QWidget *>(o);
QPoint vector = widget->mapToGlobal(m->pos()) - initialClickPosition;
if (vector.manhattanLength() > 9 && blockMouseReleaseTimer.isActive())
blockMouseReleaseTimer.stop();
+ QModelIndex indexUnderMouse = view->indexAt(m->pos());
+ if (indexUnderMouse.isValid() && indexUnderMouse != view->currentIndex()
+ && !QComboBoxDelegate::isSeparator(indexUnderMouse)) {
+ view->setCurrentIndex(indexUnderMouse);
+ }
}
break;
- }
case QEvent::MouseButtonRelease: {
QMouseEvent *m = static_cast<QMouseEvent *>(e);
if (isVisible() && view->rect().contains(m->pos()) && view->currentIndex().isValid()