From 07536c0230692506d7207970eda8f255736fa653 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 15 Feb 2010 09:27:19 +1000 Subject: Move type initialization from global static initializers to QmlEngine construction. Task-number: QT-2798 --- src/declarative/graphicsitems/graphicsitems.pri | 3 + .../graphicsitems/qmlgraphicsanchors.cpp | 2 - .../graphicsitems/qmlgraphicsanimatedimage.cpp | 1 - .../graphicsitems/qmlgraphicsborderimage.cpp | 2 - .../graphicsitems/qmlgraphicseffects.cpp | 13 -- .../graphicsitems/qmlgraphicseffects_p.h | 65 +++++++ .../graphicsitems/qmlgraphicsevents.cpp | 3 - .../graphicsitems/qmlgraphicsflickable.cpp | 35 ---- .../graphicsitems/qmlgraphicsflickable_p_p.h | 32 ++++ .../graphicsitems/qmlgraphicsflipable.cpp | 2 - .../graphicsitems/qmlgraphicsfocuspanel.cpp | 2 - .../graphicsitems/qmlgraphicsfocusscope.cpp | 1 - .../qmlgraphicsgraphicsobjectcontainer.cpp | 3 - .../graphicsitems/qmlgraphicsgridview.cpp | 59 ------ .../graphicsitems/qmlgraphicsgridview_p.h | 58 ++++++ src/declarative/graphicsitems/qmlgraphicsimage.cpp | 2 - src/declarative/graphicsitems/qmlgraphicsitem.cpp | 210 --------------------- src/declarative/graphicsitems/qmlgraphicsitem_p.h | 201 ++++++++++++++++++++ .../graphicsitems/qmlgraphicsitemsmodule.cpp | 158 ++++++++++++++++ .../graphicsitems/qmlgraphicsitemsmodule_p.h | 63 +++++++ .../graphicsitems/qmlgraphicslayoutitem.cpp | 2 - .../graphicsitems/qmlgraphicslistview.cpp | 69 ------- .../graphicsitems/qmlgraphicslistview_p.h | 67 +++++++ .../graphicsitems/qmlgraphicsloader.cpp | 2 - .../graphicsitems/qmlgraphicsmouseregion.cpp | 3 - .../graphicsitems/qmlgraphicsparticles.cpp | 10 - src/declarative/graphicsitems/qmlgraphicspath.cpp | 8 - .../graphicsitems/qmlgraphicspathview.cpp | 3 - .../graphicsitems/qmlgraphicspositioners.cpp | 4 - .../graphicsitems/qmlgraphicsrectangle.cpp | 4 - .../graphicsitems/qmlgraphicsrepeater.cpp | 2 - .../graphicsitems/qmlgraphicsscalegrid.cpp | 1 - src/declarative/graphicsitems/qmlgraphicstext.cpp | 1 - .../graphicsitems/qmlgraphicstextedit.cpp | 1 - .../graphicsitems/qmlgraphicstextinput.cpp | 6 - .../graphicsitems/qmlgraphicsvisualitemmodel.cpp | 42 ----- .../graphicsitems/qmlgraphicsvisualitemmodel_p.h | 39 ++++ .../graphicsitems/qmlgraphicswebview.cpp | 28 --- .../graphicsitems/qmlgraphicswebview_p.h | 25 +++ src/declarative/qml/qmlengine.cpp | 8 + 40 files changed, 719 insertions(+), 521 deletions(-) create mode 100644 src/declarative/graphicsitems/qmlgraphicseffects_p.h create mode 100644 src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp create mode 100644 src/declarative/graphicsitems/qmlgraphicsitemsmodule_p.h diff --git a/src/declarative/graphicsitems/graphicsitems.pri b/src/declarative/graphicsitems/graphicsitems.pri index eb6e0ad..db9c29e 100644 --- a/src/declarative/graphicsitems/graphicsitems.pri +++ b/src/declarative/graphicsitems/graphicsitems.pri @@ -1,9 +1,11 @@ INCLUDEPATH += $$PWD HEADERS += \ + $$PWD/qmlgraphicsitemsmodule_p.h \ $$PWD/qmlgraphicsanchors_p.h \ $$PWD/qmlgraphicsanchors_p_p.h \ $$PWD/qmlgraphicsevents_p_p.h \ + $$PWD/qmlgraphicseffects_p.h \ $$PWD/qmlgraphicsflickable_p.h \ $$PWD/qmlgraphicsflickable_p_p.h \ $$PWD/qmlgraphicsflipable_p.h \ @@ -52,6 +54,7 @@ HEADERS += \ $$PWD/qmlgraphicseffects.cpp SOURCES += \ + $$PWD/qmlgraphicsitemsmodule.cpp \ $$PWD/qmlgraphicsanchors.cpp \ $$PWD/qmlgraphicsevents.cpp \ $$PWD/qmlgraphicsflickable.cpp \ diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp index 93055fc..816e580 100644 --- a/src/declarative/graphicsitems/qmlgraphicsanchors.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsanchors.cpp @@ -50,8 +50,6 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_NOCREATE_TYPE(QmlGraphicsAnchors) - //TODO: should we cache relationships, so we don't have to check each time (parent-child or sibling)? //TODO: support non-parent, non-sibling (need to find lowest common ancestor) diff --git a/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp b/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp index e01e569..7d1c87a 100644 --- a/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp @@ -78,7 +78,6 @@ Item { \endqml \endtable */ -QML_DEFINE_TYPE(Qt,4,6,AnimatedImage,QmlGraphicsAnimatedImage) QmlGraphicsAnimatedImage::QmlGraphicsAnimatedImage(QmlGraphicsItem *parent) : QmlGraphicsImage(*(new QmlGraphicsAnimatedImagePrivate), parent) diff --git a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp index 877e141..19da151 100644 --- a/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsborderimage.cpp @@ -50,8 +50,6 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,BorderImage,QmlGraphicsBorderImage) - /*! \qmlclass BorderImage QmlGraphicsBorderImage \brief The BorderImage element provides an image that can be used as a border. diff --git a/src/declarative/graphicsitems/qmlgraphicseffects.cpp b/src/declarative/graphicsitems/qmlgraphicseffects.cpp index e1f5687..268ba28 100644 --- a/src/declarative/graphicsitems/qmlgraphicseffects.cpp +++ b/src/declarative/graphicsitems/qmlgraphicseffects.cpp @@ -43,12 +43,6 @@ #include -QML_DECLARE_TYPE(QGraphicsEffect) -QML_DEFINE_NOCREATE_TYPE(QGraphicsEffect) - -QML_DECLARE_TYPE(QGraphicsBlurEffect) -QML_DEFINE_TYPE(Qt,4,6,Blur,QGraphicsBlurEffect) - /*! \qmlclass Blur QGraphicsBlurEffect \brief The Blur object provides a blur effect. @@ -84,9 +78,6 @@ QML_DEFINE_TYPE(Qt,4,6,Blur,QGraphicsBlurEffect) The default hint is Qt.PerformanceHint. */ -QML_DECLARE_TYPE(QGraphicsColorizeEffect) -QML_DEFINE_TYPE(Qt,4,6,Colorize,QGraphicsColorizeEffect) - /*! \qmlclass Colorize QGraphicsColorizeEffect \brief The Colorize object provides a colorize effect. @@ -112,8 +103,6 @@ QML_DEFINE_TYPE(Qt,4,6,Colorize,QGraphicsColorizeEffect) while 1.0 means full colorization. By default, the strength is 1.0. */ -QML_DECLARE_TYPE(QGraphicsDropShadowEffect) -QML_DEFINE_TYPE(Qt,4,6,DropShadow,QGraphicsDropShadowEffect) /*! \qmlclass DropShadow QGraphicsDropShadowEffect @@ -155,8 +144,6 @@ QML_DEFINE_TYPE(Qt,4,6,DropShadow,QGraphicsDropShadowEffect) By default, the drop color is a semi-transparent dark gray. */ -QML_DECLARE_TYPE(QGraphicsOpacityEffect) -QML_DEFINE_TYPE(Qt,4,6,Opacity,QGraphicsOpacityEffect) /*! \qmlclass Opacity QGraphicsOpacityEffect diff --git a/src/declarative/graphicsitems/qmlgraphicseffects_p.h b/src/declarative/graphicsitems/qmlgraphicseffects_p.h new file mode 100644 index 0000000..2e561f8 --- /dev/null +++ b/src/declarative/graphicsitems/qmlgraphicseffects_p.h @@ -0,0 +1,65 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QMLGRAPHICSEFFECTS_P_H +#define QMLGRAPHICSEFFECTS_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 + +QML_DECLARE_TYPE(QGraphicsEffect) +QML_DECLARE_TYPE(QGraphicsBlurEffect) +QML_DECLARE_TYPE(QGraphicsColorizeEffect) +QML_DECLARE_TYPE(QGraphicsDropShadowEffect) +QML_DECLARE_TYPE(QGraphicsOpacityEffect) + +#endif // QMLGRAPHICSEFFECTS_P_H diff --git a/src/declarative/graphicsitems/qmlgraphicsevents.cpp b/src/declarative/graphicsitems/qmlgraphicsevents.cpp index 9958dea..0d6adf6 100644 --- a/src/declarative/graphicsitems/qmlgraphicsevents.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsevents.cpp @@ -189,7 +189,4 @@ MouseRegion { \endqml */ -QML_DEFINE_NOCREATE_TYPE(QmlGraphicsKeyEvent) -QML_DEFINE_NOCREATE_TYPE(QmlGraphicsMouseEvent) - QT_END_NAMESPACE diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp index 2ff3b30..cf8952d 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp @@ -56,36 +56,6 @@ static const int FlickThreshold = 20; // Really slow flicks can be annoying. static const int minimumFlickVelocity = 200; -class QmlGraphicsFlickableVisibleArea : public QObject -{ - Q_OBJECT - - Q_PROPERTY(qreal xPosition READ xPosition NOTIFY pageChanged) - Q_PROPERTY(qreal yPosition READ yPosition NOTIFY pageChanged) - Q_PROPERTY(qreal widthRatio READ widthRatio NOTIFY pageChanged) - Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY pageChanged) - -public: - QmlGraphicsFlickableVisibleArea(QmlGraphicsFlickable *parent=0); - - qreal xPosition() const; - qreal widthRatio() const; - qreal yPosition() const; - qreal heightRatio() const; - - void updateVisible(); - -signals: - void pageChanged(); - -private: - QmlGraphicsFlickable *flickable; - qreal m_xPosition; - qreal m_widthRatio; - qreal m_yPosition; - qreal m_heightRatio; -}; - QmlGraphicsFlickableVisibleArea::QmlGraphicsFlickableVisibleArea(QmlGraphicsFlickable *parent) : QObject(parent), flickable(parent), m_xPosition(0.), m_widthRatio(0.) , m_yPosition(0.), m_heightRatio(0.) @@ -356,8 +326,6 @@ void QmlGraphicsFlickablePrivate::updateBeginningEnd() visibleArea->updateVisible(); } -QML_DEFINE_TYPE(Qt,4,6,Flickable,QmlGraphicsFlickable) - /*! \qmlclass Flickable QmlGraphicsFlickable \brief The Flickable item provides a surface that can be "flicked". @@ -1368,7 +1336,4 @@ void QmlGraphicsFlickablePrivate::updateVelocity() QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlGraphicsFlickableVisibleArea) -QML_DEFINE_TYPE(Qt,4,6,VisibleArea,QmlGraphicsFlickableVisibleArea) - #include diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h b/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h index ae164cc..e83e81b 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsflickable_p_p.h @@ -159,6 +159,38 @@ public: QML_DECLARE_LIST_PROXY(QmlGraphicsFlickablePrivate, QObject *, data) }; +class QmlGraphicsFlickableVisibleArea : public QObject +{ + Q_OBJECT + + Q_PROPERTY(qreal xPosition READ xPosition NOTIFY pageChanged) + Q_PROPERTY(qreal yPosition READ yPosition NOTIFY pageChanged) + Q_PROPERTY(qreal widthRatio READ widthRatio NOTIFY pageChanged) + Q_PROPERTY(qreal heightRatio READ heightRatio NOTIFY pageChanged) + +public: + QmlGraphicsFlickableVisibleArea(QmlGraphicsFlickable *parent=0); + + qreal xPosition() const; + qreal widthRatio() const; + qreal yPosition() const; + qreal heightRatio() const; + + void updateVisible(); + +signals: + void pageChanged(); + +private: + QmlGraphicsFlickable *flickable; + qreal m_xPosition; + qreal m_widthRatio; + qreal m_yPosition; + qreal m_heightRatio; +}; + QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlGraphicsFlickableVisibleArea) + #endif diff --git a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp b/src/declarative/graphicsitems/qmlgraphicsflipable.cpp index ff8995b..4116817 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsflipable.cpp @@ -49,8 +49,6 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,Flipable,QmlGraphicsFlipable) - class QmlGraphicsFlipablePrivate : public QmlGraphicsItemPrivate { Q_DECLARE_PUBLIC(QmlGraphicsFlipable) diff --git a/src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp b/src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp index 333b689..4e1542a 100644 --- a/src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsfocuspanel.cpp @@ -46,8 +46,6 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,FocusPanel,QmlGraphicsFocusPanel) - /*! \qmlclass FocusPanel QmlGraphicsFocusPanel \brief The FocusPanel item explicitly creates a focus panel. diff --git a/src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp b/src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp index 828756c..ce0e376 100644 --- a/src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsfocusscope.cpp @@ -42,7 +42,6 @@ #include "qmlgraphicsfocusscope_p.h" QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,FocusScope,QmlGraphicsFocusScope) /*! \qmlclass FocusScope QmlGraphicsFocusScope diff --git a/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp b/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp index a5a7935..f2b3c00 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsgraphicsobjectcontainer.cpp @@ -131,9 +131,6 @@ public: \brief The QmlGraphicsGraphicsObjectContainer class allows you to add QGraphicsObjects into Fluid UI applications. */ -QML_DEFINE_NOCREATE_TYPE(QGraphicsObject) -QML_DEFINE_TYPE(Qt,4,6,GraphicsObjectContainer,QmlGraphicsGraphicsObjectContainer) - QmlGraphicsGraphicsObjectContainer::QmlGraphicsGraphicsObjectContainer(QmlGraphicsItem *parent) : QmlGraphicsItem(*new QmlGraphicsGraphicsObjectContainerPrivate, parent) { diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp index 83911c0..34aed4e 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp @@ -51,63 +51,6 @@ QT_BEGIN_NAMESPACE -class QmlGraphicsGridViewAttached : public QObject -{ - Q_OBJECT -public: - QmlGraphicsGridViewAttached(QObject *parent) - : QObject(parent), m_isCurrent(false), m_delayRemove(false) {} - ~QmlGraphicsGridViewAttached() { - attachedProperties.remove(parent()); - } - - Q_PROPERTY(QmlGraphicsGridView *view READ view CONSTANT) - QmlGraphicsGridView *view() { return m_view; } - - Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged) - bool isCurrentItem() const { return m_isCurrent; } - void setIsCurrentItem(bool c) { - if (m_isCurrent != c) { - m_isCurrent = c; - emit currentItemChanged(); - } - } - - Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged) - bool delayRemove() const { return m_delayRemove; } - void setDelayRemove(bool delay) { - if (m_delayRemove != delay) { - m_delayRemove = delay; - emit delayRemoveChanged(); - } - } - - static QmlGraphicsGridViewAttached *properties(QObject *obj) { - QmlGraphicsGridViewAttached *rv = attachedProperties.value(obj); - if (!rv) { - rv = new QmlGraphicsGridViewAttached(obj); - attachedProperties.insert(obj, rv); - } - return rv; - } - - void emitAdd() { emit add(); } - void emitRemove() { emit remove(); } - -Q_SIGNALS: - void currentItemChanged(); - void delayRemoveChanged(); - void add(); - void remove(); - -public: - QmlGraphicsGridView *m_view; - bool m_isCurrent; - bool m_delayRemove; - - static QHash attachedProperties; -}; - QHash QmlGraphicsGridViewAttached::attachedProperties; @@ -1754,8 +1697,6 @@ QmlGraphicsGridViewAttached *QmlGraphicsGridView::qmlAttachedProperties(QObject return QmlGraphicsGridViewAttached::properties(obj); } -QML_DEFINE_TYPE(Qt, 4,6, GridView, QmlGraphicsGridView) - QT_END_NAMESPACE #include diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview_p.h b/src/declarative/graphicsitems/qmlgraphicsgridview_p.h index d2ef70e..25a76a3 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgridview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsgridview_p.h @@ -154,6 +154,64 @@ private: void refill(); }; +class QmlGraphicsGridViewAttached : public QObject +{ + Q_OBJECT +public: + QmlGraphicsGridViewAttached(QObject *parent) + : QObject(parent), m_isCurrent(false), m_delayRemove(false) {} + ~QmlGraphicsGridViewAttached() { + attachedProperties.remove(parent()); + } + + Q_PROPERTY(QmlGraphicsGridView *view READ view CONSTANT) + QmlGraphicsGridView *view() { return m_view; } + + Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged) + bool isCurrentItem() const { return m_isCurrent; } + void setIsCurrentItem(bool c) { + if (m_isCurrent != c) { + m_isCurrent = c; + emit currentItemChanged(); + } + } + + Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged) + bool delayRemove() const { return m_delayRemove; } + void setDelayRemove(bool delay) { + if (m_delayRemove != delay) { + m_delayRemove = delay; + emit delayRemoveChanged(); + } + } + + static QmlGraphicsGridViewAttached *properties(QObject *obj) { + QmlGraphicsGridViewAttached *rv = attachedProperties.value(obj); + if (!rv) { + rv = new QmlGraphicsGridViewAttached(obj); + attachedProperties.insert(obj, rv); + } + return rv; + } + + void emitAdd() { emit add(); } + void emitRemove() { emit remove(); } + +Q_SIGNALS: + void currentItemChanged(); + void delayRemoveChanged(); + void add(); + void remove(); + +public: + QmlGraphicsGridView *m_view; + bool m_isCurrent; + bool m_delayRemove; + + static QHash attachedProperties; +}; + + QT_END_NAMESPACE QML_DECLARE_TYPE(QmlGraphicsGridView) diff --git a/src/declarative/graphicsitems/qmlgraphicsimage.cpp b/src/declarative/graphicsitems/qmlgraphicsimage.cpp index 7e63c8b..558511d 100644 --- a/src/declarative/graphicsitems/qmlgraphicsimage.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsimage.cpp @@ -48,8 +48,6 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,Image,QmlGraphicsImage) - /*! \qmlclass Image QmlGraphicsImage \brief The Image element allows you to add bitmaps to a scene. diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp index 8973cb4..9fd8702 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp @@ -69,12 +69,6 @@ QT_BEGIN_NAMESPACE #define FLT_MAX 1E+37 #endif -QML_DEFINE_TYPE(Qt,4,6,Item,QmlGraphicsItem) - -QML_DEFINE_NOCREATE_TYPE(QGraphicsTransform); -QML_DEFINE_TYPE(Qt,4,6,Scale,QGraphicsScale) -QML_DEFINE_TYPE(Qt,4,6,Rotation,QGraphicsRotation) - #include "qmlgraphicseffects.cpp" /*! @@ -325,28 +319,6 @@ void QmlGraphicsContents::setItem(QmlGraphicsItem *item) calcWidth(); } -/* - Key filters can be installed on a QmlGraphicsItem, but not removed. Currently they - are only used by attached objects (which are only destroyed on Item - destruction), so this isn't a problem. If in future this becomes any form - of public API, they will have to support removal too. -*/ -class QmlGraphicsItemKeyFilter -{ -public: - QmlGraphicsItemKeyFilter(QmlGraphicsItem * = 0); - virtual ~QmlGraphicsItemKeyFilter(); - - virtual void keyPressed(QKeyEvent *event); - virtual void keyReleased(QKeyEvent *event); - virtual void inputMethodEvent(QInputMethodEvent *event); - virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; - virtual void componentComplete(); - -private: - QmlGraphicsItemKeyFilter *m_next; -}; - QmlGraphicsItemKeyFilter::QmlGraphicsItemKeyFilter(QmlGraphicsItem *item) : m_next(0) { @@ -458,49 +430,6 @@ void QmlGraphicsItemKeyFilter::componentComplete() pressed. */ -class QmlGraphicsKeyNavigationAttachedPrivate : public QObjectPrivate -{ -public: - QmlGraphicsKeyNavigationAttachedPrivate() - : QObjectPrivate(), left(0), right(0), up(0), down(0) {} - - QmlGraphicsItem *left; - QmlGraphicsItem *right; - QmlGraphicsItem *up; - QmlGraphicsItem *down; -}; - -class QmlGraphicsKeyNavigationAttached : public QObject, public QmlGraphicsItemKeyFilter -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QmlGraphicsKeyNavigationAttached) - - Q_PROPERTY(QmlGraphicsItem *left READ left WRITE setLeft NOTIFY changed) - Q_PROPERTY(QmlGraphicsItem *right READ right WRITE setRight NOTIFY changed) - Q_PROPERTY(QmlGraphicsItem *up READ up WRITE setUp NOTIFY changed) - Q_PROPERTY(QmlGraphicsItem *down READ down WRITE setDown NOTIFY changed) -public: - QmlGraphicsKeyNavigationAttached(QObject * = 0); - - QmlGraphicsItem *left() const; - void setLeft(QmlGraphicsItem *); - QmlGraphicsItem *right() const; - void setRight(QmlGraphicsItem *); - QmlGraphicsItem *up() const; - void setUp(QmlGraphicsItem *); - QmlGraphicsItem *down() const; - void setDown(QmlGraphicsItem *); - - static QmlGraphicsKeyNavigationAttached *qmlAttachedProperties(QObject *); - -Q_SIGNALS: - void changed(); - -private: - virtual void keyPressed(QKeyEvent *event); - virtual void keyReleased(QKeyEvent *event); -}; - QmlGraphicsKeyNavigationAttached::QmlGraphicsKeyNavigationAttached(QObject *parent) : QObject(*(new QmlGraphicsKeyNavigationAttachedPrivate), parent), QmlGraphicsItemKeyFilter(qobject_cast(parent)) @@ -964,137 +893,6 @@ void QmlGraphicsKeyNavigationAttached::keyReleased(QKeyEvent *event) */ -class QmlGraphicsKeysAttachedPrivate : public QObjectPrivate -{ -public: - QmlGraphicsKeysAttachedPrivate() - : QObjectPrivate(), inPress(false), inRelease(false) - , inIM(false), enabled(true), imeItem(0), item(0) - {} - - bool isConnected(const char *signalName); - - QGraphicsItem *finalFocusProxy(QGraphicsItem *item) const - { - QGraphicsItem *fp; - while ((fp = item->focusProxy())) - item = fp; - return item; - } - - //loop detection - bool inPress:1; - bool inRelease:1; - bool inIM:1; - - bool enabled : 1; - - QGraphicsItem *imeItem; - QList targets; - QmlGraphicsItem *item; -}; - -class QmlGraphicsKeysAttached : public QObject, public QmlGraphicsItemKeyFilter -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QmlGraphicsKeysAttached) - - Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) - Q_PROPERTY(QList *forwardTo READ forwardTo) - -public: - QmlGraphicsKeysAttached(QObject *parent=0); - ~QmlGraphicsKeysAttached(); - - bool enabled() const { Q_D(const QmlGraphicsKeysAttached); return d->enabled; } - void setEnabled(bool enabled) { - Q_D(QmlGraphicsKeysAttached); - if (enabled != d->enabled) { - d->enabled = enabled; - emit enabledChanged(); - } - } - - QList *forwardTo() { - Q_D(QmlGraphicsKeysAttached); - return &d->targets; - } - - virtual void componentComplete(); - - static QmlGraphicsKeysAttached *qmlAttachedProperties(QObject *); - -Q_SIGNALS: - void enabledChanged(); - void pressed(QmlGraphicsKeyEvent *event); - void released(QmlGraphicsKeyEvent *event); - void digit0Pressed(QmlGraphicsKeyEvent *event); - void digit1Pressed(QmlGraphicsKeyEvent *event); - void digit2Pressed(QmlGraphicsKeyEvent *event); - void digit3Pressed(QmlGraphicsKeyEvent *event); - void digit4Pressed(QmlGraphicsKeyEvent *event); - void digit5Pressed(QmlGraphicsKeyEvent *event); - void digit6Pressed(QmlGraphicsKeyEvent *event); - void digit7Pressed(QmlGraphicsKeyEvent *event); - void digit8Pressed(QmlGraphicsKeyEvent *event); - void digit9Pressed(QmlGraphicsKeyEvent *event); - - void leftPressed(QmlGraphicsKeyEvent *event); - void rightPressed(QmlGraphicsKeyEvent *event); - void upPressed(QmlGraphicsKeyEvent *event); - void downPressed(QmlGraphicsKeyEvent *event); - - void asteriskPressed(QmlGraphicsKeyEvent *event); - void numberSignPressed(QmlGraphicsKeyEvent *event); - void escapePressed(QmlGraphicsKeyEvent *event); - void returnPressed(QmlGraphicsKeyEvent *event); - void enterPressed(QmlGraphicsKeyEvent *event); - void deletePressed(QmlGraphicsKeyEvent *event); - void spacePressed(QmlGraphicsKeyEvent *event); - void backPressed(QmlGraphicsKeyEvent *event); - void cancelPressed(QmlGraphicsKeyEvent *event); - void selectPressed(QmlGraphicsKeyEvent *event); - void yesPressed(QmlGraphicsKeyEvent *event); - void noPressed(QmlGraphicsKeyEvent *event); - void context1Pressed(QmlGraphicsKeyEvent *event); - void context2Pressed(QmlGraphicsKeyEvent *event); - void context3Pressed(QmlGraphicsKeyEvent *event); - void context4Pressed(QmlGraphicsKeyEvent *event); - void callPressed(QmlGraphicsKeyEvent *event); - void hangupPressed(QmlGraphicsKeyEvent *event); - void flipPressed(QmlGraphicsKeyEvent *event); - void menuPressed(QmlGraphicsKeyEvent *event); - void volumeUpPressed(QmlGraphicsKeyEvent *event); - void volumeDownPressed(QmlGraphicsKeyEvent *event); - -private: - virtual void keyPressed(QKeyEvent *event); - virtual void keyReleased(QKeyEvent *event); - virtual void inputMethodEvent(QInputMethodEvent *); - virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; - - const QByteArray keyToSignal(int key) { - QByteArray keySignal; - if (key >= Qt::Key_0 && key <= Qt::Key_9) { - keySignal = "digit0Pressed"; - keySignal[5] = '0' + (key - Qt::Key_0); - } else { - int i = 0; - while (sigMap[i].key && sigMap[i].key != key) - ++i; - keySignal = sigMap[i].sig; - } - return keySignal; - } - - struct SigMap { - int key; - const char *sig; - }; - - static const SigMap sigMap[]; -}; - const QmlGraphicsKeysAttached::SigMap QmlGraphicsKeysAttached::sigMap[] = { { Qt::Key_Left, "leftPressed" }, { Qt::Key_Right, "rightPressed" }, @@ -3086,14 +2884,6 @@ int QmlGraphicsItemPrivate::restart(QTime &t) return n; } -#include #include QT_END_NAMESPACE - -QML_DECLARE_TYPE(QmlGraphicsKeysAttached) -QML_DECLARE_TYPEINFO(QmlGraphicsKeysAttached, QML_HAS_ATTACHED_PROPERTIES) -QML_DEFINE_TYPE(Qt,4,6,Keys,QmlGraphicsKeysAttached) -QML_DECLARE_TYPE(QmlGraphicsKeyNavigationAttached) -QML_DECLARE_TYPEINFO(QmlGraphicsKeyNavigationAttached, QML_HAS_ATTACHED_PROPERTIES) -QML_DEFINE_TYPE(Qt,4,6,KeyNavigation,QmlGraphicsKeyNavigationAttached) diff --git a/src/declarative/graphicsitems/qmlgraphicsitem_p.h b/src/declarative/graphicsitems/qmlgraphicsitem_p.h index 1741808..9a77dbb 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsitem_p.h @@ -280,8 +280,209 @@ public: static int restart(QTime &); }; +/* + Key filters can be installed on a QmlGraphicsItem, but not removed. Currently they + are only used by attached objects (which are only destroyed on Item + destruction), so this isn't a problem. If in future this becomes any form + of public API, they will have to support removal too. +*/ +class QmlGraphicsItemKeyFilter +{ +public: + QmlGraphicsItemKeyFilter(QmlGraphicsItem * = 0); + virtual ~QmlGraphicsItemKeyFilter(); + + virtual void keyPressed(QKeyEvent *event); + virtual void keyReleased(QKeyEvent *event); + virtual void inputMethodEvent(QInputMethodEvent *event); + virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; + virtual void componentComplete(); + +private: + QmlGraphicsItemKeyFilter *m_next; +}; + +class QmlGraphicsKeyNavigationAttachedPrivate : public QObjectPrivate +{ +public: + QmlGraphicsKeyNavigationAttachedPrivate() + : QObjectPrivate(), left(0), right(0), up(0), down(0) {} + + QmlGraphicsItem *left; + QmlGraphicsItem *right; + QmlGraphicsItem *up; + QmlGraphicsItem *down; +}; + +class QmlGraphicsKeyNavigationAttached : public QObject, public QmlGraphicsItemKeyFilter +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QmlGraphicsKeyNavigationAttached) + + Q_PROPERTY(QmlGraphicsItem *left READ left WRITE setLeft NOTIFY changed) + Q_PROPERTY(QmlGraphicsItem *right READ right WRITE setRight NOTIFY changed) + Q_PROPERTY(QmlGraphicsItem *up READ up WRITE setUp NOTIFY changed) + Q_PROPERTY(QmlGraphicsItem *down READ down WRITE setDown NOTIFY changed) +public: + QmlGraphicsKeyNavigationAttached(QObject * = 0); + + QmlGraphicsItem *left() const; + void setLeft(QmlGraphicsItem *); + QmlGraphicsItem *right() const; + void setRight(QmlGraphicsItem *); + QmlGraphicsItem *up() const; + void setUp(QmlGraphicsItem *); + QmlGraphicsItem *down() const; + void setDown(QmlGraphicsItem *); + + static QmlGraphicsKeyNavigationAttached *qmlAttachedProperties(QObject *); + +Q_SIGNALS: + void changed(); + +private: + virtual void keyPressed(QKeyEvent *event); + virtual void keyReleased(QKeyEvent *event); +}; + +class QmlGraphicsKeysAttachedPrivate : public QObjectPrivate +{ +public: + QmlGraphicsKeysAttachedPrivate() + : QObjectPrivate(), inPress(false), inRelease(false) + , inIM(false), enabled(true), imeItem(0), item(0) + {} + + bool isConnected(const char *signalName); + + QGraphicsItem *finalFocusProxy(QGraphicsItem *item) const + { + QGraphicsItem *fp; + while ((fp = item->focusProxy())) + item = fp; + return item; + } + + //loop detection + bool inPress:1; + bool inRelease:1; + bool inIM:1; + + bool enabled : 1; + + QGraphicsItem *imeItem; + QList targets; + QmlGraphicsItem *item; +}; + +class QmlGraphicsKeysAttached : public QObject, public QmlGraphicsItemKeyFilter +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QmlGraphicsKeysAttached) + + Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) + Q_PROPERTY(QList *forwardTo READ forwardTo) + +public: + QmlGraphicsKeysAttached(QObject *parent=0); + ~QmlGraphicsKeysAttached(); + + bool enabled() const { Q_D(const QmlGraphicsKeysAttached); return d->enabled; } + void setEnabled(bool enabled) { + Q_D(QmlGraphicsKeysAttached); + if (enabled != d->enabled) { + d->enabled = enabled; + emit enabledChanged(); + } + } + + QList *forwardTo() { + Q_D(QmlGraphicsKeysAttached); + return &d->targets; + } + + virtual void componentComplete(); + + static QmlGraphicsKeysAttached *qmlAttachedProperties(QObject *); + +Q_SIGNALS: + void enabledChanged(); + void pressed(QmlGraphicsKeyEvent *event); + void released(QmlGraphicsKeyEvent *event); + void digit0Pressed(QmlGraphicsKeyEvent *event); + void digit1Pressed(QmlGraphicsKeyEvent *event); + void digit2Pressed(QmlGraphicsKeyEvent *event); + void digit3Pressed(QmlGraphicsKeyEvent *event); + void digit4Pressed(QmlGraphicsKeyEvent *event); + void digit5Pressed(QmlGraphicsKeyEvent *event); + void digit6Pressed(QmlGraphicsKeyEvent *event); + void digit7Pressed(QmlGraphicsKeyEvent *event); + void digit8Pressed(QmlGraphicsKeyEvent *event); + void digit9Pressed(QmlGraphicsKeyEvent *event); + + void leftPressed(QmlGraphicsKeyEvent *event); + void rightPressed(QmlGraphicsKeyEvent *event); + void upPressed(QmlGraphicsKeyEvent *event); + void downPressed(QmlGraphicsKeyEvent *event); + + void asteriskPressed(QmlGraphicsKeyEvent *event); + void numberSignPressed(QmlGraphicsKeyEvent *event); + void escapePressed(QmlGraphicsKeyEvent *event); + void returnPressed(QmlGraphicsKeyEvent *event); + void enterPressed(QmlGraphicsKeyEvent *event); + void deletePressed(QmlGraphicsKeyEvent *event); + void spacePressed(QmlGraphicsKeyEvent *event); + void backPressed(QmlGraphicsKeyEvent *event); + void cancelPressed(QmlGraphicsKeyEvent *event); + void selectPressed(QmlGraphicsKeyEvent *event); + void yesPressed(QmlGraphicsKeyEvent *event); + void noPressed(QmlGraphicsKeyEvent *event); + void context1Pressed(QmlGraphicsKeyEvent *event); + void context2Pressed(QmlGraphicsKeyEvent *event); + void context3Pressed(QmlGraphicsKeyEvent *event); + void context4Pressed(QmlGraphicsKeyEvent *event); + void callPressed(QmlGraphicsKeyEvent *event); + void hangupPressed(QmlGraphicsKeyEvent *event); + void flipPressed(QmlGraphicsKeyEvent *event); + void menuPressed(QmlGraphicsKeyEvent *event); + void volumeUpPressed(QmlGraphicsKeyEvent *event); + void volumeDownPressed(QmlGraphicsKeyEvent *event); + +private: + virtual void keyPressed(QKeyEvent *event); + virtual void keyReleased(QKeyEvent *event); + virtual void inputMethodEvent(QInputMethodEvent *); + virtual QVariant inputMethodQuery(Qt::InputMethodQuery query) const; + + const QByteArray keyToSignal(int key) { + QByteArray keySignal; + if (key >= Qt::Key_0 && key <= Qt::Key_9) { + keySignal = "digit0Pressed"; + keySignal[5] = '0' + (key - Qt::Key_0); + } else { + int i = 0; + while (sigMap[i].key && sigMap[i].key != key) + ++i; + keySignal = sigMap[i].sig; + } + return keySignal; + } + + struct SigMap { + int key; + const char *sig; + }; + + static const SigMap sigMap[]; +}; + Q_DECLARE_OPERATORS_FOR_FLAGS(QmlGraphicsItemPrivate::ChangeTypes); QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlGraphicsKeysAttached) +QML_DECLARE_TYPEINFO(QmlGraphicsKeysAttached, QML_HAS_ATTACHED_PROPERTIES) +QML_DECLARE_TYPE(QmlGraphicsKeyNavigationAttached) +QML_DECLARE_TYPEINFO(QmlGraphicsKeyNavigationAttached, QML_HAS_ATTACHED_PROPERTIES) + #endif // QMLGRAPHICSITEM_P_H diff --git a/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp b/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp new file mode 100644 index 0000000..d2cfb1a --- /dev/null +++ b/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp @@ -0,0 +1,158 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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$ +** +****************************************************************************/ + +#include "qmlgraphicsitemsmodule_p.h" + +#include +#include +#include + +#include "qmlgraphicsevents_p_p.h" +#include "qmlgraphicseffects_p.h" +#include "qmlgraphicsscalegrid_p_p.h" +#include "qmlgraphicsanimatedimage_p.h" +#include "qmlgraphicsborderimage_p.h" +#include "qmlgraphicspositioners_p.h" +#include "qmlgraphicsmouseregion_p.h" +#include "qmlgraphicsflickable_p.h" +#include "qmlgraphicsflickable_p_p.h" +#include "qmlgraphicsflipable_p.h" +#include "qmlgraphicsfocuspanel_p.h" +#include "qmlgraphicsfocusscope_p.h" +#include "qmlgraphicsgraphicsobjectcontainer_p.h" +#include "qmlgraphicsgridview_p.h" +#include "qmlgraphicsimage_p.h" +#include "qmlgraphicsitem_p.h" +#include "qmlgraphicslayoutitem_p.h" +#include "qmlgraphicslistview_p.h" +#include "qmlgraphicsloader_p.h" +#include "qmlgraphicsmouseregion_p.h" +#include "qmlgraphicsparticles_p.h" +#include "qmlgraphicspath_p.h" +#include "qmlgraphicspathview_p.h" +#include "qmlgraphicsrectangle_p.h" +#include "qmlgraphicsrepeater_p.h" +#include "qmlgraphicstext_p.h" +#include "qmlgraphicstextedit_p.h" +#include "qmlgraphicstextinput_p.h" +#include "qmlgraphicsvisualitemmodel_p.h" +#include "qmlgraphicswebview_p.h" +#include "qmlgraphicswebview_p_p.h" +#include "qmlgraphicsanchors_p.h" + +#define QML_REGISTER_TYPE(URI,VMAJ,VMIN,TYPE,CLASS) \ + qmlRegisterType(#URI, VMAJ, VMIN, #TYPE, #CLASS) + +#define QML_REGISTER_NOCREATE_TYPE(CLASS) \ + qmlRegisterType(#CLASS) + +void QmlGraphicsItemModule::defineModule() +{ + QML_REGISTER_TYPE(Qt,4,6,AnimatedImage,QmlGraphicsAnimatedImage); + QML_REGISTER_TYPE(Qt,4,6,Blur,QGraphicsBlurEffect); + QML_REGISTER_TYPE(Qt,4,6,BorderImage,QmlGraphicsBorderImage); + QML_REGISTER_TYPE(Qt,4,6,Colorize,QGraphicsColorizeEffect); + QML_REGISTER_TYPE(Qt,4,6,Column,QmlGraphicsColumn); + QML_REGISTER_TYPE(Qt,4,6,Drag,QmlGraphicsDrag); + QML_REGISTER_TYPE(Qt,4,6,DropShadow,QGraphicsDropShadowEffect); + QML_REGISTER_TYPE(Qt,4,6,Flickable,QmlGraphicsFlickable); + QML_REGISTER_TYPE(Qt,4,6,Flipable,QmlGraphicsFlipable); + QML_REGISTER_TYPE(Qt,4,6,Flow,QmlGraphicsFlow); + QML_REGISTER_TYPE(Qt,4,6,FocusPanel,QmlGraphicsFocusPanel); + QML_REGISTER_TYPE(Qt,4,6,FocusScope,QmlGraphicsFocusScope); + QML_REGISTER_TYPE(Qt,4,6,Gradient,QmlGraphicsGradient); + QML_REGISTER_TYPE(Qt,4,6,GradientStop,QmlGraphicsGradientStop); + QML_REGISTER_TYPE(Qt,4,6,GraphicsObjectContainer,QmlGraphicsGraphicsObjectContainer); + QML_REGISTER_TYPE(Qt,4,6,Grid,QmlGraphicsGrid); + QML_REGISTER_TYPE(Qt,4,6,GridView,QmlGraphicsGridView); + QML_REGISTER_TYPE(Qt,4,6,Image,QmlGraphicsImage); + QML_REGISTER_TYPE(Qt,4,6,Item,QmlGraphicsItem); + QML_REGISTER_TYPE(Qt,4,6,KeyNavigation,QmlGraphicsKeyNavigationAttached); + QML_REGISTER_TYPE(Qt,4,6,Keys,QmlGraphicsKeysAttached); + QML_REGISTER_TYPE(Qt,4,6,LayoutItem,QmlGraphicsLayoutItem); + QML_REGISTER_TYPE(Qt,4,6,ListView,QmlGraphicsListView); + QML_REGISTER_TYPE(Qt,4,6,Loader,QmlGraphicsLoader); + QML_REGISTER_TYPE(Qt,4,6,MouseRegion,QmlGraphicsMouseRegion); + QML_REGISTER_TYPE(Qt,4,6,Opacity,QGraphicsOpacityEffect); + QML_REGISTER_TYPE(Qt,4,6,ParticleMotion,QmlGraphicsParticleMotion); + QML_REGISTER_TYPE(Qt,4,6,ParticleMotionGravity,QmlGraphicsParticleMotionGravity); + QML_REGISTER_TYPE(Qt,4,6,ParticleMotionLinear,QmlGraphicsParticleMotionLinear); + QML_REGISTER_TYPE(Qt,4,6,ParticleMotionWander,QmlGraphicsParticleMotionWander); + QML_REGISTER_TYPE(Qt,4,6,Particles,QmlGraphicsParticles); + QML_REGISTER_TYPE(Qt,4,6,Path,QmlGraphicsPath); + QML_REGISTER_TYPE(Qt,4,6,PathAttribute,QmlGraphicsPathAttribute); + QML_REGISTER_TYPE(Qt,4,6,PathCubic,QmlGraphicsPathCubic); + QML_REGISTER_TYPE(Qt,4,6,PathLine,QmlGraphicsPathLine); + QML_REGISTER_TYPE(Qt,4,6,PathPercent,QmlGraphicsPathPercent); + QML_REGISTER_TYPE(Qt,4,6,PathQuad,QmlGraphicsPathQuad); + QML_REGISTER_TYPE(Qt,4,6,PathView,QmlGraphicsPathView); + QML_REGISTER_TYPE(Qt,4,6,Pen,QmlGraphicsPen); + QML_REGISTER_TYPE(Qt,4,6,QDoubleValidator,QDoubleValidator); + QML_REGISTER_TYPE(Qt,4,6,QIntValidator,QIntValidator); + QML_REGISTER_TYPE(Qt,4,6,QRegExpValidator,QRegExpValidator); + QML_REGISTER_TYPE(Qt,4,6,Rectangle,QmlGraphicsRectangle); + QML_REGISTER_TYPE(Qt,4,6,Repeater,QmlGraphicsRepeater); + QML_REGISTER_TYPE(Qt,4,6,Rotation,QGraphicsRotation); + QML_REGISTER_TYPE(Qt,4,6,Row,QmlGraphicsRow); + QML_REGISTER_TYPE(Qt,4,6,Scale,QGraphicsScale); + QML_REGISTER_TYPE(Qt,4,6,Text,QmlGraphicsText); + QML_REGISTER_TYPE(Qt,4,6,TextEdit,QmlGraphicsTextEdit); + QML_REGISTER_TYPE(Qt,4,6,TextInput,QmlGraphicsTextInput); + QML_REGISTER_TYPE(Qt,4,6,ViewSection,QmlGraphicsViewSection); + QML_REGISTER_TYPE(Qt,4,6,VisibleArea,QmlGraphicsFlickableVisibleArea); + QML_REGISTER_TYPE(Qt,4,6,VisualDataModel,QmlGraphicsVisualDataModel); + QML_REGISTER_TYPE(Qt,4,6,VisualItemModel,QmlGraphicsVisualItemModel); + QML_REGISTER_TYPE(Qt,4,6,WebView,QmlGraphicsWebView); + + QML_REGISTER_NOCREATE_TYPE(QmlGraphicsAnchors); + QML_REGISTER_NOCREATE_TYPE(QGraphicsEffect); + QML_REGISTER_NOCREATE_TYPE(QmlGraphicsKeyEvent); + QML_REGISTER_NOCREATE_TYPE(QmlGraphicsMouseEvent); + QML_REGISTER_NOCREATE_TYPE(QGraphicsObject); + QML_REGISTER_NOCREATE_TYPE(QGraphicsTransform); + QML_REGISTER_NOCREATE_TYPE(QmlGraphicsPathElement); + QML_REGISTER_NOCREATE_TYPE(QmlGraphicsCurve); + QML_REGISTER_NOCREATE_TYPE(QmlGraphicsScaleGrid); + QML_REGISTER_NOCREATE_TYPE(QValidator); + QML_REGISTER_NOCREATE_TYPE(QmlGraphicsVisualModel); + QML_REGISTER_NOCREATE_TYPE(QAction); + QML_REGISTER_NOCREATE_TYPE(QmlGraphicsWebSettings); +} diff --git a/src/declarative/graphicsitems/qmlgraphicsitemsmodule_p.h b/src/declarative/graphicsitems/qmlgraphicsitemsmodule_p.h new file mode 100644 index 0000000..bf38c24 --- /dev/null +++ b/src/declarative/graphicsitems/qmlgraphicsitemsmodule_p.h @@ -0,0 +1,63 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QMLGRAPHICSITEMMODULE_H +#define QMLGRAPHICSITEMMODULE_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QmlGraphicsItemModule +{ +public: + static void defineModule(); +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QMLGRAPHICSITEMMODULE_H diff --git a/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp b/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp index 7227eb0..98361dc 100644 --- a/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp @@ -47,8 +47,6 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,LayoutItem,QmlGraphicsLayoutItem) - /*! \qmlclass LayoutItem QmlGraphicsLayoutItem \brief The LayoutItem element allows you to place your Fluid UI elements inside a classical Qt layout. diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp index d0b3739..cdff73e 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp @@ -85,72 +85,6 @@ QString QmlGraphicsViewSection::sectionString(const QString &value) return value; } -class QmlGraphicsListViewAttached : public QObject -{ - Q_OBJECT -public: - QmlGraphicsListViewAttached(QObject *parent) - : QObject(parent), m_view(0), m_isCurrent(false), m_delayRemove(false) {} - ~QmlGraphicsListViewAttached() {} - - Q_PROPERTY(QmlGraphicsListView *view READ view CONSTANT) - QmlGraphicsListView *view() { return m_view; } - - Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged) - bool isCurrentItem() const { return m_isCurrent; } - void setIsCurrentItem(bool c) { - if (m_isCurrent != c) { - m_isCurrent = c; - emit currentItemChanged(); - } - } - - Q_PROPERTY(QString prevSection READ prevSection NOTIFY prevSectionChanged) - QString prevSection() const { return m_prevSection; } - void setPrevSection(const QString §) { - if (m_prevSection != sect) { - m_prevSection = sect; - emit prevSectionChanged(); - } - } - - Q_PROPERTY(QString section READ section NOTIFY sectionChanged) - QString section() const { return m_section; } - void setSection(const QString §) { - if (m_section != sect) { - m_section = sect; - emit sectionChanged(); - } - } - - Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged) - bool delayRemove() const { return m_delayRemove; } - void setDelayRemove(bool delay) { - if (m_delayRemove != delay) { - m_delayRemove = delay; - emit delayRemoveChanged(); - } - } - - void emitAdd() { emit add(); } - void emitRemove() { emit remove(); } - -Q_SIGNALS: - void currentItemChanged(); - void sectionChanged(); - void prevSectionChanged(); - void delayRemoveChanged(); - void add(); - void remove(); - -public: - QmlGraphicsListView *m_view; - bool m_isCurrent; - mutable QString m_section; - QString m_prevSection; - bool m_delayRemove; -}; - //---------------------------------------------------------------------------- class FxListItem @@ -2740,9 +2674,6 @@ QmlGraphicsListViewAttached *QmlGraphicsListView::qmlAttachedProperties(QObject return new QmlGraphicsListViewAttached(obj); } -QML_DEFINE_TYPE(Qt,4,6,ListView,QmlGraphicsListView) -QML_DEFINE_TYPE(Qt,4,6,ViewSection,QmlGraphicsViewSection) - QT_END_NAMESPACE #include diff --git a/src/declarative/graphicsitems/qmlgraphicslistview_p.h b/src/declarative/graphicsitems/qmlgraphicslistview_p.h index 79d678a..42ace15 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicslistview_p.h @@ -227,6 +227,73 @@ private Q_SLOTS: void animStopped(); }; +class QmlGraphicsListViewAttached : public QObject +{ + Q_OBJECT +public: + QmlGraphicsListViewAttached(QObject *parent) + : QObject(parent), m_view(0), m_isCurrent(false), m_delayRemove(false) {} + ~QmlGraphicsListViewAttached() {} + + Q_PROPERTY(QmlGraphicsListView *view READ view CONSTANT) + QmlGraphicsListView *view() { return m_view; } + + Q_PROPERTY(bool isCurrentItem READ isCurrentItem NOTIFY currentItemChanged) + bool isCurrentItem() const { return m_isCurrent; } + void setIsCurrentItem(bool c) { + if (m_isCurrent != c) { + m_isCurrent = c; + emit currentItemChanged(); + } + } + + Q_PROPERTY(QString prevSection READ prevSection NOTIFY prevSectionChanged) + QString prevSection() const { return m_prevSection; } + void setPrevSection(const QString §) { + if (m_prevSection != sect) { + m_prevSection = sect; + emit prevSectionChanged(); + } + } + + Q_PROPERTY(QString section READ section NOTIFY sectionChanged) + QString section() const { return m_section; } + void setSection(const QString §) { + if (m_section != sect) { + m_section = sect; + emit sectionChanged(); + } + } + + Q_PROPERTY(bool delayRemove READ delayRemove WRITE setDelayRemove NOTIFY delayRemoveChanged) + bool delayRemove() const { return m_delayRemove; } + void setDelayRemove(bool delay) { + if (m_delayRemove != delay) { + m_delayRemove = delay; + emit delayRemoveChanged(); + } + } + + void emitAdd() { emit add(); } + void emitRemove() { emit remove(); } + +Q_SIGNALS: + void currentItemChanged(); + void sectionChanged(); + void prevSectionChanged(); + void delayRemoveChanged(); + void add(); + void remove(); + +public: + QmlGraphicsListView *m_view; + bool m_isCurrent; + mutable QString m_section; + QString m_prevSection; + bool m_delayRemove; +}; + + QT_END_NAMESPACE QML_DECLARE_TYPEINFO(QmlGraphicsListView, QML_HAS_ATTACHED_PROPERTIES) diff --git a/src/declarative/graphicsitems/qmlgraphicsloader.cpp b/src/declarative/graphicsitems/qmlgraphicsloader.cpp index b3486ef..d778c83 100644 --- a/src/declarative/graphicsitems/qmlgraphicsloader.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsloader.cpp @@ -108,8 +108,6 @@ void QmlGraphicsLoaderPrivate::initResize() _q_updateSize(); } -QML_DEFINE_TYPE(Qt,4,6,Loader,QmlGraphicsLoader) - /*! \qmlclass Loader QmlGraphicsLoader \inherits Item diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp index bd21e7a..fe72e84 100644 --- a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp @@ -49,7 +49,6 @@ QT_BEGIN_NAMESPACE static const int PressAndHoldDelay = 800; -QML_DEFINE_TYPE(Qt,4,6,Drag,QmlGraphicsDrag) QmlGraphicsDrag::QmlGraphicsDrag(QObject *parent) : QObject(parent), _target(0), _axis(XandYAxis), _xmin(0), _xmax(0), _ymin(0), _ymax(0) { @@ -231,8 +230,6 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate() The \e accepted property of the MouseEvent parameter is ignored in this handler. */ -QML_DEFINE_TYPE(Qt,4,6,MouseRegion,QmlGraphicsMouseRegion) - /*! \internal \class QmlGraphicsMouseRegion diff --git a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp index 8c5fb4f..5edd59e 100644 --- a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp @@ -108,8 +108,6 @@ public: //--------------------------------------------------------------------------- -QML_DEFINE_TYPE(Qt,4,6,ParticleMotion,QmlGraphicsParticleMotion) - /*! \class QmlGraphicsParticleMotion \ingroup group_effects @@ -169,8 +167,6 @@ void QmlGraphicsParticleMotion::destroy(QmlGraphicsParticle &particle) \brief The QmlGraphicsParticleMotionLinear class moves the particles linearly. */ -QML_DEFINE_TYPE(Qt,4,6,ParticleMotionLinear,QmlGraphicsParticleMotionLinear) - void QmlGraphicsParticleMotionLinear::advance(QmlGraphicsParticle &p, int interval) { p.x += interval * p.x_velocity; @@ -191,8 +187,6 @@ void QmlGraphicsParticleMotionLinear::advance(QmlGraphicsParticle &p, int interv \brief The QmlGraphicsParticleMotionGravity class moves the particles towards a point. */ -QML_DEFINE_TYPE(Qt,4,6,ParticleMotionGravity,QmlGraphicsParticleMotionGravity) - /*! \qmlproperty int ParticleMotionGravity::xattractor \qmlproperty int ParticleMotionGravity::yattractor @@ -293,8 +287,6 @@ Rectangle { This property holds how quickly the paricles will move from side to side. */ -QML_DEFINE_TYPE(Qt,4,6,ParticleMotionWander,QmlGraphicsParticleMotionWander) - void QmlGraphicsParticleMotionWander::advance(QmlGraphicsParticle &p, int interval) { if (!particles) @@ -561,8 +553,6 @@ void QmlGraphicsParticlesPrivate::updateOpacity(QmlGraphicsParticle &p, int age) } } -QML_DEFINE_TYPE(Qt,4,6,Particles,QmlGraphicsParticles) - /*! \qmlclass Particles \brief The Particles object generates and moves particles. diff --git a/src/declarative/graphicsitems/qmlgraphicspath.cpp b/src/declarative/graphicsitems/qmlgraphicspath.cpp index 18f27af..fae8161 100644 --- a/src/declarative/graphicsitems/qmlgraphicspath.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspath.cpp @@ -49,14 +49,6 @@ #include QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,Path,QmlGraphicsPath) -QML_DEFINE_NOCREATE_TYPE(QmlGraphicsPathElement) -QML_DEFINE_NOCREATE_TYPE(QmlGraphicsCurve) -QML_DEFINE_TYPE(Qt,4,6,PathAttribute,QmlGraphicsPathAttribute) -QML_DEFINE_TYPE(Qt,4,6,PathPercent,QmlGraphicsPathPercent) -QML_DEFINE_TYPE(Qt,4,6,PathLine,QmlGraphicsPathLine) -QML_DEFINE_TYPE(Qt,4,6,PathQuad,QmlGraphicsPathQuad) -QML_DEFINE_TYPE(Qt,4,6,PathCubic,QmlGraphicsPathCubic) /*! \qmlclass PathElement QmlGraphicsPathElement diff --git a/src/declarative/graphicsitems/qmlgraphicspathview.cpp b/src/declarative/graphicsitems/qmlgraphicspathview.cpp index 6718d25..a1c9229 100644 --- a/src/declarative/graphicsitems/qmlgraphicspathview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspathview.cpp @@ -54,9 +54,6 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,PathView,QmlGraphicsPathView) - - inline qreal qmlMod(qreal x, qreal y) { #ifdef QT_USE_MATH_H_FLOATS diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp index 5b081a2..142cdce 100644 --- a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp @@ -288,7 +288,6 @@ void QmlGraphicsBasePositioner::finishApplyTransitions() d->moveActions.clear(); } -QML_DEFINE_TYPE(Qt,4,6,Column,QmlGraphicsColumn) /*! \qmlclass Column QmlGraphicsColumn \brief The Column item lines up its children vertically. @@ -418,7 +417,6 @@ void QmlGraphicsColumn::doPositioning() } } -QML_DEFINE_TYPE(Qt,4,6,Row,QmlGraphicsRow) /*! \qmlclass Row QmlGraphicsRow \brief The Row item lines up its children horizontally. @@ -523,7 +521,6 @@ void QmlGraphicsRow::doPositioning() } } -QML_DEFINE_TYPE(Qt,4,6,Grid,QmlGraphicsGrid) /*! \qmlclass Grid QmlGraphicsGrid @@ -711,7 +708,6 @@ void QmlGraphicsGrid::doPositioning() } -QML_DEFINE_TYPE(Qt,4,6,Flow,QmlGraphicsFlow) /*! \qmlclass Flow QmlGraphicsFlow \brief The Flow item lines up its children side by side, wrapping as necessary. diff --git a/src/declarative/graphicsitems/qmlgraphicsrectangle.cpp b/src/declarative/graphicsitems/qmlgraphicsrectangle.cpp index cc09436..ec44d93 100644 --- a/src/declarative/graphicsitems/qmlgraphicsrectangle.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsrectangle.cpp @@ -46,9 +46,6 @@ #include QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,Pen,QmlGraphicsPen) -QML_DEFINE_TYPE(Qt,4,6,GradientStop,QmlGraphicsGradientStop) -QML_DEFINE_TYPE(Qt,4,6,Gradient,QmlGraphicsGradient) /*! \internal @@ -149,7 +146,6 @@ void QmlGraphicsGradient::doUpdate() emit updated(); } -QML_DEFINE_TYPE(Qt,4,6,Rectangle,QmlGraphicsRectangle) /*! \qmlclass Rectangle QmlGraphicsRectangle diff --git a/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp b/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp index 99f0faa..f0e5bb3 100644 --- a/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp @@ -60,8 +60,6 @@ QmlGraphicsRepeaterPrivate::~QmlGraphicsRepeaterPrivate() delete model; } -QML_DEFINE_TYPE(Qt,4,6,Repeater,QmlGraphicsRepeater) - /*! \qmlclass Repeater QmlGraphicsRepeater \inherits Item diff --git a/src/declarative/graphicsitems/qmlgraphicsscalegrid.cpp b/src/declarative/graphicsitems/qmlgraphicsscalegrid.cpp index f50b79b..94b562b 100644 --- a/src/declarative/graphicsitems/qmlgraphicsscalegrid.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsscalegrid.cpp @@ -52,7 +52,6 @@ QT_BEGIN_NAMESPACE \class QmlGraphicsScaleGrid \brief The QmlGraphicsScaleGrid class allows you to specify a 3x3 grid to use in scaling an image. */ -QML_DEFINE_NOCREATE_TYPE(QmlGraphicsScaleGrid) QmlGraphicsScaleGrid::QmlGraphicsScaleGrid(QObject *parent) : QObject(parent), _left(0), _top(0), _right(0), _bottom(0) { diff --git a/src/declarative/graphicsitems/qmlgraphicstext.cpp b/src/declarative/graphicsitems/qmlgraphicstext.cpp index b13fb7c..89081eb 100644 --- a/src/declarative/graphicsitems/qmlgraphicstext.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstext.cpp @@ -55,7 +55,6 @@ #include QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,Text,QmlGraphicsText) /*! \qmlclass Text QmlGraphicsText diff --git a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp index fc80258..00f7e42 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextedit.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstextedit.cpp @@ -56,7 +56,6 @@ #include QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,TextEdit,QmlGraphicsTextEdit) /*! \qmlclass TextEdit QmlGraphicsTextEdit diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp index 6d79c7a..ea54351 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp @@ -51,12 +51,6 @@ QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,TextInput,QmlGraphicsTextInput); -QML_DEFINE_NOCREATE_TYPE(QValidator); -QML_DEFINE_TYPE(Qt,4,6,QIntValidator,QIntValidator); -QML_DEFINE_TYPE(Qt,4,6,QDoubleValidator,QDoubleValidator); -QML_DEFINE_TYPE(Qt,4,6,QRegExpValidator,QRegExpValidator); - /*! \qmlclass TextInput QmlGraphicsTextInput The TextInput item allows you to add an editable line of text to a scene. diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp index 2fc143d..b4487a6 100644 --- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp @@ -66,44 +66,6 @@ QML_DECLARE_TYPE(QListModelInterface) QT_BEGIN_NAMESPACE -class QmlGraphicsVisualItemModelAttached : public QObject -{ - Q_OBJECT - -public: - QmlGraphicsVisualItemModelAttached(QObject *parent) - : QObject(parent), m_index(0) {} - ~QmlGraphicsVisualItemModelAttached() { - attachedProperties.remove(parent()); - } - - Q_PROPERTY(int index READ index NOTIFY indexChanged) - int index() const { return m_index; } - void setIndex(int idx) { - if (m_index != idx) { - m_index = idx; - emit indexChanged(); - } - } - - static QmlGraphicsVisualItemModelAttached *properties(QObject *obj) { - QmlGraphicsVisualItemModelAttached *rv = attachedProperties.value(obj); - if (!rv) { - rv = new QmlGraphicsVisualItemModelAttached(obj); - attachedProperties.insert(obj, rv); - } - return rv; - } - -Q_SIGNALS: - void indexChanged(); - -public: - int m_index; - - static QHash attachedProperties; -}; - QHash QmlGraphicsVisualItemModelAttached::attachedProperties; @@ -1146,10 +1108,6 @@ void QmlGraphicsVisualDataModel::_q_destroyingPackage(QmlPackage *package) emit destroyingItem(qobject_cast(package->part(d->m_part))); } -QML_DEFINE_NOCREATE_TYPE(QmlGraphicsVisualModel); -QML_DEFINE_TYPE(Qt,4,6,VisualItemModel,QmlGraphicsVisualItemModel) -QML_DEFINE_TYPE(Qt,4,6,VisualDataModel,QmlGraphicsVisualDataModel) - QT_END_NAMESPACE #include diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h index ef849b0..9ebf626 100644 --- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel_p.h @@ -195,6 +195,45 @@ private: Q_DISABLE_COPY(QmlGraphicsVisualDataModel) }; +class QmlGraphicsVisualItemModelAttached : public QObject +{ + Q_OBJECT + +public: + QmlGraphicsVisualItemModelAttached(QObject *parent) + : QObject(parent), m_index(0) {} + ~QmlGraphicsVisualItemModelAttached() { + attachedProperties.remove(parent()); + } + + Q_PROPERTY(int index READ index NOTIFY indexChanged) + int index() const { return m_index; } + void setIndex(int idx) { + if (m_index != idx) { + m_index = idx; + emit indexChanged(); + } + } + + static QmlGraphicsVisualItemModelAttached *properties(QObject *obj) { + QmlGraphicsVisualItemModelAttached *rv = attachedProperties.value(obj); + if (!rv) { + rv = new QmlGraphicsVisualItemModelAttached(obj); + attachedProperties.insert(obj, rv); + } + return rv; + } + +Q_SIGNALS: + void indexChanged(); + +public: + int m_index; + + static QHash attachedProperties; +}; + + QT_END_NAMESPACE QML_DECLARE_TYPE(QmlGraphicsVisualModel) diff --git a/src/declarative/graphicsitems/qmlgraphicswebview.cpp b/src/declarative/graphicsitems/qmlgraphicswebview.cpp index 85fd0d7..c71a366 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicswebview.cpp @@ -64,13 +64,9 @@ #include QT_BEGIN_NAMESPACE -QML_DEFINE_TYPE(Qt,4,6,WebView,QmlGraphicsWebView) -QML_DEFINE_NOCREATE_TYPE(QAction) static const int MAX_DOUBLECLICK_TIME=500; // XXX need better gesture system -QML_DEFINE_NOCREATE_TYPE(QmlGraphicsWebSettings) - class QmlGraphicsWebViewPrivate : public QmlGraphicsPaintedItemPrivate { Q_DECLARE_PUBLIC(QmlGraphicsWebView) @@ -461,30 +457,6 @@ QmlList *QmlGraphicsWebView::javaScriptWindowObjects() return &d->windowObjects; } -class QmlGraphicsWebViewAttached : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString windowObjectName READ windowObjectName WRITE setWindowObjectName) -public: - QmlGraphicsWebViewAttached(QObject *parent) - : QObject(parent) - { - } - - QString windowObjectName() const - { - return m_windowObjectName; - } - - void setWindowObjectName(const QString &n) - { - m_windowObjectName = n; - } - -private: - QString m_windowObjectName; -}; - QmlGraphicsWebViewAttached *QmlGraphicsWebView::qmlAttachedProperties(QObject *o) { return new QmlGraphicsWebViewAttached(o); diff --git a/src/declarative/graphicsitems/qmlgraphicswebview_p.h b/src/declarative/graphicsitems/qmlgraphicswebview_p.h index f5edb7a..c370c59 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicswebview_p.h @@ -246,6 +246,31 @@ private: friend class QmlGraphicsWebPage; }; +class QmlGraphicsWebViewAttached : public QObject +{ + Q_OBJECT + Q_PROPERTY(QString windowObjectName READ windowObjectName WRITE setWindowObjectName) +public: + QmlGraphicsWebViewAttached(QObject *parent) + : QObject(parent) + { + } + + QString windowObjectName() const + { + return m_windowObjectName; + } + + void setWindowObjectName(const QString &n) + { + m_windowObjectName = n; + } + +private: + QString m_windowObjectName; +}; + + QT_END_NAMESPACE QML_DECLARE_TYPE(QmlGraphicsWebView) diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index cdbe5f3..35fc3d4 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -95,6 +95,8 @@ #include #include +#include + #ifdef Q_OS_WIN // for %APPDATA% #include #include @@ -136,6 +138,8 @@ struct StaticQtMetaObject : public QObject { return &static_cast (0)->staticQtMetaObject; } }; +static bool qt_QmlQtModule_registered = false; + QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) : captureProperties(false), rootContext(0), currentExpression(0), isDebugging(false), contextClass(0), sharedContext(0), sharedScope(0), objectClass(0), valueTypeClass(0), @@ -144,6 +148,10 @@ QmlEnginePrivate::QmlEnginePrivate(QmlEngine *e) networkAccessManager(0), networkAccessManagerFactory(0), typeManager(e), uniqueId(1) { + if (!qt_QmlQtModule_registered) { + qt_QmlQtModule_registered = true; + QmlGraphicsItemModule::defineModule(); + } globalClass = new QmlGlobalScriptClass(&scriptEngine); fileImportPath.append(QLibraryInfo::location(QLibraryInfo::DataPath)+QDir::separator()+QLatin1String("qml")); } -- cgit v0.12 From 21f9b43979f5a8193de8932448466aa42d7a4e5f Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Fri, 12 Feb 2010 16:24:11 +1000 Subject: Remove noop code --- src/declarative/qml/qmlcomponent.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp index 9e06016..343bd4b 100644 --- a/src/declarative/qml/qmlcomponent.cpp +++ b/src/declarative/qml/qmlcomponent.cpp @@ -539,7 +539,6 @@ QObject *QmlComponent::create(QmlContext *context) QObject *QmlComponentPrivate::create(QmlContext *context, const QBitField &bindings) { - QObject *create(QmlContext *context, const QBitField &); if (!context) context = engine->rootContext(); -- cgit v0.12 From fb28599786d069a2b99040bd7eee8c5ad8ef1ba9 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 15 Feb 2010 11:47:52 +1000 Subject: Not exported in Qt 4.6.2, push to next release. --- tools/qmlviewer/qmlviewer.cpp | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index 1566473..8b3b7aa 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -52,8 +52,9 @@ #include #include "deviceskin.h" -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) +#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 3)) #include +#define QMLVIEWER_ZIP_SUPPORT #endif #include @@ -866,7 +867,7 @@ void QmlViewer::reload() void QmlViewer::open(const QString& doc) { -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) +#ifdef QMLVIEWER_ZIP_SUPPORT if (doc.endsWith(".wgt",Qt::CaseInsensitive) || doc.endsWith(".wgz",Qt::CaseInsensitive) || doc.endsWith(".zip",Qt::CaseInsensitive)) @@ -878,7 +879,7 @@ void QmlViewer::open(const QString& doc) void QmlViewer::openWgt(const QString& doc) { -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) +#ifdef QMLVIEWER_ZIP_SUPPORT // XXX This functionality could be migrated to QmlView once refined QUrl url(doc); @@ -891,7 +892,7 @@ void QmlViewer::openWgt(const QString& doc) #endif } -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) +#ifdef QMLVIEWER_ZIP_SUPPORT static void removeRecursive(const QString& dirname) { QDir dir(dirname); @@ -907,7 +908,7 @@ static void removeRecursive(const QString& dirname) void QmlViewer::unpackWgt() { -#if (QT_VERSION >= QT_VERSION_CHECK(4, 6, 2)) +#ifdef QMLVIEWER_ZIP_SUPPORT QByteArray all = wgtreply->readAll(); QBuffer buf(&all); buf.open(QIODevice::ReadOnly); -- cgit v0.12 From b258be1d39889e65411324fe5cda47a34f814033 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 15 Feb 2010 12:47:36 +1000 Subject: Fix build Remove unneeded .moc imports resulting from moved classes. --- src/declarative/graphicsitems/qmlgraphicsflickable.cpp | 2 -- src/declarative/graphicsitems/qmlgraphicsgridview.cpp | 2 -- src/declarative/graphicsitems/qmlgraphicslistview.cpp | 2 -- 3 files changed, 6 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp index cf8952d..5143251 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp @@ -1335,5 +1335,3 @@ void QmlGraphicsFlickablePrivate::updateVelocity() } QT_END_NAMESPACE - -#include diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp index 34aed4e..ee711b4 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp @@ -1698,5 +1698,3 @@ QmlGraphicsGridViewAttached *QmlGraphicsGridView::qmlAttachedProperties(QObject } QT_END_NAMESPACE - -#include diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp index cdff73e..db0afe1 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp @@ -2675,5 +2675,3 @@ QmlGraphicsListViewAttached *QmlGraphicsListView::qmlAttachedProperties(QObject } QT_END_NAMESPACE - -#include -- cgit v0.12 From 40a8d38c68258623da468483b75c5256240d0557 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 15 Feb 2010 13:04:59 +1000 Subject: Fix compile with -no-webkit --- src/declarative/graphicsitems/qmlgraphicsitem.h | 2 ++ src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp | 6 ++++++ src/declarative/graphicsitems/qmlgraphicswebview_p.h | 1 - 3 files changed, 8 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.h b/src/declarative/graphicsitems/qmlgraphicsitem.h index 8ae2d5c..e0f33c7 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.h +++ b/src/declarative/graphicsitems/qmlgraphicsitem.h @@ -50,6 +50,7 @@ #include #include #include +#include QT_BEGIN_HEADER @@ -233,6 +234,7 @@ QML_DECLARE_TYPE(QmlGraphicsItem) QML_DECLARE_TYPE(QGraphicsTransform) QML_DECLARE_TYPE(QGraphicsScale) QML_DECLARE_TYPE(QGraphicsRotation) +QML_DECLARE_TYPE(QAction) QT_END_HEADER diff --git a/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp b/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp index d2cfb1a..127aec8 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp @@ -74,8 +74,10 @@ #include "qmlgraphicstextedit_p.h" #include "qmlgraphicstextinput_p.h" #include "qmlgraphicsvisualitemmodel_p.h" +#ifdef QT_WEBKIT_LIB #include "qmlgraphicswebview_p.h" #include "qmlgraphicswebview_p_p.h" +#endif #include "qmlgraphicsanchors_p.h" #define QML_REGISTER_TYPE(URI,VMAJ,VMIN,TYPE,CLASS) \ @@ -140,7 +142,9 @@ void QmlGraphicsItemModule::defineModule() QML_REGISTER_TYPE(Qt,4,6,VisibleArea,QmlGraphicsFlickableVisibleArea); QML_REGISTER_TYPE(Qt,4,6,VisualDataModel,QmlGraphicsVisualDataModel); QML_REGISTER_TYPE(Qt,4,6,VisualItemModel,QmlGraphicsVisualItemModel); +#ifdef QT_WEBKIT_LIB QML_REGISTER_TYPE(Qt,4,6,WebView,QmlGraphicsWebView); +#endif QML_REGISTER_NOCREATE_TYPE(QmlGraphicsAnchors); QML_REGISTER_NOCREATE_TYPE(QGraphicsEffect); @@ -154,5 +158,7 @@ void QmlGraphicsItemModule::defineModule() QML_REGISTER_NOCREATE_TYPE(QValidator); QML_REGISTER_NOCREATE_TYPE(QmlGraphicsVisualModel); QML_REGISTER_NOCREATE_TYPE(QAction); +#ifdef QT_WEBKIT_LIB QML_REGISTER_NOCREATE_TYPE(QmlGraphicsWebSettings); +#endif } diff --git a/src/declarative/graphicsitems/qmlgraphicswebview_p.h b/src/declarative/graphicsitems/qmlgraphicswebview_p.h index c370c59..0aaf895 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview_p.h +++ b/src/declarative/graphicsitems/qmlgraphicswebview_p.h @@ -275,7 +275,6 @@ QT_END_NAMESPACE QML_DECLARE_TYPE(QmlGraphicsWebView) QML_DECLARE_TYPEINFO(QmlGraphicsWebView, QML_HAS_ATTACHED_PROPERTIES) -QML_DECLARE_TYPE(QAction) QT_END_HEADER -- cgit v0.12 From e55cb23edff635061ec9537c7589b900cc65a83c Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 15 Feb 2010 14:07:02 +1000 Subject: Make tests compile without webkit --- tests/auto/declarative/declarative.pro | 5 ++++- tests/auto/declarative/qmlengine/qmlengine.pro | 2 +- 2 files changed, 5 insertions(+), 2 deletions(-) diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 8773026..c0e807e 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -35,7 +35,6 @@ SUBDIRS += \ qmlgraphicstext \ # Cover qmlgraphicstextedit \ # Cover qmlgraphicstextinput \ # Cover - qmlgraphicswebview \ # Cover qmlinfo \ # Cover qmlinstruction \ # Cover qmllanguage \ # Cover @@ -59,6 +58,10 @@ SUBDIRS += \ qmlxmlhttprequest \ # Cover sql # Cover +contains(QT_CONFIG, webkit) { + SUBDIRS += \ + qmlgraphicswebview # Cover +} # Tests which should run in Pulse PULSE_TESTS = $$SUBDIRS diff --git a/tests/auto/declarative/qmlengine/qmlengine.pro b/tests/auto/declarative/qmlengine/qmlengine.pro index 21d55a4..1a0e5f4 100644 --- a/tests/auto/declarative/qmlengine/qmlengine.pro +++ b/tests/auto/declarative/qmlengine/qmlengine.pro @@ -1,5 +1,5 @@ load(qttest_p4) -contains(QT_CONFIG,declarative): QT += declarative webkit network +contains(QT_CONFIG,declarative): QT += declarative network macx:CONFIG -= app_bundle SOURCES += tst_qmlengine.cpp -- cgit v0.12 From 1caff7f6909aa69f280d7ba89aeaad15e80563d8 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 15 Feb 2010 14:15:49 +1000 Subject: Make tst_qmlmetatype stable --- tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp b/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp index ccb8f30..c336226 100644 --- a/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp +++ b/tests/auto/declarative/qmlmetatype/tst_qmlmetatype.cpp @@ -157,9 +157,12 @@ void tst_qmlmetatype::copy() QT_COPY_TEST(QStringList, QStringList() << "QML" << "Rocks"); QT_COPY_TEST(QByteArray, QByteArray("0x1102DDD")); QT_COPY_TEST(QBitArray, QBitArray(102, true)); - QT_COPY_TEST(QDate, QDate::currentDate()); - QT_COPY_TEST(QTime, QTime::currentTime()); - QT_COPY_TEST(QDateTime, QDateTime::currentDateTime()); + QDate cd = QDate::currentDate(); + QT_COPY_TEST(QDate, cd); + QTime ct = QTime::currentTime(); + QT_COPY_TEST(QTime, ct); + QDateTime cdt = QDateTime::currentDateTime(); + QT_COPY_TEST(QDateTime, cdt); QT_COPY_TEST(QUrl, QUrl("http://www.nokia.com")); QT_COPY_TEST(QLocale, QLocale(QLocale::English, QLocale::Australia)); QT_COPY_TEST(QRect, QRect(-10, 10, 102, 99)); -- cgit v0.12 From 070208528ca9a532a926d7b38abf4b5df576c0d5 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 15 Feb 2010 14:27:49 +1000 Subject: Make tst_qmlecmascript::dynamicDestruction stable --- tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp index e5472bb..4edca69 100644 --- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp +++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp @@ -45,7 +45,7 @@ #include #include #include -#include +#include #include #include #include @@ -835,9 +835,9 @@ void tst_qmlecmascript::dynamicCreation() void tst_qmlecmascript::dynamicDestruction() { QmlComponent component(&engine, TEST_FILE("dynamicDeletion.qml")); - QGuard object = qobject_cast(component.create()); + QmlGuard object = qobject_cast(component.create()); QVERIFY(object != 0); - QGuard createdQmlObject = 0; + QmlGuard createdQmlObject = 0; QMetaObject::invokeMethod(object, "create"); createdQmlObject = object->objectProperty(); @@ -846,10 +846,9 @@ void tst_qmlecmascript::dynamicDestruction() QMetaObject::invokeMethod(object, "killOther"); QVERIFY(createdQmlObject); - QTest::qWait(0); QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion); QVERIFY(createdQmlObject); - for (int ii = 0; createdQmlObject && ii < 10; ++ii) { + for (int ii = 0; createdQmlObject && ii < 50; ++ii) { // After 5 seconds we should give up if (createdQmlObject) { QTest::qWait(100); QCoreApplication::instance()->processEvents(QEventLoop::DeferredDeletion); -- cgit v0.12 From e1ffe40b36a69ba1b1e3bcd3619e5dc2a2fbe8ba Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Mon, 15 Feb 2010 14:31:33 +1000 Subject: Update as test running qmakery changes. --- tests/auto/declarative/runall.sh | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/tests/auto/declarative/runall.sh b/tests/auto/declarative/runall.sh index 33087a1..d9eddf9 100755 --- a/tests/auto/declarative/runall.sh +++ b/tests/auto/declarative/runall.sh @@ -5,13 +5,19 @@ sleep 1 trap "kill $!" EXIT export DISPLAY=:7 -make -k -j1 install 2>&1 | +( make -k -j1 install 2>&1; + for exe in $(make install | sed -n 's/^install .* "\([^"]*qt4\/tst_[^"]*\)".*/\1/p') + do + $exe + done +) | while read line do case "$line" in make*Error) echo "$line";; make*Stop) echo "$line";; make*) ;; + install*) ;; */qmake*) ;; */bin/moc*) ;; *targ.debug*) ;; -- cgit v0.12 From 988c69de1a16080bf9646f9698ff62cc5541e0b8 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 15 Feb 2010 16:36:25 +1000 Subject: Make tst_xmlhttprequest more reliable --- tests/auto/declarative/qmlxmlhttprequest/data/abort.reply | 1 + .../qmlxmlhttprequest/data/getResponseHeader.reply | 1 + .../declarative/qmlxmlhttprequest/data/open_network.reply | 1 + tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply | 1 + .../declarative/qmlxmlhttprequest/data/send_ignoreData.reply | 1 + .../declarative/qmlxmlhttprequest/data/setRequestHeader.reply | 1 + .../qmlxmlhttprequest/data/setRequestHeader_illegalName.qml | 1 + .../auto/declarative/qmlxmlhttprequest/data/status.200.reply | 1 + .../auto/declarative/qmlxmlhttprequest/data/status.404.reply | 1 + tests/auto/declarative/shared/testhttpserver.cpp | 11 ++++++----- 10 files changed, 15 insertions(+), 5 deletions(-) diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply b/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply index 35b11f4..7ae6951 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply +++ b/tests/auto/declarative/qmlxmlhttprequest/data/abort.reply @@ -1,2 +1,3 @@ HTTP/1.0 200 OK +Connection: close Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply index 62ec67b..c4b4bb2 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getResponseHeader.reply @@ -1,4 +1,5 @@ HTTP/1.0 200 OK +Connection: close Content-type: text/html; charset=UTF-8 Test-Header: TestValue MultiTest-Header: TestValue diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply b/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply index 35b11f4..7ae6951 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply +++ b/tests/auto/declarative/qmlxmlhttprequest/data/open_network.reply @@ -1,2 +1,3 @@ HTTP/1.0 200 OK +Connection: close Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply index 35b11f4..7ae6951 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_data.reply @@ -1,2 +1,3 @@ HTTP/1.0 200 OK +Connection: close Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply index 35b11f4..7ae6951 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply +++ b/tests/auto/declarative/qmlxmlhttprequest/data/send_ignoreData.reply @@ -1,2 +1,3 @@ HTTP/1.0 200 OK +Connection: close Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply index 35b11f4..7ae6951 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply +++ b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader.reply @@ -1,2 +1,3 @@ HTTP/1.0 200 OK +Connection: close Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml index bf31eca..e9535d5 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml +++ b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml @@ -46,6 +46,7 @@ QtObject { x.onreadystatechange = function() { if (x.readyState == XMLHttpRequest.DONE) { dataOK = (x.responseText == "QML Rocks!\n"); + print("DATA:" + x.responseText); } } diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply b/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply index 35b11f4..7ae6951 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply +++ b/tests/auto/declarative/qmlxmlhttprequest/data/status.200.reply @@ -1,2 +1,3 @@ HTTP/1.0 200 OK +Connection: close Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply b/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply index 964a7a8..2e29f56 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply +++ b/tests/auto/declarative/qmlxmlhttprequest/data/status.404.reply @@ -1,2 +1,3 @@ HTTP/1.0 404 Document not found +Connection: close Content-type: text/html; charset=UTF-8 diff --git a/tests/auto/declarative/shared/testhttpserver.cpp b/tests/auto/declarative/shared/testhttpserver.cpp index 490fc95..5740925 100644 --- a/tests/auto/declarative/shared/testhttpserver.cpp +++ b/tests/auto/declarative/shared/testhttpserver.cpp @@ -190,13 +190,14 @@ void TestHTTPServer::disconnected() --ii; } } + socket->disconnect(); socket->deleteLater(); } void TestHTTPServer::readyRead() { QTcpSocket *socket = qobject_cast(sender()); - if (!socket) return; + if (!socket || socket->state() == QTcpSocket::ClosingState) return; QByteArray ba = socket->readAll(); @@ -222,14 +223,14 @@ void TestHTTPServer::readyRead() QByteArray data = ba.mid(ii); qWarning() << "TestHTTPServer: Unexpected data" << data << "\nExpected: " << waitData; m_hasFailed = true; - socket->disconnect(); + socket->disconnectFromHost(); return; } } if (waitData.isEmpty()) { socket->write(replyData); - socket->disconnect(); + socket->disconnectFromHost(); } } @@ -316,8 +317,8 @@ void TestHTTPServer::serveGET(QTcpSocket *socket, const QByteArray &data) } dataCache.remove(socket); - if (close) - socket->close(); + if (close) + socket->disconnectFromHost(); } } -- cgit v0.12 From af36be2c7257870e1ad094ec7b2cc37ae4ca2176 Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Mon, 15 Feb 2010 17:22:29 +1000 Subject: For qmldebug* tests, make sure engine is running before the test thread is started. Also fix some memory leaks. --- src/declarative/debugger/qmldebugservice.cpp | 33 ++++++++++++++++++ src/declarative/debugger/qmldebugservice_p.h | 4 ++- tests/auto/declarative/qmldebug/tst_qmldebug.cpp | 40 +++++++++++++--------- .../qmldebugservice/tst_qmldebugservice.cpp | 1 + tests/auto/declarative/shared/debugutil.cpp | 21 +++++++----- tests/auto/declarative/shared/debugutil_p.h | 25 ++++++++------ 6 files changed, 88 insertions(+), 36 deletions(-) diff --git a/src/declarative/debugger/qmldebugservice.cpp b/src/declarative/debugger/qmldebugservice.cpp index 810fbed..2c9586f 100644 --- a/src/declarative/debugger/qmldebugservice.cpp +++ b/src/declarative/debugger/qmldebugservice.cpp @@ -61,9 +61,11 @@ class QmlDebugServer : public QObject public: static QmlDebugServer *instance(); void wait(); + void registerForStartNotification(QObject *object, const char *receiver); private Q_SLOTS: void readyRead(); + void registeredObjectDestroyed(QObject *object); private: friend class QmlDebugService; @@ -83,6 +85,7 @@ public: QPacketProtocol *protocol; QHash plugins; QStringList enabledPlugins; + QList > notifyClients; }; class QmlDebugServicePrivate : public QObjectPrivate @@ -112,6 +115,14 @@ void QmlDebugServerPrivate::wait() qWarning("QmlDebugServer: Waiting for connection on port %d...", port); + for (int i=0; iwait(); } +void QmlDebugServer::registerForStartNotification(QObject *object, const char *methodName) +{ + Q_D(QmlDebugServer); + connect(object, SIGNAL(destroyed(QObject*)), SLOT(registeredObjectDestroyed(QObject*))); + d->notifyClients.append(qMakePair(object, QByteArray(methodName))); +} + +void QmlDebugServer::registeredObjectDestroyed(QObject *object) +{ + Q_D(QmlDebugServer); + QMutableListIterator > i(d->notifyClients); + while (i.hasNext()) { + if (i.next().first == object) + i.remove(); + } +} + QmlDebugServer::QmlDebugServer(int port) : QObject(*(new QmlDebugServerPrivate)) { @@ -367,6 +395,11 @@ void QmlDebugService::waitForClients() QmlDebugServer::instance()->wait(); } +void QmlDebugService::notifyOnServerStart(QObject *object, const char *receiver) +{ + QmlDebugServer::instance()->registerForStartNotification(object, receiver); +} + void QmlDebugService::sendMessage(const QByteArray &message) { Q_D(QmlDebugService); diff --git a/src/declarative/debugger/qmldebugservice_p.h b/src/declarative/debugger/qmldebugservice_p.h index b406a3c..ec90d95 100644 --- a/src/declarative/debugger/qmldebugservice_p.h +++ b/src/declarative/debugger/qmldebugservice_p.h @@ -68,17 +68,19 @@ public: static int idForObject(QObject *); static QObject *objectForId(int); - static bool isDebuggingEnabled(); static QString objectToString(QObject *obj); static void waitForClients(); + static void notifyOnServerStart(QObject *object, const char *receiver); + protected: virtual void enabledChanged(bool); virtual void messageReceived(const QByteArray &); private: + void registerForStartNotification(QObject *object, const char *methodName); friend class QmlDebugServer; }; diff --git a/tests/auto/declarative/qmldebug/tst_qmldebug.cpp b/tests/auto/declarative/qmldebug/tst_qmldebug.cpp index 82e74ce..a51fd29 100644 --- a/tests/auto/declarative/qmldebug/tst_qmldebug.cpp +++ b/tests/auto/declarative/qmldebug/tst_qmldebug.cpp @@ -288,10 +288,11 @@ void tst_QmlDebug::watch_property() QmlDebugPropertyWatch *watch; - QmlEngineDebug unconnected(0); - watch = unconnected.addWatch(prop, this); + QmlEngineDebug *unconnected = new QmlEngineDebug(0); + watch = unconnected->addWatch(prop, this); QCOMPARE(watch->state(), QmlDebugWatch::Dead); delete watch; + delete unconnected; watch = m_dbg->addWatch(QmlDebugPropertyReference(), this); QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State)))); @@ -346,10 +347,11 @@ void tst_QmlDebug::watch_object() QmlDebugWatch *watch; - QmlEngineDebug unconnected(0); - watch = unconnected.addWatch(obj, this); + QmlEngineDebug *unconnected = new QmlEngineDebug(0); + watch = unconnected->addWatch(obj, this); QCOMPARE(watch->state(), QmlDebugWatch::Dead); delete watch; + delete unconnected; watch = m_dbg->addWatch(QmlDebugObjectReference(), this); QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State)))); @@ -409,10 +411,11 @@ void tst_QmlDebug::watch_expression() QmlDebugObjectExpressionWatch *watch; - QmlEngineDebug unconnected(0); - watch = unconnected.addWatch(obj, expr, this); + QmlEngineDebug *unconnected = new QmlEngineDebug(0); + watch = unconnected->addWatch(obj, expr, this); QCOMPARE(watch->state(), QmlDebugWatch::Dead); delete watch; + delete unconnected; watch = m_dbg->addWatch(QmlDebugObjectReference(), expr, this); QVERIFY(QmlDebugTest::waitForSignal(watch, SIGNAL(stateChanged(QmlDebugWatch::State)))); @@ -487,10 +490,11 @@ void tst_QmlDebug::queryAvailableEngines() { QmlDebugEnginesQuery *q_engines; - QmlEngineDebug unconnected(0); - q_engines = unconnected.queryAvailableEngines(0); + QmlEngineDebug *unconnected = new QmlEngineDebug(0); + q_engines = unconnected->queryAvailableEngines(0); QCOMPARE(q_engines->state(), QmlDebugQuery::Error); delete q_engines; + delete unconnected; q_engines = m_dbg->queryAvailableEngines(this); delete q_engines; @@ -519,10 +523,11 @@ void tst_QmlDebug::queryRootContexts() QmlDebugRootContextQuery *q_context; - QmlEngineDebug unconnected(0); - q_context = unconnected.queryRootContexts(engineId, this); + QmlEngineDebug *unconnected = new QmlEngineDebug(0); + q_context = unconnected->queryRootContexts(engineId, this); QCOMPARE(q_context->state(), QmlDebugQuery::Error); delete q_context; + delete unconnected; q_context = m_dbg->queryRootContexts(engineId, this); delete q_context; @@ -563,10 +568,11 @@ void tst_QmlDebug::queryObject() QmlDebugObjectQuery *q_obj = 0; - QmlEngineDebug unconnected(0); - q_obj = recursive ? unconnected.queryObjectRecursive(rootObject, this) : unconnected.queryObject(rootObject, this); + QmlEngineDebug *unconnected = new QmlEngineDebug(0); + q_obj = recursive ? unconnected->queryObjectRecursive(rootObject, this) : unconnected->queryObject(rootObject, this); QCOMPARE(q_obj->state(), QmlDebugQuery::Error); delete q_obj; + delete unconnected; q_obj = recursive ? m_dbg->queryObjectRecursive(rootObject, this) : m_dbg->queryObject(rootObject, this); delete q_obj; @@ -637,10 +643,11 @@ void tst_QmlDebug::queryExpressionResult() QmlDebugExpressionQuery *q_expr; - QmlEngineDebug unconnected(0); - q_expr = unconnected.queryExpressionResult(objectId, expr, this); + QmlEngineDebug *unconnected = new QmlEngineDebug(0); + q_expr = unconnected->queryExpressionResult(objectId, expr, this); QCOMPARE(q_expr->state(), QmlDebugQuery::Error); delete q_expr; + delete unconnected; q_expr = m_dbg->queryExpressionResult(objectId, expr, this); delete q_expr; @@ -801,9 +808,10 @@ class tst_QmlDebug_Factory : public QmlTestFactory public: QObject *createTest(QmlDebugTestData *data) { - QmlContext *c = new QmlContext(data->engine->rootContext()); + tst_QmlDebug *test = new tst_QmlDebug(data); + QmlContext *c = new QmlContext(data->engine->rootContext(), test); c->setObjectName("tst_QmlDebug_childContext"); - return new tst_QmlDebug(data); + return test; } }; diff --git a/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp b/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp index 4e7bc27..9abc5a5 100644 --- a/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp +++ b/tests/auto/declarative/qmldebugservice/tst_qmldebugservice.cpp @@ -167,6 +167,7 @@ void tst_QmlDebugService::objectToString() obj->setObjectName("Hello"); QCOMPARE(QmlDebugService::objectToString(obj), QString("QObject: Hello")); + delete obj; } diff --git a/tests/auto/declarative/shared/debugutil.cpp b/tests/auto/declarative/shared/debugutil.cpp index aa0cd31..0010508 100644 --- a/tests/auto/declarative/shared/debugutil.cpp +++ b/tests/auto/declarative/shared/debugutil.cpp @@ -47,6 +47,8 @@ #include "debugutil_p.h" +#include + bool QmlDebugTest::waitForSignal(QObject *receiver, const char *member, int timeout) { QEventLoop loop; QTimer timer; @@ -117,21 +119,22 @@ void QmlDebugTestClient::messageReceived(const QByteArray &ba) tst_QmlDebug_Thread::tst_QmlDebug_Thread(QmlDebugTestData *data, QmlTestFactory *factory) - : m_ready(false), m_data(data), m_factory(factory) + : m_data(data), m_factory(factory) { } void tst_QmlDebug_Thread::run() { - QTest::qWait(1000); + bool ok = false; QmlDebugConnection conn; conn.connectToHost("127.0.0.1", 3768); - bool ok = conn.waitForConnected(5000); + ok = conn.waitForConnected(); Q_ASSERT(ok); - while (!m_ready) - QTest::qWait(100); + QEventLoop loop; + connect(m_data, SIGNAL(engineCreated()), &loop, SLOT(quit())); + loop.exec(); m_data->conn = &conn; @@ -139,10 +142,10 @@ void tst_QmlDebug_Thread::run() QObject *test = m_factory->createTest(m_data); Q_ASSERT(test); int code = QTest::qExec(test, QCoreApplication::arguments()); + delete test; emit testsFinished(code); } - int QmlDebugTest::runTests(QmlTestFactory *factory, const QList &qml) { qputenv("QML_DEBUG_SERVER_PORT", "3768"); @@ -152,7 +155,8 @@ int QmlDebugTest::runTests(QmlTestFactory *factory, const QList &qml tst_QmlDebug_Thread thread(&data, factory); QObject::connect(&thread, SIGNAL(testsFinished(int)), &data, SLOT(testsFinished(int))); - thread.start(); + + QmlDebugService::notifyOnServerStart(&thread, "start"); QmlEngine engine; // blocks until client connects @@ -165,7 +169,7 @@ int QmlDebugTest::runTests(QmlTestFactory *factory, const QList &qml // start the test data.engine = &engine; - thread.m_ready = true; + emit data.engineCreated(); loop.exec(); thread.wait(); @@ -173,4 +177,3 @@ int QmlDebugTest::runTests(QmlTestFactory *factory, const QList &qml return data.exitCode; } - diff --git a/tests/auto/declarative/shared/debugutil_p.h b/tests/auto/declarative/shared/debugutil_p.h index 313d16c..6f23899 100644 --- a/tests/auto/declarative/shared/debugutil_p.h +++ b/tests/auto/declarative/shared/debugutil_p.h @@ -51,6 +51,15 @@ #include #include +class QmlTestFactory; + +class QmlDebugTest +{ +public: + static bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000); + + static int runTests(QmlTestFactory *factory, const QList &qml = QList()); +}; class QmlDebugTestData : public QObject { @@ -68,8 +77,14 @@ public: QList items; +signals: + void engineCreated(); + public slots: void testsFinished(int code); + +private: + friend class QmlDebugTest; }; @@ -82,14 +97,6 @@ public: virtual QObject *createTest(QmlDebugTestData *data) = 0; }; - -namespace QmlDebugTest { - - bool waitForSignal(QObject *receiver, const char *member, int timeout = 5000); - - int runTests(QmlTestFactory *factory, const QList &qml = QList()); -} - class QmlDebugTestService : public QmlDebugService { Q_OBJECT @@ -132,8 +139,6 @@ public: void run(); - bool m_ready; - signals: void testsFinished(int); -- cgit v0.12 From fa6dc19b9212706532f3f88da0fb3542e9c3eafe Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 15 Feb 2010 09:23:27 +0100 Subject: Enhance samegame high score dialog 'Better' layout mechanics, included animated resize for those people with long names. --- demos/declarative/samegame/content/Dialog.qml | 1 + demos/declarative/samegame/content/samegame.js | 4 ++++ demos/declarative/samegame/samegame.qml | 16 +++++++++++++--- 3 files changed, 18 insertions(+), 3 deletions(-) diff --git a/demos/declarative/samegame/content/Dialog.qml b/demos/declarative/samegame/content/Dialog.qml index f9a281a..5bd1123 100644 --- a/demos/declarative/samegame/content/Dialog.qml +++ b/demos/declarative/samegame/content/Dialog.qml @@ -11,6 +11,7 @@ Rectangle { page.opacity = 1; } signal closed(); + property Item text: myText color: "white"; border.width: 1; width: myText.width + 20; height: myText.height + 40; opacity: 0 opacity: Behavior { diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js index 0a42e88..41ed84c 100755 --- a/demos/declarative/samegame/content/samegame.js +++ b/demos/declarative/samegame/content/samegame.js @@ -158,7 +158,11 @@ function victoryCheck() //Checks for game over if(deservesBonus || !(floodMoveCheck(0,maxY-1, -1))){ timer = new Date() - timer; + //scoreName.show("You won! Please enter your name: "); scoreName.show("You won! Please enter your name: "); + scoreName.initialWidth = scoreName.text.width + 20; + scoreName.width = scoreName.initialWidth; + scoreName.text.opacity = 0;//Just a spacer //dialog.show("Game Over. Your score is " + gameCanvas.score); } } diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml index 626c76b..c2557ae 100644 --- a/demos/declarative/samegame/samegame.qml +++ b/demos/declarative/samegame/samegame.qml @@ -38,20 +38,30 @@ Rectangle { Dialog { id: dialog; anchors.centerIn: parent; z: 21 } Dialog { id: scoreName; anchors.centerIn: parent; z: 22; + property int initialWidth: 0 + width: Behavior{NumberAnimation{} enabled: initialWidth!=0} Text { id: spacer - opacity: 0 - text: " You won! Please enter your name:" + anchors.left: scoreName.left + anchors.leftMargin: 20 + anchors.verticalCenter: parent.verticalCenter + text: "You won! Please enter your name: " } TextInput { id: editor + onTextChanged: { + var newWidth = editor.width + spacer.width + 40; + if((newWidth > scoreName.width && newWidth < screen.width) + || (scoreName.width > scoreName.initialWidth)) + scoreName.width = newWidth; + } onAccepted: { if(scoreName.opacity==1&&editor.text!="") saveHighScore(editor.text); scoreName.forceClose(); } anchors.verticalCenter: parent.verticalCenter - width: 72; focus: true + focus: true anchors.left: spacer.right } } -- cgit v0.12 From 564d73b9a8ec5a5dd6f692b73625cd4c6a2f6b99 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 15 Feb 2010 13:12:19 +0100 Subject: Stabilize positioner tests --- .../tst_qmlgraphicspositioners.cpp | 117 ++++++++++----------- 1 file changed, 55 insertions(+), 62 deletions(-) diff --git a/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp b/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp index da541c8..42d6da9 100644 --- a/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp +++ b/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp @@ -43,6 +43,7 @@ #include #include #include +#include "../../../shared/util.h" class tst_QmlGraphicsPositioners : public QObject { @@ -75,7 +76,6 @@ void tst_QmlGraphicsPositioners::test_horizontal() QmlView *canvas = createView(SRCDIR "/data/horizontal.qml"); canvas->execute(); - qApp->processEvents(); QmlGraphicsRectangle *one = canvas->root()->findChild("one"); QVERIFY(one != 0); @@ -99,7 +99,6 @@ void tst_QmlGraphicsPositioners::test_horizontal_spacing() QmlView *canvas = createView(SRCDIR "/data/horizontal-spacing.qml"); canvas->execute(); - qApp->processEvents(); QmlGraphicsRectangle *one = canvas->root()->findChild("one"); QVERIFY(one != 0); @@ -123,30 +122,31 @@ void tst_QmlGraphicsPositioners::test_horizontal_animated() QmlView *canvas = createView(SRCDIR "/data/horizontal-animated.qml"); canvas->execute(); - qApp->processEvents(); - //Note that they animate in QmlGraphicsRectangle *one = canvas->root()->findChild("one"); QVERIFY(one != 0); - QCOMPARE(one->x(), -100.0); QmlGraphicsRectangle *two = canvas->root()->findChild("two"); QVERIFY(two != 0); - QCOMPARE(two->x(), -100.0); QmlGraphicsRectangle *three = canvas->root()->findChild("three"); QVERIFY(three != 0); + + //Note that they animate in + QCOMPARE(one->x(), -100.0); + QCOMPARE(two->x(), -100.0); QCOMPARE(three->x(), -100.0); - QTest::qWait(300);//Let the animation complete + //QTRY_COMPARE used instead of waiting for the expected time of animation completion + //Note that this means the duration of the animation is NOT tested - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(two->opacity(), 0.0); - QCOMPARE(two->x(), -100.0);//Not 'in' yet - QCOMPARE(two->y(), 0.0); - QCOMPARE(three->x(), 50.0); - QCOMPARE(three->y(), 0.0); + QTRY_COMPARE(one->x(), 0.0); + QTRY_COMPARE(one->y(), 0.0); + QTRY_COMPARE(two->opacity(), 0.0); + QTRY_COMPARE(two->x(), -100.0);//Not 'in' yet + QTRY_COMPARE(two->y(), 0.0); + QTRY_COMPARE(three->x(), 50.0); + QTRY_COMPARE(three->y(), 0.0); //Add 'two' two->setOpacity(1.0); @@ -154,9 +154,9 @@ void tst_QmlGraphicsPositioners::test_horizontal_animated() QTest::qWait(0);//Let the animation start QCOMPARE(two->x(), -100.0); QCOMPARE(three->x(), 50.0); - QTest::qWait(300);//Let the animation complete - QCOMPARE(two->x(), 50.0); - QCOMPARE(three->x(), 100.0); + + QTRY_COMPARE(two->x(), 50.0); + QTRY_COMPARE(three->x(), 100.0); } void tst_QmlGraphicsPositioners::test_vertical() @@ -164,7 +164,6 @@ void tst_QmlGraphicsPositioners::test_vertical() QmlView *canvas = createView(SRCDIR "/data/vertical.qml"); canvas->execute(); - qApp->processEvents(); QmlGraphicsRectangle *one = canvas->root()->findChild("one"); QVERIFY(one != 0); @@ -188,7 +187,6 @@ void tst_QmlGraphicsPositioners::test_vertical_spacing() QmlView *canvas = createView(SRCDIR "/data/vertical-spacing.qml"); canvas->execute(); - qApp->processEvents(); QmlGraphicsRectangle *one = canvas->root()->findChild("one"); QVERIFY(one != 0); @@ -212,9 +210,7 @@ void tst_QmlGraphicsPositioners::test_vertical_animated() QmlView *canvas = createView(SRCDIR "/data/vertical-animated.qml"); canvas->execute(); - qApp->processEvents(); - QTest::qWait(0);//Let the animation start //Note that they animate in QmlGraphicsRectangle *one = canvas->root()->findChild("one"); QVERIFY(one != 0); @@ -228,25 +224,26 @@ void tst_QmlGraphicsPositioners::test_vertical_animated() QVERIFY(three != 0); QCOMPARE(three->y(), -100.0); - QTest::qWait(300);//Let the animation complete + //QTRY_COMPARE used instead of waiting for the expected time of animation completion + //Note that this means the duration of the animation is NOT tested - QCOMPARE(one->y(), 0.0); - QCOMPARE(one->x(), 0.0); - QCOMPARE(two->opacity(), 0.0); - QCOMPARE(two->y(), -100.0);//Not 'in' yet - QCOMPARE(two->x(), 0.0); - QCOMPARE(three->y(), 50.0); - QCOMPARE(three->x(), 0.0); + QTRY_COMPARE(one->y(), 0.0); + QTRY_COMPARE(one->x(), 0.0); + QTRY_COMPARE(two->opacity(), 0.0); + QTRY_COMPARE(two->y(), -100.0);//Not 'in' yet + QTRY_COMPARE(two->x(), 0.0); + QTRY_COMPARE(three->y(), 50.0); + QTRY_COMPARE(three->x(), 0.0); //Add 'two' two->setOpacity(1.0); - QCOMPARE(two->opacity(), 1.0); + QTRY_COMPARE(two->opacity(), 1.0); QTest::qWait(0);//Let the animation start QCOMPARE(two->y(), -100.0); QCOMPARE(three->y(), 50.0); - QTest::qWait(300);//Let the animation complete - QCOMPARE(two->y(), 50.0); - QCOMPARE(three->y(), 100.0); + + QTRY_COMPARE(two->y(), 50.0); + QTRY_COMPARE(three->y(), 100.0); } @@ -255,7 +252,6 @@ void tst_QmlGraphicsPositioners::test_grid() QmlView *canvas = createView("data/grid.qml"); canvas->execute(); - qApp->processEvents(); QmlGraphicsRectangle *one = canvas->root()->findChild("one"); QVERIFY(one != 0); @@ -285,7 +281,6 @@ void tst_QmlGraphicsPositioners::test_grid_spacing() QmlView *canvas = createView("data/grid-spacing.qml"); canvas->execute(); - qApp->processEvents(); QmlGraphicsRectangle *one = canvas->root()->findChild("one"); QVERIFY(one != 0); @@ -314,9 +309,7 @@ void tst_QmlGraphicsPositioners::test_grid_animated() { QmlView *canvas = createView(SRCDIR "/data/grid-animated.qml"); canvas->execute(); - qApp->processEvents(); - QTest::qWait(0);//Let the animation start //Note that all animate in QmlGraphicsRectangle *one = canvas->root()->findChild("one"); QVERIFY(one != 0); @@ -343,19 +336,20 @@ void tst_QmlGraphicsPositioners::test_grid_animated() QCOMPARE(five->x(), -100.0); QCOMPARE(five->y(), -100.0); - QTest::qWait(300);//Let the animation complete - - QCOMPARE(one->y(), 0.0); - QCOMPARE(one->x(), 0.0); - QCOMPARE(two->opacity(), 0.0); - QCOMPARE(two->y(), -100.0); - QCOMPARE(two->x(), -100.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(three->x(), 50.0); - QCOMPARE(four->y(), 0.0); - QCOMPARE(four->x(), 100.0); - QCOMPARE(five->y(), 50.0); - QCOMPARE(five->x(), 0.0); + //QTRY_COMPARE used instead of waiting for the expected time of animation completion + //Note that this means the duration of the animation is NOT tested + + QTRY_COMPARE(one->y(), 0.0); + QTRY_COMPARE(one->x(), 0.0); + QTRY_COMPARE(two->opacity(), 0.0); + QTRY_COMPARE(two->y(), -100.0); + QTRY_COMPARE(two->x(), -100.0); + QTRY_COMPARE(three->y(), 0.0); + QTRY_COMPARE(three->x(), 50.0); + QTRY_COMPARE(four->y(), 0.0); + QTRY_COMPARE(four->x(), 100.0); + QTRY_COMPARE(five->y(), 50.0); + QTRY_COMPARE(five->x(), 0.0); //Add 'two' two->setOpacity(1.0); @@ -371,17 +365,17 @@ void tst_QmlGraphicsPositioners::test_grid_animated() QCOMPARE(four->y(), 0.0); QCOMPARE(five->x(), 0.0); QCOMPARE(five->y(), 50.0); - QTest::qWait(300);//Let the animation complete - QCOMPARE(two->x(), 50.0); - QCOMPARE(two->y(), 0.0); - QCOMPARE(one->x(), 0.0); - QCOMPARE(one->y(), 0.0); - QCOMPARE(three->x(), 100.0); - QCOMPARE(three->y(), 0.0); - QCOMPARE(four->x(), 0.0); - QCOMPARE(four->y(), 50.0); - QCOMPARE(five->x(), 50.0); - QCOMPARE(five->y(), 50.0); + //Let the animation complete + QTRY_COMPARE(two->x(), 50.0); + QTRY_COMPARE(two->y(), 0.0); + QTRY_COMPARE(one->x(), 0.0); + QTRY_COMPARE(one->y(), 0.0); + QTRY_COMPARE(three->x(), 100.0); + QTRY_COMPARE(three->y(), 0.0); + QTRY_COMPARE(four->x(), 0.0); + QTRY_COMPARE(four->y(), 50.0); + QTRY_COMPARE(five->x(), 50.0); + QTRY_COMPARE(five->y(), 50.0); } @@ -390,7 +384,6 @@ void tst_QmlGraphicsPositioners::test_repeater() QmlView *canvas = createView("data/repeater.qml"); canvas->execute(); - qApp->processEvents(); QmlGraphicsRectangle *one = canvas->root()->findChild("one"); QVERIFY(one != 0); -- cgit v0.12 From 8ac9280bad33e7f70bfb4381e20c6aae785ce744 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 15 Feb 2010 16:20:06 +0100 Subject: Exposing some Validators requires Qt >= 4.7.0 This commit should make declarative compile against 4.6.2 again. --- src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp | 6 ++++-- src/declarative/graphicsitems/qmlgraphicstextinput_p.h | 2 ++ 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp b/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp index 127aec8..66d62f0 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsitemsmodule.cpp @@ -127,9 +127,11 @@ void QmlGraphicsItemModule::defineModule() QML_REGISTER_TYPE(Qt,4,6,PathQuad,QmlGraphicsPathQuad); QML_REGISTER_TYPE(Qt,4,6,PathView,QmlGraphicsPathView); QML_REGISTER_TYPE(Qt,4,6,Pen,QmlGraphicsPen); - QML_REGISTER_TYPE(Qt,4,6,QDoubleValidator,QDoubleValidator); QML_REGISTER_TYPE(Qt,4,6,QIntValidator,QIntValidator); - QML_REGISTER_TYPE(Qt,4,6,QRegExpValidator,QRegExpValidator); +#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0)) + QML_REGISTER_TYPE(Qt,4,7,QDoubleValidator,QDoubleValidator); + QML_REGISTER_TYPE(Qt,4,7,QRegExpValidator,QRegExpValidator); +#endif QML_REGISTER_TYPE(Qt,4,6,Rectangle,QmlGraphicsRectangle); QML_REGISTER_TYPE(Qt,4,6,Repeater,QmlGraphicsRepeater); QML_REGISTER_TYPE(Qt,4,6,Rotation,QGraphicsRotation); diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput_p.h b/src/declarative/graphicsitems/qmlgraphicstextinput_p.h index 4708381..a91e71a 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextinput_p.h +++ b/src/declarative/graphicsitems/qmlgraphicstextinput_p.h @@ -222,8 +222,10 @@ QT_END_NAMESPACE QML_DECLARE_TYPE(QmlGraphicsTextInput) QML_DECLARE_TYPE(QValidator) QML_DECLARE_TYPE(QIntValidator) +#if (QT_VERSION >= QT_VERSION_CHECK(4,7,0)) QML_DECLARE_TYPE(QDoubleValidator) QML_DECLARE_TYPE(QRegExpValidator) +#endif QT_END_HEADER -- cgit v0.12 From 4f2c8da75770716ca797d488f5e82e909b2d4e2c Mon Sep 17 00:00:00 2001 From: Aleksandar Sasha Babic Date: Mon, 15 Feb 2010 18:00:18 +0100 Subject: Fixing QDesktopServices so that file server session can be accessed from secondary thread. It is well known fact that CEikonEnv::Static() will return NULL from secondary thread. This means that accessing QDesktopServices from secondary thread will cause crash. Example for this is qmlviewer, where there is separate thread that handles .qml files. Reviewed-by: TrustMe --- src/gui/util/qdesktopservices_s60.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/gui/util/qdesktopservices_s60.cpp b/src/gui/util/qdesktopservices_s60.cpp index 319c4b0..0f5792f 100644 --- a/src/gui/util/qdesktopservices_s60.cpp +++ b/src/gui/util/qdesktopservices_s60.cpp @@ -413,11 +413,11 @@ QString QDesktopServices::storageLocation(StandardLocation type) //return QDir::homePath(); break; break; case DataLocation: - CEikonEnv::Static()->FsSession().PrivatePath(path); + qt_s60GetRFs().PrivatePath(path); path.Insert(0, writableExeDrive().Name()); break; case CacheLocation: - CEikonEnv::Static()->FsSession().PrivatePath(path); + qt_s60GetRFs().PrivatePath(path); path.Insert(0, writableExeDrive().Name()); path.Append(KCacheSubDir); break; -- cgit v0.12 From 6d095d54cb42f4456f09cc3c1473db9a87347f65 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 16 Feb 2010 05:52:52 +1000 Subject: Fix TextInput keypad navigation Was accidentally ignoring key movements even when an existing selection meant that pressing right/left would do something. Task-number: QT-2944 --- src/declarative/graphicsitems/qmlgraphicstextinput.cpp | 6 ++++-- .../declarative/qmlgraphicstextinput/data/navigation.qml | 1 + .../declarative/qmlgraphicstextinput/data/validators.qml | 2 +- .../qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp | 13 ++++++++++++- 4 files changed, 18 insertions(+), 4 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp index ea54351..6d9b7b1 100644 --- a/src/declarative/graphicsitems/qmlgraphicstextinput.cpp +++ b/src/declarative/graphicsitems/qmlgraphicstextinput.cpp @@ -646,10 +646,12 @@ void QmlGraphicsTextInput::focusChanged(bool hasFocus) void QmlGraphicsTextInput::keyPressEvent(QKeyEvent* ev) { Q_D(QmlGraphicsTextInput); - if((d->control->cursor() == 0 && ev->key() == Qt::Key_Left) + if(((d->control->cursor() == 0 && ev->key() == Qt::Key_Left) || (d->control->cursor() == d->control->text().length() - && ev->key() == Qt::Key_Right)){ + && ev->key() == Qt::Key_Right)) + && (d->lastSelectionStart == d->lastSelectionEnd)){ //ignore when moving off the end + //unless there is a selection, because then moving will do something (deselect) ev->ignore(); }else{ d->control->processKeyEvent(ev); diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml b/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml index 7a2e914..493db5b 100644 --- a/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml +++ b/tests/auto/declarative/qmlgraphicstextinput/data/navigation.qml @@ -11,6 +11,7 @@ Rectangle { } TextInput { id: input; focus: true + text: "Needs some text" KeyNavigation.left: firstItem KeyNavigation.right: lastItem KeyNavigation.up: firstItem diff --git a/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml b/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml index 673790d..0c81548 100644 --- a/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml +++ b/tests/auto/declarative/qmlgraphicstextinput/data/validators.qml @@ -1,4 +1,4 @@ -import Qt 4.6 +import Qt 4.7 Item { property var intInput: intInput diff --git a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp index 906dbc2..b7ae4a2 100644 --- a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp +++ b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp @@ -508,6 +508,7 @@ void tst_qmlgraphicstextinput::inputMethodHints() /* TextInput element should only handle left/right keys until the cursor reaches the extent of the text, then they should ignore the keys. + */ void tst_qmlgraphicstextinput::navigation() { @@ -518,14 +519,24 @@ void tst_qmlgraphicstextinput::navigation() QVERIFY(canvas->root() != 0); - QmlGraphicsItem *input = qobject_cast(qvariant_cast(canvas->root()->property("myInput"))); + QmlGraphicsTextInput *input = qobject_cast(qvariant_cast(canvas->root()->property("myInput"))); QVERIFY(input != 0); + input->setCursorPosition(0); QTRY_VERIFY(input->hasFocus() == true); simulateKey(canvas, Qt::Key_Left); QVERIFY(input->hasFocus() == false); simulateKey(canvas, Qt::Key_Right); QVERIFY(input->hasFocus() == true); + //QT-2944: If text is selected, then we should deselect first. + input->setCursorPosition(input->text().length()); + input->setSelectionStart(0); + input->setSelectionEnd(input->text().length()); + QVERIFY(input->selectionStart() != input->selectionEnd()); + simulateKey(canvas, Qt::Key_Right); + QVERIFY(input->selectionStart() == input->selectionEnd()); + QVERIFY(input->selectionStart() == input->text().length()); + QVERIFY(input->hasFocus() == true); simulateKey(canvas, Qt::Key_Right); QVERIFY(input->hasFocus() == false); simulateKey(canvas, Qt::Key_Left); -- cgit v0.12 From 0c0cde558139d12531c4b1e820622bcb81b8eaa5 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Mon, 15 Feb 2010 21:56:49 +0100 Subject: Fix SameGame high scores When it's deployed across multiple devices, there is no 'standard' grid size. This allows non-desktop versions to display high scores. --- demos/declarative/samegame/content/samegame.js | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js index 41ed84c..c0f10bd 100755 --- a/demos/declarative/samegame/content/samegame.js +++ b/demos/declarative/samegame/content/samegame.js @@ -222,8 +222,9 @@ function saveHighScore(name) { tx.executeSql('CREATE TABLE IF NOT EXISTS Scores(name TEXT, score NUMBER, gridSize TEXT, time NUMBER)'); tx.executeSql(dataStr, data); - var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "12x17" ORDER BY score desc LIMIT 10'); - var r = "\nHIGH SCORES for a standard sized grid\n\n" + //Only show results for the current grid size + var rs = tx.executeSql('SELECT * FROM Scores WHERE gridSize = "'+maxX+"x"+maxY+'" ORDER BY score desc LIMIT 10'); + var r = "\nHIGH SCORES for this grid size\n\n" for(var i = 0; i < rs.rows.length; i++){ r += (i+1)+". " + rs.rows.item(i).name +' got ' + rs.rows.item(i).score + ' points in ' -- cgit v0.12 From cffa023dab05c8add3cd7cd71220975086eacbda Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 16 Feb 2010 09:14:02 +1000 Subject: Ensure new WebView windows are notified correctly. Improve test. Change 282a46ab5edafa7b82e9c58658143cb979db2d85 prevents itemChange() notification. That seems wrong, but this change is a work-around. --- src/declarative/graphicsitems/qmlgraphicswebview.cpp | 3 ++- tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml | 1 + tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp | 3 +++ 3 files changed, 6 insertions(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qmlgraphicswebview.cpp b/src/declarative/graphicsitems/qmlgraphicswebview.cpp index c71a366..533df2a 100644 --- a/src/declarative/graphicsitems/qmlgraphicswebview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicswebview.cpp @@ -1083,7 +1083,8 @@ QmlGraphicsWebView *QmlGraphicsWebView::createWindow(QWebPage::WebWindowType typ if (!webview) { delete item; } else { - item->setParent(d->newWindowParent); + nobj->setParent(d->newWindowParent); + static_cast(item)->setParentItem(d->newWindowParent); } } } else { diff --git a/tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml b/tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml index b8524af..0bc8263 100644 --- a/tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml +++ b/tests/auto/declarative/qmlgraphicswebview/data/newwindows.qml @@ -17,6 +17,7 @@ Grid { WebView { id: webView + width: 150 // force predictable for test newWindowComponent: webViewPage newWindowParent: pages url: "newwindows.html" diff --git a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp index 6996a6c..d48f11d 100644 --- a/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp +++ b/tests/auto/declarative/qmlgraphicswebview/tst_qmlgraphicswebview.cpp @@ -304,6 +304,9 @@ void tst_qmlgraphicswebview::multipleWindows() QmlGraphicsGrid *grid = qobject_cast(component.create()); QVERIFY(grid != 0); QTRY_COMPARE(grid->children().count(), 2+5); // Component, Loader, 5 WebViews + QmlGraphicsItem* popup = qobject_cast(grid->children().at(3)); // first popup after Component, Loaded, original. + QVERIFY(popup != 0); + QTRY_COMPARE(popup->x(), 150.0); } void tst_qmlgraphicswebview::loadError() -- cgit v0.12 From 89505af1661fab0c12585416b66322cd09a30bdf Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 16 Feb 2010 10:04:21 +1000 Subject: Ensure types are registered. Perhaps instead, such 'private' property types should be registered by the using class? --- tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp index 17a1453..545f204 100644 --- a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp +++ b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp @@ -53,6 +53,8 @@ public: tst_animations() {} private slots: + void initTestCase() { QmlEngine engine; } // ensure types are registered + void simpleProperty(); void simpleNumber(); void simpleColor(); -- cgit v0.12 From 4460d24950614bd7c60ad7ec14e0418f1b06cc86 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 16 Feb 2010 10:15:27 +1000 Subject: Remove linux-g++-x11egl mkspec. Relies on hard-coded paths, and is no longer used/maintained. --- mkspecs/linux-g++-x11egl/qmake.conf | 30 ------ mkspecs/linux-g++-x11egl/qplatformdefs.h | 164 ------------------------------- 2 files changed, 194 deletions(-) delete mode 100644 mkspecs/linux-g++-x11egl/qmake.conf delete mode 100644 mkspecs/linux-g++-x11egl/qplatformdefs.h diff --git a/mkspecs/linux-g++-x11egl/qmake.conf b/mkspecs/linux-g++-x11egl/qmake.conf deleted file mode 100644 index 593f120..0000000 --- a/mkspecs/linux-g++-x11egl/qmake.conf +++ /dev/null @@ -1,30 +0,0 @@ -# -# qmake configuration for linux-g++ -# - -MAKEFILE_GENERATOR = UNIX -TEMPLATE = app -CONFIG += qt warn_on release incremental link_prl -QT += core gui -QMAKE_INCREMENTAL_STYLE = sublib - -include(../common/g++.conf) -include(../common/linux.conf) -load(qt_config) - -QMAKE_INCDIR_EGL = $(HOME)/opengles2/SDKPackage/Builds/OGLES2/Include -QMAKE_LIBDIR_EGL = $(HOME)/opengles2/SDKPackage/Builds/OGLES2/LinuxPC/Lib -QMAKE_LIBS_EGL = -lGLESv2 -lEGL - -QMAKE_INCDIR_OPENGL = $(HOME)/opengles2/SDKPackage/Builds/OGLES2/Include -QMAKE_INCDIR_OPENGL_QT = $(HOME)/opengles2/SDKPackage/Builds/OGLES2/Include - -QMAKE_LIBDIR_OPENGL = $(HOME)/opengles2/SDKPackage/Builds/OGLES2/LinuxPC/Lib -QMAKE_LIBDIR_OPENGL_QT = $(HOME)/opengles2/SDKPackage/Builds/OGLES2/LinuxPC/Lib - -QMAKE_LIBS_OPENGL = -lGLESv2 -lEGL -QMAKE_LIBS += -Wl,-rpath=$(HOME)/opengles2/SDKPackage/Builds/OGLES2/LinuxPC/Lib - -QMAKE_LIBS_OPENGL_QT = -lGLESv2 -lEGL - -QMAKE_RPATH = -Wl,-rpath, diff --git a/mkspecs/linux-g++-x11egl/qplatformdefs.h b/mkspecs/linux-g++-x11egl/qplatformdefs.h deleted file mode 100644 index 1430916..0000000 --- a/mkspecs/linux-g++-x11egl/qplatformdefs.h +++ /dev/null @@ -1,164 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the qmake spec 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 QPLATFORMDEFS_H -#define QPLATFORMDEFS_H - -// Get Qt defines/settings - -#include "qglobal.h" - -// Set any POSIX/XOPEN defines at the top of this file to turn on specific APIs - -// 1) need to reset default environment if _BSD_SOURCE is defined -// 2) need to specify POSIX thread interfaces explicitly in glibc 2.0 -// 3) it seems older glibc need this to include the X/Open stuff -#ifndef _GNU_SOURCE -# define _GNU_SOURCE -#endif - -#include - - -// We are hot - unistd.h should have turned on the specific APIs we requested - -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#ifndef QT_NO_IPV6IFNAME -#include -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_STATBUF struct stat64 -#define QT_STATBUF4TSTAT struct stat64 -#define QT_STAT ::stat64 -#define QT_FSTAT ::fstat64 -#define QT_LSTAT ::lstat64 -#define QT_OPEN ::open64 -#define QT_TRUNCATE ::truncate64 -#define QT_FTRUNCATE ::ftruncate64 -#define QT_LSEEK ::lseek64 -#else -#define QT_STATBUF struct stat -#define QT_STATBUF4TSTAT struct stat -#define QT_STAT ::stat -#define QT_FSTAT ::fstat -#define QT_LSTAT ::lstat -#define QT_OPEN ::open -#define QT_TRUNCATE ::truncate -#define QT_FTRUNCATE ::ftruncate -#define QT_LSEEK ::lseek -#endif - -#ifdef QT_LARGEFILE_SUPPORT -#define QT_FOPEN ::fopen64 -#define QT_FSEEK ::fseeko64 -#define QT_FTELL ::ftello64 -#define QT_FGETPOS ::fgetpos64 -#define QT_FSETPOS ::fsetpos64 -#define QT_FPOS_T fpos64_t -#define QT_OFF_T off64_t -#else -#define QT_FOPEN ::fopen -#define QT_FSEEK ::fseek -#define QT_FTELL ::ftell -#define QT_FGETPOS ::fgetpos -#define QT_FSETPOS ::fsetpos -#define QT_FPOS_T fpos_t -#define QT_OFF_T long -#endif - -#define QT_STAT_REG S_IFREG -#define QT_STAT_DIR S_IFDIR -#define QT_STAT_MASK S_IFMT -#define QT_STAT_LNK S_IFLNK -#define QT_SOCKET_CONNECT ::connect -#define QT_SOCKET_BIND ::bind -#define QT_FILENO fileno -#define QT_CLOSE ::close -#define QT_READ ::read -#define QT_WRITE ::write -#define QT_ACCESS ::access -#define QT_GETCWD ::getcwd -#define QT_CHDIR ::chdir -#define QT_MKDIR ::mkdir -#define QT_RMDIR ::rmdir -#define QT_OPEN_LARGEFILE O_LARGEFILE -#define QT_OPEN_RDONLY O_RDONLY -#define QT_OPEN_WRONLY O_WRONLY -#define QT_OPEN_RDWR O_RDWR -#define QT_OPEN_CREAT O_CREAT -#define QT_OPEN_TRUNC O_TRUNC -#define QT_OPEN_APPEND O_APPEND - -#define QT_SIGNAL_RETTYPE void -#define QT_SIGNAL_ARGS int -#define QT_SIGNAL_IGNORE SIG_IGN - -#if defined(__GLIBC__) && (__GLIBC__ >= 2) -#define QT_SOCKLEN_T socklen_t -#else -#define QT_SOCKLEN_T int -#endif - -#if defined(_XOPEN_SOURCE) && (_XOPEN_SOURCE >= 500) -#define QT_SNPRINTF ::snprintf -#define QT_VSNPRINTF ::vsnprintf -#endif - - -#endif // QPLATFORMDEFS_H -- cgit v0.12 From c6ba330bc92ad8704f53a79f8f79d87c22b1db1e Mon Sep 17 00:00:00 2001 From: Wolfgang Beck Date: Thu, 11 Feb 2010 09:41:37 +1000 Subject: MOBILITY-404 QS Windows. --- .../accessibility/qt/AccessibilityObjectQt.cpp | 4 +++ src/declarative/debugger/qmldebug.cpp | 8 +++-- .../graphicsitems/qmlgraphicsanchors_p_p.h | 6 ++-- src/declarative/graphicsitems/qmlgraphicsitem.cpp | 4 +-- .../graphicsitems/qmlgraphicsvisualitemmodel.cpp | 4 +-- src/declarative/qml/qmlcleanup.cpp | 4 ++- src/declarative/qml/qmlcompositetypedata_p.h | 2 ++ src/declarative/qml/qmlmetatype.cpp | 3 ++ src/declarative/qml/qmlpropertycache.cpp | 4 +-- src/declarative/qml/qmlscriptstring.h | 4 +-- src/declarative/qml/qmlsqldatabase.cpp | 3 ++ src/declarative/qml/qmlsqldatabase_p.h | 4 +++ src/declarative/qml/qmlstringconverters_p.h | 4 +-- src/declarative/qml/qmlworkerscript.cpp | 10 +++++- src/declarative/qml/qmlxmlhttprequest.cpp | 8 +++-- src/declarative/qml/qmlxmlhttprequest_p.h | 4 +++ src/declarative/util/qmlpixmapcache.cpp | 4 +-- src/declarative/util/qmlstategroup.cpp | 4 +-- src/declarative/util/qmlstyledtext.cpp | 4 +++ src/declarative/util/qmlstyledtext_p.h | 5 +++ src/declarative/util/qmlxmllistmodel.cpp | 4 +-- src/gui/kernel/qapplication.cpp | 6 +++- .../gl2paintengineex/qpaintengineex_opengl2.cpp | 4 ++- src/plugins/imageformats/ico/qicohandler.cpp | 4 +++ src/plugins/imageformats/ico/qicohandler.h | 4 +++ tools/linguist/lconvert/main.cpp | 2 ++ tools/linguist/lupdate/qscript.cpp | 41 +++++++++++----------- tools/qmldebugger/standalone/engine.cpp | 2 +- .../standalone/expressionquerywidget.cpp | 4 +++ tools/qmldebugger/standalone/main.cpp | 2 ++ tools/qmldebugger/standalone/objecttree.cpp | 4 +++ tools/qmldebugger/standalone/qmldebugger.cpp | 4 +++ tools/qmldebugger/standalone/qmldebugger.h | 4 +++ tools/qmlviewer/deviceorientation.cpp | 2 ++ tools/qmlviewer/deviceorientation.h | 4 +++ tools/qmlviewer/main.cpp | 2 ++ tools/qmlviewer/proxysettings.cpp | 4 +++ tools/qmlviewer/proxysettings.h | 3 ++ tools/qmlviewer/qfxtester.h | 20 +++++++++++ tools/qmlviewer/qmlfolderlistmodel.cpp | 2 ++ tools/qmlviewer/qmlfolderlistmodel.h | 4 +++ tools/qmlviewer/qmlviewer.cpp | 6 +++- tools/qtestlib/chart/database.cpp | 3 ++ tools/qtestlib/chart/database.h | 6 ++++ tools/qtestlib/chart/reportgenerator.cpp | 2 ++ tools/qtestlib/chart/reportgenerator.h | 5 +++ 46 files changed, 191 insertions(+), 50 deletions(-) diff --git a/src/3rdparty/webkit/WebCore/accessibility/qt/AccessibilityObjectQt.cpp b/src/3rdparty/webkit/WebCore/accessibility/qt/AccessibilityObjectQt.cpp index 07f13d4..756ece3 100644 --- a/src/3rdparty/webkit/WebCore/accessibility/qt/AccessibilityObjectQt.cpp +++ b/src/3rdparty/webkit/WebCore/accessibility/qt/AccessibilityObjectQt.cpp @@ -20,6 +20,8 @@ #include "config.h" #include "AccessibilityObject.h" +QT_BEGIN_NAMESPACE + #if HAVE(ACCESSIBILITY) namespace WebCore { @@ -37,3 +39,5 @@ AccessibilityObjectPlatformInclusion AccessibilityObject::accessibilityPlatformI } // namespace WebCore #endif // HAVE(ACCESSIBILITY) + +QT_END_NAMESPACE diff --git a/src/declarative/debugger/qmldebug.cpp b/src/declarative/debugger/qmldebug.cpp index dc779ac..41e27bc 100644 --- a/src/declarative/debugger/qmldebug.cpp +++ b/src/declarative/debugger/qmldebug.cpp @@ -47,6 +47,8 @@ #include +QT_BEGIN_NAMESPACE + class QmlEngineDebugClient : public QmlDebugClient { public: @@ -142,8 +144,6 @@ void QmlEngineDebugPrivate::remove(QmlEngineDebug *c, QmlDebugExpressionQuery *q } } - -Q_DECLARE_METATYPE(QmlDebugObjectReference); void QmlEngineDebugPrivate::decode(QDataStream &ds, QmlDebugObjectReference &o, bool simple) { @@ -932,3 +932,7 @@ bool QmlDebugPropertyReference::hasNotifySignal() const { return m_hasNotifySignal; } + +QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QmlDebugObjectReference); diff --git a/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h b/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h index 5b02158..22eabdd 100644 --- a/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsanchors_p_p.h @@ -87,9 +87,6 @@ public: return item == other.item && anchorLine == other.anchorLine; } }; -Q_DECLARE_METATYPE(QmlGraphicsAnchorLine) - - class QmlGraphicsAnchorsPrivate : public QObjectPrivate, public QmlGraphicsItemChangeListener { @@ -171,4 +168,7 @@ public: }; QT_END_NAMESPACE + +Q_DECLARE_METATYPE(QmlGraphicsAnchorLine) + #endif diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp index 9fd8702..070c70f 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp @@ -2884,6 +2884,6 @@ int QmlGraphicsItemPrivate::restart(QTime &t) return n; } -#include - QT_END_NAMESPACE + +#include diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp index b4487a6..cc416d0 100644 --- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp @@ -62,8 +62,6 @@ #include -QML_DECLARE_TYPE(QListModelInterface) - QT_BEGIN_NAMESPACE QHash QmlGraphicsVisualItemModelAttached::attachedProperties; @@ -1110,4 +1108,6 @@ void QmlGraphicsVisualDataModel::_q_destroyingPackage(QmlPackage *package) QT_END_NAMESPACE +QML_DECLARE_TYPE(QListModelInterface) + #include diff --git a/src/declarative/qml/qmlcleanup.cpp b/src/declarative/qml/qmlcleanup.cpp index 599e4e7..e7767d2 100644 --- a/src/declarative/qml/qmlcleanup.cpp +++ b/src/declarative/qml/qmlcleanup.cpp @@ -43,6 +43,8 @@ #include "qmlengine_p.h" +QT_BEGIN_NAMESPACE + /*! \internal \class QmlCleanup @@ -82,4 +84,4 @@ QmlCleanup::~QmlCleanup() prev = 0; next = 0; } - +QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlcompositetypedata_p.h b/src/declarative/qml/qmlcompositetypedata_p.h index c8b9f25..5358963 100644 --- a/src/declarative/qml/qmlcompositetypedata_p.h +++ b/src/declarative/qml/qmlcompositetypedata_p.h @@ -146,5 +146,7 @@ public: QByteArray data; }; +QT_END_NAMESPACE + #endif // QMLCOMPOSITETYPEDATA_P_H diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index e66f600..7dfc48d 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -840,6 +840,8 @@ QList QmlMetaType::qmlTypes() return data->nameToType.values(); } +QT_END_NAMESPACE + #include #include #include @@ -867,6 +869,7 @@ QList QmlMetaType::qmlTypes() Q_DECLARE_METATYPE(QScriptValue); +QT_BEGIN_NAMESPACE /*! Copies \a copy into \a data, assuming they both are of type \a type. If \a copy is zero, a default type is copied. Returns true if the copy was diff --git a/src/declarative/qml/qmlpropertycache.cpp b/src/declarative/qml/qmlpropertycache.cpp index 04cffe1..a0a7cea 100644 --- a/src/declarative/qml/qmlpropertycache.cpp +++ b/src/declarative/qml/qmlpropertycache.cpp @@ -45,10 +45,10 @@ #include "qmlbinding.h" #include "qdebug.h" -QT_BEGIN_NAMESPACE - Q_DECLARE_METATYPE(QScriptValue); +QT_BEGIN_NAMESPACE + void QmlPropertyCache::Data::load(const QMetaProperty &p, QmlEngine *engine) { propType = p.userType(); diff --git a/src/declarative/qml/qmlscriptstring.h b/src/declarative/qml/qmlscriptstring.h index 73a473f..d07137e 100644 --- a/src/declarative/qml/qmlscriptstring.h +++ b/src/declarative/qml/qmlscriptstring.h @@ -77,10 +77,10 @@ private: QSharedDataPointer d; }; -Q_DECLARE_METATYPE(QmlScriptString); - QT_END_NAMESPACE +Q_DECLARE_METATYPE(QmlScriptString); + QT_END_HEADER #endif // QMLSCRIPTSTRING_H diff --git a/src/declarative/qml/qmlsqldatabase.cpp b/src/declarative/qml/qmlsqldatabase.cpp index 684caa2..9c951fc 100644 --- a/src/declarative/qml/qmlsqldatabase.cpp +++ b/src/declarative/qml/qmlsqldatabase.cpp @@ -65,6 +65,8 @@ Q_DECLARE_METATYPE(QSqlDatabase) Q_DECLARE_METATYPE(QSqlQuery) +QT_BEGIN_NAMESPACE + class QmlSqlQueryScriptClass: public QScriptClass { public: QmlSqlQueryScriptClass(QScriptEngine *engine) : QScriptClass(engine) @@ -423,3 +425,4 @@ We add a "forwardOnly" property that stops Qt caching results (code promises to through the data. */ +QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlsqldatabase_p.h b/src/declarative/qml/qmlsqldatabase_p.h index 5a38bf0..9965a2b 100644 --- a/src/declarative/qml/qmlsqldatabase_p.h +++ b/src/declarative/qml/qmlsqldatabase_p.h @@ -42,6 +42,7 @@ #ifndef QMLSQLDATABASE_P_H #define QMLSQLDATABASE_P_H +#include // // W A R N I N G // ------------- @@ -52,9 +53,12 @@ // // We mean it. // +QT_BEGIN_NAMESPACE class QScriptEngine; void qt_add_qmlsqldatabase(QScriptEngine *engine); +QT_END_NAMESPACE + #endif // QMLSQLDATABASE_P_H diff --git a/src/declarative/qml/qmlstringconverters_p.h b/src/declarative/qml/qmlstringconverters_p.h index dfc59ce..46b2de6 100644 --- a/src/declarative/qml/qmlstringconverters_p.h +++ b/src/declarative/qml/qmlstringconverters_p.h @@ -56,6 +56,8 @@ #include #include +QT_BEGIN_NAMESPACE + class QColor; class QPointF; class QSizeF; @@ -64,8 +66,6 @@ class QString; class QByteArray; class QVector3D; -QT_BEGIN_NAMESPACE - // XXX - Bauhaus currently uses these methods which is why they're exported namespace QmlStringConverters { diff --git a/src/declarative/qml/qmlworkerscript.cpp b/src/declarative/qml/qmlworkerscript.cpp index 5e39eaf..ec790ca 100644 --- a/src/declarative/qml/qmlworkerscript.cpp +++ b/src/declarative/qml/qmlworkerscript.cpp @@ -55,6 +55,7 @@ #include #include "qmlnetworkaccessmanagerfactory.h" + QT_BEGIN_NAMESPACE class WorkerDataEvent : public QEvent @@ -238,8 +239,13 @@ private: QAtomicInt m_ref; QmlWorkerListModel *m_model; }; + +QT_END_NAMESPACE + Q_DECLARE_METATYPE(QmlWorkerListModelAgent::VariantRef); +QT_BEGIN_NAMESPACE + QmlWorkerScriptEnginePrivate::QmlWorkerScriptEnginePrivate(QmlEngine *engine) : workerEngine(0), qmlengine(engine), m_nextId(0) { @@ -1030,8 +1036,10 @@ QVariant QmlWorkerListModel::data(int index, int role) const return m_values.at(index).value(role); } +QT_END_NAMESPACE + QML_DEFINE_TYPE(Qt,4,6,WorkerListModel,QmlWorkerListModel) #include "qmlworkerscript.moc" -QT_END_NAMESPACE + diff --git a/src/declarative/qml/qmlxmlhttprequest.cpp b/src/declarative/qml/qmlxmlhttprequest.cpp index 1883d1b..54e26df 100644 --- a/src/declarative/qml/qmlxmlhttprequest.cpp +++ b/src/declarative/qml/qmlxmlhttprequest.cpp @@ -91,7 +91,7 @@ #define D(arg) (arg)->release() #define A(arg) (arg)->addref() -namespace { +QT_BEGIN_NAMESPACE class DocumentImpl; class NodeImpl @@ -315,12 +315,14 @@ public: static QScriptValue load(QScriptEngine *engine, const QString &data); }; -}; // namespace +QT_END_NAMESPACE Q_DECLARE_METATYPE(Node); Q_DECLARE_METATYPE(NodeList); Q_DECLARE_METATYPE(NamedNodeMap); +QT_BEGIN_NAMESPACE + void NodeImpl::addref() { A(document); @@ -1624,4 +1626,6 @@ void qt_add_qmlxmlhttprequest(QScriptEngine *engine) engine->globalObject().setProperty(QLatin1String("DOMException"), domExceptionPrototype); } +QT_END_NAMESPACE + #include diff --git a/src/declarative/qml/qmlxmlhttprequest_p.h b/src/declarative/qml/qmlxmlhttprequest_p.h index dfed5d2..3a81278 100644 --- a/src/declarative/qml/qmlxmlhttprequest_p.h +++ b/src/declarative/qml/qmlxmlhttprequest_p.h @@ -42,6 +42,7 @@ #ifndef QMLXMLHTTPREQUEST_P_H #define QMLXMLHTTPREQUEST_P_H +#include // // W A R N I N G // ------------- @@ -52,9 +53,12 @@ // // We mean it. // +QT_BEGIN_NAMESPACE class QScriptEngine; void qt_add_qmlxmlhttprequest(QScriptEngine *engine); +QT_END_NAMESPACE + #endif // QMLXMLHTTPREQUEST_P_H diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp index c03b5df..acd1b89 100644 --- a/src/declarative/util/qmlpixmapcache.cpp +++ b/src/declarative/util/qmlpixmapcache.cpp @@ -600,6 +600,6 @@ int QmlPixmapCache::pendingRequests() return qmlActivePixmapReplies()->count(); } -#include - QT_END_NAMESPACE + +#include diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qmlstategroup.cpp index d4db2b9..aad19d9 100644 --- a/src/declarative/util/qmlstategroup.cpp +++ b/src/declarative/util/qmlstategroup.cpp @@ -55,8 +55,6 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); -QML_DEFINE_TYPE(Qt,4,6,StateGroup,QmlStateGroup) - class QmlStateGroupPrivate : public QObjectPrivate { Q_DECLARE_PUBLIC(QmlStateGroup) @@ -421,3 +419,5 @@ void QmlStateGroup::removeState(QmlState *state) } QT_END_NAMESPACE + +QML_DEFINE_TYPE(Qt,4,6,StateGroup,QmlStateGroup) diff --git a/src/declarative/util/qmlstyledtext.cpp b/src/declarative/util/qmlstyledtext.cpp index 36b5e49..63f341e 100644 --- a/src/declarative/util/qmlstyledtext.cpp +++ b/src/declarative/util/qmlstyledtext.cpp @@ -58,6 +58,8 @@ The opening and closing tags must be correctly nested. */ +QT_BEGIN_NAMESPACE + class QmlStyledTextPrivate { public: @@ -341,3 +343,5 @@ QStringRef QmlStyledTextPrivate::parseValue(const QChar *&ch, const QString &tex return QStringRef(&textIn, valStart, valLength); } + +QT_END_NAMESPACE diff --git a/src/declarative/util/qmlstyledtext_p.h b/src/declarative/util/qmlstyledtext_p.h index 0cfb43e..502a4b5 100644 --- a/src/declarative/util/qmlstyledtext_p.h +++ b/src/declarative/util/qmlstyledtext_p.h @@ -44,10 +44,13 @@ #include +QT_BEGIN_NAMESPACE + class QPainter; class QPointF; class QString; class QmlStyledTextPrivate; + class Q_DECLARATIVE_EXPORT QmlStyledText { public: @@ -60,4 +63,6 @@ private: QmlStyledTextPrivate *d; }; +QT_END_NAMESPACE + #endif diff --git a/src/declarative/util/qmlxmllistmodel.cpp b/src/declarative/util/qmlxmllistmodel.cpp index d31fadf..b2c2e61 100644 --- a/src/declarative/util/qmlxmllistmodel.cpp +++ b/src/declarative/util/qmlxmllistmodel.cpp @@ -126,8 +126,6 @@ private: QString m_query; }; -QML_DECLARE_TYPE(QmlXmlListModelRole) - class QmlXmlListModelPrivate; struct QmlXmlRoleList : public QmlConcreteList { @@ -725,4 +723,6 @@ void QmlXmlListModel::queryCompleted(int id, int size) QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlXmlListModelRole) + #include diff --git a/src/gui/kernel/qapplication.cpp b/src/gui/kernel/qapplication.cpp index 336be91..4ec2ae2 100644 --- a/src/gui/kernel/qapplication.cpp +++ b/src/gui/kernel/qapplication.cpp @@ -122,15 +122,19 @@ extern bool qt_wince_is_pocket_pc(); //qguifunctions_wince.cpp static void initResources() { #if defined(Q_WS_WINCE) + Q_INIT_RESOURCE_EXTERN(qstyle_wince) Q_INIT_RESOURCE(qstyle_wince); #elif defined(Q_OS_SYMBIAN) + Q_INIT_RESOURCE_EXTERN(qstyle_s60) Q_INIT_RESOURCE(qstyle_s60); #else + Q_INIT_RESOURCE_EXTERN(qstyle) Q_INIT_RESOURCE(qstyle); #endif - + Q_INIT_RESOURCE_EXTERN(qmessagebox) Q_INIT_RESOURCE(qmessagebox); #if !defined(QT_NO_PRINTDIALOG) + Q_INIT_RESOURCE_EXTERN(qprintdialog) Q_INIT_RESOURCE(qprintdialog); #endif diff --git a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp index d2fb925..e39d385 100644 --- a/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp +++ b/src/opengl/gl2paintengineex/qpaintengineex_opengl2.cpp @@ -90,6 +90,9 @@ QT_BEGIN_NAMESPACE //#define QT_GL_NO_SCISSOR_TEST +#ifdef Q_WS_WIN +extern Q_GUI_EXPORT bool qt_cleartype_enabled; +#endif extern QImage qt_imageForBrush(int brushStyle, bool invert); @@ -1673,7 +1676,6 @@ bool QGL2PaintEngineEx::begin(QPaintDevice *pdev) #if !defined(QT_OPENGL_ES_2) #if defined(Q_WS_WIN) - extern Q_GUI_EXPORT bool qt_cleartype_enabled; if (qt_cleartype_enabled) #endif d->glyphCacheType = QFontEngineGlyphCache::Raster_RGBMask; diff --git a/src/plugins/imageformats/ico/qicohandler.cpp b/src/plugins/imageformats/ico/qicohandler.cpp index 4edb87a..032ff85 100644 --- a/src/plugins/imageformats/ico/qicohandler.cpp +++ b/src/plugins/imageformats/ico/qicohandler.cpp @@ -54,6 +54,9 @@ #include #include #include + +QT_BEGIN_NAMESPACE + // These next two structs represent how the icon information is stored // in an ICO file. typedef struct @@ -891,3 +894,4 @@ bool QtIcoHandler::jumpToNextImage() return jumpToImage(m_currentIconIndex + 1); } +QT_END_NAMESPACE diff --git a/src/plugins/imageformats/ico/qicohandler.h b/src/plugins/imageformats/ico/qicohandler.h index 394a5eb..4334ad9 100644 --- a/src/plugins/imageformats/ico/qicohandler.h +++ b/src/plugins/imageformats/ico/qicohandler.h @@ -43,6 +43,8 @@ #include +QT_BEGIN_NAMESPACE + class ICOReader; class QtIcoHandler: public QImageIOHandler { @@ -71,5 +73,7 @@ private: }; +QT_END_NAMESPACE + #endif /* QTICOHANDLER_H */ diff --git a/tools/linguist/lconvert/main.cpp b/tools/linguist/lconvert/main.cpp index 3a30027..543c405 100644 --- a/tools/linguist/lconvert/main.cpp +++ b/tools/linguist/lconvert/main.cpp @@ -48,6 +48,8 @@ #include +QT_USE_NAMESPACE + static int usage(const QStringList &args) { Q_UNUSED(args); diff --git a/tools/linguist/lupdate/qscript.cpp b/tools/linguist/lupdate/qscript.cpp index 6f34c2b..33276e6 100644 --- a/tools/linguist/lupdate/qscript.cpp +++ b/tools/linguist/lupdate/qscript.cpp @@ -40,6 +40,26 @@ ** ****************************************************************************/ + +#define Q_SCRIPT_REGEXPLITERAL_RULE1 7 + +#define Q_SCRIPT_REGEXPLITERAL_RULE2 8 + +#include + +#include +#include +#include +#include +#include + +#include +#include +#include +#include + +QT_BEGIN_NAMESPACE + class QScriptGrammar { public: @@ -174,7 +194,6 @@ public: } }; - const char *const QScriptGrammar::spell [] = { "end of file", "&", "&&", "&=", "break", "case", "catch", ":", ";", "continue", "default", "delete", "/", "/=", "do", ".", "else", "=", "==", "===", @@ -747,26 +766,6 @@ const int QScriptGrammar::action_check [] = { -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1, -1}; - -#define Q_SCRIPT_REGEXPLITERAL_RULE1 7 - -#define Q_SCRIPT_REGEXPLITERAL_RULE2 8 - -#include - -#include -#include -#include -#include -#include - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - static void recordMessage( Translator *tor, const QString &context, const QString &text, const QString &comment, const QString &extracomment, bool plural, const QString &fileName, int lineNo) diff --git a/tools/qmldebugger/standalone/engine.cpp b/tools/qmldebugger/standalone/engine.cpp index 6cfd82b..acd90f1 100644 --- a/tools/qmldebugger/standalone/engine.cpp +++ b/tools/qmldebugger/standalone/engine.cpp @@ -212,8 +212,8 @@ void EnginePane::enginesChanged() engineSelected(qobject_cast(m_engineItems.at(0))->engineId()); } +QT_END_NAMESPACE #include "engine.moc" -QT_END_NAMESPACE diff --git a/tools/qmldebugger/standalone/expressionquerywidget.cpp b/tools/qmldebugger/standalone/expressionquerywidget.cpp index cd59871..4fea41f 100644 --- a/tools/qmldebugger/standalone/expressionquerywidget.cpp +++ b/tools/qmldebugger/standalone/expressionquerywidget.cpp @@ -51,6 +51,8 @@ #include "expressionquerywidget.h" +QT_BEGIN_NAMESPACE + ExpressionQueryWidget::ExpressionQueryWidget(Mode mode, QmlEngineDebug *client, QWidget *parent) : QWidget(parent), m_mode(mode), @@ -274,3 +276,5 @@ bool ExpressionQueryWidget::eventFilter(QObject *obj, QEvent *event) } return QWidget::eventFilter(obj, event); } + +QT_END_NAMESPACE diff --git a/tools/qmldebugger/standalone/main.cpp b/tools/qmldebugger/standalone/main.cpp index 715837e..c2117f2 100644 --- a/tools/qmldebugger/standalone/main.cpp +++ b/tools/qmldebugger/standalone/main.cpp @@ -42,6 +42,8 @@ #include "qmldebugger.h" +QT_USE_NAMESPACE + int main(int argc, char ** argv) { QApplication app(argc, argv); diff --git a/tools/qmldebugger/standalone/objecttree.cpp b/tools/qmldebugger/standalone/objecttree.cpp index cf467f2..b5bac53 100644 --- a/tools/qmldebugger/standalone/objecttree.cpp +++ b/tools/qmldebugger/standalone/objecttree.cpp @@ -52,6 +52,8 @@ Q_DECLARE_METATYPE(QmlDebugObjectReference) +QT_BEGIN_NAMESPACE + ObjectTree::ObjectTree(QmlEngineDebug *client, QWidget *parent) : QTreeWidget(parent), m_client(client), @@ -229,3 +231,5 @@ void ObjectTree::mousePressEvent(QMouseEvent *me) } } } + +QT_END_NAMESPACE diff --git a/tools/qmldebugger/standalone/qmldebugger.cpp b/tools/qmldebugger/standalone/qmldebugger.cpp index 4d86377..1c1057a 100644 --- a/tools/qmldebugger/standalone/qmldebugger.cpp +++ b/tools/qmldebugger/standalone/qmldebugger.cpp @@ -53,6 +53,8 @@ #include "engine.h" #include "qmldebugger.h" +QT_BEGIN_NAMESPACE + QmlDebugger::QmlDebugger(QWidget *parent) : QWidget(parent) { @@ -179,3 +181,5 @@ void QmlDebugger::disconnectFromHost() { client.disconnectFromHost(); } + +QT_END_NAMESPACE diff --git a/tools/qmldebugger/standalone/qmldebugger.h b/tools/qmldebugger/standalone/qmldebugger.h index da95ef9..3df47d1 100644 --- a/tools/qmldebugger/standalone/qmldebugger.h +++ b/tools/qmldebugger/standalone/qmldebugger.h @@ -45,6 +45,8 @@ #include #include +QT_BEGIN_NAMESPACE + class QLabel; class QLineEdit; class QSpinBox; @@ -87,4 +89,6 @@ private: QTabWidget *m_tabs; }; +QT_END_NAMESPACE + #endif diff --git a/tools/qmlviewer/deviceorientation.cpp b/tools/qmlviewer/deviceorientation.cpp index c507479..0fb4a5a 100644 --- a/tools/qmlviewer/deviceorientation.cpp +++ b/tools/qmlviewer/deviceorientation.cpp @@ -41,6 +41,8 @@ #include "deviceorientation.h" +QT_USE_NAMESPACE + class DefaultDeviceOrientation : public DeviceOrientation { Q_OBJECT diff --git a/tools/qmlviewer/deviceorientation.h b/tools/qmlviewer/deviceorientation.h index fa7758f..efd45b3 100644 --- a/tools/qmlviewer/deviceorientation.h +++ b/tools/qmlviewer/deviceorientation.h @@ -44,6 +44,8 @@ #include +QT_BEGIN_NAMESPACE + class DeviceOrientationPrivate; class DeviceOrientation : public QObject { @@ -66,4 +68,6 @@ private: friend class DeviceOrientationPrivate; }; +QT_END_NAMESPACE + #endif diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp index b7a3f1a..14a4735 100644 --- a/tools/qmlviewer/main.cpp +++ b/tools/qmlviewer/main.cpp @@ -47,6 +47,8 @@ #include #include +QT_USE_NAMESPACE + #if defined (Q_OS_SYMBIAN) #include #include diff --git a/tools/qmlviewer/proxysettings.cpp b/tools/qmlviewer/proxysettings.cpp index 52fa74f..c3ec32e 100644 --- a/tools/qmlviewer/proxysettings.cpp +++ b/tools/qmlviewer/proxysettings.cpp @@ -45,6 +45,8 @@ #include "proxysettings.h" +QT_BEGIN_NAMESPACE + ProxySettings::ProxySettings (QWidget * parent) : QDialog (parent), Ui::ProxySettings() { @@ -104,3 +106,5 @@ bool ProxySettings::httpProxyInUse() QSettings settings; return settings.value ("http_proxy/use", 0).toBool (); } + +QT_END_NAMESPACE diff --git a/tools/qmlviewer/proxysettings.h b/tools/qmlviewer/proxysettings.h index b2f3e25..2392127 100644 --- a/tools/qmlviewer/proxysettings.h +++ b/tools/qmlviewer/proxysettings.h @@ -46,6 +46,7 @@ #include #include "ui_proxysettings.h" +QT_BEGIN_NAMESPACE /** */ class ProxySettings : public QDialog, public Ui::ProxySettings @@ -65,4 +66,6 @@ public slots: virtual void accept (); }; +QT_END_NAMESPACE + #endif // PROXYSETTINGS_H diff --git a/tools/qmlviewer/qfxtester.h b/tools/qmlviewer/qfxtester.h index 303ac3a..0a10763 100644 --- a/tools/qmlviewer/qfxtester.h +++ b/tools/qmlviewer/qfxtester.h @@ -65,8 +65,13 @@ public: private: QList m_events; }; + +QT_END_NAMESPACE + QML_DECLARE_TYPE(QmlGraphicsVisualTest) +QT_BEGIN_NAMESPACE + class QmlGraphicsVisualTestFrame : public QObject { Q_OBJECT @@ -90,8 +95,13 @@ private: QString m_hash; QUrl m_image; }; + +QT_END_NAMESPACE + QML_DECLARE_TYPE(QmlGraphicsVisualTestFrame) +QT_BEGIN_NAMESPACE + class QmlGraphicsVisualTestMouse : public QObject { Q_OBJECT @@ -134,8 +144,13 @@ private: int m_modifiers; bool m_viewport; }; + +QT_END_NAMESPACE + QML_DECLARE_TYPE(QmlGraphicsVisualTestMouse) +QT_BEGIN_NAMESPACE + class QmlGraphicsVisualTestKey : public QObject { Q_OBJECT @@ -178,8 +193,13 @@ private: int m_count; bool m_viewport; }; + +QT_END_NAMESPACE + QML_DECLARE_TYPE(QmlGraphicsVisualTestKey) +QT_BEGIN_NAMESPACE + class QmlGraphicsTester : public QAbstractAnimation { public: diff --git a/tools/qmlviewer/qmlfolderlistmodel.cpp b/tools/qmlviewer/qmlfolderlistmodel.cpp index 35c672d..cf63fec 100644 --- a/tools/qmlviewer/qmlfolderlistmodel.cpp +++ b/tools/qmlviewer/qmlfolderlistmodel.cpp @@ -44,6 +44,8 @@ #include #include +QT_BEGIN_NAMESPACE + class QmlFolderListModelPrivate { public: diff --git a/tools/qmlviewer/qmlfolderlistmodel.h b/tools/qmlviewer/qmlfolderlistmodel.h index 7357954..188ac27 100644 --- a/tools/qmlviewer/qmlfolderlistmodel.h +++ b/tools/qmlviewer/qmlfolderlistmodel.h @@ -45,6 +45,8 @@ #include #include "../../src/declarative/3rdparty/qlistmodelinterface_p.h" +QT_BEGIN_NAMESPACE + class QmlContext; class QModelIndex; @@ -114,6 +116,8 @@ private: QmlFolderListModelPrivate *d; }; +QT_END_NAMESPACE + QML_DECLARE_TYPE(QmlFolderListModel) #endif // QMLFOLDERLISTMODEL_H diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index 8b3b7aa..7c620ef 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -108,7 +108,6 @@ QT_BEGIN_NAMESPACE - class Screen : public QObject { Q_OBJECT @@ -131,7 +130,12 @@ signals: void orientationChanged(); }; +QT_END_NAMESPACE + QML_DECLARE_TYPE(Screen) + +QT_BEGIN_NAMESPACE + QML_DEFINE_TYPE(QmlViewer, 1, 0, Screen, Screen) class SizedMenuBar : public QMenuBar diff --git a/tools/qtestlib/chart/database.cpp b/tools/qtestlib/chart/database.cpp index dfc0fc5..1f1f7da 100644 --- a/tools/qtestlib/chart/database.cpp +++ b/tools/qtestlib/chart/database.cpp @@ -42,6 +42,7 @@ #include #include +QT_BEGIN_NAMESPACE // Database schema definition and open/create functions QString resultsTable = QString("(TestName varchar, TestCaseName varchar, Series varchar, Idx varchar, ") + @@ -319,3 +320,5 @@ void DataBaseWriter::addResult(const QString &series, const QString &index, cons query.bindValue(":ChartType", "BarChart"); execQuery(query); } + +QT_END_NAMESPACE diff --git a/tools/qtestlib/chart/database.h b/tools/qtestlib/chart/database.h index d9861ad..9a67490 100644 --- a/tools/qtestlib/chart/database.h +++ b/tools/qtestlib/chart/database.h @@ -43,6 +43,9 @@ #include #include +#include + +QT_BEGIN_NAMESPACE extern QString resultsTable; QSqlDatabase openDataBase(const QString &databaseFile = "database"); @@ -57,6 +60,7 @@ void execQuery(const QString &spec, bool warnOnFail = true); void printDataBase(); void displayTable(const QString &table); + class TempTable { public: @@ -95,5 +99,7 @@ public: QSqlDatabase db; }; +QT_END_NAMESPACE #endif + diff --git a/tools/qtestlib/chart/reportgenerator.cpp b/tools/qtestlib/chart/reportgenerator.cpp index 1ce362c..c3b42a0 100644 --- a/tools/qtestlib/chart/reportgenerator.cpp +++ b/tools/qtestlib/chart/reportgenerator.cpp @@ -41,6 +41,7 @@ #include "reportgenerator.h" // Report generator file utility functions +QT_BEGIN_NAMESPACE QList readLines(const QString &fileName) { @@ -559,3 +560,4 @@ QByteArray ReportGenerator::printColors(const QString &tableName, const QString return colors; } +QT_END_NAMESPACE diff --git a/tools/qtestlib/chart/reportgenerator.h b/tools/qtestlib/chart/reportgenerator.h index d44aea9..1f075bd 100644 --- a/tools/qtestlib/chart/reportgenerator.h +++ b/tools/qtestlib/chart/reportgenerator.h @@ -42,6 +42,9 @@ #define REPORTGENERATOR_H #include "database.h" +#include + +QT_BEGIN_NAMESPACE class ReportGenerator { @@ -59,5 +62,7 @@ private: void printTestCaseResults(const QString &testCaseName); +QT_END_NAMESPACE + #endif -- cgit v0.12 From bc7dca6516a71118c73fcd84dc80cd5a8ba9eaa8 Mon Sep 17 00:00:00 2001 From: Wolfgang Beck Date: Thu, 11 Feb 2010 12:24:48 +1000 Subject: MOBILITY -404 / 507 --- src/corelib/global/qglobal.h | 3 +++ src/corelib/global/qmalloc.cpp | 1 + 2 files changed, 4 insertions(+) diff --git a/src/corelib/global/qglobal.h b/src/corelib/global/qglobal.h index 99bbe42..7e7d7d8 100644 --- a/src/corelib/global/qglobal.h +++ b/src/corelib/global/qglobal.h @@ -864,6 +864,9 @@ typedef quint64 qulonglong; # endif #endif +#define Q_INIT_RESOURCE_EXTERN(name) \ + extern int QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); + #define Q_INIT_RESOURCE(name) \ do { extern int QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); \ QT_MANGLE_NAMESPACE(qInitResources_ ## name) (); } while (0) diff --git a/src/corelib/global/qmalloc.cpp b/src/corelib/global/qmalloc.cpp index 43e89e3..090998c 100644 --- a/src/corelib/global/qmalloc.cpp +++ b/src/corelib/global/qmalloc.cpp @@ -124,3 +124,4 @@ void qFreeAligned(void *ptr) } QT_END_NAMESPACE + -- cgit v0.12 From 3b7bcb72857c8c73435b801536c0d5330d3df469 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 16 Feb 2010 11:18:14 +1000 Subject: Remove left over debugging --- .../declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml | 1 - 1 file changed, 1 deletion(-) diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml index e9535d5..bf31eca 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml +++ b/tests/auto/declarative/qmlxmlhttprequest/data/setRequestHeader_illegalName.qml @@ -46,7 +46,6 @@ QtObject { x.onreadystatechange = function() { if (x.readyState == XMLHttpRequest.DONE) { dataOK = (x.responseText == "QML Rocks!\n"); - print("DATA:" + x.responseText); } } -- cgit v0.12 From aca8ddb97886b3eaf4c3618ce6774f2b56997604 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 16 Feb 2010 11:20:48 +1000 Subject: Fix test case --- tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml index 02a8083..8d67fad 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml +++ b/tests/auto/declarative/qmlxmlhttprequest/data/getAllResponseHeaders.qml @@ -42,7 +42,7 @@ QtObject { openedException = true; } - var headers = "content-type: text/html; charset=UTF-8\r\ntest-header: TestValue\r\nmultitest-header: TestValue, SecondTestValue\r\ncontent-length: 11"; + var headers = "connection: close\r\ncontent-type: text/html; charset=UTF-8\r\ntest-header: TestValue\r\nmultitest-header: TestValue, SecondTestValue\r\ncontent-length: 11"; // Test to the end x.onreadystatechange = function() { -- cgit v0.12 From 154915b3a7d37cd4046110e77ae9223bef2523bb Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Wed, 17 Feb 2010 19:01:45 +0000 Subject: Renamed declarative autotests class names to match the targets The default target name for the autotests is the dir name and the class name didnt change when we renamed the dir names. --- .../qmlanimations/tst_qmlanimations.cpp | 38 ++++----- .../declarative/qmlbehaviors/tst_qmlbehaviors.cpp | 30 +++---- .../tst_qmldatetimeformatter.cpp | 12 +-- .../qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp | 34 ++++---- .../tst_qmlgraphicsanimatedimage.cpp | 22 +++--- .../qmlnumberformatter/tst_qmlnumberformatter.cpp | 14 ++-- tests/auto/declarative/qmlstates/tst_qmlstates.cpp | 54 ++++++------- .../qmlvaluetypes/tst_qmlvaluetypes.cpp | 46 +++++------ .../qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp | 92 +++++++++++----------- 9 files changed, 171 insertions(+), 171 deletions(-) diff --git a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp index 545f204..b2653df 100644 --- a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp +++ b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp @@ -46,11 +46,11 @@ #include #include -class tst_animations : public QObject +class tst_qmlanimations : public QObject { Q_OBJECT public: - tst_animations() {} + tst_qmlanimations() {} private slots: void initTestCase() { QmlEngine engine; } // ensure types are registered @@ -82,7 +82,7 @@ private slots: QCOMPARE(lhs, rhs); \ } while (false) -void tst_animations::simpleProperty() +void tst_qmlanimations::simpleProperty() { QmlGraphicsRectangle rect; QmlPropertyAnimation animation; @@ -107,7 +107,7 @@ void tst_animations::simpleProperty() QCOMPARE(rect.pos(), QPointF(100,100)); } -void tst_animations::simpleNumber() +void tst_qmlanimations::simpleNumber() { QmlGraphicsRectangle rect; QmlNumberAnimation animation; @@ -132,7 +132,7 @@ void tst_animations::simpleNumber() QCOMPARE(rect.x(), qreal(100)); } -void tst_animations::simpleColor() +void tst_qmlanimations::simpleColor() { QmlGraphicsRectangle rect; QmlColorAnimation animation; @@ -166,7 +166,7 @@ void tst_animations::simpleColor() QCOMPARE(rect.color(), QColor::fromRgbF(0.498039, 0, 0.498039, 1)); } -void tst_animations::alwaysRunToEnd() +void tst_qmlanimations::alwaysRunToEnd() { QmlGraphicsRectangle rect; QmlPropertyAnimation animation; @@ -186,7 +186,7 @@ void tst_animations::alwaysRunToEnd() QTIMED_COMPARE(rect.x(), qreal(200)); } -void tst_animations::complete() +void tst_qmlanimations::complete() { QmlGraphicsRectangle rect; QmlPropertyAnimation animation; @@ -207,7 +207,7 @@ void tst_animations::complete() QCOMPARE(rect.x(), qreal(200)); } -void tst_animations::resume() +void tst_qmlanimations::resume() { QmlGraphicsRectangle rect; QmlPropertyAnimation animation; @@ -234,7 +234,7 @@ void tst_animations::resume() QVERIFY(rect.x() > x); } -void tst_animations::dotProperty() +void tst_qmlanimations::dotProperty() { QmlGraphicsRectangle rect; QmlNumberAnimation animation; @@ -253,7 +253,7 @@ void tst_animations::dotProperty() QCOMPARE(rect.border()->width(), 5); } -void tst_animations::badTypes() +void tst_qmlanimations::badTypes() { //don't crash { @@ -303,7 +303,7 @@ void tst_animations::badTypes() } } -void tst_animations::badProperties() +void tst_qmlanimations::badProperties() { //make sure we get a runtime error { @@ -330,7 +330,7 @@ void tst_animations::badProperties() //test animating mixed types with property animation in a transition //for example, int + real; color + real; etc -void tst_animations::mixedTypes() +void tst_qmlanimations::mixedTypes() { //assumes border.width stats a real -- not real robust { @@ -366,7 +366,7 @@ void tst_animations::mixedTypes() } } -void tst_animations::properties() +void tst_qmlanimations::properties() { const int waitDuration = 300; { @@ -433,7 +433,7 @@ void tst_animations::properties() } } -void tst_animations::propertiesTransition() +void tst_qmlanimations::propertiesTransition() { const int waitDuration = 300; { @@ -504,7 +504,7 @@ void tst_animations::propertiesTransition() } } -void tst_animations::easingStringConversion() +void tst_qmlanimations::easingStringConversion() { QmlNumberAnimation *animation = new QmlNumberAnimation; animation->setEasing("easeInOutQuad"); @@ -555,7 +555,7 @@ void tst_animations::easingStringConversion() delete animation; } -void tst_animations::invalidDuration() +void tst_qmlanimations::invalidDuration() { QmlPropertyAnimation *animation = new QmlPropertyAnimation; QTest::ignoreMessage(QtWarningMsg, "QML PropertyAnimation (unknown location) Cannot set a duration of < 0"); @@ -568,7 +568,7 @@ void tst_animations::invalidDuration() QCOMPARE(pauseAnimation->duration(), 250); } -void tst_animations::attached() +void tst_qmlanimations::attached() { QmlEngine engine; @@ -579,7 +579,7 @@ void tst_animations::attached() QVERIFY(rect); } -void tst_animations::propertyValueSourceDefaultStart() +void tst_qmlanimations::propertyValueSourceDefaultStart() { { QmlEngine engine; @@ -608,6 +608,6 @@ void tst_animations::propertyValueSourceDefaultStart() } } -QTEST_MAIN(tst_animations) +QTEST_MAIN(tst_qmlanimations) #include "tst_qmlanimations.moc" diff --git a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp index 61023a2..5663237 100644 --- a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp +++ b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp @@ -46,11 +46,11 @@ #include #include -class tst_behaviors : public QObject +class tst_qmlbehaviors : public QObject { Q_OBJECT public: - tst_behaviors() {} + tst_qmlbehaviors() {} private slots: void simpleBehavior(); @@ -68,7 +68,7 @@ private slots: void disabled(); }; -void tst_behaviors::simpleBehavior() +void tst_qmlbehaviors::simpleBehavior() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/simple.qml")); @@ -82,7 +82,7 @@ void tst_behaviors::simpleBehavior() QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered } -void tst_behaviors::scriptTriggered() +void tst_qmlbehaviors::scriptTriggered() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/scripttrigger.qml")); @@ -95,7 +95,7 @@ void tst_behaviors::scriptTriggered() QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered } -void tst_behaviors::cppTriggered() +void tst_qmlbehaviors::cppTriggered() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/cpptrigger.qml")); @@ -111,7 +111,7 @@ void tst_behaviors::cppTriggered() QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered } -void tst_behaviors::loop() +void tst_qmlbehaviors::loop() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/loop.qml")); @@ -122,7 +122,7 @@ void tst_behaviors::loop() rect->setState("moved"); } -void tst_behaviors::colorBehavior() +void tst_qmlbehaviors::colorBehavior() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/color.qml")); @@ -135,7 +135,7 @@ void tst_behaviors::colorBehavior() QVERIFY(color != QColor("red") && color != QColor("green")); //i.e. the behavior has been triggered } -void tst_behaviors::parentBehavior() +void tst_qmlbehaviors::parentBehavior() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/parent.qml")); @@ -152,7 +152,7 @@ void tst_behaviors::parentBehavior() QVERIFY(parent == newParent); } -void tst_behaviors::replaceBinding() +void tst_qmlbehaviors::replaceBinding() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/binding.qml")); @@ -186,7 +186,7 @@ void tst_behaviors::replaceBinding() QCOMPARE(innerRect->x(), (qreal)20); } -void tst_behaviors::group() +void tst_qmlbehaviors::group() { { QmlEngine engine; @@ -213,7 +213,7 @@ void tst_behaviors::group() } } -void tst_behaviors::emptyBehavior() +void tst_qmlbehaviors::emptyBehavior() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/empty.qml")); @@ -225,7 +225,7 @@ void tst_behaviors::emptyBehavior() QCOMPARE(x, qreal(200)); //should change immediately } -void tst_behaviors::nonSelectingBehavior() +void tst_qmlbehaviors::nonSelectingBehavior() { { QmlEngine engine; @@ -250,7 +250,7 @@ void tst_behaviors::nonSelectingBehavior() } } -void tst_behaviors::reassignedAnimation() +void tst_qmlbehaviors::reassignedAnimation() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/reassignedAnimation.qml")); @@ -262,7 +262,7 @@ void tst_behaviors::reassignedAnimation() rect->findChild("MyBehavior"))->animation())->duration(), 200); } -void tst_behaviors::disabled() +void tst_qmlbehaviors::disabled() { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/disabled.qml")); @@ -276,6 +276,6 @@ void tst_behaviors::disabled() } -QTEST_MAIN(tst_behaviors) +QTEST_MAIN(tst_qmlbehaviors) #include "tst_qmlbehaviors.moc" diff --git a/tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp b/tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp index 2ce6186..b21a4f0 100644 --- a/tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp +++ b/tests/auto/declarative/qmldatetimeformatter/tst_qmldatetimeformatter.cpp @@ -44,11 +44,11 @@ #include #include -class tst_datetimeformatter : public QObject +class tst_qmldatetimeformatter : public QObject { Q_OBJECT public: - tst_datetimeformatter() {} + tst_qmldatetimeformatter() {} private slots: void date(); @@ -56,7 +56,7 @@ private slots: void dateTime(); }; -void tst_datetimeformatter::date() +void tst_qmldatetimeformatter::date() { QmlEngine engine; QmlComponent formatterComponent(&engine); @@ -86,7 +86,7 @@ void tst_datetimeformatter::date() delete formatter; } -void tst_datetimeformatter::time() +void tst_qmldatetimeformatter::time() { QmlEngine engine; QmlComponent formatterComponent(&engine); @@ -119,7 +119,7 @@ void tst_datetimeformatter::time() delete formatter; } -void tst_datetimeformatter::dateTime() +void tst_qmldatetimeformatter::dateTime() { QmlEngine engine; QmlComponent formatterComponent(&engine); @@ -145,6 +145,6 @@ void tst_datetimeformatter::dateTime() delete formatter; } -QTEST_MAIN(tst_datetimeformatter) +QTEST_MAIN(tst_qmldatetimeformatter) #include "tst_qmldatetimeformatter.moc" diff --git a/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp b/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp index 5850cf0..1187038 100644 --- a/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp +++ b/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp @@ -51,11 +51,11 @@ Q_DECLARE_METATYPE(QmlGraphicsAnchors::UsedAnchor) Q_DECLARE_METATYPE(QmlGraphicsAnchorLine::AnchorLine) -class tst_anchors : public QObject +class tst_qmlgraphicsanchors : public QObject { Q_OBJECT public: - tst_anchors() {} + tst_qmlgraphicsanchors() {} template T *findItem(QmlGraphicsItem *parent, const QString &id); @@ -80,7 +80,7 @@ private slots: Find an item with the specified id. */ template -T *tst_anchors::findItem(QmlGraphicsItem *parent, const QString &objectName) +T *tst_qmlgraphicsanchors::findItem(QmlGraphicsItem *parent, const QString &objectName) { const QMetaObject &mo = T::staticMetaObject; QList children = parent->childItems(); @@ -99,7 +99,7 @@ T *tst_anchors::findItem(QmlGraphicsItem *parent, const QString &objectName) return 0; } -void tst_anchors::basicAnchors() +void tst_qmlgraphicsanchors::basicAnchors() { QmlView *view = new QmlView; view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml")); @@ -168,7 +168,7 @@ void tst_anchors::basicAnchors() } // mostly testing that we don't crash -void tst_anchors::loops() +void tst_qmlgraphicsanchors::loops() { { QmlView *view = new QmlView; @@ -199,7 +199,7 @@ void tst_anchors::loops() } } -void tst_anchors::illegalSets() +void tst_qmlgraphicsanchors::illegalSets() { QFETCH(QString, qml); QFETCH(QString, warning); @@ -216,7 +216,7 @@ void tst_anchors::illegalSets() delete o; } -void tst_anchors::illegalSets_data() +void tst_qmlgraphicsanchors::illegalSets_data() { QTest::addColumn("qml"); QTest::addColumn("warning"); @@ -274,7 +274,7 @@ void tst_anchors::illegalSets_data() << "QML Rectangle (file::2:45) Can't anchor to an item that isn't a parent or sibling."; } -void tst_anchors::reset() +void tst_qmlgraphicsanchors::reset() { QFETCH(QString, side); QFETCH(QmlGraphicsAnchorLine::AnchorLine, anchorLine); @@ -301,7 +301,7 @@ void tst_anchors::reset() delete baseItem; } -void tst_anchors::reset_data() +void tst_qmlgraphicsanchors::reset_data() { QTest::addColumn("side"); QTest::addColumn("anchorLine"); @@ -317,7 +317,7 @@ void tst_anchors::reset_data() QTest::newRow("baseline") << "baseline" << QmlGraphicsAnchorLine::Baseline << QmlGraphicsAnchors::HasBaselineAnchor; } -void tst_anchors::resetConvenience() +void tst_qmlgraphicsanchors::resetConvenience() { QmlGraphicsItem *baseItem = new QmlGraphicsItem; QmlGraphicsItem *item = new QmlGraphicsItem; @@ -338,7 +338,7 @@ void tst_anchors::resetConvenience() delete baseItem; } -void tst_anchors::nullItem() +void tst_qmlgraphicsanchors::nullItem() { QFETCH(QString, side); @@ -354,7 +354,7 @@ void tst_anchors::nullItem() delete item; } -void tst_anchors::nullItem_data() +void tst_qmlgraphicsanchors::nullItem_data() { QTest::addColumn("side"); @@ -368,7 +368,7 @@ void tst_anchors::nullItem_data() QTest::newRow("baseline") << "baseline"; } -void tst_anchors::crash1() +void tst_qmlgraphicsanchors::crash1() { QmlView *view = new QmlView; @@ -383,7 +383,7 @@ void tst_anchors::crash1() delete view; } -void tst_anchors::fill() +void tst_qmlgraphicsanchors::fill() { QmlView *view = new QmlView; @@ -409,7 +409,7 @@ void tst_anchors::fill() delete view; } -void tst_anchors::centerIn() +void tst_qmlgraphicsanchors::centerIn() { QmlView *view = new QmlView; @@ -429,7 +429,7 @@ void tst_anchors::centerIn() delete view; } -void tst_anchors::margins() +void tst_qmlgraphicsanchors::margins() { QmlView *view = new QmlView; @@ -454,6 +454,6 @@ void tst_anchors::margins() delete view; } -QTEST_MAIN(tst_anchors) +QTEST_MAIN(tst_qmlgraphicsanchors) #include "tst_qmlgraphicsanchors.moc" diff --git a/tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp b/tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp index bc10e30..1703c01 100644 --- a/tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp +++ b/tests/auto/declarative/qmlgraphicsanimatedimage/tst_qmlgraphicsanimatedimage.cpp @@ -58,11 +58,11 @@ } while (false) -class tst_animatedimage : public QObject +class tst_qmlgraphicsanimatedimage : public QObject { Q_OBJECT public: - tst_animatedimage() {} + tst_qmlgraphicsanimatedimage() {} private slots: void play(); @@ -75,7 +75,7 @@ private slots: void invalidSource(); }; -void tst_animatedimage::play() +void tst_qmlgraphicsanimatedimage::play() { QmlEngine engine; QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickman.qml")); @@ -86,7 +86,7 @@ void tst_animatedimage::play() delete anim; } -void tst_animatedimage::pause() +void tst_qmlgraphicsanimatedimage::pause() { QmlEngine engine; QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml")); @@ -98,7 +98,7 @@ void tst_animatedimage::pause() delete anim; } -void tst_animatedimage::stopped() +void tst_qmlgraphicsanimatedimage::stopped() { QmlEngine engine; QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanstopped.qml")); @@ -110,7 +110,7 @@ void tst_animatedimage::stopped() delete anim; } -void tst_animatedimage::setFrame() +void tst_qmlgraphicsanimatedimage::setFrame() { QmlEngine engine; QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/stickmanpause.qml")); @@ -122,7 +122,7 @@ void tst_animatedimage::setFrame() delete anim; } -void tst_animatedimage::frameCount() +void tst_qmlgraphicsanimatedimage::frameCount() { QmlEngine engine; QmlComponent component(&engine, QUrl::fromLocalFile(SRCDIR "/data/colors.qml")); @@ -134,7 +134,7 @@ void tst_animatedimage::frameCount() delete anim; } -void tst_animatedimage::remote() +void tst_qmlgraphicsanimatedimage::remote() { QFETCH(QString, fileName); QFETCH(bool, paused); @@ -159,7 +159,7 @@ void tst_animatedimage::remote() delete anim; } -void tst_animatedimage::remote_data() +void tst_qmlgraphicsanimatedimage::remote_data() { QTest::addColumn("fileName"); QTest::addColumn("paused"); @@ -168,7 +168,7 @@ void tst_animatedimage::remote_data() QTest::newRow("paused") << "stickmanpause.qml" << true; } -void tst_animatedimage::invalidSource() +void tst_qmlgraphicsanimatedimage::invalidSource() { QmlEngine engine; QmlComponent component(&engine); @@ -186,6 +186,6 @@ void tst_animatedimage::invalidSource() QCOMPARE(anim->frameCount(), 0); } -QTEST_MAIN(tst_animatedimage) +QTEST_MAIN(tst_qmlgraphicsanimatedimage) #include "tst_qmlgraphicsanimatedimage.moc" diff --git a/tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp b/tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp index bf71625..f8ac76c 100644 --- a/tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp +++ b/tests/auto/declarative/qmlnumberformatter/tst_qmlnumberformatter.cpp @@ -45,12 +45,12 @@ #include #include -class tst_numberformat : public QObject +class tst_qmlnumberformatter : public QObject { Q_OBJECT public: - tst_numberformat(); - + tst_qmlnumberformatter(); + void init() {} void initTestCase() {} @@ -67,7 +67,7 @@ private: QStringList texts; }; -tst_numberformat::tst_numberformat() +tst_qmlnumberformatter::tst_qmlnumberformatter() { strings << "100.0" << "12345" @@ -177,7 +177,7 @@ tst_numberformat::tst_numberformat() << "texts.size()" << texts.size(); } -void tst_numberformat::text_data() +void tst_qmlnumberformatter::text_data() { QTest::addColumn("string"); QTest::addColumn("format"); @@ -194,7 +194,7 @@ void tst_numberformat::text_data() } -void tst_numberformat::text() +void tst_qmlnumberformatter::text() { QFETCH(QString, string); QFETCH(QString, format); @@ -217,6 +217,6 @@ void tst_numberformat::text() delete formatter; } -QTEST_MAIN(tst_numberformat) +QTEST_MAIN(tst_qmlnumberformatter) #include "tst_qmlnumberformatter.moc" diff --git a/tests/auto/declarative/qmlstates/tst_qmlstates.cpp b/tests/auto/declarative/qmlstates/tst_qmlstates.cpp index fc348a5..2274889 100644 --- a/tests/auto/declarative/qmlstates/tst_qmlstates.cpp +++ b/tests/auto/declarative/qmlstates/tst_qmlstates.cpp @@ -46,11 +46,11 @@ #include #include -class tst_states : public QObject +class tst_qmlstates : public QObject { Q_OBJECT public: - tst_states() {} + tst_qmlstates() {} private: static QByteArray fullDataPath(const QString &path); @@ -81,12 +81,12 @@ private slots: void nonExistantProperty(); }; -QByteArray tst_states::fullDataPath(const QString &path) +QByteArray tst_qmlstates::fullDataPath(const QString &path) { return QUrl::fromLocalFile(SRCDIR + path).toString().toUtf8(); } -void tst_states::basicChanges() +void tst_qmlstates::basicChanges() { QmlEngine engine; @@ -156,7 +156,7 @@ void tst_states::basicChanges() } } -void tst_states::basicExtension() +void tst_qmlstates::basicExtension() { QmlEngine engine; @@ -220,7 +220,7 @@ void tst_states::basicExtension() } } -void tst_states::basicBinding() +void tst_qmlstates::basicBinding() { QmlEngine engine; @@ -346,7 +346,7 @@ Q_SIGNALS: QML_DECLARE_TYPE(MyRect) QML_DEFINE_TYPE(Qt.test, 1, 0, MyRectangle,MyRect); -void tst_states::signalOverride() +void tst_qmlstates::signalOverride() { QmlEngine engine; @@ -383,7 +383,7 @@ void tst_states::signalOverride() } } -void tst_states::signalOverrideCrash() +void tst_qmlstates::signalOverrideCrash() { QmlEngine engine; @@ -395,7 +395,7 @@ void tst_states::signalOverrideCrash() rect->doSomething(); } -void tst_states::parentChange() +void tst_qmlstates::parentChange() { QmlEngine engine; @@ -462,7 +462,7 @@ void tst_states::parentChange() } } -void tst_states::parentChangeErrors() +void tst_qmlstates::parentChangeErrors() { QmlEngine engine; @@ -499,7 +499,7 @@ void tst_states::parentChangeErrors() } } -void tst_states::anchorChanges() +void tst_qmlstates::anchorChanges() { QmlEngine engine; @@ -527,7 +527,7 @@ void tst_states::anchorChanges() delete rect; } -void tst_states::anchorChanges2() +void tst_qmlstates::anchorChanges2() { QmlEngine engine; @@ -548,7 +548,7 @@ void tst_states::anchorChanges2() delete rect; } -void tst_states::anchorChanges3() +void tst_qmlstates::anchorChanges3() { QmlEngine engine; @@ -594,7 +594,7 @@ void tst_states::anchorChanges3() delete rect; } -void tst_states::anchorChanges4() +void tst_qmlstates::anchorChanges4() { QmlEngine engine; @@ -625,7 +625,7 @@ void tst_states::anchorChanges4() delete rect; } -void tst_states::anchorChanges5() +void tst_qmlstates::anchorChanges5() { QmlEngine engine; @@ -656,7 +656,7 @@ void tst_states::anchorChanges5() delete rect; } -void tst_states::script() +void tst_qmlstates::script() { QmlEngine engine; @@ -675,7 +675,7 @@ void tst_states::script() } } -void tst_states::restoreEntryValues() +void tst_qmlstates::restoreEntryValues() { QmlEngine engine; @@ -692,7 +692,7 @@ void tst_states::restoreEntryValues() QCOMPARE(rect->color(),QColor("blue")); } -void tst_states::explicitChanges() +void tst_qmlstates::explicitChanges() { QmlEngine engine; @@ -722,7 +722,7 @@ void tst_states::explicitChanges() QCOMPARE(rect->color(),QColor("yellow")); } -void tst_states::propertyErrors() +void tst_qmlstates::propertyErrors() { QmlEngine engine; QmlComponent rectComponent(&engine, SRCDIR "/data/propertyErrors.qml"); @@ -736,7 +736,7 @@ void tst_states::propertyErrors() rect->setState("blue"); } -void tst_states::incorrectRestoreBug() +void tst_qmlstates::incorrectRestoreBug() { QmlEngine engine; @@ -762,7 +762,7 @@ void tst_states::incorrectRestoreBug() QCOMPARE(rect->color(),QColor("green")); } -void tst_states::autoStateAtStartupRestoreBug() +void tst_qmlstates::autoStateAtStartupRestoreBug() { QmlEngine engine; @@ -779,7 +779,7 @@ void tst_states::autoStateAtStartupRestoreBug() delete obj; } -void tst_states::deletingChange() +void tst_qmlstates::deletingChange() { QmlEngine engine; @@ -811,7 +811,7 @@ void tst_states::deletingChange() delete rect; } -void tst_states::deletingState() +void tst_qmlstates::deletingState() { QmlEngine engine; @@ -842,7 +842,7 @@ void tst_states::deletingState() delete rect; } -void tst_states::tempState() +void tst_qmlstates::tempState() { QmlEngine engine; @@ -856,7 +856,7 @@ void tst_states::tempState() QCOMPARE(rect->state(), QLatin1String("idle")); } -void tst_states::illegalTempState() +void tst_qmlstates::illegalTempState() { QmlEngine engine; @@ -869,7 +869,7 @@ void tst_states::illegalTempState() QCOMPARE(rect->state(), QLatin1String("placed")); } -void tst_states::nonExistantProperty() +void tst_qmlstates::nonExistantProperty() { QmlEngine engine; @@ -882,6 +882,6 @@ void tst_states::nonExistantProperty() QCOMPARE(rect->state(), QLatin1String("blue")); } -QTEST_MAIN(tst_states) +QTEST_MAIN(tst_qmlstates) #include "tst_qmlstates.moc" diff --git a/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp b/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp index 49655db..61ac93d 100644 --- a/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp +++ b/tests/auto/declarative/qmlvaluetypes/tst_qmlvaluetypes.cpp @@ -46,11 +46,11 @@ #include #include "testtypes.h" -class tst_valuetypes : public QObject +class tst_qmlvaluetypes : public QObject { Q_OBJECT public: - tst_valuetypes() {} + tst_qmlvaluetypes() {} private slots: void point(); @@ -84,7 +84,7 @@ inline QUrl TEST_FILE(const QString &filename) return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); } -void tst_valuetypes::point() +void tst_qmlvaluetypes::point() { { QmlComponent component(&engine, TEST_FILE("point_read.qml")); @@ -109,7 +109,7 @@ void tst_valuetypes::point() } } -void tst_valuetypes::pointf() +void tst_qmlvaluetypes::pointf() { { QmlComponent component(&engine, TEST_FILE("pointf_read.qml")); @@ -134,7 +134,7 @@ void tst_valuetypes::pointf() } } -void tst_valuetypes::size() +void tst_qmlvaluetypes::size() { { QmlComponent component(&engine, TEST_FILE("size_read.qml")); @@ -159,7 +159,7 @@ void tst_valuetypes::size() } } -void tst_valuetypes::sizef() +void tst_qmlvaluetypes::sizef() { { QmlComponent component(&engine, TEST_FILE("sizef_read.qml")); @@ -184,7 +184,7 @@ void tst_valuetypes::sizef() } } -void tst_valuetypes::rect() +void tst_qmlvaluetypes::rect() { { QmlComponent component(&engine, TEST_FILE("rect_read.qml")); @@ -211,7 +211,7 @@ void tst_valuetypes::rect() } } -void tst_valuetypes::rectf() +void tst_qmlvaluetypes::rectf() { { QmlComponent component(&engine, TEST_FILE("rectf_read.qml")); @@ -238,7 +238,7 @@ void tst_valuetypes::rectf() } } -void tst_valuetypes::vector3d() +void tst_qmlvaluetypes::vector3d() { { QmlComponent component(&engine, TEST_FILE("vector3d_read.qml")); @@ -264,7 +264,7 @@ void tst_valuetypes::vector3d() } } -void tst_valuetypes::font() +void tst_qmlvaluetypes::font() { { QmlComponent component(&engine, TEST_FILE("font_read.qml")); @@ -337,7 +337,7 @@ void tst_valuetypes::font() } // Test bindings can write to value types -void tst_valuetypes::bindingAssignment() +void tst_qmlvaluetypes::bindingAssignment() { QmlComponent component(&engine, TEST_FILE("bindingAssignment.qml")); MyTypeObject *object = qobject_cast(component.create()); @@ -353,7 +353,7 @@ void tst_valuetypes::bindingAssignment() } // Test bindings can read from value types -void tst_valuetypes::bindingRead() +void tst_qmlvaluetypes::bindingRead() { QmlComponent component(&engine, TEST_FILE("bindingRead.qml")); MyTypeObject *object = qobject_cast(component.create()); @@ -369,7 +369,7 @@ void tst_valuetypes::bindingRead() } // Test static values can assign to value types -void tst_valuetypes::staticAssignment() +void tst_qmlvaluetypes::staticAssignment() { QmlComponent component(&engine, TEST_FILE("staticAssignment.qml")); MyTypeObject *object = qobject_cast(component.create()); @@ -381,7 +381,7 @@ void tst_valuetypes::staticAssignment() } // Test scripts can read/write value types -void tst_valuetypes::scriptAccess() +void tst_qmlvaluetypes::scriptAccess() { QmlComponent component(&engine, TEST_FILE("scriptAccess.qml")); MyTypeObject *object = qobject_cast(component.create()); @@ -395,7 +395,7 @@ void tst_valuetypes::scriptAccess() } // Test that assigning a constant from script removes any binding -void tst_valuetypes::autoBindingRemoval() +void tst_qmlvaluetypes::autoBindingRemoval() { { QmlComponent component(&engine, TEST_FILE("autoBindingRemoval.qml")); @@ -466,7 +466,7 @@ void tst_valuetypes::autoBindingRemoval() } // Test that property value sources assign to value types -void tst_valuetypes::valueSources() +void tst_qmlvaluetypes::valueSources() { QmlComponent component(&engine, TEST_FILE("valueSources.qml")); MyTypeObject *object = qobject_cast(component.create()); @@ -489,7 +489,7 @@ static void checkNoErrors(QmlComponent& component) } // Test that property value interceptors can be applied to value types -void tst_valuetypes::valueInterceptors() +void tst_qmlvaluetypes::valueInterceptors() { QmlComponent component(&engine, TEST_FILE("valueInterceptors.qml")); MyTypeObject *object = qobject_cast(component.create()); @@ -507,7 +507,7 @@ void tst_valuetypes::valueInterceptors() } // Test that you can't assign a binding to the "root" value type, and a sub-property -void tst_valuetypes::bindingConflict() +void tst_qmlvaluetypes::bindingConflict() { QmlComponent component(&engine, TEST_FILE("bindingConflict.qml")); QCOMPARE(component.isError(), true); @@ -524,7 +524,7 @@ void tst_valuetypes::bindingConflict() // Test that accessing a reference to a valuetype after the owning object is deleted // doesn't crash -void tst_valuetypes::deletedObject() +void tst_qmlvaluetypes::deletedObject() { QmlComponent component(&engine, TEST_FILE("deletedObject.qml")); QTest::ignoreMessage(QtDebugMsg, "Test: 2"); @@ -542,7 +542,7 @@ void tst_valuetypes::deletedObject() } // Test that value types can be assigned to another value type property in a binding -void tst_valuetypes::bindingVariantCopy() +void tst_qmlvaluetypes::bindingVariantCopy() { QmlComponent component(&engine, TEST_FILE("bindingVariantCopy.qml")); MyTypeObject *object = qobject_cast(component.create()); @@ -554,7 +554,7 @@ void tst_valuetypes::bindingVariantCopy() } // Test that value types can be assigned to another value type property in script -void tst_valuetypes::scriptVariantCopy() +void tst_qmlvaluetypes::scriptVariantCopy() { QmlComponent component(&engine, TEST_FILE("scriptVariantCopy.qml")); MyTypeObject *object = qobject_cast(component.create()); @@ -571,7 +571,7 @@ void tst_valuetypes::scriptVariantCopy() // Test that the value type classes can be used manually -void tst_valuetypes::cppClasses() +void tst_qmlvaluetypes::cppClasses() { CPP_TEST(QmlPointValueType, QPoint(19, 33)); CPP_TEST(QmlPointFValueType, QPointF(33.6, -23)); @@ -583,6 +583,6 @@ void tst_valuetypes::cppClasses() CPP_TEST(QmlFontValueType, QFont("Helvetica")); } -QTEST_MAIN(tst_valuetypes) +QTEST_MAIN(tst_qmlvaluetypes) #include "tst_qmlvaluetypes.moc" diff --git a/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp b/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp index df5442c..96f9ec6 100644 --- a/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp +++ b/tests/auto/declarative/qmlxmlhttprequest/tst_qmlxmlhttprequest.cpp @@ -48,11 +48,11 @@ #define SERVER_PORT 14445 -class tst_xmlhttprequest : public QObject +class tst_qmlxmlhttprequest : public QObject { Q_OBJECT public: - tst_xmlhttprequest() {} + tst_qmlxmlhttprequest() {} private slots: void initTestCase() { @@ -123,7 +123,7 @@ inline QUrl TEST_FILE(const QString &filename) } // Test that the dom exception codes are correct -void tst_xmlhttprequest::domExceptionCodes() +void tst_qmlxmlhttprequest::domExceptionCodes() { QmlComponent component(&engine, TEST_FILE("domExceptionCodes.qml")); QObject *object = component.create(); @@ -160,7 +160,7 @@ void tst_xmlhttprequest::domExceptionCodes() } while (false) -void tst_xmlhttprequest::callbackException_data() +void tst_qmlxmlhttprequest::callbackException_data() { QTest::addColumn("which"); QTest::addColumn("line"); @@ -170,7 +170,7 @@ void tst_xmlhttprequest::callbackException_data() QTest::newRow("on-done") << "4" << 15; } -void tst_xmlhttprequest::callbackException() +void tst_qmlxmlhttprequest::callbackException() { // Test exception reporting for exceptions thrown at various points. @@ -194,7 +194,7 @@ void tst_xmlhttprequest::callbackException() // Test that the state value properties on the XMLHttpRequest constructor have the correct values. // ### WebKit does not do this, but it seems to fit the standard and QML better -void tst_xmlhttprequest::staticStateValues() +void tst_qmlxmlhttprequest::staticStateValues() { QmlComponent component(&engine, TEST_FILE("staticStateValues.qml")); QObject *object = component.create(); @@ -210,7 +210,7 @@ void tst_xmlhttprequest::staticStateValues() } // Test that the state value properties on instances have the correct values. -void tst_xmlhttprequest::instanceStateValues() +void tst_qmlxmlhttprequest::instanceStateValues() { QmlComponent component(&engine, TEST_FILE("instanceStateValues.qml")); QObject *object = component.create(); @@ -226,7 +226,7 @@ void tst_xmlhttprequest::instanceStateValues() } // Test calling constructor -void tst_xmlhttprequest::constructor() +void tst_qmlxmlhttprequest::constructor() { QmlComponent component(&engine, TEST_FILE("constructor.qml")); QObject *object = component.create(); @@ -239,7 +239,7 @@ void tst_xmlhttprequest::constructor() } // Test that all the properties are set correctly before any request is sent -void tst_xmlhttprequest::defaultState() +void tst_qmlxmlhttprequest::defaultState() { QmlComponent component(&engine, TEST_FILE("defaultState.qml")); QObject *object = component.create(); @@ -255,7 +255,7 @@ void tst_xmlhttprequest::defaultState() } // Test valid XMLHttpRequest.open() calls -void tst_xmlhttprequest::open() +void tst_qmlxmlhttprequest::open() { // Relative url { @@ -353,7 +353,7 @@ void tst_xmlhttprequest::open() } // Test that calling XMLHttpRequest.open() with an invalid method raises an exception -void tst_xmlhttprequest::open_invalid_method() +void tst_qmlxmlhttprequest::open_invalid_method() { QmlComponent component(&engine, TEST_FILE("open_invalid_method.qml")); QObject *object = component.create(); @@ -365,7 +365,7 @@ void tst_xmlhttprequest::open_invalid_method() } // Test that calling XMLHttpRequest.open() with sync raises an exception -void tst_xmlhttprequest::open_sync() +void tst_qmlxmlhttprequest::open_sync() { QmlComponent component(&engine, TEST_FILE("open_sync.qml")); QObject *object = component.create(); @@ -377,7 +377,7 @@ void tst_xmlhttprequest::open_sync() } // Calling with incorrect arg count raises an exception -void tst_xmlhttprequest::open_arg_count() +void tst_qmlxmlhttprequest::open_arg_count() { { QmlComponent component(&engine, TEST_FILE("open_arg_count.1.qml")); @@ -401,7 +401,7 @@ void tst_xmlhttprequest::open_arg_count() } // Test valid setRequestHeader() calls -void tst_xmlhttprequest::setRequestHeader() +void tst_qmlxmlhttprequest::setRequestHeader() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); @@ -421,7 +421,7 @@ void tst_xmlhttprequest::setRequestHeader() } // Test setting headers before open() throws exception -void tst_xmlhttprequest::setRequestHeader_unsent() +void tst_qmlxmlhttprequest::setRequestHeader_unsent() { QmlComponent component(&engine, TEST_FILE("setRequestHeader_unsent.qml")); QObject *object = component.create(); @@ -432,7 +432,7 @@ void tst_xmlhttprequest::setRequestHeader_unsent() delete object; } -void tst_xmlhttprequest::setRequestHeader_illegalName_data() +void tst_qmlxmlhttprequest::setRequestHeader_illegalName_data() { QTest::addColumn("name"); @@ -461,7 +461,7 @@ void tst_xmlhttprequest::setRequestHeader_illegalName_data() } // Tests that using illegal header names has no effect -void tst_xmlhttprequest::setRequestHeader_illegalName() +void tst_qmlxmlhttprequest::setRequestHeader_illegalName() { QFETCH(QString, name); @@ -491,7 +491,7 @@ void tst_xmlhttprequest::setRequestHeader_illegalName() } // Test that attempting to set a header after a request is sent throws an exception -void tst_xmlhttprequest::setRequestHeader_sent() +void tst_qmlxmlhttprequest::setRequestHeader_sent() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); @@ -513,7 +513,7 @@ void tst_xmlhttprequest::setRequestHeader_sent() } // Invalid arg count throws exception -void tst_xmlhttprequest::setRequestHeader_args() +void tst_qmlxmlhttprequest::setRequestHeader_args() { QmlComponent component(&engine, TEST_FILE("setRequestHeader_args.qml")); QObject *object = component.create(); @@ -525,7 +525,7 @@ void tst_xmlhttprequest::setRequestHeader_args() } // Test that calling send() in UNSENT state throws an exception -void tst_xmlhttprequest::send_unsent() +void tst_qmlxmlhttprequest::send_unsent() { QmlComponent component(&engine, TEST_FILE("send_unsent.qml")); QObject *object = component.create(); @@ -537,7 +537,7 @@ void tst_xmlhttprequest::send_unsent() } // Test attempting to resend a sent request throws an exception -void tst_xmlhttprequest::send_alreadySent() +void tst_qmlxmlhttprequest::send_alreadySent() { QmlComponent component(&engine, TEST_FILE("send_alreadySent.qml")); QObject *object = component.create(); @@ -550,7 +550,7 @@ void tst_xmlhttprequest::send_alreadySent() } // Test that send for a GET or HEAD ignores data -void tst_xmlhttprequest::send_ignoreData() +void tst_qmlxmlhttprequest::send_ignoreData() { { TestHTTPServer server(SERVER_PORT); @@ -592,7 +592,7 @@ void tst_xmlhttprequest::send_ignoreData() } // Test that send()'ing data works -void tst_xmlhttprequest::send_withdata() +void tst_qmlxmlhttprequest::send_withdata() { // No content-type { @@ -729,7 +729,7 @@ void tst_xmlhttprequest::send_withdata() } // Test abort() has no effect in unsent state -void tst_xmlhttprequest::abort_unsent() +void tst_qmlxmlhttprequest::abort_unsent() { QmlComponent component(&engine, TEST_FILE("abort_unsent.qml")); QObject *object = component.beginCreate(engine.rootContext()); @@ -750,7 +750,7 @@ void tst_xmlhttprequest::abort_unsent() } // Test abort() cancels an open (but unsent) request -void tst_xmlhttprequest::abort_opened() +void tst_qmlxmlhttprequest::abort_opened() { QmlComponent component(&engine, TEST_FILE("abort_opened.qml")); QObject *object = component.beginCreate(engine.rootContext()); @@ -771,7 +771,7 @@ void tst_xmlhttprequest::abort_opened() } // Test abort() aborts in progress send -void tst_xmlhttprequest::abort() +void tst_qmlxmlhttprequest::abort() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); @@ -795,7 +795,7 @@ void tst_xmlhttprequest::abort() delete object; } -void tst_xmlhttprequest::getResponseHeader() +void tst_qmlxmlhttprequest::getResponseHeader() { QmlEngine engine; // Avoid cookie contamination @@ -835,7 +835,7 @@ void tst_xmlhttprequest::getResponseHeader() } // Test getResponseHeader throws an exception in an invalid state -void tst_xmlhttprequest::getResponseHeader_unsent() +void tst_qmlxmlhttprequest::getResponseHeader_unsent() { QmlComponent component(&engine, TEST_FILE("getResponseHeader_unsent.qml")); QObject *object = component.create(); @@ -847,7 +847,7 @@ void tst_xmlhttprequest::getResponseHeader_unsent() } // Test getResponseHeader throws an exception in an invalid state -void tst_xmlhttprequest::getResponseHeader_sent() +void tst_qmlxmlhttprequest::getResponseHeader_sent() { QmlComponent component(&engine, TEST_FILE("getResponseHeader_sent.qml")); QObject *object = component.create(); @@ -859,7 +859,7 @@ void tst_xmlhttprequest::getResponseHeader_sent() } // Invalid arg count throws exception -void tst_xmlhttprequest::getResponseHeader_args() +void tst_qmlxmlhttprequest::getResponseHeader_args() { QmlComponent component(&engine, TEST_FILE("getResponseHeader_args.qml")); QObject *object = component.create(); @@ -870,7 +870,7 @@ void tst_xmlhttprequest::getResponseHeader_args() delete object; } -void tst_xmlhttprequest::getAllResponseHeaders() +void tst_qmlxmlhttprequest::getAllResponseHeaders() { QmlEngine engine; // Avoid cookie contamination @@ -903,7 +903,7 @@ void tst_xmlhttprequest::getAllResponseHeaders() } // Test getAllResponseHeaders throws an exception in an invalid state -void tst_xmlhttprequest::getAllResponseHeaders_unsent() +void tst_qmlxmlhttprequest::getAllResponseHeaders_unsent() { QmlComponent component(&engine, TEST_FILE("getAllResponseHeaders_unsent.qml")); QObject *object = component.create(); @@ -915,7 +915,7 @@ void tst_xmlhttprequest::getAllResponseHeaders_unsent() } // Test getAllResponseHeaders throws an exception in an invalid state -void tst_xmlhttprequest::getAllResponseHeaders_sent() +void tst_qmlxmlhttprequest::getAllResponseHeaders_sent() { QmlComponent component(&engine, TEST_FILE("getAllResponseHeaders_sent.qml")); QObject *object = component.create(); @@ -927,7 +927,7 @@ void tst_xmlhttprequest::getAllResponseHeaders_sent() } // Invalid arg count throws exception -void tst_xmlhttprequest::getAllResponseHeaders_args() +void tst_qmlxmlhttprequest::getAllResponseHeaders_args() { QmlComponent component(&engine, TEST_FILE("getAllResponseHeaders_args.qml")); QObject *object = component.create(); @@ -938,7 +938,7 @@ void tst_xmlhttprequest::getAllResponseHeaders_args() delete object; } -void tst_xmlhttprequest::status() +void tst_qmlxmlhttprequest::status() { { TestHTTPServer server(SERVER_PORT); @@ -995,7 +995,7 @@ void tst_xmlhttprequest::status() } } -void tst_xmlhttprequest::statusText() +void tst_qmlxmlhttprequest::statusText() { { TestHTTPServer server(SERVER_PORT); @@ -1052,7 +1052,7 @@ void tst_xmlhttprequest::statusText() } } -void tst_xmlhttprequest::responseText() +void tst_qmlxmlhttprequest::responseText() { { TestHTTPServer server(SERVER_PORT); @@ -1138,7 +1138,7 @@ void tst_xmlhttprequest::responseText() // Test that calling hte XMLHttpRequest methods on a non-XMLHttpRequest object // throws an exception -void tst_xmlhttprequest::invalidMethodUsage() +void tst_qmlxmlhttprequest::invalidMethodUsage() { QmlComponent component(&engine, TEST_FILE("invalidMethodUsage.qml")); QObject *object = component.create(); @@ -1162,7 +1162,7 @@ void tst_xmlhttprequest::invalidMethodUsage() } // Test that XMLHttpRequest transparently redirects -void tst_xmlhttprequest::redirects() +void tst_qmlxmlhttprequest::redirects() { { TestHTTPServer server(SERVER_PORT); @@ -1227,7 +1227,7 @@ void tst_xmlhttprequest::redirects() } } -void tst_xmlhttprequest::responseXML_invalid() +void tst_qmlxmlhttprequest::responseXML_invalid() { QmlComponent component(&engine, TEST_FILE("responseXML_invalid.qml")); QObject *object = component.create(); @@ -1241,7 +1241,7 @@ void tst_xmlhttprequest::responseXML_invalid() } // Test the Document DOM element -void tst_xmlhttprequest::document() +void tst_qmlxmlhttprequest::document() { QmlComponent component(&engine, TEST_FILE("document.qml")); QObject *object = component.create(); @@ -1255,7 +1255,7 @@ void tst_xmlhttprequest::document() } // Test the Element DOM element -void tst_xmlhttprequest::element() +void tst_qmlxmlhttprequest::element() { QmlComponent component(&engine, TEST_FILE("element.qml")); QObject *object = component.create(); @@ -1269,7 +1269,7 @@ void tst_xmlhttprequest::element() } // Test the Attr DOM element -void tst_xmlhttprequest::attr() +void tst_qmlxmlhttprequest::attr() { QmlComponent component(&engine, TEST_FILE("attr.qml")); QObject *object = component.create(); @@ -1283,7 +1283,7 @@ void tst_xmlhttprequest::attr() } // Test the Text DOM element -void tst_xmlhttprequest::text() +void tst_qmlxmlhttprequest::text() { QmlComponent component(&engine, TEST_FILE("text.qml")); QObject *object = component.create(); @@ -1297,7 +1297,7 @@ void tst_xmlhttprequest::text() } // Test the CDataSection DOM element -void tst_xmlhttprequest::cdata() +void tst_qmlxmlhttprequest::cdata() { QmlComponent component(&engine, TEST_FILE("cdata.qml")); QObject *object = component.create(); @@ -1310,6 +1310,6 @@ void tst_xmlhttprequest::cdata() delete object; } -QTEST_MAIN(tst_xmlhttprequest) +QTEST_MAIN(tst_qmlxmlhttprequest) #include "tst_qmlxmlhttprequest.moc" -- cgit v0.12 From 11fad736e949c04543036654970b9d93cd99d9ff Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 16 Feb 2010 11:21:56 +1000 Subject: transformOrigin defaults to Center, fix image/docs. --- doc/src/images/declarative-rotation.png | Bin 645 -> 667 bytes src/declarative/graphicsitems/qmlgraphicsitem.cpp | 4 ---- 2 files changed, 4 deletions(-) diff --git a/doc/src/images/declarative-rotation.png b/doc/src/images/declarative-rotation.png index 994011b..b4031f5 100644 Binary files a/doc/src/images/declarative-rotation.png and b/doc/src/images/declarative-rotation.png differ diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp index 9fd8702..08c0c2d 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp @@ -2070,10 +2070,6 @@ void QmlGraphicsItem::setBaselineOffset(qreal offset) color: "blue" width: 100; height: 100 Rectangle { - color: "green" - width: 25; height: 25 - } - Rectangle { color: "red" x: 25; y: 25; width: 50; height: 50 rotation: 30 -- cgit v0.12 From b77e592cf9709c31f61c3e1d229b2a6c446ab8bc Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 16 Feb 2010 11:27:24 +1000 Subject: Add QmlImageProvider to allow asynchronous access to images. Setting an image source to image://providerid/imageid will pass the request for imageid to the provider registered for providerid. QmlImageProvider::request() is run in a low priority thread, so the main thread is not blocked while the image is loaded/rendered. Reviewed-by: Aaron Kennedy --- .../declarative/imageprovider/imageprovider.pro | 9 ++ .../declarative/imageprovider/imageprovider.qrc | 5 + examples/declarative/imageprovider/main.cpp | 99 +++++++++++++ examples/declarative/imageprovider/view.qml | 22 +++ src/declarative/qml/qml.pri | 2 + src/declarative/qml/qmlengine.cpp | 89 ++++++++++- src/declarative/qml/qmlengine.h | 5 + src/declarative/qml/qmlengine_p.h | 7 + src/declarative/qml/qmlimageprovider.cpp | 68 +++++++++ src/declarative/qml/qmlimageprovider.h | 64 ++++++++ src/declarative/util/qmlpixmapcache.cpp | 38 +++-- tests/auto/declarative/declarative.pro | 1 + .../declarative/qmlimageprovider/data/exists.png | Bin 0 -> 2738 bytes .../declarative/qmlimageprovider/data/exists1.png | Bin 0 -> 2738 bytes .../declarative/qmlimageprovider/data/exists2.png | Bin 0 -> 2738 bytes .../qmlimageprovider/qmlimageprovider.pro | 12 ++ .../qmlimageprovider/tst_qmlimageprovider.cpp | 164 +++++++++++++++++++++ 17 files changed, 562 insertions(+), 23 deletions(-) create mode 100644 examples/declarative/imageprovider/imageprovider.pro create mode 100644 examples/declarative/imageprovider/imageprovider.qrc create mode 100644 examples/declarative/imageprovider/main.cpp create mode 100644 examples/declarative/imageprovider/view.qml create mode 100644 src/declarative/qml/qmlimageprovider.cpp create mode 100644 src/declarative/qml/qmlimageprovider.h create mode 100644 tests/auto/declarative/qmlimageprovider/data/exists.png create mode 100644 tests/auto/declarative/qmlimageprovider/data/exists1.png create mode 100644 tests/auto/declarative/qmlimageprovider/data/exists2.png create mode 100644 tests/auto/declarative/qmlimageprovider/qmlimageprovider.pro create mode 100644 tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp diff --git a/examples/declarative/imageprovider/imageprovider.pro b/examples/declarative/imageprovider/imageprovider.pro new file mode 100644 index 0000000..60423ab --- /dev/null +++ b/examples/declarative/imageprovider/imageprovider.pro @@ -0,0 +1,9 @@ +TEMPLATE = app +TARGET = imageprovider +DEPENDPATH += . +INCLUDEPATH += . +QT += declarative + +# Input +SOURCES += main.cpp +RESOURCES += imageprovider.qrc diff --git a/examples/declarative/imageprovider/imageprovider.qrc b/examples/declarative/imageprovider/imageprovider.qrc new file mode 100644 index 0000000..17e9301 --- /dev/null +++ b/examples/declarative/imageprovider/imageprovider.qrc @@ -0,0 +1,5 @@ + + + view.qml + + diff --git a/examples/declarative/imageprovider/main.cpp b/examples/declarative/imageprovider/main.cpp new file mode 100644 index 0000000..718e9bb --- /dev/null +++ b/examples/declarative/imageprovider/main.cpp @@ -0,0 +1,99 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the demonstration applications 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$ +** +****************************************************************************/ + +#include + +#include +#include +#include +#include +#include +#include +#include +#include + +/* + This example illustrates using a QmlImageProvider to serve + images asynchronously. +*/ + +//![0] +class ColorImageProvider : public QmlImageProvider +{ +public: + // This is run in a low priority thread. + QImage request(const QString &id) { + QImage image(100, 50, QImage::Format_RGB32); + image.fill(QColor(id).rgba()); + QPainter p(&image); + p.setPen(Qt::black); + p.drawText(QRectF(0,0,100,50),Qt::AlignCenter,id); + return image; + } +}; + +int main(int argc, char ** argv) +{ + QApplication app(argc, argv); + + QmlView view; + view.setUrl(QUrl("qrc:view.qml")); + + view.engine()->addImageProvider("colors", new ColorImageProvider); + + QStringList dataList; + dataList.append("image://colors/red"); + dataList.append("image://colors/green"); + dataList.append("image://colors/blue"); + dataList.append("image://colors/brown"); + dataList.append("image://colors/orange"); + dataList.append("image://colors/purple"); + dataList.append("image://colors/yellow"); + + QmlContext *ctxt = view.rootContext(); + ctxt->setContextProperty("myModel", QVariant::fromValue(dataList)); + + view.execute(); + view.show(); + + return app.exec(); +} +//![0] diff --git a/examples/declarative/imageprovider/view.qml b/examples/declarative/imageprovider/view.qml new file mode 100644 index 0000000..2ab729d --- /dev/null +++ b/examples/declarative/imageprovider/view.qml @@ -0,0 +1,22 @@ +import Qt 4.6 +//![0] +ListView { + width: 100 + height: 100 + anchors.fill: parent + model: myModel + delegate: Component { + Item { + width: 100 + height: 50 + Text { + text: "Loading..." + anchors.centerIn: parent + } + Image { + source: modelData + } + } + } +} +//![0] diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index cd2fbff..021ef9e 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -50,6 +50,7 @@ SOURCES += \ $$PWD/qmltypenamescriptclass.cpp \ $$PWD/qmllistscriptclass.cpp \ $$PWD/qmlworkerscript.cpp \ + $$PWD/qmlimageprovider.cpp \ $$PWD/qmlnetworkaccessmanagerfactory.cpp HEADERS += \ $$PWD/qmlparser_p.h \ @@ -117,6 +118,7 @@ HEADERS += \ $$PWD/qmlworkerscript_p.h \ $$PWD/qmlscriptclass_p.h \ $$PWD/qmlguard_p.h \ + $$PWD/qmlimageprovider.h \ $$PWD/qmlnetworkaccessmanagerfactory.h QT += sql include(parser/parser.pri) diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index cdbe5f3..4edab4d 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -65,6 +65,7 @@ #include "qmlcomponent_p.h" #include "qmlscriptclass_p.h" #include "qmlnetworkaccessmanagerfactory.h" +#include "qmlimageprovider.h" #include @@ -85,6 +86,7 @@ #include #include #include +#include #include #include #include @@ -424,6 +426,7 @@ QmlContext *QmlEngine::rootContext() void QmlEngine::setNetworkAccessManagerFactory(QmlNetworkAccessManagerFactory *factory) { Q_D(QmlEngine); + QMutexLocker locker(&d->mutex); d->networkAccessManagerFactory = factory; } @@ -438,17 +441,24 @@ QmlNetworkAccessManagerFactory *QmlEngine::networkAccessManagerFactory() const return d->networkAccessManagerFactory; } +QNetworkAccessManager *QmlEnginePrivate::createNetworkAccessManager(QObject *parent) const +{ + QMutexLocker locker(&mutex); + QNetworkAccessManager *nam; + if (networkAccessManagerFactory) { + nam = networkAccessManagerFactory->create(parent); + } else { + nam = new QNetworkAccessManager(parent); + } + + return nam; +} + QNetworkAccessManager *QmlEnginePrivate::getNetworkAccessManager() const { Q_Q(const QmlEngine); - - if (!networkAccessManager) { - if (networkAccessManagerFactory) { - networkAccessManager = networkAccessManagerFactory->create(const_cast(q)); - } else { - networkAccessManager = new QNetworkAccessManager(const_cast(q)); - } - } + if (!networkAccessManager) + networkAccessManager = createNetworkAccessManager(const_cast(q)); return networkAccessManager; } @@ -470,6 +480,69 @@ QNetworkAccessManager *QmlEngine::networkAccessManager() const } /*! + Sets the \a provider to use for images requested via the \e image: url + scheme, with host \a providerId. + + QmlImageProvider allows images to be provided to QML asynchronously. + The image request will be run in a low priority thread. This allows + potentially costly image loading to be done in the background, without + affecting the performance of the UI. + + Note that images loaded from a QmlImageProvider are cached by + QPixmapCache, similar to any image loaded by QML. + + The QmlEngine assumes ownership of the provider. + + This example creates a provider with id \e colors: + + \snippet examples/declarative/imageprovider/main.cpp 0 + + \snippet examples/declarative/imageprovider/view.qml 0 + + \sa removeImageProvider() +*/ +void QmlEngine::addImageProvider(const QString &providerId, QmlImageProvider *provider) +{ + Q_D(QmlEngine); + QMutexLocker locker(&d->mutex); + d->imageProviders.insert(providerId, provider); +} + +/*! + Returns the QmlImageProvider set for \a providerId. +*/ +QmlImageProvider *QmlEngine::imageProvider(const QString &providerId) const +{ + Q_D(const QmlEngine); + QMutexLocker locker(&d->mutex); + return d->imageProviders.value(providerId); +} + +/*! + Removes the QmlImageProvider for \a providerId. + + Returns the provider if it was found; otherwise returns 0. + + \sa addImageProvider() +*/ +void QmlEngine::removeImageProvider(const QString &providerId) +{ + Q_D(QmlEngine); + QMutexLocker locker(&d->mutex); + delete d->imageProviders.take(providerId); +} + +QImage QmlEnginePrivate::getImageFromProvider(const QUrl &url) +{ + QMutexLocker locker(&mutex); + QImage image; + QmlImageProvider *provider = imageProviders.value(url.host()); + if (provider) + image = provider->request(url.path().mid(1)); + return image; +} + +/*! Return the base URL for this engine. The base URL is only used to resolve components when a relative URL is passed to the QmlComponent constructor. diff --git a/src/declarative/qml/qmlengine.h b/src/declarative/qml/qmlengine.h index 7ee014a..a59a1ba 100644 --- a/src/declarative/qml/qmlengine.h +++ b/src/declarative/qml/qmlengine.h @@ -62,6 +62,7 @@ class QmlType; class QUrl; class QScriptEngine; class QScriptContext; +class QmlImageProvider; class QNetworkAccessManager; class QmlNetworkAccessManagerFactory; class Q_DECLARATIVE_EXPORT QmlEngine : public QObject @@ -83,6 +84,10 @@ public: QNetworkAccessManager *networkAccessManager() const; + void addImageProvider(const QString &id, QmlImageProvider *); + QmlImageProvider *imageProvider(const QString &id) const; + void removeImageProvider(const QString &id); + void setOfflineStoragePath(const QString& dir); QString offlineStoragePath() const; diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index 13ed5ef..87864b7 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -75,6 +75,7 @@ #include #include #include +#include #include #include @@ -211,10 +212,16 @@ public: bool inBeginCreate; + QNetworkAccessManager *createNetworkAccessManager(QObject *parent) const; QNetworkAccessManager *getNetworkAccessManager() const; mutable QNetworkAccessManager *networkAccessManager; mutable QmlNetworkAccessManagerFactory *networkAccessManagerFactory; + QHash imageProviders; + QImage getImageFromProvider(const QUrl &url); + + mutable QMutex mutex; + QmlCompositeTypeManager typeManager; QStringList fileImportPath; QString offlineStoragePath; diff --git a/src/declarative/qml/qmlimageprovider.cpp b/src/declarative/qml/qmlimageprovider.cpp new file mode 100644 index 0000000..ebb8656 --- /dev/null +++ b/src/declarative/qml/qmlimageprovider.cpp @@ -0,0 +1,68 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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$ +** +****************************************************************************/ + +#include "qmlimageprovider.h" + +QT_BEGIN_NAMESPACE + +/*! + \class QmlImageProvider + \brief The QmlImageProvider class provides an interface for threaded image requests. + + Note: the request() method may be called by multiple threads, so ensure the + implementation of this method is reentrant. + + \sa QmlEngine::addImageProvider() +*/ +QmlImageProvider::~QmlImageProvider() +{ +} + +/*! + \fn QImage QmlImageProvider::request(const QString &id) + + Implement this method to return the image with \a id. + + Note: this method may be called by multiple threads, so ensure the + implementation of this method is reentrant. +*/ + +QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlimageprovider.h b/src/declarative/qml/qmlimageprovider.h new file mode 100644 index 0000000..9804815 --- /dev/null +++ b/src/declarative/qml/qmlimageprovider.h @@ -0,0 +1,64 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QMLIMAGEPROVIDER_H +#define QMLIMAGEPROVIDER_H + +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class Q_DECLARATIVE_EXPORT QmlImageProvider +{ +public: + virtual ~QmlImageProvider(); + virtual QImage request(const QString &id) = 0; +}; + +QT_END_NAMESPACE + +QT_END_HEADER + +#endif // QMLIMAGEPROVIDER diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp index c03b5df..623aaf0 100644 --- a/src/declarative/util/qmlpixmapcache.cpp +++ b/src/declarative/util/qmlpixmapcache.cpp @@ -41,11 +41,13 @@ #include "qmlpixmapcache_p.h" #include "qmlnetworkaccessmanagerfactory.h" +#include "qmlimageprovider.h" #include "qfxperf_p_p.h" #include #include +#include #include #include @@ -82,7 +84,7 @@ class QmlImageReaderEvent : public QEvent public: enum ReadError { NoError, Loading, Decoding }; - QmlImageReaderEvent(QmlImageReaderEvent::ReadError err, const QString &errStr, QImage &img) + QmlImageReaderEvent(QmlImageReaderEvent::ReadError err, const QString &errStr, const QImage &img) : QEvent(QEvent::User), error(err), errorString(errStr), image(img) {} ReadError error; @@ -143,13 +145,8 @@ private slots: private: QNetworkAccessManager *networkAccessManager() { - if (!accessManager) { - if (engine && engine->networkAccessManagerFactory()) { - accessManager = engine->networkAccessManagerFactory()->create(this); - } else { - accessManager = new QNetworkAccessManager(this); - } - } + if (!accessManager) + accessManager = QmlEnginePrivate::get(engine)->createNetworkAccessManager(this); return accessManager; } @@ -197,21 +194,32 @@ bool QmlImageRequestHandler::event(QEvent *event) break; } - QmlPixmapReply *runningJob = reader->jobs.takeFirst(); + QmlPixmapReply *runningJob = reader->jobs.takeLast(); runningJob->addRef(); runningJob->setLoading(); QUrl url = runningJob->url(); reader->mutex.unlock(); // fetch - QNetworkRequest req(url); - req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); - QNetworkReply *reply = networkAccessManager()->get(req); + if (url.scheme() == QLatin1String("image")) { + QImage image = QmlEnginePrivate::get(engine)->getImageFromProvider(url); + QmlImageReaderEvent::ReadError errorCode = QmlImageReaderEvent::NoError; + QString errorStr; + if (image.isNull()) { + errorCode = QmlImageReaderEvent::Loading; + errorStr = QLatin1String("Failed to get image from provider: ") + url.toString(); + } + QCoreApplication::postEvent(runningJob, new QmlImageReaderEvent(errorCode, errorStr, image)); + } else { + QNetworkRequest req(url); + req.setAttribute(QNetworkRequest::HttpPipeliningAllowedAttribute, true); + QNetworkReply *reply = networkAccessManager()->get(req); - QMetaObject::connect(reply, replyDownloadProgress, runningJob, downloadProgress); - QMetaObject::connect(reply, replyFinished, this, thisNetworkRequestDone); + QMetaObject::connect(reply, replyDownloadProgress, runningJob, downloadProgress); + QMetaObject::connect(reply, replyFinished, this, thisNetworkRequestDone); - replies.insert(reply, runningJob); + replies.insert(reply, runningJob); + } } return true; } diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 8773026..fba63d5 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -57,6 +57,7 @@ SUBDIRS += \ qmlgraphicsrepeater \ # Cover qmlvaluetypes \ # Cover qmlxmlhttprequest \ # Cover + qmlimageprovider \ # Cover sql # Cover diff --git a/tests/auto/declarative/qmlimageprovider/data/exists.png b/tests/auto/declarative/qmlimageprovider/data/exists.png new file mode 100644 index 0000000..399bd0b Binary files /dev/null and b/tests/auto/declarative/qmlimageprovider/data/exists.png differ diff --git a/tests/auto/declarative/qmlimageprovider/data/exists1.png b/tests/auto/declarative/qmlimageprovider/data/exists1.png new file mode 100644 index 0000000..399bd0b Binary files /dev/null and b/tests/auto/declarative/qmlimageprovider/data/exists1.png differ diff --git a/tests/auto/declarative/qmlimageprovider/data/exists2.png b/tests/auto/declarative/qmlimageprovider/data/exists2.png new file mode 100644 index 0000000..399bd0b Binary files /dev/null and b/tests/auto/declarative/qmlimageprovider/data/exists2.png differ diff --git a/tests/auto/declarative/qmlimageprovider/qmlimageprovider.pro b/tests/auto/declarative/qmlimageprovider/qmlimageprovider.pro new file mode 100644 index 0000000..0ef7739 --- /dev/null +++ b/tests/auto/declarative/qmlimageprovider/qmlimageprovider.pro @@ -0,0 +1,12 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative +QT += network +macx:CONFIG -= app_bundle + +SOURCES += tst_qmlimageprovider.cpp + +# QMAKE_CXXFLAGS = -fprofile-arcs -ftest-coverage +# LIBS += -lgcov + +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp b/tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp new file mode 100644 index 0000000..475cb7a --- /dev/null +++ b/tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp @@ -0,0 +1,164 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite 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$ +** +****************************************************************************/ +#include +#include +#include +#include +#include + +#define TRY_WAIT(expr) \ + do { \ + for (int ii = 0; ii < 6; ++ii) { \ + if ((expr)) break; \ + QTest::qWait(50); \ + } \ + QVERIFY((expr)); \ + } while (false) + + +class tst_qmlimageprovider : public QObject +{ + Q_OBJECT +public: + tst_qmlimageprovider() + { + } + +private slots: + void imageSource(); + void imageSource_data(); + void removeProvider(); + +private: + QmlEngine engine; +}; + +class TestProvider : public QmlImageProvider +{ +public: + QImage request(const QString &id) { + QImage image; + image.load(SRCDIR "/data/" + id); + return image; + } +}; + +void tst_qmlimageprovider::imageSource_data() +{ + QTest::addColumn("source"); + QTest::addColumn("error"); + + QTest::newRow("exists") << "image://test/exists.png" << ""; + QTest::newRow("missing") << "image://test/no-such-file.png" + << "\"Failed to get image from provider: image://test/no-such-file.png\" "; + QTest::newRow("unknown provider") << "image://bogus/exists.png" + << "\"Failed to get image from provider: image://bogus/exists.png\" "; +} + +void tst_qmlimageprovider::imageSource() +{ + QFETCH(QString, source); + QFETCH(QString, error); + + if (!error.isEmpty()) + QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); + + engine.addImageProvider("test", new TestProvider); + QVERIFY(engine.imageProvider("test") != 0); + + QString componentStr = "import Qt 4.6\nImage { source: \"" + source + "\" }"; + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QmlGraphicsImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + + TRY_WAIT(obj->status() == QmlGraphicsImage::Loading); + + QCOMPARE(obj->source(), QUrl(source)); + + if (error.isEmpty()) { + TRY_WAIT(obj->status() == QmlGraphicsImage::Ready); + QCOMPARE(obj->width(), 100.); + QCOMPARE(obj->height(), 100.); + QCOMPARE(obj->fillMode(), QmlGraphicsImage::Stretch); + QCOMPARE(obj->progress(), 1.0); + } else { + TRY_WAIT(obj->status() == QmlGraphicsImage::Error); + } + + delete obj; +} + +void tst_qmlimageprovider::removeProvider() +{ + engine.addImageProvider("test2", new TestProvider); + QVERIFY(engine.imageProvider("test2") != 0); + + // add provider, confirm it works + QString componentStr = "import Qt 4.6\nImage { source: \"image://test2/exists1.png\" }"; + QmlComponent component(&engine); + component.setData(componentStr.toLatin1(), QUrl::fromLocalFile("")); + QmlGraphicsImage *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + + TRY_WAIT(obj->status() == QmlGraphicsImage::Loading); + TRY_WAIT(obj->status() == QmlGraphicsImage::Ready); + + QCOMPARE(obj->width(), 100.0); + + // remove the provider and confirm + QString error("\"Failed to get image from provider: image://test2/exists2.png\" "); + QTest::ignoreMessage(QtWarningMsg, error.toUtf8()); + + engine.removeImageProvider("test2"); + + obj->setSource(QUrl("image://test2/exists2.png")); + + TRY_WAIT(obj->status() == QmlGraphicsImage::Loading); + TRY_WAIT(obj->status() == QmlGraphicsImage::Error); + + delete obj; +} + + +QTEST_MAIN(tst_qmlimageprovider) + +#include "tst_qmlimageprovider.moc" -- cgit v0.12 From dd4d3e1ce0adba26396c5ab4e77c728e2159ff30 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 16 Feb 2010 13:12:22 +1000 Subject: Don't delete binding directly Bindings should be destroyed by calling their destroy() method, not by deleting them. --- src/declarative/qml/qmlmetaproperty.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index f23a50a..d63261c 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -754,8 +754,10 @@ bool QmlMetaPropertyPrivate::writeValueProperty(const QVariant &value, QmlMetaProperty::WriteFlags flags) { // Remove any existing bindings on this property - if (!(flags & QmlMetaProperty::DontRemoveBinding)) - delete q->setBinding(0); + if (!(flags & QmlMetaProperty::DontRemoveBinding)) { + QmlAbstractBinding *binding = q->setBinding(0); + if (binding) binding->destroy(); + } bool rv = false; uint type = q->type(); -- cgit v0.12 From d6b2b36b02f6c61e91209629dd7af30311014873 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 16 Feb 2010 13:12:45 +1000 Subject: Fix crash in QML binding optimizer Optimized bindings need to reset the mePtr too. --- src/declarative/qml/qmlbinding.cpp | 6 + src/declarative/qml/qmlbinding.h | 3 + src/declarative/qml/qmlcompiledbindings.cpp | 293 +++++++++++++++------------- 3 files changed, 164 insertions(+), 138 deletions(-) diff --git a/src/declarative/qml/qmlbinding.cpp b/src/declarative/qml/qmlbinding.cpp index 3e29a3c..a986818 100644 --- a/src/declarative/qml/qmlbinding.cpp +++ b/src/declarative/qml/qmlbinding.cpp @@ -291,6 +291,12 @@ void QmlAbstractBinding::removeFromObject() } } +void QmlAbstractBinding::clear() +{ + if (m_mePtr) + *m_mePtr = 0; +} + QString QmlAbstractBinding::expression() const { return QLatin1String(""); diff --git a/src/declarative/qml/qmlbinding.h b/src/declarative/qml/qmlbinding.h index cefb4fe..bae971d 100644 --- a/src/declarative/qml/qmlbinding.h +++ b/src/declarative/qml/qmlbinding.h @@ -75,6 +75,9 @@ public: void addToObject(QObject *); void removeFromObject(); +protected: + void clear(); + private: friend class QmlDeclarativeData; friend class QmlMetaProperty; diff --git a/src/declarative/qml/qmlcompiledbindings.cpp b/src/declarative/qml/qmlcompiledbindings.cpp index b5fbab9..c9580c7 100644 --- a/src/declarative/qml/qmlcompiledbindings.cpp +++ b/src/declarative/qml/qmlcompiledbindings.cpp @@ -39,6 +39,8 @@ ** ****************************************************************************/ +// #define COMPILEDBINDINGS_DEBUG + #include "qmlcompiledbindings_p.h" #include @@ -275,6 +277,7 @@ void QmlCompiledBindingsPrivate::Binding::destroy() enabled = false; removeFromObject(); parent->q_func()->release(); + clear(); } int QmlCompiledBindings::qt_metacall(QMetaObject::Call c, int id, void **) @@ -975,6 +978,147 @@ static void throwException(int id, QmlDelayedError *error, qWarning() << error->error; } +static void dumpInstruction(const Instr *instr) +{ + switch (instr->common.type) { + case Instr::Noop: + qWarning().nospace() << "Noop"; + break; + case Instr::Subscribe: + qWarning().nospace() << "Subscribe" << "\t\t" << instr->subscribe.offset << "\t" << instr->subscribe.reg << "\t" << instr->subscribe.index; + break; + case Instr::SubscribeId: + qWarning().nospace() << "SubscribeId" << "\t\t" << instr->subscribe.offset << "\t" << instr->subscribe.reg << "\t" << instr->subscribe.index; + break; + case Instr::LoadId: + qWarning().nospace() << "LoadId" << "\t\t\t" << instr->load.index << "\t" << instr->load.reg; + break; + case Instr::LoadScope: + qWarning().nospace() << "LoadScope" << "\t\t" << instr->load.index << "\t" << instr->load.reg; + break; + case Instr::LoadRoot: + qWarning().nospace() << "LoadRoot" << "\t\t" << instr->load.index << "\t" << instr->load.reg; + break; + case Instr::LoadAttached: + qWarning().nospace() << "LoadAttached" << "\t\t" << instr->attached.output << "\t" << instr->attached.reg << "\t" << instr->attached.index; + break; + case Instr::ConvertIntToReal: + qWarning().nospace() << "ConvertIntToReal" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; + break; + case Instr::ConvertRealToInt: + qWarning().nospace() << "ConvertRealToInt" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; + break; + case Instr::Real: + qWarning().nospace() << "Real" << "\t\t\t" << instr->real_value.reg << "\t" << instr->real_value.value; + break; + case Instr::Int: + qWarning().nospace() << "Int" << "\t\t\t" << instr->int_value.reg << "\t" << instr->int_value.value; + break; + case Instr::Bool: + qWarning().nospace() << "Bool" << "\t\t\t" << instr->bool_value.reg << "\t" << instr->bool_value.value; + break; + case Instr::String: + qWarning().nospace() << "String" << "\t\t\t" << instr->string_value.reg << "\t" << instr->string_value.offset << "\t" << instr->string_value.length; + break; + case Instr::AddReal: + qWarning().nospace() << "AddReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::AddInt: + qWarning().nospace() << "AddInt" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::AddString: + qWarning().nospace() << "AddString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::MinusReal: + qWarning().nospace() << "MinusReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::MinusInt: + qWarning().nospace() << "MinusInt" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::CompareReal: + qWarning().nospace() << "CompareReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::CompareString: + qWarning().nospace() << "CompareString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::NotCompareReal: + qWarning().nospace() << "NotCompareReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::NotCompareString: + qWarning().nospace() << "NotCompareString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::GreaterThanReal: + qWarning().nospace() << "GreaterThanReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::MaxReal: + qWarning().nospace() << "MaxReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::MinReal: + qWarning().nospace() << "MinReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; + break; + case Instr::NewString: + qWarning().nospace() << "NewString" << "\t\t" << instr->construct.reg; + break; + case Instr::NewUrl: + qWarning().nospace() << "NewUrl" << "\t\t\t" << instr->construct.reg; + break; + case Instr::CleanupString: + qWarning().nospace() << "CleanupString" << "\t\t" << instr->cleanup.reg; + break; + case Instr::CleanupUrl: + qWarning().nospace() << "CleanupUrl" << "\t\t" << instr->cleanup.reg; + break; + case Instr::Fetch: + qWarning().nospace() << "Fetch" << "\t\t\t" << instr->fetch.output << "\t" << instr->fetch.index << "\t" << instr->fetch.objectReg; + break; + case Instr::Store: + qWarning().nospace() << "Store" << "\t\t\t" << instr->store.output << "\t" << instr->store.index << "\t" << instr->store.reg; + break; + case Instr::Copy: + qWarning().nospace() << "Copy" << "\t\t\t" << instr->copy.reg << "\t" << instr->copy.src; + break; + case Instr::Skip: + qWarning().nospace() << "Skip" << "\t\t\t" << instr->skip.reg << "\t" << instr->skip.count; + break; + case Instr::Done: + qWarning().nospace() << "Done"; + break; + case Instr::InitString: + qWarning().nospace() << "InitString" << "\t\t" << instr->initstring.offset << "\t" << instr->initstring.dataIdx; + break; + case Instr::FindGeneric: + qWarning().nospace() << "FindGeneric" << "\t\t" << instr->find.reg << "\t" << instr->find.name; + break; + case Instr::FindGenericTerminal: + qWarning().nospace() << "FindGenericTerminal" << "\t" << instr->find.reg << "\t" << instr->find.name; + break; + case Instr::FindProperty: + qWarning().nospace() << "FindProperty" << "\t\t" << instr->find.reg << "\t" << instr->find.src << "\t" << instr->find.name; + break; + case Instr::FindPropertyTerminal: + qWarning().nospace() << "FindPropertyTerminal" << "\t" << instr->find.reg << "\t" << instr->find.src << "\t" << instr->find.name; + break; + case Instr::CleanupGeneric: + qWarning().nospace() << "CleanupGeneric" << "\t\t" << instr->cleanup.reg; + break; + case Instr::ConvertGenericToReal: + qWarning().nospace() << "ConvertGenericToReal" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; + break; + case Instr::ConvertGenericToBool: + qWarning().nospace() << "ConvertGenericToBool" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; + break; + case Instr::ConvertGenericToString: + qWarning().nospace() << "ConvertGenericToString" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; + break; + case Instr::ConvertGenericToUrl: + qWarning().nospace() << "ConvertGenericToUrl" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; + break; + default: + qWarning().nospace() << "Unknown"; + break; + } +} + void QmlCompiledBindingsPrivate::run(int instrIndex, QmlContextPrivate *context, QmlDelayedError *error, QObject *scope, QObject *output) @@ -990,7 +1134,14 @@ void QmlCompiledBindingsPrivate::run(int instrIndex, instr += instrIndex; const char *data = program->data(); +#ifdef COMPILEDBINDINGS_DEBUG + qWarning().nospace() << "Begin binding run"; +#endif + while (instr) { +#ifdef COMPILEDBINDINGS_DEBUG + dumpInstruction(instr); +#endif switch (instr->common.type) { case Instr::Noop: @@ -1403,144 +1554,7 @@ void QmlBindingCompiler::dump(const QByteArray &programData) while (count--) { - switch (instr->common.type) { - case Instr::Noop: - qWarning().nospace() << "Noop"; - break; - case Instr::Subscribe: - qWarning().nospace() << "Subscribe" << "\t\t" << instr->subscribe.offset << "\t" << instr->subscribe.reg << "\t" << instr->subscribe.index; - break; - case Instr::SubscribeId: - qWarning().nospace() << "SubscribeId" << "\t\t" << instr->subscribe.offset << "\t" << instr->subscribe.reg << "\t" << instr->subscribe.index; - break; - case Instr::LoadId: - qWarning().nospace() << "LoadId" << "\t\t\t" << instr->load.index << "\t" << instr->load.reg; - break; - case Instr::LoadScope: - qWarning().nospace() << "LoadScope" << "\t\t" << instr->load.index << "\t" << instr->load.reg; - break; - case Instr::LoadRoot: - qWarning().nospace() << "LoadRoot" << "\t\t" << instr->load.index << "\t" << instr->load.reg; - break; - case Instr::LoadAttached: - qWarning().nospace() << "LoadAttached" << "\t\t" << instr->attached.output << "\t" << instr->attached.reg << "\t" << instr->attached.index; - break; - case Instr::ConvertIntToReal: - qWarning().nospace() << "ConvertIntToReal" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; - break; - case Instr::ConvertRealToInt: - qWarning().nospace() << "ConvertRealToInt" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; - break; - case Instr::Real: - qWarning().nospace() << "Real" << "\t\t\t" << instr->real_value.reg << "\t" << instr->real_value.value; - break; - case Instr::Int: - qWarning().nospace() << "Int" << "\t\t\t" << instr->int_value.reg << "\t" << instr->int_value.value; - break; - case Instr::Bool: - qWarning().nospace() << "Bool" << "\t\t\t" << instr->bool_value.reg << "\t" << instr->bool_value.value; - break; - case Instr::String: - qWarning().nospace() << "String" << "\t\t\t" << instr->string_value.reg << "\t" << instr->string_value.offset << "\t" << instr->string_value.length; - break; - case Instr::AddReal: - qWarning().nospace() << "AddReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::AddInt: - qWarning().nospace() << "AddInt" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::AddString: - qWarning().nospace() << "AddString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::MinusReal: - qWarning().nospace() << "MinusReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::MinusInt: - qWarning().nospace() << "MinusInt" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::CompareReal: - qWarning().nospace() << "CompareReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::CompareString: - qWarning().nospace() << "CompareString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::NotCompareReal: - qWarning().nospace() << "NotCompareReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::NotCompareString: - qWarning().nospace() << "NotCompareString" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::GreaterThanReal: - qWarning().nospace() << "GreaterThanReal" << "\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::MaxReal: - qWarning().nospace() << "MaxReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::MinReal: - qWarning().nospace() << "MinReal" << "\t\t\t" << instr->binaryop.output << "\t" << instr->binaryop.src1 << "\t" << instr->binaryop.src2; - break; - case Instr::NewString: - qWarning().nospace() << "NewString" << "\t\t" << instr->construct.reg; - break; - case Instr::NewUrl: - qWarning().nospace() << "NewUrl" << "\t\t\t" << instr->construct.reg; - break; - case Instr::CleanupString: - qWarning().nospace() << "CleanupString" << "\t\t" << instr->cleanup.reg; - break; - case Instr::CleanupUrl: - qWarning().nospace() << "CleanupUrl" << "\t\t" << instr->cleanup.reg; - break; - case Instr::Fetch: - qWarning().nospace() << "Fetch" << "\t\t\t" << instr->fetch.output << "\t" << instr->fetch.index << "\t" << instr->fetch.objectReg; - break; - case Instr::Store: - qWarning().nospace() << "Store" << "\t\t\t" << instr->store.output << "\t" << instr->store.index << "\t" << instr->store.reg; - break; - case Instr::Copy: - qWarning().nospace() << "Copy" << "\t\t\t" << instr->copy.reg << "\t" << instr->copy.src; - break; - case Instr::Skip: - qWarning().nospace() << "Skip" << "\t\t\t" << instr->skip.reg << "\t" << instr->skip.count; - break; - case Instr::Done: - qWarning().nospace() << "Done"; - break; - case Instr::InitString: - qWarning().nospace() << "InitString" << "\t\t" << instr->initstring.offset << "\t" << instr->initstring.dataIdx; - break; - case Instr::FindGeneric: - qWarning().nospace() << "FindGeneric" << "\t\t" << instr->find.reg << "\t" << instr->find.name; - break; - case Instr::FindGenericTerminal: - qWarning().nospace() << "FindGenericTerminal" << "\t" << instr->find.reg << "\t" << instr->find.name; - break; - case Instr::FindProperty: - qWarning().nospace() << "FindProperty" << "\t\t" << instr->find.reg << "\t" << instr->find.src << "\t" << instr->find.name; - break; - case Instr::FindPropertyTerminal: - qWarning().nospace() << "FindPropertyTerminal" << "\t" << instr->find.reg << "\t" << instr->find.src << "\t" << instr->find.name; - break; - case Instr::CleanupGeneric: - qWarning().nospace() << "CleanupGeneric" << "\t\t" << instr->cleanup.reg; - break; - case Instr::ConvertGenericToReal: - qWarning().nospace() << "ConvertGenericToReal" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; - break; - case Instr::ConvertGenericToBool: - qWarning().nospace() << "ConvertGenericToBool" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; - break; - case Instr::ConvertGenericToString: - qWarning().nospace() << "ConvertGenericToString" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; - break; - case Instr::ConvertGenericToUrl: - qWarning().nospace() << "ConvertGenericToUrl" << "\t" << instr->unaryop.output << "\t" << instr->unaryop.src; - break; - default: - qWarning().nospace() << "Unknown"; - break; - } - + dumpInstruction(instr); ++instr; } } @@ -1585,6 +1599,9 @@ bool QmlBindingCompilerPrivate::compile(QmlJS::AST::Node *node) { resetInstanceState(); + if (destination->type == -1) + return false; + Result type; if (!parseExpression(node, type)) -- cgit v0.12 From 1f5170e7556a590eaa6581cf212775208620f934 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 16 Feb 2010 13:33:41 +1000 Subject: QML binding optimizer crash We should check that the fetch() generation succeeded before continuing. --- src/declarative/qml/qmlcompiledbindings.cpp | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/src/declarative/qml/qmlcompiledbindings.cpp b/src/declarative/qml/qmlcompiledbindings.cpp index c9580c7..bc62d9a 100644 --- a/src/declarative/qml/qmlcompiledbindings.cpp +++ b/src/declarative/qml/qmlcompiledbindings.cpp @@ -1881,7 +1881,8 @@ bool QmlBindingCompilerPrivate::parseName(AST::Node *node, Result &type) subscribeName << contextName(); subscribeName << name; - fetch(type, context->metaObject(), reg, d0Idx, subscribeName, nameNodes.at(ii)); + if (!fetch(type, context->metaObject(), reg, d0Idx, subscribeName, nameNodes.at(ii))) + return false; } else if(d1Idx != -1) { Instr instr; instr.common.type = Instr::LoadRoot; @@ -1892,7 +1893,8 @@ bool QmlBindingCompilerPrivate::parseName(AST::Node *node, Result &type) subscribeName << QLatin1String("$$$ROOT"); subscribeName << name; - fetch(type, component->metaObject(), reg, d1Idx, subscribeName, nameNodes.at(ii)); + if (!fetch(type, component->metaObject(), reg, d1Idx, subscribeName, nameNodes.at(ii))) + return false; } else { Instr find; if (nameParts.count() == 1) @@ -1952,8 +1954,7 @@ bool QmlBindingCompilerPrivate::parseName(AST::Node *node, Result &type) if (absType || (wasAttachedObject && idx != -1) || (mo && mo->property(idx).isFinal())) { absType = 0; - fetch(type, mo, reg, idx, subscribeName, nameNodes.at(ii)); - if (type.type == -1) + if (!fetch(type, mo, reg, idx, subscribeName, nameNodes.at(ii))) return false; } else { -- cgit v0.12 From 2ad3954c6a383553f000d5d223eff4acf34d3c77 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 16 Feb 2010 13:47:06 +1000 Subject: QML binding optimizer crash The context's id values must be deleted after the compiled bindings as they may access the id values during shutdown. --- src/declarative/qml/qmlcontext.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/declarative/qml/qmlcontext.cpp b/src/declarative/qml/qmlcontext.cpp index d9fc76b..3c419b6 100644 --- a/src/declarative/qml/qmlcontext.cpp +++ b/src/declarative/qml/qmlcontext.cpp @@ -300,8 +300,6 @@ QmlContext::~QmlContext() co->prevContextObject = 0; } - delete [] d->idValues; - if (d->propertyNames) d->propertyNames->release(); @@ -310,6 +308,8 @@ QmlContext::~QmlContext() if (d->optimizedBindings) d->optimizedBindings->release(); + + delete [] d->idValues; } void QmlContextPrivate::invalidateEngines() -- cgit v0.12 From c37fbe0cbe0ccc0e5991df921aa0c7cf811a3baf Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 16 Feb 2010 13:49:15 +1000 Subject: Fix crash in QmlMetaProperty that could occur when using value-type properties after the engine was deleted. --- src/declarative/qml/qmlengine_p.h | 1 + src/declarative/qml/qmlmetaproperty.cpp | 7 +++-- .../qmlmetaproperty/tst_qmlmetaproperty.cpp | 30 ++++++++++++++++++++++ 3 files changed, 34 insertions(+), 4 deletions(-) diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index 87864b7..5586311 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -316,6 +316,7 @@ public: static QScriptEngine *getScriptEngine(QmlEngine *e) { return &e->d_func()->scriptEngine; } static QmlEngine *getEngine(QScriptEngine *e) { return static_cast(e)->p->q_func(); } static QmlEnginePrivate *get(QmlEngine *e) { return e->d_func(); } + static QmlEnginePrivate *get(QmlContext *c) { return (c && c->engine()) ? QmlEnginePrivate::get(c->engine()) : 0; } static QmlEnginePrivate *get(QScriptEngine *e) { return static_cast(e)->p; } static QmlEngine *get(QmlEnginePrivate *p) { return p->q_func(); } QmlContext *getContext(QScriptContext *); diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index d63261c..70f9ad3 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -276,7 +276,7 @@ const char *QmlMetaProperty::propertyTypeName() const { if (type() & ValueTypeProperty) { - QmlEnginePrivate *ep = d->context?QmlEnginePrivate::get(d->context->engine()):0; + QmlEnginePrivate *ep = QmlEnginePrivate::get(d->context); QmlValueType *valueType = 0; if (ep) valueType = ep->valueTypes[d->core.propType]; else valueType = QmlValueTypeFactory::valueType(d->core.propType); @@ -689,7 +689,7 @@ QVariant QmlMetaPropertyPrivate::readValueProperty() } else if(type & QmlMetaProperty::ValueTypeProperty) { - QmlEnginePrivate *ep = context?QmlEnginePrivate::get(context->engine()):0; + QmlEnginePrivate *ep = QmlEnginePrivate::get(context); QmlValueType *valueType = 0; if (ep) valueType = ep->valueTypes[core.propType]; else valueType = QmlValueTypeFactory::valueType(core.propType); @@ -762,8 +762,7 @@ bool QmlMetaPropertyPrivate::writeValueProperty(const QVariant &value, bool rv = false; uint type = q->type(); if (type & QmlMetaProperty::ValueTypeProperty) { - QmlEnginePrivate *ep = - context?static_cast(QObjectPrivate::get(context->engine())):0; + QmlEnginePrivate *ep = QmlEnginePrivate::get(context); QmlValueType *writeBack = 0; if (ep) { diff --git a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp index ec6b87f..5c8178f 100644 --- a/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp +++ b/tests/auto/declarative/qmlmetaproperty/tst_qmlmetaproperty.cpp @@ -122,6 +122,9 @@ private slots: //writeToReadOnly(); + // Bugs + void crashOnValueProperty(); + private: QmlEngine engine; }; @@ -208,6 +211,9 @@ private: QUrl m_url; }; +QML_DECLARE_TYPE(PropertyObject); +QML_DEFINE_TYPE(Test,1,0,PropertyObject,PropertyObject); + void tst_qmlmetaproperty::qmlmetaproperty_object() { QObject object; // Has no default property @@ -1118,6 +1124,30 @@ void tst_qmlmetaproperty::writeObjectToQmlList() QCOMPARE(container->qmlChildren()->at(1), object); } +void tst_qmlmetaproperty::crashOnValueProperty() +{ + QmlEngine *engine = new QmlEngine; + QmlComponent component(engine); + + component.setData("import Test 1.0\nPropertyObject { wrectProperty.x: 10 }", QUrl()); + PropertyObject *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + + QmlMetaProperty p = QmlMetaProperty::createProperty(obj, "wrectProperty.x", qmlContext(obj)); + QCOMPARE(p.name(), QString("wrectProperty.x")); + + QCOMPARE(p.read(), QVariant(10)); + + //don't crash once the engine is deleted + delete engine; + engine = 0; + + QCOMPARE(p.propertyTypeName(), "int"); + QCOMPARE(p.read(), QVariant(10)); + p.write(QVariant(20)); + QCOMPARE(p.read(), QVariant(20)); +} + QTEST_MAIN(tst_qmlmetaproperty) #include "tst_qmlmetaproperty.moc" -- cgit v0.12 From 37fc9b6c3e10bb708d6c294ac37693b6df1d5351 Mon Sep 17 00:00:00 2001 From: Wolfgang Beck Date: Tue, 16 Feb 2010 14:53:33 +1000 Subject: Mobility 404 --- configure.exe | Bin 1180160 -> 1179136 bytes src/declarative/qml/qmlguard_p.h | 4 ++-- tools/configure/configureapp.cpp | 4 ++++ 3 files changed, 6 insertions(+), 2 deletions(-) diff --git a/configure.exe b/configure.exe index 8913de1..980c190 100644 Binary files a/configure.exe and b/configure.exe differ diff --git a/src/declarative/qml/qmlguard_p.h b/src/declarative/qml/qmlguard_p.h index 1e55bcb..ad8dd84 100644 --- a/src/declarative/qml/qmlguard_p.h +++ b/src/declarative/qml/qmlguard_p.h @@ -94,10 +94,10 @@ private: inline void remGuard(); }; -Q_DECLARE_METATYPE(QmlGuard); - QT_END_NAMESPACE +Q_DECLARE_METATYPE(QmlGuard); + #include "qmldeclarativedata_p.h" QT_BEGIN_NAMESPACE diff --git a/tools/configure/configureapp.cpp b/tools/configure/configureapp.cpp index 7154fd4..77b2f66 100644 --- a/tools/configure/configureapp.cpp +++ b/tools/configure/configureapp.cpp @@ -961,6 +961,7 @@ void Configure::parseCmdLine() if(i==argCount) break; qmakeDefines += "QT_NAMESPACE="+configCmdLine.at(i); + dictionary[ "QT_NAMESPACE" ] = configCmdLine.at(i); } else if( configCmdLine.at(i) == "-qtlibinfix" ) { ++i; if(i==argCount) @@ -2792,6 +2793,9 @@ void Configure::generateCachefile() if(!dictionary["ARM_FPU_TYPE"].isEmpty()) { configStream<<"MMP_RULES += \"ARMFPU "<< dictionary["ARM_FPU_TYPE"]<< "\""; } + if (!dictionary["QT_NAMESPACE"].isEmpty()) { + configStream << "#namespaces" << endl << "QT_NAMESPACE = " << dictionary["QT_NAMESPACE"] << endl; + } configStream.flush(); configFile.close(); -- cgit v0.12 From a601e6d71c8f6ae76b8ab820e6a49e29f3a7ba8d Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Tue, 16 Feb 2010 15:32:08 +1000 Subject: Remove standalone QmlDebugger. It is now only available through the plugin in the Creator repo. --- tools/qmldebugger/qmldebugger.pro | 5 - tools/qmldebugger/standalone/canvasframerate.cpp | 581 --------------------- tools/qmldebugger/standalone/canvasframerate.h | 91 ---- tools/qmldebugger/standalone/engine.cpp | 219 -------- tools/qmldebugger/standalone/engine.h | 101 ---- tools/qmldebugger/standalone/engine.png | Bin 6394 -> 0 bytes tools/qmldebugger/standalone/engines.qml | 46 -- .../standalone/expressionquerywidget.cpp | 280 ---------- .../qmldebugger/standalone/expressionquerywidget.h | 105 ---- tools/qmldebugger/standalone/main.cpp | 79 --- .../standalone/objectpropertiesview.cpp | 274 ---------- .../qmldebugger/standalone/objectpropertiesview.h | 93 ---- tools/qmldebugger/standalone/objecttree.cpp | 235 --------- tools/qmldebugger/standalone/objecttree.h | 96 ---- tools/qmldebugger/standalone/qmldebugger.cpp | 185 ------- tools/qmldebugger/standalone/qmldebugger.h | 94 ---- tools/qmldebugger/standalone/qmldebugger.pri | 18 - tools/qmldebugger/standalone/qmldebugger.qrc | 7 - tools/qmldebugger/standalone/refresh.png | Bin 6169 -> 0 bytes tools/qmldebugger/standalone/standalone.pro | 19 - tools/qmldebugger/standalone/watchtable.cpp | 366 ------------- tools/qmldebugger/standalone/watchtable.h | 154 ------ tools/tools.pro | 2 +- 23 files changed, 1 insertion(+), 3049 deletions(-) delete mode 100644 tools/qmldebugger/qmldebugger.pro delete mode 100644 tools/qmldebugger/standalone/canvasframerate.cpp delete mode 100644 tools/qmldebugger/standalone/canvasframerate.h delete mode 100644 tools/qmldebugger/standalone/engine.cpp delete mode 100644 tools/qmldebugger/standalone/engine.h delete mode 100644 tools/qmldebugger/standalone/engine.png delete mode 100644 tools/qmldebugger/standalone/engines.qml delete mode 100644 tools/qmldebugger/standalone/expressionquerywidget.cpp delete mode 100644 tools/qmldebugger/standalone/expressionquerywidget.h delete mode 100644 tools/qmldebugger/standalone/main.cpp delete mode 100644 tools/qmldebugger/standalone/objectpropertiesview.cpp delete mode 100644 tools/qmldebugger/standalone/objectpropertiesview.h delete mode 100644 tools/qmldebugger/standalone/objecttree.cpp delete mode 100644 tools/qmldebugger/standalone/objecttree.h delete mode 100644 tools/qmldebugger/standalone/qmldebugger.cpp delete mode 100644 tools/qmldebugger/standalone/qmldebugger.h delete mode 100644 tools/qmldebugger/standalone/qmldebugger.pri delete mode 100644 tools/qmldebugger/standalone/qmldebugger.qrc delete mode 100644 tools/qmldebugger/standalone/refresh.png delete mode 100644 tools/qmldebugger/standalone/standalone.pro delete mode 100644 tools/qmldebugger/standalone/watchtable.cpp delete mode 100644 tools/qmldebugger/standalone/watchtable.h diff --git a/tools/qmldebugger/qmldebugger.pro b/tools/qmldebugger/qmldebugger.pro deleted file mode 100644 index 679cae6..0000000 --- a/tools/qmldebugger/qmldebugger.pro +++ /dev/null @@ -1,5 +0,0 @@ -TEMPLATE = subdirs -CONFIG += ordered - -SUBDIRS = standalone - diff --git a/tools/qmldebugger/standalone/canvasframerate.cpp b/tools/qmldebugger/standalone/canvasframerate.cpp deleted file mode 100644 index d956029..0000000 --- a/tools/qmldebugger/standalone/canvasframerate.cpp +++ /dev/null @@ -1,581 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger 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$ -** -****************************************************************************/ -#include -#include -#include -#include - -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include -#include - -#include -#include - -#include -#include "canvasframerate.h" - -QT_BEGIN_NAMESPACE - -class QLineGraph : public QWidget -{ -Q_OBJECT -public: - QLineGraph(QAbstractSlider *slider, QWidget * = 0); - - void setPosition(int); - -public slots: - void addSample(int, int, int, bool); - void setResolutionForHeight(int); - void clear(); - -protected: - virtual void paintEvent(QPaintEvent *); - virtual void mouseMoveEvent(QMouseEvent *); - virtual void leaveEvent(QEvent *); - virtual void wheelEvent(QWheelEvent *event); - -private slots: - void sliderChanged(int); - -private: - void updateSlider(); - void drawSample(QPainter *, int, const QRect &, QList *); - void drawTime(QPainter *, const QRect &); - QRect findContainingRect(const QList &rects, const QPoint &pos) const; - struct Sample { - int sample[3]; - bool isBreak; - }; - QList _samples; - - QAbstractSlider *slider; - int position; - int samplesPerWidth; - int resolutionForHeight; - bool ignoreScroll; - QMargins graphMargins; - - QList rectsPaintTime; // time to do a paintEvent() - QList rectsTimeBetween; // time between frames - QRect highlightedBar; -}; - -QLineGraph::QLineGraph(QAbstractSlider *slider, QWidget *parent) -: QWidget(parent), slider(slider), position(-1), samplesPerWidth(99), resolutionForHeight(50), - ignoreScroll(false), graphMargins(65, 10, 71, 35) -{ - setMouseTracking(true); - - slider->setMaximum(0); - slider->setMinimum(0); - slider->setSingleStep(1); - - connect(slider, SIGNAL(valueChanged(int)), this, SLOT(sliderChanged(int))); -} - -void QLineGraph::sliderChanged(int v) -{ - if(ignoreScroll) - return; - - if (v == slider->maximum()) - position = -1; - else - position = v; - - update(); - - // update highlightedRect - QPoint pos = mapFromGlobal(QCursor::pos()); - if (geometry().contains(pos)) { - QMouseEvent *me = new QMouseEvent(QEvent::MouseMove, pos, - Qt::NoButton, Qt::NoButton, Qt::NoModifier); - QApplication::postEvent(this, me); - } -} - -void QLineGraph::clear() -{ - _samples.clear(); - rectsPaintTime.clear(); - rectsTimeBetween.clear(); - highlightedBar = QRect(); - position = -1; - - updateSlider(); - update(); -} - -void QLineGraph::updateSlider() -{ - ignoreScroll = true; - slider->setMaximum(qMax(0, _samples.count() - samplesPerWidth - 1)); - - if(position == -1) { - slider->setValue(slider->maximum()); - } else { - slider->setValue(position); - } - ignoreScroll = false; -} - -void QLineGraph::addSample(int a, int b, int d, bool isBreak) -{ - Sample s; - s.isBreak = isBreak; - s.sample[0] = a; - s.sample[1] = b; - s.sample[2] = d; - _samples << s; - updateSlider(); - update(); -} - -void QLineGraph::setPosition(int p) -{ - sliderChanged(p); -} - -void QLineGraph::drawTime(QPainter *p, const QRect &rect) -{ - if(_samples.isEmpty()) - return; - - int first = position; - if(first == -1) - first = qMax(0, _samples.count() - samplesPerWidth - 1); - int last = qMin(_samples.count() - 1, first + samplesPerWidth); - - qreal scaleX = qreal(rect.width()) / qreal(samplesPerWidth); - - int t = 0; - - for(int ii = first; ii <= last; ++ii) { - int sampleTime = _samples.at(ii).sample[2] / 1000; - if(sampleTime != t) { - - int xEnd = rect.left() + scaleX * (ii - first); - p->drawLine(xEnd, rect.bottom(), xEnd, rect.bottom() + 7); - - QRect text(xEnd - 30, rect.bottom() + 10, 60, 30); - - p->drawText(text, Qt::AlignHCenter | Qt::AlignTop, QString::number(_samples.at(ii).sample[2])); - - t = sampleTime; - } - } - -} - -void QLineGraph::drawSample(QPainter *p, int s, const QRect &rect, QList *record) -{ - if(_samples.isEmpty()) - return; - - int first = position; - if(first == -1) - first = qMax(0, _samples.count() - samplesPerWidth - 1); - int last = qMin(_samples.count() - 1, first + samplesPerWidth); - - qreal scaleY = qreal(rect.height()) / resolutionForHeight; - qreal scaleX = qreal(rect.width()) / qreal(samplesPerWidth); - - int xEnd; - int lastXEnd = rect.left(); - - p->save(); - p->setPen(Qt::NoPen); - for(int ii = first + 1; ii <= last; ++ii) { - - xEnd = rect.left() + scaleX * (ii - first); - int yEnd = rect.bottom() - _samples.at(ii).sample[s] * scaleY; - - if (!(s == 0 && _samples.at(ii).isBreak)) { - QRect bar(lastXEnd, yEnd, scaleX, _samples.at(ii).sample[s] * scaleY); - record->append(bar); - p->drawRect(bar); - } - - lastXEnd = xEnd; - } - p->restore(); -} - -void QLineGraph::paintEvent(QPaintEvent *) -{ - QPainter p(this); - p.setRenderHint(QPainter::Antialiasing); - - QRect r(graphMargins.left(), graphMargins.top(), - width() - graphMargins.right(), height() - graphMargins.bottom()); - - p.save(); - p.rotate(-90); - p.translate(-r.height()/2 - r.width()/2 - graphMargins.right(), -r.height()/2); - p.drawText(r, Qt::AlignCenter, tr("Frame rate")); - p.restore(); - - p.setBrush(QColor("lightsteelblue")); - rectsTimeBetween.clear(); - drawSample(&p, 0, r, &rectsTimeBetween); - - p.setBrush(QColor("pink")); - rectsPaintTime.clear(); - drawSample(&p, 1, r, &rectsPaintTime); - - if (!highlightedBar.isNull()) { - p.setBrush(Qt::darkGreen); - p.drawRect(highlightedBar); - } - - p.setBrush(Qt::NoBrush); - p.drawRect(r); - - slider->setGeometry(x() + r.x(), slider->y(), r.width(), slider->height()); - - for(int ii = 0; ii <= resolutionForHeight; ++ii) { - int y = 1 + r.bottom() - ii * r.height() / resolutionForHeight; - - if((ii % 10) == 0) { - p.drawLine(r.left() - 20, y, r.left(), y); - QRect text(r.left() - 20 - 53, y - 10, 50, 20); - p.drawText(text, Qt::AlignRight | Qt::AlignVCenter, QString::number(ii)); - } else { - p.drawLine(r.left() - 7, y, r.left(), y); - } - } - - drawTime(&p, r); -} - -void QLineGraph::mouseMoveEvent(QMouseEvent *event) -{ - QPoint pos = event->pos(); - - QRect rect = findContainingRect(rectsPaintTime, pos); - if (rect.isNull()) - rect = findContainingRect(rectsTimeBetween, pos); - - if (!highlightedBar.isNull()) - update(highlightedBar.adjusted(-1, -1, 1, 1)); - highlightedBar = rect; - - if (!rect.isNull()) { - QRect graph(graphMargins.left(), graphMargins.top(), - width() - graphMargins.right(), height() - graphMargins.bottom()); - qreal scaleY = qreal(graph.height()) / resolutionForHeight; - QToolTip::showText(event->globalPos(), QString::number(qRound(rect.height() / scaleY)), this, rect); - update(rect.adjusted(-1, -1, 1, 1)); - } -} - -void QLineGraph::leaveEvent(QEvent *) -{ - if (!highlightedBar.isNull()) { - QRect bar = highlightedBar.adjusted(-1, -1, 1, 1); - highlightedBar = QRect(); - update(bar); - } -} - -void QLineGraph::wheelEvent(QWheelEvent *event) -{ - QWheelEvent we(QPoint(0,0), event->delta(), event->buttons(), event->modifiers(), event->orientation()); - QApplication::sendEvent(slider, &we); -} - -void QLineGraph::setResolutionForHeight(int resolution) -{ - resolutionForHeight = resolution; - update(); -} - -QRect QLineGraph::findContainingRect(const QList &rects, const QPoint &pos) const -{ - for (int i=0; isetFocusPolicy(Qt::WheelFocus); - m_graph = new QLineGraph(scroll); - - setFocusPolicy(Qt::WheelFocus); - setFocusProxy(scroll); - - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setContentsMargins(0, 0, 5, 0); - layout->setSpacing(0); - layout->addWidget(m_graph, 2); - layout->addWidget(new QLabel(tr("Total time elapsed (ms)")), 0, Qt::AlignHCenter); - layout->addWidget(scroll); -} - -void GraphWindow::addSample(int a, int b, int d, bool isBreak) -{ - m_graph->addSample(a, b, d, isBreak); -} - -void GraphWindow::setResolutionForHeight(int res) -{ - m_graph->setResolutionForHeight(res); -} - -void GraphWindow::clear() -{ - m_graph->clear(); -} - -QSize GraphWindow::sizeHint() const -{ - return QSize(400, 220); -} - - -class CanvasFrameRatePlugin : public QmlDebugClient -{ - Q_OBJECT -public: - CanvasFrameRatePlugin(QmlDebugConnection *client); - -signals: - void sample(int, int, int, bool); - -protected: - virtual void messageReceived(const QByteArray &); - -private: - int lb; - int ld; -}; - -CanvasFrameRatePlugin::CanvasFrameRatePlugin(QmlDebugConnection *client) -: QmlDebugClient(QLatin1String("CanvasFrameRate"), client), lb(-1) -{ -} - -void CanvasFrameRatePlugin::messageReceived(const QByteArray &data) -{ - QByteArray rwData = data; - QDataStream stream(&rwData, QIODevice::ReadOnly); - - int b; int c; int d; bool isBreak; - stream >> b >> c >> d >> isBreak; - - if (lb != -1) - emit sample(c, lb, ld, isBreak); - - lb = b; - ld = d; -} - -CanvasFrameRate::CanvasFrameRate(QWidget *parent) -: QWidget(parent), - m_plugin(0) -{ - m_tabs = new QTabWidget(this); - - QHBoxLayout *bottom = new QHBoxLayout; - bottom->setMargin(0); - bottom->setSpacing(10); - - m_res = new QSpinBox; - m_res->setRange(30, 200); - m_res->setValue(m_res->minimum()); - m_res->setSingleStep(10); - m_res->setSuffix(QLatin1String("ms")); - bottom->addWidget(new QLabel(tr("Resolution:"))); - bottom->addWidget(m_res); - - bottom->addStretch(); - - m_clearButton = new QPushButton(tr("Clear")); - connect(m_clearButton, SIGNAL(clicked()), SLOT(clearGraph())); - bottom->addWidget(m_clearButton); - - QPushButton *pb = new QPushButton(tr("New Graph"), this); - connect(pb, SIGNAL(clicked()), this, SLOT(newTab())); - bottom->addWidget(pb); - - m_group = new QGroupBox(tr("Enabled")); - m_group->setCheckable(true); - m_group->setChecked(false); - connect(m_group, SIGNAL(toggled(bool)), SLOT(enabledToggled(bool))); - - QVBoxLayout *groupLayout = new QVBoxLayout(m_group); - groupLayout->setContentsMargins(5, 0, 5, 0); - groupLayout->setSpacing(2); - groupLayout->addWidget(m_tabs); - groupLayout->addLayout(bottom); - - QVBoxLayout *layout = new QVBoxLayout; - layout->setContentsMargins(0, 10, 0, 0); - layout->setSpacing(0); - layout->addWidget(m_group); - setLayout(layout); -} - -void CanvasFrameRate::reset(QmlDebugConnection *conn) -{ - delete m_plugin; - m_plugin = 0; - - QWidget *w; - for (int i=0; icount(); i++) { - w = m_tabs->widget(i); - m_tabs->removeTab(i); - delete w; - } - - if (conn) { - connect(conn, SIGNAL(stateChanged(QAbstractSocket::SocketState)), - SLOT(connectionStateChanged(QAbstractSocket::SocketState))); - if (conn->state() == QAbstractSocket::ConnectedState) - handleConnected(conn); - } -} - -void CanvasFrameRate::connectionStateChanged(QAbstractSocket::SocketState state) -{ - if (state == QAbstractSocket::UnconnectedState) { - delete m_plugin; - m_plugin = 0; - } else if (state == QAbstractSocket::ConnectedState) { - handleConnected(qobject_cast(sender())); - } -} - -void CanvasFrameRate::handleConnected(QmlDebugConnection *conn) -{ - delete m_plugin; - m_plugin = new CanvasFrameRatePlugin(conn); - enabledToggled(m_group->isChecked()); - newTab(); -} - -void CanvasFrameRate::setSizeHint(const QSize &size) -{ - m_sizeHint = size; -} - -QSize CanvasFrameRate::sizeHint() const -{ - return m_sizeHint; -} - -void CanvasFrameRate::clearGraph() -{ - if (m_tabs->count()) { - GraphWindow *w = qobject_cast(m_tabs->currentWidget()); - if (w) - w->clear(); - } -} - -void CanvasFrameRate::newTab() -{ - if (!m_plugin) - return; - - if (m_tabs->count()) { - QWidget *w = m_tabs->widget(m_tabs->count() - 1); - QObject::disconnect(m_plugin, SIGNAL(sample(int,int,int,bool)), - w, SLOT(addSample(int,int,int,bool))); - } - - int count = m_tabs->count(); - - GraphWindow *graph = new GraphWindow; - graph->setResolutionForHeight(m_res->value()); - connect(m_plugin, SIGNAL(sample(int,int,int,bool)), - graph, SLOT(addSample(int,int,int,bool))); - connect(m_res, SIGNAL(valueChanged(int)), - graph, SLOT(setResolutionForHeight(int))); - - QString name = QLatin1String("Graph ") + QString::number(count + 1); - m_tabs->addTab(graph, name); - m_tabs->setCurrentIndex(count); -} - -void CanvasFrameRate::enabledToggled(bool checked) -{ - if (m_plugin) - static_cast(m_plugin)->setEnabled(checked); -} - -QT_END_NAMESPACE - -#include "canvasframerate.moc" diff --git a/tools/qmldebugger/standalone/canvasframerate.h b/tools/qmldebugger/standalone/canvasframerate.h deleted file mode 100644 index f8eec59..0000000 --- a/tools/qmldebugger/standalone/canvasframerate.h +++ /dev/null @@ -1,91 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger 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 CANVASFRAMERATE_H -#define CANVASFRAMERATE_H - -#include -#include - -#include - -QT_BEGIN_NAMESPACE - -class QTabWidget; -class QSlider; -class QGroupBox; -class QLabel; -class QSpinBox; -class QPushButton; - -class CanvasFrameRatePlugin; - -class CanvasFrameRate : public QWidget -{ - Q_OBJECT -public: - CanvasFrameRate(QWidget *parent = 0); - - void reset(QmlDebugConnection *conn); - - void setSizeHint(const QSize &); - virtual QSize sizeHint() const; - -private slots: - void clearGraph(); - void newTab(); - void enabledToggled(bool); - void connectionStateChanged(QAbstractSocket::SocketState state); - -private: - void handleConnected(QmlDebugConnection *conn); - - QGroupBox *m_group; - QTabWidget *m_tabs; - QSpinBox *m_res; - QPushButton *m_clearButton; - CanvasFrameRatePlugin *m_plugin; - QSize m_sizeHint; -}; - -QT_END_NAMESPACE - -#endif // CANVASFRAMERATE_H - diff --git a/tools/qmldebugger/standalone/engine.cpp b/tools/qmldebugger/standalone/engine.cpp deleted file mode 100644 index acd90f1..0000000 --- a/tools/qmldebugger/standalone/engine.cpp +++ /dev/null @@ -1,219 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger 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$ -** -****************************************************************************/ -#include -#include -#include -#include -#include - -#include -#include -#include -#include -#include - -#include "engine.h" -#include "objectpropertiesview.h" -#include "expressionquerywidget.h" -#include "objecttree.h" -#include "watchtable.h" - -QT_BEGIN_NAMESPACE - - -class DebuggerEngineItem : public QObject -{ - Q_OBJECT - Q_PROPERTY(QString name READ name CONSTANT); - Q_PROPERTY(int engineId READ engineId CONSTANT); - -public: - DebuggerEngineItem(const QString &name, int id) - : m_name(name), m_engineId(id) {} - - QString name() const { return m_name; } - int engineId() const { return m_engineId; } - -private: - QString m_name; - int m_engineId; -}; - -EnginePane::EnginePane(QmlDebugConnection *conn, QWidget *parent) -: QWidget(parent), m_client(new QmlEngineDebug(conn, this)), m_engines(0), m_context(0), m_watchTableModel(0), m_exprQueryWidget(0) -{ - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setContentsMargins(0, 0, 0, 0); - - QFile enginesFile(":/engines.qml"); - enginesFile.open(QFile::ReadOnly); - Q_ASSERT(enginesFile.isOpen()); - - m_engineView = new QmlView(this); - m_engineView->rootContext()->setContextProperty("engines", qVariantFromValue(&m_engineItems)); - m_engineView->setContentResizable(true); - m_engineView->setQml(enginesFile.readAll()); - m_engineView->execute(); - m_engineView->setFixedHeight(100); - QObject::connect(m_engineView->root(), SIGNAL(engineClicked(int)), - this, SLOT(engineSelected(int))); - QObject::connect(m_engineView->root(), SIGNAL(refreshEngines()), - this, SLOT(refreshEngines())); - - m_engineView->setVisible(false); - layout->addWidget(m_engineView); - - QSplitter *splitter = new QSplitter; - - m_objTree = new ObjectTree(m_client, this); - m_propertiesView = new ObjectPropertiesView(m_client); - m_watchTableModel = new WatchTableModel(m_client, this); - - m_watchTableView = new WatchTableView(m_watchTableModel); - m_watchTableView->setModel(m_watchTableModel); - WatchTableHeaderView *header = new WatchTableHeaderView(m_watchTableModel); - m_watchTableView->setHorizontalHeader(header); - - connect(m_objTree, SIGNAL(currentObjectChanged(QmlDebugObjectReference)), - m_propertiesView, SLOT(reload(QmlDebugObjectReference))); - connect(m_objTree, SIGNAL(expressionWatchRequested(QmlDebugObjectReference,QString)), - m_watchTableModel, SLOT(expressionWatchRequested(QmlDebugObjectReference,QString))); - - connect(m_propertiesView, SIGNAL(activated(QmlDebugObjectReference,QmlDebugPropertyReference)), - m_watchTableModel, SLOT(togglePropertyWatch(QmlDebugObjectReference,QmlDebugPropertyReference))); - - connect(m_watchTableModel, SIGNAL(watchCreated(QmlDebugWatch*)), - m_propertiesView, SLOT(watchCreated(QmlDebugWatch*))); - - connect(m_watchTableView, SIGNAL(objectActivated(int)), - m_objTree, SLOT(setCurrentObject(int))); - - m_exprQueryWidget = new ExpressionQueryWidget(ExpressionQueryWidget::SeparateEntryMode, m_client); - connect(m_objTree, SIGNAL(currentObjectChanged(QmlDebugObjectReference)), - m_exprQueryWidget, SLOT(setCurrentObject(QmlDebugObjectReference))); - - QSplitter *propertiesTab = new QSplitter(Qt::Vertical); - propertiesTab->addWidget(m_propertiesView); - propertiesTab->addWidget(m_exprQueryWidget); - propertiesTab->setStretchFactor(0, 2); - propertiesTab->setStretchFactor(1, 1); - - m_tabs = new QTabWidget(this); - m_tabs->addTab(propertiesTab, tr("Properties")); - m_tabs->addTab(m_watchTableView, tr("Watched")); - - splitter->addWidget(m_objTree); - splitter->addWidget(m_tabs); - splitter->setStretchFactor(1, 2); - layout->addWidget(splitter); -} - -void EnginePane::engineSelected(int id) -{ - qWarning() << "Engine selected" << id; - queryContext(id); -} - -void EnginePane::queryContext(int id) -{ - if (m_context) { - delete m_context; - m_context = 0; - } - - m_context = m_client->queryRootContexts(QmlDebugEngineReference(id), this); - if (!m_context->isWaiting()) - contextChanged(); - else - QObject::connect(m_context, SIGNAL(stateChanged(QmlDebugQuery::State)), - this, SLOT(contextChanged())); -} - -void EnginePane::contextChanged() -{ - //dump(m_context->rootContext(), 0); - - foreach (const QmlDebugObjectReference &object, m_context->rootContext().objects()) - m_objTree->reload(object.debugId()); - - delete m_context; m_context = 0; -} - -void EnginePane::refreshEngines() -{ - if (m_engines) - return; - - m_engines = m_client->queryAvailableEngines(this); - if (!m_engines->isWaiting()) - enginesChanged(); - else - QObject::connect(m_engines, SIGNAL(stateChanged(QmlDebugQuery::State)), - this, SLOT(enginesChanged())); -} - -void EnginePane::enginesChanged() -{ - qDeleteAll(m_engineItems); - m_engineItems.clear(); - - QList engines = m_engines->engines(); - delete m_engines; m_engines = 0; - - if (engines.isEmpty()) - qWarning("qmldebugger: no engines found!"); - - for (int ii = 0; ii < engines.count(); ++ii) - m_engineItems << new DebuggerEngineItem(engines.at(ii).name(), - engines.at(ii).debugId()); - - m_engineView->rootContext()->setContextProperty("engines", qVariantFromValue(&m_engineItems)); - - m_engineView->setVisible(m_engineItems.count() > 1); - if (m_engineItems.count() == 1) - engineSelected(qobject_cast(m_engineItems.at(0))->engineId()); -} - -QT_END_NAMESPACE - -#include "engine.moc" - - diff --git a/tools/qmldebugger/standalone/engine.h b/tools/qmldebugger/standalone/engine.h deleted file mode 100644 index f4c4275..0000000 --- a/tools/qmldebugger/standalone/engine.h +++ /dev/null @@ -1,101 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger 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 ENGINE_H -#define ENGINE_H - -#include -#include -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class ObjectPropertiesView; -class QmlDebugConnection; -class QmlDebugPropertyReference; -class QmlDebugWatch; -class ObjectTree; -class WatchTableModel; -class WatchTableView; -class ExpressionQueryWidget; - -class QTabWidget; - -class EnginePane : public QWidget -{ -Q_OBJECT -public: - EnginePane(QmlDebugConnection *, QWidget *parent = 0); - -public slots: - void refreshEngines(); - -private slots: - void enginesChanged(); - - void queryContext(int); - void contextChanged(); - - void engineSelected(int); - -private: - QmlEngineDebug *m_client; - QmlDebugEnginesQuery *m_engines; - QmlDebugRootContextQuery *m_context; - - ObjectTree *m_objTree; - QTabWidget *m_tabs; - WatchTableView *m_watchTableView; - WatchTableModel *m_watchTableModel; - ExpressionQueryWidget *m_exprQueryWidget; - - QmlView *m_engineView; - QList m_engineItems; - - ObjectPropertiesView *m_propertiesView; -}; - -QT_END_NAMESPACE - -#endif // ENGINE_H - diff --git a/tools/qmldebugger/standalone/engine.png b/tools/qmldebugger/standalone/engine.png deleted file mode 100644 index a0a8a04..0000000 Binary files a/tools/qmldebugger/standalone/engine.png and /dev/null differ diff --git a/tools/qmldebugger/standalone/engines.qml b/tools/qmldebugger/standalone/engines.qml deleted file mode 100644 index 0b2b7ac..0000000 --- a/tools/qmldebugger/standalone/engines.qml +++ /dev/null @@ -1,46 +0,0 @@ -import Qt 4.6 - -Item { - height: 100 - id: root - signal engineClicked(int id) - signal refreshEngines() - - Row { - anchors.fill: parent - Repeater { - model: engines - Item { - width: 100; height: 100; - Image { - id: engineIcon; - source: "qrc:/engine.png" - anchors.horizontalCenter: parent.horizontalCenter - } - Text { - anchors.top: engineIcon.bottom; - text: modelData.name + "(" + modelData.engineId + ")" - anchors.horizontalCenter: parent.horizontalCenter - } - MouseRegion { - anchors.fill: parent - onClicked: root.engineClicked(modelData.engineId); - } - } - } - } - - - Image { - y: 15 - source: "qrc:/refresh.png"; - width: 75; - height: 63; - smooth: true - anchors.right: parent.right - MouseRegion { - anchors.fill: parent - onClicked: root.refreshEngines() - } - } -} diff --git a/tools/qmldebugger/standalone/expressionquerywidget.cpp b/tools/qmldebugger/standalone/expressionquerywidget.cpp deleted file mode 100644 index 4fea41f..0000000 --- a/tools/qmldebugger/standalone/expressionquerywidget.cpp +++ /dev/null @@ -1,280 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger 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$ -** -****************************************************************************/ -#include - -#include -#include -#include -#include -#include -#include -#include -#include - -#include "expressionquerywidget.h" - -QT_BEGIN_NAMESPACE - -ExpressionQueryWidget::ExpressionQueryWidget(Mode mode, QmlEngineDebug *client, QWidget *parent) - : QWidget(parent), - m_mode(mode), - m_client(client), - m_query(0), - m_textEdit(new QTextEdit), - m_lineEdit(0) -{ - m_prompt = QLatin1String(">> "); - - QVBoxLayout *layout = new QVBoxLayout(this); - layout->setMargin(0); - layout->setSpacing(0); - layout->addWidget(m_textEdit); - - updateTitle(); - - if (m_mode == SeparateEntryMode) { - m_lineEdit = new QLineEdit; - connect(m_lineEdit, SIGNAL(returnPressed()), SLOT(executeExpression())); - QHBoxLayout *hbox = new QHBoxLayout; - hbox->setMargin(5); - hbox->setSpacing(5); - hbox->addWidget(new QLabel(tr("Expression:"))); - hbox->addWidget(m_lineEdit); - layout->addLayout(hbox); - - m_textEdit->setReadOnly(true); - m_lineEdit->installEventFilter(this); - } else { - m_textEdit->installEventFilter(this); - appendPrompt(); - } -} - -void ExpressionQueryWidget::setEngineDebug(QmlEngineDebug *client) -{ - m_client = client; -} - -void ExpressionQueryWidget::clear() -{ - m_textEdit->clear(); - if (m_lineEdit) - m_lineEdit->clear(); - if (m_mode == ShellMode) - appendPrompt(); -} - -void ExpressionQueryWidget::updateTitle() -{ - if (m_currObject.debugId() < 0) { - m_title = tr("Expression queries"); - } else { - QString desc = QLatin1String("<") - + m_currObject.className() + QLatin1String(": ") - + (m_currObject.name().isEmpty() ? QLatin1String("") : m_currObject.name()) - + QLatin1String(">"); - m_title = tr("Expression queries (using context for %1)" , "Selected object").arg(desc); - } -} - -void ExpressionQueryWidget::appendPrompt() -{ - m_textEdit->moveCursor(QTextCursor::End); - - if (m_mode == SeparateEntryMode) { - m_textEdit->insertPlainText("\n"); - } else { - m_textEdit->setTextColor(Qt::gray); - m_textEdit->append(m_prompt); - } -} - -void ExpressionQueryWidget::setCurrentObject(const QmlDebugObjectReference &obj) -{ - m_currObject = obj; - updateTitle(); -} - -void ExpressionQueryWidget::checkCurrentContext() -{ - m_textEdit->moveCursor(QTextCursor::End); - - if (m_currObject.debugId() != -1 && m_currObject.debugId() != m_objectAtLastFocus.debugId()) - showCurrentContext(); - m_objectAtLastFocus = m_currObject; -} - -void ExpressionQueryWidget::showCurrentContext() -{ - if (m_mode == ShellMode) { - // clear the initial prompt - if (m_textEdit->document()->lineCount() == 1) - m_textEdit->clear(); - } - - m_textEdit->moveCursor(QTextCursor::End); - m_textEdit->setTextColor(Qt::darkGreen); - m_textEdit->append(m_currObject.className() - + QLatin1String(": ") - + (m_currObject.name().isEmpty() ? QLatin1String("") : m_currObject.name())); - appendPrompt(); -} - -void ExpressionQueryWidget::executeExpression() -{ - if (!m_client) - return; - - if (m_mode == SeparateEntryMode) - m_expr = m_lineEdit->text().trimmed(); - else - m_expr = m_expr.trimmed(); - - if (!m_expr.isEmpty() && m_currObject.debugId() != -1) { - if (m_query) - delete m_query; - m_query = m_client->queryExpressionResult(m_currObject.debugId(), m_expr, this); - if (!m_query->isWaiting()) - showResult(); - else - QObject::connect(m_query, SIGNAL(stateChanged(QmlDebugQuery::State)), - this, SLOT(showResult())); - - m_lastExpr = m_expr; - if (m_lineEdit) - m_lineEdit->clear(); - } -} - -void ExpressionQueryWidget::showResult() -{ - if (m_query) { - m_textEdit->moveCursor(QTextCursor::End); - QVariant value = m_query->result(); - QString result; - - if (value.type() == QVariant::List || value.type() == QVariant::StringList) { - result = tr("<%1 items>", "%1 = number of items").arg(value.toList().count()); - } else if (value.isNull()) { - result = QLatin1String(""); - } else { - result = value.toString(); - } - - if (m_mode == SeparateEntryMode) { - m_textEdit->setTextColor(Qt::black); - m_textEdit->setFontWeight(QFont::Bold); - m_textEdit->insertPlainText(m_expr + " : "); - m_textEdit->setFontWeight(QFont::Normal); - m_textEdit->insertPlainText(result); - } else { - m_textEdit->setTextColor(Qt::darkGreen); - m_textEdit->insertPlainText(" => "); - m_textEdit->setTextColor(Qt::black); - m_textEdit->insertPlainText(result); - } - appendPrompt(); - m_expr.clear(); - } -} - -bool ExpressionQueryWidget::eventFilter(QObject *obj, QEvent *event) -{ - if (obj == m_textEdit) { - switch (event->type()) { - case QEvent::KeyPress: - { - QKeyEvent *keyEvent = static_cast(event); - int key = keyEvent->key(); - if (key == Qt::Key_Return || key == Qt::Key_Enter) { - executeExpression(); - return true; - } else if (key == Qt::Key_Backspace) { - // ensure m_expr doesn't contain backspace characters - QTextCursor cursor = m_textEdit->textCursor(); - bool atLastLine = !(cursor.block().next().isValid()); - if (!atLastLine) - return true; - if (cursor.columnNumber() <= m_prompt.count()) - return true; - cursor.deletePreviousChar(); - m_expr = cursor.block().text().mid(m_prompt.count()); - return true; - } else { - m_textEdit->moveCursor(QTextCursor::End); - m_textEdit->setTextColor(Qt::black); - m_expr += keyEvent->text(); - } - break; - } - case QEvent::FocusIn: - checkCurrentContext(); - m_textEdit->moveCursor(QTextCursor::End); - break; - default: - break; - } - } else if (obj == m_lineEdit) { - switch (event->type()) { - case QEvent::KeyPress: - { - QKeyEvent *keyEvent = static_cast(event); - int key = keyEvent->key(); - if (key == Qt::Key_Up && m_lineEdit->text() != m_lastExpr) { - m_expr = m_lineEdit->text(); - if (!m_lastExpr.isEmpty()) - m_lineEdit->setText(m_lastExpr); - } else if (key == Qt::Key_Down) { - m_lineEdit->setText(m_expr); - } - break; - } - case QEvent::FocusIn: - checkCurrentContext(); - break; - default: - break; - } - } - return QWidget::eventFilter(obj, event); -} - -QT_END_NAMESPACE diff --git a/tools/qmldebugger/standalone/expressionquerywidget.h b/tools/qmldebugger/standalone/expressionquerywidget.h deleted file mode 100644 index 8c224f8..0000000 --- a/tools/qmldebugger/standalone/expressionquerywidget.h +++ /dev/null @@ -1,105 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger 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 EXPRESSIONQUERYWIDGET_H -#define EXPRESSIONQUERYWIDGET_H - -#include - -#include - -QT_BEGIN_NAMESPACE - -class QGroupBox; -class QTextEdit; -class QLineEdit; -class QPushButton; - -class ExpressionQueryWidget : public QWidget -{ - Q_OBJECT -public: - enum Mode { - SeparateEntryMode, - ShellMode - }; - - ExpressionQueryWidget(Mode mode = SeparateEntryMode, QmlEngineDebug *client = 0, QWidget *parent = 0); - - void setEngineDebug(QmlEngineDebug *client); - void clear(); - -protected: - bool eventFilter(QObject *obj, QEvent *event); - -public slots: - void setCurrentObject(const QmlDebugObjectReference &obj); - -private slots: - void executeExpression(); - void showResult(); - -private: - void appendPrompt(); - void checkCurrentContext(); - void showCurrentContext(); - void updateTitle(); - - Mode m_mode; - - QmlEngineDebug *m_client; - QmlDebugExpressionQuery *m_query; - QTextEdit *m_textEdit; - QLineEdit *m_lineEdit; - QPushButton *m_button; - QString m_prompt; - QString m_expr; - QString m_lastExpr; - - QString m_title; - - QmlDebugObjectReference m_currObject; - QmlDebugObjectReference m_objectAtLastFocus; -}; - -QT_END_NAMESPACE - -#endif - diff --git a/tools/qmldebugger/standalone/main.cpp b/tools/qmldebugger/standalone/main.cpp deleted file mode 100644 index c2117f2..0000000 --- a/tools/qmldebugger/standalone/main.cpp +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger 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$ -** -****************************************************************************/ -#include - -#include "qmldebugger.h" - -QT_USE_NAMESPACE - -int main(int argc, char ** argv) -{ - QApplication app(argc, argv); - app.setApplicationName("QtQmlDebugger"); - app.setOrganizationName("Nokia"); - app.setOrganizationDomain("nokia.com"); - - QStringList args = app.arguments(); - - QmlDebugger win; - if (args.contains("--engine")) - win.showEngineTab(); - - for (int i=0; i - -#include -#include -#include - -#include -#include -#include - -#include "objectpropertiesview.h" - -QT_BEGIN_NAMESPACE - -class PropertiesViewItem : public QObject, public QTreeWidgetItem -{ - Q_OBJECT -public: - enum Type { - BindingType, - OtherType - }; - - PropertiesViewItem(QTreeWidget *widget, Type type = OtherType); - PropertiesViewItem(QTreeWidgetItem *parent, Type type = OtherType); - - QmlDebugPropertyReference property; - Type type; -}; - -PropertiesViewItem::PropertiesViewItem(QTreeWidget *widget, Type type) - : QTreeWidgetItem(widget), type(type) -{ -} - -PropertiesViewItem::PropertiesViewItem(QTreeWidgetItem *parent, Type type) - : QTreeWidgetItem(parent), type(type) -{ -} - -ObjectPropertiesView::ObjectPropertiesView(QmlEngineDebug *client, QWidget *parent) - : QWidget(parent), - m_client(client), - m_query(0), - m_watch(0) -{ - QVBoxLayout *layout = new QVBoxLayout; - layout->setContentsMargins(0, 0, 0, 0); - layout->setSpacing(0); - setLayout(layout); - - m_tree = new QTreeWidget(this); - m_tree->setAlternatingRowColors(true); - m_tree->setExpandsOnDoubleClick(false); - m_tree->setHeaderLabels(QStringList() - << tr("Name") << tr("Value") << tr("Type")); - QObject::connect(m_tree, SIGNAL(itemActivated(QTreeWidgetItem *, int)), - this, SLOT(itemActivated(QTreeWidgetItem *))); - - m_tree->setColumnCount(3); - m_tree->header()->setDefaultSectionSize(150); - - layout->addWidget(m_tree); -} - -void ObjectPropertiesView::setEngineDebug(QmlEngineDebug *client) -{ - m_client = client; -} - -void ObjectPropertiesView::clear() -{ - setObject(QmlDebugObjectReference()); -} - -void ObjectPropertiesView::reload(const QmlDebugObjectReference &obj) -{ - if (!m_client) - return; - if (m_query) - delete m_query; - - m_query = m_client->queryObjectRecursive(obj, this); - if (!m_query->isWaiting()) - queryFinished(); - else - QObject::connect(m_query, SIGNAL(stateChanged(QmlDebugQuery::State)), - this, SLOT(queryFinished())); -} - -void ObjectPropertiesView::queryFinished() -{ - if (!m_client || !m_query) - return; - - QmlDebugObjectReference obj = m_query->object(); - - QmlDebugWatch *watch = m_client->addWatch(obj, this); - if (watch->state() == QmlDebugWatch::Dead) { - delete watch; - watch = 0; - } else { - if (m_watch) { - m_client->removeWatch(m_watch); - delete m_watch; - } - m_watch = watch; - QObject::connect(watch, SIGNAL(valueChanged(QByteArray,QVariant)), - this, SLOT(valueChanged(QByteArray,QVariant))); - } - - delete m_query; - m_query = 0; - - setObject(obj); -} - -void ObjectPropertiesView::setPropertyValue(PropertiesViewItem *item, const QVariant &value, bool makeGray) -{ - if (value.type() == QVariant::List || value.type() == QVariant::StringList) { - PropertiesViewItem *bindingItem = static_cast(item->takeChild(item->childCount() - 1)); - if (bindingItem && bindingItem->type != PropertiesViewItem::BindingType) { - delete bindingItem; - bindingItem = 0; - } - - qDeleteAll(item->takeChildren()); - - QVariantList variants = value.toList(); - item->setText(1, tr("<%1 items>", "%1 = number of items").arg(variants.count())); - item->setText(2, QString::fromUtf8(value.typeName())); - - PropertiesViewItem *child; - for (int i=0; iaddChild(bindingItem); - - item->setExpanded(false); - } else { - item->setText(1, (value.isNull() ? QLatin1String("") : value.toString())); - item->setExpanded(true); - } - - if (makeGray) { - for (int i=0; icolumnCount(); i++) - item->setForeground(i, Qt::gray); - } -} - -void ObjectPropertiesView::setObject(const QmlDebugObjectReference &object) -{ - m_object = object; - m_tree->clear(); - - QList properties = object.properties(); - for (int i=0; iproperty = p; - - item->setText(0, p.name()); - item->setFlags(Qt::ItemIsSelectable | Qt::ItemIsEnabled); - - setPropertyValue(item, p.value(), !p.hasNotifySignal()); - item->setText(2, p.valueTypeName()); - - // binding is set after property value to ensure it is added to the end of the - // list, if the value is a list - if (!p.binding().isEmpty()) { - PropertiesViewItem *binding = new PropertiesViewItem(item, PropertiesViewItem::BindingType); - binding->setText(1, p.binding()); - binding->setForeground(1, Qt::darkGreen); - } - } -} - -void ObjectPropertiesView::watchCreated(QmlDebugWatch *watch) -{ - if (watch->objectDebugId() == m_object.debugId() - && qobject_cast(watch)) { - connect(watch, SIGNAL(stateChanged(QmlDebugWatch::State)), SLOT(watchStateChanged())); - setWatched(qobject_cast(watch)->name(), true); - } -} - -void ObjectPropertiesView::watchStateChanged() -{ - QmlDebugWatch *watch = qobject_cast(sender()); - - if (watch->objectDebugId() == m_object.debugId() - && qobject_cast(watch) - && watch->state() == QmlDebugWatch::Inactive) { - setWatched(qobject_cast(watch)->name(), false); - } -} - -void ObjectPropertiesView::setWatched(const QString &property, bool watched) -{ - for (int i=0; itopLevelItemCount(); i++) { - PropertiesViewItem *item = static_cast(m_tree->topLevelItem(i)); - if (item->property.name() == property && item->property.hasNotifySignal()) { - QFont font = m_tree->font(); - font.setBold(watched); - item->setFont(0, font); - } - } -} - -void ObjectPropertiesView::valueChanged(const QByteArray &name, const QVariant &value) -{ - for (int i=0; itopLevelItemCount(); i++) { - PropertiesViewItem *item = static_cast(m_tree->topLevelItem(i)); - if (item->property.name() == name) { - setPropertyValue(item, value, !item->property.hasNotifySignal()); - return; - } - } -} - -void ObjectPropertiesView::itemActivated(QTreeWidgetItem *i) -{ - PropertiesViewItem *item = static_cast(i); - if (!item->property.name().isEmpty()) - emit activated(m_object, item->property); -} - -QT_END_NAMESPACE - -#include "objectpropertiesview.moc" diff --git a/tools/qmldebugger/standalone/objectpropertiesview.h b/tools/qmldebugger/standalone/objectpropertiesview.h deleted file mode 100644 index 43413dc..0000000 --- a/tools/qmldebugger/standalone/objectpropertiesview.h +++ /dev/null @@ -1,93 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger 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 PROPERTIESTABLEMODEL_H -#define PROPERTIESTABLEMODEL_H - -#include - -#include - -QT_BEGIN_NAMESPACE - -class QTreeWidget; -class QTreeWidgetItem; -class QmlDebugConnection; -class PropertiesViewItem; - -class ObjectPropertiesView : public QWidget -{ - Q_OBJECT -public: - ObjectPropertiesView(QmlEngineDebug *client = 0, QWidget *parent = 0); - - void setEngineDebug(QmlEngineDebug *client); - void clear(); - -signals: - void activated(const QmlDebugObjectReference &, const QmlDebugPropertyReference &); - -public slots: - void reload(const QmlDebugObjectReference &); - void watchCreated(QmlDebugWatch *); - -private slots: - void queryFinished(); - void watchStateChanged(); - void valueChanged(const QByteArray &name, const QVariant &value); - void itemActivated(QTreeWidgetItem *i); - -private: - void setObject(const QmlDebugObjectReference &object); - void setWatched(const QString &property, bool watched); - void setPropertyValue(PropertiesViewItem *item, const QVariant &value, bool makeGray); - - QmlEngineDebug *m_client; - QmlDebugObjectQuery *m_query; - QmlDebugWatch *m_watch; - - QTreeWidget *m_tree; - QmlDebugObjectReference m_object; -}; - - -QT_END_NAMESPACE - -#endif diff --git a/tools/qmldebugger/standalone/objecttree.cpp b/tools/qmldebugger/standalone/objecttree.cpp deleted file mode 100644 index b5bac53..0000000 --- a/tools/qmldebugger/standalone/objecttree.cpp +++ /dev/null @@ -1,235 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger 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$ -** -****************************************************************************/ -#include -#include -#include - -#include - -#include -#include -#include - -#include "objecttree.h" - -Q_DECLARE_METATYPE(QmlDebugObjectReference) - -QT_BEGIN_NAMESPACE - -ObjectTree::ObjectTree(QmlEngineDebug *client, QWidget *parent) - : QTreeWidget(parent), - m_client(client), - m_query(0) -{ - setHeaderHidden(true); - setMinimumWidth(250); - setExpandsOnDoubleClick(false); - - connect(this, SIGNAL(currentItemChanged(QTreeWidgetItem *, QTreeWidgetItem *)), - SLOT(currentItemChanged(QTreeWidgetItem *))); - connect(this, SIGNAL(itemActivated(QTreeWidgetItem *, int)), - SLOT(activated(QTreeWidgetItem *))); -} - -void ObjectTree::setEngineDebug(QmlEngineDebug *client) -{ - m_client = client; -} - -void ObjectTree::reload(int objectDebugId) -{ - if (!m_client) - return; - - if (m_query) { - delete m_query; - m_query = 0; - } - - m_query = m_client->queryObjectRecursive(QmlDebugObjectReference(objectDebugId), this); - if (!m_query->isWaiting()) - objectFetched(); - else - QObject::connect(m_query, SIGNAL(stateChanged(QmlDebugQuery::State)), - this, SLOT(objectFetched())); -} - -void ObjectTree::setCurrentObject(int debugId) -{ - QTreeWidgetItem *item = findItemByObjectId(debugId); - if (item) { - setCurrentItem(item); - scrollToItem(item); - item->setExpanded(true); - } -} - -void ObjectTree::objectFetched() -{ - dump(m_query->object(), 0); - buildTree(m_query->object(), 0); - setCurrentItem(topLevelItem(0)); - - delete m_query; - m_query = 0; -} - -void ObjectTree::currentItemChanged(QTreeWidgetItem *item) -{ - if (!item) - return; - - QmlDebugObjectReference obj = item->data(0, Qt::UserRole).value(); - if (obj.debugId() >= 0) - emit currentObjectChanged(obj); -} - -void ObjectTree::activated(QTreeWidgetItem *item) -{ - if (!item) - return; - - QmlDebugObjectReference obj = item->data(0, Qt::UserRole).value(); - if (obj.debugId() >= 0) - emit activated(obj); -} - -void ObjectTree::buildTree(const QmlDebugObjectReference &obj, QTreeWidgetItem *parent) -{ - if (!parent) - clear(); - - QTreeWidgetItem *item = parent ? new QTreeWidgetItem(parent) : new QTreeWidgetItem(this); - item->setText(0, obj.className()); - item->setData(0, Qt::UserRole, qVariantFromValue(obj)); - - if (parent && obj.contextDebugId() >= 0 - && obj.contextDebugId() != parent->data(0, Qt::UserRole - ).value().contextDebugId()) { - QmlDebugFileReference source = obj.source(); - if (!source.url().isEmpty()) { - QString toolTipString = QLatin1String("URL: ") + source.url().toString(); - item->setToolTip(0, toolTipString); - } - item->setForeground(0, QColor("orange")); - } else { - item->setExpanded(true); - } - - if (obj.contextDebugId() < 0) - item->setForeground(0, Qt::lightGray); - - for (int ii = 0; ii < obj.children().count(); ++ii) - buildTree(obj.children().at(ii), item); -} - -void ObjectTree::dump(const QmlDebugContextReference &ctxt, int ind) -{ - QByteArray indent(ind * 4, ' '); - qWarning().nospace() << indent.constData() << ctxt.debugId() << " " - << qPrintable(ctxt.name()); - - for (int ii = 0; ii < ctxt.contexts().count(); ++ii) - dump(ctxt.contexts().at(ii), ind + 1); - - for (int ii = 0; ii < ctxt.objects().count(); ++ii) - dump(ctxt.objects().at(ii), ind); -} - -void ObjectTree::dump(const QmlDebugObjectReference &obj, int ind) -{ - QByteArray indent(ind * 4, ' '); - qWarning().nospace() << indent.constData() << qPrintable(obj.className()) - << " " << qPrintable(obj.name()) << " " - << obj.debugId(); - - for (int ii = 0; ii < obj.children().count(); ++ii) - dump(obj.children().at(ii), ind + 1); -} - -QTreeWidgetItem *ObjectTree::findItemByObjectId(int debugId) const -{ - for (int i=0; idata(0, Qt::UserRole).value().debugId() == debugId) - return item; - - QTreeWidgetItem *child; - for (int i=0; ichildCount(); i++) { - child = findItem(item->child(i), debugId); - if (child) - return child; - } - - return 0; -} - -void ObjectTree::mousePressEvent(QMouseEvent *me) -{ - QTreeWidget::mousePressEvent(me); - if (!currentItem()) - return; - if(me->button() == Qt::RightButton && me->type() == QEvent::MouseButtonPress) { - QAction action(tr("Add watch..."), 0); - QList actions; - actions << &action; - QmlDebugObjectReference obj = - currentItem()->data(0, Qt::UserRole).value(); - if (QMenu::exec(actions, me->globalPos())) { - bool ok = false; - QString watch = QInputDialog::getText(this, tr("Watch expression"), - tr("Expression:"), QLineEdit::Normal, QString(), &ok); - if (ok && !watch.isEmpty()) - emit expressionWatchRequested(obj, watch); - } - } -} - -QT_END_NAMESPACE diff --git a/tools/qmldebugger/standalone/objecttree.h b/tools/qmldebugger/standalone/objecttree.h deleted file mode 100644 index c8d625c..0000000 --- a/tools/qmldebugger/standalone/objecttree.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger 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 OBJECTTREE_H -#define OBJECTTREE_H - -#include - -QT_BEGIN_NAMESPACE - -class QTreeWidgetItem; - -class QmlEngineDebug; -class QmlDebugObjectReference; -class QmlDebugObjectQuery; -class QmlDebugContextReference; -class QmlDebugConnection; - - -class ObjectTree : public QTreeWidget -{ - Q_OBJECT -public: - ObjectTree(QmlEngineDebug *client = 0, QWidget *parent = 0); - - void setEngineDebug(QmlEngineDebug *client); - -signals: - void currentObjectChanged(const QmlDebugObjectReference &); - void activated(const QmlDebugObjectReference &); - void expressionWatchRequested(const QmlDebugObjectReference &, const QString &); - -public slots: - void reload(int objectDebugId); // set the root object - void setCurrentObject(int debugId); // select an object in the tree - -protected: - virtual void mousePressEvent(QMouseEvent *); - -private slots: - void objectFetched(); - void currentItemChanged(QTreeWidgetItem *); - void activated(QTreeWidgetItem *); - -private: - QTreeWidgetItem *findItemByObjectId(int debugId) const; - QTreeWidgetItem *findItem(QTreeWidgetItem *item, int debugId) const; - void dump(const QmlDebugContextReference &, int); - void dump(const QmlDebugObjectReference &, int); - void buildTree(const QmlDebugObjectReference &, QTreeWidgetItem *parent); - - QmlEngineDebug *m_client; - QmlDebugObjectQuery *m_query; -}; - -QT_END_NAMESPACE - - -#endif diff --git a/tools/qmldebugger/standalone/qmldebugger.cpp b/tools/qmldebugger/standalone/qmldebugger.cpp deleted file mode 100644 index 1c1057a..0000000 --- a/tools/qmldebugger/standalone/qmldebugger.cpp +++ /dev/null @@ -1,185 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger 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$ -** -****************************************************************************/ -#include -#include -#include - -#include -#include -#include -#include -#include -#include - -#include "canvasframerate.h" -#include "engine.h" -#include "qmldebugger.h" - -QT_BEGIN_NAMESPACE - -QmlDebugger::QmlDebugger(QWidget *parent) -: QWidget(parent) -{ - QVBoxLayout *layout = new QVBoxLayout; - setLayout(layout); - - QHBoxLayout *connectLayout = new QHBoxLayout; - layout->addLayout(connectLayout); - connectLayout->addStretch(2); - - m_connectionState = new QLabel(this); - connectLayout->addWidget(m_connectionState); - m_host = new QLineEdit(this); - connectLayout->addWidget(m_host); - m_port = new QSpinBox(this); - m_port->setMinimum(1024); - m_port->setMaximum(20000); - connectLayout->addWidget(m_port); - m_connectButton = new QPushButton(tr("Connect"), this); - QObject::connect(m_connectButton, SIGNAL(clicked()), - this, SLOT(connectToHost())); - connectLayout->addWidget(m_connectButton); - m_disconnectButton = new QPushButton(tr("Disconnect"), this); - QObject::connect(m_disconnectButton, SIGNAL(clicked()), - this, SLOT(disconnectFromHost())); - m_disconnectButton->setEnabled(false); - connectLayout->addWidget(m_disconnectButton); - - m_tabs = new QTabWidget(this); - layout->addWidget(m_tabs); - - CanvasFrameRate *cfr = new CanvasFrameRate(this); - cfr->reset(&client); - cfr->setSizeHint(QSize(800, 600)); - m_tabs->addTab(cfr, tr("Frame Rate")); - - m_enginePane = new EnginePane(&client, this); - m_tabs->addTab(m_enginePane, tr("QML Engine")); - - QObject::connect(&client, SIGNAL(stateChanged(QAbstractSocket::SocketState)), - this, SLOT(connectionStateChanged())); - connectionStateChanged(); - - QObject::connect(&client, SIGNAL(error(QAbstractSocket::SocketError)), - this, SLOT(connectionError(QAbstractSocket::SocketError))); - - QSettings settings; - m_host->setText(settings.value("Host", "127.0.0.1").toString()); - m_port->setValue(settings.value("Port", 3768).toInt()); - - connectToHost(); -} - -void QmlDebugger::setHost(const QString &host) -{ - m_host->setText(host); -} - -void QmlDebugger::setPort(quint16 port) -{ - m_port->setValue(port); -} - -void QmlDebugger::showEngineTab() -{ - m_tabs->setCurrentWidget(m_enginePane); -} - -void QmlDebugger::closeEvent(QCloseEvent *event) -{ - QSettings settings; - settings.setValue("Host", m_host->text()); - settings.setValue("Port", m_port->value()); - - QWidget::closeEvent(event); -} - -void QmlDebugger::connectionStateChanged() -{ - switch (client.state()) { - default: - case QAbstractSocket::UnconnectedState: - m_connectionState->setText(tr("Disconnected")); - m_connectButton->setEnabled(true); - m_disconnectButton->setEnabled(false); - break; - case QAbstractSocket::HostLookupState: - m_connectionState->setText(tr("Resolving")); - m_connectButton->setEnabled(false); - m_disconnectButton->setEnabled(true); - break; - case QAbstractSocket::ConnectingState: - m_connectionState->setText(tr("Connecting")); - m_connectButton->setEnabled(false); - m_disconnectButton->setEnabled(true); - break; - case QAbstractSocket::ConnectedState: - m_connectionState->setText(tr("Connected")); - m_connectButton->setEnabled(false); - m_disconnectButton->setEnabled(true); - - QTimer::singleShot(0, m_enginePane, SLOT(refreshEngines())); - break; - case QAbstractSocket::ClosingState: - m_connectionState->setText(tr("Closing")); - m_connectButton->setEnabled(false); - m_disconnectButton->setEnabled(false); - break; - } -} - -void QmlDebugger::connectionError(QAbstractSocket::SocketError socketError) -{ - qWarning() << "qmldebugger cannot connect:" << socketError - << client.errorString(); -} - -void QmlDebugger::connectToHost() -{ - client.connectToHost(m_host->text(), m_port->value()); -} - -void QmlDebugger::disconnectFromHost() -{ - client.disconnectFromHost(); -} - -QT_END_NAMESPACE diff --git a/tools/qmldebugger/standalone/qmldebugger.h b/tools/qmldebugger/standalone/qmldebugger.h deleted file mode 100644 index 3df47d1..0000000 --- a/tools/qmldebugger/standalone/qmldebugger.h +++ /dev/null @@ -1,94 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger 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 QMLDEBUGGER_H -#define QMLDEBUGGER_H - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QLabel; -class QLineEdit; -class QSpinBox; -class QPushButton; -class QTabWidget; - -class EnginePane; - -class QmlDebugger : public QWidget -{ - Q_OBJECT -public: - QmlDebugger(QWidget * = 0); - - void setHost(const QString &host); - void setPort(quint16 port); - void showEngineTab(); - -public slots: - void connectToHost(); - void disconnectFromHost(); - -protected: - void closeEvent(QCloseEvent *); - -private slots: - void connectionStateChanged(); - void connectionError(QAbstractSocket::SocketError socketError); - -private: - QmlDebugConnection client; - - QLabel *m_connectionState; - QLineEdit *m_host; - QSpinBox *m_port; - QPushButton *m_connectButton; - QPushButton *m_disconnectButton; - - EnginePane *m_enginePane; - QTabWidget *m_tabs; -}; - -QT_END_NAMESPACE - -#endif diff --git a/tools/qmldebugger/standalone/qmldebugger.pri b/tools/qmldebugger/standalone/qmldebugger.pri deleted file mode 100644 index ede7d31..0000000 --- a/tools/qmldebugger/standalone/qmldebugger.pri +++ /dev/null @@ -1,18 +0,0 @@ -QT += network declarative -contains(QT_CONFIG, opengles2)|contains(QT_CONFIG, opengles1): QT += opengl - -INCLUDEPATH += ../../../src/declarative/debugger - -# Input -HEADERS += $$PWD/canvasframerate.h \ - $$PWD/watchtable.h \ - $$PWD/objecttree.h \ - $$PWD/objectpropertiesview.h \ - $$PWD/expressionquerywidget.h - -SOURCES += $$PWD/canvasframerate.cpp \ - $$PWD/watchtable.cpp \ - $$PWD/objecttree.cpp \ - $$PWD/objectpropertiesview.cpp \ - $$PWD/expressionquerywidget.cpp - diff --git a/tools/qmldebugger/standalone/qmldebugger.qrc b/tools/qmldebugger/standalone/qmldebugger.qrc deleted file mode 100644 index cb53ad5..0000000 --- a/tools/qmldebugger/standalone/qmldebugger.qrc +++ /dev/null @@ -1,7 +0,0 @@ - - - engines.qml - engine.png - refresh.png - - diff --git a/tools/qmldebugger/standalone/refresh.png b/tools/qmldebugger/standalone/refresh.png deleted file mode 100644 index 8befc80..0000000 Binary files a/tools/qmldebugger/standalone/refresh.png and /dev/null differ diff --git a/tools/qmldebugger/standalone/standalone.pro b/tools/qmldebugger/standalone/standalone.pro deleted file mode 100644 index 72d051f..0000000 --- a/tools/qmldebugger/standalone/standalone.pro +++ /dev/null @@ -1,19 +0,0 @@ -DESTDIR = ../../../bin -TARGET = qmldebugger - -include(qmldebugger.pri) - -HEADERS += $$PWD/qmldebugger.h \ - $$PWD/engine.h - -SOURCES += $$PWD/qmldebugger.cpp \ - $$PWD/engine.cpp \ - $$PWD/main.cpp - -RESOURCES += $$PWD/qmldebugger.qrc -OTHER_FILES += $$PWD/engines.qml - -target.path=$$[QT_INSTALL_BINS] -INSTALLS += target - -CONFIG += console diff --git a/tools/qmldebugger/standalone/watchtable.cpp b/tools/qmldebugger/standalone/watchtable.cpp deleted file mode 100644 index 6f9f99a..0000000 --- a/tools/qmldebugger/standalone/watchtable.cpp +++ /dev/null @@ -1,366 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger 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$ -** -****************************************************************************/ -#include "watchtable.h" - -#include -#include -#include -#include - -#include -#include - -QT_BEGIN_NAMESPACE - - -WatchTableModel::WatchTableModel(QmlEngineDebug *client, QObject *parent) - : QAbstractTableModel(parent), - m_client(client) -{ -} - -WatchTableModel::~WatchTableModel() -{ - for (int i=0; i(watch)) - property = qobject_cast(watch)->name(); - - connect(watch, SIGNAL(valueChanged(QByteArray,QVariant)), - SLOT(watchedValueChanged(QByteArray,QVariant))); - - connect(watch, SIGNAL(stateChanged(QmlDebugWatch::State)), SLOT(watchStateChanged())); - - int col = columnCount(QModelIndex()); - beginInsertColumns(QModelIndex(), col, col); - - WatchedEntity e; - e.title = title; - e.hasFirstValue = false; - e.property = property; - e.watch = watch; - m_columns.append(e); - - endInsertColumns(); -} - -void WatchTableModel::removeWatch(QmlDebugWatch *watch) -{ - int column = columnForWatch(watch); - if (column == -1) - return; - - WatchedEntity entity = m_columns.takeAt(column); - - for (QList::Iterator iter = m_values.begin(); iter != m_values.end();) { - if (iter->column == column) { - iter = m_values.erase(iter); - } else { - if(iter->column > column) - --iter->column; - ++iter; - } - } - - reset(); -} - -void WatchTableModel::updateWatch(QmlDebugWatch *watch, const QVariant &value) -{ - int column = columnForWatch(watch); - if (column == -1) - return; - - addValue(column, value); - - if (!m_columns[column].hasFirstValue) { - m_columns[column].hasFirstValue = true; - m_values[m_values.count() - 1].first = true; - } -} - -QmlDebugWatch *WatchTableModel::findWatch(int column) const -{ - if (column < m_columns.count()) - return m_columns.at(column).watch; - return 0; -} - -QmlDebugWatch *WatchTableModel::findWatch(int objectDebugId, const QString &property) const -{ - for (int i=0; iobjectDebugId() == objectDebugId - && m_columns[i].property == property) { - return m_columns[i].watch; - } - } - return 0; -} - -int WatchTableModel::rowCount(const QModelIndex &) const -{ - return m_values.count(); -} - -int WatchTableModel::columnCount(const QModelIndex &) const -{ - return m_columns.count(); -} - -QVariant WatchTableModel::headerData(int section, Qt::Orientation orientation, int role) const -{ - if (orientation == Qt::Horizontal) { - if (section < m_columns.count() && role == Qt::DisplayRole) - return m_columns.at(section).title; - } else { - if (role == Qt::DisplayRole) - return section + 1; - } - return QVariant(); -} - -QVariant WatchTableModel::data(const QModelIndex &idx, int role) const -{ - if (m_values.at(idx.row()).column == idx.column()) { - if (role == Qt::DisplayRole) { - const QVariant &value = m_values.at(idx.row()).variant; - QString str = value.toString(); - - if (str.isEmpty() && QmlMetaType::isQObject(value.userType())) { - QObject *o = QmlMetaType::toQObject(value); - if(o) { - QString objectName = o->objectName(); - if(objectName.isEmpty()) - objectName = QLatin1String(""); - str = QLatin1String(o->metaObject()->className()) + - QLatin1String(": ") + objectName; - } - } - - if(str.isEmpty()) { - QDebug d(&str); - d << value; - } - return QVariant(str); - } else if(role == Qt::BackgroundRole) { - if(m_values.at(idx.row()).first) - return QColor(Qt::green); - else - return QVariant(); - } else { - return QVariant(); - } - } else { - return QVariant(); - } -} - -void WatchTableModel::watchStateChanged() -{ - QmlDebugWatch *watch = qobject_cast(sender()); - - if (watch && watch->state() == QmlDebugWatch::Inactive) { - removeWatch(watch); - watch->deleteLater(); - } -} - -int WatchTableModel::columnForWatch(QmlDebugWatch *watch) const -{ - for (int i=0; iremoveWatch(watch); - return; - } - - watch = m_client->addWatch(property, this); - if (watch->state() == QmlDebugWatch::Dead) { - delete watch; - watch = 0; - } else { - QString desc = property.name() - + QLatin1String(" on\n") - + object.className() - + QLatin1String(":\n") - + (object.name().isEmpty() ? QLatin1String("") : object.name()); - addWatch(watch, desc); - emit watchCreated(watch); - } -} - -void WatchTableModel::watchedValueChanged(const QByteArray &propertyName, const QVariant &value) -{ - Q_UNUSED(propertyName); - QmlDebugWatch *watch = qobject_cast(sender()); - if (watch) - updateWatch(watch, value); -} - -void WatchTableModel::expressionWatchRequested(const QmlDebugObjectReference &obj, const QString &expr) -{ - if (!m_client) - return; - - QmlDebugWatch *watch = m_client->addWatch(obj, expr, this); - - if (watch->state() == QmlDebugWatch::Dead) { - delete watch; - watch = 0; - } else { - addWatch(watch, expr); - emit watchCreated(watch); - } -} - -void WatchTableModel::removeWatchAt(int column) -{ - if (!m_client) - return; - - QmlDebugWatch *watch = findWatch(column); - if (watch) { - m_client->removeWatch(watch); - delete watch; - watch = 0; - } -} - -void WatchTableModel::removeAllWatches() -{ - for (int i=0; iremoveWatch(m_columns[i].watch); - else - delete m_columns[i].watch; - } - m_columns.clear(); - m_values.clear(); - reset(); -} - -//---------------------------------------------- - -WatchTableHeaderView::WatchTableHeaderView(WatchTableModel *model, QWidget *parent) - : QHeaderView(Qt::Horizontal, parent), - m_model(model) -{ - setClickable(true); -} - -void WatchTableHeaderView::mousePressEvent(QMouseEvent *me) -{ - QHeaderView::mousePressEvent(me); - - if (me->button() == Qt::RightButton && me->type() == QEvent::MouseButtonPress) { - int col = logicalIndexAt(me->pos()); - if (col >= 0) { - QAction action(tr("Stop watching"), 0); - QList actions; - actions << &action; - if (QMenu::exec(actions, me->globalPos())) - m_model->removeWatchAt(col); - } - } -} - - -//---------------------------------------------- - -WatchTableView::WatchTableView(WatchTableModel *model, QWidget *parent) - : QTableView(parent), - m_model(model) -{ - setAlternatingRowColors(true); - connect(model, SIGNAL(watchCreated(QmlDebugWatch*)), SLOT(watchCreated(QmlDebugWatch*))); - connect(this, SIGNAL(activated(QModelIndex)), SLOT(indexActivated(QModelIndex))); -} - -void WatchTableView::indexActivated(const QModelIndex &index) -{ - QmlDebugWatch *watch = m_model->findWatch(index.column()); - if (watch) - emit objectActivated(watch->objectDebugId()); -} - -void WatchTableView::watchCreated(QmlDebugWatch *watch) -{ - int column = m_model->columnForWatch(watch); - resizeColumnToContents(column); -} - -QT_END_NAMESPACE diff --git a/tools/qmldebugger/standalone/watchtable.h b/tools/qmldebugger/standalone/watchtable.h deleted file mode 100644 index fd12d3d..0000000 --- a/tools/qmldebugger/standalone/watchtable.h +++ /dev/null @@ -1,154 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). -** All rights reserved. -** Contact: Nokia Corporation (qt-info@nokia.com) -** -** This file is part of the Qt QML Debugger 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 WATCHTABLEMODEL_H -#define WATCHTABLEMODEL_H - -#include -#include - -#include -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QmlDebugWatch; -class QmlEngineDebug; -class QmlDebugConnection; -class QmlDebugPropertyReference; -class QmlDebugObjectReference; - -class WatchTableModel : public QAbstractTableModel -{ - Q_OBJECT -public: - WatchTableModel(QmlEngineDebug *client = 0, QObject *parent = 0); - ~WatchTableModel(); - - void setEngineDebug(QmlEngineDebug *client); - - QmlDebugWatch *findWatch(int column) const; - int columnForWatch(QmlDebugWatch *watch) const; - - void removeWatchAt(int column); - void removeAllWatches(); - - int rowCount(const QModelIndex &parent = QModelIndex()) const; - int columnCount(const QModelIndex &parent = QModelIndex()) const; - QVariant headerData(int section, Qt::Orientation orientation, int role) const; - QVariant data(const QModelIndex &index, int role = Qt::DisplayRole) const; - -signals: - void watchCreated(QmlDebugWatch *watch); - -public slots: - void togglePropertyWatch(const QmlDebugObjectReference &obj, const QmlDebugPropertyReference &prop); - void expressionWatchRequested(const QmlDebugObjectReference &, const QString &); - -private slots: - void watchStateChanged(); - void watchedValueChanged(const QByteArray &propertyName, const QVariant &value); - -private: - void addWatch(QmlDebugWatch *watch, const QString &title); - void removeWatch(QmlDebugWatch *watch); - void updateWatch(QmlDebugWatch *watch, const QVariant &value); - - QmlDebugWatch *findWatch(int objectDebugId, const QString &property) const; - - void addValue(int column, const QVariant &value); - - struct WatchedEntity - { - QString title; - bool hasFirstValue; - QString property; - QPointer watch; - }; - - struct Value { - int column; - QVariant variant; - bool first; - }; - - QmlEngineDebug *m_client; - QList m_columns; - QList m_values; -}; - - -class WatchTableHeaderView : public QHeaderView -{ - Q_OBJECT -public: - WatchTableHeaderView(WatchTableModel *model, QWidget *parent = 0); - -protected: - void mousePressEvent(QMouseEvent *me); - -private: - WatchTableModel *m_model; -}; - - -class WatchTableView : public QTableView -{ - Q_OBJECT -public: - WatchTableView(WatchTableModel *model, QWidget *parent = 0); - -signals: - void objectActivated(int objectDebugId); - -private slots: - void indexActivated(const QModelIndex &index); - void watchCreated(QmlDebugWatch *watch); - -private: - WatchTableModel *m_model; -}; - - -QT_END_NAMESPACE - -#endif // WATCHTABLEMODEL_H diff --git a/tools/tools.pro b/tools/tools.pro index 4cff507..d5569b6 100644 --- a/tools/tools.pro +++ b/tools/tools.pro @@ -26,7 +26,7 @@ mac { embedded:SUBDIRS += kmap2qmap -contains(QT_CONFIG, declarative):SUBDIRS += qmlviewer qmldebugger +contains(QT_CONFIG, declarative):SUBDIRS += qmlviewer contains(QT_CONFIG, dbus):SUBDIRS += qdbus !wince*:contains(QT_CONFIG, xmlpatterns): SUBDIRS += xmlpatterns xmlpatternsvalidator embedded: SUBDIRS += makeqpf -- cgit v0.12 From 3a96ecef0db619016cf132b16a99f2714215ebdd Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Tue, 16 Feb 2010 16:09:22 +1000 Subject: Run dos2unix on these files. --- .../qmlgraphicsloader/data/NoResizeGraphicsWidget.qml | 16 ++++++++-------- .../data/SizeGraphicsWidgetToLoader.qml | 16 ++++++++-------- .../data/SizeLoaderToGraphicsWidget.qml | 12 ++++++------ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml b/tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml index 0704e18..5eab965 100644 --- a/tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml +++ b/tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml @@ -1,8 +1,8 @@ -import Qt 4.6 - -Loader { - resizeMode: Loader.NoResize - source: "GraphicsWidget250x250.qml" - width: 200 - height: 80 -} +import Qt 4.6 + +Loader { + resizeMode: Loader.NoResize + source: "GraphicsWidget250x250.qml" + width: 200 + height: 80 +} diff --git a/tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml b/tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml index 97c72f4..568a136 100644 --- a/tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml +++ b/tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml @@ -1,8 +1,8 @@ -import Qt 4.6 - -Loader { - resizeMode: Loader.SizeItemToLoader - width: 200 - height: 80 - source: "GraphicsWidget250x250.qml" -} +import Qt 4.6 + +Loader { + resizeMode: Loader.SizeItemToLoader + width: 200 + height: 80 + source: "GraphicsWidget250x250.qml" +} diff --git a/tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml b/tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml index cb72f05..a710803 100644 --- a/tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml +++ b/tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml @@ -1,6 +1,6 @@ -import Qt 4.6 - -Loader { - resizeMode: Loader.SizeLoaderToItem - source: "GraphicsWidget250x250.qml" -} +import Qt 4.6 + +Loader { + resizeMode: Loader.SizeLoaderToItem + source: "GraphicsWidget250x250.qml" +} -- cgit v0.12 From 8454c53b304a4aba7c058b315041b3a38ad4fff5 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Tue, 16 Feb 2010 16:42:31 +1000 Subject: Replace QList<>* support with QmlListProperty Conflicts: src/declarative/graphicsitems/qmlgraphicsitem.cpp src/declarative/qml/qmlmetaproperty.cpp src/declarative/qml/qmlmetatype.cpp --- src/declarative/graphicsitems/qmlgraphicsitem.cpp | 1 - src/declarative/graphicsitems/qmlgraphicsitem_p.h | 6 +- src/declarative/graphicsitems/qmlgraphicspath.cpp | 4 +- src/declarative/graphicsitems/qmlgraphicspath_p.h | 4 +- .../graphicsitems/qmlgraphicsrectangle_p.h | 4 +- .../graphicsitems/qmlgraphicsvisualitemmodel.cpp | 4 +- src/declarative/qml/qml.h | 4 +- src/declarative/qml/qmllist.h | 66 +++++++++ src/declarative/qml/qmllistscriptclass.cpp | 57 ++++--- src/declarative/qml/qmllistscriptclass_p.h | 2 +- src/declarative/qml/qmlmetaproperty.cpp | 3 +- src/declarative/qml/qmlmetatype.cpp | 54 +++---- src/declarative/qml/qmlmetatype.h | 47 +++--- src/declarative/qml/qmlobjectscriptclass.cpp | 2 +- src/declarative/qml/qmlprivate.h | 163 +-------------------- src/declarative/qml/qmlvme.cpp | 26 ++-- src/declarative/util/qmlanimation.cpp | 16 +- src/declarative/util/qmlanimation_p.h | 16 +- src/declarative/util/qmllistaccessor.cpp | 41 +++--- src/declarative/util/qmllistaccessor_p.h | 2 +- tests/auto/declarative/qmlecmascript/testtypes.h | 8 +- .../qmlecmascript/tst_qmlecmascript.cpp | 2 +- tests/auto/declarative/qmllanguage/testtypes.h | 11 +- .../declarative/qmllanguage/tst_qmllanguage.cpp | 34 ++--- .../qmllistaccessor/tst_qmllistaccessor.cpp | 10 +- 25 files changed, 248 insertions(+), 339 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp index 2fbf18b..e10c919 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp @@ -892,7 +892,6 @@ void QmlGraphicsKeyNavigationAttached::keyReleased(QKeyEvent *event) parameter provides information about the event. */ - const QmlGraphicsKeysAttached::SigMap QmlGraphicsKeysAttached::sigMap[] = { { Qt::Key_Left, "leftPressed" }, { Qt::Key_Right, "rightPressed" }, diff --git a/src/declarative/graphicsitems/qmlgraphicsitem_p.h b/src/declarative/graphicsitems/qmlgraphicsitem_p.h index 9a77dbb..7ebbd85 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsitem_p.h @@ -381,7 +381,7 @@ class QmlGraphicsKeysAttached : public QObject, public QmlGraphicsItemKeyFilter Q_DECLARE_PRIVATE(QmlGraphicsKeysAttached) Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) - Q_PROPERTY(QList *forwardTo READ forwardTo) + Q_PROPERTY(QmlListProperty forwardTo READ forwardTo) public: QmlGraphicsKeysAttached(QObject *parent=0); @@ -396,9 +396,9 @@ public: } } - QList *forwardTo() { + QmlListProperty forwardTo() { Q_D(QmlGraphicsKeysAttached); - return &d->targets; + return QmlListProperty(this, d->targets); } virtual void componentComplete(); diff --git a/src/declarative/graphicsitems/qmlgraphicspath.cpp b/src/declarative/graphicsitems/qmlgraphicspath.cpp index fae8161..eaf0d88 100644 --- a/src/declarative/graphicsitems/qmlgraphicspath.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspath.cpp @@ -155,10 +155,10 @@ bool QmlGraphicsPath::isClosed() const \snippet doc/src/snippets/declarative/pathview/pathattributes.qml 2 */ -QList* QmlGraphicsPath::pathElements() +QmlListProperty QmlGraphicsPath::pathElements() { Q_D(QmlGraphicsPath); - return &(d->_pathElements); + return QmlListProperty(this, d->_pathElements); } void QmlGraphicsPath::interpolate(int idx, const QString &name, qreal value) diff --git a/src/declarative/graphicsitems/qmlgraphicspath_p.h b/src/declarative/graphicsitems/qmlgraphicspath_p.h index 2b4b0fd..50ea15b 100644 --- a/src/declarative/graphicsitems/qmlgraphicspath_p.h +++ b/src/declarative/graphicsitems/qmlgraphicspath_p.h @@ -189,7 +189,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsPath : public QObject, public QmlParserSta Q_OBJECT Q_INTERFACES(QmlParserStatus) - Q_PROPERTY(QList* pathElements READ pathElements) + Q_PROPERTY(QmlListProperty pathElements READ pathElements) Q_PROPERTY(qreal startX READ startX WRITE setStartX) Q_PROPERTY(qreal startY READ startY WRITE setStartY) Q_PROPERTY(bool closed READ isClosed NOTIFY changed) @@ -199,7 +199,7 @@ public: QmlGraphicsPath(QObject *parent=0); ~QmlGraphicsPath(); - QList* pathElements(); + QmlListProperty pathElements(); qreal startX() const; void setStartX(qreal x); diff --git a/src/declarative/graphicsitems/qmlgraphicsrectangle_p.h b/src/declarative/graphicsitems/qmlgraphicsrectangle_p.h index 4f4c1cf..b8c2179 100644 --- a/src/declarative/graphicsitems/qmlgraphicsrectangle_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsrectangle_p.h @@ -107,14 +107,14 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsGradient : public QObject { Q_OBJECT - Q_PROPERTY(QList *stops READ stops) + Q_PROPERTY(QmlListProperty stops READ stops) Q_CLASSINFO("DefaultProperty", "stops") public: QmlGraphicsGradient(QObject *parent=0) : QObject(parent), m_gradient(0) {} ~QmlGraphicsGradient() { delete m_gradient; } - QList *stops() { return &m_stops; } + QmlListProperty stops() { return QmlListProperty(this, m_stops); } const QGradient *gradient() const; diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp index cc416d0..d14fc84 100644 --- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp @@ -423,7 +423,7 @@ int QmlGraphicsVisualDataModelDataMetaObject::createProperty(const char *name, c if ((!model->m_listModelInterface || !model->m_abstractItemModel) && model->m_listAccessor) { if (model->m_listAccessor->type() == QmlListAccessor::QmlList - || model->m_listAccessor->type() == QmlListAccessor::QListPtr) { + || model->m_listAccessor->type() == QmlListAccessor::ListProperty) { model->ensureRoles(); QObject *object = model->m_listAccessor->at(data->m_index).value(); if (object && object->property(name).isValid()) @@ -685,7 +685,7 @@ void QmlGraphicsVisualDataModel::setModel(const QVariant &model) } d->m_listAccessor = new QmlListAccessor; d->m_listAccessor->setList(model, d->m_context?d->m_context->engine():qmlEngine(this)); - if (d->m_listAccessor->type() != QmlListAccessor::QmlList && d->m_listAccessor->type() != QmlListAccessor::QListPtr) + if (d->m_listAccessor->type() != QmlListAccessor::QmlList && d->m_listAccessor->type() != QmlListAccessor::ListProperty) d->m_metaDataCacheable = true; if (d->m_delegate && d->modelCount()) { emit itemsInserted(0, d->modelCount()); diff --git a/src/declarative/qml/qml.h b/src/declarative/qml/qml.h index c009093..859fd66 100644 --- a/src/declarative/qml/qml.h +++ b/src/declarative/qml/qml.h @@ -59,11 +59,11 @@ QT_MODULE(Declarative) #define QML_DECLARE_TYPE(TYPE) \ Q_DECLARE_METATYPE(TYPE *) \ - Q_DECLARE_METATYPE(QList *) \ + Q_DECLARE_METATYPE(QmlListProperty) \ Q_DECLARE_METATYPE(QmlList *) #define QML_DECLARE_TYPE_HASMETATYPE(TYPE) \ - Q_DECLARE_METATYPE(QList *) \ + Q_DECLARE_METATYPE(QmlListProperty) \ Q_DECLARE_METATYPE(QmlList *) #define QML_DECLARE_INTERFACE(INTERFACE) \ diff --git a/src/declarative/qml/qmllist.h b/src/declarative/qml/qmllist.h index ad2d874..b1a81c4 100644 --- a/src/declarative/qml/qmllist.h +++ b/src/declarative/qml/qmllist.h @@ -119,6 +119,72 @@ class Qml_ProxyList_ ##ListName : public QmlList \ friend class Qml_ProxyList_ ##ListName ; \ Qml_ProxyList_##ListName ListName; +template +struct QmlListProperty { + typedef void (*AppendFunction)(QmlListProperty *, T*); + typedef int (*CountFunction)(QmlListProperty *); + typedef T *(*AtFunction)(QmlListProperty *, int); + typedef void (*ClearFunction)(QmlListProperty *); + typedef void (*InsertFunction)(QmlListProperty *, int, T *); + typedef void (*RemoveAtFunction)(QmlListProperty *, int); + + QmlListProperty() + : version(1), object(0), data(0), append(0), count(0), at(0), clear(0), insert(0), removeAt(0) {} + QmlListProperty(QObject *o, QList &list) + : version(1), object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at), + clear(qlist_clear), insert(qlist_insert), removeAt(qlist_removeAt) {} + QmlListProperty(QObject *o, void *d, AppendFunction a, CountFunction c = 0, AtFunction t = 0, + ClearFunction l = 0, InsertFunction i = 0, RemoveAtFunction r = 0) + : version(1), object(o), data(d), append(a), count(c), at(t), clear(l), insert(i), removeAt(r) {} + + bool operator==(const QmlListProperty &o) const { + return version == o.version && + object == o.object && + data == o.data && + append == o.append && + count == o.count && + at == o.at && + clear == o.clear && + insert == o.insert && + removeAt == o.removeAt; + } + + int version; + + QObject *object; + void *data; + + AppendFunction append; + + CountFunction count; + AtFunction at; + + ClearFunction clear; + + InsertFunction insert; + RemoveAtFunction removeAt; + +private: + static void qlist_append(QmlListProperty *p, T *v) { + ((QList *)p->data)->append(v); + } + static int qlist_count(QmlListProperty *p) { + return ((QList *)p->data)->count(); + } + static T *qlist_at(QmlListProperty *p, int idx) { + return ((QList *)p->data)->at(idx); + } + static void qlist_clear(QmlListProperty *p) { + return ((QList *)p->data)->clear(); + } + static void qlist_insert(QmlListProperty *p, int idx, T *v) { + return ((QList *)p->data)->insert(idx, v); + } + static void qlist_removeAt(QmlListProperty *p, int idx) { + return ((QList *)p->data)->removeAt(idx); + } +}; + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/declarative/qml/qmllistscriptclass.cpp b/src/declarative/qml/qmllistscriptclass.cpp index d4cdc6e..caa4e4e 100644 --- a/src/declarative/qml/qmllistscriptclass.cpp +++ b/src/declarative/qml/qmllistscriptclass.cpp @@ -111,27 +111,31 @@ QmlListScriptClass::ScriptValue QmlListScriptClass::property(Object *obj, const if (!data->object) return Value(); - void *list = 0; - void *args[] = { &list, 0 }; - QMetaObject::metacall(data->object, QMetaObject::ReadProperty, - data->propertyIdx, args); + if (data->type == ListProperty) { + QmlListProperty list; + void *args[] = { &list, 0 }; - if (!list) - return Value(); - - if (data->type == QListPtr) { - const QList &qlist = *((QList*)list); + QMetaObject::metacall(data->object, QMetaObject::ReadProperty, + data->propertyIdx, args); - quint32 count = qlist.count(); + quint32 count = list.count(&list); if (name == m_lengthId.identifier) return Value(scriptEngine, count); else if (lastIndex < count) - return Value(scriptEngine, enginePriv->objectClass->newQObject(qlist.at(lastIndex))); + return Value(scriptEngine, enginePriv->objectClass->newQObject(list.at(&list, lastIndex))); else return Value(); } else { + void *list = 0; + void *args[] = { &list, 0 }; + QMetaObject::metacall(data->object, QMetaObject::ReadProperty, + data->propertyIdx, args); + + if (!list) + return Value(); + Q_ASSERT(data->type == QmlListPtr); const QmlList &qmllist = *((QmlList*)list); @@ -155,18 +159,29 @@ QVariant QmlListScriptClass::toVariant(Object *obj, bool *ok) return QVariant(); } - void *list = 0; - void *args[] = { &list, 0 }; - QMetaObject::metacall(data->object, QMetaObject::ReadProperty, - data->propertyIdx, args); + if (data->type == QmlListScriptClass::QmlListPtr) { + void *list = 0; + void *args[] = { &list, 0 }; + QMetaObject::metacall(data->object, QMetaObject::ReadProperty, + data->propertyIdx, args); - if (!list) { - if (ok) *ok = false; - return QVariant(); - } + if (!list) { + if (ok) *ok = false; + return QVariant(); + } + + if (ok) *ok = true; + return QVariant(data->propertyType, &list); + } else { + QmlListProperty list; + void *args[] = { &list, 0 }; + + QMetaObject::metacall(data->object, QMetaObject::ReadProperty, + data->propertyIdx, args); - if (ok) *ok = true; - return QVariant(data->propertyType, &list); + if (ok) *ok = true; + return QVariant(data->propertyType, &list); + } } QT_END_NAMESPACE diff --git a/src/declarative/qml/qmllistscriptclass_p.h b/src/declarative/qml/qmllistscriptclass_p.h index e484b34..464f91e 100644 --- a/src/declarative/qml/qmllistscriptclass_p.h +++ b/src/declarative/qml/qmllistscriptclass_p.h @@ -64,7 +64,7 @@ public: QmlListScriptClass(QmlEngine *); ~QmlListScriptClass(); - enum ListCategory { QListPtr, QmlListPtr }; + enum ListCategory { ListProperty, QmlListPtr }; QScriptValue newList(QObject *, int, ListCategory, int); protected: diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index 70f9ad3..fc11bd6 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -889,7 +889,8 @@ bool QmlMetaPropertyPrivate::write(QObject *object, const QmlPropertyCache::Data QVariant listVar = prop.read(object); QmlMetaType::clear(listVar); for (int ii = 0; ii < list.count(); ++ii) { - QVariant v = QmlMetaType::qmlType(listType)->fromObject(list.at(ii)); + QObject *o = list.at(ii); + QVariant v = QVariant(listType, &o); QmlMetaType::append(listVar, v); } diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index 7dfc48d..e613b7c 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -125,7 +125,7 @@ public: int m_version_maj; int m_version_min; int m_typeId; int m_listId; int m_qmlListId; - QmlPrivate::Func m_opFunc; + QObject *(*m_newFunc)(); const QMetaObject *m_baseMetaObject; QmlAttachedPropertiesFunc m_attachedPropertiesFunc; const QMetaObject *m_attachedPropertiesType; @@ -142,15 +142,14 @@ public: QmlTypePrivate::QmlTypePrivate() : m_isInterface(false), m_iid(0), m_typeId(0), m_listId(0), m_qmlListId(0), - m_opFunc(0), m_baseMetaObject(0), m_attachedPropertiesFunc(0), m_attachedPropertiesType(0), + m_newFunc(0), m_baseMetaObject(0), m_attachedPropertiesFunc(0), m_attachedPropertiesType(0), m_parserStatusCast(-1), m_propertyValueSourceCast(-1), m_propertyValueInterceptorCast(-1), m_extFunc(0), m_extMetaObject(0), m_index(-1), m_customParser(0), m_isSetup(false) { } -QmlType::QmlType(int type, int listType, int qmlListType, - QmlPrivate::Func opFunc, const char *iid, int index) +QmlType::QmlType(int type, int listType, int qmlListType, const char *iid, int index) : d(new QmlTypePrivate) { d->m_isInterface = true; @@ -158,7 +157,7 @@ QmlType::QmlType(int type, int listType, int qmlListType, d->m_typeId = type; d->m_listId = listType; d->m_qmlListId = qmlListType; - d->m_opFunc = opFunc; + d->m_newFunc = 0; d->m_index = index; d->m_isSetup = true; d->m_version_maj = 0; @@ -166,7 +165,7 @@ QmlType::QmlType(int type, int listType, int qmlListType, } QmlType::QmlType(int type, int listType, int qmlListType, - QmlPrivate::Func opFunc, const char *qmlName, + QObject *(*newFunc)(), const char *qmlName, int version_maj, int version_min, const QMetaObject *metaObject, QmlAttachedPropertiesFunc attachedPropertiesFunc, @@ -183,7 +182,7 @@ QmlType::QmlType(int type, int listType, int qmlListType, d->m_typeId = type; d->m_listId = listType; d->m_qmlListId = qmlListType; - d->m_opFunc = opFunc; + d->m_newFunc = newFunc; d->m_baseMetaObject = metaObject; d->m_attachedPropertiesFunc = attachedPropertiesFunc; d->m_attachedPropertiesType = attachedType; @@ -283,10 +282,7 @@ QObject *QmlType::create() const { d->init(); - QVariant v; - QObject *rv = 0; - d->m_opFunc(QmlPrivate::Create, 0, v, v, (void **)&rv); - + QObject *rv = d->m_newFunc(); if (rv && !d->m_metaObjects.isEmpty()) (void *)new QmlProxyMetaObject(rv, &d->m_metaObjects); @@ -321,29 +317,35 @@ int QmlType::qmlListTypeId() const void QmlType::listClear(const QVariant &list) { Q_ASSERT(list.userType() == qListTypeId()); - QVariant arg; - d->m_opFunc(QmlPrivate::Clear, 0, list, arg, 0); + QmlListProperty *l = (QmlListProperty *)list.data(); + if (l->clear) l->clear(l); } void QmlType::listAppend(const QVariant &list, const QVariant &item) { Q_ASSERT(list.userType() == qListTypeId()); - d->m_opFunc(QmlPrivate::Append, 0, list, item, 0); + QmlListProperty *l = (QmlListProperty *)list.data(); + if (l->append) l->append(l, *(void **)item.data()); } QVariant QmlType::listAt(const QVariant &list, int idx) { Q_ASSERT(list.userType() == qListTypeId()); - QVariant rv; - void *ptr = (void *)&rv; - d->m_opFunc(QmlPrivate::Value, idx, list, QVariant(), &ptr); - return rv; + QmlListProperty *l = (QmlListProperty *)list.data(); + if (l->at) { + void *v = l->at(l, idx); + return QVariant(typeId(), &v); + } else { + return QVariant(); + } } int QmlType::listCount(const QVariant &list) { Q_ASSERT(list.userType() == qListTypeId()); - return d->m_opFunc(QmlPrivate::Length, 0, list, QVariant(), 0); + QmlListProperty *l = (QmlListProperty *)list.data(); + if (l->count) return l->count(l); + return 0; } const QMetaObject *QmlType::metaObject() const @@ -387,15 +389,6 @@ int QmlType::propertyValueInterceptorCast() const return d->m_propertyValueInterceptorCast; } -QVariant QmlType::fromObject(QObject *obj) const -{ - QVariant rv; - QVariant *v_ptr = &rv; - QVariant vobj = QVariant::fromValue(obj); - d->m_opFunc(QmlPrivate::FromObject, 0, QVariant(), vobj, (void **)&v_ptr); - return rv; -} - const char *QmlType::interfaceIId() const { return d->m_iid; @@ -407,7 +400,6 @@ int QmlType::index() const } int QmlMetaType::registerInterface(const QmlPrivate::MetaTypeIds &id, - QmlPrivate::Func listFunction, const char *iid) { QWriteLocker lock(metaTypeDataLock()); @@ -416,7 +408,7 @@ int QmlMetaType::registerInterface(const QmlPrivate::MetaTypeIds &id, int index = data->types.count(); QmlType *type = new QmlType(id.typeId, id.listId, id.qmlListId, - listFunction, iid, index); + iid, index); data->types.append(type); data->idToType.insert(type->typeId(), type); @@ -439,7 +431,7 @@ int QmlMetaType::registerInterface(const QmlPrivate::MetaTypeIds &id, return index; } -int QmlMetaType::registerType(const QmlPrivate::MetaTypeIds &id, QmlPrivate::Func func, +int QmlMetaType::registerType(const QmlPrivate::MetaTypeIds &id, QObject *(*func)(), const char *uri, int version_maj, int version_min, const char *cname, const QMetaObject *mo, QmlAttachedPropertiesFunc attach, const QMetaObject *attachMo, int pStatus, int object, int valueSource, int valueInterceptor, QmlPrivate::CreateFunc extFunc, const QMetaObject *extmo, QmlCustomParser *parser) diff --git a/src/declarative/qml/qmlmetatype.h b/src/declarative/qml/qmlmetatype.h index 45ec11d..1d9c096 100644 --- a/src/declarative/qml/qmlmetatype.h +++ b/src/declarative/qml/qmlmetatype.h @@ -46,6 +46,7 @@ #include "qmlparserstatus.h" #include "qmlpropertyvaluesource.h" #include "qmlpropertyvalueinterceptor.h" +#include "qmllist.h" #include #include @@ -62,8 +63,8 @@ class QmlCustomParser; class Q_DECLARATIVE_EXPORT QmlMetaType { public: - static int registerType(const QmlPrivate::MetaTypeIds &, QmlPrivate::Func, const char *, int vmaj, int vmin, const char *qmlName, const QMetaObject *, QmlAttachedPropertiesFunc, const QMetaObject *, int pStatus, int object, int valueSource, int valueInterceptor, QmlPrivate::CreateFunc extFunc, const QMetaObject *extmo, QmlCustomParser *); - static int registerInterface(const QmlPrivate::MetaTypeIds &, QmlPrivate::Func, const char *); + static int registerType(const QmlPrivate::MetaTypeIds &, QObject *(*)(), const char *, int vmaj, int vmin, const char *qmlName, const QMetaObject *, QmlAttachedPropertiesFunc, const QMetaObject *, int pStatus, int object, int valueSource, int valueInterceptor, QmlPrivate::CreateFunc extFunc, const QMetaObject *extmo, QmlCustomParser *); + static int registerInterface(const QmlPrivate::MetaTypeIds &, const char *); static bool copy(int type, void *data, const void *copy = 0); @@ -147,8 +148,8 @@ private: friend class QmlMetaType; friend class QmlTypePrivate; friend struct QmlMetaTypeData; - QmlType(int, int, int, QmlPrivate::Func, const char *, int); - QmlType(int, int, int, QmlPrivate::Func, const char *, int, int, const QMetaObject *, QmlAttachedPropertiesFunc, const QMetaObject *, int, int, int, QmlPrivate::CreateFunc, const QMetaObject *, int, QmlCustomParser *); + QmlType(int, int, int, const char *, int); + QmlType(int, int, int, QObject *(*)(), const char *, int, int, const QMetaObject *, QmlAttachedPropertiesFunc, const QMetaObject *, int, int, int, QmlPrivate::CreateFunc, const QMetaObject *, int, QmlCustomParser *); ~QmlType(); QmlTypePrivate *d; @@ -160,11 +161,11 @@ int qmlRegisterType(const char *typeName) QByteArray name(typeName); QmlPrivate::MetaTypeIds ids = { qRegisterMetaType(QByteArray(name + '*').constData()), - qRegisterMetaType(QByteArray("QList<" + name + "*>*").constData()), - qRegisterMetaType(QByteArray("QmlList<" + name + "*>*").constData()) + qRegisterMetaType >(QByteArray("QmlListProperty<" + name + ">").constData()), + qRegisterMetaType*>(QByteArray("QmlList<" + name + "*>*").constData()) }; - return QmlMetaType::registerType(ids, QmlPrivate::list_nocreate_op, 0, 0, 0, 0, + return QmlMetaType::registerType(ids, 0, 0, 0, 0, 0, &T::staticMetaObject, QmlPrivate::attachedPropertiesFunc(), QmlPrivate::attachedPropertiesMetaObject(), @@ -181,11 +182,11 @@ int qmlRegisterType(const char *uri, int version_maj, int version_min, const cha QByteArray name(typeName); QmlPrivate::MetaTypeIds ids = { qRegisterMetaType(QByteArray(name + '*').constData()), - qRegisterMetaType(QByteArray("QList<" + name + "*>*").constData()), - qRegisterMetaType(QByteArray("QmlList<" + name + "*>*").constData()) + qRegisterMetaType >(QByteArray("QmlListProperty<" + name + ">").constData()), + qRegisterMetaType*>(QByteArray("QmlList<" + name + "*>*").constData()) }; - return QmlMetaType::registerType(ids, QmlPrivate::list_op, + return QmlMetaType::registerType(ids, QmlPrivate::create, uri, version_maj, version_min, qmlName, &T::staticMetaObject, QmlPrivate::attachedPropertiesFunc(), @@ -203,8 +204,8 @@ int qmlRegisterExtendedType(const char *typeName) QByteArray name(typeName); QmlPrivate::MetaTypeIds ids = { qRegisterMetaType(QByteArray(name + '*').constData()), - qRegisterMetaType(QByteArray("QList<" + name + "*>*").constData()), - qRegisterMetaType(QByteArray("QmlList<" + name + "*>*").constData()) + qRegisterMetaType >(QByteArray("QmlListProperty<" + name + ">").constData()), + qRegisterMetaType*>(QByteArray("QmlList<" + name + "*>*").constData()) }; QmlAttachedPropertiesFunc attached = @@ -216,7 +217,7 @@ int qmlRegisterExtendedType(const char *typeName) attachedMo = QmlPrivate::attachedPropertiesMetaObject(); } - return QmlMetaType::registerType(ids, QmlPrivate::list_nocreate_op, 0, 0, 0, 0, + return QmlMetaType::registerType(ids, 0, 0, 0, 0, 0, &T::staticMetaObject, attached, attachedMo, QmlPrivate::StaticCastSelector::cast(), QmlPrivate::StaticCastSelector::cast(), @@ -231,8 +232,8 @@ int qmlRegisterExtendedType(const char *uri, int version_maj, int version_min, c QByteArray name(typeName); QmlPrivate::MetaTypeIds ids = { qRegisterMetaType(QByteArray(name + '*').constData()), - qRegisterMetaType(QByteArray("QList<" + name + "*>*").constData()), - qRegisterMetaType(QByteArray("QmlList<" + name + "*>*").constData()) + qRegisterMetaType >(QByteArray("QmlListProperty<" + name + ">").constData()), + qRegisterMetaType*>(QByteArray("QmlList<" + name + "*>*").constData()) }; QmlAttachedPropertiesFunc attached = @@ -244,7 +245,7 @@ int qmlRegisterExtendedType(const char *uri, int version_maj, int version_min, c attachedMo = QmlPrivate::attachedPropertiesMetaObject(); } - return QmlMetaType::registerType(ids, QmlPrivate::list_op, + return QmlMetaType::registerType(ids, QmlPrivate::create, uri, version_maj, version_min, qmlName, &T::staticMetaObject, attached, attachedMo, @@ -262,13 +263,11 @@ int qmlRegisterInterface(const char *typeName) QByteArray name(typeName); QmlPrivate::MetaTypeIds ids = { qRegisterMetaType(QByteArray(name + '*').constData()), - qRegisterMetaType(QByteArray("QList<" + name + "*>*").constData()), - qRegisterMetaType(QByteArray("QmlList<" + name + "*>*").constData()) + qRegisterMetaType >(QByteArray("QmlListProperty<" + name + ">").constData()), + qRegisterMetaType*>(QByteArray("QmlList<" + name + "*>*").constData()) }; - return QmlMetaType::registerInterface(ids, - QmlPrivate::list_interface_op, - qobject_interface_iid()); + return QmlMetaType::registerInterface(ids, qobject_interface_iid()); } template @@ -277,11 +276,11 @@ int qmlRegisterCustomType(const char *uri, int version_maj, int version_min, con QByteArray name(typeName); QmlPrivate::MetaTypeIds ids = { qRegisterMetaType(QByteArray(name + '*').constData()), - qRegisterMetaType(QByteArray("QList<" + name + "*>*").constData()), - qRegisterMetaType(QByteArray("QmlList<" + name + "*>*").constData()) + qRegisterMetaType >(QByteArray("QmlListProperty<" + name + ">").constData()), + qRegisterMetaType*>(QByteArray("QmlList<" + name + "*>*").constData()) }; - return QmlMetaType::registerType(ids, QmlPrivate::list_op, + return QmlMetaType::registerType(ids, QmlPrivate::create, uri, version_maj, version_min, qmlName, &T::staticMetaObject, QmlPrivate::attachedPropertiesFunc(), diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp index 1c41d46..75b5c08 100644 --- a/src/declarative/qml/qmlobjectscriptclass.cpp +++ b/src/declarative/qml/qmlobjectscriptclass.cpp @@ -239,7 +239,7 @@ QmlObjectScriptClass::property(QObject *obj, const Identifier &name) } if (lastData->flags & QmlPropertyCache::Data::IsQList) { - return Value(scriptEngine, enginePriv->listClass->newList(obj, lastData->coreIndex, QmlListScriptClass::QListPtr, lastData->propType)); + return Value(scriptEngine, enginePriv->listClass->newList(obj, lastData->coreIndex, QmlListScriptClass::ListProperty, lastData->propType)); } else if (lastData->flags & QmlPropertyCache::Data::IsQmlList) { return Value(scriptEngine, enginePriv->listClass->newList(obj, lastData->coreIndex, QmlListScriptClass::QmlListPtr, lastData->propType)); } else if (lastData->flags & QmlPropertyCache::Data::IsQObjectDerived) { diff --git a/src/declarative/qml/qmlprivate.h b/src/declarative/qml/qmlprivate.h index dd98110..c367497 100644 --- a/src/declarative/qml/qmlprivate.h +++ b/src/declarative/qml/qmlprivate.h @@ -85,26 +85,8 @@ namespace QmlPrivate virtual void clear() = 0; }; - enum ListOp { Append, Set, Insert, Prepend, Length, FromObject, - Object, Create, Value, Clear }; - - template - int list_op(ListOp op, int val, - const QVariant &vlist, - const QVariant &value, - void **out); - template - int list_nocreate_op(ListOp op, int val, - const QVariant &vlist, - const QVariant &value, - void **out); - - template - int list_interface_op(ListOp op, int val, - const QVariant &vlist, - const QVariant &value, - void **out); + QObject *create() { return new T; } template struct StaticCastSelectorClass @@ -203,7 +185,6 @@ namespace QmlPrivate int listId; int qmlListId; }; - typedef int (*Func)(QmlPrivate::ListOp, int, const QVariant &, const QVariant &, void **); typedef QObject *(*CreateFunc)(QObject *); template @@ -237,148 +218,6 @@ namespace QmlPrivate }; } -template -int QmlPrivate::list_op(QmlPrivate::ListOp op, int val, - const QVariant &vlist, - const QVariant &value, - void **out) -{ - if (op == QmlPrivate::Create) { - QObject *obj = static_cast(new T); - *((QObject **)out) = obj; - return 0; - } - QList *list = vlist.value *>(); - switch(op) { - case QmlPrivate::Append: - list->append(value.value()); - break; - case QmlPrivate::Set: - (*list)[val] = value.value(); - break; - case QmlPrivate::Insert: - list->insert(val, value.value()); - break; - case QmlPrivate::Prepend: - list->prepend(value.value()); - break; - case QmlPrivate::Length: - return list->count(); - break; - case QmlPrivate::Clear: - list->clear(); - return 0; - break; - case QmlPrivate::Create: - break; - case QmlPrivate::Object: - *out = static_cast(value.value()); - break; - case QmlPrivate::FromObject: - { - QObject *fromObj = value.value(); - T *me = qobject_cast(fromObj); - if (me) { - *((QVariant *)*out) = QVariant::fromValue(me); - } - } - break; - case QmlPrivate::Value: - if (list->count() <= val) *((QVariant *)*out) = QVariant(); - else *((QVariant *)*out) = QVariant::fromValue(list->at(val)); - break; - } - return 0; -} - -template -int QmlPrivate::list_nocreate_op(QmlPrivate::ListOp op, int val, - const QVariant &vlist, - const QVariant &value, - void **out) -{ - QList *list = vlist.value *>(); - switch(op) { - case QmlPrivate::Append: - list->append(value.value()); - break; - case QmlPrivate::Set: - (*list)[val] = value.value(); - break; - case QmlPrivate::Insert: - list->insert(val, value.value()); - break; - case QmlPrivate::Prepend: - list->prepend(value.value()); - break; - case QmlPrivate::Length: - return list->count(); - break; - case QmlPrivate::Clear: - list->clear(); - return 0; - break; - case QmlPrivate::Create: - break; - case QmlPrivate::Object: - *out = static_cast(value.value()); - break; - case QmlPrivate::FromObject: - { - QObject *fromObj = value.value(); - T *me = qobject_cast(fromObj); - if (me) { - *((QVariant *)*out) = QVariant::fromValue(me); - } - } - break; - case QmlPrivate::Value: - *((QVariant *)*out) = QVariant::fromValue(list->at(val)); - break; - } - return 0; -} - -template -int QmlPrivate::list_interface_op(QmlPrivate::ListOp op, int val, - const QVariant &vlist, - const QVariant &value, - void **out) -{ - QList *list = vlist.value *>(); - switch(op) { - case QmlPrivate::Append: - list->append(value.value()); - break; - case QmlPrivate::Set: - (*list)[val] = value.value(); - break; - case QmlPrivate::Insert: - list->insert(val, value.value()); - break; - case QmlPrivate::Prepend: - list->prepend(value.value()); - break; - case QmlPrivate::Length: - return list->count(); - break; - case QmlPrivate::Clear: - list->clear(); - return 0; - break; - case QmlPrivate::Create: - break; - case QmlPrivate::Object: - break; - case QmlPrivate::FromObject: - break; - case QmlPrivate::Value: - *((QVariant *)*out) = QVariant::fromValue(list->at(val)); - break; - } - return 0; -} - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index e9a0449..4ab205e 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -91,14 +91,15 @@ QmlVME::QmlVME() struct ListInstance { - ListInstance() {} - ListInstance(QList *q, int t) - : type(t), qListInterface(q), qmlListInterface(0) {} + ListInstance() + : type(0), qmlListInterface(0) {} + ListInstance(int t) + : type(t), qmlListInterface(0) {} ListInstance(QmlPrivate::ListInterface *q, int t) - : type(t), qListInterface(0), qmlListInterface(q) {} + : type(t), qmlListInterface(q) {} int type; - QList *qListInterface; + QmlListProperty qListProperty; QmlPrivate::ListInterface *qmlListInterface; }; @@ -669,7 +670,7 @@ QObject *QmlVME::run(QmlVMEStack &stack, QmlContext *ctxt, QObject *assign = stack.pop(); const ListInstance &list = qliststack.top(); - list.qListInterface->append((void *)assign); + list.qListProperty.append((QmlListProperty*)&list.qListProperty, assign); } break; @@ -694,7 +695,7 @@ QObject *QmlVME::run(QmlVMEStack &stack, QmlContext *ctxt, void *d = (void *)&ptr; list.qmlListInterface->append(d); } else { - list.qListInterface->append(ptr); + list.qListProperty.append((QmlListProperty*)&list.qListProperty, ptr); } } break; @@ -772,17 +773,12 @@ QObject *QmlVME::run(QmlVMEStack &stack, QmlContext *ctxt, { QObject *target = stack.top(); + qliststack.push(ListInstance(instr.fetchQmlList.type)); + void *a[1]; - // We know that QList* can be converted to - // QList* - QList *list = 0; - a[0] = &list; + a[0] = (void *)&(qliststack.top().qListProperty); QMetaObject::metacall(target, QMetaObject::ReadProperty, instr.fetchQmlList.property, a); - if (!list) - VME_EXCEPTION(QCoreApplication::translate("QmlVME","Cannot assign to null list")); - - qliststack.push(ListInstance(list, instr.fetchQmlList.type)); } break; diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index abffefe..4f68b6c 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -947,10 +947,10 @@ void QmlPropertyAction::setProperties(const QString &p) \sa exclude matchProperties PropertyAnimation::matchTargets */ -QList *QmlPropertyAction::targets() +QmlListProperty QmlPropertyAction::targets() { Q_D(QmlPropertyAction); - return &d->targets; + return QmlListProperty(this, d->targets); } /*! @@ -958,10 +958,10 @@ QList *QmlPropertyAction::targets() This property holds the objects not to be affected by this animation. \sa matchTargets */ -QList *QmlPropertyAction::exclude() +QmlListProperty QmlPropertyAction::exclude() { Q_D(QmlPropertyAction); - return &d->exclude; + return QmlListProperty(this, d->exclude); } /*! @@ -2097,10 +2097,10 @@ void QmlPropertyAnimation::setProperties(const QString &prop) \sa exclude matchProperties */ -QList *QmlPropertyAnimation::targets() +QmlListProperty QmlPropertyAnimation::targets() { Q_D(QmlPropertyAnimation); - return &d->targets; + return QmlListProperty(this, d->targets); } /*! @@ -2108,10 +2108,10 @@ QList *QmlPropertyAnimation::targets() This property holds the items not to be affected by this animation. \sa matchTargets */ -QList *QmlPropertyAnimation::exclude() +QmlListProperty QmlPropertyAnimation::exclude() { Q_D(QmlPropertyAnimation); - return &d->exclude; + return QmlListProperty(this, d->exclude); } void QmlPropertyAnimationPrivate::valueChanged(qreal r) diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index 6a69e4d..a566074 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -187,8 +187,8 @@ class QmlPropertyAction : public QmlAbstractAnimation Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged) Q_PROPERTY(QString matchProperties READ properties WRITE setProperties NOTIFY propertiesChanged) - Q_PROPERTY(QList* matchTargets READ targets) - Q_PROPERTY(QList* exclude READ exclude) + Q_PROPERTY(QmlListProperty matchTargets READ targets) + Q_PROPERTY(QmlListProperty exclude READ exclude) Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) public: @@ -204,8 +204,8 @@ public: QString properties() const; void setProperties(const QString &); - QList *targets(); - QList *exclude(); + QmlListProperty targets(); + QmlListProperty exclude(); QVariant value() const; void setValue(const QVariant &); @@ -267,8 +267,8 @@ class Q_AUTOTEST_EXPORT QmlPropertyAnimation : public QmlAbstractAnimation Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged) Q_PROPERTY(QString matchProperties READ properties WRITE setProperties NOTIFY propertiesChanged) - Q_PROPERTY(QList* matchTargets READ targets) - Q_PROPERTY(QList* exclude READ exclude) + Q_PROPERTY(QmlListProperty matchTargets READ targets) + Q_PROPERTY(QmlListProperty exclude READ exclude) public: QmlPropertyAnimation(QObject *parent=0); @@ -295,8 +295,8 @@ public: QString properties() const; void setProperties(const QString &); - QList *targets(); - QList *exclude(); + QmlListProperty targets(); + QmlListProperty exclude(); protected: virtual void transition(QmlStateActions &actions, diff --git a/src/declarative/util/qmllistaccessor.cpp b/src/declarative/util/qmllistaccessor.cpp index 6658949..2e37d49 100644 --- a/src/declarative/util/qmllistaccessor.cpp +++ b/src/declarative/util/qmllistaccessor.cpp @@ -88,7 +88,7 @@ void QmlListAccessor::setList(const QVariant &v, QmlEngine *engine) (enginePrivate && enginePrivate->isQmlList(d.userType()))) { m_type = QmlList; } else if (QmlMetaType::isList(d.userType())) { - m_type = QListPtr; + m_type = ListProperty; } else { m_type = Instance; } @@ -106,10 +106,11 @@ int QmlListAccessor::count() const QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData(); return li->count(); } - case QListPtr: + case ListProperty: { - QList *li = *(QList **)d.constData(); - return li->count(); + QmlListProperty *li = (QmlListProperty*)d.constData(); + if (li->count) return li->count(li); + else return 0; } case Instance: return 1; @@ -136,11 +137,11 @@ QVariant QmlListAccessor::at(int idx) const li->at(idx, ptr); return QVariant::fromValue((QObject*)ptr[0]); } - case QListPtr: + case ListProperty: { - QList *li = *(QList **)d.constData(); - void *ptr = li->at(idx); - return QVariant::fromValue((QObject*)ptr); + QmlListProperty *li = (QmlListProperty*)d.constData(); + if (li->at) return QVariant::fromValue((QObject *)li->at(li, idx)); + else return QVariant(); } case Instance: return d; @@ -161,10 +162,10 @@ bool QmlListAccessor::append(const QVariant &value) li->append(const_cast(value.constData())); //XXX Typesafety return true; } - case QListPtr: + case ListProperty: { - QList *li = *(QList **)d.constData(); - li->append(*reinterpret_cast(const_cast(value.constData()))); //XXX Typesafety + QmlListProperty *li = (QmlListProperty*)d.constData(); + if (li->append) li->append(li, *(void **)value.constData()); // XXX Typesafety return true; } case StringList: @@ -186,10 +187,10 @@ bool QmlListAccessor::insert(int index, const QVariant &value) li->insert(index, const_cast(value.constData())); //XXX Typesafety return true; } - case QListPtr: + case ListProperty: { - QList *li = *(QList**)d.constData(); - li->insert(index, *reinterpret_cast(const_cast(value.constData()))); //XXX Typesafety + QmlListProperty *li = (QmlListProperty*)d.constData(); + if (li->insert) li->insert(li, index, *(void **)value.constData()); // XXX Typesafety return true; } case StringList: @@ -211,10 +212,10 @@ bool QmlListAccessor::removeAt(int index) li->removeAt(index); return true; } - case QListPtr: + case ListProperty: { - QList *li = *(QList**)d.constData(); - li->removeAt(index); + QmlListProperty *li = (QmlListProperty*)d.constData(); + if (li->removeAt) li->removeAt(li, index); return true; } case StringList: @@ -236,10 +237,10 @@ bool QmlListAccessor::clear() li->clear(); return true; } - case QListPtr: + case ListProperty: { - QList *li = *(QList**)d.constData(); - li->clear(); + QmlListProperty *li = (QmlListProperty*)d.constData(); + if (li->clear) li->clear(li); return true; } case StringList: diff --git a/src/declarative/util/qmllistaccessor_p.h b/src/declarative/util/qmllistaccessor_p.h index 3c67e3a..6866150 100644 --- a/src/declarative/util/qmllistaccessor_p.h +++ b/src/declarative/util/qmllistaccessor_p.h @@ -70,7 +70,7 @@ public: bool removeAt(int); bool clear(); - enum Type { Invalid, StringList, VariantList, QmlList, QListPtr, Instance, Integer }; + enum Type { Invalid, StringList, VariantList, QmlList, ListProperty, Instance, Integer }; Type type() const { return m_type; } private: diff --git a/tests/auto/declarative/qmlecmascript/testtypes.h b/tests/auto/declarative/qmlecmascript/testtypes.h index 09c850d..b307d9c 100644 --- a/tests/auto/declarative/qmlecmascript/testtypes.h +++ b/tests/auto/declarative/qmlecmascript/testtypes.h @@ -78,7 +78,7 @@ class MyQmlObject : public QObject Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged) Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged) Q_PROPERTY(QmlList *objectQmlListProperty READ objectQmlListProperty CONSTANT) - Q_PROPERTY(QList *objectListProperty READ objectListProperty CONSTANT) + Q_PROPERTY(QmlListProperty objectListProperty READ objectListProperty CONSTANT) Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty) public: @@ -108,7 +108,7 @@ public: } QmlList *objectQmlListProperty() { return &m_objectQmlList; } - QList *objectListProperty() { return &m_objectQList; } + QmlListProperty objectListProperty() { return QmlListProperty(this, m_objectQList); } bool methodCalled() const { return m_methodCalled; } bool methodIntCalled() const { return m_methodIntCalled; } @@ -162,11 +162,11 @@ QML_DECLARE_TYPE(MyQmlObject); class MyQmlContainer : public QObject { Q_OBJECT - Q_PROPERTY(QList* children READ children CONSTANT) + Q_PROPERTY(QmlListProperty children READ children CONSTANT) public: MyQmlContainer() {} - QList *children() { return &m_children; } + QmlListProperty children() { return QmlListProperty(this, m_children); } private: QList m_children; diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp index 4edca69..f8a4f5a 100644 --- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp +++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp @@ -1612,7 +1612,7 @@ void tst_qmlecmascript::listToVariant() QObject *object = component.create(&context); QVERIFY(object != 0); - QCOMPARE(object->property("test"), QVariant::fromValue(container.children())); + QVERIFY(qvariant_cast >(object->property("test")) == container.children()); delete object; } diff --git a/tests/auto/declarative/qmllanguage/testtypes.h b/tests/auto/declarative/qmllanguage/testtypes.h index d6ca898..6cd4cb5 100644 --- a/tests/auto/declarative/qmllanguage/testtypes.h +++ b/tests/auto/declarative/qmllanguage/testtypes.h @@ -447,19 +447,20 @@ QML_DECLARE_TYPE(MyTypeObject); class MyContainer : public QObject { Q_OBJECT - Q_PROPERTY(QList* children READ children) - Q_PROPERTY(QList* qlistInterfaces READ qlistInterfaces) + Q_PROPERTY(QmlListProperty children READ children) + Q_PROPERTY(QmlListProperty qlistInterfaces READ qlistInterfaces) Q_PROPERTY(QmlList* qmllistInterfaces READ qmllistInterfaces) Q_CLASSINFO("DefaultProperty", "children"); public: MyContainer() {} - QList *children() { return &m_children; } - QList *qlistInterfaces() { return &m_interfaces; } + QmlListProperty children() { return QmlListProperty(this, m_children); } + QList *getChildren() { return &m_children; } + QmlListProperty qlistInterfaces() { return QmlListProperty(this, m_interfaces); } + QList *getQListInterfaces() { return &m_interfaces; } QmlList *qmllistInterfaces() { return &m_qmlinterfaces; } const QmlConcreteList &qmllistAccessor() const { return m_qmlinterfaces; } -private: QList m_children; QList m_interfaces; QmlConcreteList m_qmlinterfaces; diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp index 3029501..1e68f5a 100644 --- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp +++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp @@ -354,7 +354,7 @@ void tst_qmllanguage::simpleContainer() VERIFY_ERRORS(0); MyContainer *container= qobject_cast(component.create()); QVERIFY(container != 0); - QCOMPARE(container->children()->count(),2); + QCOMPARE(container->getChildren()->count(),2); } void tst_qmllanguage::interfaceProperty() @@ -384,9 +384,9 @@ void tst_qmllanguage::interfaceQList() VERIFY_ERRORS(0); MyContainer *container= qobject_cast(component.create()); QVERIFY(container != 0); - QVERIFY(container->qlistInterfaces()->count() == 2); + QVERIFY(container->getQListInterfaces()->count() == 2); for(int ii = 0; ii < 2; ++ii) - QVERIFY(container->qlistInterfaces()->at(ii)->id == 913); + QVERIFY(container->getQListInterfaces()->at(ii)->id == 913); } void tst_qmllanguage::assignObjectToSignal() @@ -425,8 +425,8 @@ void tst_qmllanguage::assignQmlComponent() VERIFY_ERRORS(0); MyContainer *object = qobject_cast(component.create()); QVERIFY(object != 0); - QVERIFY(object->children()->count() == 1); - QObject *child = object->children()->at(0); + QVERIFY(object->getChildren()->count() == 1); + QObject *child = object->getChildren()->at(0); QCOMPARE(child->property("x"), QVariant(10)); QCOMPARE(child->property("y"), QVariant(11)); } @@ -504,7 +504,7 @@ void tst_qmllanguage::rootAsQmlComponent() MyContainer *object = qobject_cast(component.create()); QVERIFY(object != 0); QCOMPARE(object->property("x"), QVariant(11)); - QCOMPARE(object->children()->count(), 2); + QCOMPARE(object->getChildren()->count(), 2); } // Tests that components can be specified inline @@ -514,8 +514,8 @@ void tst_qmllanguage::inlineQmlComponents() VERIFY_ERRORS(0); MyContainer *object = qobject_cast(component.create()); QVERIFY(object != 0); - QCOMPARE(object->children()->count(), 1); - QmlComponent *comp = qobject_cast(object->children()->at(0)); + QCOMPARE(object->getChildren()->count(), 1); + QmlComponent *comp = qobject_cast(object->getChildren()->at(0)); QVERIFY(comp != 0); MyQmlObject *compObject = qobject_cast(comp->create()); QVERIFY(compObject != 0); @@ -529,9 +529,9 @@ void tst_qmllanguage::idProperty() VERIFY_ERRORS(0); MyContainer *object = qobject_cast(component.create()); QVERIFY(object != 0); - QCOMPARE(object->children()->count(), 1); + QCOMPARE(object->getChildren()->count(), 1); MyTypeObject *child = - qobject_cast(object->children()->at(0)); + qobject_cast(object->getChildren()->at(0)); QVERIFY(child != 0); QCOMPARE(child->id(), QString("myObjectId")); QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child)); @@ -1034,13 +1034,13 @@ void tst_qmllanguage::defaultPropertyListOrder() MyContainer *container = qobject_cast(component.create()); QVERIFY(container != 0); - QCOMPARE(container->children()->count(), 6); - QCOMPARE(container->children()->at(0)->property("index"), QVariant(0)); - QCOMPARE(container->children()->at(1)->property("index"), QVariant(1)); - QCOMPARE(container->children()->at(2)->property("index"), QVariant(2)); - QCOMPARE(container->children()->at(3)->property("index"), QVariant(3)); - QCOMPARE(container->children()->at(4)->property("index"), QVariant(4)); - QCOMPARE(container->children()->at(5)->property("index"), QVariant(5)); + QCOMPARE(container->getChildren()->count(), 6); + QCOMPARE(container->getChildren()->at(0)->property("index"), QVariant(0)); + QCOMPARE(container->getChildren()->at(1)->property("index"), QVariant(1)); + QCOMPARE(container->getChildren()->at(2)->property("index"), QVariant(2)); + QCOMPARE(container->getChildren()->at(3)->property("index"), QVariant(3)); + QCOMPARE(container->getChildren()->at(4)->property("index"), QVariant(4)); + QCOMPARE(container->getChildren()->at(5)->property("index"), QVariant(5)); } void tst_qmllanguage::declaredPropertyValues() diff --git a/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp b/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp index ddf9a07..9bf47b6 100644 --- a/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp +++ b/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp @@ -52,7 +52,7 @@ public: private slots: void invalid(); void qmllist(); - void qlist(); + void listproperty(); void qstringlist(); void qvariantlist(); void qobject(); @@ -149,7 +149,7 @@ void tst_QmlListAccessor::qmllist() QCOMPARE(list.count(), 0); } -void tst_QmlListAccessor::qlist() +void tst_QmlListAccessor::listproperty() { QList list; QObject *obj = new QObject(this); @@ -161,11 +161,11 @@ void tst_QmlListAccessor::qlist() QCOMPARE(list.at(0), obj); QmlListAccessor accessor; - accessor.setList(qVariantFromValue((QList*)&list)); - QCOMPARE(accessor.list(), qVariantFromValue((QList*)&list)); + accessor.setList(qVariantFromValue(QmlListProperty(this, list))); + QVERIFY(qvariant_cast >(accessor.list()) == QmlListProperty(this, list)); // type - QCOMPARE(accessor.type(), QmlListAccessor::QListPtr); + QCOMPARE(accessor.type(), QmlListAccessor::ListProperty); // isValid QVERIFY(accessor.isValid()); -- cgit v0.12 From 1c486fb2c993c966970caf377498c5d5fb8421a2 Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 16 Feb 2010 16:48:42 +1000 Subject: Fix QTBUG-8090, improve original patch effectiveness. --- tools/qdoc3/cppcodemarker.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/tools/qdoc3/cppcodemarker.cpp b/tools/qdoc3/cppcodemarker.cpp index d9c767a..22562f3 100644 --- a/tools/qdoc3/cppcodemarker.cpp +++ b/tools/qdoc3/cppcodemarker.cpp @@ -881,7 +881,7 @@ QString CppCodeMarker::addMarkUp(const QString& protectedCode, static QRegExp globalX("[\n{()=] *([a-zA-Z_][a-zA-Z_0-9]*)[ \n]*\\("); static QRegExp multiLineComment("/(?:( )?\\*(?:[^*]+|\\*(?! /))*\\*\\1/)"); multiLineComment.setMinimal(true); - static QRegExp singleLineCommentLine("(?:^|\n)(?:[^&]|&(?!quot;)|"(?:[^&\\\\]|&(?!quot;)|\\\\"|\\\\(?!"))*")*//(?!!)[^!\n]*"); + static QRegExp singleLineCommentLine("(?:^|\n)(?:[^\n&]|&(?!quot;)|"(?:[^&\n\\\\]|&(?!quot;)|\\\\"|\\\\(?!"))*")*//(?!!)[^!\n]*"); static QRegExp singleLineComment("//(?!!)[^!\n]*"); static QRegExp preprocessor("(?:^|\n)(#[ \t]*(?:include|if|elif|endif|error|pragma|define" "|warning)(?:(?:\\\\\n|\\n#)[^\n]*)*)"); -- cgit v0.12 From b966e7ef9a7d0c826d62dfaa2d4a7b6399a7d9a3 Mon Sep 17 00:00:00 2001 From: Harald Fernengel Date: Tue, 16 Feb 2010 15:57:04 +0100 Subject: Fix palette on the N900 The N900 has by default black background with white text, but white line edits with black text. Use windowText for the "Score" label to make it readable. Reviewed-by: Alan Alpert --- demos/declarative/samegame/samegame.qml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/demos/declarative/samegame/samegame.qml b/demos/declarative/samegame/samegame.qml index c2557ae..f5c4fc5 100644 --- a/demos/declarative/samegame/samegame.qml +++ b/demos/declarative/samegame/samegame.qml @@ -89,7 +89,7 @@ Rectangle { text: "Score: " + gameCanvas.score; font.bold: true anchors.right: parent.right; anchors.rightMargin: 3 anchors.verticalCenter: parent.verticalCenter - color: activePalette.text + color: activePalette.windowText } } } -- cgit v0.12 From fcb42e9da411695faea723e9196be6549d46bbdb Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 16 Feb 2010 22:24:07 +0100 Subject: Expose LayoutItem documentation Also made it slightly more verbose. --- doc/src/declarative/elements.qdoc | 1 + src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp | 7 +++++++ 2 files changed, 8 insertions(+) diff --git a/doc/src/declarative/elements.qdoc b/doc/src/declarative/elements.qdoc index cfbabf2..1d9d166 100644 --- a/doc/src/declarative/elements.qdoc +++ b/doc/src/declarative/elements.qdoc @@ -143,6 +143,7 @@ The following table lists the QML elements provided by the Qt Declarative module \o \l Repeater \o \l SystemPalette \o \l GraphicsObjectContainer +\o \l LayoutItem \endlist \header diff --git a/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp b/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp index 98361dc..856a37f 100644 --- a/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslayoutitem.cpp @@ -50,6 +50,13 @@ QT_BEGIN_NAMESPACE /*! \qmlclass LayoutItem QmlGraphicsLayoutItem \brief The LayoutItem element allows you to place your Fluid UI elements inside a classical Qt layout. + + LayoutItem is a variant of Item with a couple of additional properties. These properties provide the size hints + needed for items to work in conjunction with Qt Layouts. The Qt Layout will resize the LayoutItem as appropriate, + taking its size hints into account, and you can propagate this to the other elements in your UI via anchors and bindings. + + This is a QGraphicsLayoutItem subclass, and the properties merely expose the QGraphicsLayoutItem functionality to QML. + See the QGraphicsLayoutItem documentation for further details. */ /*! -- cgit v0.12 From cd9a35494b664e60693c2aac987ab9d166c0f865 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 17 Feb 2010 08:05:12 +1000 Subject: Revert "Run dos2unix on these files." This reverts commit 3a96ecef0db619016cf132b16a99f2714215ebdd. --- .../qmlgraphicsloader/data/NoResizeGraphicsWidget.qml | 16 ++++++++-------- .../data/SizeGraphicsWidgetToLoader.qml | 16 ++++++++-------- .../data/SizeLoaderToGraphicsWidget.qml | 12 ++++++------ 3 files changed, 22 insertions(+), 22 deletions(-) diff --git a/tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml b/tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml index 5eab965..0704e18 100644 --- a/tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml +++ b/tests/auto/declarative/qmlgraphicsloader/data/NoResizeGraphicsWidget.qml @@ -1,8 +1,8 @@ -import Qt 4.6 - -Loader { - resizeMode: Loader.NoResize - source: "GraphicsWidget250x250.qml" - width: 200 - height: 80 -} +import Qt 4.6 + +Loader { + resizeMode: Loader.NoResize + source: "GraphicsWidget250x250.qml" + width: 200 + height: 80 +} diff --git a/tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml b/tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml index 568a136..97c72f4 100644 --- a/tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml +++ b/tests/auto/declarative/qmlgraphicsloader/data/SizeGraphicsWidgetToLoader.qml @@ -1,8 +1,8 @@ -import Qt 4.6 - -Loader { - resizeMode: Loader.SizeItemToLoader - width: 200 - height: 80 - source: "GraphicsWidget250x250.qml" -} +import Qt 4.6 + +Loader { + resizeMode: Loader.SizeItemToLoader + width: 200 + height: 80 + source: "GraphicsWidget250x250.qml" +} diff --git a/tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml b/tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml index a710803..cb72f05 100644 --- a/tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml +++ b/tests/auto/declarative/qmlgraphicsloader/data/SizeLoaderToGraphicsWidget.qml @@ -1,6 +1,6 @@ -import Qt 4.6 - -Loader { - resizeMode: Loader.SizeLoaderToItem - source: "GraphicsWidget250x250.qml" -} +import Qt 4.6 + +Loader { + resizeMode: Loader.SizeLoaderToItem + source: "GraphicsWidget250x250.qml" +} -- cgit v0.12 From 2c8fd4485a707000be2cb001fd8cd7f0398ff9a1 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 17 Feb 2010 10:29:23 +1000 Subject: Conditionally link webkit on wince --- tools/qmlviewer/qmlviewer.pro | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/tools/qmlviewer/qmlviewer.pro b/tools/qmlviewer/qmlviewer.pro index 35e4ba8..81c1e6c 100644 --- a/tools/qmlviewer/qmlviewer.pro +++ b/tools/qmlviewer/qmlviewer.pro @@ -41,8 +41,11 @@ wince* { QT += scripttools \ xml \ xmlpatterns \ - webkit \ phonon + + contains(QT_CONFIG, webkit) { + QT += webkit + } } symbian { # TARGET.UID3 = -- cgit v0.12 From 9853ac3587655c97cf7f6a7fe282c997c2b19f5e Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Wed, 17 Feb 2010 12:01:24 +1000 Subject: Make compile on Symbian (call Q_DECLARE_METATYPE earlier) --- src/declarative/debugger/qmldebug.cpp | 1 - src/declarative/debugger/qmldebug_p.h | 5 +++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/src/declarative/debugger/qmldebug.cpp b/src/declarative/debugger/qmldebug.cpp index 41e27bc..489eaa1 100644 --- a/src/declarative/debugger/qmldebug.cpp +++ b/src/declarative/debugger/qmldebug.cpp @@ -935,4 +935,3 @@ bool QmlDebugPropertyReference::hasNotifySignal() const QT_END_NAMESPACE -Q_DECLARE_METATYPE(QmlDebugObjectReference); diff --git a/src/declarative/debugger/qmldebug_p.h b/src/declarative/debugger/qmldebug_p.h index cd2adf6..58c66ec 100644 --- a/src/declarative/debugger/qmldebug_p.h +++ b/src/declarative/debugger/qmldebug_p.h @@ -361,6 +361,11 @@ private: QT_END_NAMESPACE +Q_DECLARE_METATYPE(QmlDebugEngineReference) +Q_DECLARE_METATYPE(QmlDebugObjectReference) +Q_DECLARE_METATYPE(QmlDebugContextReference) +Q_DECLARE_METATYPE(QmlDebugPropertyReference) + QT_END_HEADER #endif // QMLDEBUG_H -- cgit v0.12 From ddd1428cd15cc19e7d0b9a1adaba2f889d17111f Mon Sep 17 00:00:00 2001 From: Bea Lam Date: Wed, 17 Feb 2010 12:07:33 +1000 Subject: Declare QmlXmlListModelRole meta type before any code uses it. --- src/declarative/util/qmlxmllistmodel.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/src/declarative/util/qmlxmllistmodel.cpp b/src/declarative/util/qmlxmllistmodel.cpp index b2c2e61..df2102a 100644 --- a/src/declarative/util/qmlxmllistmodel.cpp +++ b/src/declarative/util/qmlxmllistmodel.cpp @@ -125,6 +125,10 @@ private: QString m_name; QString m_query; }; +QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlXmlListModelRole) +QT_BEGIN_NAMESPACE + class QmlXmlListModelPrivate; struct QmlXmlRoleList : public QmlConcreteList @@ -723,6 +727,4 @@ void QmlXmlListModel::queryCompleted(int id, int size) QT_END_NAMESPACE -QML_DECLARE_TYPE(QmlXmlListModelRole) - #include -- cgit v0.12 From 9f12ede32d9eaadde7b1f72cf2191f39d5780d57 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Wed, 17 Feb 2010 13:39:45 +1000 Subject: Revert "Replace QList<>* support with QmlListProperty" This was accidentally pushed early. This reverts commit 8454c53b304a4aba7c058b315041b3a38ad4fff5. --- src/declarative/graphicsitems/qmlgraphicsitem.cpp | 1 + src/declarative/graphicsitems/qmlgraphicsitem_p.h | 6 +- src/declarative/graphicsitems/qmlgraphicspath.cpp | 4 +- src/declarative/graphicsitems/qmlgraphicspath_p.h | 4 +- .../graphicsitems/qmlgraphicsrectangle_p.h | 4 +- .../graphicsitems/qmlgraphicsvisualitemmodel.cpp | 4 +- src/declarative/qml/qml.h | 4 +- src/declarative/qml/qmllist.h | 66 --------- src/declarative/qml/qmllistscriptclass.cpp | 57 +++---- src/declarative/qml/qmllistscriptclass_p.h | 2 +- src/declarative/qml/qmlmetaproperty.cpp | 3 +- src/declarative/qml/qmlmetatype.cpp | 54 ++++--- src/declarative/qml/qmlmetatype.h | 47 +++--- src/declarative/qml/qmlobjectscriptclass.cpp | 2 +- src/declarative/qml/qmlprivate.h | 163 ++++++++++++++++++++- src/declarative/qml/qmlvme.cpp | 26 ++-- src/declarative/util/qmlanimation.cpp | 16 +- src/declarative/util/qmlanimation_p.h | 16 +- src/declarative/util/qmllistaccessor.cpp | 41 +++--- src/declarative/util/qmllistaccessor_p.h | 2 +- tests/auto/declarative/qmlecmascript/testtypes.h | 8 +- .../qmlecmascript/tst_qmlecmascript.cpp | 2 +- tests/auto/declarative/qmllanguage/testtypes.h | 11 +- .../declarative/qmllanguage/tst_qmllanguage.cpp | 34 ++--- .../qmllistaccessor/tst_qmllistaccessor.cpp | 10 +- 25 files changed, 339 insertions(+), 248 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp index e10c919..2fbf18b 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp @@ -892,6 +892,7 @@ void QmlGraphicsKeyNavigationAttached::keyReleased(QKeyEvent *event) parameter provides information about the event. */ + const QmlGraphicsKeysAttached::SigMap QmlGraphicsKeysAttached::sigMap[] = { { Qt::Key_Left, "leftPressed" }, { Qt::Key_Right, "rightPressed" }, diff --git a/src/declarative/graphicsitems/qmlgraphicsitem_p.h b/src/declarative/graphicsitems/qmlgraphicsitem_p.h index 7ebbd85..9a77dbb 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsitem_p.h @@ -381,7 +381,7 @@ class QmlGraphicsKeysAttached : public QObject, public QmlGraphicsItemKeyFilter Q_DECLARE_PRIVATE(QmlGraphicsKeysAttached) Q_PROPERTY(bool enabled READ enabled WRITE setEnabled NOTIFY enabledChanged) - Q_PROPERTY(QmlListProperty forwardTo READ forwardTo) + Q_PROPERTY(QList *forwardTo READ forwardTo) public: QmlGraphicsKeysAttached(QObject *parent=0); @@ -396,9 +396,9 @@ public: } } - QmlListProperty forwardTo() { + QList *forwardTo() { Q_D(QmlGraphicsKeysAttached); - return QmlListProperty(this, d->targets); + return &d->targets; } virtual void componentComplete(); diff --git a/src/declarative/graphicsitems/qmlgraphicspath.cpp b/src/declarative/graphicsitems/qmlgraphicspath.cpp index eaf0d88..fae8161 100644 --- a/src/declarative/graphicsitems/qmlgraphicspath.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspath.cpp @@ -155,10 +155,10 @@ bool QmlGraphicsPath::isClosed() const \snippet doc/src/snippets/declarative/pathview/pathattributes.qml 2 */ -QmlListProperty QmlGraphicsPath::pathElements() +QList* QmlGraphicsPath::pathElements() { Q_D(QmlGraphicsPath); - return QmlListProperty(this, d->_pathElements); + return &(d->_pathElements); } void QmlGraphicsPath::interpolate(int idx, const QString &name, qreal value) diff --git a/src/declarative/graphicsitems/qmlgraphicspath_p.h b/src/declarative/graphicsitems/qmlgraphicspath_p.h index 50ea15b..2b4b0fd 100644 --- a/src/declarative/graphicsitems/qmlgraphicspath_p.h +++ b/src/declarative/graphicsitems/qmlgraphicspath_p.h @@ -189,7 +189,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsPath : public QObject, public QmlParserSta Q_OBJECT Q_INTERFACES(QmlParserStatus) - Q_PROPERTY(QmlListProperty pathElements READ pathElements) + Q_PROPERTY(QList* pathElements READ pathElements) Q_PROPERTY(qreal startX READ startX WRITE setStartX) Q_PROPERTY(qreal startY READ startY WRITE setStartY) Q_PROPERTY(bool closed READ isClosed NOTIFY changed) @@ -199,7 +199,7 @@ public: QmlGraphicsPath(QObject *parent=0); ~QmlGraphicsPath(); - QmlListProperty pathElements(); + QList* pathElements(); qreal startX() const; void setStartX(qreal x); diff --git a/src/declarative/graphicsitems/qmlgraphicsrectangle_p.h b/src/declarative/graphicsitems/qmlgraphicsrectangle_p.h index b8c2179..4f4c1cf 100644 --- a/src/declarative/graphicsitems/qmlgraphicsrectangle_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsrectangle_p.h @@ -107,14 +107,14 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsGradient : public QObject { Q_OBJECT - Q_PROPERTY(QmlListProperty stops READ stops) + Q_PROPERTY(QList *stops READ stops) Q_CLASSINFO("DefaultProperty", "stops") public: QmlGraphicsGradient(QObject *parent=0) : QObject(parent), m_gradient(0) {} ~QmlGraphicsGradient() { delete m_gradient; } - QmlListProperty stops() { return QmlListProperty(this, m_stops); } + QList *stops() { return &m_stops; } const QGradient *gradient() const; diff --git a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp index d14fc84..cc416d0 100644 --- a/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsvisualitemmodel.cpp @@ -423,7 +423,7 @@ int QmlGraphicsVisualDataModelDataMetaObject::createProperty(const char *name, c if ((!model->m_listModelInterface || !model->m_abstractItemModel) && model->m_listAccessor) { if (model->m_listAccessor->type() == QmlListAccessor::QmlList - || model->m_listAccessor->type() == QmlListAccessor::ListProperty) { + || model->m_listAccessor->type() == QmlListAccessor::QListPtr) { model->ensureRoles(); QObject *object = model->m_listAccessor->at(data->m_index).value(); if (object && object->property(name).isValid()) @@ -685,7 +685,7 @@ void QmlGraphicsVisualDataModel::setModel(const QVariant &model) } d->m_listAccessor = new QmlListAccessor; d->m_listAccessor->setList(model, d->m_context?d->m_context->engine():qmlEngine(this)); - if (d->m_listAccessor->type() != QmlListAccessor::QmlList && d->m_listAccessor->type() != QmlListAccessor::ListProperty) + if (d->m_listAccessor->type() != QmlListAccessor::QmlList && d->m_listAccessor->type() != QmlListAccessor::QListPtr) d->m_metaDataCacheable = true; if (d->m_delegate && d->modelCount()) { emit itemsInserted(0, d->modelCount()); diff --git a/src/declarative/qml/qml.h b/src/declarative/qml/qml.h index 859fd66..c009093 100644 --- a/src/declarative/qml/qml.h +++ b/src/declarative/qml/qml.h @@ -59,11 +59,11 @@ QT_MODULE(Declarative) #define QML_DECLARE_TYPE(TYPE) \ Q_DECLARE_METATYPE(TYPE *) \ - Q_DECLARE_METATYPE(QmlListProperty) \ + Q_DECLARE_METATYPE(QList *) \ Q_DECLARE_METATYPE(QmlList *) #define QML_DECLARE_TYPE_HASMETATYPE(TYPE) \ - Q_DECLARE_METATYPE(QmlListProperty) \ + Q_DECLARE_METATYPE(QList *) \ Q_DECLARE_METATYPE(QmlList *) #define QML_DECLARE_INTERFACE(INTERFACE) \ diff --git a/src/declarative/qml/qmllist.h b/src/declarative/qml/qmllist.h index b1a81c4..ad2d874 100644 --- a/src/declarative/qml/qmllist.h +++ b/src/declarative/qml/qmllist.h @@ -119,72 +119,6 @@ class Qml_ProxyList_ ##ListName : public QmlList \ friend class Qml_ProxyList_ ##ListName ; \ Qml_ProxyList_##ListName ListName; -template -struct QmlListProperty { - typedef void (*AppendFunction)(QmlListProperty *, T*); - typedef int (*CountFunction)(QmlListProperty *); - typedef T *(*AtFunction)(QmlListProperty *, int); - typedef void (*ClearFunction)(QmlListProperty *); - typedef void (*InsertFunction)(QmlListProperty *, int, T *); - typedef void (*RemoveAtFunction)(QmlListProperty *, int); - - QmlListProperty() - : version(1), object(0), data(0), append(0), count(0), at(0), clear(0), insert(0), removeAt(0) {} - QmlListProperty(QObject *o, QList &list) - : version(1), object(o), data(&list), append(qlist_append), count(qlist_count), at(qlist_at), - clear(qlist_clear), insert(qlist_insert), removeAt(qlist_removeAt) {} - QmlListProperty(QObject *o, void *d, AppendFunction a, CountFunction c = 0, AtFunction t = 0, - ClearFunction l = 0, InsertFunction i = 0, RemoveAtFunction r = 0) - : version(1), object(o), data(d), append(a), count(c), at(t), clear(l), insert(i), removeAt(r) {} - - bool operator==(const QmlListProperty &o) const { - return version == o.version && - object == o.object && - data == o.data && - append == o.append && - count == o.count && - at == o.at && - clear == o.clear && - insert == o.insert && - removeAt == o.removeAt; - } - - int version; - - QObject *object; - void *data; - - AppendFunction append; - - CountFunction count; - AtFunction at; - - ClearFunction clear; - - InsertFunction insert; - RemoveAtFunction removeAt; - -private: - static void qlist_append(QmlListProperty *p, T *v) { - ((QList *)p->data)->append(v); - } - static int qlist_count(QmlListProperty *p) { - return ((QList *)p->data)->count(); - } - static T *qlist_at(QmlListProperty *p, int idx) { - return ((QList *)p->data)->at(idx); - } - static void qlist_clear(QmlListProperty *p) { - return ((QList *)p->data)->clear(); - } - static void qlist_insert(QmlListProperty *p, int idx, T *v) { - return ((QList *)p->data)->insert(idx, v); - } - static void qlist_removeAt(QmlListProperty *p, int idx) { - return ((QList *)p->data)->removeAt(idx); - } -}; - QT_END_NAMESPACE QT_END_HEADER diff --git a/src/declarative/qml/qmllistscriptclass.cpp b/src/declarative/qml/qmllistscriptclass.cpp index caa4e4e..d4cdc6e 100644 --- a/src/declarative/qml/qmllistscriptclass.cpp +++ b/src/declarative/qml/qmllistscriptclass.cpp @@ -111,31 +111,27 @@ QmlListScriptClass::ScriptValue QmlListScriptClass::property(Object *obj, const if (!data->object) return Value(); - if (data->type == ListProperty) { - QmlListProperty list; - void *args[] = { &list, 0 }; + void *list = 0; + void *args[] = { &list, 0 }; + QMetaObject::metacall(data->object, QMetaObject::ReadProperty, + data->propertyIdx, args); - QMetaObject::metacall(data->object, QMetaObject::ReadProperty, - data->propertyIdx, args); + if (!list) + return Value(); + + if (data->type == QListPtr) { + const QList &qlist = *((QList*)list); - quint32 count = list.count(&list); + quint32 count = qlist.count(); if (name == m_lengthId.identifier) return Value(scriptEngine, count); else if (lastIndex < count) - return Value(scriptEngine, enginePriv->objectClass->newQObject(list.at(&list, lastIndex))); + return Value(scriptEngine, enginePriv->objectClass->newQObject(qlist.at(lastIndex))); else return Value(); } else { - void *list = 0; - void *args[] = { &list, 0 }; - QMetaObject::metacall(data->object, QMetaObject::ReadProperty, - data->propertyIdx, args); - - if (!list) - return Value(); - Q_ASSERT(data->type == QmlListPtr); const QmlList &qmllist = *((QmlList*)list); @@ -159,29 +155,18 @@ QVariant QmlListScriptClass::toVariant(Object *obj, bool *ok) return QVariant(); } - if (data->type == QmlListScriptClass::QmlListPtr) { - void *list = 0; - void *args[] = { &list, 0 }; - QMetaObject::metacall(data->object, QMetaObject::ReadProperty, - data->propertyIdx, args); - - if (!list) { - if (ok) *ok = false; - return QVariant(); - } + void *list = 0; + void *args[] = { &list, 0 }; + QMetaObject::metacall(data->object, QMetaObject::ReadProperty, + data->propertyIdx, args); - if (ok) *ok = true; - return QVariant(data->propertyType, &list); - } else { - QmlListProperty list; - void *args[] = { &list, 0 }; - - QMetaObject::metacall(data->object, QMetaObject::ReadProperty, - data->propertyIdx, args); - - if (ok) *ok = true; - return QVariant(data->propertyType, &list); + if (!list) { + if (ok) *ok = false; + return QVariant(); } + + if (ok) *ok = true; + return QVariant(data->propertyType, &list); } QT_END_NAMESPACE diff --git a/src/declarative/qml/qmllistscriptclass_p.h b/src/declarative/qml/qmllistscriptclass_p.h index 464f91e..e484b34 100644 --- a/src/declarative/qml/qmllistscriptclass_p.h +++ b/src/declarative/qml/qmllistscriptclass_p.h @@ -64,7 +64,7 @@ public: QmlListScriptClass(QmlEngine *); ~QmlListScriptClass(); - enum ListCategory { ListProperty, QmlListPtr }; + enum ListCategory { QListPtr, QmlListPtr }; QScriptValue newList(QObject *, int, ListCategory, int); protected: diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index fc11bd6..70f9ad3 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -889,8 +889,7 @@ bool QmlMetaPropertyPrivate::write(QObject *object, const QmlPropertyCache::Data QVariant listVar = prop.read(object); QmlMetaType::clear(listVar); for (int ii = 0; ii < list.count(); ++ii) { - QObject *o = list.at(ii); - QVariant v = QVariant(listType, &o); + QVariant v = QmlMetaType::qmlType(listType)->fromObject(list.at(ii)); QmlMetaType::append(listVar, v); } diff --git a/src/declarative/qml/qmlmetatype.cpp b/src/declarative/qml/qmlmetatype.cpp index e613b7c..7dfc48d 100644 --- a/src/declarative/qml/qmlmetatype.cpp +++ b/src/declarative/qml/qmlmetatype.cpp @@ -125,7 +125,7 @@ public: int m_version_maj; int m_version_min; int m_typeId; int m_listId; int m_qmlListId; - QObject *(*m_newFunc)(); + QmlPrivate::Func m_opFunc; const QMetaObject *m_baseMetaObject; QmlAttachedPropertiesFunc m_attachedPropertiesFunc; const QMetaObject *m_attachedPropertiesType; @@ -142,14 +142,15 @@ public: QmlTypePrivate::QmlTypePrivate() : m_isInterface(false), m_iid(0), m_typeId(0), m_listId(0), m_qmlListId(0), - m_newFunc(0), m_baseMetaObject(0), m_attachedPropertiesFunc(0), m_attachedPropertiesType(0), + m_opFunc(0), m_baseMetaObject(0), m_attachedPropertiesFunc(0), m_attachedPropertiesType(0), m_parserStatusCast(-1), m_propertyValueSourceCast(-1), m_propertyValueInterceptorCast(-1), m_extFunc(0), m_extMetaObject(0), m_index(-1), m_customParser(0), m_isSetup(false) { } -QmlType::QmlType(int type, int listType, int qmlListType, const char *iid, int index) +QmlType::QmlType(int type, int listType, int qmlListType, + QmlPrivate::Func opFunc, const char *iid, int index) : d(new QmlTypePrivate) { d->m_isInterface = true; @@ -157,7 +158,7 @@ QmlType::QmlType(int type, int listType, int qmlListType, const char *iid, int i d->m_typeId = type; d->m_listId = listType; d->m_qmlListId = qmlListType; - d->m_newFunc = 0; + d->m_opFunc = opFunc; d->m_index = index; d->m_isSetup = true; d->m_version_maj = 0; @@ -165,7 +166,7 @@ QmlType::QmlType(int type, int listType, int qmlListType, const char *iid, int i } QmlType::QmlType(int type, int listType, int qmlListType, - QObject *(*newFunc)(), const char *qmlName, + QmlPrivate::Func opFunc, const char *qmlName, int version_maj, int version_min, const QMetaObject *metaObject, QmlAttachedPropertiesFunc attachedPropertiesFunc, @@ -182,7 +183,7 @@ QmlType::QmlType(int type, int listType, int qmlListType, d->m_typeId = type; d->m_listId = listType; d->m_qmlListId = qmlListType; - d->m_newFunc = newFunc; + d->m_opFunc = opFunc; d->m_baseMetaObject = metaObject; d->m_attachedPropertiesFunc = attachedPropertiesFunc; d->m_attachedPropertiesType = attachedType; @@ -282,7 +283,10 @@ QObject *QmlType::create() const { d->init(); - QObject *rv = d->m_newFunc(); + QVariant v; + QObject *rv = 0; + d->m_opFunc(QmlPrivate::Create, 0, v, v, (void **)&rv); + if (rv && !d->m_metaObjects.isEmpty()) (void *)new QmlProxyMetaObject(rv, &d->m_metaObjects); @@ -317,35 +321,29 @@ int QmlType::qmlListTypeId() const void QmlType::listClear(const QVariant &list) { Q_ASSERT(list.userType() == qListTypeId()); - QmlListProperty *l = (QmlListProperty *)list.data(); - if (l->clear) l->clear(l); + QVariant arg; + d->m_opFunc(QmlPrivate::Clear, 0, list, arg, 0); } void QmlType::listAppend(const QVariant &list, const QVariant &item) { Q_ASSERT(list.userType() == qListTypeId()); - QmlListProperty *l = (QmlListProperty *)list.data(); - if (l->append) l->append(l, *(void **)item.data()); + d->m_opFunc(QmlPrivate::Append, 0, list, item, 0); } QVariant QmlType::listAt(const QVariant &list, int idx) { Q_ASSERT(list.userType() == qListTypeId()); - QmlListProperty *l = (QmlListProperty *)list.data(); - if (l->at) { - void *v = l->at(l, idx); - return QVariant(typeId(), &v); - } else { - return QVariant(); - } + QVariant rv; + void *ptr = (void *)&rv; + d->m_opFunc(QmlPrivate::Value, idx, list, QVariant(), &ptr); + return rv; } int QmlType::listCount(const QVariant &list) { Q_ASSERT(list.userType() == qListTypeId()); - QmlListProperty *l = (QmlListProperty *)list.data(); - if (l->count) return l->count(l); - return 0; + return d->m_opFunc(QmlPrivate::Length, 0, list, QVariant(), 0); } const QMetaObject *QmlType::metaObject() const @@ -389,6 +387,15 @@ int QmlType::propertyValueInterceptorCast() const return d->m_propertyValueInterceptorCast; } +QVariant QmlType::fromObject(QObject *obj) const +{ + QVariant rv; + QVariant *v_ptr = &rv; + QVariant vobj = QVariant::fromValue(obj); + d->m_opFunc(QmlPrivate::FromObject, 0, QVariant(), vobj, (void **)&v_ptr); + return rv; +} + const char *QmlType::interfaceIId() const { return d->m_iid; @@ -400,6 +407,7 @@ int QmlType::index() const } int QmlMetaType::registerInterface(const QmlPrivate::MetaTypeIds &id, + QmlPrivate::Func listFunction, const char *iid) { QWriteLocker lock(metaTypeDataLock()); @@ -408,7 +416,7 @@ int QmlMetaType::registerInterface(const QmlPrivate::MetaTypeIds &id, int index = data->types.count(); QmlType *type = new QmlType(id.typeId, id.listId, id.qmlListId, - iid, index); + listFunction, iid, index); data->types.append(type); data->idToType.insert(type->typeId(), type); @@ -431,7 +439,7 @@ int QmlMetaType::registerInterface(const QmlPrivate::MetaTypeIds &id, return index; } -int QmlMetaType::registerType(const QmlPrivate::MetaTypeIds &id, QObject *(*func)(), +int QmlMetaType::registerType(const QmlPrivate::MetaTypeIds &id, QmlPrivate::Func func, const char *uri, int version_maj, int version_min, const char *cname, const QMetaObject *mo, QmlAttachedPropertiesFunc attach, const QMetaObject *attachMo, int pStatus, int object, int valueSource, int valueInterceptor, QmlPrivate::CreateFunc extFunc, const QMetaObject *extmo, QmlCustomParser *parser) diff --git a/src/declarative/qml/qmlmetatype.h b/src/declarative/qml/qmlmetatype.h index 1d9c096..45ec11d 100644 --- a/src/declarative/qml/qmlmetatype.h +++ b/src/declarative/qml/qmlmetatype.h @@ -46,7 +46,6 @@ #include "qmlparserstatus.h" #include "qmlpropertyvaluesource.h" #include "qmlpropertyvalueinterceptor.h" -#include "qmllist.h" #include #include @@ -63,8 +62,8 @@ class QmlCustomParser; class Q_DECLARATIVE_EXPORT QmlMetaType { public: - static int registerType(const QmlPrivate::MetaTypeIds &, QObject *(*)(), const char *, int vmaj, int vmin, const char *qmlName, const QMetaObject *, QmlAttachedPropertiesFunc, const QMetaObject *, int pStatus, int object, int valueSource, int valueInterceptor, QmlPrivate::CreateFunc extFunc, const QMetaObject *extmo, QmlCustomParser *); - static int registerInterface(const QmlPrivate::MetaTypeIds &, const char *); + static int registerType(const QmlPrivate::MetaTypeIds &, QmlPrivate::Func, const char *, int vmaj, int vmin, const char *qmlName, const QMetaObject *, QmlAttachedPropertiesFunc, const QMetaObject *, int pStatus, int object, int valueSource, int valueInterceptor, QmlPrivate::CreateFunc extFunc, const QMetaObject *extmo, QmlCustomParser *); + static int registerInterface(const QmlPrivate::MetaTypeIds &, QmlPrivate::Func, const char *); static bool copy(int type, void *data, const void *copy = 0); @@ -148,8 +147,8 @@ private: friend class QmlMetaType; friend class QmlTypePrivate; friend struct QmlMetaTypeData; - QmlType(int, int, int, const char *, int); - QmlType(int, int, int, QObject *(*)(), const char *, int, int, const QMetaObject *, QmlAttachedPropertiesFunc, const QMetaObject *, int, int, int, QmlPrivate::CreateFunc, const QMetaObject *, int, QmlCustomParser *); + QmlType(int, int, int, QmlPrivate::Func, const char *, int); + QmlType(int, int, int, QmlPrivate::Func, const char *, int, int, const QMetaObject *, QmlAttachedPropertiesFunc, const QMetaObject *, int, int, int, QmlPrivate::CreateFunc, const QMetaObject *, int, QmlCustomParser *); ~QmlType(); QmlTypePrivate *d; @@ -161,11 +160,11 @@ int qmlRegisterType(const char *typeName) QByteArray name(typeName); QmlPrivate::MetaTypeIds ids = { qRegisterMetaType(QByteArray(name + '*').constData()), - qRegisterMetaType >(QByteArray("QmlListProperty<" + name + ">").constData()), - qRegisterMetaType*>(QByteArray("QmlList<" + name + "*>*").constData()) + qRegisterMetaType(QByteArray("QList<" + name + "*>*").constData()), + qRegisterMetaType(QByteArray("QmlList<" + name + "*>*").constData()) }; - return QmlMetaType::registerType(ids, 0, 0, 0, 0, 0, + return QmlMetaType::registerType(ids, QmlPrivate::list_nocreate_op, 0, 0, 0, 0, &T::staticMetaObject, QmlPrivate::attachedPropertiesFunc(), QmlPrivate::attachedPropertiesMetaObject(), @@ -182,11 +181,11 @@ int qmlRegisterType(const char *uri, int version_maj, int version_min, const cha QByteArray name(typeName); QmlPrivate::MetaTypeIds ids = { qRegisterMetaType(QByteArray(name + '*').constData()), - qRegisterMetaType >(QByteArray("QmlListProperty<" + name + ">").constData()), - qRegisterMetaType*>(QByteArray("QmlList<" + name + "*>*").constData()) + qRegisterMetaType(QByteArray("QList<" + name + "*>*").constData()), + qRegisterMetaType(QByteArray("QmlList<" + name + "*>*").constData()) }; - return QmlMetaType::registerType(ids, QmlPrivate::create, + return QmlMetaType::registerType(ids, QmlPrivate::list_op, uri, version_maj, version_min, qmlName, &T::staticMetaObject, QmlPrivate::attachedPropertiesFunc(), @@ -204,8 +203,8 @@ int qmlRegisterExtendedType(const char *typeName) QByteArray name(typeName); QmlPrivate::MetaTypeIds ids = { qRegisterMetaType(QByteArray(name + '*').constData()), - qRegisterMetaType >(QByteArray("QmlListProperty<" + name + ">").constData()), - qRegisterMetaType*>(QByteArray("QmlList<" + name + "*>*").constData()) + qRegisterMetaType(QByteArray("QList<" + name + "*>*").constData()), + qRegisterMetaType(QByteArray("QmlList<" + name + "*>*").constData()) }; QmlAttachedPropertiesFunc attached = @@ -217,7 +216,7 @@ int qmlRegisterExtendedType(const char *typeName) attachedMo = QmlPrivate::attachedPropertiesMetaObject(); } - return QmlMetaType::registerType(ids, 0, 0, 0, 0, 0, + return QmlMetaType::registerType(ids, QmlPrivate::list_nocreate_op, 0, 0, 0, 0, &T::staticMetaObject, attached, attachedMo, QmlPrivate::StaticCastSelector::cast(), QmlPrivate::StaticCastSelector::cast(), @@ -232,8 +231,8 @@ int qmlRegisterExtendedType(const char *uri, int version_maj, int version_min, c QByteArray name(typeName); QmlPrivate::MetaTypeIds ids = { qRegisterMetaType(QByteArray(name + '*').constData()), - qRegisterMetaType >(QByteArray("QmlListProperty<" + name + ">").constData()), - qRegisterMetaType*>(QByteArray("QmlList<" + name + "*>*").constData()) + qRegisterMetaType(QByteArray("QList<" + name + "*>*").constData()), + qRegisterMetaType(QByteArray("QmlList<" + name + "*>*").constData()) }; QmlAttachedPropertiesFunc attached = @@ -245,7 +244,7 @@ int qmlRegisterExtendedType(const char *uri, int version_maj, int version_min, c attachedMo = QmlPrivate::attachedPropertiesMetaObject(); } - return QmlMetaType::registerType(ids, QmlPrivate::create, + return QmlMetaType::registerType(ids, QmlPrivate::list_op, uri, version_maj, version_min, qmlName, &T::staticMetaObject, attached, attachedMo, @@ -263,11 +262,13 @@ int qmlRegisterInterface(const char *typeName) QByteArray name(typeName); QmlPrivate::MetaTypeIds ids = { qRegisterMetaType(QByteArray(name + '*').constData()), - qRegisterMetaType >(QByteArray("QmlListProperty<" + name + ">").constData()), - qRegisterMetaType*>(QByteArray("QmlList<" + name + "*>*").constData()) + qRegisterMetaType(QByteArray("QList<" + name + "*>*").constData()), + qRegisterMetaType(QByteArray("QmlList<" + name + "*>*").constData()) }; - return QmlMetaType::registerInterface(ids, qobject_interface_iid()); + return QmlMetaType::registerInterface(ids, + QmlPrivate::list_interface_op, + qobject_interface_iid()); } template @@ -276,11 +277,11 @@ int qmlRegisterCustomType(const char *uri, int version_maj, int version_min, con QByteArray name(typeName); QmlPrivate::MetaTypeIds ids = { qRegisterMetaType(QByteArray(name + '*').constData()), - qRegisterMetaType >(QByteArray("QmlListProperty<" + name + ">").constData()), - qRegisterMetaType*>(QByteArray("QmlList<" + name + "*>*").constData()) + qRegisterMetaType(QByteArray("QList<" + name + "*>*").constData()), + qRegisterMetaType(QByteArray("QmlList<" + name + "*>*").constData()) }; - return QmlMetaType::registerType(ids, QmlPrivate::create, + return QmlMetaType::registerType(ids, QmlPrivate::list_op, uri, version_maj, version_min, qmlName, &T::staticMetaObject, QmlPrivate::attachedPropertiesFunc(), diff --git a/src/declarative/qml/qmlobjectscriptclass.cpp b/src/declarative/qml/qmlobjectscriptclass.cpp index 75b5c08..1c41d46 100644 --- a/src/declarative/qml/qmlobjectscriptclass.cpp +++ b/src/declarative/qml/qmlobjectscriptclass.cpp @@ -239,7 +239,7 @@ QmlObjectScriptClass::property(QObject *obj, const Identifier &name) } if (lastData->flags & QmlPropertyCache::Data::IsQList) { - return Value(scriptEngine, enginePriv->listClass->newList(obj, lastData->coreIndex, QmlListScriptClass::ListProperty, lastData->propType)); + return Value(scriptEngine, enginePriv->listClass->newList(obj, lastData->coreIndex, QmlListScriptClass::QListPtr, lastData->propType)); } else if (lastData->flags & QmlPropertyCache::Data::IsQmlList) { return Value(scriptEngine, enginePriv->listClass->newList(obj, lastData->coreIndex, QmlListScriptClass::QmlListPtr, lastData->propType)); } else if (lastData->flags & QmlPropertyCache::Data::IsQObjectDerived) { diff --git a/src/declarative/qml/qmlprivate.h b/src/declarative/qml/qmlprivate.h index c367497..dd98110 100644 --- a/src/declarative/qml/qmlprivate.h +++ b/src/declarative/qml/qmlprivate.h @@ -85,8 +85,26 @@ namespace QmlPrivate virtual void clear() = 0; }; + enum ListOp { Append, Set, Insert, Prepend, Length, FromObject, + Object, Create, Value, Clear }; + + template + int list_op(ListOp op, int val, + const QVariant &vlist, + const QVariant &value, + void **out); + template - QObject *create() { return new T; } + int list_nocreate_op(ListOp op, int val, + const QVariant &vlist, + const QVariant &value, + void **out); + + template + int list_interface_op(ListOp op, int val, + const QVariant &vlist, + const QVariant &value, + void **out); template struct StaticCastSelectorClass @@ -185,6 +203,7 @@ namespace QmlPrivate int listId; int qmlListId; }; + typedef int (*Func)(QmlPrivate::ListOp, int, const QVariant &, const QVariant &, void **); typedef QObject *(*CreateFunc)(QObject *); template @@ -218,6 +237,148 @@ namespace QmlPrivate }; } +template +int QmlPrivate::list_op(QmlPrivate::ListOp op, int val, + const QVariant &vlist, + const QVariant &value, + void **out) +{ + if (op == QmlPrivate::Create) { + QObject *obj = static_cast(new T); + *((QObject **)out) = obj; + return 0; + } + QList *list = vlist.value *>(); + switch(op) { + case QmlPrivate::Append: + list->append(value.value()); + break; + case QmlPrivate::Set: + (*list)[val] = value.value(); + break; + case QmlPrivate::Insert: + list->insert(val, value.value()); + break; + case QmlPrivate::Prepend: + list->prepend(value.value()); + break; + case QmlPrivate::Length: + return list->count(); + break; + case QmlPrivate::Clear: + list->clear(); + return 0; + break; + case QmlPrivate::Create: + break; + case QmlPrivate::Object: + *out = static_cast(value.value()); + break; + case QmlPrivate::FromObject: + { + QObject *fromObj = value.value(); + T *me = qobject_cast(fromObj); + if (me) { + *((QVariant *)*out) = QVariant::fromValue(me); + } + } + break; + case QmlPrivate::Value: + if (list->count() <= val) *((QVariant *)*out) = QVariant(); + else *((QVariant *)*out) = QVariant::fromValue(list->at(val)); + break; + } + return 0; +} + +template +int QmlPrivate::list_nocreate_op(QmlPrivate::ListOp op, int val, + const QVariant &vlist, + const QVariant &value, + void **out) +{ + QList *list = vlist.value *>(); + switch(op) { + case QmlPrivate::Append: + list->append(value.value()); + break; + case QmlPrivate::Set: + (*list)[val] = value.value(); + break; + case QmlPrivate::Insert: + list->insert(val, value.value()); + break; + case QmlPrivate::Prepend: + list->prepend(value.value()); + break; + case QmlPrivate::Length: + return list->count(); + break; + case QmlPrivate::Clear: + list->clear(); + return 0; + break; + case QmlPrivate::Create: + break; + case QmlPrivate::Object: + *out = static_cast(value.value()); + break; + case QmlPrivate::FromObject: + { + QObject *fromObj = value.value(); + T *me = qobject_cast(fromObj); + if (me) { + *((QVariant *)*out) = QVariant::fromValue(me); + } + } + break; + case QmlPrivate::Value: + *((QVariant *)*out) = QVariant::fromValue(list->at(val)); + break; + } + return 0; +} + +template +int QmlPrivate::list_interface_op(QmlPrivate::ListOp op, int val, + const QVariant &vlist, + const QVariant &value, + void **out) +{ + QList *list = vlist.value *>(); + switch(op) { + case QmlPrivate::Append: + list->append(value.value()); + break; + case QmlPrivate::Set: + (*list)[val] = value.value(); + break; + case QmlPrivate::Insert: + list->insert(val, value.value()); + break; + case QmlPrivate::Prepend: + list->prepend(value.value()); + break; + case QmlPrivate::Length: + return list->count(); + break; + case QmlPrivate::Clear: + list->clear(); + return 0; + break; + case QmlPrivate::Create: + break; + case QmlPrivate::Object: + break; + case QmlPrivate::FromObject: + break; + case QmlPrivate::Value: + *((QVariant *)*out) = QVariant::fromValue(list->at(val)); + break; + } + return 0; +} + QT_END_NAMESPACE QT_END_HEADER diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index 4ab205e..e9a0449 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -91,15 +91,14 @@ QmlVME::QmlVME() struct ListInstance { - ListInstance() - : type(0), qmlListInterface(0) {} - ListInstance(int t) - : type(t), qmlListInterface(0) {} + ListInstance() {} + ListInstance(QList *q, int t) + : type(t), qListInterface(q), qmlListInterface(0) {} ListInstance(QmlPrivate::ListInterface *q, int t) - : type(t), qmlListInterface(q) {} + : type(t), qListInterface(0), qmlListInterface(q) {} int type; - QmlListProperty qListProperty; + QList *qListInterface; QmlPrivate::ListInterface *qmlListInterface; }; @@ -670,7 +669,7 @@ QObject *QmlVME::run(QmlVMEStack &stack, QmlContext *ctxt, QObject *assign = stack.pop(); const ListInstance &list = qliststack.top(); - list.qListProperty.append((QmlListProperty*)&list.qListProperty, assign); + list.qListInterface->append((void *)assign); } break; @@ -695,7 +694,7 @@ QObject *QmlVME::run(QmlVMEStack &stack, QmlContext *ctxt, void *d = (void *)&ptr; list.qmlListInterface->append(d); } else { - list.qListProperty.append((QmlListProperty*)&list.qListProperty, ptr); + list.qListInterface->append(ptr); } } break; @@ -773,12 +772,17 @@ QObject *QmlVME::run(QmlVMEStack &stack, QmlContext *ctxt, { QObject *target = stack.top(); - qliststack.push(ListInstance(instr.fetchQmlList.type)); - void *a[1]; - a[0] = (void *)&(qliststack.top().qListProperty); + // We know that QList* can be converted to + // QList* + QList *list = 0; + a[0] = &list; QMetaObject::metacall(target, QMetaObject::ReadProperty, instr.fetchQmlList.property, a); + if (!list) + VME_EXCEPTION(QCoreApplication::translate("QmlVME","Cannot assign to null list")); + + qliststack.push(ListInstance(list, instr.fetchQmlList.type)); } break; diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 4f68b6c..abffefe 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -947,10 +947,10 @@ void QmlPropertyAction::setProperties(const QString &p) \sa exclude matchProperties PropertyAnimation::matchTargets */ -QmlListProperty QmlPropertyAction::targets() +QList *QmlPropertyAction::targets() { Q_D(QmlPropertyAction); - return QmlListProperty(this, d->targets); + return &d->targets; } /*! @@ -958,10 +958,10 @@ QmlListProperty QmlPropertyAction::targets() This property holds the objects not to be affected by this animation. \sa matchTargets */ -QmlListProperty QmlPropertyAction::exclude() +QList *QmlPropertyAction::exclude() { Q_D(QmlPropertyAction); - return QmlListProperty(this, d->exclude); + return &d->exclude; } /*! @@ -2097,10 +2097,10 @@ void QmlPropertyAnimation::setProperties(const QString &prop) \sa exclude matchProperties */ -QmlListProperty QmlPropertyAnimation::targets() +QList *QmlPropertyAnimation::targets() { Q_D(QmlPropertyAnimation); - return QmlListProperty(this, d->targets); + return &d->targets; } /*! @@ -2108,10 +2108,10 @@ QmlListProperty QmlPropertyAnimation::targets() This property holds the items not to be affected by this animation. \sa matchTargets */ -QmlListProperty QmlPropertyAnimation::exclude() +QList *QmlPropertyAnimation::exclude() { Q_D(QmlPropertyAnimation); - return QmlListProperty(this, d->exclude); + return &d->exclude; } void QmlPropertyAnimationPrivate::valueChanged(qreal r) diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index a566074..6a69e4d 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -187,8 +187,8 @@ class QmlPropertyAction : public QmlAbstractAnimation Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged) Q_PROPERTY(QString matchProperties READ properties WRITE setProperties NOTIFY propertiesChanged) - Q_PROPERTY(QmlListProperty matchTargets READ targets) - Q_PROPERTY(QmlListProperty exclude READ exclude) + Q_PROPERTY(QList* matchTargets READ targets) + Q_PROPERTY(QList* exclude READ exclude) Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) public: @@ -204,8 +204,8 @@ public: QString properties() const; void setProperties(const QString &); - QmlListProperty targets(); - QmlListProperty exclude(); + QList *targets(); + QList *exclude(); QVariant value() const; void setValue(const QVariant &); @@ -267,8 +267,8 @@ class Q_AUTOTEST_EXPORT QmlPropertyAnimation : public QmlAbstractAnimation Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged) Q_PROPERTY(QString matchProperties READ properties WRITE setProperties NOTIFY propertiesChanged) - Q_PROPERTY(QmlListProperty matchTargets READ targets) - Q_PROPERTY(QmlListProperty exclude READ exclude) + Q_PROPERTY(QList* matchTargets READ targets) + Q_PROPERTY(QList* exclude READ exclude) public: QmlPropertyAnimation(QObject *parent=0); @@ -295,8 +295,8 @@ public: QString properties() const; void setProperties(const QString &); - QmlListProperty targets(); - QmlListProperty exclude(); + QList *targets(); + QList *exclude(); protected: virtual void transition(QmlStateActions &actions, diff --git a/src/declarative/util/qmllistaccessor.cpp b/src/declarative/util/qmllistaccessor.cpp index 2e37d49..6658949 100644 --- a/src/declarative/util/qmllistaccessor.cpp +++ b/src/declarative/util/qmllistaccessor.cpp @@ -88,7 +88,7 @@ void QmlListAccessor::setList(const QVariant &v, QmlEngine *engine) (enginePrivate && enginePrivate->isQmlList(d.userType()))) { m_type = QmlList; } else if (QmlMetaType::isList(d.userType())) { - m_type = ListProperty; + m_type = QListPtr; } else { m_type = Instance; } @@ -106,11 +106,10 @@ int QmlListAccessor::count() const QmlPrivate::ListInterface *li = *(QmlPrivate::ListInterface **)d.constData(); return li->count(); } - case ListProperty: + case QListPtr: { - QmlListProperty *li = (QmlListProperty*)d.constData(); - if (li->count) return li->count(li); - else return 0; + QList *li = *(QList **)d.constData(); + return li->count(); } case Instance: return 1; @@ -137,11 +136,11 @@ QVariant QmlListAccessor::at(int idx) const li->at(idx, ptr); return QVariant::fromValue((QObject*)ptr[0]); } - case ListProperty: + case QListPtr: { - QmlListProperty *li = (QmlListProperty*)d.constData(); - if (li->at) return QVariant::fromValue((QObject *)li->at(li, idx)); - else return QVariant(); + QList *li = *(QList **)d.constData(); + void *ptr = li->at(idx); + return QVariant::fromValue((QObject*)ptr); } case Instance: return d; @@ -162,10 +161,10 @@ bool QmlListAccessor::append(const QVariant &value) li->append(const_cast(value.constData())); //XXX Typesafety return true; } - case ListProperty: + case QListPtr: { - QmlListProperty *li = (QmlListProperty*)d.constData(); - if (li->append) li->append(li, *(void **)value.constData()); // XXX Typesafety + QList *li = *(QList **)d.constData(); + li->append(*reinterpret_cast(const_cast(value.constData()))); //XXX Typesafety return true; } case StringList: @@ -187,10 +186,10 @@ bool QmlListAccessor::insert(int index, const QVariant &value) li->insert(index, const_cast(value.constData())); //XXX Typesafety return true; } - case ListProperty: + case QListPtr: { - QmlListProperty *li = (QmlListProperty*)d.constData(); - if (li->insert) li->insert(li, index, *(void **)value.constData()); // XXX Typesafety + QList *li = *(QList**)d.constData(); + li->insert(index, *reinterpret_cast(const_cast(value.constData()))); //XXX Typesafety return true; } case StringList: @@ -212,10 +211,10 @@ bool QmlListAccessor::removeAt(int index) li->removeAt(index); return true; } - case ListProperty: + case QListPtr: { - QmlListProperty *li = (QmlListProperty*)d.constData(); - if (li->removeAt) li->removeAt(li, index); + QList *li = *(QList**)d.constData(); + li->removeAt(index); return true; } case StringList: @@ -237,10 +236,10 @@ bool QmlListAccessor::clear() li->clear(); return true; } - case ListProperty: + case QListPtr: { - QmlListProperty *li = (QmlListProperty*)d.constData(); - if (li->clear) li->clear(li); + QList *li = *(QList**)d.constData(); + li->clear(); return true; } case StringList: diff --git a/src/declarative/util/qmllistaccessor_p.h b/src/declarative/util/qmllistaccessor_p.h index 6866150..3c67e3a 100644 --- a/src/declarative/util/qmllistaccessor_p.h +++ b/src/declarative/util/qmllistaccessor_p.h @@ -70,7 +70,7 @@ public: bool removeAt(int); bool clear(); - enum Type { Invalid, StringList, VariantList, QmlList, ListProperty, Instance, Integer }; + enum Type { Invalid, StringList, VariantList, QmlList, QListPtr, Instance, Integer }; Type type() const { return m_type; } private: diff --git a/tests/auto/declarative/qmlecmascript/testtypes.h b/tests/auto/declarative/qmlecmascript/testtypes.h index b307d9c..09c850d 100644 --- a/tests/auto/declarative/qmlecmascript/testtypes.h +++ b/tests/auto/declarative/qmlecmascript/testtypes.h @@ -78,7 +78,7 @@ class MyQmlObject : public QObject Q_PROPERTY(QString stringProperty READ stringProperty WRITE setStringProperty NOTIFY stringChanged) Q_PROPERTY(QObject *objectProperty READ objectProperty WRITE setObjectProperty NOTIFY objectChanged) Q_PROPERTY(QmlList *objectQmlListProperty READ objectQmlListProperty CONSTANT) - Q_PROPERTY(QmlListProperty objectListProperty READ objectListProperty CONSTANT) + Q_PROPERTY(QList *objectListProperty READ objectListProperty CONSTANT) Q_PROPERTY(int resettableProperty READ resettableProperty WRITE setResettableProperty RESET resetProperty) public: @@ -108,7 +108,7 @@ public: } QmlList *objectQmlListProperty() { return &m_objectQmlList; } - QmlListProperty objectListProperty() { return QmlListProperty(this, m_objectQList); } + QList *objectListProperty() { return &m_objectQList; } bool methodCalled() const { return m_methodCalled; } bool methodIntCalled() const { return m_methodIntCalled; } @@ -162,11 +162,11 @@ QML_DECLARE_TYPE(MyQmlObject); class MyQmlContainer : public QObject { Q_OBJECT - Q_PROPERTY(QmlListProperty children READ children CONSTANT) + Q_PROPERTY(QList* children READ children CONSTANT) public: MyQmlContainer() {} - QmlListProperty children() { return QmlListProperty(this, m_children); } + QList *children() { return &m_children; } private: QList m_children; diff --git a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp index f8a4f5a..4edca69 100644 --- a/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp +++ b/tests/auto/declarative/qmlecmascript/tst_qmlecmascript.cpp @@ -1612,7 +1612,7 @@ void tst_qmlecmascript::listToVariant() QObject *object = component.create(&context); QVERIFY(object != 0); - QVERIFY(qvariant_cast >(object->property("test")) == container.children()); + QCOMPARE(object->property("test"), QVariant::fromValue(container.children())); delete object; } diff --git a/tests/auto/declarative/qmllanguage/testtypes.h b/tests/auto/declarative/qmllanguage/testtypes.h index 6cd4cb5..d6ca898 100644 --- a/tests/auto/declarative/qmllanguage/testtypes.h +++ b/tests/auto/declarative/qmllanguage/testtypes.h @@ -447,20 +447,19 @@ QML_DECLARE_TYPE(MyTypeObject); class MyContainer : public QObject { Q_OBJECT - Q_PROPERTY(QmlListProperty children READ children) - Q_PROPERTY(QmlListProperty qlistInterfaces READ qlistInterfaces) + Q_PROPERTY(QList* children READ children) + Q_PROPERTY(QList* qlistInterfaces READ qlistInterfaces) Q_PROPERTY(QmlList* qmllistInterfaces READ qmllistInterfaces) Q_CLASSINFO("DefaultProperty", "children"); public: MyContainer() {} - QmlListProperty children() { return QmlListProperty(this, m_children); } - QList *getChildren() { return &m_children; } - QmlListProperty qlistInterfaces() { return QmlListProperty(this, m_interfaces); } - QList *getQListInterfaces() { return &m_interfaces; } + QList *children() { return &m_children; } + QList *qlistInterfaces() { return &m_interfaces; } QmlList *qmllistInterfaces() { return &m_qmlinterfaces; } const QmlConcreteList &qmllistAccessor() const { return m_qmlinterfaces; } +private: QList m_children; QList m_interfaces; QmlConcreteList m_qmlinterfaces; diff --git a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp index 1e68f5a..3029501 100644 --- a/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp +++ b/tests/auto/declarative/qmllanguage/tst_qmllanguage.cpp @@ -354,7 +354,7 @@ void tst_qmllanguage::simpleContainer() VERIFY_ERRORS(0); MyContainer *container= qobject_cast(component.create()); QVERIFY(container != 0); - QCOMPARE(container->getChildren()->count(),2); + QCOMPARE(container->children()->count(),2); } void tst_qmllanguage::interfaceProperty() @@ -384,9 +384,9 @@ void tst_qmllanguage::interfaceQList() VERIFY_ERRORS(0); MyContainer *container= qobject_cast(component.create()); QVERIFY(container != 0); - QVERIFY(container->getQListInterfaces()->count() == 2); + QVERIFY(container->qlistInterfaces()->count() == 2); for(int ii = 0; ii < 2; ++ii) - QVERIFY(container->getQListInterfaces()->at(ii)->id == 913); + QVERIFY(container->qlistInterfaces()->at(ii)->id == 913); } void tst_qmllanguage::assignObjectToSignal() @@ -425,8 +425,8 @@ void tst_qmllanguage::assignQmlComponent() VERIFY_ERRORS(0); MyContainer *object = qobject_cast(component.create()); QVERIFY(object != 0); - QVERIFY(object->getChildren()->count() == 1); - QObject *child = object->getChildren()->at(0); + QVERIFY(object->children()->count() == 1); + QObject *child = object->children()->at(0); QCOMPARE(child->property("x"), QVariant(10)); QCOMPARE(child->property("y"), QVariant(11)); } @@ -504,7 +504,7 @@ void tst_qmllanguage::rootAsQmlComponent() MyContainer *object = qobject_cast(component.create()); QVERIFY(object != 0); QCOMPARE(object->property("x"), QVariant(11)); - QCOMPARE(object->getChildren()->count(), 2); + QCOMPARE(object->children()->count(), 2); } // Tests that components can be specified inline @@ -514,8 +514,8 @@ void tst_qmllanguage::inlineQmlComponents() VERIFY_ERRORS(0); MyContainer *object = qobject_cast(component.create()); QVERIFY(object != 0); - QCOMPARE(object->getChildren()->count(), 1); - QmlComponent *comp = qobject_cast(object->getChildren()->at(0)); + QCOMPARE(object->children()->count(), 1); + QmlComponent *comp = qobject_cast(object->children()->at(0)); QVERIFY(comp != 0); MyQmlObject *compObject = qobject_cast(comp->create()); QVERIFY(compObject != 0); @@ -529,9 +529,9 @@ void tst_qmllanguage::idProperty() VERIFY_ERRORS(0); MyContainer *object = qobject_cast(component.create()); QVERIFY(object != 0); - QCOMPARE(object->getChildren()->count(), 1); + QCOMPARE(object->children()->count(), 1); MyTypeObject *child = - qobject_cast(object->getChildren()->at(0)); + qobject_cast(object->children()->at(0)); QVERIFY(child != 0); QCOMPARE(child->id(), QString("myObjectId")); QCOMPARE(object->property("object"), QVariant::fromValue((QObject *)child)); @@ -1034,13 +1034,13 @@ void tst_qmllanguage::defaultPropertyListOrder() MyContainer *container = qobject_cast(component.create()); QVERIFY(container != 0); - QCOMPARE(container->getChildren()->count(), 6); - QCOMPARE(container->getChildren()->at(0)->property("index"), QVariant(0)); - QCOMPARE(container->getChildren()->at(1)->property("index"), QVariant(1)); - QCOMPARE(container->getChildren()->at(2)->property("index"), QVariant(2)); - QCOMPARE(container->getChildren()->at(3)->property("index"), QVariant(3)); - QCOMPARE(container->getChildren()->at(4)->property("index"), QVariant(4)); - QCOMPARE(container->getChildren()->at(5)->property("index"), QVariant(5)); + QCOMPARE(container->children()->count(), 6); + QCOMPARE(container->children()->at(0)->property("index"), QVariant(0)); + QCOMPARE(container->children()->at(1)->property("index"), QVariant(1)); + QCOMPARE(container->children()->at(2)->property("index"), QVariant(2)); + QCOMPARE(container->children()->at(3)->property("index"), QVariant(3)); + QCOMPARE(container->children()->at(4)->property("index"), QVariant(4)); + QCOMPARE(container->children()->at(5)->property("index"), QVariant(5)); } void tst_qmllanguage::declaredPropertyValues() diff --git a/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp b/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp index 9bf47b6..ddf9a07 100644 --- a/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp +++ b/tests/auto/declarative/qmllistaccessor/tst_qmllistaccessor.cpp @@ -52,7 +52,7 @@ public: private slots: void invalid(); void qmllist(); - void listproperty(); + void qlist(); void qstringlist(); void qvariantlist(); void qobject(); @@ -149,7 +149,7 @@ void tst_QmlListAccessor::qmllist() QCOMPARE(list.count(), 0); } -void tst_QmlListAccessor::listproperty() +void tst_QmlListAccessor::qlist() { QList list; QObject *obj = new QObject(this); @@ -161,11 +161,11 @@ void tst_QmlListAccessor::listproperty() QCOMPARE(list.at(0), obj); QmlListAccessor accessor; - accessor.setList(qVariantFromValue(QmlListProperty(this, list))); - QVERIFY(qvariant_cast >(accessor.list()) == QmlListProperty(this, list)); + accessor.setList(qVariantFromValue((QList*)&list)); + QCOMPARE(accessor.list(), qVariantFromValue((QList*)&list)); // type - QCOMPARE(accessor.type(), QmlListAccessor::ListProperty); + QCOMPARE(accessor.type(), QmlListAccessor::QListPtr); // isValid QVERIFY(accessor.isValid()); -- cgit v0.12 From a38a6fe09b93e7962163858bb5ae3d0b0244c91b Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 17 Feb 2010 14:39:55 +1000 Subject: qmlviewer: build on symbian Task-number: QTBUG-8266 --- tools/qmlviewer/qmlviewer.pro | 1 + 1 file changed, 1 insertion(+) diff --git a/tools/qmlviewer/qmlviewer.pro b/tools/qmlviewer/qmlviewer.pro index 81c1e6c..aba3cf5 100644 --- a/tools/qmlviewer/qmlviewer.pro +++ b/tools/qmlviewer/qmlviewer.pro @@ -33,6 +33,7 @@ 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 -- cgit v0.12 From 7f6317c25e6c1ec457971ab70c850d4d2bbe4cd2 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 17 Feb 2010 14:52:24 +1000 Subject: Fix currentIndex after itemsMoved() Ensure fixupPosition() positions properly for StrictlyEnforceRange highlight mode. Update visibleIndex after itemsMoved(). --- .../graphicsitems/qmlgraphicslistview.cpp | 54 ++++++++++++++++++---- 1 file changed, 46 insertions(+), 8 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicslistview.cpp b/src/declarative/graphicsitems/qmlgraphicslistview.cpp index db0afe1..da6f8e0 100644 --- a/src/declarative/graphicsitems/qmlgraphicslistview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicslistview.cpp @@ -1069,9 +1069,13 @@ void QmlGraphicsListViewPrivate::fixupY() fixupDuration = moveReason == Mouse ? fixupDuration : 0; if (haveHighlightRange && highlightRange == QmlGraphicsListView::StrictlyEnforceRange) { - if (currentItem && highlight && currentItem->position() != highlight->position()) { + if (currentItem && currentItem->position() - position() != highlightRangeStart) { + qreal pos = currentItem->position() - highlightRangeStart; timeline.reset(_moveY); - timeline.move(_moveY, -(currentItem->position() - highlightRangeStart), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); + if (fixupDuration) + timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); + else + _moveY.setValue(-pos); vTime = timeline.time(); } } else if (snapMode != QmlGraphicsListView::NoSnap) { @@ -1080,7 +1084,10 @@ void QmlGraphicsListViewPrivate::fixupY() qreal dist = qAbs(_moveY + pos); if (dist > 0) { timeline.reset(_moveY); - timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); + if (fixupDuration) + timeline.move(_moveY, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); + else + _moveY.setValue(-pos); vTime = timeline.time(); } } @@ -1102,9 +1109,13 @@ void QmlGraphicsListViewPrivate::fixupX() fixupDuration = moveReason == Mouse ? fixupDuration : 0; if (haveHighlightRange && highlightRange == QmlGraphicsListView::StrictlyEnforceRange) { - if (currentItem && highlight && currentItem->position() != highlight->position()) { + if (currentItem && currentItem->position() - position() != highlightRangeStart) { + qreal pos = currentItem->position() - highlightRangeStart; timeline.reset(_moveX); - timeline.move(_moveX, -(currentItem->position() - highlightRangeStart), QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); + if (fixupDuration) + timeline.move(_moveX, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); + else + _moveX.setValue(-pos); vTime = timeline.time(); } } else if (snapMode != QmlGraphicsListView::NoSnap) { @@ -1113,7 +1124,10 @@ void QmlGraphicsListViewPrivate::fixupX() qreal dist = qAbs(_moveX + pos); if (dist > 0) { timeline.reset(_moveX); - timeline.move(_moveX, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); + if (fixupDuration) + timeline.move(_moveX, -pos, QEasingCurve(QEasingCurve::InOutQuad), fixupDuration); + else + _moveX.setValue(-pos); vTime = timeline.time(); } } @@ -2261,6 +2275,7 @@ void QmlGraphicsListView::positionViewAtIndex(int index) for (int i = 0; i < oldVisible.count(); ++i) d->releaseItem(oldVisible.at(i)); } + d->fixupPosition(); } @@ -2633,9 +2648,32 @@ void QmlGraphicsListView::itemsMoved(int from, int to, int count) ++endIndex; } + // update visibleIndex + for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) { + if ((*it)->index != -1) { + d->visibleIndex = (*it)->index; + break; + } + } + + // Fix current index + if (d->currentIndex >= 0 && d->currentItem) { + int oldCurrent = d->currentIndex; + d->currentIndex = d->model->indexOf(d->currentItem->item, this); + if (oldCurrent != d->currentIndex) { + d->currentItem->index = d->currentIndex; + emit currentIndexChanged(); + } + } + // Whatever moved items remain are no longer visible items. - while (moved.count()) - d->releaseItem(moved.take(moved.begin().key())); + while (moved.count()) { + int idx = moved.begin().key(); + FxListItem *item = moved.take(idx); + if (item->item == d->currentItem->item) + item->setPosition(d->positionAt(idx)); + d->releaseItem(item); + } // Ensure we don't cause an ugly list scroll. d->visibleItems.first()->setPosition(d->visibleItems.first()->position() + moveBy); -- cgit v0.12 From 060d833d3e0fd5a99876e0717fb26ef93fae30e1 Mon Sep 17 00:00:00 2001 From: Joona Petrell Date: Tue, 16 Feb 2010 16:16:38 +1000 Subject: Add missing NOTIFY signals to various QML item class properties Reviewed-by: Aaron Kennedy --- .../graphicsitems/qmlgraphicsflickable.cpp | 8 ++ .../graphicsitems/qmlgraphicsflickable_p.h | 12 +- src/declarative/graphicsitems/qmlgraphicsitem.cpp | 4 + src/declarative/graphicsitems/qmlgraphicsitem.h | 6 +- .../graphicsitems/qmlgraphicsloader.cpp | 1 + .../graphicsitems/qmlgraphicsloader_p.h | 4 +- .../graphicsitems/qmlgraphicsmouseregion.cpp | 18 +++ .../graphicsitems/qmlgraphicsmouseregion_p.h | 22 +++- .../graphicsitems/qmlgraphicsrepeater.cpp | 9 ++ .../graphicsitems/qmlgraphicsrepeater_p.h | 7 +- tests/auto/declarative/declarative.pro | 1 + .../tst_qmlgraphicsflickable.cpp | 79 ++++++++++++ .../qmlgraphicsitem/tst_qmlgraphicsitem.cpp | 52 +++++++- .../qmlgraphicsloader/tst_qmlgraphicsloader.cpp | 8 ++ .../qmlgraphicsmouseregion/data/dragproperties.qml | 28 ++++ .../qmlgraphicsmouseregion.pro | 9 ++ .../tst_qmlgraphicsmouseregion.cpp | 142 +++++++++++++++++++++ .../qmlgraphicsrepeater/data/properties.qml | 11 ++ .../tst_qmlgraphicsrepeater.cpp | 40 +++++- 19 files changed, 441 insertions(+), 20 deletions(-) create mode 100644 tests/auto/declarative/qmlgraphicsmouseregion/data/dragproperties.qml create mode 100644 tests/auto/declarative/qmlgraphicsmouseregion/qmlgraphicsmouseregion.pro create mode 100644 tests/auto/declarative/qmlgraphicsmouseregion/tst_qmlgraphicsmouseregion.cpp create mode 100644 tests/auto/declarative/qmlgraphicsrepeater/data/properties.qml diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp index 5143251..39fe5b4 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflickable.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsflickable.cpp @@ -1006,7 +1006,10 @@ bool QmlGraphicsFlickable::overShoot() const void QmlGraphicsFlickable::setOverShoot(bool o) { Q_D(QmlGraphicsFlickable); + if (d->overShoot == o) + return; d->overShoot = o; + emit overShootChanged(); } /*! @@ -1215,6 +1218,7 @@ void QmlGraphicsFlickable::setMaximumFlickVelocity(qreal v) if (v == d->maxVelocity) return; d->maxVelocity = v; + emit maximumFlickVelocityChanged(); } /*! @@ -1232,7 +1236,10 @@ qreal QmlGraphicsFlickable::flickDeceleration() const void QmlGraphicsFlickable::setFlickDeceleration(qreal deceleration) { Q_D(QmlGraphicsFlickable); + if (deceleration == d->deceleration) + return; d->deceleration = deceleration; + emit flickDecelerationChanged(); } /*! @@ -1270,6 +1277,7 @@ void QmlGraphicsFlickable::setPressDelay(int delay) if (d->pressDelay == delay) return; d->pressDelay = delay; + emit pressDelayChanged(); } qreal QmlGraphicsFlickable::reportedVelocitySmoothing() const diff --git a/src/declarative/graphicsitems/qmlgraphicsflickable_p.h b/src/declarative/graphicsitems/qmlgraphicsflickable_p.h index ea07da4..5a1d15a 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflickable_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsflickable_p.h @@ -65,15 +65,15 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsFlickable : public QmlGraphicsItem Q_PROPERTY(qreal verticalVelocity READ verticalVelocity NOTIFY verticalVelocityChanged) Q_PROPERTY(qreal reportedVelocitySmoothing READ reportedVelocitySmoothing WRITE setReportedVelocitySmoothing NOTIFY reportedVelocitySmoothingChanged) - Q_PROPERTY(bool overShoot READ overShoot WRITE setOverShoot) - Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity) - Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration) + Q_PROPERTY(bool overShoot READ overShoot WRITE setOverShoot NOTIFY overShootChanged) + Q_PROPERTY(qreal maximumFlickVelocity READ maximumFlickVelocity WRITE setMaximumFlickVelocity NOTIFY maximumFlickVelocityChanged) + Q_PROPERTY(qreal flickDeceleration READ flickDeceleration WRITE setFlickDeceleration NOTIFY flickDecelerationChanged) Q_PROPERTY(bool moving READ isMoving NOTIFY movingChanged) Q_PROPERTY(bool flicking READ isFlicking NOTIFY flickingChanged) Q_PROPERTY(FlickDirection flickDirection READ flickDirection WRITE setFlickDirection NOTIFY flickDirectionChanged) Q_PROPERTY(bool interactive READ isInteractive WRITE setInteractive NOTIFY interactiveChanged) - Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay) + Q_PROPERTY(int pressDelay READ pressDelay WRITE setPressDelay NOTIFY pressDelayChanged) Q_PROPERTY(bool atXEnd READ isAtXEnd NOTIFY isAtBoundaryChanged) Q_PROPERTY(bool atYEnd READ isAtYEnd NOTIFY isAtBoundaryChanged) @@ -160,6 +160,10 @@ Q_SIGNALS: void pageChanged(); void flickDirectionChanged(); void interactiveChanged(); + void overShootChanged(); + void maximumFlickVelocityChanged(); + void flickDecelerationChanged(); + void pressDelayChanged(); protected: virtual bool sceneEventFilter(QGraphicsItem *, QEvent *); diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp index 2fbf18b..5cda430 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp @@ -1640,7 +1640,10 @@ bool QmlGraphicsItem::clip() const void QmlGraphicsItem::setClip(bool c) { + if (clip() == c) + return; setFlag(ItemClipsChildrenToShape, c); + emit clipChanged(); } /*! @@ -2628,6 +2631,7 @@ void QmlGraphicsItem::setSmooth(bool smooth) if (d->smooth == smooth) return; d->smooth = smooth; + emit smoothChanged(); update(); } diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.h b/src/declarative/graphicsitems/qmlgraphicsitem.h index e0f33c7..ed4a7cf 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.h +++ b/src/declarative/graphicsitems/qmlgraphicsitem.h @@ -88,12 +88,12 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsItem : public QGraphicsObject, public QmlP Q_PROPERTY(QmlGraphicsAnchorLine verticalCenter READ verticalCenter CONSTANT FINAL) Q_PROPERTY(QmlGraphicsAnchorLine baseline READ baseline CONSTANT FINAL) Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged) - Q_PROPERTY(bool clip READ clip WRITE setClip) // ### move to QGI/QGO, NOTIFY + Q_PROPERTY(bool clip READ clip WRITE setClip NOTIFY clipChanged) // ### move to QGI/QGO, NOTIFY Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL) Q_PROPERTY(bool wantsFocus READ wantsFocus NOTIFY wantsFocusChanged) Q_PROPERTY(QmlList* transform READ transform DESIGNABLE false FINAL) Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin NOTIFY transformOriginChanged) - Q_PROPERTY(bool smooth READ smooth WRITE setSmooth) + Q_PROPERTY(bool smooth READ smooth WRITE setSmooth NOTIFY smoothChanged) Q_PROPERTY(QGraphicsEffect *effect READ graphicsEffect WRITE setGraphicsEffect) Q_ENUMS(TransformOrigin) Q_CLASSINFO("DefaultProperty", "data") @@ -178,6 +178,8 @@ Q_SIGNALS: void wantsFocusChanged(); void parentChanged(); void transformOriginChanged(TransformOrigin); + void smoothChanged(); + void clipChanged(); protected: bool isComponentComplete() const; diff --git a/src/declarative/graphicsitems/qmlgraphicsloader.cpp b/src/declarative/graphicsitems/qmlgraphicsloader.cpp index d778c83..342fec2 100644 --- a/src/declarative/graphicsitems/qmlgraphicsloader.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsloader.cpp @@ -398,6 +398,7 @@ void QmlGraphicsLoader::setResizeMode(ResizeMode mode) } d->resizeMode = mode; + emit resizeModeChanged(); d->initResize(); } diff --git a/src/declarative/graphicsitems/qmlgraphicsloader_p.h b/src/declarative/graphicsitems/qmlgraphicsloader_p.h index 87b6a52..a115aa9 100644 --- a/src/declarative/graphicsitems/qmlgraphicsloader_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsloader_p.h @@ -59,7 +59,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsLoader : public QmlGraphicsItem Q_PROPERTY(QUrl source READ source WRITE setSource NOTIFY sourceChanged) Q_PROPERTY(QmlComponent *sourceComponent READ sourceComponent WRITE setSourceComponent NOTIFY sourceChanged) - Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode) + Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode NOTIFY resizeModeChanged) Q_PROPERTY(QGraphicsObject *item READ item NOTIFY itemChanged) Q_PROPERTY(Status status READ status NOTIFY statusChanged) Q_PROPERTY(qreal progress READ progress NOTIFY progressChanged) @@ -89,6 +89,8 @@ Q_SIGNALS: void sourceChanged(); void statusChanged(); void progressChanged(); + void resizeModeChanged(); + protected: void geometryChanged(const QRectF &newGeometry, const QRectF &oldGeometry); QVariant itemChange(GraphicsItemChange change, const QVariant &value); diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp index fe72e84..003c18d 100644 --- a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp @@ -65,7 +65,10 @@ QmlGraphicsItem *QmlGraphicsDrag::target() const void QmlGraphicsDrag::setTarget(QmlGraphicsItem *t) { + if (_target == t) + return; _target = t; + emit targetChanged(); } QmlGraphicsDrag::Axis QmlGraphicsDrag::axis() const @@ -75,7 +78,10 @@ QmlGraphicsDrag::Axis QmlGraphicsDrag::axis() const void QmlGraphicsDrag::setAxis(QmlGraphicsDrag::Axis a) { + if (_axis == a) + return; _axis = a; + emit axisChanged(); } qreal QmlGraphicsDrag::xmin() const @@ -85,7 +91,10 @@ qreal QmlGraphicsDrag::xmin() const void QmlGraphicsDrag::setXmin(qreal m) { + if (_xmin == m) + return; _xmin = m; + emit minimumXChanged(); } qreal QmlGraphicsDrag::xmax() const @@ -95,7 +104,10 @@ qreal QmlGraphicsDrag::xmax() const void QmlGraphicsDrag::setXmax(qreal m) { + if (_xmax == m) + return; _xmax = m; + emit maximumXChanged(); } qreal QmlGraphicsDrag::ymin() const @@ -105,7 +117,10 @@ qreal QmlGraphicsDrag::ymin() const void QmlGraphicsDrag::setYmin(qreal m) { + if (_ymin == m) + return; _ymin = m; + emit minimumYChanged(); } qreal QmlGraphicsDrag::ymax() const @@ -115,7 +130,10 @@ qreal QmlGraphicsDrag::ymax() const void QmlGraphicsDrag::setYmax(qreal m) { + if (_ymax == m) + return; _ymax = m; + emit maximumYChanged(); } QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate() diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion_p.h b/src/declarative/graphicsitems/qmlgraphicsmouseregion_p.h index 0ddad1b..1a8f83e 100644 --- a/src/declarative/graphicsitems/qmlgraphicsmouseregion_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsmouseregion_p.h @@ -55,12 +55,12 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsDrag : public QObject Q_OBJECT Q_ENUMS(Axis) - Q_PROPERTY(QmlGraphicsItem *target READ target WRITE setTarget) - Q_PROPERTY(Axis axis READ axis WRITE setAxis) - Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin) - Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax) - Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin) - Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax) + Q_PROPERTY(QmlGraphicsItem *target READ target WRITE setTarget NOTIFY targetChanged) + Q_PROPERTY(Axis axis READ axis WRITE setAxis NOTIFY axisChanged) + Q_PROPERTY(qreal minimumX READ xmin WRITE setXmin NOTIFY minimumXChanged) + Q_PROPERTY(qreal maximumX READ xmax WRITE setXmax NOTIFY maximumXChanged) + Q_PROPERTY(qreal minimumY READ ymin WRITE setYmin NOTIFY minimumYChanged) + Q_PROPERTY(qreal maximumY READ ymax WRITE setYmax NOTIFY maximumYChanged) //### consider drag and drop public: @@ -83,6 +83,14 @@ public: qreal ymax() const; void setYmax(qreal); +Q_SIGNALS: + void targetChanged(); + void axisChanged(); + void minimumXChanged(); + void maximumXChanged(); + void minimumYChanged(); + void maximumYChanged(); + private: QmlGraphicsItem *_target; Axis _axis; @@ -107,7 +115,7 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsMouseRegion : public QmlGraphicsItem Q_PROPERTY(Qt::MouseButtons pressedButtons READ pressedButtons NOTIFY pressedChanged) Q_PROPERTY(Qt::MouseButtons acceptedButtons READ acceptedButtons WRITE setAcceptedButtons NOTIFY acceptedButtonsChanged) Q_PROPERTY(bool hoverEnabled READ acceptHoverEvents WRITE setAcceptHoverEvents) - Q_PROPERTY(QmlGraphicsDrag *drag READ drag) //### add flicking to QmlGraphicsDrag or add a QmlGraphicsFlick ??? + Q_PROPERTY(QmlGraphicsDrag *drag READ drag CONSTANT) //### add flicking to QmlGraphicsDrag or add a QmlGraphicsFlick ??? public: QmlGraphicsMouseRegion(QmlGraphicsItem *parent=0); diff --git a/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp b/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp index f0e5bb3..4b01952 100644 --- a/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsrepeater.cpp @@ -157,6 +157,9 @@ QVariant QmlGraphicsRepeater::model() const void QmlGraphicsRepeater::setModel(const QVariant &model) { Q_D(QmlGraphicsRepeater); + if (d->dataSource == model) + return; + clear(); if (d->model) { disconnect(d->model, SIGNAL(itemsInserted(int,int)), this, SLOT(itemsInserted(int,int))); @@ -168,6 +171,7 @@ void QmlGraphicsRepeater::setModel(const QVariant &model) */ } d->dataSource = model; + emit modelChanged(); QObject *object = qvariant_cast(model); QmlGraphicsVisualModel *vim = 0; if (object && (vim = qobject_cast(object))) { @@ -219,6 +223,10 @@ QmlComponent *QmlGraphicsRepeater::delegate() const void QmlGraphicsRepeater::setDelegate(QmlComponent *delegate) { Q_D(QmlGraphicsRepeater); + if (QmlGraphicsVisualDataModel *dataModel = qobject_cast(d->model)) + if (delegate == dataModel->delegate()) + return; + if (!d->ownModel) { d->model = new QmlGraphicsVisualDataModel(qmlContext(this)); d->ownModel = true; @@ -226,6 +234,7 @@ void QmlGraphicsRepeater::setDelegate(QmlComponent *delegate) if (QmlGraphicsVisualDataModel *dataModel = qobject_cast(d->model)) { dataModel->setDelegate(delegate); regenerate(); + emit delegateChanged(); } } diff --git a/src/declarative/graphicsitems/qmlgraphicsrepeater_p.h b/src/declarative/graphicsitems/qmlgraphicsrepeater_p.h index 61f82d7..d0c009f 100644 --- a/src/declarative/graphicsitems/qmlgraphicsrepeater_p.h +++ b/src/declarative/graphicsitems/qmlgraphicsrepeater_p.h @@ -55,8 +55,8 @@ class Q_DECLARATIVE_EXPORT QmlGraphicsRepeater : public QmlGraphicsItem { Q_OBJECT - Q_PROPERTY(QVariant model READ model WRITE setModel) - Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate) + Q_PROPERTY(QVariant model READ model WRITE setModel NOTIFY modelChanged) + Q_PROPERTY(QmlComponent *delegate READ delegate WRITE setDelegate NOTIFY delegateChanged) Q_PROPERTY(int count READ count NOTIFY countChanged) Q_CLASSINFO("DefaultProperty", "delegate") @@ -73,8 +73,9 @@ public: int count() const; Q_SIGNALS: + void modelChanged(); + void delegateChanged(); void countChanged(); - private: void clear(); void regenerate(); diff --git a/tests/auto/declarative/declarative.pro b/tests/auto/declarative/declarative.pro index 9ef10b0..b4a0d0f 100644 --- a/tests/auto/declarative/declarative.pro +++ b/tests/auto/declarative/declarative.pro @@ -29,6 +29,7 @@ SUBDIRS += \ qmlgraphicsitem \ # Cover qmlgraphicslistview \ # Cover qmlgraphicsloader \ # Cover + qmlgraphicsmouseregion \ # Cover qmlgraphicsparticles \ # Cover qmlgraphicspathview \ # Cover qmlgraphicspositioners \ # Cover diff --git a/tests/auto/declarative/qmlgraphicsflickable/tst_qmlgraphicsflickable.cpp b/tests/auto/declarative/qmlgraphicsflickable/tst_qmlgraphicsflickable.cpp index c0ffeb7..7860bcf 100644 --- a/tests/auto/declarative/qmlgraphicsflickable/tst_qmlgraphicsflickable.cpp +++ b/tests/auto/declarative/qmlgraphicsflickable/tst_qmlgraphicsflickable.cpp @@ -39,6 +39,7 @@ ** ****************************************************************************/ #include +#include #include #include #include @@ -56,6 +57,10 @@ private slots: void horizontalViewportSize(); void verticalViewportSize(); void properties(); + void overShoot(); + void maximumFlickVelocity(); + void flickDeceleration(); + void pressDelay(); private: QmlEngine engine; @@ -140,6 +145,80 @@ void tst_qmlgraphicsflickable::properties() delete obj; } +void tst_qmlgraphicsflickable::overShoot() +{ + QmlComponent component(&engine); + component.setData("import Qt 4.6; Flickable { overShoot: false; }", QUrl::fromLocalFile("")); + QmlGraphicsFlickable *flickable = qobject_cast(component.create()); + QSignalSpy spy(flickable, SIGNAL(overShootChanged())); + + QVERIFY(flickable); + QVERIFY(!flickable->overShoot()); + + flickable->setOverShoot(true); + QVERIFY(flickable->overShoot()); + QCOMPARE(spy.count(),1); + flickable->setOverShoot(true); + QCOMPARE(spy.count(),1); + + flickable->setOverShoot(false); + QVERIFY(!flickable->overShoot()); + QCOMPARE(spy.count(),2); + flickable->setOverShoot(false); + QCOMPARE(spy.count(),2); +} + +void tst_qmlgraphicsflickable::maximumFlickVelocity() +{ + QmlComponent component(&engine); + component.setData("import Qt 4.6; Flickable { maximumFlickVelocity: 1.0; }", QUrl::fromLocalFile("")); + QmlGraphicsFlickable *flickable = qobject_cast(component.create()); + QSignalSpy spy(flickable, SIGNAL(maximumFlickVelocityChanged())); + + QVERIFY(flickable); + QCOMPARE(flickable->maximumFlickVelocity(), 1.0); + + flickable->setMaximumFlickVelocity(2.0); + QCOMPARE(flickable->maximumFlickVelocity(), 2.0); + QCOMPARE(spy.count(),1); + flickable->setMaximumFlickVelocity(2.0); + QCOMPARE(spy.count(),1); +} + +void tst_qmlgraphicsflickable::flickDeceleration() +{ + QmlComponent component(&engine); + component.setData("import Qt 4.6; Flickable { flickDeceleration: 1.0; }", QUrl::fromLocalFile("")); + QmlGraphicsFlickable *flickable = qobject_cast(component.create()); + QSignalSpy spy(flickable, SIGNAL(flickDecelerationChanged())); + + QVERIFY(flickable); + QCOMPARE(flickable->flickDeceleration(), 1.0); + + flickable->setFlickDeceleration(2.0); + QCOMPARE(flickable->flickDeceleration(), 2.0); + QCOMPARE(spy.count(),1); + flickable->setFlickDeceleration(2.0); + QCOMPARE(spy.count(),1); +} + +void tst_qmlgraphicsflickable::pressDelay() +{ + QmlComponent component(&engine); + component.setData("import Qt 4.6; Flickable { pressDelay: 100; }", QUrl::fromLocalFile("")); + QmlGraphicsFlickable *flickable = qobject_cast(component.create()); + QSignalSpy spy(flickable, SIGNAL(pressDelayChanged())); + + QVERIFY(flickable); + QCOMPARE(flickable->pressDelay(), 100); + + flickable->setPressDelay(200); + QCOMPARE(flickable->pressDelay(), 200); + QCOMPARE(spy.count(),1); + flickable->setPressDelay(200); + QCOMPARE(spy.count(),1); +} + QTEST_MAIN(tst_qmlgraphicsflickable) #include "tst_qmlgraphicsflickable.moc" diff --git a/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp b/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp index c671dae..639f64c 100644 --- a/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp +++ b/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp @@ -39,11 +39,12 @@ ** ****************************************************************************/ #include +#include #include #include #include #include -#include +#include class tst_QmlGraphicsItem : public QObject @@ -55,10 +56,13 @@ public: private slots: void keys(); void keyNavigation(); + void smooth(); + void clip(); private: template T *findItem(QmlGraphicsItem *parent, const QString &objectName); + QmlEngine engine; }; class KeysTestObject : public QObject @@ -241,6 +245,52 @@ void tst_QmlGraphicsItem::keyNavigation() QVERIFY(item->hasFocus()); } +void tst_QmlGraphicsItem::smooth() +{ + QmlComponent component(&engine); + component.setData("import Qt 4.6; Item { smooth: false; }", QUrl::fromLocalFile("")); + QmlGraphicsItem *item = qobject_cast(component.create()); + QSignalSpy spy(item, SIGNAL(smoothChanged())); + + QVERIFY(item); + QVERIFY(!item->smooth()); + + item->setSmooth(true); + QVERIFY(item->smooth()); + QCOMPARE(spy.count(),1); + item->setSmooth(true); + QCOMPARE(spy.count(),1); + + item->setSmooth(false); + QVERIFY(!item->smooth()); + QCOMPARE(spy.count(),2); + item->setSmooth(false); + QCOMPARE(spy.count(),2); +} + +void tst_QmlGraphicsItem::clip() +{ + QmlComponent component(&engine); + component.setData("import Qt 4.6\nItem { clip: false\n }", QUrl::fromLocalFile("")); + QmlGraphicsItem *item = qobject_cast(component.create()); + QSignalSpy spy(item, SIGNAL(clipChanged())); + + QVERIFY(item); + QVERIFY(!item->clip()); + + item->setClip(true); + QVERIFY(item->clip()); + QCOMPARE(spy.count(),1); + item->setClip(true); + QCOMPARE(spy.count(),1); + + item->setClip(false); + QVERIFY(!item->clip()); + QCOMPARE(spy.count(),2); + item->setClip(false); + QCOMPARE(spy.count(),2); +} + template T *tst_QmlGraphicsItem::findItem(QmlGraphicsItem *parent, const QString &objectName) { diff --git a/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp b/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp index 43f58c1..65c0523 100644 --- a/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp +++ b/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp @@ -42,6 +42,7 @@ #include #include +#include #include #include #include @@ -259,6 +260,13 @@ void tst_QmlGraphicsLoader::sizeLoaderToItem() loader->setHeight(30); QCOMPARE(rect->width(), 180.0); QCOMPARE(rect->height(), 30.0); + + // notify + QSignalSpy spy(loader, SIGNAL(resizeModeChanged())); + loader->setResizeMode(QmlGraphicsLoader::NoResize); + QCOMPARE(spy.count(),1); + loader->setResizeMode(QmlGraphicsLoader::NoResize); + QCOMPARE(spy.count(),1); } void tst_QmlGraphicsLoader::sizeItemToLoader() diff --git a/tests/auto/declarative/qmlgraphicsmouseregion/data/dragproperties.qml b/tests/auto/declarative/qmlgraphicsmouseregion/data/dragproperties.qml new file mode 100644 index 0000000..5acb3e4 --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsmouseregion/data/dragproperties.qml @@ -0,0 +1,28 @@ +import Qt 4.6 +Rectangle { + id: whiteRect + width: 200 + height: 200 + color: "white" + Rectangle { + id: blackRect + objectName: "blackrect" + color: "black" + y: 50 + x: 50 + width: 100 + height: 100 + opacity: (whiteRect.width-blackRect.x+whiteRect.height-blackRect.y-199)/200 + Text { text: blackRect.opacity} + MouseRegion { + objectName: "mouseregion" + anchors.fill: parent + drag.target: blackRect + drag.axis: Drag.XandYAxis + drag.minimumX: 0 + drag.maximumX: whiteRect.width-blackRect.width + drag.minimumY: 0 + drag.maximumY: whiteRect.height-blackRect.height + } + } + } \ No newline at end of file diff --git a/tests/auto/declarative/qmlgraphicsmouseregion/qmlgraphicsmouseregion.pro b/tests/auto/declarative/qmlgraphicsmouseregion/qmlgraphicsmouseregion.pro new file mode 100644 index 0000000..7a7c8bd --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsmouseregion/qmlgraphicsmouseregion.pro @@ -0,0 +1,9 @@ +load(qttest_p4) +contains(QT_CONFIG,declarative): QT += declarative gui network +macx:CONFIG -= app_bundle + +HEADERS += ../shared/testhttpserver.h +SOURCES += tst_qmlgraphicsmouseregion.cpp ../shared/testhttpserver.cpp + +# Define SRCDIR equal to test's source directory +DEFINES += SRCDIR=\\\"$$PWD\\\" diff --git a/tests/auto/declarative/qmlgraphicsmouseregion/tst_qmlgraphicsmouseregion.cpp b/tests/auto/declarative/qmlgraphicsmouseregion/tst_qmlgraphicsmouseregion.cpp new file mode 100644 index 0000000..7ba076c --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsmouseregion/tst_qmlgraphicsmouseregion.cpp @@ -0,0 +1,142 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** All rights reserved. +** Contact: Nokia Corporation (qt-info@nokia.com) +** +** This file is part of the test suite 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$ +** +****************************************************************************/ + +#include +#include +#include +#include + +class tst_QmlGraphicsMouseRegion: public QObject +{ + Q_OBJECT +private slots: + void dragProperties(); +private: + QmlView *createView(const QString &filename); +}; + +void tst_QmlGraphicsMouseRegion::dragProperties() +{ + QmlView *canvas = createView(SRCDIR "/data/dragproperties.qml"); + canvas->execute(); + canvas->show(); + canvas->setFocus(); + QVERIFY(canvas->root() != 0); + + QmlGraphicsMouseRegion *mouseRegion = canvas->root()->findChild("mouseregion"); + QmlGraphicsDrag *drag = mouseRegion->drag(); + QVERIFY(mouseRegion != 0); + QVERIFY(drag != 0); + + // target + QmlGraphicsItem *blackRect = canvas->root()->findChild("blackrect"); + QVERIFY(blackRect != 0); + QVERIFY(blackRect == drag->target()); + QmlGraphicsItem *rootItem = qobject_cast(canvas->root()); + QVERIFY(rootItem != 0); + QSignalSpy targetSpy(drag, SIGNAL(targetChanged())); + drag->setTarget(rootItem); + QCOMPARE(targetSpy.count(),1); + drag->setTarget(rootItem); + QCOMPARE(targetSpy.count(),1); + + // axis + QCOMPARE(drag->axis(), QmlGraphicsDrag::XandYAxis); + QSignalSpy axisSpy(drag, SIGNAL(axisChanged())); + drag->setAxis(QmlGraphicsDrag::XAxis); + QCOMPARE(drag->axis(), QmlGraphicsDrag::XAxis); + QCOMPARE(axisSpy.count(),1); + drag->setAxis(QmlGraphicsDrag::XAxis); + QCOMPARE(axisSpy.count(),1); + + // minimum and maximum properties + QSignalSpy xminSpy(drag, SIGNAL(minimumXChanged())); + QSignalSpy xmaxSpy(drag, SIGNAL(maximumXChanged())); + QSignalSpy yminSpy(drag, SIGNAL(minimumYChanged())); + QSignalSpy ymaxSpy(drag, SIGNAL(maximumYChanged())); + + QCOMPARE(drag->xmin(), 0.0); + QCOMPARE(drag->xmax(), rootItem->width()-blackRect->width()); + QCOMPARE(drag->ymin(), 0.0); + QCOMPARE(drag->ymax(), rootItem->height()-blackRect->height()); + + drag->setXmin(10); + drag->setXmax(10); + drag->setYmin(10); + drag->setYmax(10); + + QCOMPARE(drag->xmin(), 10.0); + QCOMPARE(drag->xmax(), 10.0); + QCOMPARE(drag->ymin(), 10.0); + QCOMPARE(drag->ymax(), 10.0); + + QCOMPARE(xminSpy.count(),1); + QCOMPARE(xmaxSpy.count(),1); + QCOMPARE(yminSpy.count(),1); + QCOMPARE(ymaxSpy.count(),1); + + drag->setXmin(10); + drag->setXmax(10); + drag->setYmin(10); + drag->setYmax(10); + + QCOMPARE(xminSpy.count(),1); + QCOMPARE(xmaxSpy.count(),1); + QCOMPARE(yminSpy.count(),1); + QCOMPARE(ymaxSpy.count(),1); +} + +QmlView *tst_QmlGraphicsMouseRegion::createView(const QString &filename) +{ + QmlView *canvas = new QmlView(0); + canvas->setFixedSize(240,320); + + QFile file(filename); + file.open(QFile::ReadOnly); + QString qml = file.readAll(); + canvas->setQml(qml, filename); + + return canvas; +} + +QTEST_MAIN(tst_QmlGraphicsMouseRegion) + +#include "tst_qmlgraphicsmouseregion.moc" diff --git a/tests/auto/declarative/qmlgraphicsrepeater/data/properties.qml b/tests/auto/declarative/qmlgraphicsrepeater/data/properties.qml new file mode 100644 index 0000000..550ce8d --- /dev/null +++ b/tests/auto/declarative/qmlgraphicsrepeater/data/properties.qml @@ -0,0 +1,11 @@ +import Qt 4.6 + +Row { + Repeater { + objectName: "repeater" + model: 5 + Text { + text: "I'm item " + index + } + } +} \ No newline at end of file diff --git a/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp b/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp index 4297901..ef0ca1d 100644 --- a/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp +++ b/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp @@ -38,12 +38,20 @@ ** $QT_END_LICENSE$ ** ****************************************************************************/ + #include +#include #include -#include +#include +#include +#include #include #include -#include + +inline QUrl TEST_FILE(const QString &filename) +{ + return QUrl::fromLocalFile(QLatin1String(SRCDIR) + QLatin1String("/data/") + filename); +} class tst_QmlGraphicsRepeater : public QObject { @@ -57,6 +65,7 @@ private slots: void stringList(); void dataModel(); void itemModel(); + void properties(); private: QmlView *createView(const QString &filename); @@ -317,6 +326,33 @@ void tst_QmlGraphicsRepeater::itemModel() delete canvas; } +void tst_QmlGraphicsRepeater::properties() +{ + QmlEngine engine; + QmlComponent component(&engine, TEST_FILE("/properties.qml")); + + QmlGraphicsItem *root = qobject_cast(component.create()); + QVERIFY(root); + + QmlGraphicsRepeater *repeater = findItem(root, "repeater"); + QVERIFY(repeater); + + QSignalSpy modelSpy(repeater, SIGNAL(modelChanged())); + repeater->setModel(3); + QCOMPARE(modelSpy.count(),1); + repeater->setModel(3); + QCOMPARE(modelSpy.count(),1); + + QSignalSpy delegateSpy(repeater, SIGNAL(delegateChanged())); + + QmlComponent rectComponent(&engine); + rectComponent.setData("import Qt 4.6; Rectangle {}", QUrl::fromLocalFile("")); + + repeater->setDelegate(&rectComponent); + QCOMPARE(delegateSpy.count(),1); + repeater->setDelegate(&rectComponent); + QCOMPARE(delegateSpy.count(),1); +} QmlView *tst_QmlGraphicsRepeater::createView(const QString &filename) { -- cgit v0.12 From 2b3ffec298b1c210d0e978c6c0e9cc4f51e72294 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 17 Feb 2010 17:19:56 +1000 Subject: Document loading QML from Qt resources. --- doc/src/declarative/qtbinding.qdoc | 36 ++++++++++++++++++++++++++++++++++++ 1 file changed, 36 insertions(+) diff --git a/doc/src/declarative/qtbinding.qdoc b/doc/src/declarative/qtbinding.qdoc index cae0263..2b427dc 100644 --- a/doc/src/declarative/qtbinding.qdoc +++ b/doc/src/declarative/qtbinding.qdoc @@ -358,5 +358,41 @@ void MyApplication::continueLoading() } } \endcode + +\section1 Qt Resources + +QML content can be loaded from \l {The Qt Resource System} using the \e qrc: URL scheme. +For example: + +\code + + + main.qml + images/background.png + + +\endcode +\code +// main.cpp +MyApplication::MyApplication() +{ + // ... + component = new QmlComponent(engine, QUrl("qrc:/main.qml")); + if (component->isError()) { + qWarning() << component->errors(); + } else { + QObject *myObject = component->create(); + } +} +\endcode +\code +// main.qml +import Qt 4.6 + +Image { + source: "images/background.png" +} +\endcode + */ -- cgit v0.12 From 2e7fe52065114f8c56140afe26b04fba962730b4 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 17 Feb 2010 14:32:26 +0100 Subject: Fix minor doc typo --- doc/src/declarative/focus.qdoc | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/doc/src/declarative/focus.qdoc b/doc/src/declarative/focus.qdoc index 46bfc38..4439c92 100644 --- a/doc/src/declarative/focus.qdoc +++ b/doc/src/declarative/focus.qdoc @@ -326,7 +326,7 @@ which in turn gives \e {active focus} to the \c {Text} element that actually performs the work of handling the \e {Return} key. All of the QML view classes, such as \l PathView and \l GridView, behave -in a similar mannor to allow key handling in their respective delegates. +in a similar manner to allow key handling in their respective delegates. \section1 Focus Panels -- cgit v0.12 From e69dbf126d0844702fc1ef356d858839c83562cf Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 17 Feb 2010 14:38:24 +0100 Subject: Fix typo in docs --- src/declarative/graphicsitems/qmlgraphicsparticles.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp index 5edd59e..810bce8 100644 --- a/src/declarative/graphicsitems/qmlgraphicsparticles.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsparticles.cpp @@ -635,7 +635,7 @@ QmlGraphicsParticles::~QmlGraphicsParticles() } /*! - \qmlproperty string Particles::src + \qmlproperty string Particles::source This property holds the URL of the particle image. */ -- cgit v0.12 From 015db206709de206dec26d8ab9536fc88ea67af6 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Wed, 17 Feb 2010 16:05:14 +0100 Subject: Doc fix --- doc/src/declarative/qtbinding.qdoc | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/doc/src/declarative/qtbinding.qdoc b/doc/src/declarative/qtbinding.qdoc index 2b427dc..fe5ccba 100644 --- a/doc/src/declarative/qtbinding.qdoc +++ b/doc/src/declarative/qtbinding.qdoc @@ -153,7 +153,7 @@ class CustomPalette : public QObject { Q_OBJECT Q_PROPERTY(QColor background READ background WRITE setBackground NOTIFY backgroundChanged) -Q_PROPERTY(QColor text READ text WRITE setText NOTIFY text) +Q_PROPERTY(QColor text READ text WRITE setText NOTIFY textChanged) public: CustomPalette() : m_background(Qt::white), m_text(Qt::black) {} @@ -172,6 +172,10 @@ public: emit textChanged(); } } +signals: + void textChanged(); + void backgroundChanged(): + private: QColor m_background; QColor m_text; -- cgit v0.12 From 635b329592f26d64eeb6212b6056249b15293dcf Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 18 Feb 2010 08:45:49 +1000 Subject: Provide a very generous timeout for QmlImageProvider test Because it runs in an idle thread, which you would expect to be quite slow under load. --- tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp b/tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp index 475cb7a..d07558a 100644 --- a/tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp +++ b/tests/auto/declarative/qmlimageprovider/tst_qmlimageprovider.cpp @@ -44,11 +44,13 @@ #include #include +// QmlImageProvider::request() is run in an idle thread where possible +// Be generous in our timeout. #define TRY_WAIT(expr) \ do { \ - for (int ii = 0; ii < 6; ++ii) { \ + for (int ii = 0; ii < 10; ++ii) { \ if ((expr)) break; \ - QTest::qWait(50); \ + QTest::qWait(100); \ } \ QVERIFY((expr)); \ } while (false) -- cgit v0.12 From ad2b2c698d90d04aebe1f6d05c3a4eb992c0e7b6 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 16 Feb 2010 11:59:27 +1000 Subject: Get rid of the matchProperties/properties distinction, as it has proven to be confusing in practice. property/target and properties/targets will be functionally equivilant (the only distinction being singular/plural). In a transition these properties can be used for both 'matching' and explicit animation based on whether a 'to' value is supplied. The documentation, tests, examples and demos have been updated as well. --- demos/declarative/calculator/calculator.qml | 4 +- demos/declarative/flickr/common/ImageDetails.qml | 2 +- demos/declarative/flickr/common/MediaLineEdit.qml | 2 +- demos/declarative/flickr/common/ScrollBar.qml | 2 +- demos/declarative/flickr/common/Star.qml | 2 +- demos/declarative/flickr/flickr-desktop.qml | 8 +- demos/declarative/flickr/flickr-mobile.qml | 4 +- demos/declarative/flickr/mobile/GridDelegate.qml | 6 +- demos/declarative/flickr/mobile/ImageDetails.qml | 2 +- demos/declarative/flickr/mobile/TitleBar.qml | 2 +- demos/declarative/minehunt/minehunt.qml | 2 +- demos/declarative/twitter/content/HomeTitleBar.qml | 2 +- .../declarative/twitter/content/MultiTitleBar.qml | 2 +- demos/declarative/twitter/content/TitleBar.qml | 2 +- demos/declarative/twitter/twitter.qml | 2 +- .../content/RetractingWebBrowserHeader.qml | 4 +- .../webbrowser/content/fieldtext/FieldText.qml | 2 +- demos/declarative/webbrowser/webbrowser.qml | 4 +- doc/src/declarative/animation.qdoc | 88 +- doc/src/declarative/qmlstates.qdoc | 2 +- examples/declarative/anchors/anchor-changes.qml | 2 +- examples/declarative/animations/easing.qml | 4 +- examples/declarative/layouts/Button.qml | 2 +- examples/declarative/layouts/positioners.qml | 16 +- examples/declarative/listview/dynamic.qml | 2 +- examples/declarative/listview/highlight.qml | 2 +- examples/declarative/listview/recipes.qml | 2 +- examples/declarative/parallax/qml/ParallaxView.qml | 2 +- examples/declarative/scrollbar/ScrollBar.qml | 2 +- examples/declarative/scrollbar/display.qml | 2 +- examples/declarative/searchbox/SearchBox.qml | 4 +- .../declarative/slideswitch/content/Switch.qml | 2 +- examples/declarative/snow/ImageBatch.qml | 10 +- examples/declarative/states/transitions.qml | 8 +- .../declarative/tutorials/helloworld/tutorial3.qml | 2 +- .../samegame/samegame4/content/BoomBlock.qml | 2 +- examples/declarative/velocity/Day.qml | 2 +- examples/declarative/webview/autosize.qml | 2 +- examples/declarative/webview/content/FieldText.qml | 2 +- examples/declarative/xmldata/yahoonews.qml | 4 +- .../graphicsitems/qmlgraphicsflipable.cpp | 2 +- .../graphicsitems/qmlgraphicspositioners.cpp | 8 +- src/declarative/util/qmlanimation.cpp | 695 ++++----- src/declarative/util/qmlanimation_p.h | 23 +- src/declarative/util/qmlanimation_p_p.h | 24 +- src/declarative/util/qmlbehavior.cpp | 4 +- src/declarative/util/qmlstateoperations.cpp | 2 +- .../declarative/qmlanimations/data/badtype4.qml | 4 +- .../qmlanimations/data/dontAutoStart.qml | 18 + .../declarative/qmlanimations/data/dotproperty.qml | 2 +- .../declarative/qmlanimations/data/mixedtype1.qml | 2 +- .../declarative/qmlanimations/data/mixedtype2.qml | 2 +- .../declarative/qmlanimations/data/properties2.qml | 2 +- .../declarative/qmlanimations/data/properties5.qml | 2 +- .../qmlanimations/data/propertiesTransition.qml | 2 +- .../qmlanimations/data/propertiesTransition3.qml | 2 +- .../qmlanimations/data/propertiesTransition4.qml | 2 +- .../qmlanimations/data/propertiesTransition5.qml | 2 +- .../qmlanimations/data/propertiesTransition6.qml | 2 +- .../qmlanimations/tst_qmlanimations.cpp | 44 +- .../declarative/qmlbehaviors/data/explicit.qml | 26 + .../declarative/qmlbehaviors/data/nonSelecting.qml | 26 - .../qmlbehaviors/data/nonSelecting2.qml | 2 +- .../declarative/qmlbehaviors/tst_qmlbehaviors.cpp | 11 +- .../qmlgraphicspositioners/data/grid-animated.qml | 4 +- .../data/horizontal-animated.qml | 4 +- .../data/vertical-animated.qml | 4 +- .../visual/Package_Views/packageviews.qml | 2 +- .../bindinganimation/bindinganimation.qml | 2 +- .../declarative/visual/animation/easing/easing.qml | 2 +- .../visual/animation/loop/data/loop.0.png | Bin 0 -> 508 bytes .../visual/animation/loop/data/loop.1.png | Bin 0 -> 507 bytes .../visual/animation/loop/data/loop.2.png | Bin 0 -> 508 bytes .../visual/animation/loop/data/loop.3.png | Bin 0 -> 508 bytes .../visual/animation/loop/data/loop.4.png | Bin 0 -> 505 bytes .../visual/animation/loop/data/loop.5.png | Bin 0 -> 508 bytes .../visual/animation/loop/data/loop.qml | 1471 ++++++++++++++++++++ .../declarative/visual/animation/loop/loop.qml | 24 + .../parallelAnimation/parallelAnimation.qml | 6 +- .../visual/animation/parentAction/parentAction.qml | 2 +- .../animation/propertyAction/propertyAction.qml | 4 +- .../visual/animation/reanchor/reanchor.qml | 2 +- .../visual/animation/scriptAction/scriptAction.qml | 4 +- .../data/flickable-vertical.qml | 2 +- .../visual/qmlgraphicsflipable/test-flipable.qml | 4 +- .../visual/qmlgraphicspositioners/dynamic.qml | 4 +- .../visual/qmlgraphicstextedit/cursorDelegate.qml | 4 +- .../visual/qmlgraphicstextinput/cursorDelegate.qml | 4 +- 88 files changed, 2050 insertions(+), 626 deletions(-) create mode 100644 tests/auto/declarative/qmlanimations/data/dontAutoStart.qml create mode 100644 tests/auto/declarative/qmlbehaviors/data/explicit.qml delete mode 100644 tests/auto/declarative/qmlbehaviors/data/nonSelecting.qml create mode 100644 tests/auto/declarative/visual/animation/loop/data/loop.0.png create mode 100644 tests/auto/declarative/visual/animation/loop/data/loop.1.png create mode 100644 tests/auto/declarative/visual/animation/loop/data/loop.2.png create mode 100644 tests/auto/declarative/visual/animation/loop/data/loop.3.png create mode 100644 tests/auto/declarative/visual/animation/loop/data/loop.4.png create mode 100644 tests/auto/declarative/visual/animation/loop/data/loop.5.png create mode 100644 tests/auto/declarative/visual/animation/loop/data/loop.qml create mode 100644 tests/auto/declarative/visual/animation/loop/loop.qml diff --git a/demos/declarative/calculator/calculator.qml b/demos/declarative/calculator/calculator.qml index d9b73ed..54af7ad 100644 --- a/demos/declarative/calculator/calculator.qml +++ b/demos/declarative/calculator/calculator.qml @@ -118,7 +118,7 @@ Rectangle { } transitions: Transition { - NumberAnimation { matchProperties: "x,y,width"; easing: "easeOutBounce"; duration: 500 } - NumberAnimation { matchProperties: "opacity"; easing: "easeInOutQuad"; duration: 500 } + NumberAnimation { properties: "x,y,width"; easing: "easeOutBounce"; duration: 500 } + NumberAnimation { properties: "opacity"; easing: "easeInOutQuad"; duration: 500 } } } diff --git a/demos/declarative/flickr/common/ImageDetails.qml b/demos/declarative/flickr/common/ImageDetails.qml index 95c32e8..19cad06 100644 --- a/demos/declarative/flickr/common/ImageDetails.qml +++ b/demos/declarative/flickr/common/ImageDetails.qml @@ -149,7 +149,7 @@ Flipable { property: "smooth" value: false } - NumberAnimation { easing: "easeInOutQuad"; matchProperties: "angle"; duration: 500 } + NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 500 } PropertyAction { target: bigImage property: "smooth" diff --git a/demos/declarative/flickr/common/MediaLineEdit.qml b/demos/declarative/flickr/common/MediaLineEdit.qml index abc8034..b24b296 100644 --- a/demos/declarative/flickr/common/MediaLineEdit.qml +++ b/demos/declarative/flickr/common/MediaLineEdit.qml @@ -42,7 +42,7 @@ Item { ] transitions: [ Transition { - NumberAnimation { matchProperties: "x,width"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,width"; duration: 500; easing: "easeInOutQuad" } } ] diff --git a/demos/declarative/flickr/common/ScrollBar.qml b/demos/declarative/flickr/common/ScrollBar.qml index 2c1ec8a..feebcb0 100644 --- a/demos/declarative/flickr/common/ScrollBar.qml +++ b/demos/declarative/flickr/common/ScrollBar.qml @@ -32,7 +32,7 @@ Item { to: "*" NumberAnimation { target: container - matchProperties: "opacity" + properties: "opacity" duration: 400 } } diff --git a/demos/declarative/flickr/common/Star.qml b/demos/declarative/flickr/common/Star.qml index c5abcca..173021b 100644 --- a/demos/declarative/flickr/common/Star.qml +++ b/demos/declarative/flickr/common/Star.qml @@ -37,7 +37,7 @@ Item { transitions: [ Transition { NumberAnimation { - matchProperties: "opacity,scale,x,y" + properties: "opacity,scale,x,y" easing: "easeOutBounce" } } diff --git a/demos/declarative/flickr/flickr-desktop.qml b/demos/declarative/flickr/flickr-desktop.qml index 4e3b6cb..3848f12 100644 --- a/demos/declarative/flickr/flickr-desktop.qml +++ b/demos/declarative/flickr/flickr-desktop.qml @@ -86,15 +86,15 @@ Item { from: "*"; to: "Details" SequentialAnimation { ParentAction { } - NumberAnimation { matchProperties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } } }, Transition { from: "Details"; to: "*" SequentialAnimation { ParentAction { } - NumberAnimation { matchProperties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } - PropertyAction { matchTargets: wrapper; matchProperties: "z" } + NumberAnimation { properties: "x,y,scale,opacity,angle"; duration: 500; easing: "easeInOutQuad" } + PropertyAction { targets: wrapper; properties: "z" } } } ] @@ -180,7 +180,7 @@ Item { transitions: [ Transition { from: "*"; to: "*" - NumberAnimation { matchProperties: "y"; duration: 1000; easing: "easeOutBounce(amplitude:0.5)" } + NumberAnimation { properties: "y"; duration: 1000; easing: "easeOutBounce(amplitude:0.5)" } } ] } diff --git a/demos/declarative/flickr/flickr-mobile.qml b/demos/declarative/flickr/flickr-mobile.qml index 583f992..0a89c4f 100644 --- a/demos/declarative/flickr/flickr-mobile.qml +++ b/demos/declarative/flickr/flickr-mobile.qml @@ -38,7 +38,7 @@ Item { } transitions: Transition { - NumberAnimation { matchProperties: "x"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x"; duration: 500; easing: "easeInOutQuad" } } } @@ -76,7 +76,7 @@ Item { } transitions: Transition { - NumberAnimation { matchProperties: "x"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x"; duration: 500; easing: "easeInOutQuad" } } } } diff --git a/demos/declarative/flickr/mobile/GridDelegate.qml b/demos/declarative/flickr/mobile/GridDelegate.qml index 3a42507..6c12896 100644 --- a/demos/declarative/flickr/mobile/GridDelegate.qml +++ b/demos/declarative/flickr/mobile/GridDelegate.qml @@ -55,14 +55,14 @@ Transition { from: "Show"; to: "Details" ParentAction { } - NumberAnimation { matchProperties: "x,y"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,y"; duration: 500; easing: "easeInOutQuad" } }, Transition { from: "Details"; to: "Show" SequentialAnimation { ParentAction { } - NumberAnimation { matchProperties: "x,y"; duration: 500; easing: "easeInOutQuad" } - PropertyAction { matchTargets: wrapper; matchProperties: "z" } + NumberAnimation { properties: "x,y"; duration: 500; easing: "easeInOutQuad" } + PropertyAction { targets: wrapper; properties: "z" } } } ] diff --git a/demos/declarative/flickr/mobile/ImageDetails.qml b/demos/declarative/flickr/mobile/ImageDetails.qml index 9116428..1963bf5 100644 --- a/demos/declarative/flickr/mobile/ImageDetails.qml +++ b/demos/declarative/flickr/mobile/ImageDetails.qml @@ -117,7 +117,7 @@ Flipable { transitions: Transition { SequentialAnimation { PropertyAction { target: bigImage; property: "smooth"; value: false } - NumberAnimation { easing: "easeInOutQuad"; matchProperties: "angle"; duration: 500 } + NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 500 } PropertyAction { target: bigImage; property: "smooth"; value: !flickable.moving } } } diff --git a/demos/declarative/flickr/mobile/TitleBar.qml b/demos/declarative/flickr/mobile/TitleBar.qml index 0341585..07b9762 100644 --- a/demos/declarative/flickr/mobile/TitleBar.qml +++ b/demos/declarative/flickr/mobile/TitleBar.qml @@ -71,6 +71,6 @@ Item { } transitions: Transition { - NumberAnimation { matchProperties: "x"; easing: "easeInOutQuad" } + NumberAnimation { properties: "x"; easing: "easeInOutQuad" } } } diff --git a/demos/declarative/minehunt/minehunt.qml b/demos/declarative/minehunt/minehunt.qml index ff00d83..58e2cc9 100644 --- a/demos/declarative/minehunt/minehunt.qml +++ b/demos/declarative/minehunt/minehunt.qml @@ -93,7 +93,7 @@ Item { } NumberAnimation { easing: "easeInOutQuad" - matchProperties: "angle" + properties: "angle" } ScriptAction{ script: if(modelData.hasMine && modelData.flipped){expl.explode = true;} diff --git a/demos/declarative/twitter/content/HomeTitleBar.qml b/demos/declarative/twitter/content/HomeTitleBar.qml index c48befd..8054f2e 100644 --- a/demos/declarative/twitter/content/HomeTitleBar.qml +++ b/demos/declarative/twitter/content/HomeTitleBar.qml @@ -115,7 +115,7 @@ Item { transitions: [ Transition { from: "*"; to: "*" - NumberAnimation { matchProperties: "x,y,width,height"; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,y,width,height"; easing: "easeInOutQuad" } } ] } diff --git a/demos/declarative/twitter/content/MultiTitleBar.qml b/demos/declarative/twitter/content/MultiTitleBar.qml index ef8a450..ef7de65 100644 --- a/demos/declarative/twitter/content/MultiTitleBar.qml +++ b/demos/declarative/twitter/content/MultiTitleBar.qml @@ -18,7 +18,7 @@ Item { } ] transitions: [ - Transition { NumberAnimation { matchProperties: "x,y"; duration: 500; easing: "easeInOutQuad" } } + Transition { NumberAnimation { properties: "x,y"; duration: 500; easing: "easeInOutQuad" } } ] } diff --git a/demos/declarative/twitter/content/TitleBar.qml b/demos/declarative/twitter/content/TitleBar.qml index 28e7389..42a6115 100644 --- a/demos/declarative/twitter/content/TitleBar.qml +++ b/demos/declarative/twitter/content/TitleBar.qml @@ -72,6 +72,6 @@ Item { } transitions: Transition { - NumberAnimation { matchProperties: "x"; easing: "easeInOutQuad" } + NumberAnimation { properties: "x"; easing: "easeInOutQuad" } } } diff --git a/demos/declarative/twitter/twitter.qml b/demos/declarative/twitter/twitter.qml index bb7da9c..d2abf28 100644 --- a/demos/declarative/twitter/twitter.qml +++ b/demos/declarative/twitter/twitter.qml @@ -89,7 +89,7 @@ Item { } ] transitions: [ - Transition { NumberAnimation { matchProperties: "x,y"; duration: 500; easing: "easeInOutQuad" } } + Transition { NumberAnimation { properties: "x,y"; duration: 500; easing: "easeInOutQuad" } } ] } } diff --git a/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml b/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml index a7e6a97..e58ab0a 100644 --- a/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml +++ b/demos/declarative/webbrowser/content/RetractingWebBrowserHeader.qml @@ -96,8 +96,8 @@ Image { transitions: [ Transition { NumberAnimation { - matchTargets: header - matchProperties: "progressOff" + targets: header + properties: "progressOff" easing: "easeInOutQuad" duration: 300 } diff --git a/demos/declarative/webbrowser/content/fieldtext/FieldText.qml b/demos/declarative/webbrowser/content/fieldtext/FieldText.qml index 6b1d271..b1c1938 100644 --- a/demos/declarative/webbrowser/content/fieldtext/FieldText.qml +++ b/demos/declarative/webbrowser/content/fieldtext/FieldText.qml @@ -149,7 +149,7 @@ Item { to: "*" reversible: true NumberAnimation { - matchProperties: "opacity,leftMargin,rightMargin" + properties: "opacity,leftMargin,rightMargin" duration: 200 } ColorAnimation { diff --git a/demos/declarative/webbrowser/webbrowser.qml b/demos/declarative/webbrowser/webbrowser.qml index 3b3790c..8de13d5 100644 --- a/demos/declarative/webbrowser/webbrowser.qml +++ b/demos/declarative/webbrowser/webbrowser.qml @@ -97,7 +97,7 @@ Item { transitions: [ Transition { NumberAnimation { - matchProperties: "opacity" + properties: "opacity" easing: "easeInOutQuad" duration: 300 } @@ -153,7 +153,7 @@ Item { transitions: [ Transition { NumberAnimation { - matchProperties: "opacity" + properties: "opacity" easing: "easeInOutQuad" duration: 320 } diff --git a/doc/src/declarative/animation.qdoc b/doc/src/declarative/animation.qdoc index bf5907d..4efc806 100644 --- a/doc/src/declarative/animation.qdoc +++ b/doc/src/declarative/animation.qdoc @@ -44,9 +44,9 @@ \title QML Animation Animation in QML is done by animating properties of objects. Properties of type -real, int, color, rect, point, and size can all be animated. +real, int, color, rect, point, size, and vector3d can all be animated. -QML supports three different forms of animation - basic property animation, +QML supports three main forms of animation - basic property animation, transitions, and property behaviors. \tableofcontents @@ -71,7 +71,6 @@ Rectangle { x: 60-img.width/2 y: 0 y: SequentialAnimation { - running: true repeat: true NumberAnimation { to: 200-img.height; easing: "easeOutBounce"; duration: 2000 } PauseAnimation { duration: 1000 } @@ -84,8 +83,8 @@ Rectangle { \image propanim.gif When you assign an animation as a value source, you do not need to specify \c property -or \c target; they are automatically selected for you. You do, however, need to specify \c to, and explicitly -start the animation (usually via the \c running property). +or \c target; they are automatically selected for you. You do, however, need to specify \c to. +An animation specified as a value source will be \c running by default. \qml Rectangle { @@ -94,7 +93,7 @@ Rectangle { Rectangle { color: "red" width: 50; height: 50 - x: NumberAnimation { to: 50; running: true } + x: NumberAnimation { to: 50; } } } \endqml @@ -135,7 +134,7 @@ For example, a transition could describe how an item moves from its initial posi transitions: [ Transition { NumberAnimation { - matchProperties: "x,y" + properties: "x,y" easing: "easeOutBounce" duration: 200 } @@ -143,13 +142,38 @@ transitions: [ ] \endcode -As you can see from the above example, transitions make use of the same basic animation classes introduced -above. However, you generally use a different set of properties when working with transitions. In the example, -no \c target or \c property has been specified. Instead, we have specified \c matchProperties, -which (along with \c matchTargets) acts as a selector to determine which property changes to animate; -in this case, we will animate any x,y properties that have changed on any objects. +As can be seen, transitions make use of the same basic animation classes introduced above. +In the above example we have specified that we want to animate the \c x and \c y properties, but have not +specified the objects to animate or the \c to values. By default these values are supplied by the framework -- +the animation will animate any \c targets whose \c x and \c y have changed, and the \c to values will be those +defined in the end state. You can always supply explicit values to override these implicit values when needed. -QML transitions also have selectors to determine which state changes a transition should apply to: +\code +Transition { + from: "*" + to: "MyState" + reversible: true + SequentialAnimation { + NumberAnimation { + duration: 1000 + easing: "easeOutBounce" + // animate myItem's x and y if they have changed in the state + target: myItem + properties: "x,y" + } + NumberAnimation { + duration: 1000 + // animate myItem2's y to 200, regardless of what happens in the state + target: myItem2 + property: "y" + to: 200 + } + } +} +\endcode + +QML transitions have selectors to determine which state changes a transition should apply to. +The following transition will only be triggered when we enter into the \c "details" state. \code Transition { @@ -175,50 +199,24 @@ Transition { NumberAnimation { duration: 1000 easing: "easeOutBounce" - matchTargets: box1 - matchProperties: "x,y" + targets: box1 + properties: "x,y" } NumberAnimation { duration: 1000 - matchTargets: box2 - matchProperties: "x,y" + targets: box2 + properties: "x,y" } } } } \endcode -To insert an explicit animation into your transition, you can use \c target and \c property as normal. - -\code -Transition { - from: "*" - to: "MyState" - reversible: true - SequentialAnimation { - NumberAnimation { - duration: 1000 - easing: "easeOutBounce" - // animate myItem's x and y if they have changed in the state - matchTargets: myItem - matchProperties: "x,y" - } - NumberAnimation { - duration: 1000 - // animate myItem2's y to 200, regardless of what happens in the state - target: myItem2 - property: "y" - to: 200 - } - } -} -\endcode - \section1 Property Behaviors A \l{Behavior}{property behavior} specifies a default animation to run whenever the property's value changes, regardless -of what caused the change. Unlike Transition, \l Behavior doesn't provide a way to indicate that a Behavior -should only apply under certain circumstances. +of what caused the change. The \c enabled property can be used to force a \l Behavior +to only apply under certain circumstances. In the following snippet, we specify that we want the x position of redRect to be animated whenever it changes. The animation will last 300 milliseconds and use an InOutQuad easing curve. diff --git a/doc/src/declarative/qmlstates.qdoc b/doc/src/declarative/qmlstates.qdoc index abf3c93..18ba35d 100644 --- a/doc/src/declarative/qmlstates.qdoc +++ b/doc/src/declarative/qmlstates.qdoc @@ -67,7 +67,7 @@ For example, adding this code to the above \c {Item {}} element animates the tra \qml transitions: [ Transition { - NumberAnimation { matchProperties: "x,y"; duration: 500 } + NumberAnimation { properties: "x,y"; duration: 500 } } ] \endqml diff --git a/examples/declarative/anchors/anchor-changes.qml b/examples/declarative/anchors/anchor-changes.qml index 2ebe1c0..f6fd35d 100644 --- a/examples/declarative/anchors/anchor-changes.qml +++ b/examples/declarative/anchors/anchor-changes.qml @@ -41,6 +41,6 @@ Item { } transitions : Transition { - NumberAnimation { matchProperties: "y,height" } + NumberAnimation { properties: "y,height" } } } diff --git a/examples/declarative/animations/easing.qml b/examples/declarative/animations/easing.qml index a9ba05f..59e9b17 100644 --- a/examples/declarative/animations/easing.qml +++ b/examples/declarative/animations/easing.qml @@ -80,8 +80,8 @@ Rectangle { transitions: Transition { ParallelAnimation { - NumberAnimation { matchProperties: "x"; easing: type; duration: 1000 } - ColorAnimation { matchProperties: "color"; easing: type; duration: 1000 } + NumberAnimation { properties: "x"; easing: type; duration: 1000 } + ColorAnimation { properties: "color"; easing: type; duration: 1000 } } } } diff --git a/examples/declarative/layouts/Button.qml b/examples/declarative/layouts/Button.qml index 215b536..44d0c7b 100644 --- a/examples/declarative/layouts/Button.qml +++ b/examples/declarative/layouts/Button.qml @@ -17,6 +17,6 @@ Rectangle { border.color: "black"; color: "steelblue"; radius: 5; width: pix.wid transitions: Transition{ - NumberAnimation { matchProperties:"x,left"; easing:"easeInOutQuad"; duration:200 } + NumberAnimation { properties:"x,left"; easing:"easeInOutQuad"; duration:200 } } } diff --git a/examples/declarative/layouts/positioners.qml b/examples/declarative/layouts/positioners.qml index 46762f7..fefd964 100644 --- a/examples/declarative/layouts/positioners.qml +++ b/examples/declarative/layouts/positioners.qml @@ -11,12 +11,12 @@ Rectangle { y: 0 move: Transition { NumberAnimation { - matchProperties: "y"; easing: "easeOutBounce" + properties: "y"; easing: "easeOutBounce" } } add: Transition { NumberAnimation { - matchProperties: "y"; easing: "easeOutQuad" + properties: "y"; easing: "easeOutQuad" } } Rectangle { color: "red"; width: 100; height: 50; border.color: "black"; radius: 15 } @@ -35,12 +35,12 @@ Rectangle { y: 300 move: Transition { NumberAnimation { - matchProperties: "x"; easing: "easeOutBounce" + properties: "x"; easing: "easeOutBounce" } } add: Transition { NumberAnimation { - matchProperties: "x"; easing: "easeOutQuad" + properties: "x"; easing: "easeOutQuad" } } Rectangle { color: "red"; width: 50; height: 100; border.color: "black"; radius: 15 } @@ -101,13 +101,13 @@ Rectangle { move: Transition { NumberAnimation { - matchProperties: "x,y"; easing: "easeOutBounce" + properties: "x,y"; easing: "easeOutBounce" } } add: Transition { NumberAnimation { - matchProperties: "x,y"; easing: "easeOutBounce" + properties: "x,y"; easing: "easeOutBounce" } } @@ -136,13 +136,13 @@ Rectangle { move: Transition { NumberAnimation { - matchProperties: "x,y"; easing: "easeOutBounce" + properties: "x,y"; easing: "easeOutBounce" } } add: Transition { NumberAnimation { - matchProperties: "x,y"; easing: "easeOutBounce" + properties: "x,y"; easing: "easeOutBounce" } } Rectangle { color: "red"; width: 50; height: 50; border.color: "black"; radius: 15 } diff --git a/examples/declarative/listview/dynamic.qml b/examples/declarative/listview/dynamic.qml index 101b708..2607527 100644 --- a/examples/declarative/listview/dynamic.qml +++ b/examples/declarative/listview/dynamic.qml @@ -122,7 +122,7 @@ Rectangle { PropertyChanges { target: verticalScrollBar; opacity: 1 } } ] - transitions: [ Transition { NumberAnimation { matchProperties: "opacity"; duration: 400 } } ] + transitions: [ Transition { NumberAnimation { properties: "opacity"; duration: 400 } } ] } Row { diff --git a/examples/declarative/listview/highlight.qml b/examples/declarative/listview/highlight.qml index 9665499..be1f62d 100644 --- a/examples/declarative/listview/highlight.qml +++ b/examples/declarative/listview/highlight.qml @@ -31,7 +31,7 @@ Rectangle { transitions: [ Transition { NumberAnimation { - matchProperties: "x"; duration: 200 + properties: "x"; duration: 200 } } ] diff --git a/examples/declarative/listview/recipes.qml b/examples/declarative/listview/recipes.qml index c133351..3410f56 100644 --- a/examples/declarative/listview/recipes.qml +++ b/examples/declarative/listview/recipes.qml @@ -124,7 +124,7 @@ Rectangle { ParallelAnimation { ColorAnimation { property: "color"; duration: 500 } NumberAnimation { - duration: 300; matchProperties: "detailsOpacity,x,viewportY,height,width" + duration: 300; properties: "detailsOpacity,x,viewportY,height,width" } } } diff --git a/examples/declarative/parallax/qml/ParallaxView.qml b/examples/declarative/parallax/qml/ParallaxView.qml index ff4a85a..f10d374 100644 --- a/examples/declarative/parallax/qml/ParallaxView.qml +++ b/examples/declarative/parallax/qml/ParallaxView.qml @@ -74,7 +74,7 @@ Item { } transitions: Transition { NumberAnimation { - matchProperties: "scale,y" + properties: "scale,y" } } } diff --git a/examples/declarative/scrollbar/ScrollBar.qml b/examples/declarative/scrollbar/ScrollBar.qml index f68775c..802b537 100644 --- a/examples/declarative/scrollbar/ScrollBar.qml +++ b/examples/declarative/scrollbar/ScrollBar.qml @@ -2,7 +2,7 @@ import Qt 4.6 Item { id: scrollBar - // The matchProperties that define the scrollbar's state. + // The properties that define the scrollbar's state. // position and pageSize are in the range 0.0 - 1.0. They are relative to the // height of the page, i.e. a pageSize of 0.5 means that you can see 50% // of the height of the view. diff --git a/examples/declarative/scrollbar/display.qml b/examples/declarative/scrollbar/display.qml index 0b9f95a..536a8b7 100644 --- a/examples/declarative/scrollbar/display.qml +++ b/examples/declarative/scrollbar/display.qml @@ -27,7 +27,7 @@ Rectangle { from: "*" to: "*" NumberAnimation { - matchProperties: "opacity" + properties: "opacity" duration: 400 } } diff --git a/examples/declarative/searchbox/SearchBox.qml b/examples/declarative/searchbox/SearchBox.qml index 42b5d67..7077a11 100644 --- a/examples/declarative/searchbox/SearchBox.qml +++ b/examples/declarative/searchbox/SearchBox.qml @@ -50,11 +50,11 @@ FocusScope { transitions: [ Transition { from: ""; to: "hasText" - NumberAnimation { exclude: typeSomething; matchProperties: "opacity" } + NumberAnimation { exclude: typeSomething; properties: "opacity" } }, Transition { from: "hasText"; to: "" - NumberAnimation { matchProperties: "opacity" } + NumberAnimation { properties: "opacity" } } ] } diff --git a/examples/declarative/slideswitch/content/Switch.qml b/examples/declarative/slideswitch/content/Switch.qml index 29a62f7..c7f1c24 100644 --- a/examples/declarative/slideswitch/content/Switch.qml +++ b/examples/declarative/slideswitch/content/Switch.qml @@ -66,7 +66,7 @@ Item { //![7] transitions: Transition { - NumberAnimation { matchProperties: "x"; easing: "easeInOutQuad"; duration: 200 } + NumberAnimation { properties: "x"; easing: "easeInOutQuad"; duration: 200 } } //![7] } diff --git a/examples/declarative/snow/ImageBatch.qml b/examples/declarative/snow/ImageBatch.qml index 1d738b2..c2a2674 100644 --- a/examples/declarative/snow/ImageBatch.qml +++ b/examples/declarative/snow/ImageBatch.qml @@ -23,7 +23,7 @@ GridView { transitions: Transition { SequentialAnimation { PauseAnimation { duration: 150 } - PropertyAction { matchProperties: "z" } + PropertyAction { properties: "z" } } } model: XmlListModel { @@ -55,15 +55,15 @@ GridView { to: "selected" SequentialAnimation { PauseAnimation { duration: 150 } - PropertyAction { matchProperties: "z" } - NumberAnimation { matchProperties: "scale"; duration: 150; } + PropertyAction { properties: "z" } + NumberAnimation { properties: "scale"; duration: 150; } } }, Transition { from: "selected" SequentialAnimation { - NumberAnimation { matchProperties: "scale"; duration: 150 } - PropertyAction { matchProperties: "z" } + NumberAnimation { properties: "scale"; duration: 150 } + PropertyAction { properties: "z" } } } ] diff --git a/examples/declarative/states/transitions.qml b/examples/declarative/states/transitions.qml index 925d90e..ba97d9be 100644 --- a/examples/declarative/states/transitions.qml +++ b/examples/declarative/states/transitions.qml @@ -48,23 +48,23 @@ Rectangle { } ] - // transitions define how the matchProperties change. + // transitions define how the properties change. transitions: [ // When transitioning to 'Position1' move x,y over a duration of 1 second, // with easeOutBounce easing function. Transition { from: "*"; to: "Position1" - NumberAnimation { matchProperties: "x,y"; easing: "easeOutBounce"; duration: 1000 } + NumberAnimation { properties: "x,y"; easing: "easeOutBounce"; duration: 1000 } }, // When transitioning to 'Position2' move x,y over a duration of 2 seconds, // with easeInOutQuad easing function. Transition { from: "*"; to: "Position2" - NumberAnimation { matchProperties: "x,y"; easing: "easeInOutQuad"; duration: 2000 } + NumberAnimation { properties: "x,y"; easing: "easeInOutQuad"; duration: 2000 } }, // For any other state changes move x,y linearly over duration of 200ms. Transition { - NumberAnimation { matchProperties: "x,y"; duration: 200 } + NumberAnimation { properties: "x,y"; duration: 200 } } ] } diff --git a/examples/declarative/tutorials/helloworld/tutorial3.qml b/examples/declarative/tutorials/helloworld/tutorial3.qml index 0f27f86..107b066 100644 --- a/examples/declarative/tutorials/helloworld/tutorial3.qml +++ b/examples/declarative/tutorials/helloworld/tutorial3.qml @@ -28,7 +28,7 @@ Rectangle { transitions: Transition { from: ""; to: "down"; reversible: true ParallelAnimation { - NumberAnimation { matchProperties: "y,rotation"; duration: 500; easing: "easeInOutQuad" } + NumberAnimation { properties: "y,rotation"; duration: 500; easing: "easeInOutQuad" } ColorAnimation { duration: 500 } } } diff --git a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml index 2eb2ceb..4c2ba43 100644 --- a/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml +++ b/examples/declarative/tutorials/samegame/samegame4/content/BoomBlock.qml @@ -24,7 +24,7 @@ Item { id:block } } opacity: 0 - opacity: Behavior { NumberAnimation { matchProperties:"opacity"; duration: 200 } } + opacity: Behavior { NumberAnimation { properties:"opacity"; duration: 200 } } anchors.fill: parent } //![2] diff --git a/examples/declarative/velocity/Day.qml b/examples/declarative/velocity/Day.qml index 3a7ffa9..030fa13 100644 --- a/examples/declarative/velocity/Day.qml +++ b/examples/declarative/velocity/Day.qml @@ -71,7 +71,7 @@ Rectangle { } transitions: Transition { - NumberAnimation { matchProperties: "rotation,scale"; duration: 200 } + NumberAnimation { properties: "rotation,scale"; duration: 200 } } } } diff --git a/examples/declarative/webview/autosize.qml b/examples/declarative/webview/autosize.qml index 1614906..74c6844 100644 --- a/examples/declarative/webview/autosize.qml +++ b/examples/declarative/webview/autosize.qml @@ -1,7 +1,7 @@ import Qt 4.6 // The WebView size is determined by the width, height, -// preferredWidth, and preferredHeight matchProperties. +// preferredWidth, and preferredHeight properties. Rectangle { id: rect color: "white" diff --git a/examples/declarative/webview/content/FieldText.qml b/examples/declarative/webview/content/FieldText.qml index 6b1d271..b1c1938 100644 --- a/examples/declarative/webview/content/FieldText.qml +++ b/examples/declarative/webview/content/FieldText.qml @@ -149,7 +149,7 @@ Item { to: "*" reversible: true NumberAnimation { - matchProperties: "opacity,leftMargin,rightMargin" + properties: "opacity,leftMargin,rightMargin" duration: 200 } ColorAnimation { diff --git a/examples/declarative/xmldata/yahoonews.qml b/examples/declarative/xmldata/yahoonews.qml index bd14516..23463c2 100644 --- a/examples/declarative/xmldata/yahoonews.qml +++ b/examples/declarative/xmldata/yahoonews.qml @@ -61,8 +61,8 @@ Rectangle { transitions: Transition { from: "*"; to: "Details"; reversible: true SequentialAnimation { - NumberAnimation { duration: 200; matchProperties: "height"; easing: "easeOutQuad" } - NumberAnimation { duration: 200; matchProperties: "opacity" } + NumberAnimation { duration: 200; properties: "height"; easing: "easeOutQuad" } + NumberAnimation { duration: 200; properties: "opacity" } } } } diff --git a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp b/src/declarative/graphicsitems/qmlgraphicsflipable.cpp index 4116817..6857eae 100644 --- a/src/declarative/graphicsitems/qmlgraphicsflipable.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsflipable.cpp @@ -94,7 +94,7 @@ public: } transitions: Transition { - NumberAnimation { matchProperties: "angle"; duration: 2000 } + NumberAnimation { properties: "angle"; duration: 2000 } } MouseRegion { diff --git a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp index 142cdce..4905a30 100644 --- a/src/declarative/graphicsitems/qmlgraphicspositioners.cpp +++ b/src/declarative/graphicsitems/qmlgraphicspositioners.cpp @@ -361,7 +361,7 @@ Column { Column { move: Transition { NumberAnimation { - matchProperties: "y" + properties: "y" ease: "easeOutBounce" } } @@ -470,7 +470,7 @@ Row { id: positioner move: Transition { NumberAnimation { - matchProperties: "x" + properties: "x" ease: "easeOutBounce" } } @@ -592,7 +592,7 @@ Grid { Grid { move: Transition { NumberAnimation { - matchProperties: "x,y" + properties: "x,y" ease: "easeOutBounce" } } @@ -737,7 +737,7 @@ Flow { id: positioner move: Transition { NumberAnimation { - matchProperties: "x,y" + properties: "x,y" ease: "easeOutBounce" } } diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 6609c73..e36a1cc 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -213,7 +213,6 @@ bool QmlAbstractAnimation::isRunning() const void QmlAbstractAnimationPrivate::commence() { Q_Q(QmlAbstractAnimation); - q->prepare(userProperty.value); q->qtAnimation()->start(); if (q->qtAnimation()->state() != QAbstractAnimation::Running) { @@ -238,7 +237,6 @@ QmlMetaProperty QmlAbstractAnimationPrivate::createProperty(QObject *obj, const void QmlAbstractAnimation::setRunning(bool r) { Q_D(QmlAbstractAnimation); - if (r == false) d->avoidPropertyValueSourceStart = true; @@ -541,10 +539,22 @@ void QmlAbstractAnimation::setTarget(const QmlMetaProperty &p) setRunning(true); } +//we rely on setTarget only being called when used as a value source +//so this function allows us to do the same thing as setTarget without +//that assumption +void QmlAbstractAnimation::setDefaultTarget(const QmlMetaProperty &p) +{ + Q_D(QmlAbstractAnimation); + d->userProperty = p; +} + //prepare is called before an animation begins //(when an animation is used as a simple animation, and not as part of a transition) void QmlAbstractAnimation::prepare(QmlMetaProperty &) { + QmlStateActions actions; + QmlMetaProperties properties; + transition(actions, properties, QmlAbstractAnimation::Forward); } void QmlAbstractAnimation::transition(QmlStateActions &actions, @@ -685,7 +695,7 @@ void QmlColorAnimation::setFrom(const QColor &f) } /*! - \qmlproperty color ColorAnimation::from + \qmlproperty color ColorAnimation::to This property holds the ending color. */ QColor QmlColorAnimation::to() const @@ -819,7 +829,7 @@ QML_DEFINE_TYPE(Qt,4,6,ScriptAction,QmlScriptAction) Set \c thewebview.url to the value set for the destination state: \code - PropertyAction { matchTargets: thewebview; matchProperties: "url" } + PropertyAction { target: thewebview; property: "url" } \endcode The PropertyAction is immediate - @@ -866,14 +876,7 @@ void QmlPropertyAction::setTarget(QObject *o) Q_D(QmlPropertyAction); if (d->target == o) return; - d->target = o; - if (d->target && !d->propertyName.isEmpty()) { - d->userProperty = d->createProperty(d->target, d->propertyName, this); - } else { - d->userProperty.invalidate(); - } - emit targetChanged(d->target, d->propertyName); } @@ -896,29 +899,18 @@ void QmlPropertyAction::setProperty(const QString &n) Q_D(QmlPropertyAction); if (d->propertyName == n) return; - d->propertyName = n; - if (d->target && !d->propertyName.isEmpty()) { - d->userProperty = d->createProperty(d->target, d->propertyName, this); - } else { - d->userProperty.invalidate(); - } - emit targetChanged(d->target, d->propertyName); } /*! - \qmlproperty string PropertyAction::matchProperties + \qmlproperty string PropertyAction::properties This property holds a comma-separated list of property names this action - will match against. These names are used in conjunction with matchTargets - to create a list of properties that the action will set, assuming those - properties have changed. + will affect. These names are used in conjunction with targets (and the + singular forms target and property) to create a list of properties that the + action will set. - This property is typically used for an action appearing as part of a Transition. - - By default, no property names will be matched. - - \sa matchTargets PropertyAnimation::matchProperties + \sa targets PropertyAnimation::properties */ QString QmlPropertyAction::properties() const { @@ -936,16 +928,15 @@ void QmlPropertyAction::setProperties(const QString &p) } /*! - \qmlproperty list PropertyAction::matchTargets - This property holds a list of objects this action will match against. - These objects are used in conjunction with matchProperties to create a list of properties - that the action will set, assuming those properties have changed. + \qmlproperty list PropertyAction::targets + This property holds a list of objects this action will affect. + These objects are used in conjunction with properties (and their singular + forms property and target) to create a list of properties + that the action will set. - This property is typically used for an action appearing as part of a Transition. + If no targets are specificed, all changing targets will be animated. - By default, all changing targets will be matched. - - \sa exclude matchProperties PropertyAnimation::matchTargets + \sa exclude properties PropertyAnimation::targets */ QList *QmlPropertyAction::targets() { @@ -956,7 +947,7 @@ QList *QmlPropertyAction::targets() /*! \qmlproperty list PropertyAction::exclude This property holds the objects not to be affected by this animation. - \sa matchTargets + \sa targets */ QList *QmlPropertyAction::exclude() { @@ -984,29 +975,12 @@ void QmlPropertyAction::setValue(const QVariant &v) } } -void QmlPropertyActionPrivate::doAction() -{ - property.write(value, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); -} - QAbstractAnimation *QmlPropertyAction::qtAnimation() { Q_D(QmlPropertyAction); return d->spa; } -void QmlPropertyAction::prepare(QmlMetaProperty &p) -{ - Q_D(QmlPropertyAction); - - if (d->userProperty.isNull) - d->property = p; - else - d->property = d->userProperty; - - d->spa->setAnimAction(&d->proxy, QAbstractAnimation::KeepWhenStopped); -} - void QmlPropertyAction::transition(QmlStateActions &actions, QmlMetaProperties &modified, TransitionDirection direction) @@ -1029,31 +1003,42 @@ void QmlPropertyAction::transition(QmlStateActions &actions, QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(',')); for (int ii = 0; ii < props.count(); ++ii) props[ii] = props.at(ii).trimmed(); + if (!d->propertyName.isEmpty()) + props << d->propertyName; - bool hasSelectors = !props.isEmpty() || !d->targets.isEmpty() || !d->exclude.isEmpty(); - bool hasTarget = !d->propertyName.isEmpty() || d->target; + QList targets = d->targets; + if (d->target) + targets.append(d->target); - if (hasSelectors && hasTarget) { - qmlInfo(this) << tr("matchTargets/matchProperties/exclude and target/property are mutually exclusive."); - return; + bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty(); + + if (d->userProperty.isValid() && !hasSelectors) { + props << d->userProperty.value.name(); + targets << d->userProperty.value.object(); } QmlSetPropertyAnimationAction *data = new QmlSetPropertyAnimationAction; bool hasExplicit = false; - if (hasTarget && d->value.isValid()) { - QmlAction myAction; - myAction.property = d->createProperty(target(), d->propertyName, this); - if (myAction.property.isValid()) { - myAction.toValue = d->value; - data->actions << myAction; - hasExplicit = true; - for (int ii = 0; ii < actions.count(); ++ii) { - QmlAction &action = actions[ii]; - if (action.property.object() == myAction.property.object() && - myAction.property.name() == action.property.name()) { - modified << action.property; - break; //### any chance there could be multiples? + //an explicit animation has been specified + if (d->value.isValid()) { + for (int i = 0; i < props.count(); ++i) { + for (int j = 0; j < targets.count(); ++j) { + QmlAction myAction; + myAction.property = d->createProperty(targets.at(j), props.at(i), this); + if (myAction.property.isValid()) { + myAction.toValue = d->value; + QmlPropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType()); + data->actions << myAction; + hasExplicit = true; + for (int ii = 0; ii < actions.count(); ++ii) { + QmlAction &action = actions[ii]; + if (action.property.object() == myAction.property.object() && + myAction.property.name() == action.property.name()) { + modified << action.property; + break; //### any chance there could be multiples? + } + } } } } @@ -1069,31 +1054,18 @@ void QmlPropertyAction::transition(QmlStateActions &actions, QString sPropertyName = action.specifiedProperty; bool same = (obj == sObj); - if ((d->targets.isEmpty() || d->targets.contains(obj) || (!same && d->targets.contains(sObj))) && + if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) && (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) && (props.contains(propertyName) || (!same && props.contains(sPropertyName)))) { QmlAction myAction = action; if (d->value.isValid()) myAction.toValue = d->value; + QmlPropertyAnimationPrivate::convertVariant(myAction.toValue, myAction.property.propertyType()); modified << action.property; data->actions << myAction; action.fromValue = myAction.toValue; - } else if (d->userProperty.isValid() && - !hasSelectors && !hasTarget) { - if ((d->userProperty.value.object() == obj || (!same && d->userProperty.value.object() == sObj)) && - (d->userProperty.value.name() == propertyName || (!same && d->userProperty.value.name() == sPropertyName))) { - //### same as above. merge - QmlAction myAction = action; - - if (d->value.isValid()) - myAction.toValue = d->value; - - modified << action.property; - data->actions << myAction; - action.fromValue = myAction.toValue; - } } } @@ -1161,24 +1133,7 @@ void QmlParentActionPrivate::init() /*! \qmlproperty Item ParentAction::target - This property holds an explicit target item to reparent. - */ -QmlGraphicsItem *QmlParentAction::object() const -{ - Q_D(const QmlParentAction); - return d->pcTarget; -} - -void QmlParentAction::setObject(QmlGraphicsItem *target) -{ - Q_D(QmlParentAction); - d->pcTarget = target; -} - -/*! - \qmlproperty Item ParentAction::matchTarget - This property holds the item this action will match against -- the item - that the action will reparent, assuming its parent has changed. + This property holds a target item to reparent. In the following example, \c myItem will be reparented by the ParentAction, while \c myOtherItem will not. @@ -1196,24 +1151,23 @@ void QmlParentAction::setObject(QmlGraphicsItem *target) Transition { SequentialAnimation { PropertyAnimation { ... } - ParentAction { matchTargets: myItem } + ParentAction { target: myItem } PropertyAnimation { ... } } } \endqml - This property is typically used for an action appearing as part of a Transition. */ -QmlGraphicsItem *QmlParentAction::matchTarget() const +QmlGraphicsItem *QmlParentAction::object() const { Q_D(const QmlParentAction); return d->pcTarget; } -void QmlParentAction::setMatchTarget(QmlGraphicsItem *target) +void QmlParentAction::setObject(QmlGraphicsItem *target) { Q_D(QmlParentAction); - d->pcMatchTarget = target; + d->pcTarget = target; } /*! @@ -1277,17 +1231,27 @@ void QmlParentAction::transition(QmlStateActions &actions, QmlParentActionData *data = new QmlParentActionData; - if (d->pcTarget && d->pcMatchTarget) { - qmlInfo(this) << tr("matchTarget and target are mutually exclusive."); - return; + //### need to correctly handle modified/done + + bool hasExplicit = false; + if (d->pcTarget && d->pcParent) { + data->reverse = false; + QmlAction myAction; + QmlParentChange *pc = new QmlParentChange; + pc->setObject(d->pcTarget); + pc->setParent(d->pcParent); + myAction.event = pc; + data->pc = pc; + data->actions << myAction; + hasExplicit = true; } + if (!hasExplicit) for (int ii = 0; ii < actions.count(); ++ii) { QmlAction &action = actions[ii]; if (action.event && action.event->typeName() == QLatin1String("ParentChange") - && !d->pcTarget - && (!d->pcMatchTarget || static_cast(action.event)->object() == d->pcMatchTarget)) { + && (!d->pcTarget || static_cast(action.event)->object() == d->pcTarget)) { QmlAction myAction = action; data->reverse = action.reverseEvent; //### this logic differs from PropertyAnimation @@ -1308,17 +1272,6 @@ void QmlParentAction::transition(QmlStateActions &actions, } } - if (d->pcTarget && d->pcParent) { - data->reverse = false; - QmlAction myAction; - QmlParentChange *pc = new QmlParentChange; - pc->setObject(d->pcTarget); - pc->setParent(d->pcParent); - myAction.event = pc; - data->pc = pc; - data->actions << myAction; - } - if (data->actions.count()) { d->cpa->setAnimAction(data, QAbstractAnimation::DeleteWhenStopped); } else { @@ -1336,7 +1289,7 @@ QML_DEFINE_TYPE(Qt,4,6,ParentAction,QmlParentAction) Animate a set of properties over 200ms, from their values in the start state to their values in the end state of the transition: \code - NumberAnimation { matchProperties: "x,y,scale"; duration: 200 } + NumberAnimation { properties: "x,y,scale"; duration: 200 } \endcode */ @@ -1376,7 +1329,7 @@ void QmlNumberAnimation::setFrom(qreal f) /*! \qmlproperty real NumberAnimation::to This property holds the ending value. - If not set, then the value defined in the end state of the transition. + If not set, then the value defined in the end state of the transition or Behavior. */ qreal QmlNumberAnimation::to() const { @@ -1434,7 +1387,7 @@ void QmlVector3dAnimation::setFrom(QVector3D f) /*! \qmlproperty real Vector3dAnimation::to This property holds the ending value. - If not set, then the value defined in the end state of the transition. + If not set, then the value defined in the end state of the transition or Behavior. */ QVector3D QmlVector3dAnimation::to() const { @@ -1495,18 +1448,6 @@ QmlSequentialAnimation::~QmlSequentialAnimation() { } -void QmlSequentialAnimation::prepare(QmlMetaProperty &p) -{ - Q_D(QmlAnimationGroup); - if (d->userProperty.isNull) - d->property = p; - else - d->property = d->userProperty; - - for (int i = 0; i < d->animations.size(); ++i) - d->animations.at(i)->prepare(d->property); -} - QAbstractAnimation *QmlSequentialAnimation::qtAnimation() { Q_D(QmlAnimationGroup); @@ -1526,13 +1467,10 @@ void QmlSequentialAnimation::transition(QmlStateActions &actions, from = d->animations.count() - 1; } - //needed for Behavior - if (d->userProperty.isValid()) { - for (int i = 0; i < d->animations.count(); ++i) - d->animations.at(i)->setTarget(d->userProperty); - } - + bool valid = d->userProperty.isValid(); for (int ii = from; ii < d->animations.count() && ii >= 0; ii += inc) { + if (valid) + d->animations.at(ii)->setDefaultTarget(d->userProperty); d->animations.at(ii)->transition(actions, modified, direction); } } @@ -1574,18 +1512,6 @@ QmlParallelAnimation::~QmlParallelAnimation() { } -void QmlParallelAnimation::prepare(QmlMetaProperty &p) -{ - Q_D(QmlAnimationGroup); - if (d->userProperty.isNull) - d->property = p; - else - d->property = d->userProperty; - - for (int i = 0; i < d->animations.size(); ++i) - d->animations.at(i)->prepare(d->property); -} - QAbstractAnimation *QmlParallelAnimation::qtAnimation() { Q_D(QmlAnimationGroup); @@ -1597,14 +1523,10 @@ void QmlParallelAnimation::transition(QmlStateActions &actions, TransitionDirection direction) { Q_D(QmlAnimationGroup); - - //needed for Behavior - if (d->userProperty.isValid()) { - for (int i = 0; i < d->animations.count(); ++i) - d->animations.at(i)->setTarget(d->userProperty); - } - + bool valid = d->userProperty.isValid(); for (int ii = 0; ii < d->animations.count(); ++ii) { + if (valid) + d->animations.at(ii)->setDefaultTarget(d->userProperty); d->animations.at(ii)->transition(actions, modified, direction); } } @@ -1668,12 +1590,56 @@ void QmlPropertyAnimationPrivate::convertVariant(QVariant &variant, int type) \inherits Animation \brief The PropertyAnimation element allows you to animate property changes. - Animate theObject's size property over 200ms, from its current size to 20-by-20: - \code + PropertyAnimation provides a way to animate changes to a property's value. It can + be used in many different situations: + \list + \o In a Transition + + Animate any objects that have changed their x or y properties in the target state using + an InOutQuad easing curve: + \qml + Transition { PropertyAnimation { properties: "x,y"; easing: "InOutQuad" } } + \endqml + \o In a Behavior + + Animate all changes to a rectangle's x property. + \qml + Rectangle { + x: Behavior { PropertyAnimation {} } + } + \endqml + \o As a property value source + + Repeatedly animate the rectangle's x property. + \qml + Rectangle { + x: SequentialAnimation { + repeat: true + PropertyAnimation { to: 50 } + PropertyAnimation { to: 0 } + } + } + \endqml + \o In a signal handler + + Fade out \c theObject when clicked: + \qml + MouseRegion { + anchors.fill: theObject + onClicked: PropertyAnimation { target: theObject; property: "opacity"; to: 0 } + } + \endqml + \o Standalone + + Animate \c theObject's size property over 200ms, from its current size to 20-by-20: + \qml PropertyAnimation { target: theObject; property: "size"; to: "20x20"; duration: 200 } - \endcode + \endqml + \endlist - For an introduction to animation in QML, see \l{QML Animation}. + Depending on how the animation is used, the set of properties normally used will be + different. For more information see the individual property documentation, as well + as the \l{QML Animation} introduction. */ QmlPropertyAnimation::QmlPropertyAnimation(QObject *parent) @@ -1744,7 +1710,7 @@ void QmlPropertyAnimation::setFrom(const QVariant &f) /*! \qmlproperty real PropertyAnimation::to This property holds the ending value. - If not set, then the value defined in the end state of the transition. + If not set, then the value defined in the end state of the transition or Behavior. */ QVariant QmlPropertyAnimation::to() const { @@ -1955,16 +1921,6 @@ void QmlPropertyAnimation::setEasing(const QString &e) emit easingChanged(e); } -/*! - \qmlproperty Object PropertyAnimation::target - This property holds an explicit target object to animate. - - target is used in conjunction with property to determine - what property should be animated. - - \sa property matchTargets -*/ - QObject *QmlPropertyAnimation::target() const { Q_D(const QmlPropertyAnimation); @@ -1976,27 +1932,10 @@ void QmlPropertyAnimation::setTarget(QObject *o) Q_D(QmlPropertyAnimation); if (d->target == o) return; - d->target = o; - if (d->target && !d->propertyName.isEmpty()) { - d->userProperty = d->createProperty(d->target, d->propertyName, this); - } else { - d->userProperty.invalidate(); - } - emit targetChanged(d->target, d->propertyName); } -/*! - \qmlproperty string PropertyAnimation::property - This property holds an explicit property name to animate. - - property is used in conjunction with target to determine - what property should be animated. - - \sa target matchProperties -*/ - QString QmlPropertyAnimation::property() const { Q_D(const QmlPropertyAnimation); @@ -2008,46 +1947,10 @@ void QmlPropertyAnimation::setProperty(const QString &n) Q_D(QmlPropertyAnimation); if (d->propertyName == n) return; - d->propertyName = n; - if (d->target && !d->propertyName.isEmpty()) { - d->userProperty = d->createProperty(d->target, d->propertyName, this); - } else { - d->userProperty.invalidate(); - } - emit targetChanged(d->target, d->propertyName); } -/*! - \qmlproperty string PropertyAnimation::matchProperties - This property holds a comma-separated list of property names this animation - will match against. These names are used in conjunction with matchTargets - to create a list of properties that the animation will animate, assuming those - properties have changed. - - In the following example, the change in 'x' will be animated by the transition, while - the change in 'y' will not. - \qml - State { - PropertyChanges { - target: myItem - x: 15; y: 15 - } - } - Transition { - PropertyAnimation { - matchProperties: "x" - } - } - \endqml - - This property is typically used for an animation appearing as part of a Transition. - - By default, no property names will be matched. - - \sa matchTargets PropertyAction::matchTargets -*/ QString QmlPropertyAnimation::properties() const { Q_D(const QmlPropertyAnimation); @@ -2065,37 +1968,86 @@ void QmlPropertyAnimation::setProperties(const QString &prop) } /*! - \qmlproperty list PropertyAnimation::matchTargets - This property holds a list of objects this animation will match against. - These objects are used in conjunction with matchProperties to create a list of properties - that the animation will animate, assuming those properties have changed. + \qmlproperty string PropertyAnimation::property + \qmlproperty string PropertyAnimation::properties + \qmlproperty Object PropertyAnimation::target + \qmlproperty list PropertyAnimation::targets - In the following example, the changes to \c myItem will be animated by the transition, while - the changes to \c myOtherItem will not. + These properties are used as a set to determine which properties should be animated. + The singular and plural forms are functionally identical, e.g. \qml - State { - PropertyChanges { - target: myItem - x: 15; y: 15 - } - PropertyChanges { - target: myOtherItem - x: 30; y: 30 - } - } - Transition { - PropertyAnimation { - matchTargets: myItem - matchProperties: "x,y" - } - } + NumberAnimation { target: theItem; property: "x"; to: 500 } + \endqml + has the same meaning as + \qml + NumberAnimation { targets: theItem; properties: "x"; to: 500 } \endqml + The singular forms are slightly optimized, so if you do have only a single target/property + to animate you should try to use them. + + In many cases these properties do not need to be explicitly specified -- they can be + inferred from the animation framework. + \table 80% + \row + \o Value Source / Behavior + \o When an animation is used as a value source or in a Behavior, the default target and property + name to be animated can both be inferred. + \qml + Rectangle { + id: theRect + width: 100; height: 100 + color: Qt.rgba(0,0,1) + x: NumberAnimation { to: 500; repeat: true } //animate theRect's x property + y: Behavior { NumberAnimation {} } //animate theRect's y property + } + \endqml + \row + \o Transition + \o When used in a transition, a property animation is assumed to match \e all targets + but \e no properties. In practice, that means you need to specify at least the properties + in order for the animation to do anything. + \qml + Rectangle { + id: theRect + width: 100; height: 100 + color: Qt.rgba(0,0,1) + Item { id: uselessItem } + states: State { + name: "state1" + PropertyChanges { target: theRect; x: 200; y: 200; z: 4 } + PropertyChanges { target: uselessItem; x: 10; y: 10; z: 2 } + } + transitions: Transition { + //animate both theRect's and uselessItem's x and y to their final values + NumberAnimation { properties: "x,y" } + + //animate theRect's z to its final value + NumberAnimation { target: theRect; property: "z" } + } + } + \endqml + \row + \o Standalone + \o When an animation is used standalone, both the target and property need to be + explicitly specified. + \qml + Rectangle { + id: theRect + width: 100; height: 100 + color: Qt.rgba(0,0,1) + //need to explicitly specify target and property + NumberAnimation { id: theAnim; target: theRect; property: "x" to: 500 } + MouseRegion { + anchors.fill: parent + onClicked: theAnim.start() + } + } + \endqml + \endtable - This property is typically used for an animation appearing as part of a Transition. + As seen in the above example, properties is specified as a comma-separated string of property names to animate. - By default, all changing targets will be matched. - - \sa exclude matchProperties + \sa exclude */ QList *QmlPropertyAnimation::targets() { @@ -2106,7 +2058,7 @@ QList *QmlPropertyAnimation::targets() /*! \qmlproperty list PropertyAnimation::exclude This property holds the items not to be affected by this animation. - \sa matchTargets + \sa targets */ QList *QmlPropertyAnimation::exclude() { @@ -2114,60 +2066,59 @@ QList *QmlPropertyAnimation::exclude() return &d->exclude; } -void QmlPropertyAnimationPrivate::valueChanged(qreal r) -{ - if (!fromSourced) { - if (!fromIsDefined) { - from = property.read(); - convertVariant(from, interpolatorType ? interpolatorType : property.propertyType()); - //### check for invalid variant if using property type - } - fromSourced = true; - } - - if (r == 1.) { - property.write(to, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); - } else { - if (interpolator) - property.write(interpolator(from.constData(), to.constData(), r), QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); - } -} - QAbstractAnimation *QmlPropertyAnimation::qtAnimation() { Q_D(QmlPropertyAnimation); return d->va; } -void QmlPropertyAnimation::prepare(QmlMetaProperty &p) +struct PropertyUpdater : public QmlTimeLineValue { - Q_D(QmlPropertyAnimation); - if (d->userProperty.isNull) - d->property = p; - else - d->property = d->userProperty; - - if (!d->rangeIsSet) { - d->va->setStartValue(qreal(0)); - d->va->setEndValue(qreal(1)); - d->rangeIsSet = true; - } - - int propType = d->property.propertyType(); - d->convertVariant(d->to, d->interpolatorType ? d->interpolatorType : propType); - if (d->fromIsDefined) - d->convertVariant(d->from, d->interpolatorType ? d->interpolatorType : propType); - - if (!d->interpolatorType) { - //### check for invalid variants - d->interpolator = QVariantAnimationPrivate::getInterpolator(propType); + QmlStateActions actions; + int interpolatorType; //for Number/ColorAnimation + int prevInterpolatorType; //for generic + QVariantAnimation::Interpolator interpolator; + bool reverse; + bool fromSourced; + bool fromDefined; + bool *wasDeleted; + PropertyUpdater() : wasDeleted(0) {} + ~PropertyUpdater() { if (wasDeleted) *wasDeleted = true; } + void setValue(qreal v) + { + bool deleted = false; + wasDeleted = &deleted; + if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1 + v = 1 - v; + QmlTimeLineValue::setValue(v); + for (int ii = 0; ii < actions.count(); ++ii) { + QmlAction &action = actions[ii]; + + if (v == 1.) + action.property.write(action.toValue, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); + else { + if (!fromSourced && !fromDefined) { + action.fromValue = action.property.read(); + if (interpolatorType) + QmlPropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType); + } + if (!interpolatorType) { + int propType = action.property.propertyType(); + if (!prevInterpolatorType || prevInterpolatorType != propType) { + prevInterpolatorType = propType; + interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType); + } + } + if (interpolator) + action.property.write(interpolator(action.fromValue.constData(), action.toValue.constData(), v), QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); + } + if (deleted) + return; + } + wasDeleted = 0; + fromSourced = true; } - - d->fromSourced = false; - d->value.QmlTimeLineValue::setValue(0.); - d->va->setAnimValue(&d->value, QAbstractAnimation::KeepWhenStopped); - d->va->setFromSourcedValue(&d->fromSourced); -} +}; void QmlPropertyAnimation::transition(QmlStateActions &actions, QmlMetaProperties &modified, @@ -2176,90 +2127,55 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, Q_D(QmlPropertyAnimation); Q_UNUSED(direction); - struct PropertyUpdater : public QmlTimeLineValue - { - QmlStateActions actions; - int interpolatorType; //for Number/ColorAnimation - int prevInterpolatorType; //for generic - QVariantAnimation::Interpolator interpolator; - bool reverse; - bool *wasDeleted; - PropertyUpdater() : wasDeleted(0) {} - ~PropertyUpdater() { if (wasDeleted) *wasDeleted = true; } - void setValue(qreal v) - { - bool deleted = false; - wasDeleted = &deleted; - if (reverse) //QVariantAnimation sends us 1->0 when reversed, but we are expecting 0->1 - v = 1 - v; - QmlTimeLineValue::setValue(v); - for (int ii = 0; ii < actions.count(); ++ii) { - QmlAction &action = actions[ii]; - - if (v == 1.) - action.property.write(action.toValue, QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); - else { - if (action.fromValue.isNull()) { - action.fromValue = action.property.read(); - if (interpolatorType) - QmlPropertyAnimationPrivate::convertVariant(action.fromValue, interpolatorType); - } - if (!interpolatorType) { - int propType = action.property.propertyType(); - if (!prevInterpolatorType || prevInterpolatorType != propType) { - prevInterpolatorType = propType; - interpolator = QVariantAnimationPrivate::getInterpolator(prevInterpolatorType); - } - } - if (interpolator) - action.property.write(interpolator(action.fromValue.constData(), action.toValue.constData(), v), QmlMetaProperty::BypassInterceptor | QmlMetaProperty::DontRemoveBinding); - } - if (deleted) - return; - } - wasDeleted = 0; - } - }; - QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(',')); for (int ii = 0; ii < props.count(); ++ii) props[ii] = props.at(ii).trimmed(); + if (!d->propertyName.isEmpty()) + props << d->propertyName; - bool hasSelectors = !props.isEmpty() || !d->targets.isEmpty() || !d->exclude.isEmpty(); - bool hasTarget = !d->propertyName.isEmpty() || d->target; - - if (hasSelectors && hasTarget) { - qmlInfo(this) << tr("matchTargets/matchProperties/exclude and target/property are mutually exclusive."); - return; - } + QList targets = d->targets; + if (d->target) + targets.append(d->target); + bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty(); bool useType = (props.isEmpty() && d->propertyName.isEmpty() && d->defaultToInterpolatorType) ? true : false; + if (d->userProperty.isValid() && !hasSelectors) { + props << d->userProperty.value.name(); + targets << d->userProperty.value.object(); + } + PropertyUpdater *data = new PropertyUpdater; data->interpolatorType = d->interpolatorType; data->interpolator = d->interpolator; data->reverse = direction == Backward ? true : false; + data->fromSourced = false; + data->fromDefined = d->fromIsDefined; bool hasExplicit = false; //an explicit animation has been specified - if (hasTarget && d->toIsDefined) { - QmlAction myAction; - myAction.property = d->createProperty(target(), d->propertyName, this); - if (myAction.property.isValid()) { - if (d->fromIsDefined) { - d->convertVariant(d->from, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); - myAction.fromValue = d->from; - } - d->convertVariant(d->to, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); - myAction.toValue = d->to; - data->actions << myAction; - hasExplicit = true; - for (int ii = 0; ii < actions.count(); ++ii) { - QmlAction &action = actions[ii]; - if (action.property.object() == myAction.property.object() && - myAction.property.name() == action.property.name()) { - modified << action.property; - break; //### any chance there could be multiples? + if (d->toIsDefined) { + for (int i = 0; i < props.count(); ++i) { + for (int j = 0; j < targets.count(); ++j) { + QmlAction myAction; + myAction.property = d->createProperty(targets.at(j), props.at(i), this); + if (myAction.property.isValid()) { + if (d->fromIsDefined) { + myAction.fromValue = d->from; + d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); + } + myAction.toValue = d->to; + d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); + data->actions << myAction; + hasExplicit = true; + for (int ii = 0; ii < actions.count(); ++ii) { + QmlAction &action = actions[ii]; + if (action.property.object() == myAction.property.object() && + myAction.property.name() == action.property.name()) { + modified << action.property; + break; //### any chance there could be multiples? + } + } } } } @@ -2275,7 +2191,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, QString sPropertyName = action.specifiedProperty; bool same = (obj == sObj); - if ((d->targets.isEmpty() || d->targets.contains(obj) || (!same && d->targets.contains(sObj))) && + if ((targets.isEmpty() || targets.contains(obj) || (!same && targets.contains(sObj))) && (!d->exclude.contains(obj)) && (same || (!d->exclude.contains(sObj))) && (props.contains(propertyName) || (!same && props.contains(sPropertyName)) || (useType && action.property.propertyType() == d->interpolatorType))) { @@ -2295,29 +2211,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, data->actions << myAction; action.fromValue = myAction.toValue; - } else if (d->userProperty.isValid() && - !hasSelectors && !hasTarget) { - if ((d->userProperty.value.object() == obj || (!same && d->userProperty.value.object() == sObj)) && - (d->userProperty.value.name() == propertyName || (!same && d->userProperty.value.name() == sPropertyName))) { - //### same as above. merge - QmlAction myAction = action; - - if (d->fromIsDefined) - myAction.fromValue = d->from; - else - myAction.fromValue = QVariant(); - if (d->toIsDefined) - myAction.toValue = d->to; - - d->convertVariant(myAction.fromValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); - d->convertVariant(myAction.toValue, d->interpolatorType ? d->interpolatorType : myAction.property.propertyType()); - - modified << action.property; - - data->actions << myAction; - action.fromValue = myAction.toValue; - } - } + } } if (data->actions.count()) { @@ -2327,6 +2221,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, d->rangeIsSet = true; } d->va->setAnimValue(data, QAbstractAnimation::DeleteWhenStopped); + d->va->setFromSourcedValue(&data->fromSourced); } else { delete data; } diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index 6a69e4d..cd4f575 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -94,7 +94,8 @@ public: QmlAnimationGroup *group() const; void setGroup(QmlAnimationGroup *); - virtual void setTarget(const QmlMetaProperty &); + virtual void setTarget(const QmlMetaProperty &); //###make private? + void setDefaultTarget(const QmlMetaProperty &); void classBegin(); void componentComplete(); @@ -123,7 +124,7 @@ public: virtual void transition(QmlStateActions &actions, QmlMetaProperties &modified, TransitionDirection direction); - virtual void prepare(QmlMetaProperty &); + void prepare(QmlMetaProperty &); //### make private virtual QAbstractAnimation *qtAnimation() = 0; private Q_SLOTS: @@ -186,8 +187,8 @@ class QmlPropertyAction : public QmlAbstractAnimation Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged) - Q_PROPERTY(QString matchProperties READ properties WRITE setProperties NOTIFY propertiesChanged) - Q_PROPERTY(QList* matchTargets READ targets) + Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged) + Q_PROPERTY(QList* targets READ targets) Q_PROPERTY(QList* exclude READ exclude) Q_PROPERTY(QVariant value READ value WRITE setValue NOTIFY valueChanged) @@ -220,7 +221,6 @@ protected: QmlMetaProperties &modified, TransitionDirection direction); virtual QAbstractAnimation *qtAnimation(); - virtual void prepare(QmlMetaProperty &); }; class QmlGraphicsItem; @@ -231,8 +231,7 @@ class QmlParentAction : public QmlAbstractAnimation Q_DECLARE_PRIVATE(QmlParentAction) Q_PROPERTY(QmlGraphicsItem *target READ object WRITE setObject) - Q_PROPERTY(QmlGraphicsItem *matchTarget READ matchTarget WRITE setMatchTarget) - Q_PROPERTY(QmlGraphicsItem *parent READ parent WRITE setParent) + Q_PROPERTY(QmlGraphicsItem *parent READ parent WRITE setParent) //### newParent public: QmlParentAction(QObject *parent=0); @@ -241,9 +240,6 @@ public: QmlGraphicsItem *object() const; void setObject(QmlGraphicsItem *); - QmlGraphicsItem *matchTarget() const; - void setMatchTarget(QmlGraphicsItem *); - QmlGraphicsItem *parent() const; void setParent(QmlGraphicsItem *); @@ -266,8 +262,8 @@ class Q_AUTOTEST_EXPORT QmlPropertyAnimation : public QmlAbstractAnimation Q_PROPERTY(QString easing READ easing WRITE setEasing NOTIFY easingChanged) Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) Q_PROPERTY(QString property READ property WRITE setProperty NOTIFY targetChanged) - Q_PROPERTY(QString matchProperties READ properties WRITE setProperties NOTIFY propertiesChanged) - Q_PROPERTY(QList* matchTargets READ targets) + Q_PROPERTY(QString properties READ properties WRITE setProperties NOTIFY propertiesChanged) + Q_PROPERTY(QList* targets READ targets) Q_PROPERTY(QList* exclude READ exclude) public: @@ -303,7 +299,6 @@ protected: QmlMetaProperties &modified, TransitionDirection direction); virtual QAbstractAnimation *qtAnimation(); - virtual void prepare(QmlMetaProperty &); Q_SIGNALS: void durationChanged(int); @@ -401,7 +396,6 @@ protected: QmlMetaProperties &modified, TransitionDirection direction); virtual QAbstractAnimation *qtAnimation(); - virtual void prepare(QmlMetaProperty &); }; class QmlParallelAnimation : public QmlAnimationGroup @@ -418,7 +412,6 @@ protected: QmlMetaProperties &modified, TransitionDirection direction); virtual QAbstractAnimation *qtAnimation(); - virtual void prepare(QmlMetaProperty &); }; QT_END_NAMESPACE diff --git a/src/declarative/util/qmlanimation_p_p.h b/src/declarative/util/qmlanimation_p_p.h index d680194..2dc59f9 100644 --- a/src/declarative/util/qmlanimation_p_p.h +++ b/src/declarative/util/qmlanimation_p_p.h @@ -151,6 +151,8 @@ public: { if (state() == Running) stop(); + if (policy == DeleteWhenStopped) + delete animValue; animValue = value; policy = p; } @@ -165,16 +167,17 @@ protected: animValue->setValue(value.toReal()); } virtual void updateState(State newState, State oldState) - { + { QVariantAnimation::updateState(newState, oldState); if (newState == Running) { //check for new from every loop if (fromSourced) *fromSourced = false; - } else if (newState == Stopped && policy == DeleteWhenStopped) { + } /*else if (newState == Stopped && policy == DeleteWhenStopped) { delete animValue; animValue = 0; - } + }*/ //### we get a stop each loop if we are in a group + //### top-level animation is the only reliable one for this } private: @@ -265,7 +268,7 @@ class QmlPropertyActionPrivate : public QmlAbstractAnimationPrivate Q_DECLARE_PUBLIC(QmlPropertyAction) public: QmlPropertyActionPrivate() - : QmlAbstractAnimationPrivate(), target(0), proxy(this), spa(0) {} + : QmlAbstractAnimationPrivate(), target(0), spa(0) {} void init(); @@ -277,10 +280,6 @@ public: QmlNullableValue value; - void doAction(); - - QAnimationActionProxy proxy; QActionAnimation *spa; }; @@ -289,12 +288,11 @@ class QmlParentActionPrivate : public QmlAbstractAnimationPrivate Q_DECLARE_PUBLIC(QmlParentAction) public: QmlParentActionPrivate() - : QmlAbstractAnimationPrivate(), pcTarget(0), pcMatchTarget(0), pcParent(0) {} + : QmlAbstractAnimationPrivate(), pcTarget(0), pcParent(0) {} void init(); QmlGraphicsItem *pcTarget; - QmlGraphicsItem *pcMatchTarget; QmlGraphicsItem *pcParent; void doAction(); @@ -346,8 +344,7 @@ class QmlPropertyAnimationPrivate : public QmlAbstractAnimationPrivate public: QmlPropertyAnimationPrivate() : QmlAbstractAnimationPrivate(), target(0), fromSourced(false), fromIsDefined(false), toIsDefined(false), - rangeIsSet(false), defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0), - value(this, &QmlPropertyAnimationPrivate::valueChanged) {} + rangeIsSet(false), defaultToInterpolatorType(0), interpolatorType(0), interpolator(0), va(0) {} void init(); @@ -371,9 +368,6 @@ public: QVariantAnimation::Interpolator interpolator; QmlTimeLineValueAnimator *va; - virtual void valueChanged(qreal); - - QmlTimeLineValueProxy value; static QVariant interpolateVariant(const QVariant &from, const QVariant &to, qreal progress); static void convertVariant(QVariant &variant, int type); diff --git a/src/declarative/util/qmlbehavior.cpp b/src/declarative/util/qmlbehavior.cpp index e8feeaa..5e11dea 100644 --- a/src/declarative/util/qmlbehavior.cpp +++ b/src/declarative/util/qmlbehavior.cpp @@ -125,7 +125,7 @@ void QmlBehavior::setAnimation(QmlAbstractAnimation *animation) d->animation = animation; if (d->animation) - d->animation->setTarget(d->property); + d->animation->setDefaultTarget(d->property); } /*! @@ -183,7 +183,7 @@ void QmlBehavior::setTarget(const QmlMetaProperty &property) d->property = property; d->currentValue = property.read(); if (d->animation) - d->animation->setTarget(property); + d->animation->setDefaultTarget(property); } QT_END_NAMESPACE diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp index cefe2bc..b68a59c 100644 --- a/src/declarative/util/qmlstateoperations.cpp +++ b/src/declarative/util/qmlstateoperations.cpp @@ -403,7 +403,7 @@ QString QmlStateChangeScript::typeName() const so you can animate them as you would normally changes to these properties: \qml //animate our anchor changes - NumberAnimation { matchTargets: content; matchProperties: "x,y,width,height" } + NumberAnimation { targets: content; properties: "x,y,width,height" } \endqml For more information on anchors see \l {anchor-layout}{Anchor Layouts}. diff --git a/tests/auto/declarative/qmlanimations/data/badtype4.qml b/tests/auto/declarative/qmlanimations/data/badtype4.qml index a4cf265..2ffed37 100644 --- a/tests/auto/declarative/qmlanimations/data/badtype4.qml +++ b/tests/auto/declarative/qmlanimations/data/badtype4.qml @@ -21,7 +21,7 @@ Rectangle { } transitions: Transition { //comment out each in turn to make sure each only animates the relevant property - ColorAnimation { matchProperties: "x,color"; duration: 1000 } //x is real, color is color - NumberAnimation { matchProperties: "x,color"; duration: 1000 } //x is real, color is color + ColorAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color + NumberAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color } } diff --git a/tests/auto/declarative/qmlanimations/data/dontAutoStart.qml b/tests/auto/declarative/qmlanimations/data/dontAutoStart.qml new file mode 100644 index 0000000..d9660b6 --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/dontAutoStart.qml @@ -0,0 +1,18 @@ +import Qt 4.6 + +Rectangle { + id: wrapper + width: 600 + height: 400 + + Rectangle { + id: redRect + width: 100; height: 100 + color: Qt.rgba(1,0,0) + x: Behavior { + NumberAnimation { objectName: "MyAnim"; target: redRect; property: "y"; to: 300; repeat: true} + } + + } + +} diff --git a/tests/auto/declarative/qmlanimations/data/dotproperty.qml b/tests/auto/declarative/qmlanimations/data/dotproperty.qml index 369491f..08bb5d8 100644 --- a/tests/auto/declarative/qmlanimations/data/dotproperty.qml +++ b/tests/auto/declarative/qmlanimations/data/dotproperty.qml @@ -19,6 +19,6 @@ Rectangle { PropertyChanges { target: myRect; border.color: "blue" } } transitions: Transition { - ColorAnimation { matchProperties: "border.color"; duration: 1000 } + ColorAnimation { properties: "border.color"; duration: 1000 } } } diff --git a/tests/auto/declarative/qmlanimations/data/mixedtype1.qml b/tests/auto/declarative/qmlanimations/data/mixedtype1.qml index 87f4f16..b46270c 100644 --- a/tests/auto/declarative/qmlanimations/data/mixedtype1.qml +++ b/tests/auto/declarative/qmlanimations/data/mixedtype1.qml @@ -20,6 +20,6 @@ Rectangle { PropertyChanges { target: myRect; x: 200; border.width: 10 } } transitions: Transition { - PropertyAnimation { matchProperties: "x,border.width"; duration: 1000 } //x is real, border.width is int + PropertyAnimation { properties: "x,border.width"; duration: 1000 } //x is real, border.width is int } } diff --git a/tests/auto/declarative/qmlanimations/data/mixedtype2.qml b/tests/auto/declarative/qmlanimations/data/mixedtype2.qml index d555abd..15537f1 100644 --- a/tests/auto/declarative/qmlanimations/data/mixedtype2.qml +++ b/tests/auto/declarative/qmlanimations/data/mixedtype2.qml @@ -20,6 +20,6 @@ Rectangle { PropertyChanges { target: myRect; x: 200; color: "blue" } } transitions: Transition { - PropertyAnimation { matchProperties: "x,color"; duration: 1000 } //x is real, color is color + PropertyAnimation { properties: "x,color"; duration: 1000 } //x is real, color is color } } diff --git a/tests/auto/declarative/qmlanimations/data/properties2.qml b/tests/auto/declarative/qmlanimations/data/properties2.qml index 86568ca..6c96155 100644 --- a/tests/auto/declarative/qmlanimations/data/properties2.qml +++ b/tests/auto/declarative/qmlanimations/data/properties2.qml @@ -9,6 +9,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: NumberAnimation { matchTargets: theRect; matchProperties: "x"; to: 200; } + x: NumberAnimation { targets: theRect; properties: "x"; to: 200; } } } diff --git a/tests/auto/declarative/qmlanimations/data/properties5.qml b/tests/auto/declarative/qmlanimations/data/properties5.qml index 56e0be8..38396b1 100644 --- a/tests/auto/declarative/qmlanimations/data/properties5.qml +++ b/tests/auto/declarative/qmlanimations/data/properties5.qml @@ -9,6 +9,6 @@ Rectangle { color: "red" width: 50; height: 50 x: 100; y: 100 - x: NumberAnimation { matchTargets: theRect; matchProperties: "y"; to: 200; } + x: NumberAnimation { targets: theRect; properties: "y"; to: 200; } } } diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml index 75603b9..2f7fd4a 100644 --- a/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml +++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition.qml @@ -19,7 +19,7 @@ Rectangle { } } transitions: Transition { - NumberAnimation { matchTargets: theRect; matchProperties: "x" } + NumberAnimation { targets: theRect; properties: "x" } } MouseRegion { diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml index eedba7b..5aaaab8 100644 --- a/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml +++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition3.qml @@ -19,7 +19,7 @@ Rectangle { } } transitions: Transition { - NumberAnimation { matchTargets: theRect; matchProperties: "y" } + NumberAnimation { targets: theRect; properties: "y" } } MouseRegion { diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml index 301f796..b7ebb1b 100644 --- a/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml +++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition4.qml @@ -19,7 +19,7 @@ Rectangle { } } transitions: Transition { - NumberAnimation { target: theRect; matchProperties: "x" } + NumberAnimation { target: theRect; properties: "x" } } MouseRegion { diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml index 565c519..9034fc5 100644 --- a/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml +++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition5.qml @@ -19,7 +19,7 @@ Rectangle { } } transitions: Transition { - NumberAnimation { matchTargets: theRect; property: "x" } + NumberAnimation { targets: theRect; property: "x" } } MouseRegion { diff --git a/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml b/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml index b541dab..3d8be51 100644 --- a/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml +++ b/tests/auto/declarative/qmlanimations/data/propertiesTransition6.qml @@ -19,7 +19,7 @@ Rectangle { } } transitions: Transition { - NumberAnimation { matchTargets: theItem; matchProperties: "x" } + NumberAnimation { targets: theItem; properties: "x" } } MouseRegion { diff --git a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp index 92b0bf2..0f39c9d 100644 --- a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp +++ b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp @@ -312,14 +312,12 @@ void tst_qmlanimations::badProperties() QmlComponent c1(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml")); QByteArray message = "QML ColorAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/badproperty1.qml").toString().toUtf8() + ":18:9) Cannot animate non-existent property \"border.colr\""; QTest::ignoreMessage(QtWarningMsg, message); - QTest::ignoreMessage(QtWarningMsg, message); // why twice? QmlGraphicsRectangle *rect = qobject_cast(c1.create()); QVERIFY(rect); QmlComponent c2(&engine, QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml")); message = "QML ColorAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/badproperty2.qml").toString().toUtf8() + ":18:9) Cannot animate read-only property \"border\""; QTest::ignoreMessage(QtWarningMsg, message); - QTest::ignoreMessage(QtWarningMsg, message); // why twice? rect = qobject_cast(c2.create()); QVERIFY(rect); @@ -427,9 +425,8 @@ void tst_qmlanimations::properties() QmlGraphicsRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); QTest::qWait(waitDuration); - QEXPECT_FAIL("", "QTBUG-8072", Continue); QTIMED_COMPARE(myRect->x(),qreal(100)); - QTIMED_COMPARE(myRect->y(),qreal(100)); + QTIMED_COMPARE(myRect->y(),qreal(200)); } } @@ -472,9 +469,9 @@ void tst_qmlanimations::propertiesTransition() QmlGraphicsRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); - QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition4.qml").toString().toUtf8() + ":22:9) matchTargets/matchProperties/exclude and target/property are mutually exclusive."); rect->setState("moved"); QCOMPARE(myRect->x(),qreal(200)); + QCOMPARE(myRect->y(),qreal(100)); } { @@ -485,9 +482,10 @@ void tst_qmlanimations::propertiesTransition() QmlGraphicsRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); - QTest::ignoreMessage(QtWarningMsg, "QML NumberAnimation (" + QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition5.qml").toString().toUtf8() + ":22:9) matchTargets/matchProperties/exclude and target/property are mutually exclusive."); rect->setState("moved"); - QCOMPARE(myRect->x(),qreal(200)); + QCOMPARE(myRect->x(),qreal(100)); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(200)); } { @@ -496,12 +494,27 @@ void tst_qmlanimations::propertiesTransition() QmlGraphicsRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); - //### should output warning at some point -- theItem doesn't exist QmlGraphicsRectangle *myRect = rect->findChild("TheRect"); QVERIFY(myRect); rect->setState("moved"); - QCOMPARE(myRect->x(),qreal(200)); + QCOMPARE(myRect->x(),qreal(100)); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(200)); } + + /*{ + QmlEngine engine; + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/propertiesTransition6.qml")); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QmlGraphicsRectangle *myRect = rect->findChild("TheRect"); + QVERIFY(myRect); + rect->setState("moved"); + QCOMPARE(myRect->x(),qreal(100)); + QTest::qWait(waitDuration); + QTIMED_COMPARE(myRect->x(),qreal(100)); + }*/ } void tst_qmlanimations::easingStringConversion() @@ -606,6 +619,19 @@ void tst_qmlanimations::propertyValueSourceDefaultStart() QVERIFY(myAnim); QVERIFY(myAnim->isRunning() == false); } + + { + QmlEngine engine; + + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontAutoStart.qml")); + + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QmlAbstractAnimation *myAnim = rect->findChild("MyAnim"); + QVERIFY(myAnim && myAnim->qtAnimation()); + QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); + } } QTEST_MAIN(tst_qmlanimations) diff --git a/tests/auto/declarative/qmlbehaviors/data/explicit.qml b/tests/auto/declarative/qmlbehaviors/data/explicit.qml new file mode 100644 index 0000000..ba36d93 --- /dev/null +++ b/tests/auto/declarative/qmlbehaviors/data/explicit.qml @@ -0,0 +1,26 @@ +import Qt 4.6 +Rectangle { + width: 400 + height: 400 + Rectangle { + id: rect + objectName: "MyRect" + width: 100; height: 100; color: "green" + x: Behavior { + objectName: "MyBehavior"; + NumberAnimation { target: rect; property: "x"; duration: 200; } + } + } + MouseRegion { + id: clicker + anchors.fill: parent + } + states: State { + name: "moved" + when: clicker.pressed + PropertyChanges { + target: rect + x: 200 + } + } +} diff --git a/tests/auto/declarative/qmlbehaviors/data/nonSelecting.qml b/tests/auto/declarative/qmlbehaviors/data/nonSelecting.qml deleted file mode 100644 index ba36d93..0000000 --- a/tests/auto/declarative/qmlbehaviors/data/nonSelecting.qml +++ /dev/null @@ -1,26 +0,0 @@ -import Qt 4.6 -Rectangle { - width: 400 - height: 400 - Rectangle { - id: rect - objectName: "MyRect" - width: 100; height: 100; color: "green" - x: Behavior { - objectName: "MyBehavior"; - NumberAnimation { target: rect; property: "x"; duration: 200; } - } - } - MouseRegion { - id: clicker - anchors.fill: parent - } - states: State { - name: "moved" - when: clicker.pressed - PropertyChanges { - target: rect - x: 200 - } - } -} diff --git a/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml b/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml index e9849eb..59cbd1a 100644 --- a/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml +++ b/tests/auto/declarative/qmlbehaviors/data/nonSelecting2.qml @@ -8,7 +8,7 @@ Rectangle { width: 100; height: 100; color: "green" x: Behavior { objectName: "MyBehavior"; - NumberAnimation { matchTargets: rect; matchProperties: "y"; duration: 200; } + NumberAnimation { targets: rect; properties: "y"; duration: 200; } } } MouseRegion { diff --git a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp index aa8d057..47bd329 100644 --- a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp +++ b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp @@ -63,6 +63,7 @@ private slots: //void transitionOverrides(); void group(); void emptyBehavior(); + void explicitSelection(); void nonSelectingBehavior(); void reassignedAnimation(); void disabled(); @@ -225,19 +226,23 @@ void tst_qmlbehaviors::emptyBehavior() QCOMPARE(x, qreal(200)); //should change immediately } -void tst_qmlbehaviors::nonSelectingBehavior() +void tst_qmlbehaviors::explicitSelection() { { QmlEngine engine; - QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting.qml")); + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/explicit.qml")); QmlGraphicsRectangle *rect = qobject_cast(c.create()); QVERIFY(rect); rect->setState("moved"); + QTest::qWait(100); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); - QCOMPARE(x, qreal(200)); //should change immediately + QVERIFY(x > 0 && x < 200); //i.e. the behavior has been triggered } +} +void tst_qmlbehaviors::nonSelectingBehavior() +{ { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/nonSelecting2.qml")); diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml b/tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml index 022019c..f6376a1 100644 --- a/tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml +++ b/tests/auto/declarative/qmlgraphicspositioners/data/grid-animated.qml @@ -7,12 +7,12 @@ Item { columns: 3 add: Transition { NumberAnimation { - matchProperties: "x,y"; + properties: "x,y"; } } move: Transition { NumberAnimation { - matchProperties: "x,y"; + properties: "x,y"; } } Rectangle { diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml b/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml index eba165c..c113a36 100644 --- a/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml +++ b/tests/auto/declarative/qmlgraphicspositioners/data/horizontal-animated.qml @@ -6,12 +6,12 @@ Item { Row { add: Transition { NumberAnimation { - matchProperties: "x"; + properties: "x"; } } move: Transition { NumberAnimation { - matchProperties: "x"; + properties: "x"; } } Rectangle { diff --git a/tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml b/tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml index 8e3abbd..10f6cbb 100644 --- a/tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml +++ b/tests/auto/declarative/qmlgraphicspositioners/data/vertical-animated.qml @@ -6,12 +6,12 @@ Item { Column { add: Transition { NumberAnimation { - matchProperties: "y"; + properties: "y"; } } move: Transition { NumberAnimation { - matchProperties: "y"; + properties: "y"; } } Rectangle { diff --git a/tests/auto/declarative/visual/Package_Views/packageviews.qml b/tests/auto/declarative/visual/Package_Views/packageviews.qml index c8016b6..dcfe7de 100644 --- a/tests/auto/declarative/visual/Package_Views/packageviews.qml +++ b/tests/auto/declarative/visual/Package_Views/packageviews.qml @@ -64,7 +64,7 @@ Rectangle { from: "*"; to: "*" SequentialAnimation { ParentAction{} - NumberAnimation { matchProperties: "x,y,width"; easing: "easeInOutQuad" } + NumberAnimation { properties: "x,y,width"; easing: "easeInOutQuad" } } } ] diff --git a/tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml b/tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml index 732eb59..5230ca4 100644 --- a/tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml +++ b/tests/auto/declarative/visual/animation/bindinganimation/bindinganimation.qml @@ -28,7 +28,7 @@ Rectangle { transitions: [ Transition { NumberAnimation { - matchProperties: "x" + properties: "x" } } ] diff --git a/tests/auto/declarative/visual/animation/easing/easing.qml b/tests/auto/declarative/visual/animation/easing/easing.qml index 1e8e907..f81400b 100644 --- a/tests/auto/declarative/visual/animation/easing/easing.qml +++ b/tests/auto/declarative/visual/animation/easing/easing.qml @@ -176,7 +176,7 @@ Rectangle { to: "to" reversible: true NumberAnimation { - matchProperties: "x" + properties: "x" easing: type duration: 1000 } diff --git a/tests/auto/declarative/visual/animation/loop/data/loop.0.png b/tests/auto/declarative/visual/animation/loop/data/loop.0.png new file mode 100644 index 0000000..f4301d3 Binary files /dev/null and b/tests/auto/declarative/visual/animation/loop/data/loop.0.png differ diff --git a/tests/auto/declarative/visual/animation/loop/data/loop.1.png b/tests/auto/declarative/visual/animation/loop/data/loop.1.png new file mode 100644 index 0000000..ceb0e20 Binary files /dev/null and b/tests/auto/declarative/visual/animation/loop/data/loop.1.png differ diff --git a/tests/auto/declarative/visual/animation/loop/data/loop.2.png b/tests/auto/declarative/visual/animation/loop/data/loop.2.png new file mode 100644 index 0000000..197c8c0 Binary files /dev/null and b/tests/auto/declarative/visual/animation/loop/data/loop.2.png differ diff --git a/tests/auto/declarative/visual/animation/loop/data/loop.3.png b/tests/auto/declarative/visual/animation/loop/data/loop.3.png new file mode 100644 index 0000000..3a4327e Binary files /dev/null and b/tests/auto/declarative/visual/animation/loop/data/loop.3.png differ diff --git a/tests/auto/declarative/visual/animation/loop/data/loop.4.png b/tests/auto/declarative/visual/animation/loop/data/loop.4.png new file mode 100644 index 0000000..2397719 Binary files /dev/null and b/tests/auto/declarative/visual/animation/loop/data/loop.4.png differ diff --git a/tests/auto/declarative/visual/animation/loop/data/loop.5.png b/tests/auto/declarative/visual/animation/loop/data/loop.5.png new file mode 100644 index 0000000..70d91a2 Binary files /dev/null and b/tests/auto/declarative/visual/animation/loop/data/loop.5.png differ diff --git a/tests/auto/declarative/visual/animation/loop/data/loop.qml b/tests/auto/declarative/visual/animation/loop/data/loop.qml new file mode 100644 index 0000000..8804d44 --- /dev/null +++ b/tests/auto/declarative/visual/animation/loop/data/loop.qml @@ -0,0 +1,1471 @@ +import Qt.VisualTest 4.6 + +VisualTest { + Frame { + msec: 0 + } + Frame { + msec: 16 + hash: "eff7cc4b163dceb6084270cc589393f1" + } + Frame { + msec: 32 + hash: "1012b52727ae98522061945e32a6269a" + } + Frame { + msec: 48 + hash: "06c3f3c1fa014b0eb7341e0a45ca16e4" + } + Frame { + msec: 64 + hash: "71ecb0af25649c056310d3b865d4144d" + } + Frame { + msec: 80 + hash: "e249fe5b113797433f96a2f84d47e42b" + } + Frame { + msec: 96 + hash: "2a7256921c25c79c22263f2b48d4e98c" + } + Frame { + msec: 112 + hash: "8657944b456402622f2991a0c9acc2fb" + } + Frame { + msec: 128 + hash: "c919a94cd7afb1fbad4c88537af00869" + } + Frame { + msec: 144 + hash: "303b5057d94e328f9447a01d54eea93d" + } + Frame { + msec: 160 + hash: "72eb974dc008c9454935b18b47d4d9e6" + } + Frame { + msec: 176 + hash: "545f258cb0ec7f5d951b74cc7d3f4f0d" + } + Frame { + msec: 192 + hash: "3b3d6046fb01adf7c8a7f67bbc46d28e" + } + Frame { + msec: 208 + hash: "12f7556076cf7a4c2f029dab80e666e7" + } + Frame { + msec: 224 + hash: "fab272c7dce2bbee4042764d38c7ceb5" + } + Frame { + msec: 240 + hash: "ff8addee408527bbaed1819bae07c23f" + } + Frame { + msec: 256 + hash: "53eb6f575db2af3635139e5ddbd7b2f9" + } + Frame { + msec: 272 + hash: "a2fa1cf169acb8ff26a2c5ec1f1d5c81" + } + Frame { + msec: 288 + hash: "ab8d5d6d146ed11b92bc93e78f28e50c" + } + Frame { + msec: 304 + hash: "0fbfc6609b082008e44592067b18ab63" + } + Frame { + msec: 320 + hash: "7fbeda19c19c62a0af5f7f98e633993f" + } + Frame { + msec: 336 + hash: "1882b591bc9d4e79d69d0baecb78b700" + } + Frame { + msec: 352 + hash: "dde429007f876206f3ec0c68d239983e" + } + Frame { + msec: 368 + hash: "b656bdba2978a9a1af511cc2bb0cb59a" + } + Frame { + msec: 384 + hash: "1f6573bf67b2893c94f0c2d40213dc73" + } + Frame { + msec: 400 + hash: "f5786fb532300a1b2f820251fc17c775" + } + Frame { + msec: 416 + hash: "a0e9c4bd3b6c4cdadd40bdf3ca5e2986" + } + Frame { + msec: 432 + hash: "073f74ab23a1173025b3c63424ce2697" + } + Frame { + msec: 448 + hash: "1ac1367d21e346c6c652a88b9ea25bfc" + } + Frame { + msec: 464 + hash: "f62720308dc9ae67c3856bc3afb32b75" + } + Frame { + msec: 480 + hash: "066476a57efba802d2497bc3731a3583" + } + Frame { + msec: 496 + hash: "fb965028a760e8d0a4d81fd982a18ff3" + } + Frame { + msec: 512 + hash: "ba008abd1a7a73c750b909d57c043649" + } + Frame { + msec: 528 + hash: "4c974470953f74d1ee7bcd0f4a4c48cf" + } + Frame { + msec: 544 + hash: "ea233f3476da26c90d67b7775b718aa2" + } + Frame { + msec: 560 + hash: "e12c3b810c0aa628d7a3827453bea9f3" + } + Frame { + msec: 576 + hash: "7451954ca0465c430fc4bae84f6d97cb" + } + Frame { + msec: 592 + hash: "503e40f193a8b099daa4013eddc2f664" + } + Frame { + msec: 608 + hash: "1f81acf94f325a51faa7aa61e73f8a25" + } + Frame { + msec: 624 + hash: "0257d7d53eda8afe182a9f97ef451679" + } + Frame { + msec: 640 + hash: "cfc260bdc977ef16311840022cc85378" + } + Frame { + msec: 656 + hash: "27483f0b89d727b32722ea153fad30ad" + } + Frame { + msec: 672 + hash: "355afa11b8e7b24a353d1aa79daf7564" + } + Frame { + msec: 688 + hash: "bbc1d55f346719476f471a2294227bda" + } + Frame { + msec: 704 + hash: "9bbab5ff75219d8bd65022c6d061e57a" + } + Frame { + msec: 720 + hash: "ff0699f02845f3c5cf5aabb19198c346" + } + Frame { + msec: 736 + hash: "26768e09270ade4c5b484154e7042f43" + } + Frame { + msec: 752 + hash: "31c9ae63071de3fb2f7e1836a22515cb" + } + Frame { + msec: 768 + hash: "783ce2acdae8d87883151532c9293336" + } + Frame { + msec: 784 + hash: "86b9fd739f437127e0cc4d7dcd4284bd" + } + Frame { + msec: 800 + hash: "5e1d6e164dd184cc197d514e5ff60a4c" + } + Frame { + msec: 816 + hash: "13063a8d73704165d64dd2a95803ec0f" + } + Frame { + msec: 832 + hash: "c244e0c0d60f4be2e017bba21a17ab3f" + } + Frame { + msec: 848 + hash: "b3bd657873f1b49c888b9b98d8c0e23f" + } + Frame { + msec: 864 + hash: "65a011e4f62ecddd820bdbdeb0084b65" + } + Frame { + msec: 880 + hash: "86018de7b4a93b267fe94c4de9e61bab" + } + Frame { + msec: 896 + hash: "44827055c99ae3ed924c101c9d1be5c5" + } + Frame { + msec: 912 + hash: "1c31fcb20ec1abc7ea815b703ae05363" + } + Frame { + msec: 928 + hash: "9d7825b7b05ca696846a4116ab27f966" + } + Frame { + msec: 944 + hash: "61b6690dd14fc76dbac4d785bbddb8ee" + } + Frame { + msec: 960 + image: "loop.0.png" + } + Frame { + msec: 976 + hash: "2cc40e1119060483ae067f3881af0391" + } + Frame { + msec: 992 + hash: "9747fdff3429f7a2dbc9e3173ad43a67" + } + Frame { + msec: 1008 + hash: "e68058b9565138f2d7f0f96b74c38dec" + } + Frame { + msec: 1024 + hash: "f32aceabb929471dffd73bf0290e75a2" + } + Frame { + msec: 1040 + hash: "9112838cc8f9a0cfb94e0ef6ca7eca71" + } + Frame { + msec: 1056 + hash: "53bd2c46e3a11db0ee151a6a0311b3a8" + } + Frame { + msec: 1072 + hash: "d5105f958a592324e53aae4a83beb049" + } + Frame { + msec: 1088 + hash: "862249432e6fc6114b63284ad9c97cb6" + } + Frame { + msec: 1104 + hash: "3e6a6f505aa146a6789434d265ad4d3b" + } + Frame { + msec: 1120 + hash: "0f5b2b05f72b86bd2b0a6d0ea2b6bf37" + } + Frame { + msec: 1136 + hash: "922520f7ec954d6d1061208cbd63877e" + } + Frame { + msec: 1152 + hash: "d1c02f3ce4bcc96e0c3d2503a0e9aa48" + } + Frame { + msec: 1168 + hash: "ebb41112b687ecb062dedc3b49cb93fc" + } + Frame { + msec: 1184 + hash: "7bc87d71d532aa52abc26ac9c1cbb665" + } + Frame { + msec: 1200 + hash: "1a7a81f851c8817cac3cc0cb7ac07971" + } + Frame { + msec: 1216 + hash: "ca17c870c55f2947bb5f85d28f30ee7c" + } + Frame { + msec: 1232 + hash: "48b123cfd6d2ea1c2bc9f2ba822ec7bf" + } + Frame { + msec: 1248 + hash: "2a6b8aecef26793e200993dc1e25fd95" + } + Frame { + msec: 1264 + hash: "f10a0a11ed54a910fe434311f67343a4" + } + Frame { + msec: 1280 + hash: "47b6e1beabdcd3cd3d21d77c62e5bed8" + } + Frame { + msec: 1296 + hash: "1eea7eb2853a9e7a1a69738667457b7a" + } + Frame { + msec: 1312 + hash: "9e018f9e7a5ba22bbb9be3049373124a" + } + Frame { + msec: 1328 + hash: "d63069a8e7b0eb5611cc34caaecef2fb" + } + Frame { + msec: 1344 + hash: "def9383a090e4454343725f1a7c4fb3d" + } + Frame { + msec: 1360 + hash: "fd3036e559fd31eeadb0032666a95864" + } + Frame { + msec: 1376 + hash: "cf9f82b9e2a03f63f75b6ac113b3d4e5" + } + Frame { + msec: 1392 + hash: "346e7f597cfb4fc51d5393e705deddd5" + } + Frame { + msec: 1408 + hash: "0d6d6cb2ca808f5a57acfa32e10fc335" + } + Frame { + msec: 1424 + hash: "9a660a0fed41211a37d3ac82be40f81a" + } + Frame { + msec: 1440 + hash: "df3fd60ecbd517879e00e8112c49bed4" + } + Frame { + msec: 1456 + hash: "cd86fe5894e5d061f7ffe37913f00ce6" + } + Frame { + msec: 1472 + hash: "a5fdb825c18d43f3ae18f5c28e715174" + } + Frame { + msec: 1488 + hash: "0fdfb5f9463def560da6c19acf96bafb" + } + Frame { + msec: 1504 + hash: "8849a36af064503dbccad69a35b6ab03" + } + Frame { + msec: 1520 + hash: "baeb4f90b0e2efc09225dbb5dd003e9e" + } + Frame { + msec: 1536 + hash: "86922e71c80976ef3aa2cab18f86c010" + } + Frame { + msec: 1552 + hash: "10d166d7da9949370a66251415522186" + } + Frame { + msec: 1568 + hash: "ada1608055b221dc9f1f7650a9764930" + } + Frame { + msec: 1584 + hash: "dd25ffb9a6bf009139b2942f9cc1f8e7" + } + Frame { + msec: 1600 + hash: "dc4a1c44d08328965b53ff079a8fa57b" + } + Frame { + msec: 1616 + hash: "d3d88cf635ba38e5035732cb36014417" + } + Frame { + msec: 1632 + hash: "be5e44f6b9978ba3b9ae878ae5758a96" + } + Frame { + msec: 1648 + hash: "34f193daf199ab45310be2b407499e57" + } + Frame { + msec: 1664 + hash: "d87c854e1c16642dba0d87e25f0e416f" + } + Frame { + msec: 1680 + hash: "08c404f4efd27695071ad52fbfa57c0b" + } + Frame { + msec: 1696 + hash: "84828f8e0cace1a39d9b7f19b6e4cbaa" + } + Frame { + msec: 1712 + hash: "8a0c6e1f597e699c3e2be816ae4e1dd4" + } + Frame { + msec: 1728 + hash: "9aecb0c464fb140725f34ad94ede367a" + } + Frame { + msec: 1744 + hash: "a298b3ab2939819ced7e7f903ec63be4" + } + Frame { + msec: 1760 + hash: "99789b6e168355a3960986c7d1f21f82" + } + Frame { + msec: 1776 + hash: "ebd37ee719ca460480521fd4ec284a3f" + } + Frame { + msec: 1792 + hash: "9c9b3fb5b623d3deaf9920c99279d71b" + } + Frame { + msec: 1808 + hash: "8f0be6d4d6fd7f66a43fd604e17717dd" + } + Frame { + msec: 1824 + hash: "854defd35cf3315e4501583756814ff6" + } + Frame { + msec: 1840 + hash: "fd7157aef6dfb303472cd33b176f91d8" + } + Frame { + msec: 1856 + hash: "e6521a3c74c190c193af2c913e5326e2" + } + Frame { + msec: 1872 + hash: "19862dcb88fcbbb2c4ecdc42821c7fef" + } + Frame { + msec: 1888 + hash: "5e29a9f9c6c4131c5b71f84d24503ad2" + } + Frame { + msec: 1904 + hash: "140e63c071ef77d26034d0bb6a5d5b7a" + } + Frame { + msec: 1920 + image: "loop.1.png" + } + Frame { + msec: 1936 + hash: "7f79dd50a0af8e8871191ee80afcad0f" + } + Frame { + msec: 1952 + hash: "a5eb3334044999f56c759ce8727d627f" + } + Frame { + msec: 1968 + hash: "3fb70a7591b6decfa44f7cad18f73855" + } + Frame { + msec: 1984 + hash: "3fab99be73f7f12b9463dea359fc86d2" + } + Frame { + msec: 2000 + hash: "50ce6b869e42c949b84cf2dd0cca3af9" + } + Frame { + msec: 2016 + hash: "5369125b23e2f954c18f2fd4e0ba6f6a" + } + Frame { + msec: 2032 + hash: "a76f624be0db97ec4450b10f748065df" + } + Frame { + msec: 2048 + hash: "3fb70a7591b6decfa44f7cad18f73855" + } + Frame { + msec: 2064 + hash: "dada267799b6e57acfcc5de3b8822c7c" + } + Frame { + msec: 2080 + hash: "72c0bf8225504e86ff023242b84513a8" + } + Frame { + msec: 2096 + hash: "1e8b095c39bd359637b1b9c975ee514c" + } + Frame { + msec: 2112 + hash: "19862dcb88fcbbb2c4ecdc42821c7fef" + } + Frame { + msec: 2128 + hash: "60c95993a894e1c6e2d476db365b7746" + } + Frame { + msec: 2144 + hash: "854defd35cf3315e4501583756814ff6" + } + Frame { + msec: 2160 + hash: "15e8959bfa4d206b2f0607322b21cba6" + } + Frame { + msec: 2176 + hash: "ebd37ee719ca460480521fd4ec284a3f" + } + Frame { + msec: 2192 + hash: "6d278926822d044fff04c3f182dcb058" + } + Frame { + msec: 2208 + hash: "9aecb0c464fb140725f34ad94ede367a" + } + Frame { + msec: 2224 + hash: "b36f70f138e6deecf5b105bcd89d1a15" + } + Frame { + msec: 2240 + hash: "08c404f4efd27695071ad52fbfa57c0b" + } + Frame { + msec: 2256 + hash: "6469d0bee7ab280639b565ebf174f251" + } + Frame { + msec: 2272 + hash: "be5e44f6b9978ba3b9ae878ae5758a96" + } + Frame { + msec: 2288 + hash: "5214e578bc78b729ddf35c140093c0da" + } + Frame { + msec: 2304 + hash: "dd25ffb9a6bf009139b2942f9cc1f8e7" + } + Frame { + msec: 2320 + hash: "2ddf31aeac4815be56848703a9b5aa14" + } + Frame { + msec: 2336 + hash: "86922e71c80976ef3aa2cab18f86c010" + } + Frame { + msec: 2352 + hash: "d8415ba4fb19b62b838ef2e09ae7607a" + } + Frame { + msec: 2368 + hash: "0fdfb5f9463def560da6c19acf96bafb" + } + Frame { + msec: 2384 + hash: "68fac60713af7cb130e92fa381be411c" + } + Frame { + msec: 2400 + hash: "df3fd60ecbd517879e00e8112c49bed4" + } + Frame { + msec: 2416 + hash: "64e49282d97ba864d2f6be632ae048e4" + } + Frame { + msec: 2432 + hash: "346e7f597cfb4fc51d5393e705deddd5" + } + Frame { + msec: 2448 + hash: "f302a9ce45187ff1001c967a4c753b2b" + } + Frame { + msec: 2464 + hash: "def9383a090e4454343725f1a7c4fb3d" + } + Frame { + msec: 2480 + hash: "fd177a7ae3b5b9205fd38e955be327e0" + } + Frame { + msec: 2496 + hash: "1eea7eb2853a9e7a1a69738667457b7a" + } + Frame { + msec: 2512 + hash: "32b16dd62ccf06e44be38fd5885f297e" + } + Frame { + msec: 2528 + hash: "2a6b8aecef26793e200993dc1e25fd95" + } + Frame { + msec: 2544 + hash: "8637606843905d6ae3f95fcb745f2a6e" + } + Frame { + msec: 2560 + hash: "1a7a81f851c8817cac3cc0cb7ac07971" + } + Frame { + msec: 2576 + hash: "704ca30ddc0a637f3d1cd4926a6f7983" + } + Frame { + msec: 2592 + hash: "d1c02f3ce4bcc96e0c3d2503a0e9aa48" + } + Frame { + msec: 2608 + hash: "7759418b4fe412857ab8e7294f5a3206" + } + Frame { + msec: 2624 + hash: "3e6a6f505aa146a6789434d265ad4d3b" + } + Frame { + msec: 2640 + hash: "3e6089b47573cd53b0a220275202c80b" + } + Frame { + msec: 2656 + hash: "53bd2c46e3a11db0ee151a6a0311b3a8" + } + Frame { + msec: 2672 + hash: "f30202ae354a587c5949a16c1f8b95c3" + } + Frame { + msec: 2688 + hash: "66f78a34fe9d297af1ae8e98f84ead55" + } + Frame { + msec: 2704 + hash: "3e2fc29876812fe57ea008a71db299a4" + } + Frame { + msec: 2720 + hash: "7234b6df2220e418ef8ebe8f1c82bf26" + } + Frame { + msec: 2736 + hash: "82dd491c3b34e702a24ece8e55761a6f" + } + Frame { + msec: 2752 + hash: "d7f1065f5c42088dfc5ce36687fd8010" + } + Frame { + msec: 2768 + hash: "15bfbb0261b66ccbe3b34d0ac807165c" + } + Frame { + msec: 2784 + hash: "69963ce07eb434d787588b21fd020fa3" + } + Frame { + msec: 2800 + hash: "2fb9e078573ebd1a5cf0f615c97f1d20" + } + Frame { + msec: 2816 + hash: "31fa31ed47ea16390be8ea9d41f483e7" + } + Frame { + msec: 2832 + hash: "0f9ed8cd5cfbdab03bcb05cf6dd92620" + } + Frame { + msec: 2848 + hash: "a0e737132ae642c465e991e770ab3e34" + } + Frame { + msec: 2864 + hash: "d57cc5045f01ab4e7eb72575aef22a10" + } + Frame { + msec: 2880 + image: "loop.2.png" + } + Frame { + msec: 2896 + hash: "df41be1fa564353ceb2088af209610d3" + } + Frame { + msec: 2912 + hash: "2d294613ed10dfdbca829b43b6990574" + } + Frame { + msec: 2928 + hash: "0a278a4ec3626442c94ef2da30771171" + } + Frame { + msec: 2944 + hash: "7071526c830fdfde9d520ad1578d27a8" + } + Frame { + msec: 2960 + hash: "ad02e7b90f223d3fc5a433bc4ffbee9e" + } + Frame { + msec: 2976 + hash: "e7ef412697c7df3887980ed1b079ffd5" + } + Frame { + msec: 2992 + hash: "ebda21f95079b37f4862b42523bbc1c0" + } + Frame { + msec: 3008 + hash: "6e8889e9b44ff8ed44e228d97fb5034c" + } + Frame { + msec: 3024 + hash: "f32aceabb929471dffd73bf0290e75a2" + } + Frame { + msec: 3040 + hash: "9112838cc8f9a0cfb94e0ef6ca7eca71" + } + Frame { + msec: 3056 + hash: "53bd2c46e3a11db0ee151a6a0311b3a8" + } + Frame { + msec: 3072 + hash: "d5105f958a592324e53aae4a83beb049" + } + Frame { + msec: 3088 + hash: "862249432e6fc6114b63284ad9c97cb6" + } + Frame { + msec: 3104 + hash: "3e6a6f505aa146a6789434d265ad4d3b" + } + Frame { + msec: 3120 + hash: "0f5b2b05f72b86bd2b0a6d0ea2b6bf37" + } + Frame { + msec: 3136 + hash: "922520f7ec954d6d1061208cbd63877e" + } + Frame { + msec: 3152 + hash: "d1c02f3ce4bcc96e0c3d2503a0e9aa48" + } + Frame { + msec: 3168 + hash: "ebb41112b687ecb062dedc3b49cb93fc" + } + Frame { + msec: 3184 + hash: "7bc87d71d532aa52abc26ac9c1cbb665" + } + Frame { + msec: 3200 + hash: "1a7a81f851c8817cac3cc0cb7ac07971" + } + Frame { + msec: 3216 + hash: "ca17c870c55f2947bb5f85d28f30ee7c" + } + Frame { + msec: 3232 + hash: "48b123cfd6d2ea1c2bc9f2ba822ec7bf" + } + Frame { + msec: 3248 + hash: "2a6b8aecef26793e200993dc1e25fd95" + } + Frame { + msec: 3264 + hash: "f10a0a11ed54a910fe434311f67343a4" + } + Frame { + msec: 3280 + hash: "47b6e1beabdcd3cd3d21d77c62e5bed8" + } + Frame { + msec: 3296 + hash: "1eea7eb2853a9e7a1a69738667457b7a" + } + Frame { + msec: 3312 + hash: "9e018f9e7a5ba22bbb9be3049373124a" + } + Frame { + msec: 3328 + hash: "d63069a8e7b0eb5611cc34caaecef2fb" + } + Frame { + msec: 3344 + hash: "def9383a090e4454343725f1a7c4fb3d" + } + Frame { + msec: 3360 + hash: "fd3036e559fd31eeadb0032666a95864" + } + Frame { + msec: 3376 + hash: "cf9f82b9e2a03f63f75b6ac113b3d4e5" + } + Frame { + msec: 3392 + hash: "346e7f597cfb4fc51d5393e705deddd5" + } + Frame { + msec: 3408 + hash: "0d6d6cb2ca808f5a57acfa32e10fc335" + } + Frame { + msec: 3424 + hash: "9a660a0fed41211a37d3ac82be40f81a" + } + Frame { + msec: 3440 + hash: "df3fd60ecbd517879e00e8112c49bed4" + } + Frame { + msec: 3456 + hash: "cd86fe5894e5d061f7ffe37913f00ce6" + } + Frame { + msec: 3472 + hash: "a5fdb825c18d43f3ae18f5c28e715174" + } + Frame { + msec: 3488 + hash: "0fdfb5f9463def560da6c19acf96bafb" + } + Frame { + msec: 3504 + hash: "8849a36af064503dbccad69a35b6ab03" + } + Frame { + msec: 3520 + hash: "baeb4f90b0e2efc09225dbb5dd003e9e" + } + Frame { + msec: 3536 + hash: "86922e71c80976ef3aa2cab18f86c010" + } + Frame { + msec: 3552 + hash: "10d166d7da9949370a66251415522186" + } + Frame { + msec: 3568 + hash: "ada1608055b221dc9f1f7650a9764930" + } + Frame { + msec: 3584 + hash: "dd25ffb9a6bf009139b2942f9cc1f8e7" + } + Frame { + msec: 3600 + hash: "dc4a1c44d08328965b53ff079a8fa57b" + } + Frame { + msec: 3616 + hash: "d3d88cf635ba38e5035732cb36014417" + } + Frame { + msec: 3632 + hash: "be5e44f6b9978ba3b9ae878ae5758a96" + } + Frame { + msec: 3648 + hash: "34f193daf199ab45310be2b407499e57" + } + Frame { + msec: 3664 + hash: "d87c854e1c16642dba0d87e25f0e416f" + } + Frame { + msec: 3680 + hash: "08c404f4efd27695071ad52fbfa57c0b" + } + Frame { + msec: 3696 + hash: "84828f8e0cace1a39d9b7f19b6e4cbaa" + } + Frame { + msec: 3712 + hash: "8a0c6e1f597e699c3e2be816ae4e1dd4" + } + Frame { + msec: 3728 + hash: "9aecb0c464fb140725f34ad94ede367a" + } + Frame { + msec: 3744 + hash: "a298b3ab2939819ced7e7f903ec63be4" + } + Frame { + msec: 3760 + hash: "99789b6e168355a3960986c7d1f21f82" + } + Frame { + msec: 3776 + hash: "ebd37ee719ca460480521fd4ec284a3f" + } + Frame { + msec: 3792 + hash: "9c9b3fb5b623d3deaf9920c99279d71b" + } + Frame { + msec: 3808 + hash: "8f0be6d4d6fd7f66a43fd604e17717dd" + } + Frame { + msec: 3824 + hash: "854defd35cf3315e4501583756814ff6" + } + Frame { + msec: 3840 + image: "loop.3.png" + } + Frame { + msec: 3856 + hash: "e6521a3c74c190c193af2c913e5326e2" + } + Frame { + msec: 3872 + hash: "19862dcb88fcbbb2c4ecdc42821c7fef" + } + Frame { + msec: 3888 + hash: "5e29a9f9c6c4131c5b71f84d24503ad2" + } + Frame { + msec: 3904 + hash: "140e63c071ef77d26034d0bb6a5d5b7a" + } + Frame { + msec: 3920 + hash: "72c0bf8225504e86ff023242b84513a8" + } + Frame { + msec: 3936 + hash: "7f79dd50a0af8e8871191ee80afcad0f" + } + Frame { + msec: 3952 + hash: "a5eb3334044999f56c759ce8727d627f" + } + Frame { + msec: 3968 + hash: "3fb70a7591b6decfa44f7cad18f73855" + } + Frame { + msec: 3984 + hash: "3fab99be73f7f12b9463dea359fc86d2" + } + Frame { + msec: 4000 + hash: "50ce6b869e42c949b84cf2dd0cca3af9" + } + Frame { + msec: 4016 + hash: "5369125b23e2f954c18f2fd4e0ba6f6a" + } + Frame { + msec: 4032 + hash: "a76f624be0db97ec4450b10f748065df" + } + Frame { + msec: 4048 + hash: "3fb70a7591b6decfa44f7cad18f73855" + } + Frame { + msec: 4064 + hash: "dada267799b6e57acfcc5de3b8822c7c" + } + Frame { + msec: 4080 + hash: "72c0bf8225504e86ff023242b84513a8" + } + Frame { + msec: 4096 + hash: "1e8b095c39bd359637b1b9c975ee514c" + } + Frame { + msec: 4112 + hash: "19862dcb88fcbbb2c4ecdc42821c7fef" + } + Frame { + msec: 4128 + hash: "60c95993a894e1c6e2d476db365b7746" + } + Frame { + msec: 4144 + hash: "854defd35cf3315e4501583756814ff6" + } + Frame { + msec: 4160 + hash: "15e8959bfa4d206b2f0607322b21cba6" + } + Frame { + msec: 4176 + hash: "ebd37ee719ca460480521fd4ec284a3f" + } + Frame { + msec: 4192 + hash: "6d278926822d044fff04c3f182dcb058" + } + Frame { + msec: 4208 + hash: "9aecb0c464fb140725f34ad94ede367a" + } + Frame { + msec: 4224 + hash: "b36f70f138e6deecf5b105bcd89d1a15" + } + Frame { + msec: 4240 + hash: "08c404f4efd27695071ad52fbfa57c0b" + } + Frame { + msec: 4256 + hash: "6469d0bee7ab280639b565ebf174f251" + } + Frame { + msec: 4272 + hash: "be5e44f6b9978ba3b9ae878ae5758a96" + } + Frame { + msec: 4288 + hash: "5214e578bc78b729ddf35c140093c0da" + } + Frame { + msec: 4304 + hash: "dd25ffb9a6bf009139b2942f9cc1f8e7" + } + Frame { + msec: 4320 + hash: "2ddf31aeac4815be56848703a9b5aa14" + } + Frame { + msec: 4336 + hash: "86922e71c80976ef3aa2cab18f86c010" + } + Frame { + msec: 4352 + hash: "d8415ba4fb19b62b838ef2e09ae7607a" + } + Frame { + msec: 4368 + hash: "0fdfb5f9463def560da6c19acf96bafb" + } + Frame { + msec: 4384 + hash: "68fac60713af7cb130e92fa381be411c" + } + Frame { + msec: 4400 + hash: "df3fd60ecbd517879e00e8112c49bed4" + } + Frame { + msec: 4416 + hash: "64e49282d97ba864d2f6be632ae048e4" + } + Frame { + msec: 4432 + hash: "346e7f597cfb4fc51d5393e705deddd5" + } + Frame { + msec: 4448 + hash: "f302a9ce45187ff1001c967a4c753b2b" + } + Frame { + msec: 4464 + hash: "def9383a090e4454343725f1a7c4fb3d" + } + Frame { + msec: 4480 + hash: "fd177a7ae3b5b9205fd38e955be327e0" + } + Frame { + msec: 4496 + hash: "1eea7eb2853a9e7a1a69738667457b7a" + } + Frame { + msec: 4512 + hash: "32b16dd62ccf06e44be38fd5885f297e" + } + Frame { + msec: 4528 + hash: "2a6b8aecef26793e200993dc1e25fd95" + } + Frame { + msec: 4544 + hash: "8637606843905d6ae3f95fcb745f2a6e" + } + Frame { + msec: 4560 + hash: "1a7a81f851c8817cac3cc0cb7ac07971" + } + Frame { + msec: 4576 + hash: "704ca30ddc0a637f3d1cd4926a6f7983" + } + Frame { + msec: 4592 + hash: "d1c02f3ce4bcc96e0c3d2503a0e9aa48" + } + Frame { + msec: 4608 + hash: "7759418b4fe412857ab8e7294f5a3206" + } + Frame { + msec: 4624 + hash: "3e6a6f505aa146a6789434d265ad4d3b" + } + Frame { + msec: 4640 + hash: "3e6089b47573cd53b0a220275202c80b" + } + Frame { + msec: 4656 + hash: "53bd2c46e3a11db0ee151a6a0311b3a8" + } + Frame { + msec: 4672 + hash: "f30202ae354a587c5949a16c1f8b95c3" + } + Frame { + msec: 4688 + hash: "66f78a34fe9d297af1ae8e98f84ead55" + } + Frame { + msec: 4704 + hash: "3e2fc29876812fe57ea008a71db299a4" + } + Frame { + msec: 4720 + hash: "7234b6df2220e418ef8ebe8f1c82bf26" + } + Frame { + msec: 4736 + hash: "82dd491c3b34e702a24ece8e55761a6f" + } + Frame { + msec: 4752 + hash: "d7f1065f5c42088dfc5ce36687fd8010" + } + Frame { + msec: 4768 + hash: "15bfbb0261b66ccbe3b34d0ac807165c" + } + Frame { + msec: 4784 + hash: "69963ce07eb434d787588b21fd020fa3" + } + Frame { + msec: 4800 + image: "loop.4.png" + } + Frame { + msec: 4816 + hash: "31fa31ed47ea16390be8ea9d41f483e7" + } + Frame { + msec: 4832 + hash: "0f9ed8cd5cfbdab03bcb05cf6dd92620" + } + Frame { + msec: 4848 + hash: "a0e737132ae642c465e991e770ab3e34" + } + Frame { + msec: 4864 + hash: "d57cc5045f01ab4e7eb72575aef22a10" + } + Frame { + msec: 4880 + hash: "d57e1a10e48938e1f7fc219220fe1204" + } + Frame { + msec: 4896 + hash: "df41be1fa564353ceb2088af209610d3" + } + Frame { + msec: 4912 + hash: "2d294613ed10dfdbca829b43b6990574" + } + Frame { + msec: 4928 + hash: "0a278a4ec3626442c94ef2da30771171" + } + Frame { + msec: 4944 + hash: "7071526c830fdfde9d520ad1578d27a8" + } + Frame { + msec: 4960 + hash: "ad02e7b90f223d3fc5a433bc4ffbee9e" + } + Frame { + msec: 4976 + hash: "e7ef412697c7df3887980ed1b079ffd5" + } + Frame { + msec: 4992 + hash: "ebda21f95079b37f4862b42523bbc1c0" + } + Frame { + msec: 5008 + hash: "6e8889e9b44ff8ed44e228d97fb5034c" + } + Frame { + msec: 5024 + hash: "f32aceabb929471dffd73bf0290e75a2" + } + Frame { + msec: 5040 + hash: "9112838cc8f9a0cfb94e0ef6ca7eca71" + } + Frame { + msec: 5056 + hash: "53bd2c46e3a11db0ee151a6a0311b3a8" + } + Frame { + msec: 5072 + hash: "d5105f958a592324e53aae4a83beb049" + } + Frame { + msec: 5088 + hash: "862249432e6fc6114b63284ad9c97cb6" + } + Frame { + msec: 5104 + hash: "3e6a6f505aa146a6789434d265ad4d3b" + } + Frame { + msec: 5120 + hash: "0f5b2b05f72b86bd2b0a6d0ea2b6bf37" + } + Frame { + msec: 5136 + hash: "922520f7ec954d6d1061208cbd63877e" + } + Frame { + msec: 5152 + hash: "d1c02f3ce4bcc96e0c3d2503a0e9aa48" + } + Frame { + msec: 5168 + hash: "ebb41112b687ecb062dedc3b49cb93fc" + } + Frame { + msec: 5184 + hash: "7bc87d71d532aa52abc26ac9c1cbb665" + } + Frame { + msec: 5200 + hash: "1a7a81f851c8817cac3cc0cb7ac07971" + } + Frame { + msec: 5216 + hash: "ca17c870c55f2947bb5f85d28f30ee7c" + } + Frame { + msec: 5232 + hash: "48b123cfd6d2ea1c2bc9f2ba822ec7bf" + } + Frame { + msec: 5248 + hash: "2a6b8aecef26793e200993dc1e25fd95" + } + Frame { + msec: 5264 + hash: "f10a0a11ed54a910fe434311f67343a4" + } + Frame { + msec: 5280 + hash: "47b6e1beabdcd3cd3d21d77c62e5bed8" + } + Frame { + msec: 5296 + hash: "1eea7eb2853a9e7a1a69738667457b7a" + } + Frame { + msec: 5312 + hash: "9e018f9e7a5ba22bbb9be3049373124a" + } + Frame { + msec: 5328 + hash: "d63069a8e7b0eb5611cc34caaecef2fb" + } + Frame { + msec: 5344 + hash: "def9383a090e4454343725f1a7c4fb3d" + } + Frame { + msec: 5360 + hash: "fd3036e559fd31eeadb0032666a95864" + } + Frame { + msec: 5376 + hash: "cf9f82b9e2a03f63f75b6ac113b3d4e5" + } + Frame { + msec: 5392 + hash: "346e7f597cfb4fc51d5393e705deddd5" + } + Frame { + msec: 5408 + hash: "0d6d6cb2ca808f5a57acfa32e10fc335" + } + Frame { + msec: 5424 + hash: "9a660a0fed41211a37d3ac82be40f81a" + } + Frame { + msec: 5440 + hash: "df3fd60ecbd517879e00e8112c49bed4" + } + Frame { + msec: 5456 + hash: "cd86fe5894e5d061f7ffe37913f00ce6" + } + Frame { + msec: 5472 + hash: "a5fdb825c18d43f3ae18f5c28e715174" + } + Frame { + msec: 5488 + hash: "0fdfb5f9463def560da6c19acf96bafb" + } + Frame { + msec: 5504 + hash: "8849a36af064503dbccad69a35b6ab03" + } + Frame { + msec: 5520 + hash: "baeb4f90b0e2efc09225dbb5dd003e9e" + } + Frame { + msec: 5536 + hash: "86922e71c80976ef3aa2cab18f86c010" + } + Frame { + msec: 5552 + hash: "10d166d7da9949370a66251415522186" + } + Frame { + msec: 5568 + hash: "ada1608055b221dc9f1f7650a9764930" + } + Frame { + msec: 5584 + hash: "dd25ffb9a6bf009139b2942f9cc1f8e7" + } + Frame { + msec: 5600 + hash: "dc4a1c44d08328965b53ff079a8fa57b" + } + Frame { + msec: 5616 + hash: "d3d88cf635ba38e5035732cb36014417" + } + Frame { + msec: 5632 + hash: "be5e44f6b9978ba3b9ae878ae5758a96" + } + Frame { + msec: 5648 + hash: "34f193daf199ab45310be2b407499e57" + } + Frame { + msec: 5664 + hash: "d87c854e1c16642dba0d87e25f0e416f" + } + Frame { + msec: 5680 + hash: "08c404f4efd27695071ad52fbfa57c0b" + } + Frame { + msec: 5696 + hash: "84828f8e0cace1a39d9b7f19b6e4cbaa" + } + Frame { + msec: 5712 + hash: "8a0c6e1f597e699c3e2be816ae4e1dd4" + } + Frame { + msec: 5728 + hash: "9aecb0c464fb140725f34ad94ede367a" + } + Frame { + msec: 5744 + hash: "a298b3ab2939819ced7e7f903ec63be4" + } + Frame { + msec: 5760 + image: "loop.5.png" + } + Frame { + msec: 5776 + hash: "ebd37ee719ca460480521fd4ec284a3f" + } + Frame { + msec: 5792 + hash: "9c9b3fb5b623d3deaf9920c99279d71b" + } + Frame { + msec: 5808 + hash: "8f0be6d4d6fd7f66a43fd604e17717dd" + } + Frame { + msec: 5824 + hash: "854defd35cf3315e4501583756814ff6" + } + Frame { + msec: 5840 + hash: "fd7157aef6dfb303472cd33b176f91d8" + } + Frame { + msec: 5856 + hash: "e6521a3c74c190c193af2c913e5326e2" + } +} diff --git a/tests/auto/declarative/visual/animation/loop/loop.qml b/tests/auto/declarative/visual/animation/loop/loop.qml new file mode 100644 index 0000000..f6049ae --- /dev/null +++ b/tests/auto/declarative/visual/animation/loop/loop.qml @@ -0,0 +1,24 @@ +import Qt 4.6 + +Rectangle { + id: wrapper + width: 600 + height: 100 + + Rectangle { + id: redRect + width: 100; height: 100 + color: Qt.rgba(1,0,0) + /* This should produce an animation that starts at 0, animates smoothly + to 100, jumps to 200, animates smoothly to 400, animates smoothly + back to 100, jumps to 200, and so on. + */ + x: SequentialAnimation { + repeat: true + NumberAnimation { to: 100; duration: 1000 } + NumberAnimation { from: 200; to: 400; duration: 1000 } + } + + } + +} diff --git a/tests/auto/declarative/visual/animation/parallelAnimation/parallelAnimation.qml b/tests/auto/declarative/visual/animation/parallelAnimation/parallelAnimation.qml index 9e0422f..7021e05 100644 --- a/tests/auto/declarative/visual/animation/parallelAnimation/parallelAnimation.qml +++ b/tests/auto/declarative/visual/animation/parallelAnimation/parallelAnimation.qml @@ -34,10 +34,10 @@ Rectangle { } transitions: Transition { - PropertyAnimation { matchTargets: redRect; matchProperties: "x,color"; duration: 300 } + PropertyAnimation { targets: redRect; properties: "x,color"; duration: 300 } ParallelAnimation { - NumberAnimation { matchTargets: redRect2; matchProperties: "x"; duration: 300 } - ColorAnimation { matchTargets: redRect2; matchProperties: "color"; duration: 300 } + NumberAnimation { targets: redRect2; properties: "x"; duration: 300 } + ColorAnimation { targets: redRect2; properties: "color"; duration: 300 } } } } diff --git a/tests/auto/declarative/visual/animation/parentAction/parentAction.qml b/tests/auto/declarative/visual/animation/parentAction/parentAction.qml index 1e3f402..e4f4406 100644 --- a/tests/auto/declarative/visual/animation/parentAction/parentAction.qml +++ b/tests/auto/declarative/visual/animation/parentAction/parentAction.qml @@ -49,7 +49,7 @@ Rectangle { SequentialAnimation { ColorAnimation { duration: 500} ParentAction {} - NumberAnimation { matchProperties: "rotation, scale"; duration: 1000 } + NumberAnimation { properties: "rotation, scale"; duration: 1000 } } } } diff --git a/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml b/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml index b670166..68671e1 100644 --- a/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml +++ b/tests/auto/declarative/visual/animation/propertyAction/propertyAction.qml @@ -27,8 +27,8 @@ Rectangle { reversible: true SequentialAnimation { ColorAnimation {} - PropertyAction { matchProperties: "x" } - NumberAnimation { matchProperties: "y"; easing: "InOutQuad" } + PropertyAction { properties: "x" } + NumberAnimation { properties: "y"; easing: "InOutQuad" } } } } diff --git a/tests/auto/declarative/visual/animation/reanchor/reanchor.qml b/tests/auto/declarative/visual/animation/reanchor/reanchor.qml index 1cc68a9..359346f 100644 --- a/tests/auto/declarative/visual/animation/reanchor/reanchor.qml +++ b/tests/auto/declarative/visual/animation/reanchor/reanchor.qml @@ -52,7 +52,7 @@ Rectangle { }] transitions: Transition { - NumberAnimation { matchProperties: "x,y,width,height" } + NumberAnimation { properties: "x,y,width,height" } } MouseRegion { diff --git a/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml b/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml index 872701b..f121906 100644 --- a/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml +++ b/tests/auto/declarative/visual/animation/scriptAction/scriptAction.qml @@ -27,9 +27,9 @@ Rectangle { transitions: Transition { SequentialAnimation { - NumberAnimation { matchProperties: "x"; easing: "InOutQuad" } + NumberAnimation { properties: "x"; easing: "InOutQuad" } ScriptAction { stateChangeScriptName: "setColor" } - NumberAnimation { matchProperties: "y"; easing: "InOutQuad" } + NumberAnimation { properties: "y"; easing: "InOutQuad" } } } } diff --git a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.qml b/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.qml index c376e39..db70298 100644 --- a/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.qml +++ b/tests/auto/declarative/visual/qmlgraphicsflickable/data/flickable-vertical.qml @@ -7034,4 +7034,4 @@ VisualTest { } Frame { msec: 23264 - hash: "8443c45791c906a9fe23831844f48a1c \ No newline at end of file + hash: "8443c45791c906a9fe23831844f48a1c diff --git a/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml b/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml index 64adb61..c33a319 100644 --- a/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml +++ b/tests/auto/declarative/visual/qmlgraphicsflipable/test-flipable.qml @@ -36,7 +36,7 @@ Rectangle { } transitions: Transition { - NumberAnimation { easing: "easeInOutQuad"; matchProperties: "angle"; duration: 3000 } + NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 3000 } } } @@ -64,7 +64,7 @@ Rectangle { } transitions: Transition { - NumberAnimation { easing: "easeInOutQuad"; matchProperties: "angle"; duration: 3000 } + NumberAnimation { easing: "easeInOutQuad"; properties: "angle"; duration: 3000 } } } diff --git a/tests/auto/declarative/visual/qmlgraphicspositioners/dynamic.qml b/tests/auto/declarative/visual/qmlgraphicspositioners/dynamic.qml index 4b03749..f45e9a4 100644 --- a/tests/auto/declarative/visual/qmlgraphicspositioners/dynamic.qml +++ b/tests/auto/declarative/visual/qmlgraphicspositioners/dynamic.qml @@ -37,7 +37,7 @@ Item { Row{ y:20 id: row2 - move: Transition{NumberAnimation{matchProperties:"x"}} + move: Transition{NumberAnimation{properties:"x"}} Repeater{ id: repeater model: 0; @@ -48,7 +48,7 @@ Item { Rectangle{id: r2c; width:20; height:20; color: "blue"} } Row{ - move: Transition{NumberAnimation{matchProperties:"x"}} + move: Transition{NumberAnimation{properties:"x"}} y:40 id: row3 Rectangle{id: r3a; width:20; height:20; color: "red"} diff --git a/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml b/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml index 2faefc1..e0c5db4 100644 --- a/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml +++ b/tests/auto/declarative/visual/qmlgraphicstextedit/cursorDelegate.qml @@ -11,8 +11,8 @@ import Qt 4.6 Rectangle { id:bottom; color: "black"; width: 3; height: 1; x: -1; anchors.bottom: parent.bottom;} opacity: 1 opacity: SequentialAnimation { running: cPage.parent.focus == true; repeat: true; - NumberAnimation { matchProperties: "opacity"; to: 1; duration: 500; easing: "easeInQuad"} - NumberAnimation { matchProperties: "opacity"; to: 0; duration: 500; easing: "easeOutQuad"} + NumberAnimation { properties: "opacity"; to: 1; duration: 500; easing: "easeInQuad"} + NumberAnimation { properties: "opacity"; to: 0; duration: 500; easing: "easeOutQuad"} } } width: 1; diff --git a/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml b/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml index d10755c..0038664 100644 --- a/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml +++ b/tests/auto/declarative/visual/qmlgraphicstextinput/cursorDelegate.qml @@ -11,8 +11,8 @@ import Qt 4.6 Rectangle { id:bottom; color: "black"; width: 3; height: 1; x: -1; anchors.bottom: parent.bottom;} opacity: 1 opacity: SequentialAnimation { running: cPage.parent.focus == true; repeat: true; - NumberAnimation { matchProperties: "opacity"; to: 1; duration: 500; easing: "easeInQuad"} - NumberAnimation { matchProperties: "opacity"; to: 0; duration: 500; easing: "easeOutQuad"} + NumberAnimation { properties: "opacity"; to: 1; duration: 500; easing: "easeInQuad"} + NumberAnimation { properties: "opacity"; to: 0; duration: 500; easing: "easeOutQuad"} } } width: 1; -- cgit v0.12 From 32898d39fbbe0939b6bb21da7f3ad725fb8e0ee3 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 16 Feb 2010 15:59:50 +1000 Subject: Minor animation class cleanup. --- src/declarative/util/qmlanimation.cpp | 44 +++++++++++++++------------------ src/declarative/util/qmlanimation_p.h | 1 - src/declarative/util/qmlanimation_p_p.h | 9 ++++--- 3 files changed, 25 insertions(+), 29 deletions(-) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index e36a1cc..cdd5e9a 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -210,10 +210,16 @@ bool QmlAbstractAnimation::isRunning() const return d->running; } +//commence is called to start an animation when it is used as a +//simple animation, and not as part of a transition void QmlAbstractAnimationPrivate::commence() { Q_Q(QmlAbstractAnimation); - q->prepare(userProperty.value); + + QmlStateActions actions; + QmlMetaProperties properties; + q->transition(actions, properties, QmlAbstractAnimation::Forward); + q->qtAnimation()->start(); if (q->qtAnimation()->state() != QAbstractAnimation::Running) { running = false; @@ -313,7 +319,7 @@ void QmlAbstractAnimation::setPaused(bool p) else qtAnimation()->resume(); - emit pausedChanged(d->running); + emit pausedChanged(d->paused); } void QmlAbstractAnimation::classBegin() @@ -532,8 +538,7 @@ void QmlAbstractAnimation::complete() void QmlAbstractAnimation::setTarget(const QmlMetaProperty &p) { Q_D(QmlAbstractAnimation); - if (d->userProperty.isNull) - d->userProperty = p; + d->defaultProperty = p; if (!d->avoidPropertyValueSourceStart) setRunning(true); @@ -545,16 +550,7 @@ void QmlAbstractAnimation::setTarget(const QmlMetaProperty &p) void QmlAbstractAnimation::setDefaultTarget(const QmlMetaProperty &p) { Q_D(QmlAbstractAnimation); - d->userProperty = p; -} - -//prepare is called before an animation begins -//(when an animation is used as a simple animation, and not as part of a transition) -void QmlAbstractAnimation::prepare(QmlMetaProperty &) -{ - QmlStateActions actions; - QmlMetaProperties properties; - transition(actions, properties, QmlAbstractAnimation::Forward); + d->defaultProperty = p; } void QmlAbstractAnimation::transition(QmlStateActions &actions, @@ -1012,9 +1008,9 @@ void QmlPropertyAction::transition(QmlStateActions &actions, bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty(); - if (d->userProperty.isValid() && !hasSelectors) { - props << d->userProperty.value.name(); - targets << d->userProperty.value.object(); + if (d->defaultProperty.isValid() && !hasSelectors) { + props << d->defaultProperty.name(); + targets << d->defaultProperty.object(); } QmlSetPropertyAnimationAction *data = new QmlSetPropertyAnimationAction; @@ -1467,10 +1463,10 @@ void QmlSequentialAnimation::transition(QmlStateActions &actions, from = d->animations.count() - 1; } - bool valid = d->userProperty.isValid(); + bool valid = d->defaultProperty.isValid(); for (int ii = from; ii < d->animations.count() && ii >= 0; ii += inc) { if (valid) - d->animations.at(ii)->setDefaultTarget(d->userProperty); + d->animations.at(ii)->setDefaultTarget(d->defaultProperty); d->animations.at(ii)->transition(actions, modified, direction); } } @@ -1523,10 +1519,10 @@ void QmlParallelAnimation::transition(QmlStateActions &actions, TransitionDirection direction) { Q_D(QmlAnimationGroup); - bool valid = d->userProperty.isValid(); + bool valid = d->defaultProperty.isValid(); for (int ii = 0; ii < d->animations.count(); ++ii) { if (valid) - d->animations.at(ii)->setDefaultTarget(d->userProperty); + d->animations.at(ii)->setDefaultTarget(d->defaultProperty); d->animations.at(ii)->transition(actions, modified, direction); } } @@ -2140,9 +2136,9 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty(); bool useType = (props.isEmpty() && d->propertyName.isEmpty() && d->defaultToInterpolatorType) ? true : false; - if (d->userProperty.isValid() && !hasSelectors) { - props << d->userProperty.value.name(); - targets << d->userProperty.value.object(); + if (d->defaultProperty.isValid() && !hasSelectors) { + props << d->defaultProperty.name(); + targets << d->defaultProperty.object(); } PropertyUpdater *data = new PropertyUpdater; diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index cd4f575..4e8102c 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -124,7 +124,6 @@ public: virtual void transition(QmlStateActions &actions, QmlMetaProperties &modified, TransitionDirection direction); - void prepare(QmlMetaProperty &); //### make private virtual QAbstractAnimation *qtAnimation() = 0; private Q_SLOTS: diff --git a/src/declarative/util/qmlanimation_p_p.h b/src/declarative/util/qmlanimation_p_p.h index 2dc59f9..91f9f88 100644 --- a/src/declarative/util/qmlanimation_p_p.h +++ b/src/declarative/util/qmlanimation_p_p.h @@ -108,6 +108,8 @@ public: { if (state() == Running) stop(); + if (policy == DeleteWhenStopped) + delete animAction; animAction = action; policy = p; } @@ -126,12 +128,12 @@ protected: animAction = 0; } } - } else if (newState == Stopped && policy == DeleteWhenStopped) { + } /*else if (newState == Stopped && policy == DeleteWhenStopped) { if (!running) { delete animAction; animAction = 0; } - } + }*/ } private: @@ -222,9 +224,8 @@ public: void commence(); - QmlNullableValue userProperty; + QmlMetaProperty defaultProperty; - QmlMetaProperty property; QmlAnimationGroup *group; static QmlMetaProperty createProperty(QObject *obj, const QString &str, QObject *infoObj); -- cgit v0.12 From 408cd434e8399cc26f7a7b0a29e0cc6e32786029 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 17 Feb 2010 09:32:08 +1000 Subject: Minor transition cleanup. --- src/declarative/util/qmltransition.cpp | 8 +------- 1 file changed, 1 insertion(+), 7 deletions(-) diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp index 215fc91..f077982 100644 --- a/src/declarative/util/qmltransition.cpp +++ b/src/declarative/util/qmltransition.cpp @@ -86,6 +86,7 @@ public: , reversed(false), reversible(false), endState(0) { animations.parent = this; + group.trans = this; } QString fromState; @@ -95,11 +96,6 @@ public: ParallelAnimationWrapper group; QmlTransitionManager *endState; - void init() - { - group.trans = this; - } - void complete() { endState->complete(); @@ -139,8 +135,6 @@ QML_DEFINE_TYPE(Qt,4,6,Transition,QmlTransition) QmlTransition::QmlTransition(QObject *parent) : QObject(*(new QmlTransitionPrivate), parent) { - Q_D(QmlTransition); - d->init(); } QmlTransition::~QmlTransition() -- cgit v0.12 From e0b9742450222bdd835358604f70f5a2d13207a9 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 17 Feb 2010 10:01:40 +1000 Subject: Animation's setTarget should only be called via QmlValueSource*. We rely on this to know whether to autostart. Disallow easy access to setTarget by making it private. --- src/declarative/util/qmlanimation_p.h | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index 4e8102c..74330da 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -94,7 +94,6 @@ public: QmlAnimationGroup *group() const; void setGroup(QmlAnimationGroup *); - virtual void setTarget(const QmlMetaProperty &); //###make private? void setDefaultTarget(const QmlMetaProperty &); void classBegin(); @@ -128,6 +127,9 @@ public: private Q_SLOTS: void timelineComplete(); + +private: + virtual void setTarget(const QmlMetaProperty &); }; class QmlPauseAnimationPrivate; -- cgit v0.12 From 2ea6cf7976fc9a2d8a67b32ba4854c9eeb583c81 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 17 Feb 2010 10:20:47 +1000 Subject: Make test more reliable. --- tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp index 0f39c9d..b4759d4 100644 --- a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp +++ b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp @@ -219,7 +219,7 @@ void tst_qmlanimations::resume() QVERIFY(animation.from() == 10); animation.start(); - QTest::qWait(50); + QTest::qWait(100); animation.pause(); qreal x = rect.x(); QVERIFY(x != qreal(200)); @@ -229,7 +229,7 @@ void tst_qmlanimations::resume() animation.resume(); QVERIFY(animation.isRunning()); QVERIFY(!animation.isPaused()); - QTest::qWait(50); + QTest::qWait(100); animation.stop(); QVERIFY(rect.x() > x); } @@ -330,7 +330,7 @@ void tst_qmlanimations::badProperties() //for example, int + real; color + real; etc void tst_qmlanimations::mixedTypes() { - //assumes border.width stats a real -- not real robust + //assumes border.width stays a real -- not real robust { QmlEngine engine; QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/mixedtype1.qml")); -- cgit v0.12 From 9fb06ea43e807f2bbb40de89e9af5f2cca02212f Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 17 Feb 2010 12:13:29 +1000 Subject: Transitions and Behaviors should exclusively control their animations. Don't allow manual control (starting, stopping, etc) of animations in a Behavior or Transition. --- src/declarative/util/qmlanimation.cpp | 23 ++++++++++++++++++----- src/declarative/util/qmlanimation_p.h | 1 + src/declarative/util/qmlanimation_p_p.h | 4 ++-- src/declarative/util/qmlbehavior.cpp | 4 +++- src/declarative/util/qmltransition.cpp | 1 + 5 files changed, 25 insertions(+), 8 deletions(-) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index cdd5e9a..dd783ca 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -249,7 +249,7 @@ void QmlAbstractAnimation::setRunning(bool r) if (d->running == r) return; - if (d->group) { + if (d->group || d->disableUserControl) { qWarning("QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes"); return; } @@ -308,7 +308,7 @@ void QmlAbstractAnimation::setPaused(bool p) if (d->paused == p) return; - if (d->group) { + if (d->group || d->disableUserControl) { qWarning("QmlAbstractAnimation: setPaused() cannot be used on non-root animation nodes"); return; } @@ -544,15 +544,28 @@ void QmlAbstractAnimation::setTarget(const QmlMetaProperty &p) setRunning(true); } -//we rely on setTarget only being called when used as a value source -//so this function allows us to do the same thing as setTarget without -//that assumption +/* + we rely on setTarget only being called when used as a value source + so this function allows us to do the same thing as setTarget without + that assumption +*/ void QmlAbstractAnimation::setDefaultTarget(const QmlMetaProperty &p) { Q_D(QmlAbstractAnimation); d->defaultProperty = p; } +/* + don't allow start/stop/pause/resume to be manually invoked, + because something else (like a Behavior) already has control + over the animation. +*/ +void QmlAbstractAnimation::setDisableUserControl() +{ + Q_D(QmlAbstractAnimation); + d->disableUserControl = true; +} + void QmlAbstractAnimation::transition(QmlStateActions &actions, QmlMetaProperties &modified, TransitionDirection direction) diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index 74330da..791a127 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -95,6 +95,7 @@ public: void setGroup(QmlAnimationGroup *); void setDefaultTarget(const QmlMetaProperty &); + void setDisableUserControl(); void classBegin(); void componentComplete(); diff --git a/src/declarative/util/qmlanimation_p_p.h b/src/declarative/util/qmlanimation_p_p.h index 91f9f88..288aaa8 100644 --- a/src/declarative/util/qmlanimation_p_p.h +++ b/src/declarative/util/qmlanimation_p_p.h @@ -210,17 +210,17 @@ public: QmlAbstractAnimationPrivate() : running(false), paused(false), alwaysRunToEnd(false), repeat(false), connectedTimeLine(false), componentComplete(true), startOnCompletion(false), - avoidPropertyValueSourceStart(false), group(0) {} + avoidPropertyValueSourceStart(false), disableUserControl(false), group(0) {} bool running:1; bool paused:1; bool alwaysRunToEnd:1; bool repeat:1; bool connectedTimeLine:1; - bool componentComplete:1; bool startOnCompletion:1; bool avoidPropertyValueSourceStart:1; + bool disableUserControl:1; void commence(); diff --git a/src/declarative/util/qmlbehavior.cpp b/src/declarative/util/qmlbehavior.cpp index 5e11dea..276e2d0 100644 --- a/src/declarative/util/qmlbehavior.cpp +++ b/src/declarative/util/qmlbehavior.cpp @@ -124,8 +124,10 @@ void QmlBehavior::setAnimation(QmlAbstractAnimation *animation) } d->animation = animation; - if (d->animation) + if (d->animation) { d->animation->setDefaultTarget(d->property); + d->animation->setDisableUserControl(); + } } /*! diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp index f077982..d9e4bed 100644 --- a/src/declarative/util/qmltransition.cpp +++ b/src/declarative/util/qmltransition.cpp @@ -117,6 +117,7 @@ void QmlTransitionPrivate::AnimationList::append(QmlAbstractAnimation *a) { QmlConcreteList::append(a); parent->group.addAnimation(a->qtAnimation()); + a->setDisableUserControl(); } void ParallelAnimationWrapper::updateState(QAbstractAnimation::State newState, QAbstractAnimation::State oldState) -- cgit v0.12 From 05cbd2fe4b5d9cbdef3be52b6d14d2d20255641a Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 17 Feb 2010 13:21:46 +1000 Subject: Fix bugs and add tests related to manual start/stop control of animations. This better enforces the restriction on starting an animation that is not top-level, or is part of a Transition or Behavior. --- src/declarative/util/qmlanimation.cpp | 19 +++++++------ src/declarative/util/qmlanimation_p_p.h | 3 +- .../declarative/qmlanimations/data/dontStart.qml | 19 +++++++++++++ .../declarative/qmlanimations/data/dontStart2.qml | 19 +++++++++++++ .../qmlanimations/tst_qmlanimations.cpp | 33 ++++++++++++++++++++++ .../declarative/qmlbehaviors/data/dontStart.qml | 18 ++++++++++++ .../declarative/qmlbehaviors/tst_qmlbehaviors.cpp | 15 ++++++++++ 7 files changed, 116 insertions(+), 10 deletions(-) create mode 100644 tests/auto/declarative/qmlanimations/data/dontStart.qml create mode 100644 tests/auto/declarative/qmlanimations/data/dontStart2.qml create mode 100644 tests/auto/declarative/qmlbehaviors/data/dontStart.qml diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index dd783ca..4b33af0 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -243,8 +243,12 @@ QmlMetaProperty QmlAbstractAnimationPrivate::createProperty(QObject *obj, const void QmlAbstractAnimation::setRunning(bool r) { Q_D(QmlAbstractAnimation); - if (r == false) - d->avoidPropertyValueSourceStart = true; + if (!d->componentComplete) { + d->running = r; + if (r == false) + d->avoidPropertyValueSourceStart = true; + return; + } if (d->running == r) return; @@ -266,10 +270,7 @@ void QmlAbstractAnimation::setRunning(bool r) this, SLOT(timelineComplete())); d->connectedTimeLine = true; } - if (d->componentComplete) - d->commence(); - else - d->startOnCompletion = true; + d->commence(); emit started(); } else { if (d->alwaysRunToEnd) { @@ -331,9 +332,11 @@ void QmlAbstractAnimation::classBegin() void QmlAbstractAnimation::componentComplete() { Q_D(QmlAbstractAnimation); - if (d->startOnCompletion) - d->commence(); d->componentComplete = true; + if (d->running) { + d->running = false; + setRunning(true); + } } /*! diff --git a/src/declarative/util/qmlanimation_p_p.h b/src/declarative/util/qmlanimation_p_p.h index 288aaa8..ee0c291 100644 --- a/src/declarative/util/qmlanimation_p_p.h +++ b/src/declarative/util/qmlanimation_p_p.h @@ -209,7 +209,7 @@ class QmlAbstractAnimationPrivate : public QObjectPrivate public: QmlAbstractAnimationPrivate() : running(false), paused(false), alwaysRunToEnd(false), repeat(false), - connectedTimeLine(false), componentComplete(true), startOnCompletion(false), + connectedTimeLine(false), componentComplete(true), avoidPropertyValueSourceStart(false), disableUserControl(false), group(0) {} bool running:1; @@ -218,7 +218,6 @@ public: bool repeat:1; bool connectedTimeLine:1; bool componentComplete:1; - bool startOnCompletion:1; bool avoidPropertyValueSourceStart:1; bool disableUserControl:1; diff --git a/tests/auto/declarative/qmlanimations/data/dontStart.qml b/tests/auto/declarative/qmlanimations/data/dontStart.qml new file mode 100644 index 0000000..36417db --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/dontStart.qml @@ -0,0 +1,19 @@ +import Qt 4.6 + +Rectangle { + id: wrapper + width: 600 + height: 400 + + Rectangle { + id: redRect + width: 100; height: 100 + color: Qt.rgba(1,0,0) + x: SequentialAnimation { + running: false + NumberAnimation { objectName: "MyAnim"; running: true } + } + + } + +} diff --git a/tests/auto/declarative/qmlanimations/data/dontStart2.qml b/tests/auto/declarative/qmlanimations/data/dontStart2.qml new file mode 100644 index 0000000..1a6540f --- /dev/null +++ b/tests/auto/declarative/qmlanimations/data/dontStart2.qml @@ -0,0 +1,19 @@ +import Qt 4.6 + +Rectangle { + id: wrapper + width: 600 + height: 400 + + Rectangle { + id: redRect + width: 100; height: 100 + color: Qt.rgba(1,0,0) + + transitions: Transition { + SequentialAnimation { + NumberAnimation { id: myAnim; objectName: "MyAnim"; running: true } + } + } + } +} diff --git a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp index b4759d4..54e6e27 100644 --- a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp +++ b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp @@ -71,6 +71,7 @@ private slots: void invalidDuration(); void attached(); void propertyValueSourceDefaultStart(); + void dontStart(); }; #define QTIMED_COMPARE(lhs, rhs) do { \ @@ -634,6 +635,38 @@ void tst_qmlanimations::propertyValueSourceDefaultStart() } } + +void tst_qmlanimations::dontStart() +{ + { + QmlEngine engine; + + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml")); + + QTest::ignoreMessage(QtWarningMsg, "QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes"); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QmlAbstractAnimation *myAnim = rect->findChild("MyAnim"); + QVERIFY(myAnim && myAnim->qtAnimation()); + QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); + } + + { + QmlEngine engine; + + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart2.qml")); + + QTest::ignoreMessage(QtWarningMsg, "QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes"); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + + QmlAbstractAnimation *myAnim = rect->findChild("MyAnim"); + QVERIFY(myAnim && myAnim->qtAnimation()); + QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); + } +} + QTEST_MAIN(tst_qmlanimations) #include "tst_qmlanimations.moc" diff --git a/tests/auto/declarative/qmlbehaviors/data/dontStart.qml b/tests/auto/declarative/qmlbehaviors/data/dontStart.qml new file mode 100644 index 0000000..ba7cc9c --- /dev/null +++ b/tests/auto/declarative/qmlbehaviors/data/dontStart.qml @@ -0,0 +1,18 @@ +import Qt 4.6 + +Rectangle { + id: wrapper + width: 600 + height: 400 + + Rectangle { + id: redRect + width: 100; height: 100 + color: Qt.rgba(1,0,0) + x: Behavior { + NumberAnimation { objectName: "MyAnim"; running: true } + } + + } + +} diff --git a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp index 47bd329..5f199ef 100644 --- a/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp +++ b/tests/auto/declarative/qmlbehaviors/tst_qmlbehaviors.cpp @@ -67,6 +67,7 @@ private slots: void nonSelectingBehavior(); void reassignedAnimation(); void disabled(); + void dontStart(); }; void tst_qmlbehaviors::simpleBehavior() @@ -278,7 +279,21 @@ void tst_qmlbehaviors::disabled() rect->setState("moved"); qreal x = qobject_cast(rect->findChild("MyRect"))->x(); QCOMPARE(x, qreal(200)); //should change immediately +} + +void tst_qmlbehaviors::dontStart() +{ + QmlEngine engine; + + QmlComponent c(&engine, QUrl::fromLocalFile(SRCDIR "/data/dontStart.qml")); + + QTest::ignoreMessage(QtWarningMsg, "QmlAbstractAnimation: setRunning() cannot be used on non-root animation nodes"); + QmlGraphicsRectangle *rect = qobject_cast(c.create()); + QVERIFY(rect); + QmlAbstractAnimation *myAnim = rect->findChild("MyAnim"); + QVERIFY(myAnim && myAnim->qtAnimation()); + QVERIFY(myAnim->qtAnimation()->state() == QAbstractAnimation::Stopped); } QTEST_MAIN(tst_qmlbehaviors) -- cgit v0.12 From f1b1e45c3c66a9061becbee38aaabb3653a20d9d Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 18 Feb 2010 12:39:04 +1000 Subject: Remove unneeded comparison. d->propertyName is now included in props. --- src/declarative/util/qmlanimation.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 4b33af0..e1e247c 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -2150,7 +2150,7 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, targets.append(d->target); bool hasSelectors = !props.isEmpty() || !targets.isEmpty() || !d->exclude.isEmpty(); - bool useType = (props.isEmpty() && d->propertyName.isEmpty() && d->defaultToInterpolatorType) ? true : false; + bool useType = (props.isEmpty() && d->defaultToInterpolatorType) ? true : false; if (d->defaultProperty.isValid() && !hasSelectors) { props << d->defaultProperty.name(); -- cgit v0.12 From d031fce2871df878709ba5d67202a5edc08470fe Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 18 Feb 2010 13:12:34 +1000 Subject: Add a RotationAnimation element. This is needed to provide more control of rotation direction when animating. --- src/declarative/util/qmlanimation.cpp | 182 ++++++++++++++++++++++++++++++++ src/declarative/util/qmlanimation_p.h | 31 ++++++ src/declarative/util/qmlanimation_p_p.h | 10 ++ 3 files changed, 223 insertions(+) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index e1e247c..7bae661 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -1414,6 +1414,177 @@ void QmlVector3dAnimation::setTo(QVector3D t) QML_DEFINE_TYPE(Qt,4,6,Vector3dAnimation,QmlVector3dAnimation) +/*! + \qmlclass RotationAnimation QmlRotationAnimation + \inherits PropertyAnimation + \brief The RotationAnimation element allows you to animate rotations. + + RotationAnimation is a specialized PropertyAnimation that gives control + over the direction of rotation. + + The RotationAnimation in the following example ensures that we always take + the shortest rotation path when switching between our states. + \qml + states: { + State { name: "180"; PropertyChanges { target: myItem; rotation: 180 } } + State { name: "-180"; PropertyChanges { target: myItem; rotation: -180 } } + State { name: "180"; PropertyChanges { target: myItem; rotation: 270 } } + } + transition: Transition { + RotationAnimation { direction: RotationAnimation.Shortest } + } + \endqml + + By default, when used in a transition RotationAnimation will rotate all + properties named "rotation" or "angle". You can override this by providing + your own properties via \c properties or \c property. +*/ + +/*! + \internal + \class QmlRotationAnimation +*/ + +QVariant _q_interpolateShortestRotation(qreal &f, qreal &t, qreal progress) +{ + qreal newt = t; + qreal diff = t-f; + while(diff > 180.0){ + newt -= 360.0; + diff -= 360.0; + } + while(diff < -180.0){ + newt += 360.0; + diff += 360.0; + } + return QVariant(f + (newt - f) * progress); +} + +QVariant _q_interpolateClockwiseRotation(qreal &f, qreal &t, qreal progress) +{ + qreal newt = t; + qreal diff = t-f; + while(diff < 0.0){ + newt += 360.0; + diff += 360.0; + } + return QVariant(f + (newt - f) * progress); +} + +QVariant _q_interpolateCounterclockwiseRotation(qreal &f, qreal &t, qreal progress) +{ + qreal newt = t; + qreal diff = t-f; + while(diff > 0.0){ + newt -= 360.0; + diff -= 360.0; + } + return QVariant(f + (newt - f) * progress); +} + +QmlRotationAnimation::QmlRotationAnimation(QObject *parent) +: QmlPropertyAnimation(*(new QmlRotationAnimationPrivate), parent) +{ + Q_D(QmlRotationAnimation); + d->interpolatorType = QMetaType::QReal; + d->interpolator = reinterpret_cast(&_q_interpolateShortestRotation); + d->defaultProperties = QLatin1String("rotation,angle"); +} + +QmlRotationAnimation::~QmlRotationAnimation() +{ +} + +/*! + \qmlproperty real RotationAnimation::from + This property holds the starting value. + If not set, then the value defined in the start state of the transition. +*/ +qreal QmlRotationAnimation::from() const +{ + Q_D(const QmlRotationAnimation); + return d->from.toReal(); +} + +void QmlRotationAnimation::setFrom(qreal f) +{ + QmlPropertyAnimation::setFrom(f); +} + +/*! + \qmlproperty real RotationAnimation::to + This property holds the ending value. + If not set, then the value defined in the end state of the transition or Behavior. +*/ +qreal QmlRotationAnimation::to() const +{ + Q_D(const QmlRotationAnimation); + return d->to.toReal(); +} + +void QmlRotationAnimation::setTo(qreal t) +{ + QmlPropertyAnimation::setTo(t); +} + +/*! + \qmlproperty enum RotationAnimation::direction + The direction in which to rotate. + Possible values are Numerical, Clockwise, Counterclockwise, + or Shortest. + + \list + \row + \o Numerical + \o Rotate by linearly interpolating between the two numbers. + A rotation from 10 to 350 will rotate 340 degrees clockwise. + \row + \o Clockwise + \o Rotate clockwise between the two values + \row + \o Counterclockwise + \o Rotate counterclockwise between the two values + \row + \o Shortest + \o Rotate in the direction that produces the shortest animation path. + A rotation from 10 to 350 will rotate 20 degrees counterclockwise. + \list + + The default direction is Shortest. +*/ +QmlRotationAnimation::RotationDirection QmlRotationAnimation::direction() const +{ + Q_D(const QmlRotationAnimation); + return d->direction; +} + +void QmlRotationAnimation::setDirection(QmlRotationAnimation::RotationDirection direction) +{ + Q_D(QmlRotationAnimation); + if (d->direction == direction) + return; + + d->direction = direction; + switch(d->direction) { + case Clockwise: + d->interpolator = reinterpret_cast(&_q_interpolateClockwiseRotation); + break; + case Counterclockwise: + d->interpolator = reinterpret_cast(&_q_interpolateCounterclockwiseRotation); + break; + case Shortest: + d->interpolator = reinterpret_cast(&_q_interpolateShortestRotation); + break; + default: + d->interpolator = QVariantAnimationPrivate::getInterpolator(d->interpolatorType); + break; + } + + emit directionChanged(); +} + +QML_DEFINE_TYPE(Qt,4,6,RotationAnimation,QmlRotationAnimation) + QmlAnimationGroup::QmlAnimationGroup(QObject *parent) : QmlAbstractAnimation(*(new QmlAnimationGroupPrivate), parent) { @@ -1661,6 +1832,13 @@ QmlPropertyAnimation::QmlPropertyAnimation(QObject *parent) d->init(); } +QmlPropertyAnimation::QmlPropertyAnimation(QmlPropertyAnimationPrivate &dd, QObject *parent) +: QmlAbstractAnimation(dd, parent) +{ + Q_D(QmlPropertyAnimation); + d->init(); +} + QmlPropertyAnimation::~QmlPropertyAnimation() { } @@ -2157,6 +2335,10 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, targets << d->defaultProperty.object(); } + if (props.isEmpty() && !d->defaultProperties.isEmpty()) { + props << d->defaultProperties.split(QLatin1Char(',')); + } + PropertyUpdater *data = new PropertyUpdater; data->interpolatorType = d->interpolatorType; data->interpolator = d->interpolator; diff --git a/src/declarative/util/qmlanimation_p.h b/src/declarative/util/qmlanimation_p.h index 791a127..02902b0 100644 --- a/src/declarative/util/qmlanimation_p.h +++ b/src/declarative/util/qmlanimation_p.h @@ -297,6 +297,7 @@ public: QList *exclude(); protected: + QmlPropertyAnimation(QmlPropertyAnimationPrivate &dd, QObject *parent); virtual void transition(QmlStateActions &actions, QmlMetaProperties &modified, TransitionDirection direction); @@ -367,6 +368,35 @@ public: void setTo(QVector3D); }; +class QmlRotationAnimationPrivate; +class Q_AUTOTEST_EXPORT QmlRotationAnimation : public QmlPropertyAnimation +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QmlRotationAnimation) + Q_ENUMS(RotationDirection) + + Q_PROPERTY(qreal from READ from WRITE setFrom NOTIFY fromChanged) + Q_PROPERTY(qreal to READ to WRITE setTo NOTIFY toChanged) + Q_PROPERTY(RotationDirection direction READ direction WRITE setDirection NOTIFY directionChanged) + +public: + QmlRotationAnimation(QObject *parent=0); + virtual ~QmlRotationAnimation(); + + qreal from() const; + void setFrom(qreal); + + qreal to() const; + void setTo(qreal); + + enum RotationDirection { Numerical, Shortest, Clockwise, Counterclockwise }; + RotationDirection direction() const; + void setDirection(RotationDirection direction); + +Q_SIGNALS: + void directionChanged(); +}; + class QmlAnimationGroupPrivate; class QmlAnimationGroup : public QmlAbstractAnimation { @@ -429,6 +459,7 @@ QML_DECLARE_TYPE(QmlNumberAnimation) QML_DECLARE_TYPE(QmlSequentialAnimation) QML_DECLARE_TYPE(QmlParallelAnimation) QML_DECLARE_TYPE(QmlVector3dAnimation) +QML_DECLARE_TYPE(QmlRotationAnimation) QT_END_HEADER diff --git a/src/declarative/util/qmlanimation_p_p.h b/src/declarative/util/qmlanimation_p_p.h index ee0c291..a1181ed 100644 --- a/src/declarative/util/qmlanimation_p_p.h +++ b/src/declarative/util/qmlanimation_p_p.h @@ -358,6 +358,7 @@ public: QString properties; QList targets; QList exclude; + QString defaultProperties; bool fromSourced; bool fromIsDefined:1; @@ -373,6 +374,15 @@ public: static void convertVariant(QVariant &variant, int type); }; +class QmlRotationAnimationPrivate : public QmlPropertyAnimationPrivate +{ + Q_DECLARE_PUBLIC(QmlRotationAnimation) +public: + QmlRotationAnimationPrivate() : direction(QmlRotationAnimation::Shortest) {} + + QmlRotationAnimation::RotationDirection direction; +}; + QT_END_NAMESPACE #endif // QMLANIMATION_P_H -- cgit v0.12 From b800e5a8803f2b39c0b8dce5a9509503672148d5 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 18 Feb 2010 15:09:07 +1000 Subject: Animation doc fix. --- src/declarative/util/qmlanimation.cpp | 35 +++++++++++------------------------ 1 file changed, 11 insertions(+), 24 deletions(-) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 7bae661..249bd8e 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -892,14 +892,6 @@ void QmlPropertyAction::setTarget(QObject *o) emit targetChanged(d->target, d->propertyName); } -/*! - \qmlproperty string PropertyAction::property - This property holds an explicit property to animated. - - The exact effect of the \c property property depends on how the animation - is being used. Refer to the \l animation documentation for details. -*/ - QString QmlPropertyAction::property() const { Q_D(const QmlPropertyAction); @@ -916,13 +908,19 @@ void QmlPropertyAction::setProperty(const QString &n) } /*! + \qmlproperty string PropertyAction::property \qmlproperty string PropertyAction::properties - This property holds a comma-separated list of property names this action - will affect. These names are used in conjunction with targets (and the - singular forms target and property) to create a list of properties that the - action will set. + \qmlproperty Object PropertyAction::target + \qmlproperty list PropertyAction::targets - \sa targets PropertyAnimation::properties + These properties are used as a set to determine which properties should be + affected by this action. + + The details of how these properties are interpreted in different situations + is covered in the \l{PropertyAnimation::properties}{corresponding} PropertyAnimation + documentation. + + \sa exclude */ QString QmlPropertyAction::properties() const { @@ -939,17 +937,6 @@ void QmlPropertyAction::setProperties(const QString &p) emit propertiesChanged(p); } -/*! - \qmlproperty list PropertyAction::targets - This property holds a list of objects this action will affect. - These objects are used in conjunction with properties (and their singular - forms property and target) to create a list of properties - that the action will set. - - If no targets are specificed, all changing targets will be animated. - - \sa exclude properties PropertyAnimation::targets -*/ QList *QmlPropertyAction::targets() { Q_D(QmlPropertyAction); -- cgit v0.12 From f9cf46d7198a47cbe50bcbf315b9d0718439086b Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 18 Feb 2010 15:14:36 +1000 Subject: Fix example after introduction of RotationAnimation. id can't be the same as a TypeName. --- demos/declarative/flickr/common/Loading.qml | 2 +- demos/declarative/twitter/content/Loading.qml | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/demos/declarative/flickr/common/Loading.qml b/demos/declarative/flickr/common/Loading.qml index 64a04c4..174cd21 100644 --- a/demos/declarative/flickr/common/Loading.qml +++ b/demos/declarative/flickr/common/Loading.qml @@ -3,6 +3,6 @@ import Qt 4.6 Image { id: loading; source: "pics/loading.png"; transformOrigin: "Center" rotation: NumberAnimation { - id: "RotationAnimation"; from: 0; to: 360; running: loading.visible == true; repeat: true; duration: 900 + from: 0; to: 360; running: loading.visible == true; repeat: true; duration: 900 } } diff --git a/demos/declarative/twitter/content/Loading.qml b/demos/declarative/twitter/content/Loading.qml index 8b22e70..3151415 100644 --- a/demos/declarative/twitter/content/Loading.qml +++ b/demos/declarative/twitter/content/Loading.qml @@ -3,6 +3,6 @@ import Qt 4.6 Image { id: loading; source: "images/loading.png"; transformOrigin: "Center" rotation: NumberAnimation { - id: "RotationAnimation"; from: 0; to: 360; running: loading.visible == true; repeat: true; duration: 900 + from: 0; to: 360; running: loading.visible == true; repeat: true; duration: 900 } } -- cgit v0.12 From c8e266aaf21f470fd45ac61244466583b503fda2 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 18 Feb 2010 16:05:50 +1000 Subject: QmlView API review. See QmlChanges.txt for details. --- demos/declarative/minehunt/main.cpp | 5 +- demos/declarative/minehunt/minehunt.qml | 14 +- doc/src/declarative/integrating.qdoc | 9 + examples/declarative/imageprovider/main.cpp | 2 +- examples/declarative/objectlistmodel/main.cpp | 2 +- src/declarative/QmlChanges.txt | 18 +- src/declarative/util/qmlview.cpp | 389 ++++++++++----------- src/declarative/util/qmlview.h | 49 ++- tests/auto/declarative/layouts/tst_layouts.cpp | 26 +- .../qmlanimations/tst_qmlanimations.cpp | 2 +- .../qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp | 102 +++--- .../tst_qmlgraphicsgridview.cpp | 38 +- .../qmlgraphicsitem/tst_qmlgraphicsitem.cpp | 22 +- .../tst_qmlgraphicslistview.cpp | 60 ++-- .../tst_qmlgraphicsmouseregion.cpp | 13 +- .../tst_qmlgraphicsparticles.cpp | 13 +- .../tst_qmlgraphicspathview.cpp | 23 +- .../tst_qmlgraphicspositioners.cpp | 77 ++-- .../tst_qmlgraphicsrepeater.cpp | 35 +- .../tst_qmlgraphicstextedit.cpp | 45 ++- .../tst_qmlgraphicstextinput.cpp | 35 +- tools/qmlviewer/qfxtester.cpp | 2 +- tools/qmlviewer/qmlviewer.cpp | 37 +- tools/qmlviewer/qmlviewer.h | 3 +- 24 files changed, 499 insertions(+), 522 deletions(-) diff --git a/demos/declarative/minehunt/main.cpp b/demos/declarative/minehunt/main.cpp index c756e66..ac01196 100644 --- a/demos/declarative/minehunt/main.cpp +++ b/demos/declarative/minehunt/main.cpp @@ -167,10 +167,7 @@ MyWidget::MyWidget(int width, int height, QWidget *parent, Qt::WindowFlags flags canvas->setFixedSize(width, height); vbox->addWidget(canvas); - QFile file(fileName); - file.open(QFile::ReadOnly); - QString qml = file.readAll(); - canvas->setQml(qml, fileName); + canvas->setSource(QUrl::fromLocalFile(fileName)); QmlContext *ctxt = canvas->rootContext(); ctxt->addDefaultObject(this); diff --git a/demos/declarative/minehunt/minehunt.qml b/demos/declarative/minehunt/minehunt.qml index ff00d83..033a865 100644 --- a/demos/declarative/minehunt/minehunt.qml +++ b/demos/declarative/minehunt/minehunt.qml @@ -31,7 +31,7 @@ Item { anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter source: "pics/flag.png" - opacity: modelData.hasFlag + opacity: model.hasFlag opacity: Behavior { NumberAnimation { property: "opacity" @@ -47,16 +47,16 @@ Item { Text { anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter - text: modelData.hint + text: model.hint color: "white" font.bold: true - opacity: !modelData.hasMine && modelData.hint > 0 + opacity: !model.hasMine && model.hint > 0 } Image { anchors.horizontalCenter: parent.horizontalCenter anchors.verticalCenter: parent.verticalCenter source: "pics/bomb.png" - opacity: modelData.hasMine + opacity: model.hasMine } Explosion { id: expl @@ -65,7 +65,7 @@ Item { states: [ State { name: "back" - when: modelData.flipped + when: model.flipped PropertyChanges { target: flipable; angle: 180 } } ] @@ -81,7 +81,7 @@ Item { else ret = 0; if (ret > 0) { - if (modelData.hasMine && modelData.flipped) { + if (model.hasMine && model.flipped) { ret*3; } else { ret; @@ -96,7 +96,7 @@ Item { matchProperties: "angle" } ScriptAction{ - script: if(modelData.hasMine && modelData.flipped){expl.explode = true;} + script: if(model.hasMine && model.flipped){expl.explode = true;} } } } diff --git a/doc/src/declarative/integrating.qdoc b/doc/src/declarative/integrating.qdoc index d93a6ff..b1095a7 100644 --- a/doc/src/declarative/integrating.qdoc +++ b/doc/src/declarative/integrating.qdoc @@ -84,6 +84,15 @@ QGraphicsObject *object = scene->addItem(object); \endcode +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); +\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 diff --git a/examples/declarative/imageprovider/main.cpp b/examples/declarative/imageprovider/main.cpp index 718e9bb..6e97513 100644 --- a/examples/declarative/imageprovider/main.cpp +++ b/examples/declarative/imageprovider/main.cpp @@ -75,7 +75,7 @@ int main(int argc, char ** argv) QApplication app(argc, argv); QmlView view; - view.setUrl(QUrl("qrc:view.qml")); + view.setSource(QUrl("qrc:view.qml")); view.engine()->addImageProvider("colors", new ColorImageProvider); diff --git a/examples/declarative/objectlistmodel/main.cpp b/examples/declarative/objectlistmodel/main.cpp index 3f2ac6d..d76a15d 100644 --- a/examples/declarative/objectlistmodel/main.cpp +++ b/examples/declarative/objectlistmodel/main.cpp @@ -59,7 +59,7 @@ int main(int argc, char ** argv) QApplication app(argc, argv); QmlView view; - view.setUrl(QUrl("qrc:view.qml")); + view.setSource(QUrl("qrc:view.qml")); QList dataList; dataList.append(new DataObject("Item 1", "red")); diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index e54ec95..3a709e8 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -1,6 +1,22 @@ +============================================================================= +The changes below are pre Qt 4.7.0 alpha +QmlView +------- +The API of QmlView has been narrowed and its role as a convenience class +reinforced. +- remove addItem() +- remove clearItems() - use 'delete root()' +- remove reset() +- resizeContent -> enum ResizeMode { SizeViewToRootObject, SizeRootObjectToView } +- remove setQml(), qml() +- rename setUrl(), ur() to setSource(), source() +- root() -> rootObject(), returns QGraphicsObject rather than QmlGraphicsItem +- remove quit() signal -> use quit() signal of engine() +- initialSize() signal removed +- Added status() to determine status of the internal QmlComponent -Listview: sectionExpression has been replaced by section.property, section.criteria +sectionExpression has been replaced by section.property, section.criteria ============================================================================= diff --git a/src/declarative/util/qmlview.cpp b/src/declarative/util/qmlview.cpp index 690924f..be67b16 100644 --- a/src/declarative/util/qmlview.cpp +++ b/src/declarative/util/qmlview.cpp @@ -64,6 +64,7 @@ #include #include #include +#include QT_BEGIN_NAMESPACE @@ -125,24 +126,24 @@ void FrameBreakAnimation::updateCurrentTime(int msecs) server->frameBreak(); } -class QmlViewPrivate +class QmlViewPrivate : public QGraphicsViewPrivate { + Q_DECLARE_PUBLIC(QmlView) public: - QmlViewPrivate(QmlView *w) - : q(w), root(0), component(0), resizable(false) {} + QmlViewPrivate() + : root(0), component(0), resizeMode(QmlView::SizeViewToRootObject) {} - QmlView *q; - QmlGraphicsItem *root; + QGuard root; + QGuard qmlRoot; QUrl source; - QString qml; QmlEngine engine; QmlComponent *component; QBasicTimer resizetimer; - QSize initialSize; - bool resizable; + mutable QSize initialSize; + QmlView::ResizeMode resizeMode; QTime frameTimer; void init(); @@ -154,9 +155,30 @@ public: \class QmlView \brief The QmlView class provides a widget for displaying a Qt Declarative user interface. - QmlView currently provides a minimal interface for displaying QML + Any QGraphicsObject or QmlGraphicsItem + created via QML can be placed on a standard QGraphicsScene and viewed with a standard + QGraphicsView. + + QmlView is a QGraphicsView subclass provided as a convenience for displaying QML files, and connecting between QML and C++ Qt objects. + QmlView performs the following functions: + + \list + \o Manages QmlComponent loading and object creation. + \o Initializes QGraphicsView for optimal performance with QML: + \list + \o QGraphicsView::setOptimizationFlags(QGraphicsView::DontSavePainterState); + \o QGraphicsView::setViewportUpdateMode(QGraphicsView::BoundingRectViewportUpdate); + \o QGraphicsScene::setItemIndexMethod(QGraphicsScene::NoIndex); + \endlist + \o Initializes QGraphicsView for QML key handling: + \list + \o QGraphicsView::viewport()->setFocusPolicy(Qt::NoFocus); + \o QGraphicsScene::setStickyFocus(true); + \endlist + \endlist + Typical usage: \code ... @@ -164,7 +186,7 @@ public: vbox->addWidget(view); QUrl url(fileName); - view->setUrl(url); + view->setSource(url); ... view->execute(); ... @@ -172,7 +194,17 @@ public: \endcode To receive errors related to loading and executing QML with QmlView, - you can connect to the errors() signal. + you can connect to the statusChanged() signal and monitor for QmlView::Error. + The errors are available via QmlView::errors(). +*/ + + +/*! \fn void QmlView::sceneResized(QSize size) + This signal is emitted when the view is resized to \a size. +*/ + +/*! \fn void QmlView::statusChanged(QmlView::Status status) + This signal is emitted when the component's current \l{QmlView::Status} {status} changes. */ /*! @@ -181,14 +213,16 @@ public: Constructs a QmlView with the given \a parent. */ QmlView::QmlView(QWidget *parent) -: QGraphicsView(parent), d(new QmlViewPrivate(this)) +: QGraphicsView(*(new QmlViewPrivate), parent) { + Q_D(QmlView); setSizePolicy(QSizePolicy::Preferred,QSizePolicy::Preferred); d->init(); } void QmlViewPrivate::init() { + Q_Q(QmlView); #ifdef Q_ENABLE_PERFORMANCE_LOG { QmlPerfTimer perf; @@ -212,61 +246,46 @@ void QmlViewPrivate::init() } /*! - The destructor clears the view's \l {QmlGraphicsItem} {items} and + The destructor clears the view's \l {QGraphicsObject} {items} and deletes the internal representation. - - \sa clearItems() */ QmlView::~QmlView() { - clearItems(); - delete d; d = 0; + Q_D(QmlView); + delete d->root; } /*! - Sets the source to the \a url. The QML string is set to - empty. + Sets the source to the \a url. + + Call \l execute() to load the QML and instantiate the component. + + \sa execute() */ -void QmlView::setUrl(const QUrl& url) +void QmlView::setSource(const QUrl& url) { + Q_D(QmlView); d->source = url; - d->qml = QString(); } /*! Returns the source URL, if set. - \sa setUrl() + \sa setSource() */ -QUrl QmlView::url() const +QUrl QmlView::source() const { + Q_D(const QmlView); return d->source; } /*! - Sets the source to the URL from the \a filename, and sets - the QML string to \a qml. - */ -void QmlView::setQml(const QString &qml, const QString &filename) -{ - d->source = QUrl::fromLocalFile(filename); - d->qml = qml; -} - -/*! - Returns the QML string. - */ -QString QmlView::qml() const -{ - return d->qml; -} - -/*! Returns a pointer to the QmlEngine used for instantiating QML Components. */ QmlEngine* QmlView::engine() { + Q_D(QmlView); return &d->engine; } @@ -279,21 +298,21 @@ QmlEngine* QmlView::engine() */ QmlContext* QmlView::rootContext() { + Q_D(QmlView); return d->engine.rootContext(); } /*! - Displays the Qt Declarative user interface. + Loads and instantiates the QML component set by the \l setSource() method. + + \sa setSource() */ void QmlView::execute() { - if (d->qml.isEmpty()) { - d->component = new QmlComponent(&d->engine, d->source, this); - } else { - d->component = new QmlComponent(&d->engine, this); - d->component->setData(d->qml.toUtf8(), d->source); - } - connect (&d->engine, SIGNAL (quit ()), this, SIGNAL (quit ())); + Q_D(QmlView); + delete d->root; + delete d->component; + d->component = new QmlComponent(&d->engine, d->source, this); if (!d->component->isLoading()) { continueExecute(); @@ -302,26 +321,100 @@ void QmlView::execute() } } +/*! + \enum QmlView::Status + + Specifies the loading status of the QmlView. + + \value Null This QmlView has no source set. + \value Ready This QmlView has loaded and created the QML component. + \value Loading This QmlView is loading network data. + \value Error An error has occured. Calling errorDescription() to retrieve a description. +*/ + +/*! + \property QmlView::status + The component's current \l{QmlView::Status} {status}. +*/ + +QmlView::Status QmlView::status() const +{ + Q_D(const QmlView); + if (!d->component) + return QmlView::Null; + + return QmlView::Status(d->component->status()); +} + +/*! + Return the list of errors that occured during the last compile or create + operation. An empty list is returned if isError() is not set. +*/ +QList QmlView::errors() const +{ + Q_D(const QmlView); + if (d->component) + return d->component->errors(); + return QList(); +} + + +/*! + \property QmlView::resizeMode + \brief whether the view should resize the canvas contents + + If this property is set to SizeViewToRootObject (the default), the view + resizes with the root item in the QML. + + If this property is set to SizeRootObjectToView, the view will + automatically resize the root item. + + Regardless of this property, the sizeHint of the view + is the initial size of the root item. Note though that + since QML may load dynamically, that size may change. + + \sa initialSize() +*/ + +void QmlView::setResizeMode(ResizeMode mode) +{ + Q_D(QmlView); + if (d->resizeMode == mode) + return; + + d->resizeMode = mode; + if (d->qmlRoot) { + if (d->resizeMode == SizeRootObjectToView) { + d->qmlRoot->setWidth(width()); + d->qmlRoot->setHeight(height()); + } else { + d->qmlRoot->setWidth(d->initialSize.width()); + d->qmlRoot->setHeight(d->initialSize.height()); + } + } +} + +QmlView::ResizeMode QmlView::resizeMode() const +{ + Q_D(const QmlView); + return d->resizeMode; +} /*! \internal */ void QmlView::continueExecute() { - disconnect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(continueExecute())); + Q_D(QmlView); - if (!d->component) { - qWarning() << "Error in loading" << d->source; - return; - } + disconnect(d->component, SIGNAL(statusChanged(QmlComponent::Status)), this, SLOT(continueExecute())); - if(d->component->isError()) { + if (d->component->isError()) { QList errorList = d->component->errors(); foreach (const QmlError &error, errorList) { qWarning() << error; } - emit errors(errorList); - + emit statusChanged(status()); return; } @@ -332,8 +425,7 @@ void QmlView::continueExecute() foreach (const QmlError &error, errorList) { qWarning() << error; } - emit errors(errorList); - + emit statusChanged(status()); return; } @@ -345,24 +437,27 @@ void QmlView::continueExecute() QPerformanceLog::displayData(); QPerformanceLog::clear(); d->root = item; + d->qmlRoot = item; connect(item, SIGNAL(widthChanged()), this, SLOT(sizeChanged())); connect(item, SIGNAL(heightChanged()), this, SLOT(sizeChanged())); - if (d->initialSize.height() <= 0 && d->root->width() > 0) - d->initialSize.setWidth(d->root->width()); - if (d->initialSize.height() <= 0 && d->root->height() > 0) - d->initialSize.setHeight(d->root->height()); + if (d->initialSize.height() <= 0 && d->qmlRoot->width() > 0) + d->initialSize.setWidth(d->qmlRoot->width()); + if (d->initialSize.height() <= 0 && d->qmlRoot->height() > 0) + d->initialSize.setHeight(d->qmlRoot->height()); resize(d->initialSize); - if (d->resizable) { - d->root->setWidth(width()); - d->root->setHeight(height()); + if (d->resizeMode == SizeRootObjectToView) { + d->qmlRoot->setWidth(width()); + d->qmlRoot->setHeight(height()); } else { - QSize sz(d->root->width(),d->root->height()); + QSize sz(d->qmlRoot->width(),d->qmlRoot->height()); emit sceneResized(sz); resize(sz); } updateGeometry(); - emit initialSize(d->initialSize); + } else if (QGraphicsObject *item = qobject_cast(obj)) { + d->scene.addItem(item); + qWarning() << "QmlView::resizeMode is not honored for components of type QGraphicsObject"; } else if (QWidget *wid = qobject_cast(obj)) { window()->setAttribute(Qt::WA_OpaquePaintEvent, false); window()->setAttribute(Qt::WA_NoSystemBackground, false); @@ -377,41 +472,32 @@ void QmlView::continueExecute() } layout()->addWidget(wid); emit sceneResized(wid->size()); - emit initialSize(wid->size()); } } + emit statusChanged(status()); } -/*! \fn void QmlView::sceneResized(QSize size) - This signal is emitted when the view is resized to \a size. - */ - -/*! \fn void QmlView::initialSize(QSize size) - This signal is emitted when the initial \a size of the root item is known. - */ - -/*! \fn void QmlView::errors(const QList &errors) - This signal is emitted when the qml loaded contains \a errors. - */ - /*! \internal */ void QmlView::sizeChanged() { + Q_D(QmlView); // delay, so we catch both width and height changing. d->resizetimer.start(0,this); } /*! + \internal If the \l {QTimerEvent} {timer event} \a e is this view's resize timer, sceneResized() is emitted. */ void QmlView::timerEvent(QTimerEvent* e) { + Q_D(QmlView); if (!e || e->timerId() == d->resizetimer.timerId()) { - if (d->root) { - QSize sz(d->root->width(),d->root->height()); + if (d->qmlRoot) { + QSize sz(d->qmlRoot->width(),d->qmlRoot->height()); emit sceneResized(sz); //if (!d->resizable) //resize(sz); @@ -421,147 +507,47 @@ void QmlView::timerEvent(QTimerEvent* e) } } -// modelled on QScrollArea::widgetResizable -/*! - \property QmlView::contentResizable - \brief whether the view should resize the canvas contents - - If this property is set to false (the default), the view - resizes with the root item in the QML. - - If this property is set to true, the view will - automatically resize the root item. - - Regardless of this property, the sizeHint of the view - is the initial size of the root item. Note though that - since QML may load dynamically, that size may change. - - \sa initialSize() -*/ - -void QmlView::setContentResizable(bool on) -{ - if (d->resizable != on) { - d->resizable = on; - if (d->root) { - if (on) { - d->root->setWidth(width()); - d->root->setHeight(height()); - } else { - d->root->setWidth(d->initialSize.width()); - d->root->setHeight(d->initialSize.height()); - } - } - } -} - -bool QmlView::contentResizable() const -{ - return d->resizable; -} - - /*! + \internal The size hint is the size of the root item. */ QSize QmlView::sizeHint() const { - if (d->root) { + Q_D(const QmlView); + if (d->qmlRoot) { if (d->initialSize.width() <= 0) - d->initialSize.setWidth(d->root->width()); + d->initialSize.setWidth(d->qmlRoot->width()); if (d->initialSize.height() <= 0) - d->initialSize.setHeight(d->root->height()); + d->initialSize.setHeight(d->qmlRoot->height()); } return d->initialSize; } /*! - Creates a \l{QmlComponent} {component} from the \a qml - string, and returns it as an \l {QmlGraphicsItem} {item}. If the - \a parent item is provided, it becomes the new item's - parent. \a parent should be in this view's item hierarchy. + Returns the view's root \l {QGraphicsObject} {item}. */ -QmlGraphicsItem* QmlView::addItem(const QString &qml, QmlGraphicsItem* parent) -{ - if (!d->root) - return 0; - - QmlComponent component(&d->engine); - component.setData(qml.toUtf8(), QUrl()); - if(d->component->isError()) { - QList errorList = d->component->errors(); - foreach (const QmlError &error, errorList) { - qWarning() << error; - } - emit errors(errorList); - - return 0; - } - - QObject *obj = component.create(); - if(d->component->isError()) { - QList errorList = d->component->errors(); - foreach (const QmlError &error, errorList) { - qWarning() << error; - } - emit errors(errorList); - - return 0; - } - - if (obj){ - QmlGraphicsItem *item = static_cast(obj); - if (!parent) - parent = d->root; - - item->setParentItem(parent); - return item; - } - return 0; -} - -/*! - Deletes the view's \l {QmlGraphicsItem} {items} and clears the \l {QmlEngine} - {QML engine's} Component cache. - */ -void QmlView::reset() -{ - clearItems(); - d->engine.clearComponentCache(); - d->initialSize = QSize(); -} - -/*! - Deletes the view's \l {QmlGraphicsItem} {items}. - */ -void QmlView::clearItems() -{ - if (!d->root) - return; - delete d->root; - d->root = 0; -} - -/*! - Returns the view's root \l {QmlGraphicsItem} {item}. - */ -QmlGraphicsItem *QmlView::root() const +QGraphicsObject *QmlView::rootObject() const { + Q_D(const QmlView); return d->root; } /*! + \internal This function handles the \l {QResizeEvent} {resize event} \a e. */ void QmlView::resizeEvent(QResizeEvent *e) { - if (d->resizable && d->root) { - d->root->setWidth(width()); - d->root->setHeight(height()); + Q_D(QmlView); + if (d->resizeMode == SizeRootObjectToView && d->qmlRoot) { + d->qmlRoot->setWidth(width()); + d->qmlRoot->setHeight(height()); } - if (d->root) { - setSceneRect(QRectF(0, 0, d->root->width(), d->root->height())); + if (d->qmlRoot) { + setSceneRect(QRectF(0, 0, d->qmlRoot->width(), d->qmlRoot->height())); + } else if (d->root) { + setSceneRect(d->root->boundingRect()); } else { setSceneRect(rect()); } @@ -569,10 +555,11 @@ void QmlView::resizeEvent(QResizeEvent *e) } /*! - \reimp + \internal */ void QmlView::paintEvent(QPaintEvent *event) { + Q_D(QmlView); int time = 0; if (frameRateDebug() || QmlViewDebugServer::isDebuggingEnabled()) time = d->frameTimer.restart(); diff --git a/src/declarative/util/qmlview.h b/src/declarative/util/qmlview.h index f4f58fd..556a42c 100644 --- a/src/declarative/util/qmlview.h +++ b/src/declarative/util/qmlview.h @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#ifndef QFXVIEW_H -#define QFXVIEW_H +#ifndef QMLVIEW_H +#define QMLVIEW_H #include #include @@ -53,7 +53,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlGraphicsItem; +class QGraphicsObject; class QmlEngine; class QmlContext; class QmlError; @@ -62,35 +62,38 @@ class QmlViewPrivate; class Q_DECLARATIVE_EXPORT QmlView : public QGraphicsView { Q_OBJECT - Q_PROPERTY(bool contentResizable READ contentResizable WRITE setContentResizable) + Q_PROPERTY(ResizeMode resizeMode READ resizeMode WRITE setResizeMode) + Q_PROPERTY(Status status READ status NOTIFY statusChanged) + + Q_DECLARE_PRIVATE(QmlView) + public: explicit QmlView(QWidget *parent = 0); - virtual ~QmlView(); - void setUrl(const QUrl&); - QUrl url() const; - void setQml(const QString &qml, const QString &filename=QString()); - QString qml() const; + QUrl source() const; + void setSource(const QUrl&); + QmlEngine* engine(); QmlContext* rootContext(); - virtual void execute(); - virtual void reset(); + void execute(); - virtual QmlGraphicsItem* addItem(const QString &qml, QmlGraphicsItem* parent=0); - virtual void clearItems(); + QGraphicsObject *rootObject() const; - virtual QmlGraphicsItem *root() const; + enum ResizeMode { SizeViewToRootObject, SizeRootObjectToView }; + ResizeMode resizeMode() const; + void setResizeMode(ResizeMode); + + enum Status { Null, Ready, Loading, Error }; + Status status() const; + + QList errors() const; - void setContentResizable(bool); - bool contentResizable() const; QSize sizeHint() const; Q_SIGNALS: - void initialSize(QSize size); - void sceneResized(QSize size); - void errors(const QList &error); - void quit (); + void sceneResized(QSize size); // ??? + void statusChanged(QmlView::Status); private Q_SLOTS: void continueExecute(); @@ -100,14 +103,10 @@ protected: virtual void resizeEvent(QResizeEvent *); virtual void paintEvent(QPaintEvent *event); void timerEvent(QTimerEvent*); - -private: - friend class QmlViewPrivate; - QmlViewPrivate *d; }; QT_END_NAMESPACE QT_END_HEADER -#endif // QFXVIEW_H +#endif // QMLVIEW_H diff --git a/tests/auto/declarative/layouts/tst_layouts.cpp b/tests/auto/declarative/layouts/tst_layouts.cpp index 0f832bf..54ca761 100644 --- a/tests/auto/declarative/layouts/tst_layouts.cpp +++ b/tests/auto/declarative/layouts/tst_layouts.cpp @@ -69,10 +69,10 @@ void tst_QmlGraphicsLayouts::test_qml() canvas->execute(); qApp->processEvents(); - QmlGraphicsLayoutItem *left = static_cast(canvas->root()->findChild("left")); + QmlGraphicsLayoutItem *left = static_cast(canvas->rootObject()->findChild("left")); QVERIFY(left != 0); - QmlGraphicsLayoutItem *right = static_cast(canvas->root()->findChild("right")); + QmlGraphicsLayoutItem *right = static_cast(canvas->rootObject()->findChild("right")); QVERIFY(right != 0); qreal l = QApplication::style()->pixelMetric(QStyle::PM_LayoutLeftMargin); @@ -81,9 +81,13 @@ void tst_QmlGraphicsLayouts::test_qml() qreal b = QApplication::style()->pixelMetric(QStyle::PM_LayoutBottomMargin); QVERIFY2(l == r && r == t && t == b, "Test assumes equal margins."); qreal gvMargin = l; + + QmlGraphicsItem *rootItem = qobject_cast(canvas->rootObject()); + QVERIFY(rootItem != 0); + //Preferred Size - canvas->root()->setWidth(300 + 2*gvMargin); - canvas->root()->setHeight(300 + 2*gvMargin); + rootItem->setWidth(300 + 2*gvMargin); + rootItem->setHeight(300 + 2*gvMargin); QCOMPARE(left->x(), gvMargin); QCOMPARE(left->y(), gvMargin); @@ -96,8 +100,8 @@ void tst_QmlGraphicsLayouts::test_qml() QCOMPARE(right->height(), 300.0); //Minimum Size - canvas->root()->setWidth(10+2*gvMargin); - canvas->root()->setHeight(10+2*gvMargin); + rootItem->setWidth(10+2*gvMargin); + rootItem->setHeight(10+2*gvMargin); QCOMPARE(left->x(), gvMargin); QCOMPARE(left->width(), 100.0); @@ -111,8 +115,8 @@ void tst_QmlGraphicsLayouts::test_qml() /*Note that if set to maximum size (or above) GraphicsLinearLayout behavior is to shrink them down to preferred size. So the exact maximum size can't be used*/ - canvas->root()->setWidth(670 + 2*gvMargin); - canvas->root()->setHeight(300 + 2*gvMargin); + rootItem->setWidth(670 + 2*gvMargin); + rootItem->setHeight(300 + 2*gvMargin); QCOMPARE(left->x(), gvMargin); QCOMPARE(left->width(), 270.0); @@ -133,11 +137,7 @@ void tst_QmlGraphicsLayouts::test_cpp() QmlView *tst_QmlGraphicsLayouts::createView(const QString &filename) { QmlView *canvas = new QmlView(0); - - QFile file(filename); - file.open(QFile::ReadOnly); - QString qml = file.readAll(); - canvas->setQml(qml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); return canvas; } diff --git a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp index 92b0bf2..39d4326 100644 --- a/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp +++ b/tests/auto/declarative/qmlanimations/tst_qmlanimations.cpp @@ -258,7 +258,7 @@ void tst_qmlanimations::badTypes() //don't crash { QmlView *view = new QmlView; - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/badtype1.qml")); + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/badtype1.qml")); view->execute(); qApp->processEvents(); diff --git a/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp b/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp index b8e54c0..1d2d12f 100644 --- a/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp +++ b/tests/auto/declarative/qmlgraphicsanchors/tst_qmlgraphicsanchors.cpp @@ -58,7 +58,7 @@ public: tst_qmlgraphicsanchors() {} template - T *findItem(QmlGraphicsItem *parent, const QString &id); + T *findItem(QGraphicsObject *parent, const QString &id); private slots: void basicAnchors(); @@ -80,7 +80,7 @@ private slots: Find an item with the specified id. */ template -T *tst_qmlgraphicsanchors::findItem(QmlGraphicsItem *parent, const QString &objectName) +T *tst_qmlgraphicsanchors::findItem(QGraphicsObject *parent, const QString &objectName) { const QMetaObject &mo = T::staticMetaObject; QList children = parent->childItems(); @@ -102,66 +102,66 @@ T *tst_qmlgraphicsanchors::findItem(QmlGraphicsItem *parent, const QString &obje void tst_qmlgraphicsanchors::basicAnchors() { QmlView *view = new QmlView; - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml")); + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/anchors.qml")); view->execute(); qApp->processEvents(); //sibling horizontal - QCOMPARE(findItem(view->root(), QLatin1String("rect1"))->x(), 26.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect2"))->x(), 122.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect3"))->x(), 74.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect4"))->x(), 16.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect5"))->x(), 112.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect6"))->x(), 64.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect1"))->x(), 26.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect2"))->x(), 122.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect3"))->x(), 74.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect4"))->x(), 16.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect5"))->x(), 112.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect6"))->x(), 64.0); //parent horizontal - QCOMPARE(findItem(view->root(), QLatin1String("rect7"))->x(), 0.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect8"))->x(), 240.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect9"))->x(), 120.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect10"))->x(), -10.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect11"))->x(), 230.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect12"))->x(), 110.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect7"))->x(), 0.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect8"))->x(), 240.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect9"))->x(), 120.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect10"))->x(), -10.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect11"))->x(), 230.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect12"))->x(), 110.0); //vertical - QCOMPARE(findItem(view->root(), QLatin1String("rect13"))->y(), 20.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect14"))->y(), 155.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect13"))->y(), 20.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect14"))->y(), 155.0); //stretch - QCOMPARE(findItem(view->root(), QLatin1String("rect15"))->x(), 26.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect15"))->width(), 96.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect16"))->x(), 26.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect16"))->width(), 192.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect17"))->x(), -70.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect17"))->width(), 192.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect15"))->x(), 26.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect15"))->width(), 96.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect16"))->x(), 26.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect16"))->width(), 192.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect17"))->x(), -70.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect17"))->width(), 192.0); //vertical stretch - QCOMPARE(findItem(view->root(), QLatin1String("rect18"))->y(), 20.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect18"))->height(), 40.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect18"))->y(), 20.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect18"))->height(), 40.0); //more parent horizontal - QCOMPARE(findItem(view->root(), QLatin1String("rect19"))->x(), 115.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect20"))->x(), 235.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect21"))->x(), -5.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect19"))->x(), 115.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect20"))->x(), 235.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect21"))->x(), -5.0); //centerIn - QCOMPARE(findItem(view->root(), QLatin1String("rect22"))->x(), 69.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect22"))->y(), 5.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect22"))->x(), 69.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect22"))->y(), 5.0); //margins - QCOMPARE(findItem(view->root(), QLatin1String("rect23"))->x(), 31.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect23"))->y(), 5.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect23"))->width(), 86.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect23"))->height(), 10.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->x(), 31.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->y(), 5.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->width(), 86.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect23"))->height(), 10.0); // offsets - QCOMPARE(findItem(view->root(), QLatin1String("rect24"))->x(), 26.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect25"))->y(), 60.0); - QCOMPARE(findItem(view->root(), QLatin1String("rect26"))->y(), 5.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect24"))->x(), 26.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect25"))->y(), 60.0); + QCOMPARE(findItem(view->rootObject(), QLatin1String("rect26"))->y(), 5.0); //baseline - QmlGraphicsText *text1 = findItem(view->root(), QLatin1String("text1")); - QmlGraphicsText *text2 = findItem(view->root(), QLatin1String("text2")); + QmlGraphicsText *text1 = findItem(view->rootObject(), QLatin1String("text1")); + QmlGraphicsText *text2 = findItem(view->rootObject(), QLatin1String("text2")); QCOMPARE(text1->y(), text2->y()); delete view; @@ -173,9 +173,9 @@ void tst_qmlgraphicsanchors::loops() { QmlView *view = new QmlView; - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/loop1.qml")); + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/loop1.qml")); - QString expect = "QML Text (" + view->url().toString() + ":6:5" + ") Possible anchor loop detected on horizontal anchor."; + QString expect = "QML Text (" + view->source().toString() + ":6:5" + ") Possible anchor loop detected on horizontal anchor."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); @@ -188,9 +188,9 @@ void tst_qmlgraphicsanchors::loops() { QmlView *view = new QmlView; - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/loop2.qml")); + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/loop2.qml")); - QString expect = "QML Image (" + view->url().toString() + ":8:3" + ") Possible anchor loop detected on horizontal anchor."; + QString expect = "QML Image (" + view->source().toString() + ":8:3" + ") Possible anchor loop detected on horizontal anchor."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); view->execute(); qApp->processEvents(); @@ -372,9 +372,9 @@ void tst_qmlgraphicsanchors::crash1() { QmlView *view = new QmlView; - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/crash1.qml")); + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/crash1.qml")); - QString expect = "QML Text (" + view->url().toString() + ":4:5" + ") Possible anchor loop detected on fill."; + QString expect = "QML Text (" + view->source().toString() + ":4:5" + ") Possible anchor loop detected on fill."; QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); QTest::ignoreMessage(QtWarningMsg, expect.toLatin1()); // XXX ideally, should be one message view->execute(); @@ -387,11 +387,11 @@ void tst_qmlgraphicsanchors::fill() { QmlView *view = new QmlView; - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/fill.qml")); + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/fill.qml")); view->execute(); qApp->processEvents(); - QmlGraphicsRectangle* rect = findItem(view->root(), QLatin1String("filler")); + QmlGraphicsRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); QCOMPARE(rect->x(), 0.0 + 10.0); QCOMPARE(rect->y(), 0.0 + 30.0); QCOMPARE(rect->width(), 200.0 - 10.0 - 20.0); @@ -413,11 +413,11 @@ void tst_qmlgraphicsanchors::centerIn() { QmlView *view = new QmlView; - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml")); + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/centerin.qml")); view->execute(); qApp->processEvents(); - QmlGraphicsRectangle* rect = findItem(view->root(), QLatin1String("centered")); + QmlGraphicsRectangle* rect = findItem(view->rootObject(), QLatin1String("centered")); QCOMPARE(rect->x(), 75.0 + 10); QCOMPARE(rect->y(), 75.0 + 30); //Alter Offsets (QTBUG-6631) @@ -433,11 +433,11 @@ void tst_qmlgraphicsanchors::margins() { QmlView *view = new QmlView; - view->setUrl(QUrl::fromLocalFile(SRCDIR "/data/margins.qml")); + view->setSource(QUrl::fromLocalFile(SRCDIR "/data/margins.qml")); view->execute(); qApp->processEvents(); - QmlGraphicsRectangle* rect = findItem(view->root(), QLatin1String("filler")); + QmlGraphicsRectangle* rect = findItem(view->rootObject(), QLatin1String("filler")); QCOMPARE(rect->x(), 5.0); QCOMPARE(rect->y(), 6.0); QCOMPARE(rect->width(), 200.0 - 5.0 - 10.0); diff --git a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp index c157e62..b161b01 100644 --- a/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp +++ b/tests/auto/declarative/qmlgraphicsgridview/tst_qmlgraphicsgridview.cpp @@ -70,9 +70,9 @@ private slots: private: QmlView *createView(const QString &filename); template - T *findItem(QmlGraphicsItem *parent, const QString &id, int index=-1); + T *findItem(QGraphicsObject *parent, const QString &id, int index=-1); template - QList findItems(QmlGraphicsItem *parent, const QString &objectName); + QList findItems(QGraphicsObject *parent, const QString &objectName); void dumpTree(QmlGraphicsItem *parent, int depth = 0); }; @@ -160,7 +160,7 @@ void tst_QmlGraphicsGridView::items() canvas->execute(); qApp->processEvents(); - QmlGraphicsGridView *gridview = findItem(canvas->root(), "grid"); + QmlGraphicsGridView *gridview = findItem(canvas->rootObject(), "grid"); QVERIFY(gridview != 0); QmlGraphicsItem *viewport = gridview->viewport(); @@ -208,7 +208,7 @@ void tst_QmlGraphicsGridView::changed() canvas->execute(); qApp->processEvents(); - QmlGraphicsFlickable *gridview = findItem(canvas->root(), "grid"); + QmlGraphicsFlickable *gridview = findItem(canvas->rootObject(), "grid"); QVERIFY(gridview != 0); QmlGraphicsItem *viewport = gridview->viewport(); @@ -241,7 +241,7 @@ void tst_QmlGraphicsGridView::inserted() canvas->execute(); qApp->processEvents(); - QmlGraphicsGridView *gridview = findItem(canvas->root(), "grid"); + QmlGraphicsGridView *gridview = findItem(canvas->rootObject(), "grid"); QVERIFY(gridview != 0); QmlGraphicsItem *viewport = gridview->viewport(); @@ -322,7 +322,7 @@ void tst_QmlGraphicsGridView::removed() canvas->execute(); qApp->processEvents(); - QmlGraphicsGridView *gridview = findItem(canvas->root(), "grid"); + QmlGraphicsGridView *gridview = findItem(canvas->rootObject(), "grid"); QVERIFY(gridview != 0); QmlGraphicsItem *viewport = gridview->viewport(); @@ -482,7 +482,7 @@ void tst_QmlGraphicsGridView::moved() canvas->execute(); qApp->processEvents(); - QmlGraphicsGridView *gridview = findItem(canvas->root(), "grid"); + QmlGraphicsGridView *gridview = findItem(canvas->rootObject(), "grid"); QVERIFY(gridview != 0); QmlGraphicsItem *viewport = gridview->viewport(); @@ -578,15 +578,12 @@ void tst_QmlGraphicsGridView::currentIndex() ctxt->setContextProperty("testModel", &model); QString filename(SRCDIR "/data/gridview-initCurrent.qml"); - QFile file(filename); - file.open(QFile::ReadOnly); - QString qml = file.readAll(); - canvas->setQml(qml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); canvas->execute(); qApp->processEvents(); - QmlGraphicsGridView *gridview = findItem(canvas->root(), "grid"); + QmlGraphicsGridView *gridview = findItem(canvas->rootObject(), "grid"); QVERIFY(gridview != 0); QmlGraphicsItem *viewport = gridview->viewport(); @@ -722,7 +719,7 @@ void tst_QmlGraphicsGridView::changeFlow() canvas->execute(); qApp->processEvents(); - QmlGraphicsGridView *gridview = findItem(canvas->root(), "grid"); + QmlGraphicsGridView *gridview = findItem(canvas->rootObject(), "grid"); QVERIFY(gridview != 0); QmlGraphicsItem *viewport = gridview->viewport(); @@ -827,7 +824,7 @@ void tst_QmlGraphicsGridView::positionViewAtIndex() canvas->execute(); qApp->processEvents(); - QmlGraphicsGridView *gridview = findItem(canvas->root(), "grid"); + QmlGraphicsGridView *gridview = findItem(canvas->rootObject(), "grid"); QVERIFY(gridview != 0); QmlGraphicsItem *viewport = gridview->viewport(); @@ -907,10 +904,7 @@ QmlView *tst_QmlGraphicsGridView::createView(const QString &filename) QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); - QFile file(filename); - file.open(QFile::ReadOnly); - QString qml = file.readAll(); - canvas->setQml(qml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); return canvas; } @@ -920,10 +914,10 @@ QmlView *tst_QmlGraphicsGridView::createView(const QString &filename) item must also evaluate the {index} expression equal to index */ template -T *tst_QmlGraphicsGridView::findItem(QmlGraphicsItem *parent, const QString &objectName, int index) +T *tst_QmlGraphicsGridView::findItem(QGraphicsObject *parent, const QString &objectName, int index) { const QMetaObject &mo = T::staticMetaObject; - //qDebug() << parent->QGraphicsObject::children().count() << "children"; + //qDebug() << parent->childItems().count() << "children"; for (int i = 0; i < parent->childItems().count(); ++i) { QmlGraphicsItem *item = qobject_cast(parent->childItems().at(i)); if(!item) @@ -950,11 +944,11 @@ T *tst_QmlGraphicsGridView::findItem(QmlGraphicsItem *parent, const QString &obj } template -QList tst_QmlGraphicsGridView::findItems(QmlGraphicsItem *parent, const QString &objectName) +QList tst_QmlGraphicsGridView::findItems(QGraphicsObject *parent, const QString &objectName) { QList items; const QMetaObject &mo = T::staticMetaObject; - //qDebug() << parent->QGraphicsObject::children().count() << "children"; + //qDebug() << parent->childItems().count() << "children"; for (int i = 0; i < parent->childItems().count(); ++i) { QmlGraphicsItem *item = qobject_cast(parent->childItems().at(i)); if(!item) diff --git a/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp b/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp index 639f64c..dd0687c 100644 --- a/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp +++ b/tests/auto/declarative/qmlgraphicsitem/tst_qmlgraphicsitem.cpp @@ -61,7 +61,7 @@ private slots: private: template - T *findItem(QmlGraphicsItem *parent, const QString &objectName); + T *findItem(QGraphicsObject *parent, const QString &objectName); QmlEngine engine; }; @@ -112,7 +112,7 @@ void tst_QmlGraphicsItem::keys() QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); - canvas->setUrl(QUrl::fromLocalFile(SRCDIR "/data/keys.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keys.qml")); KeysTestObject *testObject = new KeysTestObject; canvas->rootContext()->setContextProperty("keysTestObject", testObject); @@ -194,7 +194,7 @@ void tst_QmlGraphicsItem::keyNavigation() QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); - canvas->setUrl(QUrl::fromLocalFile(SRCDIR "/data/keynavigation.qml")); + canvas->setSource(QUrl::fromLocalFile(SRCDIR "/data/keynavigation.qml")); canvas->execute(); canvas->show(); qApp->processEvents(); @@ -204,7 +204,7 @@ void tst_QmlGraphicsItem::keyNavigation() QFocusEvent fe(QEvent::FocusIn); QApplication::sendEvent(canvas, &fe); - QmlGraphicsItem *item = findItem(canvas->root(), "item1"); + QmlGraphicsItem *item = findItem(canvas->rootObject(), "item1"); QVERIFY(item); QVERIFY(item->hasFocus()); @@ -213,7 +213,7 @@ void tst_QmlGraphicsItem::keyNavigation() QApplication::sendEvent(canvas, &key); QVERIFY(key.isAccepted()); - item = findItem(canvas->root(), "item2"); + item = findItem(canvas->rootObject(), "item2"); QVERIFY(item); QVERIFY(item->hasFocus()); @@ -222,7 +222,7 @@ void tst_QmlGraphicsItem::keyNavigation() QApplication::sendEvent(canvas, &key); QVERIFY(key.isAccepted()); - item = findItem(canvas->root(), "item4"); + item = findItem(canvas->rootObject(), "item4"); QVERIFY(item); QVERIFY(item->hasFocus()); @@ -231,7 +231,7 @@ void tst_QmlGraphicsItem::keyNavigation() QApplication::sendEvent(canvas, &key); QVERIFY(key.isAccepted()); - item = findItem(canvas->root(), "item3"); + item = findItem(canvas->rootObject(), "item3"); QVERIFY(item); QVERIFY(item->hasFocus()); @@ -240,7 +240,7 @@ void tst_QmlGraphicsItem::keyNavigation() QApplication::sendEvent(canvas, &key); QVERIFY(key.isAccepted()); - item = findItem(canvas->root(), "item1"); + item = findItem(canvas->rootObject(), "item1"); QVERIFY(item); QVERIFY(item->hasFocus()); } @@ -292,15 +292,15 @@ void tst_QmlGraphicsItem::clip() } template -T *tst_QmlGraphicsItem::findItem(QmlGraphicsItem *parent, const QString &objectName) +T *tst_QmlGraphicsItem::findItem(QGraphicsObject *parent, const QString &objectName) { if (!parent) return 0; const QMetaObject &mo = T::staticMetaObject; //qDebug() << parent->QGraphicsObject::children().count() << "children"; - for (int i = 0; i < parent->QGraphicsObject::children().count(); ++i) { - QmlGraphicsItem *item = qobject_cast(parent->QGraphicsObject::children().at(i)); + for (int i = 0; i < parent->childItems().count(); ++i) { + QmlGraphicsItem *item = qobject_cast(parent->childItems().at(i)); if(!item) continue; //qDebug() << "try" << item; diff --git a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp index 6f97030..faa19eb 100644 --- a/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp +++ b/tests/auto/declarative/qmlgraphicslistview/tst_qmlgraphicslistview.cpp @@ -90,9 +90,9 @@ private: template void clear(); QmlView *createView(const QString &filename); template - T *findItem(QmlGraphicsItem *parent, const QString &id, int index=-1); + T *findItem(QGraphicsObject *parent, const QString &id, int index=-1); template - QList findItems(QmlGraphicsItem *parent, const QString &objectName); + QList findItems(QGraphicsObject *parent, const QString &objectName); void dumpTree(QmlGraphicsItem *parent, int depth = 0); }; @@ -316,13 +316,13 @@ void tst_QmlGraphicsListView::items() canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); QVERIFY(viewport != 0); - QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); QVERIFY(testObject->error() == false); QVERIFY(listview->highlightItem() != 0); @@ -343,20 +343,20 @@ void tst_QmlGraphicsListView::items() // switch to other delegate testObject->setAnimate(true); - QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); QVERIFY(testObject->error() == false); QVERIFY(listview->currentItem()); // set invalid highlight testObject->setInvalidHighlight(true); - QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); QVERIFY(testObject->error() == false); QVERIFY(listview->currentItem()); QVERIFY(listview->highlightItem() == 0); // back to normal highlight testObject->setInvalidHighlight(false); - QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); QVERIFY(testObject->error() == false); QVERIFY(listview->currentItem()); QVERIFY(listview->highlightItem() != 0); @@ -396,7 +396,7 @@ void tst_QmlGraphicsListView::changed() canvas->execute(); qApp->processEvents(); - QmlGraphicsFlickable *listview = findItem(canvas->root(), "list"); + QmlGraphicsFlickable *listview = findItem(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); @@ -432,7 +432,7 @@ void tst_QmlGraphicsListView::inserted() canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); @@ -501,6 +501,8 @@ void tst_QmlGraphicsListView::inserted() QCOMPARE(item->y(), i*20.0 - 20.0); } +// QCOMPARE(listview->viewportHeight(), model.count() * 20.0); + delete canvas; } @@ -523,7 +525,7 @@ void tst_QmlGraphicsListView::removed(bool animated) canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); @@ -665,7 +667,7 @@ void tst_QmlGraphicsListView::clear() canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); @@ -702,7 +704,7 @@ void tst_QmlGraphicsListView::moved() canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); @@ -795,7 +797,7 @@ void tst_QmlGraphicsListView::enforceRange() canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem(canvas->rootObject(), "list"); QVERIFY(listview != 0); QCOMPARE(listview->preferredHighlightBegin(), 100.0); @@ -843,7 +845,7 @@ void tst_QmlGraphicsListView::spacing() canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); @@ -898,7 +900,7 @@ void tst_QmlGraphicsListView::sections() canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); @@ -971,15 +973,12 @@ void tst_QmlGraphicsListView::currentIndex() ctxt->setContextProperty("testWrap", QVariant(false)); QString filename(SRCDIR "/data/listview-initCurrent.qml"); - QFile file(filename); - file.open(QFile::ReadOnly); - QString qml = file.readAll(); - canvas->setQml(qml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); @@ -1061,13 +1060,13 @@ void tst_QmlGraphicsListView::itemList() canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem(canvas->root(), "view"); + QmlGraphicsListView *listview = findItem(canvas->rootObject(), "view"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); QVERIFY(viewport != 0); - QmlGraphicsVisualItemModel *model = canvas->root()->findChild("itemModel"); + QmlGraphicsVisualItemModel *model = canvas->rootObject()->findChild("itemModel"); QVERIFY(model != 0); QVERIFY(model->count() == 3); @@ -1112,7 +1111,7 @@ void tst_QmlGraphicsListView::cacheBuffer() canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); @@ -1164,7 +1163,7 @@ void tst_QmlGraphicsListView::positionViewAtIndex() canvas->execute(); qApp->processEvents(); - QmlGraphicsListView *listview = findItem(canvas->root(), "list"); + QmlGraphicsListView *listview = findItem(canvas->rootObject(), "list"); QVERIFY(listview != 0); QmlGraphicsItem *viewport = listview->viewport(); @@ -1301,10 +1300,7 @@ QmlView *tst_QmlGraphicsListView::createView(const QString &filename) QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); - QFile file(filename); - file.open(QFile::ReadOnly); - QString qml = file.readAll(); - canvas->setQml(qml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); return canvas; } @@ -1314,10 +1310,10 @@ QmlView *tst_QmlGraphicsListView::createView(const QString &filename) item must also evaluate the {index} expression equal to index */ template -T *tst_QmlGraphicsListView::findItem(QmlGraphicsItem *parent, const QString &objectName, int index) +T *tst_QmlGraphicsListView::findItem(QGraphicsObject *parent, const QString &objectName, int index) { const QMetaObject &mo = T::staticMetaObject; - //qDebug() << parent->QGraphicsObject::children().count() << "children"; + //qDebug() << parent->childItems().count() << "children"; for (int i = 0; i < parent->childItems().count(); ++i) { QmlGraphicsItem *item = qobject_cast(parent->childItems().at(i)); if(!item) @@ -1342,11 +1338,11 @@ T *tst_QmlGraphicsListView::findItem(QmlGraphicsItem *parent, const QString &obj } template -QList tst_QmlGraphicsListView::findItems(QmlGraphicsItem *parent, const QString &objectName) +QList tst_QmlGraphicsListView::findItems(QGraphicsObject *parent, const QString &objectName) { QList items; const QMetaObject &mo = T::staticMetaObject; - //qDebug() << parent->QGraphicsObject::children().count() << "children"; + //qDebug() << parent->childItems().count() << "children"; for (int i = 0; i < parent->childItems().count(); ++i) { QmlGraphicsItem *item = qobject_cast(parent->childItems().at(i)); if(!item) diff --git a/tests/auto/declarative/qmlgraphicsmouseregion/tst_qmlgraphicsmouseregion.cpp b/tests/auto/declarative/qmlgraphicsmouseregion/tst_qmlgraphicsmouseregion.cpp index 7ba076c..82da9c8 100644 --- a/tests/auto/declarative/qmlgraphicsmouseregion/tst_qmlgraphicsmouseregion.cpp +++ b/tests/auto/declarative/qmlgraphicsmouseregion/tst_qmlgraphicsmouseregion.cpp @@ -59,18 +59,18 @@ void tst_QmlGraphicsMouseRegion::dragProperties() canvas->execute(); canvas->show(); canvas->setFocus(); - QVERIFY(canvas->root() != 0); + QVERIFY(canvas->rootObject() != 0); - QmlGraphicsMouseRegion *mouseRegion = canvas->root()->findChild("mouseregion"); + QmlGraphicsMouseRegion *mouseRegion = canvas->rootObject()->findChild("mouseregion"); QmlGraphicsDrag *drag = mouseRegion->drag(); QVERIFY(mouseRegion != 0); QVERIFY(drag != 0); // target - QmlGraphicsItem *blackRect = canvas->root()->findChild("blackrect"); + QmlGraphicsItem *blackRect = canvas->rootObject()->findChild("blackrect"); QVERIFY(blackRect != 0); QVERIFY(blackRect == drag->target()); - QmlGraphicsItem *rootItem = qobject_cast(canvas->root()); + QmlGraphicsItem *rootItem = qobject_cast(canvas->rootObject()); QVERIFY(rootItem != 0); QSignalSpy targetSpy(drag, SIGNAL(targetChanged())); drag->setTarget(rootItem); @@ -129,10 +129,7 @@ QmlView *tst_QmlGraphicsMouseRegion::createView(const QString &filename) QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); - QFile file(filename); - file.open(QFile::ReadOnly); - QString qml = file.readAll(); - canvas->setQml(qml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); return canvas; } diff --git a/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp b/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp index 5458d68..5b75b32 100644 --- a/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp +++ b/tests/auto/declarative/qmlgraphicsparticles/tst_qmlgraphicsparticles.cpp @@ -63,8 +63,8 @@ tst_QmlGraphicsParticles::tst_QmlGraphicsParticles() void tst_QmlGraphicsParticles::properties() { QmlView *canvas = createView(SRCDIR "/data/particles.qml"); - QVERIFY(canvas->root()); - QmlGraphicsParticles* particles = canvas->root()->findChild("particles"); + QVERIFY(canvas->rootObject()); + QmlGraphicsParticles* particles = canvas->rootObject()->findChild("particles"); QVERIFY(particles); particles->setSource(QUrl::fromLocalFile(SRCDIR "/data/particle.png")); @@ -101,8 +101,8 @@ void tst_QmlGraphicsParticles::properties() void tst_QmlGraphicsParticles::runs() { QmlView *canvas = createView(SRCDIR "/data/particles.qml"); - QVERIFY(canvas->root()); - QmlGraphicsParticles* particles = canvas->root()->findChild("particles"); + QVERIFY(canvas->rootObject()); + QmlGraphicsParticles* particles = canvas->rootObject()->findChild("particles"); QVERIFY(particles); QTest::qWait(1000);//Run for one second. Test passes if it doesn't crash. } @@ -112,10 +112,7 @@ QmlView *tst_QmlGraphicsParticles::createView(const QString &filename) QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); - QFile file(filename); - file.open(QFile::ReadOnly); - QString qml = file.readAll(); - canvas->setQml(qml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); canvas->execute(); return canvas; diff --git a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp index 4c2ecbd..9f67962 100644 --- a/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp +++ b/tests/auto/declarative/qmlgraphicspathview/tst_qmlgraphicspathview.cpp @@ -71,9 +71,9 @@ private slots: private: QmlView *createView(const QString &filename); template - T *findItem(QmlGraphicsItem *parent, const QString &objectName, int index=-1); + T *findItem(QGraphicsObject *parent, const QString &objectName, int index=-1); template - QList findItems(QmlGraphicsItem *parent, const QString &objectName); + QList findItems(QGraphicsObject *parent, const QString &objectName); }; class TestObject : public QObject @@ -204,7 +204,7 @@ void tst_QmlGraphicsPathView::items() canvas->execute(); qApp->processEvents(); - QmlGraphicsPathView *pathview = findItem(canvas->root(), "view"); + QmlGraphicsPathView *pathview = findItem(canvas->rootObject(), "view"); QVERIFY(pathview != 0); QCOMPARE(pathview->childItems().count(), model.count()); // assumes all are visible @@ -326,10 +326,10 @@ void tst_QmlGraphicsPathView::dataModel() canvas->execute(); qApp->processEvents(); - QmlGraphicsPathView *pathview = qobject_cast(canvas->root()); + QmlGraphicsPathView *pathview = qobject_cast(canvas->rootObject()); QVERIFY(pathview != 0); - QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); QVERIFY(testObject->error() == false); QmlGraphicsItem *item = findItem(pathview, "wrapper", 0); @@ -352,7 +352,7 @@ void tst_QmlGraphicsPathView::dataModel() QCOMPARE(text->text(), model.name(2)); testObject->setPathItemCount(5); - QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); QVERIFY(testObject->error() == false); itemCount = findItems(pathview, "wrapper").count(); @@ -398,7 +398,7 @@ void tst_QmlGraphicsPathView::pathMoved() canvas->execute(); qApp->processEvents(); - QmlGraphicsPathView *pathview = findItem(canvas->root(), "view"); + QmlGraphicsPathView *pathview = findItem(canvas->rootObject(), "view"); QVERIFY(pathview != 0); QmlGraphicsRectangle *firstItem = findItem(pathview, "wrapper", 0); @@ -430,10 +430,7 @@ QmlView *tst_QmlGraphicsPathView::createView(const QString &filename) QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); - QFile file(filename); - file.open(QFile::ReadOnly); - QString qml = file.readAll(); - canvas->setQml(qml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); return canvas; } @@ -443,7 +440,7 @@ QmlView *tst_QmlGraphicsPathView::createView(const QString &filename) item must also evaluate the {index} expression equal to index */ template -T *tst_QmlGraphicsPathView::findItem(QmlGraphicsItem *parent, const QString &objectName, int index) +T *tst_QmlGraphicsPathView::findItem(QGraphicsObject *parent, const QString &objectName, int index) { const QMetaObject &mo = T::staticMetaObject; //qDebug() << parent->childItems().count() << "children"; @@ -471,7 +468,7 @@ T *tst_QmlGraphicsPathView::findItem(QmlGraphicsItem *parent, const QString &obj } template -QList tst_QmlGraphicsPathView::findItems(QmlGraphicsItem *parent, const QString &objectName) +QList tst_QmlGraphicsPathView::findItems(QGraphicsObject *parent, const QString &objectName) { QList items; const QMetaObject &mo = T::staticMetaObject; diff --git a/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp b/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp index 42d6da9..924ce58 100644 --- a/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp +++ b/tests/auto/declarative/qmlgraphicspositioners/tst_qmlgraphicspositioners.cpp @@ -77,13 +77,13 @@ void tst_QmlGraphicsPositioners::test_horizontal() canvas->execute(); - QmlGraphicsRectangle *one = canvas->root()->findChild("one"); + QmlGraphicsRectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QmlGraphicsRectangle *two = canvas->root()->findChild("two"); + QmlGraphicsRectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QmlGraphicsRectangle *three = canvas->root()->findChild("three"); + QmlGraphicsRectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); QCOMPARE(one->x(), 0.0); @@ -100,13 +100,13 @@ void tst_QmlGraphicsPositioners::test_horizontal_spacing() canvas->execute(); - QmlGraphicsRectangle *one = canvas->root()->findChild("one"); + QmlGraphicsRectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QmlGraphicsRectangle *two = canvas->root()->findChild("two"); + QmlGraphicsRectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QmlGraphicsRectangle *three = canvas->root()->findChild("three"); + QmlGraphicsRectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); QCOMPARE(one->x(), 0.0); @@ -123,13 +123,13 @@ void tst_QmlGraphicsPositioners::test_horizontal_animated() canvas->execute(); - QmlGraphicsRectangle *one = canvas->root()->findChild("one"); + QmlGraphicsRectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QmlGraphicsRectangle *two = canvas->root()->findChild("two"); + QmlGraphicsRectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QmlGraphicsRectangle *three = canvas->root()->findChild("three"); + QmlGraphicsRectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); //Note that they animate in @@ -165,13 +165,13 @@ void tst_QmlGraphicsPositioners::test_vertical() canvas->execute(); - QmlGraphicsRectangle *one = canvas->root()->findChild("one"); + QmlGraphicsRectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QmlGraphicsRectangle *two = canvas->root()->findChild("two"); + QmlGraphicsRectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QmlGraphicsRectangle *three = canvas->root()->findChild("three"); + QmlGraphicsRectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); QCOMPARE(one->x(), 0.0); @@ -188,13 +188,13 @@ void tst_QmlGraphicsPositioners::test_vertical_spacing() canvas->execute(); - QmlGraphicsRectangle *one = canvas->root()->findChild("one"); + QmlGraphicsRectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QmlGraphicsRectangle *two = canvas->root()->findChild("two"); + QmlGraphicsRectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QmlGraphicsRectangle *three = canvas->root()->findChild("three"); + QmlGraphicsRectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); QCOMPARE(one->x(), 0.0); @@ -212,15 +212,15 @@ void tst_QmlGraphicsPositioners::test_vertical_animated() canvas->execute(); //Note that they animate in - QmlGraphicsRectangle *one = canvas->root()->findChild("one"); + QmlGraphicsRectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); QCOMPARE(one->y(), -100.0); - QmlGraphicsRectangle *two = canvas->root()->findChild("two"); + QmlGraphicsRectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); QCOMPARE(two->y(), -100.0); - QmlGraphicsRectangle *three = canvas->root()->findChild("three"); + QmlGraphicsRectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); QCOMPARE(three->y(), -100.0); @@ -253,15 +253,15 @@ void tst_QmlGraphicsPositioners::test_grid() canvas->execute(); - QmlGraphicsRectangle *one = canvas->root()->findChild("one"); + QmlGraphicsRectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QmlGraphicsRectangle *two = canvas->root()->findChild("two"); + QmlGraphicsRectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QmlGraphicsRectangle *three = canvas->root()->findChild("three"); + QmlGraphicsRectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); - QmlGraphicsRectangle *four = canvas->root()->findChild("four"); + QmlGraphicsRectangle *four = canvas->rootObject()->findChild("four"); QVERIFY(four != 0); - QmlGraphicsRectangle *five = canvas->root()->findChild("five"); + QmlGraphicsRectangle *five = canvas->rootObject()->findChild("five"); QVERIFY(five != 0); QCOMPARE(one->x(), 0.0); @@ -282,15 +282,15 @@ void tst_QmlGraphicsPositioners::test_grid_spacing() canvas->execute(); - QmlGraphicsRectangle *one = canvas->root()->findChild("one"); + QmlGraphicsRectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QmlGraphicsRectangle *two = canvas->root()->findChild("two"); + QmlGraphicsRectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QmlGraphicsRectangle *three = canvas->root()->findChild("three"); + QmlGraphicsRectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); - QmlGraphicsRectangle *four = canvas->root()->findChild("four"); + QmlGraphicsRectangle *four = canvas->rootObject()->findChild("four"); QVERIFY(four != 0); - QmlGraphicsRectangle *five = canvas->root()->findChild("five"); + QmlGraphicsRectangle *five = canvas->rootObject()->findChild("five"); QVERIFY(five != 0); QCOMPARE(one->x(), 0.0); @@ -311,27 +311,27 @@ void tst_QmlGraphicsPositioners::test_grid_animated() canvas->execute(); //Note that all animate in - QmlGraphicsRectangle *one = canvas->root()->findChild("one"); + QmlGraphicsRectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); QCOMPARE(one->x(), -100.0); QCOMPARE(one->y(), -100.0); - QmlGraphicsRectangle *two = canvas->root()->findChild("two"); + QmlGraphicsRectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); QCOMPARE(two->x(), -100.0); QCOMPARE(two->y(), -100.0); - QmlGraphicsRectangle *three = canvas->root()->findChild("three"); + QmlGraphicsRectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); QCOMPARE(three->x(), -100.0); QCOMPARE(three->y(), -100.0); - QmlGraphicsRectangle *four = canvas->root()->findChild("four"); + QmlGraphicsRectangle *four = canvas->rootObject()->findChild("four"); QVERIFY(four != 0); QCOMPARE(four->x(), -100.0); QCOMPARE(four->y(), -100.0); - QmlGraphicsRectangle *five = canvas->root()->findChild("five"); + QmlGraphicsRectangle *five = canvas->rootObject()->findChild("five"); QVERIFY(five != 0); QCOMPARE(five->x(), -100.0); QCOMPARE(five->y(), -100.0); @@ -385,13 +385,13 @@ void tst_QmlGraphicsPositioners::test_repeater() canvas->execute(); - QmlGraphicsRectangle *one = canvas->root()->findChild("one"); + QmlGraphicsRectangle *one = canvas->rootObject()->findChild("one"); QVERIFY(one != 0); - QmlGraphicsRectangle *two = canvas->root()->findChild("two"); + QmlGraphicsRectangle *two = canvas->rootObject()->findChild("two"); QVERIFY(two != 0); - QmlGraphicsRectangle *three = canvas->root()->findChild("three"); + QmlGraphicsRectangle *three = canvas->rootObject()->findChild("three"); QVERIFY(three != 0); QCOMPARE(one->x(), 0.0); @@ -406,10 +406,7 @@ QmlView *tst_QmlGraphicsPositioners::createView(const QString &filename) { QmlView *canvas = new QmlView(0); - QFile file(filename); - file.open(QFile::ReadOnly); - QString xml = file.readAll(); - canvas->setQml(xml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); return canvas; } diff --git a/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp b/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp index ef0ca1d..b759ef5 100644 --- a/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp +++ b/tests/auto/declarative/qmlgraphicsrepeater/tst_qmlgraphicsrepeater.cpp @@ -70,7 +70,7 @@ private slots: private: QmlView *createView(const QString &filename); template - T *findItem(QmlGraphicsItem *parent, const QString &id); + T *findItem(QGraphicsObject *parent, const QString &id); }; class TestObject : public QObject @@ -174,11 +174,11 @@ void tst_QmlGraphicsRepeater::numberModel() canvas->execute(); qApp->processEvents(); - QmlGraphicsRepeater *repeater = findItem(canvas->root(), "repeater"); + QmlGraphicsRepeater *repeater = findItem(canvas->rootObject(), "repeater"); QVERIFY(repeater != 0); QCOMPARE(repeater->parentItem()->childItems().count(), 5+1); - QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); QVERIFY(testObject->error() == false); delete canvas; @@ -200,7 +200,7 @@ void tst_QmlGraphicsRepeater::objectList() canvas->execute(); qApp->processEvents(); - QmlGraphicsRepeater *repeater = findItem(canvas->root(), "repeater"); + QmlGraphicsRepeater *repeater = findItem(canvas->rootObject(), "repeater"); QVERIFY(repeater != 0); QCOMPARE(repeater->property("errors").toInt(), 0);//If this fails either they are out of order or can't find the object's data QCOMPARE(repeater->property("instantiated").toInt(), 100); @@ -227,10 +227,10 @@ void tst_QmlGraphicsRepeater::stringList() canvas->execute(); qApp->processEvents(); - QmlGraphicsRepeater *repeater = findItem(canvas->root(), "repeater"); + QmlGraphicsRepeater *repeater = findItem(canvas->rootObject(), "repeater"); QVERIFY(repeater != 0); - QmlGraphicsItem *container = findItem(canvas->root(), "container"); + QmlGraphicsItem *container = findItem(canvas->rootObject(), "container"); QVERIFY(container != 0); QCOMPARE(container->childItems().count(), data.count() + 3); @@ -280,10 +280,10 @@ void tst_QmlGraphicsRepeater::dataModel() canvas->execute(); qApp->processEvents(); - QmlGraphicsRepeater *repeater = findItem(canvas->root(), "repeater"); + QmlGraphicsRepeater *repeater = findItem(canvas->rootObject(), "repeater"); QVERIFY(repeater != 0); - QmlGraphicsItem *container = findItem(canvas->root(), "container"); + QmlGraphicsItem *container = findItem(canvas->rootObject(), "container"); QVERIFY(container != 0); QCOMPARE(container->childItems().count(), 4); @@ -305,16 +305,16 @@ void tst_QmlGraphicsRepeater::itemModel() canvas->execute(); qApp->processEvents(); - QmlGraphicsRepeater *repeater = findItem(canvas->root(), "repeater"); + QmlGraphicsRepeater *repeater = findItem(canvas->rootObject(), "repeater"); QVERIFY(repeater != 0); - QmlGraphicsItem *container = findItem(canvas->root(), "container"); + QmlGraphicsItem *container = findItem(canvas->rootObject(), "container"); QVERIFY(container != 0); QCOMPARE(container->childItems().count(), 1); testObject->setUseModel(true); - QMetaObject::invokeMethod(canvas->root(), "checkProperties"); + QMetaObject::invokeMethod(canvas->rootObject(), "checkProperties"); QVERIFY(testObject->error() == false); QCOMPARE(container->childItems().count(), 4); @@ -331,10 +331,10 @@ void tst_QmlGraphicsRepeater::properties() QmlEngine engine; QmlComponent component(&engine, TEST_FILE("/properties.qml")); - QmlGraphicsItem *root = qobject_cast(component.create()); - QVERIFY(root); + QmlGraphicsItem *rootObject = qobject_cast(component.create()); + QVERIFY(rootObject); - QmlGraphicsRepeater *repeater = findItem(root, "repeater"); + QmlGraphicsRepeater *repeater = findItem(rootObject, "repeater"); QVERIFY(repeater); QSignalSpy modelSpy(repeater, SIGNAL(modelChanged())); @@ -359,16 +359,13 @@ QmlView *tst_QmlGraphicsRepeater::createView(const QString &filename) QmlView *canvas = new QmlView(0); canvas->setFixedSize(240,320); - QFile file(filename); - file.open(QFile::ReadOnly); - QString qml = file.readAll(); - canvas->setQml(qml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); return canvas; } template -T *tst_QmlGraphicsRepeater::findItem(QmlGraphicsItem *parent, const QString &objectName) +T *tst_QmlGraphicsRepeater::findItem(QGraphicsObject *parent, const QString &objectName) { const QMetaObject &mo = T::staticMetaObject; if (mo.cast(parent) && (objectName.isEmpty() || parent->objectName() == objectName)) diff --git a/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp b/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp index a197ced..2b0131b 100644 --- a/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp +++ b/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp @@ -608,8 +608,8 @@ void tst_qmlgraphicstextedit::inputMethodHints() canvas->show(); canvas->setFocus(); - QVERIFY(canvas->root() != 0); - QmlGraphicsTextEdit *textEditObject = qobject_cast(canvas->root()); + QVERIFY(canvas->rootObject() != 0); + QmlGraphicsTextEdit *textEditObject = qobject_cast(canvas->rootObject()); QVERIFY(textEditObject != 0); QVERIFY(textEditObject->inputMethodHints() & Qt::ImhNoPredictiveText); textEditObject->setInputMethodHints(Qt::ImhUppercaseOnly); @@ -622,7 +622,7 @@ void tst_qmlgraphicstextedit::cursorDelegate() view->execute(); view->show(); view->setFocus(); - QmlGraphicsTextEdit *textEditObject = view->root()->findChild("textEditObject"); + QmlGraphicsTextEdit *textEditObject = view->rootObject()->findChild("textEditObject"); QVERIFY(textEditObject != 0); QVERIFY(textEditObject->findChild("cursorInstance")); //Test Delegate gets created @@ -650,40 +650,40 @@ void tst_qmlgraphicstextedit::delegateLoading() server.serveDirectory(SRCDIR "/data/httpslow", TestHTTPServer::Delay); server.serveDirectory(SRCDIR "/data/http"); QmlView* view = new QmlView(0); - view->setUrl(QUrl("http://localhost:42332/cursorHttpTestPass.qml")); + view->setSource(QUrl("http://localhost:42332/cursorHttpTestPass.qml")); view->execute(); view->show(); view->setFocus(); - QTRY_VERIFY(view->root());//Wait for loading to finish. - QmlGraphicsTextEdit *textEditObject = view->root()->findChild("textEditObject"); - // view->root()->dumpObjectTree(); + QTRY_VERIFY(view->rootObject());//Wait for loading to finish. + QmlGraphicsTextEdit *textEditObject = view->rootObject()->findChild("textEditObject"); + // view->rootObject()->dumpObjectTree(); QVERIFY(textEditObject != 0); textEditObject->setFocus(true); QmlGraphicsItem *delegate; - delegate = view->root()->findChild("delegateOkay"); + delegate = view->rootObject()->findChild("delegateOkay"); QVERIFY(delegate); - delegate = view->root()->findChild("delegateSlow"); + delegate = view->rootObject()->findChild("delegateSlow"); QVERIFY(delegate); - view->setUrl(QUrl("http://localhost:42332/cursorHttpTestFail1.qml")); + view->setSource(QUrl("http://localhost:42332/cursorHttpTestFail1.qml")); view->execute(); view->show(); view->setFocus(); - delegate = view->root()->findChild("delegateOkay"); + delegate = view->rootObject()->findChild("delegateOkay"); QVERIFY(delegate); - delegate = view->root()->findChild("delegateFail"); + delegate = view->rootObject()->findChild("delegateFail"); QVERIFY(!delegate); - view->setUrl(QUrl("http://localhost:42332/cursorHttpTestFail2.qml")); + view->setSource(QUrl("http://localhost:42332/cursorHttpTestFail2.qml")); view->execute(); view->show(); view->setFocus(); - delegate = view->root()->findChild("delegateOkay"); + delegate = view->rootObject()->findChild("delegateOkay"); QVERIFY(delegate); - delegate = view->root()->findChild("delegateErrorA"); + delegate = view->rootObject()->findChild("delegateErrorA"); QVERIFY(!delegate); //ErrorB should get a component which is ready but component.create() returns null //Not sure how to accomplish this with QmlGraphicsTextEdits cursor delegate //###This could be a case of overzealous defensive programming - //delegate = view->root()->findChild("delegateErrorB"); + //delegate = view->rootObject()->findChild("delegateErrorB"); //QVERIFY(!delegate); } @@ -698,9 +698,9 @@ void tst_qmlgraphicstextedit::navigation() canvas->show(); canvas->setFocus(); - QVERIFY(canvas->root() != 0); + QVERIFY(canvas->rootObject() != 0); - QmlGraphicsItem *input = qobject_cast(qvariant_cast(canvas->root()->property("myInput"))); + QmlGraphicsItem *input = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); QVERIFY(input != 0); QTRY_VERIFY(input->hasFocus() == true); @@ -721,9 +721,9 @@ void tst_qmlgraphicstextedit::readOnly() canvas->show(); canvas->setFocus(); - QVERIFY(canvas->root() != 0); + QVERIFY(canvas->rootObject() != 0); - QmlGraphicsTextEdit *edit = qobject_cast(qvariant_cast(canvas->root()->property("myInput"))); + QmlGraphicsTextEdit *edit = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); QVERIFY(edit != 0); QTRY_VERIFY(edit->hasFocus() == true); @@ -750,10 +750,7 @@ QmlView *tst_qmlgraphicstextedit::createView(const QString &filename) { QmlView *canvas = new QmlView(0); - QFile file(filename); - file.open(QFile::ReadOnly); - QString xml = file.readAll(); - canvas->setQml(xml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); return canvas; } diff --git a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp index b7ae4a2..d68964b 100644 --- a/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp +++ b/tests/auto/declarative/qmlgraphicstextinput/tst_qmlgraphicstextinput.cpp @@ -352,8 +352,8 @@ void tst_qmlgraphicstextinput::maxLength() canvas->execute(); canvas->show(); canvas->setFocus(); - QVERIFY(canvas->root() != 0); - QmlGraphicsTextInput *textinputObject = qobject_cast(canvas->root()); + QVERIFY(canvas->rootObject() != 0); + QmlGraphicsTextInput *textinputObject = qobject_cast(canvas->rootObject()); QVERIFY(textinputObject != 0); QVERIFY(textinputObject->text().isEmpty()); QVERIFY(textinputObject->maxLength() == 10); @@ -381,8 +381,8 @@ void tst_qmlgraphicstextinput::masks() canvas->execute(); canvas->show(); canvas->setFocus(); - QVERIFY(canvas->root() != 0); - QmlGraphicsTextInput *textinputObject = qobject_cast(canvas->root()); + QVERIFY(canvas->rootObject() != 0); + QmlGraphicsTextInput *textinputObject = qobject_cast(canvas->rootObject()); QVERIFY(textinputObject != 0); QTRY_VERIFY(textinputObject->hasFocus() == true); QVERIFY(textinputObject->text().length() == 0); @@ -407,9 +407,9 @@ void tst_qmlgraphicstextinput::validators() canvas->show(); canvas->setFocus(); - QVERIFY(canvas->root() != 0); + QVERIFY(canvas->rootObject() != 0); - QmlGraphicsTextInput *intInput = qobject_cast(qvariant_cast(canvas->root()->property("intInput"))); + QmlGraphicsTextInput *intInput = qobject_cast(qvariant_cast(canvas->rootObject()->property("intInput"))); QVERIFY(intInput); intInput->setFocus(true); QTRY_VERIFY(intInput->hasFocus()); @@ -430,7 +430,7 @@ void tst_qmlgraphicstextinput::validators() QCOMPARE(intInput->text(), QLatin1String("11")); QCOMPARE(intInput->hasAcceptableInput(), true); - QmlGraphicsTextInput *dblInput = qobject_cast(qvariant_cast(canvas->root()->property("dblInput"))); + QmlGraphicsTextInput *dblInput = qobject_cast(qvariant_cast(canvas->rootObject()->property("dblInput"))); QTRY_VERIFY(dblInput); dblInput->setFocus(true); QVERIFY(dblInput->hasFocus() == true); @@ -459,7 +459,7 @@ void tst_qmlgraphicstextinput::validators() QCOMPARE(dblInput->text(), QLatin1String("12.11")); QCOMPARE(dblInput->hasAcceptableInput(), true); - QmlGraphicsTextInput *strInput = qobject_cast(qvariant_cast(canvas->root()->property("strInput"))); + QmlGraphicsTextInput *strInput = qobject_cast(qvariant_cast(canvas->rootObject()->property("strInput"))); QTRY_VERIFY(strInput); strInput->setFocus(true); QVERIFY(strInput->hasFocus() == true); @@ -497,8 +497,8 @@ void tst_qmlgraphicstextinput::inputMethodHints() canvas->show(); canvas->setFocus(); - QVERIFY(canvas->root() != 0); - QmlGraphicsTextInput *textinputObject = qobject_cast(canvas->root()); + QVERIFY(canvas->rootObject() != 0); + QmlGraphicsTextInput *textinputObject = qobject_cast(canvas->rootObject()); QVERIFY(textinputObject != 0); QVERIFY(textinputObject->inputMethodHints() & Qt::ImhNoPredictiveText); textinputObject->setInputMethodHints(Qt::ImhUppercaseOnly); @@ -517,9 +517,9 @@ void tst_qmlgraphicstextinput::navigation() canvas->show(); canvas->setFocus(); - QVERIFY(canvas->root() != 0); + QVERIFY(canvas->rootObject() != 0); - QmlGraphicsTextInput *input = qobject_cast(qvariant_cast(canvas->root()->property("myInput"))); + QmlGraphicsTextInput *input = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); QVERIFY(input != 0); input->setCursorPosition(0); @@ -549,7 +549,7 @@ void tst_qmlgraphicstextinput::cursorDelegate() view->execute(); view->show(); view->setFocus(); - QmlGraphicsTextInput *textInputObject = view->root()->findChild("textInputObject"); + QmlGraphicsTextInput *textInputObject = view->rootObject()->findChild("textInputObject"); QVERIFY(textInputObject != 0); QVERIFY(textInputObject->findChild("cursorInstance")); //Test Delegate gets created @@ -578,9 +578,9 @@ void tst_qmlgraphicstextinput::readOnly() canvas->show(); canvas->setFocus(); - QVERIFY(canvas->root() != 0); + QVERIFY(canvas->rootObject() != 0); - QmlGraphicsTextInput *input = qobject_cast(qvariant_cast(canvas->root()->property("myInput"))); + QmlGraphicsTextInput *input = qobject_cast(qvariant_cast(canvas->rootObject()->property("myInput"))); QVERIFY(input != 0); QTRY_VERIFY(input->hasFocus() == true); @@ -607,10 +607,7 @@ QmlView *tst_qmlgraphicstextinput::createView(const QString &filename) { QmlView *canvas = new QmlView(0); - QFile file(filename); - file.open(QFile::ReadOnly); - QString xml = file.readAll(); - canvas->setQml(xml, filename); + canvas->setSource(QUrl::fromLocalFile(filename)); return canvas; } diff --git a/tools/qmlviewer/qfxtester.cpp b/tools/qmlviewer/qfxtester.cpp index bd96545..8eceb4c 100644 --- a/tools/qmlviewer/qfxtester.cpp +++ b/tools/qmlviewer/qfxtester.cpp @@ -147,7 +147,7 @@ void QmlGraphicsTester::imagefailure() void QmlGraphicsTester::complete() { if ((options & QmlViewer::TestErrorProperty) && !hasFailed) { - QString e = m_view->root()->property("error").toString(); + QString e = m_view->rootObject()->property("error").toString(); if (!e.isEmpty()) { qWarning() << "Test failed:" << e; hasFailed = true; diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index 7c620ef..3cfbee2 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -80,6 +80,7 @@ #include #include #include +#include #include #include #include @@ -473,13 +474,12 @@ QmlViewer::QmlViewer(QWidget *parent, Qt::WindowFlags flags) canvas = new QmlView(this); canvas->setAttribute(Qt::WA_OpaquePaintEvent); canvas->setAttribute(Qt::WA_NoSystemBackground); - canvas->setContentResizable(!skin || !scaleSkin); + canvas->setResizeMode((!skin || !scaleSkin) ? QmlView::SizeRootObjectToView : QmlView::SizeViewToRootObject); canvas->setFocus(); QObject::connect(canvas, SIGNAL(sceneResized(QSize)), this, SLOT(sceneResized(QSize))); - QObject::connect(canvas, SIGNAL(initialSize(QSize)), this, SLOT(adjustSizeSlot())); - QObject::connect(canvas, SIGNAL(errors(QList)), this, SLOT(executeErrors())); - QObject::connect(canvas, SIGNAL(quit()), QCoreApplication::instance (), SLOT(quit())); + QObject::connect(canvas, SIGNAL(statusChanged(QmlView::Status)), this, SLOT(statusChanged())); + QObject::connect(canvas->engine(), SIGNAL(quit()), QCoreApplication::instance (), SLOT(quit())); if (!(flags & Qt::FramelessWindowHint)) { createMenu(menuBar(),0); @@ -516,11 +516,6 @@ QmlViewer::~QmlViewer() delete namFactory; } -void QmlViewer::adjustSizeSlot() -{ - resize(sizeHint()); -} - QMenuBar *QmlViewer::menuBar() const { #if !defined(Q_OS_SYMBIAN) @@ -731,7 +726,7 @@ void QmlViewer::setScaleSkin() if (scaleSkin) return; scaleSkin = true; - canvas->setContentResizable(!skin || !scaleSkin); + canvas->setResizeMode((!skin || !scaleSkin) ? QmlView::SizeRootObjectToView : QmlView::SizeViewToRootObject); if (skin) { canvas->setFixedSize(canvas->sizeHint()); skin->setScreenSize(canvas->sizeHint()); @@ -744,7 +739,7 @@ void QmlViewer::setScaleView() return; scaleSkin = false; if (skin) { - canvas->setContentResizable(!skin || !scaleSkin); + canvas->setResizeMode((!skin || !scaleSkin) ? QmlView::SizeRootObjectToView : QmlView::SizeViewToRootObject); canvas->setMinimumSize(QSize(0,0)); canvas->setMaximumSize(QSize(16777215,16777215)); canvas->resize(skin->standardScreenSize()); @@ -889,7 +884,8 @@ void QmlViewer::openWgt(const QString& doc) QUrl url(doc); if (url.isRelative()) url = QUrl::fromLocalFile(doc); - canvas->reset(); + delete canvas->rootObject(); + canvas->engine()->clearComponentCache(); QNetworkAccessManager * nam = canvas->engine()->networkAccessManager(); wgtreply = nam->get(QNetworkRequest(url)); connect(wgtreply,SIGNAL(finished()),this,SLOT(unpackWgt())); @@ -971,7 +967,7 @@ void QmlViewer::unpackWgt() void QmlViewer::openFile() { - QString cur = canvas->url().toLocalFile(); + QString cur = canvas->source().toLocalFile(); if (useQmlFileBrowser) { openQml("qrc:/content/Browser.qml"); } else { @@ -983,9 +979,13 @@ void QmlViewer::openFile() } } -void QmlViewer::executeErrors() +void QmlViewer::statusChanged() { - if (tester) tester->executefailure(); + if (canvas->status() == QmlView::Error && tester) + tester->executefailure(); + + if (canvas->status() == QmlView::Ready) + resize(sizeHint()); } void QmlViewer::launch(const QString& file_or_url) @@ -1008,7 +1008,8 @@ void QmlViewer::openQml(const QString& file_or_url) if (!m_script.isEmpty()) tester = new QmlGraphicsTester(m_script, m_scriptOptions, canvas); - canvas->reset(); + delete canvas->rootObject(); + canvas->engine()->clearComponentCache(); QmlContext *ctxt = canvas->rootContext(); ctxt->setContextProperty("qmlViewer", this); #ifdef Q_OS_SYMBIAN @@ -1058,7 +1059,7 @@ void QmlViewer::openQml(const QString& file_or_url) } } - canvas->setUrl(url); + canvas->setSource(url); QTime t; t.start(); @@ -1125,7 +1126,7 @@ void QmlViewer::setSkin(const QString& skinDirOrName) skin->deleteLater(); } - canvas->setContentResizable(!skin || !scaleSkin); + canvas->setResizeMode((!skin || !scaleSkin) ? QmlView::SizeRootObjectToView : QmlView::SizeViewToRootObject); DeviceSkinParameters parameters; if (!skinDirectory.isEmpty() && parameters.read(skinDirectory,DeviceSkinParameters::ReadAll,&err)) { diff --git a/tools/qmlviewer/qmlviewer.h b/tools/qmlviewer/qmlviewer.h index 6b05584..fbb5aa5 100644 --- a/tools/qmlviewer/qmlviewer.h +++ b/tools/qmlviewer/qmlviewer.h @@ -116,7 +116,7 @@ public slots: void showProxySettings (); void proxySettingsChanged (); void setScaleView(); - void executeErrors(); + void statusChanged(); void setSlowMode(bool); void launch(const QString &); @@ -132,7 +132,6 @@ private slots: void chooseRecordingOptions(); void pickRecordingFile(); void setScaleSkin(); - void adjustSizeSlot(); void setPortrait(); void setLandscape(); void toggleOrientation(); -- cgit v0.12 From 27a94129261c47629d3cf0b6493e46306fb42cad Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 18 Feb 2010 17:20:59 +1000 Subject: Ensure visibleIndex and currentIndex are updated on itemsMoved(). --- .../graphicsitems/qmlgraphicsgridview.cpp | 27 ++++++++++++++++++++-- 1 file changed, 25 insertions(+), 2 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp index ee711b4..0edf590 100644 --- a/src/declarative/graphicsitems/qmlgraphicsgridview.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsgridview.cpp @@ -1656,9 +1656,32 @@ void QmlGraphicsGridView::itemsMoved(int from, int to, int count) ++endIndex; } + // update visibleIndex + for (it = d->visibleItems.begin(); it != d->visibleItems.end(); ++it) { + if ((*it)->index != -1) { + d->visibleIndex = (*it)->index; + break; + } + } + + // Fix current index + if (d->currentIndex >= 0 && d->currentItem) { + int oldCurrent = d->currentIndex; + d->currentIndex = d->model->indexOf(d->currentItem->item, this); + if (oldCurrent != d->currentIndex) { + d->currentItem->index = d->currentIndex; + emit currentIndexChanged(); + } + } + // Whatever moved items remain are no longer visible items. - while (moved.count()) - d->releaseItem(moved.take(moved.begin().key())); + while (moved.count()) { + int idx = moved.begin().key(); + FxGridItem *item = moved.take(idx); + if (item->item == d->currentItem->item) + item->setPosition(d->colPosAt(idx), d->rowPosAt(idx)); + d->releaseItem(item); + } d->layout(removedBeforeVisible); } -- cgit v0.12 From 47fb252279aa88631412a7422de0a30f40b96c17 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Thu, 18 Feb 2010 17:40:42 +1000 Subject: Doc: onExited, onEntered only work when button pressed or hoverEnabled Task-number: QTBUG-8305 --- src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp index 003c18d..e6225e1 100644 --- a/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsmouseregion.cpp @@ -172,12 +172,24 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate() \qmlsignal MouseRegion::onEntered() This handler is called when the mouse enters the mouse region. + + By default the onEntered handler is only called while a button is + pressed. Setting hoverEnabled to true enables handling of + onExited when no mouse button is pressed. + + \sa hoverEnabled */ /*! \qmlsignal MouseRegion::onExited() This handler is called when the mouse exists the mouse region. + + By default the onExited handler is only called while a button is + pressed. Setting hoverEnabled to true enables handling of + onExited when no mouse button is pressed. + + \sa hoverEnabled */ /*! @@ -189,6 +201,10 @@ QmlGraphicsMouseRegionPrivate::~QmlGraphicsMouseRegionPrivate() position, and any buttons currently pressed. The \e accepted property of the MouseEvent parameter is ignored in this handler. + + By default the onPositionChanged handler is only called while a button is + pressed. Setting hoverEnabled to true enables handling of + onPositionChanged when no mouse button is pressed. */ /*! -- cgit v0.12 From 22f5b45d63d5977dbb1207aeb0f5013223e8e7f5 Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Thu, 18 Feb 2010 18:12:10 +1000 Subject: Removed incorrect Q_UNUSED() macro from QmlPropertyAnimation::transition --- src/declarative/util/qmlanimation.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index 249bd8e..ff16e08 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -2302,7 +2302,6 @@ void QmlPropertyAnimation::transition(QmlStateActions &actions, TransitionDirection direction) { Q_D(QmlPropertyAnimation); - Q_UNUSED(direction); QStringList props = d->properties.isEmpty() ? QStringList() : d->properties.split(QLatin1Char(',')); for (int ii = 0; ii < props.count(); ++ii) -- cgit v0.12 From 21df89dae6c0646ec5066efaea0ec2986c7c4588 Mon Sep 17 00:00:00 2001 From: Henrik Hartz Date: Thu, 18 Feb 2010 12:16:28 +0100 Subject: Doc: reformulate why we build a button --- doc/src/declarative/advtutorial1.qdoc | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/doc/src/declarative/advtutorial1.qdoc b/doc/src/declarative/advtutorial1.qdoc index 86d14ad..09645fd 100644 --- a/doc/src/declarative/advtutorial1.qdoc +++ b/doc/src/declarative/advtutorial1.qdoc @@ -55,8 +55,9 @@ This gives you a basic game window, with room for the game canvas. A new game button and room to display the score. The one thing you may not recognize here is the \l SystemPalette item. This item provides access to the Qt system palette and is used to make the button look more like a system button (for exact native -feel you would use a \l QPushButton). Since we want a fully QML button, and QML does -not include a button, we had to write our own. Below is the code which we wrote to do this: +feel you would use a \l QPushButton). Since we want a fully functional button, +we use the QML elements Text and MouseRegion inside a Rectangle to assemble a +button. Below is the code which we wrote to do this: \snippet declarative/tutorials/samegame/samegame1/Button.qml 0 -- cgit v0.12 From fa1b0faa1ede809dae3c46ecfce0ef760b887b7c Mon Sep 17 00:00:00 2001 From: hjk Date: Wed, 17 Feb 2010 16:09:42 +0100 Subject: Compile fix with namepaces Task-number: QTBUG-8205 --- src/declarative/qml/qml.h | 4 +++- src/declarative/qml/qmlsqldatabase_p.h | 3 +++ src/declarative/qml/qmlxmlhttprequest_p.h | 3 +++ tools/qmlviewer/qmlviewer.cpp | 4 ++-- 4 files changed, 11 insertions(+), 3 deletions(-) diff --git a/src/declarative/qml/qml.h b/src/declarative/qml/qml.h index c009093..f2b6b08 100644 --- a/src/declarative/qml/qml.h +++ b/src/declarative/qml/qml.h @@ -77,6 +77,7 @@ enum { /* TYPEINFO flags */ }; #define QML_DECLARE_TYPEINFO(TYPE, FLAGS) \ +QT_BEGIN_NAMESPACE \ template <> \ class QmlTypeInfo \ { \ @@ -84,7 +85,8 @@ public: \ enum { \ hasAttachedProperties = (((FLAGS) & QML_HAS_ATTACHED_PROPERTIES) == QML_HAS_ATTACHED_PROPERTIES) \ }; \ -}; +}; \ +QT_END_NAMESPACE QT_BEGIN_NAMESPACE diff --git a/src/declarative/qml/qmlsqldatabase_p.h b/src/declarative/qml/qmlsqldatabase_p.h index 9965a2b..f7d2078 100644 --- a/src/declarative/qml/qmlsqldatabase_p.h +++ b/src/declarative/qml/qmlsqldatabase_p.h @@ -53,6 +53,9 @@ // // We mean it. // + +#include + QT_BEGIN_NAMESPACE class QScriptEngine; diff --git a/src/declarative/qml/qmlxmlhttprequest_p.h b/src/declarative/qml/qmlxmlhttprequest_p.h index 3a81278..11ed027 100644 --- a/src/declarative/qml/qmlxmlhttprequest_p.h +++ b/src/declarative/qml/qmlxmlhttprequest_p.h @@ -53,6 +53,9 @@ // // We mean it. // + +#include + QT_BEGIN_NAMESPACE class QScriptEngine; diff --git a/tools/qmlviewer/qmlviewer.cpp b/tools/qmlviewer/qmlviewer.cpp index 3cfbee2..cb1bef4 100644 --- a/tools/qmlviewer/qmlviewer.cpp +++ b/tools/qmlviewer/qmlviewer.cpp @@ -135,10 +135,10 @@ QT_END_NAMESPACE QML_DECLARE_TYPE(Screen) -QT_BEGIN_NAMESPACE - QML_DEFINE_TYPE(QmlViewer, 1, 0, Screen, Screen) +QT_BEGIN_NAMESPACE + class SizedMenuBar : public QMenuBar { Q_OBJECT -- cgit v0.12 From 2eb7c3770307fc42f83ba2526270b7acb51802bf Mon Sep 17 00:00:00 2001 From: Kai Koehne Date: Thu, 18 Feb 2010 16:59:12 +0100 Subject: Make QmlDom API internal It's still used by QmlDesigner, therefore the symbols have to be exported. Task-number: QTBUG-6845 --- src/declarative/qml/qml.pri | 2 +- src/declarative/qml/qmldom.cpp | 2 +- src/declarative/qml/qmldom.h | 349 --------------------------- src/declarative/qml/qmldom_p.h | 319 +++++++++++++++++++----- src/declarative/qml/qmldom_p_p.h | 157 ++++++++++++ tests/auto/declarative/qmldom/tst_qmldom.cpp | 2 +- 6 files changed, 421 insertions(+), 410 deletions(-) delete mode 100644 src/declarative/qml/qmldom.h create mode 100644 src/declarative/qml/qmldom_p_p.h diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index 021ef9e..a8df61e 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -76,8 +76,8 @@ HEADERS += \ $$PWD/qmlengine_p.h \ $$PWD/qmlexpression_p.h \ $$PWD/qmlprivate.h \ - $$PWD/qmldom.h \ $$PWD/qmldom_p.h \ + $$PWD/qmldom_p_p.h \ $$PWD/qmlrefcount_p.h \ $$PWD/qmlmetatype.h \ $$PWD/qmlengine.h \ diff --git a/src/declarative/qml/qmldom.cpp b/src/declarative/qml/qmldom.cpp index 52530db..259d57d 100644 --- a/src/declarative/qml/qmldom.cpp +++ b/src/declarative/qml/qmldom.cpp @@ -39,8 +39,8 @@ ** ****************************************************************************/ -#include "qmldom.h" #include "qmldom_p.h" +#include "qmldom_p_p.h" #include "qmlcompositetypedata_p.h" #include "qmlcompiler_p.h" diff --git a/src/declarative/qml/qmldom.h b/src/declarative/qml/qmldom.h deleted file mode 100644 index 8442f49..0000000 --- a/src/declarative/qml/qmldom.h +++ /dev/null @@ -1,349 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2009 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 QMLDOM_H -#define QMLDOM_H - -#include "qmlerror.h" - -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QString; -class QByteArray; -class QmlDomObject; -class QmlDomList; -class QmlDomValue; -class QmlEngine; -class QmlDomComponent; -class QmlDomImport; -class QIODevice; - -class QmlDomDocumentPrivate; - -class Q_DECLARATIVE_EXPORT QmlDomDocument -{ -public: - QmlDomDocument(); - QmlDomDocument(const QmlDomDocument &); - ~QmlDomDocument(); - QmlDomDocument &operator=(const QmlDomDocument &); - - QList imports() const; - - QList errors() const; - bool load(QmlEngine *, const QByteArray &, const QUrl & = QUrl()); - - QmlDomObject rootObject() const; - -private: - QSharedDataPointer d; -}; - -class QmlDomPropertyPrivate; -class Q_DECLARATIVE_EXPORT QmlDomProperty -{ -public: - QmlDomProperty(); - QmlDomProperty(const QmlDomProperty &); - ~QmlDomProperty(); - QmlDomProperty &operator=(const QmlDomProperty &); - - bool isValid() const; - - QByteArray propertyName() const; - QList propertyNameParts() const; - - bool isDefaultProperty() const; - - QmlDomValue value() const; - - int position() const; - int length() const; - -private: - friend class QmlDomObject; - friend class QmlDomDynamicProperty; - QSharedDataPointer d; -}; - -class QmlDomDynamicPropertyPrivate; -class Q_DECLARATIVE_EXPORT QmlDomDynamicProperty -{ -public: - QmlDomDynamicProperty(); - QmlDomDynamicProperty(const QmlDomDynamicProperty &); - ~QmlDomDynamicProperty(); - QmlDomDynamicProperty &operator=(const QmlDomDynamicProperty &); - - bool isValid() const; - - QByteArray propertyName() const; - int propertyType() const; - QByteArray propertyTypeName() const; - - bool isDefaultProperty() const; - QmlDomProperty defaultValue() const; - - bool isAlias() const; - - int position() const; - int length() const; - -private: - friend class QmlDomObject; - QSharedDataPointer d; -}; - -class QmlDomObjectPrivate; -class Q_DECLARATIVE_EXPORT QmlDomObject -{ -public: - QmlDomObject(); - QmlDomObject(const QmlDomObject &); - ~QmlDomObject(); - QmlDomObject &operator=(const QmlDomObject &); - - bool isValid() const; - - QByteArray objectType() const; - QByteArray objectClassName() const; - - int objectTypeMajorVersion() const; - int objectTypeMinorVersion() const; - - QString objectId() const; - - QList properties() const; - QmlDomProperty property(const QByteArray &) const; - - QList dynamicProperties() const; - QmlDomDynamicProperty dynamicProperty(const QByteArray &) const; - - bool isCustomType() const; - QByteArray customTypeData() const; - - bool isComponent() const; - QmlDomComponent toComponent() const; - - int position() const; - int length() const; - - QUrl url() const; -private: - friend class QmlDomDocument; - friend class QmlDomComponent; - friend class QmlDomValue; - friend class QmlDomValueValueSource; - friend class QmlDomValueValueInterceptor; - QSharedDataPointer d; -}; - -class QmlDomValuePrivate; -class QmlDomBasicValuePrivate; -class Q_DECLARATIVE_EXPORT QmlDomValueLiteral -{ -public: - QmlDomValueLiteral(); - QmlDomValueLiteral(const QmlDomValueLiteral &); - ~QmlDomValueLiteral(); - QmlDomValueLiteral &operator=(const QmlDomValueLiteral &); - - QString literal() const; - -private: - friend class QmlDomValue; - QSharedDataPointer d; -}; - -class Q_DECLARATIVE_EXPORT QmlDomValueBinding -{ -public: - QmlDomValueBinding(); - QmlDomValueBinding(const QmlDomValueBinding &); - ~QmlDomValueBinding(); - QmlDomValueBinding &operator=(const QmlDomValueBinding &); - - QString binding() const; - -private: - friend class QmlDomValue; - QSharedDataPointer d; -}; - -class Q_DECLARATIVE_EXPORT QmlDomValueValueSource -{ -public: - QmlDomValueValueSource(); - QmlDomValueValueSource(const QmlDomValueValueSource &); - ~QmlDomValueValueSource(); - QmlDomValueValueSource &operator=(const QmlDomValueValueSource &); - - QmlDomObject object() const; - -private: - friend class QmlDomValue; - QSharedDataPointer d; -}; - -class Q_DECLARATIVE_EXPORT QmlDomValueValueInterceptor -{ -public: - QmlDomValueValueInterceptor(); - QmlDomValueValueInterceptor(const QmlDomValueValueInterceptor &); - ~QmlDomValueValueInterceptor(); - QmlDomValueValueInterceptor &operator=(const QmlDomValueValueInterceptor &); - - QmlDomObject object() const; - -private: - friend class QmlDomValue; - QSharedDataPointer d; -}; - - -class Q_DECLARATIVE_EXPORT QmlDomComponent : public QmlDomObject -{ -public: - QmlDomComponent(); - QmlDomComponent(const QmlDomComponent &); - ~QmlDomComponent(); - QmlDomComponent &operator=(const QmlDomComponent &); - - QmlDomObject componentRoot() const; -}; - -class Q_DECLARATIVE_EXPORT QmlDomValue -{ -public: - enum Type { - Invalid, - Literal, - PropertyBinding, - ValueSource, - ValueInterceptor, - Object, - List - }; - - QmlDomValue(); - QmlDomValue(const QmlDomValue &); - ~QmlDomValue(); - QmlDomValue &operator=(const QmlDomValue &); - - Type type() const; - - bool isInvalid() const; - bool isLiteral() const; - bool isBinding() const; - bool isValueSource() const; - bool isValueInterceptor() const; - bool isObject() const; - bool isList() const; - - QmlDomValueLiteral toLiteral() const; - QmlDomValueBinding toBinding() const; - QmlDomValueValueSource toValueSource() const; - QmlDomValueValueInterceptor toValueInterceptor() const; - QmlDomObject toObject() const; - QmlDomList toList() const; - - int position() const; - int length() const; - -private: - friend class QmlDomProperty; - friend class QmlDomList; - QSharedDataPointer d; -}; - -class Q_DECLARATIVE_EXPORT QmlDomList -{ -public: - QmlDomList(); - QmlDomList(const QmlDomList &); - ~QmlDomList(); - QmlDomList &operator=(const QmlDomList &); - - QList values() const; - - int position() const; - int length() const; - - QList commaPositions() const; - -private: - friend class QmlDomValue; - QSharedDataPointer d; -}; - -class QmlDomImportPrivate; -class Q_DECLARATIVE_EXPORT QmlDomImport -{ -public: - enum Type { Library, File }; - - QmlDomImport(); - QmlDomImport(const QmlDomImport &); - ~QmlDomImport(); - QmlDomImport &operator=(const QmlDomImport &); - - Type type() const; - QString uri() const; - QString version() const; - QString qualifier() const; - -private: - friend class QmlDomDocument; - QSharedDataPointer d; -}; - -QT_END_NAMESPACE - -QT_END_HEADER - -#endif // QMLDOM_H diff --git a/src/declarative/qml/qmldom_p.h b/src/declarative/qml/qmldom_p.h index df6a980..a823c69 100644 --- a/src/declarative/qml/qmldom_p.h +++ b/src/declarative/qml/qmldom_p.h @@ -53,105 +53,308 @@ // We mean it. // -#include "qmlparser_p.h" +#include "qmlerror.h" -#include +#include +#include + +QT_BEGIN_HEADER QT_BEGIN_NAMESPACE -class QmlDomDocumentPrivate : public QSharedData +QT_MODULE(Declarative) + +class QString; +class QByteArray; +class QmlDomObject; +class QmlDomList; +class QmlDomValue; +class QmlEngine; +class QmlDomComponent; +class QmlDomImport; +class QIODevice; + +class QmlDomDocumentPrivate; + +class Q_DECLARATIVE_EXPORT QmlDomDocument { public: - QmlDomDocumentPrivate(); - QmlDomDocumentPrivate(const QmlDomDocumentPrivate &o) - : QSharedData(o) { qFatal("Not impl"); } - ~QmlDomDocumentPrivate(); - - QList errors; - QList imports; - QmlParser::Object *root; - QList automaticSemicolonOffsets; + QmlDomDocument(); + QmlDomDocument(const QmlDomDocument &); + ~QmlDomDocument(); + QmlDomDocument &operator=(const QmlDomDocument &); + + QList imports() const; + + QList errors() const; + bool load(QmlEngine *, const QByteArray &, const QUrl & = QUrl()); + + QmlDomObject rootObject() const; + +private: + QSharedDataPointer d; +}; + +class QmlDomPropertyPrivate; +class Q_DECLARATIVE_EXPORT QmlDomProperty +{ +public: + QmlDomProperty(); + QmlDomProperty(const QmlDomProperty &); + ~QmlDomProperty(); + QmlDomProperty &operator=(const QmlDomProperty &); + + bool isValid() const; + + QByteArray propertyName() const; + QList propertyNameParts() const; + + bool isDefaultProperty() const; + + QmlDomValue value() const; + + int position() const; + int length() const; + +private: + friend class QmlDomObject; + friend class QmlDomDynamicProperty; + QSharedDataPointer d; }; -class QmlDomObjectPrivate : public QSharedData +class QmlDomDynamicPropertyPrivate; +class Q_DECLARATIVE_EXPORT QmlDomDynamicProperty { public: - QmlDomObjectPrivate(); - QmlDomObjectPrivate(const QmlDomObjectPrivate &o) - : QSharedData(o) { qFatal("Not impl"); } - ~QmlDomObjectPrivate(); + QmlDomDynamicProperty(); + QmlDomDynamicProperty(const QmlDomDynamicProperty &); + ~QmlDomDynamicProperty(); + QmlDomDynamicProperty &operator=(const QmlDomDynamicProperty &); + + bool isValid() const; + + QByteArray propertyName() const; + int propertyType() const; + QByteArray propertyTypeName() const; + + bool isDefaultProperty() const; + QmlDomProperty defaultValue() const; + + bool isAlias() const; - typedef QList > Properties; - Properties properties() const; - Properties properties(QmlParser::Property *) const; + int position() const; + int length() const; - QmlParser::Object *object; +private: + friend class QmlDomObject; + QSharedDataPointer d; }; -class QmlDomPropertyPrivate : public QSharedData +class QmlDomObjectPrivate; +class Q_DECLARATIVE_EXPORT QmlDomObject { public: - QmlDomPropertyPrivate(); - QmlDomPropertyPrivate(const QmlDomPropertyPrivate &o) - : QSharedData(o) { qFatal("Not impl"); } - ~QmlDomPropertyPrivate(); + QmlDomObject(); + QmlDomObject(const QmlDomObject &); + ~QmlDomObject(); + QmlDomObject &operator=(const QmlDomObject &); + + bool isValid() const; + + QByteArray objectType() const; + QByteArray objectClassName() const; + + int objectTypeMajorVersion() const; + int objectTypeMinorVersion() const; + + QString objectId() const; - QByteArray propertyName; - QmlParser::Property *property; + QList properties() const; + QmlDomProperty property(const QByteArray &) const; + + QList dynamicProperties() const; + QmlDomDynamicProperty dynamicProperty(const QByteArray &) const; + + bool isCustomType() const; + QByteArray customTypeData() const; + + bool isComponent() const; + QmlDomComponent toComponent() const; + + int position() const; + int length() const; + + QUrl url() const; +private: + friend class QmlDomDocument; + friend class QmlDomComponent; + friend class QmlDomValue; + friend class QmlDomValueValueSource; + friend class QmlDomValueValueInterceptor; + QSharedDataPointer d; }; -class QmlDomDynamicPropertyPrivate : public QSharedData +class QmlDomValuePrivate; +class QmlDomBasicValuePrivate; +class Q_DECLARATIVE_EXPORT QmlDomValueLiteral { public: - QmlDomDynamicPropertyPrivate(); - QmlDomDynamicPropertyPrivate(const QmlDomDynamicPropertyPrivate &o) - : QSharedData(o) { qFatal("Not impl"); } - ~QmlDomDynamicPropertyPrivate(); + QmlDomValueLiteral(); + QmlDomValueLiteral(const QmlDomValueLiteral &); + ~QmlDomValueLiteral(); + QmlDomValueLiteral &operator=(const QmlDomValueLiteral &); + + QString literal() const; - bool valid; - QmlParser::Object::DynamicProperty property; +private: + friend class QmlDomValue; + QSharedDataPointer d; }; -class QmlDomValuePrivate : public QSharedData +class Q_DECLARATIVE_EXPORT QmlDomValueBinding { public: - QmlDomValuePrivate(); - QmlDomValuePrivate(const QmlDomValuePrivate &o) - : QSharedData(o) { qFatal("Not impl"); } - ~QmlDomValuePrivate(); + QmlDomValueBinding(); + QmlDomValueBinding(const QmlDomValueBinding &); + ~QmlDomValueBinding(); + QmlDomValueBinding &operator=(const QmlDomValueBinding &); - QmlParser::Property *property; - QmlParser::Value *value; + QString binding() const; + +private: + friend class QmlDomValue; + QSharedDataPointer d; }; -class QmlDomBasicValuePrivate : public QSharedData +class Q_DECLARATIVE_EXPORT QmlDomValueValueSource { public: - QmlDomBasicValuePrivate(); - QmlDomBasicValuePrivate(const QmlDomBasicValuePrivate &o) - : QSharedData(o) { qFatal("Not impl"); } - ~QmlDomBasicValuePrivate(); + QmlDomValueValueSource(); + QmlDomValueValueSource(const QmlDomValueValueSource &); + ~QmlDomValueValueSource(); + QmlDomValueValueSource &operator=(const QmlDomValueValueSource &); + + QmlDomObject object() const; - QmlParser::Value *value; +private: + friend class QmlDomValue; + QSharedDataPointer d; }; -class QmlDomImportPrivate : public QSharedData +class Q_DECLARATIVE_EXPORT QmlDomValueValueInterceptor { public: - QmlDomImportPrivate(); - QmlDomImportPrivate(const QmlDomImportPrivate &o) - : QSharedData(o) { qFatal("Not impl"); } - ~QmlDomImportPrivate(); + QmlDomValueValueInterceptor(); + QmlDomValueValueInterceptor(const QmlDomValueValueInterceptor &); + ~QmlDomValueValueInterceptor(); + QmlDomValueValueInterceptor &operator=(const QmlDomValueValueInterceptor &); + QmlDomObject object() const; + +private: + friend class QmlDomValue; + QSharedDataPointer d; +}; + + +class Q_DECLARATIVE_EXPORT QmlDomComponent : public QmlDomObject +{ +public: + QmlDomComponent(); + QmlDomComponent(const QmlDomComponent &); + ~QmlDomComponent(); + QmlDomComponent &operator=(const QmlDomComponent &); + + QmlDomObject componentRoot() const; +}; + +class Q_DECLARATIVE_EXPORT QmlDomValue +{ +public: + enum Type { + Invalid, + Literal, + PropertyBinding, + ValueSource, + ValueInterceptor, + Object, + List + }; + + QmlDomValue(); + QmlDomValue(const QmlDomValue &); + ~QmlDomValue(); + QmlDomValue &operator=(const QmlDomValue &); + + Type type() const; + + bool isInvalid() const; + bool isLiteral() const; + bool isBinding() const; + bool isValueSource() const; + bool isValueInterceptor() const; + bool isObject() const; + bool isList() const; + + QmlDomValueLiteral toLiteral() const; + QmlDomValueBinding toBinding() const; + QmlDomValueValueSource toValueSource() const; + QmlDomValueValueInterceptor toValueInterceptor() const; + QmlDomObject toObject() const; + QmlDomList toList() const; + + int position() const; + int length() const; + +private: + friend class QmlDomProperty; + friend class QmlDomList; + QSharedDataPointer d; +}; + +class Q_DECLARATIVE_EXPORT QmlDomList +{ +public: + QmlDomList(); + QmlDomList(const QmlDomList &); + ~QmlDomList(); + QmlDomList &operator=(const QmlDomList &); + + QList values() const; + + int position() const; + int length() const; + + QList commaPositions() const; + +private: + friend class QmlDomValue; + QSharedDataPointer d; +}; + +class QmlDomImportPrivate; +class Q_DECLARATIVE_EXPORT QmlDomImport +{ +public: enum Type { Library, File }; - Type type; - QString uri; - QString version; - QString qualifier; + QmlDomImport(); + QmlDomImport(const QmlDomImport &); + ~QmlDomImport(); + QmlDomImport &operator=(const QmlDomImport &); + + Type type() const; + QString uri() const; + QString version() const; + QString qualifier() const; + +private: + friend class QmlDomDocument; + QSharedDataPointer d; }; QT_END_NAMESPACE -#endif // QMLDOM_P_H +QT_END_HEADER +#endif // QMLDOM_P_H diff --git a/src/declarative/qml/qmldom_p_p.h b/src/declarative/qml/qmldom_p_p.h new file mode 100644 index 0000000..9d955b0 --- /dev/null +++ b/src/declarative/qml/qmldom_p_p.h @@ -0,0 +1,157 @@ +/**************************************************************************** +** +** Copyright (C) 2009 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 QMLDOM_P_P_H +#define QMLDOM_P_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 "qmlparser_p.h" + +#include + +QT_BEGIN_NAMESPACE + +class QmlDomDocumentPrivate : public QSharedData +{ +public: + QmlDomDocumentPrivate(); + QmlDomDocumentPrivate(const QmlDomDocumentPrivate &o) + : QSharedData(o) { qFatal("Not impl"); } + ~QmlDomDocumentPrivate(); + + QList errors; + QList imports; + QmlParser::Object *root; + QList automaticSemicolonOffsets; +}; + +class QmlDomObjectPrivate : public QSharedData +{ +public: + QmlDomObjectPrivate(); + QmlDomObjectPrivate(const QmlDomObjectPrivate &o) + : QSharedData(o) { qFatal("Not impl"); } + ~QmlDomObjectPrivate(); + + typedef QList > Properties; + Properties properties() const; + Properties properties(QmlParser::Property *) const; + + QmlParser::Object *object; +}; + +class QmlDomPropertyPrivate : public QSharedData +{ +public: + QmlDomPropertyPrivate(); + QmlDomPropertyPrivate(const QmlDomPropertyPrivate &o) + : QSharedData(o) { qFatal("Not impl"); } + ~QmlDomPropertyPrivate(); + + QByteArray propertyName; + QmlParser::Property *property; +}; + +class QmlDomDynamicPropertyPrivate : public QSharedData +{ +public: + QmlDomDynamicPropertyPrivate(); + QmlDomDynamicPropertyPrivate(const QmlDomDynamicPropertyPrivate &o) + : QSharedData(o) { qFatal("Not impl"); } + ~QmlDomDynamicPropertyPrivate(); + + bool valid; + QmlParser::Object::DynamicProperty property; +}; + +class QmlDomValuePrivate : public QSharedData +{ +public: + QmlDomValuePrivate(); + QmlDomValuePrivate(const QmlDomValuePrivate &o) + : QSharedData(o) { qFatal("Not impl"); } + ~QmlDomValuePrivate(); + + QmlParser::Property *property; + QmlParser::Value *value; +}; + +class QmlDomBasicValuePrivate : public QSharedData +{ +public: + QmlDomBasicValuePrivate(); + QmlDomBasicValuePrivate(const QmlDomBasicValuePrivate &o) + : QSharedData(o) { qFatal("Not impl"); } + ~QmlDomBasicValuePrivate(); + + QmlParser::Value *value; +}; + +class QmlDomImportPrivate : public QSharedData +{ +public: + QmlDomImportPrivate(); + QmlDomImportPrivate(const QmlDomImportPrivate &o) + : QSharedData(o) { qFatal("Not impl"); } + ~QmlDomImportPrivate(); + + enum Type { Library, File }; + + Type type; + QString uri; + QString version; + QString qualifier; +}; + +QT_END_NAMESPACE + +#endif // QMLDOM_P_P_H + diff --git a/tests/auto/declarative/qmldom/tst_qmldom.cpp b/tests/auto/declarative/qmldom/tst_qmldom.cpp index eb4d419..2ff427c 100644 --- a/tests/auto/declarative/qmldom/tst_qmldom.cpp +++ b/tests/auto/declarative/qmldom/tst_qmldom.cpp @@ -41,7 +41,7 @@ #include #include #include -#include +#include #include #include -- cgit v0.12 From efe3909d4ebfc08384a3762635b4217f18eeaf69 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 19 Feb 2010 09:46:03 +1000 Subject: Add pixmap benchmarks and make cached rounded rect the same as Rectangle. --- .../benchmarks/declarative/painting/data/63x63.png | Bin 0 -> 3077 bytes .../declarative/painting/data/63x63_opaque.png | Bin 0 -> 3440 bytes .../benchmarks/declarative/painting/data/64x64.png | Bin 0 -> 3101 bytes .../declarative/painting/data/64x64_opaque.png | Bin 0 -> 3588 bytes .../declarative/painting/paintbenchmark.cpp | 116 ++++++++++++++++++--- 5 files changed, 102 insertions(+), 14 deletions(-) create mode 100644 tests/benchmarks/declarative/painting/data/63x63.png create mode 100644 tests/benchmarks/declarative/painting/data/63x63_opaque.png create mode 100644 tests/benchmarks/declarative/painting/data/64x64.png create mode 100644 tests/benchmarks/declarative/painting/data/64x64_opaque.png diff --git a/tests/benchmarks/declarative/painting/data/63x63.png b/tests/benchmarks/declarative/painting/data/63x63.png new file mode 100644 index 0000000..d9efda8 Binary files /dev/null and b/tests/benchmarks/declarative/painting/data/63x63.png differ diff --git a/tests/benchmarks/declarative/painting/data/63x63_opaque.png b/tests/benchmarks/declarative/painting/data/63x63_opaque.png new file mode 100644 index 0000000..d142908 Binary files /dev/null and b/tests/benchmarks/declarative/painting/data/63x63_opaque.png differ diff --git a/tests/benchmarks/declarative/painting/data/64x64.png b/tests/benchmarks/declarative/painting/data/64x64.png new file mode 100644 index 0000000..b149f33 Binary files /dev/null and b/tests/benchmarks/declarative/painting/data/64x64.png differ diff --git a/tests/benchmarks/declarative/painting/data/64x64_opaque.png b/tests/benchmarks/declarative/painting/data/64x64_opaque.png new file mode 100644 index 0000000..94c07f3 Binary files /dev/null and b/tests/benchmarks/declarative/painting/data/64x64_opaque.png differ diff --git a/tests/benchmarks/declarative/painting/paintbenchmark.cpp b/tests/benchmarks/declarative/painting/paintbenchmark.cpp index d6a873c..8452bed 100644 --- a/tests/benchmarks/declarative/painting/paintbenchmark.cpp +++ b/tests/benchmarks/declarative/painting/paintbenchmark.cpp @@ -60,6 +60,7 @@ const int spacing = 36; QSizeF size(1000, 800); const qreal lineWidth = 1000; QString strings[lines]; +QGLWidget *testWidget = 0; void paint_QTextLayout(QPainter &p, bool useCache) { @@ -160,6 +161,15 @@ void paint_QPixmapCachedText(QPainter &p) void paint_RoundedRect(QPainter &p) { + static bool first = true; + if (first) { + if (testWidget) { + QGLFormat format = testWidget->format(); + if (!format.sampleBuffers()) + qWarning() << "Cannot paint antialiased rounded rect without sampleBuffers"; + } + first = false; + } p.setRenderHint(QPainter::Antialiasing, true); p.setPen(Qt::black); p.setBrush(Qt::red); @@ -174,27 +184,101 @@ void paint_RoundedRect(QPainter &p) void paint_QPixmapCachedRoundedRect(QPainter &p) { static bool first = true; - static QPixmap cacheRect[lines]; + static QPixmap cacheRect; if (first) { - for (int i = 0; i < lines; ++i) { - QSize size((i+1)*50, spacing-1); - cacheRect[i] = QPixmap(size); - cacheRect[i].fill(Qt::transparent); - QPainter paint(&cacheRect[i]); - paint.setRenderHint(QPainter::Antialiasing); - paint.setPen(Qt::black); - paint.setBrush(Qt::red); - paint.drawRoundedRect(QRect(QPoint(0,0), size), 8, 8); + const int pw = 0; + const int radius = 8; + cacheRect = QPixmap(radius*2 + 3 + pw*2, radius*2 + 3 + pw*2); + cacheRect.fill(Qt::transparent); + QPainter paint(&cacheRect); + paint.setRenderHint(QPainter::Antialiasing); + paint.setPen(Qt::black); + paint.setBrush(Qt::red); + if (pw%2) + paint.drawRoundedRect(QRectF(qreal(pw)/2+1, qreal(pw)/2+1, cacheRect.width()-(pw+1), cacheRect.height()-(pw+1)), radius, radius); + else + paint.drawRoundedRect(QRectF(qreal(pw)/2, qreal(pw)/2, cacheRect.width()-pw, cacheRect.height()-pw), radius, radius); + + first = false; + } + for (int i = 0; i < count; i++) { + for (int j = 0; j < lines; ++j) { + QSize size((j+1)*50, spacing-1); + + p.setRenderHints(QPainter::Antialiasing | QPainter::SmoothPixmapTransform, true); + + const int pw = 0; + + int xOffset = (cacheRect.width()-1)/2; + int yOffset = (cacheRect.height()-1)/2; + + QMargins margins(xOffset, yOffset, xOffset, yOffset); + QTileRules rules(Qt::StretchTile, Qt::StretchTile); + //NOTE: even though our item may have qreal-based width and height, qDrawBorderPixmap only supports QRects + qDrawBorderPixmap(&p, QRect(-pw/2, j*spacing-pw/2, size.width()+pw, size.height()+pw), margins, cacheRect, cacheRect.rect(), margins, rules); + } + } +} + +void paint_QPixmap63x63_opaque(QPainter &p) +{ + static bool first = true; + static QPixmap pm; + if (first) { + pm.load("data/63x63_opaque.png"); + first = false; + } + for (int i = 0; i < count; i++) { + for (int j = 0; j < lines; ++j) { + p.drawPixmap((i%10) * 64,j*spacing, pm); + } + } +} + +void paint_QPixmap64x64_opaque(QPainter &p) +{ + static bool first = true; + static QPixmap pm; + if (first) { + pm.load("data/64x64_opaque.png"); + first = false; + } + for (int i = 0; i < count; i++) { + for (int j = 0; j < lines; ++j) { + p.drawPixmap((i%10) * 64,j*spacing, pm); } + } +} + +void paint_QPixmap63x63(QPainter &p) +{ + static bool first = true; + static QPixmap pm; + if (first) { + pm.load("data/63x63.png"); first = false; } for (int i = 0; i < count; i++) { for (int j = 0; j < lines; ++j) { - p.drawPixmap(0,j*spacing,cacheRect[j]); + p.drawPixmap((i%10) * 64,j*spacing, pm); } } } +void paint_QPixmap64x64(QPainter &p) +{ + static bool first = true; + static QPixmap pm; + if (first) { + pm.load("data/64x64.png"); + first = false; + } + for (int i = 0; i < count; i++) { + for (int j = 0; j < lines; ++j) { + p.drawPixmap((i%10) * 64,j*spacing, pm); + } + } +} typedef void(*PaintFunc)(QPainter &); struct { @@ -210,6 +294,10 @@ struct { { "CachedText", &paint_QPixmapCachedText }, { "RoundedRect", &paint_RoundedRect }, { "CachedRoundedRect", &paint_QPixmapCachedRoundedRect }, + { "QPixmap63x63_opaque", &paint_QPixmap63x63_opaque }, + { "QPixmap64x64_opaque", &paint_QPixmap64x64_opaque }, + { "QPixmap63x63", &paint_QPixmap63x63 }, + { "QPixmap64x64", &paint_QPixmap64x64 }, { 0, 0 } }; @@ -297,11 +385,11 @@ int main(int argc, char *argv[]) QWidget w; QGLFormat format = QGLFormat::defaultFormat(); format.setSampleBuffers(sampleBuffers); - MyGLWidget *glw = new MyGLWidget(format); - glw->setAutoFillBackground(false); + testWidget = new MyGLWidget(format); + testWidget->setAutoFillBackground(false); QVBoxLayout *layout = new QVBoxLayout(&w); w.setLayout(layout); - layout->addWidget(glw); + layout->addWidget(testWidget); w.showFullScreen(); app.exec(); -- cgit v0.12 From da055325393872e9399577d1962486fb6e3102c7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Kaj=20Gr=C3=B6nholm?= Date: Thu, 18 Feb 2010 14:48:31 +1000 Subject: Add support for startDragDistance in qmlviewer. Adding new parameter "-dragthreshold " which sets mouse drag threshold in pixels. Using this makes qmlviewer more usable in touchscreen devices, where applications may require different thresholds. Merge-request: 6 Reviewed-by: Michael Brasser --- tools/qmlviewer/main.cpp | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/tools/qmlviewer/main.cpp b/tools/qmlviewer/main.cpp index 14a4735..8cff271 100644 --- a/tools/qmlviewer/main.cpp +++ b/tools/qmlviewer/main.cpp @@ -95,6 +95,7 @@ void usage() qWarning(" -record arg .............................. add a recording process argument"); qWarning(" -autorecord [from-] ...... set recording to start and stop"); qWarning(" -devicekeys .............................. use numeric keys (see F1)"); + qWarning(" -dragthreshold .................... set mouse drag threshold size"); qWarning(" -netcache ......................... set disk cache to size bytes"); qWarning(" -translation ........... set the language to run in"); qWarning(" -L ........................... prepend to the library search path"); @@ -217,6 +218,9 @@ int main(int argc, char ** argv) autorecord_to = range.mid(dash+1).toInt(); } else if (arg == "-devicekeys") { devkeys = true; + } else if (arg == "-dragthreshold") { + if (lastArg) usage(); + app.setStartDragDistance(QString(argv[++i]).toInt()); } else if (arg == QLatin1String("-v") || arg == QLatin1String("-version")) { fprintf(stderr, "Qt Declarative UI Viewer version %s\n", QT_VERSION_STR); return 0; -- cgit v0.12 From b99363853e729df1705c636acf495b73ea9d7cfe Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 19 Feb 2010 11:09:36 +1000 Subject: doc --- doc/src/files-and-resources/resources.qdoc | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/doc/src/files-and-resources/resources.qdoc b/doc/src/files-and-resources/resources.qdoc index 639aaf4..00646ac 100644 --- a/doc/src/files-and-resources/resources.qdoc +++ b/doc/src/files-and-resources/resources.qdoc @@ -92,8 +92,11 @@ system. By default, resources are accessible in the application under the - same name as they have in the source tree, with a \c :/ prefix. - For example, the path \c :/images/cut.png would give access to the + same file name as they have in the source tree, with a \c :/ prefix, + or by a \link QUrl URL\endlink with a \c qrc scheme. + + For example, the file path \c :/images/cut.png or the URL + \c qrc:///images/cut.png would give access to the \c cut.png file, whose location in the application's source tree is \c images/cut.png. This can be changed using the \c file tag's \c alias attribute: -- cgit v0.12 From 4d035b669d9f790c385b261c7e78b547d4c4eedb Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 19 Feb 2010 13:16:35 +1000 Subject: Remove unused function that breaks build on AIX. --- src/declarative/util/qmltimeline_p_p.h | 8 -------- 1 file changed, 8 deletions(-) diff --git a/src/declarative/util/qmltimeline_p_p.h b/src/declarative/util/qmltimeline_p_p.h index f335e7d..f271a3f 100644 --- a/src/declarative/util/qmltimeline_p_p.h +++ b/src/declarative/util/qmltimeline_p_p.h @@ -154,14 +154,6 @@ public: QmlTimeLineEvent(const QmlTimeLineEvent &o); template - QmlTimeLineEvent(QmlTimeLineObject *b, T *c) - { - d0 = &callFunc; - d1 = (void *)c; - d2 = b; - } - - template static QmlTimeLineEvent timeLineEvent(QmlTimeLineObject *b, T *c) { QmlTimeLineEvent rv; -- cgit v0.12 From 91e69bbc1f390e4da209281d44f734b3d63e8e0f Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 19 Feb 2010 15:28:49 +1000 Subject: Fix "AnimatedImage ignores Anchors setting" Task-number: QTBUG-8343 --- src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp | 1 + 1 file changed, 1 insertion(+) diff --git a/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp b/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp index 3434635..697be15 100644 --- a/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsanimatedimage.cpp @@ -295,6 +295,7 @@ void QmlGraphicsAnimatedImage::playingStatusChanged() void QmlGraphicsAnimatedImage::componentComplete() { Q_D(QmlGraphicsAnimatedImage); + QmlGraphicsImage::componentComplete(); if (!d->reply) { setCurrentFrame(d->preset_currentframe); d->preset_currentframe = 0; -- cgit v0.12 From 19e4d8f19e90841689dbc5dd5d13ad730c1f936d Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Fri, 19 Feb 2010 15:47:56 +1000 Subject: Delete the QmlImageRequestHandler in the correct thread. --- src/declarative/util/qmlpixmapcache.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/declarative/util/qmlpixmapcache.cpp b/src/declarative/util/qmlpixmapcache.cpp index 21fce5e..56903ce 100644 --- a/src/declarative/util/qmlpixmapcache.cpp +++ b/src/declarative/util/qmlpixmapcache.cpp @@ -267,12 +267,12 @@ QmlImageReader::QmlImageReader(QmlEngine *eng) QmlImageReader::~QmlImageReader() { - quit(); - wait(); readerMutex.lock(); readers.remove(engine); readerMutex.unlock(); - delete handler; + + quit(); + wait(); } QmlImageReader *QmlImageReader::instance(QmlEngine *engine) @@ -335,6 +335,9 @@ void QmlImageReader::run() handler = new QmlImageRequestHandler(this, engine); exec(); + + delete handler; + handler = 0; } //=========================================================================== -- cgit v0.12 From 1d54f0ff2bb7075c8aa27a2be67056d2a2863fc1 Mon Sep 17 00:00:00 2001 From: Leonardo Sobral Cunha Date: Fri, 19 Feb 2010 15:57:27 +1000 Subject: Fix tst_qmlgraphicstextedit::delegateLoading autotest The test case was wrong before, if one sub-component fails, then the whole component fails to load. --- .../qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp | 10 ++-------- 1 file changed, 2 insertions(+), 8 deletions(-) diff --git a/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp b/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp index 3221e9a..cc2f929 100644 --- a/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp +++ b/tests/auto/declarative/qmlgraphicstextedit/tst_qmlgraphicstextedit.cpp @@ -668,18 +668,12 @@ void tst_qmlgraphicstextedit::delegateLoading() view->execute(); view->show(); view->setFocus(); - delegate = view->rootObject()->findChild("delegateOkay"); - QVERIFY(delegate); - delegate = view->rootObject()->findChild("delegateFail"); - QVERIFY(!delegate); + QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test view->setSource(QUrl("http://localhost:42332/cursorHttpTestFail2.qml")); view->execute(); view->show(); view->setFocus(); - delegate = view->rootObject()->findChild("delegateOkay"); - QVERIFY(delegate); - delegate = view->rootObject()->findChild("delegateErrorA"); - QVERIFY(!delegate); + QTRY_VERIFY(!view->rootObject()); // there is fail item inside this test //ErrorB should get a component which is ready but component.create() returns null //Not sure how to accomplish this with QmlGraphicsTextEdits cursor delegate //###This could be a case of overzealous defensive programming -- cgit v0.12 From 5ef574960981066c50b390daf4e8fc45b6fe9f83 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Fri, 19 Feb 2010 16:20:01 +1000 Subject: Fix tst_QmlGraphicsLoader::networkRequestUrl autotest. --- tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp b/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp index a152ec6..2d3d5ee 100644 --- a/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp +++ b/tests/auto/declarative/qmlgraphicsloader/tst_qmlgraphicsloader.cpp @@ -389,7 +389,7 @@ void tst_QmlGraphicsLoader::networkRequestUrl() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); - server.serveDirectory("data"); + server.serveDirectory(SRCDIR "/data"); QmlComponent component(&engine); component.setData(QByteArray("import Qt 4.6\nLoader { source: \"http://127.0.0.1:14445/Rect120x60.qml\" }"), TEST_FILE("")); @@ -441,7 +441,7 @@ void tst_QmlGraphicsLoader::failNetworkRequest() { TestHTTPServer server(SERVER_PORT); QVERIFY(server.isValid()); - server.serveDirectory("data"); + server.serveDirectory(SRCDIR "/data"); QTest::ignoreMessage(QtWarningMsg, "(:-1: Network error for URL http://127.0.0.1:14445/IDontExist.qml) "); -- cgit v0.12 From b988ef5a3d9ac96cfa7b9fd4b87522bbab84ffce Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Fri, 19 Feb 2010 17:18:42 +1000 Subject: More strict type checking of ListElement properties. Task-number: QTBUG-6203 --- .../listview/content/ClickAutoRepeating.qml | 1 + examples/declarative/listview/dynamic.qml | 5 +- src/declarative/QmlChanges.txt | 8 +++ src/declarative/util/qmllistmodel.cpp | 42 ++++++++++++---- .../declarative/qmllistmodel/tst_qmllistmodel.cpp | 57 +++++++++++++++++++++- 5 files changed, 99 insertions(+), 14 deletions(-) diff --git a/examples/declarative/listview/content/ClickAutoRepeating.qml b/examples/declarative/listview/content/ClickAutoRepeating.qml index 796f9e3..be37b50 100644 --- a/examples/declarative/listview/content/ClickAutoRepeating.qml +++ b/examples/declarative/listview/content/ClickAutoRepeating.qml @@ -11,6 +11,7 @@ Item { signal clicked isPressed: SequentialAnimation { + running: false id: autoRepeat PropertyAction { target: page; property: "isPressed"; value: true } ScriptAction { script: page.pressed() } diff --git a/examples/declarative/listview/dynamic.qml b/examples/declarative/listview/dynamic.qml index 2607527..dd898f9 100644 --- a/examples/declarative/listview/dynamic.qml +++ b/examples/declarative/listview/dynamic.qml @@ -24,7 +24,6 @@ Rectangle { } ListElement { name: "Cumquat"; cost: 3.25 - types: [ "Small", "Smaller" ] attributes: [ ListElement { description: "Citrus" } ] @@ -82,12 +81,12 @@ Rectangle { anchors.right: removeButton.left; anchors.rightMargin: 35; spacing: 10 width: childrenRect.width; anchors.verticalCenter: parent.verticalCenter Image { source: "content/pics/list-add.png" - ClickAutoRepeating { id: clickUp; anchors.fill: parent; onClicked: fruitModel.set(index,"cost",Number(cost)+0.25) } + ClickAutoRepeating { id: clickUp; anchors.fill: parent; onClicked: fruitModel.setProperty(index,"cost",cost+0.25) } scale: clickUp.isPressed ? 0.9 : 1; transformOrigin: Item.Center } Text { id: costText; text: '$'+Number(cost).toFixed(2); font.pixelSize: 15; color: "White"; font.bold: true; } Image { source: "content/pics/list-remove.png" - ClickAutoRepeating { id: clickDown; anchors.fill: parent; onClicked: fruitModel.set(index,"cost",Math.max(0,Number(cost)-0.25)) } + ClickAutoRepeating { id: clickDown; anchors.fill: parent; onClicked: fruitModel.setProperty(index,"cost",Math.max(0,cost-0.25)) } scale: clickDown.isPressed ? 0.9 : 1; transformOrigin: Item.Center } } diff --git a/src/declarative/QmlChanges.txt b/src/declarative/QmlChanges.txt index 3a709e8..e3aab65 100644 --- a/src/declarative/QmlChanges.txt +++ b/src/declarative/QmlChanges.txt @@ -18,6 +18,14 @@ reinforced. sectionExpression has been replaced by section.property, section.criteria +ListModel +--------- +- types are strictly checked (previously, everything was a string) + - foo: "bar" continues to work as before + - foo: bar is now invalid, use foo: "bar" + - foo: true is now a bool (not string "true") + - foo: false is now a bool (not string "false" == true!) + ============================================================================= The changes below are pre-4.6.0 release. diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index ee35d2e..af41dfd 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -806,7 +806,23 @@ bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QL qvariant_cast(value); int ref = data.count(); - QByteArray d = variant.asScript().toUtf8(); + + QByteArray d; + d += char(variant.type()); // type tag + if (variant.isString()) { + d += variant.asString().toUtf8(); + } else if (variant.isNumber()) { + d += QByteArray::number(variant.asNumber(),'g',20); + } else if (variant.isBoolean()) { + d += char(variant.asBoolean()); + } else if (variant.isScript()) { + if (definesEmptyList(variant.asScript())) { + d[0] = 0; // QmlParser::Variant::Invalid - marks empty list + } else { + error(prop, QmlListModel::tr("ListElement: cannot use script for property value")); + return false; + } + } d.append('\0'); data.append(d); @@ -814,7 +830,6 @@ bool QmlListModelParser::compileProperty(const QmlCustomParserProperty &prop, QL li.type = ListInstruction::Value; li.dataIdx = ref; instr << li; - } } @@ -892,15 +907,22 @@ void QmlListModelParser::setCustomData(QObject *obj, const QByteArray &d) case ListInstruction::Value: { ModelNode *n = nodes.top(); - QString s = QString::fromUtf8(QByteArray(data + instr.dataIdx)); - - bool isEmptyList = false; - if (!n->isArray) - isEmptyList = definesEmptyList(s); - if (isEmptyList) + switch (QmlParser::Variant::Type(data[instr.dataIdx])) { + case QmlParser::Variant::Invalid: n->isArray = true; - else - n->values.append(s); + break; + case QmlParser::Variant::Boolean: + n->values.append(bool(data[1 + instr.dataIdx])); + break; + case QmlParser::Variant::Number: + n->values.append(QByteArray(data + 1 + instr.dataIdx).toDouble()); + break; + case QmlParser::Variant::String: + n->values.append(QString::fromUtf8(data + 1 + instr.dataIdx)); + break; + default: + Q_ASSERT("Format error in ListInstruction"); + } processingSet = false; } diff --git a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp index fa45a01..e70c7f1 100644 --- a/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp +++ b/tests/auto/declarative/qmllistmodel/tst_qmllistmodel.cpp @@ -51,6 +51,8 @@ public: tst_QmlListModel() {} private slots: + void static_types(); + void static_types_data(); void static_i18n(); void static_nestedElements(); void static_nestedElements_data(); @@ -223,6 +225,59 @@ void tst_QmlListModel::dynamic() QCOMPARE(actual,result); } +void tst_QmlListModel::static_types_data() +{ + QTest::addColumn("qml"); + QTest::addColumn("value"); + + QTest::newRow("string") + << "ListElement { foo: \"bar\" }" + << QVariant(QString("bar")); + + QTest::newRow("real") + << "ListElement { foo: 10.5 }" + << QVariant(10.5); + + QTest::newRow("real0") + << "ListElement { foo: 0 }" + << QVariant(double(0)); + + QTest::newRow("bool") + << "ListElement { foo: false }" + << QVariant(false); + + QTest::newRow("bool") + << "ListElement { foo: true }" + << QVariant(true); +} + +void tst_QmlListModel::static_types() +{ + QFETCH(QString, qml); + QFETCH(QVariant, value); + + qml = "import Qt 4.6\nListModel { " + qml + " }"; + + QmlEngine engine; + QmlComponent component(&engine); + component.setData(qml.toUtf8(), + QUrl::fromLocalFile(QString("dummy.qml"))); + QVERIFY(!component.isError()); + + QmlListModel *obj = qobject_cast(component.create()); + QVERIFY(obj != 0); + + QScriptValue actual = obj->get(0).property(QLatin1String("foo")); + + QCOMPARE(actual.isString(), value.type() == QVariant::String); + QCOMPARE(actual.isBoolean(), value.type() == QVariant::Bool); + QCOMPARE(actual.isNumber(), value.type() == QVariant::Double); + + QCOMPARE(actual.toString(), value.toString()); + + delete obj; +} + void tst_QmlListModel::error_data() { QTest::addColumn("qml"); @@ -246,7 +301,7 @@ void tst_QmlListModel::error_data() QTest::newRow("bindings not allowed in ListElement") << "import Qt 4.6\nRectangle { id: rect; ListModel { ListElement { foo: rect.color } } }" - << "QTBUG-6203 ListElement should not allow binding its data to something"; + << "ListElement: cannot use script for property value"; QTest::newRow("random object list properties allowed in ListElement") << "import Qt 4.6\nListModel { ListElement { foo: [ ListElement { bar: 123 } ] } }" -- cgit v0.12 From efecee2ca71bb89c9e40090c50fd5c27aeadbd18 Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Fri, 19 Feb 2010 12:15:43 +0100 Subject: Fix dynamic example Dynamic property creation appears to have been restricted. --- examples/declarative/dynamic/qml/PerspectiveItem.qml | 1 + 1 file changed, 1 insertion(+) diff --git a/examples/declarative/dynamic/qml/PerspectiveItem.qml b/examples/declarative/dynamic/qml/PerspectiveItem.qml index 728c3a5..a0dfad3 100644 --- a/examples/declarative/dynamic/qml/PerspectiveItem.qml +++ b/examples/declarative/dynamic/qml/PerspectiveItem.qml @@ -6,6 +6,7 @@ Image { property double scaleFactor: Math.max((y+height-250)*0.01, 0.3) property double scaledBottom: y + (height+height*scaleFactor)/2 property bool onLand: scaledBottom > window.height/2 + property string image //Needed for compatibility with GenericItem opacity: onLand ? 1 : 0.25 onCreatedChanged: if (created && !onLand) { tree.destroy() } else { z = scaledBottom } scale: scaleFactor -- cgit v0.12 From 6c3acdf906a678158928b76cf047b58fbb9f8969 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Bj=C3=B8rn=20Erik=20Nilsen?= Date: Fri, 19 Feb 2010 12:21:45 +0100 Subject: Revert "Speed up QmlGraphicsItem::setParentItem." This reverts commit 282a46ab5edafa7b82e9c58658143cb979db2d85. This change introduced some regression due to itemChange notifications not being delivered as expected (reported by Warwick). We have to find another solution, unfortunately. However, the performance penalty isn't that big so we can live with it for now. --- src/declarative/graphicsitems/qmlgraphicsitem.cpp | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/declarative/graphicsitems/qmlgraphicsitem.cpp b/src/declarative/graphicsitems/qmlgraphicsitem.cpp index 262c192..22beb12 100644 --- a/src/declarative/graphicsitems/qmlgraphicsitem.cpp +++ b/src/declarative/graphicsitems/qmlgraphicsitem.cpp @@ -1336,12 +1336,8 @@ void QmlGraphicsItem::setParentItem(QmlGraphicsItem *parent) QmlGraphicsItem *oldParent = parentItem(); if (parent == oldParent || !parent) return; - Q_D(QmlGraphicsItem); QObject::setParent(parent); - d->setParentItemHelper(parent, /*newParentVariant=*/0, /*thisPointerVariant=*/0); - if (oldParent) - emit oldParent->childrenChanged(); - emit parentChanged(); + QGraphicsObject::setParentItem(parent); } /*! -- cgit v0.12