summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBea Lam <bea.lam@nokia.com>2009-11-17 04:22:51 (GMT)
committerBea Lam <bea.lam@nokia.com>2009-11-17 04:22:51 (GMT)
commitc0aa5c106698ec03dd144f8b53c84ff84a0f9e69 (patch)
treef6ddf165f82bce750c7d4a36e3946299694cdd0a
parenta493a5e104579c0a7908fc600be1fd622d6447ae (diff)
parent119a52991cf33b6738bdaf8296a06b33341228a0 (diff)
downloadQt-c0aa5c106698ec03dd144f8b53c84ff84a0f9e69.zip
Qt-c0aa5c106698ec03dd144f8b53c84ff84a0f9e69.tar.gz
Qt-c0aa5c106698ec03dd144f8b53c84ff84a0f9e69.tar.bz2
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--doc/src/declarative/focus.qdoc13
-rw-r--r--doc/src/declarative/globalobject.qdoc2
-rw-r--r--doc/src/declarative/qtprogrammers.qdoc2
-rw-r--r--examples/declarative/webview/content/Mapping/Map.qml20
-rwxr-xr-xexamples/declarative/webview/content/Mapping/map.html47
-rw-r--r--examples/declarative/webview/googleMaps.qml31
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsborderimage.cpp2
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsimage.cpp2
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitem.cpp7
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsitem.h3
-rw-r--r--src/declarative/graphicsitems/qmlgraphicswebview.cpp9
-rw-r--r--src/declarative/qml/qmlengine.cpp15
-rw-r--r--src/declarative/qml/qmlsqldatabase.cpp7
-rw-r--r--src/declarative/util/qmllistmodel.cpp22
-rw-r--r--tests/auto/declarative/declarative.pro1
-rw-r--r--tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml57
-rw-r--r--tests/auto/declarative/graphicswidgets/graphicswidgets.pro8
-rw-r--r--tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp77
-rw-r--r--tests/auto/declarative/qmlengine/tst_qmlengine.cpp8
-rw-r--r--tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp18
-rw-r--r--tests/auto/declarative/sql/data/2-selection-bindnames.js24
-rw-r--r--tests/auto/declarative/sql/data/6-iteration-efficient.js6
-rw-r--r--tests/auto/declarative/sql/tst_sql.cpp7
23 files changed, 349 insertions, 39 deletions
diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc
index 6eca667..8061a7c 100644
--- a/doc/src/declarative/focus.qdoc
+++ b/doc/src/declarative/focus.qdoc
@@ -75,12 +75,12 @@ Item {
\endlist
-See also the \l {Keys}{Keys attached property} and {KeyNavigation}{KeyNavigation attached property}.
+See also the \l {Keys}{Keys attached property} and \l {KeyNavigation}{KeyNavigation attached property}.
\section1 Querying the Active Focus Item
Whether or not an \l Item has \e {active focus} can be queried through the
-read-only property \c {Item::focus}. For example, here we have a \l Text
+property \c {Item::focus}. For example, here we have a \l Text
element whose text is determined by whether or not it has \e {active focus}.
\code
@@ -191,10 +191,11 @@ This problem is fundamentally one of visibility. The \c {MyWidget}
components each set their \c {keyHandler} Items as focused as that is all they can
do - they don't know how they are going to be used, but they do know that when
they're in use their \c {keyHandler} element is what needs focus. Likewise
-the code that uses the \c {MyWidget}'s sets the second \c {MyWidget} as
-focused because, while it doesn't know exactly how the \c {MyWidget} is
-implemented, it knows that it wants the second one to be focused. No one piece
-of code knows everything about the other, which is exactly how it should be.
+the code that uses the two \c {MyWidgets} sets the second \c {MyWidget} as
+focused. While it doesn't know exactly how the \c {MyWidget} is
+implemented, it knows that it wants the second one to be focused. This allows us
+to achieve encapsulation, allowing each widget to focus on it's appropriate behaviour
+itself.
To solve this problem - allowing components to care about what they know about
and ignore everything else - the QML items introduce a concept known as a
diff --git a/doc/src/declarative/globalobject.qdoc b/doc/src/declarative/globalobject.qdoc
index 3cf1ca3..dc08c28 100644
--- a/doc/src/declarative/globalobject.qdoc
+++ b/doc/src/declarative/globalobject.qdoc
@@ -126,8 +126,6 @@ This function attempts to open the specified \c target url in an external applic
\section3 Qt.md5(data)
This function returns a hex string of the md5 hash of \c data.
-\endlist
-
\section1 Dynamic Object Creation
The following functions on the global object allow you to dynamically create QML
items from files or strings.
diff --git a/doc/src/declarative/qtprogrammers.qdoc b/doc/src/declarative/qtprogrammers.qdoc
index 6892005..7b1ab44 100644
--- a/doc/src/declarative/qtprogrammers.qdoc
+++ b/doc/src/declarative/qtprogrammers.qdoc
@@ -130,8 +130,6 @@ As an example, imagine you decided to make a generic tab widget item to be used
through your application suite wherever information is in such quantity that it
needs to be divided up into pages.
-To do this in QML, ... \todo example of container definition.
-
A significant difference in the parenting concept with QML compare to QWidgets
is that while child items are positioned relative to their parents,
there is no requirement that they be wholy contained ("clipped") to
diff --git a/examples/declarative/webview/content/Mapping/Map.qml b/examples/declarative/webview/content/Mapping/Map.qml
new file mode 100644
index 0000000..9bde031
--- /dev/null
+++ b/examples/declarative/webview/content/Mapping/Map.qml
@@ -0,0 +1,20 @@
+import Qt 4.6
+
+Item {
+ id: page
+ property real latitude: -34.397
+ property real longitude: 150.644
+ property string address: ""
+ WebView {
+ id: map
+ anchors.fill: parent
+ url: "map.html"
+ javaScriptWindowObjects: Object {
+ WebView.windowObjectName: "qml"
+ property real lat: page.latitude
+ property real lng: page.longitude
+ property string address: page.address
+ onAddressChanged: {map.evaluateJavaScript("goToAddress()")}
+ }
+ }
+}
diff --git a/examples/declarative/webview/content/Mapping/map.html b/examples/declarative/webview/content/Mapping/map.html
new file mode 100755
index 0000000..8afa21c
--- /dev/null
+++ b/examples/declarative/webview/content/Mapping/map.html
@@ -0,0 +1,47 @@
+<html>
+<head>
+<meta name="viewport" content="initial-scale=1.0, user-scalable=no" />
+<script type="text/javascript" src="http://maps.google.com/maps/api/js?sensor=false"></script>
+<script type="text/javascript">
+ var geocoder
+ var map
+ function goToLatLng(latlng,bounds) {
+ if (map) {
+ map.setCenter(latlng)
+ map.fitBounds(bounds)
+ } else {
+ var myOptions = {
+ zoom: 8,
+ center: latlng,
+ mapTypeId: google.maps.MapTypeId.ROADMAP
+ };
+ map = new google.maps.Map(document.getElementById("map_canvas"), myOptions);
+ }
+ }
+ function initialize() {
+ geocoder = new google.maps.Geocoder();
+ if (window.qml.address) {
+ goToAddress()
+ } else {
+ goToLatLng(new google.maps.LatLng(window.qml.lat,window.qml.lng));
+ }
+ }
+ function goToAddress() {
+ if (geocoder) {
+ var req = {
+ address: window.qml.address,
+ }
+ if (map)
+ req.bounds = map.getBounds()
+ geocoder.geocode(req, function(results, status) {
+ if (status == google.maps.GeocoderStatus.OK)
+ goToLatLng(results[0].geometry.location,results[0].geometry.bounds);
+ });
+ }
+ }
+</script>
+</head>
+<body onload="initialize()" leftmargin="0px" topmargin="0px" marginwidth="0px" marginheight="0px">
+ <div id="map_canvas" style="width:100%; height:100%"></div>
+</body>
+</html>
diff --git a/examples/declarative/webview/googleMaps.qml b/examples/declarative/webview/googleMaps.qml
new file mode 100644
index 0000000..b5b13bb
--- /dev/null
+++ b/examples/declarative/webview/googleMaps.qml
@@ -0,0 +1,31 @@
+// This example demonstrates how Web services such as Google Maps can be
+// abstracted as QML types. Here we have a "Mapping" module with a "Map"
+// type. The Map type has an address property. Setting that property moves
+// the map. The underlying implementation uses WebView and the Google Maps
+// API, but users from QML don't need to understand the implementation in
+// order to create a Map.
+
+import Qt 4.6
+import "content/Mapping"
+
+Map {
+ id: map
+ width: 300
+ height: 300
+ address: "Paris"
+ Rectangle {
+ color: "white"
+ width: input.width + 20
+ height: input.height + 4
+ radius: 5
+ anchors.bottom: parent.bottom
+ anchors.bottomMargin: 5
+ x: 70
+ TextInput {
+ id: input
+ text: map.address
+ anchors.centerIn: parent
+ Keys.onReturnPressed: map.address = input.text
+ }
+ }
+}
diff --git a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
index 04e79f9..e1039f4 100644
--- a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
@@ -58,8 +58,6 @@ QML_DEFINE_TYPE(Qt,4,6,BorderImage,QmlGraphicsBorderImage)
\snippet snippets/declarative/border-image.qml 0
\image BorderImage.png
-
- \sa examples/declarative/border-image
*/
/*!
diff --git a/src/declarative/graphicsitems/qmlgraphicsimage.cpp b/src/declarative/graphicsitems/qmlgraphicsimage.cpp
index 89b50a1..42fd910 100644
--- a/src/declarative/graphicsitems/qmlgraphicsimage.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsimage.cpp
@@ -182,8 +182,6 @@ void QmlGraphicsImagePrivate::setPixmap(const QPixmap &pixmap)
\endlist
\image declarative-image_fillMode.gif
- \sa examples/declarative/fillmode
- \sa examples/declarative/aspectratio
*/
QmlGraphicsImage::FillMode QmlGraphicsImage::fillMode() const
{
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp
index ca45f62..fb6afb1 100644
--- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp
@@ -1428,6 +1428,11 @@ QmlGraphicsKeysAttached *QmlGraphicsKeysAttached::qmlAttachedProperties(QObject
*/
/*!
+ \fn void QmlGraphicsItem::childrenChanged()
+ \internal
+*/
+
+/*!
\fn void QmlGraphicsItem::focusChanged()
\internal
*/
@@ -2692,6 +2697,8 @@ QVariant QmlGraphicsItem::itemChange(GraphicsItemChange change,
{
if (change == ItemParentHasChanged) {
emit parentChanged();
+ } else if (change == ItemChildAddedChange || change == ItemChildRemovedChange) {
+ emit childrenChanged();
}
return QGraphicsItem::itemChange(change, value);
diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.h b/src/declarative/graphicsitems/qmlgraphicsitem.h
index 2ac43b5..11d6e2e 100644
--- a/src/declarative/graphicsitems/qmlgraphicsitem.h
+++ b/src/declarative/graphicsitems/qmlgraphicsitem.h
@@ -69,7 +69,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsItem : public QGraphicsObject, public QmlP
Q_PROPERTY(QmlGraphicsItem * parent READ parentItem WRITE setParentItem NOTIFY parentChanged DESIGNABLE false FINAL)
Q_PROPERTY(QmlList<QObject *> *data READ data DESIGNABLE false)
- Q_PROPERTY(QmlList<QmlGraphicsItem *>* children READ fxChildren DESIGNABLE false)
+ Q_PROPERTY(QmlList<QmlGraphicsItem *>* children READ fxChildren DESIGNABLE false NOTIFY childrenChanged)
Q_PROPERTY(QmlList<QObject *>* resources READ resources DESIGNABLE false)
Q_PROPERTY(QmlList<QmlState *>* states READ states DESIGNABLE false)
Q_PROPERTY(QmlList<QmlTransition *>* transitions READ transitions DESIGNABLE false)
@@ -160,6 +160,7 @@ public:
Q_SIGNALS:
void widthChanged();
void heightChanged();
+ void childrenChanged();
void childrenRectChanged();
void baselineOffsetChanged();
void stateChanged(const QString &);
diff --git a/src/declarative/graphicsitems/qmlgraphicswebview.cpp b/src/declarative/graphicsitems/qmlgraphicswebview.cpp
index 00fdd6d..c8bb504 100644
--- a/src/declarative/graphicsitems/qmlgraphicswebview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicswebview.cpp
@@ -368,8 +368,13 @@ void QmlGraphicsWebView::setPreferredHeight(int ih)
}
/*!
- Evaluates the \a scriptSource JavaScript inside the main frame
- context and returns the result of the last executed statement.
+ \qmlmethod bool WebView::evaluateJavaScript(string)
+
+ Evaluates the \a scriptSource JavaScript inside the context of the
+ main web frame, and returns the result of the last executed statement.
+
+ Note that this JavaScript does \e not have any access to QML objects
+ except as made available as windowObjects.
*/
QVariant QmlGraphicsWebView::evaluateJavaScript(const QString &scriptSource)
{
diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp
index 9abd216..86472de 100644
--- a/src/declarative/qml/qmlengine.cpp
+++ b/src/declarative/qml/qmlengine.cpp
@@ -107,11 +107,6 @@ struct StaticQtMetaObject : public QObject
{ return &static_cast<StaticQtMetaObject*> (0)->staticQtMetaObject; }
};
-static QString userLocalDataPath(const QString& app)
-{
- return QDesktopServices::storageLocation(QDesktopServices::DataLocation) + QLatin1String("/") + app;
-}
-
QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e)
: rootContext(0), currentExpression(0),
isDebugging(false), contextClass(0), objectClass(0), valueTypeClass(0), globalClass(0),
@@ -125,7 +120,9 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e)
scriptEngine.newQMetaObject(StaticQtMetaObject::get());
scriptEngine.globalObject().setProperty(QLatin1String("Qt"), qtObject);
- offlineStoragePath = userLocalDataPath(QLatin1String("QML/OfflineStorage"));
+ offlineStoragePath = QDesktopServices::storageLocation(QDesktopServices::DataLocation)
+ + QDir::separator() + QLatin1String("QML")
+ + QDir::separator() + QLatin1String("OfflineStorage");
qt_add_qmlxmlhttprequest(&scriptEngine);
qt_add_qmlsqldatabase(&scriptEngine);
@@ -1256,8 +1253,12 @@ void QmlEngine::addImportPath(const QString& path)
QmlGraphicsWebView and the SQL databases created with openDatabase()
are stored here.
- The default is QML/OfflineStorage/ in the platform-standard
+ The default is QML/OfflineStorage in the platform-standard
user application data directory.
+
+ Note that the path may not currently exist on the filesystem, so
+ callers wanting to \e create new files at this location should create
+ it first - see QDir::mkpath().
*/
void QmlEngine::setOfflineStoragePath(const QString& dir)
{
diff --git a/src/declarative/qml/qmlsqldatabase.cpp b/src/declarative/qml/qmlsqldatabase.cpp
index c7d2e12..6e32fb7 100644
--- a/src/declarative/qml/qmlsqldatabase.cpp
+++ b/src/declarative/qml/qmlsqldatabase.cpp
@@ -248,10 +248,10 @@ static QScriptValue qmlsqldatabase_executeSql(QScriptContext *context, QScriptEn
QSqlQuery query(db);
bool err = false;
if (query.prepare(sql)) {
- if (values.isArray()) {
+ if (values.isObject()) {
for (QScriptValueIterator it(values); it.hasNext();) {
it.next();
- query.addBindValue(it.value().toVariant());
+ query.bindValue(it.name(),it.value().toVariant());
}
} else {
query.bindValue(0,values.toVariant());
@@ -337,7 +337,8 @@ static QScriptValue qmlsqldatabase_open(QScriptContext *context, QScriptEngine *
database = QSqlDatabase::addDatabase(QLatin1String("QSQLITE"), dbid);
}
if (!database.isOpen()) {
- QString basename = QmlEnginePrivate::get(engine)->offlineStoragePath + QLatin1String("/Databases/");
+ QString basename = QmlEnginePrivate::get(engine)->offlineStoragePath
+ + QDir::separator() + QLatin1String("Databases") + QDir::separator();
QDir().mkpath(basename);
basename += dbid;
database.setDatabaseName(basename+QLatin1String(".sqlite"));
diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp
index 9e91147..a3c5c59 100644
--- a/src/declarative/util/qmllistmodel.cpp
+++ b/src/declarative/util/qmllistmodel.cpp
@@ -483,6 +483,10 @@ void QmlListModel::remove(int index)
*/
void QmlListModel::insert(int index, const QScriptValue& valuemap)
{
+ if (!valuemap.isObject() || valuemap.isArray()) {
+ qmlInfo(this) << tr("insert: value is not an object");
+ return;
+ }
if (!_root)
_root = new ModelNode;
if (index >= _root->values.count() || index<0) {
@@ -517,8 +521,10 @@ void QmlListModel::move(int from, int to, int n)
{
if (n==0 || from==to)
return;
- if (from+n > count() || to+n > count() || from < 0 || to < 0)
+ if (from+n > count() || to+n > count() || from < 0 || to < 0 || n < 0) {
qmlInfo(this) << tr("move: out of range");
+ return;
+ }
int origfrom=from; // preserve actual move, so any animations are correct
int origto=to;
int orign=n;
@@ -564,7 +570,7 @@ void QmlListModel::move(int from, int to, int n)
*/
void QmlListModel::append(const QScriptValue& valuemap)
{
- if (!valuemap.isObject()) {
+ if (!valuemap.isObject() || valuemap.isArray()) {
qmlInfo(this) << tr("append: value is not an object");
return;
}
@@ -636,9 +642,11 @@ QScriptValue QmlListModel::get(int index) const
*/
void QmlListModel::set(int index, const QScriptValue& valuemap)
{
- if (!_root)
- _root = new ModelNode;
- if ( index > _root->values.count()) {
+ if (!valuemap.isObject() || valuemap.isArray()) {
+ qmlInfo(this) << tr("set: value is not an object");
+ return;
+ }
+ if ( !_root || index > _root->values.count()) {
qmlInfo(this) << tr("set: index %1 out of range").arg(index);
return;
}
@@ -677,9 +685,7 @@ void QmlListModel::set(int index, const QScriptValue& valuemap)
*/
void QmlListModel::set(int index, const QString& property, const QVariant& value)
{
- if (!_root)
- _root = new ModelNode;
- if ( index >= _root->values.count()) {
+ if ( !_root || index >= _root->values.count()) {
qmlInfo(this) << tr("set: index %1 out of range").arg(index);
return;
}
diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro
index c45a05e..2f7419a 100644
--- a/tests/auto/declarative/declarative.pro
+++ b/tests/auto/declarative/declarative.pro
@@ -4,6 +4,7 @@ SUBDIRS += \
animatedimage \ # Cover
datetimeformatter \ # Cover
examples \
+ graphicswidgets \ # Cover
layouts \ # Cover
numberformatter \ # Cover
parserstress \ # Cover
diff --git a/tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml b/tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml
new file mode 100644
index 0000000..70fafd6
--- /dev/null
+++ b/tests/auto/declarative/graphicswidgets/data/graphicswidgets.qml
@@ -0,0 +1,57 @@
+import Qt 4.6
+
+QGraphicsView {
+ objectName: "GView"
+ size: "800x600"
+
+ QGraphicsScene {
+ objectName: "GScene"
+ sceneRect: "0,0,500x300"
+
+ QGraphicsWidget {
+ layout: QGraphicsLinearLayout {
+ orientation: Qt.Horizontal
+ QGraphicsWidget {
+ layout: QGraphicsLinearLayout {
+ spacing: 10; orientation: Qt.Vertical
+ LayoutItem {
+ QGraphicsLinearLayout.stretchFactor: 1
+ objectName: "left"
+ minimumSize: "100x100"
+ maximumSize: "300x300"
+ preferredSize: "100x100"
+ Rectangle { objectName: "yellowRect"; color: "yellow"; anchors.fill: parent }
+ }
+ LayoutItem {
+ QGraphicsLinearLayout.stretchFactor: 10
+ objectName: "left"
+ minimumSize: "100x100"
+ maximumSize: "300x300"
+ preferredSize: "100x100"
+ Rectangle { objectName: "yellowRect"; color: "blue"; anchors.fill: parent }
+ }
+ }
+ }
+ QGraphicsWidget {
+ layout: QGraphicsLinearLayout {
+ spacing: 10; orientation: Qt.Vertical
+ LayoutItem {
+ objectName: "left"
+ minimumSize: "100x100"
+ maximumSize: "300x300"
+ preferredSize: "100x100"
+ Rectangle { objectName: "yellowRect"; color: "red"; anchors.fill: parent }
+ }
+ LayoutItem {
+ objectName: "left"
+ minimumSize: "100x100"
+ maximumSize: "300x300"
+ preferredSize: "100x100"
+ Rectangle { objectName: "yellowRect"; color: "green"; anchors.fill: parent }
+ }
+ }
+ }
+ }
+ }
+ }
+}
diff --git a/tests/auto/declarative/graphicswidgets/graphicswidgets.pro b/tests/auto/declarative/graphicswidgets/graphicswidgets.pro
new file mode 100644
index 0000000..712c34c
--- /dev/null
+++ b/tests/auto/declarative/graphicswidgets/graphicswidgets.pro
@@ -0,0 +1,8 @@
+load(qttest_p4)
+contains(QT_CONFIG,declarative): QT += declarative gui
+macx:CONFIG -= app_bundle
+
+SOURCES += tst_graphicswidgets.cpp
+
+# Define SRCDIR equal to test's source directory
+DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp b/tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp
new file mode 100644
index 0000000..783094b
--- /dev/null
+++ b/tests/auto/declarative/graphicswidgets/tst_graphicswidgets.cpp
@@ -0,0 +1,77 @@
+/****************************************************************************
+**
+** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies).
+** All rights reserved.
+** Contact: Nokia Corporation (qt-info@nokia.com)
+**
+** This file is part of the test suite of the Qt Toolkit.
+**
+** $QT_BEGIN_LICENSE:LGPL$
+** No Commercial Usage
+** This file contains pre-release code and may not be distributed.
+** You may use this file in accordance with the terms and conditions
+** contained in the Technology Preview License Agreement accompanying
+** this package.
+**
+** GNU Lesser General Public License Usage
+** Alternatively, 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.
+**
+** If you have questions regarding the use of this file, please contact
+** Nokia at qt-info@nokia.com.
+**
+**
+**
+**
+**
+**
+**
+**
+** $QT_END_LICENSE$
+**
+****************************************************************************/
+#include <qtest.h>
+#include <QFile>
+#include <QtDeclarative/qmlengine.h>
+#include <QtDeclarative/qmlcomponent.h>
+#include <private/graphicswidgets_p.h>
+
+class tst_graphicswidgets : public QObject
+
+{
+ Q_OBJECT
+public:
+ tst_graphicswidgets();
+
+private slots:
+ void widgets();
+};
+
+tst_graphicswidgets::tst_graphicswidgets()
+{
+}
+
+void tst_graphicswidgets::widgets()
+{
+ QmlEngine engine;
+ QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/graphicswidgets.qml"));
+ QGraphicsView *obj = qobject_cast<QGraphicsView*>(c.create());
+
+ QVERIFY(obj != 0);
+ QVERIFY(obj->scene() != 0);
+ QList<QObject*> list;
+ QVERIFY(obj->scene()->children() != list);
+ delete obj;
+}
+
+QTEST_MAIN(tst_graphicswidgets)
+
+#include "tst_graphicswidgets.moc"
diff --git a/tests/auto/declarative/qmlengine/tst_qmlengine.cpp b/tests/auto/declarative/qmlengine/tst_qmlengine.cpp
index 54f916f..5471691 100644
--- a/tests/auto/declarative/qmlengine/tst_qmlengine.cpp
+++ b/tests/auto/declarative/qmlengine/tst_qmlengine.cpp
@@ -161,10 +161,18 @@ void tst_qmlengine::contextForObject()
void tst_qmlengine::offlineStoragePath()
{
+ // Without these set, QDesktopServices::storageLocation returns
+ // strings with extra "//" at the end. We set them to ignore this problem.
+ qApp->setApplicationName("tst_qmlengine");
+ qApp->setOrganizationName("Nokia");
+ qApp->setOrganizationDomain("nokia.com");
+
QmlEngine engine;
QDir dir(QDesktopServices::storageLocation(QDesktopServices::DataLocation));
+ dir.mkpath("QML");
dir.cd("QML");
+ dir.mkpath("OfflineStorage");
dir.cd("OfflineStorage");
QCOMPARE(engine.offlineStoragePath(), dir.path());
diff --git a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp
index 3222d42..80efd94 100644
--- a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp
+++ b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp
@@ -64,10 +64,14 @@ void tst_QmlListModel::dynamic_data()
QTest::newRow("count") << "count" << 0 << "";
+ QTest::newRow("get1") << "{get(0)}" << 0 << "QML QmlListModel (unknown location) get: index 0 out of range";
+
QTest::newRow("append1") << "{append({'foo':123});count}" << 1 << "";
QTest::newRow("append2") << "{append({'foo':123,'bar':456});count}" << 1 << "";
QTest::newRow("append3a") << "{append({'foo':123});append({'foo':456});get(0).foo}" << 123 << "";
QTest::newRow("append3b") << "{append({'foo':123});append({'foo':456});get(1).foo}" << 456 << "";
+ QTest::newRow("append4a") << "{append(123)}" << 0 << "QML QmlListModel (unknown location) append: value is not an object";
+ QTest::newRow("append4b") << "{append([1,2,3])}" << 0 << "QML QmlListModel (unknown location) append: value is not an object";
QTest::newRow("clear1") << "{append({'foo':456});clear();count}" << 0 << "";
QTest::newRow("clear2") << "{append({'foo':123});append({'foo':456});clear();count}" << 0 << "";
@@ -78,6 +82,9 @@ void tst_QmlListModel::dynamic_data()
QTest::newRow("remove2b") << "{append({'foo':123});append({'foo':456});remove(0);get(0).foo}" << 456 << "";
QTest::newRow("remove2c") << "{append({'foo':123});append({'foo':456});remove(1);get(0).foo}" << 123 << "";
QTest::newRow("remove3") << "{append({'foo':123});remove(0);get(0).foo}" << 0 << "QML QmlListModel (unknown location) get: index 0 out of range";
+ QTest::newRow("remove4a") << "{remove(0)}" << 0 << "QML QmlListModel (unknown location) remove: index 0 out of range";
+ QTest::newRow("remove4b") << "{append({'foo':123});remove(0);remove(0)}" << 0 << "QML QmlListModel (unknown location) remove: index 0 out of range";
+ QTest::newRow("remove4c") << "{append({'foo':123});remove(1)}" << 0 << "QML QmlListModel (unknown location) remove: index 1 out of range";
QTest::newRow("insert1") << "{insert(0,{'foo':123});count}" << 1 << "";
QTest::newRow("insert2") << "{insert(1,{'foo':123});count}" << 0 << "QML QmlListModel (unknown location) insert: index 1 out of range";
@@ -87,16 +94,23 @@ void tst_QmlListModel::dynamic_data()
QTest::newRow("insert3d") << "{append({'foo':123});insert(0,{'foo':456});get(0).foo}" << 456 << "";
QTest::newRow("insert3e") << "{append({'foo':123});insert(0,{'foo':456});get(1).foo}" << 123 << "";
QTest::newRow("insert4") << "{append({'foo':123});insert(-1,{'foo':456})}" << 0 << "QML QmlListModel (unknown location) insert: index -1 out of range";
+ QTest::newRow("insert5a") << "{insert(0,123)}" << 0 << "QML QmlListModel (unknown location) insert: value is not an object";
+ QTest::newRow("insert5b") << "{insert(0,[1,2,3])}" << 0 << "QML QmlListModel (unknown location) insert: value is not an object";
QTest::newRow("set1") << "{append({'foo':123});set(0,{'foo':456});count}" << 1 << "";
QTest::newRow("set2") << "{append({'foo':123});set(0,{'foo':456});get(0).foo}" << 456 << "";
QTest::newRow("set3a") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).foo}" << 999 << "";
QTest::newRow("set3b") << "{append({'foo':123,'bar':456});set(0,{'foo':999});get(0).bar}" << 456 << "";
+ QTest::newRow("set4a") << "{set(0,{'foo':456})}" << 0 << "QML QmlListModel (unknown location) set: index 0 out of range";
+ QTest::newRow("set5a") << "{append({'foo':123,'bar':456});set(0,123)}" << 0 << "QML QmlListModel (unknown location) set: value is not an object";
+ QTest::newRow("set5b") << "{append({'foo':123,'bar':456});set(0,[1,2,3])}" << 0 << "QML QmlListModel (unknown location) set: value is not an object";
QTest::newRow("setprop1") << "{append({'foo':123});set(0,'foo',456);count}" << 1 << "";
QTest::newRow("setprop2") << "{append({'foo':123});set(0,'foo',456);get(0).foo}" << 456 << "";
QTest::newRow("setprop3a") << "{append({'foo':123,'bar':456});set(0,'foo',999);get(0).foo}" << 999 << "";
QTest::newRow("setprop3b") << "{append({'foo':123,'bar':456});set(0,'foo',999);get(0).bar}" << 456 << "";
+ QTest::newRow("setprop4a") << "{set(0,'foo',456)}" << 0 << "QML QmlListModel (unknown location) set: index 0 out of range";
+ QTest::newRow("setprop4a") << "{append({'foo':123,'bar':456});set(1,'foo',456)}" << 0 << "QML QmlListModel (unknown location) set: index 1 out of range";
QTest::newRow("move1a") << "{append({'foo':123});append({'foo':456});move(0,1,1);count}" << 2 << "";
QTest::newRow("move1b") << "{append({'foo':123});append({'foo':456});move(0,1,1);get(0).foo}" << 456 << "";
@@ -107,6 +121,10 @@ void tst_QmlListModel::dynamic_data()
QTest::newRow("move2b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(0).foo}" << 789 << "";
QTest::newRow("move2c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(1).foo}" << 123 << "";
QTest::newRow("move2d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,1,2);get(2).foo}" << 456 << "";
+ QTest::newRow("move3a") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,3)}" << 0 << "QML QmlListModel (unknown location) move: out of range";
+ QTest::newRow("move3b") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,-1,1)}" << 0 << "QML QmlListModel (unknown location) move: out of range";
+ QTest::newRow("move3c") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(1,0,-1)}" << 0 << "QML QmlListModel (unknown location) move: out of range";
+ QTest::newRow("move3d") << "{append({'foo':123});append({'foo':456});append({'foo':789});move(0,3,1)}" << 0 << "QML QmlListModel (unknown location) move: out of range";
// Structured model
diff --git a/tests/auto/declarative/sql/data/2-selection-bindnames.js b/tests/auto/declarative/sql/data/2-selection-bindnames.js
new file mode 100644
index 0000000..c00acc14
--- /dev/null
+++ b/tests/auto/declarative/sql/data/2-selection-bindnames.js
@@ -0,0 +1,24 @@
+var db = openDatabase("QmlTestDB", "", "Test database from Qt autotests", 1000000);
+var r=0;
+
+db.transaction(
+ function(tx) {
+ tx.executeSql('SELECT * FROM Greeting WHERE salutation=:p2 AND salutee=:p1', {':p1':'world', ':p2':'hello'},
+ function(tx, rs) {
+ if ( rs.rows.length != 4 ) {
+ if (r==0) r = "SELECT RETURNED WRONG VALUE "+rs.rows.length+rs.rows.item(0)+rs.rows.item(1)
+ }
+ },
+ function(tx, error) { if (r==0) r="SELECT FAILED: "+error.message }
+ );
+ },
+ function(tx, error) { if (r==0) r="TRANSACTION FAILED: "+error.message },
+ function(tx, result) { if (r==0) r="passed" }
+);
+
+
+function test()
+{
+ if (r == 0) r = "transaction_not_finished";
+ return r;
+}
diff --git a/tests/auto/declarative/sql/data/6-iteration-efficient.js b/tests/auto/declarative/sql/data/6-iteration-efficient.js
index 2222b8a..6711fb0 100644
--- a/tests/auto/declarative/sql/data/6-iteration-efficient.js
+++ b/tests/auto/declarative/sql/data/6-iteration-efficient.js
@@ -1,12 +1,16 @@
var db = openDatabase("QmlTestDB", "", "Test database from Qt autotests", 1000000);
var r=0;
+var fbefore="FORWARD WRONG"
+var fafter="FORWARD WRONG"
db.transaction(
function(tx) {
tx.executeSql('SELECT * FROM Greeting', [],
function(tx, rs) {
var r1=""
+ if (!rs.rows.forwardOnly) fbefore=""
rs.rows.forwardOnly = true;
+ if (rs.rows.forwardOnly) fafter="";
for(var i=0; rs.rows[i]; ++i) {
r1 += rs.rows[i].salutation + ", " + rs.rows[i].salutee + ";"
}
@@ -17,7 +21,7 @@ db.transaction(
);
},
function(tx, error) { if (r==0) r="TRANSACTION FAILED: "+error.message },
- function(tx, result) { if (r==0) r="passed" }
+ function(tx, result) { if (r==0) r=fbefore+"passed"+fafter }
);
diff --git a/tests/auto/declarative/sql/tst_sql.cpp b/tests/auto/declarative/sql/tst_sql.cpp
index e4f497c..973d7b1 100644
--- a/tests/auto/declarative/sql/tst_sql.cpp
+++ b/tests/auto/declarative/sql/tst_sql.cpp
@@ -139,10 +139,11 @@ void tst_sql::testQml_data()
QTest::newRow("creation") << "data/1-creation.js" << "passed" << 1 << false;
QTest::newRow("selection") << "data/2-selection.js" << "passed" << 1 << false;
+ QTest::newRow("selection-bindnames") << "data/2-selection-bindnames.js" << "passed" << 1 << true; // WebKit somehow breaks named parameters
QTest::newRow("iteration-item-function") << "data/3-iteration-item-function.js" << "passed" << 1 << false;
- QTest::newRow("iteration-index") << "data/4-iteration-index.js" << "passed" << 1 << true;
- QTest::newRow("iteration-iterator") << "data/5-iteration-iterator.js" << "passed" << 1 << true;
- QTest::newRow("iteration-efficient") << "data/6-iteration-efficient.js" << "passed" << 1 << true;
+ QTest::newRow("iteration-index") << "data/4-iteration-index.js" << "passed" << 1 << true; // Some HTML5 documents say to use rows by index, others by item() function
+ QTest::newRow("iteration-iterator") << "data/5-iteration-iterator.js" << "passed" << 1 << true; // As with previous, WebKit doesn't give an array
+ QTest::newRow("iteration-efficient") << "data/6-iteration-efficient.js" << "passed" << 1 << true; // It's very inefficient to find the total number of results, here is a solution
}
void tst_sql::validateAgainstWebkit_data()