diff options
author | Martin Jones <martin.jones@nokia.com> | 2010-02-01 21:53:47 (GMT) |
---|---|---|
committer | Martin Jones <martin.jones@nokia.com> | 2010-02-01 21:53:47 (GMT) |
commit | e93f76cc533751944e66c02d868f3c527814efa0 (patch) | |
tree | 9a79f06ad7be400ff432a7edae33be4599a0658c | |
parent | bd95a353c621cb7dba2f0991e742ddbde0bb9a54 (diff) | |
parent | 652be80c25f61aa4fbf28d75ba9971fc709f29c9 (diff) | |
download | Qt-e93f76cc533751944e66c02d868f3c527814efa0.zip Qt-e93f76cc533751944e66c02d868f3c527814efa0.tar.gz Qt-e93f76cc533751944e66c02d868f3c527814efa0.tar.bz2 |
Merge branch 'kinetic-declarativeui' of git@scm.dev.nokia.troll.no:qt/kinetic into kinetic-declarativeui
27 files changed, 182 insertions, 21 deletions
diff --git a/doc/src/declarative/advtutorial4.qdoc b/doc/src/declarative/advtutorial4.qdoc index 96e72fc..855963c 100644 --- a/doc/src/declarative/advtutorial4.qdoc +++ b/doc/src/declarative/advtutorial4.qdoc @@ -113,10 +113,12 @@ like this: \snippet declarative/tutorials/samegame/samegame4/content/BoomBlock.qml 4 And now the game should be beautifully animated and smooth, with a subtle (or not-so-subtle) animation added for all of the -player's actions. The end result is shown below: +player's actions. The end result is shown below, with a different set of images to demonstrate basic themeing: \image declarative-adv-tutorial4.gif +The basic theme change there is the result of simply replacing the images. This can be done at run time by setting the source property, so a further advanced feature to try on your own is to add a button which toggles between two different themes. + \section2 Offline High Scores Another extension we might want for the game is some way of storing and retrieving high scores. This tutorial contains both online and offline high score storage. diff --git a/doc/src/declarative/pics/declarative-adv-tutorial1.png b/doc/src/declarative/pics/declarative-adv-tutorial1.png Binary files differindex 990a329..1699ab0 100644 --- a/doc/src/declarative/pics/declarative-adv-tutorial1.png +++ b/doc/src/declarative/pics/declarative-adv-tutorial1.png diff --git a/doc/src/declarative/pics/declarative-adv-tutorial2.png b/doc/src/declarative/pics/declarative-adv-tutorial2.png Binary files differindex b410d50..ba27c44 100644 --- a/doc/src/declarative/pics/declarative-adv-tutorial2.png +++ b/doc/src/declarative/pics/declarative-adv-tutorial2.png diff --git a/doc/src/declarative/pics/declarative-adv-tutorial3.png b/doc/src/declarative/pics/declarative-adv-tutorial3.png Binary files differindex e192772..d500434d 100644 --- a/doc/src/declarative/pics/declarative-adv-tutorial3.png +++ b/doc/src/declarative/pics/declarative-adv-tutorial3.png diff --git a/examples/declarative/plugins/plugin.cpp b/examples/declarative/plugins/plugin.cpp index 9688caf..f4aa36b 100644 --- a/examples/declarative/plugins/plugin.cpp +++ b/examples/declarative/plugins/plugin.cpp @@ -138,7 +138,6 @@ MinuteTimer *Time::timer=0; QML_DECLARE_TYPE(Time); -QML_DEFINE_TYPE(com.nokia.TimeExample,1,0,Time,Time); class QExampleQmlPlugin : public QmlModulePlugin @@ -149,6 +148,12 @@ public: { return QStringList() << QLatin1String("com.nokia.TimeExample"); } + + void defineModule(const QString& uri) + { + Q_ASSERT(uri == QLatin1String("com.nokia.TimeExample")); + qmlRegisterType<Time>("com.nokia.TimeExample", 1, 0, "Time", "Time"); + } }; #include "plugin.moc" diff --git a/examples/declarative/tutorials/samegame/samegame1/pics/background.png b/examples/declarative/tutorials/samegame/samegame1/pics/background.png Binary files differindex 25e885f..3734a27 100644 --- a/examples/declarative/tutorials/samegame/samegame1/pics/background.png +++ b/examples/declarative/tutorials/samegame/samegame1/pics/background.png diff --git a/examples/declarative/tutorials/samegame/samegame1/pics/redStone.png b/examples/declarative/tutorials/samegame/samegame1/pics/redStone.png Binary files differindex b099f60..36b09a2 100644 --- a/examples/declarative/tutorials/samegame/samegame1/pics/redStone.png +++ b/examples/declarative/tutorials/samegame/samegame1/pics/redStone.png diff --git a/examples/declarative/tutorials/samegame/samegame2/pics/background.png b/examples/declarative/tutorials/samegame/samegame2/pics/background.png Binary files differindex 25e885f..3734a27 100644 --- a/examples/declarative/tutorials/samegame/samegame2/pics/background.png +++ b/examples/declarative/tutorials/samegame/samegame2/pics/background.png diff --git a/examples/declarative/tutorials/samegame/samegame2/pics/redStone.png b/examples/declarative/tutorials/samegame/samegame2/pics/redStone.png Binary files differindex b099f60..36b09a2 100644 --- a/examples/declarative/tutorials/samegame/samegame2/pics/redStone.png +++ b/examples/declarative/tutorials/samegame/samegame2/pics/redStone.png diff --git a/examples/declarative/tutorials/samegame/samegame3/pics/background.png b/examples/declarative/tutorials/samegame/samegame3/pics/background.png Binary files differindex 25e885f..3734a27 100644 --- a/examples/declarative/tutorials/samegame/samegame3/pics/background.png +++ b/examples/declarative/tutorials/samegame/samegame3/pics/background.png diff --git a/examples/declarative/tutorials/samegame/samegame3/pics/blueStone.png b/examples/declarative/tutorials/samegame/samegame3/pics/blueStone.png Binary files differindex bf342e0..20e43c7 100644 --- a/examples/declarative/tutorials/samegame/samegame3/pics/blueStone.png +++ b/examples/declarative/tutorials/samegame/samegame3/pics/blueStone.png diff --git a/examples/declarative/tutorials/samegame/samegame3/pics/greenStone.png b/examples/declarative/tutorials/samegame/samegame3/pics/greenStone.png Binary files differindex 5ac14a5..b568a19 100644 --- a/examples/declarative/tutorials/samegame/samegame3/pics/greenStone.png +++ b/examples/declarative/tutorials/samegame/samegame3/pics/greenStone.png diff --git a/examples/declarative/tutorials/samegame/samegame3/pics/redStone.png b/examples/declarative/tutorials/samegame/samegame3/pics/redStone.png Binary files differindex b099f60..36b09a2 100644 --- a/examples/declarative/tutorials/samegame/samegame3/pics/redStone.png +++ b/examples/declarative/tutorials/samegame/samegame3/pics/redStone.png diff --git a/src/declarative/graphicsitems/qmlgraphicsimage.cpp b/src/declarative/graphicsitems/qmlgraphicsimage.cpp index a777de7..ad43027 100644 --- a/src/declarative/graphicsitems/qmlgraphicsimage.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsimage.cpp @@ -139,6 +139,12 @@ QmlGraphicsImage::~QmlGraphicsImage() { } +void QmlGraphicsImage::setSource(const QUrl &url) +{ + QmlGraphicsImageBase::setSource(url); + updatePaintedGeometry(); +} + /*! \qmlproperty QPixmap Image::pixmap @@ -205,9 +211,22 @@ void QmlGraphicsImage::setFillMode(FillMode mode) return; d->fillMode = mode; update(); + updatePaintedGeometry(); emit fillModeChanged(); } +qreal QmlGraphicsImage::paintedWidth() const +{ + Q_D(const QmlGraphicsImage); + return d->paintedWidth; +} + +qreal QmlGraphicsImage::paintedHeight() const +{ + Q_D(const QmlGraphicsImage); + return d->paintedHeight; +} + /*! \qmlproperty enum Image::status @@ -244,6 +263,33 @@ void QmlGraphicsImage::setFillMode(FillMode mode) filtering at the beginning of the animation and reenable it at the conclusion. */ +void QmlGraphicsImage::updatePaintedGeometry() +{ + Q_D(QmlGraphicsImage); + + if (d->fillMode == PreserveAspectFit) { + qreal widthScale = width() / qreal(d->pix.width()); + qreal heightScale = height() / qreal(d->pix.height()); + if (widthScale <= heightScale) { + d->paintedWidth = width(); + d->paintedHeight = widthScale * qreal(d->pix.height()); + } else if(heightScale < widthScale) { + d->paintedWidth = heightScale * qreal(d->pix.width()); + d->paintedHeight = height(); + } + } else { + d->paintedWidth = width(); + d->paintedHeight = height(); + } + emit paintedGeometryChanged(); +} + +void QmlGraphicsImage::geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry) +{ + QmlGraphicsImageBase::geometryChanged(newGeometry, oldGeometry); + updatePaintedGeometry(); +} + /*! \qmlproperty url Image::source @@ -278,7 +324,7 @@ void QmlGraphicsImage::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWid QTransform scale; if (d->fillMode == PreserveAspectFit) { - if (widthScale < heightScale) { + if (widthScale <= heightScale) { heightScale = widthScale; scale.translate(0, (height() - heightScale * d->pix.height()) / 2); } else if(heightScale < widthScale) { diff --git a/src/declarative/graphicsitems/qmlgraphicsimage_p.h b/src/declarative/graphicsitems/qmlgraphicsimage_p.h index 2547b78..36066e1 100644 --- a/src/declarative/graphicsitems/qmlgraphicsimage_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsimage_p.h @@ -59,6 +59,8 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsImage : public QmlGraphicsImageBase Q_PROPERTY(QPixmap pixmap READ pixmap WRITE setPixmap NOTIFY pixmapChanged DESIGNABLE false) Q_PROPERTY(FillMode fillMode READ fillMode WRITE setFillMode NOTIFY fillModeChanged) + Q_PROPERTY(qreal paintedWidth READ paintedWidth NOTIFY paintedGeometryChanged) + Q_PROPERTY(qreal paintedHeight READ paintedHeight NOTIFY paintedGeometryChanged) public: QmlGraphicsImage(QmlGraphicsItem *parent=0); @@ -71,13 +73,20 @@ public: QPixmap pixmap() const; void setPixmap(const QPixmap &); + qreal paintedWidth() const; + qreal paintedHeight() const; + + void setSource(const QUrl &url); void paint(QPainter *, const QStyleOptionGraphicsItem *, QWidget *); Q_SIGNALS: void fillModeChanged(); + void paintedGeometryChanged(); protected: QmlGraphicsImage(QmlGraphicsImagePrivate &dd, QmlGraphicsItem *parent); + void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); + void updatePaintedGeometry(); private: Q_DISABLE_COPY(QmlGraphicsImage) diff --git a/src/declarative/graphicsitems/qmlgraphicsimage_p_p.h b/src/declarative/graphicsitems/qmlgraphicsimage_p_p.h index f6b4e51..3a5acca 100644 --- a/src/declarative/graphicsitems/qmlgraphicsimage_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsimage_p_p.h @@ -64,11 +64,13 @@ class QmlGraphicsImagePrivate : public QmlGraphicsImageBasePrivate public: QmlGraphicsImagePrivate() - : fillMode(QmlGraphicsImage::Stretch) + : fillMode(QmlGraphicsImage::Stretch), paintedWidth(0), paintedHeight(0) { } QmlGraphicsImage::FillMode fillMode; + qreal paintedWidth; + qreal paintedHeight; void setPixmap(const QPixmap &pix); }; diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp index bd3c1ea..6835427 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp @@ -62,6 +62,8 @@ #include <QtGui/qgraphicseffect.h> #include <qlistmodelinterface_p.h> +#include <math.h> + QT_BEGIN_NAMESPACE #ifndef FLT_MAX @@ -2790,6 +2792,7 @@ void QmlGraphicsItem::setTransformOrigin(TransformOrigin origin) if (origin != d->origin) { d->origin = origin; QGraphicsItem::setTransformOriginPoint(d->computeTransformOrigin()); + emit transformOriginChanged(d->origin); } } @@ -2842,6 +2845,9 @@ qreal QmlGraphicsItem::width() const void QmlGraphicsItem::setWidth(qreal w) { Q_D(QmlGraphicsItem); + if (isnan(w)) + return; + d->widthValid = true; if (d->width == w) return; @@ -2911,6 +2917,9 @@ qreal QmlGraphicsItem::height() const void QmlGraphicsItem::setHeight(qreal h) { Q_D(QmlGraphicsItem); + if (isnan(h)) + return; + d->heightValid = true; if (d->height == h) return; diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.h b/src/declarative/graphicsitems/qmlgraphicsitem.h index df8c634..8ae2d5c 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.h +++ b/src/declarative/graphicsitems/qmlgraphicsitem.h @@ -91,7 +91,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsItem : public QGraphicsObject, public QmlP Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL) Q_PROPERTY(bool wantsFocus READ wantsFocus NOTIFY wantsFocusChanged) Q_PROPERTY(QmlList<QGraphicsTransform *>* transform READ transform DESIGNABLE false FINAL) - Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin) + Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin NOTIFY transformOriginChanged) Q_PROPERTY(bool smooth READ smooth WRITE setSmooth) Q_PROPERTY(QGraphicsEffect *effect READ graphicsEffect WRITE setGraphicsEffect) Q_ENUMS(TransformOrigin) @@ -176,6 +176,7 @@ Q_SIGNALS: void focusChanged(); void wantsFocusChanged(); void parentChanged(); + void transformOriginChanged(TransformOrigin); protected: bool isComponentComplete() const; diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index b3ac1bb..a33aea7 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -1234,8 +1234,10 @@ public: QFactoryLoader *l = loader(); QmlModuleFactoryInterface *factory = qobject_cast<QmlModuleFactoryInterface*>(l->instance(uri)); - if (factory) + if (factory) { + factory->defineModuleOnce(uri); isbuiltin = true; + } } else { url = base.resolved(QUrl(url)).toString(); } diff --git a/src/declarative/qml/qmlmoduleplugin.cpp b/src/declarative/qml/qmlmoduleplugin.cpp index 446c7bc..2f2cb25 100644 --- a/src/declarative/qml/qmlmoduleplugin.cpp +++ b/src/declarative/qml/qmlmoduleplugin.cpp @@ -59,11 +59,12 @@ QT_BEGIN_NAMESPACE exporting the class with the Q_EXPORT_PLUGIN2() macro. See \l{How to Create Qt Plugins} for details. - The plugin should register QML types with QML_DEFINE_TYPE. - - The strings returned by keys() should be the list of URIs of module + The strings returned by keys() should be the list of URIs of modules that the plugin registers. + The plugin should register QML types with qmlRegisterType() when the + defineModule() method is called. + \sa examples/declarative/plugins */ @@ -86,4 +87,25 @@ QmlModulePlugin::~QmlModulePlugin() { } +/*! + \fn void QmlModulePlugin::defineModule(const QString& uri) + + Subclasses must override this function to register types + of the module \a uri, which will be one of the strings returned by keys(). + + The plugin registers QML types with qmlRegisterType(): + + \code + qmlRegisterType<MyClass>("com.nokia.MyModule", 1, 0, "MyType", "MyClass"); + \endcode +*/ + +void QmlModulePlugin::defineModuleOnce(const QString& uri) +{ + if (!defined.contains(uri)) { + defined += uri; + defineModule(uri); + } +} + QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlmoduleplugin.h b/src/declarative/qml/qmlmoduleplugin.h index 315209d..384e05e 100644 --- a/src/declarative/qml/qmlmoduleplugin.h +++ b/src/declarative/qml/qmlmoduleplugin.h @@ -45,6 +45,7 @@ #include <QtCore/qplugin.h> #include <QtCore/qfactoryinterface.h> #include <QtCore/qlist.h> +#include <QtCore/qset.h> #include <QtCore/qbytearray.h> QT_BEGIN_HEADER @@ -55,6 +56,7 @@ QT_MODULE(Declarative) struct Q_DECLARATIVE_EXPORT QmlModuleFactoryInterface : public QFactoryInterface { + virtual void defineModuleOnce(const QString& uri) = 0; }; #define QmlModuleFactoryInterface_iid "com.nokia.Qt.QmlModuleFactoryInterface" @@ -69,6 +71,12 @@ class Q_DECLARATIVE_EXPORT QmlModulePlugin : public QObject, public QmlModuleFac public: explicit QmlModulePlugin(QObject *parent = 0); ~QmlModulePlugin(); + + virtual void defineModule(const QString& uri) = 0; + +private: + void defineModuleOnce(const QString& uri); + QSet<QString> defined; }; QT_END_NAMESPACE diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index efb4159..63044bc 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -223,7 +223,7 @@ void QmlAbstractAnimationPrivate::commence() QmlMetaProperty QmlAbstractAnimationPrivate::createProperty(QObject *obj, const QString &str, QObject *infoObj) { - QmlMetaProperty prop = QmlMetaProperty::createProperty(obj, str); + QmlMetaProperty prop = QmlMetaProperty::createProperty(obj, str, qmlContext(infoObj)); if (!prop.isValid()) { qmlInfo(infoObj) << QmlAbstractAnimation::tr("Cannot animate non-existant property \"%1\"").arg(str); return QmlMetaProperty(); diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp index 331c0ce..bfe99ac 100644 --- a/src/declarative/util/qmlpixmapcache.cpp +++ b/src/declarative/util/qmlpixmapcache.cpp @@ -404,7 +404,7 @@ bool QmlPixmapReply::event(QEvent *event) d->pixmap = QPixmap::fromImage(de->image); QByteArray key = d->url.toEncoded(QUrl::FormattingOption(0x100)); QString strKey = QString::fromLatin1(key.constData(), key.count()); - QPixmapCache::insert(strKey, d->pixmap); + QPixmapCache::insert(strKey, d->pixmap); // note: may fail (returns false) emit finished(); } return true; @@ -499,7 +499,12 @@ QmlPixmapReply::Status QmlPixmapCache::get(const QUrl& url, QPixmap *pixmap) QByteArray key = url.toEncoded(QUrl::FormattingOption(0x100)); QString strKey = QString::fromLatin1(key.constData(), key.count()); QmlPixmapReplyHash::Iterator iter = qmlActivePixmapReplies()->find(url); - if (QPixmapCache::find(strKey, pixmap)) { + if (iter != qmlActivePixmapReplies()->end() && (*iter)->status() == QmlPixmapReply::Ready) { + // Must check this, since QPixmapCache::insert may have failed. + *pixmap = (*iter)->d_func()->pixmap; + status = (*iter)->status(); + (*iter)->release(); + } else if (QPixmapCache::find(strKey, pixmap)) { if (iter != qmlActivePixmapReplies()->end()) { status = (*iter)->status(); (*iter)->release(); diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index c53a893..3d81021 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -3425,6 +3425,9 @@ void QGraphicsItem::setX(qreal x) if (d_ptr->inDestructor) return; + if (isnan(x)) + return; + d_ptr->setPosHelper(QPointF(x, d_ptr->pos.y())); } @@ -3449,6 +3452,9 @@ void QGraphicsItem::setY(qreal y) if (d_ptr->inDestructor) return; + if (isnan(y)) + return; + d_ptr->setPosHelper(QPointF(d_ptr->pos.x(), y)); } diff --git a/tests/auto/declarative/animations/data/attached.qml b/tests/auto/declarative/animations/data/attached.qml new file mode 100644 index 0000000..0fb6f8c --- /dev/null +++ b/tests/auto/declarative/animations/data/attached.qml @@ -0,0 +1,34 @@ +import Qt 4.6 + +Rectangle { + width: 180; height: 200; + + Component { + id: delegate + Rectangle { + id: wrapper + width: 180; height: 200 + color: "blue" + + states: State { + name: "otherState" + PropertyChanges { target: wrapper; color: "green" } + } + + transitions: Transition { + PropertyAction { target: wrapper; property: "ListView.delayRemove"; value: true } + ScriptAction { script: console.log(ListView.delayRemove ? "on" : "off") } + } + + Component.onCompleted: { + console.log(ListView.delayRemove ? "on" : "off"); + wrapper.state = "otherState" + } + } + } + + ListView { + model: 1 + delegate: delegate + } +} diff --git a/tests/auto/declarative/animations/tst_animations.cpp b/tests/auto/declarative/animations/tst_animations.cpp index 35eae73..7f043ba 100644 --- a/tests/auto/declarative/animations/tst_animations.cpp +++ b/tests/auto/declarative/animations/tst_animations.cpp @@ -67,6 +67,7 @@ private slots: void propertiesTransition(); void easingStringConversion(); void invalidDuration(); + void attached(); }; #define QTIMED_COMPARE(lhs, rhs) do { \ @@ -563,6 +564,17 @@ void tst_animations::invalidDuration() QCOMPARE(pauseAnimation->duration(), 250); } +void tst_animations::attached() +{ + QmlEngine engine; + + QmlComponent c(&engine, QUrl("file://" SRCDIR "/data/attached.qml")); + QTest::ignoreMessage(QtDebugMsg, "off"); + QTest::ignoreMessage(QtDebugMsg, "on"); + QmlGraphicsRectangle *rect = qobject_cast<QmlGraphicsRectangle*>(c.create()); + QVERIFY(rect); +} + QTEST_MAIN(tst_animations) #include "tst_animations.moc" diff --git a/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp b/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp index 23ecf2b..0ff5ff4 100644 --- a/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp +++ b/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp @@ -176,7 +176,6 @@ void tst_qmlgraphicstextedit::text() actual.replace(QRegExp(".*<body[^>]*>"),""); actual.replace(QRegExp("(<[^>]*>)+"),"<>"); expected.replace(QRegExp("(<[^>]*>)+"),"<>"); - expected = "<> <> <> " + expected; QCOMPARE(actual.simplified(),expected.simplified()); } } @@ -631,21 +630,19 @@ void tst_qmlgraphicstextedit::delegateLoading() server.serveDirectory("data/httpfail", TestHTTPServer::Disconnect); server.serveDirectory("data/httpslow", TestHTTPServer::Delay); server.serveDirectory("data/http"); - QmlView* view= new QmlView(0); + QmlView* view = new QmlView(0); view->setUrl(QUrl("http://localhost:42332/cursorHttpTestPass.qml")); view->execute(); view->show(); view->setFocus(); - QTest::qWait(500); + QTRY_VERIFY(view->root());//Wait for loading to finish. QmlGraphicsTextEdit *textEditObject = view->root()->findChild<QmlGraphicsTextEdit*>("textEditObject"); - QEXPECT_FAIL("","QT-2498", Continue); + // view->root()->dumpObjectTree(); QVERIFY(textEditObject != 0); - //textEditObject->setFocus(true); + textEditObject->setFocus(true); QmlGraphicsItem *delegate; - QEXPECT_FAIL("","QT-2498", Continue); delegate = view->root()->findChild<QmlGraphicsItem*>("delegateOkay"); QVERIFY(delegate); - QEXPECT_FAIL("","QT-2498", Continue); delegate = view->root()->findChild<QmlGraphicsItem*>("delegateSlow"); QVERIFY(delegate); view->setUrl(QUrl("http://localhost:42332/cursorHttpTestFail1.qml")); @@ -653,7 +650,7 @@ void tst_qmlgraphicstextedit::delegateLoading() view->show(); view->setFocus(); delegate = view->root()->findChild<QmlGraphicsItem*>("delegateOkay"); - QVERIFY(!delegate); + QVERIFY(delegate); delegate = view->root()->findChild<QmlGraphicsItem*>("delegateFail"); QVERIFY(!delegate); view->setUrl(QUrl("http://localhost:42332/cursorHttpTestFail2.qml")); @@ -661,11 +658,12 @@ void tst_qmlgraphicstextedit::delegateLoading() view->show(); view->setFocus(); delegate = view->root()->findChild<QmlGraphicsItem*>("delegateOkay"); - QVERIFY(!delegate); + QVERIFY(delegate); delegate = view->root()->findChild<QmlGraphicsItem*>("delegateErrorA"); QVERIFY(!delegate); //ErrorB should get a component which is ready but component.create() returns null //Not sure how to accomplish this with QmlGraphicsTextEdits cursor delegate + //###This could be a case of overzealous defensive programming //delegate = view->root()->findChild<QmlGraphicsItem*>("delegateErrorB"); //QVERIFY(!delegate); } |