From 1bd327f133762dabdb18d0231580b4b0d821f66d Mon Sep 17 00:00:00 2001 From: Bruno de Oliveira Abinader Date: Mon, 1 Mar 2010 19:11:32 +0000 Subject: [PATCH] Added support for passing QEasingCurve::Type enumerator literal string as valid argument on type() js binding svn path=/trunk/KDE/kdebase/runtime/; revision=1097616 --- .../javascript/simplebindings/easingcurve.cpp | 16 ++++++++++++---- 1 file changed, 12 insertions(+), 4 deletions(-) diff --git a/scriptengines/javascript/simplebindings/easingcurve.cpp b/scriptengines/javascript/simplebindings/easingcurve.cpp index bf74138bd..8bd0a5eb9 100644 --- a/scriptengines/javascript/simplebindings/easingcurve.cpp +++ b/scriptengines/javascript/simplebindings/easingcurve.cpp @@ -17,6 +17,7 @@ */ #include +#include #include #include #include @@ -55,11 +56,18 @@ static QScriptValue type(QScriptContext *ctx, QScriptEngine *eng) if (ctx->argumentCount()) { QScriptValue arg = ctx->argument(0); + + qint32 type = -1; if (arg.isNumber()) { - qint32 type = arg.toInt32(); - if (type > -1 && type < QEasingCurve::Custom) { - self->setType(static_cast(type)); - } + type = arg.toInt32(); + } else if (arg.isString()) { + QMetaObject meta = QEasingCurve::staticMetaObject; + QMetaEnum easingCurveEnum = meta.enumerator(meta.indexOfEnumerator("Type")); + + type = easingCurveEnum.keyToValue(arg.toString().toAscii().data()); + } + if (type > -1 && type < QEasingCurve::Custom) { + self->setType(static_cast(type)); } }