Qt 4.8
Public Functions | Static Public Functions | Public Variables | List of all members
QVariantAnimationPrivate Class Reference

#include <qvariantanimation_p.h>

Inheritance diagram for QVariantAnimationPrivate:
QAbstractAnimationPrivate QObjectPrivate QObjectData QPropertyAnimationPrivate

Public Functions

void convertValues (int t)
 
 QVariantAnimationPrivate ()
 
void recalculateCurrentInterval (bool force=false)
 The goal of this function is to update the currentInterval member. More...
 
void setCurrentValueForProgress (const qreal progress)
 
void setDefaultStartEndValue (const QVariant &value)
 
void setValueAt (qreal, const QVariant &)
 
void updateInterpolator ()
 
QVariant valueAt (qreal step) const
 
- Public Functions inherited from QAbstractAnimationPrivate
 QAbstractAnimationPrivate ()
 
void setState (QAbstractAnimation::State state)
 
virtual ~QAbstractAnimationPrivate ()
 
- Public Functions inherited from QObjectPrivate
void _q_reregisterTimers (void *pointer)
 
void addConnection (int signal, Connection *c)
 
void cleanConnectionLists ()
 
void connectNotify (const char *signal)
 
void deleteChildren ()
 
void disconnectNotify (const char *signal)
 
bool isSender (const QObject *receiver, const char *signal) const
 
bool isSignalConnected (uint signalIdx) const
 Returns true if the signal with index signal_index from object sender is connected. More...
 
void moveToThread_helper ()
 
 QObjectPrivate (int version=QObjectPrivateVersion)
 
QObjectList receiverList (const char *signal) const
 
QObjectList senderList () const
 
void setParent_helper (QObject *)
 
void setThreadData_helper (QThreadData *currentData, QThreadData *targetData)
 
int signalIndex (const char *signalName) const
 Returns the signal index used in the internal connectionLists vector. More...
 
virtual ~QObjectPrivate ()
 
- Public Functions inherited from QObjectData
virtual ~QObjectData ()=0
 

Static Public Functions

static QVariantAnimationPrivateget (QVariantAnimation *q)
 
static Q_CORE_EXPORT QVariantAnimation::Interpolator getInterpolator (int interpolationType)
 
- Static Public Functions inherited from QAbstractAnimationPrivate
static QAbstractAnimationPrivateget (QAbstractAnimation *q)
 
- Static Public Functions inherited from QObjectPrivate
static void clearGuards (QObject *)
 
static QObjectPrivateget (QObject *o)
 
static void resetCurrentSender (QObject *receiver, Sender *currentSender, Sender *previousSender)
 
static SendersetCurrentSender (QObject *receiver, Sender *sender)
 
static void signalSignature (const QMetaMethod &signal, QVarLengthArray< char > *result)
 

Public Variables

struct {
   QVariantAnimation::KeyValue   end
 
   QVariantAnimation::KeyValue   start
 
currentInterval
 
QVariant currentValue
 
QVariant defaultStartEndValue
 
int duration
 
QEasingCurve easing
 
QVariantAnimation::Interpolator interpolator
 
QVariantAnimation::KeyValues keyValues
 
- Public Variables inherited from QAbstractAnimationPrivate
int currentLoop
 
int currentTime
 
bool deleteWhenStopped
 
QAbstractAnimation::Direction direction
 
QAnimationGroupgroup
 
bool hasRegisteredTimer
 
bool isGroup
 
bool isPause
 
int loopCount
 
QAbstractAnimation::State state
 
int totalCurrentTime
 
- Public Variables inherited from QObjectPrivate
union {
   QObject *   currentChildBeingDeleted
 
