Qt 4.8
qdeclarativestate_p.h
Go to the documentation of this file.
1 /****************************************************************************
2 **
3 ** Copyright (C) 2014 Digia Plc and/or its subsidiary(-ies).
4 ** Contact: http://www.qt-project.org/legal
5 **
6 ** This file is part of the QtDeclarative module of the Qt Toolkit.
7 **
8 ** $QT_BEGIN_LICENSE:LGPL$
9 ** Commercial License Usage
10 ** Licensees holding valid commercial Qt licenses may use this file in
11 ** accordance with the commercial license agreement provided with the
12 ** Software or, alternatively, in accordance with the terms contained in
13 ** a written agreement between you and Digia. For licensing terms and
14 ** conditions see http://qt.digia.com/licensing. For further information
15 ** use the contact form at http://qt.digia.com/contact-us.
16 **
17 ** GNU Lesser General Public License Usage
18 ** Alternatively, this file may be used under the terms of the GNU Lesser
19 ** General Public License version 2.1 as published by the Free Software
20 ** Foundation and appearing in the file LICENSE.LGPL included in the
21 ** packaging of this file. Please review the following information to
22 ** ensure the GNU Lesser General Public License version 2.1 requirements
23 ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.
24 **
25 ** In addition, as a special exception, Digia gives you certain additional
26 ** rights. These rights are described in the Digia Qt LGPL Exception
27 ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.
28 **
29 ** GNU General Public License Usage
30 ** Alternatively, this file may be used under the terms of the GNU
31 ** General Public License version 3.0 as published by the Free Software
32 ** Foundation and appearing in the file LICENSE.GPL included in the
33 ** packaging of this file. Please review the following information to
34 ** ensure the GNU General Public License version 3.0 requirements will be
35 ** met: http://www.gnu.org/copyleft/gpl.html.
36 **
37 **
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 <QtCore/qsharedpointer.h>
49 #include <private/qdeclarativeglobal_p.h>
50 
52 
54 
55 QT_MODULE(Declarative)
56 
62 {
63 public:
65  QDeclarativeAction(QObject *, const QString &, const QVariant &);
67  QDeclarativeContext *, const QVariant &);
68 
69  bool restore:1;
70  bool actionDone:1;
71  bool reverseEvent:1;
73 
77 
81 
82  //strictly for matching
85 
86  void deleteFromBinding();
87 };
88 
90 {
91 public:
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; }
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?
116 class QDeclarativeState;
119 {
120  Q_OBJECT
121 public:
123  : QObject(parent) {}
125 
126  virtual ActionList actions();
127 
128  QDeclarativeState *state() const;
129  void setState(QDeclarativeState *state);
130 
131 protected:
133 
134 private:
137 };
138 
140 
144 {
145  Q_OBJECT
146 
151  Q_CLASSINFO("DefaultProperty", "changes")
152  Q_CLASSINFO("DeferredPropertyNames", "changes")
153 
154 public:
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 
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 QString &name) const;
184  bool changeValueInRevertList(QObject *target, const QString &name, const QVariant &revertValue);
185  bool changeBindingInRevertList(QObject *target, const QString &name, QDeclarativeAbstractBinding *binding);
186  bool removeEntryFromRevertList(QObject *target, const QString &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 QString &name) const;
191  QDeclarativeAbstractBinding *bindingInRevertList(QObject *target, const QString &name) const;
192 
193  bool isStateActive() const;
194 
195 Q_SIGNALS:
196  void completed();
197 
198 private:
199  Q_DECLARE_PRIVATE(QDeclarativeState)
200  Q_DISABLE_COPY(QDeclarativeState)
201 };
202 
204 
205 QML_DECLARE_TYPE(QDeclarativeStateOperation)
206 QML_DECLARE_TYPE(QDeclarativeState)
207 
209 
210 #endif // QDECLARATIVESTATE_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
QDeclarativeProperty property
#define Q_CLASSINFO(name, value)
This macro associates extra information to the class, which is available using QObject::metaObject()...
Definition: qobjectdefs.h:78
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
#define QT_MODULE(x)
Definition: qglobal.h:2783
QList< QDeclarativeAction > ActionList
#define QML_DECLARE_TYPE(TYPE)
Definition: qdeclarative.h:56
#define QT_BEGIN_HEADER
Definition: qglobal.h:136
static C reverse(const C &l)
#define Q_DISABLE_COPY(Class)
Disables the use of copy constructors and assignment operators for the given Class.
Definition: qglobal.h:2523
The QString class provides a Unicode character string.
Definition: qstring.h:83
The QObject class is the base class of all Qt objects.
Definition: qobject.h:111
#define Q_SIGNALS
Definition: qobjectdefs.h:72
QDeclarativeStateOperation::ActionList QDeclarativeStateActions
QDeclarativeBinding * when
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
const char * typeName
Definition: qmetatype.cpp:239
QWeakPointer< QDeclarativeAbstractBinding > toBinding
QDeclarativeListProperty< QDeclarativeStateOperation > changes
#define Q_DECLARATIVE_PRIVATE_EXPORT
#define Q_OBJECT
Definition: qobjectdefs.h:157
#define Q_DECLARATIVE_EXPORT
Definition: qglobal.h:1454
#define Q_AUTOTEST_EXPORT
Definition: qglobal.h:1510
The QDeclarativeContext class defines a context within a QML engine.
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...
#define Q_DECLARE_PRIVATE(Class)
Definition: qglobal.h:2467
QDeclarativeActionEvent * event
QDeclarativeStateOperation(QObject *parent=0)
The QDeclarativeExpression class evaluates JavaScript in a QML context.
#define QT_END_HEADER
Definition: qglobal.h:137
#define private
Definition: qregion_qws.cpp:43
virtual void copyOriginals(QDeclarativeActionEvent *)
QDeclarativeAbstractBinding * fromBinding