summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorThierry Bastian <thierry.bastian@nokia.com>2010-12-20 23:00:16 (GMT)
committerThierry Bastian <thierry.bastian@nokia.com>2010-12-20 23:00:16 (GMT)
commitad23f356e503536b34ea8e59aa3390459d1bbfea (patch)
treed4d2dd72b32b1b83ab9ae967af21609f11e46a46
parent8bea6ea27ff47ff2a02cb6e8ef5b16b3a7d0f0d5 (diff)
parent987a683ff51997cb23cb931af99c6554651742d7 (diff)
downloadQt-ad23f356e503536b34ea8e59aa3390459d1bbfea.zip
Qt-ad23f356e503536b34ea8e59aa3390459d1bbfea.tar.gz
Qt-ad23f356e503536b34ea8e59aa3390459d1bbfea.tar.bz2
Merge branch '4.7-upstream' into 4.7-water
-rw-r--r--demos/declarative/minehunt/minehunt.pro2
-rw-r--r--doc/src/declarative/javascriptblocks.qdoc4
-rw-r--r--doc/src/declarative/modules.qdoc2
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextedit.cpp2
-rw-r--r--src/declarative/graphicsitems/qdeclarativetextinput.cpp2
-rw-r--r--src/declarative/qml/qdeclarativeengine.cpp12
-rw-r--r--src/declarative/qml/qdeclarativeimageprovider.cpp16
-rw-r--r--src/plugins/bearer/icd/qicdengine.cpp3
-rw-r--r--tests/auto/declarative/qdeclarativeimage/data/heart-win32.pngbin12457 -> 12621 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeimage/data/heart200-win32.pngbin7939 -> 8062 bytes
-rw-r--r--tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp46
-rw-r--r--tests/auto/declarative/qdeclarativetextedit/tst_qdeclarativetextedit.cpp13
-rw-r--r--tests/auto/declarative/qdeclarativetextinput/tst_qdeclarativetextinput.cpp13
13 files changed, 101 insertions, 14 deletions
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
}
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
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/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<QDeclarativeImageProvider> 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<QDeclarativeImageProvider> 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/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()) {
diff --git a/tests/auto/declarative/qdeclarativeimage/data/heart-win32.png b/tests/auto/declarative/qdeclarativeimage/data/heart-win32.png
index 5992e79..351da13 100644
--- a/tests/auto/declarative/qdeclarativeimage/data/heart-win32.png
+++ b/tests/auto/declarative/qdeclarativeimage/data/heart-win32.png
Binary files 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
--- a/tests/auto/declarative/qdeclarativeimage/data/heart200-win32.png
+++ b/tests/auto/declarative/qdeclarativeimage/data/heart200-win32.png
Binary files differ
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<QString>("source");
+ QTest::addColumn<QString>("imageId");
QTest::addColumn<QString>("properties");
QTest::addColumn<QSize>("size");
QTest::addColumn<QString>("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<TestQImageProvider*>(provider)->lastImageId, imageId);
+ else
+ QCOMPARE(static_cast<TestQPixmapProvider*>(provider)->lastImageId, imageId);
+
QCOMPARE(obj->width(), qreal(size.width()));
QCOMPARE(obj->height(), qreal(size.height()));
QCOMPARE(obj->pixmap().width(), size.width());
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);