| Line | Source Code | Coverage |
|---|
| 1 | | - |
| 2 | | - |
| 3 | | - |
| 4 | QStyleAnimation::QStyleAnimation(QObject *target) : QAbstractAnimation(), | - |
| 5 | _delay(0), _duration(-1), _startTime(QTime::currentTime()) | - |
| 6 | { | - |
| 7 | if (target) { partially evaluated: target| yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
| 8 | moveToThread(target->thread()); | - |
| 9 | setParent(target); | - |
| 10 | } executed: }Execution Count:2 | 2 |
| 11 | } executed: }Execution Count:2 | 2 |
| 12 | | - |
| 13 | QStyleAnimation::~QStyleAnimation() | - |
| 14 | { | - |
| 15 | } | - |
| 16 | | - |
| 17 | QObject *QStyleAnimation::target() const | - |
| 18 | { | - |
| 19 | return parent(); executed: return parent();Execution Count:51 | 51 |
| 20 | } | - |
| 21 | | - |
| 22 | int QStyleAnimation::duration() const | - |
| 23 | { | - |
| 24 | return _duration; executed: return _duration;Execution Count:33 | 33 |
| 25 | } | - |
| 26 | | - |
| 27 | void QStyleAnimation::setDuration(int duration) | - |
| 28 | { | - |
| 29 | _duration = duration; | - |
| 30 | } | 0 |
| 31 | | - |
| 32 | int QStyleAnimation::delay() const | - |
| 33 | { | - |
| 34 | return _delay; never executed: return _delay; | 0 |
| 35 | } | - |
| 36 | | - |
| 37 | void QStyleAnimation::setDelay(int delay) | - |
| 38 | { | - |
| 39 | _delay = delay; | - |
| 40 | } | 0 |
| 41 | | - |
| 42 | QTime QStyleAnimation::startTime() const | - |
| 43 | { | - |
| 44 | return _startTime; never executed: return _startTime; | 0 |
| 45 | } | - |
| 46 | | - |
| 47 | void QStyleAnimation::setStartTime(const QTime &time) | - |
| 48 | { | - |
| 49 | _startTime = time; | - |
| 50 | } | 0 |
| 51 | | - |
| 52 | void QStyleAnimation::updateTarget() | - |
| 53 | { | - |
| 54 | QEvent event(QEvent::StyleAnimationUpdate); | - |
| 55 | QCoreApplication::sendEvent(target(), &event); | - |
| 56 | } executed: }Execution Count:15 | 15 |
| 57 | | - |
| 58 | bool QStyleAnimation::isUpdateNeeded() const | - |
| 59 | { | - |
| 60 | return currentTime() > _delay; executed: return currentTime() > _delay;Execution Count:32 | 32 |
| 61 | } | - |
| 62 | | - |
| 63 | void QStyleAnimation::updateCurrentTime(int) | - |
| 64 | { | - |
| 65 | if (QObject *tgt = target()) { partially evaluated: QObject *tgt = target()| yes Evaluation Count:32 | no Evaluation Count:0 |
| 0-32 |
| 66 | if (tgt->isWidgetType()) { partially evaluated: tgt->isWidgetType()| yes Evaluation Count:32 | no Evaluation Count:0 |
| 0-32 |
| 67 | QWidget *widget = static_cast<QWidget *>(tgt); | - |
| 68 | if (!widget->isVisible() || widget->window()->isMinimized()) partially evaluated: !widget->isVisible()| no Evaluation Count:0 | yes Evaluation Count:32 |
partially evaluated: widget->window()->isMinimized()| no Evaluation Count:0 | yes Evaluation Count:32 |
| 0-32 |
| 69 | stop(); | 0 |
| 70 | } executed: }Execution Count:32 | 32 |
| 71 | | - |
| 72 | if (isUpdateNeeded()) evaluated: isUpdateNeeded()| yes Evaluation Count:15 | yes Evaluation Count:17 |
| 15-17 |
| 73 | updateTarget(); executed: updateTarget();Execution Count:15 | 15 |
| 74 | } executed: }Execution Count:32 | 32 |
| 75 | } executed: }Execution Count:32 | 32 |
| 76 | | - |
| 77 | QProgressStyleAnimation::QProgressStyleAnimation(int speed, QObject *target) : | - |
| 78 | QStyleAnimation(target), _speed(speed), _step(-1) | - |
| 79 | { | - |
| 80 | } executed: }Execution Count:2 | 2 |
| 81 | | - |
| 82 | int QProgressStyleAnimation::animationStep() const | - |
| 83 | { | - |
| 84 | return currentTime() / (1000.0 / _speed); executed: return currentTime() / (1000.0 / _speed);Execution Count:45 | 45 |
| 85 | } | - |
| 86 | | - |
| 87 | int QProgressStyleAnimation::progressStep(int width) const | - |
| 88 | { | - |
| 89 | int step = animationStep(); | - |
| 90 | int progress = (step * width / _speed) % width; | - |
| 91 | if (((step * width / _speed) % (2 * width)) >= width) never evaluated: ((step * width / _speed) % (2 * width)) >= width | 0 |
| 92 | progress = width - progress; never executed: progress = width - progress; | 0 |
| 93 | return progress; never executed: return progress; | 0 |
| 94 | } | - |
| 95 | | - |
| 96 | int QProgressStyleAnimation::speed() const | - |
| 97 | { | - |
| 98 | return _speed; never executed: return _speed; | 0 |
| 99 | } | - |
| 100 | | - |
| 101 | void QProgressStyleAnimation::setSpeed(int speed) | - |
| 102 | { | - |
| 103 | _speed = speed; | - |
| 104 | } | 0 |
| 105 | | - |
| 106 | bool QProgressStyleAnimation::isUpdateNeeded() const | - |
| 107 | { | - |
| 108 | if (QStyleAnimation::isUpdateNeeded()) { evaluated: QStyleAnimation::isUpdateNeeded()| yes Evaluation Count:30 | yes Evaluation Count:2 |
| 2-30 |
| 109 | int current = animationStep(); | - |
| 110 | if (_step == -1 || _step != current) evaluated: _step == -1| yes Evaluation Count:1 | yes Evaluation Count:29 |
evaluated: _step != current| yes Evaluation Count:14 | yes Evaluation Count:15 |
| 1-29 |
| 111 | { | - |
| 112 | _step = current; | - |
| 113 | return true; executed: return true;Execution Count:15 | 15 |
| 114 | } | - |
| 115 | } executed: }Execution Count:15 | 15 |
| 116 | return false; executed: return false;Execution Count:17 | 17 |
| 117 | } | - |
| 118 | | - |
| 119 | QNumberStyleAnimation::QNumberStyleAnimation(QObject *target) : | - |
| 120 | QStyleAnimation(target), _start(0.0), _end(1.0), _prev(0.0) | - |
| 121 | { | - |
| 122 | setDuration(250); | - |
| 123 | } | 0 |
| 124 | | - |
| 125 | qreal QNumberStyleAnimation::startValue() const | - |
| 126 | { | - |
| 127 | return _start; never executed: return _start; | 0 |
| 128 | } | - |
| 129 | | - |
| 130 | void QNumberStyleAnimation::setStartValue(qreal value) | - |
| 131 | { | - |
| 132 | _start = value; | - |
| 133 | } | 0 |
| 134 | | - |
| 135 | qreal QNumberStyleAnimation::endValue() const | - |
| 136 | { | - |
| 137 | return _end; never executed: return _end; | 0 |
| 138 | } | - |
| 139 | | - |
| 140 | void QNumberStyleAnimation::setEndValue(qreal value) | - |
| 141 | { | - |
| 142 | _end = value; | - |
| 143 | } | 0 |
| 144 | | - |
| 145 | qreal QNumberStyleAnimation::currentValue() const | - |
| 146 | { | - |
| 147 | qreal step = qreal(currentTime() - delay()) / (duration() - delay()); | - |
| 148 | return _start + qMax(qreal(0), step) * (_end - _start); never executed: return _start + qMax(qreal(0), step) * (_end - _start); | 0 |
| 149 | } | - |
| 150 | | - |
| 151 | bool QNumberStyleAnimation::isUpdateNeeded() const | - |
| 152 | { | - |
| 153 | if (QStyleAnimation::isUpdateNeeded()) { never evaluated: QStyleAnimation::isUpdateNeeded() | 0 |
| 154 | qreal current = currentValue(); | - |
| 155 | if (!qFuzzyCompare(_prev, current)) never evaluated: !qFuzzyCompare(_prev, current) | 0 |
| 156 | { | - |
| 157 | _prev = current; | - |
| 158 | return true; never executed: return true; | 0 |
| 159 | } | - |
| 160 | } | 0 |
| 161 | return false; never executed: return false; | 0 |
| 162 | } | - |
| 163 | | - |
| 164 | QBlendStyleAnimation::QBlendStyleAnimation(Type type, QObject *target) : | - |
| 165 | QStyleAnimation(target), _type(type) | - |
| 166 | { | - |
| 167 | setDuration(250); | - |
| 168 | } | 0 |
| 169 | | - |
| 170 | QImage QBlendStyleAnimation::startImage() const | - |
| 171 | { | - |
| 172 | return _start; never executed: return _start; | 0 |
| 173 | } | - |
| 174 | | - |
| 175 | void QBlendStyleAnimation::setStartImage(const QImage& image) | - |
| 176 | { | - |
| 177 | _start = image; | - |
| 178 | } | 0 |
| 179 | | - |
| 180 | QImage QBlendStyleAnimation::endImage() const | - |
| 181 | { | - |
| 182 | return _end; never executed: return _end; | 0 |
| 183 | } | - |
| 184 | | - |
| 185 | void QBlendStyleAnimation::setEndImage(const QImage& image) | - |
| 186 | { | - |
| 187 | _end = image; | - |
| 188 | } | 0 |
| 189 | | - |
| 190 | QImage QBlendStyleAnimation::currentImage() const | - |
| 191 | { | - |
| 192 | return _current; never executed: return _current; | 0 |
| 193 | } | - |
| 194 | static QImage blendedImage(const QImage &start, const QImage &end, float alpha) | - |
| 195 | { | - |
| 196 | if (start.isNull() || end.isNull()) never evaluated: start.isNull() never evaluated: end.isNull() | 0 |
| 197 | return QImage(); never executed: return QImage(); | 0 |
| 198 | | - |
| 199 | QImage blended; | - |
| 200 | const int a = qRound(alpha*256); | - |
| 201 | const int ia = 256 - a; | - |
| 202 | const int sw = start.width(); | - |
| 203 | const int sh = start.height(); | - |
| 204 | const int bpl = start.bytesPerLine(); | - |
| 205 | switch (start.depth()) { | - |
| 206 | case 32: | - |
| 207 | { | - |
| 208 | blended = QImage(sw, sh, start.format()); | - |
| 209 | uchar *mixed_data = blended.bits(); | - |
| 210 | const uchar *back_data = start.bits(); | - |
| 211 | const uchar *front_data = end.bits(); | - |
| 212 | for (int sy = 0; sy < sh; sy++) { | 0 |
| 213 | quint32* mixed = (quint32*)mixed_data; | - |
| 214 | const quint32* back = (const quint32*)back_data; | - |
| 215 | const quint32* front = (const quint32*)front_data; | - |
| 216 | for (int sx = 0; sx < sw; sx++) { | 0 |
| 217 | quint32 bp = back[sx]; | - |
| 218 | quint32 fp = front[sx]; | - |
| 219 | mixed[sx] = qRgba ((qRed(bp)*ia + qRed(fp)*a)>>8, | - |
| 220 | (qGreen(bp)*ia + qGreen(fp)*a)>>8, | - |
| 221 | (qBlue(bp)*ia + qBlue(fp)*a)>>8, | - |
| 222 | (qAlpha(bp)*ia + qAlpha(fp)*a)>>8); | - |
| 223 | } | 0 |
| 224 | mixed_data += bpl; | - |
| 225 | back_data += bpl; | - |
| 226 | front_data += bpl; | - |
| 227 | } | 0 |
| 228 | } | - |
| 229 | default: | - |
| 230 | break; | 0 |
| 231 | } | - |
| 232 | return blended; never executed: return blended; | 0 |
| 233 | } | - |
| 234 | | - |
| 235 | void QBlendStyleAnimation::updateCurrentTime(int time) | - |
| 236 | { | - |
| 237 | QStyleAnimation::updateCurrentTime(time); | - |
| 238 | | - |
| 239 | float alpha = 1.0; | - |
| 240 | if (duration() > 0) { never evaluated: duration() > 0 | 0 |
| 241 | if (_type == Pulse) { never evaluated: _type == Pulse | 0 |
| 242 | time = time % duration() * 2; | - |
| 243 | if (time > duration()) never evaluated: time > duration() | 0 |
| 244 | time = duration() * 2 - time; never executed: time = duration() * 2 - time; | 0 |
| 245 | } | 0 |
| 246 | | - |
| 247 | alpha = time / static_cast<float>(duration()); | - |
| 248 | | - |
| 249 | if (_type == Transition && time > duration()) { never evaluated: _type == Transition never evaluated: time > duration() | 0 |
| 250 | alpha = 1.0; | - |
| 251 | stop(); | - |
| 252 | } | 0 |
| 253 | } else if (time > 0) { never evaluated: time > 0 | 0 |
| 254 | stop(); | - |
| 255 | } | 0 |
| 256 | | - |
| 257 | _current = blendedImage(_start, _end, alpha); | - |
| 258 | } | 0 |
| 259 | | - |
| 260 | | - |
| 261 | | - |
| | |