From 73d1476fb1397948a4d806bd921fce372bd8d63b Mon Sep 17 00:00:00 2001 From: Olivier Goffart Date: Mon, 2 Dec 2019 17:54:48 +0100 Subject: 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 --- src/widgets/styles/qstylesheetstyle.cpp | 31 +++++++++++++++---------------- 1 file changed, 15 insertions(+), 16 deletions(-) (limited to 'src/widgets/styles/qstylesheetstyle.cpp') diff --git a/src/widgets/styles/qstylesheetstyle.cpp b/src/widgets/styles/qstylesheetstyle.cpp index 2eccb24431..1e032b237a 100644 --- a/src/widgets/styles/qstylesheetstyle.cpp +++ b/src/widgets/styles/qstylesheetstyle.cpp @@ -1547,11 +1547,10 @@ public: } } } - QString valueStr; - if(value.type() == QVariant::StringList || value.type() == QVariant::List) - valueStr = value.toStringList().join(QLatin1Char(' ')); - else - valueStr = value.toString(); + QString valueStr = (value.userType() == QMetaType::QStringList + || value.userType() == QMetaType::QVariantList) + ? value.toStringList().join(QLatin1Char(' ')) + : value.toString(); cache[name] = valueStr; return valueStr; } @@ -2611,16 +2610,16 @@ void QStyleSheetStyle::setProperties(QWidget *w) QVariant v; const QVariant value = w->property(property.toLatin1()); - switch (value.type()) { - case QVariant::Icon: v = decl.iconValue(); break; - case QVariant::Image: v = QImage(decl.uriValue()); break; - case QVariant::Pixmap: v = QPixmap(decl.uriValue()); break; - case QVariant::Rect: v = decl.rectValue(); break; - case QVariant::Size: v = decl.sizeValue(); break; - case QVariant::Color: v = decl.colorValue(); break; - case QVariant::Brush: v = decl.brushValue(); break; + switch (value.userType()) { + case QMetaType::QIcon: v = decl.iconValue(); break; + case QMetaType::QImage: v = QImage(decl.uriValue()); break; + case QMetaType::QPixmap: v = QPixmap(decl.uriValue()); break; + case QMetaType::QRect: v = decl.rectValue(); break; + case QMetaType::QSize: v = decl.sizeValue(); break; + case QMetaType::QColor: v = decl.colorValue(); break; + case QMetaType::QBrush: v = decl.brushValue(); break; #ifndef QT_NO_SHORTCUT - case QVariant::KeySequence: v = QKeySequence(decl.d->values.at(0).variant.toString()); break; + case QMetaType::QKeySequence: v = QKeySequence(decl.d->values.at(0).variant.toString()); break; #endif default: v = decl.d->values.at(0).variant; break; } @@ -4648,7 +4647,7 @@ void QStyleSheetStyle::drawPrimitive(PrimitiveElement pe, const QStyleOption *op } if (baseStyle()->property("_q_styleSheetRealCloseButton").toBool()) - baseStyle()->setProperty("_q_styleSheetRealCloseButton", QVariant(QVariant::Invalid)); + baseStyle()->setProperty("_q_styleSheetRealCloseButton", QVariant()); } QPixmap QStyleSheetStyle::generatedIconPixmap(QIcon::Mode iconMode, const QPixmap& pixmap, @@ -6128,7 +6127,7 @@ void QStyleSheetStyle::saveWidgetFont(QWidget* w, const QFont& font) const void QStyleSheetStyle::clearWidgetFont(QWidget* w) const { - w->setProperty("_q_styleSheetWidgetFont", QVariant(QVariant::Invalid)); + w->setProperty("_q_styleSheetWidgetFont", QVariant()); } // Polish palette that should be used for a particular widget, with particular states -- cgit v1.2.3