src/gui/widgets/qcombobox.cpp
changeset 30 5dc02b23752f
parent 25 e24348a560a6
child 33 3e2da88830cd
--- a/src/gui/widgets/qcombobox.cpp	Wed Jun 23 19:07:03 2010 +0300
+++ b/src/gui/widgets/qcombobox.cpp	Tue Jul 06 15:10:48 2010 +0300
@@ -56,6 +56,7 @@
 #include <qscrollbar.h>
 #include <qtreeview.h>
 #include <qheaderview.h>
+#include <qmath.h>
 #ifndef QT_NO_IM
 #include "qinputcontext.h"
 #endif
@@ -112,7 +113,15 @@
                                                         const QModelIndex &index) const
 {
     QStyleOptionMenuItem menuOption;
-    menuOption.palette = option.palette.resolve(QApplication::palette("QMenu"));
+
+    QPalette resolvedpalette = option.palette.resolve(QApplication::palette("QMenu"));
+    QVariant value = index.data(Qt::ForegroundRole);
+    if (qVariantCanConvert<QBrush>(value)) {
+        resolvedpalette.setBrush(QPalette::WindowText, qvariant_cast<QBrush>(value));
+        resolvedpalette.setBrush(QPalette::ButtonText, qvariant_cast<QBrush>(value));
+        resolvedpalette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value));
+    }
+    menuOption.palette = resolvedpalette;
     menuOption.state = QStyle::State_None;
     if (mCombo->window()->isActiveWindow())
         menuOption.state = QStyle::State_Active;
@@ -323,7 +332,7 @@
 
 
         // height
-        sh.setHeight(qMax(fm.height(), 14) + 2);
+        sh.setHeight(qMax(qCeil(QFontMetricsF(fm).height()), 14) + 2);
         if (hasIcon) {
             sh.setHeight(qMax(sh.height(), iconSize.height() + 2));
         }
@@ -1283,7 +1292,8 @@
 
     By default, this property has a value of 10.
 
-    \note This property is ignored for non-editable comboboxes in Mac style.
+    \note This property is ignored for non-editable comboboxes in styles that returns
+    false for QStyle::SH_ComboBox_Popup such as the Mac style or the Gtk+ Style.
 */
 int QComboBox::maxVisibleItems() const
 {
@@ -2363,7 +2373,7 @@
                     toCheck.push(idx);
 #endif
                 ++count;
-                if (!usePopup && count > d->maxVisibleItems) {
+                if (!usePopup && count >= d->maxVisibleItems) {
                     toCheck.clear();
                     break;
                 }