~ubuntu-branches/ubuntu/lucid/kdebase-runtime/lucid

« back to all changes in this revision

Viewing changes to plasma/scriptengines/javascript/simplebindings/easingcurve.cpp

  • Committer: Bazaar Package Importer
  • Author(s): Jonathan Riddell
  • Date: 2010-03-29 18:14:36 UTC
  • mto: This revision was merged to the branch mainline in revision 109.
  • Revision ID: james.westby@ubuntu.com-20100329181436-fb4m27cpigph5apt
Tags: upstream-4.4.2
ImportĀ upstreamĀ versionĀ 4.4.2

Show diffs side-by-side

added added

removed removed

Lines of Context:
17
17
 */
18
18
 
19
19
#include <QEasingCurve>
 
20
#include <QMetaEnum>
20
21
#include <QScriptValue>
21
22
#include <QScriptEngine>
22
23
#include <QScriptContext>
55
56
 
56
57
    if (ctx->argumentCount()) {
57
58
        QScriptValue arg = ctx->argument(0);
 
59
 
 
60
        qint32 type = -1;
58
61
        if (arg.isNumber()) {
59
 
            qint32 type = arg.toInt32();
 
62
            type = arg.toInt32();
 
63
        } else if (arg.isString()) {
 
64
            QMetaObject meta = QEasingCurve::staticMetaObject;
 
65
            QMetaEnum easingCurveEnum = meta.enumerator(meta.indexOfEnumerator("Type"));
 
66
 
 
67
            type = easingCurveEnum.keyToValue(arg.toString().toAscii().data());
 
68
        }
60
69
            if (type > -1 && type < QEasingCurve::Custom) {
61
70
                self->setType(static_cast<QEasingCurve::Type>(type));
62
71
            }
63
72
        }
64
 
    }
65
73
 
66
74
    return QScriptValue(eng, self->type());
67
75
}