diff options
author | Tasuku Suzuki <stasuku@gmail.com> | 2012-11-25 04:36:33 +0900 |
---|---|---|
committer | The Qt Project <gerrit-noreply@qt-project.org> | 2012-11-29 17:48:46 +0100 |
commit | e0cb13a510c0099784fee00d5b4b7c608dd42dd2 (patch) | |
tree | 8d61daaaa70df2fa7b26a0c989d748fc3718e15f /src/quick | |
parent | 55f6a109e99ea2eb3359fa941a1826d4b4e11bf8 (diff) |
Move no-Gui related QML types from QtQuick into QtQml
Task-number: QTBUG-26340
Change-Id: I9049128db2598bf3c7a9d677b774eaae53b54eb5
Reviewed-by: Alan Alpert <aalpert@rim.com>
Reviewed-by: Lars Knoll <lars.knoll@digia.com>
Reviewed-by: Gunnar Sletta <gunnar.sletta@digia.com>
Diffstat (limited to 'src/quick')
-rw-r--r-- | src/quick/util/qquickbind.cpp | 310 | ||||
-rw-r--r-- | src/quick/util/qquickbind_p.h | 96 | ||||
-rw-r--r-- | src/quick/util/qquickconnections.cpp | 321 | ||||
-rw-r--r-- | src/quick/util/qquickconnections_p.h | 100 | ||||
-rw-r--r-- | src/quick/util/qquicktimer.cpp | 328 | ||||
-rw-r--r-- | src/quick/util/qquicktimer_p.h | 111 | ||||
-rw-r--r-- | src/quick/util/qquickutilmodule.cpp | 7 | ||||
-rw-r--r-- | src/quick/util/util.pri | 6 |
8 files changed, 0 insertions, 1279 deletions
diff --git a/src/quick/util/qquickbind.cpp b/src/quick/util/qquickbind.cpp deleted file mode 100644 index 7d3bc06f60..0000000000 --- a/src/quick/util/qquickbind.cpp +++ /dev/null @@ -1,310 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquickbind_p.h" - -#include <private/qqmlnullablevalue_p_p.h> -#include <private/qqmlproperty_p.h> -#include <private/qqmlbinding_p.h> -#include <private/qqmlguard_p.h> - -#include <qqmlengine.h> -#include <qqmlcontext.h> -#include <qqmlproperty.h> -#include <qqmlinfo.h> - -#include <QtCore/qfile.h> -#include <QtCore/qdebug.h> - -#include <private/qobject_p.h> - -QT_BEGIN_NAMESPACE - -class QQuickBindPrivate : public QObjectPrivate -{ -public: - QQuickBindPrivate() : componentComplete(true), obj(0), prevBind(0) {} - ~QQuickBindPrivate() { if (prevBind) prevBind->destroy(); } - - QQmlNullableValue<bool> when; - bool componentComplete; - QQmlGuard<QObject> obj; - QString propName; - QQmlNullableValue<QVariant> value; - QQmlProperty prop; - QQmlAbstractBinding *prevBind; -}; - - -/*! - \qmltype Binding - \instantiates QQuickBind - \inqmlmodule QtQuick 2 - \ingroup qtquick-interceptors - \brief Enables the arbitrary creation of property bindings - - \section1 Binding to an inaccessible property - - Sometimes it is necessary to bind to a property of an object that wasn't - directly instantiated by QML - generally a property of a class exported - to QML by C++. In these cases, regular property binding doesn't work. Binding - allows you to bind any value to any property. - - For example, imagine a C++ application that maps an "app.enteredText" - property into QML. You could use Binding to update the enteredText property - like this. - \code - TextEdit { id: myTextField; text: "Please type here..." } - Binding { target: app; property: "enteredText"; value: myTextField.text } - \endcode - Whenever the text in the TextEdit is updated, the C++ property will be - updated also. - - \section1 "Single-branch" conditional binding - - In some circumstances you may want to control the value of a property - only when a certain condition is true (and relinquish control in all - other circumstances). This often isn't possible to accomplish with a direct - binding, as you need to supply values for all possible branches. - - \code - // produces warning: "Unable to assign [undefined] to double value" - value: if (mouse.pressed) mouse.mouseX - \endcode - - The above example will produce a warning whenever we release the mouse, as the value - of the binding is undefined when the mouse isn't pressed. We can use the Binding - type to rewrite the above code and avoid the warning. - - \qml - Binding on value { - when: mouse.pressed - value: mouse.mouseX - } - \endqml - - The Binding type will also restore any previously set direct bindings on - the property. In that sense, it functions much like a simplified State. - - \qml - // this is equivalent to the above Binding - State { - name: "pressed" - when: mouse.pressed - PropertyChanges { - target: obj - value: mouse.mouseX - } - } - \endqml - - If the binding target or binding property is changed, the bound value is - immediately pushed onto the new target. - - \sa QtQml -*/ -QQuickBind::QQuickBind(QObject *parent) - : QObject(*(new QQuickBindPrivate), parent) -{ -} - -QQuickBind::~QQuickBind() -{ -} - -/*! - \qmlproperty bool QtQuick2::Binding::when - - This property holds when the binding is active. - This should be set to an expression that evaluates to true when you want the binding to be active. - - \code - Binding { - target: contactName; property: 'text' - value: name; when: list.ListView.isCurrentItem - } - \endcode - - When the binding becomes inactive again, any direct bindings that were previously - set on the property will be restored. -*/ -bool QQuickBind::when() const -{ - Q_D(const QQuickBind); - return d->when; -} - -void QQuickBind::setWhen(bool v) -{ - Q_D(QQuickBind); - if (!d->when.isNull && d->when == v) - return; - - d->when = v; - eval(); -} - -/*! - \qmlproperty Object QtQuick2::Binding::target - - The object to be updated. -*/ -QObject *QQuickBind::object() -{ - Q_D(const QQuickBind); - return d->obj; -} - -void QQuickBind::setObject(QObject *obj) -{ - Q_D(QQuickBind); - if (d->obj && d->when.isValid() && d->when) { - /* if we switch the object at runtime, we need to restore the - previous binding on the old object before continuing */ - d->when = false; - eval(); - d->when = true; - } - d->obj = obj; - if (d->componentComplete) - d->prop = QQmlProperty(d->obj, d->propName); - eval(); -} - -/*! - \qmlproperty string QtQuick2::Binding::property - - The property to be updated. -*/ -QString QQuickBind::property() const -{ - Q_D(const QQuickBind); - return d->propName; -} - -void QQuickBind::setProperty(const QString &p) -{ - Q_D(QQuickBind); - if (!d->propName.isEmpty() && d->when.isValid() && d->when) { - /* if we switch the property name at runtime, we need to restore the - previous binding on the old object before continuing */ - d->when = false; - eval(); - d->when = true; - } - d->propName = p; - if (d->componentComplete) - d->prop = QQmlProperty(d->obj, d->propName); - eval(); -} - -/*! - \qmlproperty any QtQuick2::Binding::value - - The value to be set on the target object and property. This can be a - constant (which isn't very useful), or a bound expression. -*/ -QVariant QQuickBind::value() const -{ - Q_D(const QQuickBind); - return d->value.value; -} - -void QQuickBind::setValue(const QVariant &v) -{ - Q_D(QQuickBind); - d->value = v; - eval(); -} - -void QQuickBind::setTarget(const QQmlProperty &p) -{ - Q_D(QQuickBind); - d->prop = p; -} - -void QQuickBind::classBegin() -{ - Q_D(QQuickBind); - d->componentComplete = false; -} - -void QQuickBind::componentComplete() -{ - Q_D(QQuickBind); - d->componentComplete = true; - if (!d->prop.isValid()) - d->prop = QQmlProperty(d->obj, d->propName); - eval(); -} - -void QQuickBind::eval() -{ - Q_D(QQuickBind); - if (!d->prop.isValid() || d->value.isNull || !d->componentComplete) - return; - - if (d->when.isValid()) { - if (!d->when) { - //restore any previous binding - if (d->prevBind) { - QQmlAbstractBinding *tmp = d->prevBind; - d->prevBind = 0; - tmp = QQmlPropertyPrivate::setBinding(d->prop, tmp); - if (tmp) //should this ever be true? - tmp->destroy(); - } - return; - } - - //save any set binding for restoration - QQmlAbstractBinding *tmp; - tmp = QQmlPropertyPrivate::setBinding(d->prop, 0); - if (tmp && d->prevBind) - tmp->destroy(); - else if (!d->prevBind) - d->prevBind = tmp; - } - - d->prop.write(d->value.value); -} - -QT_END_NAMESPACE diff --git a/src/quick/util/qquickbind_p.h b/src/quick/util/qquickbind_p.h deleted file mode 100644 index ced8aae9b3..0000000000 --- a/src/quick/util/qquickbind_p.h +++ /dev/null @@ -1,96 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKBIND_H -#define QQUICKBIND_H - -#include <qqml.h> - -#include <QtCore/qobject.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QQuickBindPrivate; -class Q_AUTOTEST_EXPORT QQuickBind : public QObject, public QQmlPropertyValueSource, public QQmlParserStatus -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QQuickBind) - Q_INTERFACES(QQmlParserStatus) - Q_INTERFACES(QQmlPropertyValueSource) - Q_PROPERTY(QObject *target READ object WRITE setObject) - Q_PROPERTY(QString property READ property WRITE setProperty) - Q_PROPERTY(QVariant value READ value WRITE setValue) - Q_PROPERTY(bool when READ when WRITE setWhen) - -public: - QQuickBind(QObject *parent=0); - ~QQuickBind(); - - bool when() const; - void setWhen(bool); - - QObject *object(); - void setObject(QObject *); - - QString property() const; - void setProperty(const QString &); - - QVariant value() const; - void setValue(const QVariant &); - -protected: - virtual void setTarget(const QQmlProperty &); - virtual void classBegin(); - virtual void componentComplete(); - -private: - void eval(); -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickBind) - -QT_END_HEADER - -#endif diff --git a/src/quick/util/qquickconnections.cpp b/src/quick/util/qquickconnections.cpp deleted file mode 100644 index ea3628c7fd..0000000000 --- a/src/quick/util/qquickconnections.cpp +++ /dev/null @@ -1,321 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquickconnections_p.h" - -#include <private/qqmlexpression_p.h> -#include <private/qqmlproperty_p.h> -#include <private/qqmlboundsignal_p.h> -#include <qqmlcontext.h> -#include <private/qqmlcontext_p.h> -#include <qqmlinfo.h> - -#include <QtCore/qdebug.h> -#include <QtCore/qstringlist.h> - -#include <private/qobject_p.h> - -QT_BEGIN_NAMESPACE - -class QQuickConnectionsPrivate : public QObjectPrivate -{ -public: - QQuickConnectionsPrivate() : target(0), targetSet(false), ignoreUnknownSignals(false), componentcomplete(true) {} - - QList<QQmlBoundSignal*> boundsignals; - QObject *target; - - bool targetSet; - bool ignoreUnknownSignals; - bool componentcomplete; - - QByteArray data; -}; - -/*! - \qmltype Connections - \instantiates QQuickConnections - \inqmlmodule QtQuick 2 - \ingroup qtquick-interceptors - \brief Describes generalized connections to signals - - A Connections object creates a connection to a QML signal. - - When connecting to signals in QML, the usual way is to create an - "on<Signal>" handler that reacts when a signal is received, like this: - - \qml - MouseArea { - onClicked: { foo(parameters) } - } - \endqml - - However, it is not possible to connect to a signal in this way in some - cases, such as when: - - \list - \li Multiple connections to the same signal are required - \li Creating connections outside the scope of the signal sender - \li Connecting to targets not defined in QML - \endlist - - When any of these are needed, the Connections type can be used instead. - - For example, the above code can be changed to use a Connections object, - like this: - - \qml - MouseArea { - Connections { - onClicked: foo(parameters) - } - } - \endqml - - More generally, the Connections object can be a child of some object other than - the sender of the signal: - - \qml - MouseArea { - id: area - } - // ... - \endqml - \qml - Connections { - target: area - onClicked: foo(parameters) - } - \endqml - - \sa QtQml -*/ -QQuickConnections::QQuickConnections(QObject *parent) : - QObject(*(new QQuickConnectionsPrivate), parent) -{ -} - -QQuickConnections::~QQuickConnections() -{ -} - -/*! - \qmlproperty Object QtQuick2::Connections::target - This property holds the object that sends the signal. - - If this property is not set, the \c target defaults to the parent of the Connection. - - If set to null, no connection is made and any signal handlers are ignored - until the target is not null. -*/ -QObject *QQuickConnections::target() const -{ - Q_D(const QQuickConnections); - return d->targetSet ? d->target : parent(); -} - -class QQmlBoundSignalDeleter : public QObject -{ -public: - QQmlBoundSignalDeleter(QQmlBoundSignal *signal) : m_signal(signal) { m_signal->removeFromObject(); } - ~QQmlBoundSignalDeleter() { delete m_signal; } - -private: - QQmlBoundSignal *m_signal; -}; - -void QQuickConnections::setTarget(QObject *obj) -{ - Q_D(QQuickConnections); - d->targetSet = true; // even if setting to 0, it is *set* - if (d->target == obj) - return; - foreach (QQmlBoundSignal *s, d->boundsignals) { - // It is possible that target is being changed due to one of our signal - // handlers -> use deleteLater(). - if (s->isEvaluating()) - (new QQmlBoundSignalDeleter(s))->deleteLater(); - else - delete s; - } - d->boundsignals.clear(); - d->target = obj; - connectSignals(); - emit targetChanged(); -} - -/*! - \qmlproperty bool QtQuick2::Connections::ignoreUnknownSignals - - Normally, a connection to a non-existent signal produces runtime errors. - - If this property is set to \c true, such errors are ignored. - This is useful if you intend to connect to different types of objects, handling - a different set of signals for each object. -*/ -bool QQuickConnections::ignoreUnknownSignals() const -{ - Q_D(const QQuickConnections); - return d->ignoreUnknownSignals; -} - -void QQuickConnections::setIgnoreUnknownSignals(bool ignore) -{ - Q_D(QQuickConnections); - d->ignoreUnknownSignals = ignore; -} - - - -QByteArray -QQmlConnectionsParser::compile(const QList<QQmlCustomParserProperty> &props) -{ - QByteArray rv; - QDataStream ds(&rv, QIODevice::WriteOnly); - - for(int ii = 0; ii < props.count(); ++ii) - { - QString propName = props.at(ii).name(); - int propLine = props.at(ii).location().line; - int propColumn = props.at(ii).location().column; - - if (!propName.startsWith(QLatin1String("on")) || !propName.at(2).isUpper()) { - error(props.at(ii), QQuickConnections::tr("Cannot assign to non-existent property \"%1\"").arg(propName)); - return QByteArray(); - } - - QList<QVariant> values = props.at(ii).assignedValues(); - - for (int i = 0; i < values.count(); ++i) { - const QVariant &value = values.at(i); - - if (value.userType() == qMetaTypeId<QQmlCustomParserNode>()) { - error(props.at(ii), QQuickConnections::tr("Connections: nested objects not allowed")); - return QByteArray(); - } else if (value.userType() == qMetaTypeId<QQmlCustomParserProperty>()) { - error(props.at(ii), QQuickConnections::tr("Connections: syntax error")); - return QByteArray(); - } else { - QQmlScript::Variant v = qvariant_cast<QQmlScript::Variant>(value); - if (v.isScript()) { - ds << propName; - ds << rewriteSignalHandler(v, propName).toUtf8(); - ds << propLine; - ds << propColumn; - } else { - error(props.at(ii), QQuickConnections::tr("Connections: script expected")); - return QByteArray(); - } - } - } - } - - return rv; -} - -void QQmlConnectionsParser::setCustomData(QObject *object, - const QByteArray &data) -{ - QQuickConnectionsPrivate *p = - static_cast<QQuickConnectionsPrivate *>(QObjectPrivate::get(object)); - p->data = data; -} - - -void QQuickConnections::connectSignals() -{ - Q_D(QQuickConnections); - if (!d->componentcomplete || (d->targetSet && !target())) - return; - - QDataStream ds(d->data); - while (!ds.atEnd()) { - QString propName; - ds >> propName; - QByteArray script; - ds >> script; - int line; - ds >> line; - int column; - ds >> column; - - QQmlProperty prop(target(), propName); - if (prop.isValid() && (prop.type() & QQmlProperty::SignalProperty)) { - int signalIndex = QQmlPropertyPrivate::get(prop)->signalIndex(); - QQmlBoundSignal *signal = - new QQmlBoundSignal(target(), signalIndex, this, qmlEngine(this)); - - QString location; - QQmlContextData *ctxtdata = 0; - QQmlData *ddata = QQmlData::get(this); - if (ddata) { - ctxtdata = ddata->outerContext; - if (ctxtdata && !ctxtdata->url.isEmpty()) - location = ddata->outerContext->urlString; - } - - QQmlBoundSignalExpression *expression = ctxtdata ? - new QQmlBoundSignalExpression(target(), signalIndex, - ctxtdata, this, script, - true, location, line, column) : 0; - signal->takeExpression(expression); - d->boundsignals += signal; - } else { - if (!d->ignoreUnknownSignals) - qmlInfo(this) << tr("Cannot assign to non-existent property \"%1\"").arg(propName); - } - } -} - -void QQuickConnections::classBegin() -{ - Q_D(QQuickConnections); - d->componentcomplete=false; -} - -void QQuickConnections::componentComplete() -{ - Q_D(QQuickConnections); - d->componentcomplete=true; - connectSignals(); -} - -QT_END_NAMESPACE diff --git a/src/quick/util/qquickconnections_p.h b/src/quick/util/qquickconnections_p.h deleted file mode 100644 index 0a8e716b8a..0000000000 --- a/src/quick/util/qquickconnections_p.h +++ /dev/null @@ -1,100 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKCONNECTIONS_H -#define QQUICKCONNECTIONS_H - -#include <qqml.h> -#include <private/qqmlcustomparser_p.h> - -#include <QtCore/qobject.h> -#include <QtCore/qstring.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QQmlBoundSignal; -class QQmlContext; -class QQuickConnectionsPrivate; -class Q_AUTOTEST_EXPORT QQuickConnections : public QObject, public QQmlParserStatus -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QQuickConnections) - - Q_INTERFACES(QQmlParserStatus) - Q_PROPERTY(QObject *target READ target WRITE setTarget NOTIFY targetChanged) - Q_PROPERTY(bool ignoreUnknownSignals READ ignoreUnknownSignals WRITE setIgnoreUnknownSignals) - -public: - QQuickConnections(QObject *parent=0); - ~QQuickConnections(); - - QObject *target() const; - void setTarget(QObject *); - - bool ignoreUnknownSignals() const; - void setIgnoreUnknownSignals(bool ignore); - -Q_SIGNALS: - void targetChanged(); - -private: - void connectSignals(); - void classBegin(); - void componentComplete(); -}; - -class QQmlConnectionsParser : public QQmlCustomParser -{ -public: - virtual QByteArray compile(const QList<QQmlCustomParserProperty> &); - virtual void setCustomData(QObject *, const QByteArray &); -}; - - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickConnections) - -QT_END_HEADER - -#endif diff --git a/src/quick/util/qquicktimer.cpp b/src/quick/util/qquicktimer.cpp deleted file mode 100644 index c7cdc70bc6..0000000000 --- a/src/quick/util/qquicktimer.cpp +++ /dev/null @@ -1,328 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#include "qquicktimer_p.h" - -#include <QtCore/qcoreapplication.h> -#include "private/qpauseanimationjob_p.h" -#include <qdebug.h> - -#include <private/qobject_p.h> - -QT_BEGIN_NAMESPACE - - - -class QQuickTimerPrivate : public QObjectPrivate, public QAnimationJobChangeListener -{ - Q_DECLARE_PUBLIC(QQuickTimer) -public: - QQuickTimerPrivate() - : interval(1000), running(false), repeating(false), triggeredOnStart(false) - , classBegun(false), componentComplete(false), firstTick(true) {} - - virtual void animationFinished(QAbstractAnimationJob *); - virtual void animationCurrentLoopChanged(QAbstractAnimationJob *) { Q_Q(QQuickTimer); q->ticked(); } - - int interval; - QPauseAnimationJob pause; - bool running : 1; - bool repeating : 1; - bool triggeredOnStart : 1; - bool classBegun : 1; - bool componentComplete : 1; - bool firstTick : 1; -}; - -/*! - \qmltype Timer - \instantiates QQuickTimer - \inqmlmodule QtQuick 2 - \ingroup qtquick-interceptors - \brief Triggers a handler at a specified interval - - A Timer can be used to trigger an action either once, or repeatedly - at a given interval. - - Here is a Timer that shows the current date and time, and updates - the text every 500 milliseconds. It uses the JavaScript \c Date - object to access the current time. - - \qml - import QtQuick 2.0 - - Item { - Timer { - interval: 500; running: true; repeat: true - onTriggered: time.text = Date().toString() - } - - Text { id: time } - } - \endqml - - The Timer type is synchronized with the animation timer. Since the animation - timer is usually set to 60fps, the resolution of Timer will be - at best 16ms. - - If the Timer is running and one of its properties is changed, the - elapsed time will be reset. For example, if a Timer with interval of - 1000ms has its \e repeat property changed 500ms after starting, the - elapsed time will be reset to 0, and the Timer will be triggered - 1000ms later. - - \sa {declarative/toys/clocks}{Clocks example} -*/ - -QQuickTimer::QQuickTimer(QObject *parent) - : QObject(*(new QQuickTimerPrivate), parent) -{ - Q_D(QQuickTimer); - d->pause.addAnimationChangeListener(d, QAbstractAnimationJob::Completion | QAbstractAnimationJob::CurrentLoop); - d->pause.setLoopCount(1); - d->pause.setDuration(d->interval); -} - -/*! - \qmlproperty int QtQuick2::Timer::interval - - Sets the \a interval between triggers, in milliseconds. - - The default interval is 1000 milliseconds. -*/ -void QQuickTimer::setInterval(int interval) -{ - Q_D(QQuickTimer); - if (interval != d->interval) { - d->interval = interval; - update(); - emit intervalChanged(); - } -} - -int QQuickTimer::interval() const -{ - Q_D(const QQuickTimer); - return d->interval; -} - -/*! - \qmlproperty bool QtQuick2::Timer::running - - If set to true, starts the timer; otherwise stops the timer. - For a non-repeating timer, \a running is set to false after the - timer has been triggered. - - \a running defaults to false. - - \sa repeat -*/ -bool QQuickTimer::isRunning() const -{ - Q_D(const QQuickTimer); - return d->running; -} - -void QQuickTimer::setRunning(bool running) -{ - Q_D(QQuickTimer); - if (d->running != running) { - d->running = running; - d->firstTick = true; - emit runningChanged(); - update(); - } -} - -/*! - \qmlproperty bool QtQuick2::Timer::repeat - - If \a repeat is true the timer is triggered repeatedly at the - specified interval; otherwise, the timer will trigger once at the - specified interval and then stop (i.e. running will be set to false). - - \a repeat defaults to false. - - \sa running -*/ -bool QQuickTimer::isRepeating() const -{ - Q_D(const QQuickTimer); - return d->repeating; -} - -void QQuickTimer::setRepeating(bool repeating) -{ - Q_D(QQuickTimer); - if (repeating != d->repeating) { - d->repeating = repeating; - update(); - emit repeatChanged(); - } -} - -/*! - \qmlproperty bool QtQuick2::Timer::triggeredOnStart - - When a timer is started, the first trigger is usually after the specified - interval has elapsed. It is sometimes desirable to trigger immediately - when the timer is started; for example, to establish an initial - state. - - If \a triggeredOnStart is true, the timer is triggered immediately - when started, and subsequently at the specified interval. Note that if - \e repeat is set to false, the timer is triggered twice; once on start, - and again at the interval. - - \a triggeredOnStart defaults to false. - - \sa running -*/ -bool QQuickTimer::triggeredOnStart() const -{ - Q_D(const QQuickTimer); - return d->triggeredOnStart; -} - -void QQuickTimer::setTriggeredOnStart(bool triggeredOnStart) -{ - Q_D(QQuickTimer); - if (d->triggeredOnStart != triggeredOnStart) { - d->triggeredOnStart = triggeredOnStart; - update(); - emit triggeredOnStartChanged(); - } -} - -/*! - \qmlmethod QtQuick2::Timer::start() - \brief Starts the timer - - If the timer is already running, calling this method has no effect. The - \c running property will be true following a call to \c start(). -*/ -void QQuickTimer::start() -{ - setRunning(true); -} - -/*! - \qmlmethod QtQuick2::Timer::stop() - \brief Stops the timer - - If the timer is not running, calling this method has no effect. The - \c running property will be false following a call to \c stop(). -*/ -void QQuickTimer::stop() -{ - setRunning(false); -} - -/*! - \qmlmethod QtQuick2::Timer::restart() - \brief Restarts the timer - - If the Timer is not running it will be started, otherwise it will be - stopped, reset to initial state and started. The \c running property - will be true following a call to \c restart(). -*/ -void QQuickTimer::restart() -{ - setRunning(false); - setRunning(true); -} - -void QQuickTimer::update() -{ - Q_D(QQuickTimer); - if (d->classBegun && !d->componentComplete) - return; - d->pause.stop(); - if (d->running) { - d->pause.setCurrentTime(0); - d->pause.setLoopCount(d->repeating ? -1 : 1); - d->pause.setDuration(d->interval); - d->pause.start(); - if (d->triggeredOnStart && d->firstTick) { - QCoreApplication::removePostedEvents(this, QEvent::MetaCall); - QMetaObject::invokeMethod(this, "ticked", Qt::QueuedConnection); - } - } -} - -void QQuickTimer::classBegin() -{ - Q_D(QQuickTimer); - d->classBegun = true; -} - -void QQuickTimer::componentComplete() -{ - Q_D(QQuickTimer); - d->componentComplete = true; - update(); -} - -/*! - \qmlsignal QtQuick2::Timer::onTriggered() - - This handler is called when the Timer is triggered. -*/ -void QQuickTimer::ticked() -{ - Q_D(QQuickTimer); - if (d->running && (d->pause.currentTime() > 0 || (d->triggeredOnStart && d->firstTick))) - emit triggered(); - d->firstTick = false; -} - -void QQuickTimerPrivate::animationFinished(QAbstractAnimationJob *) -{ - Q_Q(QQuickTimer); - if (repeating || !running) - return; - running = false; - firstTick = false; - emit q->triggered(); - emit q->runningChanged(); -} - -QT_END_NAMESPACE diff --git a/src/quick/util/qquicktimer_p.h b/src/quick/util/qquicktimer_p.h deleted file mode 100644 index 91bac9e9c0..0000000000 --- a/src/quick/util/qquicktimer_p.h +++ /dev/null @@ -1,111 +0,0 @@ -/**************************************************************************** -** -** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -** Contact: http://www.qt-project.org/legal -** -** This file is part of the QtQml module of the Qt Toolkit. -** -** $QT_BEGIN_LICENSE:LGPL$ -** Commercial License Usage -** Licensees holding valid commercial Qt licenses may use this file in -** accordance with the commercial license agreement provided with the -** Software or, alternatively, in accordance with the terms contained in -** a written agreement between you and Digia. For licensing terms and -** conditions see http://qt.digia.com/licensing. For further information -** use the contact form at http://qt.digia.com/contact-us. -** -** 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, Digia gives you certain additional -** rights. These rights are described in the Digia Qt LGPL Exception -** version 1.1, 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. -** -** -** $QT_END_LICENSE$ -** -****************************************************************************/ - -#ifndef QQUICKTIMER_H -#define QQUICKTIMER_H - -#include <qqml.h> - -#include <QtCore/qobject.h> - -#include <private/qtquickglobal_p.h> - -QT_BEGIN_HEADER - -QT_BEGIN_NAMESPACE - -class QQuickTimerPrivate; -class Q_AUTOTEST_EXPORT QQuickTimer : public QObject, public QQmlParserStatus -{ - Q_OBJECT - Q_DECLARE_PRIVATE(QQuickTimer) - Q_INTERFACES(QQmlParserStatus) - Q_PROPERTY(int interval READ interval WRITE setInterval NOTIFY intervalChanged) - Q_PROPERTY(bool running READ isRunning WRITE setRunning NOTIFY runningChanged) - Q_PROPERTY(bool repeat READ isRepeating WRITE setRepeating NOTIFY repeatChanged) - Q_PROPERTY(bool triggeredOnStart READ triggeredOnStart WRITE setTriggeredOnStart NOTIFY triggeredOnStartChanged) - Q_PROPERTY(QObject *parent READ parent CONSTANT) - -public: - QQuickTimer(QObject *parent=0); - - void setInterval(int interval); - int interval() const; - - bool isRunning() const; - void setRunning(bool running); - - bool isRepeating() const; - void setRepeating(bool repeating); - - bool triggeredOnStart() const; - void setTriggeredOnStart(bool triggeredOnStart); - -protected: - void classBegin(); - void componentComplete(); - -public Q_SLOTS: - void start(); - void stop(); - void restart(); - -Q_SIGNALS: - void triggered(); - void runningChanged(); - void intervalChanged(); - void repeatChanged(); - void triggeredOnStartChanged(); - -private: - void update(); - -private Q_SLOTS: - void ticked(); -}; - -QT_END_NAMESPACE - -QML_DECLARE_TYPE(QQuickTimer) - -QT_END_HEADER - -#endif diff --git a/src/quick/util/qquickutilmodule.cpp b/src/quick/util/qquickutilmodule.cpp index 7ecb792b73..0491e941f4 100644 --- a/src/quick/util/qquickutilmodule.cpp +++ b/src/quick/util/qquickutilmodule.cpp @@ -43,8 +43,6 @@ #include "qquickanimation_p.h" #include "qquickanimation_p_p.h" #include "qquickbehavior_p.h" -#include "qquickbind_p.h" -#include "qquickconnections_p.h" #include "qquicksmoothedanimation_p.h" #include "qquickfontloader_p.h" #include "qquickpackage_p.h" @@ -55,7 +53,6 @@ #include "qquickstate_p.h" #include "qquickstate_p_p.h" #include "qquicksystempalette_p.h" -#include "qquicktimer_p.h" #include "qquicktransition_p.h" #include <qqmlinfo.h> #include <private/qqmltypenotavailable_p.h> @@ -72,9 +69,7 @@ void QQuickUtilModule::defineModule() qmlRegisterUncreatableType<QQuickAbstractAnimation>("QtQuick",2,0,"Animation",QQuickAbstractAnimation::tr("Animation is an abstract class")); qmlRegisterType<QQuickBehavior>("QtQuick",2,0,"Behavior"); - qmlRegisterType<QQuickBind>("QtQuick",2,0,"Binding"); qmlRegisterType<QQuickColorAnimation>("QtQuick",2,0,"ColorAnimation"); - qmlRegisterType<QQuickConnections>("QtQuick",2,0,"Connections"); qmlRegisterType<QQuickSmoothedAnimation>("QtQuick",2,0,"SmoothedAnimation"); qmlRegisterType<QQuickFontLoader>("QtQuick",2,0,"FontLoader"); qmlRegisterType<QQuickNumberAnimation>("QtQuick",2,0,"NumberAnimation"); @@ -92,12 +87,10 @@ void QQuickUtilModule::defineModule() qmlRegisterType<QQuickStateGroup>("QtQuick",2,0,"StateGroup"); qmlRegisterType<QQuickState>("QtQuick",2,0,"State"); qmlRegisterType<QQuickSystemPalette>("QtQuick",2,0,"SystemPalette"); - qmlRegisterType<QQuickTimer>("QtQuick",2,0,"Timer"); qmlRegisterType<QQuickTransition>("QtQuick",2,0,"Transition"); qmlRegisterType<QQuickVector3dAnimation>("QtQuick",2,0,"Vector3dAnimation"); qmlRegisterType<QQuickStateOperation>(); qmlRegisterCustomType<QQuickPropertyChanges>("QtQuick",2,0,"PropertyChanges", new QQuickPropertyChangesParser); - qmlRegisterCustomType<QQuickConnections>("QtQuick",2,0,"Connections", new QQmlConnectionsParser); } diff --git a/src/quick/util/util.pri b/src/quick/util/util.pri index 3d93b9f2f5..7a56a95314 100644 --- a/src/quick/util/util.pri +++ b/src/quick/util/util.pri @@ -1,7 +1,6 @@ SOURCES += \ $$PWD/qquickapplication.cpp\ $$PWD/qquickutilmodule.cpp\ - $$PWD/qquickconnections.cpp \ $$PWD/qquickpackage.cpp \ $$PWD/qquickanimation.cpp \ $$PWD/qquicksystempalette.cpp \ @@ -16,8 +15,6 @@ SOURCES += \ $$PWD/qquicktransition.cpp \ $$PWD/qquicklistaccessor.cpp \ $$PWD/qquicktimeline.cpp \ - $$PWD/qquicktimer.cpp \ - $$PWD/qquickbind.cpp \ $$PWD/qquickpixmapcache.cpp \ $$PWD/qquickbehavior.cpp \ $$PWD/qquickfontloader.cpp \ @@ -34,7 +31,6 @@ SOURCES += \ HEADERS += \ $$PWD/qquickapplication_p.h\ $$PWD/qquickutilmodule_p.h\ - $$PWD/qquickconnections_p.h \ $$PWD/qquickpackage_p.h \ $$PWD/qquickanimation_p.h \ $$PWD/qquickanimation_p_p.h \ @@ -52,8 +48,6 @@ HEADERS += \ $$PWD/qquicktransition_p.h \ $$PWD/qquicklistaccessor_p.h \ $$PWD/qquicktimeline_p_p.h \ - $$PWD/qquicktimer_p.h \ - $$PWD/qquickbind_p.h \ $$PWD/qquickpixmapcache_p.h \ $$PWD/qquickbehavior_p.h \ $$PWD/qquickfontloader_p.h \ |