QVariant: fix converting enum to string

Use QMetaEnum::valueToKey instead of valueToKeys.

Change-Id: I270f0820a03aaebde94c37c011c5e9b81421b50f
Reviewed-by: Friedemann Kleint <Friedemann.Kleint@theqtcompany.com>
This commit is contained in:
Olivier Goffart 2015-02-18 11:41:50 +01:00 committed by Olivier Goffart (Woboq GmbH)
parent 18ab75be81
commit be4f5d55fc
2 changed files with 3 additions and 3 deletions

View File

@ -460,7 +460,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
{
QMetaEnum en = metaEnumFromType(d->type);
if (en.isValid()) {
*str = QString::fromUtf8(en.valueToKeys(qConvertToNumber(d, ok)));
*str = QString::fromUtf8(en.valueToKey(qConvertToNumber(d, ok)));
return *ok;
}
}
@ -637,7 +637,7 @@ static bool convert(const QVariant::Private *d, int t, void *result, bool *ok)
{
QMetaEnum en = metaEnumFromType(d->type);
if (en.isValid()) {
*ba = en.valueToKeys(qConvertToNumber(d, ok));
*ba = en.valueToKey(qConvertToNumber(d, ok));
return *ok;
}
}

View File

@ -77,7 +77,7 @@ public:
}
enum MetaEnumTest_Enum0 { MetaEnumTest_Enum0_value = 42, MetaEnsureSignedEnum0 = -1 };
enum MetaEnumTest_Enum0 { MetaEnumTest_Enum0_dummy = 2, MetaEnumTest_Enum0_value = 42, MetaEnsureSignedEnum0 = -1 };
Q_ENUM(MetaEnumTest_Enum0)
enum MetaEnumTest_Enum1 { MetaEnumTest_Enum1_value = 42, MetaEnumTest_Enum1_bigValue = (Q_INT64_C(1) << 33) + 50 };
Q_ENUM(MetaEnumTest_Enum1)