Added support for passing QEasingCurve::Type enumerator literal string as valid argument on type() js binding

svn path=/trunk/KDE/kdebase/runtime/; revision=1097616
This commit is contained in:
Bruno de Oliveira Abinader 2010-03-01 19:11:32 +00:00
parent 6722dbdd97
commit 1bd327f133

View File

@ -17,6 +17,7 @@
*/
#include <QEasingCurve>
#include <QMetaEnum>
#include <QScriptValue>
#include <QScriptEngine>
#include <QScriptContext>
@ -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<QEasingCurve::Type>(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<QEasingCurve::Type>(type));
}
}