diff options
author | Olivier Goffart <ogoffart@woboq.com> | 2019-12-02 17:54:48 +0100 |
---|---|---|
committer | Olivier Goffart <ogoffart@woboq.com> | 2020-01-23 16:46:51 +0100 |
commit | 73d1476fb1397948a4d806bd921fce372bd8d63b (patch) | |
tree | a476349c26627027d78c1279da00ef633323311f /src/widgets/itemviews/qitemdelegate.cpp | |
parent | a78d66743171557d79b16c08be775e3ac15bb4ef (diff) |
Replace most use of QVariant::type and occurrences of QVariant::Type
I made a clazy automated check that replaced the use of QVariant::Type
by the equivalent in QMetaType.
This has been deprecated since Qt 5.0, but many uses were not yet removed.
In addition, there was some manual changes to fix the compilation errors.
Adapted the Private API of QDateTimeParser and QMimeDataPrivate
and adjust QDateTimeEdit and QSpinBox.
QVariant(QVariant::Invalid) in qstylesheet made no sense.
But note that in QVariant::save, we actually wanted to use the non-user type.
In the SQL module, many changes were actually reverted because the API
still expects QVarient::Type.
Change-Id: I98c368490e4ee465ed3a3b63bda8b8eaa50ea67e
Reviewed-by: Lars Knoll <lars.knoll@qt.io>
Diffstat (limited to 'src/widgets/itemviews/qitemdelegate.cpp')
-rw-r--r-- | src/widgets/itemviews/qitemdelegate.cpp | 22 |
1 files changed, 11 insertions, 11 deletions
diff --git a/src/widgets/itemviews/qitemdelegate.cpp b/src/widgets/itemviews/qitemdelegate.cpp index daea907963..4420d39b8e 100644 --- a/src/widgets/itemviews/qitemdelegate.cpp +++ b/src/widgets/itemviews/qitemdelegate.cpp @@ -414,7 +414,7 @@ void QItemDelegate::paint(QPainter *painter, if (value.isValid()) { // ### we need the pixmap to call the virtual function pixmap = decoration(opt, value); - if (value.type() == QVariant::Icon) { + if (value.userType() == QMetaType::QIcon) { d->tmp.icon = qvariant_cast<QIcon>(value); d->tmp.mode = d->iconMode(option.state); d->tmp.state = d->iconState(option.state); @@ -969,12 +969,12 @@ void QItemDelegate::doLayout(const QStyleOptionViewItem &option, QPixmap QItemDelegate::decoration(const QStyleOptionViewItem &option, const QVariant &variant) const { Q_D(const QItemDelegate); - switch (variant.type()) { - case QVariant::Icon: { + switch (variant.userType()) { + case QMetaType::QIcon: { QIcon::Mode mode = d->iconMode(option.state); QIcon::State state = d->iconState(option.state); return qvariant_cast<QIcon>(variant).pixmap(option.decorationSize, mode, state); } - case QVariant::Color: { + case QMetaType::QColor: { static QPixmap pixmap(option.decorationSize); pixmap.fill(qvariant_cast<QColor>(variant)); return pixmap; } @@ -1060,24 +1060,24 @@ QRect QItemDelegate::rect(const QStyleOptionViewItem &option, if (role == Qt::CheckStateRole) return doCheck(option, option.rect, value); if (value.isValid() && !value.isNull()) { - switch (value.type()) { - case QVariant::Invalid: + switch (value.userType()) { + case QMetaType::UnknownType: break; - case QVariant::Pixmap: { + case QMetaType::QPixmap: { const QPixmap &pixmap = qvariant_cast<QPixmap>(value); return QRect(QPoint(0, 0), pixmap.size() / pixmap.devicePixelRatio() ); } - case QVariant::Image: { + case QMetaType::QImage: { const QImage &image = qvariant_cast<QImage>(value); return QRect(QPoint(0, 0), image.size() / image.devicePixelRatio() ); } - case QVariant::Icon: { + case QMetaType::QIcon: { QIcon::Mode mode = d->iconMode(option.state); QIcon::State state = d->iconState(option.state); QIcon icon = qvariant_cast<QIcon>(value); QSize size = icon.actualSize(option.decorationSize, mode, state); return QRect(QPoint(0, 0), size); } - case QVariant::Color: + case QMetaType::QColor: return QRect(QPoint(0, 0), option.decorationSize); - case QVariant::String: + case QMetaType::QString: default: { const QString text = d->valueToText(value, option); value = index.data(Qt::FontRole); |