aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorCharles Yin <charles.yin@nokia.com>2011-11-16 17:58:19 +1000
committerQt by Nokia <qt-info@nokia.com>2011-12-01 02:40:06 +0100
commit44d8691745ee9e8f927bdcd493f26b759c77d71c (patch)
tree03c45294a3ae6d199bd25aec25158f37a03d2fd9 /src
parent5b949572aa56c5bce087fb0c023af7c96c40f139 (diff)
Move XmlListModel to seperate plugin
XmlListModel is the only feature inside QtDeclarative which depends on the QtXmlPatterns module, move this item to a separate plugin can reduce the unnecessary dependency in most use cases. To use the new XmlListModel, an additional "import QtQuick.xmllistmodel 2.0" is needed. Task-number:QTBUG-22158 Change-Id: I9e19eb6cbba46cd40fb7ffcdbd741f346779a54d Reviewed-by: Yunqiao Yin <charles.yin@nokia.com>
Diffstat (limited to 'src')
-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
8 files changed, 97 insertions, 38 deletions
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