Qt 4.8
Signals | Public Functions | Private Slots | Properties | List of all members
QDeclarativeBehavior Class Reference

#include <qdeclarativebehavior_p.h>

Inheritance diagram for QDeclarativeBehavior:
QObject QDeclarativePropertyValueInterceptor

Signals

void enabledChanged ()
 
- Signals inherited from QObject
void destroyed (QObject *=0)
 This signal is emitted immediately before the object obj is destroyed, and can not be blocked. More...
 

Public Functions

QDeclarativeAbstractAnimationanimation ()
 
bool enabled () const
 
 QDeclarativeBehavior (QObject *parent=0)
 
void setAnimation (QDeclarativeAbstractAnimation *)
 
void setEnabled (bool enabled)
 
virtual void setTarget (const QDeclarativeProperty &)
 Set the target property for the value interceptor. More...
 
virtual void write (const QVariant &value)
 This method will be called when a new value is assigned to the property being intercepted. More...
 
 ~QDeclarativeBehavior ()
 
- Public Functions inherited from QObject
bool blockSignals (bool b)
 If block is true, signals emitted by this object are blocked (i.e., emitting a signal will not invoke anything connected to it). More...
 
const QObjectListchildren () const
 Returns a list of child objects. More...
 
bool connect (const QObject *sender, const char *signal, const char *member, Qt::ConnectionType type=Qt::AutoConnection) const
 
bool disconnect (const char *signal=0, const QObject *receiver=0, const char *member=0)
 
bool disconnect (const QObject *receiver, const char *member=0)
 
void dumpObjectInfo ()
 Dumps information about signal connections, etc. More...
 
void dumpObjectTree ()
 Dumps a tree of children to the debug output. More...
 
QList< QByteArraydynamicPropertyNames () const
 Returns the names of all properties that were dynamically added to the object using setProperty(). More...
 
virtual bool event (QEvent *)
 This virtual function receives events to an object and should return true if the event e was recognized and processed. More...
 
virtual bool eventFilter (QObject *, QEvent *)
 Filters events if this object has been installed as an event filter for the watched object. More...
 
template<typename T >
findChild (const QString &aName=QString()) const
 Returns the child of this object that can be cast into type T and that is called name, or 0 if there is no such object. More...
 
template<typename T >
QList< T > findChildren (const QString &aName=QString()) const
 Returns all children of this object with the given name that can be cast to type T, or an empty list if there are no such objects. More...
 
template<typename T >
QList< T > findChildren (const QRegExp &re) const
 
bool inherits (const char *classname) const
 Returns true if this object is an instance of a class that inherits className or a QObject subclass that inherits className; otherwise returns false. More...
 
void installEventFilter (QObject *)
 Installs an event filter filterObj on this object. More...
 
bool isWidgetType () const
 Returns true if the object is a widget; otherwise returns false. More...
 
void killTimer (int id)
 Kills the timer with timer identifier, id. More...
 
virtual const QMetaObjectmetaObject () const
 Returns a pointer to the meta-object of this object. More...
 
void moveToThread (QThread *thread)
 Changes the thread affinity for this object and its children. More...
 
QString objectName () const
 
QObjectparent () const
 Returns a pointer to the parent object. More...
 
QVariant property (const char *name) const
 Returns the value of the object's name property. More...
 
Q_INVOKABLE QObject (QObject *parent=0)
 Constructs an object with parent object parent. More...
 
void removeEventFilter (QObject *)
 Removes an event filter object obj from this object. More...
 
void setObjectName (const QString &name)
 
void setParent (QObject *)
 Makes the object a child of parent. More...
 
bool setProperty (const char *name, const QVariant &value)
 Sets the value of the object's name property to value. More...
 
void setUserData (uint id, QObjectUserData *data)
 
bool signalsBlocked () const
 Returns true if signals are blocked; otherwise returns false. More...
 
int startTimer (int interval)
 Starts a timer and returns a timer identifier, or returns zero if it could not start a timer. More...
 
QThreadthread () const
 Returns the thread in which the object lives. More...
 
QObjectUserDatauserData (uint id) const
 
virtual ~QObject ()
 Destroys the object, deleting all its child objects. More...
 
- Public Functions inherited from QDeclarativePropertyValueInterceptor
 QDeclarativePropertyValueInterceptor ()
 Constructs a QDeclarativePropertyValueInterceptor. More...
 
virtual ~QDeclarativePropertyValueInterceptor ()
 

Private Slots

void componentFinalized ()
 
