From fe6b1ef3942be8d0a3322a9894aab952db6df06e Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 21 Jul 2009 08:41:02 +1000 Subject: Allow minehunt example to compile again. qmlbindablevalue had been renamed and no-one updated this file. --- examples/declarative/minehunt/main.cpp | 1 - 1 file changed, 1 deletion(-) diff --git a/examples/declarative/minehunt/main.cpp b/examples/declarative/minehunt/main.cpp index d8e60cc..ae850de 100644 --- a/examples/declarative/minehunt/main.cpp +++ b/examples/declarative/minehunt/main.cpp @@ -1,4 +1,3 @@ -#include "qmlbindablevalue.h" #include "qmlengine.h" #include "qmlcontext.h" #include "qml.h" -- cgit v0.12 From cf851eced1d03c9d839626f86d00fd0734949c9d Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 21 Jul 2009 09:06:24 +1000 Subject: Update AnimatedImage item to be more similar to Animations Now has playing and paused properties that should behave the same. --- demos/declarative/samegame/content/SpinBlock.qml | 2 +- demos/declarative/samegame/content/samegame.js | 2 +- src/declarative/extra/qfxanimatedimageitem.cpp | 45 ++++++++++++++++++++++-- src/declarative/extra/qfxanimatedimageitem.h | 6 ++++ src/declarative/extra/qfxanimatedimageitem_p.h | 3 +- 5 files changed, 52 insertions(+), 6 deletions(-) diff --git a/demos/declarative/samegame/content/SpinBlock.qml b/demos/declarative/samegame/content/SpinBlock.qml index 42276d0..2597bfb 100644 --- a/demos/declarative/samegame/content/SpinBlock.qml +++ b/demos/declarative/samegame/content/SpinBlock.qml @@ -15,7 +15,7 @@ Item { id:block } else { "pics/gnome/greenStone.gif"; } - playing: selected + paused: !selected } opacity: 0 y: targetY diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js index 1814031..3592edc 100644 --- a/demos/declarative/samegame/content/samegame.js +++ b/demos/declarative/samegame/content/samegame.js @@ -49,7 +49,7 @@ function initBoard() var fillFound; var floodBoard; -var lastHoveredIdx = -1 +var lastHoveredIdx = -2 function handleHover(x,y, btn) { xIdx = Math.floor(x/tileSize); diff --git a/src/declarative/extra/qfxanimatedimageitem.cpp b/src/declarative/extra/qfxanimatedimageitem.cpp index 5516a00..4c74f6f 100644 --- a/src/declarative/extra/qfxanimatedimageitem.cpp +++ b/src/declarative/extra/qfxanimatedimageitem.cpp @@ -96,6 +96,30 @@ QFxAnimatedImageItem::~QFxAnimatedImageItem() } /*! + \qmlproperty bool AnimatedImage::paused + This property holds whether the animated image is paused or not + + Defaults to false, and can be set to true when you want to pause. +*/ +bool QFxAnimatedImageItem::isPaused() const +{ + Q_D(const QFxAnimatedImageItem); + if(!d->_movie) + return false; + return d->_movie->state()==QMovie::Paused; +} + +void QFxAnimatedImageItem::setPaused(bool pause) +{ + Q_D(QFxAnimatedImageItem); + if(pause == d->paused) + return; + d->paused = pause; + if(!d->_movie) + return; + d->_movie->setPaused(pause); +} +/*! \qmlproperty bool AnimatedImage::playing This property holds whether the animated image is playing or not @@ -106,7 +130,7 @@ bool QFxAnimatedImageItem::isPlaying() const Q_D(const QFxAnimatedImageItem); if (!d->_movie) return false; - return d->_movie->state()==QMovie::Running; + return d->_movie->state()!=QMovie::NotRunning; } void QFxAnimatedImageItem::setPlaying(bool play) @@ -120,7 +144,7 @@ void QFxAnimatedImageItem::setPlaying(bool play) if (play) d->_movie->start(); else - d->_movie->setPaused(true); + d->_movie->stop(); } /*! @@ -197,7 +221,7 @@ void QFxAnimatedImageItem::movieRequestFinished() return; } connect(d->_movie, SIGNAL(stateChanged(QMovie::MovieState)), - this, SIGNAL(playingChanged())); + this, SLOT(playingStatusChanged())); connect(d->_movie, SIGNAL(frameChanged(int)), this, SLOT(movieUpdate())); d->_movie->setCacheMode(QMovie::CacheAll); @@ -205,6 +229,8 @@ void QFxAnimatedImageItem::movieRequestFinished() d->_movie->start(); else d->_movie->jumpToFrame(0); + if(d->paused) + d->_movie->setPaused(true); setPixmap(d->_movie->currentPixmap()); } @@ -215,4 +241,17 @@ void QFxAnimatedImageItem::movieUpdate() emit frameChanged(); } +void QFxAnimatedImageItem::playingStatusChanged() +{ + Q_D(QFxAnimatedImageItem); + if((d->_movie->state() != QMovie::NotRunning) != d->playing){ + d->playing = (d->_movie->state() != QMovie::NotRunning); + emit playingChanged(); + } + if((d->_movie->state() == QMovie::Paused) != d->paused){ + d->playing = (d->_movie->state() == QMovie::Paused); + emit pausedChanged(); + } +} + QT_END_NAMESPACE diff --git a/src/declarative/extra/qfxanimatedimageitem.h b/src/declarative/extra/qfxanimatedimageitem.h index 720d187..2d531ee 100644 --- a/src/declarative/extra/qfxanimatedimageitem.h +++ b/src/declarative/extra/qfxanimatedimageitem.h @@ -58,6 +58,7 @@ class Q_DECLARATIVE_EXPORT QFxAnimatedImageItem : public QFxImage Q_OBJECT Q_PROPERTY(bool playing READ isPlaying WRITE setPlaying NOTIFY playingChanged) + Q_PROPERTY(bool paused READ isPaused WRITE setPaused NOTIFY pausedChanged) Q_PROPERTY(int currentFrame READ currentFrame WRITE setCurrentFrame NOTIFY frameChanged) Q_PROPERTY(int frameCount READ frameCount) public: @@ -67,6 +68,9 @@ public: bool isPlaying() const; void setPlaying(bool play); + bool isPaused() const; + void setPaused(bool pause); + int currentFrame() const; void setCurrentFrame(int frame); @@ -77,11 +81,13 @@ public: Q_SIGNALS: void playingChanged(); + void pausedChanged(); void frameChanged(); private Q_SLOTS: void movieUpdate(); void movieRequestFinished(); + void playingStatusChanged(); protected: QFxAnimatedImageItem(QFxAnimatedImageItemPrivate &dd, QFxItem *parent); diff --git a/src/declarative/extra/qfxanimatedimageitem_p.h b/src/declarative/extra/qfxanimatedimageitem_p.h index d743ba4..859f869 100644 --- a/src/declarative/extra/qfxanimatedimageitem_p.h +++ b/src/declarative/extra/qfxanimatedimageitem_p.h @@ -65,11 +65,12 @@ class QFxAnimatedImageItemPrivate : public QFxImagePrivate public: QFxAnimatedImageItemPrivate() - : playing(true), _movie(0) + : playing(true), paused(false), _movie(0) { } bool playing; + bool paused; QMovie *_movie; }; -- cgit v0.12 From 00b9679135be8d83556a31ebe0b3d39d201e76c5 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 21 Jul 2009 09:18:51 +1000 Subject: Fix crash. --- src/declarative/fx/qfxvisualitemmodel.cpp | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/src/declarative/fx/qfxvisualitemmodel.cpp b/src/declarative/fx/qfxvisualitemmodel.cpp index 1b15a48..3d336c5 100644 --- a/src/declarative/fx/qfxvisualitemmodel.cpp +++ b/src/declarative/fx/qfxvisualitemmodel.cpp @@ -51,6 +51,7 @@ #include "qmlopenmetaobject.h" #include "qmllistaccessor.h" #include "qfxvisualitemmodel.h" +#include "private/qguard_p.h" #include QML_DECLARE_TYPE(QListModelInterface) @@ -64,9 +65,9 @@ class QFxVisualItemModelPrivate : public QObjectPrivate public: QFxVisualItemModelPrivate(QmlContext *); - QListModelInterface *m_listModelInterface; - QAbstractItemModel *m_abstractItemModel; - QFxVisualItemModel *m_visualItemModel; + QGuard m_listModelInterface; + QGuard m_abstractItemModel; + QGuard m_visualItemModel; QString m_part; QmlComponent *m_delegate; -- cgit v0.12 From eac07b9c2bc429d475ac5e95c0fbbae2f603516c Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 21 Jul 2009 09:19:10 +1000 Subject: Doc clarification. --- src/declarative/util/qmlfollow.cpp | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/src/declarative/util/qmlfollow.cpp b/src/declarative/util/qmlfollow.cpp index 1e6fea2..63b6307 100644 --- a/src/declarative/util/qmlfollow.cpp +++ b/src/declarative/util/qmlfollow.cpp @@ -345,8 +345,7 @@ void QmlFollow::setDamping(qreal damping) to 0 to be considered equal to zero. This will depend on the usage of the value. For pixel positions, 0.25 would suffice. For scale, 0.005 will suffice. - The default is 0.01. Small performance improvements can result in tuning this - value. + The default is 0.01. Tuning this value can provide small performance improvements. */ qreal QmlFollow::epsilon() const { -- cgit v0.12 From d2ad09f42db2b6b80427918261f96081eaabfe6c Mon Sep 17 00:00:00 2001 From: Alan Alpert Date: Tue, 21 Jul 2009 16:38:15 +1000 Subject: Move the Script interface of QmlComponent to QmlBindableComponent --- demos/declarative/samegame/content/samegame.js | 4 +- examples/declarative/dynamic/dynamic.js | 4 +- src/declarative/qml/qml.pri | 3 + src/declarative/qml/qmlbindablecomponent.cpp | 104 +++++++++++++++++++++++++ src/declarative/qml/qmlbindablecomponent.h | 91 ++++++++++++++++++++++ src/declarative/qml/qmlbindablecomponent_p.h | 77 ++++++++++++++++++ src/declarative/qml/qmlcomponent.cpp | 17 ---- src/declarative/qml/qmlcomponent.h | 9 +-- src/declarative/qml/qmlengine.cpp | 12 +-- 9 files changed, 290 insertions(+), 31 deletions(-) create mode 100644 src/declarative/qml/qmlbindablecomponent.cpp create mode 100644 src/declarative/qml/qmlbindablecomponent.h create mode 100644 src/declarative/qml/qmlbindablecomponent_p.h diff --git a/demos/declarative/samegame/content/samegame.js b/demos/declarative/samegame/content/samegame.js index 3592edc..b1b2c50 100644 --- a/demos/declarative/samegame/content/samegame.js +++ b/demos/declarative/samegame/content/samegame.js @@ -201,7 +201,7 @@ var waitTop = -1; function finishCreatingBlock(xIdx,yIdx){ //TODO: Doc that the 'x', 'y' that were here are hidden properties from the calling QFxItem - if(component.isReady()){ + if(component.isReady){ if(xIdx == undefined){ //Called without arguments, create a previously stored (xIdx,yIdx) if(waitTop == -1) @@ -226,7 +226,7 @@ function finishCreatingBlock(xIdx,yIdx){ dynamicObject.spawned = true; board[index(xIdx,yIdx)] = dynamicObject; return true; - }else if(component.isError()){ + }else if(component.isError){ print("error creating block"); print(component.errorsString()); }else{ diff --git a/examples/declarative/dynamic/dynamic.js b/examples/declarative/dynamic/dynamic.js index 13317df..8f1e138 100644 --- a/examples/declarative/dynamic/dynamic.js +++ b/examples/declarative/dynamic/dynamic.js @@ -28,10 +28,10 @@ function instantCreateWithComponent() {//Like create, but assumes instant readyn } function finishCreation(){ - if(component.isReady() && dynamicObject == null){ + if(component.isReady && dynamicObject == null){ dynamicObject = component.createObject(); dynamicObject.parent = targetItem; - }else if(component.isError()){ + }else if(component.isError){ dynamicObject = null; print("error creating component"); print(component.errorsString()); diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index b3fa063..b71ca1f 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -5,6 +5,7 @@ SOURCES += qml/qmlparser.cpp \ qml/qmlexpression.cpp \ qml/qmlbinding.cpp \ qml/qmlmetaproperty.cpp \ + qml/qmlbindablecomponent.cpp \ qml/qmlcomponent.cpp \ qml/qmlcontext.cpp \ qml/qmlcustomparser.cpp \ @@ -36,6 +37,8 @@ HEADERS += qml/qmlparser_p.h \ qml/qmlbinding.h \ qml/qmlbinding_p.h \ qml/qmlmetaproperty.h \ + qml/qmlbindablecomponent.h \ + qml/qmlbindablecomponent_p.h \ qml/qmlcomponent.h \ qml/qmlcomponent_p.h \ qml/qmlcustomparser_p.h \ diff --git a/src/declarative/qml/qmlbindablecomponent.cpp b/src/declarative/qml/qmlbindablecomponent.cpp new file mode 100644 index 0000000..ed9924a --- /dev/null +++ b/src/declarative/qml/qmlbindablecomponent.cpp @@ -0,0 +1,104 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#include "qmlbindablecomponent.h" +#include "qmlbindablecomponent_p.h" +#include "qmlcomponent.h" + +QT_BEGIN_NAMESPACE +QmlBindableComponent::QmlBindableComponent(QmlEngine *engine, QObject *parent) + : QmlComponent(*(new QmlBindableComponentPrivate), parent) +{ + Q_D(QmlBindableComponent); + d->engine = engine; + connect(this, SIGNAL(statusChanged(QmlComponent::Status)), + this, SLOT(statusChange(QmlComponent::Status))); +} + +QmlBindableComponent::QmlBindableComponent(QmlEngine *engine, const QUrl &url, QObject *parent) + : QmlComponent(*(new QmlBindableComponentPrivate), parent) +{ + Q_D(QmlBindableComponent); + d->engine = engine; + loadUrl(url); + connect(this, SIGNAL(statusChanged(QmlComponent::Status)), + this, SLOT(statusChange(QmlComponent::Status))); +} + +void QmlBindableComponent::setContext(QmlContext* c) +{ + Q_D(QmlBindableComponent); + d->ctxt =c; +} +/*! + Create a script object instance from this component. Returns a null + script object if creation failed. It will create the instance in the + same context that it was created it. QmlBindableComponent is only + meant to be created from with script - C++ developers should just use + QmlComponent directly. + + Similar to QmlComponent::create(), but creates an object suitable + for usage within scripts. +*/ +QScriptValue QmlBindableComponent::createObject() +{ + Q_D(QmlBindableComponent); + QObject* ret = create(d->ctxt); + return QmlEngine::qmlScriptObject(ret, d->engine); +} + +void QmlBindableComponent::statusChange(QmlComponent::Status newStatus) +{ + Q_D(QmlBindableComponent); + if(newStatus == d->prevStatus) + return; + if(newStatus == QmlComponent::Null || d->prevStatus == QmlComponent::Null) + emit isNullChanged(); + if(newStatus == QmlComponent::Ready || d->prevStatus == QmlComponent::Ready) + emit isReadyChanged(); + if(newStatus == QmlComponent::Loading || d->prevStatus == QmlComponent::Loading) + emit isLoadingChanged(); + if(newStatus == QmlComponent::Error || d->prevStatus == QmlComponent::Error) + emit isErrorChanged(); + d->prevStatus = newStatus; +} + +QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlbindablecomponent.h b/src/declarative/qml/qmlbindablecomponent.h new file mode 100644 index 0000000..2b3e0ce --- /dev/null +++ b/src/declarative/qml/qmlbindablecomponent.h @@ -0,0 +1,91 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLBINDABLECOMPONENT_H +#define QMLBINDABLECOMPONENT_H + +#include +#include +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QmlBindableComponentPrivate; +class QmlEngine; +class QmlContext; +class Q_DECLARATIVE_EXPORT QmlBindableComponent : public QmlComponent +{ + Q_OBJECT + Q_DECLARE_PRIVATE(QmlBindableComponent) + friend class QmlEngine; +public: + QmlBindableComponent(QmlEngine *, const QUrl &url, QObject *parent = 0); + QmlBindableComponent(QmlEngine *, QObject *parent=0); + Q_PROPERTY(bool isNull READ isNull NOTIFY isNullChanged); + Q_PROPERTY(bool isReady READ isReady NOTIFY isReadyChanged); + Q_PROPERTY(bool isError READ isError NOTIFY isErrorChanged); + Q_PROPERTY(bool isLoading READ isLoading NOTIFY isLoadingChanged); + + Q_INVOKABLE QScriptValue createObject(); + + void setContext(QmlContext* c); +Q_SIGNALS: + void isNullChanged(); + void isErrorChanged(); + void isReadyChanged(); + void isLoadingChanged(); +private slots: + void statusChange(QmlComponent::Status newStatus); +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QmlBindableComponent) + +QT_END_HEADER +#endif diff --git a/src/declarative/qml/qmlbindablecomponent_p.h b/src/declarative/qml/qmlbindablecomponent_p.h new file mode 100644 index 0000000..79335df --- /dev/null +++ b/src/declarative/qml/qmlbindablecomponent_p.h @@ -0,0 +1,77 @@ +/**************************************************************************** +** +** Copyright (C) 2009 Nokia Corporation and/or its subsidiary(-ies). +** Contact: Qt Software Information (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 either Technology Preview License Agreement or the +** Beta Release License Agreement. +** +** 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.0, included in the file LGPL_EXCEPTION.txt in this +** package. +** +** GNU General Public License Usage +** Alternatively, this file may be used under the terms of the GNU +** General Public License version 3.0 as published by the Free Software +** Foundation and appearing in the file LICENSE.GPL included in the +** packaging of this file. Please review the following information to +** ensure the GNU General Public License version 3.0 requirements will be +** met: http://www.gnu.org/copyleft/gpl.html. +** +** If you are unsure which license is appropriate for your use, please +** contact the sales department at qt-sales@nokia.com. +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QMLBINDABLECOMPONENT_P_H +#define QMLBINDABLECOMPONENT_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 "qmlcomponent.h" +#include "qmlbindablecomponent.h" +#include "qmlcomponent_p.h" + +QT_BEGIN_NAMESPACE + +class QmlContext; +class QmlBindableComponentPrivate : public QmlComponentPrivate +{ + Q_DECLARE_PUBLIC(QmlBindableComponent) +public: + QmlBindableComponentPrivate() : QmlComponentPrivate(), + prevStatus(QmlBindableComponent::Null), ctxt(0) + { } + + QmlComponent::Status prevStatus; + QmlContext* ctxt; +}; + +QT_END_NAMESPACE + +#endif diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp index 4e39d7f..0fdba64 100644 --- a/src/declarative/qml/qmlcomponent.cpp +++ b/src/declarative/qml/qmlcomponent.cpp @@ -431,23 +431,6 @@ QmlComponent::QmlComponent(QmlComponentPrivate &dd, QObject *parent) { } -/*! - Create a script object instance from this component. Returns a null - script object if creation failed. It will create the instance in the - engine's \l {QmlEngine::rootContext()}{root context}. - - Similar to QmlComponent::create(), but creates an object suitable - for usage within scripts. -*/ -QScriptValue QmlComponent::createObject() -{ - Q_D(QmlComponent); - QObject* ret = create(); - if(ret) - return QmlEngine::qmlScriptObject(ret, d->engine); - else - return d->engine->scriptEngine()->nullValue(); -} /*! Create an object instance from this component. Returns 0 if creation diff --git a/src/declarative/qml/qmlcomponent.h b/src/declarative/qml/qmlcomponent.h index 9c712df..45b26eb 100644 --- a/src/declarative/qml/qmlcomponent.h +++ b/src/declarative/qml/qmlcomponent.h @@ -77,17 +77,16 @@ public: enum Status { Null, Ready, Loading, Error }; Status status() const; - Q_INVOKABLE bool isNull() const; - Q_INVOKABLE bool isReady() const; - Q_INVOKABLE bool isError() const; - Q_INVOKABLE bool isLoading() const; + bool isNull() const; + bool isReady() const; + bool isError() const; + bool isLoading() const; QList errors() const; Q_INVOKABLE QString errorsString() const; QUrl url() const; - Q_INVOKABLE QScriptValue createObject(); virtual QObject *create(QmlContext *context = 0); virtual QObject *beginCreate(QmlContext *); virtual void completeCreate(); diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 8b21290..c4b3c0d 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -71,6 +71,7 @@ #include #include #include +#include #include "private/qmlmetaproperty_p.h" #include #include @@ -583,19 +584,20 @@ QScriptValue QmlEngine::qmlScriptObject(QObject* object, QmlEngine* engine) */ QScriptValue QmlEngine::createComponent(QScriptContext *ctxt, QScriptEngine *engine) { - QmlComponent* c; + QmlBindableComponent* c; QmlEngine* activeEngine = qobject_cast( engine->globalObject().property(QLatin1String("qmlEngine")).toQObject()); + QmlContext* context =activeEngine->d_func()->currentExpression->context(); if(ctxt->argumentCount() != 1 || !activeEngine){ - c = new QmlComponent(activeEngine); + c = new QmlBindableComponent(activeEngine); }else{ - QUrl url = QUrl(activeEngine->d_func()->currentExpression->context() - ->resolvedUrl(ctxt->argument(0).toString())); + QUrl url = QUrl(context->resolvedUrl(ctxt->argument(0).toString())); if(!url.isValid()){ url = QUrl(ctxt->argument(0).toString()); } - c = new QmlComponent(activeEngine, url, activeEngine); + c = new QmlBindableComponent(activeEngine, url, activeEngine); } + c->setContext(context); return engine->newQObject(c); } -- cgit v0.12 From ae8e2b626a9acc0cdaed8dbc3fb4c2a3b13d19f4 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Tue, 21 Jul 2009 16:47:07 +1000 Subject: Fix repaint errors. Make sure the old bounding rect is repainted when we change size. --- src/declarative/fx/qfxitem.cpp | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 481733b..4ea515a 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -2097,8 +2097,9 @@ void QFxItem::childrenChanged() void QFxItem::setPaintMargin(qreal margin) { Q_D(QFxItem); - if (margin < d->paintmargin) - update(); // schedule repaint of old boundingRect + if (margin == d->paintmargin) + return; + prepareGeometryChange(); d->paintmargin = margin; } @@ -2235,6 +2236,7 @@ void QFxItem::setWidth(qreal w) qreal oldWidth = d->width; + prepareGeometryChange(); d->width = w; update(); @@ -2250,6 +2252,7 @@ void QFxItem::setImplicitWidth(qreal w) qreal oldWidth = d->width; + prepareGeometryChange(); d->width = w; update(); @@ -2278,6 +2281,7 @@ void QFxItem::setHeight(qreal h) qreal oldHeight = d->height; + prepareGeometryChange(); d->height = h; update(); @@ -2293,6 +2297,7 @@ void QFxItem::setImplicitHeight(qreal h) qreal oldHeight = d->height; + prepareGeometryChange(); d->height = h; update(); -- cgit v0.12 From c301d995c646c70f8f943e2e4fc293a3e2d29edf Mon Sep 17 00:00:00 2001 From: Warwick Allison Date: Tue, 21 Jul 2009 17:21:49 +1000 Subject: Add some (disabled) test code for limiting image size. QFxImage et al could benefit from a limit feature, especially for remote images. --- src/declarative/fx/qfxpixmap.cpp | 25 ++++++++++++++++++++++++- 1 file changed, 24 insertions(+), 1 deletion(-) diff --git a/src/declarative/fx/qfxpixmap.cpp b/src/declarative/fx/qfxpixmap.cpp index ac8a701..e4d79f4 100644 --- a/src/declarative/fx/qfxpixmap.cpp +++ b/src/declarative/fx/qfxpixmap.cpp @@ -40,6 +40,7 @@ ****************************************************************************/ #include "qfxpixmap.h" +#include #include #include #include @@ -124,8 +125,30 @@ QFxPixmap::QFxPixmap(const QUrl &url) if ((*iter)->reply->error()) { qWarning() << "Network error loading" << url << (*iter)->reply->errorString(); } else { + QImageReader imgio((*iter)->reply); + +//#define QT_TEST_SCALED_SIZE +#ifdef QT_TEST_SCALED_SIZE + /* + Some mechanism is needed for loading images at a limited size, especially + for remote images. Loading only thumbnails of remote progressive JPEG + images can be efficient. (Qt jpeg handler does not do so currently) + */ + + QSize limit(60,60); + QSize sz = imgio.size(); + if (sz.width() > limit.width() || sz.height() > limit.height()) { + sz.scale(limit,Qt::KeepAspectRatio); + imgio.setScaledSize(sz); + } +#endif + QImage img; - if (img.load((*iter)->reply, 0)) { + if (imgio.read(&img)) { +#ifdef QT_TEST_SCALED_SIZE + if (!sz.isValid()) + img = img.scaled(limit,Qt::KeepAspectRatio); +#endif d->pixmap = QPixmap::fromImage(img); QPixmapCache::insert(key, d->pixmap); } else { -- cgit v0.12 From 15be8a6b259a5cb4f528b1c765bfcddfc9edd044 Mon Sep 17 00:00:00 2001 From: Martin Jones Date: Wed, 22 Jul 2009 13:19:52 +1000 Subject: Make setRoleNames() protected and improve docs. --- src/corelib/kernel/qabstractitemmodel.cpp | 10 +++++++++- src/corelib/kernel/qabstractitemmodel.h | 3 ++- 2 files changed, 11 insertions(+), 2 deletions(-) diff --git a/src/corelib/kernel/qabstractitemmodel.cpp b/src/corelib/kernel/qabstractitemmodel.cpp index aa99b47..6e1d5c4 100644 --- a/src/corelib/kernel/qabstractitemmodel.cpp +++ b/src/corelib/kernel/qabstractitemmodel.cpp @@ -1879,6 +1879,13 @@ QSize QAbstractItemModel::span(const QModelIndex &) const /*! Sets the model's role names to \a roleNames. + + This function is provided to allow mapping of role identifiers to + role property names in Declarative UI. This function must be called + before the model is used. Modifying the role names after the model + has been set may result in undefined behaviour. + + \sa roleNames() */ void QAbstractItemModel::setRoleNames(const QHash &roleNames) { @@ -1888,11 +1895,12 @@ void QAbstractItemModel::setRoleNames(const QHash &roleNames) /*! Returns the model's role names. + + \sa setRoleNames */ const QHash &QAbstractItemModel::roleNames() const { Q_D(const QAbstractItemModel); - qDebug() << "roles" << d->roleNames; return d->roleNames; } diff --git a/src/corelib/kernel/qabstractitemmodel.h b/src/corelib/kernel/qabstractitemmodel.h index 0a29af6..a6bbff4 100644 --- a/src/corelib/kernel/qabstractitemmodel.h +++ b/src/corelib/kernel/qabstractitemmodel.h @@ -220,7 +220,6 @@ public: Qt::MatchFlags(Qt::MatchStartsWith|Qt::MatchWrap)) const; virtual QSize span(const QModelIndex &index) const; - void setRoleNames(const QHash &roleNames); const QHash &roleNames() const; #ifdef Q_NO_USING_KEYWORD @@ -285,6 +284,8 @@ protected: void changePersistentIndexList(const QModelIndexList &from, const QModelIndexList &to); QModelIndexList persistentIndexList() const; + void setRoleNames(const QHash &roleNames); + private: Q_DECLARE_PRIVATE(QAbstractItemModel) Q_DISABLE_COPY(QAbstractItemModel) -- cgit v0.12 From 1777678767e1f30ff5df0b0a7d19c0af9c5c9590 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 22 Jul 2009 13:41:56 +1000 Subject: Remove moveToParent property. Functionality has been moved to ParentChange. --- src/declarative/fx/qfxitem.cpp | 64 ---------------- src/declarative/fx/qfxitem.h | 3 - src/declarative/util/qmlanimation.cpp | 35 +++------ src/declarative/util/qmlstate.cpp | 47 ++++++++---- src/declarative/util/qmlstate.h | 3 + src/declarative/util/qmlstate_p.h | 5 ++ src/declarative/util/qmlstateoperations.cpp | 114 +++++++++++++++++++++------- src/declarative/util/qmlstateoperations.h | 19 +++-- 8 files changed, 152 insertions(+), 138 deletions(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 4ea515a..c439032 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -460,70 +460,6 @@ void QFxItem::setItemParent(QFxItem *parent) } /*! - \internal - \property QFxItem::moveToParent - Playing around with view2view transitions. - */ - -/*! - \internal - */ -void QFxItem::moveToParent(QFxItem *parent) -{ - if (parent && itemParent()) { - QPointF me = itemParent()->mapToScene(QPointF(0,0)); - QPointF them = parent->mapToScene(QPointF(0,0)); - - QPointF themx = parent->mapToScene(QPointF(1,0)); - QPointF themy = parent->mapToScene(QPointF(0,1)); - - themx -= them; - themy -= them; - - setItemParent(parent); - - // XXX - this is silly and will only work in a few cases - - /* - xDiff = rx * themx_x + ry * themy_x - yDiff = rx * themx_y + ry * themy_y - */ - - qreal rx = 0; - qreal ry = 0; - qreal xDiff = them.x() - me.x(); - qreal yDiff = them.y() - me.y(); - - - if (themx.x() == 0.) { - ry = xDiff / themy.x(); - rx = (yDiff - ry * themy.y()) / themx.y(); - } else if (themy.x() == 0.) { - rx = xDiff / themx.x(); - ry = (yDiff - rx * themx.y()) / themy.y(); - } else if (themx.y() == 0.) { - ry = yDiff / themy.y(); - rx = (xDiff - ry * themy.x()) / themx.x(); - } else if (themy.y() == 0.) { - rx = yDiff / themx.y(); - ry = (xDiff - rx * themx.x()) / themy.x(); - } else { - qreal div = (themy.x() * themx.y() - themy.y() * themx.x()); - - if (div != 0.) - rx = (themx.y() * xDiff - themx.x() * yDiff) / div; - - if (themy.y() != 0.) ry = (yDiff - rx * themx.y()) / themy.y(); - } - - setX(x() - rx); - setY(y() - ry); - } else { - setItemParent(parent); - } -} - -/*! Returns the QFxItem parent of this item. */ QFxItem *QFxItem::itemParent() const diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 67b60c1..53992d3 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -100,7 +100,6 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_INTERFACES(QmlParserStatus) Q_PROPERTY(QFxItem * parent READ itemParent WRITE setItemParent NOTIFY parentChanged DESIGNABLE false FINAL) - Q_PROPERTY(QFxItem * moveToParent READ itemParent WRITE moveToParent NOTIFY parentChanged DESIGNABLE false) Q_PROPERTY(QString id READ id WRITE setId) Q_PROPERTY(QmlList* children READ children DESIGNABLE false) Q_PROPERTY(QmlList* resources READ resources DESIGNABLE false) @@ -165,8 +164,6 @@ public: QFxItem *parentItem() const; void setItemParent(QFxItem *parent); - void moveToParent(QFxItem *parent); - QString id() const; void setId(const QString &); diff --git a/src/declarative/util/qmlanimation.cpp b/src/declarative/util/qmlanimation.cpp index ff070c1..7d9e30f 100644 --- a/src/declarative/util/qmlanimation.cpp +++ b/src/declarative/util/qmlanimation.cpp @@ -1128,54 +1128,39 @@ void QmlParentChangeAction::transition(QmlStateActions &actions, TransitionDirection direction) { Q_D(QmlParentChangeAction); + Q_UNUSED(modified); Q_UNUSED(direction); struct QmlParentChangeActionData : public QAbstractAnimationAction { QmlStateActions actions; + bool reverse; virtual void doAction() { for (int ii = 0; ii < actions.count(); ++ii) { const Action &action = actions.at(ii); - QmlBehaviour::_ignore = true; - action.property.write(action.toValue); - QmlBehaviour::_ignore = false; + if (reverse) + action.event->reverse(); + else + action.event->execute(); } } }; QmlParentChangeActionData *data = new QmlParentChangeActionData; - QSet objs; for (int ii = 0; ii < actions.count(); ++ii) { Action &action = actions[ii]; - QObject *obj = action.property.object(); - QString propertyName = action.property.name(); - - if ((!target() || target() == obj) && propertyName == QString(QLatin1String("moveToParent"))) { - objs.insert(obj); + //### should we still use target to filter? + if (action.event /*&& action.event->name() == d->parentChange*/) { //### Action myAction = action; - - /*if (d->value.isValid()) - myAction.toValue = d->value;*/ - - modified << action.property; + data->reverse = action.reverseEvent; data->actions << myAction; - action.fromValue = myAction.toValue; + action.actionDone = true; } } - /*if (d->value.isValid() && target() && !objs.contains(target())) { - QObject *obj = target(); - for (int jj = 0; jj < props.count(); ++jj) { - Action myAction; - myAction.property = QmlMetaProperty(obj, props.at(jj)); - myAction.toValue = d->value; - data->actions << myAction; - } - }*/ - if (data->actions.count()) { d->cpa->setAnimAction(data, QAbstractAnimation::DeleteWhenStopped); } else { diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp index 73ea9c2..2c44c86 100644 --- a/src/declarative/util/qmlstate.cpp +++ b/src/declarative/util/qmlstate.cpp @@ -54,14 +54,14 @@ QT_BEGIN_NAMESPACE DEFINE_BOOL_CONFIG_OPTION(stateChangeDebug, STATECHANGE_DEBUG); Action::Action() -: restore(true), actionDone(false), fromBinding(0), toBinding(0), event(0), +: restore(true), actionDone(false), reverseEvent(false), fromBinding(0), toBinding(0), event(0), specifiedObject(0) { } Action::Action(QObject *target, const QString &propertyName, const QVariant &value) -: restore(true), actionDone(false), toValue(value), fromBinding(0), +: restore(true), actionDone(false), reverseEvent(false), toValue(value), fromBinding(0), toBinding(0), event(0), specifiedObject(target), specifiedProperty(propertyName) { @@ -83,6 +83,15 @@ void ActionEvent::execute() { } +bool ActionEvent::isReversable() +{ + return false; +} + +void ActionEvent::reverse() +{ +} + /*! \internal */ @@ -345,23 +354,33 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever for (int ii = 0; ii < applyList.count(); ++ii) { Action &action = applyList[ii]; - if (action.event) - continue; - - action.fromBinding = action.property.binding(); - bool found = false; + int jj; - for (jj = 0; jj < d->revertList.count(); ++jj) { - if (d->revertList.at(jj).property == action.property) { - found = true; - break; + if (action.event) { + if (!action.event->isReversable()) + continue; + for (jj = 0; jj < d->revertList.count(); ++jj) { + ActionEvent *event = d->revertList.at(jj).event; + if (event && event->name() == action.event->name()) { + found = true; + break; + } + } + } else { + action.fromBinding = action.property.binding(); + + for (jj = 0; jj < d->revertList.count(); ++jj) { + if (d->revertList.at(jj).property == action.property) { + found = true; + break; + } } } if (!found) { if (!action.restore) { - action.deleteFromBinding(); + action.deleteFromBinding(); } else { // Only need to revert the applyList action if the previous // state doesn't have a higher priority revert already @@ -394,8 +413,10 @@ void QmlState::apply(QmlStateGroup *group, QmlTransition *trans, QmlState *rever a.fromValue = cur; a.toValue = d->revertList.at(ii).value; a.toBinding = d->revertList.at(ii).binding; - a.specifiedObject = d->revertList.at(ii).specifiedObject; //### + a.specifiedObject = d->revertList.at(ii).specifiedObject; a.specifiedProperty = d->revertList.at(ii).specifiedProperty; + a.event = d->revertList.at(ii).event; + a.reverseEvent = d->revertList.at(ii).reverseEvent; applyList << a; // Store these special reverts in the reverting list d->reverting << d->revertList.at(ii).property; diff --git a/src/declarative/util/qmlstate.h b/src/declarative/util/qmlstate.h index 90649a1..1c0d67f 100644 --- a/src/declarative/util/qmlstate.h +++ b/src/declarative/util/qmlstate.h @@ -63,6 +63,7 @@ public: bool restore:1; bool actionDone:1; + bool reverseEvent:1; QmlMetaProperty property; QVariant fromValue; @@ -84,6 +85,8 @@ public: virtual ~ActionEvent(); virtual QString name() const; virtual void execute(); + virtual bool isReversable(); + virtual void reverse(); }; class QmlStateGroup; diff --git a/src/declarative/util/qmlstate_p.h b/src/declarative/util/qmlstate_p.h index 73e2377..b601b57 100644 --- a/src/declarative/util/qmlstate_p.h +++ b/src/declarative/util/qmlstate_p.h @@ -69,12 +69,15 @@ public: property = a.property; specifiedObject = a.specifiedObject; specifiedProperty = a.specifiedProperty; + event = a.event; if (state == StartState) { value = a.fromValue; binding = property.binding(); + reverseEvent = true; } else { value = a.toValue; binding = a.toBinding; + reverseEvent = false; } } @@ -83,6 +86,8 @@ public: QmlBinding *binding; QObject *specifiedObject; QString specifiedProperty; + ActionEvent *event; + bool reverseEvent; }; class QmlStatePrivate : public QObjectPrivate diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp index 8d6abe6..dc7fef6 100644 --- a/src/declarative/util/qmlstateoperations.cpp +++ b/src/declarative/util/qmlstateoperations.cpp @@ -52,12 +52,70 @@ QT_BEGIN_NAMESPACE class QmlParentChangePrivate : public QObjectPrivate { public: - QmlParentChangePrivate() : target(0), parent(0) {} + QmlParentChangePrivate() : target(0), parent(0), origParent(0) {} - QObject *target; - QObject *parent; + QFxItem *target; + QFxItem *parent; + QFxItem *origParent; + + void doChange(QFxItem *targetParent); }; +void QmlParentChangePrivate::doChange(QFxItem *targetParent) +{ + if (targetParent && target && target->itemParent()) { + QPointF me = target->itemParent()->mapToScene(QPointF(0,0)); + QPointF them = targetParent->mapToScene(QPointF(0,0)); + + QPointF themx = targetParent->mapToScene(QPointF(1,0)); + QPointF themy = targetParent->mapToScene(QPointF(0,1)); + + themx -= them; + themy -= them; + + target->setItemParent(targetParent); + + // XXX - this is silly and will only work in a few cases + + /* + xDiff = rx * themx_x + ry * themy_x + yDiff = rx * themx_y + ry * themy_y + */ + + qreal rx = 0; + qreal ry = 0; + qreal xDiff = them.x() - me.x(); + qreal yDiff = them.y() - me.y(); + + + if (themx.x() == 0.) { + ry = xDiff / themy.x(); + rx = (yDiff - ry * themy.y()) / themx.y(); + } else if (themy.x() == 0.) { + rx = xDiff / themx.x(); + ry = (yDiff - rx * themx.y()) / themy.y(); + } else if (themx.y() == 0.) { + ry = yDiff / themy.y(); + rx = (xDiff - ry * themy.x()) / themx.x(); + } else if (themy.y() == 0.) { + rx = yDiff / themx.y(); + ry = (xDiff - rx * themx.x()) / themy.x(); + } else { + qreal div = (themy.x() * themx.y() - themy.y() * themx.x()); + + if (div != 0.) + rx = (themx.y() * xDiff - themx.x() * yDiff) / div; + + if (themy.y() != 0.) ry = (yDiff - rx * themx.y()) / themy.y(); + } + + target->setX(target->x() - rx); + target->setY(target->y() - ry); + } else if (target) { + target->setItemParent(targetParent); + } +} + /*! \preliminary \qmlclass ParentChange @@ -76,32 +134,32 @@ QmlParentChange::~QmlParentChange() /*! \qmlproperty Object ParentChange::target - This property holds the object to be reparented + This property holds the item to be reparented */ -QObject *QmlParentChange::object() const +QFxItem *QmlParentChange::object() const { Q_D(const QmlParentChange); return d->target; } -void QmlParentChange::setObject(QObject *target) +void QmlParentChange::setObject(QFxItem *target) { Q_D(QmlParentChange); d->target = target; } /*! - \qmlproperty Object ParentChange::parent - This property holds the parent for the object in this state + \qmlproperty Item ParentChange::parent + This property holds the parent for the item in this state */ -QObject *QmlParentChange::parent() const +QFxItem *QmlParentChange::parent() const { Q_D(const QmlParentChange); return d->parent; } -void QmlParentChange::setParent(QObject *parent) +void QmlParentChange::setParent(QFxItem *parent) { Q_D(QmlParentChange); d->parent = parent; @@ -113,27 +171,31 @@ QmlStateOperation::ActionList QmlParentChange::actions() if (!d->target || !d->parent) return ActionList(); - QString propName(QLatin1String("moveToParent")); - QmlMetaProperty prop(d->target, propName); - if (!prop.isValid()) { - qmlInfo(this) << d->target->metaObject()->className() - << "has no property named" << propName; - return ActionList(); - }else if (!prop.isWritable()){ - qmlInfo(this) << d->target->metaObject()->className() << propName - << "is not a writable property and cannot be set."; - return ActionList(); - } - QVariant cur = prop.read(); - Action a; - a.property = prop; - a.fromValue = cur; - a.toValue = qVariantFromValue(d->parent); + a.event = this; return ActionList() << a; } +void QmlParentChange::execute() +{ + Q_D(QmlParentChange); + if (d->target) + d->origParent = d->target->itemParent(); + d->doChange(d->parent); +} + +bool QmlParentChange::isReversable() +{ + return true; +} + +void QmlParentChange::reverse() +{ + Q_D(QmlParentChange); + d->doChange(d->origParent); +} + class QmlRunScriptPrivate : public QObjectPrivate { public: diff --git a/src/declarative/util/qmlstateoperations.h b/src/declarative/util/qmlstateoperations.h index 221373b..acbe05e 100644 --- a/src/declarative/util/qmlstateoperations.h +++ b/src/declarative/util/qmlstateoperations.h @@ -43,6 +43,7 @@ #define QMLSTATEOPERATIONS_H #include +#include QT_BEGIN_HEADER @@ -51,24 +52,28 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QmlParentChangePrivate; -class Q_DECLARATIVE_EXPORT QmlParentChange : public QmlStateOperation +class Q_DECLARATIVE_EXPORT QmlParentChange : public QmlStateOperation, public ActionEvent { Q_OBJECT Q_DECLARE_PRIVATE(QmlParentChange) - Q_PROPERTY(QObject *target READ object WRITE setObject) - Q_PROPERTY(QObject *parent READ parent WRITE setParent) + Q_PROPERTY(QFxItem *target READ object WRITE setObject) + Q_PROPERTY(QFxItem *parent READ parent WRITE setParent) public: QmlParentChange(QObject *parent=0); ~QmlParentChange(); - QObject *object() const; - void setObject(QObject *); + QFxItem *object() const; + void setObject(QFxItem *); - QObject *parent() const; - void setParent(QObject *); + QFxItem *parent() const; + void setParent(QFxItem *); virtual ActionList actions(); + + virtual void execute(); + virtual bool isReversable(); + virtual void reverse(); }; class QmlRunScriptPrivate; -- cgit v0.12 From 60aeb88aebb18dc326667f45d734fea38743bf02 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Wed, 22 Jul 2009 15:11:43 +1000 Subject: Fix GraphicsObjectContainer. --- src/declarative/fx/qfxgraphicsobjectcontainer.cpp | 1 + src/declarative/fx/qfxgraphicsobjectcontainer.h | 1 + 2 files changed, 2 insertions(+) diff --git a/src/declarative/fx/qfxgraphicsobjectcontainer.cpp b/src/declarative/fx/qfxgraphicsobjectcontainer.cpp index 479a21d..a82ea3d 100644 --- a/src/declarative/fx/qfxgraphicsobjectcontainer.cpp +++ b/src/declarative/fx/qfxgraphicsobjectcontainer.cpp @@ -55,6 +55,7 @@ QT_BEGIN_NAMESPACE \brief The QFxGraphicsObjectContainer class allows you to add QGraphicsObjects into Fluid UI applications. */ +QML_DEFINE_NOCREATE_TYPE(QGraphicsObject) QML_DEFINE_TYPE(QFxGraphicsObjectContainer, GraphicsObjectContainer) QFxGraphicsObjectContainer::QFxGraphicsObjectContainer(QFxItem *parent) diff --git a/src/declarative/fx/qfxgraphicsobjectcontainer.h b/src/declarative/fx/qfxgraphicsobjectcontainer.h index e118555..165bc48 100644 --- a/src/declarative/fx/qfxgraphicsobjectcontainer.h +++ b/src/declarative/fx/qfxgraphicsobjectcontainer.h @@ -75,6 +75,7 @@ private: QT_END_NAMESPACE +QML_DECLARE_TYPE(QGraphicsObject) QML_DECLARE_TYPE(QFxGraphicsObjectContainer) QT_END_HEADER -- cgit v0.12 From aa46924b3165e87ae195964fd18396829673bca7 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Tue, 21 Jul 2009 08:50:00 +0200 Subject: First round of cleanups for QFxItem Removed some methods that are already implemented in QGraphicsItem/Object. --- src/declarative/fx/qfxflickable.cpp | 2 +- src/declarative/fx/qfxitem.cpp | 101 ---------------------------------- src/declarative/fx/qfxitem.h | 61 ++++++++------------ src/declarative/fx/qfxitem_p.h | 5 +- src/declarative/fx/qfxpainteditem.cpp | 6 +- src/declarative/fx/qfxpathview.cpp | 4 +- src/gui/graphicsview/qgraphicsitem.h | 4 +- 7 files changed, 33 insertions(+), 150 deletions(-) diff --git a/src/declarative/fx/qfxflickable.cpp b/src/declarative/fx/qfxflickable.cpp index 24f6d72..1db6e8b 100644 --- a/src/declarative/fx/qfxflickable.cpp +++ b/src/declarative/fx/qfxflickable.cpp @@ -1019,7 +1019,7 @@ bool QFxFlickable::sendMouseEvent(QGraphicsSceneMouseEvent *event) { Q_D(QFxFlickable); QGraphicsSceneMouseEvent mouseEvent(event->type()); - QRectF myRect = mapToScene(QRectF(0, 0, width(), height())); + QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect(); QFxItem *grabber = static_cast(mouseGrabberItem()); if ((d->stealMouse || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) { mouseEvent.setAccepted(false); diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index c439032..90595ff 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -349,22 +349,6 @@ void QFxContents::setItem(QFxItem *item) */ /*! - \fn void QFxItem::visibleChanged() - - This signal is emitted when the visibility of the item changes. - - \sa setVisible() -*/ - -/*! - \fn void QFxItem::opacityChanged() - - This signal is emitted when the opacity of the item changes. - - \sa opacity(), setOpacity() -*/ - -/*! \fn void QFxItem::parentChanged() This signal is emitted when the parent of the item changes. @@ -1068,14 +1052,6 @@ void QFxItem::keyReleaseEvent(QKeyEvent *event) } /*! - Returns the bounding rectangle of the item in scene coordinates. -*/ -QRectF QFxItem::sceneBoundingRect() const -{ - return QRectF(mapToScene(QPointF(0,0)), QSize(width(), height())); -} - -/*! \qmlproperty string Item::id This property holds the identifier for the item. @@ -1503,26 +1479,6 @@ void QFxItem::setRotation(qreal rotation) */ /*! - \property QFxItem::opacity - - The opacity of the item. Opacity is specified as a number between 0 - (fully transparent) and 1 (fully opaque). The default is 1. - - Opacity is an \e inherited attribute. That is, the opacity is - also applied individually to child items. -*/ - -void QFxItem::setOpacity(qreal v) -{ - if (v == opacity()) - return; - - QGraphicsItem::setOpacity(v); - - emit opacityChanged(); -} - -/*! Returns a value indicating whether the mouse should remain with this item. */ @@ -1775,43 +1731,6 @@ QList *QFxItem::transform() return &(d->_transform); } -/*! - Returns true if the item is visible; otherwise returns false. - - An item is considered visible if its opacity is not 0. -*/ -bool QFxItem::isVisible() const -{ - Q_D(const QFxItem); - return d->visible; -} - -/*! - \property QFxItem::visible - - This property specifies whether the item is visible or invisible. - - Setting visibility to false sets opacity to 0. Setting the - visibility to true restores the opacity to its previous value. - - \sa isVisible() -*/ -void QFxItem::setVisible(bool visible) -{ - Q_D(QFxItem); - if (visible == d->visible) - return; - - d->visible = visible; - if (visible) - setOpacity(d->visibleOp); - else { - d->visibleOp = opacity(); - setOpacity(0); - } - - emit visibleChanged(); -} /*! \internal */ @@ -2281,26 +2200,6 @@ QRect QFxItem::itemBoundingRect() return boundingRect().toAlignedRect(); } -QPointF QFxItem::mapFromScene(const QPointF &p) const -{ - return QGraphicsItem::mapFromScene(p); -} - -QRectF QFxItem::mapFromScene(const QRectF &r) const -{ - return QGraphicsItem::mapFromScene(r).boundingRect(); -} - -QPointF QFxItem::mapToScene(const QPointF &p) const -{ - return QGraphicsItem::mapToScene(p); -} - -QRectF QFxItem::mapToScene(const QRectF &r) const -{ - return QGraphicsItem::mapToScene(r).boundingRect(); -} - QTransform QFxItem::transform() const { Q_D(const QFxItem); diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 53992d3..ddd3752 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -100,7 +100,7 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_INTERFACES(QmlParserStatus) Q_PROPERTY(QFxItem * parent READ itemParent WRITE setItemParent NOTIFY parentChanged DESIGNABLE false FINAL) - Q_PROPERTY(QString id READ id WRITE setId) + Q_PROPERTY(QString id READ id WRITE setId) // ### remove Q_PROPERTY(QmlList* children READ children DESIGNABLE false) Q_PROPERTY(QmlList* resources READ resources DESIGNABLE false) Q_PROPERTY(QFxAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL) @@ -109,9 +109,9 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_PROPERTY(QmlList* states READ states DESIGNABLE false) Q_PROPERTY(QmlList* transitions READ transitions DESIGNABLE false) Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged) - Q_PROPERTY(QUrl qml READ qml WRITE setQml NOTIFY qmlChanged) - Q_PROPERTY(QFxItem *qmlItem READ qmlItem NOTIFY qmlChanged) - Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged FINAL) + Q_PROPERTY(QUrl qml READ qml WRITE setQml NOTIFY qmlChanged) // ### name? Move to own class? + Q_PROPERTY(QFxItem *qmlItem READ qmlItem NOTIFY qmlChanged) // ### see above + Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged FINAL) // ### use method in QGO Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged FINAL) Q_PROPERTY(qreal z READ z WRITE setZ FINAL) Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged FINAL) @@ -124,15 +124,13 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_PROPERTY(QFxAnchorLine verticalCenter READ verticalCenter CONSTANT FINAL) Q_PROPERTY(QFxAnchorLine baseline READ baseline CONSTANT FINAL) Q_PROPERTY(qreal baselineOffset READ baselineOffset WRITE setBaselineOffset NOTIFY baselineOffsetChanged) - Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged) - Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged) - Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) - Q_PROPERTY(bool clip READ clip WRITE setClip) + Q_PROPERTY(qreal rotation READ rotation WRITE setRotation NOTIFY rotationChanged) // ## remove me + Q_PROPERTY(qreal scale READ scale WRITE setScale NOTIFY scaleChanged) // ### remove me + Q_PROPERTY(bool clip READ clip WRITE setClip) // ### move to QGI/QGO, NOTIFY Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL) Q_PROPERTY(bool activeFocus READ hasActiveFocus NOTIFY activeFocusChanged FINAL) - Q_PROPERTY(QList* transform READ transform) - Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) - Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin) + Q_PROPERTY(QList* transform READ transform) // ## QGI/QGO + Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin) // movbe to QGI Q_ENUMS(TransformOrigin) Q_CLASSINFO("DefaultProperty", "data") @@ -160,11 +158,11 @@ public: QFxItem(QFxItem *parent = 0); virtual ~QFxItem(); - QFxItem *itemParent() const; + QFxItem *itemParent() const; // ### remove me QFxItem *parentItem() const; - void setItemParent(QFxItem *parent); + void setItemParent(QFxItem *parent); // ## setParentItem - QString id() const; + QString id() const; // ### remove me void setId(const QString &); QmlList *data(); @@ -199,21 +197,14 @@ public: qreal scale() const; void setScale(qreal); - void setOpacity(qreal); - QList *transform(); - bool isVisible() const; - void setVisible(bool); - - virtual QString propertyInfo() const; + virtual QString propertyInfo() const; // ### unused, remove me bool isClassComplete() const; bool isComponentComplete() const; - QRectF sceneBoundingRect() const; - - void updateTransform(); + void updateTransform(); // ### private! bool keepMouseGrab() const; void setKeepMouseGrab(bool); @@ -231,13 +222,13 @@ public: qreal width() const; void setWidth(qreal); void setImplicitWidth(qreal); - bool widthValid() const; + bool widthValid() const; // ### better name? qreal height() const; void setHeight(qreal); void setImplicitHeight(qreal); - bool heightValid() const; + bool heightValid() const; // ### better name? - QPointF scenePos() const; + QPointF scenePos() const; // ### remove me TransformOrigin transformOrigin() const; void setTransformOrigin(TransformOrigin); @@ -245,19 +236,14 @@ public: void setParent(QFxItem *); - QRect itemBoundingRect(); + QRect itemBoundingRect(); // ### remove me void setPaintMargin(qreal margin); QRectF boundingRect() const; virtual void paintContents(QPainter &); - QPointF mapFromScene(const QPointF &) const; - QRectF mapFromScene(const QRectF &) const; - QPointF mapToScene(const QPointF &) const; - QRectF mapToScene(const QRectF &) const; - - QTransform transform() const; - void setTransform(const QTransform &); + QTransform transform() const; // ### remove me + void setTransform(const QTransform &); // ### remove me QFxItem *mouseGrabberItem() const; @@ -268,7 +254,7 @@ public: bool hasActiveFocus() const; - static QPixmap string(const QString &, const QColor & = Qt::black, const QFont & = QFont()); + static QPixmap string(const QString &, const QColor & = Qt::black, const QFont & = QFont()); // ### remove me, make private for now QVariant inputMethodQuery(Qt::InputMethodQuery query) const; //### for KeyProxy @@ -289,8 +275,6 @@ Q_SIGNALS: void keyRelease(QFxKeyEvent *event); void rotationChanged(); void scaleChanged(); - void opacityChanged(); - void visibleChanged(); void qmlChanged(); void newChildCreated(const QString &url, QScriptValue); @@ -323,6 +307,7 @@ protected: QFxItem(QFxItemPrivate &dd, QFxItem *parent = 0); private: + // ### public? QFxAnchorLine left() const; QFxAnchorLine right() const; QFxAnchorLine horizontalCenter() const; @@ -331,6 +316,7 @@ private: QFxAnchorLine verticalCenter() const; QFxAnchorLine baseline() const; + // ### move to d-pointer void init(QFxItem *parent); friend class QmlStatePrivate; friend class QFxAnchors; @@ -340,6 +326,7 @@ private: Q_DECLARE_OPERATORS_FOR_FLAGS(QFxItem::Options) +// ### move to QGO template T qobject_cast(QGraphicsItem *item) { diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index eddeb9b..1242703 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -76,7 +76,7 @@ public: : _anchors(0), _contents(0), qmlItem(0), _qmlcomp(0), _baselineOffset(0), _rotation(0.), _classComplete(true), _componentComplete(true), _keepMouse(false), - visible(true), _anchorLines(0), visibleOp(1), + _anchorLines(0), _stateGroup(0), canvas(0), origin(QFxItem::TopLeft), options(QFxItem::NoOption), widthValid(false), heightValid(false), width(0), height(0), @@ -151,7 +151,6 @@ public: bool _classComplete:1; bool _componentComplete:1; bool _keepMouse:1; - bool visible:1; QmlChildren _qmlChildren; @@ -173,8 +172,6 @@ public: return _anchorLines; } - float visibleOp; - QmlStateGroup *states(); QmlStateGroup *_stateGroup; diff --git a/src/declarative/fx/qfxpainteditem.cpp b/src/declarative/fx/qfxpainteditem.cpp index 7ff3361..a4055eb 100644 --- a/src/declarative/fx/qfxpainteditem.cpp +++ b/src/declarative/fx/qfxpainteditem.cpp @@ -224,11 +224,11 @@ void QFxPaintedItem::paintContents(QPainter &p) p.setRenderHints(QPainter::SmoothPixmapTransform, true); QRectF clipf = p.clipRegion().boundingRect(); if (clipf.isEmpty()) - clipf = mapToScene(content); // ### Inefficient: Maps toScene and then fromScene + clipf = mapToScene(content).boundingRect(); // ### Inefficient: Maps toScene and then fromScene else - clipf = mapToScene(clipf); + clipf = mapToScene(clipf).boundingRect(); - const QRect clip = mapFromScene(clipf).toRect(); + const QRect clip = mapFromScene(clipf).boundingRect().toRect(); QRegion topaint(clip); topaint &= content; diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp index 3c61050..47364d0 100644 --- a/src/declarative/fx/qfxpathview.cpp +++ b/src/declarative/fx/qfxpathview.cpp @@ -411,7 +411,7 @@ void QFxPathView::mousePressEvent(QGraphicsSceneMouseEvent *event) int idx = 0; for (; idx < d->items.count(); ++idx) { QRectF rect = d->items.at(idx)->boundingRect(); - rect = d->items.at(idx)->mapToScene(rect); + rect = d->items.at(idx)->mapToScene(rect).boundingRect(); if (rect.contains(scenePoint)) break; } @@ -495,7 +495,7 @@ bool QFxPathView::sendMouseEvent(QGraphicsSceneMouseEvent *event) { Q_D(QFxPathView); QGraphicsSceneMouseEvent mouseEvent(event->type()); - QRectF myRect = mapToScene(QRectF(0, 0, width(), height())); + QRectF myRect = mapToScene(QRectF(0, 0, width(), height())).boundingRect(); QFxItem *grabber = static_cast(mouseGrabberItem()); if ((d->stealMouse || myRect.contains(event->scenePos().toPoint())) && (!grabber || !grabber->keepMouseGrab())) { mouseEvent.setAccepted(false); diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index 7240eaa..6012053 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -510,9 +510,9 @@ class Q_GUI_EXPORT QGraphicsObject : public QObject, public QGraphicsItem Q_OBJECT Q_PROPERTY(QGraphicsObject * parent READ parentObject WRITE setParentItem NOTIFY parentChanged DESIGNABLE false) Q_PROPERTY(QString id READ objectName WRITE setObjectName) - Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged) + Q_PROPERTY(qreal opacity READ opacity WRITE setOpacity NOTIFY opacityChanged FINAL) Q_PROPERTY(bool enabled READ isEnabled WRITE setEnabled NOTIFY enabledChanged) - Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged) + Q_PROPERTY(bool visible READ isVisible WRITE setVisible NOTIFY visibleChanged FINAL) Q_PROPERTY(QPointF pos READ pos WRITE setPos) Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged) Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged) -- cgit v0.12 From 0e1c97f5835ace6ce52ef6a1ae23f8e4463ba742 Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 22 Jul 2009 07:28:24 +0200 Subject: More cleanups in QFxItem Remove the pos, x and y properties and use the ones in QGraphicsObject instead --- src/declarative/fx/qfxitem.cpp | 45 ---------------------------------- src/declarative/fx/qfxitem.h | 14 +++-------- src/declarative/fx/qfxitem_p.h | 8 ++++++ src/gui/graphicsview/qgraphicsitem_p.h | 2 +- 4 files changed, 13 insertions(+), 56 deletions(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 90595ff..66a2d99 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1974,14 +1974,6 @@ void QFxItem::parentChanged(QFxItem *, QFxItem *) } /*! - Returns the item's (0, 0) point relative to its parent. - */ -QPointF QFxItem::pos() const -{ - return QPointF(x(),y()); -} - -/*! Returns the item's (0, 0) point mapped to scene coordinates. */ QPointF QFxItem::scenePos() const @@ -2037,32 +2029,6 @@ qreal QFxItem::z() const return zValue(); } -void QFxItem::setX(qreal x) -{ - if (x == this->x()) - return; - - qreal oldX = this->x(); - - QGraphicsItem::setPos(x, y()); - - geometryChanged(QRectF(this->x(), y(), width(), height()), - QRectF(oldX, y(), width(), height())); -} - -void QFxItem::setY(qreal y) -{ - if (y == this->y()) - return; - - qreal oldY = this->y(); - - QGraphicsItem::setPos(x(), y); - - geometryChanged(QRectF(x(), this->y(), width(), height()), - QRectF(x(), oldY, width(), height())); -} - void QFxItem::setZ(qreal z) { if (z == this->z()) @@ -2166,17 +2132,6 @@ bool QFxItem::heightValid() const return d->heightValid; } -void QFxItem::setPos(const QPointF &point) -{ - qreal oldX = x(); - qreal oldY = y(); - - QGraphicsItem::setPos(point); - - geometryChanged(QRectF(x(), y(), width(), height()), - QRectF(oldX, oldY, width(), height())); -} - qreal QFxItem::scale() const { Q_D(const QFxItem); diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index ddd3752..4d96076 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -111,9 +111,7 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged) Q_PROPERTY(QUrl qml READ qml WRITE setQml NOTIFY qmlChanged) // ### name? Move to own class? Q_PROPERTY(QFxItem *qmlItem READ qmlItem NOTIFY qmlChanged) // ### see above - Q_PROPERTY(qreal x READ x WRITE setX NOTIFY xChanged FINAL) // ### use method in QGO - Q_PROPERTY(qreal y READ y WRITE setY NOTIFY yChanged FINAL) - Q_PROPERTY(qreal z READ z WRITE setZ FINAL) + Q_PROPERTY(qreal z READ z WRITE setZ FINAL) // ### use method in QGO Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged FINAL) Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged FINAL) Q_PROPERTY(QFxAnchorLine left READ left CONSTANT FINAL) @@ -130,11 +128,11 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_PROPERTY(bool focus READ hasFocus WRITE setFocus NOTIFY focusChanged FINAL) Q_PROPERTY(bool activeFocus READ hasActiveFocus NOTIFY activeFocusChanged FINAL) Q_PROPERTY(QList* transform READ transform) // ## QGI/QGO - Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin) // movbe to QGI + Q_PROPERTY(TransformOrigin transformOrigin READ transformOrigin WRITE setTransformOrigin) // ### move to QGI Q_ENUMS(TransformOrigin) Q_CLASSINFO("DefaultProperty", "data") - typedef QHash QmlChildren; + typedef QHash QmlChildren; // ### public: enum Option { NoOption = 0x00000000, @@ -213,11 +211,7 @@ public: void setOptions(Options, bool set = true); qreal z() const; - QPointF pos() const; - void setX(qreal); - void setY(qreal); - virtual void setZ(qreal); - void setPos(const QPointF &); + void setZ(qreal); qreal width() const; void setWidth(qreal); diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index 1242703..1615ad8 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -205,6 +205,14 @@ public: QGraphicsItemPrivate::setFocusItemForArea(b); q->focusChanged(b); } + + virtual void setPosHelper(const QPointF &pos) + { + Q_Q(QFxItem); + QRectF oldGeometry(this->pos.x(), this->pos.y(), width, height); + QGraphicsItemPrivate::setPosHelper(pos); + q->geometryChanged(QRectF(this->pos.x(), this->pos.y(), width, height), oldGeometry); + } }; QT_END_NAMESPACE diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index d14ae7f..9e30f54 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -199,7 +199,7 @@ public: virtual QVariant inputMethodQueryHelper(Qt::InputMethodQuery query) const; static bool movableAncestorIsSelected(const QGraphicsItem *item); - void setPosHelper(const QPointF &pos); + virtual void setPosHelper(const QPointF &pos); void setTransformHelper(const QTransform &transform); void setVisibleHelper(bool newVisible, bool explicitly, bool update = true); void setEnabledHelper(bool newEnabled, bool explicitly, bool update = true); -- cgit v0.12 From 8dc527a3837c937630c8bbbab034b8bc84d496fb Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 22 Jul 2009 07:50:23 +0200 Subject: Remove an unused method in QFxItem propertyInfo was not used by anything, let's just get rid of it. --- src/declarative/extra/qfxparticles.cpp | 6 ------ src/declarative/extra/qfxparticles.h | 2 -- src/declarative/fx/qfximage.cpp | 6 ------ src/declarative/fx/qfximage.h | 1 - src/declarative/fx/qfxitem.cpp | 7 ------- src/declarative/fx/qfxitem.h | 2 -- src/declarative/fx/qfxtext.cpp | 6 ------ src/declarative/fx/qfxtext.h | 2 -- src/declarative/fx/qfxtextedit.cpp | 9 --------- src/declarative/fx/qfxtextedit.h | 2 -- src/declarative/fx/qfxwebview.cpp | 5 ----- src/declarative/fx/qfxwebview.h | 2 -- 12 files changed, 50 deletions(-) diff --git a/src/declarative/extra/qfxparticles.cpp b/src/declarative/extra/qfxparticles.cpp index 08d38ba..a7b01dd 100644 --- a/src/declarative/extra/qfxparticles.cpp +++ b/src/declarative/extra/qfxparticles.cpp @@ -1041,12 +1041,6 @@ void QFxParticles::setMotion(QFxParticleMotion *motion) d->motion = motion; } -QString QFxParticles::propertyInfo() const -{ - Q_D(const QFxParticles); - return d->url.toString(); -} - void QFxParticlesPainter::updateSize() { const int parentX = parentItem()->x(); diff --git a/src/declarative/extra/qfxparticles.h b/src/declarative/extra/qfxparticles.h index 9f085cd..2574f7f 100644 --- a/src/declarative/extra/qfxparticles.h +++ b/src/declarative/extra/qfxparticles.h @@ -203,8 +203,6 @@ public: QFxParticleMotion *motion() const; void setMotion(QFxParticleMotion *); - virtual QString propertyInfo() const; - void paintContents(QPainter &p); protected: diff --git a/src/declarative/fx/qfximage.cpp b/src/declarative/fx/qfximage.cpp index 69030d2..7445606 100644 --- a/src/declarative/fx/qfximage.cpp +++ b/src/declarative/fx/qfximage.cpp @@ -388,12 +388,6 @@ void QFxImage::paintContents(QPainter &p) } } -QString QFxImage::propertyInfo() const -{ - Q_D(const QFxImage); - return d->url.toString(); -} - /*! \qmlproperty enum Image::status diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h index 7b3445c..9c0dde8 100644 --- a/src/declarative/fx/qfximage.h +++ b/src/declarative/fx/qfximage.h @@ -91,7 +91,6 @@ public: QUrl source() const; virtual void setSource(const QUrl &url); - virtual QString propertyInfo() const; void paintContents(QPainter &painter); Q_SIGNALS: diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 66a2d99..354e4cc 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1732,13 +1732,6 @@ QList *QFxItem::transform() } -/*! \internal -*/ -QString QFxItem::propertyInfo() const -{ - return QString(); -} - /*! Creates a new child of the given component \a type. The newChildCreated() signal will be emitted when and if the child is diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 4d96076..0dcf852 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -197,8 +197,6 @@ public: QList *transform(); - virtual QString propertyInfo() const; // ### unused, remove me - bool isClassComplete() const; bool isComponentComplete() const; diff --git a/src/declarative/fx/qfxtext.cpp b/src/declarative/fx/qfxtext.cpp index 2bae53f..3d36bf3 100644 --- a/src/declarative/fx/qfxtext.cpp +++ b/src/declarative/fx/qfxtext.cpp @@ -575,12 +575,6 @@ void QFxTextPrivate::updateSize() // ### text layout handling should be profiled and optimized as needed // what about QStackTextEngine engine(tmp, d->font.font()); QTextLayout textLayout(&engine); -QString QFxText::propertyInfo() const -{ - Q_D(const QFxText); - return QChar(QLatin1Char('\"')) + d->text + QChar(QLatin1Char('\"')); -} - void QFxTextPrivate::drawOutline() { QPixmap img = QPixmap(imgCache.size()); diff --git a/src/declarative/fx/qfxtext.h b/src/declarative/fx/qfxtext.h index b7ec333..a02b76b 100644 --- a/src/declarative/fx/qfxtext.h +++ b/src/declarative/fx/qfxtext.h @@ -125,8 +125,6 @@ public: bool smoothTransform() const; void setSmoothTransform(bool); - virtual QString propertyInfo() const; - void paintContents(QPainter &p); virtual void componentComplete(); diff --git a/src/declarative/fx/qfxtextedit.cpp b/src/declarative/fx/qfxtextedit.cpp index f9cde7c..4a8085b 100644 --- a/src/declarative/fx/qfxtextedit.cpp +++ b/src/declarative/fx/qfxtextedit.cpp @@ -679,15 +679,6 @@ void QFxTextEdit::geometryChanged(const QRectF &newGeometry, } /*! - \internal -*/ -QString QFxTextEdit::propertyInfo() const -{ - Q_D(const QFxTextEdit); - return QChar(QLatin1Char('\"')) + d->text + QChar(QLatin1Char('\"')); -} - -/*! Ensures any delayed caching or data loading the class needs to performed is complete. */ diff --git a/src/declarative/fx/qfxtextedit.h b/src/declarative/fx/qfxtextedit.h index 77fac29..132b474 100644 --- a/src/declarative/fx/qfxtextedit.h +++ b/src/declarative/fx/qfxtextedit.h @@ -161,8 +161,6 @@ public: qreal textMargin() const; void setTextMargin(qreal margin); - virtual QString propertyInfo() const; - virtual void componentComplete(); /* FROM EDIT */ diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index 42b8d2c..6c23198 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -507,11 +507,6 @@ void QFxWebView::drawContents(QPainter *p, const QRect &r) page()->mainFrame()->render(p,r); } -QString QFxWebView::propertyInfo() const -{ - return page()->mainFrame()->url().toString(); -} - static QMouseEvent *sceneMouseEventToMouseEvent(QGraphicsSceneMouseEvent *e) { QEvent::Type t; diff --git a/src/declarative/fx/qfxwebview.h b/src/declarative/fx/qfxwebview.h index ab20281..7f22439 100644 --- a/src/declarative/fx/qfxwebview.h +++ b/src/declarative/fx/qfxwebview.h @@ -139,8 +139,6 @@ public: QAction *forwardAction() const; QAction *stopAction() const; - virtual QString propertyInfo() const; - QWebPage *page() const; void setPage(QWebPage *page); -- cgit v0.12 From d5f46ae26ee0cd4a3ccdde526f011b3bdd884abc Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 22 Jul 2009 08:56:48 +0200 Subject: unify z-value handling in graphics and fx items. Add a ItemNegativeZStacksBehindParent flag to QGraphicsItem to get the behavior we need in QFxItems. Removed the z property in QFxItems. --- src/declarative/extra/qfxflowview.cpp | 6 +++--- src/declarative/fx/qfxgridview.cpp | 2 +- src/declarative/fx/qfxitem.cpp | 18 ------------------ src/declarative/fx/qfxitem.h | 4 ---- src/declarative/fx/qfxitem_p.h | 5 +++-- src/declarative/fx/qfxlistview.cpp | 2 +- src/declarative/fx/qfxpathview.cpp | 8 ++++---- src/gui/graphicsview/qgraphicsitem.cpp | 11 +++++++++++ src/gui/graphicsview/qgraphicsitem.h | 3 ++- src/gui/graphicsview/qgraphicsitem_p.h | 4 ++-- 10 files changed, 27 insertions(+), 36 deletions(-) diff --git a/src/declarative/extra/qfxflowview.cpp b/src/declarative/extra/qfxflowview.cpp index 1676512..e1200c7 100644 --- a/src/declarative/extra/qfxflowview.cpp +++ b/src/declarative/extra/qfxflowview.cpp @@ -132,7 +132,7 @@ void QFxFlowView::refresh() for (int ii = 0; ii < m_model->count(); ++ii) { if (QFxItem *item = m_model->item(ii)) { item->setParent(this); - item->setZ(0); + item->setZValue(0); m_items << item; } } @@ -296,7 +296,7 @@ void QFxFlowView::mousePressEvent(QGraphicsSceneMouseEvent *event) if (r.contains(event->pos())) { m_dragItem = item; - m_dragItem->setZ(1); + m_dragItem->setZValue(1); m_dragOffset = r.topLeft() - event->pos(); event->accept(); return; @@ -316,7 +316,7 @@ void QFxFlowView::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) { Q_UNUSED(event); if (m_dragItem) { - m_dragItem->setZ(0); + m_dragItem->setZValue(0); clearTimeLine(); diff --git a/src/declarative/fx/qfxgridview.cpp b/src/declarative/fx/qfxgridview.cpp index 3c80e98..9528af7 100644 --- a/src/declarative/fx/qfxgridview.cpp +++ b/src/declarative/fx/qfxgridview.cpp @@ -356,7 +356,7 @@ FxGridItem *QFxGridViewPrivate::createItem(int modelIndex) listItem->index = modelIndex; // complete model->completeItem(); - listItem->item->setZ(modelIndex + 1); + listItem->item->setZValue(modelIndex + 1); listItem->item->setParent(q->viewport()); } requestedIndex = 0; diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 354e4cc..42ff436 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -2017,24 +2017,6 @@ QPointF QFxItem::transformOriginPoint() const return d->transformOrigin(); } -qreal QFxItem::z() const -{ - return zValue(); -} - -void QFxItem::setZ(qreal z) -{ - if (z == this->z()) - return; - - if (z < 0) - setFlag(QGraphicsItem::ItemStacksBehindParent, true); - else - setFlag(QGraphicsItem::ItemStacksBehindParent, false); - - setZValue(z); -} - qreal QFxItem::width() const { Q_D(const QFxItem); diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 0dcf852..8e0916e 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -111,7 +111,6 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_PROPERTY(QString state READ state WRITE setState NOTIFY stateChanged) Q_PROPERTY(QUrl qml READ qml WRITE setQml NOTIFY qmlChanged) // ### name? Move to own class? Q_PROPERTY(QFxItem *qmlItem READ qmlItem NOTIFY qmlChanged) // ### see above - Q_PROPERTY(qreal z READ z WRITE setZ FINAL) // ### use method in QGO Q_PROPERTY(qreal width READ width WRITE setWidth NOTIFY widthChanged FINAL) Q_PROPERTY(qreal height READ height WRITE setHeight NOTIFY heightChanged FINAL) Q_PROPERTY(QFxAnchorLine left READ left CONSTANT FINAL) @@ -208,9 +207,6 @@ public: Options options() const; void setOptions(Options, bool set = true); - qreal z() const; - void setZ(qreal); - qreal width() const; void setWidth(qreal); void setImplicitWidth(qreal); diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index 1615ad8..ec45d6e 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -93,8 +93,9 @@ public: q->setItemParent(parent); _baselineOffset.invalidate(); q->setAcceptedMouseButtons(Qt::NoButton); - q->setFlag(QGraphicsItem::ItemHasNoContents, true); - q->setFlag(QGraphicsItem::ItemIsFocusable, true); + q->setFlags(QGraphicsItem::ItemHasNoContents | + QGraphicsItem::ItemIsFocusable | + QGraphicsItem::ItemNegativeZStacksBehindParent); mouseSetsFocus = false; } diff --git a/src/declarative/fx/qfxlistview.cpp b/src/declarative/fx/qfxlistview.cpp index 50564fb..3515b78 100644 --- a/src/declarative/fx/qfxlistview.cpp +++ b/src/declarative/fx/qfxlistview.cpp @@ -423,7 +423,7 @@ FxListItem *QFxListViewPrivate::createItem(int modelIndex) } // complete model->completeItem(); - listItem->item->setZ(modelIndex + 1); + listItem->item->setZValue(modelIndex + 1); listItem->item->setParent(q->viewport()); if (orient == Qt::Vertical) QObject::connect(listItem->item, SIGNAL(heightChanged()), q, SLOT(itemResized())); diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp index 47364d0..4f6fddd 100644 --- a/src/declarative/fx/qfxpathview.cpp +++ b/src/declarative/fx/qfxpathview.cpp @@ -581,7 +581,7 @@ void QFxPathViewPrivate::regenerate() return; } items.append(item); - item->setZ(i); + item->setZValue(i); } q->refill(); } @@ -639,7 +639,7 @@ void QFxPathView::refill() d->firstIndex %= d->model->count(); int index = (d->firstIndex + d->items.count())%d->model->count(); d->items << d->getItem(index); - d->items.last()->setZ(wrapIndex); + d->items.last()->setZValue(wrapIndex); d->pathOffset++; d->pathOffset=d->pathOffset % d->items.count(); } @@ -652,7 +652,7 @@ void QFxPathView::refill() if (d->firstIndex < 0) d->firstIndex = d->model->count() - 1; d->items.prepend(d->getItem(d->firstIndex)); - d->items.first()->setZ(d->firstIndex); + d->items.first()->setZValue(d->firstIndex); d->pathOffset--; if (d->pathOffset < 0) d->pathOffset = d->items.count() - 1; @@ -675,7 +675,7 @@ void QFxPathView::itemsInserted(int modelIndex, int count) if (d->pathItems == -1) { for (int i = 0; i < count; ++i) { QFxItem *item = d->getItem(modelIndex + i); - item->setZ(modelIndex + i); + item->setZValue(modelIndex + i); d->items.insert(modelIndex + i, item); } refill(); diff --git a/src/gui/graphicsview/qgraphicsitem.cpp b/src/gui/graphicsview/qgraphicsitem.cpp index 916724c..638f20f 100644 --- a/src/gui/graphicsview/qgraphicsitem.cpp +++ b/src/gui/graphicsview/qgraphicsitem.cpp @@ -327,6 +327,10 @@ \value ItemAcceptsInputMethod The item supports input methods typically used for Asian languages. This flag was introduced in Qt 4.6. + + \value ItemNegativeZStacksBehindParent The item automatically stacks + it's parent if it's z-value is negative. + This flag was introduced in Qt 4.6. */ /*! @@ -3726,6 +3730,13 @@ void QGraphicsItem::setZValue(qreal z) itemChange(ItemZValueHasChanged, newZVariant); + if(d_ptr->flags & ItemNegativeZStacksBehindParent) { + if (z < 0) + setFlag(QGraphicsItem::ItemStacksBehindParent, true); + else + setFlag(QGraphicsItem::ItemStacksBehindParent, false); + } + if (d_ptr->isObject) emit static_cast(this)->zChanged(); } diff --git a/src/gui/graphicsview/qgraphicsitem.h b/src/gui/graphicsview/qgraphicsitem.h index 6012053..ba7b5ef 100644 --- a/src/gui/graphicsview/qgraphicsitem.h +++ b/src/gui/graphicsview/qgraphicsitem.h @@ -100,7 +100,8 @@ public: ItemUsesExtendedStyleOption = 0x200, ItemHasNoContents = 0x400, ItemSendsGeometryChanges = 0x800, - ItemAcceptsInputMethod = 0x1000 + ItemAcceptsInputMethod = 0x1000, + ItemNegativeZStacksBehindParent = 0x2000 // NB! Don't forget to increase the d_ptr->flags bit field by 1 when adding a new flag. }; Q_DECLARE_FLAGS(GraphicsItemFlags, GraphicsItemFlag) diff --git a/src/gui/graphicsview/qgraphicsitem_p.h b/src/gui/graphicsview/qgraphicsitem_p.h index 9e30f54..ba24806 100644 --- a/src/gui/graphicsview/qgraphicsitem_p.h +++ b/src/gui/graphicsview/qgraphicsitem_p.h @@ -449,7 +449,7 @@ public: // New 32 bits quint32 fullUpdatePending : 1; - quint32 flags : 13; + quint32 flags : 14; quint32 dirtyChildrenBoundingRect : 1; quint32 paintedViewBoundingRectsNeedRepaint : 1; quint32 dirtySceneTransform : 1; @@ -466,7 +466,7 @@ public: quint32 isFocusItemForArea : 1; quint32 hasActiveFocus : 1; quint32 mouseSetsFocus : 1; - quint32 unused : 2; // feel free to use + quint32 unused : 1; // feel free to use // Optional stacking order int globalStackingOrder; -- cgit v0.12 From 7fd162fe2d38882ae81f6a7b7cf6a313764fdf0e Mon Sep 17 00:00:00 2001 From: Lars Knoll Date: Wed, 22 Jul 2009 09:03:13 +0200 Subject: remove the id property in QFxItem id's are handled by QML directly; the id property here is not actually used anymore. --- src/declarative/fx/qfxitem.cpp | 28 ---------------------------- src/declarative/fx/qfxitem.h | 4 ---- 2 files changed, 32 deletions(-) diff --git a/src/declarative/fx/qfxitem.cpp b/src/declarative/fx/qfxitem.cpp index 42ff436..212496c 100644 --- a/src/declarative/fx/qfxitem.cpp +++ b/src/declarative/fx/qfxitem.cpp @@ -1068,34 +1068,6 @@ void QFxItem::keyReleaseEvent(QKeyEvent *event) */ /*! - \property QFxItem::id - This property holds the identifier for the item. - - The identifier can be used in bindings and other expressions to - refer to the item. For example: - - \qml - Text { id: myText; ... } - Text { text: myText.text } - \endqml - - The identifier is available throughout the \l {components}{component} - where it is declared. The identifier must be unique in thecomponent. -*/ -QString QFxItem::id() const -{ - Q_D(const QFxItem); - return d->_id; -} - -void QFxItem::setId(const QString &id) -{ - Q_D(QFxItem); - setObjectName(id); - d->_id = id; -} - -/*! \internal */ QFxAnchorLine QFxItem::left() const diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 8e0916e..6e735b3 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -100,7 +100,6 @@ class Q_DECLARATIVE_EXPORT QFxItem : public QGraphicsObject, public QmlParserSta Q_INTERFACES(QmlParserStatus) Q_PROPERTY(QFxItem * parent READ itemParent WRITE setItemParent NOTIFY parentChanged DESIGNABLE false FINAL) - Q_PROPERTY(QString id READ id WRITE setId) // ### remove Q_PROPERTY(QmlList* children READ children DESIGNABLE false) Q_PROPERTY(QmlList* resources READ resources DESIGNABLE false) Q_PROPERTY(QFxAnchors * anchors READ anchors DESIGNABLE false CONSTANT FINAL) @@ -159,9 +158,6 @@ public: QFxItem *parentItem() const; void setItemParent(QFxItem *parent); // ## setParentItem - QString id() const; // ### remove me - void setId(const QString &); - QmlList *data(); QmlList *children(); QmlList *resources(); -- cgit v0.12 From 56195216c52b28dc05eb6b2944f0fac01a222fdf Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 23 Jul 2009 10:06:33 +1000 Subject: Minor header cleanup. --- src/declarative/fx/qfximage.h | 1 + src/declarative/fx/qfxitem.h | 2 -- src/declarative/fx/qfxitem_p.h | 1 + 3 files changed, 2 insertions(+), 2 deletions(-) diff --git a/src/declarative/fx/qfximage.h b/src/declarative/fx/qfximage.h index 9c0dde8..4b6e700 100644 --- a/src/declarative/fx/qfximage.h +++ b/src/declarative/fx/qfximage.h @@ -43,6 +43,7 @@ #define QFXIMAGE_H #include +#include #include diff --git a/src/declarative/fx/qfxitem.h b/src/declarative/fx/qfxitem.h index 6e735b3..e3f371e 100644 --- a/src/declarative/fx/qfxitem.h +++ b/src/declarative/fx/qfxitem.h @@ -48,9 +48,7 @@ #include #include #include -#include #include -#include #include #include diff --git a/src/declarative/fx/qfxitem_p.h b/src/declarative/fx/qfxitem_p.h index ec45d6e..029b8b0 100644 --- a/src/declarative/fx/qfxitem_p.h +++ b/src/declarative/fx/qfxitem_p.h @@ -54,6 +54,7 @@ // #include +#include #include #include #include -- cgit v0.12 From 0c1ab1a6a6652299ca28e60cad9b7f39017160e3 Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 23 Jul 2009 10:30:05 +1000 Subject: Fix State when handling. --- src/declarative/qml/qmlbinding.cpp | 2 +- src/declarative/qml/qmlbinding.h | 5 ++--- 2 files changed, 3 insertions(+), 4 deletions(-) diff --git a/src/declarative/qml/qmlbinding.cpp b/src/declarative/qml/qmlbinding.cpp index 57c1187..431dd66 100644 --- a/src/declarative/qml/qmlbinding.cpp +++ b/src/declarative/qml/qmlbinding.cpp @@ -52,7 +52,7 @@ Q_DECLARE_METATYPE(QList); QT_BEGIN_NAMESPACE -DEFINE_BOOL_CONFIG_OPTION(scriptWarnings, QML_SCRIPT_WARNINGS); +QML_DEFINE_NOCREATE_TYPE(QmlBinding); QmlBindingPrivate::QmlBindingPrivate() : inited(false), updating(false), enabled(true), mePtr(0) diff --git a/src/declarative/qml/qmlbinding.h b/src/declarative/qml/qmlbinding.h index 5f6d6f4..c2182d5 100644 --- a/src/declarative/qml/qmlbinding.h +++ b/src/declarative/qml/qmlbinding.h @@ -54,7 +54,6 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) -class QmlExpression; class QmlContext; class QmlBindingPrivate; class Q_DECLARATIVE_EXPORT QmlBinding : public QmlExpression @@ -84,10 +83,10 @@ private: Q_DECLARE_PRIVATE(QmlBinding) }; -Q_DECLARE_METATYPE(QmlBinding*); - QT_END_NAMESPACE +QML_DECLARE_TYPE(QmlBinding); + QT_END_HEADER #endif // QMLBINDING_H -- cgit v0.12 From af965934e6dbf8f581b1f9e241a08a9b2128472a Mon Sep 17 00:00:00 2001 From: Michael Brasser Date: Thu, 23 Jul 2009 11:13:24 +1000 Subject: Fix possible crash in XmlListModel. --- src/declarative/extra/qmlxmllistmodel.cpp | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/declarative/extra/qmlxmllistmodel.cpp b/src/declarative/extra/qmlxmllistmodel.cpp index 91ad538..1321f41 100644 --- a/src/declarative/extra/qmlxmllistmodel.cpp +++ b/src/declarative/extra/qmlxmllistmodel.cpp @@ -616,6 +616,7 @@ void QmlXmlListModel::requestFinished() { Q_D(QmlXmlListModel); if (d->reply->error() != QNetworkReply::NoError) { + disconnect(d->reply, 0, this, 0); d->reply->deleteLater(); d->reply = 0; d->status = Error; @@ -623,6 +624,7 @@ void QmlXmlListModel::requestFinished() d->status = Idle; QByteArray data = d->reply->readAll(); d->queryId = d->qmlXmlQuery.doQuery(d->query, d->namespaces, data, &d->roleObjects); + disconnect(d->reply, 0, this, 0); d->reply->deleteLater(); d->reply = 0; } -- cgit v0.12