54 #include <qevent.h> |
54 #include <qevent.h> |
55 #include <qlayout.h> |
55 #include <qlayout.h> |
56 #include <qscrollbar.h> |
56 #include <qscrollbar.h> |
57 #include <qtreeview.h> |
57 #include <qtreeview.h> |
58 #include <qheaderview.h> |
58 #include <qheaderview.h> |
|
59 #include <qmath.h> |
59 #ifndef QT_NO_IM |
60 #ifndef QT_NO_IM |
60 #include "qinputcontext.h" |
61 #include "qinputcontext.h" |
61 #endif |
62 #endif |
62 #include <private/qapplication_p.h> |
63 #include <private/qapplication_p.h> |
63 #include <private/qcombobox_p.h> |
64 #include <private/qcombobox_p.h> |
110 |
111 |
111 QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewItem &option, |
112 QStyleOptionMenuItem QComboMenuDelegate::getStyleOption(const QStyleOptionViewItem &option, |
112 const QModelIndex &index) const |
113 const QModelIndex &index) const |
113 { |
114 { |
114 QStyleOptionMenuItem menuOption; |
115 QStyleOptionMenuItem menuOption; |
115 menuOption.palette = option.palette.resolve(QApplication::palette("QMenu")); |
116 |
|
117 QPalette resolvedpalette = option.palette.resolve(QApplication::palette("QMenu")); |
|
118 QVariant value = index.data(Qt::ForegroundRole); |
|
119 if (qVariantCanConvert<QBrush>(value)) { |
|
120 resolvedpalette.setBrush(QPalette::WindowText, qvariant_cast<QBrush>(value)); |
|
121 resolvedpalette.setBrush(QPalette::ButtonText, qvariant_cast<QBrush>(value)); |
|
122 resolvedpalette.setBrush(QPalette::Text, qvariant_cast<QBrush>(value)); |
|
123 } |
|
124 menuOption.palette = resolvedpalette; |
116 menuOption.state = QStyle::State_None; |
125 menuOption.state = QStyle::State_None; |
117 if (mCombo->window()->isActiveWindow()) |
126 if (mCombo->window()->isActiveWindow()) |
118 menuOption.state = QStyle::State_Active; |
127 menuOption.state = QStyle::State_Active; |
119 if ((option.state & QStyle::State_Enabled) && (index.model()->flags(index) & Qt::ItemIsEnabled)) |
128 if ((option.state & QStyle::State_Enabled) && (index.model()->flags(index) & Qt::ItemIsEnabled)) |
120 menuOption.state |= QStyle::State_Enabled; |
129 menuOption.state |= QStyle::State_Enabled; |
321 if (minimumContentsLength > 0) |
330 if (minimumContentsLength > 0) |
322 sh.setWidth(qMax(sh.width(), minimumContentsLength * fm.width(QLatin1Char('X')) + (hasIcon ? iconSize.width() + 4 : 0))); |
331 sh.setWidth(qMax(sh.width(), minimumContentsLength * fm.width(QLatin1Char('X')) + (hasIcon ? iconSize.width() + 4 : 0))); |
323 |
332 |
324 |
333 |
325 // height |
334 // height |
326 sh.setHeight(qMax(fm.height(), 14) + 2); |
335 sh.setHeight(qMax(qCeil(QFontMetricsF(fm).height()), 14) + 2); |
327 if (hasIcon) { |
336 if (hasIcon) { |
328 sh.setHeight(qMax(sh.height(), iconSize.height() + 2)); |
337 sh.setHeight(qMax(sh.height(), iconSize.height() + 2)); |
329 } |
338 } |
330 |
339 |
331 // add style and strut values |
340 // add style and strut values |
1281 \property QComboBox::maxVisibleItems |
1290 \property QComboBox::maxVisibleItems |
1282 \brief the maximum allowed size on screen of the combo box, measured in items |
1291 \brief the maximum allowed size on screen of the combo box, measured in items |
1283 |
1292 |
1284 By default, this property has a value of 10. |
1293 By default, this property has a value of 10. |
1285 |
1294 |
1286 \note This property is ignored for non-editable comboboxes in Mac style. |
1295 \note This property is ignored for non-editable comboboxes in styles that returns |
|
1296 false for QStyle::SH_ComboBox_Popup such as the Mac style or the Gtk+ Style. |
1287 */ |
1297 */ |
1288 int QComboBox::maxVisibleItems() const |
1298 int QComboBox::maxVisibleItems() const |
1289 { |
1299 { |
1290 Q_D(const QComboBox); |
1300 Q_D(const QComboBox); |
1291 return d->maxVisibleItems; |
1301 return d->maxVisibleItems; |