summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2010-04-09 07:59:07 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2010-04-09 07:59:07 (GMT)
commit3d90e35abae15f133ad2a71874f6926773c96449 (patch)
tree8faae80f578c8faea02bf5a1d4855ed0bb7e402c /src
parent06c286b74274166a47df20dc425f76051fb03d4d (diff)
downloadQt-3d90e35abae15f133ad2a71874f6926773c96449.zip
Qt-3d90e35abae15f133ad2a71874f6926773c96449.tar.gz
Qt-3d90e35abae15f133ad2a71874f6926773c96449.tar.bz2
Add a Qt.isQtObject() method
QTBUG-9705
Diffstat (limited to 'src')
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp9
-rw-r--r--src/declarative/qml/qdeclarativeengine_p.h1
2 files changed, 10 insertions, 0 deletions
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp
index 944abce..e459d0f 100644
--- a/src/declarative/qml/qdeclarativeengine.cpp
+++ b/src/declarative/qml/qdeclarativeengine.cpp
@@ -225,6 +225,7 @@ QDeclarativeScriptEngine::QDeclarativeScriptEngine(QDeclarativeEnginePrivate *pr
// XXX used to add Qt.Sound class.
//types
+ qtObject.setProperty(QLatin1String("isQtObject"), newFunction(QDeclarativeEnginePrivate::isQtObject, 1));
qtObject.setProperty(QLatin1String("rgba"), newFunction(QDeclarativeEnginePrivate::rgba, 4));
qtObject.setProperty(QLatin1String("hsla"), newFunction(QDeclarativeEnginePrivate::hsla, 4));
qtObject.setProperty(QLatin1String("rect"), newFunction(QDeclarativeEnginePrivate::rect, 4));
@@ -1027,6 +1028,14 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS
return activeEnginePriv->objectClass->newQObject(obj, QMetaType::QObjectStar);
}
+QScriptValue QDeclarativeEnginePrivate::isQtObject(QScriptContext *ctxt, QScriptEngine *engine)
+{
+ if (ctxt->argumentCount() == 0)
+ return QScriptValue(engine, false);
+
+ return QScriptValue(engine, 0 != ctxt->argument(0).toQObject());
+}
+
QScriptValue QDeclarativeEnginePrivate::vector(QScriptContext *ctxt, QScriptEngine *engine)
{
if(ctxt->argumentCount() != 3)
diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h
index 6bcd0d1..7766ad6 100644
--- a/src/declarative/qml/qdeclarativeengine_p.h
+++ b/src/declarative/qml/qdeclarativeengine_p.h
@@ -317,6 +317,7 @@ public:
static QScriptValue createComponent(QScriptContext*, QScriptEngine*);
static QScriptValue createQmlObject(QScriptContext*, QScriptEngine*);
+ static QScriptValue isQtObject(QScriptContext*, QScriptEngine*);
static QScriptValue vector(QScriptContext*, QScriptEngine*);
static QScriptValue rgba(QScriptContext*, QScriptEngine*);
static QScriptValue hsla(QScriptContext*, QScriptEngine*);