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