diff -r 93b982ccede2 -r 5daf16870df6 src/gui/widgets/qcombobox.cpp --- a/src/gui/widgets/qcombobox.cpp Mon Jun 21 22:38:13 2010 +0100 +++ b/src/gui/widgets/qcombobox.cpp Thu Jul 22 16:41:55 2010 +0100 @@ -56,6 +56,7 @@ #include #include #include +#include #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(value)) { + resolvedpalette.setBrush(QPalette::WindowText, qvariant_cast(value)); + resolvedpalette.setBrush(QPalette::ButtonText, qvariant_cast(value)); + resolvedpalette.setBrush(QPalette::Text, qvariant_cast(value)); + } + menuOption.palette = resolvedpalette; menuOption.state = QStyle::State_None; if (mCombo->window()->isActiveWindow()) menuOption.state = QStyle::State_Active; @@ -143,7 +152,10 @@ menuOption.icon = qvariant_cast(variant); break; } - + if (qVariantCanConvert(index.data(Qt::BackgroundRole))) { + menuOption.palette.setBrush(QPalette::All, QPalette::Background, + qvariant_cast(index.data(Qt::BackgroundRole))); + } menuOption.text = index.model()->data(index, Qt::DisplayRole).toString() .replace(QLatin1Char('&'), QLatin1String("&&")); menuOption.tabWidth = 0; @@ -320,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)); } @@ -1280,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 { @@ -2360,7 +2373,7 @@ toCheck.push(idx); #endif ++count; - if (!usePopup && count > d->maxVisibleItems) { + if (!usePopup && count >= d->maxVisibleItems) { toCheck.clear(); break; }