src/gui/widgets/qcombobox.cpp
changeset 19 fcece45ef507
parent 18 2f34d5167611
child 22 79de32ba3296
--- a/src/gui/widgets/qcombobox.cpp	Fri Apr 16 15:50:13 2010 +0300
+++ b/src/gui/widgets/qcombobox.cpp	Mon May 03 13:17:34 2010 +0300
@@ -532,9 +532,11 @@
     QStyleOptionComboBox opt = comboStyleOption();
     const bool usePopup = combo->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, combo);
 #ifndef QT_NO_SCROLLBAR
+#ifndef Q_WS_S60
     if (usePopup)
         view->setVerticalScrollBarPolicy(Qt::ScrollBarAlwaysOff);
 #endif
+#endif
     if (combo->style()->styleHint(QStyle::SH_ComboBox_ListMouseTracking, &opt, combo) ||
         usePopup) {
         view->setMouseTracking(true);
@@ -2416,24 +2418,44 @@
         // Position horizontally.
         listRect.moveLeft(above.x());
 
+#ifndef Q_WS_S60
         // Position vertically so the curently selected item lines up
         // with the combo box.
         const QRect currentItemRect = view()->visualRect(view()->currentIndex());
         const int offset = listRect.top() - currentItemRect.top();
         listRect.moveTop(above.y() + offset - listRect.top());
+#endif
 
 
         // Clamp the listRect height and vertical position so we don't expand outside the
         // available screen geometry.This may override the vertical position, but it is more
         // important to show as much as possible of the popup.
         const int height = !boundToScreen ? listRect.height() : qMin(listRect.height(), screen.height());
+#ifdef Q_WS_S60
+        //popup needs to be stretched with screen minimum dimension
+        listRect.setHeight(qMin(screen.height(), screen.width()));
+#else
         listRect.setHeight(height);
+#endif
+
         if (boundToScreen) {
             if (listRect.top() < screen.top())
                 listRect.moveTop(screen.top());
             if (listRect.bottom() > screen.bottom())
                 listRect.moveBottom(screen.bottom());
         }
+#ifdef Q_WS_S60
+        if (screen.width() < screen.height()) {
+            // in portait, menu should be positioned above softkeys
+            listRect.moveBottom(screen.bottom());
+        } else {
+            // landscape, menu should be at the right and horizontally centered
+            listRect.setWidth(listRect.height());
+            listRect.moveCenter(screen.center());
+            (opt.direction == Qt::LeftToRight) ? listRect.setRight(screen.right()) :
+                                                 listRect.setLeft(screen.left());
+        }
+#endif
     } else if (!boundToScreen || listRect.height() <= belowHeight) {
         listRect.moveTopLeft(below);
     } else if (listRect.height() <= aboveHeight) {
@@ -2642,6 +2664,34 @@
         if (d->lineEdit)
             d->updateLineEditGeometry();
         d->setLayoutItemMargins(QStyle::SE_ComboBoxLayoutItem);
+
+#ifdef Q_WS_S60
+        if (d->container) {
+            QStyleOptionComboBox opt;
+            initStyleOption(&opt);
+
+            if (style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, this)) {
+                const QRect screen = d->popupGeometry(QApplication::desktop()->screenNumber(this));
+
+                QRect listRect(style()->subControlRect(QStyle::CC_ComboBox, &opt,
+                    QStyle::SC_ComboBoxListBoxPopup, this));
+                listRect.setHeight(qMin(screen.height(), screen.width()));
+
+                if (screen.width() < screen.height()) {
+                    // in portait, menu should be positioned above softkeys
+                    listRect.moveBottom(screen.bottom());
+                } else {
+                    // landscape, menu should be at the right and horizontally centered
+                    listRect.setWidth(listRect.height());
+                    listRect.moveCenter(screen.center());
+                    (opt.direction == Qt::LeftToRight) ? listRect.setRight(screen.right()) :
+                                                         listRect.setLeft(screen.left());
+                }
+                d->container->setGeometry(listRect);
+            }
+        }
+#endif
+
         // ### need to update scrollers etc. as well here
         break;
     case QEvent::EnabledChange: