summaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAaron Kennedy <aaron.kennedy@nokia.com>2009-11-18 07:06:33 (GMT)
committerAaron Kennedy <aaron.kennedy@nokia.com>2009-11-18 07:06:33 (GMT)
commit03388d548159f33c7829b54e911ebb9bc5fd3550 (patch)
tree38089bbdefe39de2e1ec1f067306c4091868783f
parent250e78df4a8ad1d2aa52d13c2b883e25a4432f67 (diff)
parentd15ac49efd7fab66258bd5b1e8998146ce204695 (diff)
downloadQt-03388d548159f33c7829b54e911ebb9bc5fd3550.zip
Qt-03388d548159f33c7829b54e911ebb9bc5fd3550.tar.gz
Qt-03388d548159f33c7829b54e911ebb9bc5fd3550.tar.bz2
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
-rw-r--r--demos/declarative/webbrowser/webbrowser.qml2
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsborderimage.cpp4
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsgridview.cpp1
-rw-r--r--src/declarative/graphicsitems/qmlgraphicslistview.cpp10
-rw-r--r--src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp7
-rw-r--r--tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro5
-rw-r--r--tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp124
-rw-r--r--tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp9
8 files changed, 137 insertions, 25 deletions
diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml
index 23e0a20..0f6ed25 100644
--- a/demos/declarative/webbrowser/webbrowser.qml
+++ b/demos/declarative/webbrowser/webbrowser.qml
@@ -216,7 +216,7 @@ Item {
preferredHeight: flickable.height
zoomFactor: flickable.width > 980 ? 1 : flickable.width/980
- onUrlChanged: { if (url != null) { webBrowser.urlString = url.toString(); } }
+ onUrlChanged: { if (url != null) { editUrl.text = url.toString(); } }
onDoubleClick: {
if (!heuristicZoom(clickX,clickY,2.5)) {
var zf = flickable.width > 980 ? 1 : flickable.width/980;
diff --git a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
index e1039f4..d7627ac 100644
--- a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp
@@ -212,6 +212,8 @@ void QmlGraphicsBorderImage::setSource(const QUrl &url)
setImplicitWidth(d->pix.width());
setImplicitHeight(d->pix.height());
+ if (d->pix.isNull())
+ d->status = Error;
if (d->status == Loading)
d->status = Ready;
d->progress = 1.0;
@@ -329,6 +331,8 @@ void QmlGraphicsBorderImage::setGridScaledImage(const QmlGraphicsGridScaledImage
setImplicitWidth(d->pix.width());
setImplicitHeight(d->pix.height());
+ if (d->pix.isNull())
+ d->status = Error;
if (d->status == Loading)
d->status = Ready;
d->progress = 1.0;
diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
index 5ce2836..473f9e5 100644
--- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp
@@ -950,7 +950,6 @@ void QmlGraphicsGridView::setHighlight(QmlComponent *highlight)
{
Q_D(QmlGraphicsGridView);
if (highlight != d->highlightComponent) {
- delete d->highlightComponent;
d->highlightComponent = highlight;
d->updateCurrent(d->currentIndex);
}
diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
index a166df2..c6291f2 100644
--- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp
@@ -503,7 +503,7 @@ void QmlGraphicsListViewPrivate::refill(qreal from, qreal to)
return;
from -= buffer;
to += buffer;
- int modelIndex = 0;
+ int modelIndex = visibleIndex;
qreal itemEnd = visiblePos-1;
if (!visibleItems.isEmpty()) {
visiblePos = visibleItems.first()->position();
@@ -1169,6 +1169,9 @@ void QmlGraphicsListView::setDelegate(QmlComponent *delegate)
if (QmlGraphicsVisualDataModel *dataModel = qobject_cast<QmlGraphicsVisualDataModel*>(d->model)) {
dataModel->setDelegate(delegate);
if (isComponentComplete()) {
+ for (int i = 0; i < d->visibleItems.count(); ++i)
+ d->releaseItem(d->visibleItems.at(i));
+ d->visibleItems.clear();
refill();
d->moveReason = QmlGraphicsListViewPrivate::SetIndex;
d->updateCurrent(d->currentIndex);
@@ -1268,9 +1271,10 @@ void QmlGraphicsListView::setHighlight(QmlComponent *highlight)
{
Q_D(QmlGraphicsListView);
if (highlight != d->highlightComponent) {
- delete d->highlightComponent;
d->highlightComponent = highlight;
- d->updateCurrent(d->currentIndex);
+ d->createHighlight();
+ if (d->currentItem)
+ d->updateHighlight();
}
}
diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
index cf5fc5e..e8ee196 100644
--- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
+++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp
@@ -692,11 +692,16 @@ QmlComponent *QmlGraphicsVisualDataModel::delegate() const
void QmlGraphicsVisualDataModel::setDelegate(QmlComponent *delegate)
{
Q_D(QmlGraphicsVisualDataModel);
+ bool wasValid = d->m_delegate != 0;
d->m_delegate = delegate;
- if (d->modelCount()) {
+ if (!wasValid && d->modelCount() && d->m_delegate) {
emit itemsInserted(0, d->modelCount());
emit countChanged();
}
+ if (wasValid && !d->m_delegate && d->modelCount()) {
+ emit itemsRemoved(0, d->modelCount());
+ emit countChanged();
+ }
}
QString QmlGraphicsVisualDataModel::part() const
diff --git a/tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro b/tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro
index 82da769..1f606e5 100644
--- a/tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro
+++ b/tests/auto/declarative/qmlgraphicsborderimage/qmlgraphicsborderimage.pro
@@ -1,8 +1,9 @@
load(qttest_p4)
-contains(QT_CONFIG,declarative): QT += declarative gui
+contains(QT_CONFIG,declarative): QT += declarative gui network
macx:CONFIG -= app_bundle
-SOURCES += tst_qmlgraphicsborderimage.cpp
+HEADERS += ../shared/testhttpserver.h
+SOURCES += tst_qmlgraphicsborderimage.cpp ../shared/testhttpserver.cpp
# Define SRCDIR equal to test's source directory
DEFINES += SRCDIR=\\\"$$PWD\\\"
diff --git a/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp b/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp
index aa732c5..06a05dd 100644
--- a/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp
+++ b/tests/auto/declarative/qmlgraphicsborderimage/tst_qmlgraphicsborderimage.cpp
@@ -40,11 +40,32 @@
****************************************************************************/
#include <qtest.h>
#include <QTextDocument>
+#include <QTcpServer>
+#include <QTcpSocket>
+#include <QDir>
+
#include <QtDeclarative/qmlengine.h>
#include <QtDeclarative/qmlcomponent.h>
#include <private/qmlgraphicsborderimage_p.h>
#include <private/qmlgraphicsimagebase_p.h>
#include <private/qmlgraphicsscalegrid_p_p.h>
+#include <private/qmlgraphicsloader_p.h>
+
+#include "../shared/testhttpserver.h"
+
+
+#define SERVER_PORT 14445
+#define SERVER_ADDR "http://127.0.0.1:14445"
+
+#define TRY_WAIT(expr) \
+ do { \
+ for (int ii = 0; ii < 6; ++ii) { \
+ if ((expr)) break; \
+ QTest::qWait(50); \
+ } \
+ QVERIFY((expr)); \
+ } while (false)
+
class tst_qmlgraphicsborderimage : public QObject
@@ -55,11 +76,13 @@ public:
private slots:
void noSource();
- void simple();
+ void imageSource();
+ void imageSource_data();
void resized();
void smooth();
void tileModes();
- void sciFile();
+ void sciSource();
+ void sciSource_data();
void invalidSciFile();
private:
@@ -85,21 +108,53 @@ void tst_qmlgraphicsborderimage::noSource()
delete obj;
}
-void tst_qmlgraphicsborderimage::simple()
+void tst_qmlgraphicsborderimage::imageSource()
{
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\" }";
+ QFETCH(QString, source);
+ QFETCH(bool, remote);
+ QFETCH(bool, valid);
+
+ TestHTTPServer server(SERVER_PORT);
+ if (remote) {
+ QVERIFY(server.isValid());
+ server.serveDirectory(SRCDIR "/data");
+ }
+
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\" }";
QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://"));
QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
QVERIFY(obj != 0);
- QCOMPARE(obj->source(), QUrl("file://" SRCDIR "/data/colors.png"));
- QCOMPARE(obj->width(), 120.);
- QCOMPARE(obj->height(), 120.);
- QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Stretch);
- QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Stretch);
+
+ if (remote)
+ TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Loading);
+
+ QCOMPARE(obj->source(), remote ? source : QUrl::fromLocalFile(source));
+
+ if (valid) {
+ TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Ready);
+ QCOMPARE(obj->width(), 120.);
+ QCOMPARE(obj->height(), 120.);
+ QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Stretch);
+ QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Stretch);
+ } else {
+ TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Error);
+ }
delete obj;
}
+void tst_qmlgraphicsborderimage::imageSource_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<bool>("remote");
+ QTest::addColumn<bool>("valid");
+
+ QTest::newRow("local") << SRCDIR "/data/colors.png" << false << true;
+ QTest::newRow("local not found") << SRCDIR "/data/no-such-file.png" << false << false;
+ QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << true;
+ QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true << false;
+}
+
void tst_qmlgraphicsborderimage::resized()
{
QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors.png\"; width: 300; height: 300 }";
@@ -157,24 +212,57 @@ void tst_qmlgraphicsborderimage::tileModes()
}
}
-void tst_qmlgraphicsborderimage::sciFile()
+void tst_qmlgraphicsborderimage::sciSource()
{
- QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/colors-round.sci\"; width: 300; height: 300 }";
+ QFETCH(QString, source);
+ QFETCH(bool, remote);
+ QFETCH(bool, valid);
+
+ TestHTTPServer server(SERVER_PORT);
+ if (remote) {
+ QVERIFY(server.isValid());
+ server.serveDirectory(SRCDIR "/data");
+ }
+
+ QString componentStr = "import Qt 4.6\nBorderImage { source: \"" + source + "\"; width: 300; height: 300 }";
QmlComponent component(&engine, componentStr.toLatin1(), QUrl("file://"));
QmlGraphicsBorderImage *obj = qobject_cast<QmlGraphicsBorderImage*>(component.create());
QVERIFY(obj != 0);
+
+ if (remote)
+ TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Loading);
+
+ QCOMPARE(obj->source(), remote ? source : QUrl::fromLocalFile(source));
QCOMPARE(obj->width(), 300.);
QCOMPARE(obj->height(), 300.);
- QCOMPARE(obj->border()->left(), 10);
- QCOMPARE(obj->border()->top(), 20);
- QCOMPARE(obj->border()->right(), 30);
- QCOMPARE(obj->border()->bottom(), 40);
- QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Round);
- QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Repeat);
+
+ if (valid) {
+ TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Ready);
+ QCOMPARE(obj->border()->left(), 10);
+ QCOMPARE(obj->border()->top(), 20);
+ QCOMPARE(obj->border()->right(), 30);
+ QCOMPARE(obj->border()->bottom(), 40);
+ QCOMPARE(obj->horizontalTileMode(), QmlGraphicsBorderImage::Round);
+ QCOMPARE(obj->verticalTileMode(), QmlGraphicsBorderImage::Repeat);
+ } else {
+ TRY_WAIT(obj->status() == QmlGraphicsBorderImage::Error);
+ }
delete obj;
}
+void tst_qmlgraphicsborderimage::sciSource_data()
+{
+ QTest::addColumn<QString>("source");
+ QTest::addColumn<bool>("remote");
+ QTest::addColumn<bool>("valid");
+
+ QTest::newRow("local") << SRCDIR "/data/colors-round.sci" << false << true;
+ QTest::newRow("local not found") << SRCDIR "/data/no-such-file.sci" << false << false;
+ QTest::newRow("remote") << SERVER_ADDR "/colors-round.sci" << true << true;
+ QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.sci" << true << false;
+}
+
void tst_qmlgraphicsborderimage::invalidSciFile()
{
QString componentStr = "import Qt 4.6\nBorderImage { source: \"" SRCDIR "/data/invalid.sci\"; width: 300; height: 300 }";
@@ -190,6 +278,8 @@ void tst_qmlgraphicsborderimage::invalidSciFile()
delete obj;
}
+
+
QTEST_MAIN(tst_qmlgraphicsborderimage)
#include "tst_qmlgraphicsborderimage.moc"
diff --git a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
index 36f4dc5..e9f785b 100644
--- a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
+++ b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp
@@ -318,13 +318,22 @@ void tst_QmlGraphicsListView::items()
testObject->setAnimate(true);
QMetaObject::invokeMethod(canvas->root(), "checkProperties");
QVERIFY(testObject->error() == false);
+ QVERIFY(listview->currentItem());
// set invalid highlight
testObject->setInvalidHighlight(true);
QMetaObject::invokeMethod(canvas->root(), "checkProperties");
QVERIFY(testObject->error() == false);
+ QVERIFY(listview->currentItem());
QVERIFY(listview->highlightItem() == 0);
+ // back to normal highlight
+ testObject->setInvalidHighlight(false);
+ QMetaObject::invokeMethod(canvas->root(), "checkProperties");
+ QVERIFY(testObject->error() == false);
+ QVERIFY(listview->currentItem());
+ QVERIFY(listview->highlightItem() != 0);
+
// set an empty model and confirm that items are destroyed
T model2;
ctxt->setContextProperty("testModel", &model2);