void qtAnimationStateChanged (QAbstractAnimation::State, QAbstractAnimation::State)
 

Properties

QDeclarativeAbstractAnimationanimation
 
bool enabled
 

Additional Inherited Members

- Public Slots inherited from QObject
void deleteLater ()
 Schedules this object for deletion. More...
 
- Static Public Functions inherited from QObject
static bool connect (const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
 Creates a connection of the given type from the signal in the sender object to the method in the receiver object. More...
 
static bool connect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &method, Qt::ConnectionType type=Qt::AutoConnection)
 
static bool disconnect (const QObject *sender, const char *signal, const QObject *receiver, const char *member)
 Disconnects signal in object sender from method in object receiver. More...
 
static bool disconnect (const QObject *sender, const QMetaMethod &signal, const QObject *receiver, const QMetaMethod &member)
 
static uint registerUserData ()
 
static QString tr (const char *sourceText, const char *comment=0, int n=-1)
 
static QString trUtf8 (const char *sourceText, const char *comment=0, int n=-1)
 
- Static Public Variables inherited from QObject
static const QMetaObject staticMetaObject
 This variable stores the meta-object for the class. More...
 
- Protected Functions inherited from QObject
virtual void childEvent (QChildEvent *)
 This event handler can be reimplemented in a subclass to receive child events. More...
 
virtual void connectNotify (const char *signal)
 This virtual function is called when something has been connected to signal in this object. More...
 
virtual void customEvent (QEvent *)
 This event handler can be reimplemented in a subclass to receive custom events. More...
 
virtual void disconnectNotify (const char *signal)
 This virtual function is called when something has been disconnected from signal in this object. More...
 
 QObject (QObjectPrivate &dd, QObject *parent=0)
 
int receivers (const char *signal) const
 Returns the number of receivers connected to the signal. More...
 
QObjectsender () const
 Returns a pointer to the object that sent the signal, if called in a slot activated by a signal; otherwise it returns 0. More...
 
int senderSignalIndex () const
 
virtual void timerEvent (QTimerEvent *)
 This event handler can be reimplemented in a subclass to receive timer events for the object. More...
 
- Protected Variables inherited from QObject
QScopedPointer< QObjectDatad_ptr
 
- Static Protected Variables inherited from QObject
static const QMetaObject staticQtMetaObject
 

Detailed Description

Definition at line 60 of file qdeclarativebehavior_p.h.

Constructors and Destructors

◆ QDeclarativeBehavior()

QDeclarativeBehavior::QDeclarativeBehavior ( QObject parent = 0)

Definition at line 104 of file qdeclarativebehavior.cpp.

105  : QObject(*(new QDeclarativeBehaviorPrivate), parent)
106 {
107 }
Q_INVOKABLE QObject(QObject *parent=0)
Constructs an object with parent object parent.
Definition: qobject.cpp:753

◆ ~QDeclarativeBehavior()

QDeclarativeBehavior::~QDeclarativeBehavior ( )

Definition at line 109 of file qdeclarativebehavior.cpp.

110 {
111 }

Functions

◆ animation()

QDeclarativeAbstractAnimation* QDeclarativeBehavior::animation ( )

◆ componentFinalized

void QDeclarativeBehavior::componentFinalized ( )
privateslot

Definition at line 233 of file qdeclarativebehavior.cpp.

