530 view->viewport()->installEventFilter(this); |
530 view->viewport()->installEventFilter(this); |
531 view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
531 view->setHorizontalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
532 QStyleOptionComboBox opt = comboStyleOption(); |
532 QStyleOptionComboBox opt = comboStyleOption(); |
533 const bool usePopup = combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo); |
533 const bool usePopup = combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo); |
534 #ifndef QT_NO_SCROLLBAR |
534 #ifndef QT_NO_SCROLLBAR |
|
535 #ifndef Q_WS_S60 |
535 if (usePopup) |
536 if (usePopup) |
536 view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
537 view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff); |
|
538 #endif |
537 #endif |
539 #endif |
538 if (combo->style()->styleHint(QStyle::SH_ComboBox_ListMouseTracking, &opt, combo) || |
540 if (combo->style()->styleHint(QStyle::SH_ComboBox_ListMouseTracking, &opt, combo) || |
539 usePopup) { |
541 usePopup) { |
540 view->setMouseTracking(true); |
542 view->setMouseTracking(true); |
541 } |
543 } |
2414 |
2416 |
2415 if (usePopup) { |
2417 if (usePopup) { |
2416 // Position horizontally. |
2418 // Position horizontally. |
2417 listRect.moveLeft(above.x()); |
2419 listRect.moveLeft(above.x()); |
2418 |
2420 |
|
2421 #ifndef Q_WS_S60 |
2419 // Position vertically so the curently selected item lines up |
2422 // Position vertically so the curently selected item lines up |
2420 // with the combo box. |
2423 // with the combo box. |
2421 const QRect currentItemRect = view()->visualRect(view()->currentIndex()); |
2424 const QRect currentItemRect = view()->visualRect(view()->currentIndex()); |
2422 const int offset = listRect.top() - currentItemRect.top(); |
2425 const int offset = listRect.top() - currentItemRect.top(); |
2423 listRect.moveTop(above.y() + offset - listRect.top()); |
2426 listRect.moveTop(above.y() + offset - listRect.top()); |
|
2427 #endif |
2424 |
2428 |
2425 |
2429 |
2426 // Clamp the listRect height and vertical position so we don't expand outside the |
2430 // Clamp the listRect height and vertical position so we don't expand outside the |
2427 // available screen geometry.This may override the vertical position, but it is more |
2431 // available screen geometry.This may override the vertical position, but it is more |
2428 // important to show as much as possible of the popup. |
2432 // important to show as much as possible of the popup. |
2429 const int height = !boundToScreen ? listRect.height() : qMin(listRect.height(), screen.height()); |
2433 const int height = !boundToScreen ? listRect.height() : qMin(listRect.height(), screen.height()); |
|
2434 #ifdef Q_WS_S60 |
|
2435 //popup needs to be stretched with screen minimum dimension |
|
2436 listRect.setHeight(qMin(screen.height(), screen.width())); |
|
2437 #else |
2430 listRect.setHeight(height); |
2438 listRect.setHeight(height); |
|
2439 #endif |
|
2440 |
2431 if (boundToScreen) { |
2441 if (boundToScreen) { |
2432 if (listRect.top() < screen.top()) |
2442 if (listRect.top() < screen.top()) |
2433 listRect.moveTop(screen.top()); |
2443 listRect.moveTop(screen.top()); |
2434 if (listRect.bottom() > screen.bottom()) |
2444 if (listRect.bottom() > screen.bottom()) |
2435 listRect.moveBottom(screen.bottom()); |
2445 listRect.moveBottom(screen.bottom()); |
2436 } |
2446 } |
|
2447 #ifdef Q_WS_S60 |
|
2448 if (screen.width() < screen.height()) { |
|
2449 // in portait, menu should be positioned above softkeys |
|
2450 listRect.moveBottom(screen.bottom()); |
|
2451 } else { |
|
2452 // landscape, menu should be at the right and horizontally centered |
|
2453 listRect.setWidth(listRect.height()); |
|
2454 listRect.moveCenter(screen.center()); |
|
2455 (opt.direction == Qt::LeftToRight) ? listRect.setRight(screen.right()) : |
|
2456 listRect.setLeft(screen.left()); |
|
2457 } |
|
2458 #endif |
2437 } else if (!boundToScreen || listRect.height() <= belowHeight) { |
2459 } else if (!boundToScreen || listRect.height() <= belowHeight) { |
2438 listRect.moveTopLeft(below); |
2460 listRect.moveTopLeft(below); |
2439 } else if (listRect.height() <= aboveHeight) { |
2461 } else if (listRect.height() <= aboveHeight) { |
2440 listRect.moveBottomLeft(above); |
2462 listRect.moveBottomLeft(above); |
2441 } else if (belowHeight >= aboveHeight) { |
2463 } else if (belowHeight >= aboveHeight) { |
2640 d->minimumSizeHint = QSize(); |
2662 d->minimumSizeHint = QSize(); |
2641 d->updateLayoutDirection(); |
2663 d->updateLayoutDirection(); |
2642 if (d->lineEdit) |
2664 if (d->lineEdit) |
2643 d->updateLineEditGeometry(); |
2665 d->updateLineEditGeometry(); |
2644 d->setLayoutItemMargins(QStyle::SE_ComboBoxLayoutItem); |
2666 d->setLayoutItemMargins(QStyle::SE_ComboBoxLayoutItem); |
|
2667 |
|
2668 #ifdef Q_WS_S60 |
|
2669 if (d->container) { |
|
2670 QStyleOptionComboBox opt; |
|
2671 initStyleOption(&opt); |
|
2672 |
|
2673 if (style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) { |
|
2674 const QRect screen = d->popupGeometry(QApplication::desktop()->screenNumber(this)); |
|
2675 |
|
2676 QRect listRect(style()->subControlRect(QStyle::CC_ComboBox, &opt, |
|
2677 QStyle::SC_ComboBoxListBoxPopup, this)); |
|
2678 listRect.setHeight(qMin(screen.height(), screen.width())); |
|
2679 |
|
2680 if (screen.width() < screen.height()) { |
|
2681 // in portait, menu should be positioned above softkeys |
|
2682 listRect.moveBottom(screen.bottom()); |
|
2683 } else { |
|
2684 // landscape, menu should be at the right and horizontally centered |
|
2685 listRect.setWidth(listRect.height()); |
|
2686 listRect.moveCenter(screen.center()); |
|
2687 (opt.direction == Qt::LeftToRight) ? listRect.setRight(screen.right()) : |
|
2688 listRect.setLeft(screen.left()); |
|
2689 } |
|
2690 d->container->setGeometry(listRect); |
|
2691 } |
|
2692 } |
|
2693 #endif |
|
2694 |
2645 // ### need to update scrollers etc. as well here |
2695 // ### need to update scrollers etc. as well here |
2646 break; |
2696 break; |
2647 case QEvent::EnabledChange: |
2697 case QEvent::EnabledChange: |
2648 if (!isEnabled()) |
2698 if (!isEnabled()) |
2649 hidePopup(); |
2699 hidePopup(); |