Qt 4.8
qdeclarativestate_p_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_P_H
43 #define QDECLARATIVESTATE_P_H
44 
45 //
46 // W A R N I N G
47 // -------------
48 //
49 // This file is not part of the Qt API. It exists purely as an
50 // implementation detail. This header file may change from version to
51 // version without notice, or even be removed.
52 //
53 // We mean it.
54 //
55 
56 #include "private/qdeclarativestate_p.h"
57 
58 #include "private/qdeclarativeanimation_p_p.h"
59 #include "private/qdeclarativetransitionmanager_p_p.h"
60 
61 #include <private/qdeclarativeproperty_p.h>
62 #include <private/qdeclarativeguard_p.h>
63 
64 #include <private/qdeclarativebinding_p.h>
65 
66 #include <private/qobject_p.h>
67 
69 
71 {
72 public:
75  {
76  m_property = a.property;
79  m_event = a.event;
80  if (state == StartState) {
81  m_value = a.fromValue;
84  }
85  m_reverseEvent = true;
86  } else {
87  m_value = a.toValue;
88  m_binding = a.toBinding;
89  m_reverseEvent = false;
90  }
91  }
92 
94  {
95  }
96 
98  : m_property(other.m_property),
99  m_value(other.m_value),
100  m_binding(QDeclarativeAbstractBinding::getPointer(other.binding())),
103  m_event(other.m_event),
105  {
106  }
107 
109  {
110  m_property = other.m_property;
111  m_value = other.m_value;
115  m_event = other.m_event;
117 
118  return *this;
119  }
120 
122  {
124  }
125 
127  {
128  return m_property;
129  }
130 
131  void setValue(const QVariant &value)
132  {
133  m_value = value;
134  }
135 
136  const QVariant &value() const
137  {
138  return m_value;
139  }
140 
142  {
144  }
145 
147  {
148  return m_binding.data();
149  }
150 
152  {
153  return m_specifiedObject;
154  }
155 
156  const QString &specifiedProperty() const
157  {
158  return m_specifiedProperty;
159  }
160 
162  {
163  return m_event;
164  }
165 
166  bool reverseEvent() const
167  {
168  return m_reverseEvent;
169  }
170 
171 private:
179 };
180 
182 {
184 
185 public:
186 
188  : m_state(0) {}
189 
191 };
192 
194 {
196 
197 public:
199  : when(0), named(false), inState(false), group(0) {}
200 
202 
205  bool named;
206 
207  struct OperationGuard : public QDeclarativeGuard<QDeclarativeStateOperation>
208  {
210  setObject(static_cast<QDeclarativeStateOperation *>(obj));
211  }
214  // we assume priv will always be destroyed after objectDestroyed calls
215  list->removeOne(*this);
216  }
217  };
219 
221  QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
222  op->setState(qobject_cast<QDeclarativeState*>(prop->object));
223  list->append(OperationGuard(op, list));
224  }
226  QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
227  QMutableListIterator<OperationGuard> listIterator(*list);
228  while(listIterator.hasNext())
229  listIterator.next()->setState(0);
230  list->clear();
231  }
233  QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
234  return list->count();
235  }
237  QList<OperationGuard> *list = static_cast<QList<OperationGuard> *>(prop->data);
238  return list->at(index);
239  }
240 
242 
243  SimpleActionList revertList;
246  mutable bool inState;
248 
250  void complete();
251 };
252 
254 
255 #endif // QDECLARATIVESTATE_P_H
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
void setValue(const QVariant &value)
QList< OperationGuard > operations
QDeclarativeProperty property
#define QT_END_NAMESPACE
This macro expands to.
Definition: qglobal.h:90
static Pointer getPointer(QDeclarativeAbstractBinding *p)
QDeclarativeProperty m_property
static QDeclarativeAbstractBinding * binding(QObject *, int coreIndex, int valueTypeIndex)
void setBinding(QDeclarativeAbstractBinding *binding)
long ASN1_INTEGER_get ASN1_INTEGER * a
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
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
T * data() const
static void operations_clear(QDeclarativeListProperty< QDeclarativeStateOperation > *prop)
QDeclarativeTransitionManager transitionManager
bool removeOne(const T &t)
Removes the first occurrence of value in the list and returns true on success; otherwise returns fals...
Definition: qlist.h:796
QDeclarativeActionEvent * m_event
void append(const T &t)
Inserts value at the end of the list.
Definition: qlist.h:507
#define QT_BEGIN_NAMESPACE
This macro expands to.
Definition: qglobal.h:89
void setProperty(const QDeclarativeProperty &property)
OperationGuard(QObject *obj, QList< OperationGuard > *l)
QDeclarativeSimpleAction(const QDeclarativeAction &a, State state=StartState)
void objectDestroyed(QDeclarativeStateOperation *)
void setState(QDeclarativeState *state)
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
QDeclarativeAbstractBinding * binding() const
QWeakPointer< QDeclarativeAbstractBinding > toBinding
const QString & specifiedProperty() const
void clear()
Removes all items from the list.
Definition: qlist.h:764
The State element defines configurations of objects and properties.
QDeclarativeSimpleAction(const QDeclarativeSimpleAction &other)
const QVariant & value() const
QDeclarativeBinding * when
#define Q_DECLARE_PUBLIC(Class)
Definition: qglobal.h:2477
static void operations_append(QDeclarativeListProperty< QDeclarativeStateOperation > *prop, QDeclarativeStateOperation *op)
QDeclarativeAbstractBinding::Pointer m_binding
QFactoryLoader * l
QDeclarativeActionEvent * event() const
const QDeclarativeProperty & property() const
quint16 index
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...
QDeclarativeActionEvent * event
QList< QDeclarativeProperty > reverting
QDeclarativeSimpleAction & operator=(const QDeclarativeSimpleAction &other)
static QDeclarativeStateOperation * operations_at(QDeclarativeListProperty< QDeclarativeStateOperation > *prop, int index)
QList< QDeclarativeSimpleAction > SimpleActionList
QDeclarativeStateGroup * group
static int operations_count(QDeclarativeListProperty< QDeclarativeStateOperation > *prop)