From 275d2a37c0c7179e7f34cc467192a8838705d7c2 Mon Sep 17 00:00:00 2001 From: Aaron Kennedy Date: Mon, 20 Jul 2009 13:30:31 +1000 Subject: Rename QmlBindableValue to QmlBinding --- src/declarative/fx/qfxanchors.cpp | 1 - src/declarative/fx/qfxpathview.cpp | 1 - src/declarative/fx/qfxwebview.cpp | 1 - src/declarative/qml/qml.pri | 6 +- src/declarative/qml/qmlbindablevalue.cpp | 186 -------------------------- src/declarative/qml/qmlbindablevalue.h | 98 -------------- src/declarative/qml/qmlbindablevalue_p.h | 79 ----------- src/declarative/qml/qmlbinding.cpp | 186 ++++++++++++++++++++++++++ src/declarative/qml/qmlbinding.h | 98 ++++++++++++++ src/declarative/qml/qmlbinding_p.h | 79 +++++++++++ src/declarative/qml/qmlcomponent.cpp | 4 +- src/declarative/qml/qmlcomponent_p.h | 2 +- src/declarative/qml/qmlengine.cpp | 10 +- src/declarative/qml/qmlengine_p.h | 4 +- src/declarative/qml/qmlmetaproperty.cpp | 20 +-- src/declarative/qml/qmlmetaproperty.h | 6 +- src/declarative/qml/qmlparser.cpp | 1 - src/declarative/qml/qmlvme.cpp | 20 +-- src/declarative/util/qfxperf.cpp | 2 +- src/declarative/util/qfxview.cpp | 1 - src/declarative/util/qmlbind.cpp | 1 - src/declarative/util/qmllistmodel.cpp | 1 - src/declarative/util/qmlscript.cpp | 1 - src/declarative/util/qmlsetproperties.cpp | 4 +- src/declarative/util/qmlstate.cpp | 6 +- src/declarative/util/qmlstate.h | 14 +- src/declarative/util/qmlstate_p.h | 4 +- src/declarative/util/qmlstategroup.cpp | 2 +- src/declarative/util/qmlstateoperations.cpp | 2 +- src/declarative/util/qmltransition.cpp | 1 - src/declarative/util/qmltransitionmanager.cpp | 2 +- 31 files changed, 417 insertions(+), 426 deletions(-) delete mode 100644 src/declarative/qml/qmlbindablevalue.cpp delete mode 100644 src/declarative/qml/qmlbindablevalue.h delete mode 100644 src/declarative/qml/qmlbindablevalue_p.h create mode 100644 src/declarative/qml/qmlbinding.cpp create mode 100644 src/declarative/qml/qmlbinding.h create mode 100644 src/declarative/qml/qmlbinding_p.h diff --git a/src/declarative/fx/qfxanchors.cpp b/src/declarative/fx/qfxanchors.cpp index e1b450d..350cbc0 100644 --- a/src/declarative/fx/qfxanchors.cpp +++ b/src/declarative/fx/qfxanchors.cpp @@ -44,7 +44,6 @@ #include "qfxitem_p.h" #include #include -#include QT_BEGIN_NAMESPACE diff --git a/src/declarative/fx/qfxpathview.cpp b/src/declarative/fx/qfxpathview.cpp index f940f68..3c61050 100644 --- a/src/declarative/fx/qfxpathview.cpp +++ b/src/declarative/fx/qfxpathview.cpp @@ -42,7 +42,6 @@ #include #include #include -#include "qmlbindablevalue.h" #include "qmlstate.h" #include "qlistmodelinterface.h" #include "qmlopenmetaobject.h" diff --git a/src/declarative/fx/qfxwebview.cpp b/src/declarative/fx/qfxwebview.cpp index a3dca79e..42b8d2c 100644 --- a/src/declarative/fx/qfxwebview.cpp +++ b/src/declarative/fx/qfxwebview.cpp @@ -53,7 +53,6 @@ #include #include "qml.h" -#include "qmlbindablevalue.h" #include "qmlengine.h" #include "qmlstate.h" #include "qfxtransform.h" diff --git a/src/declarative/qml/qml.pri b/src/declarative/qml/qml.pri index eecf8cd..b3fa063 100644 --- a/src/declarative/qml/qml.pri +++ b/src/declarative/qml/qml.pri @@ -3,7 +3,7 @@ SOURCES += qml/qmlparser.cpp \ qml/qmlvmemetaobject.cpp \ qml/qmlengine.cpp \ qml/qmlexpression.cpp \ - qml/qmlbindablevalue.cpp \ + qml/qmlbinding.cpp \ qml/qmlmetaproperty.cpp \ qml/qmlcomponent.cpp \ qml/qmlcontext.cpp \ @@ -33,8 +33,8 @@ HEADERS += qml/qmlparser_p.h \ qml/qmlinstruction_p.h \ qml/qmlvmemetaobject_p.h \ qml/qml.h \ - qml/qmlbindablevalue.h \ - qml/qmlbindablevalue_p.h \ + qml/qmlbinding.h \ + qml/qmlbinding_p.h \ qml/qmlmetaproperty.h \ qml/qmlcomponent.h \ qml/qmlcomponent_p.h \ diff --git a/src/declarative/qml/qmlbindablevalue.cpp b/src/declarative/qml/qmlbindablevalue.cpp deleted file mode 100644 index 6dda5e3..0000000 --- a/src/declarative/qml/qmlbindablevalue.cpp +++ /dev/null @@ -1,186 +0,0 @@ -/**************************************************************************** -** -** 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 -#include "qmlbindablevalue.h" -#include "qmlbindablevalue_p.h" -#include -#include -#include -#include -#include - -Q_DECLARE_METATYPE(QList); - -QT_BEGIN_NAMESPACE - -DEFINE_BOOL_CONFIG_OPTION(scriptWarnings, QML_SCRIPT_WARNINGS); - -QmlBindableValuePrivate::QmlBindableValuePrivate() -: inited(false), updating(false), enabled(true), mePtr(0) -{ -} - -QML_DEFINE_NOCREATE_TYPE(QmlBindableValue); -QmlBindableValue::QmlBindableValue(void *data, QmlRefCount *rc, QObject *obj, QmlContext *ctxt, QObject *parent) -: QmlPropertyValueSource(*new QmlBindableValuePrivate, parent), QmlExpression(ctxt, data, rc, obj) -{ -} - -QmlBindableValue::QmlBindableValue(const QString &str, QObject *obj, QmlContext *ctxt, QObject *parent) -: QmlPropertyValueSource(*new QmlBindableValuePrivate, parent), QmlExpression(ctxt, str, obj) -{ -} - -QmlBindableValue::~QmlBindableValue() -{ - Q_D(QmlBindableValue); - if(d->mePtr) - *(d->mePtr) = 0; -} - -void QmlBindableValue::setTarget(const QmlMetaProperty &prop) -{ - Q_D(QmlBindableValue); - d->property = prop; - - update(); -} - -QmlMetaProperty QmlBindableValue::property() const -{ - Q_D(const QmlBindableValue); - return d->property; -} - -void QmlBindableValue::init() -{ - Q_D(QmlBindableValue); - - if (d->inited) - return; - d->inited = true; - update(); -} - -void QmlBindableValue::setExpression(const QString &expr) -{ - QmlExpression::setExpression(expr); - update(); -} - -void QmlBindableValue::forceUpdate() -{ - Q_D(QmlBindableValue); - if (!d->inited) - init(); - else - update(); -} - -void QmlBindableValue::update() -{ - Q_D(QmlBindableValue); - -#ifdef Q_ENABLE_PERFORMANCE_LOG - QFxPerfTimer bu; -#endif - if (!d->inited || !d->enabled) - return; - - if (!d->updating) { - d->updating = true; - - if (d->property.propertyCategory() == QmlMetaProperty::Bindable) { - - int idx = d->property.coreIndex(); - Q_ASSERT(idx != -1); - - void *a[1]; - QmlBindableValue *t = this; - a[0] = (void *)&t; - QMetaObject::metacall(d->property.object(), - QMetaObject::WriteProperty, - idx, a); - - } else { - - QVariant value = this->value(); - if ((uint)d->property.propertyType() >= QVariant::UserType && - value.type() == QVariant::String) { - QmlMetaType::StringConverter con = QmlMetaType::customStringConverter(d->property.propertyType()); - if (con) - value = con(value.toString()); - } - - if (d->property.propertyType() == QVariant::Url && - (value.type() == QVariant::String || value.type() == QVariant::ByteArray) && !value.isNull()) - value.setValue(context()->resolvedUrl(QUrl(value.toString()))); - - d->property.write(value); - } - - d->updating = false; - } else { - qmlInfo(d->property.object()) << "Binding loop detected for property" << d->property.name(); - } -} - -void QmlBindableValue::valueChanged() -{ - update(); -} - -void QmlBindableValue::setEnabled(bool e) -{ - Q_D(QmlBindableValue); - d->enabled = e; - setTrackChange(e); -} - -bool QmlBindableValue::enabled() const -{ - Q_D(const QmlBindableValue); - - return d->enabled; -} - -QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlbindablevalue.h b/src/declarative/qml/qmlbindablevalue.h deleted file mode 100644 index 12da9f6..0000000 --- a/src/declarative/qml/qmlbindablevalue.h +++ /dev/null @@ -1,98 +0,0 @@ -/**************************************************************************** -** -** 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 QMLBINDABLEVALUE_H -#define QMLBINDABLEVALUE_H - -#include -#include -#include -#include -#include - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -QT_MODULE(Declarative) - -class QmlExpression; -class QmlContext; -class QmlBindableValuePrivate; -class Q_DECLARATIVE_EXPORT QmlBindableValue : public QmlPropertyValueSource, - public QmlExpression -{ -Q_OBJECT -public: - QmlBindableValue(const QString &, QObject *, QmlContext *, QObject *parent=0); - QmlBindableValue(void *, QmlRefCount *, QObject *, QmlContext *, QObject *parent); - ~QmlBindableValue(); - - virtual void setTarget(const QmlMetaProperty &); - QmlMetaProperty property() const; - - Q_CLASSINFO("DefaultProperty", "expression") - Q_PROPERTY(QString expression READ expression WRITE setExpression) - virtual void setExpression(const QString &); - - void init(); - void forceUpdate(); - - void setEnabled(bool); - bool enabled() const; - -public Q_SLOTS: - void update(); - -protected: - virtual void valueChanged(); - -private: - Q_DECLARE_PRIVATE(QmlBindableValue) -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QmlBindableValue) - -QT_END_HEADER - -#endif // QMLBINDABLEVALUE_H diff --git a/src/declarative/qml/qmlbindablevalue_p.h b/src/declarative/qml/qmlbindablevalue_p.h deleted file mode 100644 index a37b2c0..0000000 --- a/src/declarative/qml/qmlbindablevalue_p.h +++ /dev/null @@ -1,79 +0,0 @@ -/**************************************************************************** -** -** 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 QMLBINDABLEVALUE_P_H -#define QMLBINDABLEVALUE_P_H - -// -// W A R N I N G -// ------------- -// -// This file is not part of the Qt API. It exists purely as an -// implementation detail. This header file may change from version to -// version without notice, or even be removed. -// -// We mean it. -// - -#include -#include -#include - -QT_BEGIN_NAMESPACE - -class QmlBindableValuePrivate : public QObjectPrivate -{ - Q_DECLARE_PUBLIC(QmlBindableValue) -public: - QmlBindableValuePrivate(); - - bool inited:1; - bool updating:1; - bool enabled:1; - - QmlMetaProperty property; - - QmlBindableValue **mePtr; -}; - -QT_END_NAMESPACE - -#endif // QMLBINDABLEVALUE_P_H diff --git a/src/declarative/qml/qmlbinding.cpp b/src/declarative/qml/qmlbinding.cpp new file mode 100644 index 0000000..6a8a027 --- /dev/null +++ b/src/declarative/qml/qmlbinding.cpp @@ -0,0 +1,186 @@ +/**************************************************************************** +** +** 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 +#include "qmlbinding.h" +#include "qmlbinding_p.h" +#include +#include +#include +#include +#include + +Q_DECLARE_METATYPE(QList); + +QT_BEGIN_NAMESPACE + +DEFINE_BOOL_CONFIG_OPTION(scriptWarnings, QML_SCRIPT_WARNINGS); + +QmlBindingPrivate::QmlBindingPrivate() +: inited(false), updating(false), enabled(true), mePtr(0) +{ +} + +QML_DEFINE_NOCREATE_TYPE(QmlBinding); +QmlBinding::QmlBinding(void *data, QmlRefCount *rc, QObject *obj, QmlContext *ctxt, QObject *parent) +: QmlPropertyValueSource(*new QmlBindingPrivate, parent), QmlExpression(ctxt, data, rc, obj) +{ +} + +QmlBinding::QmlBinding(const QString &str, QObject *obj, QmlContext *ctxt, QObject *parent) +: QmlPropertyValueSource(*new QmlBindingPrivate, parent), QmlExpression(ctxt, str, obj) +{ +} + +QmlBinding::~QmlBinding() +{ + Q_D(QmlBinding); + if(d->mePtr) + *(d->mePtr) = 0; +} + +void QmlBinding::setTarget(const QmlMetaProperty &prop) +{ + Q_D(QmlBinding); + d->property = prop; + + update(); +} + +QmlMetaProperty QmlBinding::property() const +{ + Q_D(const QmlBinding); + return d->property; +} + +void QmlBinding::init() +{ + Q_D(QmlBinding); + + if (d->inited) + return; + d->inited = true; + update(); +} + +void QmlBinding::setExpression(const QString &expr) +{ + QmlExpression::setExpression(expr); + update(); +} + +void QmlBinding::forceUpdate() +{ + Q_D(QmlBinding); + if (!d->inited) + init(); + else + update(); +} + +void QmlBinding::update() +{ + Q_D(QmlBinding); + +#ifdef Q_ENABLE_PERFORMANCE_LOG + QFxPerfTimer bu; +#endif + if (!d->inited || !d->enabled) + return; + + if (!d->updating) { + d->updating = true; + + if (d->property.propertyCategory() == QmlMetaProperty::Bindable) { + + int idx = d->property.coreIndex(); + Q_ASSERT(idx != -1); + + void *a[1]; + QmlBinding *t = this; + a[0] = (void *)&t; + QMetaObject::metacall(d->property.object(), + QMetaObject::WriteProperty, + idx, a); + + } else { + + QVariant value = this->value(); + if ((uint)d->property.propertyType() >= QVariant::UserType && + value.type() == QVariant::String) { + QmlMetaType::StringConverter con = QmlMetaType::customStringConverter(d->property.propertyType()); + if (con) + value = con(value.toString()); + } + + if (d->property.propertyType() == QVariant::Url && + (value.type() == QVariant::String || value.type() == QVariant::ByteArray) && !value.isNull()) + value.setValue(context()->resolvedUrl(QUrl(value.toString()))); + + d->property.write(value); + } + + d->updating = false; + } else { + qmlInfo(d->property.object()) << "Binding loop detected for property" << d->property.name(); + } +} + +void QmlBinding::valueChanged() +{ + update(); +} + +void QmlBinding::setEnabled(bool e) +{ + Q_D(QmlBinding); + d->enabled = e; + setTrackChange(e); +} + +bool QmlBinding::enabled() const +{ + Q_D(const QmlBinding); + + return d->enabled; +} + +QT_END_NAMESPACE diff --git a/src/declarative/qml/qmlbinding.h b/src/declarative/qml/qmlbinding.h new file mode 100644 index 0000000..e208277 --- /dev/null +++ b/src/declarative/qml/qmlbinding.h @@ -0,0 +1,98 @@ +/**************************************************************************** +** +** 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 QMLBINDING_H +#define QMLBINDING_H + +#include +#include +#include +#include +#include + +QT_BEGIN_HEADER + +QT_BEGIN_NAMESPACE + +QT_MODULE(Declarative) + +class QmlExpression; +class QmlContext; +class QmlBindingPrivate; +class Q_DECLARATIVE_EXPORT QmlBinding : public QmlPropertyValueSource, + public QmlExpression +{ +Q_OBJECT +public: + QmlBinding(const QString &, QObject *, QmlContext *, QObject *parent=0); + QmlBinding(void *, QmlRefCount *, QObject *, QmlContext *, QObject *parent); + ~QmlBinding(); + + virtual void setTarget(const QmlMetaProperty &); + QmlMetaProperty property() const; + + Q_CLASSINFO("DefaultProperty", "expression") + Q_PROPERTY(QString expression READ expression WRITE setExpression) + virtual void setExpression(const QString &); + + void init(); + void forceUpdate(); + + void setEnabled(bool); + bool enabled() const; + +public Q_SLOTS: + void update(); + +protected: + virtual void valueChanged(); + +private: + Q_DECLARE_PRIVATE(QmlBinding) +}; + +QT_END_NAMESPACE + +QML_DECLARE_TYPE(QmlBinding) + +QT_END_HEADER + +#endif // QMLBINDING_H diff --git a/src/declarative/qml/qmlbinding_p.h b/src/declarative/qml/qmlbinding_p.h new file mode 100644 index 0000000..470a62a --- /dev/null +++ b/src/declarative/qml/qmlbinding_p.h @@ -0,0 +1,79 @@ +/**************************************************************************** +** +** 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 QMLBINDING_P_H +#define QMLBINDING_P_H + +// +// W A R N I N G +// ------------- +// +// This file is not part of the Qt API. It exists purely as an +// implementation detail. This header file may change from version to +// version without notice, or even be removed. +// +// We mean it. +// + +#include +#include +#include + +QT_BEGIN_NAMESPACE + +class QmlBindingPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QmlBinding) +public: + QmlBindingPrivate(); + + bool inited:1; + bool updating:1; + bool enabled:1; + + QmlMetaProperty property; + + QmlBinding **mePtr; +}; + +QT_END_NAMESPACE + +#endif // QMLBINDING_P_H diff --git a/src/declarative/qml/qmlcomponent.cpp b/src/declarative/qml/qmlcomponent.cpp index c7d45fd..4e39d7f 100644 --- a/src/declarative/qml/qmlcomponent.cpp +++ b/src/declarative/qml/qmlcomponent.cpp @@ -51,7 +51,7 @@ #include #include #include -#include +#include "qmlbinding.h" #include #include @@ -578,7 +578,7 @@ void QmlComponent::completeCreate() QFxPerfTimer bi; #endif for (int ii = 0; ii < d->bindValues.count(); ++ii) { - QmlEnginePrivate::SimpleList bv = + QmlEnginePrivate::SimpleList bv = d->bindValues.at(ii); for (int jj = 0; jj < bv.count; ++jj) { if(bv.at(jj)) diff --git a/src/declarative/qml/qmlcomponent_p.h b/src/declarative/qml/qmlcomponent_p.h index 25af342..a7a3230 100644 --- a/src/declarative/qml/qmlcomponent_p.h +++ b/src/declarative/qml/qmlcomponent_p.h @@ -88,7 +88,7 @@ public: int count; QmlCompiledData *cc; - QList > bindValues; + QList > bindValues; QList > parserStatus; bool completePending; diff --git a/src/declarative/qml/qmlengine.cpp b/src/declarative/qml/qmlengine.cpp index 429e3b0..8b21290 100644 --- a/src/declarative/qml/qmlengine.cpp +++ b/src/declarative/qml/qmlengine.cpp @@ -72,7 +72,7 @@ #include #include #include "private/qmlmetaproperty_p.h" -#include +#include #include #include @@ -118,13 +118,13 @@ QmlEnginePrivate::~QmlEnginePrivate() clear(parserStatus[ii]); } -void QmlEnginePrivate::clear(SimpleList &bvs) +void QmlEnginePrivate::clear(SimpleList &bvs) { for (int ii = 0; ii < bvs.count; ++ii) { - QmlBindableValue *bv = bvs.at(ii); + QmlBinding *bv = bvs.at(ii); if(bv) { - QmlBindableValuePrivate *p = - static_cast(QObjectPrivate::get(bv)); + QmlBindingPrivate *p = + static_cast(QObjectPrivate::get(bv)); p->mePtr = 0; } } diff --git a/src/declarative/qml/qmlengine_p.h b/src/declarative/qml/qmlengine_p.h index 4bef85a..47d2397 100644 --- a/src/declarative/qml/qmlengine_p.h +++ b/src/declarative/qml/qmlengine_p.h @@ -151,10 +151,10 @@ public: } }; - static void clear(SimpleList &); + static void clear(SimpleList &); static void clear(SimpleList &); - QList > bindValues; + QList > bindValues; QList > parserStatus; QmlComponent *rootComponent; diff --git a/src/declarative/qml/qmlmetaproperty.cpp b/src/declarative/qml/qmlmetaproperty.cpp index dea3467..daa4242 100644 --- a/src/declarative/qml/qmlmetaproperty.cpp +++ b/src/declarative/qml/qmlmetaproperty.cpp @@ -44,7 +44,7 @@ #include #include #include -#include +#include "qmlbinding.h" #include #include "qmlboundsignal_p.h" #include @@ -260,7 +260,7 @@ QmlMetaProperty::QmlMetaProperty(const QmlMetaProperty &other) \value Unknown The category is unknown. This will never be returned from propertyCategory() \value InvalidProperty The property is invalid. - \value Bindable The property is a QmlBindableValue. + \value Bindable The property is a QmlBinding. \value List The property is a QList pointer \value QmlList The property is a QmlList pointer \value Object The property is a QObject derived type pointer @@ -294,7 +294,7 @@ QmlMetaPropertyPrivate::propertyCategory() const int type = propertyType(); if (type == QmlMetaProperty::Invalid) category = QmlMetaProperty::InvalidProperty; - else if (type == qMetaTypeId()) + else if (type == qMetaTypeId()) category = QmlMetaProperty::Bindable; else if (QmlMetaType::isList(type)) category = QmlMetaProperty::List; @@ -323,7 +323,7 @@ QmlMetaProperty::propertyCategory(const QMetaProperty &prop) else type = prop.type(); - if (type == qMetaTypeId()) + if (type == qMetaTypeId()) return Bindable; else if (QmlMetaType::isList(type)) return List; @@ -510,7 +510,7 @@ QMetaProperty QmlMetaProperty::property() const Returns the binding associated with this property, or 0 if no binding exists. */ -QmlBindableValue *QmlMetaProperty::binding() const +QmlBinding *QmlMetaProperty::binding() const { if (!isProperty() || type() & Attached) return 0; @@ -519,8 +519,8 @@ QmlBindableValue *QmlMetaProperty::binding() const for (QObjectList::ConstIterator iter = children.begin(); iter != children.end(); ++iter) { QObject *child = *iter; - if (child->metaObject() == &QmlBindableValue::staticMetaObject) { - QmlBindableValue *v = static_cast(child); + if (child->metaObject() == &QmlBinding::staticMetaObject) { + QmlBinding *v = static_cast(child); if (v->property() == *this) return v; } @@ -535,7 +535,7 @@ QmlBindableValue *QmlMetaProperty::binding() const \a binding will be enabled, and the returned binding (if any) will be disabled. */ -QmlBindableValue *QmlMetaProperty::setBinding(QmlBindableValue *binding) const +QmlBinding *QmlMetaProperty::setBinding(QmlBinding *binding) const { if (!isProperty() || type() & Attached) return 0; @@ -544,8 +544,8 @@ QmlBindableValue *QmlMetaProperty::setBinding(QmlBindableValue *binding) const for (QObjectList::ConstIterator iter = children.begin(); iter != children.end(); ++iter) { QObject *child = *iter; - if (child->metaObject() == &QmlBindableValue::staticMetaObject) { - QmlBindableValue *v = static_cast(child); + if (child->metaObject() == &QmlBinding::staticMetaObject) { + QmlBinding *v = static_cast(child); if (v->property() == *this && v->enabled()) { v->setEnabled(false); diff --git a/src/declarative/qml/qmlmetaproperty.h b/src/declarative/qml/qmlmetaproperty.h index 688c4fd..fdcf9be 100644 --- a/src/declarative/qml/qmlmetaproperty.h +++ b/src/declarative/qml/qmlmetaproperty.h @@ -52,7 +52,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class QObject; -class QmlBindableValue; +class QmlBinding; class QStringList; class QVariant; struct QMetaObject; @@ -121,8 +121,8 @@ public: QMetaProperty property() const; - QmlBindableValue *binding() const; - QmlBindableValue *setBinding(QmlBindableValue *) const; + QmlBinding *binding() const; + QmlBinding *setBinding(QmlBinding *) const; static QmlMetaProperty createProperty(QObject *, const QString &); diff --git a/src/declarative/qml/qmlparser.cpp b/src/declarative/qml/qmlparser.cpp index 8eb58c8..9eed3f1 100644 --- a/src/declarative/qml/qmlparser.cpp +++ b/src/declarative/qml/qmlparser.cpp @@ -47,7 +47,6 @@ #include #include #include -#include #include #include #include "private/qmlcomponent_p.h" diff --git a/src/declarative/qml/qmlvme.cpp b/src/declarative/qml/qmlvme.cpp index f468cd0..58b8689 100644 --- a/src/declarative/qml/qmlvme.cpp +++ b/src/declarative/qml/qmlvme.cpp @@ -57,13 +57,13 @@ #include #include #include -#include +#include #include #include #include "private/qmlvmemetaobject_p.h" #include #include -#include +#include QT_BEGIN_NAMESPACE @@ -137,7 +137,7 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, QmlCompiledData const QList &floatData = comp->floatData; - QmlEnginePrivate::SimpleList bindValues; + QmlEnginePrivate::SimpleList bindValues; QmlEnginePrivate::SimpleList parserStatus; QStack qliststack; @@ -153,7 +153,7 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, QmlCompiledData case QmlInstruction::Init: { if (instr.init.bindingsSize) - bindValues = QmlEnginePrivate::SimpleList(instr.init.bindingsSize); + bindValues = QmlEnginePrivate::SimpleList(instr.init.bindingsSize); if (instr.init.parserStatusSize) parserStatus = QmlEnginePrivate::SimpleList(instr.init.parserStatusSize); } @@ -540,10 +540,10 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, QmlCompiledData QmlMetaProperty mp(target, instr.assignBinding.property, (QmlMetaProperty::PropertyCategory)instr.assignBinding.category); - QmlBindableValue *bind = new QmlBindableValue((void *)datas.at(instr.assignBinding.value).constData(), comp, context, ctxt, 0); + QmlBinding *bind = new QmlBinding((void *)datas.at(instr.assignBinding.value).constData(), comp, context, ctxt, 0); bindValues.append(bind); - QmlBindableValuePrivate *p = - static_cast(QObjectPrivate::get(bind)); + QmlBindingPrivate *p = + static_cast(QObjectPrivate::get(bind)); p->mePtr = &bindValues.values[bindValues.count - 1]; QFx_setParent_noEvent(bind, target); @@ -560,10 +560,10 @@ QObject *QmlVME::run(QStack &stack, QmlContext *ctxt, QmlCompiledData QmlMetaProperty mp(target, instr.assignBinding.property, (QmlMetaProperty::PropertyCategory)instr.assignBinding.category); - QmlBindableValue *bind = new QmlBindableValue(primitives.at(instr.assignBinding.value), context, ctxt); + QmlBinding *bind = new QmlBinding(primitives.at(instr.assignBinding.value), context, ctxt); bindValues.append(bind); - QmlBindableValuePrivate *p = - static_cast(QObjectPrivate::get(bind)); + QmlBindingPrivate *p = + static_cast(QObjectPrivate::get(bind)); p->mePtr = &bindValues.values[bindValues.count - 1]; QFx_setParent_noEvent(bind, target); diff --git a/src/declarative/util/qfxperf.cpp b/src/declarative/util/qfxperf.cpp index db56b37..f768827 100644 --- a/src/declarative/util/qfxperf.cpp +++ b/src/declarative/util/qfxperf.cpp @@ -51,7 +51,7 @@ Q_DEFINE_PERFORMANCE_LOG(QFxPerf, "QFx") { Q_DEFINE_PERFORMANCE_METRIC(BindValue, "BindValue execution") Q_DEFINE_PERFORMANCE_METRIC(BindValueSSE, "BindValue execution SSE") Q_DEFINE_PERFORMANCE_METRIC(BindValueQt, "BindValue execution QtScript") - Q_DEFINE_PERFORMANCE_METRIC(BindableValueUpdate, "QmlBindableValue::update") + Q_DEFINE_PERFORMANCE_METRIC(BindableValueUpdate, "QmlBinding::update") Q_DEFINE_PERFORMANCE_METRIC(PixmapLoad, "Pixmap loading") Q_DEFINE_PERFORMANCE_METRIC(FontDatabase, "Font database creation") Q_DEFINE_PERFORMANCE_METRIC(QFxPathViewPathCache, "FX Items: QFxPathView: Path cache") diff --git a/src/declarative/util/qfxview.cpp b/src/declarative/util/qfxview.cpp index d83de28..96d9e8e 100644 --- a/src/declarative/util/qfxview.cpp +++ b/src/declarative/util/qfxview.cpp @@ -51,7 +51,6 @@ #include "qboxlayout.h" #include "qbasictimer.h" -#include "qmlbindablevalue.h" #include "qml.h" #include "qfxitem.h" #include "private/qperformancelog_p.h" diff --git a/src/declarative/util/qmlbind.cpp b/src/declarative/util/qmlbind.cpp index bb342bc..7493b12 100644 --- a/src/declarative/util/qmlbind.cpp +++ b/src/declarative/util/qmlbind.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ -#include #include #include #include diff --git a/src/declarative/util/qmllistmodel.cpp b/src/declarative/util/qmllistmodel.cpp index 61d32f4..a969100 100644 --- a/src/declarative/util/qmllistmodel.cpp +++ b/src/declarative/util/qmllistmodel.cpp @@ -46,7 +46,6 @@ #include #include "qmlopenmetaobject.h" #include -#include #include "qmllistmodel.h" Q_DECLARE_METATYPE(QListModelInterface *) diff --git a/src/declarative/util/qmlscript.cpp b/src/declarative/util/qmlscript.cpp index 8d03804..7199341 100644 --- a/src/declarative/util/qmlscript.cpp +++ b/src/declarative/util/qmlscript.cpp @@ -39,7 +39,6 @@ ** ****************************************************************************/ -#include #include #include #include diff --git a/src/declarative/util/qmlsetproperties.cpp b/src/declarative/util/qmlsetproperties.cpp index 6464e33..ffd1e6a 100644 --- a/src/declarative/util/qmlsetproperties.cpp +++ b/src/declarative/util/qmlsetproperties.cpp @@ -47,7 +47,7 @@ #include #include #include -#include +#include QT_BEGIN_NAMESPACE @@ -334,7 +334,7 @@ QmlSetProperties::ActionList QmlSetProperties::actions() if (d->isExplicit) { a.toValue = d->expressions.at(ii).second->value(); } else { - a.toBinding = new QmlBindableValue(d->expressions.at(ii).second->expression(), object(), qmlContext(this)); + a.toBinding = new QmlBinding(d->expressions.at(ii).second->expression(), object(), qmlContext(this)); a.toBinding->setTarget(prop); } diff --git a/src/declarative/util/qmlstate.cpp b/src/declarative/util/qmlstate.cpp index e3cff38..73ea9c2 100644 --- a/src/declarative/util/qmlstate.cpp +++ b/src/declarative/util/qmlstate.cpp @@ -42,7 +42,7 @@ #include "qmltransition.h" #include "qmlstategroup.h" #include "qmlstate_p.h" -#include "qmlbindablevalue.h" +#include "qmlbinding.h" #include "qmlstateoperations.h" #include "qmlanimation.h" #include "qmlanimation_p.h" @@ -175,13 +175,13 @@ bool QmlState::isWhenKnown() const This should be set to an expression that evaluates to true when you want the state to be applied. */ -QmlBindableValue *QmlState::when() const +QmlBinding *QmlState::when() const { Q_D(const QmlState); return d->when; } -void QmlState::setWhen(QmlBindableValue *when) +void QmlState::setWhen(QmlBinding *when) { Q_D(QmlState); d->when = when; diff --git a/src/declarative/util/qmlstate.h b/src/declarative/util/qmlstate.h index 7532430..90649a1 100644 --- a/src/declarative/util/qmlstate.h +++ b/src/declarative/util/qmlstate.h @@ -54,7 +54,7 @@ QT_BEGIN_NAMESPACE QT_MODULE(Declarative) class ActionEvent; -class QmlBindableValue; +class QmlBinding; class Action { public: @@ -68,8 +68,8 @@ public: QVariant fromValue; QVariant toValue; - QmlBindableValue *fromBinding; - QmlBindableValue *toBinding; + QmlBinding *fromBinding; + QmlBinding *toBinding; ActionEvent *event; QObject *specifiedObject; @@ -111,7 +111,7 @@ class Q_DECLARATIVE_EXPORT QmlState : public QObject Q_OBJECT Q_PROPERTY(QString name READ name WRITE setName) - Q_PROPERTY(QmlBindableValue *when READ when WRITE setWhen) + Q_PROPERTY(QmlBinding *when READ when WRITE setWhen) Q_PROPERTY(QString extends READ extends WRITE setExtends) Q_PROPERTY(QmlList* operations READ operations) Q_CLASSINFO("DefaultProperty", "operations") @@ -123,11 +123,11 @@ public: QString name() const; void setName(const QString &); - /*'when' is a QmlBindableValue to limit state changes oscillation + /*'when' is a QmlBinding to limit state changes oscillation due to the unpredictable order of evaluation of bound expressions*/ bool isWhenKnown() const; - QmlBindableValue *when() const; - void setWhen(QmlBindableValue *); + QmlBinding *when() const; + void setWhen(QmlBinding *); QString extends() const; void setExtends(const QString &); diff --git a/src/declarative/util/qmlstate_p.h b/src/declarative/util/qmlstate_p.h index 414ec08..73e2377 100644 --- a/src/declarative/util/qmlstate_p.h +++ b/src/declarative/util/qmlstate_p.h @@ -80,7 +80,7 @@ public: QmlMetaProperty property; QVariant value; - QmlBindableValue *binding; + QmlBinding *binding; QObject *specifiedObject; QString specifiedProperty; }; @@ -96,7 +96,7 @@ public: typedef QList SimpleActionList; QString name; - QmlBindableValue *when; + QmlBinding *when; QmlConcreteList operations; QmlTransitionManager transitionManager; diff --git a/src/declarative/util/qmlstategroup.cpp b/src/declarative/util/qmlstategroup.cpp index 2b1cf7d..946569c 100644 --- a/src/declarative/util/qmlstategroup.cpp +++ b/src/declarative/util/qmlstategroup.cpp @@ -40,9 +40,9 @@ ****************************************************************************/ #include "private/qobject_p.h" -#include "qmlbindablevalue.h" #include "qmlstategroup.h" #include "qmltransition.h" +#include #include QT_BEGIN_NAMESPACE diff --git a/src/declarative/util/qmlstateoperations.cpp b/src/declarative/util/qmlstateoperations.cpp index 5bb2cb6..8d6abe6 100644 --- a/src/declarative/util/qmlstateoperations.cpp +++ b/src/declarative/util/qmlstateoperations.cpp @@ -42,7 +42,7 @@ #include #include #include -#include "qmlbindablevalue.h" +#include #include "qmlstateoperations.h" #include #include diff --git a/src/declarative/util/qmltransition.cpp b/src/declarative/util/qmltransition.cpp index d793c7d..dffa6b5 100644 --- a/src/declarative/util/qmltransition.cpp +++ b/src/declarative/util/qmltransition.cpp @@ -42,7 +42,6 @@ #include "qmlstate.h" #include "qmlstategroup.h" #include "qmlstate_p.h" -#include "qmlbindablevalue.h" #include "qmlstateoperations.h" #include "qmlanimation.h" #include "qmlanimation_p.h" diff --git a/src/declarative/util/qmltransitionmanager.cpp b/src/declarative/util/qmltransitionmanager.cpp index ba4e160..6f1a8e3 100644 --- a/src/declarative/util/qmltransitionmanager.cpp +++ b/src/declarative/util/qmltransitionmanager.cpp @@ -39,7 +39,7 @@ ** ****************************************************************************/ -#include +#include #include #include -- cgit v0.12