diff options
Diffstat (limited to 'src/widgets/itemviews/qstyleditemdelegate.cpp')
-rw-r--r-- | src/widgets/itemviews/qstyleditemdelegate.cpp | 38 |
1 files changed, 19 insertions, 19 deletions
diff --git a/src/widgets/itemviews/qstyleditemdelegate.cpp b/src/widgets/itemviews/qstyleditemdelegate.cpp index fc8a9203d9..54c1fb4f52 100644 --- a/src/widgets/itemviews/qstyleditemdelegate.cpp +++ b/src/widgets/itemviews/qstyleditemdelegate.cpp @@ -115,7 +115,7 @@ public: \row \li \l Qt::AccessibleDescriptionRole \li QString \row \li \l Qt::AccessibleTextRole \li QString \endomit - \row \li \l Qt::BackgroundRole \li QBrush (\since 4.2) + \row \li \l Qt::BackgroundRole \li QBrush \since 4.2 \row \li \l Qt::CheckStateRole \li Qt::CheckState \row \li \l Qt::DecorationRole \li QIcon, QPixmap, QImage and QColor \row \li \l Qt::DisplayRole \li QString and types with a string representation @@ -126,7 +126,7 @@ public: \row \li \l Qt::StatusTipRole \li \endomit \row \li \l Qt::TextAlignmentRole \li Qt::Alignment - \row \li \l Qt::ForegroundRole \li QBrush (\since 4.2) + \row \li \l Qt::ForegroundRole \li QBrush \since 4.2 \omit \row \li \l Qt::ToolTipRole \row \li \l Qt::WhatsThisRole @@ -137,12 +137,17 @@ public: instance provided by QItemEditorFactory is installed on all item delegates. You can set a custom factory using setItemEditorFactory() or set a new default factory with - QItemEditorFactory::setDefaultFactory(). It is the data stored in - the item model with the \l{Qt::}{EditRole} that is edited. See the - QItemEditorFactory class for a more high-level introduction to - item editor factories. The \l{Color Editor Factory Example}{Color - Editor Factory} example shows how to create custom editors with a - factory. + QItemEditorFactory::setDefaultFactory(). + + \snippet code/src_gui_itemviews_qitemeditorfactory.cpp setDefaultFactory + + After the new factory has been set, all standard item delegates + will use it (i.e, also delegates that were created before the new + default factory was set). + + It is the data stored in the item model with the \l{Qt::}{EditRole} + that is edited. See the QItemEditorFactory class for a more + high-level introduction to item editor factories. \section1 Subclassing QStyledItemDelegate @@ -204,8 +209,7 @@ public: documentation for details. \sa {Delegate Classes}, QItemDelegate, QAbstractItemDelegate, QStyle, - {Spin Box Delegate Example}, {Star Delegate Example}, {Color - Editor Factory Example} + {Star Delegate Example} */ @@ -285,6 +289,10 @@ void QStyledItemDelegate::initStyleOption(QStyleOptionViewItem *option, switch (value->userType()) { case QMetaType::QIcon: { option->icon = qvariant_cast<QIcon>(*value); + if (option->icon.isNull()) { + option->features &= ~QStyleOptionViewItem::HasDecoration; + break; + } QIcon::Mode mode; if (!(option->state & QStyle::State_Enabled)) mode = QIcon::Disabled; @@ -473,15 +481,7 @@ void QStyledItemDelegate::updateEditorGeometry(QWidget *editor, QStyleOptionViewItem opt = option; initStyleOption(&opt, index); - // let the editor take up all available space - //if the editor is not a QLineEdit - //or it is in a QTableView -#if QT_CONFIG(tableview) && QT_CONFIG(lineedit) - if (qobject_cast<QExpandingLineEdit*>(editor) && !qobject_cast<const QTableView*>(widget)) - opt.showDecorationSelected = editor->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, nullptr, editor); - else -#endif - opt.showDecorationSelected = true; + opt.showDecorationSelected = editor->style()->styleHint(QStyle::SH_ItemView_ShowDecorationSelected, nullptr, editor); QStyle *style = widget ? widget->style() : QApplication::style(); QRect geom = style->subElementRect(QStyle::SE_ItemViewItemText, &opt, widget); |