From 184458394b344947bea1852ab88561dc60db6038 Mon Sep 17 00:00:00 2001 From: Aaron McCarthy Date: Mon, 20 Dec 2010 10:32:54 +1000 Subject: Quiet unused parameter warnings. --- src/plugins/bearer/icd/qicdengine.cpp | 3 +++ 1 file changed, 3 insertions(+) diff --git a/src/plugins/bearer/icd/qicdengine.cpp b/src/plugins/bearer/icd/qicdengine.cpp index a5a183b..96827f3 100644 --- a/src/plugins/bearer/icd/qicdengine.cpp +++ b/src/plugins/bearer/icd/qicdengine.cpp @@ -966,6 +966,9 @@ void QIcdEngine::connectionStateSignalsSlot(QDBusMessage msg) void QIcdEngine::icdServiceOwnerChanged(const QString &serviceName, const QString &oldOwner, const QString &newOwner) { + Q_UNUSED(serviceName); + Q_UNUSED(oldOwner); + QMutexLocker locker(&mutex); if (newOwner.isEmpty()) { -- cgit v0.12 From 95b0418a7ee7aee9658fd19b363e73d583af0b04 Mon Sep 17 00:00:00 2001 From: Damian Jansen Date: Mon, 20 Dec 2010 13:09:48 +1000 Subject: Fix deployment of minehunt for Symbian Task: QT-4298 --- demos/declarative/minehunt/minehunt.pro | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/declarative/minehunt/minehunt.pro b/demos/declarative/minehunt/minehunt.pro index 8a7fdc5..5929ecf 100644 --- a/demos/declarative/minehunt/minehunt.pro +++ b/demos/declarative/minehunt/minehunt.pro @@ -18,6 +18,6 @@ symbian:{ TARGET.EPOCHEAPSIZE = 0x20000 0x2000000 include($$QT_SOURCE_TREE/demos/symbianpkgrules.pri) qmlminehuntfiles.sources = MinehuntCore minehunt.qml - DEPLOYMENT = qmlminehuntfiles + DEPLOYMENT += qmlminehuntfiles } -- cgit v0.12 From 0aeebdc851682d2afd63494ddeafa4e745ad2b72 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 20 Dec 2010 14:30:09 +1000 Subject: Update docs on importing javascript files --- doc/src/declarative/javascriptblocks.qdoc | 4 +++- doc/src/declarative/modules.qdoc | 2 ++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/src/declarative/javascriptblocks.qdoc b/doc/src/declarative/javascriptblocks.qdoc index 155bd6e..68cb392 100644 --- a/doc/src/declarative/javascriptblocks.qdoc +++ b/doc/src/declarative/javascriptblocks.qdoc @@ -99,7 +99,9 @@ resource, the component's \l {QDeclarativeComponent::status()}{status} is set to Imported JavaScript files are always qualified using the "as" keyword. The qualifier for JavaScript files must be unique, so there is always a one-to-one -mapping between qualifiers and JavaScript files. +mapping between qualifiers and JavaScript files. (This also means qualifiers cannot +be named the same as built-in JavaScript objects such as \c Date and \c Math). + \section2 Code-Behind Implementation Files diff --git a/doc/src/declarative/modules.qdoc b/doc/src/declarative/modules.qdoc index 011eb63..bf9f5fd 100644 --- a/doc/src/declarative/modules.qdoc +++ b/doc/src/declarative/modules.qdoc @@ -216,6 +216,8 @@ JavaScript files must always be imported with a named import: } \endqml +The qualifier ("MyScript" in the above example) must be unique within the QML document. +Unlike ordinary modules, multiple scripts cannot be imported into the same namespace. \section1 Writing a qmldir file -- cgit v0.12 From 327169a6a3fb0bac258cb878019734211a707cce Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 20 Dec 2010 14:30:27 +1000 Subject: Don't truncate image:// url strings prematurely Url fragments and queries were being removed from the image ids passed to QDeclarativeImageProvider. Task-number: QTBUG-16195 Reviewed-by: Martin Jones --- src/declarative/qml/qdeclarativeengine.cpp | 12 ++++-- src/declarative/qml/qdeclarativeimageprovider.cpp | 16 ++++++-- .../tst_qdeclarativeimageprovider.cpp | 46 ++++++++++++++++++++-- 3 files changed, 62 insertions(+), 12 deletions(-) diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 201e675..cf3ea42 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -760,8 +760,10 @@ QImage QDeclarativeEnginePrivate::getImageFromProvider(const QUrl &url, QSize *s QImage image; QSharedPointer provider = imageProviders.value(url.host()); locker.unlock(); - if (provider) - image = provider->requestImage(url.path().mid(1), size, req_size); + if (provider) { + QString imageId = url.toString(QUrl::RemoveScheme | QUrl::RemoveAuthority).mid(1); + image = provider->requestImage(imageId, size, req_size); + } return image; } @@ -771,8 +773,10 @@ QPixmap QDeclarativeEnginePrivate::getPixmapFromProvider(const QUrl &url, QSize QPixmap pixmap; QSharedPointer provider = imageProviders.value(url.host()); locker.unlock(); - if (provider) - pixmap = provider->requestPixmap(url.path().mid(1), size, req_size); + if (provider) { + QString imageId = url.toString(QUrl::RemoveScheme | QUrl::RemoveAuthority).mid(1); + pixmap = provider->requestPixmap(imageId, size, req_size); + } return pixmap; } diff --git a/src/declarative/qml/qdeclarativeimageprovider.cpp b/src/declarative/qml/qdeclarativeimageprovider.cpp index ef31be7..e3da645 100644 --- a/src/declarative/qml/qdeclarativeimageprovider.cpp +++ b/src/declarative/qml/qdeclarativeimageprovider.cpp @@ -182,13 +182,17 @@ QDeclarativeImageProvider::ImageType QDeclarativeImageProvider::imageType() cons Implement this method to return the image with \a id. The default implementation returns an empty image. + The \a id is the requested image source, with the "image:" scheme and + provider identifier removed. For example, if the image \l{Image::}{source} + was "image://myprovider/icons/home", the given \a id would be "icons/home". + The \a requestedSize corresponds to the \l {Image::sourceSize} requested by an Image element. If \a requestedSize is a valid size, the image returned should be of that size. In all cases, \a size must be set to the original size of the image. This - is used to set the \l {Item::}{width} and \l {Item::}{height} of image - elements that should be automatically sized to the loaded image. + is used to set the \l {Item::}{width} and \l {Item::}{height} of the + relevant \l Image if these values have not been set explicitly. \note this method may be called by multiple threads, so ensure the implementation of this method is reentrant. @@ -207,13 +211,17 @@ QImage QDeclarativeImageProvider::requestImage(const QString &id, QSize *size, c Implement this method to return the pixmap with \a id. The default implementation returns an empty pixmap. + The \a id is the requested image source, with the "image:" scheme and + provider identifier removed. For example, if the image \l{Image::}{source} + was "image://myprovider/icons/home", the given \a id would be "icons/home". + The \a requestedSize corresponds to the \l {Image::sourceSize} requested by an Image element. If \a requestedSize is a valid size, the image returned should be of that size. In all cases, \a size must be set to the original size of the image. This - is used to set the \l {Item::}{width} and \l {Item::}{height} of image - elements that should be automatically sized to the loaded image. + is used to set the \l {Item::}{width} and \l {Item::}{height} of the + relevant \l Image if these values have not been set explicitly. */ QPixmap QDeclarativeImageProvider::requestPixmap(const QString &id, QSize *size, const QSize& requestedSize) { diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp index cd12e3a..5b214e6 100644 --- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp +++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp @@ -100,6 +100,8 @@ public: QImage requestImage(const QString &id, QSize *size, const QSize& requestedSize) { + lastImageId = id; + if (id == QLatin1String("no-such-file.png")) return QImage(); @@ -114,6 +116,7 @@ public: } bool *deleteWatch; + QString lastImageId; }; Q_DECLARE_METATYPE(TestQImageProvider*); @@ -134,6 +137,8 @@ public: QPixmap requestPixmap(const QString &id, QSize *size, const QSize& requestedSize) { + lastImageId = id; + if (id == QLatin1String("no-such-file.png")) return QPixmap(); @@ -148,6 +153,7 @@ public: } bool *deleteWatch; + QString lastImageId; }; Q_DECLARE_METATYPE(TestQPixmapProvider*); @@ -164,22 +170,49 @@ QString tst_qdeclarativeimageprovider::newImageFileName() const void tst_qdeclarativeimageprovider::fillRequestTestsData(const QString &id) { QTest::addColumn("source"); + QTest::addColumn("imageId"); QTest::addColumn("properties"); QTest::addColumn("size"); QTest::addColumn("error"); - QTest::newRow(QTest::toString(id + " exists")) << newImageFileName() << "" << QSize(100,100) << ""; - QTest::newRow(QTest::toString(id + " scaled")) << newImageFileName() << "sourceSize: \"80x30\"" << QSize(80,30) << ""; + QString fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " simple test")) + << "image://test/" + fileName << fileName << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " url with no id")) + << "image://test/" + fileName << "" + fileName << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " url with path")) + << "image://test/test/path" + fileName << "test/path" + fileName << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " url with fragment")) + << "image://test/faq.html?#question13" + fileName << "faq.html?#question13" + fileName << "" << QSize(100,100) << ""; - QTest::newRow(QTest::toString(id + " missing")) << "image://test/no-such-file.png" << "" << QSize() + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " url with query")) + << "image://test/cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName << "cgi-bin/drawgraph.cgi?type=pie&color=green" + fileName + << "" << QSize(100,100) << ""; + + fileName = newImageFileName(); + QTest::newRow(QTest::toString(id + " scaled image")) + << "image://test/" + fileName << fileName << "sourceSize: \"80x30\"" << QSize(80,30) << ""; + + QTest::newRow(QTest::toString(id + " missing")) + << "image://test/no-such-file.png" << "no-such-file.png" << "" << QSize(100,100) << "file::2:1: QML Image: Failed to get image from provider: image://test/no-such-file.png"; - QTest::newRow(QTest::toString(id + " unknown provider")) << "image://bogus/exists.png" << "" << QSize() + + QTest::newRow(QTest::toString(id + " unknown provider")) + << "image://bogus/exists.png" << "" << "" << QSize() << "file::2:1: QML Image: Failed to get image from provider: image://bogus/exists.png"; } void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvider *provider) { QFETCH(QString, source); + QFETCH(QString, imageId); QFETCH(QString, properties); QFETCH(QSize, size); QFETCH(QString, error); @@ -210,6 +243,11 @@ void tst_qdeclarativeimageprovider::runTest(bool async, QDeclarativeImageProvide QTRY_VERIFY(obj->status() == QDeclarativeImage::Ready); else QVERIFY(obj->status() == QDeclarativeImage::Ready); + if (QByteArray(QTest::currentDataTag()).startsWith("qimage")) + QCOMPARE(static_cast(provider)->lastImageId, imageId); + else + QCOMPARE(static_cast(provider)->lastImageId, imageId); + QCOMPARE(obj->width(), qreal(size.width())); QCOMPARE(obj->height(), qreal(size.height())); QCOMPARE(obj->pixmap().width(), size.width()); -- cgit v0.12 From 95e64de1827f9b2bae829d40756f7142c56c460f Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Mon, 20 Dec 2010 15:44:25 +1000 Subject: Update test bitmaps for QDeclarativeImage::svg() autotest on Windows Task-number: Reviewed-by: Martin Jones --- .../qdeclarativeimage/data/heart-win32.png | Bin 12457 -> 12621 bytes .../qdeclarativeimage/data/heart200-win32.png | Bin 7939 -> 8062 bytes 2 files changed, 0 insertions(+), 0 deletions(-) diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart-win32.png b/tests/auto/declarative/qdeclarativeimage/data/heart-win32.png index 5992e79..351da13 100644 Binary files a/tests/auto/declarative/qdeclarativeimage/data/heart-win32.png and b/tests/auto/declarative/qdeclarativeimage/data/heart-win32.png differ diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart200-win32.png b/tests/auto/declarative/qdeclarativeimage/data/heart200-win32.png index 19b20a8..4976ff9 100644 Binary files a/tests/auto/declarative/qdeclarativeimage/data/heart200-win32.png and b/tests/auto/declarative/qdeclarativeimage/data/heart200-win32.png differ -- cgit v0.12 From 197ec350e4014330851a013501c6dde3068ac26f Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Mon, 20 Dec 2010 17:07:34 +1000 Subject: Setting TextInput.cursorPosition outside bounds crashed. Check bounds in TextInput and TextEdit. Task-number: QTBUG-16188 Reviewed-by: Bea Lam --- src/declarative/graphicsitems/qdeclarativetextedit.cpp | 2 ++ src/declarative/graphicsitems/qdeclarativetextinput.cpp | 2 ++ .../qdeclarativetextedit/tst_qdeclarativetextedit.cpp | 13 +++++++++++++ .../qdeclarativetextinput/tst_qdeclarativetextinput.cpp | 13 +++++++++++++ 4 files changed, 30 insertions(+) diff --git a/src/declarative/graphicsitems/qdeclarativetextedit.cpp b/src/declarative/graphicsitems/qdeclarativetextedit.cpp index e05f4e4..4e16d24 100644 --- a/src/declarative/graphicsitems/qdeclarativetextedit.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextedit.cpp @@ -643,6 +643,8 @@ int QDeclarativeTextEdit::cursorPosition() const void QDeclarativeTextEdit::setCursorPosition(int pos) { Q_D(QDeclarativeTextEdit); + if (pos < 0 || pos > d->text.length()) + return; QTextCursor cursor = d->control->textCursor(); if (cursor.position() == pos) return; diff --git a/src/declarative/graphicsitems/qdeclarativetextinput.cpp b/src/declarative/graphicsitems/qdeclarativetextinput.cpp index df103de..521e4ab 100644 --- a/src/declarative/graphicsitems/qdeclarativetextinput.cpp +++ b/src/declarative/graphicsitems/qdeclarativetextinput.cpp @@ -437,6 +437,8 @@ int QDeclarativeTextInput::cursorPosition() const void QDeclarativeTextInput::setCursorPosition(int cp) { Q_D(QDeclarativeTextInput); + if (cp < 0 || cp > d->control->text().length()) + return; d->control->moveCursor(cp); } diff --git a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp index a7971cc..c7a51f7 100644 --- a/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp +++ b/tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp @@ -652,6 +652,19 @@ void tst_qdeclarativetextedit::selection() QVERIFY(textEditObject->selectionEnd() == 0); QVERIFY(textEditObject->selectedText().isNull()); + // Verify invalid positions are ignored. + textEditObject->setCursorPosition(-1); + QVERIFY(textEditObject->cursorPosition() == 0); + QVERIFY(textEditObject->selectionStart() == 0); + QVERIFY(textEditObject->selectionEnd() == 0); + QVERIFY(textEditObject->selectedText().isNull()); + + textEditObject->setCursorPosition(textEditObject->text().count()+1); + QVERIFY(textEditObject->cursorPosition() == 0); + QVERIFY(textEditObject->selectionStart() == 0); + QVERIFY(textEditObject->selectionEnd() == 0); + QVERIFY(textEditObject->selectedText().isNull()); + //Test selection for(int i=0; i<= testStr.size(); i++) { textEditObject->select(0,i); diff --git a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp index 76e0102..7b2310a 100644 --- a/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp +++ b/tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp @@ -354,6 +354,19 @@ void tst_qdeclarativetextinput::selection() QVERIFY(textinputObject->selectionEnd() == 0); QVERIFY(textinputObject->selectedText().isNull()); + // Verify invalid positions are ignored. + textinputObject->setCursorPosition(-1); + QVERIFY(textinputObject->cursorPosition() == 0); + QVERIFY(textinputObject->selectionStart() == 0); + QVERIFY(textinputObject->selectionEnd() == 0); + QVERIFY(textinputObject->selectedText().isNull()); + + textinputObject->setCursorPosition(textinputObject->text().count()+1); + QVERIFY(textinputObject->cursorPosition() == 0); + QVERIFY(textinputObject->selectionStart() == 0); + QVERIFY(textinputObject->selectionEnd() == 0); + QVERIFY(textinputObject->selectedText().isNull()); + //Test selection for(int i=0; i<= testStr.size(); i++) { textinputObject->select(0,i); -- cgit v0.12