summaryrefslogtreecommitdiffstats
path: root/src/gui/widgets/qcombobox.cpp
diff options
context:
space:
mode:
authorOlivier Goffart <ogoffart@trolltech.com>2009-05-20 11:25:27 (GMT)
committerOlivier Goffart <ogoffart@trolltech.com>2009-05-20 11:47:58 (GMT)
commitfdefbb820f1ebf9fbde0f683ea6d05923e8c04e4 (patch)
tree5dac0f832a8ce60f1724d9978b604df64fd3e5f3 /src/gui/widgets/qcombobox.cpp
parent25f86fbab2e7d23832b0bb8ae8530289258e2aa5 (diff)
downloadQt-fdefbb820f1ebf9fbde0f683ea6d05923e8c04e4.zip
Qt-fdefbb820f1ebf9fbde0f683ea6d05923e8c04e4.tar.gz
Qt-fdefbb820f1ebf9fbde0f683ea6d05923e8c04e4.tar.bz2
QComboBox: style change event should not resets custom item delegates
Regression from 4.4 introduced while fixing task 167106 Autotest: tst_QComboBox::task253944_itemDelegateIsReset() Task-number: 253944 Reviewed-by: jbache
Diffstat (limited to 'src/gui/widgets/qcombobox.cpp')
-rw-r--r--src/gui/widgets/qcombobox.cpp22
1 files changed, 16 insertions, 6 deletions
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp
index 09a51fe..a5a98d4 100644
--- a/src/gui/widgets/qcombobox.cpp
+++ b/src/gui/widgets/qcombobox.cpp
@@ -947,7 +947,7 @@ QComboBoxPrivateContainer* QComboBoxPrivate::viewContainer()
container = new QComboBoxPrivateContainer(new QComboBoxListView(q), q);
container->itemView()->setModel(model);
container->itemView()->setTextElideMode(Qt::ElideMiddle);
- updateDelegate();
+ updateDelegate(true);
updateLayoutDirection();
QObject::connect(container, SIGNAL(itemSelected(QModelIndex)),
q, SLOT(_q_itemSelected(QModelIndex)));
@@ -1567,15 +1567,25 @@ bool QComboBox::isEditable() const
return d->lineEdit != 0;
}
-void QComboBoxPrivate::updateDelegate()
+/*! \internal
+ update the default delegate
+ depending on the style's SH_ComboBox_Popup hint, we use a different default delegate.
+
+ but we do not change the delegate is the combobox use a custom delegate,
+ unless \a force is set to true.
+ */
+void QComboBoxPrivate::updateDelegate(bool force)
{
Q_Q(QComboBox);
QStyleOptionComboBox opt;
q->initStyleOption(&opt);
- if (q->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, q))
- q->setItemDelegate(new QComboMenuDelegate(q->view(), q));
- else
- q->setItemDelegate(new QComboBoxDelegate(q->view(), q));
+ if (q->style()->styleHint(QStyle::SH_ComboBox_Popup, &opt, q)) {
+ if (force || qobject_cast<QComboBoxDelegate *>(q->itemDelegate()))
+ q->setItemDelegate(new QComboMenuDelegate(q->view(), q));
+ } else {
+ if (force || qobject_cast<QComboMenuDelegate *>(q->itemDelegate()))
+ q->setItemDelegate(new QComboBoxDelegate(q->view(), q));
+ }
}
QIcon QComboBoxPrivate::itemIcon(const QModelIndex &index) const