Qt 4.8
Public Functions | Private Functions | Properties | Friends | List of all members
QDeclarativeTransitionManager Class Reference

#include <qdeclarativetransitionmanager_p_p.h>

Public Functions

void cancel ()
 
 QDeclarativeTransitionManager ()
 
void transition (const QList< QDeclarativeAction > &, QDeclarativeTransition *transition)
 
 ~QDeclarativeTransitionManager ()
 

Private Functions

void complete ()
 
void setState (QDeclarativeState *)
 

Properties

QDeclarativeTransitionManagerPrivated
 

Friends

class QDeclarativeState
 
class QDeclarativeTransitionPrivate
 

Detailed Description

Definition at line 62 of file qdeclarativetransitionmanager_p_p.h.

Constructors and Destructors

◆ QDeclarativeTransitionManager()

QDeclarativeTransitionManager::QDeclarativeTransitionManager ( )

◆ ~QDeclarativeTransitionManager()

QDeclarativeTransitionManager::~QDeclarativeTransitionManager ( )

Definition at line 79 of file qdeclarativetransitionmanager.cpp.

80 {
81  delete d; d = 0;
82 }
QDeclarativeTransitionManagerPrivate * d

Functions

◆ cancel()

void QDeclarativeTransitionManager::cancel ( )

Definition at line 252 of file qdeclarativetransitionmanager.cpp.

Referenced by transition().

253 {
254  if (d->transition) {
255  // ### this could potentially trigger a complete in rare circumstances
256  d->transition->stop();
257  d->transition = 0;
258  }
259 
260  for(int i = 0; i < d->bindingsList.count(); ++i) {
261  QDeclarativeAction action = d->bindingsList[i];
262  if (!action.toBinding.isNull() && action.deletableToBinding) {
264  action.toBinding.data()->destroy();
265  action.toBinding.clear();
266  action.deletableToBinding = false;
267  } else if (action.event) {
268  //### what do we do here?
269  }
270 
271  }
272  d->bindingsList.clear();
273  d->completeList.clear();
274 }
QDeclarativeProperty property
QDeclarativeTransitionManagerPrivate * d
QDeclarativeGuard< QDeclarativeTransition > transition
virtual void destroy(DestroyMode mode=DisconnectBinding)
Destroy the binding.
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
bool isNull() const
Returns true if this object is holding a reference to a null pointer.
T * data() const
QDeclarativeStateOperation::ActionList bindingsList
QWeakPointer< QDeclarativeAbstractBinding > toBinding
void clear()
Removes all items from the list.
Definition: qlist.h:764
static QDeclarativeAbstractBinding * setBinding(QObject *, int coreIndex, int valueTypeIndex, QDeclarativeAbstractBinding *, WriteFlags flags=DontRemoveBinding)
void clear()
Clears this QWeakPointer object, dropping the reference that it may have had to the pointer...
QDeclarativeActionEvent * event

◆ complete()

void QDeclarativeTransitionManager::complete ( )
private

Definition at line 84 of file qdeclarativetransitionmanager.cpp.

Referenced by QDeclarativeTransitionPrivate::complete().

85 {
86  d->applyBindings();
87 
88  for (int ii = 0; ii < d->completeList.count(); ++ii) {
89  const QDeclarativeProperty &prop = d->completeList.at(ii).property();
90  prop.write(d->completeList.at(ii).value());
91  }
92 
93  d->completeList.clear();
94 
95  if (d->state)
97 }
QDeclarativeTransitionManagerPrivate * d
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
static QObjectPrivate * get(QObject *o)
Definition: qobject_p.h:177
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
void clear()
Removes all items from the list.
Definition: qlist.h:764
const QVariant & value() const
const QDeclarativeProperty & property() const
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...
bool write(const QVariant &) const
Sets the property value to value and returns true.

◆ setState()

void QDeclarativeTransitionManager::setState ( QDeclarativeState s)
private

Definition at line 74 of file qdeclarativetransitionmanager.cpp.

75 {
76  d->state = s;
77 }
QDeclarativeTransitionManagerPrivate * d

◆ transition()

void QDeclarativeTransitionManager::transition ( const QList< QDeclarativeAction > &  list,
QDeclarativeTransition transition 
)

Definition at line 116 of file qdeclarativetransitionmanager.cpp.

