diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2009-07-28 02:56:11 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2009-07-28 02:56:11 (GMT) |
commit | 0cdd8518090be320fa89efaa11ced32215cc2ccc (patch) | |
tree | 414de68c6ada9f95450a9a4410c49a4e3e72eb43 | |
parent | 7e8a096cb0ba3bbffdf0eb5aba5646cf3e1cf8bb (diff) | |
download | Qt-0cdd8518090be320fa89efaa11ced32215cc2ccc.zip Qt-0cdd8518090be320fa89efaa11ced32215cc2ccc.tar.gz Qt-0cdd8518090be320fa89efaa11ced32215cc2ccc.tar.bz2 |
Make private stuff public
commit 752a15ca makes some stuff private that is needed to be public.
Moving some stuff back to public until we make a real decision (on how
apps can interact with the engine).
-rw-r--r-- | src/declarative/fx/qfxitem.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlcomponentjs.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlcontext.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 27 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine_p.h | 3 | ||||
-rw-r--r-- | src/declarative/qml/qmlexpression.cpp | 2 | ||||
-rw-r--r-- | src/declarative/util/qmlscript.cpp | 2 |
8 files changed, 24 insertions, 18 deletions
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index f8ed7b4..09ae22c 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -821,7 +821,7 @@ void QFxItem::qmlLoaded() QFxItem* ret = qobject_cast<QFxItem*>(o); if (ret) { ret->setItemParent(this); - QScriptValue v = QmlEnginePrivate::getScriptEngine(qmlEngine(this))->newQObject(ret); + QScriptValue v = QmlEngine::getScriptEngine(qmlEngine(this))->newQObject(ret); emit newChildCreated(d->_qmlnewloading.at(i).toString(),v); } diff --git a/src/declarative/qml/qmlcomponentjs.cpp b/src/declarative/qml/qmlcomponentjs.cpp index df3e834..2552f78 100644 --- a/src/declarative/qml/qmlcomponentjs.cpp +++ b/src/declarative/qml/qmlcomponentjs.cpp @@ -84,7 +84,7 @@ QScriptValue QmlComponentJS::createObject() { Q_D(QmlComponentJS); QObject* ret = create(d->ctxt); - return QmlEnginePrivate::qmlScriptObject(ret, d->engine); + return QmlEngine::qmlScriptObject(ret, d->engine); } /*! diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp index dabaa5e..bf549d8 100644 --- a/src/declarative/qml/qmlcontext.cpp +++ b/src/declarative/qml/qmlcontext.cpp @@ -106,7 +106,7 @@ void QmlContextPrivate::init() parent->d_func()->childContexts.insert(q); //set scope chain - QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); + QScriptEngine *scriptEngine = QmlEngine::getScriptEngine(engine); QScriptValue scopeObj = scriptEngine->newObject(QmlEnginePrivate::get(engine)->contextClass, scriptEngine->newVariant(QVariant::fromValue((QObject*)q))); if (!parent) diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 321feb9..0016144 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -520,6 +520,13 @@ void QmlInstanceDeclarativeData::destroyed(QObject *object) delete this; } +/*! A way to access the QScriptEngine, so that you can add your own objects. + This function is likely to be removed upon further reflection. +*/ +QScriptEngine *QmlEngine::getScriptEngine(QmlEngine *e) +{ + return &e->d_func()->scriptEngine; +} /*! \internal */ /* QScriptEngine *QmlEngine::scriptEngine() @@ -533,14 +540,14 @@ QScriptEngine *QmlEngine::scriptEngine() Creates a QScriptValue allowing you to use \a object in QML script. \a engine is the QmlEngine it is to be created in. - The QScriptValue returned is a QtScript Object, not a QtScript QObject, due - to the special needs of QML requiring more functionality than a standard + The QScriptValue returned is a Qml Script Object, not a QtScript QObject, + due to the special needs of QML requiring more functionality than a standard QtScript QObject. */ -QScriptValue QmlEnginePrivate::qmlScriptObject(QObject* object, +QScriptValue QmlEngine::qmlScriptObject(QObject* object, QmlEngine* engine) { - QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); + QScriptEngine *scriptEngine = QmlEngine::getScriptEngine(engine); return scriptEngine->newObject(new QmlObjectScriptClass(engine), scriptEngine->newQObject(object)); } @@ -684,13 +691,13 @@ QScriptValue QmlEnginePrivate::createQmlObject(QScriptContext *ctxt, QScriptEngi if(obj) { obj->setParent(parentArg); obj->setProperty("parent", QVariant::fromValue<QObject*>(parentArg)); - return qmlScriptObject(obj, activeEngine); + return QmlEngine::qmlScriptObject(obj, activeEngine); } return engine->nullValue(); } QmlScriptClass::QmlScriptClass(QmlEngine *bindengine) -: QScriptClass(QmlEnginePrivate::getScriptEngine(bindengine)), +: QScriptClass(QmlEngine::getScriptEngine(bindengine)), engine(bindengine) { } @@ -780,7 +787,7 @@ QScriptValue QmlContextScriptClass::property(const QScriptValue &object, uint basicId = id & QmlScriptClass::ClassIdMask; - QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); + QScriptEngine *scriptEngine = QmlEngine::getScriptEngine(engine); QmlEnginePrivate *ep = QmlEnginePrivate::get(engine); switch (basicId) { @@ -840,7 +847,7 @@ void QmlContextScriptClass::setProperty(QScriptValue &object, int objIdx = (id & QmlScriptClass::ClassIdSelectorMask) >> 24; QObject *obj = bindContext->d_func()->defaultObjects.at(objIdx); - QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); + QScriptEngine *scriptEngine = QmlEngine::getScriptEngine(engine); QScriptValue oldact = scriptEngine->currentContext()->activationObject(); scriptEngine->currentContext()->setActivationObject(scriptEngine->globalObject()); @@ -948,7 +955,7 @@ QmlObjectScriptClass::QmlObjectScriptClass(QmlEngine *bindEngine) : QmlScriptClass(bindEngine) { engine = bindEngine; - QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(bindEngine); + QScriptEngine *scriptEngine = QmlEngine::getScriptEngine(bindEngine); prototypeObject = scriptEngine->newObject(); prototypeObject.setProperty(QLatin1String("destroy"), scriptEngine->newFunction(QmlObjectDestroy)); @@ -1020,7 +1027,7 @@ void QmlObjectScriptClass::setProperty(QScriptValue &object, qWarning() << "Set QmlObject Property" << name.toString() << value.toVariant(); #endif - QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); + QScriptEngine *scriptEngine = QmlEngine::getScriptEngine(engine); QScriptValue oldact = scriptEngine->currentContext()->activationObject(); scriptEngine->currentContext()->setActivationObject(scriptEngine->globalObject()); diff --git a/src/declarative/qml/qmlengine.h b/src/declarative/qml/qmlengine.h index 6066059..a3457f0 100644 --- a/src/declarative/qml/qmlengine.h +++ b/src/declarative/qml/qmlengine.h @@ -86,6 +86,8 @@ public: static QmlContext *contextForObject(const QObject *); static void setContextForObject(QObject *, QmlContext *); + static QScriptValue qmlScriptObject(QObject*, QmlEngine*); + static QScriptEngine *getScriptEngine(QmlEngine *e); private: Q_DECLARE_PRIVATE(QmlEngine) }; diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index 18cdd83..7b459e9 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -193,12 +193,9 @@ public: bool resolveType(const Imports&, const QByteArray& type, QmlType** type_return, QUrl* url_return, ImportedNamespace** ns_return=0) const; void resolveTypeInNamespace(ImportedNamespace*, const QByteArray& type, QmlType** type_return, QUrl* url_return ) const; - - static QScriptValue qmlScriptObject(QObject*, QmlEngine*); static QScriptValue createComponent(QScriptContext*, QScriptEngine*); static QScriptValue createQmlObject(QScriptContext*, QScriptEngine*); - static QScriptEngine *getScriptEngine(QmlEngine *e) { return &e->d_func()->scriptEngine; } static QmlEnginePrivate *get(QmlEngine *e) { return e->d_func(); } }; diff --git a/src/declarative/qml/qmlexpression.cpp b/src/declarative/qml/qmlexpression.cpp index 2c06efa..990722a 100644 --- a/src/declarative/qml/qmlexpression.cpp +++ b/src/declarative/qml/qmlexpression.cpp @@ -240,7 +240,7 @@ QVariant QmlExpressionPrivate::evalQtScript() if (me) ctxtPriv->defaultObjects.insert(ctxtPriv->highPriorityCount, me); - QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); + QScriptEngine *scriptEngine = QmlEngine::getScriptEngine(engine); QScriptValueList oldScopeChain = scriptEngine->currentContext()->scopeChain(); diff --git a/src/declarative/util/qmlscript.cpp b/src/declarative/util/qmlscript.cpp index ca9aad5..df05d8e 100644 --- a/src/declarative/util/qmlscript.cpp +++ b/src/declarative/util/qmlscript.cpp @@ -185,7 +185,7 @@ void QmlScriptPrivate::addScriptToEngine(const QString &script, const QString &s Q_Q(QmlScript); QmlEngine *engine = qmlEngine(q); QmlContext *context = qmlContext(q); - QScriptEngine *scriptEngine = QmlEnginePrivate::getScriptEngine(engine); + QScriptEngine *scriptEngine = QmlEngine::getScriptEngine(engine); QScriptContext *currentContext = scriptEngine->currentContext(); QScriptValueList oldScopeChain = currentContext->scopeChain(); |