diff options
Diffstat (limited to 'src/declarative/qml')
-rw-r--r-- | src/declarative/qml/qmlcomponent.cpp | 23 | ||||
-rw-r--r-- | src/declarative/qml/qmlcomponent.h | 3 | ||||
-rw-r--r-- | src/declarative/qml/qmlcomponent_p.h | 4 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompositetypedata_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompositetypemanager.cpp | 26 | ||||
-rw-r--r-- | src/declarative/qml/qmlcompositetypemanager_p.h | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlengine.cpp | 4 | ||||
-rw-r--r-- | src/declarative/qml/qmlmetaproperty.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlmetatype.cpp | 8 | ||||
-rw-r--r-- | src/declarative/qml/qmlmetatype.h | 1 | ||||
-rw-r--r-- | src/declarative/qml/qmlparser.cpp | 2 |
11 files changed, 72 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 f64547c..a99cff0 100644 --- a/src/declarative/qml/qmlcompositetypemanager.cpp +++ b/src/declarative/qml/qmlcompositetypemanager.cpp @@ -87,6 +87,7 @@ QmlComponent *QmlCompositeTypeData::toComponent(QmlEngine *engine) QmlCompiledData *cc = toCompiledComponent(engine); if (cc) { component = new QmlComponent(engine, cc, -1, -1, 0); + cc->release(); } else { component = new QmlComponent(engine, 0); component->d_func()->url = imports.baseUrl(); @@ -135,6 +136,14 @@ QmlCompositeTypeManager::QmlCompositeTypeManager(QmlEngine *e) { } +QmlCompositeTypeManager::~QmlCompositeTypeManager() +{ + for (Components::Iterator iter = components.begin(); iter != components.end();) { + (*iter)->release(); + iter = components.erase(iter); + } +} + QmlCompositeTypeData *QmlCompositeTypeManager::get(const QUrl &url) { QmlCompositeTypeData *unit = components.value(url.toString()); @@ -234,9 +243,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 cb0fc43..41cbe80 100644 --- a/src/declarative/qml/qmlcompositetypemanager_p.h +++ b/src/declarative/qml/qmlcompositetypemanager_p.h @@ -73,6 +73,7 @@ class QmlCompositeTypeManager : public QObject Q_OBJECT public: QmlCompositeTypeManager(QmlEngine *); + ~QmlCompositeTypeManager(); // Return a QmlCompositeTypeData for url. The QmlCompositeTypeData may be // cached. @@ -87,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"))); diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index f9b222f..fdba79e 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -219,6 +219,7 @@ void QmlMetaPropertyPrivate::initProperty(QObject *obj, const QString &name) if (enginePrivate && name.at(0).isUpper()) { // Attached property + //### needs to be done in a better way QmlCompositeTypeData *typeData = enginePrivate->typeManager.get(context->baseUrl()); @@ -230,6 +231,7 @@ void QmlMetaPropertyPrivate::initProperty(QObject *obj, const QString &name) if (attachedFunc != -1) type = QmlMetaProperty::Property | QmlMetaProperty::Attached; } + typeData->release(); } return; diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index c488c13..14d85ff 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -83,6 +83,7 @@ QT_BEGIN_NAMESPACE struct QmlMetaTypeData { + ~QmlMetaTypeData(); QList<QmlType *> types; typedef QHash<int, QmlType *> Ids; Ids idToType; @@ -101,6 +102,12 @@ struct QmlMetaTypeData Q_GLOBAL_STATIC(QmlMetaTypeData, metaTypeData) Q_GLOBAL_STATIC(QReadWriteLock, metaTypeDataLock) +QmlMetaTypeData::~QmlMetaTypeData() +{ + for (int i = 0; i < types.count(); ++i) + delete types.at(i); +} + class QmlTypePrivate { public: @@ -190,6 +197,7 @@ QmlType::QmlType(int type, int listType, int qmlListType, QmlType::~QmlType() { + delete d->m_customParser; delete d; } diff --git a/src/declarative/qml/qmlmetatype.h b/src/declarative/qml/qmlmetatype.h index 5ed9a5a..02c817d 100644 --- a/src/declarative/qml/qmlmetatype.h +++ b/src/declarative/qml/qmlmetatype.h @@ -151,6 +151,7 @@ public: private: friend class QmlMetaType; friend class QmlTypePrivate; + friend class QmlMetaTypeData; QmlType(int, int, int, QmlPrivate::Func, const char *, int); QmlType(int, int, int, QmlPrivate::Func, const char *, int, int, int, const QMetaObject *, QmlAttachedPropertiesFunc, const QMetaObject *, int, int, QmlPrivate::CreateFunc, const QMetaObject *, int, QmlCustomParser *); ~QmlType(); diff --git a/src/declarative/qml/qmlparser.cpp b/src/declarative/qml/qmlparser.cpp index 0f2a282..e102f05 100644 --- a/src/declarative/qml/qmlparser.cpp +++ b/src/declarative/qml/qmlparser.cpp @@ -80,6 +80,8 @@ QmlParser::Object::~Object() prop->release(); foreach(Property *prop, valueTypeProperties) prop->release(); + foreach(const DynamicProperty &prop, dynamicProperties) + if (prop.defaultValue) prop.defaultValue->release(); } const QMetaObject *Object::metaObject() const |