diff options
author | Matthew Vogt <matthew.vogt@nokia.com> | 2012-02-16 14:43:03 +1000 |
---|---|---|
committer | Qt by Nokia <qt-info@nokia.com> | 2012-02-24 04:51:31 +0100 |
commit | b855240b782395f94315f43ea3e7e182299fac48 (patch) | |
tree | bc594c04449be8cd14cd0ab0bb72dafc2be0ffb2 /src/quick/util/qquickstate_p_p.h | |
parent | 6a42a6e0a9a1abdda0d07a5a20b4ac7e45348684 (diff) |
Rename QDeclarative symbols to QQuick and QQml
Symbols beginning with QDeclarative are already exported
by the quick1 module.
Users can apply the bin/rename-qtdeclarative-symbols.sh
script to modify client code using the previous names of the
renamed symbols.
Task-number: QTBUG-23737
Change-Id: Ifaa482663767634931e8711a8e9bf6e404859e66
Reviewed-by: Martin Jones <martin.jones@nokia.com>
Diffstat (limited to 'src/quick/util/qquickstate_p_p.h')
-rw-r--r-- | src/quick/util/qquickstate_p_p.h | 264 |
1 files changed, 264 insertions, 0 deletions
diff --git a/src/quick/util/qquickstate_p_p.h b/src/quick/util/qquickstate_p_p.h new file mode 100644 index 0000000000..e1cd85a00c --- /dev/null +++ b/src/quick/util/qquickstate_p_p.h @@ -0,0 +1,264 @@ +/**************************************************************************** +** +** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies). +** Contact: http://www.qt-project.org/ +** +** This file is part of the QtQml module of the Qt Toolkit. +** +** $QT_BEGIN_LICENSE:LGPL$ +** GNU Lesser General Public License Usage +** This file may be used under the terms of the GNU Lesser General Public +** License version 2.1 as published by the Free Software Foundation and +** appearing in the file LICENSE.LGPL included in the packaging of this +** file. Please review the following information to ensure the GNU Lesser +** General Public License version 2.1 requirements will be met: +** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. +** +** In addition, as a special exception, Nokia gives you certain additional +** rights. These rights are described in the Nokia Qt LGPL Exception +** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. +** +** 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. +** +** Other Usage +** Alternatively, this file may be used in accordance with the terms and +** conditions contained in a signed written agreement between you and Nokia. +** +** +** +** +** +** +** $QT_END_LICENSE$ +** +****************************************************************************/ + +#ifndef QQUICKSTATE_P_H +#define QQUICKSTATE_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 "qquickstate_p.h" + +#include "qquicktransitionmanager_p_p.h" + +#include <private/qqmlproperty_p.h> +#include <private/qqmlguard_p.h> + +#include <private/qqmlbinding_p.h> + +#include <private/qobject_p.h> + +QT_BEGIN_NAMESPACE + +class QQuickSimpleAction +{ +public: + enum State { StartState, EndState }; + QQuickSimpleAction(const QQuickAction &a, State state = StartState) + { + m_property = a.property; + m_specifiedObject = a.specifiedObject; + m_specifiedProperty = a.specifiedProperty; + m_event = a.event; + if (state == StartState) { + m_value = a.fromValue; + if (QQmlPropertyPrivate::binding(m_property)) { + m_binding = QQmlAbstractBinding::getPointer(QQmlPropertyPrivate::binding(m_property)); + } + m_reverseEvent = true; + } else { + m_value = a.toValue; + m_binding = a.toBinding; + m_reverseEvent = false; + } + } + + ~QQuickSimpleAction() + { + } + + QQuickSimpleAction(const QQuickSimpleAction &other) + : m_property(other.m_property), + m_value(other.m_value), + m_binding(QQmlAbstractBinding::getPointer(other.binding())), + m_specifiedObject(other.m_specifiedObject), + m_specifiedProperty(other.m_specifiedProperty), + m_event(other.m_event), + m_reverseEvent(other.m_reverseEvent) + { + } + + QQuickSimpleAction &operator =(const QQuickSimpleAction &other) + { + m_property = other.m_property; + m_value = other.m_value; + m_binding = QQmlAbstractBinding::getPointer(other.binding()); + m_specifiedObject = other.m_specifiedObject; + m_specifiedProperty = other.m_specifiedProperty; + m_event = other.m_event; + m_reverseEvent = other.m_reverseEvent; + + return *this; + } + + void setProperty(const QQmlProperty &property) + { + m_property = property; + } + + const QQmlProperty &property() const + { + return m_property; + } + + void setValue(const QVariant &value) + { + m_value = value; + } + + const QVariant &value() const + { + return m_value; + } + + void setBinding(QQmlAbstractBinding *binding) + { + m_binding = QQmlAbstractBinding::getPointer(binding); + } + + QQmlAbstractBinding *binding() const + { + return m_binding.data(); + } + + QObject *specifiedObject() const + { + return m_specifiedObject; + } + + const QString &specifiedProperty() const + { + return m_specifiedProperty; + } + + QQuickActionEvent *event() const + { + return m_event; + } + + bool reverseEvent() const + { + return m_reverseEvent; + } + +private: + QQmlProperty m_property; + QVariant m_value; + QQmlAbstractBinding::Pointer m_binding; + QObject *m_specifiedObject; + QString m_specifiedProperty; + QQuickActionEvent *m_event; + bool m_reverseEvent; +}; + +class QQuickRevertAction +{ +public: + QQuickRevertAction() : event(0) {} + QQuickRevertAction(const QQmlProperty &prop) : property(prop), event(0) {} + QQuickRevertAction(QQuickActionEvent *e) : event(e) {} + QQmlProperty property; + QQuickActionEvent *event; +}; + +class QQuickStateOperationPrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QQuickStateOperation) + +public: + + QQuickStateOperationPrivate() + : m_state(0) {} + + QQuickState *m_state; +}; + +class QQuickStatePrivate : public QObjectPrivate +{ + Q_DECLARE_PUBLIC(QQuickState) + +public: + QQuickStatePrivate() + : when(0), named(false), inState(false), group(0) {} + + typedef QList<QQuickSimpleAction> SimpleActionList; + + QString name; + QQmlBinding *when; + bool named; + + struct OperationGuard : public QQmlGuard<QQuickStateOperation> + { + OperationGuard(QObject *obj, QList<OperationGuard> *l) : list(l) { + setObject(static_cast<QQuickStateOperation *>(obj)); + } + QList<OperationGuard> *list; + void objectDestroyed(QQuickStateOperation *) { + // we assume priv will always be destroyed after objectDestroyed calls + list->removeOne(*this); + } + }; + QList<OperationGuard> operations; + + static void operations_append(QQmlListProperty<QQuickStateOperation> *prop, QQuickStateOperation *op) { + QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data); + op->setState(qobject_cast<QQuickState*>(prop->object)); + list->append(OperationGuard(op, list)); + } + static void operations_clear(QQmlListProperty<QQuickStateOperation> *prop) { + QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data); + QMutableListIterator<OperationGuard> listIterator(*list); + while(listIterator.hasNext()) + listIterator.next()->setState(0); + list->clear(); + } + static int operations_count(QQmlListProperty<QQuickStateOperation> *prop) { + QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data); + return list->count(); + } + static QQuickStateOperation *operations_at(QQmlListProperty<QQuickStateOperation> *prop, int index) { + QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data); + return list->at(index); + } + + QQuickTransitionManager transitionManager; + + SimpleActionList revertList; + QList<QQuickRevertAction> reverting; + QString extends; + mutable bool inState; + QQuickStateGroup *group; + + QQuickStateOperation::ActionList generateActionList() const; + void complete(); +}; + +QT_END_NAMESPACE + +#endif // QQUICKSTATE_P_H |