diff options
author | Michael Brasser <michael.brasser@nokia.com> | 2009-07-30 23:39:53 (GMT) |
---|---|---|
committer | Michael Brasser <michael.brasser@nokia.com> | 2009-07-30 23:39:53 (GMT) |
commit | 0ce2bedf9b5da9d480b994a9b812c37d1f5caa39 (patch) | |
tree | 7e8ef6069f8c669ff6e92e23cf8b46cfad7ed3ee /src/declarative/fx/qfxitem.cpp | |
parent | a70f8a2b0966420e1911554a117e066592b1822c (diff) | |
download | Qt-0ce2bedf9b5da9d480b994a9b812c37d1f5caa39.zip Qt-0ce2bedf9b5da9d480b994a9b812c37d1f5caa39.tar.gz Qt-0ce2bedf9b5da9d480b994a9b812c37d1f5caa39.tar.bz2 |
Introduce Loader item.
The Loader item takes the qml/qmlItem functionality from Item and
moves it to a specialized subclass.
Diffstat (limited to 'src/declarative/fx/qfxitem.cpp')
-rw-r--r-- | src/declarative/fx/qfxitem.cpp | 146 |
1 files changed, 0 insertions, 146 deletions
diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 6df538e..709a243 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -51,7 +51,6 @@ #include <QtGui/qgraphicstransform.h> #include <QtDeclarative/qmlengine.h> -#include <private/qmlengine_p.h> #include "qmlstate.h" #include "qlistmodelinterface.h" #include "qfxanchors_p.h" @@ -743,151 +742,6 @@ void QFxItem::setClip(bool c) } /*! - \internal - \property QFxItem::qmlItem -*/ - -/*! \fn QFxItem *QFxItem::qmlItem() const - \internal - */ -QFxItem *QFxItem::qmlItem() const -{ - Q_D(const QFxItem); - return d->qmlItem; -} - -/*! - \qmlproperty url Item::qml - This property holds the dynamic URL of the QML for the item. - - This property is used for dynamically loading QML into the - item. Querying for the QML only has meaning if the QML has been - dynamically set; otherwise an empty URL is returned. -*/ - -/*! \fn void QFxItem::qmlChanged() - This signal is emitted whenever the item's dynamic QML - string changes. - - \sa setQml() - */ - -/*! - \property QFxItem::qml - This property holds the dynamic URL of the QML for the item. - - This property is used for dynamically loading QML into the - item. Querying for the QML only has meaning if the QML has been - dynamically set; otherwise an empty URL is returned. -*/ -QUrl QFxItem::qml() const -{ - Q_D(const QFxItem); - return d->_qml; -} - -void QFxItem::setQml(const QUrl &qml) -{ - Q_D(QFxItem); - if (d->_qml == qml) - return; - - if (!d->_qml.isEmpty()) { - QHash<QString, QFxItem *>::Iterator iter = d->_qmlChildren.find(d->_qml.toString()); - if (iter != d->_qmlChildren.end()) - (*iter)->setOpacity(0.); - } - - d->_qml = qml; - d->qmlItem = 0; - - if (d->_qml.isEmpty()) { - emit qmlChanged(); - return; - } - - QHash<QString, QFxItem *>::Iterator iter = d->_qmlChildren.find(d->_qml.toString()); - if (iter != d->_qmlChildren.end()) { - (*iter)->setOpacity(1.); - d->qmlItem = (*iter); - emit qmlChanged(); - } else { - d->_qmlcomp = - new QmlComponent(qmlEngine(this), d->_qml, this); - if (!d->_qmlcomp->isLoading()) - qmlLoaded(); - else - QObject::connect(d->_qmlcomp, SIGNAL(statusChanged(QmlComponent::Status)), - this, SLOT(qmlLoaded())); - } -} - -/*! \fn void QFxItem::newChildCreated(const QString &url, QScriptValue v) - This signal is emitted with the \a url and the script value \a v, - when a new child is created. - */ - -/*! - \internal - */ -void QFxItem::qmlLoaded() -{ - Q_D(QFxItem); - - { // newChild... - // ### - for (int i=0; i<d->_qmlnewloading.length(); ++i) { - QmlComponent *c = d->_qmlnewcomp.at(i); - if (c->isLoading()) - continue; - - QmlContext *ctxt = new QmlContext(qmlContext(this)); - QObject* o = c ? c->create(ctxt):0; - QFxItem* ret = qobject_cast<QFxItem*>(o); - if (ret) { - ret->setParentItem(this); - QScriptValue v = QmlEnginePrivate::getScriptEngine(qmlEngine(this))->newQObject(ret); - emit newChildCreated(d->_qmlnewloading.at(i).toString(),v); - } - - delete c; - d->_qmlnewloading.removeAt(i); - d->_qmlnewcomp.removeAt(i); - --i; - } - } - - // setQml... - if (d->_qmlcomp) { - QmlContext *ctxt = new QmlContext(qmlContext(this)); - ctxt->addDefaultObject(this); - - if (!d->_qmlcomp->errors().isEmpty()) { - qWarning() << d->_qmlcomp->errors(); - delete d->_qmlcomp; - d->_qmlcomp = 0; - emit qmlChanged(); - return; - } - QObject *obj = d->_qmlcomp->create(ctxt); - if (!d->_qmlcomp->errors().isEmpty()) - qWarning() << d->_qmlcomp->errors(); - QFxItem *qmlChild = qobject_cast<QFxItem *>(obj); - if (qmlChild) { - qmlChild->setParentItem(this); - d->_qmlChildren.insert(d->_qml.toString(), qmlChild); - d->qmlItem = qmlChild; - } else { - delete qmlChild; - d->_qml = QUrl(); - } - delete d->_qmlcomp; - d->_qmlcomp = 0; - emit qmlChanged(); - } -} - -/*! \qmlproperty real Item::x \qmlproperty real Item::y \qmlproperty real Item::width |