118 {
119  cancel();
120 
122  // Determine which actions are binding changes.
123  foreach(const QDeclarativeAction &action, applyList) {
124  if (action.toBinding)
125  d->bindingsList << action;
126  if (action.fromBinding)
127  QDeclarativePropertyPrivate::setBinding(action.property, 0); // Disable current binding
128  if (action.event && action.event->changesBindings()) { //### assume isReversable()?
129  d->bindingsList << action;
130  action.event->clearBindings();
131  }
132  }
133 
134  // Animated transitions need both the start and the end value for
135  // each property change. In the presence of bindings, the end values
136  // are non-trivial to calculate. As a "best effort" attempt, we first
137  // apply all the property and binding changes, then read all the actual
138  // final values, then roll back the changes and proceed as normal.
139  //
140  // This doesn't catch everything, and it might be a little fragile in
141  // some cases - but whatcha going to do?
142 
143  if (!d->bindingsList.isEmpty()) {
144 
145  // Apply all the property and binding changes
146  for (int ii = 0; ii < applyList.size(); ++ii) {
147  const QDeclarativeAction &action = applyList.at(ii);
148  if (!action.toBinding.isNull()) {
150  } else if (!action.event) {
152  } else if (action.event->isReversable()) {
153  if (action.reverseEvent)
155  else
157  }
158  }
159 
160  // Read all the end values for binding changes
161  for (int ii = 0; ii < applyList.size(); ++ii) {
162  QDeclarativeAction *action = &applyList[ii];
163  if (action->event) {
164  action->event->saveTargetValues();
165  continue;
166  }
167  const QDeclarativeProperty &prop = action->property;
168  if (!action->toBinding.isNull() || !action->toValue.isValid()) {
169  action->toValue = prop.read();
170  }
171  }
172 
173  // Revert back to the original values
174  foreach(const QDeclarativeAction &action, applyList) {
175  if (action.event) {
176  if (action.event->isReversable()) {
177  action.event->clearBindings();
178  action.event->rewind();
179  action.event->clearBindings(); //### shouldn't be needed
180  }
181  continue;
182  }
183 
184  if (action.toBinding)
185  QDeclarativePropertyPrivate::setBinding(action.property, 0); // Make sure this is disabled during the transition
186 
188  }
189  }
190 
191  if (transition) {
194  d->transition->prepare(applyList, touched, this);
195 
196  // Modify the action list to remove actions handled in the transition
197  for (int ii = 0; ii < applyList.count(); ++ii) {
198  const QDeclarativeAction &action = applyList.at(ii);
199 
200  if (action.event) {
201 
202  if (action.actionDone) {
203  applyList.removeAt(ii);
204  --ii;
205  }
206 
207  } else {
208 
209  if (touched.contains(action.property)) {
210  if (action.toValue != action.fromValue)
211  d->completeList <<
213 
214  applyList.removeAt(ii);
215  --ii;
216  }
217 
218  }
219  }
220  }
221 
222  // Any actions remaining have not been handled by the transition and should
223  // be applied immediately. We skip applying bindings, as they are all
224  // applied at the end in applyBindings() to avoid any nastiness mid
225  // transition
226  foreach(const QDeclarativeAction &action, applyList) {
227  if (action.event && !action.event->changesBindings()) {
228  if (action.event->isReversable() && action.reverseEvent)
229  action.event->reverse();
230  else
231  action.event->execute();
232  } else if (!action.event && !action.toBinding) {
233  action.property.write(action.toValue);
234  }
235  }
236 #ifndef QT_NO_DEBUG_STREAM
237  if (stateChangeDebug()) {
238  foreach(const QDeclarativeAction &action, applyList) {
239  if (action.event)
240  qWarning() << " No transition for event:" << action.event->typeName();
241  else
242  qWarning() << " No transition for:" << action.property.object()
243  << action.property.name() << "From:" << action.fromValue
244  << "To:" << action.toValue;
245  }
246  }
247 #endif
248  if (!transition)
249  d->applyBindings();
250 }
QDeclarativeProperty property
QDeclarativeTransitionManagerPrivate * d
void transition(const QList< QDeclarativeAction > &, QDeclarativeTransition *transition)
QDeclarativeGuard< QDeclarativeTransition > transition
int count(const T &t) const
Returns the number of occurrences of value in the list.
Definition: qlist.h:891
bool isNull() const
Returns true if this object is holding a reference to a null pointer.
T * data() const
bool isEmpty() const
Returns true if the list contains no items; otherwise returns false.
Definition: qlist.h:152
QObject * object() const
Returns the QDeclarativeProperty&#39;s QObject.
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
QDeclarativeStateOperation::ActionList bindingsList
const T & at(int i) const
Returns the item at index position i in the list.
Definition: qlist.h:468
Q_CORE_EXPORT void qWarning(const char *,...)
virtual void execute(Reason reason=ActualChange)
QWeakPointer< QDeclarativeAbstractBinding > toBinding
static QDeclarativeAbstractBinding * setBinding(QObject *, int coreIndex, int valueTypeIndex, QDeclarativeAbstractBinding *, WriteFlags flags=DontRemoveBinding)
virtual QString typeName() const
void prepare(QDeclarativeStateOperation::ActionList &actions, QList< QDeclarativeProperty > &after, QDeclarativeTransitionManager *end)
int size() const
Returns the number of items in the list.
Definition: qlist.h:137
The QDeclarativeProperty class abstracts accessing properties on objects created from QML...
bool write(const QVariant &) const
Sets the property value to value and returns true.
QDeclarativeActionEvent * event
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485
QString name() const
Return the name of this QML property.
virtual void reverse(Reason reason=ActualChange)
QVariant read() const
Returns the property value.
static bool write(QObject *, const QDeclarativePropertyCache::Data &, const QVariant &, QDeclarativeContextData *, WriteFlags flags=0)
QDeclarativeAbstractBinding * fromBinding
void removeAt(int i)
Removes the item at index position i.
Definition: qlist.h:480

Friends and Related Functions

◆ QDeclarativeState

friend class QDeclarativeState
friend

Definition at line 79 of file qdeclarativetransitionmanager_p_p.h.

◆ QDeclarativeTransitionPrivate

Definition at line 80 of file qdeclarativetransitionmanager_p_p.h.

Properties

◆ d

QDeclarativeTransitionManagerPrivate* QDeclarativeTransitionManager::d
private

The documentation for this class was generated from the following files: