diff options
author | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-01-12 09:49:44 (GMT) |
---|---|---|
committer | Aaron Kennedy <aaron.kennedy@nokia.com> | 2010-01-12 09:49:44 (GMT) |
commit | bc08102443fa484053320196ba3e19b98b9f62b4 (patch) | |
tree | 81369b02604009d98be9f88870e00b7c7ddd9515 | |
parent | 2b58621aebf345593f9a277b2ae8dad5aebe0ac1 (diff) | |
parent | c68b263f1ed0446ec8695c947fd43e302fabf8bd (diff) | |
download | Qt-bc08102443fa484053320196ba3e19b98b9f62b4.zip Qt-bc08102443fa484053320196ba3e19b98b9f62b4.tar.gz Qt-bc08102443fa484053320196ba3e19b98b9f62b4.tar.bz2 |
Merge branch 'kinetic-declarativeui' of scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r-- | src/declarative/graphicsitems/qmlgraphicslistview.cpp | 2 | ||||
-rw-r--r-- | src/declarative/qml/qmlxmlhttprequest.cpp | 71 | ||||
-rw-r--r-- | tests/auto/declarative/states/tst_states.cpp | 7 | ||||
-rw-r--r-- | tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp | 35 | ||||
-rw-r--r-- | tools/qmlviewer/content/Browser.qml | 30 |
5 files changed, 97 insertions, 48 deletions
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp index 3a59c6c..2752551 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp @@ -1942,6 +1942,8 @@ QString QmlGraphicsListView::currentSection() const highlightFollowsCurrentItem must be true for these properties to have effect. + The default value for these properties is 400 pixels/second. + \sa highlightFollowsCurrentItem */ qreal QmlGraphicsListView::highlightMoveSpeed() const diff --git a/src/declarative/qml/qmlxmlhttprequest.cpp b/src/declarative/qml/qmlxmlhttprequest.cpp index 9c39fc8..5fd14e7 100644 --- a/src/declarative/qml/qmlxmlhttprequest.cpp +++ b/src/declarative/qml/qmlxmlhttprequest.cpp @@ -951,12 +951,12 @@ public: int replyStatus() const; QString replyStatusText() const; - void open(const QString &, const QUrl &); + QScriptValue open(const QString &, const QUrl &); void addHeader(const QString &, const QString &); QString header(const QString &name); QString headers(); - void send(const QByteArray &); - void abort(); + QScriptValue send(const QByteArray &); + QScriptValue abort(); QString responseBody() const; private slots: @@ -977,7 +977,7 @@ private: HeadersList m_headersList; void fillHeadersList(); - void dispatchCallback(); + QScriptValue dispatchCallback(); QScriptValue m_callback; int m_status; @@ -1044,7 +1044,7 @@ QString QmlXMLHttpRequest::replyStatusText() const return m_statusText; } -void QmlXMLHttpRequest::open(const QString &method, const QUrl &url) +QScriptValue QmlXMLHttpRequest::open(const QString &method, const QUrl &url) { destroyNetwork(); m_sendFlag = false; @@ -1053,7 +1053,7 @@ void QmlXMLHttpRequest::open(const QString &method, const QUrl &url) m_method = method; m_url = url; m_state = Opened; - dispatchCallback(); + return dispatchCallback(); } void QmlXMLHttpRequest::addHeader(const QString &name, const QString &value) @@ -1107,12 +1107,13 @@ void QmlXMLHttpRequest::fillHeadersList() } } -void QmlXMLHttpRequest::send(const QByteArray &data) +QScriptValue QmlXMLHttpRequest::send(const QByteArray &data) { m_errorFlag = false; m_sendFlag = true; - dispatchCallback(); + QScriptValue cbv = dispatchCallback(); + if (cbv.isError()) return cbv; m_request.setUrl(m_url); QNetworkRequest request = m_request; @@ -1160,9 +1161,11 @@ void QmlXMLHttpRequest::send(const QByteArray &data) this, SLOT(error(QNetworkReply::NetworkError))); QObject::connect(m_network, SIGNAL(finished()), this, SLOT(finished())); + + return QScriptValue(); } -void QmlXMLHttpRequest::abort() +QScriptValue QmlXMLHttpRequest::abort() { destroyNetwork(); m_responseEntityBody = QByteArray(); @@ -1175,10 +1178,12 @@ void QmlXMLHttpRequest::abort() m_state = Done; m_sendFlag = false; - dispatchCallback(); + QScriptValue cbv = dispatchCallback(); + if (cbv.isError()) return cbv; } m_state = Unsent; + return QScriptValue(); } void QmlXMLHttpRequest::downloadProgress(qint64 bytes) @@ -1193,14 +1198,18 @@ void QmlXMLHttpRequest::downloadProgress(qint64 bytes) if (m_state < HeadersReceived) { m_state = HeadersReceived; fillHeadersList (); - dispatchCallback(); + QScriptValue cbv = dispatchCallback(); + if (cbv.isError()) + qWarning().nospace() << qPrintable(cbv.toString()); } bool wasEmpty = m_responseEntityBody.isEmpty(); m_responseEntityBody.append(m_network->readAll()); if (wasEmpty && !m_responseEntityBody.isEmpty()) { m_state = Loading; - dispatchCallback(); + QScriptValue cbv = dispatchCallback(); + if (cbv.isError()) + qWarning().nospace() << qPrintable(cbv.toString()); } } @@ -1223,13 +1232,17 @@ void QmlXMLHttpRequest::error(QNetworkReply::NetworkError error) error == QNetworkReply::AuthenticationRequiredError || error == QNetworkReply::ContentReSendError) { m_state = Loading; - dispatchCallback(); + QScriptValue cbv = dispatchCallback(); + if (cbv.isError()) + qWarning().nospace() << qPrintable(cbv.toString()); } else { m_errorFlag = true; } m_state = Done; - dispatchCallback(); + QScriptValue cbv = dispatchCallback(); + if (cbv.isError()) + qWarning().nospace() << qPrintable(cbv.toString()); } void QmlXMLHttpRequest::finished() @@ -1244,16 +1257,22 @@ void QmlXMLHttpRequest::finished() if (m_state < HeadersReceived) { m_state = HeadersReceived; fillHeadersList (); - dispatchCallback(); + QScriptValue cbv = dispatchCallback(); + if (cbv.isError()) + qWarning().nospace() << qPrintable(cbv.toString()); } m_responseEntityBody.append(m_network->readAll()); destroyNetwork(); if (m_state < Loading) { m_state = Loading; - dispatchCallback(); + QScriptValue cbv = dispatchCallback(); + if (cbv.isError()) + qWarning().nospace() << qPrintable(cbv.toString()); } m_state = Done; - dispatchCallback(); + QScriptValue cbv = dispatchCallback(); + if (cbv.isError()) + qWarning().nospace() << qPrintable(cbv.toString()); } @@ -1262,9 +1281,9 @@ QString QmlXMLHttpRequest::responseBody() const return QString::fromUtf8(m_responseEntityBody); } -void QmlXMLHttpRequest::dispatchCallback() +QScriptValue QmlXMLHttpRequest::dispatchCallback() { - m_callback.call(); + return m_callback.call(); } void QmlXMLHttpRequest::destroyNetwork() @@ -1321,9 +1340,7 @@ static QScriptValue qmlxmlhttprequest_open(QScriptContext *context, QScriptEngin if (!username.isNull()) url.setUserName(username); if (!password.isNull()) url.setPassword(password); - request->open(method, url); - - return engine->undefinedValue(); + return request->open(method, url); } static QScriptValue qmlxmlhttprequest_setRequestHeader(QScriptContext *context, QScriptEngine *engine) @@ -1390,20 +1407,16 @@ static QScriptValue qmlxmlhttprequest_send(QScriptContext *context, QScriptEngin if (context->argumentCount() > 0) data = context->argument(0).toString().toUtf8(); - request->send(data); - - return engine->undefinedValue(); + return request->send(data); } -static QScriptValue qmlxmlhttprequest_abort(QScriptContext *context, QScriptEngine *engine) +static QScriptValue qmlxmlhttprequest_abort(QScriptContext *context, QScriptEngine *) { QmlXMLHttpRequest *request = qobject_cast<QmlXMLHttpRequest *>(context->thisObject().data().toQObject()); if (!request) THROW_REFERENCE("Not an XMLHttpRequest object"); - request->abort(); - - return engine->undefinedValue(); + return request->abort(); } static QScriptValue qmlxmlhttprequest_getResponseHeader(QScriptContext *context, QScriptEngine *engine) diff --git a/tests/auto/declarative/states/tst_states.cpp b/tests/auto/declarative/states/tst_states.cpp index 3301048..3c89747 100644 --- a/tests/auto/declarative/states/tst_states.cpp +++ b/tests/auto/declarative/states/tst_states.cpp @@ -398,6 +398,7 @@ void tst_states::parentChange() QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect")); QVERIFY(innerRect != 0); + qmlExecuteDeferred(rect->states()->at(0)); QmlParentChange *pChange = qobject_cast<QmlParentChange*>(rect->states()->at(0)->changes()->at(0)); QVERIFY(pChange != 0); QmlGraphicsItem *nParent = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("NewParent")); @@ -497,6 +498,7 @@ void tst_states::anchorChanges() QmlGraphicsRectangle *innerRect = qobject_cast<QmlGraphicsRectangle*>(rect->findChild<QmlGraphicsRectangle*>("MyRect")); QVERIFY(innerRect != 0); + qmlExecuteDeferred(rect->states()->at(0)); QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(rect->states()->at(0)->changes()->at(0)); QVERIFY(aChanges != 0); @@ -551,6 +553,7 @@ void tst_states::anchorChanges3() QmlGraphicsItem *bottomGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("BottomGuideline")); QVERIFY(bottomGuideline != 0); + qmlExecuteDeferred(rect->states()->at(0)); QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(rect->states()->at(0)->changes()->at(0)); QVERIFY(aChanges != 0); @@ -596,6 +599,7 @@ void tst_states::anchorChanges4() QmlGraphicsItem *bottomGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("BottomGuideline")); QVERIFY(bottomGuideline != 0); + qmlExecuteDeferred(rect->states()->at(0)); QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(rect->states()->at(0)->changes()->at(0)); QVERIFY(aChanges != 0); @@ -626,6 +630,7 @@ void tst_states::anchorChanges5() QmlGraphicsItem *bottomGuideline = qobject_cast<QmlGraphicsItem*>(rect->findChild<QmlGraphicsItem*>("BottomGuideline")); QVERIFY(bottomGuideline != 0); + qmlExecuteDeferred(rect->states()->at(0)); QmlAnchorChanges *aChanges = qobject_cast<QmlAnchorChanges*>(rect->states()->at(0)->changes()->at(0)); QVERIFY(aChanges != 0); @@ -683,6 +688,7 @@ void tst_states::explicitChanges() QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(rectComponent.create()); QVERIFY(rect != 0); + qmlExecuteDeferred(rect->states()->at(0)); QmlPropertyChanges *changes = qobject_cast<QmlPropertyChanges*>(rect->findChild<QmlPropertyChanges*>("changes")); QVERIFY(changes != 0); QVERIFY(changes->isExplicit()); @@ -783,6 +789,7 @@ void tst_states::deletingChange() QmlState *state = rect->findChild<QmlState*>(); QVERIFY(state != 0); + qmlExecuteDeferred(state); QCOMPARE(state->changes()->count(), 1); rect->setState("blue"); diff --git a/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp b/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp index dc48195..f952099 100644 --- a/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp +++ b/tests/auto/declarative/xmlhttprequest/tst_xmlhttprequest.cpp @@ -64,6 +64,7 @@ private slots: } void domExceptionCodes(); + void callbackException(); void staticStateValues(); void instanceStateValues(); void constructor(); @@ -157,6 +158,31 @@ void tst_xmlhttprequest::domExceptionCodes() delete object; } +#define TRY_WAIT(expr) \ + do { \ + for (int ii = 0; ii < 6; ++ii) { \ + if ((expr)) break; \ + QTest::qWait(50); \ + } \ + QVERIFY((expr)); \ + } while (false) + +void tst_xmlhttprequest::callbackException() +{ + QString expect = TEST_FILE("callbackException.qml").toString() + ":16: Error: Exception from Callback"; + QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); + + QmlComponent component(&engine, TEST_FILE("callbackException.qml")); + QObject *object = component.beginCreate(engine.rootContext()); + QVERIFY(object != 0); + object->setProperty("url", "testdocument.html"); + component.completeCreate(); + + TRY_WAIT(object->property("threw").toBool() == true); + + delete object; +} + // Test that the state value properties on the XMLHttpRequest constructor have the correct values. // ### WebKit does not do this, but it seems to fit the standard and QML better void tst_xmlhttprequest::staticStateValues() @@ -219,15 +245,6 @@ void tst_xmlhttprequest::defaultState() delete object; } -#define TRY_WAIT(expr) \ - do { \ - for (int ii = 0; ii < 6; ++ii) { \ - if ((expr)) break; \ - QTest::qWait(50); \ - } \ - QVERIFY((expr)); \ - } while (false) - // Test valid XMLHttpRequest.open() calls void tst_xmlhttprequest::open() { diff --git a/tools/qmlviewer/content/Browser.qml b/tools/qmlviewer/content/Browser.qml index 7643a57..446045b 100644 --- a/tools/qmlviewer/content/Browser.qml +++ b/tools/qmlviewer/content/Browser.qml @@ -8,6 +8,7 @@ Rectangle { width: 320 height: 480 color: palette.window + FolderListModel { id: folders1 nameFilters: [ "*.qml" ] @@ -34,6 +35,7 @@ Rectangle { } view.x = root.width; view.state = "current"; + view.focus = true; folders.folder = path; } function up() { @@ -49,6 +51,7 @@ Rectangle { } view.x = -root.width; view.state = "current"; + view.focus = true; folders.folder = path; } } @@ -65,7 +68,7 @@ Rectangle { } } width: root.width - height: 48 + height: 52 color: "transparent" Rectangle { id: highlight; visible: false @@ -76,15 +79,16 @@ Rectangle { } } Item { - width: 46; height: 46 + width: 48; height: 48 Image { source: "images/folder.png"; anchors.centerIn: parent; visible: folders.isFolder(index)} } Text { id: nameText anchors.fill: parent; verticalAlignment: Text.AlignVCenter - text: fileName; anchors.leftMargin: 48 + text: fileName + anchors.leftMargin: 54 font.pixelSize: 32 - color: wrapper.isCurrentItem ? palette.highlightedText : palette.text + color: (wrapper.ListView.isCurrentItem && root.keyPressed) ? palette.highlightedText : palette.windowText } MouseRegion { id: mouseRegion @@ -110,9 +114,10 @@ Rectangle { width: parent.width model: folders1 delegate: folderDelegate - highlight: Rectangle { color: palette.highlight; visible: root.keyPressed } - focus: true + highlight: Rectangle { color: palette.highlight; visible: root.keyPressed && view1.count != 0 } + highlightMoveSpeed: 1000 pressDelay: 100 + focus: true state: "current" states: [ State { @@ -140,6 +145,7 @@ Rectangle { NumberAnimation { matchProperties: "x"; duration: 250 } } ] + Keys.onPressed: { root.keyPressed = true; } } ListView { @@ -150,8 +156,8 @@ Rectangle { width: parent.width model: folders2 delegate: folderDelegate - highlight: Rectangle { color: palette.highlight; visible: root.keyPressed } - focus: true + highlight: Rectangle { color: palette.highlight; visible: root.keyPressed && view2.count != 0 } + highlightMoveSpeed: 1000 pressDelay: 100 states: [ State { @@ -178,6 +184,7 @@ Rectangle { NumberAnimation { matchProperties: "x"; duration: 250 } } ] + Keys.onPressed: { root.keyPressed = true; } } Keys.onPressed: { @@ -185,9 +192,10 @@ Rectangle { if (event.key == Qt.Key_Return || event.key == Qt.Key_Select || event.key == Qt.Key_Right) { view.currentItem.launch(); event.accepted = true; + } else if (event.key == Qt.Key_Left) { + up(); } } - Keys.onLeftPressed: up() BorderImage { source: "images/titlebar.sci"; @@ -203,7 +211,9 @@ Rectangle { color: "transparent" Image { anchors.centerIn: parent; source: "images/up.png" } - MouseRegion { id: upRegion; anchors.fill: parent + MouseRegion { id: upRegion; anchors.centerIn: parent + width: 56 + height: 56 onClicked: if (folders.parentFolder != "") up() } states: [ |