diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-04-30 07:24:07 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-04-30 07:24:07 (GMT) |
commit | 89f21d7269ae7bf29e718958d00da84e5c60257f (patch) | |
tree | dc78b51060cb34430177a7a1912d0ebbd674795d /src/declarative | |
parent | 3011031d0d95d47e7597a81ecbf47004664c4ed9 (diff) | |
parent | d8683cd18c852569672e43237c06dc619f193eba (diff) | |
download | Qt-89f21d7269ae7bf29e718958d00da84e5c60257f.zip Qt-89f21d7269ae7bf29e718958d00da84e5c60257f.tar.gz Qt-89f21d7269ae7bf29e718958d00da84e5c60257f.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Diffstat (limited to 'src/declarative')
-rw-r--r-- | src/declarative/qml/qdeclarativeengine.cpp | 12 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeengine_p.h | 1 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeparserstatus.cpp | 10 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeparserstatus.h | 4 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeworkerscript.cpp | 29 | ||||
-rw-r--r-- | src/declarative/qml/qdeclarativeworkerscript_p.h | 3 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativebind.cpp | 8 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativebind_p.h | 1 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeconnections.cpp | 8 | ||||
-rw-r--r-- | src/declarative/util/qdeclarativeconnections_p.h | 1 |
10 files changed, 60 insertions, 17 deletions
diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 4d23e8f..dee5ec6 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -82,6 +82,7 @@ #include <QStack> #include <QMap> #include <QPluginLoader> +#include <QtGui/qfontdatabase.h> #include <QtCore/qlibraryinfo.h> #include <QtCore/qthreadstorage.h> #include <QtCore/qthread.h> @@ -225,6 +226,7 @@ QDeclarativeScriptEngine::QDeclarativeScriptEngine(QDeclarativeEnginePrivate *pr //misc methods qtObject.setProperty(QLatin1String("openUrlExternally"),newFunction(QDeclarativeEnginePrivate::desktopOpenUrl, 1)); + qtObject.setProperty(QLatin1String("fontFamilies"),newFunction(QDeclarativeEnginePrivate::fontFamilies, 0)); qtObject.setProperty(QLatin1String("md5"),newFunction(QDeclarativeEnginePrivate::md5, 1)); qtObject.setProperty(QLatin1String("btoa"),newFunction(QDeclarativeEnginePrivate::btoa, 1)); qtObject.setProperty(QLatin1String("atob"),newFunction(QDeclarativeEnginePrivate::atob, 1)); @@ -1274,6 +1276,16 @@ QScriptValue QDeclarativeEnginePrivate::desktopOpenUrl(QScriptContext *ctxt, QSc return QScriptValue(e, ret); } +QScriptValue QDeclarativeEnginePrivate::fontFamilies(QScriptContext *ctxt, QScriptEngine *e) +{ + if(ctxt->argumentCount() != 0) + return ctxt->throwError("Qt.fontFamilies(): Invalid arguments"); + + QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(e); + QFontDatabase database; + return p->scriptValueFromVariant(database.families()); +} + QScriptValue QDeclarativeEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine *) { if (ctxt->argumentCount() != 1) diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h index 45656e8..531ac97 100644 --- a/src/declarative/qml/qdeclarativeengine_p.h +++ b/src/declarative/qml/qdeclarativeengine_p.h @@ -294,6 +294,7 @@ public: static QScriptValue tint(QScriptContext*, QScriptEngine*); static QScriptValue desktopOpenUrl(QScriptContext*, QScriptEngine*); + static QScriptValue fontFamilies(QScriptContext*, QScriptEngine*); static QScriptValue md5(QScriptContext*, QScriptEngine*); static QScriptValue btoa(QScriptContext*, QScriptEngine*); static QScriptValue atob(QScriptContext*, QScriptEngine*); diff --git a/src/declarative/qml/qdeclarativeparserstatus.cpp b/src/declarative/qml/qdeclarativeparserstatus.cpp index 978bfb4..4c4e429 100644 --- a/src/declarative/qml/qdeclarativeparserstatus.cpp +++ b/src/declarative/qml/qdeclarativeparserstatus.cpp @@ -91,19 +91,17 @@ QDeclarativeParserStatus::~QDeclarativeParserStatus() } /*! + \fn void QDeclarativeParserStatus::classBegin() + Invoked after class creation, but before any properties have been set. */ -void QDeclarativeParserStatus::classBegin() -{ -} /*! + \fn void QDeclarativeParserStatus::componentComplete() + Invoked after the root component that caused this instantiation has completed construction. At this point all static values and binding values have been assigned to the class. */ -void QDeclarativeParserStatus::componentComplete() -{ -} QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeparserstatus.h b/src/declarative/qml/qdeclarativeparserstatus.h index 34528c1..60d423e 100644 --- a/src/declarative/qml/qdeclarativeparserstatus.h +++ b/src/declarative/qml/qdeclarativeparserstatus.h @@ -56,8 +56,8 @@ public: QDeclarativeParserStatus(); virtual ~QDeclarativeParserStatus(); - virtual void classBegin(); - virtual void componentComplete(); + virtual void classBegin()=0; + virtual void componentComplete()=0; private: friend class QDeclarativeVME; diff --git a/src/declarative/qml/qdeclarativeworkerscript.cpp b/src/declarative/qml/qdeclarativeworkerscript.cpp index 138d979..c55998f 100644 --- a/src/declarative/qml/qdeclarativeworkerscript.cpp +++ b/src/declarative/qml/qdeclarativeworkerscript.cpp @@ -538,7 +538,7 @@ void QDeclarativeWorkerScriptEngine::run() by the \tt onMessage() handler of \tt myWorker. */ QDeclarativeWorkerScript::QDeclarativeWorkerScript(QObject *parent) -: QObject(parent), m_engine(0), m_scriptId(-1) +: QObject(parent), m_engine(0), m_scriptId(-1), m_componentComplete(true) { } @@ -565,7 +565,7 @@ void QDeclarativeWorkerScript::setSource(const QUrl &source) m_source = source; - if (m_engine) + if (engine()) m_engine->executeUrl(m_scriptId, m_source); emit sourceChanged(); @@ -580,7 +580,7 @@ void QDeclarativeWorkerScript::setSource(const QUrl &source) */ void QDeclarativeWorkerScript::sendMessage(const QScriptValue &message) { - if (!m_engine) { + if (!engine()) { qWarning("QDeclarativeWorkerScript: Attempt to send message before WorkerScript establishment"); return; } @@ -588,13 +588,19 @@ void QDeclarativeWorkerScript::sendMessage(const QScriptValue &message) m_engine->sendMessage(m_scriptId, QDeclarativeWorkerScriptEnginePrivate::scriptValueToVariant(message)); } -void QDeclarativeWorkerScript::componentComplete() +void QDeclarativeWorkerScript::classBegin() { - if (!m_engine) { + m_componentComplete = false; +} + +QDeclarativeWorkerScriptEngine *QDeclarativeWorkerScript::engine() +{ + if (m_engine) return m_engine; + if (m_componentComplete) { QDeclarativeEngine *engine = qmlEngine(this); if (!engine) { - qWarning("QDeclarativeWorkerScript: componentComplete() called without qmlEngine() set"); - return; + qWarning("QDeclarativeWorkerScript: engine() called without qmlEngine() set"); + return 0; } m_engine = QDeclarativeEnginePrivate::get(engine)->getWorkerScriptEngine(); @@ -602,7 +608,16 @@ void QDeclarativeWorkerScript::componentComplete() if (m_source.isValid()) m_engine->executeUrl(m_scriptId, m_source); + + return m_engine; } + return 0; +} + +void QDeclarativeWorkerScript::componentComplete() +{ + m_componentComplete = true; + engine(); // Get it started now. } /*! diff --git a/src/declarative/qml/qdeclarativeworkerscript_p.h b/src/declarative/qml/qdeclarativeworkerscript_p.h index 6cce799..80ef5f3 100644 --- a/src/declarative/qml/qdeclarativeworkerscript_p.h +++ b/src/declarative/qml/qdeclarativeworkerscript_p.h @@ -108,13 +108,16 @@ signals: void message(const QScriptValue &messageObject); protected: + virtual void classBegin(); virtual void componentComplete(); virtual bool event(QEvent *); private: + QDeclarativeWorkerScriptEngine *engine(); QDeclarativeWorkerScriptEngine *m_engine; int m_scriptId; QUrl m_source; + bool m_componentComplete; }; QT_END_NAMESPACE diff --git a/src/declarative/util/qdeclarativebind.cpp b/src/declarative/util/qdeclarativebind.cpp index 5516628..1f528e8 100644 --- a/src/declarative/util/qdeclarativebind.cpp +++ b/src/declarative/util/qdeclarativebind.cpp @@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE class QDeclarativeBindPrivate : public QObjectPrivate { public: - QDeclarativeBindPrivate() : when(true), componentComplete(false), obj(0) {} + QDeclarativeBindPrivate() : when(true), componentComplete(true), obj(0) {} bool when : 1; bool componentComplete : 1; @@ -198,6 +198,12 @@ void QDeclarativeBind::setValue(const QVariant &v) eval(); } +void QDeclarativeBind::classBegin() +{ + Q_D(QDeclarativeBind); + d->componentComplete = false; +} + void QDeclarativeBind::componentComplete() { Q_D(QDeclarativeBind); diff --git a/src/declarative/util/qdeclarativebind_p.h b/src/declarative/util/qdeclarativebind_p.h index f756e80..f89c2eb 100644 --- a/src/declarative/util/qdeclarativebind_p.h +++ b/src/declarative/util/qdeclarativebind_p.h @@ -80,6 +80,7 @@ public: void setValue(const QVariant &); protected: + virtual void classBegin(); virtual void componentComplete(); private: diff --git a/src/declarative/util/qdeclarativeconnections.cpp b/src/declarative/util/qdeclarativeconnections.cpp index 5dd825e..ffa160f 100644 --- a/src/declarative/util/qdeclarativeconnections.cpp +++ b/src/declarative/util/qdeclarativeconnections.cpp @@ -57,7 +57,7 @@ QT_BEGIN_NAMESPACE class QDeclarativeConnectionsPrivate : public QObjectPrivate { public: - QDeclarativeConnectionsPrivate() : target(0), targetSet(false), ignoreUnknownSignals(false), componentcomplete(false) {} + QDeclarativeConnectionsPrivate() : target(0), targetSet(false), ignoreUnknownSignals(false), componentcomplete(true) {} QList<QDeclarativeBoundSignal*> boundsignals; QObject *target; @@ -271,6 +271,12 @@ void QDeclarativeConnections::connectSignals() } } +void QDeclarativeConnections::classBegin() +{ + Q_D(QDeclarativeConnections); + d->componentcomplete=false; +} + void QDeclarativeConnections::componentComplete() { Q_D(QDeclarativeConnections); diff --git a/src/declarative/util/qdeclarativeconnections_p.h b/src/declarative/util/qdeclarativeconnections_p.h index b51899e..a914166 100644 --- a/src/declarative/util/qdeclarativeconnections_p.h +++ b/src/declarative/util/qdeclarativeconnections_p.h @@ -82,6 +82,7 @@ Q_SIGNALS: private: void connectSignals(); + void classBegin(); void componentComplete(); }; |