source: trunk/src/declarative/util/qdeclarativestate_p.h@ 902

Last change on this file since 902 was 846, checked in by Dmitry A. Kuminov, 15 years ago

trunk: Merged in qt 4.7.2 sources from branches/vendor/nokia/qt.

File size: 7.0 KB
Line 
1/****************************************************************************
2**
3** Copyright (C) 2011 Nokia Corporation and/or its subsidiary(-ies).
4** All rights reserved.
5** Contact: Nokia Corporation ([email protected])
6**
7** This file is part of the QtDeclarative module of the Qt Toolkit.
8**
9** $QT_BEGIN_LICENSE:LGPL$
10** Commercial Usage
11** Licensees holding valid Qt Commercial licenses may use this file in
12** accordance with the Qt Commercial License Agreement provided with the
13** Software or, alternatively, in accordance with the terms contained in
14** a written agreement between you and Nokia.
15**
16** GNU Lesser General Public License Usage
17** Alternatively, this file may be used under the terms of the GNU Lesser
18** General Public License version 2.1 as published by the Free Software
19** Foundation and appearing in the file LICENSE.LGPL included in the
20** packaging of this file. Please review the following information to
21** ensure the GNU Lesser General Public License version 2.1 requirements
22** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
23**
24** In addition, as a special exception, Nokia gives you certain additional
25** rights. These rights are described in the Nokia Qt LGPL Exception
26** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
27**
28** GNU General Public License Usage
29** Alternatively, this file may be used under the terms of the GNU
30** General Public License version 3.0 as published by the Free Software
31** Foundation and appearing in the file LICENSE.GPL included in the
32** packaging of this file. Please review the following information to
33** ensure the GNU General Public License version 3.0 requirements will be
34** met: http://www.gnu.org/copyleft/gpl.html.
35**
36** If you have questions regarding the use of this file, please contact
37** Nokia at [email protected].
38** $QT_END_LICENSE$
39**
40****************************************************************************/
41
42#ifndef QDECLARATIVESTATE_H
43#define QDECLARATIVESTATE_H
44
45#include <qdeclarative.h>
46#include <qdeclarativeproperty.h>
47#include <QtCore/qobject.h>
48#include <private/qdeclarativebinding_p.h>
49#include <private/qdeclarativeglobal_p.h>
50
51QT_BEGIN_HEADER
52
53QT_BEGIN_NAMESPACE
54
55QT_MODULE(Declarative)
56
57class QDeclarativeActionEvent;
58class QDeclarativeAbstractBinding;
59class QDeclarativeBinding;
60class QDeclarativeExpression;
61class Q_DECLARATIVE_PRIVATE_EXPORT QDeclarativeAction
62{
63public:
64 QDeclarativeAction();
65 QDeclarativeAction(QObject *, const QString &, const QVariant &);
66 QDeclarativeAction(QObject *, const QString &,
67 QDeclarativeContext *, const QVariant &);
68
69 bool restore:1;
70 bool actionDone:1;
71 bool reverseEvent:1;
72 bool deletableToBinding:1;
73
74 QDeclarativeProperty property;
75 QVariant fromValue;
76 QVariant toValue;
77
78 QDeclarativeAbstractBinding *fromBinding;
79 QDeclarativeAbstractBinding::Pointer toBinding;
80 QDeclarativeActionEvent *event;
81
82 //strictly for matching
83 QObject *specifiedObject;
84 QString specifiedProperty;
85
86 void deleteFromBinding();
87};
88
89class Q_AUTOTEST_EXPORT QDeclarativeActionEvent
90{
91public:
92 virtual ~QDeclarativeActionEvent();
93 virtual QString typeName() const;
94
95 enum Reason { ActualChange, FastForward };
96
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(QDeclarativeActionEvent *) {}
103
104 virtual bool isRewindable() { return isReversable(); }
105 virtual void rewind() {}
106 virtual void saveCurrentValues() {}
107 virtual void saveTargetValues() {}
108
109 virtual bool changesBindings();
110 virtual void clearBindings();
111 virtual bool override(QDeclarativeActionEvent*other);
112};
113
114//### rename to QDeclarativeStateChange?
115class QDeclarativeStateGroup;
116class QDeclarativeState;
117class QDeclarativeStateOperationPrivate;
118class Q_DECLARATIVE_EXPORT QDeclarativeStateOperation : public QObject
119{
120 Q_OBJECT
121public:
122 QDeclarativeStateOperation(QObject *parent = 0)
123 : QObject(parent) {}
124 typedef QList<QDeclarativeAction> ActionList;
125
126 virtual ActionList actions();
127
128 QDeclarativeState *state() const;
129 void setState(QDeclarativeState *state);
130
131protected:
132 QDeclarativeStateOperation(QObjectPrivate &dd, QObject *parent = 0);
133
134private:
135 Q_DECLARE_PRIVATE(QDeclarativeStateOperation)
136 Q_DISABLE_COPY(QDeclarativeStateOperation)
137};
138
139typedef QDeclarativeStateOperation::ActionList QDeclarativeStateActions;
140
141class QDeclarativeTransition;
142class QDeclarativeStatePrivate;
143class Q_DECLARATIVE_EXPORT QDeclarativeState : public QObject
144{
145 Q_OBJECT
146
147 Q_PROPERTY(QString name READ name WRITE setName)
148 Q_PROPERTY(QDeclarativeBinding *when READ when WRITE setWhen)
149 Q_PROPERTY(QString extend READ extends WRITE setExtends)
150 Q_PROPERTY(QDeclarativeListProperty<QDeclarativeStateOperation> changes READ changes)
151 Q_CLASSINFO("DefaultProperty", "changes")
152 Q_CLASSINFO("DeferredPropertyNames", "changes")
153
154public:
155 QDeclarativeState(QObject *parent=0);
156 virtual ~QDeclarativeState();
157
158 QString name() const;
159 void setName(const QString &);
160 bool isNamed() const;
161
162 /*'when' is a QDeclarativeBinding to limit state changes oscillation
163 due to the unpredictable order of evaluation of bound expressions*/
164 bool isWhenKnown() const;
165 QDeclarativeBinding *when() const;
166 void setWhen(QDeclarativeBinding *);
167
168 QString extends() const;
169 void setExtends(const QString &);
170
171 QDeclarativeListProperty<QDeclarativeStateOperation> changes();
172 int operationCount() const;
173 QDeclarativeStateOperation *operationAt(int) const;
174
175 QDeclarativeState &operator<<(QDeclarativeStateOperation *);
176
177 void apply(QDeclarativeStateGroup *, QDeclarativeTransition *, QDeclarativeState *revert);
178 void cancel();
179
180 QDeclarativeStateGroup *stateGroup() const;
181 void setStateGroup(QDeclarativeStateGroup *);
182
183 bool containsPropertyInRevertList(QObject *target, const QByteArray &name) const;
184 bool changeValueInRevertList(QObject *target, const QByteArray &name, const QVariant &revertValue);
185 bool changeBindingInRevertList(QObject *target, const QByteArray &name, QDeclarativeAbstractBinding *binding);
186 bool removeEntryFromRevertList(QObject *target, const QByteArray &name);
187 void addEntryToRevertList(const QDeclarativeAction &action);
188 void removeAllEntriesFromRevertList(QObject *target);
189 void addEntriesToRevertList(const QList<QDeclarativeAction> &actions);
190 QVariant valueInRevertList(QObject *target, const QByteArray &name) const;
191 QDeclarativeAbstractBinding *bindingInRevertList(QObject *target, const QByteArray &name) const;
192
193 bool isStateActive() const;
194
195Q_SIGNALS:
196 void completed();
197
198private:
199 Q_DECLARE_PRIVATE(QDeclarativeState)
200 Q_DISABLE_COPY(QDeclarativeState)
201};
202
203QT_END_NAMESPACE
204
205QML_DECLARE_TYPE(QDeclarativeStateOperation)
206QML_DECLARE_TYPE(QDeclarativeState)
207
208QT_END_HEADER
209
210#endif // QDECLARATIVESTATE_H
Note: See TracBrowser for help on using the repository browser.