From f9aa040505c5c679bed4181e462fb4d2b9216fa6 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Fri, 27 Nov 2009 10:40:08 +0100 Subject: Fix use of XmlHttpRequest in examples --- demos/declarative/samegame/content/samegame.js | 1 + demos/declarative/twitter/content/HomeTitleBar.qml | 1 + examples/declarative/tutorials/samegame/samegame4/content/samegame.js | 1 + 3 files changed, 3 insertions(+) diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js index 3598c26..8651c84 100755 --- a/demos/declarative/samegame/content/samegame.js +++ b/demos/declarative/samegame/content/samegame.js @@ -235,6 +235,7 @@ function sendHighScore(name) { var postData = "name="+name+"&score="+gameCanvas.score +"&gridSize="+maxX+"x"+maxY +"&time="+Math.floor(timer/1000); postman.open("POST", scoresURL, true); + postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); postman.onreadystatechange = function() { if (postman.readyState == postman.DONE) { dialog.show("Your score has been uploaded."); diff --git a/demos/declarative/twitter/content/HomeTitleBar.qml b/demos/declarative/twitter/content/HomeTitleBar.qml index e5bdb85..c48befd 100644 --- a/demos/declarative/twitter/content/HomeTitleBar.qml +++ b/demos/declarative/twitter/content/HomeTitleBar.qml @@ -24,6 +24,7 @@ Item { titleBar.update(); } } + postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); postman.send(postData); editor.text = "" diff --git a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js index b833385..2a0d718 100755 --- a/examples/declarative/tutorials/samegame/samegame4/content/samegame.js +++ b/examples/declarative/tutorials/samegame/samegame4/content/samegame.js @@ -238,6 +238,7 @@ function sendHighScore(name) { var postData = "name="+name+"&score="+gameCanvas.score +"&gridSize="+maxX+"x"+maxY +"&time="+Math.floor(timer/1000); postman.open("POST", scoresURL, true); + postman.setRequestHeader("Content-Type", "application/x-www-form-urlencoded"); postman.onreadystatechange = function() { if (postman.readyState == postman.DONE) { dialog.show("Your score has been uploaded."); -- cgit v0.12 From dc59b792119241988cdfe9f31d3aea55dcd5e8fe Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Mon, 30 Nov 2009 09:48:13 +1000 Subject: Fix tutorial3. Task-number: QTBUG-6306 --- examples/declarative/tutorials/helloworld/tutorial3.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/declarative/tutorials/helloworld/tutorial3.qml b/examples/declarative/tutorials/helloworld/tutorial3.qml index 52c3fe8..0f27f86 100644 --- a/examples/declarative/tutorials/helloworld/tutorial3.qml +++ b/examples/declarative/tutorials/helloworld/tutorial3.qml @@ -29,7 +29,7 @@ Rectangle { from: ""; to: "down"; reversible: true ParallelAnimation { NumberAnimation { matchProperties: "y,rotation"; duration: 500; easing: "easeInOutQuad" } - ColorAnimation { property: "color"; duration: 500 } + ColorAnimation { duration: 500 } } } //![3] -- cgit v0.12 From 1f8e66b71bc641a9e29f3b3157de2d393d911f23 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 30 Nov 2009 09:53:03 +1000 Subject: Fix and test ListModel UTF8 reading. --- src/declarative/util/qmllistmodel.cpp | 2 +- tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp | 14 ++++++++++++++ 2 files changed, 15 insertions(+), 1 deletion(-) diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index 5491fd7..8259dcd 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -851,7 +851,7 @@ void QmlListModelParser::setCustomData(QObject *obj, const QByteArray &d) case ListInstruction::Value: { ModelNode *n = nodes.top(); - n->values.append(QByteArray(data + instr.dataIdx)); + n->values.append(QString::fromUtf8(QByteArray(data + instr.dataIdx))); } break; diff --git a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp index f2ffb7b..c7de5d9 100644 --- a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp +++ b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp @@ -51,12 +51,26 @@ public: tst_QmlListModel() {} private slots: + void static_i18n(); void dynamic_data(); void dynamic(); void error_data(); void error(); }; +void tst_QmlListModel::static_i18n() +{ + QString expect = QString::fromUtf8("na\303\257ve"); + QString componentStr = "import Qt 4.6\nListModel { ListElement { prop1: \""+expect+"\" } }"; + QmlEngine engine; + QmlComponent component(&engine, componentStr.toUtf8(), QUrl("file://")); + QmlListModel *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + QString prop = obj->get(0).property(QLatin1String("prop1")).toString(); + QCOMPARE(prop,expect); + delete obj; +} + void tst_QmlListModel::dynamic_data() { QTest::addColumn("script"); -- cgit v0.12 From 37cd2eb354e62bf8c3eba0b5edaebe082bf8b3ac Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 30 Nov 2009 09:53:25 +1000 Subject: atob and btoa functions (as per JS window functions) --- src/declarative/qml/qmlengine.cpp | 22 ++++++++++++++++++++++ src/declarative/qml/qmlengine_p.h | 2 ++ 2 files changed, 24 insertions(+) diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 0a00092..aa66c17 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -144,6 +144,8 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) qtObject.setProperty(QLatin1String("playSound"), scriptEngine.newFunction(QmlEnginePrivate::playSound, 1)); qtObject.setProperty(QLatin1String("openUrlExternally"),scriptEngine.newFunction(desktopOpenUrl, 1)); qtObject.setProperty(QLatin1String("md5"),scriptEngine.newFunction(md5, 1)); + qtObject.setProperty(QLatin1String("btoa"),scriptEngine.newFunction(btoa, 1)); + qtObject.setProperty(QLatin1String("atob"),scriptEngine.newFunction(atob, 1)); //firebug/webkit compat QScriptValue consoleObject = scriptEngine.newObject(); @@ -818,6 +820,26 @@ QScriptValue QmlEnginePrivate::md5(QScriptContext *ctxt, QScriptEngine *) return QScriptValue(QLatin1String(result.toHex())); } +QScriptValue QmlEnginePrivate::btoa(QScriptContext *ctxt, QScriptEngine *) +{ + QByteArray data; + + if (ctxt->argumentCount() >= 1) + data = ctxt->argument(0).toString().toUtf8(); + + return QScriptValue(QLatin1String(data.toBase64())); +} + +QScriptValue QmlEnginePrivate::atob(QScriptContext *ctxt, QScriptEngine *) +{ + QByteArray data; + + if (ctxt->argumentCount() >= 1) + data = ctxt->argument(0).toString().toUtf8(); + + return QScriptValue(QLatin1String(QByteArray::fromBase64(data))); +} + QScriptValue QmlEnginePrivate::consoleLog(QScriptContext *ctxt, QScriptEngine *e) { if(ctxt->argumentCount() < 1) diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index c11a399..cabd0ad 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -269,6 +269,8 @@ public: static QScriptValue playSound(QScriptContext*, QScriptEngine*); static QScriptValue desktopOpenUrl(QScriptContext*, QScriptEngine*); static QScriptValue md5(QScriptContext*, QScriptEngine*); + static QScriptValue btoa(QScriptContext*, QScriptEngine*); + static QScriptValue atob(QScriptContext*, QScriptEngine*); static QScriptValue consoleLog(QScriptContext*, QScriptEngine*); static QScriptEngine *getScriptEngine(QmlEngine *e) { return &e->d_func()->scriptEngine; } -- cgit v0.12 From 15145a3b6d675c268b6262d11d390eaf9fc25fee Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 30 Nov 2009 09:54:27 +1000 Subject: Some UTF8 --- examples/declarative/listview/dummydata/MyPetsModel.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/examples/declarative/listview/dummydata/MyPetsModel.qml b/examples/declarative/listview/dummydata/MyPetsModel.qml index 9a00dca..074fc13 100644 --- a/examples/declarative/listview/dummydata/MyPetsModel.qml +++ b/examples/declarative/listview/dummydata/MyPetsModel.qml @@ -29,7 +29,7 @@ ListModel { size: "Medium" } ListElement { - name: "Whiskers" + name: "Schrödinger" type: "Cat" age: 2 size: "Medium" -- cgit v0.12