1 /****************************************************************************
3 ** Copyright (C) 2012 Nokia Corporation and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/
6 ** This file is part of the QtQml module of the Qt Toolkit.
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** GNU Lesser General Public License Usage
10 ** This file may be used under the terms of the GNU Lesser General Public
11 ** License version 2.1 as published by the Free Software Foundation and
12 ** appearing in the file LICENSE.LGPL included in the packaging of this
13 ** file. Please review the following information to ensure the GNU Lesser
14 ** General Public License version 2.1 requirements will be met:
15 ** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
17 ** In addition, as a special exception, Nokia gives you certain additional
18 ** rights. These rights are described in the Nokia Qt LGPL Exception
19 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
21 ** GNU General Public License Usage
22 ** Alternatively, this file may be used under the terms of the GNU General
23 ** Public License version 3.0 as published by the Free Software Foundation
24 ** and appearing in the file LICENSE.GPL included in the packaging of this
25 ** file. Please review the following information to ensure the GNU General
26 ** Public License version 3.0 requirements will be met:
27 ** http://www.gnu.org/copyleft/gpl.html.
30 ** Alternatively, this file may be used in accordance with the terms and
31 ** conditions contained in a signed written agreement between you and Nokia.
40 ****************************************************************************/
46 #include <qqmlproperty.h>
47 #include <QtCore/qobject.h>
48 #include <QtCore/qsharedpointer.h>
49 #include <private/qtquickglobal_p.h>
55 class QQuickActionEvent;
56 class QQmlAbstractBinding;
59 class Q_QUICK_PRIVATE_EXPORT QQuickAction
63 QQuickAction(QObject *, const QString &, const QVariant &);
64 QQuickAction(QObject *, const QString &,
65 QQmlContext *, const QVariant &);
70 bool deletableToBinding:1;
72 QQmlProperty property;
76 QQmlAbstractBinding *fromBinding;
77 QWeakPointer<QQmlAbstractBinding> toBinding;
78 QQuickActionEvent *event;
80 //strictly for matching
81 QObject *specifiedObject;
82 QString specifiedProperty;
84 void deleteFromBinding();
87 class Q_AUTOTEST_EXPORT QQuickActionEvent
90 virtual ~QQuickActionEvent();
92 enum EventType { Script, SignalHandler, ParentChange, AnchorChanges };
93 enum Reason { ActualChange, FastForward };
95 virtual EventType type() const = 0;
97 virtual void execute(Reason reason = ActualChange);
98 virtual bool isReversable();
99 virtual void reverse(Reason reason = ActualChange);
100 virtual void saveOriginals() {}
101 virtual bool needsCopy() { return false; }
102 virtual void copyOriginals(QQuickActionEvent *) {}
104 virtual bool isRewindable() { return isReversable(); }
105 virtual void rewind() {}
106 virtual void saveCurrentValues() {}
107 virtual void saveTargetValues() {}
109 virtual bool changesBindings();
110 virtual void clearBindings();
111 virtual bool override(QQuickActionEvent*other);
114 //### rename to QQuickStateChange?
115 class QQuickStateGroup;
117 class QQuickStateOperationPrivate;
118 class Q_QUICK_EXPORT QQuickStateOperation : public QObject
122 QQuickStateOperation(QObject *parent = 0)
124 typedef QList<QQuickAction> ActionList;
126 virtual ActionList actions();
128 QQuickState *state() const;
129 void setState(QQuickState *state);
132 QQuickStateOperation(QObjectPrivate &dd, QObject *parent = 0);
135 Q_DECLARE_PRIVATE(QQuickStateOperation)
136 Q_DISABLE_COPY(QQuickStateOperation)
139 typedef QQuickStateOperation::ActionList QQuickStateActions;
141 class QQuickTransition;
142 class QQuickStatePrivate;
143 class Q_QUICK_EXPORT QQuickState : public QObject
147 Q_PROPERTY(QString name READ name WRITE setName)
148 Q_PROPERTY(QQmlBinding *when READ when WRITE setWhen)
149 Q_PROPERTY(QString extend READ extends WRITE setExtends)
150 Q_PROPERTY(QQmlListProperty<QQuickStateOperation> changes READ changes)
151 Q_CLASSINFO("DefaultProperty", "changes")
152 Q_CLASSINFO("DeferredPropertyNames", "changes")
155 QQuickState(QObject *parent=0);
156 virtual ~QQuickState();
158 QString name() const;
159 void setName(const QString &);
160 bool isNamed() const;
162 /*'when' is a QQmlBinding to limit state changes oscillation
163 due to the unpredictable order of evaluation of bound expressions*/
164 bool isWhenKnown() const;
165 QQmlBinding *when() const;
166 void setWhen(QQmlBinding *);
168 QString extends() const;
169 void setExtends(const QString &);
171 QQmlListProperty<QQuickStateOperation> changes();
172 int operationCount() const;
173 QQuickStateOperation *operationAt(int) const;
175 QQuickState &operator<<(QQuickStateOperation *);
177 void apply(QQuickTransition *, QQuickState *revert);
180 QQuickStateGroup *stateGroup() const;
181 void setStateGroup(QQuickStateGroup *);
183 bool containsPropertyInRevertList(QObject *target, const QString &name) const;
184 bool changeValueInRevertList(QObject *target, const QString &name, const QVariant &revertValue);
185 bool changeBindingInRevertList(QObject *target, const QString &name, QQmlAbstractBinding *binding);
186 bool removeEntryFromRevertList(QObject *target, const QString &name);
187 void addEntryToRevertList(const QQuickAction &action);
188 void removeAllEntriesFromRevertList(QObject *target);
189 void addEntriesToRevertList(const QList<QQuickAction> &actions);
190 QVariant valueInRevertList(QObject *target, const QString &name) const;
191 QQmlAbstractBinding *bindingInRevertList(QObject *target, const QString &name) const;
193 bool isStateActive() const;
199 Q_DECLARE_PRIVATE(QQuickState)
200 Q_DISABLE_COPY(QQuickState)
205 QML_DECLARE_TYPE(QQuickStateOperation)
206 QML_DECLARE_TYPE(QQuickState)
210 #endif // QQUICKSTATE_H