diff options
author | Yann Bodson <yann.bodson@nokia.com> | 2009-08-31 03:42:25 (GMT) |
---|---|---|
committer | Yann Bodson <yann.bodson@nokia.com> | 2009-08-31 03:42:25 (GMT) |
commit | bffc072ae6177dcebc3bfa24c747a88b4eb09d74 (patch) | |
tree | 288e3c7a2e81e8e6e9d0f7ad3b6a6fc1f65acc7e | |
parent | 97cfec8495939dcc128fdf9ee831b5e284a12191 (diff) | |
parent | 11214b3cfbf890df00de5a90c143b61477a0a8c6 (diff) | |
download | Qt-bffc072ae6177dcebc3bfa24c747a88b4eb09d74.zip Qt-bffc072ae6177dcebc3bfa24c747a88b4eb09d74.tar.gz Qt-bffc072ae6177dcebc3bfa24c747a88b4eb09d74.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r-- | src/declarative/extra/qmlxmllistmodel.cpp | 40 | ||||
-rw-r--r-- | src/declarative/extra/qmlxmllistmodel.h | 4 |
2 files changed, 39 insertions, 5 deletions
diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp index 816c3fd..60a28b4 100644 --- a/src/declarative/extra/qmlxmllistmodel.cpp +++ b/src/declarative/extra/qmlxmllistmodel.cpp @@ -76,8 +76,6 @@ struct QmlXmlRoleList : public QmlConcreteList<XmlListModelRole *> QmlXmlListModelPrivate *model; }; - - class QmlXmlQuery : public QThread { Q_OBJECT @@ -295,6 +293,7 @@ public: bool isComponentComplete; QUrl src; + QString xml; QString query; QString namespaces; int size; @@ -460,6 +459,8 @@ QString QmlXmlListModel::toString(int role) const /*! \qmlproperty url XmlListModel::source The location of the XML data source. + + If both source and xml are set, xml will be used. */ QUrl QmlXmlListModel::source() const { @@ -477,6 +478,27 @@ void QmlXmlListModel::setSource(const QUrl &src) } /*! + \qmlproperty string XmlListModel::xml + This property holds XML text set directly. + + The text is assumed to be UTF-8 encoded. + + If both source and xml are set, xml will be used. +*/ +QString QmlXmlListModel::xml() const +{ + Q_D(const QmlXmlListModel); + return d->xml; +} + +void QmlXmlListModel::setXml(const QString &xml) +{ + Q_D(QmlXmlListModel); + d->xml = xml; + reload(); +} + +/*! \qmlproperty url XmlListModel::query An absolute XPath query representing the base query for the model items. The query should start with a '/' or '//'. @@ -589,16 +611,24 @@ void QmlXmlListModel::reload() if (count > 0) emit itemsRemoved(0, count); - if (d->src.isEmpty()) { - qmlInfo(this) << "Can't load empty src string"; + if (d->src.isEmpty() && d->xml.isEmpty()) return; - } if (d->reply) { d->reply->abort(); d->reply->deleteLater(); d->reply = 0; } + + if (!d->xml.isEmpty()) { + d->queryId = d->qmlXmlQuery.doQuery(d->query, d->namespaces, d->xml.toUtf8(), &d->roleObjects); + d->progress = 1.0; + d->status = Idle; + emit progressChanged(d->progress); + emit statusChanged(d->status); + return; + } + d->progress = 0.0; d->status = Loading; emit progressChanged(d->progress); diff --git a/src/declarative/extra/qmlxmllistmodel.h b/src/declarative/extra/qmlxmllistmodel.h index 18d33fb..fbf95db 100644 --- a/src/declarative/extra/qmlxmllistmodel.h +++ b/src/declarative/extra/qmlxmllistmodel.h @@ -95,6 +95,7 @@ class Q_DECLARATIVE_EXPORT QmlXmlListModel : public QListModelInterface, public Q_PROPERTY(Status status READ status NOTIFY statusChanged) Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) Q_PROPERTY(QUrl source READ source WRITE setSource) + Q_PROPERTY(QString xml READ xml WRITE setXml) Q_PROPERTY(QString query READ query WRITE setQuery) Q_PROPERTY(QString namespaceDeclarations READ namespaceDeclarations WRITE setNamespaceDeclarations) Q_PROPERTY(QmlList<XmlListModelRole *> *roles READ roleObjects) @@ -115,6 +116,9 @@ public: QUrl source() const; void setSource(const QUrl&); + QString xml() const; + void setXml(const QString&); + QString query() const; void setQuery(const QString&); |