summaryrefslogtreecommitdiffstats
path: root/src/declarative/graphicsitems/qdeclarativeloader.cpp
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/graphicsitems/qdeclarativeloader.cpp')
-rw-r--r--src/declarative/graphicsitems/qdeclarativeloader.cpp60
1 files changed, 27 insertions, 33 deletions
diff --git a/src/declarative/graphicsitems/qdeclarativeloader.cpp b/src/declarative/graphicsitems/qdeclarativeloader.cpp
index 86e438f925..ded2be31df 100644
--- a/src/declarative/graphicsitems/qdeclarativeloader.cpp
+++ b/src/declarative/graphicsitems/qdeclarativeloader.cpp
@@ -48,7 +48,7 @@
QT_BEGIN_NAMESPACE
QDeclarativeLoaderPrivate::QDeclarativeLoaderPrivate()
- : item(0), component(0), ownComponent(false), isComponentComplete(false)
+ : item(0), component(0), ownComponent(false)
{
}
@@ -262,7 +262,6 @@ void QDeclarativeLoader::setSource(const QUrl &url)
d->clear();
d->source = url;
-
if (d->source.isEmpty()) {
emit sourceChanged();
emit statusChanged();
@@ -273,9 +272,18 @@ void QDeclarativeLoader::setSource(const QUrl &url)
d->component = new QDeclarativeComponent(qmlEngine(this), d->source, this);
d->ownComponent = true;
-
- if (d->isComponentComplete)
- d->load();
+ if (!d->component->isLoading()) {
+ d->_q_sourceLoaded();
+ } else {
+ connect(d->component, SIGNAL(statusChanged(QDeclarativeComponent::Status)),
+ this, SLOT(_q_sourceLoaded()));
+ connect(d->component, SIGNAL(progressChanged(qreal)),
+ this, SIGNAL(progressChanged()));
+ emit statusChanged();
+ emit progressChanged();
+ emit sourceChanged();
+ emit itemChanged();
+ }
}
/*!
@@ -316,7 +324,6 @@ void QDeclarativeLoader::setSourceComponent(QDeclarativeComponent *comp)
d->component = comp;
d->ownComponent = false;
-
if (!d->component) {
emit sourceChanged();
emit statusChanged();
@@ -325,8 +332,18 @@ void QDeclarativeLoader::setSourceComponent(QDeclarativeComponent *comp)
return;
}
- if (d->isComponentComplete)
- d->load();
+ if (!d->component->isLoading()) {
+ d->_q_sourceLoaded();
+ } else {
+ connect(d->component, SIGNAL(statusChanged(QDeclarativeComponent::Status)),
+ this, SLOT(_q_sourceLoaded()));
+ connect(d->component, SIGNAL(progressChanged(qreal)),
+ this, SIGNAL(progressChanged()));
+ emit progressChanged();
+ emit sourceChanged();
+ emit statusChanged();
+ emit itemChanged();
+ }
}
void QDeclarativeLoader::resetSourceComponent()
@@ -334,27 +351,6 @@ void QDeclarativeLoader::resetSourceComponent()
setSourceComponent(0);
}
-void QDeclarativeLoaderPrivate::load()
-{
- Q_Q(QDeclarativeLoader);
-
- if (!isComponentComplete || !component)
- return;
-
- if (!component->isLoading()) {
- _q_sourceLoaded();
- } else {
- QObject::connect(component, SIGNAL(statusChanged(QDeclarativeComponent::Status)),
- q, SLOT(_q_sourceLoaded()));
- QObject::connect(component, SIGNAL(progressChanged(qreal)),
- q, SIGNAL(progressChanged()));
- emit q->statusChanged();
- emit q->progressChanged();
- emit q->sourceChanged();
- emit q->itemChanged();
- }
-}
-
void QDeclarativeLoaderPrivate::_q_sourceLoaded()
{
Q_Q(QDeclarativeLoader);
@@ -469,11 +465,9 @@ QDeclarativeLoader::Status QDeclarativeLoader::status() const
void QDeclarativeLoader::componentComplete()
{
- Q_D(QDeclarativeLoader);
-
QDeclarativeItem::componentComplete();
- d->isComponentComplete = true;
- d->load();
+ if (status() == Ready)
+ emit loaded();
}