summaryrefslogtreecommitdiffstats
path: root/src/script/qscriptextqobject.cpp
diff options
context:
space:
mode:
authorBradley T. Hughes <bradley.hughes@nokia.com>2009-05-20 12:45:16 (GMT)
committerBradley T. Hughes <bradley.hughes@nokia.com>2009-05-20 12:45:16 (GMT)
commit7b49dee3036603a99e8367f715d6ebde933ab6ba (patch)
tree1c0d56f5e487e76c5470aeb9b62f2b033f25836d /src/script/qscriptextqobject.cpp
parentc6f8b600cb1635bef425b3d2232213fb41ea96bd (diff)
parentfc6e0155cc3fa9beb3b48704a1effe87a74c2779 (diff)
downloadQt-7b49dee3036603a99e8367f715d6ebde933ab6ba.zip
Qt-7b49dee3036603a99e8367f715d6ebde933ab6ba.tar.gz
Qt-7b49dee3036603a99e8367f715d6ebde933ab6ba.tar.bz2
Merge branch 'master' of git@scm.dev.nokia.troll.no:qt/qt
Diffstat (limited to 'src/script/qscriptextqobject.cpp')
-rw-r--r--src/script/qscriptextqobject.cpp33
1 files changed, 26 insertions, 7 deletions
diff --git a/src/script/qscriptextqobject.cpp b/src/script/qscriptextqobject.cpp
index d18c3da..4522807 100644
--- a/src/script/qscriptextqobject.cpp
+++ b/src/script/qscriptextqobject.cpp
@@ -425,7 +425,7 @@ static void callQtMethod(QScriptContextPrivate *context, QMetaMethod::MethodType
matchDistance += 10;
}
}
- } else if (actual.isNumber()) {
+ } else if (actual.isNumber() || actual.isString()) {
// see if it's an enum value
QMetaEnum m;
if (argType.isMetaEnum()) {
@@ -436,11 +436,21 @@ static void callQtMethod(QScriptContextPrivate *context, QMetaMethod::MethodType
m = meta->enumerator(mi);
}
if (m.isValid()) {
- int ival = actual.toInt32();
- if (m.valueToKey(ival) != 0) {
- qVariantSetValue(v, ival);
- converted = true;
- matchDistance += 10;
+ if (actual.isNumber()) {
+ int ival = actual.toInt32();
+ if (m.valueToKey(ival) != 0) {
+ qVariantSetValue(v, ival);
+ converted = true;
+ matchDistance += 10;
+ }
+ } else {
+ QString sval = actual.toString();
+ int ival = m.keyToValue(sval.toLatin1());
+ if (ival != -1) {
+ qVariantSetValue(v, ival);
+ converted = true;
+ matchDistance += 10;
+ }
}
}
}
@@ -1809,7 +1819,16 @@ void QScript::QtPropertyFunction::execute(QScriptContextPrivate *context)
}
} else {
// set
- QVariant v = variantFromValue(eng_p, prop.userType(), context->argument(0));
+ QScriptValueImpl arg = context->argument(0);
+ QVariant v;
+ if (prop.isEnumType() && arg.isString()
+ && !eng_p->demarshalFunction(prop.userType())) {
+ // give QMetaProperty::write() a chance to convert from
+ // string to enum value
+ v = arg.toString();
+ } else {
+ v = variantFromValue(eng_p, prop.userType(), arg);
+ }
QScriptable *scriptable = scriptableFromQObject(qobject);
QScriptEngine *oldEngine = 0;