Fix more metatype related deprecation warnings

Change-Id: If206b70d263bcdb6d617827fb9cb8fe3214564a1
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
Reviewed-by: Mahmoud Badri <mahmoud.badri@qt.io>
This commit is contained in:
hjk
2024-06-07 08:57:42 +02:00
parent 36ec16a34c
commit 4e2d8d0226
9 changed files with 17 additions and 17 deletions

View File

@@ -904,7 +904,7 @@ static ConsoleItem *constructLogItemTree(const QVariant &result, const QString &
if (child) if (child)
item->appendChild(child); item->appendChild(child);
} }
} else if (result.canConvert(QMetaType::QString)) { } else if (result.canConvert(QMetaType(QMetaType::QString))) {
item = new ConsoleItem(ConsoleItem::DefaultType, result.toString()); item = new ConsoleItem(ConsoleItem::DefaultType, result.toString());
} else { } else {
item = new ConsoleItem(ConsoleItem::DefaultType, "Unknown Value"); item = new ConsoleItem(ConsoleItem::DefaultType, "Unknown Value");

View File

@@ -39,9 +39,9 @@ QString EffectComposerContextObject::convertColorToString(const QVariant &color)
{ {
QString colorString; QString colorString;
QColor theColor; QColor theColor;
if (color.canConvert(QVariant::Color)) { if (color.canConvert(QMetaType(QMetaType::QColor))) {
theColor = color.value<QColor>(); theColor = color.value<QColor>();
} else if (color.canConvert(QVariant::Vector3D)) { } else if (color.canConvert(QMetaType(QMetaType::QVector3D))) {
auto vec = color.value<QVector3D>(); auto vec = color.value<QVector3D>();
theColor = QColor::fromRgbF(vec.x(), vec.y(), vec.z()); theColor = QColor::fromRgbF(vec.x(), vec.y(), vec.z());
} }

View File

@@ -78,7 +78,7 @@ public:
const QVariant checkFormat = kit->value(McuDependenciesKitAspect::id()); const QVariant checkFormat = kit->value(McuDependenciesKitAspect::id());
if (!checkFormat.isValid() || checkFormat.isNull()) if (!checkFormat.isValid() || checkFormat.isNull())
return result; return result;
if (!checkFormat.canConvert(QMetaType::QVariantList)) if (!checkFormat.canConvert(QMetaType(QMetaType::QVariantList)))
return {BuildSystemTask(Task::Error, Tr::tr("The MCU dependencies setting value is invalid."))}; return {BuildSystemTask(Task::Error, Tr::tr("The MCU dependencies setting value is invalid."))};
// check paths defined in cmake variables for given dependencies exist // check paths defined in cmake variables for given dependencies exist
@@ -105,7 +105,7 @@ public:
QTC_ASSERT(kit, return ); QTC_ASSERT(kit, return );
const QVariant variant = kit->value(McuDependenciesKitAspect::id()); const QVariant variant = kit->value(McuDependenciesKitAspect::id());
if (!variant.isNull() && !variant.canConvert(QMetaType::QVariantList)) { if (!variant.isNull() && !variant.canConvert(QMetaType(QMetaType::QVariantList))) {
qWarning("Kit \"%s\" has a wrong mcu dependencies value set.", qWarning("Kit \"%s\" has a wrong mcu dependencies value set.",
qPrintable(kit->displayName())); qPrintable(kit->displayName()));
McuDependenciesKitAspect::setDependencies(kit, Utils::EnvironmentItems()); McuDependenciesKitAspect::setDependencies(kit, Utils::EnvironmentItems());

View File

@@ -1539,7 +1539,7 @@ Tasks EnvironmentKitAspectFactory::validate(const Kit *k) const
QTC_ASSERT(k, return result); QTC_ASSERT(k, return result);
const QVariant variant = k->value(EnvironmentKitAspect::id()); const QVariant variant = k->value(EnvironmentKitAspect::id());
if (!variant.isNull() && !variant.canConvert(QMetaType::QVariantList)) if (!variant.isNull() && !variant.canConvert(QMetaType(QMetaType::QVariantList)))
result << BuildSystemTask(Task::Error, Tr::tr("The environment setting value is invalid.")); result << BuildSystemTask(Task::Error, Tr::tr("The environment setting value is invalid."));
return result; return result;
@@ -1550,7 +1550,7 @@ void EnvironmentKitAspectFactory::fix(Kit *k)
QTC_ASSERT(k, return); QTC_ASSERT(k, return);
const QVariant variant = k->value(EnvironmentKitAspect::id()); const QVariant variant = k->value(EnvironmentKitAspect::id());
if (!variant.isNull() && !variant.canConvert(QMetaType::QVariantList)) { if (!variant.isNull() && !variant.canConvert(QMetaType(QMetaType::QVariantList))) {
qWarning("Kit \"%s\" has a wrong environment value set.", qPrintable(k->displayName())); qWarning("Kit \"%s\" has a wrong environment value set.", qPrintable(k->displayName()));
EnvironmentKitAspect::setEnvironmentChanges(k, EnvironmentItems()); EnvironmentKitAspect::setEnvironmentChanges(k, EnvironmentItems());
} }

View File

@@ -46,9 +46,9 @@ QString MaterialEditorContextObject::convertColorToString(const QVariant &color)
{ {
QString colorString; QString colorString;
QColor theColor; QColor theColor;
if (color.canConvert(QVariant::Color)) { if (color.canConvert(QMetaType(QMetaType::QColor))) {
theColor = color.value<QColor>(); theColor = color.value<QColor>();
} else if (color.canConvert(QVariant::Vector3D)) { } else if (color.canConvert(QMetaType(QMetaType::QVector3D))) {
auto vec = color.value<QVector3D>(); auto vec = color.value<QVector3D>();
theColor = QColor::fromRgbF(vec.x(), vec.y(), vec.z()); theColor = QColor::fromRgbF(vec.x(), vec.y(), vec.z());
} }

View File

@@ -87,9 +87,9 @@ QString PropertyEditorContextObject::convertColorToString(const QVariant &color)
{ {
QString colorString; QString colorString;
QColor theColor; QColor theColor;
if (color.canConvert(QVariant::Color)) { if (color.canConvert(QMetaType(QMetaType::QColor))) {
theColor = color.value<QColor>(); theColor = color.value<QColor>();
} else if (color.canConvert(QVariant::Vector3D)) { } else if (color.canConvert(QMetaType(QMetaType::QVector3D))) {
auto vec = color.value<QVector3D>(); auto vec = color.value<QVector3D>();
theColor = QColor::fromRgbF(vec.x(), vec.y(), vec.z()); theColor = QColor::fromRgbF(vec.x(), vec.y(), vec.z());
} }

View File

@@ -47,9 +47,9 @@ QString TextureEditorContextObject::convertColorToString(const QVariant &color)
{ {
QString colorString; QString colorString;
QColor theColor; QColor theColor;
if (color.canConvert(QVariant::Color)) { if (color.canConvert(QMetaType(QMetaType::QColor))) {
theColor = color.value<QColor>(); theColor = color.value<QColor>();
} else if (color.canConvert(QVariant::Vector3D)) { } else if (color.canConvert(QMetaType(QMetaType::QVector3D))) {
auto vec = color.value<QVector3D>(); auto vec = color.value<QVector3D>();
theColor = QColor::fromRgbF(vec.x(), vec.y(), vec.z()); theColor = QColor::fromRgbF(vec.x(), vec.y(), vec.z());
} }

View File

@@ -107,14 +107,14 @@ static void editValue(const ModelNode &frameNode, const std::pair<qreal, qreal>
int userType = value.typeId(); int userType = value.typeId();
QVariant newValue = dialog->value(); QVariant newValue = dialog->value();
if (newValue.canConvert(userType)) { if (newValue.canConvert(QMetaType(userType))) {
QVariant newValueConverted = newValue; QVariant newValueConverted = newValue;
bool converted = newValueConverted.convert(userType); bool converted = newValueConverted.convert(QMetaType(userType));
if (!converted) { if (!converted) {
// convert() fails for int to double, so we try this combination // convert() fails for int to double, so we try this combination
newValueConverted = newValue; newValueConverted = newValue;
converted = newValueConverted.convert(QMetaType::Double); converted = newValueConverted.convert(QMetaType(QMetaType::Double));
} }
if (converted) if (converted)

View File

@@ -1565,7 +1565,7 @@ void TextToModelMerger::syncVariantProperty(AbstractProperty &modelProperty,
const TypeName &astType, const TypeName &astType,
DifferenceHandler &differenceHandler) DifferenceHandler &differenceHandler)
{ {
if (astValue.canConvert(QMetaType::QString)) if (astValue.canConvert(QMetaType(QMetaType::QString)))
populateQrcMapping(astValue.toString()); populateQrcMapping(astValue.toString());
if (modelProperty.isVariantProperty()) { if (modelProperty.isVariantProperty()) {