diff options
Diffstat (limited to 'src/widgets/widgets/qcombobox.cpp')
-rw-r--r-- | src/widgets/widgets/qcombobox.cpp | 34 |
1 files changed, 28 insertions, 6 deletions
diff --git a/src/widgets/widgets/qcombobox.cpp b/src/widgets/widgets/qcombobox.cpp index 506986f4ba..58a1ff9e7f 100644 --- a/src/widgets/widgets/qcombobox.cpp +++ b/src/widgets/widgets/qcombobox.cpp @@ -70,11 +70,6 @@ #include <private/qabstractscrollarea_p.h> #include <private/qlineedit_p.h> #include <qdebug.h> -#if 0 /* Used to be included in Qt4 for Q_WS_MAC */ && !defined(QT_NO_EFFECTS) && QT_CONFIG(style_mac) -#include <private/qcore_mac_p.h> -#include <private/qmacstyle_mac_p.h> -#include <private/qt_cocoa_helpers_mac_p.h> -#endif #ifndef QT_NO_EFFECTS # include <private/qeffects_p.h> #endif @@ -200,7 +195,21 @@ void QComboBoxPrivate::_q_completerActivated(const QModelIndex &index) if (index.isValid() && q->completer()) { QAbstractProxyModel *proxy = qobject_cast<QAbstractProxyModel *>(q->completer()->completionModel()); if (proxy) { - q->setCurrentIndex(proxy->mapToSource(index).row()); + const QModelIndex &completerIndex = proxy->mapToSource(index); + int row = -1; + if (completerIndex.model() == model) { + row = completerIndex.row(); + } else { + // if QCompleter uses a proxy model to host widget's one - map again + QAbstractProxyModel *completerProxy = qobject_cast<QAbstractProxyModel *>(q->completer()->model()); + if (completerProxy && completerProxy->sourceModel() == model) { + row = completerProxy->mapToSource(completerIndex).row(); + } else { + QString match = q->completer()->model()->data(completerIndex).toString(); + row = q->findText(match, matchFlags()); + } + } + q->setCurrentIndex(row); emitActivated(currentIndex); } } @@ -484,6 +493,14 @@ void QComboBoxPrivateContainer::scrollItemView(int action) #endif } +void QComboBoxPrivateContainer::hideScrollers() +{ + if (top) + top->hide(); + if (bottom) + bottom->hide(); +} + /* Hides or shows the scrollers when we emulate a popupmenu */ @@ -2725,6 +2742,11 @@ void QComboBox::showPopup() if (needHorizontalScrollBar) { listRect.adjust(0, 0, 0, sb->height()); } + + // Hide the scrollers here, so that the listrect gets the full height of the container + // If the scrollers are truly needed, the later call to container->updateScrollers() + // will make them visible again. + container->hideScrollers(); container->setGeometry(listRect); #ifndef Q_OS_MAC |