234 {
236  d->finalized = true;
237 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ enabled()

bool QDeclarativeBehavior::enabled ( ) const

◆ enabledChanged

void QDeclarativeBehavior::enabledChanged ( )
signal

Referenced by setEnabled().

◆ qtAnimationStateChanged

void QDeclarativeBehavior::qtAnimationStateChanged ( QAbstractAnimation::State  newState,
QAbstractAnimation::State   
)
privateslot

Definition at line 149 of file qdeclarativebehavior.cpp.

Referenced by setAnimation().

150 {
152  if (!d->blockRunningChanged)
153  d->animation->notifyRunningChanged(newState == QAbstractAnimation::Running);
154 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482

◆ setAnimation()

void QDeclarativeBehavior::setAnimation ( QDeclarativeAbstractAnimation animation)

Definition at line 129 of file qdeclarativebehavior.cpp.

130 {
132  if (d->animation) {
133  qmlInfo(this) << tr("Cannot change the animation assigned to a Behavior.");
134  return;
135  }
136 
137  d->animation = animation;
138  if (d->animation) {
139  d->animation->setDefaultTarget(d->property);
140  d->animation->setDisableUserControl();
141  connect(d->animation->qtAnimation(),
143  this,
145  }
146 }
double d
Definition: qnumeric_p.h:62
State
This enum describes the state of the animation.
#define SLOT(a)
Definition: qobjectdefs.h:226
static QString tr(const char *sourceText, const char *comment=0, int n=-1)
#define Q_D(Class)
Definition: qglobal.h:2482
#define SIGNAL(a)
Definition: qobjectdefs.h:227
static bool connect(const QObject *sender, const char *signal, const QObject *receiver, const char *member, Qt::ConnectionType=Qt::AutoConnection)
Creates a connection of the given type from the signal in the sender object to the method in the rece...
Definition: qobject.cpp:2580
void qtAnimationStateChanged(QAbstractAnimation::State, QAbstractAnimation::State)
QDeclarativeInfo qmlInfo(const QObject *me)
QDeclarativeAbstractAnimation * animation()

◆ setEnabled()

void QDeclarativeBehavior::setEnabled ( bool  enabled)

Definition at line 175 of file qdeclarativebehavior.cpp.

176 {
178  if (d->enabled == enabled)
179  return;
180  d->enabled = enabled;
182 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
#define emit
Definition: qobjectdefs.h:76
bool enabled() const

◆ setTarget()

void QDeclarativeBehavior::setTarget ( const QDeclarativeProperty property)
virtual

Set the target property for the value interceptor.

This method will be called by the QML engine when assigning a value interceptor.

Implements QDeclarativePropertyValueInterceptor.

Definition at line 221 of file qdeclarativebehavior.cpp.

222 {
224  d->property = property;
225  d->currentValue = property.read();
226  if (d->animation)
227  d->animation->setDefaultTarget(property);
228 
230  engPriv->registerFinalizedParserStatusObject(this, this->metaObject()->indexOfSlot("componentFinalized()"));
231 }
double d
Definition: qnumeric_p.h:62
#define Q_D(Class)
Definition: qglobal.h:2482
static QDeclarativeEnginePrivate * get(QDeclarativeEngine *e)
void registerFinalizedParserStatusObject(QObject *obj, int index)
Q_DECLARATIVE_EXPORT QDeclarativeEngine * qmlEngine(const QObject *)
QVariant property(const char *name) const
Returns the value of the object&#39;s name property.
Definition: qobject.cpp:3807
virtual const QMetaObject * metaObject() const
Returns a pointer to the meta-object of this object.

◆ write()

void QDeclarativeBehavior::write ( const QVariant value)
virtual

This method will be called when a new value is assigned to the property being intercepted.

Implements QDeclarativePropertyValueInterceptor.

Definition at line 184 of file qdeclarativebehavior.cpp.

185 {
187  qmlExecuteDeferred(this);
188  if (!d->animation || !d->enabled || !d->finalized) {
190  d->targetValue = value;
191  return;
192  }
193 
194  if (d->animation->isRunning() && value == d->targetValue)
195  return;
196 
197  d->currentValue = d->property.read();
198  d->targetValue = value;
199 
200  if (d->animation->qtAnimation()->duration() != -1
201  && d->animation->qtAnimation()->state() != QAbstractAnimation::Stopped) {
202  d->blockRunningChanged = true;
203  d->animation->qtAnimation()->stop();
204  }
205 
207  QDeclarativeAction action;
208  action.property = d->property;
209  action.fromValue = d->currentValue;
210  action.toValue = value;
211  actions << action;
212 
214  d->animation->transition(actions, after, QDeclarativeAbstractAnimation::Forward);
215  d->animation->qtAnimation()->start();
216  d->blockRunningChanged = false;
217  if (!after.contains(d->property))
219 }
double d
Definition: qnumeric_p.h:62
QDeclarativeProperty property
#define Q_D(Class)
Definition: qglobal.h:2482
QBool contains(const T &t) const
Returns true if the list contains an occurrence of value; otherwise returns false.
Definition: qlist.h:880
Q_DECLARATIVE_EXPORT void qmlExecuteDeferred(QObject *)
static bool write(QObject *, const QDeclarativePropertyCache::Data &, const QVariant &, QDeclarativeContextData *, WriteFlags flags=0)

Properties

◆ animation

QDeclarativeAbstractAnimation * QDeclarativeBehavior::animation
private

Definition at line 67 of file qdeclarativebehavior_p.h.

◆ enabled

bool QDeclarativeBehavior::enabled
private

Definition at line 68 of file qdeclarativebehavior_p.h.


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