diff options
author | Aleksandar Sasha Babic <aleksandar.babic@nokia.com> | 2009-05-27 08:30:07 (GMT) |
---|---|---|
committer | Aleksandar Sasha Babic <aleksandar.babic@nokia.com> | 2009-05-27 08:30:07 (GMT) |
commit | d9e42d5c30ec551e6bded0277712eb0c6718b659 (patch) | |
tree | 7ca4f5f08c644ea130ade8f2eaf84cf54abe797c /src/gui/widgets/qcombobox.cpp | |
parent | fde5a9bde254dd0381762e2c52c0f4904599d40a (diff) | |
parent | d61736900e8781fa2fa3b98f30abf8925787d0f9 (diff) | |
download | Qt-d9e42d5c30ec551e6bded0277712eb0c6718b659.zip Qt-d9e42d5c30ec551e6bded0277712eb0c6718b659.tar.gz Qt-d9e42d5c30ec551e6bded0277712eb0c6718b659.tar.bz2 |
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt-s60-public
Diffstat (limited to 'src/gui/widgets/qcombobox.cpp')
-rw-r--r-- | src/gui/widgets/qcombobox.cpp | 22 |
1 files changed, 16 insertions, 6 deletions
diff --git a/src/gui/widgets/qcombobox.cpp b/src/gui/widgets/qcombobox.cpp index e9884bb..16e2f39 100644 --- a/src/gui/widgets/qcombobox.cpp +++ b/src/gui/widgets/qcombobox.cpp @@ -948,7 +948,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))); @@ -1568,15 +1568,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 |