| Absolute File Name: | /home/qt/qt5_coco/qt5/qtbase/src/corelib/tools/qtimeline.cpp |
| Switch to Source code | Preprocessed file |
| Line | Source | Count | ||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
| 1 | - | |||||||||||||||||||
| 2 | - | |||||||||||||||||||
| 3 | - | |||||||||||||||||||
| 4 | - | |||||||||||||||||||
| 5 | class QTimeLinePrivate : public QObjectPrivate | - | ||||||||||||||||||
| 6 | { | - | ||||||||||||||||||
| 7 | inline QTimeLine* q_func() { return static_cast<QTimeLine *>(q_ptr); } inline const QTimeLine* q_func() const { return static_cast<const QTimeLine *>(q_ptr); } friend class QTimeLine; | - | ||||||||||||||||||
| 8 | public: | - | ||||||||||||||||||
| 9 | inline QTimeLinePrivate() | - | ||||||||||||||||||
| 10 | : easingCurve(QEasingCurve::InOutSine), | - | ||||||||||||||||||
| 11 | startTime(0), duration(1000), startFrame(0), endFrame(0), | - | ||||||||||||||||||
| 12 | updateInterval(1000 / 25), | - | ||||||||||||||||||
| 13 | totalLoopCount(1), currentLoopCount(0), currentTime(0), timerId(0), | - | ||||||||||||||||||
| 14 | direction(QTimeLine::Forward), | - | ||||||||||||||||||
| 15 | state(QTimeLine::NotRunning) | - | ||||||||||||||||||
| 16 | { } executed 28 times by 3 tests: end of blockExecuted by:
| 28 | ||||||||||||||||||
| 17 | - | |||||||||||||||||||
| 18 | QElapsedTimer timer; | - | ||||||||||||||||||
| 19 | QEasingCurve easingCurve; | - | ||||||||||||||||||
| 20 | - | |||||||||||||||||||
| 21 | int startTime; | - | ||||||||||||||||||
| 22 | int duration; | - | ||||||||||||||||||
| 23 | int startFrame; | - | ||||||||||||||||||
| 24 | int endFrame; | - | ||||||||||||||||||
| 25 | int updateInterval; | - | ||||||||||||||||||
| 26 | int totalLoopCount; | - | ||||||||||||||||||
| 27 | int currentLoopCount; | - | ||||||||||||||||||
| 28 | - | |||||||||||||||||||
| 29 | int currentTime; | - | ||||||||||||||||||
| 30 | int timerId; | - | ||||||||||||||||||
| 31 | - | |||||||||||||||||||
| 32 | QTimeLine::Direction direction; | - | ||||||||||||||||||
| 33 | QTimeLine::State state; | - | ||||||||||||||||||
| 34 | inline void setState(QTimeLine::State newState) | - | ||||||||||||||||||
| 35 | { | - | ||||||||||||||||||
| 36 | QTimeLine * const q = q_func(); | - | ||||||||||||||||||
| 37 | if (newState != state
| 0-84 | ||||||||||||||||||
| 38 | q->stateChanged(state = newState, QTimeLine::QPrivateSignal()); executed 84 times by 2 tests: q->stateChanged(state = newState, QTimeLine::QPrivateSignal());Executed by:
| 84 | ||||||||||||||||||
| 39 | } executed 84 times by 2 tests: end of blockExecuted by:
| 84 | ||||||||||||||||||
| 40 | - | |||||||||||||||||||
| 41 | void setCurrentTime(int msecs); | - | ||||||||||||||||||
| 42 | }; | - | ||||||||||||||||||
| 43 | - | |||||||||||||||||||
| 44 | - | |||||||||||||||||||
| 45 | - | |||||||||||||||||||
| 46 | - | |||||||||||||||||||
| 47 | void QTimeLinePrivate::setCurrentTime(int msecs) | - | ||||||||||||||||||
| 48 | { | - | ||||||||||||||||||
| 49 | QTimeLine * const q = q_func(); | - | ||||||||||||||||||
| 50 | - | |||||||||||||||||||
| 51 | qreal lastValue = q->currentValue(); | - | ||||||||||||||||||
| 52 | int lastFrame = q->currentFrame(); | - | ||||||||||||||||||
| 53 | - | |||||||||||||||||||
| 54 | - | |||||||||||||||||||
| 55 | int elapsed = (
| 281-1168 | ||||||||||||||||||
| 56 | int loopCount = elapsed / duration; | - | ||||||||||||||||||
| 57 | - | |||||||||||||||||||
| 58 | bool looping = (loopCount != currentLoopCount); | - | ||||||||||||||||||
| 59 | - | |||||||||||||||||||
| 60 | - | |||||||||||||||||||
| 61 | - | |||||||||||||||||||
| 62 | - | |||||||||||||||||||
| 63 | - | |||||||||||||||||||
| 64 | if (looping
| 35-1414 | ||||||||||||||||||
| 65 | currentLoopCount = loopCount; executed 35 times by 2 tests: currentLoopCount = loopCount;Executed by:
| 35 | ||||||||||||||||||
| 66 | - | |||||||||||||||||||
| 67 | - | |||||||||||||||||||
| 68 | currentTime = elapsed % duration; | - | ||||||||||||||||||
| 69 | if (direction == QTimeLine::Backward
| 281-1168 | ||||||||||||||||||
| 70 | currentTime = duration - currentTime; executed 281 times by 1 test: currentTime = duration - currentTime;Executed by:
| 281 | ||||||||||||||||||
| 71 | - | |||||||||||||||||||
| 72 | - | |||||||||||||||||||
| 73 | bool finished = false; | - | ||||||||||||||||||
| 74 | if (totalLoopCount
| 20-1414 | ||||||||||||||||||
| 75 | finished = true; | - | ||||||||||||||||||
| 76 | currentTime = (
| 1-19 | ||||||||||||||||||
| 77 | currentLoopCount = totalLoopCount - 1; | - | ||||||||||||||||||
| 78 | } executed 20 times by 2 tests: end of blockExecuted by:
| 20 | ||||||||||||||||||
| 79 | - | |||||||||||||||||||
| 80 | int currentFrame = q->frameForTime(currentTime); | - | ||||||||||||||||||
| 81 | - | |||||||||||||||||||
| 82 | - | |||||||||||||||||||
| 83 | - | |||||||||||||||||||
| 84 | if (!qFuzzyCompare(lastValue, q->currentValue())
| 30-1419 | ||||||||||||||||||
| 85 | q->valueChanged(q->currentValue(), QTimeLine::QPrivateSignal()); executed 1419 times by 2 tests: q->valueChanged(q->currentValue(), QTimeLine::QPrivateSignal());Executed by:
| 1419 | ||||||||||||||||||
| 86 | if (lastFrame != currentFrame
| 314-1135 | ||||||||||||||||||
| 87 | const int transitionframe = (direction == QTimeLine::Forward
| 24-290 | ||||||||||||||||||
| 88 | if (looping
| 0-283 | ||||||||||||||||||
| 89 | - | |||||||||||||||||||
| 90 | - | |||||||||||||||||||
| 91 | - | |||||||||||||||||||
| 92 | q->frameChanged(transitionframe, QTimeLine::QPrivateSignal()); | - | ||||||||||||||||||
| 93 | } executed 15 times by 1 test: end of blockExecuted by:
| 15 | ||||||||||||||||||
| 94 | q->frameChanged(currentFrame, QTimeLine::QPrivateSignal()); | - | ||||||||||||||||||
| 95 | } executed 314 times by 1 test: end of blockExecuted by:
| 314 | ||||||||||||||||||
| 96 | if (finished
| 0-1429 | ||||||||||||||||||
| 97 | q->stop(); | - | ||||||||||||||||||
| 98 | q->finished(QTimeLine::QPrivateSignal()); | - | ||||||||||||||||||
| 99 | } executed 20 times by 2 tests: end of blockExecuted by:
| 20 | ||||||||||||||||||
| 100 | } executed 1449 times by 2 tests: end of blockExecuted by:
| 1449 | ||||||||||||||||||
| 101 | QTimeLine::QTimeLine(int duration, QObject *parent) | - | ||||||||||||||||||
| 102 | : QObject(*new QTimeLinePrivate, parent) | - | ||||||||||||||||||
| 103 | { | - | ||||||||||||||||||
| 104 | setDuration(duration); | - | ||||||||||||||||||
| 105 | } executed 28 times by 3 tests: end of blockExecuted by:
| 28 | ||||||||||||||||||
| 106 | - | |||||||||||||||||||
| 107 | - | |||||||||||||||||||
| 108 | - | |||||||||||||||||||
| 109 | - | |||||||||||||||||||
| 110 | QTimeLine::~QTimeLine() | - | ||||||||||||||||||
| 111 | { | - | ||||||||||||||||||
| 112 | QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 113 | - | |||||||||||||||||||
| 114 | if (d->state == Running
| 6-22 | ||||||||||||||||||
| 115 | stop(); executed 6 times by 1 test: stop();Executed by:
| 6 | ||||||||||||||||||
| 116 | } executed 28 times by 3 tests: end of blockExecuted by:
| 28 | ||||||||||||||||||
| 117 | - | |||||||||||||||||||
| 118 | - | |||||||||||||||||||
| 119 | - | |||||||||||||||||||
| 120 | - | |||||||||||||||||||
| 121 | - | |||||||||||||||||||
| 122 | - | |||||||||||||||||||
| 123 | QTimeLine::State QTimeLine::state() const | - | ||||||||||||||||||
| 124 | { | - | ||||||||||||||||||
| 125 | const QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 126 | return executed 255 times by 1 test: d->state;return d->state;Executed by:
executed 255 times by 1 test: return d->state;Executed by:
| 255 | ||||||||||||||||||
| 127 | } | - | ||||||||||||||||||
| 128 | int QTimeLine::loopCount() const | - | ||||||||||||||||||
| 129 | { | - | ||||||||||||||||||
| 130 | const QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 131 | return executed 4 times by 1 test: d->totalLoopCount;return d->totalLoopCount;Executed by:
executed 4 times by 1 test: return d->totalLoopCount;Executed by:
| 4 | ||||||||||||||||||
| 132 | } | - | ||||||||||||||||||
| 133 | void QTimeLine::setLoopCount(int count) | - | ||||||||||||||||||
| 134 | { | - | ||||||||||||||||||
| 135 | QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 136 | d->totalLoopCount = count; | - | ||||||||||||||||||
| 137 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 138 | QTimeLine::Direction QTimeLine::direction() const | - | ||||||||||||||||||
| 139 | { | - | ||||||||||||||||||
| 140 | const QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 141 | return executed 6 times by 1 test: d->direction;return d->direction;Executed by:
executed 6 times by 1 test: return d->direction;Executed by:
| 6 | ||||||||||||||||||
| 142 | } | - | ||||||||||||||||||
| 143 | void QTimeLine::setDirection(Direction direction) | - | ||||||||||||||||||
| 144 | { | - | ||||||||||||||||||
| 145 | QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 146 | d->direction = direction; | - | ||||||||||||||||||
| 147 | d->startTime = d->currentTime; | - | ||||||||||||||||||
| 148 | d->timer.start(); | - | ||||||||||||||||||
| 149 | } executed 38 times by 1 test: end of blockExecuted by:
| 38 | ||||||||||||||||||
| 150 | int QTimeLine::duration() const | - | ||||||||||||||||||
| 151 | { | - | ||||||||||||||||||
| 152 | const QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 153 | return executed 83 times by 1 test: d->duration;return d->duration;Executed by:
executed 83 times by 1 test: return d->duration;Executed by:
| 83 | ||||||||||||||||||
| 154 | } | - | ||||||||||||||||||
| 155 | void QTimeLine::setDuration(int duration) | - | ||||||||||||||||||
| 156 | { | - | ||||||||||||||||||
| 157 | QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 158 | if (duration <= 0
| 0-32 | ||||||||||||||||||
| 159 | QMessageLogger(__FILE__, 395, __PRETTY_FUNCTION__).warning("QTimeLine::setDuration: cannot set duration <= 0"); | - | ||||||||||||||||||
| 160 | return; never executed: return; | 0 | ||||||||||||||||||
| 161 | } | - | ||||||||||||||||||
| 162 | d->duration = duration; | - | ||||||||||||||||||
| 163 | } executed 32 times by 3 tests: end of blockExecuted by:
| 32 | ||||||||||||||||||
| 164 | - | |||||||||||||||||||
| 165 | - | |||||||||||||||||||
| 166 | - | |||||||||||||||||||
| 167 | - | |||||||||||||||||||
| 168 | - | |||||||||||||||||||
| 169 | - | |||||||||||||||||||
| 170 | - | |||||||||||||||||||
| 171 | int QTimeLine::startFrame() const | - | ||||||||||||||||||
| 172 | { | - | ||||||||||||||||||
| 173 | const QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 174 | return executed 7 times by 1 test: d->startFrame;return d->startFrame;Executed by:
executed 7 times by 1 test: return d->startFrame;Executed by:
| 7 | ||||||||||||||||||
| 175 | } | - | ||||||||||||||||||
| 176 | - | |||||||||||||||||||
| 177 | - | |||||||||||||||||||
| 178 | - | |||||||||||||||||||
| 179 | - | |||||||||||||||||||
| 180 | - | |||||||||||||||||||
| 181 | - | |||||||||||||||||||
| 182 | - | |||||||||||||||||||
| 183 | void QTimeLine::setStartFrame(int frame) | - | ||||||||||||||||||
| 184 | { | - | ||||||||||||||||||
| 185 | QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 186 | d->startFrame = frame; | - | ||||||||||||||||||
| 187 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 188 | - | |||||||||||||||||||
| 189 | - | |||||||||||||||||||
| 190 | - | |||||||||||||||||||
| 191 | - | |||||||||||||||||||
| 192 | - | |||||||||||||||||||
| 193 | - | |||||||||||||||||||
| 194 | - | |||||||||||||||||||
| 195 | int QTimeLine::endFrame() const | - | ||||||||||||||||||
| 196 | { | - | ||||||||||||||||||
| 197 | const QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 198 | return executed 24 times by 1 test: d->endFrame;return d->endFrame;Executed by:
executed 24 times by 1 test: return d->endFrame;Executed by:
| 24 | ||||||||||||||||||
| 199 | } | - | ||||||||||||||||||
| 200 | - | |||||||||||||||||||
| 201 | - | |||||||||||||||||||
| 202 | - | |||||||||||||||||||
| 203 | - | |||||||||||||||||||
| 204 | - | |||||||||||||||||||
| 205 | - | |||||||||||||||||||
| 206 | - | |||||||||||||||||||
| 207 | void QTimeLine::setEndFrame(int frame) | - | ||||||||||||||||||
| 208 | { | - | ||||||||||||||||||
| 209 | QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 210 | d->endFrame = frame; | - | ||||||||||||||||||
| 211 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 212 | void QTimeLine::setFrameRange(int startFrame, int endFrame) | - | ||||||||||||||||||
| 213 | { | - | ||||||||||||||||||
| 214 | QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 215 | d->startFrame = startFrame; | - | ||||||||||||||||||
| 216 | d->endFrame = endFrame; | - | ||||||||||||||||||
| 217 | } executed 22 times by 1 test: end of blockExecuted by:
| 22 | ||||||||||||||||||
| 218 | int QTimeLine::updateInterval() const | - | ||||||||||||||||||
| 219 | { | - | ||||||||||||||||||
| 220 | const QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 221 | return executed 2 times by 1 test: d->updateInterval;return d->updateInterval;Executed by:
executed 2 times by 1 test: return d->updateInterval;Executed by:
| 2 | ||||||||||||||||||
| 222 | } | - | ||||||||||||||||||
| 223 | void QTimeLine::setUpdateInterval(int interval) | - | ||||||||||||||||||
| 224 | { | - | ||||||||||||||||||
| 225 | QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 226 | d->updateInterval = interval; | - | ||||||||||||||||||
| 227 | } executed 5 times by 1 test: end of blockExecuted by:
| 5 | ||||||||||||||||||
| 228 | QTimeLine::CurveShape QTimeLine::curveShape() const | - | ||||||||||||||||||
| 229 | { | - | ||||||||||||||||||
| 230 | const QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 231 | switch (d->easingCurve.type()) { | - | ||||||||||||||||||
| 232 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 233 | case executed 1 time by 1 test: QEasingCurve::InOutSine:case QEasingCurve::InOutSine:Executed by:
executed 1 time by 1 test: case QEasingCurve::InOutSine:Executed by:
| 1 | ||||||||||||||||||
| 234 | return executed 1 time by 1 test: EaseInOutCurve;return EaseInOutCurve;Executed by:
executed 1 time by 1 test: return EaseInOutCurve;Executed by:
| 1 | ||||||||||||||||||
| 235 | case never executed: QEasingCurve::InCurve:case QEasingCurve::InCurve:never executed: case QEasingCurve::InCurve: | 0 | ||||||||||||||||||
| 236 | return never executed: EaseInCurve;return EaseInCurve;never executed: return EaseInCurve; | 0 | ||||||||||||||||||
| 237 | case never executed: QEasingCurve::OutCurve:case QEasingCurve::OutCurve:never executed: case QEasingCurve::OutCurve: | 0 | ||||||||||||||||||
| 238 | return never executed: EaseOutCurve;return EaseOutCurve;never executed: return EaseOutCurve; | 0 | ||||||||||||||||||
| 239 | case executed 1 time by 1 test: QEasingCurve::Linear:case QEasingCurve::Linear:Executed by:
executed 1 time by 1 test: case QEasingCurve::Linear:Executed by:
| 1 | ||||||||||||||||||
| 240 | return executed 1 time by 1 test: LinearCurve;return LinearCurve;Executed by:
executed 1 time by 1 test: return LinearCurve;Executed by:
| 1 | ||||||||||||||||||
| 241 | case never executed: QEasingCurve::SineCurve:case QEasingCurve::SineCurve:never executed: case QEasingCurve::SineCurve: | 0 | ||||||||||||||||||
| 242 | return never executed: SineCurve;return SineCurve;never executed: return SineCurve; | 0 | ||||||||||||||||||
| 243 | case never executed: QEasingCurve::CosineCurve:case QEasingCurve::CosineCurve:never executed: case QEasingCurve::CosineCurve: | 0 | ||||||||||||||||||
| 244 | return never executed: CosineCurve;return CosineCurve;never executed: return CosineCurve; | 0 | ||||||||||||||||||
| 245 | } | - | ||||||||||||||||||
| 246 | return dead code: EaseInOutCurve;return EaseInOutCurve;dead code: return EaseInOutCurve; | - | ||||||||||||||||||
| 247 | } | - | ||||||||||||||||||
| 248 | - | |||||||||||||||||||
| 249 | void QTimeLine::setCurveShape(CurveShape shape) | - | ||||||||||||||||||
| 250 | { | - | ||||||||||||||||||
| 251 | switch (shape) { | - | ||||||||||||||||||
| 252 | default never executed: :default:never executed: default: | 0 | ||||||||||||||||||
| 253 | case executed 1 time by 1 test: EaseInOutCurve:case EaseInOutCurve:Executed by:
executed 1 time by 1 test: case EaseInOutCurve:Executed by:
| 1 | ||||||||||||||||||
| 254 | setEasingCurve(QEasingCurve(QEasingCurve::InOutSine)); | - | ||||||||||||||||||
| 255 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||
| 256 | case never executed: EaseInCurve:case EaseInCurve:never executed: case EaseInCurve: | 0 | ||||||||||||||||||
| 257 | setEasingCurve(QEasingCurve(QEasingCurve::InCurve)); | - | ||||||||||||||||||
| 258 | break; never executed: break; | 0 | ||||||||||||||||||
| 259 | case never executed: EaseOutCurve:case EaseOutCurve:never executed: case EaseOutCurve: | 0 | ||||||||||||||||||
| 260 | setEasingCurve(QEasingCurve(QEasingCurve::OutCurve)); | - | ||||||||||||||||||
| 261 | break; never executed: break; | 0 | ||||||||||||||||||
| 262 | case executed 6 times by 1 test: LinearCurve:case LinearCurve:Executed by:
executed 6 times by 1 test: case LinearCurve:Executed by:
| 6 | ||||||||||||||||||
| 263 | setEasingCurve(QEasingCurve(QEasingCurve::Linear)); | - | ||||||||||||||||||
| 264 | break; executed 6 times by 1 test: break;Executed by:
| 6 | ||||||||||||||||||
| 265 | case executed 2 times by 1 test: SineCurve:case SineCurve:Executed by:
executed 2 times by 1 test: case SineCurve:Executed by:
| 2 | ||||||||||||||||||
| 266 | setEasingCurve(QEasingCurve(QEasingCurve::SineCurve)); | - | ||||||||||||||||||
| 267 | break; executed 2 times by 1 test: break;Executed by:
| 2 | ||||||||||||||||||
| 268 | case executed 1 time by 1 test: CosineCurve:case CosineCurve:Executed by:
executed 1 time by 1 test: case CosineCurve:Executed by:
| 1 | ||||||||||||||||||
| 269 | setEasingCurve(QEasingCurve(QEasingCurve::CosineCurve)); | - | ||||||||||||||||||
| 270 | break; executed 1 time by 1 test: break;Executed by:
| 1 | ||||||||||||||||||
| 271 | } | - | ||||||||||||||||||
| 272 | } | - | ||||||||||||||||||
| 273 | QEasingCurve QTimeLine::easingCurve() const | - | ||||||||||||||||||
| 274 | { | - | ||||||||||||||||||
| 275 | const QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 276 | return never executed: d->easingCurve;return d->easingCurve;never executed: return d->easingCurve; | 0 | ||||||||||||||||||
| 277 | } | - | ||||||||||||||||||
| 278 | - | |||||||||||||||||||
| 279 | void QTimeLine::setEasingCurve(const QEasingCurve& curve) | - | ||||||||||||||||||
| 280 | { | - | ||||||||||||||||||
| 281 | QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 282 | d->easingCurve = curve; | - | ||||||||||||||||||
| 283 | } executed 10 times by 1 test: end of blockExecuted by:
| 10 | ||||||||||||||||||
| 284 | int QTimeLine::currentTime() const | - | ||||||||||||||||||
| 285 | { | - | ||||||||||||||||||
| 286 | const QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 287 | return executed 112 times by 1 test: d->currentTime;return d->currentTime;Executed by:
executed 112 times by 1 test: return d->currentTime;Executed by:
| 112 | ||||||||||||||||||
| 288 | } | - | ||||||||||||||||||
| 289 | void QTimeLine::setCurrentTime(int msec) | - | ||||||||||||||||||
| 290 | { | - | ||||||||||||||||||
| 291 | QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 292 | d->startTime = 0; | - | ||||||||||||||||||
| 293 | d->currentLoopCount = 0; | - | ||||||||||||||||||
| 294 | d->timer.restart(); | - | ||||||||||||||||||
| 295 | d->setCurrentTime(msec); | - | ||||||||||||||||||
| 296 | } executed 12 times by 1 test: end of blockExecuted by:
| 12 | ||||||||||||||||||
| 297 | - | |||||||||||||||||||
| 298 | - | |||||||||||||||||||
| 299 | - | |||||||||||||||||||
| 300 | - | |||||||||||||||||||
| 301 | - | |||||||||||||||||||
| 302 | - | |||||||||||||||||||
| 303 | int QTimeLine::currentFrame() const | - | ||||||||||||||||||
| 304 | { | - | ||||||||||||||||||
| 305 | const QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 306 | return executed 1515 times by 2 tests: frameForTime(d->currentTime);return frameForTime(d->currentTime);Executed by:
executed 1515 times by 2 tests: return frameForTime(d->currentTime);Executed by:
| 1515 | ||||||||||||||||||
| 307 | } | - | ||||||||||||||||||
| 308 | - | |||||||||||||||||||
| 309 | - | |||||||||||||||||||
| 310 | - | |||||||||||||||||||
| 311 | - | |||||||||||||||||||
| 312 | - | |||||||||||||||||||
| 313 | - | |||||||||||||||||||
| 314 | qreal QTimeLine::currentValue() const | - | ||||||||||||||||||
| 315 | { | - | ||||||||||||||||||
| 316 | const QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 317 | return executed 4338 times by 2 tests: valueForTime(d->currentTime);return valueForTime(d->currentTime);Executed by:
executed 4338 times by 2 tests: return valueForTime(d->currentTime);Executed by:
| 4338 | ||||||||||||||||||
| 318 | } | - | ||||||||||||||||||
| 319 | int QTimeLine::frameForTime(int msec) const | - | ||||||||||||||||||
| 320 | { | - | ||||||||||||||||||
| 321 | const QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 322 | if (d->direction == Forward
| 578-2386 | ||||||||||||||||||
| 323 | return executed 2386 times by 2 tests: d->startFrame + int((d->endFrame - d->startFrame) * valueForTime(msec));return d->startFrame + int((d->endFrame - d->startFrame) * valueForTime(msec));Executed by:
executed 2386 times by 2 tests: return d->startFrame + int((d->endFrame - d->startFrame) * valueForTime(msec));Executed by:
| 2386 | ||||||||||||||||||
| 324 | return executed 578 times by 1 test: d->startFrame + qCeil((d->endFrame - d->startFrame) * valueForTime(msec));return d->startFrame + qCeil((d->endFrame - d->startFrame) * valueForTime(msec));Executed by:
executed 578 times by 1 test: return d->startFrame + qCeil((d->endFrame - d->startFrame) * valueForTime(msec));Executed by:
| 578 | ||||||||||||||||||
| 325 | } | - | ||||||||||||||||||
| 326 | qreal QTimeLine::valueForTime(int msec) const | - | ||||||||||||||||||
| 327 | { | - | ||||||||||||||||||
| 328 | const QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 329 | msec = qMin(qMax(msec, 0), d->duration); | - | ||||||||||||||||||
| 330 | - | |||||||||||||||||||
| 331 | qreal value = msec / qreal(d->duration); | - | ||||||||||||||||||
| 332 | return executed 7315 times by 2 tests: d->easingCurve.valueForProgress(value);return d->easingCurve.valueForProgress(value);Executed by:
executed 7315 times by 2 tests: return d->easingCurve.valueForProgress(value);Executed by:
| 7315 | ||||||||||||||||||
| 333 | } | - | ||||||||||||||||||
| 334 | void QTimeLine::start() | - | ||||||||||||||||||
| 335 | { | - | ||||||||||||||||||
| 336 | QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 337 | if (d->timerId
| 0-38 | ||||||||||||||||||
| 338 | QMessageLogger(__FILE__, 669, __PRETTY_FUNCTION__).warning("QTimeLine::start: already running"); | - | ||||||||||||||||||
| 339 | return; never executed: return; | 0 | ||||||||||||||||||
| 340 | } | - | ||||||||||||||||||
| 341 | int curTime = 0; | - | ||||||||||||||||||
| 342 | if (d->direction == Backward
| 5-33 | ||||||||||||||||||
| 343 | curTime = d->duration; executed 5 times by 1 test: curTime = d->duration;Executed by:
| 5 | ||||||||||||||||||
| 344 | d->timerId = startTimer(d->updateInterval); | - | ||||||||||||||||||
| 345 | d->startTime = curTime; | - | ||||||||||||||||||
| 346 | d->currentLoopCount = 0; | - | ||||||||||||||||||
| 347 | d->timer.start(); | - | ||||||||||||||||||
| 348 | d->setState(Running); | - | ||||||||||||||||||
| 349 | d->setCurrentTime(curTime); | - | ||||||||||||||||||
| 350 | } executed 38 times by 2 tests: end of blockExecuted by:
| 38 | ||||||||||||||||||
| 351 | void QTimeLine::resume() | - | ||||||||||||||||||
| 352 | { | - | ||||||||||||||||||
| 353 | QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 354 | if (d->timerId
| 0-3 | ||||||||||||||||||
| 355 | QMessageLogger(__FILE__, 697, __PRETTY_FUNCTION__).warning("QTimeLine::resume: already running"); | - | ||||||||||||||||||
| 356 | return; never executed: return; | 0 | ||||||||||||||||||
| 357 | } | - | ||||||||||||||||||
| 358 | d->timerId = startTimer(d->updateInterval); | - | ||||||||||||||||||
| 359 | d->startTime = d->currentTime; | - | ||||||||||||||||||
| 360 | d->timer.start(); | - | ||||||||||||||||||
| 361 | d->setState(Running); | - | ||||||||||||||||||
| 362 | } executed 3 times by 1 test: end of blockExecuted by:
| 3 | ||||||||||||||||||
| 363 | - | |||||||||||||||||||
| 364 | - | |||||||||||||||||||
| 365 | - | |||||||||||||||||||
| 366 | - | |||||||||||||||||||
| 367 | - | |||||||||||||||||||
| 368 | - | |||||||||||||||||||
| 369 | void QTimeLine::stop() | - | ||||||||||||||||||
| 370 | { | - | ||||||||||||||||||
| 371 | QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 372 | if (d->timerId
| 0-41 | ||||||||||||||||||
| 373 | killTimer(d->timerId); executed 41 times by 2 tests: killTimer(d->timerId);Executed by:
| 41 | ||||||||||||||||||
| 374 | d->setState(NotRunning); | - | ||||||||||||||||||
| 375 | d->timerId = 0; | - | ||||||||||||||||||
| 376 | } executed 41 times by 2 tests: end of blockExecuted by:
| 41 | ||||||||||||||||||
| 377 | void QTimeLine::setPaused(bool paused) | - | ||||||||||||||||||
| 378 | { | - | ||||||||||||||||||
| 379 | QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 380 | if (d->state == NotRunning
| 0-2 | ||||||||||||||||||
| 381 | QMessageLogger(__FILE__, 732, __PRETTY_FUNCTION__).warning("QTimeLine::setPaused: Not running"); | - | ||||||||||||||||||
| 382 | return; never executed: return; | 0 | ||||||||||||||||||
| 383 | } | - | ||||||||||||||||||
| 384 | if (paused
| 0-1 | ||||||||||||||||||
| 385 | d->startTime = d->currentTime; | - | ||||||||||||||||||
| 386 | killTimer(d->timerId); | - | ||||||||||||||||||
| 387 | d->timerId = 0; | - | ||||||||||||||||||
| 388 | d->setState(Paused); | - | ||||||||||||||||||
| 389 | } executed 1 time by 1 test: else if (!pausedend of blockExecuted by:
| 0-1 | ||||||||||||||||||
| 390 | - | |||||||||||||||||||
| 391 | d->timerId = startTimer(d->updateInterval); | - | ||||||||||||||||||
| 392 | d->startTime = d->currentTime; | - | ||||||||||||||||||
| 393 | d->timer.start(); | - | ||||||||||||||||||
| 394 | d->setState(Running); | - | ||||||||||||||||||
| 395 | } executed 1 time by 1 test: end of blockExecuted by:
| 1 | ||||||||||||||||||
| 396 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 397 | - | |||||||||||||||||||
| 398 | - | |||||||||||||||||||
| 399 | - | |||||||||||||||||||
| 400 | - | |||||||||||||||||||
| 401 | - | |||||||||||||||||||
| 402 | - | |||||||||||||||||||
| 403 | - | |||||||||||||||||||
| 404 | void QTimeLine::toggleDirection() | - | ||||||||||||||||||
| 405 | { | - | ||||||||||||||||||
| 406 | QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 407 | setDirection(d->direction == Forward ? Backward : Forward); | - | ||||||||||||||||||
| 408 | } executed 2 times by 1 test: end of blockExecuted by:
| 2 | ||||||||||||||||||
| 409 | - | |||||||||||||||||||
| 410 | - | |||||||||||||||||||
| 411 | - | |||||||||||||||||||
| 412 | - | |||||||||||||||||||
| 413 | void QTimeLine::timerEvent(QTimerEvent *event) | - | ||||||||||||||||||
| 414 | { | - | ||||||||||||||||||
| 415 | QTimeLinePrivate * const d = d_func(); | - | ||||||||||||||||||
| 416 | if (event->timerId() != d->timerId
| 0-1399 | ||||||||||||||||||
| 417 | event->ignore(); | - | ||||||||||||||||||
| 418 | return; never executed: return; | 0 | ||||||||||||||||||
| 419 | } | - | ||||||||||||||||||
| 420 | event->accept(); | - | ||||||||||||||||||
| 421 | - | |||||||||||||||||||
| 422 | if (d->direction == Forward
| 272-1127 | ||||||||||||||||||
| 423 | d->setCurrentTime(d->startTime + d->timer.elapsed()); | - | ||||||||||||||||||
| 424 | } executed 1127 times by 2 tests: else {end of blockExecuted by:
| 1127 | ||||||||||||||||||
| 425 | d->setCurrentTime(d->startTime - d->timer.elapsed()); | - | ||||||||||||||||||
| 426 | } executed 272 times by 1 test: end of blockExecuted by:
| 272 | ||||||||||||||||||
| 427 | } | - | ||||||||||||||||||
| 428 | - | |||||||||||||||||||
| 429 | - | |||||||||||||||||||
| Switch to Source code | Preprocessed file |