aboutsummaryrefslogtreecommitdiff
path: root/libqmenumodel/src/converter.cpp
diff options
context:
space:
mode:
authorMarco Trevisan (Treviño) <mail@3v1n0.net>2016-10-18 15:50:17 +0200
committerMarco Trevisan (Treviño) <mail@3v1n0.net>2016-10-18 15:50:17 +0200
commit36681ba81d33e3c1e66bef49450f4e7008154b61 (patch)
treea26d692fce762e44bd134dfad324f4deb0831d8e /libqmenumodel/src/converter.cpp
parentc42bc210a32f06b2850fbe010be9356d477330b0 (diff)
downloadqmenumodel-36681ba81d33e3c1e66bef49450f4e7008154b61.tar.gz
qmenumodel-36681ba81d33e3c1e66bef49450f4e7008154b61.tar.bz2
qmenumodel-36681ba81d33e3c1e66bef49450f4e7008154b61.zip
Converter: use QMetaType to check integer subtypes
Diffstat (limited to 'libqmenumodel/src/converter.cpp')
-rw-r--r--libqmenumodel/src/converter.cpp36
1 files changed, 16 insertions, 20 deletions
diff --git a/libqmenumodel/src/converter.cpp b/libqmenumodel/src/converter.cpp
index 9fd65ed..9f89662 100644
--- a/libqmenumodel/src/converter.cpp
+++ b/libqmenumodel/src/converter.cpp
@@ -131,25 +131,6 @@ QVariant Converter::toQVariant(GVariant *value)
return result;
}
-static GVariant* toGVariant(const QString &typeName, const QVariant &value)
-{
- if (typeName == "uchar") {
- return g_variant_new_byte(value.value<uchar>());
- } else if (typeName == "short") {
- return g_variant_new_int16(value.value<short>());
- } else if (typeName == "ushort") {
- return g_variant_new_uint16(value.value<ushort>());
- } else if (typeName == "long") {
- return g_variant_new_int64(value.value<long>());
- } else if (typeName == "ulong") {
- return g_variant_new_uint64(value.value<ulong>());
- } else {
- qWarning() << "QVariant type not supported:" << typeName;
- }
-
- return NULL;
-}
-
QVariant Converter::toQVariantFromVariantString(const QString &variantString)
{
GVariant *gvariant;
@@ -204,6 +185,21 @@ GVariant* Converter::toGVariant(const QVariant &value)
case QVariant::ULongLong:
result = g_variant_new_uint64(value.toULongLong());
break;
+ case QMetaType::UChar:
+ result = g_variant_new_byte(value.value<uchar>());
+ break;
+ case QMetaType::Short:
+ result = g_variant_new_int16(value.value<short>());
+ break;
+ case QMetaType::UShort:
+ result = g_variant_new_uint16(value.value<ushort>());
+ break;
+ case QMetaType::Long:
+ result = g_variant_new_int64(value.value<long>());
+ break;
+ case QMetaType::ULong:
+ result = g_variant_new_uint64(value.value<ulong>());
+ break;
case QVariant::Map:
{
GVariantBuilder *b;
@@ -243,7 +239,7 @@ GVariant* Converter::toGVariant(const QVariant &value)
break;
}
default:
- result = ::toGVariant(value.typeName(), value);
+ qWarning() << "QVariant type not supported:" << value.type();
}
return result;