Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | void QPropertyAnimationPrivate::updateMetaProperty() | - |
8 | { | - |
9 | if (!target || propertyName.isEmpty()) { | - |
10 | propertyType = QVariant::Invalid; | - |
11 | propertyIndex = -1; | - |
12 | return; | - |
13 | } | - |
14 | | - |
15 | | - |
16 | | - |
17 | propertyType = targetValue->property(propertyName).userType(); | - |
18 | propertyIndex = targetValue->metaObject()->indexOfProperty(propertyName); | - |
19 | | - |
20 | if (propertyType != QVariant::Invalid) | - |
21 | convertValues(propertyType); | - |
22 | if (propertyIndex == -1) { | - |
23 | | - |
24 | propertyType = QVariant::Invalid; | - |
25 | if (!targetValue->dynamicPropertyNames().contains(propertyName)) | - |
26 | QMessageLogger("animation/qpropertyanimation.cpp", 121, __PRETTY_FUNCTION__).warning("QPropertyAnimation: you're trying to animate a non-existing property %s of your QObject", propertyName.constData()); | - |
27 | } else if (!targetValue->metaObject()->property(propertyIndex).isWritable()) { | - |
28 | QMessageLogger("animation/qpropertyanimation.cpp", 123, __PRETTY_FUNCTION__).warning("QPropertyAnimation: you're trying to animate the non-writable property %s of your QObject", propertyName.constData()); | - |
29 | } | - |
30 | } | - |
31 | | - |
32 | void QPropertyAnimationPrivate::updateProperty(const QVariant &newValue) | - |
33 | { | - |
34 | if (state == QAbstractAnimation::Stopped) evaluated: state == QAbstractAnimation::Stopped yes Evaluation Count:66 | yes Evaluation Count:2212 |
| 66-2212 |
35 | return; executed: return; Execution Count:66 | 66 |
36 | | - |
37 | if (!target) { evaluated: !target yes Evaluation Count:1 | yes Evaluation Count:2211 |
| 1-2211 |
38 | q_func()->stop(); | - |
39 | return; executed: return; Execution Count:1 | 1 |
40 | } | - |
41 | | - |
42 | if (newValue.userType() == propertyType) { evaluated: newValue.userType() == propertyType yes Evaluation Count:1124 | yes Evaluation Count:1087 |
| 1087-1124 |
43 | | - |
44 | | - |
45 | int status = -1; | - |
46 | int flags = 0; | - |
47 | void *dataargv[] = { const_cast<void *>(newValue.constData());()), const_cast<QVariant *>(&newValue), &status, &flags }; | - |
48 | QMetaObject::metacall(targetValue, QMetaObject::WriteProperty, propertyIndex, &dataargv); | - |
49 | } else { executed: } Execution Count:1124 | 1124 |
50 | targetValue->setProperty(propertyName.constData(), newValue); | - |
51 | } executed: } Execution Count:1087 | 1087 |
52 | } | - |
53 | | - |
54 | | - |
55 | | - |
56 | | - |
57 | | - |
58 | QPropertyAnimation::QPropertyAnimation(QObject *parent) | - |
59 | : QVariantAnimation(*new QPropertyAnimationPrivate, parent) | - |
60 | { | - |
61 | } | - |
62 | QPropertyAnimation::QPropertyAnimation(QObject *target, const QByteArray &propertyName, QObject *parent) | - |
63 | : QVariantAnimation(*new QPropertyAnimationPrivate, parent) | - |
64 | { | - |
65 | setTargetObject(target); | - |
66 | setPropertyName(propertyName); | - |
67 | } | - |
68 | | - |
69 | | - |
70 | | - |
71 | | - |
72 | QPropertyAnimation::~QPropertyAnimation() | - |
73 | { | - |
74 | stop(); | - |
75 | } | - |
76 | | - |
77 | | - |
78 | | - |
79 | | - |
80 | | - |
81 | | - |
82 | | - |
83 | QObject *QPropertyAnimation::targetObject() const | - |
84 | { | - |
85 | return d_func()->target.data(); | - |
86 | } | - |
87 | | - |
88 | void QPropertyAnimation::setTargetObject(QObject *target) | - |
89 | { | - |
90 | QPropertyAnimationPrivate * const d = d_func(); | - |
91 | if (d->target.data() == target) | - |
92 | return; | - |
93 | | - |
94 | if (d->state != QAbstractAnimation::Stopped) { | - |
95 | QMessageLogger("animation/qpropertyanimation.cpp", 195198, __PRETTY_FUNCTION__).warning("QPropertyAnimation::setTargetObject: you can't change the target of a running animation"); | - |
96 | return; | - |
97 | } | - |
98 | | - |
99 | d->target = d->targetValue = target; | - |
100 | d->updateMetaProperty(); | - |
101 | } | - |
102 | QByteArray QPropertyAnimation::propertyName() const | - |
103 | { | - |
104 | const QPropertyAnimationPrivate * const d = d_func(); | - |
105 | return d->propertyName; | - |
106 | } | - |
107 | | - |
108 | void QPropertyAnimation::setPropertyName(const QByteArray &propertyName) | - |
109 | { | - |
110 | QPropertyAnimationPrivate * const d = d_func(); | - |
111 | if (d->state != QAbstractAnimation::Stopped) { | - |
112 | QMessageLogger("animation/qpropertyanimation.cpp", 220223, __PRETTY_FUNCTION__).warning("QPropertyAnimation::setPropertyName: you can't change the property name of a running animation"); | - |
113 | return; | - |
114 | } | - |
115 | | - |
116 | d->propertyName = propertyName; | - |
117 | d->updateMetaProperty(); | - |
118 | } | - |
119 | | - |
120 | | - |
121 | | - |
122 | | - |
123 | | - |
124 | bool QPropertyAnimation::event(QEvent *event) | - |
125 | { | - |
126 | return QVariantAnimation::event(event); | - |
127 | } | - |
128 | void QPropertyAnimation::updateCurrentValue(const QVariant &value) | - |
129 | { | - |
130 | QPropertyAnimationPrivate * const d = d_func(); | - |
131 | d->updateProperty(value); | - |
132 | } | - |
133 | | - |
134 | | - |
135 | | - |
136 | | - |
137 | | - |
138 | | - |
139 | | - |
140 | void QPropertyAnimation::updateState(QAbstractAnimation::State newState, | - |
141 | QAbstractAnimation::State oldState) | - |
142 | { | - |
143 | QPropertyAnimationPrivate * const d = d_func(); | - |
144 | | - |
145 | if (!d->target && oldState == Stopped) { | - |
146 | QMessageLogger("animation/qpropertyanimation.cpp", 262265, __PRETTY_FUNCTION__).warning("QPropertyAnimation::updateState (%s): Changing state of an animation without target", | - |
147 | d->propertyName.constData()); | - |
148 | return; | - |
149 | } | - |
150 | | - |
151 | QVariantAnimation::updateState(newState, oldState); | - |
152 | | - |
153 | QPropertyAnimation *animToStop = 0; | - |
154 | { | - |
155 | | - |
156 | static QBasicMutex mutex; | - |
157 | QMutexLocker locker(&mutex); | - |
158 | | - |
159 | typedef QPair<QObject *, QByteArray> QPropertyAnimationPair; | - |
160 | typedef QHash<QPropertyAnimationPair, QPropertyAnimation*> QPropertyAnimationHash; | - |
161 | static QPropertyAnimationHash hash; | - |
162 | | - |
163 | | - |
164 | QPropertyAnimationPair key(d->targetValue, d->propertyName); | - |
165 | if (newState == Running) { | - |
166 | d->updateMetaProperty(); | - |
167 | animToStop = hash.value(key, 0); | - |
168 | hash.insert(key, this); | - |
169 | locker.unlock(); | - |
170 | | - |
171 | if (oldState == Stopped) { | - |
172 | d->setDefaultStartEndValue(d->targetValue->property(d->propertyName.constData())); | - |
173 | | - |
174 | if (!startValue().isValid() && (d->direction == Backward || !d->defaultStartEndValue.isValid())) { | - |
175 | QMessageLogger("animation/qpropertyanimation.cpp", 291294, __PRETTY_FUNCTION__).warning("QPropertyAnimation::updateState (%s, %s, %s): starting an animation without start value", | - |
176 | d->propertyName.constData(), d->target.data()->metaObject()->className(), | - |
177 | QString(d->target.data()->objectName()).toLocal8Bit().constData()); | - |
178 | } | - |
179 | if (!endValue().isValid() && (d->direction == Forward || !d->defaultStartEndValue.isValid())) { | - |
180 | QMessageLogger("animation/qpropertyanimation.cpp", 296299, __PRETTY_FUNCTION__).warning("QPropertyAnimation::updateState (%s, %s, %s): starting an animation without end value", | - |
181 | d->propertyName.constData(), d->target.data()->metaObject()->className(), | - |
182 | QString(d->target.data()->objectName()).toLocal8Bit().constData()); | - |
183 | } | - |
184 | } | - |
185 | } else if (hash.value(key) == this) { | - |
186 | hash.remove(key); | - |
187 | } | - |
188 | } | - |
189 | | - |
190 | | - |
191 | if (animToStop) { | - |
192 | | - |
193 | QAbstractAnimation *current = animToStop; | - |
194 | while (current->group() && current->state() != Stopped) | - |
195 | current = current->group(); | - |
196 | current->stop(); | - |
197 | } | - |
198 | } | - |
199 | | - |
200 | | - |
201 | | - |
202 | | - |
| | |