   QAbstractDeclarativeData *   declarativeData
 
}; 
 
quint32 connectedSignals [2]
 
QObjectConnectionListVectorconnectionLists
 
SendercurrentSender
 
QList< QPointer< QObject > > eventFilters
 
ExtraDataextraData
 
QString objectName
 
Connectionsenders
 
QAtomicPointer< QtSharedPointer::ExternalRefCountData > sharedRefcount
 
QThreadDatathreadData
 
void * unused
 
- Public Variables inherited from QObjectData
uint blockSig: 1
 
QObjectList children
 
uint hasGuards: 1
 
uint inEventHandler: 1
 
uint inThreadChangeEvent: 1
 
uint isWidget: 1
 
QMetaObjectmetaObject
 
uint ownObjectName: 1
 
QObjectparent
 
uint pendTimer: 1
 
int postedEvents
 
QObjectq_ptr
 
uint receiveChildEvents: 1
 
uint sendChildEvents: 1
 
uint unused: 22
 
uint wasDeleted: 1
 

Additional Inherited Members

- Public Types inherited from QObjectPrivate
typedef void(* StaticMetaCallFunction) (QObject *, QMetaObject::Call, int, void **)
 

Detailed Description

Definition at line 67 of file qvariantanimation_p.h.

Constructors and Destructors

◆ QVariantAnimationPrivate()

QVariantAnimationPrivate::QVariantAnimationPrivate ( )

Definition at line 207 of file qvariantanimation.cpp.

208 { }
QVariantAnimation::Interpolator interpolator
static QVariant defaultInterpolator(const void *, const void *, qreal)

Functions

◆ convertValues()

void QVariantAnimationPrivate::convertValues ( int  t)

Definition at line 210 of file qvariantanimation.cpp.

Referenced by QPropertyAnimationPrivate::updateMetaProperty().

211 {
212  //this ensures that all the keyValues are of type t
213  for (int i = 0; i < keyValues.count(); ++i) {
215  pair.second.convert(static_cast<QVariant::Type>(t));
216  }
217  //we also need update to the current interval if needed
218  currentInterval.start.second.convert(static_cast<QVariant::Type>(t));
219  currentInterval.end.second.convert(static_cast<QVariant::Type>(t));
220 
221  //... and the interpolator
223 }
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
T2 second
Definition: qpair.h:66
QVariantAnimation::KeyValues keyValues
bool convert(Type t)
Casts the variant to the requested type, t.
Definition: qvariant.cpp:2959
struct QVariantAnimationPrivate::@1 currentInterval

◆ get()

static QVariantAnimationPrivate* QVariantAnimationPrivate::get ( QVariantAnimation q)
inlinestatic

Definition at line 74 of file qvariantanimation_p.h.

75  {
76  return q->d_func();
77  }

◆ getInterpolator()

QVariantAnimation::Interpolator QVariantAnimationPrivate::getInterpolator ( int  interpolationType)
static

Definition at line 470 of file qvariantanimation.cpp.

Referenced by QDeclarativeNumberAnimation::init(), QDeclarativeColorAnimation::QDeclarativeColorAnimation(), QDeclarativeRotationAnimation::QDeclarativeRotationAnimation(), QDeclarativeVector3dAnimation::QDeclarativeVector3dAnimation(), QDeclarativeRotationAnimation::setDirection(), QDeclarativeAnimationPropertyUpdater::setValue(), and updateInterpolator().

471 {
472  QInterpolatorVector *interpolators = registeredInterpolators();
473 #ifndef QT_NO_THREAD
474  QMutexLocker locker(QMutexPool::globalInstanceGet(interpolators));
475 #endif
477  if (interpolationType < interpolators->count()) {
478  ret = interpolators->at(interpolationType);
479  if (ret) return ret;
480  }
481 
482  switch(interpolationType)
483  {
484  case QMetaType::Int:
485  return castToInterpolator(_q_interpolateVariant<int>);
486  case QMetaType::UInt:
487  return castToInterpolator(_q_interpolateVariant<uint>);
488  case QMetaType::Double:
489  return castToInterpolator(_q_interpolateVariant<double>);
490  case QMetaType::Float:
491  return castToInterpolator(_q_interpolateVariant<float>);
492  case QMetaType::QLine:
493  return castToInterpolator(_q_interpolateVariant<QLine>);
494  case QMetaType::QLineF:
495  return castToInterpolator(_q_interpolateVariant<QLineF>);
496  case QMetaType::QPoint:
497  return castToInterpolator(_q_interpolateVariant<QPoint>);
498  case QMetaType::QPointF:
499  return castToInterpolator(_q_interpolateVariant<QPointF>);
500  case QMetaType::QSize:
501  return castToInterpolator(_q_interpolateVariant<QSize>);
502  case QMetaType::QSizeF:
503  return castToInterpolator(_q_interpolateVariant<QSizeF>);
504  case QMetaType::QRect:
505  return castToInterpolator(_q_interpolateVariant<QRect>);
506  case QMetaType::QRectF:
507  return castToInterpolator(_q_interpolateVariant<QRectF>);
508  default:
509  return 0; //this type is not handled
510  }
511 }
The QVector class is a template class that provides a dynamic array.
Definition: qdatastream.h:64
QVariant(* Interpolator)(const void *from, const void *to, qreal progress)
const T & at(int i) const
Returns the item at index position i in the vector.
Definition: qvector.h:350
static QVariantAnimation::Interpolator castToInterpolator(QVariant(*func)(const T &from, const T &to, qreal progress))
The QMutexLocker class is a convenience class that simplifies locking and unlocking mutexes...
Definition: qmutex.h:101
static QMutex * globalInstanceGet(const void *address)
Returns a QMutex from the global mutex pool.
Definition: qmutexpool.cpp:150

◆ recalculateCurrentInterval()

void QVariantAnimationPrivate::recalculateCurrentInterval ( bool  force = false)

The goal of this function is to update the currentInterval member.

Warning
This function is not part of the public interface. As a consequence, we also need to update the currentValue. Set force to true to always recalculate the interval.

Definition at line 247 of file qvariantanimation.cpp.

Referenced by setDefaultStartEndValue(), and setValueAt().

248 {
249  // can't interpolate if we don't have at least 2 values
250  if ((keyValues.count() + (defaultStartEndValue.isValid() ? 1 : 0)) < 2)
251  return;
252 
253  const qreal endProgress = (direction == QAbstractAnimation::Forward) ? qreal(1) : qreal(0);
254  const qreal progress = easing.valueForProgress(((duration == 0) ? endProgress : qreal(currentTime) / qreal(duration)));
255 
256  //0 and 1 are still the boundaries
257  if (force || (currentInterval.start.first > 0 && progress < currentInterval.start.first)
258  || (currentInterval.end.first < 1 && progress > currentInterval.end.first)) {
259  //let's update currentInterval
262  qMakePair(progress, QVariant()),
264  if (it == keyValues.constBegin()) {
265  //the item pointed to by it is the start element in the range
266  if (it->first == 0 && keyValues.count() > 1) {
267  currentInterval.start = *it;
268  currentInterval.end = *(it+1);
269  } else {
271  currentInterval.end = *it;
272  }
273  } else if (it == keyValues.constEnd()) {
274  --it; //position the iterator on the last item
275  if (it->first == 1 && keyValues.count() > 1) {
276  //we have an end value (item with progress = 1)
277  currentInterval.start = *(it-1);
278  currentInterval.end = *it;
279  } else {
280  //we use the default end value here
281  currentInterval.start = *it;
283  }
284  } else {
285  currentInterval.start = *(it-1);
286  currentInterval.end = *it;
287  }
288 
289  // update all the values of the currentInterval
291  }
292  setCurrentValueForProgress(progress);
293 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
qreal valueForProgress(qreal progress) const
Return the effective progress for the easing curve at progress.
double qreal
Definition: qglobal.h:1193
#define it(className, varName)
int count(const T &t) const
Returns the number of occurrences of value in the vector.
Definition: qvector.h:742
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the vector...
Definition: qvector.h:252
QAbstractAnimation::Direction direction
static bool animationValueLessThan(const QVariantAnimation::KeyValue &p1, const QVariantAnimation::KeyValue &p2)
const_iterator constBegin() const
Returns a const STL-style iterator pointing to the first item in the vector.
Definition: qvector.h:249
QVariantAnimation::KeyValues keyValues
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
Definition: qalgorithms.h:227
Q_OUTOFLINE_TEMPLATE QPair< T1, T2 > qMakePair(const T1 &x, const T2 &y)
Definition: qpair.h:102
void setCurrentValueForProgress(const qreal progress)
const KeyValue * const_iterator
The QVector::const_iterator typedef provides an STL-style const iterator for QVector and QStack...
Definition: qvector.h:245
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485
struct QVariantAnimationPrivate::@1 currentInterval

◆ setCurrentValueForProgress()

void QVariantAnimationPrivate::setCurrentValueForProgress ( const qreal  progress)

Definition at line 295 of file qvariantanimation.cpp.

Referenced by recalculateCurrentInterval().

296 {
298 
299  const qreal startProgress = currentInterval.start.first;
300  const qreal endProgress = currentInterval.end.first;
301  const qreal localProgress = (progress - startProgress) / (endProgress - startProgress);
302 
303  QVariant ret = q->interpolated(currentInterval.start.second,
304  currentInterval.end.second,
305  localProgress);
306  qSwap(currentValue, ret);
307  q->updateCurrentValue(currentValue);
308  static QBasicAtomicInt changedSignalIndex = Q_BASIC_ATOMIC_INITIALIZER(0);
309  if (!changedSignalIndex) {
310  //we keep the mask so that we emit valueChanged only when needed (for performance reasons)
311  changedSignalIndex.testAndSetRelaxed(0, signalIndex("valueChanged(QVariant)"));
312  }
313  if (isSignalConnected(changedSignalIndex) && currentValue != ret) {
314  //the value has changed
315  emit q->valueChanged(currentValue);
316  }
317 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
double qreal
Definition: qglobal.h:1193
#define Q_BASIC_ATOMIC_INITIALIZER(a)
Definition: qbasicatomic.h:218
#define Q_Q(Class)
Definition: qglobal.h:2483
bool testAndSetRelaxed(int expectedValue, int newValue)
The QVariantAnimation class provides an abstract base class for animations.
#define emit
Definition: qobjectdefs.h:76
void qSwap(T &value1, T &value2)
Definition: qglobal.h:2181
bool isSignalConnected(uint signalIdx) const
Returns true if the signal with index signal_index from object sender is connected.
Definition: qobject_p.h:237
struct QVariantAnimationPrivate::@1 currentInterval
int signalIndex(const char *signalName) const
Returns the signal index used in the internal connectionLists vector.
Definition: qobject.cpp:3719

◆ setDefaultStartEndValue()

void QVariantAnimationPrivate::setDefaultStartEndValue ( const QVariant value)

Definition at line 351 of file qvariantanimation.cpp.

Referenced by get().

352 {
353  defaultStartEndValue = value;
354  recalculateCurrentInterval(/*force=*/true);
355 }
void recalculateCurrentInterval(bool force=false)
The goal of this function is to update the currentInterval member.

◆ setValueAt()

void QVariantAnimationPrivate::setValueAt ( qreal  step,
const QVariant value 
)

Definition at line 329 of file qvariantanimation.cpp.

330 {
331  if (step < qreal(0.0) || step > qreal(1.0)) {
332  qWarning("QVariantAnimation::setValueAt: invalid step = %f", step);
333  return;
334  }
335 
336  QVariantAnimation::KeyValue pair(step, value);
337 
339  if (result == keyValues.end() || result->first != step) {
340  keyValues.insert(result, pair);
341  } else {
342  if (value.isValid())
343  result->second = value; // replaces the previous value
344  else
345  keyValues.erase(result); // removes the previous value
346  }
347 
348  recalculateCurrentInterval(/*force=*/true);
349 }
double qreal
Definition: qglobal.h:1193
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the vector...
Definition: qvector.h:250
static bool animationValueLessThan(const QVariantAnimation::KeyValue &p1, const QVariantAnimation::KeyValue &p2)
Q_CORE_EXPORT void qWarning(const char *,...)
QVariantAnimation::KeyValues keyValues
KeyValue * iterator
The QVector::iterator typedef provides an STL-style non-const iterator for QVector and QStack...
Definition: qvector.h:244
void insert(int i, const T &t)
Inserts value at index position i in the vector.
Definition: qvector.h:362
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qLowerBound(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
Definition: qalgorithms.h:227
iterator begin()
Returns an STL-style iterator pointing to the first item in the vector.
Definition: qvector.h:247
iterator erase(iterator begin, iterator end)
Removes all the items from begin up to (but not including) end.
Definition: qvector.h:627
void recalculateCurrentInterval(bool force=false)
The goal of this function is to update the currentInterval member.
bool isValid() const
Returns true if the storage type of this variant is not QVariant::Invalid; otherwise returns false...
Definition: qvariant.h:485

◆ updateInterpolator()

void QVariantAnimationPrivate::updateInterpolator ( )

Definition at line 225 of file qvariantanimation.cpp.

Referenced by convertValues(), and recalculateCurrentInterval().

226 {
227  int type = currentInterval.start.second.userType();
228  if (type == currentInterval.end.second.userType())
230  else
231  interpolator = 0;
232 
233  //we make sure that the interpolator is always set to something
234  if (!interpolator)
236 }
int type
Definition: qmetatype.cpp:239
static Q_CORE_EXPORT QVariantAnimation::Interpolator getInterpolator(int interpolationType)
QVariantAnimation::Interpolator interpolator
static QVariant defaultInterpolator(const void *, const void *, qreal)
struct QVariantAnimationPrivate::@1 currentInterval

◆ valueAt()

QVariant QVariantAnimationPrivate::valueAt ( qreal  step) const

Definition at line 319 of file qvariantanimation.cpp.

320 {
323  if (result != keyValues.constEnd())
324  return result->second;
325 
326  return QVariant();
327 }
The QVariant class acts like a union for the most common Qt data types.
Definition: qvariant.h:92
const_iterator constEnd() const
Returns a const STL-style iterator pointing to the imaginary item after the last item in the vector...
Definition: qvector.h:252
Q_OUTOFLINE_TEMPLATE RandomAccessIterator qBinaryFind(RandomAccessIterator begin, RandomAccessIterator end, const T &value)
Definition: qalgorithms.h:295
iterator end()
Returns an STL-style iterator pointing to the imaginary item after the last item in the vector...
Definition: qvector.h:250
static bool animationValueLessThan(const QVariantAnimation::KeyValue &p1, const QVariantAnimation::KeyValue &p2)
QVariantAnimation::KeyValues keyValues
iterator begin()
Returns an STL-style iterator pointing to the first item in the vector.
Definition: qvector.h:247
Q_OUTOFLINE_TEMPLATE QPair< T1, T2 > qMakePair(const T1 &x, const T2 &y)
Definition: qpair.h:102
const KeyValue * const_iterator
The QVector::const_iterator typedef provides an STL-style const iterator for QVector and QStack...
Definition: qvector.h:245

Properties

◆ currentInterval

struct { ... } QVariantAnimationPrivate::currentInterval

◆ currentValue

QVariant QVariantAnimationPrivate::currentValue

Definition at line 82 of file qvariantanimation_p.h.

Referenced by setCurrentValueForProgress().

◆ defaultStartEndValue

QVariant QVariantAnimationPrivate::defaultStartEndValue

Definition at line 83 of file qvariantanimation_p.h.

Referenced by recalculateCurrentInterval(), and setDefaultStartEndValue().

◆ duration

int QVariantAnimationPrivate::duration

Definition at line 92 of file qvariantanimation_p.h.

Referenced by recalculateCurrentInterval().

◆ easing

QEasingCurve QVariantAnimationPrivate::easing

Definition at line 91 of file qvariantanimation_p.h.

Referenced by recalculateCurrentInterval().

◆ end

QVariantAnimation::KeyValue QVariantAnimationPrivate::end

Definition at line 88 of file qvariantanimation_p.h.

◆ interpolator

QVariantAnimation::Interpolator QVariantAnimationPrivate::interpolator

Definition at line 94 of file qvariantanimation_p.h.

Referenced by updateInterpolator().

◆ keyValues

QVariantAnimation::KeyValues QVariantAnimationPrivate::keyValues

◆ start

QVariantAnimation::KeyValue QVariantAnimationPrivate::start

Definition at line 88 of file qvariantanimation_p.h.


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