From a8ba5e3a0909de536a2793a522749a3c0c42525e Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 14 Apr 2010 19:46:53 +1000 Subject: Remove dead wgt support from qml runtime --- tools/qml/qml.pri | 29 ++++++++++++ tools/qml/qml.pro | 35 +++------------ tools/qml/qmlruntime.cpp | 114 +++++------------------------------------------ tools/qml/qmlruntime.h | 2 - 4 files changed, 44 insertions(+), 136 deletions(-) create mode 100644 tools/qml/qml.pri diff --git a/tools/qml/qml.pri b/tools/qml/qml.pri new file mode 100644 index 0000000..c48e919 --- /dev/null +++ b/tools/qml/qml.pri @@ -0,0 +1,29 @@ +QT += declarative script network sql +contains(QT_CONFIG, opengl) { + QT += opengl + DEFINES += GL_SUPPORTED +} + +INCLUDEPATH += $$PWD + +HEADERS += $$PWD/qmlruntime.h \ + $$PWD/proxysettings.h \ + $$PWD/qdeclarativetester.h \ + $$PWD/deviceorientation.h \ + $$PWD/qdeclarativefolderlistmodel.h +SOURCES += $$PWD/qmlruntime.cpp \ + $$PWD/proxysettings.cpp \ + $$PWD/qdeclarativetester.cpp \ + $$PWD/qdeclarativefolderlistmodel.cpp + +RESOURCES = $$PWD/qmlruntime.qrc +maemo5 { + SOURCES += $$PWD/deviceorientation_maemo.cpp +} else { + SOURCES += $$PWD/deviceorientation.cpp +} +FORMS = $$PWD/recopts.ui \ + $$PWD/proxysettings.ui + +include(../shared/deviceskin/deviceskin.pri) + diff --git a/tools/qml/qml.pro b/tools/qml/qml.pro index 1ed8b2c..869907f 100644 --- a/tools/qml/qml.pro +++ b/tools/qml/qml.pro @@ -1,40 +1,15 @@ TEMPLATE = app -CONFIG += qt \ - uic +CONFIG += qt uic DESTDIR = ../../bin -QT += declarative \ - script \ - network \ - sql -contains(QT_CONFIG, opengl) { - QT += opengl - DEFINES += GL_SUPPORTED -} +include(qml.pri) + +SOURCES += main.cpp -# Input -HEADERS += qmlruntime.h \ - proxysettings.h \ - qdeclarativetester.h \ - deviceorientation.h \ - qdeclarativefolderlistmodel.h -SOURCES += main.cpp \ - qmlruntime.cpp \ - proxysettings.cpp \ - qdeclarativetester.cpp \ - qdeclarativefolderlistmodel.cpp -RESOURCES = qmlruntime.qrc -maemo5 { - SOURCES += deviceorientation_maemo.cpp -} else { - SOURCES += deviceorientation.cpp -} -FORMS = recopts.ui \ - proxysettings.ui INCLUDEPATH += ../../include/QtDeclarative INCLUDEPATH += ../../src/declarative/util INCLUDEPATH += ../../src/declarative/graphicsitems -include(../shared/deviceskin/deviceskin.pri) + target.path = $$[QT_INSTALL_BINS] INSTALLS += target diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index df29294..0a0ad9b 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -55,11 +55,6 @@ #include #include "deviceskin.h" -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 3)) -#include -#define QDECLARATIVEVIEWER_ZIP_SUPPORT -#endif - #include #include #include @@ -470,6 +465,8 @@ QDeclarativeViewer::QDeclarativeViewer(QWidget *parent, Qt::WindowFlags flags) , portraitOrientation(0), landscapeOrientation(0) , m_scriptOptions(0), tester(0), useQmlFileBrowser(true) { + QDeclarativeViewer::registerTypes(); + devicemode = false; skin = 0; canvas = 0; @@ -896,103 +893,7 @@ void QDeclarativeViewer::reload() void QDeclarativeViewer::open(const QString& doc) { -#ifdef QDECLARATIVEVIEWER_ZIP_SUPPORT - if (doc.endsWith(".wgt",Qt::CaseInsensitive) - || doc.endsWith(".wgz",Qt::CaseInsensitive) - || doc.endsWith(".zip",Qt::CaseInsensitive)) - openWgt(doc); - else -#endif - openQml(doc); -} - -void QDeclarativeViewer::openWgt(const QString& doc) -{ -#ifdef QDECLARATIVEVIEWER_ZIP_SUPPORT - // XXX This functionality could be migrated to QDeclarativeView once refined - - QUrl url(doc); - if (url.isRelative()) - url = QUrl::fromLocalFile(doc); - delete canvas->rootObject(); - canvas->engine()->clearComponentCache(); - QNetworkAccessManager * nam = canvas->engine()->networkAccessManager(); - wgtreply = nam->get(QNetworkRequest(url)); - connect(wgtreply,SIGNAL(finished()),this,SLOT(unpackWgt())); -#endif -} - -#ifdef QDECLARATIVEVIEWER_ZIP_SUPPORT -static void removeRecursive(const QString& dirname) -{ - QDir dir(dirname); - QFileInfoList entries(dir.entryInfoList(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot)); - for (int i = 0; i < entries.count(); ++i) - if (entries[i].isDir()) - removeRecursive(entries[i].filePath()); - else - dir.remove(entries[i].fileName()); - QDir().rmdir(dirname); -} -#endif - -void QDeclarativeViewer::unpackWgt() -{ -#ifdef QDECLARATIVEVIEWER_ZIP_SUPPORT - QByteArray all = wgtreply->readAll(); - QBuffer buf(&all); - buf.open(QIODevice::ReadOnly); - QZipReader zip(&buf); - /* - for (int i=0; iheader(QNetworkRequest::ContentTypeHeader).toString() == "application/widget" || wgtreply->url().path().endsWith(".wgt",Qt::CaseInsensitive)) { - // W3C Draft http://www.w3.org/TR/2009/CR-widgets-20091201 - QFile configfile(wgtdir+QDir::separator()+"config.xml"); - if (configfile.open(QIODevice::ReadOnly)) { - QXmlStreamReader config(&configfile); - if (config.readNextStartElement() && config.name() == "widget") { - while (config.readNextStartElement()) { - if (config.name() == "content") { - rootfile = wgtdir + QDir::separator(); - rootfile += config.attributes().value(QLatin1String("src")); - } - // XXX process other config - - config.skipCurrentElement(); - } - } - } else { - qWarning("No config.xml found - non-standard WGT file"); - } - if (rootfile.isEmpty()) { - QString def = wgtdir+QDir::separator()+"index.qml"; - if (QFile::exists(def)) - rootfile = def; - } - } else { - // Just find index.qml, preferably at the root - for (int i=0; i("Qt",4,6,"Orientation"); + static bool registered = false; + + if (!registered) { + // registering only for exposing the DeviceOrientation::Orientation enum + qmlRegisterUncreatableType("Qt",4,6,"Orientation"); + registered = true; + } } QT_END_NAMESPACE diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h index 1ae771a..8792d0c 100644 --- a/tools/qml/qmlruntime.h +++ b/tools/qml/qmlruntime.h @@ -108,7 +108,6 @@ public: public slots: void sceneResized(QSize size); void open(const QString&); - void openWgt(const QString&); void openQml(const QString&); void openFile(); void reload(); @@ -142,7 +141,6 @@ private slots: void toggleOrientation(); void startNetwork(); void toggleFullScreen(); - void unpackWgt(); private: QString getVideoFileName(); -- cgit v0.12 From 114f627d14e7c4f06f82a7286c38c78388fe7623 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 15 Apr 2010 09:35:23 +1000 Subject: Don't create delegates when destroying view. Task-number: QTBUG-9840 --- src/declarative/graphicsitems/qdeclarativelistview.cpp | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativelistview.cpp b/src/declarative/graphicsitems/qdeclarativelistview.cpp index cf7b96f..307c0a7 100644 --- a/src/declarative/graphicsitems/qdeclarativelistview.cpp +++ b/src/declarative/graphicsitems/qdeclarativelistview.cpp @@ -521,7 +521,6 @@ void QDeclarativeListViewPrivate::clear() trackedItem = 0; minExtentDirty = true; maxExtentDirty = true; - setPosition(0); itemCount = 0; } @@ -708,6 +707,7 @@ void QDeclarativeListViewPrivate::layout() layoutScheduled = false; if (!isValid()) { clear(); + setPosition(0); return; } updateSections(); @@ -1416,6 +1416,7 @@ void QDeclarativeListView::setModel(const QVariant &model) disconnect(d->model, SIGNAL(destroyingItem(QDeclarativeItem*)), this, SLOT(destroyingItem(QDeclarativeItem*))); } d->clear(); + d->setPosition(0); d->modelVariant = model; QObject *object = qvariant_cast(model); QDeclarativeVisualModel *vim = 0; @@ -1770,6 +1771,7 @@ void QDeclarativeListView::setOrientation(QDeclarativeListView::Orientation orie setFlickDirection(HorizontalFlick); } d->clear(); + d->setPosition(0); refill(); emit orientationChanged(); d->updateCurrent(d->currentIndex); @@ -2791,6 +2793,7 @@ void QDeclarativeListView::modelReset() { Q_D(QDeclarativeListView); d->clear(); + d->setPosition(0); refill(); d->moveReason = QDeclarativeListViewPrivate::SetIndex; d->updateCurrent(d->currentIndex); -- cgit v0.12 From 9d9ac32f7be34c9ac30b23cf55b3f383d6c70568 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 15 Apr 2010 10:10:49 +1000 Subject: Fix localFont path in fonts example. --- examples/declarative/fonts/fonts.qml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/examples/declarative/fonts/fonts.qml b/examples/declarative/fonts/fonts.qml index 97dd645..ae31b03 100644 --- a/examples/declarative/fonts/fonts.qml +++ b/examples/declarative/fonts/fonts.qml @@ -7,7 +7,7 @@ Rectangle { color: "steelblue" FontLoader { id: fixedFont; name: "Courier" } - FontLoader { id: localFont; source: "fonts/tarzenau-ocr-a.ttf" } + FontLoader { id: localFont; source: "fonts/tarzeau_ocr_a.ttf" } FontLoader { id: webFont; source: "http://www.princexml.com/fonts/steffmann/Starburst.ttf" } Column { @@ -19,7 +19,7 @@ Rectangle { color: "lightsteelblue" width: parent.width elide: Text.ElideRight - font.family: "Times"; font.pointSize: 42 + font.family: "Times"; font.pointSize: 42 } Text { text: myText -- cgit v0.12 From 0ddd9958b483e4dbbd5d4b69f3a8425855bdc53b Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 15 Apr 2010 11:56:39 +1000 Subject: Output script errors in ScriptAction and StateChangeScript Task-number: QTBUG-9897 --- src/declarative/util/qdeclarativeanimation.cpp | 7 +++++++ src/declarative/util/qdeclarativestateoperations.cpp | 6 ++++++ 2 files changed, 13 insertions(+) diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index 33ddb46..fac38d7 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -44,6 +44,7 @@ #include "private/qdeclarativebehavior_p.h" #include "private/qdeclarativestateoperations_p.h" +#include "private/qdeclarativecontext_p.h" #include #include @@ -767,6 +768,7 @@ void QDeclarativeScriptAction::setStateChangeScriptName(const QString &name) void QDeclarativeScriptActionPrivate::execute() { + Q_Q(QDeclarativeScriptAction); if (hasRunScriptScript && reversing) return; @@ -775,7 +777,12 @@ void QDeclarativeScriptActionPrivate::execute() const QString &str = scriptStr.script(); if (!str.isEmpty()) { QDeclarativeExpression expr(scriptStr.context(), str, scriptStr.scopeObject()); + QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(q); + if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) + expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); expr.value(); + if (expr.hasError()) + qWarning() << expr.error(); } } diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index 410a269..0521d27 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -49,6 +49,7 @@ #include #include #include +#include "private/qdeclarativecontext_p.h" #include #include @@ -571,7 +572,12 @@ void QDeclarativeStateChangeScript::execute() const QString &script = d->script.script(); if (!script.isEmpty()) { QDeclarativeExpression expr(d->script.context(), script, d->script.scopeObject()); + QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(this); + if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) + expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); expr.value(); + if (expr.hasError()) + qWarning() << expr.error(); } } -- cgit v0.12 From 5645cd7d7a97edb248a67d094993900f1dba4be8 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 15 Apr 2010 12:41:36 +1000 Subject: Make sure richtext wraps correctly with a fixed height set. --- src/declarative/graphicsitems/qdeclarativetext.cpp | 2 +- .../qdeclarativetext/tst_qdeclarativetext.cpp | 20 ++++++++++++++++++++ 2 files changed, 21 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index b65212b..3a35dd5 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -677,7 +677,7 @@ void QDeclarativeTextPrivate::updateSize() QTextOption option((Qt::Alignment)int(hAlign | vAlign)); option.setWrapMode(QTextOption::WrapMode(wrapMode)); doc->setDefaultTextOption(option); - if (wrapMode != QDeclarativeText::NoWrap && !q->heightValid() && q->widthValid()) + if (wrapMode != QDeclarativeText::NoWrap && q->widthValid()) doc->setTextWidth(q->width()); else doc->setTextWidth(doc->idealWidth()); // ### Text does not align if width is not set (QTextDoc bug) diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp index 2d10756..6637415 100644 --- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp @@ -286,8 +286,28 @@ void tst_qdeclarativetext::wrap() QVERIFY(textObject != 0); QCOMPARE(textObject->width(), 30.); QVERIFY(textObject->height() > textHeight); + + qreal oldHeight = textObject->height(); + textObject->setWidth(100); + QVERIFY(textObject->height() < oldHeight); } + // richtext again with a fixed height + for (int i = 0; i < richText.size(); i++) + { + QString componentStr = "import Qt 4.7\nText { wrapMode: Text.WordWrap; width: 30; height: 50; text: \"" + richText.at(i) + "\" }"; + QDeclarativeComponent textComponent(&engine); + textComponent.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QDeclarativeText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + QCOMPARE(textObject->width(), 30.); + QVERIFY(textObject->implicitHeight() > textHeight); + + qreal oldHeight = textObject->implicitHeight(); + textObject->setWidth(100); + QVERIFY(textObject->implicitHeight() < oldHeight); + } } void tst_qdeclarativetext::elide() -- cgit v0.12 From c0eb81664f2bae225dcaca897c23564d6f97a3d1 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 15 Apr 2010 12:51:51 +1000 Subject: Add QML object destruction hook --- src/declarative/qml/qdeclarativeengine.cpp | 4 ++++ src/declarative/qml/qdeclarativeprivate.h | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index c5afe92..85e8a9e 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -350,6 +350,10 @@ typedef QMap StringStringMap; Q_GLOBAL_STATIC(StringStringMap, qmlEnginePluginsWithRegisteredTypes); // stores the uri +void QDeclarativePrivate::qdeclarativeelement_destructor(QObject *) +{ +} + void QDeclarativeDeclarativeData::destroyed(QDeclarativeData *d, QObject *o) { static_cast(d)->destroyed(o); diff --git a/src/declarative/qml/qdeclarativeprivate.h b/src/declarative/qml/qdeclarativeprivate.h index bebe82c..6e240d8 100644 --- a/src/declarative/qml/qdeclarativeprivate.h +++ b/src/declarative/qml/qdeclarativeprivate.h @@ -69,11 +69,18 @@ public: class QDeclarativeCustomParser; namespace QDeclarativePrivate { + void Q_DECLARATIVE_EXPORT qdeclarativeelement_destructor(QObject *); template - QObject *create() { return new T; } + class QDeclarativeElement : public T + { + public: + virtual ~QDeclarativeElement() { + QDeclarativePrivate::qdeclarativeelement_destructor(this); + } + }; template - void createInto(void *memory) { new (memory) T; } + void createInto(void *memory) { new (memory) QDeclarativeElement; } template QObject *createParent(QObject *p) { return new T(p); } -- cgit v0.12 From 9d4489ff403e675aceb29497a557b1bb6dd53e73 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 15 Apr 2010 13:24:14 +1000 Subject: Improve integration docs and add examples --- doc/src/declarative/integrating.qdoc | 148 ++++++++++++++------- .../integrating/graphicswidgets/bluecircle.h | 58 ++++++++ .../graphicswidgets/graphicswidgets.pro | 13 ++ .../snippets/integrating/graphicswidgets/main.qml | 32 +++++ .../snippets/integrating/graphicswidgets/qmldir | 1 + .../integrating/graphicswidgets/redsquare.h | 57 ++++++++ .../integrating/graphicswidgets/shapesplugin.cpp | 61 +++++++++ .../declarative-integrating-graphicswidgets.png | Bin 0 -> 1061 bytes 8 files changed, 319 insertions(+), 51 deletions(-) create mode 100644 doc/src/declarative/snippets/integrating/graphicswidgets/bluecircle.h create mode 100644 doc/src/declarative/snippets/integrating/graphicswidgets/graphicswidgets.pro create mode 100644 doc/src/declarative/snippets/integrating/graphicswidgets/main.qml create mode 100644 doc/src/declarative/snippets/integrating/graphicswidgets/qmldir create mode 100644 doc/src/declarative/snippets/integrating/graphicswidgets/redsquare.h create mode 100644 doc/src/declarative/snippets/integrating/graphicswidgets/shapesplugin.cpp create mode 100644 doc/src/images/declarative-integrating-graphicswidgets.png diff --git a/doc/src/declarative/integrating.qdoc b/doc/src/declarative/integrating.qdoc index 165a735..d4034fa 100644 --- a/doc/src/declarative/integrating.qdoc +++ b/doc/src/declarative/integrating.qdoc @@ -43,44 +43,56 @@ \page qml-integration.html \title Integrating QML with existing Qt UI code -If you have existing Qt UI code which does not use QML you can still -add QML to your UI, without having to rewrite it. - -\section1 Adding QML to a \l{QWidget} based UI -If you have an existing QWidget based UI you can simply write new custom -widgets in QML. To integrate them into your application you can create a -QDeclarativeView widget, and load the QML file into that. You'll then have a new widget -containing your declarative UI, and you can interact with it through the -QDeclarativeView interface. The one drawback of this approach is that QDeclarativeView is a lot -heavier than a QWidget in terms of memory consumption and initialization speed, -and so having large numbers of them may lead to performance degredation. - -For a smooth transition from a QWidget based UI to a QML based UI, simply -rewrite your widgets in QML one at a time, using the above method. When -all of your widgets are written in QML you can rewrite your main widget in -QML, so as to load the other widgets in QML instead of using QDeclarativeViews. Then -you just load the main QML file on startup. - -Keep in mind that QWidgets were designed for different sorts of UIs than QML -was, and so it is not always a good idea to switch. QWidgets are a better -choice if your UI is comprised of a small number of complex and static -elements, and QML is a better choice if your UI is comprised of a large number +There are a number of ways to integrate QML into QWidget-based UI applications, +depending on the characteristics of your existing UI code. + + +\section1 Integrating with a \l{QWidget}-based UI + +If you have an existing QWidget-based UI, QML widgets can be integrated into +it using QDeclarativeView. QDeclarativeView is a subclass of QWidget so you +can add it to your user interface like any other QWidget. Use +QDeclarativeView::setSource() to load a QML file into the view, then add the +view to your UI: + +\code +QDeclarativeView *qmlView = new QDeclarativeView; +qmlView->setSource(QUrl::fromLocalFile("myqml.qml")); + +QWidget *widget = myExistingWidget(); +QVBoxLayout *layout = new QVBoxLayout(widget); +widget->addWidget(qmlView); +\endcode + +The one drawback to this approach is that QDeclarativeView is slower to initialize +and uses more memory than a QWidget, and creating large numbers of QDeclarativeView +objects may lead to performance degradation. If this is the case, it may be +better to rewrite your widgets in QML, and load the widgets from a main QML widget +instead of using QDeclarativeView. + +Keep in mind that QWidgets were designed for a different type of user interface +than QML, so it is not always a good idea to port a QWidget-based application to +QML. QWidgets are a better choice if your UI is comprised of a small number of +complex and static elements, and QML is a better choice if your UI is comprised of a large number of simple and dynamic elements. -\section1 Adding QML to a QGraphicsView based UI -If you have an existing Graphics View based UI you can create new -items in QML, and use \l{QDeclarativeComponent} to create \l{QGraphicsObject}s -from the QML files. These \l{QGraphicsObject}s can then be placed into -your \l{QGraphicsScene} using \l{QGraphicsScene::addItem()} or by -reparenting them to an item already in the \l{QGraphicsScene}. +\section1 Integrating with a QGraphicsView-based UI + +\section2 Adding QML widgets to a QGraphicsScene -Example, for local QML files: +If you have an existing UI based on the \l{The Graphics View Framework}{Graphics View Framework}, +you can integrate QML widgets directly into your QGraphicsScene. Use +QDeclarativeComponent to create a QGraphicsObject from a QML file, and +place the graphics object into your scene using \l{QGraphicsScene::addItem()}, or +reparent it to an item already in the \l{QGraphicsScene}. + +For example: \code -QGraphicsScene* scene = new QGraphicsScene; +QGraphicsScene* scene = myExistingGraphicsScene(); QDeclarativeEngine *engine = new QDeclarativeEngine; -QDeclarativeComponent component(engine, QUrl::fromLocalFile(filename)); +QDeclarativeComponent component(engine, QUrl::fromLocalFile("myqml.qml")); QGraphicsObject *object = qobject_cast(component.create()); scene->addItem(object); @@ -90,26 +102,60 @@ The following QGraphicsView options are recommended for optimal performance of QML UIs: \list -\o QGraphicsView::setOptimizationFlags(QGraphicsView::DontSavePainterState); -\o QGraphicsView::setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); -\o QGraphicsScene::setItemIndexMethod(QGraphicsScene::NoIndex); +\o QGraphicsView::setOptimizationFlags(QGraphicsView::DontSavePainterState) +\o QGraphicsView::setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate) +\o QGraphicsScene::setItemIndexMethod(QGraphicsScene::NoIndex) \endlist -\section1 Using existing QGraphicsWidgets in QML -Another way of integrating with a QGraphicsView based UI is to expose your -existing QGraphicsWidgets to QML, and constructing your scene in QML. Note that -this approach will not work with QGraphicsItems which are not QGraphicsWidgets, -and that this approach allows you to integrate new items written in QML -without using the above method. - -You can make custom C++ types -available in QML using the pair of macros listed in \l{Extending QML in C++}. -While this is normally only useful for -types that were designed for QML use, in conjunction with the -\l{GraphicsObjectContainer} element QGraphicsWidget subclasses can also be -used effectively (if they were designed, like QGraphicsWidget, to be controllable through Qt's property system). -This way you can write your UI using QML, without having to rewrite your existing items. - -For details on implementing this approach see \l{Extending QML in C++} page for details on exposing your C++ types, -and the \l{GraphicsObjectContainer} documentation for details about using it to wrap QGraphicsWidgets. +\section2 Loading QGraphicsWidget objects in QML + +An alternative approach is to expose your existing QGraphicsWidget objects to +QML and construct your scene in QML instead. To do this, you need to register +any custom C++ types and create a plugin that registers the custom types +so that they can be used from your QML file. + +Here is an example. Suppose you have two classes, \c RedSquare and \c BlueCircle, +that both inherit from QGraphicsWidget. First, you need to register these two types +using the \c QML_DECLARE_TYPE macro from \c , like this: + +\c [graphicswidgets/redsquare.h] +\snippet doc/src/declarative/snippets/integrating/graphicswidgets/redsquare.h 0 + +\c [graphicswidgets/bluecircle.h] +\snippet doc/src/declarative/snippets/integrating/graphicswidgets/bluecircle.h 0 + +Then, create a plugin by subclassing QDeclarativeExtensionPlugin, and register the +types by calling qmlRegisterType(). Also export the plugin with Q_EXPORT_PLUGIN2. + +\c [graphicswidgets/shapesplugin.cpp] +\snippet doc/src/declarative/snippets/integrating/graphicswidgets/shapesplugin.cpp 0 + +Now write a project file that creates the plugin: + +\c [graphicswidgets/graphicswidgets.pro] +\quotefile doc/src/declarative/snippets/integrating/graphicswidgets/graphicswidgets.pro + +And add a \c qmldir file that includes the \c graphicswidgets plugin from the \c lib +subdirectory (as defined in the project file): + +\c [graphicswidgets/qmldir] +\quotefile doc/src/declarative/snippets/integrating/graphicswidgets/qmldir + +Now, we can write a QML file that uses the \c RedSquare and \c BlueCircle widgets. +(As an example, we can also create \c QGraphicsWidget items if we import the \c Qt.widgets +module.) + +\c [main.qml] +\quotefile doc/src/declarative/snippets/integrating/graphicswidgets/main.qml + +Here is a screenshot of the result: + +\image declarative-integrating-graphicswidgets.png + + +Note this approach of creating your graphics widgets from QML does not work +with QGraphicsItem objects that are not QGraphicsWidget-based, since they are not QObjects. + +See \l{Extending QML in C++} for further information on using C++ types. + */ diff --git a/doc/src/declarative/snippets/integrating/graphicswidgets/bluecircle.h b/doc/src/declarative/snippets/integrating/graphicswidgets/bluecircle.h new file mode 100644 index 0000000..028718f --- /dev/null +++ b/doc/src/declarative/snippets/integrating/graphicswidgets/bluecircle.h @@ -0,0 +1,58 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +#include +#include +#include + +class BlueCircle : public QGraphicsWidget +{ + Q_OBJECT +public: + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) + { + painter->setPen(QColor(Qt::blue)); + painter->drawEllipse(0, 0, size().width(), size().height()); + } +}; + +QML_DECLARE_TYPE(BlueCircle) +//![0] diff --git a/doc/src/declarative/snippets/integrating/graphicswidgets/graphicswidgets.pro b/doc/src/declarative/snippets/integrating/graphicswidgets/graphicswidgets.pro new file mode 100644 index 0000000..21c8a37 --- /dev/null +++ b/doc/src/declarative/snippets/integrating/graphicswidgets/graphicswidgets.pro @@ -0,0 +1,13 @@ +TEMPLATE = lib +CONFIG += qt plugin +QT += declarative + +HEADERS += redsquare.h \ + bluecircle.h + +SOURCES += shapesplugin.cpp + +DESTDIR = lib +OBJECTS_DIR = tmp +MOC_DIR = tmp + diff --git a/doc/src/declarative/snippets/integrating/graphicswidgets/main.qml b/doc/src/declarative/snippets/integrating/graphicswidgets/main.qml new file mode 100644 index 0000000..ffcf79d --- /dev/null +++ b/doc/src/declarative/snippets/integrating/graphicswidgets/main.qml @@ -0,0 +1,32 @@ +import Qt 4.7 +import Qt.widgets 4.7 + +Rectangle { + width: 200 + height: 200 + + RedSquare { + id: square + width: 80 + height: 80 + } + + BlueCircle { + anchors.left: square.right + width: 80 + height: 80 + } + + QGraphicsWidget { + anchors.top: square.bottom + size.width: 80 + size.height: 80 + layout: QGraphicsLinearLayout { + LayoutItem { + preferredSize: "100x100" + Rectangle { color: "yellow"; anchors.fill: parent } + } + } + } +} + diff --git a/doc/src/declarative/snippets/integrating/graphicswidgets/qmldir b/doc/src/declarative/snippets/integrating/graphicswidgets/qmldir new file mode 100644 index 0000000..f94dad2 --- /dev/null +++ b/doc/src/declarative/snippets/integrating/graphicswidgets/qmldir @@ -0,0 +1 @@ +plugin graphicswidgets lib diff --git a/doc/src/declarative/snippets/integrating/graphicswidgets/redsquare.h b/doc/src/declarative/snippets/integrating/graphicswidgets/redsquare.h new file mode 100644 index 0000000..76e7d11 --- /dev/null +++ b/doc/src/declarative/snippets/integrating/graphicswidgets/redsquare.h @@ -0,0 +1,57 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +#include +#include +#include + +class RedSquare : public QGraphicsWidget +{ + Q_OBJECT +public: + void paint(QPainter *painter, const QStyleOptionGraphicsItem *, QWidget *) + { + painter->fillRect(0, 0, size().width(), size().height(), QColor(Qt::red)); + } +}; + +QML_DECLARE_TYPE(RedSquare) +//![0] diff --git a/doc/src/declarative/snippets/integrating/graphicswidgets/shapesplugin.cpp b/doc/src/declarative/snippets/integrating/graphicswidgets/shapesplugin.cpp new file mode 100644 index 0000000..4c18ef3 --- /dev/null +++ b/doc/src/declarative/snippets/integrating/graphicswidgets/shapesplugin.cpp @@ -0,0 +1,61 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the documentation of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ +//![0] +#include "redsquare.h" +#include "bluecircle.h" + +#include +#include + +class ShapesPlugin : public QDeclarativeExtensionPlugin +{ + Q_OBJECT +public: + void registerTypes(const char *uri) { + qmlRegisterType(uri, 1, 0, "RedSquare"); + qmlRegisterType(uri, 1, 0, "BlueCircle"); + } +}; + +#include "shapesplugin.moc" + +Q_EXPORT_PLUGIN2(shapesplugin, ShapesPlugin); +//![0] diff --git a/doc/src/images/declarative-integrating-graphicswidgets.png b/doc/src/images/declarative-integrating-graphicswidgets.png new file mode 100644 index 0000000..d57f4b9 Binary files /dev/null and b/doc/src/images/declarative-integrating-graphicswidgets.png differ -- cgit v0.12 From 451f1f33fa65ba213b1585592225c358f124146a Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 15 Apr 2010 13:34:07 +1000 Subject: Add flow property to Grid, adding TopToBottom mode. Task-number: QTBUG-9183 --- .../graphicsitems/qdeclarativepositioners.cpp | 138 +++++++++++++++------ .../graphicsitems/qdeclarativepositioners_p.h | 17 ++- .../data/grid-toptobottom.qml | 41 ++++++ .../tst_qdeclarativepositioners.cpp | 32 +++++ 4 files changed, 185 insertions(+), 43 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativepositioners/data/grid-toptobottom.qml diff --git a/src/declarative/graphicsitems/qdeclarativepositioners.cpp b/src/declarative/graphicsitems/qdeclarativepositioners.cpp index f436471..21c33e2 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners.cpp +++ b/src/declarative/graphicsitems/qdeclarativepositioners.cpp @@ -656,10 +656,8 @@ Grid { */ QDeclarativeGrid::QDeclarativeGrid(QDeclarativeItem *parent) : - QDeclarativeBasePositioner(Both, parent) + QDeclarativeBasePositioner(Both, parent), m_rows(-1), m_columns(-1), m_flow(LeftToRight) { - _columns=-1; - _rows=-1; } /*! @@ -682,55 +680,101 @@ QDeclarativeGrid::QDeclarativeGrid(QDeclarativeItem *parent) : void QDeclarativeGrid::setColumns(const int columns) { - if (columns == _columns) + if (columns == m_columns) return; - _columns = columns; + m_columns = columns; prePositioning(); emit columnsChanged(); } void QDeclarativeGrid::setRows(const int rows) { - if (rows == _rows) + if (rows == m_rows) return; - _rows = rows; + m_rows = rows; prePositioning(); emit rowsChanged(); } +/*! + \qmlproperty enumeration Flow::flow + This property holds the flow of the layout. + + Possible values are \c LeftToRight (default) and \c TopToBottom. + + If \a flow is \c LeftToRight, the items are positioned next to + to each other from left to right, then wrapped to the next line. + If \a flow is \c TopToBottom, the items are positioned next to each + other from top to bottom, then wrapped to the next column. +*/ +QDeclarativeGrid::Flow QDeclarativeGrid::flow() const +{ + return m_flow; +} + +void QDeclarativeGrid::setFlow(Flow flow) +{ + if (m_flow != flow) { + m_flow = flow; + prePositioning(); + emit flowChanged(); + } +} + void QDeclarativeGrid::doPositioning(QSizeF *contentSize) { - int c = _columns; - int r = _rows; + int c = m_columns; + int r = m_rows; int numVisible = positionedItems.count(); - if (_columns <= 0 && _rows <= 0){ + if (m_columns <= 0 && m_rows <= 0){ c = 4; r = (numVisible+3)/4; - } else if (_rows <= 0){ - r = (numVisible+(_columns-1))/_columns; - } else if (_columns <= 0){ - c = (numVisible+(_rows-1))/_rows; + } else if (m_rows <= 0){ + r = (numVisible+(m_columns-1))/m_columns; + } else if (m_columns <= 0){ + c = (numVisible+(m_rows-1))/m_rows; } QList maxColWidth; QList maxRowHeight; int childIndex =0; - for (int i=0; iwidth() > maxColWidth[j]) - maxColWidth[j] = child.item->width(); - if (child.item->height() > maxRowHeight[i]) - maxRowHeight[i] = child.item->height(); + if (m_flow == LeftToRight) { + for (int i=0; i < r; i++){ + for (int j=0; j < c; j++){ + if (j==0) + maxRowHeight << 0; + if (i==0) + maxColWidth << 0; + + if (childIndex == positionedItems.count()) + continue; + const PositionedItem &child = positionedItems.at(childIndex++); + if (!child.item || isInvisible(child.item)) + continue; + if (child.item->width() > maxColWidth[j]) + maxColWidth[j] = child.item->width(); + if (child.item->height() > maxRowHeight[i]) + maxRowHeight[i] = child.item->height(); + } + } + } else { + for (int j=0; j < c; j++){ + for (int i=0; i < r; i++){ + if (j==0) + maxRowHeight << 0; + if (i==0) + maxColWidth << 0; + + if (childIndex == positionedItems.count()) + continue; + const PositionedItem &child = positionedItems.at(childIndex++); + if (!child.item || isInvisible(child.item)) + continue; + if (child.item->width() > maxColWidth[j]) + maxColWidth[j] = child.item->width(); + if (child.item->height() > maxRowHeight[i]) + maxRowHeight[i] = child.item->height(); + } } } @@ -747,18 +791,34 @@ void QDeclarativeGrid::doPositioning(QSizeF *contentSize) positionY(yoffset, child); } - contentSize->setWidth(qMax(contentSize->width(), xoffset + child.item->width())); - contentSize->setHeight(yoffset + maxRowHeight[curRow]); + if (m_flow == LeftToRight) { + contentSize->setWidth(qMax(contentSize->width(), xoffset + child.item->width())); + contentSize->setHeight(yoffset + maxRowHeight[curRow]); + + xoffset+=maxColWidth[curCol]+spacing(); + curCol++; + curCol%=c; + if (!curCol){ + yoffset+=maxRowHeight[curRow]+spacing(); + xoffset=0; + curRow++; + if (curRow>=r) + break; + } + } else { + contentSize->setHeight(qMax(contentSize->height(), yoffset + child.item->height())); + contentSize->setWidth(xoffset + maxColWidth[curCol]); - xoffset+=maxColWidth[curCol]+spacing(); - curCol++; - curCol%=c; - if (!curCol){ yoffset+=maxRowHeight[curRow]+spacing(); - xoffset=0; curRow++; - if (curRow>=r) - break; + curRow%=r; + if (!curRow){ + xoffset+=maxColWidth[curCol]+spacing(); + yoffset=0; + curCol++; + if (curCol>=c) + break; + } } } } diff --git a/src/declarative/graphicsitems/qdeclarativepositioners_p.h b/src/declarative/graphicsitems/qdeclarativepositioners_p.h index c4414d1..24b65fa 100644 --- a/src/declarative/graphicsitems/qdeclarativepositioners_p.h +++ b/src/declarative/graphicsitems/qdeclarativepositioners_p.h @@ -138,25 +138,34 @@ class Q_DECLARATIVE_EXPORT QDeclarativeGrid : public QDeclarativeBasePositioner Q_OBJECT Q_PROPERTY(int rows READ rows WRITE setRows NOTIFY rowChanged) Q_PROPERTY(int columns READ columns WRITE setColumns NOTIFY columnsChanged) + Q_PROPERTY(Flow flow READ flow WRITE setFlow NOTIFY flowChanged) + public: QDeclarativeGrid(QDeclarativeItem *parent=0); - int rows() const {return _rows;} + int rows() const {return m_rows;} void setRows(const int rows); - int columns() const {return _columns;} + int columns() const {return m_columns;} void setColumns(const int columns); + Q_ENUMS(Flow) + enum Flow { LeftToRight, TopToBottom }; + Flow flow() const; + void setFlow(Flow); + Q_SIGNALS: void rowsChanged(); void columnsChanged(); + void flowChanged(); protected: virtual void doPositioning(QSizeF *contentSize); private: - int _rows; - int _columns; + int m_rows; + int m_columns; + Flow m_flow; Q_DISABLE_COPY(QDeclarativeGrid) }; diff --git a/tests/auto/declarative/qdeclarativepositioners/data/grid-toptobottom.qml b/tests/auto/declarative/qdeclarativepositioners/data/grid-toptobottom.qml new file mode 100644 index 0000000..34a84bf --- /dev/null +++ b/tests/auto/declarative/qdeclarativepositioners/data/grid-toptobottom.qml @@ -0,0 +1,41 @@ +import Qt 4.6 + +Item { + width: 640 + height: 480 + Grid { + objectName: "grid" + rows: 3 + flow: Grid.TopToBottom + Rectangle { + objectName: "one" + color: "red" + width: 50 + height: 50 + } + Rectangle { + objectName: "two" + color: "green" + width: 20 + height: 50 + } + Rectangle { + objectName: "three" + color: "blue" + width: 50 + height: 20 + } + Rectangle { + objectName: "four" + color: "cyan" + width: 50 + height: 50 + } + Rectangle { + objectName: "five" + color: "magenta" + width: 10 + height: 10 + } + } +} diff --git a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp index 8692596..b4ac0e1 100644 --- a/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp +++ b/tests/auto/declarative/qdeclarativepositioners/tst_qdeclarativepositioners.cpp @@ -61,6 +61,7 @@ private slots: void test_vertical_spacing(); void test_vertical_animated(); void test_grid(); + void test_grid_topToBottom(); void test_grid_spacing(); void test_grid_animated(); void test_grid_zero_columns(); @@ -305,6 +306,37 @@ void tst_QDeclarativePositioners::test_grid() QCOMPARE(grid->height(), 100.0); } +void tst_QDeclarativePositioners::test_grid_topToBottom() +{ + QDeclarativeView *canvas = createView(SRCDIR "/data/grid-toptobottom.qml"); + + QDeclarativeRectangle *one = canvas->rootObject()->findChild("one"); + QVERIFY(one != 0); + QDeclarativeRectangle *two = canvas->rootObject()->findChild("two"); + QVERIFY(two != 0); + QDeclarativeRectangle *three = canvas->rootObject()->findChild("three"); + QVERIFY(three != 0); + QDeclarativeRectangle *four = canvas->rootObject()->findChild("four"); + QVERIFY(four != 0); + QDeclarativeRectangle *five = canvas->rootObject()->findChild("five"); + QVERIFY(five != 0); + + QCOMPARE(one->x(), 0.0); + QCOMPARE(one->y(), 0.0); + QCOMPARE(two->x(), 0.0); + QCOMPARE(two->y(), 50.0); + QCOMPARE(three->x(), 0.0); + QCOMPARE(three->y(), 100.0); + QCOMPARE(four->x(), 50.0); + QCOMPARE(four->y(), 0.0); + QCOMPARE(five->x(), 50.0); + QCOMPARE(five->y(), 50.0); + + QDeclarativeItem *grid = canvas->rootObject()->findChild("grid"); + QCOMPARE(grid->width(), 100.0); + QCOMPARE(grid->height(), 120.0); +} + void tst_QDeclarativePositioners::test_grid_spacing() { QDeclarativeView *canvas = createView(SRCDIR "/data/grid-spacing.qml"); -- cgit v0.12 From 43b2d65dddaf0dacdd998ceb93f923deafc466d1 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 15 Apr 2010 13:43:13 +1000 Subject: Fix typo --- doc/src/declarative/qmlruntime.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/declarative/qmlruntime.qdoc b/doc/src/declarative/qmlruntime.qdoc index fbe82c6..9f7183a 100644 --- a/doc/src/declarative/qmlruntime.qdoc +++ b/doc/src/declarative/qmlruntime.qdoc @@ -164,7 +164,7 @@ The runtime.isActiveWindow property tells whether the main window of the qml runtime is currently active or not. This is specially useful for embedded devices when you want to pause parts of your application, - including animations, when your application looses focus or goes to the background. + including animations, when your application loses focus or goes to the background. The example below, stops the animation when the application's window is deactivated and resumes on activation: -- cgit v0.12 From a21bd329e4ba9b0e67931ea5a635088afda58eb5 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 15 Apr 2010 13:45:43 +1000 Subject: Rename QDeclarativeData -> QAbstractDeclarativeData Reviewed-by: Martin Jones --- src/corelib/kernel/qobject.cpp | 8 ++++---- src/corelib/kernel/qobject_p.h | 8 ++++---- src/declarative/qml/qdeclarativedeclarativedata_p.h | 10 +++++----- src/declarative/qml/qdeclarativeengine.cpp | 4 ++-- src/gui/graphicsview/qgraphicsitem.cpp | 2 +- src/gui/kernel/qwidget.cpp | 2 +- 6 files changed, 17 insertions(+), 17 deletions(-) diff --git a/src/corelib/kernel/qobject.cpp b/src/corelib/kernel/qobject.cpp index 411f22e..c13d829 100644 --- a/src/corelib/kernel/qobject.cpp +++ b/src/corelib/kernel/qobject.cpp @@ -125,8 +125,8 @@ extern "C" Q_CORE_EXPORT void qt_removeObject(QObject *) } } -void (*QDeclarativeData::destroyed)(QDeclarativeData *, QObject *) = 0; -void (*QDeclarativeData::parentChanged)(QDeclarativeData *, QObject *, QObject *) = 0; +void (*QAbstractDeclarativeData::destroyed)(QAbstractDeclarativeData *, QObject *) = 0; +void (*QAbstractDeclarativeData::parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *) = 0; QObjectData::~QObjectData() {} @@ -878,7 +878,7 @@ QObject::~QObject() } if (d->declarativeData) - QDeclarativeData::destroyed(d->declarativeData, this); + QAbstractDeclarativeData::destroyed(d->declarativeData, this); { QMutex *signalSlotMutex = 0; @@ -2027,7 +2027,7 @@ void QObjectPrivate::setParent_helper(QObject *o) } } if (!wasDeleted && declarativeData) - QDeclarativeData::parentChanged(declarativeData, q, o); + QAbstractDeclarativeData::parentChanged(declarativeData, q, o); } /*! diff --git a/src/corelib/kernel/qobject_p.h b/src/corelib/kernel/qobject_p.h index e5d904c..341b3e9 100644 --- a/src/corelib/kernel/qobject_p.h +++ b/src/corelib/kernel/qobject_p.h @@ -84,11 +84,11 @@ extern QSignalSpyCallbackSet Q_CORE_EXPORT qt_signal_spy_callback_set; enum { QObjectPrivateVersion = QT_VERSION }; -class Q_CORE_EXPORT QDeclarativeData +class Q_CORE_EXPORT QAbstractDeclarativeData { public: - static void (*destroyed)(QDeclarativeData *, QObject *); - static void (*parentChanged)(QDeclarativeData *, QObject *, QObject *); + static void (*destroyed)(QAbstractDeclarativeData *, QObject *); + static void (*parentChanged)(QAbstractDeclarativeData *, QObject *, QObject *); }; class Q_CORE_EXPORT QObjectPrivate : public QObjectData @@ -194,7 +194,7 @@ public: QList > eventFilters; union { QObject *currentChildBeingDeleted; - QDeclarativeData *declarativeData; //extra data used by the DeclarativeUI project. + QAbstractDeclarativeData *declarativeData; //extra data used by the declarative module }; // these objects are all used to indicate that a QObject was deleted diff --git a/src/declarative/qml/qdeclarativedeclarativedata_p.h b/src/declarative/qml/qdeclarativedeclarativedata_p.h index 5b12629..fdc51a4 100644 --- a/src/declarative/qml/qdeclarativedeclarativedata_p.h +++ b/src/declarative/qml/qdeclarativedeclarativedata_p.h @@ -68,7 +68,7 @@ class QDeclarativeContextData; // default state for elemental object allocations. This is crucial in the // workings of the QDeclarativeInstruction::CreateSimpleObject instruction. // Don't change anything here without first considering that case! -class Q_AUTOTEST_EXPORT QDeclarativeDeclarativeData : public QDeclarativeData +class Q_AUTOTEST_EXPORT QDeclarativeDeclarativeData : public QAbstractDeclarativeData { public: QDeclarativeDeclarativeData() @@ -80,12 +80,12 @@ public: } static inline void init() { - QDeclarativeData::destroyed = destroyed; - QDeclarativeData::parentChanged = parentChanged; + QAbstractDeclarativeData::destroyed = destroyed; + QAbstractDeclarativeData::parentChanged = parentChanged; } - static void destroyed(QDeclarativeData *, QObject *); - static void parentChanged(QDeclarativeData *, QObject *, QObject *); + static void destroyed(QAbstractDeclarativeData *, QObject *); + static void parentChanged(QAbstractDeclarativeData *, QObject *, QObject *); void destroyed(QObject *); void parentChanged(QObject *, QObject *); diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 85e8a9e..eb149b1 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -354,12 +354,12 @@ void QDeclarativePrivate::qdeclarativeelement_destructor(QObject *) { } -void QDeclarativeDeclarativeData::destroyed(QDeclarativeData *d, QObject *o) +void QDeclarativeDeclarativeData::destroyed(QAbstractDeclarativeData *d, QObject *o) { static_cast(d)->destroyed(o); } -void QDeclarativeDeclarativeData::parentChanged(QDeclarativeData *d, QObject *o, QObject *p) +void QDeclarativeDeclarativeData::parentChanged(QAbstractDeclarativeData *d, QObject *o, QObject *p) { static_cast(d)->parentChanged(o, p); } diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 9e0ec2e..9759b39 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -1413,7 +1413,7 @@ QGraphicsItem::~QGraphicsItem() QObjectPrivate *p = QObjectPrivate::get(o); p->wasDeleted = true; if (p->declarativeData) { - QDeclarativeData::destroyed(p->declarativeData, o); + QAbstractDeclarativeData::destroyed(p->declarativeData, o); p->declarativeData = 0; } } diff --git a/src/gui/kernel/qwidget.cpp b/src/gui/kernel/qwidget.cpp index 4fba8cf..10fa4b9 100644 --- a/src/gui/kernel/qwidget.cpp +++ b/src/gui/kernel/qwidget.cpp @@ -1478,7 +1478,7 @@ QWidget::~QWidget() QObjectPrivate::clearGuards(this); if (d->declarativeData) { - QDeclarativeData::destroyed(d->declarativeData, this); + QAbstractDeclarativeData::destroyed(d->declarativeData, this); d->declarativeData = 0; // don't activate again in ~QObject } -- cgit v0.12 From a7fe2b895980ef203631d15375f175e25b9ca6a9 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 15 Apr 2010 14:07:13 +1000 Subject: Rename the ridiculous QDeclarativeDeclarativeData -> QDeclarativeData --- .../graphicsitems/qdeclarativevisualitemmodel.cpp | 4 +- src/declarative/qml/qdeclarativebinding.cpp | 6 +- src/declarative/qml/qdeclarativebinding_p.h | 2 +- src/declarative/qml/qdeclarativecomponent.cpp | 4 +- src/declarative/qml/qdeclarativecontext.cpp | 4 +- src/declarative/qml/qdeclarativecontext_p.h | 4 +- src/declarative/qml/qdeclarativedata_p.h | 175 +++++++++++++++++++++ .../qml/qdeclarativedeclarativedata_p.h | 175 --------------------- src/declarative/qml/qdeclarativeengine.cpp | 38 ++--- src/declarative/qml/qdeclarativeenginedebug.cpp | 2 +- src/declarative/qml/qdeclarativeguard_p.h | 4 +- src/declarative/qml/qdeclarativeinfo.cpp | 4 +- .../qml/qdeclarativeobjectscriptclass.cpp | 14 +- src/declarative/qml/qdeclarativeproperty.cpp | 6 +- src/declarative/qml/qdeclarativepropertycache.cpp | 4 +- src/declarative/qml/qdeclarativevme.cpp | 26 +-- src/declarative/qml/qdeclarativevmemetaobject.cpp | 2 +- src/declarative/qml/qml.pri | 2 +- src/declarative/util/qdeclarativeanimation.cpp | 2 +- .../util/qdeclarativelistmodelworkeragent.cpp | 2 +- .../util/qdeclarativeopenmetaobject.cpp | 4 +- .../util/qdeclarativestateoperations.cpp | 2 +- 22 files changed, 243 insertions(+), 243 deletions(-) create mode 100644 src/declarative/qml/qdeclarativedata_p.h delete mode 100644 src/declarative/qml/qdeclarativedeclarativedata_p.h diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index 03e4703..4365ea3 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -50,7 +50,7 @@ #include #include #include -#include +#include #include #include #include @@ -1058,7 +1058,7 @@ QString QDeclarativeVisualDataModel::stringValue(int index, const QString &name) tempData = true; } - QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(data); + QDeclarativeData *ddata = QDeclarativeData::get(data); if (ddata && ddata->propertyCache) { QDeclarativePropertyCache::Data *prop = ddata->propertyCache->property(name); if (prop) { diff --git a/src/declarative/qml/qdeclarativebinding.cpp b/src/declarative/qml/qdeclarativebinding.cpp index 664118d..25492ac 100644 --- a/src/declarative/qml/qdeclarativebinding.cpp +++ b/src/declarative/qml/qdeclarativebinding.cpp @@ -46,7 +46,7 @@ #include "qdeclarativecontext.h" #include "qdeclarativeinfo.h" #include "private/qdeclarativecontext_p.h" -#include "private/qdeclarativedeclarativedata_p.h" +#include "private/qdeclarativedata_p.h" #include "private/qdeclarativestringconverters_p.h" #include @@ -296,7 +296,7 @@ void QDeclarativeAbstractBinding::addToObject(QObject *object) Q_ASSERT(!m_prevBinding); m_object = object; - QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(object, true); + QDeclarativeData *data = QDeclarativeData::get(object, true); if (index & 0xFF000000) { // Value type @@ -348,7 +348,7 @@ void QDeclarativeAbstractBinding::removeFromObject() // Value type - we don't remove the proxy from the object. It will sit their happily // doing nothing for ever more. } else { - QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(m_object, false); + QDeclarativeData *data = QDeclarativeData::get(m_object, false); if (data) data->clearBindingBit(index); } diff --git a/src/declarative/qml/qdeclarativebinding_p.h b/src/declarative/qml/qdeclarativebinding_p.h index 2789738..2d3acf5 100644 --- a/src/declarative/qml/qdeclarativebinding_p.h +++ b/src/declarative/qml/qdeclarativebinding_p.h @@ -92,7 +92,7 @@ protected: private: - friend class QDeclarativeDeclarativeData; + friend class QDeclarativeData; friend class QDeclarativeValueTypeProxyBinding; friend class QDeclarativePropertyPrivate; friend class QDeclarativeVME; diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 5f26ad5..1903006 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -518,7 +518,7 @@ QScriptValue QDeclarativeComponent::createObject() if (!ret) return QScriptValue(); QDeclarativeEnginePrivate *priv = QDeclarativeEnginePrivate::get(d->engine); - QDeclarativeDeclarativeData::get(ret, true)->setImplicitDestructible(); + QDeclarativeData::get(ret, true)->setImplicitDestructible(); return priv->objectClass->newQObject(ret, QMetaType::QObjectStar); } @@ -581,7 +581,7 @@ QObject *QDeclarativeComponent::beginCreate(QDeclarativeContext *context) Q_D(QDeclarativeComponent); QObject *rv = d->beginCreate(context?QDeclarativeContextData::get(context):0, QBitField()); if (rv) { - QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(rv); + QDeclarativeData *ddata = QDeclarativeData::get(rv); Q_ASSERT(ddata); ddata->indestructible = true; } diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp index ba4da95..42e7386 100644 --- a/src/declarative/qml/qdeclarativecontext.cpp +++ b/src/declarative/qml/qdeclarativecontext.cpp @@ -525,7 +525,7 @@ void QDeclarativeContextData::destroy() expressions = 0; while (contextObjects) { - QDeclarativeDeclarativeData *co = contextObjects; + QDeclarativeData *co = contextObjects; contextObjects = contextObjects->nextContextObject; co->context = 0; @@ -608,7 +608,7 @@ void QDeclarativeContextData::refreshExpressions() void QDeclarativeContextData::addObject(QObject *o) { - QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(o, true); + QDeclarativeData *data = QDeclarativeData::get(o, true); Q_ASSERT(data->context == 0); diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h index 7a16179..5d26e7e 100644 --- a/src/declarative/qml/qdeclarativecontext_p.h +++ b/src/declarative/qml/qdeclarativecontext_p.h @@ -55,7 +55,7 @@ #include "qdeclarativecontext.h" -#include "private/qdeclarativedeclarativedata_p.h" +#include "private/qdeclarativedata_p.h" #include "private/qdeclarativeintegercache_p.h" #include "private/qdeclarativetypenamecache_p.h" #include "private/qdeclarativenotifier_p.h" @@ -166,7 +166,7 @@ public: QDeclarativeAbstractExpression *expressions; // Doubly-linked list of objects that are owned by this context - QDeclarativeDeclarativeData *contextObjects; + QDeclarativeData *contextObjects; // Doubly-linked list of context guards (XXX merge with contextObjects) QDeclarativeGuardedContextData *contextGuards; diff --git a/src/declarative/qml/qdeclarativedata_p.h b/src/declarative/qml/qdeclarativedata_p.h new file mode 100644 index 0000000..3676d8d --- /dev/null +++ b/src/declarative/qml/qdeclarativedata_p.h @@ -0,0 +1,175 @@ +/**************************************************************************** +** +** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the QtDeclarative module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** No Commercial Usage +** This file contains pre-release code and may not be distributed. +** You may use this file in accordance with the terms and conditions +** contained in the Technology Preview License Agreement accompanying +** this package. +** +** GNU Lesser General Public License Usage +** Alternatively, this file may be used under the terms of the GNU Lesser +** General Public License version 2.1 as published by the Free Software +** Foundation and appearing in the file LICENSE.LGPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU Lesser General Public License version 2.1 requirements +** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** If you have questions regarding the use of this file, please contact +** Nokia at qt-info@nokia.com. +** +** +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QDECLARATIVEDATA_P_H +#define QDECLARATIVEDATA_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include "private/qdeclarativeguard_p.h" + +QT_BEGIN_NAMESPACE + +class QDeclarativeCompiledData; +class QDeclarativeAbstractBinding; +class QDeclarativeContext; +class QDeclarativePropertyCache; +class QDeclarativeContextData; +// This class is structured in such a way, that simply zero'ing it is the +// default state for elemental object allocations. This is crucial in the +// workings of the QDeclarativeInstruction::CreateSimpleObject instruction. +// Don't change anything here without first considering that case! +class Q_AUTOTEST_EXPORT QDeclarativeData : public QAbstractDeclarativeData +{ +public: + QDeclarativeData() + : ownMemory(true), ownContext(false), indestructible(true), explicitIndestructibleSet(false), + context(0), outerContext(0), bindings(0), nextContextObject(0), prevContextObject(0), bindingBitsSize(0), + bindingBits(0), lineNumber(0), columnNumber(0), deferredComponent(0), deferredIdx(0), + attachedProperties(0), scriptValue(0), propertyCache(0), guards(0) { + init(); + } + + static inline void init() { + QAbstractDeclarativeData::destroyed = destroyed; + QAbstractDeclarativeData::parentChanged = parentChanged; + } + + static void destroyed(QAbstractDeclarativeData *, QObject *); + static void parentChanged(QAbstractDeclarativeData *, QObject *, QObject *); + + void destroyed(QObject *); + void parentChanged(QObject *, QObject *); + + void setImplicitDestructible() { + if (!explicitIndestructibleSet) indestructible = false; + } + + quint32 ownMemory:1; + quint32 ownContext:1; + quint32 indestructible:1; + quint32 explicitIndestructibleSet:1; + quint32 dummy:28; + + QDeclarativeContextData *context; + QDeclarativeContextData *outerContext; + + QDeclarativeAbstractBinding *bindings; + + // Linked list for QDeclarativeContext::contextObjects + QDeclarativeData *nextContextObject; + QDeclarativeData**prevContextObject; + + int bindingBitsSize; + quint32 *bindingBits; + bool hasBindingBit(int) const; + void clearBindingBit(int); + void setBindingBit(QObject *obj, int); + + ushort lineNumber; + ushort columnNumber; + + QDeclarativeCompiledData *deferredComponent; // Can't this be found from the context? + unsigned int deferredIdx; + + QHash *attachedProperties; + + // ### Can we make this QScriptValuePrivate so we incur no additional allocation + // cost? + QScriptValue *scriptValue; + QDeclarativePropertyCache *propertyCache; + + QDeclarativeGuard *guards; + + static QDeclarativeData *get(const QObject *object, bool create = false) { + QObjectPrivate *priv = QObjectPrivate::get(const_cast(object)); + if (priv->wasDeleted) { + Q_ASSERT(!create); + return 0; + } else if (priv->declarativeData) { + return static_cast(priv->declarativeData); + } else if (create) { + priv->declarativeData = new QDeclarativeData; + return static_cast(priv->declarativeData); + } else { + return 0; + } + } +}; + +template +void QDeclarativeGuard::addGuard() +{ + if (QObjectPrivate::get(o)->wasDeleted) { + if (prev) remGuard(); + return; + } + + QDeclarativeData *data = QDeclarativeData::get(o, true); + next = data->guards; + if (next) reinterpret_cast *>(next)->prev = &next; + data->guards = reinterpret_cast *>(this); + prev = &data->guards; +} + +template +void QDeclarativeGuard::remGuard() +{ + if (next) reinterpret_cast *>(next)->prev = prev; + *prev = next; + next = 0; + prev = 0; +} + +QT_END_NAMESPACE + +#endif // QDECLARATIVEDATA_P_H diff --git a/src/declarative/qml/qdeclarativedeclarativedata_p.h b/src/declarative/qml/qdeclarativedeclarativedata_p.h deleted file mode 100644 index fdc51a4..0000000 --- a/src/declarative/qml/qdeclarativedeclarativedata_p.h +++ /dev/null @@ -1,175 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2010 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the QtDeclarative module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** No Commercial Usage -** This file contains pre-release code and may not be distributed. -** You may use this file in accordance with the terms and conditions -** contained in the Technology Preview License Agreement accompanying -** this package. -** -** GNU Lesser General Public License Usage -** Alternatively, this file may be used under the terms of the GNU Lesser -** General Public License version 2.1 as published by the Free Software -** Foundation and appearing in the file LICENSE.LGPL included in the -** packaging of this file. Please review the following information to -** ensure the GNU Lesser General Public License version 2.1 requirements -** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -** -** In addition, as a special exception, Nokia gives you certain additional -** rights. These rights are described in the Nokia Qt LGPL Exception -** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -** -** If you have questions regarding the use of this file, please contact -** Nokia at qt-info@nokia.com. -** -** -** -** -** -** -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QDECLARATIVEDECLARATIVEDATA_P_H -#define QDECLARATIVEDECLARATIVEDATA_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include "private/qdeclarativeguard_p.h" - -QT_BEGIN_NAMESPACE - -class QDeclarativeCompiledData; -class QDeclarativeAbstractBinding; -class QDeclarativeContext; -class QDeclarativePropertyCache; -class QDeclarativeContextData; -// This class is structured in such a way, that simply zero'ing it is the -// default state for elemental object allocations. This is crucial in the -// workings of the QDeclarativeInstruction::CreateSimpleObject instruction. -// Don't change anything here without first considering that case! -class Q_AUTOTEST_EXPORT QDeclarativeDeclarativeData : public QAbstractDeclarativeData -{ -public: - QDeclarativeDeclarativeData() - : ownMemory(true), ownContext(false), indestructible(true), explicitIndestructibleSet(false), - context(0), outerContext(0), bindings(0), nextContextObject(0), prevContextObject(0), bindingBitsSize(0), - bindingBits(0), lineNumber(0), columnNumber(0), deferredComponent(0), deferredIdx(0), - attachedProperties(0), scriptValue(0), propertyCache(0), guards(0) { - init(); - } - - static inline void init() { - QAbstractDeclarativeData::destroyed = destroyed; - QAbstractDeclarativeData::parentChanged = parentChanged; - } - - static void destroyed(QAbstractDeclarativeData *, QObject *); - static void parentChanged(QAbstractDeclarativeData *, QObject *, QObject *); - - void destroyed(QObject *); - void parentChanged(QObject *, QObject *); - - void setImplicitDestructible() { - if (!explicitIndestructibleSet) indestructible = false; - } - - quint32 ownMemory:1; - quint32 ownContext:1; - quint32 indestructible:1; - quint32 explicitIndestructibleSet:1; - quint32 dummy:28; - - QDeclarativeContextData *context; - QDeclarativeContextData *outerContext; - - QDeclarativeAbstractBinding *bindings; - - // Linked list for QDeclarativeContext::contextObjects - QDeclarativeDeclarativeData *nextContextObject; - QDeclarativeDeclarativeData**prevContextObject; - - int bindingBitsSize; - quint32 *bindingBits; - bool hasBindingBit(int) const; - void clearBindingBit(int); - void setBindingBit(QObject *obj, int); - - ushort lineNumber; - ushort columnNumber; - - QDeclarativeCompiledData *deferredComponent; // Can't this be found from the context? - unsigned int deferredIdx; - - QHash *attachedProperties; - - // ### Can we make this QScriptValuePrivate so we incur no additional allocation - // cost? - QScriptValue *scriptValue; - QDeclarativePropertyCache *propertyCache; - - QDeclarativeGuard *guards; - - static QDeclarativeDeclarativeData *get(const QObject *object, bool create = false) { - QObjectPrivate *priv = QObjectPrivate::get(const_cast(object)); - if (priv->wasDeleted) { - Q_ASSERT(!create); - return 0; - } else if (priv->declarativeData) { - return static_cast(priv->declarativeData); - } else if (create) { - priv->declarativeData = new QDeclarativeDeclarativeData; - return static_cast(priv->declarativeData); - } else { - return 0; - } - } -}; - -template -void QDeclarativeGuard::addGuard() -{ - if (QObjectPrivate::get(o)->wasDeleted) { - if (prev) remGuard(); - return; - } - - QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(o, true); - next = data->guards; - if (next) reinterpret_cast *>(next)->prev = &next; - data->guards = reinterpret_cast *>(this); - prev = &data->guards; -} - -template -void QDeclarativeGuard::remGuard() -{ - if (next) reinterpret_cast *>(next)->prev = prev; - *prev = next; - next = 0; - prev = 0; -} - -QT_END_NAMESPACE - -#endif // QDECLARATIVEDECLARATIVEDATA_P_H diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index eb149b1..ae0929b 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -354,14 +354,14 @@ void QDeclarativePrivate::qdeclarativeelement_destructor(QObject *) { } -void QDeclarativeDeclarativeData::destroyed(QAbstractDeclarativeData *d, QObject *o) +void QDeclarativeData::destroyed(QAbstractDeclarativeData *d, QObject *o) { - static_cast(d)->destroyed(o); + static_cast(d)->destroyed(o); } -void QDeclarativeDeclarativeData::parentChanged(QAbstractDeclarativeData *d, QObject *o, QObject *p) +void QDeclarativeData::parentChanged(QAbstractDeclarativeData *d, QObject *o, QObject *p) { - static_cast(d)->parentChanged(o, p); + static_cast(d)->parentChanged(o, p); } void QDeclarativeEnginePrivate::init() @@ -371,7 +371,7 @@ void QDeclarativeEnginePrivate::init() qRegisterMetaType("QDeclarativeScriptString"); qRegisterMetaType("QScriptValue"); - QDeclarativeDeclarativeData::init(); + QDeclarativeData::init(); contextClass = new QDeclarativeContextScriptClass(q); objectClass = new QDeclarativeObjectScriptClass(q); @@ -663,8 +663,8 @@ QDeclarativeContext *QDeclarativeEngine::contextForObject(const QObject *object) QObjectPrivate *priv = QObjectPrivate::get(const_cast(object)); - QDeclarativeDeclarativeData *data = - static_cast(priv->declarativeData); + QDeclarativeData *data = + static_cast(priv->declarativeData); if (!data) return 0; @@ -687,7 +687,7 @@ void QDeclarativeEngine::setContextForObject(QObject *object, QDeclarativeContex if (!object || !context) return; - QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(object, true); + QDeclarativeData *data = QDeclarativeData::get(object, true); if (data->context) { qWarning("QDeclarativeEngine::setContextForObject(): Object already has a QDeclarativeContext"); return; @@ -738,7 +738,7 @@ void QDeclarativeEngine::setContextForObject(QObject *object, QDeclarativeContex */ void QDeclarativeEngine::setObjectOwnership(QObject *object, ObjectOwnership ownership) { - QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(object, true); + QDeclarativeData *ddata = QDeclarativeData::get(object, true); if (!ddata) return; @@ -751,7 +751,7 @@ void QDeclarativeEngine::setObjectOwnership(QObject *object, ObjectOwnership own */ QDeclarativeEngine::ObjectOwnership QDeclarativeEngine::objectOwnership(QObject *object) { - QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(object, false); + QDeclarativeData *ddata = QDeclarativeData::get(object, false); if (!ddata) return CppOwnership; else @@ -760,7 +760,7 @@ QDeclarativeEngine::ObjectOwnership QDeclarativeEngine::objectOwnership(QObject void qmlExecuteDeferred(QObject *object) { - QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(object); + QDeclarativeData *data = QDeclarativeData::get(object); if (data && data->deferredComponent) { @@ -793,7 +793,7 @@ QDeclarativeEngine *qmlEngine(const QObject *obj) QObject *qmlAttachedPropertiesObjectById(int id, const QObject *object, bool create) { - QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(object); + QDeclarativeData *data = QDeclarativeData::get(object); if (!data) return 0; // Attached properties are only on objects created by QML @@ -828,7 +828,7 @@ QObject *qmlAttachedPropertiesObject(int *idCache, const QObject *object, return qmlAttachedPropertiesObjectById(*idCache, object, create); } -void QDeclarativeDeclarativeData::destroyed(QObject *object) +void QDeclarativeData::destroyed(QObject *object) { if (deferredComponent) deferredComponent->release(); @@ -875,12 +875,12 @@ void QDeclarativeDeclarativeData::destroyed(QObject *object) delete this; } -void QDeclarativeDeclarativeData::parentChanged(QObject *, QObject *parent) +void QDeclarativeData::parentChanged(QObject *, QObject *parent) { if (!parent && scriptValue) { delete scriptValue; scriptValue = 0; } } -bool QDeclarativeDeclarativeData::hasBindingBit(int bit) const +bool QDeclarativeData::hasBindingBit(int bit) const { if (bindingBitsSize > bit) return bindingBits[bit / 32] & (1 << (bit % 32)); @@ -888,13 +888,13 @@ bool QDeclarativeDeclarativeData::hasBindingBit(int bit) const return false; } -void QDeclarativeDeclarativeData::clearBindingBit(int bit) +void QDeclarativeData::clearBindingBit(int bit) { if (bindingBitsSize > bit) bindingBits[bit / 32] &= ~(1 << (bit % 32)); } -void QDeclarativeDeclarativeData::setBindingBit(QObject *obj, int bit) +void QDeclarativeData::setBindingBit(QObject *obj, int bit) { if (bindingBitsSize <= bit) { int props = obj->metaObject()->propertyCount(); @@ -960,7 +960,7 @@ QScriptValue QDeclarativeEnginePrivate::createComponent(QScriptContext *ctxt, QS QUrl url = QUrl(context->resolvedUrl(QUrl(arg))); QDeclarativeComponent *c = new QDeclarativeComponent(activeEngine, url, activeEngine); QDeclarativeComponentPrivate::get(c)->creationContext = context; - QDeclarativeDeclarativeData::get(c, true)->setImplicitDestructible(); + QDeclarativeData::get(c, true)->setImplicitDestructible(); return activeEnginePriv->objectClass->newQObject(c, qMetaTypeId()); } } @@ -1031,7 +1031,7 @@ QScriptValue QDeclarativeEnginePrivate::createQmlObject(QScriptContext *ctxt, QS if(gobj && gparent) gobj->setParentItem(gparent); - QDeclarativeDeclarativeData::get(obj, true)->setImplicitDestructible(); + QDeclarativeData::get(obj, true)->setImplicitDestructible(); return activeEnginePriv->objectClass->newQObject(obj, QMetaType::QObjectStar); } diff --git a/src/declarative/qml/qdeclarativeenginedebug.cpp b/src/declarative/qml/qdeclarativeenginedebug.cpp index 3455883..578733c 100644 --- a/src/declarative/qml/qdeclarativeenginedebug.cpp +++ b/src/declarative/qml/qdeclarativeenginedebug.cpp @@ -264,7 +264,7 @@ void QDeclarativeEngineDebugServer::buildObjectList(QDataStream &message, QDecla QDeclarativeEngineDebugServer::QDeclarativeObjectData QDeclarativeEngineDebugServer::objectData(QObject *object) { - QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(object); + QDeclarativeData *ddata = QDeclarativeData::get(object); QDeclarativeObjectData rv; if (ddata && ddata->outerContext) { rv.url = ddata->outerContext->url; diff --git a/src/declarative/qml/qdeclarativeguard_p.h b/src/declarative/qml/qdeclarativeguard_p.h index 747d58f..be60ce4 100644 --- a/src/declarative/qml/qdeclarativeguard_p.h +++ b/src/declarative/qml/qdeclarativeguard_p.h @@ -65,7 +65,7 @@ class QDeclarativeGuard QObject *o; QDeclarativeGuard *next; QDeclarativeGuard **prev; - friend class QDeclarativeDeclarativeData; + friend class QDeclarativeData; public: inline QDeclarativeGuard(); inline QDeclarativeGuard(T *); @@ -99,7 +99,7 @@ QT_END_NAMESPACE Q_DECLARE_METATYPE(QDeclarativeGuard); -#include "private/qdeclarativedeclarativedata_p.h" +#include "private/qdeclarativedata_p.h" QT_BEGIN_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeinfo.cpp b/src/declarative/qml/qdeclarativeinfo.cpp index 6199aa9..0a4352f 100644 --- a/src/declarative/qml/qdeclarativeinfo.cpp +++ b/src/declarative/qml/qdeclarativeinfo.cpp @@ -41,7 +41,7 @@ #include "qdeclarativeinfo.h" -#include "private/qdeclarativedeclarativedata_p.h" +#include "private/qdeclarativedata_p.h" #include "qdeclarativecontext.h" #include "private/qdeclarativecontext_p.h" #include "private/qdeclarativemetatype_p.h" @@ -100,7 +100,7 @@ QDeclarativeInfo::QDeclarativeInfo(const QObject *object) pos += typeName; } - QDeclarativeDeclarativeData *ddata = object?QDeclarativeDeclarativeData::get(object):0; + QDeclarativeData *ddata = object?QDeclarativeData::get(object):0; pos += QLatin1String(" ("); if (ddata) { if (ddata->outerContext && !ddata->outerContext->url.isEmpty()) { diff --git a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp index e1e33ab..5773fe6 100644 --- a/src/declarative/qml/qdeclarativeobjectscriptclass.cpp +++ b/src/declarative/qml/qdeclarativeobjectscriptclass.cpp @@ -43,7 +43,7 @@ #include "private/qdeclarativeengine_p.h" #include "private/qdeclarativecontext_p.h" -#include "private/qdeclarativedeclarativedata_p.h" +#include "private/qdeclarativedata_p.h" #include "private/qdeclarativetypenamescriptclass_p.h" #include "private/qdeclarativelistscriptclass_p.h" #include "private/qdeclarativebinding_p.h" @@ -63,7 +63,7 @@ struct ObjectData : public QScriptDeclarativeClass::Object { virtual ~ObjectData() { if (object && !object->parent()) { - QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(object, false); + QDeclarativeData *ddata = QDeclarativeData::get(object, false); if (ddata && !ddata->indestructible) object->deleteLater(); } @@ -104,7 +104,7 @@ QScriptValue QDeclarativeObjectScriptClass::newQObject(QObject *object, int type if (QObjectPrivate::get(object)->wasDeleted) return scriptEngine->undefinedValue(); - QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(object, true); + QDeclarativeData *ddata = QDeclarativeData::get(object, true); if (!ddata) { return scriptEngine->undefinedValue(); @@ -428,7 +428,7 @@ QScriptValue QDeclarativeObjectScriptClass::destroy(QScriptContext *context, QSc if (!data->object) return engine->undefinedValue(); - QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(data->object, false); + QDeclarativeData *ddata = QDeclarativeData::get(data->object, false); if (!ddata || ddata->indestructible) return engine->currentContext()->throwError(QLatin1String("Invalid attempt to destroy() an indestructible object")); @@ -453,7 +453,7 @@ QStringList QDeclarativeObjectScriptClass::propertyNames(Object *object) QDeclarativeEnginePrivate *enginePrivate = QDeclarativeEnginePrivate::get(engine); QDeclarativePropertyCache *cache = 0; - QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(obj); + QDeclarativeData *ddata = QDeclarativeData::get(obj); if (ddata) cache = ddata->propertyCache; if (!cache) { @@ -752,7 +752,7 @@ QScriptDeclarativeClass::Value MetaCallArgument::toValue(QDeclarativeEngine *e) return QScriptDeclarativeClass::Value(engine, *((QString *)&data)); } else if (type == QMetaType::QObjectStar) { QObject *object = *((QObject **)&data); - QDeclarativeDeclarativeData::get(object, true)->setImplicitDestructible(); + QDeclarativeData::get(object, true)->setImplicitDestructible(); QDeclarativeEnginePrivate *priv = QDeclarativeEnginePrivate::get(e); return QScriptDeclarativeClass::Value(engine, priv->objectClass->newQObject(object)); } else if (type == qMetaTypeId >()) { @@ -761,7 +761,7 @@ QScriptDeclarativeClass::Value MetaCallArgument::toValue(QDeclarativeEngine *e) QDeclarativeEnginePrivate *priv = QDeclarativeEnginePrivate::get(e); for (int ii = 0; ii < list.count(); ++ii) { QObject *object = list.at(ii); - QDeclarativeDeclarativeData::get(object, true)->setImplicitDestructible(); + QDeclarativeData::get(object, true)->setImplicitDestructible(); rv.setProperty(ii, priv->objectClass->newQObject(object)); } return QScriptDeclarativeClass::Value(engine, rv); diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index affb6b9..9cb2416 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -50,7 +50,7 @@ #include "private/qdeclarativeboundsignal_p.h" #include "qdeclarativeengine.h" #include "private/qdeclarativeengine_p.h" -#include "private/qdeclarativedeclarativedata_p.h" +#include "private/qdeclarativedata_p.h" #include "private/qdeclarativestringconverters_p.h" #include "private/qdeclarativelist_p.h" #include "private/qdeclarativecompiler_p.h" @@ -606,7 +606,7 @@ QDeclarativePropertyPrivate::binding(const QDeclarativeProperty &that) if (!that.isProperty() || !that.d->object) return 0; - QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(that.d->object); + QDeclarativeData *data = QDeclarativeData::get(that.d->object); if (!data) return 0; @@ -660,7 +660,7 @@ QDeclarativeAbstractBinding * QDeclarativePropertyPrivate::setBinding(QObject *object, int coreIndex, int valueTypeIndex, QDeclarativeAbstractBinding *newBinding, WriteFlags flags) { - QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(object, 0 != newBinding); + QDeclarativeData *data = QDeclarativeData::get(object, 0 != newBinding); QDeclarativeAbstractBinding *binding = 0; if (data && data->hasBindingBit(coreIndex)) { diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp index 111259d..4b4b142 100644 --- a/src/declarative/qml/qdeclarativepropertycache.cpp +++ b/src/declarative/qml/qdeclarativepropertycache.cpp @@ -368,7 +368,7 @@ QDeclarativePropertyCache::Data *QDeclarativePropertyCache::property(QDeclarativ QDeclarativeEnginePrivate *enginePrivate = QDeclarativeEnginePrivate::get(engine); QDeclarativePropertyCache *cache = 0; - QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(obj); + QDeclarativeData *ddata = QDeclarativeData::get(obj); if (ddata && ddata->propertyCache && ddata->propertyCache->qmlEngine() == engine) cache = ddata->propertyCache; if (!cache) { @@ -400,7 +400,7 @@ QDeclarativePropertyCache::Data *QDeclarativePropertyCache::property(QDeclarativ QDeclarativeEnginePrivate *enginePrivate = QDeclarativeEnginePrivate::get(engine); QDeclarativePropertyCache *cache = 0; - QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(obj); + QDeclarativeData *ddata = QDeclarativeData::get(obj); if (ddata && ddata->propertyCache && ddata->propertyCache->qmlEngine() == engine) cache = ddata->propertyCache; if (!cache) { diff --git a/src/declarative/qml/qdeclarativevme.cpp b/src/declarative/qml/qdeclarativevme.cpp index 3575c17..fdcbeee 100644 --- a/src/declarative/qml/qdeclarativevme.cpp +++ b/src/declarative/qml/qdeclarativevme.cpp @@ -45,7 +45,7 @@ #include "private/qdeclarativeboundsignal_p.h" #include "private/qdeclarativestringconverters_p.h" #include "private/qmetaobjectbuilder_p.h" -#include "private/qdeclarativedeclarativedata_p.h" +#include "private/qdeclarativedata_p.h" #include "qdeclarative.h" #include "private/qdeclarativecustomparser_p.h" #include "qdeclarativeengine.h" @@ -112,7 +112,7 @@ QObject *QDeclarativeVME::run(QDeclarativeContextData *ctxt, QDeclarativeCompile void QDeclarativeVME::runDeferred(QObject *object) { - QDeclarativeDeclarativeData *data = QDeclarativeDeclarativeData::get(object); + QDeclarativeData *data = QDeclarativeData::get(object); if (!data || !data->context || !data->deferredComponent) return; @@ -194,7 +194,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack &stack, VME_EXCEPTION(QCoreApplication::translate("QDeclarativeVME","Unable to create object of type %1").arg(QString::fromLatin1(types.at(instr.create.type).className))); } - QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(o); + QDeclarativeData *ddata = QDeclarativeData::get(o); Q_ASSERT(ddata); if (stack.isEmpty()) { @@ -245,12 +245,12 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack &stack, case QDeclarativeInstruction::CreateSimpleObject: { QObject *o = (QObject *)operator new(instr.createSimple.typeSize + - sizeof(QDeclarativeDeclarativeData)); - ::memset(o, 0, instr.createSimple.typeSize + sizeof(QDeclarativeDeclarativeData)); + sizeof(QDeclarativeData)); + ::memset(o, 0, instr.createSimple.typeSize + sizeof(QDeclarativeData)); instr.createSimple.create(o); - QDeclarativeDeclarativeData *ddata = - (QDeclarativeDeclarativeData *)(((const char *)o) + instr.createSimple.typeSize); + QDeclarativeData *ddata = + (QDeclarativeData *)(((const char *)o) + instr.createSimple.typeSize); ddata->lineNumber = instr.line; ddata->columnNumber = instr.createSimple.column; @@ -289,7 +289,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack &stack, new QDeclarativeComponent(ctxt->engine, comp, ii + 1, instr.createComponent.count, stack.isEmpty() ? 0 : stack.top()); - QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(qcomp, true); + QDeclarativeData *ddata = QDeclarativeData::get(qcomp, true); Q_ASSERT(ddata); ctxt->addObject(qcomp); @@ -322,7 +322,7 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack &stack, (void)new QDeclarativeVMEMetaObject(target, &mo, data, comp); - QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(target, true); + QDeclarativeData *ddata = QDeclarativeData::get(target, true); if (ddata->propertyCache) ddata->propertyCache->release(); ddata->propertyCache = propertyCaches.at(instr.storeMeta.propertyCache); ddata->propertyCache->addref(); @@ -854,8 +854,8 @@ QObject *QDeclarativeVME::run(QDeclarativeVMEStack &stack, { if (instr.defer.deferCount) { QObject *target = stack.top(); - QDeclarativeDeclarativeData *data = - QDeclarativeDeclarativeData::get(target, true); + QDeclarativeData *data = + QDeclarativeData::get(target, true); comp->addref(); data->deferredComponent = comp; data->deferredIdx = ii; @@ -935,8 +935,8 @@ QDeclarativeCompiledData::TypeReference::createInstance(QDeclarativeContextData QObject *rv = 0; void *memory = 0; - type->create(&rv, &memory, sizeof(QDeclarativeDeclarativeData)); - QDeclarativeDeclarativeData *ddata = new (memory) QDeclarativeDeclarativeData; + type->create(&rv, &memory, sizeof(QDeclarativeData)); + QDeclarativeData *ddata = new (memory) QDeclarativeData; ddata->ownMemory = false; QObjectPrivate::get(rv)->declarativeData = ddata; diff --git a/src/declarative/qml/qdeclarativevmemetaobject.cpp b/src/declarative/qml/qdeclarativevmemetaobject.cpp index 2e2a8e8..c4d47b3 100644 --- a/src/declarative/qml/qdeclarativevmemetaobject.cpp +++ b/src/declarative/qml/qdeclarativevmemetaobject.cpp @@ -379,7 +379,7 @@ QDeclarativeVMEMetaObject::QDeclarativeVMEMetaObject(QObject *obj, const QMetaObject *other, const QDeclarativeVMEMetaData *meta, QDeclarativeCompiledData *cdata) -: object(obj), compiledData(cdata), ctxt(QDeclarativeDeclarativeData::get(obj)->outerContext), +: object(obj), compiledData(cdata), ctxt(QDeclarativeData::get(obj)->outerContext), metaData(meta), data(0), methods(0), parent(0) { compiledData->addref(); diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index 1087f44..c48662c 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -94,7 +94,7 @@ HEADERS += \ $$PWD/qdeclarativecompositetypemanager_p.h \ $$PWD/qdeclarativelist.h \ $$PWD/qdeclarativelist_p.h \ - $$PWD/qdeclarativedeclarativedata_p.h \ + $$PWD/qdeclarativedata_p.h \ $$PWD/qdeclarativeerror.h \ $$PWD/qdeclarativescriptparser_p.h \ $$PWD/qdeclarativeenginedebug_p.h \ diff --git a/src/declarative/util/qdeclarativeanimation.cpp b/src/declarative/util/qdeclarativeanimation.cpp index fac38d7..7e20428 100644 --- a/src/declarative/util/qdeclarativeanimation.cpp +++ b/src/declarative/util/qdeclarativeanimation.cpp @@ -777,7 +777,7 @@ void QDeclarativeScriptActionPrivate::execute() const QString &str = scriptStr.script(); if (!str.isEmpty()) { QDeclarativeExpression expr(scriptStr.context(), str, scriptStr.scopeObject()); - QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(q); + QDeclarativeData *ddata = QDeclarativeData::get(q); if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); expr.value(); diff --git a/src/declarative/util/qdeclarativelistmodelworkeragent.cpp b/src/declarative/util/qdeclarativelistmodelworkeragent.cpp index 3c0a086..d91b107 100644 --- a/src/declarative/util/qdeclarativelistmodelworkeragent.cpp +++ b/src/declarative/util/qdeclarativelistmodelworkeragent.cpp @@ -41,7 +41,7 @@ #include "private/qdeclarativelistmodelworkeragent_p.h" #include "private/qdeclarativelistmodel_p_p.h" -#include "private/qdeclarativedeclarativedata_p.h" +#include "private/qdeclarativedata_p.h" #include "private/qdeclarativeengine_p.h" #include "qdeclarativeinfo.h" diff --git a/src/declarative/util/qdeclarativeopenmetaobject.cpp b/src/declarative/util/qdeclarativeopenmetaobject.cpp index 3d95125..0e5aaa6 100644 --- a/src/declarative/util/qdeclarativeopenmetaobject.cpp +++ b/src/declarative/util/qdeclarativeopenmetaobject.cpp @@ -41,7 +41,7 @@ #include "private/qdeclarativeopenmetaobject_p.h" #include "private/qdeclarativepropertycache_p.h" -#include "private/qdeclarativedeclarativedata_p.h" +#include "private/qdeclarativedata_p.h" #include #include @@ -302,7 +302,7 @@ void QDeclarativeOpenMetaObject::setCached(bool c) d->cacheProperties = c; - QDeclarativeDeclarativeData *qmldata = QDeclarativeDeclarativeData::get(d->object, true); + QDeclarativeData *qmldata = QDeclarativeData::get(d->object, true); if (d->cacheProperties) { if (!d->type->d->cache) d->type->d->cache = QDeclarativePropertyCache::create(d->type->d->engine, this); diff --git a/src/declarative/util/qdeclarativestateoperations.cpp b/src/declarative/util/qdeclarativestateoperations.cpp index 0521d27..3854b10 100644 --- a/src/declarative/util/qdeclarativestateoperations.cpp +++ b/src/declarative/util/qdeclarativestateoperations.cpp @@ -572,7 +572,7 @@ void QDeclarativeStateChangeScript::execute() const QString &script = d->script.script(); if (!script.isEmpty()) { QDeclarativeExpression expr(d->script.context(), script, d->script.scopeObject()); - QDeclarativeDeclarativeData *ddata = QDeclarativeDeclarativeData::get(this); + QDeclarativeData *ddata = QDeclarativeData::get(this); if (ddata && ddata->outerContext && !ddata->outerContext->url.isEmpty()) expr.setSourceLocation(ddata->outerContext->url.toString(), ddata->lineNumber); expr.value(); -- cgit v0.12 From 05c01500d24a0715d65c1c4d1c3e827fdf376126 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 14 Apr 2010 13:16:44 +1000 Subject: ignore autotester logs --- tests/auto/declarative/.gitignore | 1 + 1 file changed, 1 insertion(+) diff --git a/tests/auto/declarative/.gitignore b/tests/auto/declarative/.gitignore index d937eb4..57608cf 100644 --- a/tests/auto/declarative/.gitignore +++ b/tests/auto/declarative/.gitignore @@ -1,4 +1,5 @@ tst_* !tst_*.* +tst_*.log tst_*.debug tst_*~ -- cgit v0.12 From fa93b3fb3956f77f36c520e41b0c5065e51a56ce Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 14 Apr 2010 14:38:28 +1000 Subject: Should work now, don't skip. --- .../qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp index 26199d3..6d17acc 100644 --- a/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp +++ b/tests/auto/declarative/qdeclarativemoduleplugin/tst_qdeclarativemoduleplugin.cpp @@ -101,7 +101,6 @@ inline QUrl TEST_FILE(const QString &filename) void tst_qdeclarativemoduleplugin::importsPlugin() { -QSKIP("Fix me", SkipAll); QDeclarativeEngine engine; engine.addImportPath(QLatin1String(SRCDIR) + QDir::separator() + QLatin1String("imports")); QTest::ignoreMessage(QtWarningMsg, "plugin created"); -- cgit v0.12 From 35afac3d3a275aa69c74e174cfeb5e411816e94a Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Wed, 14 Apr 2010 14:53:13 +1000 Subject: Rename "sql" test so autotester doesn't get confused. --- tests/auto/declarative/declarative.pro | 2 +- .../qdeclarativesqldatabase/data/README | 3 + .../qdeclarativesqldatabase/data/changeversion.js | 53 +++++ .../qdeclarativesqldatabase/data/creation-a.js | 18 ++ .../qdeclarativesqldatabase/data/creation.js | 14 ++ .../qdeclarativesqldatabase/data/error-a.js | 20 ++ .../qdeclarativesqldatabase/data/error-b.js | 13 ++ .../qdeclarativesqldatabase/data/error-creation.js | 14 ++ .../data/error-notransaction.js | 15 ++ .../data/error-outsidetransaction.js | 17 ++ .../data/iteration-forwardonly.js | 29 +++ .../qdeclarativesqldatabase/data/iteration.js | 28 +++ .../qdeclarativesqldatabase/data/readonly-error.js | 27 +++ .../qdeclarativesqldatabase/data/readonly.js | 24 +++ .../qdeclarativesqldatabase/data/reopen1.js | 14 ++ .../qdeclarativesqldatabase/data/reopen2.js | 16 ++ .../data/selection-bindnames.js | 26 +++ .../qdeclarativesqldatabase/data/selection.js | 26 +++ .../qdeclarativesqldatabase.pro | 12 ++ .../tst_qdeclarativesqldatabase.cpp | 239 +++++++++++++++++++++ tests/auto/declarative/sql/data/README | 3 - tests/auto/declarative/sql/data/changeversion.js | 53 ----- tests/auto/declarative/sql/data/creation-a.js | 18 -- tests/auto/declarative/sql/data/creation.js | 14 -- tests/auto/declarative/sql/data/error-a.js | 20 -- tests/auto/declarative/sql/data/error-b.js | 13 -- tests/auto/declarative/sql/data/error-creation.js | 14 -- .../declarative/sql/data/error-notransaction.js | 15 -- .../sql/data/error-outsidetransaction.js | 17 -- .../declarative/sql/data/iteration-forwardonly.js | 29 --- tests/auto/declarative/sql/data/iteration.js | 28 --- tests/auto/declarative/sql/data/readonly-error.js | 27 --- tests/auto/declarative/sql/data/readonly.js | 24 --- tests/auto/declarative/sql/data/reopen1.js | 14 -- tests/auto/declarative/sql/data/reopen2.js | 16 -- .../declarative/sql/data/selection-bindnames.js | 26 --- tests/auto/declarative/sql/data/selection.js | 26 --- tests/auto/declarative/sql/sql.pro | 12 -- tests/auto/declarative/sql/tst_sql.cpp | 239 --------------------- 39 files changed, 609 insertions(+), 609 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/README create mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/changeversion.js create mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/creation-a.js create mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/creation.js create mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/error-a.js create mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/error-b.js create mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/error-creation.js create mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/error-notransaction.js create mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/error-outsidetransaction.js create mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/iteration-forwardonly.js create mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/iteration.js create mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/readonly-error.js create mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/readonly.js create mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/reopen1.js create mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/reopen2.js create mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/selection-bindnames.js create mode 100644 tests/auto/declarative/qdeclarativesqldatabase/data/selection.js create mode 100644 tests/auto/declarative/qdeclarativesqldatabase/qdeclarativesqldatabase.pro create mode 100644 tests/auto/declarative/qdeclarativesqldatabase/tst_qdeclarativesqldatabase.cpp delete mode 100644 tests/auto/declarative/sql/data/README delete mode 100644 tests/auto/declarative/sql/data/changeversion.js delete mode 100644 tests/auto/declarative/sql/data/creation-a.js delete mode 100644 tests/auto/declarative/sql/data/creation.js delete mode 100644 tests/auto/declarative/sql/data/error-a.js delete mode 100644 tests/auto/declarative/sql/data/error-b.js delete mode 100644 tests/auto/declarative/sql/data/error-creation.js delete mode 100644 tests/auto/declarative/sql/data/error-notransaction.js delete mode 100644 tests/auto/declarative/sql/data/error-outsidetransaction.js delete mode 100644 tests/auto/declarative/sql/data/iteration-forwardonly.js delete mode 100644 tests/auto/declarative/sql/data/iteration.js delete mode 100644 tests/auto/declarative/sql/data/readonly-error.js delete mode 100644 tests/auto/declarative/sql/data/readonly.js delete mode 100644 tests/auto/declarative/sql/data/reopen1.js delete mode 100644 tests/auto/declarative/sql/data/reopen2.js delete mode 100644 tests/auto/declarative/sql/data/selection-bindnames.js delete mode 100644 tests/auto/declarative/sql/data/selection.js delete mode 100644 tests/auto/declarative/sql/sql.pro delete mode 100644 tests/auto/declarative/sql/tst_sql.cpp diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 5441311..7834650 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -62,7 +62,7 @@ SUBDIRS += \ qdeclarativexmlhttprequest \ # Cover qdeclarativeimageprovider \ # Cover qdeclarativestyledtext \ # Cover - sql \ # Cover + qdeclarativesqldatabase \ # Cover qmlvisual # Cover contains(QT_CONFIG, webkit) { diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/README b/tests/auto/declarative/qdeclarativesqldatabase/data/README new file mode 100644 index 0000000..7efca3a --- /dev/null +++ b/tests/auto/declarative/qdeclarativesqldatabase/data/README @@ -0,0 +1,3 @@ +These tests are executed in sequence - the database persist until the end of the +testing. This is done to better exercise the persistence of the database, since +that is how it is used. diff --git a/tests/auto/declarative/qdeclarativesqldatabase/data/changeversion.js b/tests/auto/declarative/qdeclarativesqldatabase/data/changeversion.js new file mode 100644 index 0000000..680d7a6 --- /dev/null +++ b/tests/auto/declarative/qdeclarativesqldatabase/data/changeversion.js @@ -0,0 +1,53 @@ +function test() { + var r="transaction_not_finished"; + + var db = openDatabaseSync("QmlTestDB-changeversion", "", "Test database from Qt autotests", 1000000, + function(db) { + db.changeVersion("","1.0") + db.transaction(function(tx){ + tx.executeSql('CREATE TABLE Greeting(salutation TEXT, salutee TEXT)'); + }) + }); + + db.transaction(function(tx){ + tx.executeSql('INSERT INTO Greeting VALUES ("Hello", "world")'); + tx.executeSql('INSERT INTO Greeting VALUES ("Goodbye", "cruel world")'); + }); + + + db = openDatabaseSync("QmlTestDB-changeversion", "", "Test database from Qt autotests", 1000000); + + if (db.version == "1.0") + db.changeVersion("1.0","2.0",function(tx) + { + tx.executeSql('CREATE TABLE Utterance(type TEXT, phrase TEXT)') + var rs = tx.executeSql('SELECT * FROM Greeting'); + for (var i=0; i +#include "../../../shared/util.h" +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include +#include + +class tst_qdeclarativesqldatabase : public QObject +{ + Q_OBJECT +public: + tst_qdeclarativesqldatabase() + { + qApp->setApplicationName("tst_qdeclarativesqldatabase"); + qApp->setOrganizationName("Nokia"); + qApp->setOrganizationDomain("nokia.com"); + engine = new QDeclarativeEngine; + } + + ~tst_qdeclarativesqldatabase() + { + delete engine; + } + +private slots: + void initTestCase(); + + void checkDatabasePath(); + + void testQml_data(); + void testQml(); + void testQml_cleanopen_data(); + void testQml_cleanopen(); + void totalDatabases(); + + void cleanupTestCase(); + +private: + QString dbDir() const; + QDeclarativeEngine *engine; +}; + +class QWebPageWithJavaScriptConsoleMessages : public QWebPage { +public: + void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID) + { + qWarning() << sourceID << ":" << lineNumber << ":" << message; + } +}; + +void removeRecursive(const QString& dirname) +{ + QDir dir(dirname); + QFileInfoList entries(dir.entryInfoList(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot)); + for (int i = 0; i < entries.count(); ++i) + if (entries[i].isDir()) + removeRecursive(entries[i].filePath()); + else + dir.remove(entries[i].fileName()); + QDir().rmdir(dirname); +} + +void tst_qdeclarativesqldatabase::initTestCase() +{ + removeRecursive(dbDir()); + QDir().mkpath(dbDir()); +} + +void tst_qdeclarativesqldatabase::cleanupTestCase() +{ + removeRecursive(dbDir()); +} + +QString tst_qdeclarativesqldatabase::dbDir() const +{ + static QString tmpd = QDir::tempPath()+"/tst_qdeclarativesqldatabase_output-" + + QDateTime::currentDateTime().toString(QLatin1String("yyyyMMddhhmmss")); + return tmpd; +} + +void tst_qdeclarativesqldatabase::checkDatabasePath() +{ + // Check default storage path (we can't use it since we don't want to mess with user's data) + QVERIFY(engine->offlineStoragePath().contains("tst_qdeclarativesqldatabase")); + QVERIFY(engine->offlineStoragePath().contains("OfflineStorage")); +} + +static const int total_databases_created_by_tests = 12; +void tst_qdeclarativesqldatabase::testQml_data() +{ + QTest::addColumn("jsfile"); // The input file + + // Each test should use a newly named DB to avoid inter-test dependencies + QTest::newRow("creation") << "data/creation.js"; + QTest::newRow("creation-a") << "data/creation-a.js"; + QTest::newRow("creation") << "data/creation.js"; + QTest::newRow("error-creation") << "data/error-creation.js"; // re-uses above DB + QTest::newRow("changeversion") << "data/changeversion.js"; + QTest::newRow("readonly") << "data/readonly.js"; + QTest::newRow("readonly-error") << "data/readonly-error.js"; + QTest::newRow("selection") << "data/selection.js"; + QTest::newRow("selection-bindnames") << "data/selection-bindnames.js"; + QTest::newRow("iteration") << "data/iteration.js"; + QTest::newRow("iteration-forwardonly") << "data/iteration-forwardonly.js"; + QTest::newRow("error-a") << "data/error-a.js"; + QTest::newRow("error-notransaction") << "data/error-notransaction.js"; + QTest::newRow("error-outsidetransaction") << "data/error-outsidetransaction.js"; // reuse above + QTest::newRow("reopen1") << "data/reopen1.js"; + QTest::newRow("reopen2") << "data/reopen2.js"; // re-uses above DB + + // If you add a test, you should usually use a new database in the + // test - in which case increment total_databases_created_by_tests above. +} + +/* +void tst_qdeclarativesqldatabase::validateAgainstWebkit() +{ + // Validates tests against WebKit (HTML5) support. + // + QFETCH(QString, jsfile); + QFETCH(QString, result); + QFETCH(int, databases); + + QFile f(jsfile); + QVERIFY(f.open(QIODevice::ReadOnly)); + QString js=f.readAll(); + + QWebPageWithJavaScriptConsoleMessages webpage; + webpage.settings()->setOfflineStoragePath(dbDir()); + webpage.settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); + + QEXPECT_FAIL("","WebKit doesn't support openDatabaseSync yet", Continue); + QCOMPARE(webpage.mainFrame()->evaluateJavaScript(js).toString(),result); + + QTest::qWait(100); // WebKit crashes if you quit it too fast + + QWebSecurityOrigin origin = webpage.mainFrame()->securityOrigin(); + QList dbs = origin.databases(); + QCOMPARE(dbs.count(), databases); +} +*/ + +void tst_qdeclarativesqldatabase::testQml() +{ + // Tests QML SQL Database support with tests + // that have been validated against Webkit. + // + QFETCH(QString, jsfile); + + QString qml= + "import Qt 4.7\n" + "import \""+jsfile+"\" as JS\n" + "Text { text: JS.test() }"; + + engine->setOfflineStoragePath(dbDir()); + QDeclarativeComponent component(engine); + component.setData(qml.toUtf8(), QUrl::fromLocalFile(SRCDIR "/empty.qml")); // just a file for relative local imports + QVERIFY(!component.isError()); + QDeclarativeText *text = qobject_cast(component.create()); + QVERIFY(text != 0); + QCOMPARE(text->text(),QString("passed")); +} + +void tst_qdeclarativesqldatabase::testQml_cleanopen_data() +{ + QTest::addColumn("jsfile"); // The input file + QTest::newRow("reopen1") << "data/reopen1.js"; + QTest::newRow("reopen2") << "data/reopen2.js"; + QTest::newRow("error-creation") << "data/error-creation.js"; // re-uses creation DB +} + +void tst_qdeclarativesqldatabase::testQml_cleanopen() +{ + // Same as testQml, but clean connections between tests, + // making it more like the tests are running in new processes. + testQml(); + + QDeclarativeEnginePrivate::getScriptEngine(engine)->collectGarbage(); // close databases + foreach (QString dbname, QSqlDatabase::connectionNames()) { + QSqlDatabase::removeDatabase(dbname); + } +} + +void tst_qdeclarativesqldatabase::totalDatabases() +{ + QCOMPARE(QDir(dbDir()+"/Databases").entryInfoList(QDir::Files|QDir::NoDotAndDotDot).count(), total_databases_created_by_tests*2); +} + +QTEST_MAIN(tst_qdeclarativesqldatabase) + +#include "tst_qdeclarativesqldatabase.moc" diff --git a/tests/auto/declarative/sql/data/README b/tests/auto/declarative/sql/data/README deleted file mode 100644 index 7efca3a..0000000 --- a/tests/auto/declarative/sql/data/README +++ /dev/null @@ -1,3 +0,0 @@ -These tests are executed in sequence - the database persist until the end of the -testing. This is done to better exercise the persistence of the database, since -that is how it is used. diff --git a/tests/auto/declarative/sql/data/changeversion.js b/tests/auto/declarative/sql/data/changeversion.js deleted file mode 100644 index 680d7a6..0000000 --- a/tests/auto/declarative/sql/data/changeversion.js +++ /dev/null @@ -1,53 +0,0 @@ -function test() { - var r="transaction_not_finished"; - - var db = openDatabaseSync("QmlTestDB-changeversion", "", "Test database from Qt autotests", 1000000, - function(db) { - db.changeVersion("","1.0") - db.transaction(function(tx){ - tx.executeSql('CREATE TABLE Greeting(salutation TEXT, salutee TEXT)'); - }) - }); - - db.transaction(function(tx){ - tx.executeSql('INSERT INTO Greeting VALUES ("Hello", "world")'); - tx.executeSql('INSERT INTO Greeting VALUES ("Goodbye", "cruel world")'); - }); - - - db = openDatabaseSync("QmlTestDB-changeversion", "", "Test database from Qt autotests", 1000000); - - if (db.version == "1.0") - db.changeVersion("1.0","2.0",function(tx) - { - tx.executeSql('CREATE TABLE Utterance(type TEXT, phrase TEXT)') - var rs = tx.executeSql('SELECT * FROM Greeting'); - for (var i=0; i -#include "../../../shared/util.h" -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -class tst_sql : public QObject -{ - Q_OBJECT -public: - tst_sql() - { - qApp->setApplicationName("tst_sql"); - qApp->setOrganizationName("Nokia"); - qApp->setOrganizationDomain("nokia.com"); - engine = new QDeclarativeEngine; - } - - ~tst_sql() - { - delete engine; - } - -private slots: - void initTestCase(); - - void checkDatabasePath(); - - void testQml_data(); - void testQml(); - void testQml_cleanopen_data(); - void testQml_cleanopen(); - void totalDatabases(); - - void cleanupTestCase(); - -private: - QString dbDir() const; - QDeclarativeEngine *engine; -}; - -class QWebPageWithJavaScriptConsoleMessages : public QWebPage { -public: - void javaScriptConsoleMessage(const QString& message, int lineNumber, const QString& sourceID) - { - qWarning() << sourceID << ":" << lineNumber << ":" << message; - } -}; - -void removeRecursive(const QString& dirname) -{ - QDir dir(dirname); - QFileInfoList entries(dir.entryInfoList(QDir::Dirs|QDir::Files|QDir::NoDotAndDotDot)); - for (int i = 0; i < entries.count(); ++i) - if (entries[i].isDir()) - removeRecursive(entries[i].filePath()); - else - dir.remove(entries[i].fileName()); - QDir().rmdir(dirname); -} - -void tst_sql::initTestCase() -{ - removeRecursive(dbDir()); - QDir().mkpath(dbDir()); -} - -void tst_sql::cleanupTestCase() -{ - removeRecursive(dbDir()); -} - -QString tst_sql::dbDir() const -{ - static QString tmpd = QDir::tempPath()+"/tst_sql_output-" - + QDateTime::currentDateTime().toString(QLatin1String("yyyyMMddhhmmss")); - return tmpd; -} - -void tst_sql::checkDatabasePath() -{ - // Check default storage path (we can't use it since we don't want to mess with user's data) - QVERIFY(engine->offlineStoragePath().contains("tst_sql")); - QVERIFY(engine->offlineStoragePath().contains("OfflineStorage")); -} - -static const int total_databases_created_by_tests = 12; -void tst_sql::testQml_data() -{ - QTest::addColumn("jsfile"); // The input file - - // Each test should use a newly named DB to avoid inter-test dependencies - QTest::newRow("creation") << "data/creation.js"; - QTest::newRow("creation-a") << "data/creation-a.js"; - QTest::newRow("creation") << "data/creation.js"; - QTest::newRow("error-creation") << "data/error-creation.js"; // re-uses above DB - QTest::newRow("changeversion") << "data/changeversion.js"; - QTest::newRow("readonly") << "data/readonly.js"; - QTest::newRow("readonly-error") << "data/readonly-error.js"; - QTest::newRow("selection") << "data/selection.js"; - QTest::newRow("selection-bindnames") << "data/selection-bindnames.js"; - QTest::newRow("iteration") << "data/iteration.js"; - QTest::newRow("iteration-forwardonly") << "data/iteration-forwardonly.js"; - QTest::newRow("error-a") << "data/error-a.js"; - QTest::newRow("error-notransaction") << "data/error-notransaction.js"; - QTest::newRow("error-outsidetransaction") << "data/error-outsidetransaction.js"; // reuse above - QTest::newRow("reopen1") << "data/reopen1.js"; - QTest::newRow("reopen2") << "data/reopen2.js"; // re-uses above DB - - // If you add a test, you should usually use a new database in the - // test - in which case increment total_databases_created_by_tests above. -} - -/* -void tst_sql::validateAgainstWebkit() -{ - // Validates tests against WebKit (HTML5) support. - // - QFETCH(QString, jsfile); - QFETCH(QString, result); - QFETCH(int, databases); - - QFile f(jsfile); - QVERIFY(f.open(QIODevice::ReadOnly)); - QString js=f.readAll(); - - QWebPageWithJavaScriptConsoleMessages webpage; - webpage.settings()->setOfflineStoragePath(dbDir()); - webpage.settings()->setAttribute(QWebSettings::OfflineStorageDatabaseEnabled, true); - - QEXPECT_FAIL("","WebKit doesn't support openDatabaseSync yet", Continue); - QCOMPARE(webpage.mainFrame()->evaluateJavaScript(js).toString(),result); - - QTest::qWait(100); // WebKit crashes if you quit it too fast - - QWebSecurityOrigin origin = webpage.mainFrame()->securityOrigin(); - QList dbs = origin.databases(); - QCOMPARE(dbs.count(), databases); -} -*/ - -void tst_sql::testQml() -{ - // Tests QML SQL Database support with tests - // that have been validated against Webkit. - // - QFETCH(QString, jsfile); - - QString qml= - "import Qt 4.7\n" - "import \""+jsfile+"\" as JS\n" - "Text { text: JS.test() }"; - - engine->setOfflineStoragePath(dbDir()); - QDeclarativeComponent component(engine); - component.setData(qml.toUtf8(), QUrl::fromLocalFile(SRCDIR "/empty.qml")); // just a file for relative local imports - QVERIFY(!component.isError()); - QDeclarativeText *text = qobject_cast(component.create()); - QVERIFY(text != 0); - QCOMPARE(text->text(),QString("passed")); -} - -void tst_sql::testQml_cleanopen_data() -{ - QTest::addColumn("jsfile"); // The input file - QTest::newRow("reopen1") << "data/reopen1.js"; - QTest::newRow("reopen2") << "data/reopen2.js"; - QTest::newRow("error-creation") << "data/error-creation.js"; // re-uses creation DB -} - -void tst_sql::testQml_cleanopen() -{ - // Same as testQml, but clean connections between tests, - // making it more like the tests are running in new processes. - testQml(); - - QDeclarativeEnginePrivate::getScriptEngine(engine)->collectGarbage(); // close databases - foreach (QString dbname, QSqlDatabase::connectionNames()) { - QSqlDatabase::removeDatabase(dbname); - } -} - -void tst_sql::totalDatabases() -{ - QCOMPARE(QDir(dbDir()+"/Databases").entryInfoList(QDir::Files|QDir::NoDotAndDotDot).count(), total_databases_created_by_tests*2); -} - -QTEST_MAIN(tst_sql) - -#include "tst_sql.moc" -- cgit v0.12 From aad82abd84022f5401c6b79ab15d24abebf082af Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 15 Apr 2010 14:47:10 +1000 Subject: Correctly resolve, and load, IMG tags in Text element. Task-number: QTBUG-9900 Reviewed-by: Martin Jones --- src/declarative/graphicsitems/qdeclarativetext.cpp | 102 +++++++++++++++++++-- src/declarative/graphicsitems/qdeclarativetext_p.h | 7 ++ .../graphicsitems/qdeclarativetext_p_p.h | 5 +- .../qdeclarativetext/data/embeddedImagesLocal.qml | 5 + .../data/embeddedImagesLocalError.qml | 5 + .../qdeclarativetext/data/embeddedImagesRemote.qml | 5 + .../data/embeddedImagesRemoteError.qml | 5 + .../qdeclarativetext/data/http/exists.png | Bin 0 -> 2738 bytes .../qdeclarativetext/qdeclarativetext.pro | 7 ++ .../qdeclarativetext/tst_qdeclarativetext.cpp | 45 +++++++++ 10 files changed, 176 insertions(+), 10 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativetext/data/embeddedImagesLocal.qml create mode 100644 tests/auto/declarative/qdeclarativetext/data/embeddedImagesLocalError.qml create mode 100644 tests/auto/declarative/qdeclarativetext/data/embeddedImagesRemote.qml create mode 100644 tests/auto/declarative/qdeclarativetext/data/embeddedImagesRemoteError.qml create mode 100644 tests/auto/declarative/qdeclarativetext/data/http/exists.png diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 3a35dd5..3b39fa4 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -43,6 +43,7 @@ #include "private/qdeclarativetext_p_p.h" #include #include +#include #include #include @@ -55,6 +56,50 @@ QT_BEGIN_NAMESPACE +class QTextDocumentWithImageResources : public QTextDocument { + Q_OBJECT + +public: + QTextDocumentWithImageResources(QDeclarativeText *parent) : + QTextDocument(parent), + outstanding(0) + { + } + + int resourcesLoading() const { return outstanding; } + +protected: + QVariant loadResource(int type, const QUrl &name) + { + QUrl url = qmlContext(parent())->resolvedUrl(name); + + if (type == QTextDocument::ImageResource) { + QPixmap pm; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(url, &pm, 0, true, 0, 0); + if (status == QDeclarativePixmapReply::Ready) + return pm; + if (status != QDeclarativePixmapReply::Error) { + QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(parent()), url); + connect(reply, SIGNAL(finished()), this, SLOT(requestFinished())); + outstanding++; + static_cast(parent())->reloadWithResources(); + } + } + + return QTextDocument::loadResource(type,url); // The *resolved* URL + } + +private slots: + void requestFinished() + { + outstanding--; + static_cast(parent())->reloadWithResources(); + } + +private: + int outstanding; +}; + /*! \qmlclass Text QDeclarativeText \since 4.7 @@ -77,6 +122,9 @@ QT_BEGIN_NAMESPACE The \c elide property can alternatively be used to fit a single line of plain text to a set width. + Note that the \l{Supported HTML Subset} is limited, and that if IMG tags + load remote images, the text reloads (see resourcesLoading). + Text provides read-only text. For editable text, see \l TextEdit. */ @@ -259,11 +307,10 @@ void QDeclarativeText::setText(const QString &n) d->richText = d->format == RichText || (d->format == AutoText && Qt::mightBeRichText(n)); if (d->richText) { - if (!d->doc) { - d->doc = new QTextDocument(this); - d->doc->setDocumentMargin(0); + if (isComponentComplete()) { + d->ensureDoc(); + d->doc->setHtml(n); } - d->doc->setHtml(n); } d->text = n; @@ -550,11 +597,10 @@ void QDeclarativeText::setTextFormat(TextFormat format) d->updateLayout(); d->markImgDirty(); } else if (!wasRich && d->richText) { - if (!d->doc) { - d->doc = new QTextDocument(this); - d->doc->setDocumentMargin(0); + if (isComponentComplete()) { + d->ensureDoc(); + d->doc->setHtml(d->text); } - d->doc->setHtml(d->text); d->updateLayout(); d->markImgDirty(); } @@ -898,6 +944,39 @@ void QDeclarativeTextPrivate::checkImgCache() imgDirty = false; } +void QDeclarativeTextPrivate::ensureDoc() +{ + if (!doc) { + Q_Q(QDeclarativeText); + doc = new QTextDocumentWithImageResources(q); + doc->setDocumentMargin(0); + } +} + +void QDeclarativeText::reloadWithResources() +{ + Q_D(QDeclarativeText); + if (!d->richText) + return; + if (resourcesLoading()!=0) + return; + emit resourcesLoadingChanged(); + d->doc->setHtml(d->text); + d->updateLayout(); + d->markImgDirty(); +} + +/*! + \qmlproperty int Text::resourcesLoading + This property is the number of resources (images) that are being loaded asynchronously. +*/ +int QDeclarativeText::resourcesLoading() const +{ + Q_D(const QDeclarativeText); + return d->doc ? d->doc->resourcesLoading() : 0; +} + + void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { Q_D(QDeclarativeText); @@ -1011,6 +1090,10 @@ void QDeclarativeText::componentComplete() Q_D(QDeclarativeText); QDeclarativeItem::componentComplete(); if (d->dirty) { + if (d->richText) { + d->ensureDoc(); + d->doc->setHtml(d->text); + } d->updateLayout(); d->dirty = false; } @@ -1061,4 +1144,7 @@ void QDeclarativeText::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) if (!event->isAccepted()) QDeclarativeItem::mouseReleaseEvent(event); } + QT_END_NAMESPACE + +#include "qdeclarativetext.moc" diff --git a/src/declarative/graphicsitems/qdeclarativetext_p.h b/src/declarative/graphicsitems/qdeclarativetext_p.h index 871c833..fcad898 100644 --- a/src/declarative/graphicsitems/qdeclarativetext_p.h +++ b/src/declarative/graphicsitems/qdeclarativetext_p.h @@ -72,6 +72,7 @@ class Q_DECLARATIVE_EXPORT QDeclarativeText : public QDeclarativeItem Q_PROPERTY(bool wrap READ wrap WRITE setWrap NOTIFY wrapModeChanged) Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged) Q_PROPERTY(TextElideMode elide READ elideMode WRITE setElideMode NOTIFY elideModeChanged) //### elideMode? + Q_PROPERTY(int resourcesLoading READ resourcesLoading NOTIFY resourcesLoadingChanged) public: QDeclarativeText(QDeclarativeItem *parent=0); @@ -138,6 +139,8 @@ public: virtual void componentComplete(); + int resourcesLoading() const; + Q_SIGNALS: void textChanged(const QString &text); void linkActivated(const QString &link); @@ -150,6 +153,7 @@ Q_SIGNALS: void wrapModeChanged(); void textFormatChanged(TextFormat textFormat); void elideModeChanged(TextElideMode mode); + void resourcesLoadingChanged(); protected: void mousePressEvent(QGraphicsSceneMouseEvent *event); @@ -160,6 +164,9 @@ protected: private: Q_DISABLE_COPY(QDeclarativeText) Q_DECLARE_PRIVATE_D(QGraphicsItem::d_ptr.data(), QDeclarativeText) + + friend class QTextDocumentWithImageResources; + void reloadWithResources(); }; QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qdeclarativetext_p_p.h b/src/declarative/graphicsitems/qdeclarativetext_p_p.h index cc5a9f2..332f99e 100644 --- a/src/declarative/graphicsitems/qdeclarativetext_p_p.h +++ b/src/declarative/graphicsitems/qdeclarativetext_p_p.h @@ -63,7 +63,7 @@ QT_BEGIN_NAMESPACE class QTextLayout; -class QTextDocument; +class QTextDocumentWithImageResources; class QDeclarativeTextPrivate : public QDeclarativeItemPrivate { @@ -84,6 +84,7 @@ public: ~QDeclarativeTextPrivate(); + void ensureDoc(); void updateSize(); void updateLayout(); void markImgDirty() { @@ -118,7 +119,7 @@ public: bool richText:1; bool singleline:1; bool cache:1; - QTextDocument *doc; + QTextDocumentWithImageResources *doc; QTextLayout layout; QSize cachedLayoutSize; QDeclarativeText::TextFormat format; diff --git a/tests/auto/declarative/qdeclarativetext/data/embeddedImagesLocal.qml b/tests/auto/declarative/qdeclarativetext/data/embeddedImagesLocal.qml new file mode 100644 index 0000000..5aeea56 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/embeddedImagesLocal.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +Text { + text: "" +} diff --git a/tests/auto/declarative/qdeclarativetext/data/embeddedImagesLocalError.qml b/tests/auto/declarative/qdeclarativetext/data/embeddedImagesLocalError.qml new file mode 100644 index 0000000..17bb21c --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/embeddedImagesLocalError.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +Text { + text: "" +} diff --git a/tests/auto/declarative/qdeclarativetext/data/embeddedImagesRemote.qml b/tests/auto/declarative/qdeclarativetext/data/embeddedImagesRemote.qml new file mode 100644 index 0000000..53b0266 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/embeddedImagesRemote.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +Text { + text: "" +} diff --git a/tests/auto/declarative/qdeclarativetext/data/embeddedImagesRemoteError.qml b/tests/auto/declarative/qdeclarativetext/data/embeddedImagesRemoteError.qml new file mode 100644 index 0000000..48c7a95 --- /dev/null +++ b/tests/auto/declarative/qdeclarativetext/data/embeddedImagesRemoteError.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +Text { + text: "" +} diff --git a/tests/auto/declarative/qdeclarativetext/data/http/exists.png b/tests/auto/declarative/qdeclarativetext/data/http/exists.png new file mode 100644 index 0000000..399bd0b Binary files /dev/null and b/tests/auto/declarative/qdeclarativetext/data/http/exists.png differ diff --git a/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro b/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro index 73c05b5..e70443e 100644 --- a/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro +++ b/tests/auto/declarative/qdeclarativetext/qdeclarativetext.pro @@ -1,8 +1,15 @@ load(qttest_p4) contains(QT_CONFIG,declarative): QT += declarative gui +QT += network macx:CONFIG -= app_bundle SOURCES += tst_qdeclarativetext.cpp +INCLUDEPATH += ../shared/ +HEADERS += ../shared/testhttpserver.h +SOURCES += ../shared/testhttpserver.cpp + +DEFINES += SRCDIR=\\\"$$PWD\\\" + CONFIG += parallel_test diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp index 6637415..53640d0 100644 --- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp @@ -48,6 +48,9 @@ #include #include +#include "../../../shared/util.h" +#include "testhttpserver.h" + class tst_qdeclarativetext : public QObject { @@ -62,6 +65,9 @@ private slots: void elide(); void textFormat(); + void embeddedImages_data(); + void embeddedImages(); + // ### these tests may be trivial void horizontalAlignment(); void verticalAlignment(); @@ -859,6 +865,45 @@ void tst_qdeclarativetext::clickLink() } } +void tst_qdeclarativetext::embeddedImages_data() +{ + QTest::addColumn("qmlfile"); + QTest::addColumn("error"); + QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocal.qml") << ""; + QTest::newRow("local-error") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocalError.qml") + << "\"Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/http/notexists.png").toString() + "\" "; + QTest::newRow("remote") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemote.qml") << ""; + QTest::newRow("remote-error") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemoteError.qml") + << "\"Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found\" "; +} + +void tst_qdeclarativetext::embeddedImages() +{ + // Tests QTBUG-9900 + + QFETCH(QUrl, qmlfile); + QFETCH(QString, error); + + TestHTTPServer server(14453); + server.serveDirectory(SRCDIR "/data/http"); + + if (!error.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, error.toLatin1()); + + QDeclarativeComponent textComponent(&engine, qmlfile); + QDeclarativeText *textObject = qobject_cast(textComponent.create()); + + QVERIFY(textObject != 0); + + QTRY_COMPARE(textObject->resourcesLoading(), 0); + + if (error.isEmpty()) { + QPixmap pm(SRCDIR "/data/http/exists.png"); + QCOMPARE(textObject->width(), double(pm.width())); + QCOMPARE(textObject->height(), double(pm.height())); + } +} + QTEST_MAIN(tst_qdeclarativetext) #include "tst_qdeclarativetext.moc" -- cgit v0.12 From f6f030cfff44f4625fd7655f3401651c0ecc760b Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 15 Apr 2010 14:48:58 +1000 Subject: Remove unused parameter --- src/declarative/qml/qdeclarativecomponent.cpp | 2 +- src/declarative/qml/qdeclarativecomponent_p.h | 4 ++-- src/declarative/qml/qdeclarativeengine.cpp | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 1903006..7744b75 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -671,7 +671,7 @@ QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *ctxt, QDe return rv; } -void QDeclarativeComponentPrivate::beginDeferred(QDeclarativeContextData *, QDeclarativeEnginePrivate *enginePriv, +void QDeclarativeComponentPrivate::beginDeferred(QDeclarativeEnginePrivate *enginePriv, QObject *object, ConstructionState *state) { bool isRoot = !enginePriv->inBeginCreate; diff --git a/src/declarative/qml/qdeclarativecomponent_p.h b/src/declarative/qml/qdeclarativecomponent_p.h index dfe327b..dfd0fc3 100644 --- a/src/declarative/qml/qdeclarativecomponent_p.h +++ b/src/declarative/qml/qdeclarativecomponent_p.h @@ -111,8 +111,8 @@ public: static QObject *begin(QDeclarativeContextData *ctxt, QDeclarativeEnginePrivate *enginePriv, QDeclarativeCompiledData *component, int start, int count, ConstructionState *state, const QBitField &bindings = QBitField()); - static void beginDeferred(QDeclarativeContextData *ctxt, QDeclarativeEnginePrivate *enginePriv, - QObject *object, ConstructionState *state); + static void beginDeferred(QDeclarativeEnginePrivate *enginePriv, QObject *object, + ConstructionState *state); static void complete(QDeclarativeEnginePrivate *enginePriv, ConstructionState *state); QDeclarativeEngine *engine; diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index ae0929b..a478bf5 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -767,7 +767,7 @@ void qmlExecuteDeferred(QObject *object) QDeclarativeEnginePrivate *ep = QDeclarativeEnginePrivate::get(data->context->engine); QDeclarativeComponentPrivate::ConstructionState state; - QDeclarativeComponentPrivate::beginDeferred(data->context, ep, object, &state); + QDeclarativeComponentPrivate::beginDeferred(ep, object, &state); data->deferredComponent->release(); data->deferredComponent = 0; -- cgit v0.12 From 6362d17d5551749618f5975e050c54fca31c408f Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 15 Apr 2010 14:54:01 +1000 Subject: Comments --- src/declarative/qml/qdeclarativedata_p.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/declarative/qml/qdeclarativedata_p.h b/src/declarative/qml/qdeclarativedata_p.h index 3676d8d..2ddd7e5 100644 --- a/src/declarative/qml/qdeclarativedata_p.h +++ b/src/declarative/qml/qdeclarativedata_p.h @@ -100,7 +100,9 @@ public: quint32 explicitIndestructibleSet:1; quint32 dummy:28; - QDeclarativeContextData *context; + // The context that created the C++ object + QDeclarativeContextData *context; + // The outermost context in which this object lives QDeclarativeContextData *outerContext; QDeclarativeAbstractBinding *bindings; -- cgit v0.12 From efde86d38896c13dc8d447e33e80baec5b6cdc1d Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 15 Apr 2010 14:57:06 +1000 Subject: Doc improvements --- doc/src/declarative/advtutorial.qdoc | 33 +++++++++++++++++++------------- doc/src/images/declarative-samegame.png | Bin 0 -> 124904 bytes 2 files changed, 20 insertions(+), 13 deletions(-) create mode 100644 doc/src/images/declarative-samegame.png diff --git a/doc/src/declarative/advtutorial.qdoc b/doc/src/declarative/advtutorial.qdoc index 3a70eee..751bf00 100644 --- a/doc/src/declarative/advtutorial.qdoc +++ b/doc/src/declarative/advtutorial.qdoc @@ -46,27 +46,34 @@ \nextpage QML Advanced Tutorial 1 - Creating the Game Canvas and Blocks This tutorial walks step-by-step through the creation of a full application using QML. +It assumes that you already know the basics of QML (for example, from reading the +\l{QML Tutorial}{simple tutorial}). -It is assumed that you already know the basics of QML (for example, from reading the \l{QML Tutorial}{simple tutorial}) and this -tutorial focuses on using that knowledge to produce a complete and functioning application. +In this tutorial we write a game, \e {Same Game}, based on the Same Game application +included in the declarative \c demos directory, which looks like this: -The tutorial involves a significant amount of JavaScript to implement the game logic. An understanding of JavaScript is helpful to understand parts of this tutorial, but if you don't understand JavaScript you can still get a feel for how you can integrate backend logic to create and control QML elements. From the QML perspective, there is little difference between integrating QML with backend logic written in C++ and backend logic written in JavaScript. +\image declarative-samegame.png -In this tutorial we recreate, step by step, a version of the Same Game demo in $QTDIR/demos/declarative/samegame.qml. -The results of the individual steps are in the $QTDIR/examples/declarative/tutorials/samegame directory. +We will cover concepts for producing a fully functioning application, including +JavaScript integration, using QML \l States and \l {Behavior}{Behaviors} to +manage components and enhance your interface, and storing persistent application data. + +An understanding of JavaScript is helpful to understand parts of this tutorial, but if you don't +know JavaScript you can still get a feel for how you can integrate backend logic to create and +control QML elements. -The Same Game demo has been extended since this tutorial was written. This tutorial only covers the version in -the $QTDIR/examples/declarative/tutorials/samegame directory. However once you have completed the tutorial you should be able -to understand the extensions in the most recent Same Game demo, and even extend it yourself. Tutorial chapters: -\list -\o \l {QML Advanced Tutorial 1 - Creating the Game Canvas and Blocks} -\o \l {QML Advanced Tutorial 2 - Populating the Game Canvas} -\o \l {QML Advanced Tutorial 3 - Implementing the Game Logic} -\o \l {QML Advanced Tutorial 4 - Finishing Touches} +\list 1 +\o \l {QML Advanced Tutorial 1 - Creating the Game Canvas and Blocks}{Creating the Game Canvas and Blocks} +\o \l {QML Advanced Tutorial 2 - Populating the Game Canvas}{Populating the Game Canvas}} +\o \l {QML Advanced Tutorial 3 - Implementing the Game Logic}{Implementing the Game Logic} +\o \l {QML Advanced Tutorial 4 - Finishing Touches}{Finishing Touches} \endlist + +All the code in this tutorial can be found in the $QTDIR/examples/declarative/tutorials/samegame +directory. */ /*! diff --git a/doc/src/images/declarative-samegame.png b/doc/src/images/declarative-samegame.png new file mode 100644 index 0000000..2232df2 Binary files /dev/null and b/doc/src/images/declarative-samegame.png differ -- cgit v0.12 From 6dba05f9334a82c849806293ff0448c65c33a5d2 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Thu, 15 Apr 2010 15:00:09 +1000 Subject: Rename section so that it's not linked to by references to "JavaScript" --- doc/src/declarative/codingconventions.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/declarative/codingconventions.qdoc b/doc/src/declarative/codingconventions.qdoc index e1e7871..7ae5cbd 100644 --- a/doc/src/declarative/codingconventions.qdoc +++ b/doc/src/declarative/codingconventions.qdoc @@ -101,7 +101,7 @@ we will write this: \snippet doc/src/snippets/declarative/codingconventions/lists.qml 1 -\section1 Javascript +\section1 Javascript code If the script is a single expression, we recommend writing it inline: -- cgit v0.12 From 62e52a19f1c7ac81a36f394e43f916c3c8933e8f Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 15 Apr 2010 15:10:44 +1000 Subject: Visual test updates. --- .../qmlvisual/Package_Views/packageviews.qml | 5 +- .../data/colorAnimation-visual.0.png | Bin 0 -> 627 bytes .../data/colorAnimation-visual.1.png | Bin 0 -> 626 bytes .../data/colorAnimation-visual.2.png | Bin 0 -> 625 bytes .../colorAnimation/data/colorAnimation-visual.qml | 14 +- .../colorAnimation/data/colorAnimation.0.png | Bin 627 -> 0 bytes .../colorAnimation/data/colorAnimation.1.png | Bin 626 -> 0 bytes .../colorAnimation/data/colorAnimation.2.png | Bin 625 -> 0 bytes .../data/propertyAction-visual.0.png | Bin 0 -> 1418 bytes .../data/propertyAction-visual.1.png | Bin 0 -> 1430 bytes .../data/propertyAction-visual.2.png | Bin 0 -> 1431 bytes .../propertyAction/data/propertyAction-visual.qml | 8 +- .../propertyAction/data/propertyAction.0.png | Bin 1418 -> 0 bytes .../propertyAction/data/propertyAction.1.png | Bin 1430 -> 0 bytes .../propertyAction/data/propertyAction.2.png | Bin 1431 -> 0 bytes .../data/animated-smooth.1.png | Bin 98912 -> 98927 bytes .../data/animated-smooth.qml | 110 +- .../qdeclarativeborderimage/data/borders.1.png | Bin 23029 -> 0 bytes .../qdeclarativeborderimage/data/borders.2.png | Bin 23029 -> 0 bytes .../qdeclarativeborderimage/data/borders.3.png | Bin 23029 -> 0 bytes .../qdeclarativeborderimage/data/borders.4.png | Bin 23029 -> 0 bytes .../qdeclarativeborderimage/data/borders.qml | 1350 +------------------- .../qmlvisual/qdeclarativeparticles/particles.qml | 1 + .../qdeclarativepositioners/data/repeater.qml | 339 ----- .../qdeclarativepositioners/data/usingRepeater.qml | 339 +++++ .../qmlvisual/qdeclarativepositioners/repeater.qml | 15 - .../qdeclarativepositioners/usingRepeater.qml | 15 + tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp | 25 +- tools/qml/qdeclarativetester.cpp | 18 + 29 files changed, 463 insertions(+), 1776 deletions(-) create mode 100644 tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation-visual.0.png create mode 100644 tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation-visual.1.png create mode 100644 tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation-visual.2.png delete mode 100644 tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation.0.png delete mode 100644 tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation.1.png delete mode 100644 tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation.2.png create mode 100644 tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction-visual.0.png create mode 100644 tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction-visual.1.png create mode 100644 tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction-visual.2.png delete mode 100644 tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction.0.png delete mode 100644 tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction.1.png delete mode 100644 tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction.2.png delete mode 100644 tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/borders.1.png delete mode 100644 tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/borders.2.png delete mode 100644 tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/borders.3.png delete mode 100644 tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/borders.4.png delete mode 100644 tests/auto/declarative/qmlvisual/qdeclarativepositioners/data/repeater.qml create mode 100644 tests/auto/declarative/qmlvisual/qdeclarativepositioners/data/usingRepeater.qml delete mode 100644 tests/auto/declarative/qmlvisual/qdeclarativepositioners/repeater.qml create mode 100644 tests/auto/declarative/qmlvisual/qdeclarativepositioners/usingRepeater.qml diff --git a/tests/auto/declarative/qmlvisual/Package_Views/packageviews.qml b/tests/auto/declarative/qmlvisual/Package_Views/packageviews.qml index f6c033f..7ccba10 100644 --- a/tests/auto/declarative/qmlvisual/Package_Views/packageviews.qml +++ b/tests/auto/declarative/qmlvisual/Package_Views/packageviews.qml @@ -63,8 +63,9 @@ Rectangle { Transition { from: "*"; to: "*" SequentialAnimation { - ParentAction{} - NumberAnimation { properties: "x,y,width"; easing.type: "InOutQuad" } + ParentAnimation{ + NumberAnimation { properties: "x,y,width"; easing.type: "InOutQuad" } + } } } ] diff --git a/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation-visual.0.png b/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation-visual.0.png new file mode 100644 index 0000000..e6ea16d Binary files /dev/null and b/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation-visual.0.png differ diff --git a/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation-visual.1.png b/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation-visual.1.png new file mode 100644 index 0000000..b75ba61 Binary files /dev/null and b/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation-visual.1.png differ diff --git a/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation-visual.2.png b/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation-visual.2.png new file mode 100644 index 0000000..4320f6f Binary files /dev/null and b/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation-visual.2.png differ diff --git a/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation-visual.qml b/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation-visual.qml index 4d0959a..4ab94f3 100644 --- a/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation-visual.qml +++ b/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation-visual.qml @@ -258,7 +258,7 @@ VisualTest { } Frame { msec: 960 - image: "colorAnimation.0.png" + image: "colorAnimation-visual.0.png" } Frame { msec: 976 @@ -270,7 +270,7 @@ VisualTest { } Frame { msec: 1008 - hash: "243dbffcf416926242bbcb7348974c4c" + hash: "e0f53c5605116a30d9bf3c031c63d958" } Frame { msec: 1024 @@ -370,7 +370,7 @@ VisualTest { } Frame { msec: 1408 - hash: "7178bfe86fd2fd513218b33760460f8d" + hash: "45770fe0d61c485c13992d0f98b2a3ba" } Frame { msec: 1424 @@ -470,7 +470,7 @@ VisualTest { } Frame { msec: 1808 - hash: "8593a81be812edf54ec94da8ae9c1314" + hash: "a2fa71b4147372175774250501b6625e" } Frame { msec: 1824 @@ -498,7 +498,7 @@ VisualTest { } Frame { msec: 1920 - image: "colorAnimation.1.png" + image: "colorAnimation-visual.1.png" } Frame { msec: 1936 @@ -570,7 +570,7 @@ VisualTest { } Frame { msec: 2208 - hash: "e5dc5450604a491cc24a0dcf5c278b58" + hash: "10d46d2862e333e5136b1c046dabb33b" } Frame { msec: 2224 @@ -738,7 +738,7 @@ VisualTest { } Frame { msec: 2880 - image: "colorAnimation.2.png" + image: "colorAnimation-visual.2.png" } Frame { msec: 2896 diff --git a/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation.0.png b/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation.0.png deleted file mode 100644 index e6ea16d..0000000 Binary files a/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation.0.png and /dev/null differ diff --git a/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation.1.png b/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation.1.png deleted file mode 100644 index b75ba61..0000000 Binary files a/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation.1.png and /dev/null differ diff --git a/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation.2.png b/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation.2.png deleted file mode 100644 index 4320f6f..0000000 Binary files a/tests/auto/declarative/qmlvisual/animation/colorAnimation/data/colorAnimation.2.png and /dev/null differ diff --git a/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction-visual.0.png b/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction-visual.0.png new file mode 100644 index 0000000..64d6b06 Binary files /dev/null and b/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction-visual.0.png differ diff --git a/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction-visual.1.png b/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction-visual.1.png new file mode 100644 index 0000000..f7fce15 Binary files /dev/null and b/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction-visual.1.png differ diff --git a/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction-visual.2.png b/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction-visual.2.png new file mode 100644 index 0000000..3080df5 Binary files /dev/null and b/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction-visual.2.png differ diff --git a/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction-visual.qml b/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction-visual.qml index 7c8c233..0a9057e 100644 --- a/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction-visual.qml +++ b/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction-visual.qml @@ -242,7 +242,7 @@ VisualTest { } Frame { msec: 960 - image: "propertyAction.0.png" + image: "propertyAction-visual.0.png" } Frame { msec: 976 @@ -490,7 +490,7 @@ VisualTest { } Frame { msec: 1920 - image: "propertyAction.1.png" + image: "propertyAction-visual.1.png" } Frame { msec: 1936 @@ -738,7 +738,7 @@ VisualTest { } Frame { msec: 2880 - image: "propertyAction.2.png" + image: "propertyAction-visual.2.png" } Frame { msec: 2896 @@ -810,7 +810,7 @@ VisualTest { } Frame { msec: 3168 - hash: "dcc79277fdb8966e5a3f2ed1b2fc4292" + hash: "38b7e5894cf49a19ac055264d6447b9f" } Frame { msec: 3184 diff --git a/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction.0.png b/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction.0.png deleted file mode 100644 index 64d6b06..0000000 Binary files a/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction.0.png and /dev/null differ diff --git a/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction.1.png b/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction.1.png deleted file mode 100644 index f7fce15..0000000 Binary files a/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction.1.png and /dev/null differ diff --git a/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction.2.png b/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction.2.png deleted file mode 100644 index 3080df5..0000000 Binary files a/tests/auto/declarative/qmlvisual/animation/propertyAction/data/propertyAction.2.png and /dev/null differ diff --git a/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/animated-smooth.1.png b/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/animated-smooth.1.png index 1f960e5..4366d53 100644 Binary files a/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/animated-smooth.1.png and b/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/animated-smooth.1.png differ diff --git a/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/animated-smooth.qml b/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/animated-smooth.qml index 043f5e2..c6df3c4 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/animated-smooth.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/animated-smooth.qml @@ -130,7 +130,7 @@ VisualTest { } Frame { msec: 512 - hash: "37c3f25e5cfdb48d7e3ab0cf8ffb9154" + hash: "0f347763f25350ebb62dda1536372b45" } Frame { msec: 528 @@ -186,7 +186,7 @@ VisualTest { } Frame { msec: 736 - hash: "902683d72f789399e9d99d1cea1bf177" + hash: "74af3457583fbaf73f14556aeccc8403" } Frame { msec: 752 @@ -210,7 +210,7 @@ VisualTest { } Frame { msec: 832 - hash: "a15f19f374bbfb6a922b69d080a91eaa" + hash: "d2ed2cf3a12e41bac299399cc35abe6a" } Frame { msec: 848 @@ -294,7 +294,7 @@ VisualTest { } Frame { msec: 1168 - hash: "2192094410e2d7c8d9d4aa5f8deacff5" + hash: "85ef33fcb3f91e4fc20391bf94455984" } Frame { msec: 1184 @@ -302,7 +302,7 @@ VisualTest { } Frame { msec: 1200 - hash: "92176cce4836dcae4dfca94e49b041a8" + hash: "07acba64dc608439a8a54fcb080379e8" } Frame { msec: 1216 @@ -310,7 +310,7 @@ VisualTest { } Frame { msec: 1232 - hash: "42be5d26afb9f066dd27cc9fbaf6ce20" + hash: "1f964c6c9bebdc9945dc69a6095400f7" } Frame { msec: 1248 @@ -318,7 +318,7 @@ VisualTest { } Frame { msec: 1264 - hash: "7f9999a9c87af43b9703323efab31770" + hash: "2084ccc60ddd493399c128717816d33b" } Frame { msec: 1280 @@ -346,7 +346,7 @@ VisualTest { } Frame { msec: 1376 - hash: "49a1df977b0494c7c72ca0b65c394e13" + hash: "45d891d804609ebbe1d5ac3f826d0c17" } Frame { msec: 1392 @@ -406,7 +406,7 @@ VisualTest { } Frame { msec: 1616 - hash: "4520003d4b221a3de6834b2729b3026d" + hash: "880640372bf584955627f6835f24be13" } Frame { msec: 1632 @@ -414,7 +414,7 @@ VisualTest { } Frame { msec: 1648 - hash: "83d49474db15d5779923972ff5f55917" + hash: "705d9c8de05c859a42769f73761c6a63" } Frame { msec: 1664 @@ -426,7 +426,7 @@ VisualTest { } Frame { msec: 1696 - hash: "d8e398a1ce9ca45c19951e93bd5c932a" + hash: "64cd225202ed6c91b02c368a9160a656" } Frame { msec: 1712 @@ -438,7 +438,7 @@ VisualTest { } Frame { msec: 1744 - hash: "fc913807eb1069d611495fbd5d43ee3d" + hash: "fe899138116774df4c4441687e3019c5" } Frame { msec: 1760 @@ -450,7 +450,7 @@ VisualTest { } Frame { msec: 1792 - hash: "e3a2b5c7247acfc1b30825233fbfd56b" + hash: "c3ea530de646612f9203c5800cad884b" } Frame { msec: 1808 @@ -490,7 +490,7 @@ VisualTest { } Frame { msec: 1952 - hash: "3991bc7760b7981d80665e3a7654c9f4" + hash: "b980703c1d0018937e83a8ba8862469e" } Frame { msec: 1968 @@ -502,15 +502,15 @@ VisualTest { } Frame { msec: 2000 - hash: "723f87da7e5b002a2e9b0bcbc81f9458" + hash: "ee297a2d68c9e58157d9bf189d353713" } Frame { msec: 2016 - hash: "6b8ded0d9386a3fff0601a100c513080" + hash: "00f3c9b8b37cb104cf2a7701639bc61f" } Frame { msec: 2032 - hash: "f976cd5046ef5391536859e63db905bd" + hash: "ee297a2d68c9e58157d9bf189d353713" } Frame { msec: 2048 @@ -562,7 +562,7 @@ VisualTest { } Frame { msec: 2240 - hash: "e3a2b5c7247acfc1b30825233fbfd56b" + hash: "c3ea530de646612f9203c5800cad884b" } Frame { msec: 2256 @@ -598,7 +598,7 @@ VisualTest { } Frame { msec: 2384 - hash: "83d49474db15d5779923972ff5f55917" + hash: "705d9c8de05c859a42769f73761c6a63" } Frame { msec: 2400 @@ -606,7 +606,7 @@ VisualTest { } Frame { msec: 2416 - hash: "4520003d4b221a3de6834b2729b3026d" + hash: "880640372bf584955627f6835f24be13" } Frame { msec: 2432 @@ -666,7 +666,7 @@ VisualTest { } Frame { msec: 2656 - hash: "a676f45d946aeb9fa577c0e862735b01" + hash: "45d891d804609ebbe1d5ac3f826d0c17" } Frame { msec: 2672 @@ -702,7 +702,7 @@ VisualTest { } Frame { msec: 2800 - hash: "42be5d26afb9f066dd27cc9fbaf6ce20" + hash: "1f964c6c9bebdc9945dc69a6095400f7" } Frame { msec: 2816 @@ -710,7 +710,7 @@ VisualTest { } Frame { msec: 2832 - hash: "92176cce4836dcae4dfca94e49b041a8" + hash: "07acba64dc608439a8a54fcb080379e8" } Frame { msec: 2848 @@ -802,7 +802,7 @@ VisualTest { } Frame { msec: 3200 - hash: "a15f19f374bbfb6a922b69d080a91eaa" + hash: "d2ed2cf3a12e41bac299399cc35abe6a" } Frame { msec: 3216 @@ -826,7 +826,7 @@ VisualTest { } Frame { msec: 3296 - hash: "902683d72f789399e9d99d1cea1bf177" + hash: "74af3457583fbaf73f14556aeccc8403" } Frame { msec: 3312 @@ -854,7 +854,7 @@ VisualTest { } Frame { msec: 3408 - hash: "f602e3eda1889d1a7e49560f0dfb5d4c" + hash: "89c159ef00d273ecfe61332e1bf7244d" } Frame { msec: 3424 @@ -862,7 +862,7 @@ VisualTest { } Frame { msec: 3440 - hash: "c8312ede0998636a6bd6451d13636577" + hash: "61c16009b65a55bffb63e27727e1615e" } Frame { msec: 3456 @@ -950,7 +950,7 @@ VisualTest { } Frame { msec: 3792 - hash: "8419b295f67cae133760da79dfc26505" + hash: "f22a47b846cfee96ebdf39bbce2e6d51" } Frame { msec: 3808 @@ -970,7 +970,7 @@ VisualTest { } Frame { msec: 3872 - hash: "d56ba74d38c1889a278929d1c1b7f17a" + hash: "ed9f2ca797894612600bc4b7fbaecb84" } Frame { msec: 3888 @@ -1130,7 +1130,7 @@ VisualTest { } Frame { msec: 4512 - hash: "37c3f25e5cfdb48d7e3ab0cf8ffb9154" + hash: "0f347763f25350ebb62dda1536372b45" } Frame { msec: 4528 @@ -1186,7 +1186,7 @@ VisualTest { } Frame { msec: 4736 - hash: "902683d72f789399e9d99d1cea1bf177" + hash: "74af3457583fbaf73f14556aeccc8403" } Frame { msec: 4752 @@ -1210,7 +1210,7 @@ VisualTest { } Frame { msec: 4832 - hash: "a15f19f374bbfb6a922b69d080a91eaa" + hash: "d2ed2cf3a12e41bac299399cc35abe6a" } Frame { msec: 4848 @@ -1294,7 +1294,7 @@ VisualTest { } Frame { msec: 5168 - hash: "2192094410e2d7c8d9d4aa5f8deacff5" + hash: "85ef33fcb3f91e4fc20391bf94455984" } Frame { msec: 5184 @@ -1302,7 +1302,7 @@ VisualTest { } Frame { msec: 5200 - hash: "92176cce4836dcae4dfca94e49b041a8" + hash: "07acba64dc608439a8a54fcb080379e8" } Frame { msec: 5216 @@ -1310,7 +1310,7 @@ VisualTest { } Frame { msec: 5232 - hash: "42be5d26afb9f066dd27cc9fbaf6ce20" + hash: "1f964c6c9bebdc9945dc69a6095400f7" } Frame { msec: 5248 @@ -1318,7 +1318,7 @@ VisualTest { } Frame { msec: 5264 - hash: "7f9999a9c87af43b9703323efab31770" + hash: "2084ccc60ddd493399c128717816d33b" } Frame { msec: 5280 @@ -1346,7 +1346,7 @@ VisualTest { } Frame { msec: 5376 - hash: "49a1df977b0494c7c72ca0b65c394e13" + hash: "45d891d804609ebbe1d5ac3f826d0c17" } Frame { msec: 5392 @@ -1406,7 +1406,7 @@ VisualTest { } Frame { msec: 5616 - hash: "4520003d4b221a3de6834b2729b3026d" + hash: "880640372bf584955627f6835f24be13" } Frame { msec: 5632 @@ -1414,7 +1414,7 @@ VisualTest { } Frame { msec: 5648 - hash: "83d49474db15d5779923972ff5f55917" + hash: "705d9c8de05c859a42769f73761c6a63" } Frame { msec: 5664 @@ -1426,7 +1426,7 @@ VisualTest { } Frame { msec: 5696 - hash: "d8e398a1ce9ca45c19951e93bd5c932a" + hash: "64cd225202ed6c91b02c368a9160a656" } Frame { msec: 5712 @@ -1438,7 +1438,7 @@ VisualTest { } Frame { msec: 5744 - hash: "fc913807eb1069d611495fbd5d43ee3d" + hash: "fe899138116774df4c4441687e3019c5" } Frame { msec: 5760 @@ -1450,7 +1450,7 @@ VisualTest { } Frame { msec: 5792 - hash: "e3a2b5c7247acfc1b30825233fbfd56b" + hash: "c3ea530de646612f9203c5800cad884b" } Frame { msec: 5808 @@ -1482,7 +1482,7 @@ VisualTest { } Frame { msec: 5920 - hash: "ec7e1190dd4fe122545e6ce6c8740500" + hash: "3b7b83e97d17440b42e6ef4b962076d8" } Frame { msec: 5936 @@ -1490,7 +1490,7 @@ VisualTest { } Frame { msec: 5952 - hash: "3991bc7760b7981d80665e3a7654c9f4" + hash: "b980703c1d0018937e83a8ba8862469e" } Frame { msec: 5968 @@ -1502,15 +1502,15 @@ VisualTest { } Frame { msec: 6000 - hash: "723f87da7e5b002a2e9b0bcbc81f9458" + hash: "ee297a2d68c9e58157d9bf189d353713" } Frame { msec: 6016 - hash: "6b8ded0d9386a3fff0601a100c513080" + hash: "00f3c9b8b37cb104cf2a7701639bc61f" } Frame { msec: 6032 - hash: "f976cd5046ef5391536859e63db905bd" + hash: "ee297a2d68c9e58157d9bf189d353713" } Frame { msec: 6048 @@ -1562,7 +1562,7 @@ VisualTest { } Frame { msec: 6240 - hash: "e3a2b5c7247acfc1b30825233fbfd56b" + hash: "c3ea530de646612f9203c5800cad884b" } Frame { msec: 6256 @@ -1598,7 +1598,7 @@ VisualTest { } Frame { msec: 6384 - hash: "83d49474db15d5779923972ff5f55917" + hash: "705d9c8de05c859a42769f73761c6a63" } Frame { msec: 6400 @@ -1606,7 +1606,7 @@ VisualTest { } Frame { msec: 6416 - hash: "4520003d4b221a3de6834b2729b3026d" + hash: "880640372bf584955627f6835f24be13" } Frame { msec: 6432 @@ -1666,7 +1666,7 @@ VisualTest { } Frame { msec: 6656 - hash: "a676f45d946aeb9fa577c0e862735b01" + hash: "45d891d804609ebbe1d5ac3f826d0c17" } Frame { msec: 6672 @@ -1702,7 +1702,7 @@ VisualTest { } Frame { msec: 6800 - hash: "42be5d26afb9f066dd27cc9fbaf6ce20" + hash: "1f964c6c9bebdc9945dc69a6095400f7" } Frame { msec: 6816 @@ -1710,7 +1710,7 @@ VisualTest { } Frame { msec: 6832 - hash: "92176cce4836dcae4dfca94e49b041a8" + hash: "07acba64dc608439a8a54fcb080379e8" } Frame { msec: 6848 @@ -1779,7 +1779,7 @@ VisualTest { Key { type: 6 key: 16777249 - modifiers: 67108864 + modifiers: 0 text: "" autorep: false count: 1 @@ -1810,7 +1810,7 @@ VisualTest { } Frame { msec: 7200 - hash: "a15f19f374bbfb6a922b69d080a91eaa" + hash: "d2ed2cf3a12e41bac299399cc35abe6a" } Frame { msec: 7216 diff --git a/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/borders.1.png b/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/borders.1.png deleted file mode 100644 index 80cbd26..0000000 Binary files a/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/borders.1.png and /dev/null differ diff --git a/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/borders.2.png b/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/borders.2.png deleted file mode 100644 index 80cbd26..0000000 Binary files a/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/borders.2.png and /dev/null differ diff --git a/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/borders.3.png b/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/borders.3.png deleted file mode 100644 index 80cbd26..0000000 Binary files a/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/borders.3.png and /dev/null differ diff --git a/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/borders.4.png b/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/borders.4.png deleted file mode 100644 index 80cbd26..0000000 Binary files a/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/borders.4.png and /dev/null differ diff --git a/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/borders.qml b/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/borders.qml index 16cd5e9..1403d35 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/borders.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativeborderimage/data/borders.qml @@ -6,1354 +6,6 @@ VisualTest { } Frame { msec: 16 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 32 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 48 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 64 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 80 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 96 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 112 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 128 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 144 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 160 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 176 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 192 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 208 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 224 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 240 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 256 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 272 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 288 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 304 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 320 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 336 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 352 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 368 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 384 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 400 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 416 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 432 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 448 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 464 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 480 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 496 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 512 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 528 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 544 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 560 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 576 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 592 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 608 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 624 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 640 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 656 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 672 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 688 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 704 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 720 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 736 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 752 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 768 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 784 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 800 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 816 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 832 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 848 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 864 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 880 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 896 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 912 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 928 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 944 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 960 - image: "borders.0.png" - } - Frame { - msec: 976 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 992 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1008 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1024 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1040 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1056 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1072 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1088 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1104 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1120 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1136 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1152 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1168 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1184 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1200 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1216 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1232 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1248 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1264 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1280 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1296 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1312 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1328 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1344 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1360 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1376 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1392 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1408 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1424 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1440 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1456 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1472 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1488 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1504 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1520 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1536 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1552 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1568 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1584 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1600 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1616 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1632 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1648 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1664 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1680 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1696 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1712 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1728 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1744 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1760 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1776 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1792 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1808 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1824 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1840 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1856 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1872 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1888 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1904 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1920 - image: "borders.1.png" - } - Frame { - msec: 1936 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1952 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1968 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 1984 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2000 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2016 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2032 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2048 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2064 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2080 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2096 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2112 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2128 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2144 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2160 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2176 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2192 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2208 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2224 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2240 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2256 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2272 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2288 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2304 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2320 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2336 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2352 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2368 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2384 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2400 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2416 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2432 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2448 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2464 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2480 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2496 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2512 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2528 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2544 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2560 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2576 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2592 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2608 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2624 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2640 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2656 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2672 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2688 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2704 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2720 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2736 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2752 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2768 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2784 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2800 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2816 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2832 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2848 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2864 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2880 - image: "borders.2.png" - } - Frame { - msec: 2896 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2912 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2928 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2944 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2960 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2976 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 2992 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3008 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3024 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3040 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3056 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3072 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3088 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3104 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3120 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3136 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3152 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3168 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3184 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3200 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3216 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3232 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3248 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3264 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3280 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3296 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3312 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3328 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3344 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3360 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3376 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3392 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3408 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3424 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3440 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3456 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3472 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3488 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3504 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3520 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3536 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3552 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3568 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3584 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3600 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3616 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3632 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3648 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3664 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3680 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3696 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3712 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3728 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3744 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3760 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3776 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3792 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3808 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3824 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3840 - image: "borders.3.png" - } - Frame { - msec: 3856 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3872 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3888 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3904 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3920 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3936 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3952 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3968 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 3984 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4000 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4016 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4032 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4048 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4064 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4080 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4096 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4112 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4128 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4144 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4160 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4176 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4192 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4208 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4224 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4240 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4256 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4272 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4288 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4304 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4320 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4336 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4352 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4368 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4384 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4400 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4416 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4432 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4448 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4464 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4480 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4496 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4512 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4528 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4544 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4560 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4576 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4592 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4608 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4624 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4640 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4656 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4672 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4688 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4704 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4720 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4736 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4752 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4768 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4784 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4800 - image: "borders.4.png" - } - Frame { - msec: 4816 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4832 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4848 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4864 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4880 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4896 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4912 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4928 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4944 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4960 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4976 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 4992 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5008 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5024 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5040 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5056 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5072 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5088 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5104 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5120 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5136 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5152 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5168 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5184 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5200 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5216 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5232 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5248 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5264 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5280 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5296 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5312 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5328 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5344 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5360 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5376 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5392 - hash: "ab9753116e289c932064144bb0845857" - } - Frame { - msec: 5408 - hash: "ab9753116e289c932064144bb0845857" + hash: "258a7e75b491e4f51a91739c776803b3" } } diff --git a/tests/auto/declarative/qmlvisual/qdeclarativeparticles/particles.qml b/tests/auto/declarative/qmlvisual/qdeclarativeparticles/particles.qml index 2d481c9..fc8261f 100644 --- a/tests/auto/declarative/qmlvisual/qdeclarativeparticles/particles.qml +++ b/tests/auto/declarative/qmlvisual/qdeclarativeparticles/particles.qml @@ -1,4 +1,5 @@ import Qt 4.6 +import Qt.labs.particles 1.0 Rectangle { width: 640; height: 480; color: "black" diff --git a/tests/auto/declarative/qmlvisual/qdeclarativepositioners/data/repeater.qml b/tests/auto/declarative/qmlvisual/qdeclarativepositioners/data/repeater.qml deleted file mode 100644 index 1eb115d..0000000 --- a/tests/auto/declarative/qmlvisual/qdeclarativepositioners/data/repeater.qml +++ /dev/null @@ -1,339 +0,0 @@ -import Qt.VisualTest 4.6 - -VisualTest { - Frame { - msec: 0 - } - Frame { - msec: 16 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 32 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 48 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 64 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 80 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 96 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 112 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 128 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 144 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 160 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 176 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 192 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 208 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 224 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 240 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 256 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 272 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 288 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 304 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 320 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 336 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 352 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 368 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 384 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 400 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 416 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 432 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 448 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 464 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 480 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 496 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 512 - hash: "0273c293855f2b2bdbf579fc5cdce63f" - } - Frame { - msec: 528 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 544 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 560 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 576 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 592 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 608 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 624 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 640 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 656 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 672 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 688 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 704 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 720 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 736 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 752 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 768 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 784 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 800 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 816 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 832 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 848 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 864 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 880 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 896 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 912 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 928 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 944 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 960 - image: "repeater.0.png" - } - Frame { - msec: 976 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 992 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 1008 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 1024 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 1040 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 1056 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 1072 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 1088 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 1104 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 1120 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 1136 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 1152 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 1168 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 1184 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 1200 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 1216 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 1232 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 1248 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 1264 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 1280 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 1296 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 1312 - hash: "53a01771047c8ec806a335a1a3d6af71" - } - Frame { - msec: 1328 - hash: "53a01771047c8ec806a335a1a3d6af71" - } -} diff --git a/tests/auto/declarative/qmlvisual/qdeclarativepositioners/data/usingRepeater.qml b/tests/auto/declarative/qmlvisual/qdeclarativepositioners/data/usingRepeater.qml new file mode 100644 index 0000000..1eb115d --- /dev/null +++ b/tests/auto/declarative/qmlvisual/qdeclarativepositioners/data/usingRepeater.qml @@ -0,0 +1,339 @@ +import Qt.VisualTest 4.6 + +VisualTest { + Frame { + msec: 0 + } + Frame { + msec: 16 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 32 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 48 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 64 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 80 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 96 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 112 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 128 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 144 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 160 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 176 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 192 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 208 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 224 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 240 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 256 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 272 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 288 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 304 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 320 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 336 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 352 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 368 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 384 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 400 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 416 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 432 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 448 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 464 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 480 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 496 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 512 + hash: "0273c293855f2b2bdbf579fc5cdce63f" + } + Frame { + msec: 528 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 544 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 560 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 576 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 592 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 608 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 624 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 640 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 656 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 672 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 688 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 704 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 720 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 736 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 752 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 768 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 784 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 800 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 816 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 832 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 848 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 864 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 880 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 896 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 912 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 928 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 944 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 960 + image: "repeater.0.png" + } + Frame { + msec: 976 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 992 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 1008 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 1024 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 1040 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 1056 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 1072 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 1088 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 1104 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 1120 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 1136 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 1152 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 1168 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 1184 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 1200 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 1216 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 1232 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 1248 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 1264 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 1280 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 1296 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 1312 + hash: "53a01771047c8ec806a335a1a3d6af71" + } + Frame { + msec: 1328 + hash: "53a01771047c8ec806a335a1a3d6af71" + } +} diff --git a/tests/auto/declarative/qmlvisual/qdeclarativepositioners/repeater.qml b/tests/auto/declarative/qmlvisual/qdeclarativepositioners/repeater.qml deleted file mode 100644 index ff60365..0000000 --- a/tests/auto/declarative/qmlvisual/qdeclarativepositioners/repeater.qml +++ /dev/null @@ -1,15 +0,0 @@ -import Qt 4.6 - -Item{ - width: 200; height: 600 - Column{ - Rectangle{color:"Red"; width:40; height:40;} - Repeater{ - id: rep - model: 3 - delegate: Component{Rectangle{color:"Green"; width:40; height:40; radius: 20;}} - } - Rectangle{color:"Blue"; width:40; height:40;} - } - Timer{ interval: 500; running: true; onTriggered: rep.model=6;} -} diff --git a/tests/auto/declarative/qmlvisual/qdeclarativepositioners/usingRepeater.qml b/tests/auto/declarative/qmlvisual/qdeclarativepositioners/usingRepeater.qml new file mode 100644 index 0000000..ff60365 --- /dev/null +++ b/tests/auto/declarative/qmlvisual/qdeclarativepositioners/usingRepeater.qml @@ -0,0 +1,15 @@ +import Qt 4.6 + +Item{ + width: 200; height: 600 + Column{ + Rectangle{color:"Red"; width:40; height:40;} + Repeater{ + id: rep + model: 3 + delegate: Component{Rectangle{color:"Green"; width:40; height:40; radius: 20;}} + } + Rectangle{color:"Blue"; width:40; height:40;} + } + Timer{ interval: 500; running: true; onTriggered: rep.model=6;} +} diff --git a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp index 718e3a6..681b530 100644 --- a/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp +++ b/tests/auto/declarative/qmlvisual/tst_qmlvisual.cpp @@ -100,20 +100,35 @@ void tst_qmlvisual::visual_data() if (qgetenv("QMLVISUAL_ALL") != "") files << findQmlFiles(QDir(QT_TEST_SOURCE_DIR)); else { + //these are newly added tests we want to try out in CI (then move to the stable list) + files << QT_TEST_SOURCE_DIR "/qdeclarativeborderimage/borders.qml"; + files << QT_TEST_SOURCE_DIR "/qdeclarativeborderimage/animated.qml"; + files << QT_TEST_SOURCE_DIR "/qdeclarativeborderimage/animated-smooth.qml"; + files << QT_TEST_SOURCE_DIR "/qdeclarativeflipable/test-flipable.qml"; + files << QT_TEST_SOURCE_DIR "/qdeclarativepositioners/usingRepeater.qml"; + //these are tests we think are stable and useful enough to be run by the CI system files << QT_TEST_SOURCE_DIR "/animation/bindinganimation/bindinganimation.qml"; - files << QT_TEST_SOURCE_DIR "/animation/colorAnimation/colorAnimation-visual.qml"; - files << QT_TEST_SOURCE_DIR "/animation/easing/easing.qml"; files << QT_TEST_SOURCE_DIR "/animation/loop/loop.qml"; files << QT_TEST_SOURCE_DIR "/animation/parallelAnimation/parallelAnimation-visual.qml"; files << QT_TEST_SOURCE_DIR "/animation/parentAnimation/parentAnimation-visual.qml"; - files << QT_TEST_SOURCE_DIR "/animation/pauseAnimation/pauseAnimation-visual.qml"; - files << QT_TEST_SOURCE_DIR "/animation/propertyAction/propertyAction-visual.qml"; files << QT_TEST_SOURCE_DIR "/animation/reanchor/reanchor.qml"; files << QT_TEST_SOURCE_DIR "/animation/scriptAction/scriptAction-visual.qml"; - files << QT_TEST_SOURCE_DIR "/qdeclarativemousearea/mousearea-visual.qml"; files << QT_TEST_SOURCE_DIR "/qdeclarativemousearea/drag.qml"; files << QT_TEST_SOURCE_DIR "/fillmode/fillmode.qml"; + + //these reliably fail in CI, for unknown reasons + //files << QT_TEST_SOURCE_DIR "/animation/easing/easing.qml"; + //files << QT_TEST_SOURCE_DIR "/animation/pauseAnimation/pauseAnimation-visual.qml"; + + //these reliably fail on Linux because of color interpolation (different float rounding) +#if !defined(Q_WS_X11) && !defined(Q_WS_QWS) + files << QT_TEST_SOURCE_DIR "/animation/colorAnimation/colorAnimation-visual.qml"; + files << QT_TEST_SOURCE_DIR "/animation/propertyAction/propertyAction-visual.qml"; +#endif + + //this is unstable because the MouseArea press-and-hold timer is not synchronized to the animation framework. + //files << QT_TEST_SOURCE_DIR "/qdeclarativemousearea/mousearea-visual.qml"; } foreach (const QString &file, files) { diff --git a/tools/qml/qdeclarativetester.cpp b/tools/qml/qdeclarativetester.cpp index cf537ee..11fa22f 100644 --- a/tools/qml/qdeclarativetester.cpp +++ b/tools/qml/qdeclarativetester.cpp @@ -332,6 +332,24 @@ void QDeclarativeTester::updateCurrentTime(int msec) qWarning() << "QDeclarativeTester: Image mismatch. Reject saved to:" << reject; img.save(reject); + bool doDiff = (goodImage.size() == img.size()); + if (doDiff) { + QImage diffimg(m_view->width(), m_view->height(), QImage::Format_RGB32); + diffimg.fill(qRgb(255,255,255)); + QPainter p(&diffimg); + int diffCount = 0; + for (int x = 0; x < img.width(); ++x) { + for (int y = 0; y < img.height(); ++y) { + if (goodImage.pixel(x,y) != img.pixel(x,y)) { + ++diffCount; + p.drawPoint(x,y); + } + } + } + QString diff(frame->image().toLocalFile() + ".diff.png"); + diffimg.save(diff); + qWarning().nospace() << " Diff (" << diffCount << " pixels differed) saved to: " << diff; + } imagefailure(); } } -- cgit v0.12 From c24d3ce5d268e6e91bcecb155e4e2f5bd9c7dadd Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 15 Apr 2010 16:17:39 +1000 Subject: Use qmlInfo for image loading errors, not qWarning(). Task-number: QTBUG-9908 --- .../graphicsitems/qdeclarativeborderimage.cpp | 26 +++++++++++++---- .../graphicsitems/qdeclarativeimagebase.cpp | 10 +++++-- src/declarative/graphicsitems/qdeclarativetext.cpp | 14 +++++++-- src/declarative/util/qdeclarativepixmapcache.cpp | 34 +++++++++++++++------- src/declarative/util/qdeclarativepixmapcache_p.h | 3 +- src/imports/particles/qdeclarativeparticles.cpp | 10 +++++-- .../tst_qdeclarativeborderimage.cpp | 4 +-- .../qdeclarativeimage/tst_qdeclarativeimage.cpp | 9 +++--- .../tst_qdeclarativeimageprovider.cpp | 8 +++-- .../tst_qdeclarativepixmapcache.cpp | 23 +++++++++------ .../qdeclarativetext/tst_qdeclarativetext.cpp | 4 +-- 11 files changed, 101 insertions(+), 44 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp index 420ed90..be9d8bd 100644 --- a/src/declarative/graphicsitems/qdeclarativeborderimage.cpp +++ b/src/declarative/graphicsitems/qdeclarativeborderimage.cpp @@ -43,6 +43,7 @@ #include "private/qdeclarativeborderimage_p_p.h" #include +#include #include #include @@ -218,7 +219,8 @@ void QDeclarativeBorderImage::load() } } else { QSize impsize; - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async); + QString errorString; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, &errorString, &impsize, d->async); if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) { QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->url); d->pendingPixmapCache = true; @@ -230,8 +232,10 @@ void QDeclarativeBorderImage::load() setImplicitWidth(impsize.width()); setImplicitHeight(impsize.height()); - if (d->pix.isNull()) + if (d->pix.isNull()) { d->status = Error; + qmlInfo(this) << errorString; + } if (d->status == Loading) d->status = Ready; d->progress = 1.0; @@ -338,7 +342,8 @@ void QDeclarativeBorderImage::setGridScaledImage(const QDeclarativeGridScaledIma d->sciurl = d->url.resolved(QUrl(sci.pixmapUrl())); QSize impsize; - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->sciurl, &d->pix, &impsize, d->async); + QString errorString; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->sciurl, &d->pix, &errorString, &impsize, d->async); if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) { QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->sciurl); d->sciPendingPixmapCache = true; @@ -367,8 +372,10 @@ void QDeclarativeBorderImage::setGridScaledImage(const QDeclarativeGridScaledIma setImplicitWidth(impsize.width()); setImplicitHeight(impsize.height()); - if (d->pix.isNull()) + if (d->pix.isNull()) { d->status = Error; + qmlInfo(this) << errorString; + } if (d->status == Loading) d->status = Ready; d->progress = 1.0; @@ -386,11 +393,18 @@ void QDeclarativeBorderImage::requestFinished() QSize impsize; if (d->url.path().endsWith(QLatin1String(".sci"))) { d->sciPendingPixmapCache = false; - QDeclarativePixmapCache::get(d->sciurl, &d->pix, &impsize, d->async); + QString errorString; + if (QDeclarativePixmapCache::get(d->sciurl, &d->pix, &errorString, &impsize, d->async) != QDeclarativePixmapReply::Ready) { + d->status = Error; + qmlInfo(this) << errorString; + } } else { d->pendingPixmapCache = false; - if (QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async) != QDeclarativePixmapReply::Ready) + QString errorString; + if (QDeclarativePixmapCache::get(d->url, &d->pix, &errorString, &impsize, d->async) != QDeclarativePixmapReply::Ready) { d->status = Error; + qmlInfo(this) << errorString; + } } setImplicitWidth(impsize.width()); setImplicitHeight(impsize.height()); diff --git a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp index 3acafe8..c3f8195 100644 --- a/src/declarative/graphicsitems/qdeclarativeimagebase.cpp +++ b/src/declarative/graphicsitems/qdeclarativeimagebase.cpp @@ -43,6 +43,7 @@ #include "private/qdeclarativeimagebase_p_p.h" #include +#include #include #include @@ -154,7 +155,8 @@ void QDeclarativeImageBase::load() int reqwidth = d->sourcesize.width(); int reqheight = d->sourcesize.height(); QSize impsize; - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async, reqwidth, reqheight); + QString errorString; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->pix, &errorString, &impsize, d->async, reqwidth, reqheight); if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) { QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->url, reqwidth, reqheight); d->pendingPixmapCache = true; @@ -191,6 +193,7 @@ void QDeclarativeImageBase::load() emit sourceSizeChanged(); } else { d->status = Error; + qmlInfo(this) << errorString; } d->progress = 1.0; emit statusChanged(d->status); @@ -210,8 +213,11 @@ void QDeclarativeImageBase::requestFinished() d->pendingPixmapCache = false; QSize impsize; - if (QDeclarativePixmapCache::get(d->url, &d->pix, &impsize, d->async, d->sourcesize.width(), d->sourcesize.height()) != QDeclarativePixmapReply::Ready) + QString errorString; + if (QDeclarativePixmapCache::get(d->url, &d->pix, &errorString, &impsize, d->async, d->sourcesize.width(), d->sourcesize.height()) != QDeclarativePixmapReply::Ready) { d->status = Error; + qmlInfo(this) << errorString; + } setImplicitWidth(impsize.width()); setImplicitHeight(impsize.height()); diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 3b39fa4..9fcfd92 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -45,6 +45,7 @@ #include #include +#include #include #include #include @@ -75,10 +76,16 @@ protected: if (type == QTextDocument::ImageResource) { QPixmap pm; - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(url, &pm, 0, true, 0, 0); + QString errorString; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(url, &pm, &errorString, 0, true, 0, 0); if (status == QDeclarativePixmapReply::Ready) return pm; - if (status != QDeclarativePixmapReply::Error) { + if (status == QDeclarativePixmapReply::Error) { + if (!errors.contains(url)) { + errors.insert(url); + qmlInfo(parent()) << errorString; + } + } else { QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(parent()), url); connect(reply, SIGNAL(finished()), this, SLOT(requestFinished())); outstanding++; @@ -98,8 +105,11 @@ private slots: private: int outstanding; + static QSet errors; }; +QSet QTextDocumentWithImageResources::errors; + /*! \qmlclass Text QDeclarativeText \since 4.7 diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp index 5e60819..4a96a2a 100644 --- a/src/declarative/util/qdeclarativepixmapcache.cpp +++ b/src/declarative/util/qdeclarativepixmapcache.cpp @@ -194,8 +194,8 @@ static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *e return true; } else { if (errorString) - *errorString = QLatin1String("Error decoding: ") + url.toString() - + QLatin1String(" \"") + imgio.errorString() + QLatin1String("\""); + *errorString = QDeclarativeImageRequestHandler::tr("Error decoding: %1: %2").arg(url.toString()) + .arg(imgio.errorString()); return false; } } @@ -264,7 +264,7 @@ bool QDeclarativeImageRequestHandler::event(QEvent *event) QString errorStr; if (image.isNull()) { errorCode = QDeclarativeImageReaderEvent::Loading; - errorStr = QLatin1String("Failed to get image from provider: ") + url.toString(); + errorStr = QDeclarativeImageRequestHandler::tr("Failed to get image from provider: %1").arg(url.toString()); } QCoreApplication::postEvent(runningJob, new QDeclarativeImageReaderEvent(errorCode, errorStr, image)); } else { @@ -283,7 +283,7 @@ bool QDeclarativeImageRequestHandler::event(QEvent *event) errorCode = QDeclarativeImageReaderEvent::Loading; } } else { - errorStr = QLatin1String("Cannot open: ") + url.toString(); + errorStr = QDeclarativeImageRequestHandler::tr("Cannot open: %1").arg(url.toString()); errorCode = QDeclarativeImageReaderEvent::Loading; } QCoreApplication::postEvent(runningJob, new QDeclarativeImageReaderEvent(errorCode, errorStr, image)); @@ -460,6 +460,7 @@ public: bool loading; QDeclarativeImageReader *reader; int forced_width, forced_height; + QString errorString; }; @@ -511,7 +512,7 @@ bool QDeclarativePixmapReply::event(QEvent *event) if (d->status == Ready) d->pixmap = QPixmap::fromImage(de->image); else - qWarning() << de->errorString; + d->errorString = de->errorString; QByteArray key = d->url.toEncoded(QUrl::FormattingOption(0x100)); QString strKey = QString::fromLatin1(key.constData(), key.count()); QPixmapCache::insert(strKey, d->pixmap); // note: may fail (returns false) @@ -523,6 +524,12 @@ bool QDeclarativePixmapReply::event(QEvent *event) return QObject::event(event); } +QString QDeclarativePixmapReply::errorString() const +{ + Q_D(const QDeclarativePixmapReply); + return d->errorString; +} + QDeclarativePixmapReply::Status QDeclarativePixmapReply::status() const { Q_D(const QDeclarativePixmapReply); @@ -586,7 +593,7 @@ bool QDeclarativePixmapReply::release(bool defer) Note that images sourced from the network will always be loaded and decoded asynchonously. */ -QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QPixmap *pixmap, QSize *impsize, bool async, int req_width, int req_height) +QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QPixmap *pixmap, QString *errorString, QSize *impsize, bool async, int req_width, int req_height) { QDeclarativePixmapReply::Status status = QDeclarativePixmapReply::Unrequested; QByteArray key = url.toEncoded(QUrl::FormattingOption(0x100)); @@ -609,17 +616,16 @@ QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QP QFile f(lf); QSize read_impsize; if (f.open(QIODevice::ReadOnly)) { - QString errorString; QImage image; - if (readImage(url, &f, &image, &errorString, &read_impsize, req_width, req_height)) { + if (readImage(url, &f, &image, errorString, &read_impsize, req_width, req_height)) { *pixmap = QPixmap::fromImage(image); } else { - qWarning() << errorString; *pixmap = QPixmap(); status = QDeclarativePixmapReply::Error; } } else { - qWarning() << "Cannot open" << url; + if (errorString) + *errorString = QDeclarativeImageRequestHandler::tr("Cannot open: %1").arg(url.toString()); *pixmap = QPixmap(); status = QDeclarativePixmapReply::Error; } @@ -650,9 +656,15 @@ QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QP } else if (QPixmapCache::find(strKey, pixmap)) { if (iter != qmlActivePixmapReplies()->end()) { status = (*iter)->status(); + if (errorString) + *errorString = (*iter)->errorString(); (*iter)->release(); + } else if (pixmap->isNull()) { + status = QDeclarativePixmapReply::Error; + if (errorString) + *errorString = QDeclarativeImageRequestHandler::tr("Unknown Error loading %1").arg(url); } else { - status = pixmap->isNull() ? QDeclarativePixmapReply::Error : QDeclarativePixmapReply::Ready; + status = QDeclarativePixmapReply::Ready; } } else if (iter != qmlActivePixmapReplies()->end()) { status = QDeclarativePixmapReply::Loading; diff --git a/src/declarative/util/qdeclarativepixmapcache_p.h b/src/declarative/util/qdeclarativepixmapcache_p.h index df71d65..7b94728 100644 --- a/src/declarative/util/qdeclarativepixmapcache_p.h +++ b/src/declarative/util/qdeclarativepixmapcache_p.h @@ -64,6 +64,7 @@ public: enum Status { Ready, Error, Unrequested, Loading }; Status status() const; + QString errorString() const; const QUrl &url() const; int forcedWidth() const; @@ -95,7 +96,7 @@ private: class Q_DECLARATIVE_EXPORT QDeclarativePixmapCache { public: - static QDeclarativePixmapReply::Status get(const QUrl& url, QPixmap *pixmap, QSize *impsize=0, bool async=false, int req_width=0, int req_height=0); + static QDeclarativePixmapReply::Status get(const QUrl& url, QPixmap *pixmap, QString *errorString, QSize *impsize=0, bool async=false, int req_width=0, int req_height=0); static QDeclarativePixmapReply *request(QDeclarativeEngine *, const QUrl& url, int req_width=0, int req_height=0); static void cancel(const QUrl& url, QObject *obj); static int pendingRequests(); diff --git a/src/imports/particles/qdeclarativeparticles.cpp b/src/imports/particles/qdeclarativeparticles.cpp index d17a8a1..264cba2 100644 --- a/src/imports/particles/qdeclarativeparticles.cpp +++ b/src/imports/particles/qdeclarativeparticles.cpp @@ -41,6 +41,7 @@ #include "qdeclarativeparticles_p.h" +#include #include #include @@ -730,7 +731,9 @@ void QDeclarativeParticles::imageLoaded() { Q_D(QDeclarativeParticles); d->pendingPixmapCache = false; - QDeclarativePixmapCache::get(d->url, &d->image); + QString errorString; + if (QDeclarativePixmapCache::get(d->url, &d->image, &errorString)==QDeclarativePixmapReply::Error) + qmlInfo(this) << errorString; d->paintItem->updateSize(); d->paintItem->update(); } @@ -754,12 +757,15 @@ void QDeclarativeParticles::setSource(const QUrl &name) } else { d->url = name; Q_ASSERT(!name.isRelative()); - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->image); + QString errorString; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(d->url, &d->image, &errorString); if (status != QDeclarativePixmapReply::Ready && status != QDeclarativePixmapReply::Error) { QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(this), d->url); connect(reply, SIGNAL(finished()), this, SLOT(imageLoaded())); d->pendingPixmapCache = true; } else { + if (status == QDeclarativePixmapReply::Error) + qmlInfo(this) << errorString; //### unify with imageLoaded d->paintItem->updateSize(); d->paintItem->update(); diff --git a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp index 0f03527..8621239 100644 --- a/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp +++ b/tests/auto/declarative/qdeclarativeborderimage/tst_qdeclarativeborderimage.cpp @@ -121,10 +121,10 @@ void tst_qdeclarativeborderimage::imageSource_data() QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << false << ""; QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << false - << "Cannot open QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() + "\" ) "; + << "QML BorderImage (file::2:1) Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString(); QTest::newRow("remote") << SERVER_ADDR "/colors.png" << true << ""; QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << true - << "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" "; + << "QML BorderImage (file::2:1) Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found"; } void tst_qdeclarativeborderimage::imageSource() diff --git a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp index 53c208e..854bcdd 100644 --- a/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp +++ b/tests/auto/declarative/qdeclarativeimage/tst_qdeclarativeimage.cpp @@ -124,13 +124,14 @@ void tst_qdeclarativeimage::imageSource_data() QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/colors.png").toString() << 120.0 << 120.0 << false << false << ""; QTest::newRow("local async") << QUrl::fromLocalFile(SRCDIR "/data/colors1.png").toString() << 120.0 << 120.0 << false << true << ""; QTest::newRow("local not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() << 0.0 << 0.0 << false - << false << "Cannot open QUrl( \"" + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString() + "\" ) "; + << false << "QML Image (file::2:1) Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file.png").toString(); QTest::newRow("local async not found") << QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() << 0.0 << 0.0 << false - << true << "\"Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString() + "\" "; + << true << "QML Image (file::2:1) Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/no-such-file-1.png").toString(); QTest::newRow("remote") << SERVER_ADDR "/colors.png" << 120.0 << 120.0 << true << false << ""; QTest::newRow("remote svg") << SERVER_ADDR "/heart.svg" << 550.0 << 500.0 << true << false << ""; - QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << 0.0 << 0.0 << true << false - << "\"Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found\" "; + QTest::newRow("remote not found") << SERVER_ADDR "/no-such-file.png" << 0.0 << 0.0 << true + << false << "QML Image (file::2:1) Error downloading " SERVER_ADDR "/no-such-file.png - server replied: Not found"; + } void tst_qdeclarativeimage::imageSource() diff --git a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp index 162c266..aca951b 100644 --- a/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp +++ b/tests/auto/declarative/qdeclarativeimageprovider/tst_qdeclarativeimageprovider.cpp @@ -96,9 +96,10 @@ void tst_qdeclarativeimageprovider::imageSource_data() QTest::newRow("exists") << "image://test/exists.png" << "" << QSize(100,100) << ""; QTest::newRow("scaled") << "image://test/exists.png" << "sourceSize: \"80x30\"" << QSize(80,30) << ""; QTest::newRow("missing") << "image://test/no-such-file.png" << "" << QSize() - << "\"Failed to get image from provider: image://test/no-such-file.png\" "; + << "QML Image (file::2:1) Failed to get image from provider: image://test/no-such-file.png"; QTest::newRow("unknown provider") << "image://bogus/exists.png" << "" << QSize() - << "\"Failed to get image from provider: image://bogus/exists.png\" "; + << "QML Image (file::2:1) Failed to get image from provider: image://bogus/exists.png"; + } void tst_qdeclarativeimageprovider::imageSource() @@ -157,7 +158,8 @@ void tst_qdeclarativeimageprovider::removeProvider() QCOMPARE(obj->width(), 100.0); // remove the provider and confirm - QString error("\"Failed to get image from provider: image://test2/exists2.png\" "); + QString error("QML Image (file::2:1) Failed to get image from provider: image://test2/exists2.png"); + QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); engine.removeImageProvider("test2"); diff --git a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp index f2ccf80..0cc13ad 100644 --- a/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp +++ b/tests/auto/declarative/qdeclarativepixmapcache/tst_qdeclarativepixmapcache.cpp @@ -126,19 +126,20 @@ void tst_qdeclarativepixmapcache::single() QFETCH(bool, exists); QFETCH(bool, neterror); + QString expectedError; if (neterror) { - QString expected = "\"Error downloading " + target.toString() + " - server replied: Not found\" "; - QTest::ignoreMessage(QtWarningMsg, expected.toLatin1()); + expectedError = "Error downloading " + target.toString() + " - server replied: Not found"; } else if (!exists) { - QString expected = "Cannot open QUrl( \"" + target.toString() + "\" ) "; - QTest::ignoreMessage(QtWarningMsg, expected.toLatin1()); + expectedError = "Cannot open: " + target.toString(); } QPixmap pixmap; QVERIFY(pixmap.width() <= 0); // Check Qt assumption - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(target, &pixmap); + QString errorString; + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(target, &pixmap, &errorString); if (incache) { + QCOMPARE(errorString, expectedError); if (exists) { QVERIFY(status == QDeclarativePixmapReply::Ready); QVERIFY(pixmap.width() > 0); @@ -156,13 +157,15 @@ void tst_qdeclarativepixmapcache::single() QTestEventLoop::instance().enterLoop(10); QVERIFY(!QTestEventLoop::instance().timeout()); QVERIFY(getter.gotslot); + QString errorString; if (exists) { - QVERIFY(QDeclarativePixmapCache::get(target, &pixmap) == QDeclarativePixmapReply::Ready); + QVERIFY(QDeclarativePixmapCache::get(target, &pixmap, &errorString) == QDeclarativePixmapReply::Ready); QVERIFY(pixmap.width() > 0); } else { - QVERIFY(QDeclarativePixmapCache::get(target, &pixmap) == QDeclarativePixmapReply::Error); + QVERIFY(QDeclarativePixmapCache::get(target, &pixmap, &errorString) == QDeclarativePixmapReply::Error); QVERIFY(pixmap.width() <= 0); } + QCOMPARE(errorString, expectedError); } QCOMPARE(QDeclarativePixmapCache::pendingRequests(), 0); @@ -236,7 +239,8 @@ void tst_qdeclarativepixmapcache::parallel() for (int i=0; igotslot); QPixmap pixmap; - QVERIFY(QDeclarativePixmapCache::get(targets[i], &pixmap) == QDeclarativePixmapReply::Ready); + QString errorString; + QVERIFY(QDeclarativePixmapCache::get(targets[i], &pixmap, &errorString) == QDeclarativePixmapReply::Ready); QVERIFY(pixmap.width() > 0); } delete getters[i]; diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp index 53640d0..ca7dfe7 100644 --- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp @@ -871,10 +871,10 @@ void tst_qdeclarativetext::embeddedImages_data() QTest::addColumn("error"); QTest::newRow("local") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocal.qml") << ""; QTest::newRow("local-error") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocalError.qml") - << "\"Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/http/notexists.png").toString() + "\" "; + << "QML Text ("+QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesLocalError.qml").toString()+":3:1) Cannot open: " + QUrl::fromLocalFile(SRCDIR "/data/http/notexists.png").toString(); QTest::newRow("remote") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemote.qml") << ""; QTest::newRow("remote-error") << QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemoteError.qml") - << "\"Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found\" "; + << "QML Text ("+QUrl::fromLocalFile(SRCDIR "/data/embeddedImagesRemoteError.qml").toString()+":3:1) Error downloading http://127.0.0.1:14453/notexists.png - server replied: Not found"; } void tst_qdeclarativetext::embeddedImages() -- cgit v0.12 From 30a3e78a12b72ab6f67992ec2f06cd4f21a01a6c Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 15 Apr 2010 16:35:51 +1000 Subject: Add Component.onDestruction attached property This property complements Component.onCompleted. It is emitted before the destruction actually begins (for the most part) so the objects are still alive and accessible. The QtObject.onDestroyed signal is now blocked as it never really worked properly anyway. --- src/declarative/qml/qdeclarativecompiler.cpp | 31 +----------- src/declarative/qml/qdeclarativecompiler_p.h | 2 - src/declarative/qml/qdeclarativecomponent.cpp | 45 +++++++++-------- src/declarative/qml/qdeclarativecomponent_p.h | 15 +++++- src/declarative/qml/qdeclarativecontext.cpp | 57 +++++++++++----------- src/declarative/qml/qdeclarativecontext_p.h | 7 ++- src/declarative/qml/qdeclarativeengine.cpp | 11 +++-- src/declarative/qml/qdeclarativeengine_p.h | 2 +- src/declarative/qml/qdeclarativeproperty.cpp | 34 ++++++++++++- src/declarative/qml/qdeclarativeproperty_p.h | 3 +- src/declarative/qml/qdeclarativepropertycache.cpp | 6 +-- .../tst_qdeclarativecontext.cpp | 10 ++-- .../data/OnDestructionType.qml | 8 +++ .../data/destroyedSignal.errors.txt | 1 + .../qdeclarativelanguage/data/destroyedSignal.qml | 5 ++ .../qdeclarativelanguage/data/onDestruction.qml | 17 +++++++ .../tst_qdeclarativelanguage.cpp | 16 ++++++ 17 files changed, 171 insertions(+), 99 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml create mode 100644 tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index fad7779..5c5ad37 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -1364,35 +1364,6 @@ int QDeclarativeCompiler::componentTypeRef() return output->types.count() - 1; } -QMetaMethod QDeclarativeCompiler::findSignalByName(const QMetaObject *mo, const QByteArray &name) -{ - Q_ASSERT(mo); - int methods = mo->methodCount(); - for (int ii = methods - 1; ii >= 0; --ii) { - QMetaMethod method = mo->method(ii); - QByteArray methodName = method.signature(); - int idx = methodName.indexOf('('); - methodName = methodName.left(idx); - - if (methodName == name) - return method; - } - - // If no signal is found, but the signal is of the form "onBlahChanged", - // return the notify signal for the property "Blah" - if (name.endsWith("Changed")) { - QByteArray propName = name.mid(0, name.length() - 7); - int propIdx = mo->indexOfProperty(propName.constData()); - if (propIdx >= 0) { - QMetaProperty prop = mo->property(propIdx); - if (prop.hasNotifySignal()) - return prop.notifySignal(); - } - } - - return QMetaMethod(); -} - bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDeclarativeParser::Object *obj, const BindingContext &ctxt) { @@ -1404,7 +1375,7 @@ bool QDeclarativeCompiler::buildSignal(QDeclarativeParser::Property *prop, QDecl if(name[0] >= 'A' && name[0] <= 'Z') name[0] = name[0] - 'A' + 'a'; - int sigIdx = findSignalByName(obj->metaObject(), name).methodIndex(); + int sigIdx = QDeclarativePropertyPrivate::findSignalByName(obj->metaObject(), name).methodIndex(); if (sigIdx == -1) { diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h index 0e47774..002c6c9 100644 --- a/src/declarative/qml/qdeclarativecompiler_p.h +++ b/src/declarative/qml/qdeclarativecompiler_p.h @@ -159,8 +159,6 @@ public: static bool isAttachedPropertyName(const QByteArray &); static bool isSignalPropertyName(const QByteArray &); - static QMetaMethod findSignalByName(const QMetaObject *, const QByteArray &name); - int evaluateEnum(const QByteArray& script) const; // for QDeclarativeCustomParser::evaluateEnum private: diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 7744b75..5cc6639 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -657,11 +657,11 @@ QObject * QDeclarativeComponentPrivate::begin(QDeclarativeContextData *ctxt, QDe state->bindValues = enginePriv->bindValues; state->parserStatus = enginePriv->parserStatus; - state->componentAttacheds = enginePriv->componentAttacheds; - if (state->componentAttacheds) - state->componentAttacheds->prev = &state->componentAttacheds; + state->componentAttached = enginePriv->componentAttached; + if (state->componentAttached) + state->componentAttached->prev = &state->componentAttached; - enginePriv->componentAttacheds = 0; + enginePriv->componentAttached = 0; enginePriv->bindValues.clear(); enginePriv->parserStatus.clear(); state->completePending = true; @@ -688,11 +688,11 @@ void QDeclarativeComponentPrivate::beginDeferred(QDeclarativeEnginePrivate *engi state->bindValues = enginePriv->bindValues; state->parserStatus = enginePriv->parserStatus; - state->componentAttacheds = enginePriv->componentAttacheds; - if (state->componentAttacheds) - state->componentAttacheds->prev = &state->componentAttacheds; + state->componentAttached = enginePriv->componentAttached; + if (state->componentAttached) + state->componentAttached->prev = &state->componentAttached; - enginePriv->componentAttacheds = 0; + enginePriv->componentAttached = 0; enginePriv->bindValues.clear(); enginePriv->parserStatus.clear(); state->completePending = true; @@ -729,11 +729,13 @@ void QDeclarativeComponentPrivate::complete(QDeclarativeEnginePrivate *enginePri QDeclarativeEnginePrivate::clear(ps); } - while (state->componentAttacheds) { - QDeclarativeComponentAttached *a = state->componentAttacheds; - if (a->next) a->next->prev = &state->componentAttacheds; - state->componentAttacheds = a->next; - a->prev = 0; a->next = 0; + while (state->componentAttached) { + QDeclarativeComponentAttached *a = state->componentAttached; + a->rem(); + QDeclarativeData *d = QDeclarativeData::get(a->parent()); + Q_ASSERT(d); + Q_ASSERT(d->context); + a->add(&d->context->componentAttached); emit a->completed(); } @@ -793,15 +795,18 @@ QDeclarativeComponentAttached *QDeclarativeComponent::qmlAttachedProperties(QObj QDeclarativeComponentAttached *a = new QDeclarativeComponentAttached(obj); QDeclarativeEngine *engine = qmlEngine(obj); - if (!engine || !QDeclarativeEnginePrivate::get(engine)->inBeginCreate) + if (!engine) return a; - QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine); - - a->next = p->componentAttacheds; - a->prev = &p->componentAttacheds; - if (a->next) a->next->prev = &a->next; - p->componentAttacheds = a; + if (QDeclarativeEnginePrivate::get(engine)->inBeginCreate) { + QDeclarativeEnginePrivate *p = QDeclarativeEnginePrivate::get(engine); + a->add(&p->componentAttached); + } else { + QDeclarativeData *d = QDeclarativeData::get(obj); + Q_ASSERT(d); + Q_ASSERT(d->context); + a->add(&d->context->componentAttached); + } return a; } diff --git a/src/declarative/qml/qdeclarativecomponent_p.h b/src/declarative/qml/qdeclarativecomponent_p.h index dfd0fc3..24e5386 100644 --- a/src/declarative/qml/qdeclarativecomponent_p.h +++ b/src/declarative/qml/qdeclarativecomponent_p.h @@ -99,10 +99,10 @@ public: QDeclarativeCompiledData *cc; struct ConstructionState { - ConstructionState() : componentAttacheds(0), completePending(false) {} + ConstructionState() : componentAttached(0), completePending(false) {} QList > bindValues; QList > parserStatus; - QDeclarativeComponentAttached *componentAttacheds; + QDeclarativeComponentAttached *componentAttached; QList errors; bool completePending; }; @@ -132,13 +132,24 @@ public: QDeclarativeComponentAttached(QObject *parent = 0); ~QDeclarativeComponentAttached(); + void add(QDeclarativeComponentAttached **a) { + prev = a; next = *a; *a = this; + if (next) next->prev = &next; + } + void rem() { + if (next) next->prev = prev; + *prev = next; + next = 0; prev = 0; + } QDeclarativeComponentAttached **prev; QDeclarativeComponentAttached *next; Q_SIGNALS: void completed(); + void destruction(); private: + friend class QDeclarativeContextData;; friend class QDeclarativeComponentPrivate; }; diff --git a/src/declarative/qml/qdeclarativecontext.cpp b/src/declarative/qml/qdeclarativecontext.cpp index 42e7386..6657fea 100644 --- a/src/declarative/qml/qdeclarativecontext.cpp +++ b/src/declarative/qml/qdeclarativecontext.cpp @@ -42,6 +42,7 @@ #include "qdeclarativecontext.h" #include "private/qdeclarativecontext_p.h" +#include "private/qdeclarativecomponent_p.h" #include "private/qdeclarativeexpression_p.h" #include "private/qdeclarativeengine_p.h" #include "qdeclarativeengine.h" @@ -476,21 +477,34 @@ QObject *QDeclarativeContextPrivate::context_at(QDeclarativeListPropertydestroy(); + while (childContexts) + childContexts->invalidate(); + + while (componentAttached) { + QDeclarativeComponentAttached *a = componentAttached; + componentAttached = a->next; + if (componentAttached) componentAttached->prev = &componentAttached; + + a->next = 0; + a->prev = 0; + + emit a->destruction(); + } if (prevChild) { *prevChild = nextChild; @@ -498,19 +512,17 @@ void QDeclarativeContextData::destroy() nextChild = 0; prevChild = 0; } - - QDeclarativeContextData *child = childContexts; - while (child) { - QDeclarativeContextData *next = child->nextChild; - child->invalidateEngines(); - child->parent = 0; - child->nextChild = 0; - child->prevChild = 0; + engine = 0; + parent = 0; +} - child = next; - } - childContexts = 0; +void QDeclarativeContextData::destroy() +{ + if (linkedContext) + linkedContext->destroy(); + + if (engine) invalidate(); QDeclarativeAbstractExpression *expression = expressions; while (expression) { @@ -573,19 +585,6 @@ void QDeclarativeContextData::setParent(QDeclarativeContextData *p) } } -void QDeclarativeContextData::invalidateEngines() -{ - if (!engine) - return; - engine = 0; - - QDeclarativeContextData *child = childContexts; - while (child) { - child->invalidateEngines(); - child = child->nextChild; - } -} - /* Refreshes all expressions that could possibly depend on this context. Refreshing flushes all context-tree dependent caches in the expressions, and should occur every time the context tree diff --git a/src/declarative/qml/qdeclarativecontext_p.h b/src/declarative/qml/qdeclarativecontext_p.h index 5d26e7e..77a6d94 100644 --- a/src/declarative/qml/qdeclarativecontext_p.h +++ b/src/declarative/qml/qdeclarativecontext_p.h @@ -106,6 +106,7 @@ public: static QObject *context_at(QDeclarativeListProperty *, int); }; +class QDeclarativeComponentAttached; class QDeclarativeGuardedContextData; class QDeclarativeContextData { @@ -113,6 +114,7 @@ public: QDeclarativeContextData(); QDeclarativeContextData(QDeclarativeContext *); void destroy(); + void invalidate(); inline bool isValid() const { return engine && (!isInternal || !contextObject || !QObjectPrivate::get(contextObject)->wasDeleted); @@ -123,7 +125,6 @@ public: QDeclarativeEngine *engine; void setParent(QDeclarativeContextData *); - void invalidateEngines(); void refreshExpressions(); void addObject(QObject *); @@ -194,6 +195,10 @@ public: // Linked contexts. this owns linkedContext. QDeclarativeContextData *linkedContext; + // Linked list of uses of the Component attached property in this + // context + QDeclarativeComponentAttached *componentAttached; + QString findObjectId(const QObject *obj) const; static QDeclarativeContextData *get(QDeclarativeContext *context) { diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index a478bf5..1deadb2 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -155,7 +155,7 @@ QDeclarativeEnginePrivate::QDeclarativeEnginePrivate(QDeclarativeEngine *e) : captureProperties(false), rootContext(0), currentExpression(0), isDebugging(false), contextClass(0), sharedContext(0), sharedScope(0), objectClass(0), valueTypeClass(0), globalClass(0), cleanup(0), erroredBindings(0), inProgressCreations(0), - scriptEngine(this), workerScriptEngine(0), componentAttacheds(0), inBeginCreate(false), + scriptEngine(this), workerScriptEngine(0), componentAttached(0), inBeginCreate(false), networkAccessManager(0), networkAccessManagerFactory(0), typeManager(e), uniqueId(1) { @@ -350,8 +350,13 @@ typedef QMap StringStringMap; Q_GLOBAL_STATIC(StringStringMap, qmlEnginePluginsWithRegisteredTypes); // stores the uri -void QDeclarativePrivate::qdeclarativeelement_destructor(QObject *) +void QDeclarativePrivate::qdeclarativeelement_destructor(QObject *o) { + QObjectPrivate *p = QObjectPrivate::get(o); + Q_ASSERT(p->declarativeData); + QDeclarativeData *d = static_cast(p->declarativeData); + if (d->ownContext) + d->context->destroy(); } void QDeclarativeData::destroyed(QAbstractDeclarativeData *d, QObject *o) @@ -855,7 +860,7 @@ void QDeclarativeData::destroyed(QObject *object) if (propertyCache) propertyCache->release(); - if (ownContext) + if (ownContext && context) context->destroy(); QDeclarativeGuard *guard = guards; diff --git a/src/declarative/qml/qdeclarativeengine_p.h b/src/declarative/qml/qdeclarativeengine_p.h index 7766ad6..b3bba43 100644 --- a/src/declarative/qml/qdeclarativeengine_p.h +++ b/src/declarative/qml/qdeclarativeengine_p.h @@ -215,7 +215,7 @@ public: QList > bindValues; QList > parserStatus; - QDeclarativeComponentAttached *componentAttacheds; + QDeclarativeComponentAttached *componentAttached; bool inBeginCreate; diff --git a/src/declarative/qml/qdeclarativeproperty.cpp b/src/declarative/qml/qdeclarativeproperty.cpp index 9cb2416..afd0d84 100644 --- a/src/declarative/qml/qdeclarativeproperty.cpp +++ b/src/declarative/qml/qdeclarativeproperty.cpp @@ -286,7 +286,7 @@ void QDeclarativePropertyPrivate::initProperty(QObject *obj, const QString &name QString signalName = terminal.mid(2); signalName[0] = signalName.at(0).toLower(); - QMetaMethod method = QDeclarativeCompiler::findSignalByName(currentObject->metaObject(), signalName.toLatin1().constData()); + QMetaMethod method = findSignalByName(currentObject->metaObject(), signalName.toLatin1().constData()); if (method.signature()) { object = currentObject; core.load(method); @@ -1353,4 +1353,36 @@ bool QDeclarativePropertyPrivate::canConvert(const QMetaObject *from, const QMet return false; } +/*! + Return the signal corresponding to \a name +*/ +QMetaMethod QDeclarativePropertyPrivate::findSignalByName(const QMetaObject *mo, const QByteArray &name) +{ + Q_ASSERT(mo); + int methods = mo->methodCount(); + for (int ii = methods - 1; ii >= 2; --ii) { // >= 2 to block the destroyed signal + QMetaMethod method = mo->method(ii); + QByteArray methodName = method.signature(); + int idx = methodName.indexOf('('); + methodName = methodName.left(idx); + + if (methodName == name) + return method; + } + + // If no signal is found, but the signal is of the form "onBlahChanged", + // return the notify signal for the property "Blah" + if (name.endsWith("Changed")) { + QByteArray propName = name.mid(0, name.length() - 7); + int propIdx = mo->indexOfProperty(propName.constData()); + if (propIdx >= 0) { + QMetaProperty prop = mo->property(propIdx); + if (prop.hasNotifySignal()) + return prop.notifySignal(); + } + } + + return QMetaMethod(); +} + QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativeproperty_p.h b/src/declarative/qml/qdeclarativeproperty_p.h index 420a1ba..8522561 100644 --- a/src/declarative/qml/qdeclarativeproperty_p.h +++ b/src/declarative/qml/qdeclarativeproperty_p.h @@ -96,8 +96,6 @@ public: void initProperty(QObject *obj, const QString &name); void initDefault(QObject *obj); - QMetaMethod findSignal(QObject *, const QString &); - bool isValueType() const; int propertyType() const; QDeclarativeProperty::PropertyTypeCategory propertyTypeCategory() const; @@ -134,6 +132,7 @@ public: static bool write(const QDeclarativeProperty &that, const QVariant &, WriteFlags); static int valueTypeCoreIndex(const QDeclarativeProperty &that); static int bindingIndex(const QDeclarativeProperty &that); + static QMetaMethod findSignalByName(const QMetaObject *mo, const QByteArray &); }; Q_DECLARE_OPERATORS_FOR_FLAGS(QDeclarativePropertyPrivate::WriteFlags) diff --git a/src/declarative/qml/qdeclarativepropertycache.cpp b/src/declarative/qml/qdeclarativepropertycache.cpp index 4b4b142..888945b 100644 --- a/src/declarative/qml/qdeclarativepropertycache.cpp +++ b/src/declarative/qml/qdeclarativepropertycache.cpp @@ -147,7 +147,7 @@ QDeclarativePropertyCache::Data QDeclarativePropertyCache::create(const QMetaObj } int methodCount = metaObject->methodCount(); - for (int ii = methodCount - 1; ii >= 0; --ii) { + for (int ii = methodCount - 1; ii >= 2; --ii) { // >=2 to block the destroyed signal QMetaMethod m = metaObject->method(ii); if (m.access() == QMetaMethod::Private) continue; @@ -216,7 +216,7 @@ void QDeclarativePropertyCache::append(QDeclarativeEngine *engine, const QMetaOb } int methodCount = metaObject->methodCount(); - int methodOffset = metaObject->methodOffset(); + int methodOffset = qMax(2, metaObject->methodOffset()); // 2 to block the destroyed signal for (int ii = methodOffset; ii < methodCount; ++ii) { QMetaMethod m = metaObject->method(ii); if (m.access() == QMetaMethod::Private) @@ -289,7 +289,7 @@ void QDeclarativePropertyCache::update(QDeclarativeEngine *engine, const QMetaOb } int methodCount = metaObject->methodCount(); - for (int ii = methodCount - 1; ii >= 0; --ii) { + for (int ii = methodCount - 1; ii >= 2; --ii) { // >=2 to block the destroyed signal QMetaMethod m = metaObject->method(ii); if (m.access() == QMetaMethod::Private) continue; diff --git a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp index 35cffdc..851460f 100644 --- a/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp +++ b/tests/auto/declarative/qdeclarativecontext/tst_qdeclarativecontext.cpp @@ -172,8 +172,8 @@ void tst_qdeclarativecontext::parentContext() delete ctxt2; ctxt2 = 0; QCOMPARE(ctxt->parentContext(), engine->rootContext()); - QCOMPARE(ctxt3->parentContext(), ctxt2); - QCOMPARE(ctxt4->parentContext(), ctxt2); + QCOMPARE(ctxt3->parentContext(), (QDeclarativeContext *)0); + QCOMPARE(ctxt4->parentContext(), (QDeclarativeContext *)0); QCOMPARE(ctxt5->parentContext(), ctxt); QCOMPARE(ctxt6->parentContext(), engine->rootContext()); QCOMPARE(ctxt7->parentContext(), engine->rootContext()); @@ -181,9 +181,9 @@ void tst_qdeclarativecontext::parentContext() delete engine; engine = 0; QCOMPARE(ctxt->parentContext(), (QDeclarativeContext *)0); - QCOMPARE(ctxt3->parentContext(), ctxt2); - QCOMPARE(ctxt4->parentContext(), ctxt2); - QCOMPARE(ctxt5->parentContext(), ctxt); + QCOMPARE(ctxt3->parentContext(), (QDeclarativeContext *)0); + QCOMPARE(ctxt4->parentContext(), (QDeclarativeContext *)0); + QCOMPARE(ctxt5->parentContext(), (QDeclarativeContext *)0); QCOMPARE(ctxt6->parentContext(), (QDeclarativeContext *)0); QCOMPARE(ctxt7->parentContext(), (QDeclarativeContext *)0); diff --git a/tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml b/tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml new file mode 100644 index 0000000..e5a7cf8 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/OnDestructionType.qml @@ -0,0 +1,8 @@ +import Test 1.0 +import Qt 4.6 + +MyQmlObject { + property int a: Math.max(10, 9) + property int b: 11 + Component.onDestruction: console.log("Destruction " + a + " " + b); +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt b/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt new file mode 100644 index 0000000..3348494 --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.errors.txt @@ -0,0 +1 @@ +4:5:Cannot assign to non-existent property "onDestroyed" diff --git a/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml b/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml new file mode 100644 index 0000000..4eab50a --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/destroyedSignal.qml @@ -0,0 +1,5 @@ +import Qt 4.6 + +QtObject { + onDestroyed: print("Hello World!") +} diff --git a/tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml b/tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml new file mode 100644 index 0000000..7ebae7b --- /dev/null +++ b/tests/auto/declarative/qdeclarativelanguage/data/onDestruction.qml @@ -0,0 +1,17 @@ +import Test 1.0 +import Qt 4.6 + +MyTypeObject { + // We set a and b to ensure that onCompleted is executed after bindings and + // constants have been assigned + property int a: Math.min(6, 7) + Component.onDestruction: console.log("Destruction " + a + " " + nestedObject.b) + + objectProperty: OnDestructionType { + qmlobjectProperty: MyQmlObject { + id: nestedObject + property int b: 10 + Component.onDestruction: console.log("Destruction " + a + " " + nestedObject.b) + } + } +} diff --git a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp index 7c327c2..8feab32 100644 --- a/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp +++ b/tests/auto/declarative/qdeclarativelanguage/tst_qdeclarativelanguage.cpp @@ -113,6 +113,7 @@ private slots: void i18n(); void i18n_data(); void onCompleted(); + void onDestruction(); void scriptString(); void defaultPropertyListOrder(); void declaredPropertyValues(); @@ -329,6 +330,7 @@ void tst_qdeclarativelanguage::errors_data() QTest::newRow("missingValueTypeProperty") << "missingValueTypeProperty.qml" << "missingValueTypeProperty.errors.txt" << false; QTest::newRow("objectValueTypeProperty") << "objectValueTypeProperty.qml" << "objectValueTypeProperty.errors.txt" << false; QTest::newRow("enumTypes") << "enumTypes.qml" << "enumTypes.errors.txt" << false; + QTest::newRow("destroyedSignal") << "destroyedSignal.qml" << "destroyedSignal.errors.txt" << false; } @@ -1049,6 +1051,20 @@ void tst_qdeclarativelanguage::onCompleted() QVERIFY(object != 0); } +// Check that the Component::onDestruction attached property works +void tst_qdeclarativelanguage::onDestruction() +{ + QDeclarativeComponent component(&engine, TEST_FILE("onDestruction.qml")); + VERIFY_ERRORS(0); + QObject *object = component.create(); + QVERIFY(object != 0); + + QTest::ignoreMessage(QtDebugMsg, "Destruction 6 10"); + QTest::ignoreMessage(QtDebugMsg, "Destruction 6 10"); + QTest::ignoreMessage(QtDebugMsg, "Destruction 10 11"); + delete object; +} + // Check that assignments to QDeclarativeScriptString properties work void tst_qdeclarativelanguage::scriptString() { -- cgit v0.12 From 5783d51bcaed2a769c222ae7f6123f7638d6388a Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Thu, 15 Apr 2010 16:49:35 +1000 Subject: Simplify dynamic resource loading to avoid cluttering Text API. Task-number: QTBUG-9900 QT-3287 --- src/declarative/graphicsitems/qdeclarativetext.cpp | 13 ++++--------- src/declarative/graphicsitems/qdeclarativetext_p.h | 4 +--- .../declarative/qdeclarativetext/tst_qdeclarativetext.cpp | 6 +++++- 3 files changed, 10 insertions(+), 13 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativetext.cpp b/src/declarative/graphicsitems/qdeclarativetext.cpp index 9fcfd92..a95c930 100644 --- a/src/declarative/graphicsitems/qdeclarativetext.cpp +++ b/src/declarative/graphicsitems/qdeclarativetext.cpp @@ -77,7 +77,7 @@ protected: if (type == QTextDocument::ImageResource) { QPixmap pm; QString errorString; - QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(url, &pm, &errorString, 0, true, 0, 0); + QDeclarativePixmapReply::Status status = QDeclarativePixmapCache::get(url, &pm, &errorString, 0, false, 0, 0); if (status == QDeclarativePixmapReply::Ready) return pm; if (status == QDeclarativePixmapReply::Error) { @@ -89,7 +89,6 @@ protected: QDeclarativePixmapReply *reply = QDeclarativePixmapCache::request(qmlEngine(parent()), url); connect(reply, SIGNAL(finished()), this, SLOT(requestFinished())); outstanding++; - static_cast(parent())->reloadWithResources(); } } @@ -100,7 +99,8 @@ private slots: void requestFinished() { outstanding--; - static_cast(parent())->reloadWithResources(); + if (outstanding == 0) + static_cast(parent())->reloadWithResources(); } private: @@ -968,17 +968,13 @@ void QDeclarativeText::reloadWithResources() Q_D(QDeclarativeText); if (!d->richText) return; - if (resourcesLoading()!=0) - return; - emit resourcesLoadingChanged(); d->doc->setHtml(d->text); d->updateLayout(); d->markImgDirty(); } /*! - \qmlproperty int Text::resourcesLoading - This property is the number of resources (images) that are being loaded asynchronously. + Returns the number of resources (images) that are being loaded asynchronously. */ int QDeclarativeText::resourcesLoading() const { @@ -986,7 +982,6 @@ int QDeclarativeText::resourcesLoading() const return d->doc ? d->doc->resourcesLoading() : 0; } - void QDeclarativeText::paint(QPainter *p, const QStyleOptionGraphicsItem *, QWidget *) { Q_D(QDeclarativeText); diff --git a/src/declarative/graphicsitems/qdeclarativetext_p.h b/src/declarative/graphicsitems/qdeclarativetext_p.h index fcad898..4fd5e3a 100644 --- a/src/declarative/graphicsitems/qdeclarativetext_p.h +++ b/src/declarative/graphicsitems/qdeclarativetext_p.h @@ -72,7 +72,6 @@ class Q_DECLARATIVE_EXPORT QDeclarativeText : public QDeclarativeItem Q_PROPERTY(bool wrap READ wrap WRITE setWrap NOTIFY wrapModeChanged) Q_PROPERTY(TextFormat textFormat READ textFormat WRITE setTextFormat NOTIFY textFormatChanged) Q_PROPERTY(TextElideMode elide READ elideMode WRITE setElideMode NOTIFY elideModeChanged) //### elideMode? - Q_PROPERTY(int resourcesLoading READ resourcesLoading NOTIFY resourcesLoadingChanged) public: QDeclarativeText(QDeclarativeItem *parent=0); @@ -139,7 +138,7 @@ public: virtual void componentComplete(); - int resourcesLoading() const; + int resourcesLoading() const; // mainly for testing Q_SIGNALS: void textChanged(const QString &text); @@ -153,7 +152,6 @@ Q_SIGNALS: void wrapModeChanged(); void textFormatChanged(TextFormat textFormat); void elideModeChanged(TextElideMode mode); - void resourcesLoadingChanged(); protected: void mousePressEvent(QGraphicsSceneMouseEvent *event); diff --git a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp index ca7dfe7..edb4a32 100644 --- a/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp +++ b/tests/auto/declarative/qdeclarativetext/tst_qdeclarativetext.cpp @@ -897,10 +897,14 @@ void tst_qdeclarativetext::embeddedImages() QTRY_COMPARE(textObject->resourcesLoading(), 0); + QPixmap pm(SRCDIR "/data/http/exists.png"); if (error.isEmpty()) { - QPixmap pm(SRCDIR "/data/http/exists.png"); QCOMPARE(textObject->width(), double(pm.width())); QCOMPARE(textObject->height(), double(pm.height())); + } else { + QVERIFY(16 != pm.width()); // check test is effective + QCOMPARE(textObject->width(), 16.0); // default size of QTextDocument broken image icon + QCOMPARE(textObject->height(), 16.0); } } -- cgit v0.12 From 55a33571a2cbf8187f5533125f961316f866fca2 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 15 Apr 2010 16:53:12 +1000 Subject: Doc --- src/declarative/qml/qdeclarativecomponent.cpp | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) diff --git a/src/declarative/qml/qdeclarativecomponent.cpp b/src/declarative/qml/qdeclarativecomponent.cpp index 5cc6639..3e4651c 100644 --- a/src/declarative/qml/qdeclarativecomponent.cpp +++ b/src/declarative/qml/qdeclarativecomponent.cpp @@ -120,6 +120,26 @@ Item { } } \endqml + + \e onDestruction + + Emitted as the component begins destruction. This can be used to undo + work done in the onCompleted signal, or other imperative code in your + application. + + The \c {Component::onDestruction} attached property can be applied to + any element. However, it applies to the destruction of the component as + a whole, and not the destruction of the specific object. The order of + running the \c onDestruction scripts is undefined. + + \qml + Rectangle { + Component.onDestruction: console.log("Destruction Beginning!") + Rectangle { + Component.onDestruction: console.log("Nested Destruction Beginning!") + } + } + \endqml */ /*! -- cgit v0.12 From 0b3ade40922ecb06e3f67be96973322f8440bef9 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 15 Apr 2010 17:25:14 +1000 Subject: Compile without Qt3 support. --- src/declarative/util/qdeclarativepixmapcache.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp index 4a96a2a..893fbf3 100644 --- a/src/declarative/util/qdeclarativepixmapcache.cpp +++ b/src/declarative/util/qdeclarativepixmapcache.cpp @@ -662,7 +662,7 @@ QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QP } else if (pixmap->isNull()) { status = QDeclarativePixmapReply::Error; if (errorString) - *errorString = QDeclarativeImageRequestHandler::tr("Unknown Error loading %1").arg(url); + *errorString = QDeclarativeImageRequestHandler::tr("Unknown Error loading %1").arg(url.toString()); } else { status = QDeclarativePixmapReply::Ready; } -- cgit v0.12 From 2c9ff8dc79b69b310a568f7457838753abbf2178 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 15 Apr 2010 17:48:56 +1000 Subject: Support valuetypes as method return values QTBUG-9818 --- src/declarative/qml/qdeclarativeengine.cpp | 4 +- src/declarative/qml/qdeclarativevaluetype.cpp | 6 - src/declarative/qml/qdeclarativevaluetype_p.h | 5 +- .../qml/qdeclarativevaluetypescriptclass.cpp | 123 +++++++++++++++------ .../qml/qdeclarativevaluetypescriptclass_p.h | 1 + .../tst_qdeclarativeecmascript.cpp | 1 - .../qdeclarativevaluetypes/data/returnValues.qml | 17 +++ .../declarative/qdeclarativevaluetypes/testtypes.h | 3 + .../tst_qdeclarativevaluetypes.cpp | 14 +++ 9 files changed, 133 insertions(+), 41 deletions(-) create mode 100644 tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml diff --git a/src/declarative/qml/qdeclarativeengine.cpp b/src/declarative/qml/qdeclarativeengine.cpp index 1deadb2..96145fb 100644 --- a/src/declarative/qml/qdeclarativeengine.cpp +++ b/src/declarative/qml/qdeclarativeengine.cpp @@ -1365,7 +1365,9 @@ QScriptValue QDeclarativeEnginePrivate::scriptValueFromVariant(const QVariant &v rv.setProperty(ii, objectClass->newQObject(object)); } return rv; - } + } else if (QDeclarativeValueType *vt = valueTypes[val.userType()]) { + return valueTypeClass->newObject(val, vt); + } bool objOk; QObject *obj = QDeclarativeMetaType::toQObject(val, &objOk); diff --git a/src/declarative/qml/qdeclarativevaluetype.cpp b/src/declarative/qml/qdeclarativevaluetype.cpp index 261c84a..352a6c0 100644 --- a/src/declarative/qml/qdeclarativevaluetype.cpp +++ b/src/declarative/qml/qdeclarativevaluetype.cpp @@ -99,12 +99,6 @@ void QDeclarativeValueTypeFactory::registerValueTypes() qmlRegisterValueTypeEnums("Font"); } -QDeclarativeValueType *QDeclarativeValueTypeFactory::operator[](int idx) const -{ - return valueTypes[idx]; -} - - QDeclarativeValueType *QDeclarativeValueTypeFactory::valueType(int t) { switch (t) { diff --git a/src/declarative/qml/qdeclarativevaluetype_p.h b/src/declarative/qml/qdeclarativevaluetype_p.h index 5bfc27d..d1833bb 100644 --- a/src/declarative/qml/qdeclarativevaluetype_p.h +++ b/src/declarative/qml/qdeclarativevaluetype_p.h @@ -86,7 +86,10 @@ public: static void registerValueTypes(); - QDeclarativeValueType *operator[](int idx) const; + QDeclarativeValueType *operator[](int idx) const { + if (idx >= (int)QVariant::UserType) return 0; + else return valueTypes[idx]; + } private: QDeclarativeValueType *valueTypes[QVariant::UserType - 1]; diff --git a/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp b/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp index fdb71c6..cb1f27d 100644 --- a/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp +++ b/src/declarative/qml/qdeclarativevaluetypescriptclass.cpp @@ -48,12 +48,24 @@ QT_BEGIN_NAMESPACE -struct QDeclarativeValueTypeReference : public QScriptDeclarativeClass::Object { +struct QDeclarativeValueTypeObject : public QScriptDeclarativeClass::Object { + enum Type { Reference, Copy }; + QDeclarativeValueTypeObject(Type t) : objectType(t) {} + Type objectType; QDeclarativeValueType *type; +}; + +struct QDeclarativeValueTypeReference : public QDeclarativeValueTypeObject { + QDeclarativeValueTypeReference() : QDeclarativeValueTypeObject(Reference) {} QDeclarativeGuard object; int property; }; +struct QDeclarativeValueTypeCopy : public QDeclarativeValueTypeObject { + QDeclarativeValueTypeCopy() : QDeclarativeValueTypeObject(Copy) {} + QVariant value; +}; + QDeclarativeValueTypeScriptClass::QDeclarativeValueTypeScriptClass(QDeclarativeEngine *bindEngine) : QScriptDeclarativeClass(QDeclarativeEnginePrivate::getScriptEngine(bindEngine)), engine(bindEngine) { @@ -73,40 +85,67 @@ QScriptValue QDeclarativeValueTypeScriptClass::newObject(QObject *object, int co return QScriptDeclarativeClass::newObject(scriptEngine, this, ref); } +QScriptValue QDeclarativeValueTypeScriptClass::newObject(const QVariant &v, QDeclarativeValueType *type) +{ + QDeclarativeValueTypeCopy *copy = new QDeclarativeValueTypeCopy; + copy->type = type; + copy->value = v; + QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine); + return QScriptDeclarativeClass::newObject(scriptEngine, this, copy); +} + QScriptClass::QueryFlags QDeclarativeValueTypeScriptClass::queryProperty(Object *obj, const Identifier &name, - QScriptClass::QueryFlags) + QScriptClass::QueryFlags) { - QDeclarativeValueTypeReference *ref = static_cast(obj); + QDeclarativeValueTypeObject *o = static_cast(obj); m_lastIndex = -1; - if (!ref->object) - return 0; - QByteArray propName = toString(name).toUtf8(); - m_lastIndex = ref->type->metaObject()->indexOfProperty(propName.constData()); + m_lastIndex = o->type->metaObject()->indexOfProperty(propName.constData()); if (m_lastIndex == -1) return 0; - QMetaProperty prop = ref->object->metaObject()->property(m_lastIndex); + QScriptClass::QueryFlags rv = 0; + + if (o->objectType == QDeclarativeValueTypeObject::Reference) { + QDeclarativeValueTypeReference *ref = static_cast(o); + + if (!ref->object) + return 0; - QScriptClass::QueryFlags rv = - QScriptClass::HandlesReadAccess; - if (prop.isWritable()) - rv |= QScriptClass::HandlesWriteAccess; + QMetaProperty prop = ref->object->metaObject()->property(m_lastIndex); + + rv = QScriptClass::HandlesReadAccess; + if (prop.isWritable()) + rv |= QScriptClass::HandlesWriteAccess; + } else { + rv = QScriptClass::HandlesReadAccess | QScriptClass::HandlesWriteAccess; + } return rv; } QDeclarativeValueTypeScriptClass::Value QDeclarativeValueTypeScriptClass::property(Object *obj, const Identifier &) { - QDeclarativeValueTypeReference *ref = static_cast(obj); + QDeclarativeValueTypeObject *o = static_cast(obj); - QMetaProperty p = ref->type->metaObject()->property(m_lastIndex); - ref->type->read(ref->object, ref->property); - QVariant rv = p.read(ref->type); + QVariant rv; + if (o->objectType == QDeclarativeValueTypeObject::Reference) { + QDeclarativeValueTypeReference *ref = static_cast(obj); + + QMetaProperty p = ref->type->metaObject()->property(m_lastIndex); + ref->type->read(ref->object, ref->property); + rv = p.read(ref->type); + } else { + QDeclarativeValueTypeCopy *copy = static_cast(obj); + + QMetaProperty p = copy->type->metaObject()->property(m_lastIndex); + copy->type->setValue(copy->value); + rv = p.read(copy->type); + } QScriptEngine *scriptEngine = QDeclarativeEnginePrivate::getScriptEngine(engine); return Value(scriptEngine, static_cast(QObjectPrivate::get(engine))->scriptValueFromVariant(rv)); @@ -115,33 +154,53 @@ QDeclarativeValueTypeScriptClass::Value QDeclarativeValueTypeScriptClass::proper void QDeclarativeValueTypeScriptClass::setProperty(Object *obj, const Identifier &, const QScriptValue &value) { - QDeclarativeValueTypeReference *ref = static_cast(obj); - - QDeclarativeAbstractBinding *delBinding = - QDeclarativePropertyPrivate::setBinding(ref->object, ref->property, m_lastIndex, 0); - if (delBinding) - delBinding->destroy(); + QDeclarativeValueTypeObject *o = static_cast(obj); QVariant v = QDeclarativeEnginePrivate::get(engine)->scriptValueToVariant(value); - ref->type->read(ref->object, ref->property); - QMetaProperty p = ref->type->metaObject()->property(m_lastIndex); - p.write(ref->type, v); - ref->type->write(ref->object, ref->property, 0); + if (o->objectType == QDeclarativeValueTypeObject::Reference) { + QDeclarativeValueTypeReference *ref = static_cast(obj); + + QDeclarativeAbstractBinding *delBinding = + QDeclarativePropertyPrivate::setBinding(ref->object, ref->property, m_lastIndex, 0); + if (delBinding) + delBinding->destroy(); + + ref->type->read(ref->object, ref->property); + QMetaProperty p = ref->type->metaObject()->property(m_lastIndex); + p.write(ref->type, v); + ref->type->write(ref->object, ref->property, 0); + } else { + QDeclarativeValueTypeCopy *copy = static_cast(obj); + copy->type->setValue(copy->value); + QMetaProperty p = copy->type->metaObject()->property(m_lastIndex); + p.write(copy->type, v); + copy->value = copy->type->value(); + } } QVariant QDeclarativeValueTypeScriptClass::toVariant(Object *obj, bool *ok) { - QDeclarativeValueTypeReference *ref = static_cast(obj); + QDeclarativeValueTypeObject *o = static_cast(obj); - if (ok) *ok = true; + if (o->objectType == QDeclarativeValueTypeObject::Reference) { + QDeclarativeValueTypeReference *ref = static_cast(obj); - if (ref->object) { - ref->type->read(ref->object, ref->property); - return ref->type->value(); + if (ok) *ok = true; + + if (ref->object) { + ref->type->read(ref->object, ref->property); + return ref->type->value(); + } } else { - return QVariant(); + QDeclarativeValueTypeCopy *copy = static_cast(obj); + + if (ok) *ok = true; + + return copy->value; } + + return QVariant(); } QVariant QDeclarativeValueTypeScriptClass::toVariant(const QScriptValue &value) diff --git a/src/declarative/qml/qdeclarativevaluetypescriptclass_p.h b/src/declarative/qml/qdeclarativevaluetypescriptclass_p.h index 2bbb61f..9dafa99 100644 --- a/src/declarative/qml/qdeclarativevaluetypescriptclass_p.h +++ b/src/declarative/qml/qdeclarativevaluetypescriptclass_p.h @@ -67,6 +67,7 @@ public: ~QDeclarativeValueTypeScriptClass(); QScriptValue newObject(QObject *object, int coreIndex, QDeclarativeValueType *); + QScriptValue newObject(const QVariant &, QDeclarativeValueType *); virtual QScriptClass::QueryFlags queryProperty(Object *, const Identifier &, QScriptClass::QueryFlags flags); diff --git a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp index 35b4d99..098ac36 100644 --- a/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp +++ b/tests/auto/declarative/qdeclarativeecmascript/tst_qdeclarativeecmascript.cpp @@ -1382,7 +1382,6 @@ void tst_qdeclarativeecmascript::callQtInvokables() o.reset(); { QScriptValue ret = engine->evaluate("object.method_NoArgs_QPointF()"); - QVERIFY(ret.isVariant()); QCOMPARE(ret.toVariant(), QVariant(QPointF(123, 4.5))); QCOMPARE(o.error(), false); QCOMPARE(o.invoked(), 3); diff --git a/tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml b/tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml new file mode 100644 index 0000000..185e7ba --- /dev/null +++ b/tests/auto/declarative/qdeclarativevaluetypes/data/returnValues.qml @@ -0,0 +1,17 @@ +import Test 1.0 +import Qt 4.6 + +MyTypeObject { + property bool test1: false; + property bool test2: false; + + Component.onCompleted: { + var a = method(); + + test1 = (a.width == 13) + test2 = (a.height == 14) + + size = a; + } +} + diff --git a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h index 9057b4f..dd13429 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h +++ b/tests/auto/declarative/qdeclarativevaluetypes/testtypes.h @@ -129,6 +129,9 @@ public: signals: void changed(); void runScript(); + +public slots: + QSize method() { return QSize(13, 14); } }; QML_DECLARE_TYPE(MyTypeObject); diff --git a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp index e653abf..b733b10 100644 --- a/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp +++ b/tests/auto/declarative/qdeclarativevaluetypes/tst_qdeclarativevaluetypes.cpp @@ -79,6 +79,7 @@ private slots: void cppClasses(); void enums(); void conflictingBindings(); + void returnValues(); private: QDeclarativeEngine engine; @@ -763,6 +764,19 @@ void tst_qdeclarativevaluetypes::conflictingBindings() } } +void tst_qdeclarativevaluetypes::returnValues() +{ + QDeclarativeComponent component(&engine, TEST_FILE("returnValues.qml")); + QObject *object = component.create(); + QVERIFY(object != 0); + + QCOMPARE(object->property("test1").toBool(), true); + QCOMPARE(object->property("test2").toBool(), true); + QCOMPARE(object->property("size").toSize(), QSize(13, 14)); + + delete object; +} + QTEST_MAIN(tst_qdeclarativevaluetypes) #include "tst_qdeclarativevaluetypes.moc" -- cgit v0.12 From b9f71669979f7e892e3af3197915bb732ab0f243 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Thu, 15 Apr 2010 18:23:33 +1000 Subject: Update examples autotest to use the runtime directly This improves the test execution time --- tests/auto/declarative/examples/examples.pro | 2 + tests/auto/declarative/examples/tst_examples.cpp | 103 ++++++----------------- tools/qml/qmlruntime.cpp | 28 +++--- tools/qml/qmlruntime.h | 5 +- 4 files changed, 42 insertions(+), 96 deletions(-) diff --git a/tests/auto/declarative/examples/examples.pro b/tests/auto/declarative/examples/examples.pro index b316cb9..4c32524 100644 --- a/tests/auto/declarative/examples/examples.pro +++ b/tests/auto/declarative/examples/examples.pro @@ -4,6 +4,8 @@ macx:CONFIG -= app_bundle SOURCES += tst_examples.cpp +include(../../../../tools/qml/qml.pri) + DEFINES += SRCDIR=\\\"$$PWD\\\" CONFIG += parallel_test diff --git a/tests/auto/declarative/examples/tst_examples.cpp b/tests/auto/declarative/examples/tst_examples.cpp index e62aad2..c650346 100644 --- a/tests/auto/declarative/examples/tst_examples.cpp +++ b/tests/auto/declarative/examples/tst_examples.cpp @@ -43,8 +43,9 @@ #include #include #include -#include -#include +#include "qmlruntime.h" +#include +#include class tst_examples : public QObject { @@ -53,6 +54,7 @@ public: tst_examples(); private slots: + void examples_data(); void examples(); void namingConvention(); @@ -173,8 +175,6 @@ QStringList tst_examples::findQmlFiles(const QDir &d) return rv; } - - /* This test runs all the examples in the declarative UI source tree and ensures that they start and exit cleanly. @@ -182,57 +182,9 @@ that they start and exit cleanly. Examples are any .qml files under the examples/ or demos/ directory that start with a lower case letter. */ -#define THREADS 5 - -struct Example { -public: - Example() : result(Unknown) {} - - enum Result { Pass, Unknown, Fail }; - Result result; - QString file; - QString qmlruntime; - - void run(); -}; - -void Example::run() +void tst_examples::examples_data() { - QFileInfo fi(file); - QFileInfo dir(fi.path()); - QString script = SRCDIR "/data/"+dir.baseName()+"/"+fi.baseName(); - QFileInfo testdata(script+".qml"); - QStringList arguments; - arguments << "-script" << (testdata.exists() ? script : QLatin1String(SRCDIR "/data/dummytest")) - << "-scriptopts" << "play,testerror,exitoncomplete,exitonfailure" - << file; -#ifdef Q_WS_QWS - arguments << "-qws"; -#endif - - QProcess p; - p.start(qmlruntime, arguments); - if (!p.waitForFinished()) { - result = Fail; - return; - } - - if (p.exitStatus() != QProcess::NormalExit || p.exitCode() != 0) - qWarning() << p.readAllStandardOutput() << p.readAllStandardError(); - - if (p.exitStatus() != QProcess::NormalExit || - p.exitCode() != 0) { - result = Fail; - return; - } else { - result = Pass; - return; - } -} - -void tst_examples::examples() -{ - QThreadPool::globalInstance()->setMaxThreadCount(5); + QTest::addColumn("file"); QString examples = QLatin1String(SRCDIR) + "/../../../../demos/declarative/"; QString demos = QLatin1String(SRCDIR) + "/../../../../examples/declarative/"; @@ -243,38 +195,31 @@ void tst_examples::examples() files << findQmlFiles(QDir(demos)); files << findQmlFiles(QDir(snippets)); - QList tests; - - for (int ii = 0; ii < files.count(); ++ii) { - Example e; - e.file = files.at(ii); - e.qmlruntime = qmlruntime; - tests << e; - } + foreach (const QString &file, files) + QTest::newRow(qPrintable(file)) << file; +} - QFutureSynchronizer sync; +static void silentErrorsMsgHandler(QtMsgType, const char *) +{ +} - for (int ii = 0; ii < tests.count(); ++ii) { - Example *e = &tests[ii]; - QFuture r = QtConcurrent::run(e, &Example::run); - sync.addFuture(r); - } +void tst_examples::examples() +{ + QFETCH(QString, file); - sync.waitForFinished(); + QDeclarativeViewer viewer; - QStringList failures; - for (int ii = 0; ii < tests.count(); ++ii) { - if (tests.at(ii).result != Example::Pass) - failures << QDir::cleanPath(tests.at(ii).file); - } + QtMsgHandler old = qInstallMsgHandler(silentErrorsMsgHandler); + QVERIFY(viewer.open(file)); + qInstallMsgHandler(old); - if (failures.count()) { - QString error("Failed examples: "); - error += failures.join(", "); + if (viewer.view()->status() == QDeclarativeView::Error) + qWarning() << viewer.view()->errors(); - QFAIL(qPrintable(error)); - } + QCOMPARE(viewer.view()->status(), QDeclarativeView::Ready); + viewer.show(); + QTest::qWaitForWindowShown(&viewer); } QTEST_MAIN(tst_examples) diff --git a/tools/qml/qmlruntime.cpp b/tools/qml/qmlruntime.cpp index 0a0ad9b..53409c1 100644 --- a/tools/qml/qmlruntime.cpp +++ b/tools/qml/qmlruntime.cpp @@ -550,6 +550,11 @@ QMenuBar *QDeclarativeViewer::menuBar() const return mb; } +QDeclarativeView *QDeclarativeViewer::view() const +{ + return canvas; +} + void QDeclarativeViewer::createMenu(QMenuBar *menu, QMenu *flatmenu) { QObject *parent = flatmenu ? (QObject*)flatmenu : (QObject*)menu; @@ -888,24 +893,19 @@ void QDeclarativeViewer::addPluginPath(const QString& plugin) void QDeclarativeViewer::reload() { - openQml(currentFileOrUrl); -} - -void QDeclarativeViewer::open(const QString& doc) -{ - openQml(doc); + open(currentFileOrUrl); } void QDeclarativeViewer::openFile() { QString cur = canvas->source().toLocalFile(); if (useQmlFileBrowser) { - openQml("qrc:/content/Browser.qml"); + open("qrc:/content/Browser.qml"); } else { QString fileName = QFileDialog::getOpenFileName(this, tr("Open QML file"), cur, tr("QML Files (*.qml)")); if (!fileName.isEmpty()) { QFileInfo fi(fileName); - openQml(fi.absoluteFilePath()); + open(fi.absoluteFilePath()); } } } @@ -935,10 +935,10 @@ void QDeclarativeViewer::statusChanged() void QDeclarativeViewer::launch(const QString& file_or_url) { - QMetaObject::invokeMethod(this, "openQml", Qt::QueuedConnection, Q_ARG(QString, file_or_url)); + QMetaObject::invokeMethod(this, "open", Qt::QueuedConnection, Q_ARG(QString, file_or_url)); } -void QDeclarativeViewer::openQml(const QString& file_or_url) +bool QDeclarativeViewer::open(const QString& file_or_url) { currentFileOrUrl = file_or_url; @@ -971,7 +971,7 @@ void QDeclarativeViewer::openQml(const QString& file_or_url) if (fi.exists()) { if (fi.suffix().toLower() != QLatin1String("qml")) { qWarning() << "qml cannot open non-QML file" << fileName; - return; + return false; } QDir dir(fi.path()+"/dummydata", "*.qml"); @@ -1002,7 +1002,7 @@ void QDeclarativeViewer::openQml(const QString& file_or_url) } } else { qWarning() << "qml cannot find file:" << fileName; - return; + return false; } } @@ -1013,9 +1013,7 @@ void QDeclarativeViewer::openQml(const QString& file_or_url) qWarning() << "Wall startup time:" << t.elapsed(); -#ifdef QTOPIA - show(); -#endif + return true; } void QDeclarativeViewer::startNetwork() diff --git a/tools/qml/qmlruntime.h b/tools/qml/qmlruntime.h index 8792d0c..2089dda 100644 --- a/tools/qml/qmlruntime.h +++ b/tools/qml/qmlruntime.h @@ -105,10 +105,11 @@ public: QMenuBar *menuBar() const; + QDeclarativeView *view() const; + public slots: void sceneResized(QSize size); - void open(const QString&); - void openQml(const QString&); + bool open(const QString&); void openFile(); void reload(); void takeSnapShot(); -- cgit v0.12 From 0e0009e0bae445938e73e3ea7b031c882b8930d2 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 15 Apr 2010 18:54:57 +1000 Subject: Improve declarative calculator example. --- demos/declarative/calculator/CalcButton.qml | 41 ----- demos/declarative/calculator/Core/Button.qml | 39 +++++ demos/declarative/calculator/Core/Display.qml | 27 ++++ demos/declarative/calculator/Core/calculator.js | 91 +++++++++++ .../declarative/calculator/Core/images/button-.png | Bin 0 -> 1288 bytes .../calculator/Core/images/button-blue.png | Bin 0 -> 1565 bytes .../calculator/Core/images/button-green.png | Bin 0 -> 1543 bytes .../calculator/Core/images/button-purple.png | Bin 0 -> 1566 bytes .../calculator/Core/images/button-red.png | Bin 0 -> 1586 bytes .../declarative/calculator/Core/images/display.png | Bin 0 -> 998 bytes demos/declarative/calculator/Core/qmldir | 2 + demos/declarative/calculator/calculator.js | 87 ---------- demos/declarative/calculator/calculator.qml | 178 +++++++++------------ 13 files changed, 238 insertions(+), 227 deletions(-) delete mode 100644 demos/declarative/calculator/CalcButton.qml create mode 100644 demos/declarative/calculator/Core/Button.qml create mode 100644 demos/declarative/calculator/Core/Display.qml create mode 100644 demos/declarative/calculator/Core/calculator.js create mode 100644 demos/declarative/calculator/Core/images/button-.png create mode 100644 demos/declarative/calculator/Core/images/button-blue.png create mode 100644 demos/declarative/calculator/Core/images/button-green.png create mode 100644 demos/declarative/calculator/Core/images/button-purple.png create mode 100644 demos/declarative/calculator/Core/images/button-red.png create mode 100644 demos/declarative/calculator/Core/images/display.png create mode 100644 demos/declarative/calculator/Core/qmldir delete mode 100644 demos/declarative/calculator/calculator.js diff --git a/demos/declarative/calculator/CalcButton.qml b/demos/declarative/calculator/CalcButton.qml deleted file mode 100644 index a125346..0000000 --- a/demos/declarative/calculator/CalcButton.qml +++ /dev/null @@ -1,41 +0,0 @@ -import Qt 4.7 - -Rectangle { - property alias operation: label.text - property bool toggable: false - property bool toggled: false - signal clicked - - id: button; width: 50; height: 30 - border.color: palette.mid; radius: 6 - gradient: Gradient { - GradientStop { id: gradientStop1; position: 0.0; color: Qt.lighter(palette.button) } - GradientStop { id: gradientStop2; position: 1.0; color: palette.button } - } - - Text { id: label; anchors.centerIn: parent; color: palette.buttonText } - - MouseArea { - id: clickRegion - anchors.fill: parent - onClicked: { - doOp(operation); - button.clicked(); - if (!button.toggable) return; - button.toggled ? button.toggled = false : button.toggled = true - } - } - - states: [ - State { - name: "Pressed"; when: clickRegion.pressed == true - PropertyChanges { target: gradientStop1; color: palette.dark } - PropertyChanges { target: gradientStop2; color: palette.button } - }, - State { - name: "Toggled"; when: button.toggled == true - PropertyChanges { target: gradientStop1; color: palette.dark } - PropertyChanges { target: gradientStop2; color: palette.button } - } - ] -} diff --git a/demos/declarative/calculator/Core/Button.qml b/demos/declarative/calculator/Core/Button.qml new file mode 100644 index 0000000..8948adc --- /dev/null +++ b/demos/declarative/calculator/Core/Button.qml @@ -0,0 +1,39 @@ +import Qt 4.7 + +BorderImage { + id: button + + property alias operation: buttonText.text + property string color: "" + + signal clicked + + source: "images/button-" + color + ".png"; clip: true + border { left: 10; top: 10; right: 10; bottom: 10 } + + Rectangle { + id: shade + anchors.fill: button; radius: 10; color: "black"; opacity: 0 + } + + Text { + id: buttonText + anchors.centerIn: parent; anchors.verticalCenterOffset: -1 + font.pixelSize: parent.width > parent.height ? parent.height * .5 : parent.width * .5 + style: Text.Sunken; color: "white"; styleColor: "black"; smooth: true + } + + MouseArea { + id: mouseArea + anchors.fill: parent + onClicked: { + doOp(operation) + button.clicked() + } + } + + states: State { + name: "pressed"; when: mouseArea.pressed == true + PropertyChanges { target: shade; opacity: .4 } + } +} diff --git a/demos/declarative/calculator/Core/Display.qml b/demos/declarative/calculator/Core/Display.qml new file mode 100644 index 0000000..b98c44b --- /dev/null +++ b/demos/declarative/calculator/Core/Display.qml @@ -0,0 +1,27 @@ +import Qt 4.7 + +BorderImage { + id: image + + property alias text : displayText.text + property alias currentOperation : operationText + + source: "images/display.png" + border { left: 10; top: 10; right: 10; bottom: 10 } + + Text { + id: displayText + anchors { + right: parent.right; verticalCenter: parent.verticalCenter; verticalCenterOffset: -1 + rightMargin: 6; left: operationText.right + } + font.pixelSize: parent.height * .6; text: "0"; horizontalAlignment: Text.AlignRight; elide: Text.ElideRight + color: "#343434"; smooth: true; font.bold: true + } + Text { + id: operationText + font.bold: true; font.pixelSize: parent.height * .7 + color: "#343434"; smooth: true + anchors { left: parent.left; leftMargin: 6; verticalCenterOffset: -3; verticalCenter: parent.verticalCenter } + } +} diff --git a/demos/declarative/calculator/Core/calculator.js b/demos/declarative/calculator/Core/calculator.js new file mode 100644 index 0000000..2b19de8 --- /dev/null +++ b/demos/declarative/calculator/Core/calculator.js @@ -0,0 +1,91 @@ + +var curVal = 0 +var memory = 0 +var lastOp = "" +var timer = 0 + +function disabled(op) { + if (op == "." && display.text.toString().search(/\./) != -1) { + return true + } else if (op == squareRoot && display.text.toString().search(/-/) != -1) { + return true + } else { + return false + } +} + +function doOperation(op) { + if (disabled(op)) { + return + } + + if (op.toString().length==1 && ((op >= "0" && op <= "9") || op==".") ) { + if (display.text.toString().length >= 14) + return; // No arbitrary length numbers + if (lastOp.toString().length == 1 && ((lastOp >= "0" && lastOp <= "9") || lastOp == ".") ) { + display.text = display.text + op.toString() + } else { + display.text = op + } + lastOp = op + return + } + lastOp = op + + if (display.currentOperation.text == "+") { + display.text = Number(display.text.valueOf()) + Number(curVal.valueOf()) + } else if (display.currentOperation.text == "-") { + display.text = Number(curVal) - Number(display.text.valueOf()) + } else if (display.currentOperation.text == multiplication) { + display.text = Number(curVal) * Number(display.text.valueOf()) + } else if (display.currentOperation.text == division) { + display.text = Number(Number(curVal) / Number(display.text.valueOf())).toString() + } else if (display.currentOperation.text == "=") { + } + + if (op == "+" || op == "-" || op == multiplication || op == division) { + display.currentOperation.text = op + curVal = display.text.valueOf() + return + } + + curVal = 0 + display.currentOperation.text = "" + + if (op == "1/x") { + display.text = (1 / display.text.valueOf()).toString() + } else if (op == "^2") { + display.text = (display.text.valueOf() * display.text.valueOf()).toString() + } else if (op == "Abs") { + display.text = (Math.abs(display.text.valueOf())).toString() + } else if (op == "Int") { + display.text = (Math.floor(display.text.valueOf())).toString() + } else if (op == plusminus) { + display.text = (display.text.valueOf() * -1).toString() + } else if (op == squareRoot) { + display.text = (Math.sqrt(display.text.valueOf())).toString() + } else if (op == "mc") { + memory = 0; + } else if (op == "m+") { + memory += display.text.valueOf() + } else if (op == "mr") { + display.text = memory.toString() + } else if (op == "m-") { + memory = display.text.valueOf() + } else if (op == leftArrow) { + display.text = display.text.toString().slice(0, -1) + } else if (op == "C") { + display.text = "0" + } else if (op == "AC") { + curVal = 0 + memory = 0 + lastOp = "" + display.text ="0" + } + + if (op == rotateLeft) + main.state = 'rotated' + if (op == rotateRight) + main.state = '' +} + diff --git a/demos/declarative/calculator/Core/images/button-.png b/demos/declarative/calculator/Core/images/button-.png new file mode 100644 index 0000000..544e514 Binary files /dev/null and b/demos/declarative/calculator/Core/images/button-.png differ diff --git a/demos/declarative/calculator/Core/images/button-blue.png b/demos/declarative/calculator/Core/images/button-blue.png new file mode 100644 index 0000000..5f92de3 Binary files /dev/null and b/demos/declarative/calculator/Core/images/button-blue.png differ diff --git a/demos/declarative/calculator/Core/images/button-green.png b/demos/declarative/calculator/Core/images/button-green.png new file mode 100644 index 0000000..36c9391 Binary files /dev/null and b/demos/declarative/calculator/Core/images/button-green.png differ diff --git a/demos/declarative/calculator/Core/images/button-purple.png b/demos/declarative/calculator/Core/images/button-purple.png new file mode 100644 index 0000000..347cbbe Binary files /dev/null and b/demos/declarative/calculator/Core/images/button-purple.png differ diff --git a/demos/declarative/calculator/Core/images/button-red.png b/demos/declarative/calculator/Core/images/button-red.png new file mode 100644 index 0000000..3b33589 Binary files /dev/null and b/demos/declarative/calculator/Core/images/button-red.png differ diff --git a/demos/declarative/calculator/Core/images/display.png b/demos/declarative/calculator/Core/images/display.png new file mode 100644 index 0000000..9507f43 Binary files /dev/null and b/demos/declarative/calculator/Core/images/display.png differ diff --git a/demos/declarative/calculator/Core/qmldir b/demos/declarative/calculator/Core/qmldir new file mode 100644 index 0000000..a926b93 --- /dev/null +++ b/demos/declarative/calculator/Core/qmldir @@ -0,0 +1,2 @@ +Button Button.qml +Display Display.qml diff --git a/demos/declarative/calculator/calculator.js b/demos/declarative/calculator/calculator.js deleted file mode 100644 index f172daf..0000000 --- a/demos/declarative/calculator/calculator.js +++ /dev/null @@ -1,87 +0,0 @@ - -var curVal = 0; -var memory = 0; -var lastOp = ""; -var timer = 0; - -function disabled(op) { - if (op == "." && curNum.text.toString().search(/\./) != -1) { - return true; - } else if (op == "Sqrt" && curNum.text.toString().search(/-/) != -1) { - return true; - } else { - return false; - } -} - -function doOperation(op) { - if (disabled(op)) { - return; - } - - if (op.toString().length==1 && ((op >= "0" && op <= "9") || op==".") ) { - if (curNum.text.toString().length >= 14) - return; // No arbitrary length numbers - if (lastOp.toString().length == 1 && ((lastOp >= "0" && lastOp <= "9") || lastOp==".") ) { - curNum.text = curNum.text + op.toString(); - } else { - curNum.text = op; - } - lastOp = op; - return; - } - lastOp = op; - - // Pending operations - if (currentOperation.text == "+") { - curNum.text = Number(curNum.text.valueOf()) + Number(curVal.valueOf()); - } else if (currentOperation.text == "-") { - curNum.text = Number(curVal) - Number(curNum.text.valueOf()); - } else if (currentOperation.text == "x") { - curNum.text = Number(curVal) * Number(curNum.text.valueOf()); - } else if (currentOperation.text == "/") { - curNum.text = Number(Number(curVal) / Number(curNum.text.valueOf())).toString(); - } else if (currentOperation.text == "=") { - } - - if (op == "+" || op == "-" || op == "x" || op == "/") { - currentOperation.text = op; - curVal = curNum.text.valueOf(); - return; - } - curVal = 0; - currentOperation.text = ""; - - // Immediate operations - if (op == "1/x") { // reciprocal - curNum.text = (1 / curNum.text.valueOf()).toString(); - } else if (op == "^2") { // squared - curNum.text = (curNum.text.valueOf() * curNum.text.valueOf()).toString(); - } else if (op == "Abs") { - curNum.text = (Math.abs(curNum.text.valueOf())).toString(); - } else if (op == "Int") { - curNum.text = (Math.floor(curNum.text.valueOf())).toString(); - } else if (op == "+/-") { // plus/minus - curNum.text = (curNum.text.valueOf() * -1).toString(); - } else if (op == "Sqrt") { // square root - curNum.text = (Math.sqrt(curNum.text.valueOf())).toString(); - } else if (op == "MC") { // memory clear - memory = 0; - } else if (op == "M+") { // memory increment - memory += curNum.text.valueOf(); - } else if (op == "MR") { // memory recall - curNum.text = memory.toString(); - } else if (op == "MS") { // memory set - memory = curNum.text.valueOf(); - } else if (op == "Bksp") { - curNum.text = curNum.text.toString().slice(0, -1); - } else if (op == "C") { - curNum.text = "0"; - } else if (op == "AC") { - curVal = 0; - memory = 0; - lastOp = ""; - curNum.text ="0"; - } -} - diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml index b8e506e..fc2b95a 100644 --- a/demos/declarative/calculator/calculator.qml +++ b/demos/declarative/calculator/calculator.qml @@ -1,126 +1,106 @@ import Qt 4.7 -import "calculator.js" as CalcEngine +import "Core" +import "Core/calculator.js" as CalcEngine Rectangle { - width: 320; height: 270; color: palette.window + id: window - function doOp(operation) { CalcEngine.doOperation(operation); } + width: 480; height: 360 + color: "#282828" - SystemPalette { id: palette } + property string rotateLeft: "\u2939" + property string rotateRight: "\u2935" + property string leftArrow: "\u2190" + property string division : "\u00f7" + property string multiplication : "\u00d7" + property string squareRoot : "\u221a" + property string plusminus : "\u00b1" - Column { - x: 2; spacing: 10; + function doOp(operation) { CalcEngine.doOperation(operation) } - Rectangle { - id: container - width: 316; height: 50 - border.color: palette.dark; color: palette.base + Item { + id: main + state: (runtime.orientation == Orientation.Portrait) ? '' : 'rotated' + width: parent.width; height: parent.height; anchors.centerIn: parent - Text { - id: curNum - font.bold: true; font.pointSize: 16 - color: palette.text - anchors.right: container.right - anchors.rightMargin: 5 - anchors.verticalCenter: container.verticalCenter - } + Column { + id: box; spacing: 8 - Text { - id: currentOperation - color: palette.text - font.bold: true; font.pointSize: 16 - anchors.left: container.left - anchors.leftMargin: 5 - anchors.verticalCenter: container.verticalCenter - } - } + anchors { fill: parent; topMargin: 6; bottomMargin: 6; leftMargin: 6; rightMargin: 6 } - Item { - width: 320; height: 30 - - CalcButton { - id: advancedCheckBox - x: 55; width: 206 - operation: "Advanced Mode" - toggable: true + Row { + Display { id: display; width: box.width; height: 64 } } - } - Item { - width: 320; height: 160 + Column { + id: column; spacing: 6 - Item { - id: basicButtons - x: 55; width: 160; height: 160 + property real h: ((box.height - 72) / 6) - ((spacing * (6 - 1)) / 6) - CalcButton { operation: "Bksp"; id: bksp; width: 67; opacity: 0 } - CalcButton { operation: "C"; id: c; width: 76 } - CalcButton { operation: "AC"; id: ac; x: 78; width: 76 } - - Grid { - id: numKeypad; y: 32; spacing: 2; columns: 3 - - CalcButton { operation: "7" } - CalcButton { operation: "8" } - CalcButton { operation: "9" } - CalcButton { operation: "4" } - CalcButton { operation: "5" } - CalcButton { operation: "6" } - CalcButton { operation: "1" } - CalcButton { operation: "2" } - CalcButton { operation: "3" } + Row { + spacing: 6 + property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) + + Button { + id: rotateButton + width: parent.w; height: column.h; color: 'purple'; operation: rotateLeft + } + Button { width: parent.w; height: column.h; color: 'purple'; operation: leftArrow } + Button { width: parent.w; height: column.h; color: 'purple'; operation: "C" } + Button { width: parent.w; height: column.h; color: 'purple'; operation: "AC" } } Row { - y: 128; spacing: 2 + spacing: 6 + property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) - CalcButton { operation: "0"; width: 50 } - CalcButton { operation: "."; x: 77; width: 50 } - CalcButton { operation: "="; id: equals; x: 77; width: 102 } + Button { width: parent.w; height: column.h; color: 'green'; operation: "mc" } + Button { width: parent.w; height: column.h; color: 'green'; operation: "m+" } + Button { width: parent.w; height: column.h; color: 'green'; operation: "m-" } + Button { width: parent.w; height: column.h; color: 'green'; operation: "mr" } } - Column { - id: simpleOperations - x: 156; y: 0; spacing: 2 - - CalcButton { operation: "x" } - CalcButton { operation: "/" } - CalcButton { operation: "-" } - CalcButton { operation: "+" } + Grid { + id: grid; rows: 4; columns: 5; spacing: 6 + + property real w: (box.width / columns) - ((spacing * (columns - 1)) / columns) + + Button { width: grid.w; height: column.h; operation: "7"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "8"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "9"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: division } + Button { width: grid.w; height: column.h; operation: squareRoot } + Button { width: grid.w; height: column.h; operation: "4"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "5"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "6"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: multiplication } + Button { width: grid.w; height: column.h; operation: "x^2" } + Button { width: grid.w; height: column.h; operation: "1"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "2"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "3"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "-" } + Button { width: grid.w; height: column.h; operation: "1/x" } + Button { width: grid.w; height: column.h; operation: "0"; color: 'blue' } + Button { width: grid.w; height: column.h; operation: "." } + Button { width: grid.w; height: column.h; operation: plusminus } + Button { width: grid.w; height: column.h; operation: "+" } + Button { width: grid.w; height: column.h; operation: "="; color: 'red' } } } - - Grid { - id: advancedButtons - x: 350; spacing: 2; columns: 2; opacity: 0 - - CalcButton { operation: "Abs" } - CalcButton { operation: "Int" } - CalcButton { operation: "MC" } - CalcButton { operation: "Sqrt" } - CalcButton { operation: "MR" } - CalcButton { operation: "^2" } - CalcButton { operation: "MS" } - CalcButton { operation: "1/x" } - CalcButton { operation: "M+" } - CalcButton { operation: "+/-" } - } } - } - states: State { - name: "Advanced"; when: advancedCheckBox.toggled == true - PropertyChanges { target: basicButtons; x: 0 } - PropertyChanges { target: simpleOperations; y: 32 } - PropertyChanges { target: bksp; opacity: 1 } - PropertyChanges { target: c; x: 69; width: 67 } - PropertyChanges { target: ac; x: 138; width: 67 } - PropertyChanges { target: equals; width: 50 } - PropertyChanges { target: advancedButtons; x: 210; opacity: 1 } - } + states: State { + name: 'rotated' + PropertyChanges { target: main; rotation: -90; width: window.height; height: window.width } + PropertyChanges { target: rotateButton; operation: rotateRight } + } - transitions: Transition { - NumberAnimation { properties: "x,y,width"; easing.type: "OutBounce"; duration: 500 } - NumberAnimation { properties: "opacity"; easing.type: "InOutQuad"; duration: 500 } + transitions: Transition { + SequentialAnimation { + PropertyAction { target: rotateButton; property: "operation" } + NumberAnimation { properties: "rotation"; duration: 300; easing.type: "InOutQuint" } + NumberAnimation { properties: "x,y,width,height"; duration: 300; easing.type: "InOutQuint" } + } + } } } -- cgit v0.12 From 8dca45fa2ad0f260143282ee01d52e72f8f88a68 Mon Sep 17 00:00:00 2001 From: Yann Bodson Date: Thu, 15 Apr 2010 19:03:12 +1000 Subject: Small calculator fix. --- demos/declarative/calculator/Core/calculator.js | 2 +- demos/declarative/calculator/calculator.qml | 18 +++++++++--------- 2 files changed, 10 insertions(+), 10 deletions(-) diff --git a/demos/declarative/calculator/Core/calculator.js b/demos/declarative/calculator/Core/calculator.js index 2b19de8..51b3dd3 100644 --- a/demos/declarative/calculator/Core/calculator.js +++ b/demos/declarative/calculator/Core/calculator.js @@ -54,7 +54,7 @@ function doOperation(op) { if (op == "1/x") { display.text = (1 / display.text.valueOf()).toString() - } else if (op == "^2") { + } else if (op == "x^2") { display.text = (display.text.valueOf() * display.text.valueOf()).toString() } else if (op == "Abs") { display.text = (Math.abs(display.text.valueOf())).toString() diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml index fc2b95a..286a4d1 100644 --- a/demos/declarative/calculator/calculator.qml +++ b/demos/declarative/calculator/calculator.qml @@ -36,28 +36,28 @@ Rectangle { id: column; spacing: 6 property real h: ((box.height - 72) / 6) - ((spacing * (6 - 1)) / 6) + property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) Row { spacing: 6 - property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) Button { id: rotateButton - width: parent.w; height: column.h; color: 'purple'; operation: rotateLeft + width: column.w; height: column.h; color: 'purple'; operation: rotateLeft } - Button { width: parent.w; height: column.h; color: 'purple'; operation: leftArrow } - Button { width: parent.w; height: column.h; color: 'purple'; operation: "C" } - Button { width: parent.w; height: column.h; color: 'purple'; operation: "AC" } + Button { width: column.w; height: column.h; color: 'purple'; operation: leftArrow } + Button { width: column.w; height: column.h; color: 'purple'; operation: "C" } + Button { width: column.w; height: column.h; color: 'purple'; operation: "AC" } } Row { spacing: 6 property real w: (box.width / 4) - ((spacing * (4 - 1)) / 4) - Button { width: parent.w; height: column.h; color: 'green'; operation: "mc" } - Button { width: parent.w; height: column.h; color: 'green'; operation: "m+" } - Button { width: parent.w; height: column.h; color: 'green'; operation: "m-" } - Button { width: parent.w; height: column.h; color: 'green'; operation: "mr" } + Button { width: column.w; height: column.h; color: 'green'; operation: "mc" } + Button { width: column.w; height: column.h; color: 'green'; operation: "m+" } + Button { width: column.w; height: column.h; color: 'green'; operation: "m-" } + Button { width: column.w; height: column.h; color: 'green'; operation: "mr" } } Grid { -- cgit v0.12 From 16ae00c689faac5d7af312ae31d7f715dc6e0745 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 16 Apr 2010 09:54:24 +1000 Subject: Correctly support translation in QDeclarativeCompiler Reviewed-by: Friedemann Kleint --- src/declarative/qml/qdeclarativecompiler.cpp | 6 ------ src/declarative/qml/qdeclarativecompiler_p.h | 4 ++-- 2 files changed, 2 insertions(+), 8 deletions(-) diff --git a/src/declarative/qml/qdeclarativecompiler.cpp b/src/declarative/qml/qdeclarativecompiler.cpp index 5c5ad37..065009a 100644 --- a/src/declarative/qml/qdeclarativecompiler.cpp +++ b/src/declarative/qml/qdeclarativecompiler.cpp @@ -67,7 +67,6 @@ #include "private/qdeclarativecompiledbindings_p.h" #include "private/qdeclarativeglobalscriptclass_p.h" -#include #include #include #include @@ -2947,9 +2946,4 @@ QStringList QDeclarativeCompiler::deferredProperties(QDeclarativeParser::Object return rv; } -QString QDeclarativeCompiler::tr(const char *str) -{ - return QCoreApplication::translate("QDeclarativeCompiler", str); -} - QT_END_NAMESPACE diff --git a/src/declarative/qml/qdeclarativecompiler_p.h b/src/declarative/qml/qdeclarativecompiler_p.h index 002c6c9..867db2c 100644 --- a/src/declarative/qml/qdeclarativecompiler_p.h +++ b/src/declarative/qml/qdeclarativecompiler_p.h @@ -66,6 +66,7 @@ #include #include +#include QT_BEGIN_NAMESPACE @@ -148,6 +149,7 @@ private: class QMetaObjectBuilder; class Q_DECLARATIVE_EXPORT QDeclarativeCompiler { + Q_DECLARE_TR_FUNCTIONS(QDeclarativeCompiler) public: QDeclarativeCompiler(); @@ -279,8 +281,6 @@ private: void addId(const QString &, QDeclarativeParser::Object *); - QString tr(const char *); - void dumpStats(); struct BindingReference { -- cgit v0.12 From bac82138b76ac9f6a0603fa454f6660d139287d0 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 16 Apr 2010 10:11:14 +1000 Subject: Improve warning for non-Item delegates. Task-number: QTBUG-9682 --- .../graphicsitems/qdeclarativevisualitemmodel.cpp | 14 ++++++++++++-- 1 file changed, 12 insertions(+), 2 deletions(-) diff --git a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp index 4365ea3..751284d 100644 --- a/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qdeclarativevisualitemmodel.cpp @@ -353,6 +353,7 @@ public: friend class QDeclarativeVisualDataModelData; bool m_metaDataCreated; bool m_metaDataCacheable; + bool m_delegateValidated; QDeclarativeVisualDataModelData *data(QObject *item); @@ -560,7 +561,7 @@ QDeclarativeVisualDataModelParts::QDeclarativeVisualDataModelParts(QDeclarativeV QDeclarativeVisualDataModelPrivate::QDeclarativeVisualDataModelPrivate(QDeclarativeContext *ctxt) : m_listModelInterface(0), m_abstractItemModel(0), m_visualItemModel(0), m_delegate(0) , m_context(ctxt), m_parts(0), m_delegateDataType(0), m_metaDataCreated(false) -, m_metaDataCacheable(false), m_listAccessor(0) +, m_metaDataCacheable(false), m_delegateValidated(false), m_listAccessor(0) { } @@ -768,6 +769,7 @@ void QDeclarativeVisualDataModel::setDelegate(QDeclarativeComponent *delegate) Q_D(QDeclarativeVisualDataModel); bool wasValid = d->m_delegate != 0; d->m_delegate = delegate; + d->m_delegateValidated = false; if (!wasValid && d->modelCount() && d->m_delegate) { emit itemsInserted(0, d->modelCount()); emit countChanged(); @@ -987,6 +989,7 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray if (d->modelCount() <= 0 || !d->m_delegate) return 0; QObject *nobj = d->m_cache.getItem(index); + bool needComplete = false; if (!nobj) { QDeclarativeContext *ccontext = d->m_context; if (!ccontext) ccontext = qmlContext(this); @@ -997,6 +1000,8 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray nobj = d->m_delegate->beginCreate(ctxt); if (complete) d->m_delegate->completeCreate(); + else + needComplete = true; if (nobj) { QDeclarative_setParent_noEvent(ctxt, nobj); QDeclarative_setParent_noEvent(data, nobj); @@ -1020,8 +1025,13 @@ QDeclarativeItem *QDeclarativeVisualDataModel::item(int index, const QByteArray } } if (!item) { + if (needComplete) + d->m_delegate->completeCreate(); d->m_cache.releaseItem(nobj); - qmlInfo(d->m_delegate) << QDeclarativeVisualDataModel::tr("Delegate component must be Item type."); + if (!d->m_delegateValidated) { + qmlInfo(d->m_delegate) << QDeclarativeVisualDataModel::tr("Delegate component must be Item type."); + d->m_delegateValidated = true; + } } return item; -- cgit v0.12 From fc399f2cd81772fed179d59a6f53abe69a81083a Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 16 Apr 2010 11:28:14 +1000 Subject: Correctly support translation in QDeclarativePixmapCache --- src/declarative/util/qdeclarativepixmapcache.cpp | 10 +++++----- src/declarative/util/qdeclarativepixmapcache_p.h | 2 ++ 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/src/declarative/util/qdeclarativepixmapcache.cpp b/src/declarative/util/qdeclarativepixmapcache.cpp index 893fbf3..dbca326 100644 --- a/src/declarative/util/qdeclarativepixmapcache.cpp +++ b/src/declarative/util/qdeclarativepixmapcache.cpp @@ -194,7 +194,7 @@ static bool readImage(const QUrl& url, QIODevice *dev, QImage *image, QString *e return true; } else { if (errorString) - *errorString = QDeclarativeImageRequestHandler::tr("Error decoding: %1: %2").arg(url.toString()) + *errorString = QDeclarativePixmapCache::tr("Error decoding: %1: %2").arg(url.toString()) .arg(imgio.errorString()); return false; } @@ -264,7 +264,7 @@ bool QDeclarativeImageRequestHandler::event(QEvent *event) QString errorStr; if (image.isNull()) { errorCode = QDeclarativeImageReaderEvent::Loading; - errorStr = QDeclarativeImageRequestHandler::tr("Failed to get image from provider: %1").arg(url.toString()); + errorStr = QDeclarativePixmapCache::tr("Failed to get image from provider: %1").arg(url.toString()); } QCoreApplication::postEvent(runningJob, new QDeclarativeImageReaderEvent(errorCode, errorStr, image)); } else { @@ -283,7 +283,7 @@ bool QDeclarativeImageRequestHandler::event(QEvent *event) errorCode = QDeclarativeImageReaderEvent::Loading; } } else { - errorStr = QDeclarativeImageRequestHandler::tr("Cannot open: %1").arg(url.toString()); + errorStr = QDeclarativePixmapCache::tr("Cannot open: %1").arg(url.toString()); errorCode = QDeclarativeImageReaderEvent::Loading; } QCoreApplication::postEvent(runningJob, new QDeclarativeImageReaderEvent(errorCode, errorStr, image)); @@ -625,7 +625,7 @@ QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QP } } else { if (errorString) - *errorString = QDeclarativeImageRequestHandler::tr("Cannot open: %1").arg(url.toString()); + *errorString = tr("Cannot open: %1").arg(url.toString()); *pixmap = QPixmap(); status = QDeclarativePixmapReply::Error; } @@ -662,7 +662,7 @@ QDeclarativePixmapReply::Status QDeclarativePixmapCache::get(const QUrl& url, QP } else if (pixmap->isNull()) { status = QDeclarativePixmapReply::Error; if (errorString) - *errorString = QDeclarativeImageRequestHandler::tr("Unknown Error loading %1").arg(url.toString()); + *errorString = tr("Unknown Error loading %1").arg(url.toString()); } else { status = QDeclarativePixmapReply::Ready; } diff --git a/src/declarative/util/qdeclarativepixmapcache_p.h b/src/declarative/util/qdeclarativepixmapcache_p.h index 7b94728..33d9de1 100644 --- a/src/declarative/util/qdeclarativepixmapcache_p.h +++ b/src/declarative/util/qdeclarativepixmapcache_p.h @@ -45,6 +45,7 @@ #include #include #include +#include QT_BEGIN_HEADER @@ -95,6 +96,7 @@ private: class Q_DECLARATIVE_EXPORT QDeclarativePixmapCache { + Q_DECLARE_TR_FUNCTIONS(QDeclarativePixmapCache) public: static QDeclarativePixmapReply::Status get(const QUrl& url, QPixmap *pixmap, QString *errorString, QSize *impsize=0, bool async=false, int req_width=0, int req_height=0); static QDeclarativePixmapReply *request(QDeclarativeEngine *, const QUrl& url, int req_width=0, int req_height=0); -- cgit v0.12