aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--doc/src/declarative/qdeclarativemodels.qdoc4
-rw-r--r--doc/src/snippets/declarative/xmlrole.qml1
-rw-r--r--examples/declarative/flickr/content/RssModel.qml1
-rw-r--r--examples/declarative/modelviews/visualdatamodel/slideshow.qml1
-rw-r--r--examples/declarative/particles/itemparticle/content/RssModel.qml1
-rw-r--r--examples/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml1
-rw-r--r--examples/declarative/photoviewer/PhotoViewerCore/RssModel.qml1
-rw-r--r--examples/declarative/rssnews/rssnews.qml1
-rw-r--r--examples/declarative/twitter/TwitterCore/RssModel.qml1
-rw-r--r--examples/declarative/twitter/TwitterCore/UserModel.qml1
-rw-r--r--examples/declarative/twitter/twitter.qml1
-rw-r--r--src/declarative/util/qdeclarativeutilmodule.cpp12
-rw-r--r--src/declarative/util/util.pri10
-rw-r--r--src/imports/imports.pro2
-rw-r--r--src/imports/xmllistmodel/plugin.cpp65
-rw-r--r--src/imports/xmllistmodel/qdeclarativexmllistmodel.cpp (renamed from src/declarative/util/qdeclarativexmllistmodel.cpp)27
-rw-r--r--src/imports/xmllistmodel/qdeclarativexmllistmodel_p.h (renamed from src/declarative/util/qdeclarativexmllistmodel_p.h)2
-rw-r--r--src/imports/xmllistmodel/qmldir1
-rw-r--r--src/imports/xmllistmodel/xmllistmodel.pro16
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/empty.xml0
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/get.qml2
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/model.qml1
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml1
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/recipes.qml1
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/roleCrash.qml1
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/roleErrors.qml1
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/roleKeys.qml2
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/testtypes.qml2
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/data/unique.qml1
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro3
-rw-r--r--tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp286
31 files changed, 257 insertions, 193 deletions
diff --git a/doc/src/declarative/qdeclarativemodels.qdoc b/doc/src/declarative/qdeclarativemodels.qdoc
index 61604d271d..4fe7193530 100644
--- a/doc/src/declarative/qdeclarativemodels.qdoc
+++ b/doc/src/declarative/qdeclarativemodels.qdoc
@@ -114,8 +114,12 @@ using the model. To reset the roles available in the model, call ListModel::clea
XmlListModel allows construction of a model from an XML data source. The roles
are specified via the \l XmlRole element.
+Note: From QtQuick 2.0, XmlListModel has been move to a seperate module \l QtQuick.XmlListModel,
+to use XmlListModel item, an additional "import QtQuick.XmlListModel 2.0" is needed.
+
The following model has three roles, \i title, \i link and \i description:
\qml
+import QtQuick.XmlListModel 2.0
XmlListModel {
id: feedModel
source: "http://rss.news.yahoo.com/rss/oceania"
diff --git a/doc/src/snippets/declarative/xmlrole.qml b/doc/src/snippets/declarative/xmlrole.qml
index 6709d319ac..4d6964a89a 100644
--- a/doc/src/snippets/declarative/xmlrole.qml
+++ b/doc/src/snippets/declarative/xmlrole.qml
@@ -39,6 +39,7 @@
****************************************************************************/
import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
Rectangle {
width: 300; height: 200
diff --git a/examples/declarative/flickr/content/RssModel.qml b/examples/declarative/flickr/content/RssModel.qml
index fa28aead18..c581b76738 100644
--- a/examples/declarative/flickr/content/RssModel.qml
+++ b/examples/declarative/flickr/content/RssModel.qml
@@ -40,6 +40,7 @@
****************************************************************************/
import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
XmlListModel {
property string tags : ""
diff --git a/examples/declarative/modelviews/visualdatamodel/slideshow.qml b/examples/declarative/modelviews/visualdatamodel/slideshow.qml
index edf1f0f057..bbcf128608 100644
--- a/examples/declarative/modelviews/visualdatamodel/slideshow.qml
+++ b/examples/declarative/modelviews/visualdatamodel/slideshow.qml
@@ -39,6 +39,7 @@
****************************************************************************/
import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
Rectangle {
id: root
diff --git a/examples/declarative/particles/itemparticle/content/RssModel.qml b/examples/declarative/particles/itemparticle/content/RssModel.qml
index edb3ceac42..9049fe4b5b 100644
--- a/examples/declarative/particles/itemparticle/content/RssModel.qml
+++ b/examples/declarative/particles/itemparticle/content/RssModel.qml
@@ -39,6 +39,7 @@
****************************************************************************/
import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
XmlListModel {
property string tags : ""
diff --git a/examples/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml b/examples/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml
index 6a5d16e6f6..d6b5710ae4 100644
--- a/examples/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml
+++ b/examples/declarative/photoviewer/PhotoViewerCore/AlbumDelegate.qml
@@ -40,6 +40,7 @@
****************************************************************************/
import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
Component {
id: albumDelegate
diff --git a/examples/declarative/photoviewer/PhotoViewerCore/RssModel.qml b/examples/declarative/photoviewer/PhotoViewerCore/RssModel.qml
index b92685c765..c9f1daf0ed 100644
--- a/examples/declarative/photoviewer/PhotoViewerCore/RssModel.qml
+++ b/examples/declarative/photoviewer/PhotoViewerCore/RssModel.qml
@@ -40,6 +40,7 @@
****************************************************************************/
import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
XmlListModel {
property string tags : ""
diff --git a/examples/declarative/rssnews/rssnews.qml b/examples/declarative/rssnews/rssnews.qml
index ddbfdd9ee3..7ae5998c33 100644
--- a/examples/declarative/rssnews/rssnews.qml
+++ b/examples/declarative/rssnews/rssnews.qml
@@ -40,6 +40,7 @@
****************************************************************************/
import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
import "content"
Rectangle {
diff --git a/examples/declarative/twitter/TwitterCore/RssModel.qml b/examples/declarative/twitter/TwitterCore/RssModel.qml
index 2abbedcf69..5a99a9a0f6 100644
--- a/examples/declarative/twitter/TwitterCore/RssModel.qml
+++ b/examples/declarative/twitter/TwitterCore/RssModel.qml
@@ -40,6 +40,7 @@
****************************************************************************/
import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
Item { id: wrapper
property variant model: xmlModel
diff --git a/examples/declarative/twitter/TwitterCore/UserModel.qml b/examples/declarative/twitter/TwitterCore/UserModel.qml
index 00eabb912d..b3b7bf5699 100644
--- a/examples/declarative/twitter/TwitterCore/UserModel.qml
+++ b/examples/declarative/twitter/TwitterCore/UserModel.qml
@@ -40,6 +40,7 @@
****************************************************************************/
import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
//This "model" gets the user information about the searched user. Mainly for the icon.
diff --git a/examples/declarative/twitter/twitter.qml b/examples/declarative/twitter/twitter.qml
index 05197e26b8..1f8b5f4c21 100644
--- a/examples/declarative/twitter/twitter.qml
+++ b/examples/declarative/twitter/twitter.qml
@@ -40,6 +40,7 @@
****************************************************************************/
import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
import "TwitterCore" 2.0 as Twitter
Item {
diff --git a/src/declarative/util/qdeclarativeutilmodule.cpp b/src/declarative/util/qdeclarativeutilmodule.cpp
index 511ccd3f36..2e82364a42 100644
--- a/src/declarative/util/qdeclarativeutilmodule.cpp
+++ b/src/declarative/util/qdeclarativeutilmodule.cpp
@@ -59,9 +59,6 @@
#include "qdeclarativetransition_p.h"
#include <qdeclarativeinfo.h>
#include <private/qdeclarativetypenotavailable_p.h>
-#ifndef QT_NO_XMLPATTERNS
-#include "qdeclarativexmllistmodel_p.h"
-#endif
#include <QtCore/qcoreapplication.h>
#include <QtGui/QInputPanel>
@@ -93,15 +90,6 @@ void QDeclarativeUtilModule::defineModule()
qmlRegisterType<QDeclarativeTimer>("QtQuick",2,0,"Timer");
qmlRegisterType<QDeclarativeTransition>("QtQuick",2,0,"Transition");
qmlRegisterType<QDeclarativeVector3dAnimation>("QtQuick",2,0,"Vector3dAnimation");
-#ifdef QT_NO_XMLPATTERNS
- qmlRegisterTypeNotAvailable("QtQuick",2,0,"XmlListModel",
- qApp->translate("QDeclarativeXmlListModel","Qt was built without support for xmlpatterns"));
- qmlRegisterTypeNotAvailable("QtQuick",2,0,"XmlRole",
- qApp->translate("QDeclarativeXmlListModel","Qt was built without support for xmlpatterns"));
-#else
- qmlRegisterType<QDeclarativeXmlListModel>("QtQuick",2,0,"XmlListModel");
- qmlRegisterType<QDeclarativeXmlListModelRole>("QtQuick",2,0,"XmlRole");
-#endif
qmlRegisterType<QDeclarativeStateOperation>();
diff --git a/src/declarative/util/util.pri b/src/declarative/util/util.pri
index e476db7925..3122cd24bb 100644
--- a/src/declarative/util/util.pri
+++ b/src/declarative/util/util.pri
@@ -58,12 +58,4 @@ HEADERS += \
$$PWD/qdeclarativechangeset_p.h \
$$PWD/qdeclarativelistcompositor_p.h \
$$PWD/qdeclarativepathinterpolator_p.h \
- $$PWD/qdeclarativesvgparser_p.h
-
-contains(QT_CONFIG, xmlpatterns) {
- QT+=xmlpatterns
- SOURCES += $$PWD/qdeclarativexmllistmodel.cpp
- HEADERS += $$PWD/qdeclarativexmllistmodel_p.h
-} else {
- DEFINES += QT_NO_XMLPATTERNS
-}
+ $$PWD/qdeclarativesvgparser_p.h \ No newline at end of file
diff --git a/src/imports/imports.pro b/src/imports/imports.pro
index 9c66082ba9..35590b221d 100644
--- a/src/imports/imports.pro
+++ b/src/imports/imports.pro
@@ -2,4 +2,4 @@ TEMPLATE = subdirs
SUBDIRS += qtquick1 qt47 folderlistmodel particles gestures etcprovider
contains(QT_CONFIG, qmltest): SUBDIRS += testlib
-
+contains(QT_CONFIG, xmlpatterns) : SUBDIRS += xmllistmodel \ No newline at end of file
diff --git a/src/imports/xmllistmodel/plugin.cpp b/src/imports/xmllistmodel/plugin.cpp
new file mode 100644
index 0000000000..4e25470734
--- /dev/null
+++ b/src/imports/xmllistmodel/plugin.cpp
@@ -0,0 +1,65 @@
+/****************************************************************************
+**
+** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the QtDeclarative module of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** GNU Lesser General Public License Usage
+** This file may be used under the terms of the GNU Lesser General Public
+** License version 2.1 as published by the Free Software Foundation and
+** appearing in the file LICENSE.LGPL included in the packaging of this
+** file. Please review the following information to ensure the GNU Lesser
+** General Public License version 2.1 requirements will be met:
+** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
+**
+** In addition, as a special exception, Nokia gives you certain additional
+** rights. These rights are described in the Nokia Qt LGPL Exception
+** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
+**
+** GNU General Public License Usage
+** Alternatively, this file may be used under the terms of the GNU General
+** Public License version 3.0 as published by the Free Software Foundation
+** and appearing in the file LICENSE.GPL included in the packaging of this
+** file. Please review the following information to ensure the GNU General
+** Public License version 3.0 requirements will be met:
+** http://www.gnu.org/copyleft/gpl.html.
+**
+** Other Usage
+** Alternatively, this file may be used in accordance with the terms and
+** conditions contained in a signed written agreement between you and Nokia.
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+
+#include <QtDeclarative/qdeclarativeextensionplugin.h>
+#include <QtDeclarative/qdeclarative.h>
+
+#include "qdeclarativexmllistmodel_p.h"
+
+QT_BEGIN_NAMESPACE
+
+class QmlXmlListModelPlugin : public QDeclarativeExtensionPlugin
+{
+ Q_OBJECT
+public:
+ virtual void registerTypes(const char *uri)
+ {
+ Q_ASSERT(QLatin1String(uri) == QLatin1String("QtQuick.XmlListModel"));
+ qmlRegisterType<QDeclarativeXmlListModel>(uri,2,0,"XmlListModel");
+ qmlRegisterType<QDeclarativeXmlListModelRole>(uri,2,0,"XmlRole");
+ }
+};
+
+QT_END_NAMESPACE
+
+#include "plugin.moc"
+
+Q_EXPORT_PLUGIN2(qmlxmllistmodelplugin, QT_PREPEND_NAMESPACE(QmlXmlListModelPlugin));
diff --git a/src/declarative/util/qdeclarativexmllistmodel.cpp b/src/imports/xmllistmodel/qdeclarativexmllistmodel.cpp
index d757516c91..868d9cbd7e 100644
--- a/src/declarative/util/qdeclarativexmllistmodel.cpp
+++ b/src/imports/xmllistmodel/qdeclarativexmllistmodel.cpp
@@ -112,7 +112,6 @@ typedef QPair<int, int> QDeclarativeXmlListRange;
For example, if there is an XML document like this:
\quotefile doc/src/snippets/declarative/xmlrole.xml
-
Here are some valid XPath expressions for XmlRole queries on this document:
\snippet doc/src/snippets/declarative/xmlrole.qml 0
@@ -125,7 +124,6 @@ typedef QPair<int, int> QDeclarativeXmlListRange;
/*!
\qmlproperty bool QtQuick2::XmlRole::isKey
Defines whether this is a key role.
-
Key roles are used to to determine whether a set of values should
be updated or added to the XML list model when XmlListModel::reload()
is called.
@@ -448,10 +446,9 @@ void QDeclarativeXmlQueryEngine::doSubQueryJob(XmlQueryJob *currentJob, QDeclara
for (int i=0; i<currentJob->keyRoleResultsCache.count(); i++) {
if (!keyRoleResults.contains(currentJob->keyRoleResultsCache[i]))
addIndexToRangeList(&currentResult->removed, i);
- else
+ else
temp << currentJob->keyRoleResultsCache[i];
}
-
for (int i=0; i<keyRoleResults.count(); i++) {
if (temp.count() == i || keyRoleResults[i] != temp[i]) {
temp.insert(i, keyRoleResults[i]);
@@ -641,10 +638,10 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla
\endqml
The \l {XmlListModel::query}{query} value of "/rss/channel/item" specifies that the XmlListModel should generate
- a model item for each \c <item> in the XML document.
-
+ a model item for each \c <item> in the XML document.
+
The XmlRole objects define the
- model item attributes. Here, each model item will have \c title and \c pubDate
+ 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>.
(See \l XmlRole::query for more examples of valid XPath expressions for XmlRole.)
@@ -679,8 +676,8 @@ void QDeclarativeXmlListModelPrivate::clear_role(QDeclarativeListProperty<QDecla
\endqml
Then when reload() is called, the model will only add and reload
- items with a "pubDate" value that is not already
- present in the model.
+ items with a "pubDate" value that is not already
+ present in the model.
This is useful when displaying the contents of XML documents that
are incrementally updated (such as RSS feeds) to avoid repainting the
@@ -900,8 +897,8 @@ QDeclarativeV8Handle QDeclarativeXmlListModel::get(int index) const
QDeclarativeEngine *engine = qmlContext(this)->engine();
QV8Engine *v8engine = QDeclarativeEnginePrivate::getV8Engine(engine);
v8::Local<v8::Object> rv = v8::Object::New();
- for (int ii = 0; ii < d->roleObjects.count(); ++ii)
- rv->Set(v8engine->toString(d->roleObjects[ii]->name()),
+ for (int ii = 0; ii < d->roleObjects.count(); ++ii)
+ rv->Set(v8engine->toString(d->roleObjects[ii]->name()),
v8engine->fromVariant(d->data.value(ii).value(index)));
return QDeclarativeV8Handle::fromHandle(rv);
@@ -936,7 +933,7 @@ QDeclarativeXmlListModel::Status QDeclarativeXmlListModel::status() const
1.0 (all data downloaded). If the XML data is not from a remote source,
the progress becomes 1.0 as soon as the data is read.
- Note that when the progress is 1.0, the XML data has been downloaded, but
+ Note that when the progress is 1.0, the XML data has been downloaded, but
it is yet to be loaded into the model at this point. Use the status
property to find out when the XML data has been read and loaded into
the model.
@@ -984,13 +981,13 @@ void QDeclarativeXmlListModel::componentComplete()
\qmlmethod QtQuick2::XmlListModel::reload()
Reloads the model.
-
+
If no key roles have been specified, all existing model
data is removed, and the model is rebuilt from scratch.
Otherwise, items are only added if the model does not already
contain items with matching key role values.
-
+
\sa {Using key XML roles}, XmlRole::isKey
*/
void QDeclarativeXmlListModel::reload()
@@ -1160,4 +1157,4 @@ void QDeclarativeXmlListModel::queryCompleted(const QDeclarativeXmlQueryResult &
QT_END_NAMESPACE
-#include <qdeclarativexmllistmodel.moc>
+#include <qdeclarativexmllistmodel.moc> \ No newline at end of file
diff --git a/src/declarative/util/qdeclarativexmllistmodel_p.h b/src/imports/xmllistmodel/qdeclarativexmllistmodel_p.h
index 3d8617f929..c12d3d98fb 100644
--- a/src/declarative/util/qdeclarativexmllistmodel_p.h
+++ b/src/imports/xmllistmodel/qdeclarativexmllistmodel_p.h
@@ -70,7 +70,7 @@ struct QDeclarativeXmlQueryResult {
QStringList keyRoleResultsCache;
};
-class Q_AUTOTEST_EXPORT QDeclarativeXmlListModel : public QListModelInterface, public QDeclarativeParserStatus
+class Q_DECLARATIVE_EXPORT QDeclarativeXmlListModel : public QListModelInterface, public QDeclarativeParserStatus
{
Q_OBJECT
Q_INTERFACES(QDeclarativeParserStatus)
diff --git a/src/imports/xmllistmodel/qmldir b/src/imports/xmllistmodel/qmldir
new file mode 100644
index 0000000000..dd39bcd7f8
--- /dev/null
+++ b/src/imports/xmllistmodel/qmldir
@@ -0,0 +1 @@
+plugin qmlxmllistmodelplugin \ No newline at end of file
diff --git a/src/imports/xmllistmodel/xmllistmodel.pro b/src/imports/xmllistmodel/xmllistmodel.pro
new file mode 100644
index 0000000000..e3897e04ca
--- /dev/null
+++ b/src/imports/xmllistmodel/xmllistmodel.pro
@@ -0,0 +1,16 @@
+TARGET = qmlxmllistmodelplugin
+TARGETPATH = QtQuick/XmlListModel
+include(../qimportbase.pri)
+
+QT+= declarative xmlpatterns declarative-private v8-private core-private
+
+SOURCES += qdeclarativexmllistmodel.cpp plugin.cpp
+HEADERS += qdeclarativexmllistmodel_p.h
+
+DESTDIR = $$QT.declarative.imports/$$TARGETPATH
+target.path = $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
+
+qmldir.files += $$PWD/qmldir
+qmldir.path += $$[QT_INSTALL_IMPORTS]/$$TARGETPATH
+
+INSTALLS += target qmldir \ No newline at end of file
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/empty.xml b/tests/auto/declarative/qdeclarativexmllistmodel/data/empty.xml
new file mode 100644
index 0000000000..e69de29bb2
--- /dev/null
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/empty.xml
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/get.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/get.qml
index 2466c031ab..509da7174b 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/data/get.qml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/get.qml
@@ -1,4 +1,5 @@
import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
XmlListModel {
source: "model.xml"
@@ -58,4 +59,3 @@ XmlListModel {
postTest = true;
}
}
-
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/model.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/model.qml
index bf47f43567..2df3927479 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/data/model.qml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/model.qml
@@ -1,4 +1,5 @@
import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
XmlListModel {
source: "model.xml"
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml
index cc05b7c665..f8a97bffc3 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/propertychanges.qml
@@ -1,4 +1,5 @@
import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
XmlListModel {
source: "model.xml"
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/recipes.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/recipes.qml
index 3834cccf1d..dc609e95e3 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/data/recipes.qml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/recipes.qml
@@ -1,4 +1,5 @@
import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
XmlListModel {
source: "recipes.xml"
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/roleCrash.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleCrash.qml
index 50b8c0db49..6a7059bb45 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/data/roleCrash.qml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleCrash.qml
@@ -1,4 +1,5 @@
import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
XmlListModel {
id: model
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/roleErrors.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleErrors.qml
index c86a3720ad..91664b6d4a 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/data/roleErrors.qml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleErrors.qml
@@ -1,4 +1,5 @@
import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
XmlListModel {
source: "model.xml"
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/roleKeys.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleKeys.qml
index 74eca3edcf..9f667d86e5 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/data/roleKeys.qml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/roleKeys.qml
@@ -1,4 +1,5 @@
import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
XmlListModel {
query: "/data/item"
@@ -10,4 +11,3 @@ XmlListModel {
nameRole.isKey = false;
}
}
-
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/testtypes.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/testtypes.qml
index 1f987e0781..5ec1ffa35f 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/data/testtypes.qml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/testtypes.qml
@@ -1,8 +1,8 @@
import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
XmlListModel {
query: "/data"
XmlRole { name: "stringValue"; query: "a-string/string()" }
XmlRole { name: "numberValue"; query: "a-number/number()" }
}
-
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/data/unique.qml b/tests/auto/declarative/qdeclarativexmllistmodel/data/unique.qml
index e4ed533d4e..322a2e4e5c 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/data/unique.qml
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/data/unique.qml
@@ -1,4 +1,5 @@
import QtQuick 2.0
+import QtQuick.XmlListModel 2.0
XmlListModel {
source: "model.xml"
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro b/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro
index ae5523711c..6ece73e684 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/qdeclarativexmllistmodel.pro
@@ -3,11 +3,10 @@ TARGET = tst_qdeclarativexmllistmodel
macx:CONFIG -= app_bundle
SOURCES += tst_qdeclarativexmllistmodel.cpp
-
testDataFiles.files = data
testDataFiles.path = .
DEPLOYMENT += testDataFiles
CONFIG += parallel_test
-QT += core-private gui-private v8-private declarative-private network testlib xmlpatterns
+QT += core-private gui-private v8-private declarative-private network testlib xmlpatterns \ No newline at end of file
diff --git a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
index 2b66e67024..7a119dd0bd 100644
--- a/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
+++ b/tests/auto/declarative/qdeclarativexmllistmodel/tst_qdeclarativexmllistmodel.cpp
@@ -38,12 +38,11 @@
** $QT_END_LICENSE$
**
****************************************************************************/
-#include <private/qdeclarativeengine_p.h>
#include <QtTest/QtTest>
#include <QtGlobal>
#include <math.h>
-
+#include <QMetaObject>
#include <qtest.h>
#include <QtTest/qsignalspy.h>
#include <QtDeclarative/qdeclarativenetworkaccessmanagerfactory.h>
@@ -53,17 +52,17 @@
#include <QtCore/qfile.h>
#include <QtCore/qtemporaryfile.h>
#include "../shared/util.h"
+#include <private/qdeclarativeengine_p.h>
#include <QtDeclarative/qdeclarativeengine.h>
#include <QtDeclarative/qdeclarativecomponent.h>
-#include <private/qdeclarativexmllistmodel_p.h>
+#include <private/qlistmodelinterface_p.h>
typedef QPair<int, int> QDeclarativeXmlListRange;
typedef QList<QVariantList> QDeclarativeXmlModelData;
Q_DECLARE_METATYPE(QList<QDeclarativeXmlListRange>)
Q_DECLARE_METATYPE(QDeclarativeXmlModelData)
-Q_DECLARE_METATYPE(QDeclarativeXmlListModel::Status)
class tst_qdeclarativexmllistmodel : public QObject
@@ -71,10 +70,11 @@ class tst_qdeclarativexmllistmodel : public QObject
Q_OBJECT
public:
tst_qdeclarativexmllistmodel() {}
+ enum Status { Null, Ready, Loading, Error };
private slots:
void initTestCase() {
- qRegisterMetaType<QDeclarativeXmlListModel::Status>("QDeclarativeXmlListModel::Status");
+ qRegisterMetaType<Status>("tst_qdeclarativexmllistmodel::Status");
}
void buildModel();
@@ -104,6 +104,12 @@ private slots:
void roleCrash();
private:
+ QString errorString(QListModelInterface* model) {
+ QString ret;
+ QMetaObject::invokeMethod(model, "errorString", Q_RETURN_ARG(QString, ret));
+ return ret;
+ }
+
QString makeItemXmlAndData(const QString &data, QDeclarativeXmlModelData *modelData = 0) const
{
if (modelData)
@@ -146,7 +152,7 @@ private:
QDeclarativeEngine engine;
};
-
+Q_DECLARE_METATYPE(tst_qdeclarativexmllistmodel::Status)
class CustomNetworkAccessManagerFactory : public QObject, public QDeclarativeNetworkAccessManagerFactory
{
Q_OBJECT
@@ -188,18 +194,14 @@ QNetworkAccessManager *CustomNetworkAccessManagerFactory::create(QObject *parent
void tst_qdeclarativexmllistmodel::buildModel()
{
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml")));
- QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
QTRY_COMPARE(model->count(), 9);
- QList<int> roles;
- roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3;
- QHash<int, QVariant> data = model->data(3, roles);
- QVERIFY(data.count() == 4);
- QCOMPARE(data.value(Qt::UserRole).toString(), QLatin1String("Spot"));
- QCOMPARE(data.value(Qt::UserRole+1).toString(), QLatin1String("Dog"));
- QCOMPARE(data.value(Qt::UserRole+2).toInt(), 9);
- QCOMPARE(data.value(Qt::UserRole+3).toString(), QLatin1String("Medium"));
+ QCOMPARE(model->data(3, Qt::UserRole).toString(), QLatin1String("Spot"));
+ QCOMPARE(model->data(3, Qt::UserRole+1).toString(), QLatin1String("Dog"));
+ QCOMPARE(model->data(3, Qt::UserRole+2).toInt(), 9);
+ QCOMPARE(model->data(3, Qt::UserRole+3).toString(), QLatin1String("Medium"));
delete model;
}
@@ -211,10 +213,10 @@ void tst_qdeclarativexmllistmodel::testTypes()
QFETCH(QVariant, expectedValue);
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("testtypes.qml")));
- QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
- model->setXml(xml.toUtf8());
- model->reload();
+ model->setProperty("xml",xml.toUtf8());
+ QMetaObject::invokeMethod(model, "reload");
QTRY_COMPARE(model->count(), 1);
int role = -1;
@@ -271,15 +273,11 @@ void tst_qdeclarativexmllistmodel::testTypes_data()
void tst_qdeclarativexmllistmodel::cdata()
{
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("recipes.qml")));
- QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
QTRY_COMPARE(model->count(), 5);
- QList<int> roles;
- roles << Qt::UserRole + 2;
- QHash<int, QVariant> data = model->data(2, roles);
- QVERIFY(data.count() == 1);
- QVERIFY(data.value(Qt::UserRole+2).toString().startsWith(QLatin1String("<html>")));
+ QVERIFY(model->data(2, Qt::UserRole+2).toString().startsWith(QLatin1String("<html>")));
delete model;
}
@@ -287,14 +285,10 @@ void tst_qdeclarativexmllistmodel::cdata()
void tst_qdeclarativexmllistmodel::attributes()
{
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("recipes.qml")));
- QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
QTRY_COMPARE(model->count(), 5);
- QList<int> roles;
- roles << Qt::UserRole;
- QHash<int, QVariant> data = model->data(2, roles);
- QVERIFY(data.count() == 1);
- QCOMPARE(data.value(Qt::UserRole).toString(), QLatin1String("Vegetable Soup"));
+ QCOMPARE(model->data(2, Qt::UserRole).toString(), QLatin1String("Vegetable Soup"));
delete model;
}
@@ -302,7 +296,7 @@ void tst_qdeclarativexmllistmodel::attributes()
void tst_qdeclarativexmllistmodel::roles()
{
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml")));
- QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
QTRY_COMPARE(model->count(), 9);
@@ -319,26 +313,22 @@ void tst_qdeclarativexmllistmodel::roles()
void tst_qdeclarativexmllistmodel::roleErrors()
{
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleErrors.qml")));
- QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(TESTDATA("roleErrors.qml")).toString() + ":6:5: QML XmlRole: An XmlRole query must not start with '/'").toUtf8().constData());
- QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(TESTDATA("roleErrors.qml")).toString() + ":9:5: QML XmlRole: invalid query: \"age/\"").toUtf8().constData());
+ QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(TESTDATA("roleErrors.qml")).toString() + ":7:5: QML XmlRole: An XmlRole query must not start with '/'").toUtf8().constData());
+ QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(TESTDATA("roleErrors.qml")).toString() + ":10:5: QML XmlRole: invalid query: \"age/\"").toUtf8().constData());
//### make sure we receive all expected warning messages.
- QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
QTRY_COMPARE(model->count(), 9);
- QList<int> roles;
- roles << Qt::UserRole << Qt::UserRole + 1 << Qt::UserRole + 2 << Qt::UserRole + 3;
- QHash<int, QVariant> data = model->data(3, roles);
- QVERIFY(data.count() == 4);
//### should any of these return valid values?
- QCOMPARE(data.value(Qt::UserRole), QVariant());
- QCOMPARE(data.value(Qt::UserRole+1), QVariant());
- QCOMPARE(data.value(Qt::UserRole+2), QVariant());
+ QCOMPARE(model->data(3, Qt::UserRole), QVariant());
+ QCOMPARE(model->data(3, Qt::UserRole+1), QVariant());
+ QCOMPARE(model->data(3, Qt::UserRole+2), QVariant());
QEXPECT_FAIL("", "QTBUG-10797", Continue);
- QCOMPARE(data.value(Qt::UserRole+3), QVariant());
+ QCOMPARE(model->data(3, Qt::UserRole+3), QVariant());
delete model;
}
@@ -346,8 +336,8 @@ void tst_qdeclarativexmllistmodel::roleErrors()
void tst_qdeclarativexmllistmodel::uniqueRoleNames()
{
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("unique.qml")));
- QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(TESTDATA("unique.qml")).toString() + ":7:5: QML XmlRole: \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData());
- QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QTest::ignoreMessage(QtWarningMsg, (QUrl::fromLocalFile(TESTDATA("unique.qml")).toString() + ":8:5: QML XmlRole: \"name\" duplicates a previous role name and will be disabled.").toUtf8().constData());
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
QTRY_COMPARE(model->count(), 9);
@@ -364,31 +354,32 @@ void tst_qdeclarativexmllistmodel::xml()
QFETCH(int, count);
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml")));
- QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
- QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status)));
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
- QVERIFY(model->errorString().isEmpty());
- QCOMPARE(model->progress(), qreal(0.0));
- QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading);
+ QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status)));
+ QVERIFY(errorString(model).isEmpty());
+ QCOMPARE(model->property("progress").toDouble(), qreal(0.0));
+ QCOMPARE(model->property("status").toInt(), static_cast<int>(Loading));
QTRY_COMPARE(spy.count(), 1); spy.clear();
- QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready);
- QVERIFY(model->errorString().isEmpty());
- QCOMPARE(model->progress(), qreal(1.0));
+ QTest::qWait(50);
+ QCOMPARE(model->property("status").toInt(), static_cast<int>(Ready));
+ QVERIFY(errorString(model).isEmpty());
+ QCOMPARE(model->property("progress").toDouble(), qreal(1.0));
QCOMPARE(model->count(), 9);
// if xml is empty (i.e. clearing) it won't have any effect if a source is set
if (xml.isEmpty())
- model->setSource(QUrl());
- model->setXml(xml);
- QCOMPARE(model->progress(), qreal(1.0)); // immediately goes to 1.0 if using setXml()
+ model->setProperty("source",QUrl());
+ model->setProperty("xml",xml);
+ QCOMPARE(model->property("progress").toDouble(), qreal(1.0)); // immediately goes to 1.0 if using setXml()
QTRY_COMPARE(spy.count(), 1); spy.clear();
- QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading);
+ QCOMPARE(model->property("status").toInt(), static_cast<int>(Loading));
QTRY_COMPARE(spy.count(), 1); spy.clear();
if (xml.isEmpty())
- QCOMPARE(model->status(), QDeclarativeXmlListModel::Null);
+ QCOMPARE(model->property("status").toInt(), static_cast<int>(Null));
else
- QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready);
- QVERIFY(model->errorString().isEmpty());
+ QCOMPARE(model->property("status").toInt(), static_cast<int>(Ready));
+ QVERIFY(errorString(model).isEmpty());
QCOMPARE(model->count(), count);
delete model;
@@ -413,9 +404,9 @@ void tst_qdeclarativexmllistmodel::headers()
qmlEng.setNetworkAccessManagerFactory(&factory);
QDeclarativeComponent component(&qmlEng, QUrl::fromLocalFile(TESTDATA("model.qml")));
- QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
- QTRY_COMPARE(model->status(), QDeclarativeXmlListModel::Ready);
+ QTRY_COMPARE(model->property("status").toInt(), static_cast<int>(Ready));
QVariantMap expectedHeaders;
expectedHeaders["Accept"] = "application/xml,*/*";
@@ -433,28 +424,28 @@ void tst_qdeclarativexmllistmodel::source()
{
QFETCH(QUrl, source);
QFETCH(int, count);
- QFETCH(QDeclarativeXmlListModel::Status, status);
+ QFETCH(Status, status);
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml")));
- QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QSignalSpy spy(model, SIGNAL(statusChanged(QDeclarativeXmlListModel::Status)));
- QVERIFY(model->errorString().isEmpty());
- QCOMPARE(model->progress(), qreal(0.0));
- QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading);
+ QVERIFY(errorString(model).isEmpty());
+ QCOMPARE(model->property("progress").toDouble(), qreal(0.0));
+ QCOMPARE(model->property("status").toInt(), static_cast<int>(Loading));
QTRY_COMPARE(spy.count(), 1); spy.clear();
- QCOMPARE(model->status(), QDeclarativeXmlListModel::Ready);
- QVERIFY(model->errorString().isEmpty());
- QCOMPARE(model->progress(), qreal(1.0));
+ QCOMPARE(model->property("status").toInt(), static_cast<int>(Ready));
+ QVERIFY(errorString(model).isEmpty());
+ QCOMPARE(model->property("progress").toDouble(), qreal(1.0));
QCOMPARE(model->count(), 9);
- model->setSource(source);
- if (model->source().isEmpty())
- QCOMPARE(model->status(), QDeclarativeXmlListModel::Null);
- QCOMPARE(model->progress(), qreal(0.0));
+ model->setProperty("source",source);
+ if (model->property("source").toString().isEmpty())
+ QCOMPARE(model->property("status").toInt(), static_cast<int>(Null));
+ QCOMPARE(model->property("progress").toDouble(), qreal(0.0));
QTRY_COMPARE(spy.count(), 1); spy.clear();
- QCOMPARE(model->status(), QDeclarativeXmlListModel::Loading);
- QVERIFY(model->errorString().isEmpty());
+ QCOMPARE(model->property("status").toInt(), static_cast<int>(Loading));
+ QVERIFY(errorString(model).isEmpty());
QEventLoop loop;
QTimer timer;
@@ -464,19 +455,19 @@ void tst_qdeclarativexmllistmodel::source()
timer.start(20000);
loop.exec();
- if (spy.count() == 0 && status != QDeclarativeXmlListModel::Ready) {
+ if (spy.count() == 0 && status != Ready) {
qWarning("QDeclarativeXmlListModel invalid source test timed out");
} else {
QCOMPARE(spy.count(), 1); spy.clear();
}
- QCOMPARE(model->status(), status);
+ QCOMPARE(model->property("status").toInt(), static_cast<int>(status));
QCOMPARE(model->count(), count);
- if (status == QDeclarativeXmlListModel::Ready)
- QCOMPARE(model->progress(), qreal(1.0));
+ if (status == Ready)
+ QCOMPARE(model->property("progress").toDouble(), qreal(1.0));
- QCOMPARE(model->errorString().isEmpty(), status == QDeclarativeXmlListModel::Ready);
+ QCOMPARE(errorString(model).isEmpty(), status == Ready);
delete model;
}
@@ -485,29 +476,25 @@ void tst_qdeclarativexmllistmodel::source_data()
{
QTest::addColumn<QUrl>("source");
QTest::addColumn<int>("count");
- QTest::addColumn<QDeclarativeXmlListModel::Status>("status");
+ QTest::addColumn<Status>("status");
- QTest::newRow("valid") << QUrl::fromLocalFile(TESTDATA("model2.xml")) << 2 << QDeclarativeXmlListModel::Ready;
- QTest::newRow("invalid") << QUrl("http://blah.blah/blah.xml") << 0 << QDeclarativeXmlListModel::Error;
+ QTest::newRow("valid") << QUrl::fromLocalFile(TESTDATA("model2.xml")) << 2 << Ready;
+ QTest::newRow("invalid") << QUrl("http://blah.blah/blah.xml") << 0 << Error;
// empty file
QTemporaryFile *temp = new QTemporaryFile(this);
if (temp->open())
- QTest::newRow("empty file") << QUrl::fromLocalFile(temp->fileName()) << 0 << QDeclarativeXmlListModel::Ready;
+ QTest::newRow("empty file") << QUrl::fromLocalFile(temp->fileName()) << 0 << Ready;
temp->close();
}
void tst_qdeclarativexmllistmodel::data()
{
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml")));
- QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
- QHash<int,QVariant> blank;
- for (int i=0; i<model->roles().count(); i++)
- blank.insert(model->roles()[i], QVariant());
for (int i=0; i<9; i++) {
- QCOMPARE(model->data(i, model->roles()), blank);
for (int j=0; j<model->roles().count(); j++) {
QCOMPARE(model->data(i, j), QVariant());
}
@@ -520,7 +507,7 @@ void tst_qdeclarativexmllistmodel::data()
void tst_qdeclarativexmllistmodel::get()
{
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("get.qml")));
- QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
@@ -541,20 +528,19 @@ void tst_qdeclarativexmllistmodel::reload()
// reload() is called.
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("model.qml")));
- QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
QTRY_COMPARE(model->count(), 9);
QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
- QSignalSpy spyCount(model, SIGNAL(countChanged()));
-
+ QSignalSpy spyCount(model, SIGNAL(countChanged()));
//reload multiple times to test the xml query aborting
- model->reload();
- model->reload();
+ QMetaObject::invokeMethod(model, "reload");
+ QMetaObject::invokeMethod(model, "reload");
QCoreApplication::processEvents();
- model->reload();
- model->reload();
+ QMetaObject::invokeMethod(model, "reload");
+ QMetaObject::invokeMethod(model, "reload");
QTRY_COMPARE(spyCount.count(), 1);
QTRY_COMPARE(spyInsert.count(), 1);
QTRY_COMPARE(spyRemove.count(), 1);
@@ -582,17 +568,17 @@ void tst_qdeclarativexmllistmodel::useKeys()
QFETCH(QList<QDeclarativeXmlListRange>, removeRanges);
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleKeys.qml")));
- QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
- model->setXml(oldXml);
+ model->setProperty("xml",oldXml);
QTRY_COMPARE(model->count(), oldCount);
QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
QSignalSpy spyCount(model, SIGNAL(countChanged()));
- model->setXml(newXml);
+ model->setProperty("xml",newXml);
if (oldCount != newData.count()) {
QTRY_COMPARE(model->count(), newData.count());
@@ -733,23 +719,23 @@ void tst_qdeclarativexmllistmodel::noKeysValueChanges()
// since 'sport' is not marked as a key.
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleKeys.qml")));
- QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
QString xml;
xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics");
- model->setXml(xml);
+ model->setProperty("xml",xml);
QTRY_COMPARE(model->count(), 2);
- model->setXml("");
+ model->setProperty("xml","");
QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
QSignalSpy spyCount(model, SIGNAL(countChanged()));
xml = makeItemXmlAndData("name=A,age=25,sport=AussieRules;name=B,age=35,sport=Athletics");
- model->setXml(xml);
+ model->setProperty("xml",xml);
// wait for the new xml data to be set, and verify no signals were emitted
QTRY_VERIFY(model->data(0, model->roles()[2]).toString() != QLatin1String("Football"));
@@ -771,21 +757,21 @@ void tst_qdeclarativexmllistmodel::keysChanged()
// if no keys are set).
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleKeys.qml")));
- QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
QString xml = makeItemXmlAndData("name=A,age=25,sport=Football;name=B,age=35,sport=Athletics");
- model->setXml(xml);
+ model->setProperty("xml",xml);
QTRY_COMPARE(model->count(), 2);
- model->setXml("");
+ model->setProperty("xml","");
QSignalSpy spyInsert(model, SIGNAL(itemsInserted(int,int)));
QSignalSpy spyRemove(model, SIGNAL(itemsRemoved(int,int)));
QSignalSpy spyCount(model, SIGNAL(countChanged()));
QVERIFY(QMetaObject::invokeMethod(model, "disableNameKey"));
- model->setXml(xml);
+ model->setProperty("xml",xml);
QTRY_VERIFY(spyInsert.count() > 0 && spyRemove.count() > 0);
@@ -808,11 +794,11 @@ void tst_qdeclarativexmllistmodel::threading()
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleKeys.qml")));
- QDeclarativeXmlListModel *m1 = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QListModelInterface *m1 = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(m1 != 0);
- QDeclarativeXmlListModel *m2 = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QListModelInterface *m2 = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(m2 != 0);
- QDeclarativeXmlListModel *m3 = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QListModelInterface *m3 = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(m3 != 0);
for (int dataCount=0; dataCount<xmlDataCount; dataCount++) {
@@ -826,24 +812,24 @@ void tst_qdeclarativexmllistmodel::threading()
//Set the xml data multiple times with randomized order and mixed with multiple event loops
//to test the xml query reloading/aborting, the result should be stable.
- m1->setXml(makeItemXmlAndData(data1));
- m2->setXml(makeItemXmlAndData(data2));
- m3->setXml(makeItemXmlAndData(data3));
+ m1->setProperty("xml",makeItemXmlAndData(data1));
+ m2->setProperty("xml",makeItemXmlAndData(data2));
+ m3->setProperty("xml",makeItemXmlAndData(data3));
QCoreApplication::processEvents();
- m2->setXml(makeItemXmlAndData(data2));
- m1->setXml(makeItemXmlAndData(data1));
- m2->setXml(makeItemXmlAndData(data2));
+ m2->setProperty("xml",makeItemXmlAndData(data2));
+ m1->setProperty("xml",makeItemXmlAndData(data1));
+ m2->setProperty("xml",makeItemXmlAndData(data2));
QCoreApplication::processEvents();
- m3->setXml(makeItemXmlAndData(data3));
+ m3->setProperty("xml",makeItemXmlAndData(data3));
QCoreApplication::processEvents();
- m2->setXml(makeItemXmlAndData(data2));
- m1->setXml(makeItemXmlAndData(data1));
- m2->setXml(makeItemXmlAndData(data2));
- m3->setXml(makeItemXmlAndData(data3));
+ m2->setProperty("xml",makeItemXmlAndData(data2));
+ m1->setProperty("xml",makeItemXmlAndData(data1));
+ m2->setProperty("xml",makeItemXmlAndData(data2));
+ m3->setProperty("xml",makeItemXmlAndData(data3));
QCoreApplication::processEvents();
- m2->setXml(makeItemXmlAndData(data2));
- m3->setXml(makeItemXmlAndData(data3));
- m3->setXml(makeItemXmlAndData(data3));
+ m2->setProperty("xml",makeItemXmlAndData(data2));
+ m3->setProperty("xml",makeItemXmlAndData(data3));
+ m3->setProperty("xml",makeItemXmlAndData(data3));
QCoreApplication::processEvents();
QTRY_VERIFY(m1->count() == dataCount && m2->count() == dataCount && m3->count() == dataCount);
@@ -880,32 +866,32 @@ void tst_qdeclarativexmllistmodel::threading_data()
void tst_qdeclarativexmllistmodel::propertyChanges()
{
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("propertychanges.qml")));
- QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
QTRY_COMPARE(model->count(), 9);
- QDeclarativeXmlListModelRole *role = model->findChild<QDeclarativeXmlListModelRole*>("role");
+ QObject *role = model->findChild<QObject*>("role");
QVERIFY(role);
QSignalSpy nameSpy(role, SIGNAL(nameChanged()));
QSignalSpy querySpy(role, SIGNAL(queryChanged()));
QSignalSpy isKeySpy(role, SIGNAL(isKeyChanged()));
- role->setName("size");
- role->setQuery("size/string()");
- role->setIsKey(true);
+ role->setProperty("name","size");
+ role->setProperty("query","size/string()");
+ role->setProperty("isKey",true);
- QCOMPARE(role->name(), QString("size"));
- QCOMPARE(role->query(), QString("size/string()"));
- QVERIFY(role->isKey());
+ QCOMPARE(role->property("name").toString(), QString("size"));
+ QCOMPARE(role->property("query").toString(), QString("size/string()"));
+ QVERIFY(role->property("isKey").toBool());
QCOMPARE(nameSpy.count(),1);
QCOMPARE(querySpy.count(),1);
QCOMPARE(isKeySpy.count(),1);
- role->setName("size");
- role->setQuery("size/string()");
- role->setIsKey(true);
+ role->setProperty("name","size");
+ role->setProperty("query","size/string()");
+ role->setProperty("isKey",true);
QCOMPARE(nameSpy.count(),1);
QCOMPARE(querySpy.count(),1);
@@ -916,15 +902,15 @@ void tst_qdeclarativexmllistmodel::propertyChanges()
QSignalSpy modelQuerySpy(model, SIGNAL(queryChanged()));
QSignalSpy namespaceDeclarationsSpy(model, SIGNAL(namespaceDeclarationsChanged()));
- model->setSource(QUrl(""));
- model->setXml("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>");
- model->setQuery("/Pets");
- model->setNamespaceDeclarations("declare namespace media=\"http://search.yahoo.com/mrss/\";");
+ model->setProperty("source",QUrl(""));
+ model->setProperty("xml","<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>");
+ model->setProperty("query","/Pets");
+ model->setProperty("namespaceDeclarations","declare namespace media=\"http://search.yahoo.com/mrss/\";");
- QCOMPARE(model->source(), QUrl(""));
- QCOMPARE(model->xml(), QString("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>"));
- QCOMPARE(model->query(), QString("/Pets"));
- QCOMPARE(model->namespaceDeclarations(), QString("declare namespace media=\"http://search.yahoo.com/mrss/\";"));
+ QCOMPARE(model->property("source").toUrl(), QUrl(""));
+ QCOMPARE(model->property("xml").toString(), QString("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>"));
+ QCOMPARE(model->property("query").toString(), QString("/Pets"));
+ QCOMPARE(model->property("namespaceDeclarations").toString(), QString("declare namespace media=\"http://search.yahoo.com/mrss/\";"));
QTRY_VERIFY(model->count() == 1);
@@ -933,10 +919,10 @@ void tst_qdeclarativexmllistmodel::propertyChanges()
QCOMPARE(modelQuerySpy.count(),1);
QCOMPARE(namespaceDeclarationsSpy.count(),1);
- model->setSource(QUrl(""));
- model->setXml("<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>");
- model->setQuery("/Pets");
- model->setNamespaceDeclarations("declare namespace media=\"http://search.yahoo.com/mrss/\";");
+ model->setProperty("source",QUrl(""));
+ model->setProperty("xml","<Pets><Pet><name>Polly</name><type>Parrot</type><age>12</age><size>Small</size></Pet></Pets>");
+ model->setProperty("query","/Pets");
+ model->setProperty("namespaceDeclarations","declare namespace media=\"http://search.yahoo.com/mrss/\";");
QCOMPARE(sourceSpy.count(),1);
QCOMPARE(xmlSpy.count(),1);
@@ -951,11 +937,11 @@ void tst_qdeclarativexmllistmodel::roleCrash()
{
// don't crash
QDeclarativeComponent component(&engine, QUrl::fromLocalFile(TESTDATA("roleCrash.qml")));
- QDeclarativeXmlListModel *model = qobject_cast<QDeclarativeXmlListModel*>(component.create());
+ QListModelInterface *model = qobject_cast<QListModelInterface*>(component.create());
QVERIFY(model != 0);
delete model;
}
QTEST_MAIN(tst_qdeclarativexmllistmodel)
-#include "tst_qdeclarativexmllistmodel.moc"
+#include "tst_qdeclarativexmllistmodel.moc" \ No newline at end of file