X-Git-Url: https://vaikene.ee/gitweb/pswgen11.html?a=blobdiff_plain;f=src%2Flibs%2FCommon%2Futil.cpp;h=eeedb61ff19fddeab479a322c9dc0eedec681c36;hb=60aebc188674bbfb67be51958ec33171c72986b9;hp=ccabdab922921a0ac2b927149cfd8e6dc22c86d8;hpb=814d12e0a340ae11fa4a22077b37316aa41716d7;p=evaf
diff --git a/src/libs/Common/util.cpp b/src/libs/Common/util.cpp
index ccabdab..eeedb61 100644
--- a/src/libs/Common/util.cpp
+++ b/src/libs/Common/util.cpp
@@ -19,6 +19,7 @@
#include "util.h"
+#include
//-------------------------------------------------------------------
@@ -58,21 +59,38 @@ QVariant eVaf::Common::toVariant(QString const & value, QVariant const & default
break;
}
case QVariant::Bool: {
- bool ok;
- uint v = value.toUInt(&ok, 0);
if (eVaf::Common::isTrue(value))
return QVariant(true);
else if (eVaf::Common::isFalse(value))
return QVariant(false);
- else
- return QVariant(v);
+ else {
+ bool ok;
+ uint v = value.toUInt(&ok, 0);
+ if (ok)
+ return QVariant(v);
+ else
+ return defaultValue;
+ }
break;
}
case QVariant::Char: {
- if (value.size() > 0)
- return QVariant(value.at(0));
- else
- return defaultValue;
+ if (value.size() > 0) {
+ if (value.startsWith("\\0x")) {
+ bool ok;
+ char c = value.mid(1).toUInt(&ok, 16);
+ if (ok)
+ return QVariant(c);
+ }
+ else if (value.startsWith("\\0")) {
+ bool ok;
+ char c = value.mid(1).toUInt(&ok, 8);
+ if (ok)
+ return QVariant(c);
+ }
+ else
+ return QVariant(value.at(0));
+ }
+ return defaultValue;
break;
}
default: