diff options
author | Alan Alpert <alan.alpert@nokia.com> | 2010-05-20 08:22:14 (GMT) |
---|---|---|
committer | Alan Alpert <alan.alpert@nokia.com> | 2010-05-20 08:22:14 (GMT) |
commit | d92b8e0fdcbfcad0c98b8c51fe2bd6451868af62 (patch) | |
tree | 462bf65a95e6de5438c728cbf157994e9684cd37 /src/declarative | |
parent | eff255bd29a8cbd09494f9e9480c2e4b07869386 (diff) | |
parent | a948c797e0c45c965ada005b34c274514a3c4d42 (diff) | |
download | Qt-d92b8e0fdcbfcad0c98b8c51fe2bd6451868af62.zip Qt-d92b8e0fdcbfcad0c98b8c51fe2bd6451868af62.tar.gz Qt-d92b8e0fdcbfcad0c98b8c51fe2bd6451868af62.tar.bz2 |
Merge branch '4.7' of scm.dev.nokia.troll.no:qt/qt-qml into 4.7
Conflicts:
examples/declarative/toys/dynamicscene/qml/itemCreation.js
Diffstat (limited to 'src/declarative')
18 files changed, 110 insertions, 65 deletions
diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index c121a2d..25c2417 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -6,8 +6,11 @@ Flickable: - flickingHorizontally and flickingVertically properties added - movingHorizontally and movingVertically properties added - flickDirection is renamed flickableDirection -Component: isReady, isLoading, isError and isNull properties removed, use - status property instead +Component: + - isReady, isLoading, isError and isNull properties removed, use + status property instead + - errorsString() renamed to errorString() + QList<QObject*> models no longer provide properties in model object. The properties are now updated when the object changes. An object's property "foo" may now be accessed as "foo", modelData.foo" or model.modelData.foo" diff --git a/src/declarative/graphicsitems/qdeclarativeflickable.cpp b/src/declarative/graphicsitems/qdeclarativeflickable.cpp index 3c0f5a2..560d586 100644 --- a/src/declarative/graphicsitems/qdeclarativeflickable.cpp +++ b/src/declarative/graphicsitems/qdeclarativeflickable.cpp @@ -415,7 +415,7 @@ void QDeclarativeFlickablePrivate::updateBeginningEnd() These properties are typically used to draw a scrollbar. For example: \snippet doc/src/snippets/declarative/flickableScrollbar.qml 0 - \dots 4 + \dots 8 \snippet doc/src/snippets/declarative/flickableScrollbar.qml 1 \sa {declarative/ui-components/scrollbar}{scrollbar example} diff --git a/src/declarative/graphicsitems/qdeclarativegridview.cpp b/src/declarative/graphicsitems/qdeclarativegridview.cpp index e1874b8..906f1fc 100644 --- a/src/declarative/graphicsitems/qdeclarativegridview.cpp +++ b/src/declarative/graphicsitems/qdeclarativegridview.cpp @@ -679,8 +679,10 @@ void QDeclarativeGridViewPrivate::createHighlight() highlightYAnimator = new QSmoothedAnimation(q); highlightYAnimator->target = QDeclarativeProperty(highlight->item, QLatin1String("y")); highlightYAnimator->userDuration = highlightMoveDuration; - highlightXAnimator->restart(); - highlightYAnimator->restart(); + if (autoHighlight) { + highlightXAnimator->restart(); + highlightYAnimator->restart(); + } changed = true; } } @@ -1226,8 +1228,8 @@ void QDeclarativeGridView::setHighlight(QDeclarativeComponent *highlight) id: myHighlight Rectangle { id: wrapper; color: "lightsteelblue"; radius: 4; width: 320; height: 60 - SpringFollow on y { source: Wrapper.GridView.view.currentItem.y; spring: 3; damping: 0.2 } - SpringFollow on x { source: Wrapper.GridView.view.currentItem.x; spring: 3; damping: 0.2 } + SpringFollow on y { source: wrapper.GridView.view.currentItem.y; spring: 3; damping: 0.2 } + SpringFollow on x { source: wrapper.GridView.view.currentItem.x; spring: 3; damping: 0.2 } } } \endcode @@ -1243,7 +1245,12 @@ void QDeclarativeGridView::setHighlightFollowsCurrentItem(bool autoHighlight) Q_D(QDeclarativeGridView); if (d->autoHighlight != autoHighlight) { d->autoHighlight = autoHighlight; - d->updateHighlight(); + if (autoHighlight) { + d->updateHighlight(); + } else if (d->highlightXAnimator) { + d->highlightXAnimator->stop(); + d->highlightYAnimator->stop(); + } } } diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index 23a6f63..78c56d6 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -851,13 +851,15 @@ void QDeclarativeListViewPrivate::createHighlight() highlightPosAnimator->target = QDeclarativeProperty(highlight->item, posProp); highlightPosAnimator->velocity = highlightMoveSpeed; highlightPosAnimator->userDuration = highlightMoveDuration; - highlightPosAnimator->restart(); const QLatin1String sizeProp(orient == QDeclarativeListView::Vertical ? "height" : "width"); highlightSizeAnimator = new QSmoothedAnimation(q); highlightSizeAnimator->velocity = highlightResizeSpeed; highlightSizeAnimator->userDuration = highlightResizeDuration; highlightSizeAnimator->target = QDeclarativeProperty(highlight->item, sizeProp); - highlightSizeAnimator->restart(); + if (autoHighlight) { + highlightPosAnimator->restart(); + highlightSizeAnimator->restart(); + } changed = true; } } @@ -1321,7 +1323,7 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m \snippet doc/src/snippets/declarative/listview/ContactModel.qml 0 - A ListView can display the data in the model, like this: + Another component can display this model data in a ListView, like this: \table \row @@ -1332,13 +1334,13 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m \endtable Here, the ListView creates a \c ContactModel component for its model, and a \l Text element - for its delegate. The view creates a new \l Text component for each item in the model. Note + for its delegate. The view will create a new \l Text component for each item in the model. Notice the delegate is able to access the model's \c name and \c number data directly. An improved list view is shown below. The delegate is visually improved and is moved into a separate \c contactDelegate component. Also, the currently selected item is highlighted with a blue \l Rectangle using the \l highlight property, and \c focus is set to \c true - to enable keyboard navigation for the list. + to enable keyboard navigation for the list view. \table \row @@ -1346,10 +1348,10 @@ void QDeclarativeListViewPrivate::flick(AxisData &data, qreal minExtent, qreal m \o \image listview-highlight.png \endtable - Delegates are instantiated as needed and may be destroyed at any time. + In a ListView, delegates are instantiated as needed and may be destroyed at any time. State should \e never be stored in a delegate. - \bold Note that views do not enable \e clip automatically. If the view + \note Views do not enable \e clip automatically. If the view is not clipped by another item or the screen, it will be necessary to set \e {clip: true} in order to have the out of view items clipped nicely. @@ -1682,7 +1684,14 @@ void QDeclarativeListView::setHighlightFollowsCurrentItem(bool autoHighlight) Q_D(QDeclarativeListView); if (d->autoHighlight != autoHighlight) { d->autoHighlight = autoHighlight; - d->updateHighlight(); + if (autoHighlight) { + d->updateHighlight(); + } else { + if (d->highlightPosAnimator) + d->highlightPosAnimator->stop(); + if (d->highlightSizeAnimator) + d->highlightSizeAnimator->stop(); + } emit highlightFollowsCurrentItemChanged(); } } @@ -1693,9 +1702,9 @@ void QDeclarativeListView::setHighlightFollowsCurrentItem(bool autoHighlight) \qmlproperty real ListView::preferredHighlightEnd \qmlproperty enumeration ListView::highlightRangeMode - These properties set the preferred range of the highlight (current item) - within the view. The \c preferredHighlightEnd must be greater than or equal to - \c preferredHighlightBegin. + These properties define the preferred range of the highlight (for the current item) + within the view. The \c preferredHighlightBegin value must be less than the + \c preferredHighlightEnd value. These properties affect the position of the current item when the list is scrolled. For example, if the currently selected item should stay in the middle of the @@ -1794,8 +1803,8 @@ void QDeclarativeListView::setSpacing(qreal spacing) Possible values: \list - \o ListView.Horizontal - Items are laid out horizontally. - \o ListView.Vertical - Items are laid out vertically. This is the default value. + \o ListView.Horizontal - Items are laid out horizontally + \o ListView.Vertical (default) - Items are laid out vertically \endlist \table diff --git a/src/declarative/graphicsitems/qdeclarativerectangle.cpp b/src/declarative/graphicsitems/qdeclarativerectangle.cpp index ccabbde..d098aa0 100644 --- a/src/declarative/graphicsitems/qdeclarativerectangle.cpp +++ b/src/declarative/graphicsitems/qdeclarativerectangle.cpp @@ -380,7 +380,9 @@ void QDeclarativeRectangle::generateBorderedRect() key += d->pen->color().name() % QString::number(d->pen->color().alpha(), 16); if (!QPixmapCache::find(key, &d->rectImage)) { - d->rectImage = QPixmap(pw*2 + 3, pw*2 + 3); + // Adding 5 here makes qDrawBorderPixmap() paint correctly with smooth: true + // See QTBUG-7999 and QTBUG-10765 for more details. + d->rectImage = QPixmap(pw*2 + 5, pw*2 + 5); d->rectImage.fill(Qt::transparent); QPainter p(&(d->rectImage)); p.setRenderHint(QPainter::Antialiasing); diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index 291378f..c6ee46f 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -1224,7 +1224,7 @@ void QDeclarativeVisualDataModel::_q_itemsChanged(int index, int count, if (d->m_listModelInterface) roleName = d->m_listModelInterface->toString(role); else if (d->m_abstractItemModel) - roleName = d->m_abstractItemModel->roleNames().value(role); + roleName = QString::fromUtf8(d->m_abstractItemModel->roleNames().value(role)); qmlInfo(this) << "Changing role not present in item: " << roleName; } } diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index e757675..3f11425 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -246,7 +246,7 @@ QDeclarativeComponent::~QDeclarativeComponent() \o Component.Ready - the component has been loaded, and can be used to create instances. \o Component.Loading - the component is currently being loaded \o Component.Error - an error occurred while loading the component. - Calling errorsString() will provide a human-readable description of any errors. + Calling errorString() will provide a human-readable description of any errors. \endlist */ @@ -492,7 +492,7 @@ QList<QDeclarativeError> QDeclarativeComponent::errors() const } /*! - \qmlmethod string Component::errorsString() + \qmlmethod string Component::errorString() Returns a human-readable description of any errors. @@ -504,9 +504,9 @@ QList<QDeclarativeError> QDeclarativeComponent::errors() const /*! \internal - errorsString is only meant as a way to get the errors in script + errorString is only meant as a way to get the errors in script */ -QString QDeclarativeComponent::errorsString() const +QString QDeclarativeComponent::errorString() const { Q_D(const QDeclarativeComponent); QString ret; diff --git a/src/declarative/qml/qdeclarativecomponent.h b/src/declarative/qml/qdeclarativecomponent.h index 688e233..1d1fca7 100644 --- a/src/declarative/qml/qdeclarativecomponent.h +++ b/src/declarative/qml/qdeclarativecomponent.h @@ -86,7 +86,7 @@ public: bool isLoading() const; QList<QDeclarativeError> errors() const; - Q_INVOKABLE QString errorsString() const; + Q_INVOKABLE QString errorString() const; qreal progress() const; diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 3ab94d3..0a75532 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1024,14 +1024,14 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS foreach (const QDeclarativeError &error, errors){ errstr += QLatin1String(" ") + error.toString() + QLatin1String("\n"); QScriptValue qmlErrObject = ctxt->engine()->newObject(); - qmlErrObject.setProperty("lineNumber", QScriptValue(error.line())); - qmlErrObject.setProperty("columnNumber", QScriptValue(error.column())); - qmlErrObject.setProperty("fileName", QScriptValue(error.url().toString())); - qmlErrObject.setProperty("message", QScriptValue(error.description())); + qmlErrObject.setProperty(QLatin1String("lineNumber"), QScriptValue(error.line())); + qmlErrObject.setProperty(QLatin1String("columnNumber"), QScriptValue(error.column())); + qmlErrObject.setProperty(QLatin1String("fileName"), QScriptValue(error.url().toString())); + qmlErrObject.setProperty(QLatin1String("message"), QScriptValue(error.description())); arr.setProperty(i++, qmlErrObject); } QScriptValue err = ctxt->throwError(errstr); - err.setProperty("qmlErrors",arr); + err.setProperty(QLatin1String("qmlErrors"),arr); return err; } @@ -1051,14 +1051,14 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS foreach (const QDeclarativeError &error, errors){ errstr += QLatin1String(" ") + error.toString() + QLatin1String("\n"); QScriptValue qmlErrObject = ctxt->engine()->newObject(); - qmlErrObject.setProperty("lineNumber", QScriptValue(error.line())); - qmlErrObject.setProperty("columnNumber", QScriptValue(error.column())); - qmlErrObject.setProperty("fileName", QScriptValue(error.url().toString())); - qmlErrObject.setProperty("message", QScriptValue(error.description())); + qmlErrObject.setProperty(QLatin1String("lineNumber"), QScriptValue(error.line())); + qmlErrObject.setProperty(QLatin1String("columnNumber"), QScriptValue(error.column())); + qmlErrObject.setProperty(QLatin1String("fileName"), QScriptValue(error.url().toString())); + qmlErrObject.setProperty(QLatin1String("message"), QScriptValue(error.description())); arr.setProperty(i++, qmlErrObject); } QScriptValue err = ctxt->throwError(errstr); - err.setProperty("qmlErrors",arr); + err.setProperty(QLatin1String("qmlErrors"),arr); return err; } diff --git a/src/declarative/qml/qdeclarativeimport.cpp b/src/declarative/qml/qdeclarativeimport.cpp index cb36818..0c87671 100644 --- a/src/declarative/qml/qdeclarativeimport.cpp +++ b/src/declarative/qml/qdeclarativeimport.cpp @@ -678,11 +678,11 @@ bool QDeclarativeImportDatabase::resolveType(const QDeclarativeImports& imports, If either return pointer is 0, the corresponding search is not done. */ -void QDeclarativeImportDatabase::resolveTypeInNamespace(QDeclarativeImportedNamespace* ns, const QByteArray& type, +bool QDeclarativeImportDatabase::resolveTypeInNamespace(QDeclarativeImportedNamespace* ns, const QByteArray& type, QDeclarativeType** type_return, QUrl* url_return, int *vmaj, int *vmin) const { - ns->find(type,vmaj,vmin,type_return,url_return); + return ns->find(type,vmaj,vmin,type_return,url_return); } /*! diff --git a/src/declarative/qml/qdeclarativeimport_p.h b/src/declarative/qml/qdeclarativeimport_p.h index 62b0517..88246d4 100644 --- a/src/declarative/qml/qdeclarativeimport_p.h +++ b/src/declarative/qml/qdeclarativeimport_p.h @@ -112,7 +112,7 @@ public: int *version_major, int *version_minor, QDeclarativeImportedNamespace** ns_return, QString *errorString = 0) const; - void resolveTypeInNamespace(QDeclarativeImportedNamespace*, const QByteArray& type, + bool resolveTypeInNamespace(QDeclarativeImportedNamespace*, const QByteArray& type, QDeclarativeType** type_return, QUrl* url_return, int *version_major, int *version_minor ) const; diff --git a/src/declarative/qml/qdeclarativeinclude.cpp b/src/declarative/qml/qdeclarativeinclude.cpp index e37b68b..4cde54b 100644 --- a/src/declarative/qml/qdeclarativeinclude.cpp +++ b/src/declarative/qml/qdeclarativeinclude.cpp @@ -259,8 +259,6 @@ QScriptValue QDeclarativeInclude::worker_include(QScriptContext *ctxt, QScriptEn if (ctxt->argumentCount() == 0) return engine->undefinedValue(); - QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(engine); - QString urlString = ctxt->argument(0).toString(); QUrl url(ctxt->argument(0).toString()); if (url.isRelative()) { diff --git a/src/declarative/qml/qdeclarativeinstruction.cpp b/src/declarative/qml/qdeclarativeinstruction.cpp index 0236950..b86d082 100644 --- a/src/declarative/qml/qdeclarativeinstruction.cpp +++ b/src/declarative/qml/qdeclarativeinstruction.cpp @@ -60,6 +60,7 @@ void QDeclarativeCompiledData::dump(QDeclarativeInstruction *instr, int idx) break; case QDeclarativeInstruction::CreateObject: qWarning().nospace() << idx << "\t\t" << line << "\t" << "CREATE\t\t\t" << instr->create.type << "\t\t\t" << types.at(instr->create.type).className; + break; case QDeclarativeInstruction::CreateSimpleObject: qWarning().nospace() << idx << "\t\t" << line << "\t" << "CREATE_SIMPLE\t\t" << instr->createSimple.typeSize; break; diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index 3881d0a..071dd07 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -1049,26 +1049,24 @@ bool QDeclarativePropertyPrivate::write(QObject *object, const QDeclarativePrope } else { Q_ASSERT(variantType != propertyType); - QVariant v = value; - if (v.convert((QVariant::Type)propertyType)) { - void *a[] = { (void *)v.constData(), 0, &status, &flags}; - QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a); - } else if ((uint)propertyType >= QVariant::UserType && variantType == QVariant::String) { - QDeclarativeMetaType::StringConverter con = QDeclarativeMetaType::customStringConverter(propertyType); - if (!con) - return false; - - QVariant v = con(value.toString()); - if (v.userType() == propertyType) { - void *a[] = { (void *)v.constData(), 0, &status, &flags}; - QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a); + bool ok = false; + QVariant v; + if (variantType == QVariant::String) + v = QDeclarativeStringConverters::variantFromString(value.toString(), propertyType, &ok); + if (!ok) { + v = value; + if (v.convert((QVariant::Type)propertyType)) { + ok = true; + } else if ((uint)propertyType >= QVariant::UserType && variantType == QVariant::String) { + QDeclarativeMetaType::StringConverter con = QDeclarativeMetaType::customStringConverter(propertyType); + if (con) { + v = con(value.toString()); + if (v.userType() == propertyType) + ok = true; + } } - } else if (variantType == QVariant::String) { - bool ok = false; - QVariant v = QDeclarativeStringConverters::variantFromString(value.toString(), propertyType, &ok); - if (!ok) - return false; - + } + if (ok) { void *a[] = { (void *)v.constData(), 0, &status, &flags}; QMetaObject::metacall(object, QMetaObject::WriteProperty, coreIdx, a); } else { diff --git a/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp b/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp index cb1f27d..f06d6ae 100644 --- a/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp +++ b/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp @@ -168,6 +168,8 @@ void QDeclarativeValueTypeScriptClass::setProperty(Object *obj, const Identifier ref->type->read(ref->object, ref->property); QMetaProperty p = ref->type->metaObject()->property(m_lastIndex); + if (p.isEnumType() && (QMetaType::Type)v.type() == QMetaType::QReal) + v = v.toInt(); p.write(ref->type, v); ref->type->write(ref->object, ref->property, 0); } else { diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 1365cd7..de1c0cb 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -2543,7 +2543,6 @@ void QDeclarativeParentAnimation::transition(QDeclarativeStateActions &actions, QDeclarativeAction &yAction = pc->yIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; QDeclarativeAction &sAction = pc->scaleIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; QDeclarativeAction &rAction = pc->rotationIsSet() && i < actions.size()-1 ? actions[++i] : dummyAction; - bool forward = (direction == QDeclarativeAbstractAnimation::Forward); QDeclarativeItem *target = pc->object(); QDeclarativeItem *targetParent = action.reverseEvent ? pc->originalParent() : pc->parent(); diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/declarative/util/qdeclarativexmllistmodel.cpp index 4a374a5..cae1d3a 100644 --- a/src/declarative/util/qdeclarativexmllistmodel.cpp +++ b/src/declarative/util/qdeclarativexmllistmodel.cpp @@ -423,6 +423,7 @@ public: int highestRole; QNetworkReply *reply; QDeclarativeXmlListModel::Status status; + QString errorString; qreal progress; int queryId; QStringList keyRoleResultsCache; @@ -495,10 +496,11 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla </rss> \endcode - Then it could be used to create the following model: + A XmlListModel could create a model from this data, like this: \qml XmlListModel { + id: xmlModel source: "http://www.mysite.com/feed.xml" query: "/rss/channel/item" XmlRole { name: "title"; query: "title/string()" } @@ -511,6 +513,16 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla model item attributes; here, each model item will have \c title and \c pubDate attributes that match the \c title and \c pubDate values of its corresponding \c <item>. + The model could be used in a ListView, like this: + + \qml + ListView { + width: 180; height: 300 + model: xmlModel + delegate: Text { title + " (" + pubDate + ")" } + } + \endqml + \section2 Using key XML roles @@ -722,7 +734,8 @@ void QDeclarativeXmlListModel::setNamespaceDeclarations(const QString &declarati \o XmlListModel.Null - No XML data has been set for this model. \o XmlListModel.Ready - The XML data has been loaded into the model. \o XmlListModel.Loading - The model is in the process of reading and loading XML data. - \o XmlListModel.Error - An error occurred while the model was loading. + \o XmlListModel.Error - An error occurred while the model was loading. See errorString() for details + about the error. \endlist \sa progress @@ -755,6 +768,12 @@ qreal QDeclarativeXmlListModel::progress() const return d->progress; } +QString QDeclarativeXmlListModel::errorString() const +{ + Q_D(const QDeclarativeXmlListModel); + return d->errorString; +} + void QDeclarativeXmlListModel::classBegin() { Q_D(QDeclarativeXmlListModel); @@ -807,6 +826,7 @@ void QDeclarativeXmlListModel::reload() d->queryId = globalXmlQuery()->doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects, d->keyRoleResultsCache); d->progress = 1.0; d->status = Loading; + d->errorString.clear(); emit progressChanged(d->progress); emit statusChanged(d->status); return; @@ -816,6 +836,7 @@ void QDeclarativeXmlListModel::reload() d->queryId = XMLLISTMODEL_CLEAR_ID; d->progress = 1.0; d->status = Loading; + d->errorString.clear(); emit progressChanged(d->progress); emit statusChanged(d->status); QTimer::singleShot(0, this, SLOT(dataCleared())); @@ -824,6 +845,7 @@ void QDeclarativeXmlListModel::reload() d->progress = 0.0; d->status = Loading; + d->errorString.clear(); emit progressChanged(d->progress); emit statusChanged(d->status); @@ -854,6 +876,7 @@ void QDeclarativeXmlListModel::requestFinished() d->redirectCount = 0; if (d->reply->error() != QNetworkReply::NoError) { + d->errorString = d->reply->errorString(); disconnect(d->reply, 0, this, 0); d->reply->deleteLater(); d->reply = 0; @@ -919,6 +942,7 @@ void QDeclarativeXmlListModel::queryCompleted(const QDeclarativeXmlQueryResult & d->data = result.data; d->keyRoleResultsCache = result.keyRoleResultsCache; d->status = Ready; + d->errorString.clear(); d->queryId = -1; bool hasKeys = false; diff --git a/src/declarative/util/qdeclarativexmllistmodel_p.h b/src/declarative/util/qdeclarativexmllistmodel_p.h index 7b85476..7101c57 100644 --- a/src/declarative/util/qdeclarativexmllistmodel_p.h +++ b/src/declarative/util/qdeclarativexmllistmodel_p.h @@ -113,6 +113,8 @@ public: Status status() const; qreal progress() const; + Q_INVOKABLE QString errorString() const; + virtual void classBegin(); virtual void componentComplete(); |