summaryrefslogtreecommitdiffstats
path: root/src/declarative/qml
diff options
context:
space:
mode:
Diffstat (limited to 'src/declarative/qml')
-rw-r--r--src/declarative/qml/qmlcomponent.cpp23
-rw-r--r--src/declarative/qml/qmlcomponent.h3
-rw-r--r--src/declarative/qml/qmlcomponent_p.h4
-rw-r--r--src/declarative/qml/qmlcompositetypedata_p.h2
-rw-r--r--src/declarative/qml/qmlcompositetypemanager.cpp17
-rw-r--r--src/declarative/qml/qmlcompositetypemanager_p.h1
-rw-r--r--src/declarative/qml/qmlengine.cpp4
7 files changed, 49 insertions, 5 deletions
diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp
index e897cce..f291ac0 100644
--- a/src/declarative/qml/qmlcomponent.cpp
+++ b/src/declarative/qml/qmlcomponent.cpp
@@ -121,6 +121,14 @@ void QmlComponentPrivate::typeDataReady()
emit q->statusChanged(q->status());
}
+void QmlComponentPrivate::updateProgress(qreal p)
+{
+ Q_Q(QmlComponent);
+
+ progress = p;
+ emit q->progressChanged(p);
+}
+
void QmlComponentPrivate::fromTypeData(QmlCompositeTypeData *data)
{
url = data->imports.baseUrl();
@@ -238,6 +246,12 @@ bool QmlComponent::isLoading() const
return status() == Loading;
}
+qreal QmlComponent::progress() const
+{
+ Q_D(const QmlComponent);
+ return d->progress;
+}
+
/*!
\fn void QmlComponent::statusChanged(QmlComponent::Status status)
@@ -343,7 +357,9 @@ void QmlComponent::setData(const QByteArray &data, const QUrl &url)
}
+ d->progress = 1.0;
emit statusChanged(status());
+ emit progressChanged(d->progress);
}
/*!
@@ -364,17 +380,16 @@ void QmlComponent::loadUrl(const QUrl &url)
QmlEnginePrivate::get(d->engine)->typeManager.get(d->url);
if (data->status == QmlCompositeTypeData::Waiting) {
-
d->typeData = data;
d->typeData->addWaiter(d);
-
+ d->progress = data->progress;
} else {
-
d->fromTypeData(data);
-
+ d->progress = 1.0;
}
emit statusChanged(status());
+ emit progressChanged(d->progress);
}
/*!
diff --git a/src/declarative/qml/qmlcomponent.h b/src/declarative/qml/qmlcomponent.h
index 60b7ccd..af250e5 100644
--- a/src/declarative/qml/qmlcomponent.h
+++ b/src/declarative/qml/qmlcomponent.h
@@ -84,6 +84,8 @@ public:
QList<QmlError> errors() const;
+ qreal progress() const;
+
QUrl url() const;
virtual QObject *create(QmlContext *context = 0);
@@ -95,6 +97,7 @@ public:
Q_SIGNALS:
void statusChanged(QmlComponent::Status);
+ void progressChanged(qreal);
protected:
QmlComponent(QmlComponentPrivate &dd, QObject* parent);
diff --git a/src/declarative/qml/qmlcomponent_p.h b/src/declarative/qml/qmlcomponent_p.h
index 4b459c2..2b25b78 100644
--- a/src/declarative/qml/qmlcomponent_p.h
+++ b/src/declarative/qml/qmlcomponent_p.h
@@ -74,15 +74,17 @@ class QmlComponentPrivate : public QObjectPrivate
Q_DECLARE_PUBLIC(QmlComponent)
public:
- QmlComponentPrivate() : typeData(0), start(-1), count(-1), cc(0), completePending(false), engine(0) {}
+ QmlComponentPrivate() : typeData(0), progress(0.), start(-1), count(-1), cc(0), completePending(false), engine(0) {}
QmlCompositeTypeData *typeData;
void typeDataReady();
+ void updateProgress(qreal);
void fromTypeData(QmlCompositeTypeData *data);
QList<QmlError> errors;
QUrl url;
+ qreal progress;
int start;
int count;
diff --git a/src/declarative/qml/qmlcompositetypedata_p.h b/src/declarative/qml/qmlcompositetypedata_p.h
index 54933c4..044b4ca 100644
--- a/src/declarative/qml/qmlcompositetypedata_p.h
+++ b/src/declarative/qml/qmlcompositetypedata_p.h
@@ -108,6 +108,8 @@ struct QmlCompositeTypeData : public QmlRefCount
void addWaiter(QmlComponentPrivate *p);
void remWaiter(QmlComponentPrivate *p);
+ qreal progress;
+
private:
friend class QmlCompositeTypeManager;
friend class QmlCompiler;
diff --git a/src/declarative/qml/qmlcompositetypemanager.cpp b/src/declarative/qml/qmlcompositetypemanager.cpp
index 4f16bc4..bcfbcc8 100644
--- a/src/declarative/qml/qmlcompositetypemanager.cpp
+++ b/src/declarative/qml/qmlcompositetypemanager.cpp
@@ -242,9 +242,26 @@ void QmlCompositeTypeManager::loadSource(QmlCompositeTypeData *unit)
engine->networkAccessManager()->get(QNetworkRequest(url));
QObject::connect(reply, SIGNAL(finished()),
this, SLOT(replyFinished()));
+ QObject::connect(reply, SIGNAL(downloadProgress(qint64,qint64)),
+ this, SLOT(requestProgress(qint64,qint64)));
}
}
+void QmlCompositeTypeManager::requestProgress(qint64 received, qint64 total)
+{
+ if (total <= 0)
+ return;
+ QNetworkReply *reply = static_cast<QNetworkReply *>(sender());
+
+ QmlCompositeTypeData *unit = components.value(reply->url().toString());
+ Q_ASSERT(unit);
+
+ unit->progress = qreal(received)/total;
+
+ foreach (QmlComponentPrivate *comp, unit->waiters)
+ comp->updateProgress(unit->progress);
+}
+
void QmlCompositeTypeManager::setData(QmlCompositeTypeData *unit,
const QByteArray &data,
const QUrl &url)
diff --git a/src/declarative/qml/qmlcompositetypemanager_p.h b/src/declarative/qml/qmlcompositetypemanager_p.h
index 1b28044..41cbe80 100644
--- a/src/declarative/qml/qmlcompositetypemanager_p.h
+++ b/src/declarative/qml/qmlcompositetypemanager_p.h
@@ -88,6 +88,7 @@ public:
private Q_SLOTS:
void replyFinished();
+ void requestProgress(qint64 received, qint64 total);
private:
void loadSource(QmlCompositeTypeData *);
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 6d3506c..e3d4840 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -1509,6 +1509,10 @@ public:
if (s) {
if (s->find(unqualifiedtype,vmajor,vminor,type_return,url_return))
return true;
+ if (s->urls.count() == 1 && !s->isBuiltin[0] && !s->isLibrary[0] && url_return) {
+ *url_return = QUrl(s->urls[0]+"/").resolved(QUrl(QLatin1String(unqualifiedtype + ".qml")));
+ return true;
+ }
}
if (url_return) {
*url_return = base.resolved(QUrl(QLatin1String(type + ".qml")));