image/qmovie.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42/*! -
43 \class QMovie -
44 -
45 \inmodule QtGui -
46 -
47 \brief The QMovie class is a convenience class for playing movies -
48 with QImageReader. -
49 -
50 This class is used to show simple animations without sound. If you want -
51 to display video and media content, use the \l{Phonon Module}{Phonon} -
52 multimedia framework instead. -
53 -
54 First, create a QMovie object by passing either the name of a file or a -
55 pointer to a QIODevice containing an animated image format to QMovie's -
56 constructor. You can call isValid() to check if the image data is valid, -
57 before starting the movie. To start the movie, call start(). QMovie will -
58 enter \l Running state, and emit started() and stateChanged(). To get the -
59 current state of the movie, call state(). -
60 -
61 To display the movie in your application, you can pass your QMovie object -
62 to QLabel::setMovie(). Example: -
63 -
64 \snippet code/src_gui_image_qmovie.cpp 0 -
65 -
66 Whenever a new frame is available in the movie, QMovie will emit -
67 updated(). If the size of the frame changes, resized() is emitted. You can -
68 call currentImage() or currentPixmap() to get a copy of the current -
69 frame. When the movie is done, QMovie emits finished(). If any error -
70 occurs during playback (i.e, the image file is corrupt), QMovie will emit -
71 error(). -
72 -
73 You can control the speed of the movie playback by calling setSpeed(), -
74 which takes the percentage of the original speed as an argument. Pause the -
75 movie by calling setPaused(true). QMovie will then enter \l Paused state -
76 and emit stateChanged(). If you call setPaused(false), QMovie will reenter -
77 \l Running state and start the movie again. To stop the movie, call -
78 stop(). -
79 -
80 Certain animation formats allow you to set the background color. You can -
81 call setBackgroundColor() to set the color, or backgroundColor() to -
82 retrieve the current background color. -
83 -
84 currentFrameNumber() returns the sequence number of the current frame. The -
85 first frame in the animation has the sequence number 0. frameCount() -
86 returns the total number of frames in the animation, if the image format -
87 supports this. You can call loopCount() to get the number of times the -
88 movie should loop before finishing. nextFrameDelay() returns the number of -
89 milliseconds the current frame should be displayed. -
90 -
91 QMovie can be instructed to cache frames of an animation by calling -
92 setCacheMode(). -
93 -
94 Call supportedFormats() for a list of formats that QMovie supports. -
95 -
96 \sa QLabel, QImageReader, {Movie Example} -
97*/ -
98 -
99/*! \enum QMovie::MovieState -
100 -
101 This enum describes the different states of QMovie. -
102 -
103 \value NotRunning The movie is not running. This is QMovie's initial -
104 state, and the state it enters after stop() has been called or the movie -
105 is finished. -
106 -
107 \value Paused The movie is paused, and QMovie stops emitting updated() or -
108 resized(). This state is entered after calling pause() or -
109 setPaused(true). The current frame number it kept, and the movie will -
110 continue with the next frame when unpause() or setPaused(false) is called. -
111 -
112 \value Running The movie is running. -
113*/ -
114 -
115/*! \enum QMovie::CacheMode -
116 -
117 This enum describes the different cache modes of QMovie. -
118 -
119 \value CacheNone No frames are cached (the default). -
120 -
121 \value CacheAll All frames are cached. -
122*/ -
123 -
124/*! \fn void QMovie::started() -
125 -
126 This signal is emitted after QMovie::start() has been called, and QMovie -
127 has entered QMovie::Running state. -
128*/ -
129 -
130/*! \fn void QMovie::resized(const QSize &size) -
131 -
132 This signal is emitted when the current frame has been resized to \a -
133 size. This effect is sometimes used in animations as an alternative to -
134 replacing the frame. You can call currentImage() or currentPixmap() to get a -
135 copy of the updated frame. -
136*/ -
137 -
138/*! \fn void QMovie::updated(const QRect &rect) -
139 -
140 This signal is emitted when the rect \a rect in the current frame has been -
141 updated. You can call currentImage() or currentPixmap() to get a copy of the -
142 updated frame. -
143*/ -
144 -
145/*! \fn void QMovie::frameChanged(int frameNumber) -
146 \since 4.1 -
147 -
148 This signal is emitted when the frame number has changed to -
149 \a frameNumber. You can call currentImage() or currentPixmap() to get a -
150 copy of the frame. -
151*/ -
152 -
153/*! -
154 \fn void QMovie::stateChanged(QMovie::MovieState state) -
155 -
156 This signal is emitted every time the state of the movie changes. The new -
157 state is specified by \a state. -
158 -
159 \sa QMovie::state() -
160*/ -
161 -
162/*! \fn void QMovie::error(QImageReader::ImageReaderError error) -
163 -
164 This signal is emitted by QMovie when the error \a error occurred during -
165 playback. QMovie will stop the movie, and enter QMovie::NotRunning state. -
166*/ -
167 -
168/*! \fn void QMovie::finished() -
169 -
170 This signal is emitted when the movie has finished. -
171 -
172 \sa QMovie::stop() -
173*/ -
174 -
175#include "qglobal.h" -
176 -
177#ifndef QT_NO_MOVIE -
178 -
179#include "qmovie.h" -
180#include "qimage.h" -
181#include "qimagereader.h" -
182#include "qpixmap.h" -
183#include "qrect.h" -
184#include "qdatetime.h" -
185#include "qtimer.h" -
186#include "qpair.h" -
187#include "qmap.h" -
188#include "qlist.h" -
189#include "qbuffer.h" -
190#include "qdir.h" -
191#include "private/qobject_p.h" -
192 -
193#define QMOVIE_INVALID_DELAY -1 -
194 -
195QT_BEGIN_NAMESPACE -
196 -
197class QFrameInfo -
198{ -
199public: -
200 QPixmap pixmap; -
201 int delay; -
202 bool endMark; -
203 inline QFrameInfo(bool endMark) -
204 : pixmap(QPixmap()), delay(QMOVIE_INVALID_DELAY), endMark(endMark) -
205 { }
executed: }
Execution Count:9
9
206 -
207 inline QFrameInfo() -
208 : pixmap(QPixmap()), delay(QMOVIE_INVALID_DELAY), endMark(false) -
209 { }
never executed: }
0
210 -
211 inline QFrameInfo(const QPixmap &pixmap, int delay) -
212 : pixmap(pixmap), delay(delay), endMark(false) -
213 { }
executed: }
Execution Count:134
134
214 -
215 inline bool isValid() -
216 { -
217 return endMark || !(pixmap.isNull() && (delay == QMOVIE_INVALID_DELAY));
executed: return endMark || !(pixmap.isNull() && (delay == -1));
Execution Count:143
143
218 } -
219 -
220 inline bool isEndMarker() -
221 { return endMark; }
executed: return endMark;
Execution Count:143
143
222 -
223 static inline QFrameInfo endMarker() -
224 { return QFrameInfo(true); }
executed: return QFrameInfo(true);
Execution Count:9
9
225}; -
226 -
227class QMoviePrivate : public QObjectPrivate -
228{ -
229 Q_DECLARE_PUBLIC(QMovie) -
230 -
231public: -
232 QMoviePrivate(QMovie *qq); -
233 bool isDone(); -
234 bool next(); -
235 int speedAdjustedDelay(int delay) const; -
236 bool isValid() const; -
237 bool jumpToFrame(int frameNumber); -
238 int frameCount() const; -
239 bool jumpToNextFrame(); -
240 QFrameInfo infoForFrame(int frameNumber); -
241 void reset(); -
242 -
243 inline void enterState(QMovie::MovieState newState) { -
244 movieState = newState;
executed (the execution status of this line is deduced): movieState = newState;
-
245 emit q_func()->stateChanged(newState);
executed (the execution status of this line is deduced): q_func()->stateChanged(newState);
-
246 }
executed: }
Execution Count:23
23
247 -
248 // private slots -
249 void _q_loadNextFrame(); -
250 void _q_loadNextFrame(bool starting); -
251 -
252 QImageReader *reader; -
253 int speed; -
254 QMovie::MovieState movieState; -
255 QRect frameRect; -
256 QPixmap currentPixmap; -
257 int currentFrameNumber; -
258 int nextFrameNumber; -
259 int greatestFrameNumber; -
260 int nextDelay; -
261 int playCounter; -
262 qint64 initialDevicePos; -
263 QMovie::CacheMode cacheMode; -
264 bool haveReadAll; -
265 bool isFirstIteration; -
266 QMap<int, QFrameInfo> frameMap; -
267 QString absoluteFilePath; -
268 -
269 QTimer nextImageTimer; -
270}; -
271 -
272/*! \internal -
273 */ -
274QMoviePrivate::QMoviePrivate(QMovie *qq) -
275 : reader(0), speed(100), movieState(QMovie::NotRunning), -
276 currentFrameNumber(-1), nextFrameNumber(0), greatestFrameNumber(-1), -
277 nextDelay(0), playCounter(-1), -
278 cacheMode(QMovie::CacheNone), haveReadAll(false), isFirstIteration(true) -
279{ -
280 q_ptr = qq;
executed (the execution status of this line is deduced): q_ptr = qq;
-
281 nextImageTimer.setSingleShot(true);
executed (the execution status of this line is deduced): nextImageTimer.setSingleShot(true);
-
282}
executed: }
Execution Count:11
11
283 -
284/*! \internal -
285 */ -
286void QMoviePrivate::reset() -
287{ -
288 nextImageTimer.stop();
executed (the execution status of this line is deduced): nextImageTimer.stop();
-
289 if (reader->device())
evaluated: reader->device()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
290 initialDevicePos = reader->device()->pos();
executed: initialDevicePos = reader->device()->pos();
Execution Count:4
4
291 currentFrameNumber = -1;
executed (the execution status of this line is deduced): currentFrameNumber = -1;
-
292 nextFrameNumber = 0;
executed (the execution status of this line is deduced): nextFrameNumber = 0;
-
293 greatestFrameNumber = -1;
executed (the execution status of this line is deduced): greatestFrameNumber = -1;
-
294 nextDelay = 0;
executed (the execution status of this line is deduced): nextDelay = 0;
-
295 playCounter = -1;
executed (the execution status of this line is deduced): playCounter = -1;
-
296 haveReadAll = false;
executed (the execution status of this line is deduced): haveReadAll = false;
-
297 isFirstIteration = true;
executed (the execution status of this line is deduced): isFirstIteration = true;
-
298 frameMap.clear();
executed (the execution status of this line is deduced): frameMap.clear();
-
299}
executed: }
Execution Count:5
5
300 -
301/*! \internal -
302 */ -
303bool QMoviePrivate::isDone() -
304{ -
305 return (playCounter == 0);
executed: return (playCounter == 0);
Execution Count:4
4
306} -
307 -
308/*! -
309 \internal -
310 -
311 Given the original \a delay, this function returns the -
312 actual number of milliseconds to delay according to -
313 the current speed. E.g. if the speed is 200%, the -
314 result will be half of the original delay. -
315*/ -
316int QMoviePrivate::speedAdjustedDelay(int delay) const -
317{ -
318 return int( (qint64(delay) * qint64(100) ) / qint64(speed) );
executed: return int( (qint64(delay) * qint64(100) ) / qint64(speed) );
Execution Count:134
134
319} -
320 -
321/*! -
322 \internal -
323 -
324 Returns the QFrameInfo for the given \a frameNumber. -
325 -
326 If the frame number is invalid, an invalid QFrameInfo is -
327 returned. -
328 -
329 If the end of the animation has been reached, a -
330 special end marker QFrameInfo is returned. -
331 -
332*/ -
333QFrameInfo QMoviePrivate::infoForFrame(int frameNumber) -
334{ -
335 if (frameNumber < 0)
partially evaluated: frameNumber < 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:143
0-143
336 return QFrameInfo(); // Invalid
never executed: return QFrameInfo();
0
337 -
338 if (haveReadAll && (frameNumber > greatestFrameNumber)) {
evaluated: haveReadAll
TRUEFALSE
yes
Evaluation Count:86
yes
Evaluation Count:57
evaluated: (frameNumber > greatestFrameNumber)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:82
4-86
339 if (frameNumber == greatestFrameNumber+1)
partially evaluated: frameNumber == greatestFrameNumber+1
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
340 return QFrameInfo::endMarker();
executed: return QFrameInfo::endMarker();
Execution Count:4
4
341 return QFrameInfo(); // Invalid
never executed: return QFrameInfo();
0
342 } -
343 -
344 if (cacheMode == QMovie::CacheNone) {
partially evaluated: cacheMode == QMovie::CacheNone
TRUEFALSE
yes
Evaluation Count:139
no
Evaluation Count:0
0-139
345 if (frameNumber != currentFrameNumber+1) {
evaluated: frameNumber != currentFrameNumber+1
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:132
7-132
346 // Non-sequential frame access -
347 if (!reader->jumpToImage(frameNumber)) {
partially evaluated: !reader->jumpToImage(frameNumber)
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
348 if (frameNumber == 0) {
partially evaluated: frameNumber == 0
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
349 // Special case: Attempt to "rewind" so we can loop -
350 // ### This could be implemented as QImageReader::rewind() -
351 if (reader->device()->isSequential())
partially evaluated: reader->device()->isSequential()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
352 return QFrameInfo(); // Invalid
never executed: return QFrameInfo();
0
353 QString fileName = reader->fileName();
executed (the execution status of this line is deduced): QString fileName = reader->fileName();
-
354 QByteArray format = reader->format();
executed (the execution status of this line is deduced): QByteArray format = reader->format();
-
355 QIODevice *device = reader->device();
executed (the execution status of this line is deduced): QIODevice *device = reader->device();
-
356 QColor bgColor = reader->backgroundColor();
executed (the execution status of this line is deduced): QColor bgColor = reader->backgroundColor();
-
357 QSize scaledSize = reader->scaledSize();
executed (the execution status of this line is deduced): QSize scaledSize = reader->scaledSize();
-
358 delete reader;
executed (the execution status of this line is deduced): delete reader;
-
359 if (fileName.isEmpty())
partially evaluated: fileName.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
360 reader = new QImageReader(device, format);
never executed: reader = new QImageReader(device, format);
0
361 else -
362 reader = new QImageReader(absoluteFilePath, format);
executed: reader = new QImageReader(absoluteFilePath, format);
Execution Count:7
7
363 (void)reader->canRead(); // Provoke a device->open() call
executed (the execution status of this line is deduced): (void)reader->canRead();
-
364 reader->device()->seek(initialDevicePos);
executed (the execution status of this line is deduced): reader->device()->seek(initialDevicePos);
-
365 reader->setBackgroundColor(bgColor);
executed (the execution status of this line is deduced): reader->setBackgroundColor(bgColor);
-
366 reader->setScaledSize(scaledSize);
executed (the execution status of this line is deduced): reader->setScaledSize(scaledSize);
-
367 } else {
executed: }
Execution Count:7
7
368 return QFrameInfo(); // Invalid
never executed: return QFrameInfo();
0
369 } -
370 } -
371 }
executed: }
Execution Count:7
7
372 if (reader->canRead()) {
evaluated: reader->canRead()
TRUEFALSE
yes
Evaluation Count:134
yes
Evaluation Count:5
5-134
373 // reader says we can read. Attempt to actually read image -
374 QImage anImage = reader->read();
executed (the execution status of this line is deduced): QImage anImage = reader->read();
-
375 if (anImage.isNull()) {
partially evaluated: anImage.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:134
0-134
376 // Reading image failed. -
377 return QFrameInfo(); // Invalid
never executed: return QFrameInfo();
0
378 } -
379 if (frameNumber > greatestFrameNumber)
evaluated: frameNumber > greatestFrameNumber
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:84
50-84
380 greatestFrameNumber = frameNumber;
executed: greatestFrameNumber = frameNumber;
Execution Count:50
50
381 QPixmap aPixmap = QPixmap::fromImage(anImage);
executed (the execution status of this line is deduced): QPixmap aPixmap = QPixmap::fromImage(anImage);
-
382 int aDelay = reader->nextImageDelay();
executed (the execution status of this line is deduced): int aDelay = reader->nextImageDelay();
-
383 return QFrameInfo(aPixmap, aDelay);
executed: return QFrameInfo(aPixmap, aDelay);
Execution Count:134
134
384 } else if (frameNumber != 0) {
partially evaluated: frameNumber != 0
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
385 // We've read all frames now. Return an end marker -
386 haveReadAll = true;
executed (the execution status of this line is deduced): haveReadAll = true;
-
387 return QFrameInfo::endMarker();
executed: return QFrameInfo::endMarker();
Execution Count:5
5
388 } else { -
389 // No readable frames -
390 haveReadAll = true;
never executed (the execution status of this line is deduced): haveReadAll = true;
-
391 return QFrameInfo();
never executed: return QFrameInfo();
0
392 } -
393 } -
394 -
395 // CacheMode == CacheAll -
396 if (frameNumber > greatestFrameNumber) {
never evaluated: frameNumber > greatestFrameNumber
0
397 // Frame hasn't been read from file yet. Try to do it -
398 for (int i = greatestFrameNumber + 1; i <= frameNumber; ++i) {
never evaluated: i <= frameNumber
0
399 if (reader->canRead()) {
never evaluated: reader->canRead()
0
400 // reader says we can read. Attempt to actually read image -
401 QImage anImage = reader->read();
never executed (the execution status of this line is deduced): QImage anImage = reader->read();
-
402 if (anImage.isNull()) {
never evaluated: anImage.isNull()
0
403 // Reading image failed. -
404 return QFrameInfo(); // Invalid
never executed: return QFrameInfo();
0
405 } -
406 greatestFrameNumber = i;
never executed (the execution status of this line is deduced): greatestFrameNumber = i;
-
407 QPixmap aPixmap = QPixmap::fromImage(anImage);
never executed (the execution status of this line is deduced): QPixmap aPixmap = QPixmap::fromImage(anImage);
-
408 int aDelay = reader->nextImageDelay();
never executed (the execution status of this line is deduced): int aDelay = reader->nextImageDelay();
-
409 QFrameInfo info(aPixmap, aDelay);
never executed (the execution status of this line is deduced): QFrameInfo info(aPixmap, aDelay);
-
410 // Cache it! -
411 frameMap.insert(i, info);
never executed (the execution status of this line is deduced): frameMap.insert(i, info);
-
412 if (i == frameNumber) {
never evaluated: i == frameNumber
0
413 return info;
never executed: return info;
0
414 } -
415 } else {
never executed: }
0
416 // We've read all frames now. Return an end marker -
417 haveReadAll = true;
never executed (the execution status of this line is deduced): haveReadAll = true;
-
418 return QFrameInfo::endMarker();
never executed: return QFrameInfo::endMarker();
0
419 } -
420 } -
421 }
never executed: }
0
422 // Return info for requested (cached) frame -
423 return frameMap.value(frameNumber);
never executed: return frameMap.value(frameNumber);
0
424} -
425 -
426/*! -
427 \internal -
428 -
429 Attempts to advance the animation to the next frame. -
430 If successful, currentFrameNumber, currentPixmap and -
431 nextDelay are updated accordingly, and true is returned. -
432 Otherwise, false is returned. -
433 When false is returned, isDone() can be called to -
434 determine whether the animation ended gracefully or -
435 an error occurred when reading the frame. -
436*/ -
437bool QMoviePrivate::next() -
438{ -
439 QTime time;
executed (the execution status of this line is deduced): QTime time;
-
440 time.start();
executed (the execution status of this line is deduced): time.start();
-
441 QFrameInfo info = infoForFrame(nextFrameNumber);
executed (the execution status of this line is deduced): QFrameInfo info = infoForFrame(nextFrameNumber);
-
442 if (!info.isValid())
partially evaluated: !info.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:143
0-143
443 return false;
never executed: return false;
0
444 if (info.isEndMarker()) {
evaluated: info.isEndMarker()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:134
9-134
445 // We reached the end of the animation. -
446 if (isFirstIteration) {
evaluated: isFirstIteration
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:4
4-5
447 if (nextFrameNumber == 0) {
partially evaluated: nextFrameNumber == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
448 // No frames could be read at all (error). -
449 return false;
never executed: return false;
0
450 } -
451 // End of first iteration. Initialize play counter -
452 playCounter = reader->loopCount();
executed (the execution status of this line is deduced): playCounter = reader->loopCount();
-
453 isFirstIteration = false;
executed (the execution status of this line is deduced): isFirstIteration = false;
-
454 }
executed: }
Execution Count:5
5
455 // Loop as appropriate -
456 if (playCounter != 0) {
evaluated: playCounter != 0
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:4
4-5
457 if (playCounter != -1) // Infinite?
evaluated: playCounter != -1
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:1
1-4
458 playCounter--; // Nope
executed: playCounter--;
Execution Count:4
4
459 nextFrameNumber = 0;
executed (the execution status of this line is deduced): nextFrameNumber = 0;
-
460 return next();
executed: return next();
Execution Count:5
5
461 } -
462 // Loop no more. Done -
463 return false;
executed: return false;
Execution Count:4
4
464 } -
465 // Image and delay OK, update internal state -
466 currentFrameNumber = nextFrameNumber++;
executed (the execution status of this line is deduced): currentFrameNumber = nextFrameNumber++;
-
467 QSize scaledSize = reader->scaledSize();
executed (the execution status of this line is deduced): QSize scaledSize = reader->scaledSize();
-
468 if (scaledSize.isValid() && (scaledSize != info.pixmap.size()))
partially evaluated: scaledSize.isValid()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:134
never evaluated: (scaledSize != info.pixmap.size())
0-134
469 currentPixmap = QPixmap::fromImage( info.pixmap.toImage().scaled(scaledSize) );
never executed: currentPixmap = QPixmap::fromImage( info.pixmap.toImage().scaled(scaledSize) );
0
470 else -
471 currentPixmap = info.pixmap;
executed: currentPixmap = info.pixmap;
Execution Count:134
134
472 nextDelay = speedAdjustedDelay(info.delay);
executed (the execution status of this line is deduced): nextDelay = speedAdjustedDelay(info.delay);
-
473 // Adjust delay according to the time it took to read the frame -
474 int processingTime = time.elapsed();
executed (the execution status of this line is deduced): int processingTime = time.elapsed();
-
475 if (processingTime > nextDelay)
evaluated: processingTime > nextDelay
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:130
4-130
476 nextDelay = 0;
executed: nextDelay = 0;
Execution Count:4
4
477 else -
478 nextDelay = nextDelay - processingTime;
executed: nextDelay = nextDelay - processingTime;
Execution Count:130
130
479 return true;
executed: return true;
Execution Count:134
134
480} -
481 -
482/*! \internal -
483 */ -
484void QMoviePrivate::_q_loadNextFrame() -
485{ -
486 _q_loadNextFrame(false);
executed (the execution status of this line is deduced): _q_loadNextFrame(false);
-
487}
executed: }
Execution Count:128
128
488 -
489void QMoviePrivate::_q_loadNextFrame(bool starting) -
490{ -
491 Q_Q(QMovie);
executed (the execution status of this line is deduced): QMovie * const q = q_func();
-
492 if (next()) {
evaluated: next()
TRUEFALSE
yes
Evaluation Count:134
yes
Evaluation Count:4
4-134
493 if (starting && movieState == QMovie::NotRunning) {
evaluated: starting
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:124
partially evaluated: movieState == QMovie::NotRunning
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-124
494 enterState(QMovie::Running);
executed (the execution status of this line is deduced): enterState(QMovie::Running);
-
495 emit q->started();
executed (the execution status of this line is deduced): q->started();
-
496 }
executed: }
Execution Count:10
10
497 -
498 if (frameRect.size() != currentPixmap.rect().size()) {
evaluated: frameRect.size() != currentPixmap.rect().size()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:126
8-126
499 frameRect = currentPixmap.rect();
executed (the execution status of this line is deduced): frameRect = currentPixmap.rect();
-
500 emit q->resized(frameRect.size());
executed (the execution status of this line is deduced): q->resized(frameRect.size());
-
501 }
executed: }
Execution Count:8
8
502 -
503 emit q->updated(frameRect);
executed (the execution status of this line is deduced): q->updated(frameRect);
-
504 emit q->frameChanged(currentFrameNumber);
executed (the execution status of this line is deduced): q->frameChanged(currentFrameNumber);
-
505 -
506 if (movieState == QMovie::Running)
partially evaluated: movieState == QMovie::Running
TRUEFALSE
yes
Evaluation Count:134
no
Evaluation Count:0
0-134
507 nextImageTimer.start(nextDelay);
executed: nextImageTimer.start(nextDelay);
Execution Count:134
134
508 } else {
executed: }
Execution Count:134
134
509 // Could not read another frame -
510 if (!isDone()) {
partially evaluated: !isDone()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
511 emit q->error(reader->error());
never executed (the execution status of this line is deduced): q->error(reader->error());
-
512 }
never executed: }
0
513 -
514 // Graceful finish -
515 if (movieState != QMovie::Paused) {
partially evaluated: movieState != QMovie::Paused
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
516 nextFrameNumber = 0;
executed (the execution status of this line is deduced): nextFrameNumber = 0;
-
517 isFirstIteration = true;
executed (the execution status of this line is deduced): isFirstIteration = true;
-
518 playCounter = -1;
executed (the execution status of this line is deduced): playCounter = -1;
-
519 enterState(QMovie::NotRunning);
executed (the execution status of this line is deduced): enterState(QMovie::NotRunning);
-
520 emit q->finished();
executed (the execution status of this line is deduced): q->finished();
-
521 }
executed: }
Execution Count:4
4
522 }
executed: }
Execution Count:4
4
523} -
524 -
525/*! -
526 \internal -
527*/ -
528bool QMoviePrivate::isValid() const -
529{ -
530 return (greatestFrameNumber >= 0) // have we seen valid data
executed: return (greatestFrameNumber >= 0) || reader->canRead();
Execution Count:130
130
531 || reader->canRead(); // or does the reader see valid data
executed: return (greatestFrameNumber >= 0) || reader->canRead();
Execution Count:130
130
532} -
533 -
534/*! -
535 \internal -
536*/ -
537bool QMoviePrivate::jumpToFrame(int frameNumber) -
538{ -
539 if (frameNumber < 0)
evaluated: frameNumber < 0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
540 return false;
executed: return false;
Execution Count:2
2
541 if (currentFrameNumber == frameNumber)
partially evaluated: currentFrameNumber == frameNumber
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
542 return true;
executed: return true;
Execution Count:2
2
543 nextFrameNumber = frameNumber;
never executed (the execution status of this line is deduced): nextFrameNumber = frameNumber;
-
544 if (movieState == QMovie::Running)
never evaluated: movieState == QMovie::Running
0
545 nextImageTimer.stop();
never executed: nextImageTimer.stop();
0
546 _q_loadNextFrame();
never executed (the execution status of this line is deduced): _q_loadNextFrame();
-
547 return (nextFrameNumber == currentFrameNumber+1);
never executed: return (nextFrameNumber == currentFrameNumber+1);
0
548} -
549 -
550/*! -
551 \internal -
552*/ -
553int QMoviePrivate::frameCount() const -
554{ -
555 int result;
executed (the execution status of this line is deduced): int result;
-
556 if ((result = reader->imageCount()) != 0)
partially evaluated: (result = reader->imageCount()) != 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
557 return result;
executed: return result;
Execution Count:2
2
558 if (haveReadAll)
never evaluated: haveReadAll
0
559 return greatestFrameNumber+1;
never executed: return greatestFrameNumber+1;
0
560 return 0; // Don't know
never executed: return 0;
0
561} -
562 -
563/*! -
564 \internal -
565*/ -
566bool QMoviePrivate::jumpToNextFrame() -
567{ -
568 return jumpToFrame(currentFrameNumber+1);
never executed: return jumpToFrame(currentFrameNumber+1);
0
569} -
570 -
571/*! -
572 Constructs a QMovie object, passing the \a parent object to QObject's -
573 constructor. -
574 -
575 \sa setFileName(), setDevice(), setFormat() -
576 */ -
577QMovie::QMovie(QObject *parent) -
578 : QObject(*new QMoviePrivate(this), parent) -
579{ -
580 Q_D(QMovie);
executed (the execution status of this line is deduced): QMoviePrivate * const d = d_func();
-
581 d->reader = new QImageReader;
executed (the execution status of this line is deduced): d->reader = new QImageReader;
-
582 connect(&d->nextImageTimer, SIGNAL(timeout()), this, SLOT(_q_loadNextFrame()));
executed (the execution status of this line is deduced): connect(&d->nextImageTimer, "2""timeout()", this, "1""_q_loadNextFrame()");
-
583}
executed: }
Execution Count:5
5
584 -
585/*! -
586 Constructs a QMovie object. QMovie will use read image data from \a -
587 device, which it assumes is open and readable. If \a format is not empty, -
588 QMovie will use the image format \a format for decoding the image -
589 data. Otherwise, QMovie will attempt to guess the format. -
590 -
591 The \a parent object is passed to QObject's constructor. -
592 */ -
593QMovie::QMovie(QIODevice *device, const QByteArray &format, QObject *parent) -
594 : QObject(*new QMoviePrivate(this), parent) -
595{ -
596 Q_D(QMovie);
never executed (the execution status of this line is deduced): QMoviePrivate * const d = d_func();
-
597 d->reader = new QImageReader(device, format);
never executed (the execution status of this line is deduced): d->reader = new QImageReader(device, format);
-
598 d->initialDevicePos = device->pos();
never executed (the execution status of this line is deduced): d->initialDevicePos = device->pos();
-
599 connect(&d->nextImageTimer, SIGNAL(timeout()), this, SLOT(_q_loadNextFrame()));
never executed (the execution status of this line is deduced): connect(&d->nextImageTimer, "2""timeout()", this, "1""_q_loadNextFrame()");
-
600}
never executed: }
0
601 -
602/*! -
603 Constructs a QMovie object. QMovie will use read image data from \a -
604 fileName. If \a format is not empty, QMovie will use the image format \a -
605 format for decoding the image data. Otherwise, QMovie will attempt to -
606 guess the format. -
607 -
608 The \a parent object is passed to QObject's constructor. -
609 */ -
610QMovie::QMovie(const QString &fileName, const QByteArray &format, QObject *parent) -
611 : QObject(*new QMoviePrivate(this), parent) -
612{ -
613 Q_D(QMovie);
executed (the execution status of this line is deduced): QMoviePrivate * const d = d_func();
-
614 d->absoluteFilePath = QDir(fileName).absolutePath();
executed (the execution status of this line is deduced): d->absoluteFilePath = QDir(fileName).absolutePath();
-
615 d->reader = new QImageReader(fileName, format);
executed (the execution status of this line is deduced): d->reader = new QImageReader(fileName, format);
-
616 if (d->reader->device())
partially evaluated: d->reader->device()
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
617 d->initialDevicePos = d->reader->device()->pos();
executed: d->initialDevicePos = d->reader->device()->pos();
Execution Count:6
6
618 connect(&d->nextImageTimer, SIGNAL(timeout()), this, SLOT(_q_loadNextFrame()));
executed (the execution status of this line is deduced): connect(&d->nextImageTimer, "2""timeout()", this, "1""_q_loadNextFrame()");
-
619}
executed: }
Execution Count:6
6
620 -
621/*! -
622 Destructs the QMovie object. -
623*/ -
624QMovie::~QMovie() -
625{ -
626 Q_D(QMovie);
executed (the execution status of this line is deduced): QMoviePrivate * const d = d_func();
-
627 delete d->reader;
executed (the execution status of this line is deduced): delete d->reader;
-
628}
executed: }
Execution Count:11
11
629 -
630/*! -
631 Sets the current device to \a device. QMovie will read image data from -
632 this device when the movie is running. -
633 -
634 \sa device(), setFormat() -
635*/ -
636void QMovie::setDevice(QIODevice *device) -
637{ -
638 Q_D(QMovie);
executed (the execution status of this line is deduced): QMoviePrivate * const d = d_func();
-
639 d->reader->setDevice(device);
executed (the execution status of this line is deduced): d->reader->setDevice(device);
-
640 d->reset();
executed (the execution status of this line is deduced): d->reset();
-
641}
executed: }
Execution Count:2
2
642 -
643/*! -
644 Returns the device QMovie reads image data from. If no device has -
645 currently been assigned, 0 is returned. -
646 -
647 \sa setDevice(), fileName() -
648*/ -
649QIODevice *QMovie::device() const -
650{ -
651 Q_D(const QMovie);
executed (the execution status of this line is deduced): const QMoviePrivate * const d = d_func();
-
652 return d->reader->device();
executed: return d->reader->device();
Execution Count:3
3
653} -
654 -
655/*! -
656 Sets the name of the file that QMovie reads image data from, to \a -
657 fileName. -
658 -
659 \sa fileName(), setDevice(), setFormat() -
660*/ -
661void QMovie::setFileName(const QString &fileName) -
662{ -
663 Q_D(QMovie);
executed (the execution status of this line is deduced): QMoviePrivate * const d = d_func();
-
664 d->absoluteFilePath = QDir(fileName).absolutePath();
executed (the execution status of this line is deduced): d->absoluteFilePath = QDir(fileName).absolutePath();
-
665 d->reader->setFileName(fileName);
executed (the execution status of this line is deduced): d->reader->setFileName(fileName);
-
666 d->reset();
executed (the execution status of this line is deduced): d->reset();
-
667}
executed: }
Execution Count:3
3
668 -
669/*! -
670 Returns the name of the file that QMovie reads image data from. If no file -
671 name has been assigned, or if the assigned device is not a file, an empty -
672 QString is returned. -
673 -
674 \sa setFileName(), device() -
675*/ -
676QString QMovie::fileName() const -
677{ -
678 Q_D(const QMovie);
executed (the execution status of this line is deduced): const QMoviePrivate * const d = d_func();
-
679 return d->reader->fileName();
executed: return d->reader->fileName();
Execution Count:1
1
680} -
681 -
682/*! -
683 Sets the format that QMovie will use when decoding image data, to \a -
684 format. By default, QMovie will attempt to guess the format of the image -
685 data. -
686 -
687 You can call supportedFormats() for the full list of formats -
688 QMovie supports. -
689 -
690 \sa QImageReader::supportedImageFormats() -
691*/ -
692void QMovie::setFormat(const QByteArray &format) -
693{ -
694 Q_D(QMovie);
never executed (the execution status of this line is deduced): QMoviePrivate * const d = d_func();
-
695 d->reader->setFormat(format);
never executed (the execution status of this line is deduced): d->reader->setFormat(format);
-
696}
never executed: }
0
697 -
698/*! -
699 Returns the format that QMovie uses when decoding image data. If no format -
700 has been assigned, an empty QByteArray() is returned. -
701 -
702 \sa setFormat() -
703*/ -
704QByteArray QMovie::format() const -
705{ -
706 Q_D(const QMovie);
never executed (the execution status of this line is deduced): const QMoviePrivate * const d = d_func();
-
707 return d->reader->format();
never executed: return d->reader->format();
0
708} -
709 -
710/*! -
711 For image formats that support it, this function sets the background color -
712 to \a color. -
713 -
714 \sa backgroundColor() -
715*/ -
716void QMovie::setBackgroundColor(const QColor &color) -
717{ -
718 Q_D(QMovie);
never executed (the execution status of this line is deduced): QMoviePrivate * const d = d_func();
-
719 d->reader->setBackgroundColor(color);
never executed (the execution status of this line is deduced): d->reader->setBackgroundColor(color);
-
720}
never executed: }
0
721 -
722/*! -
723 Returns the background color of the movie. If no background color has been -
724 assigned, an invalid QColor is returned. -
725 -
726 \sa setBackgroundColor() -
727*/ -
728QColor QMovie::backgroundColor() const -
729{ -
730 Q_D(const QMovie);
never executed (the execution status of this line is deduced): const QMoviePrivate * const d = d_func();
-
731 return d->reader->backgroundColor();
never executed: return d->reader->backgroundColor();
0
732} -
733 -
734/*! -
735 Returns the current state of QMovie. -
736 -
737 \sa MovieState, stateChanged() -
738*/ -
739QMovie::MovieState QMovie::state() const -
740{ -
741 Q_D(const QMovie);
executed (the execution status of this line is deduced): const QMoviePrivate * const d = d_func();
-
742 return d->movieState;
executed: return d->movieState;
Execution Count:23
23
743} -
744 -
745/*! -
746 Returns the rect of the last frame. If no frame has yet been updated, an -
747 invalid QRect is returned. -
748 -
749 \sa currentImage(), currentPixmap() -
750*/ -
751QRect QMovie::frameRect() const -
752{ -
753 Q_D(const QMovie);
never executed (the execution status of this line is deduced): const QMoviePrivate * const d = d_func();
-
754 return d->frameRect;
never executed: return d->frameRect;
0
755} -
756 -
757/*! -
758 Returns the current frame as a QPixmap. -
759 -
760 \sa currentImage(), updated() -
761*/ -
762QPixmap QMovie::currentPixmap() const -
763{ -
764 Q_D(const QMovie);
executed (the execution status of this line is deduced): const QMoviePrivate * const d = d_func();
-
765 return d->currentPixmap;
executed: return d->currentPixmap;
Execution Count:264
264
766} -
767 -
768/*! -
769 Returns the current frame as a QImage. -
770 -
771 \sa currentPixmap(), updated() -
772*/ -
773QImage QMovie::currentImage() const -
774{ -
775 Q_D(const QMovie);
never executed (the execution status of this line is deduced): const QMoviePrivate * const d = d_func();
-
776 return d->currentPixmap.toImage();
never executed: return d->currentPixmap.toImage();
0
777} -
778 -
779/*! -
780 Returns true if the movie is valid (e.g., the image data is readable and -
781 the image format is supported); otherwise returns false. -
782*/ -
783bool QMovie::isValid() const -
784{ -
785 Q_D(const QMovie);
executed (the execution status of this line is deduced): const QMoviePrivate * const d = d_func();
-
786 return d->isValid();
executed: return d->isValid();
Execution Count:130
130
787} -
788 -
789/*! -
790 Returns the number of frames in the movie. -
791 -
792 Certain animation formats do not support this feature, in which -
793 case 0 is returned. -
794*/ -
795int QMovie::frameCount() const -
796{ -
797 Q_D(const QMovie);
executed (the execution status of this line is deduced): const QMoviePrivate * const d = d_func();
-
798 return d->frameCount();
executed: return d->frameCount();
Execution Count:2
2
799} -
800 -
801/*! -
802 Returns the number of milliseconds QMovie will wait before updating the -
803 next frame in the animation. -
804*/ -
805int QMovie::nextFrameDelay() const -
806{ -
807 Q_D(const QMovie);
executed (the execution status of this line is deduced): const QMoviePrivate * const d = d_func();
-
808 return d->nextDelay;
executed: return d->nextDelay;
Execution Count:2
2
809} -
810 -
811/*! -
812 Returns the sequence number of the current frame. The number of the first -
813 frame in the movie is 0. -
814*/ -
815int QMovie::currentFrameNumber() const -
816{ -
817 Q_D(const QMovie);
executed (the execution status of this line is deduced): const QMoviePrivate * const d = d_func();
-
818 return d->currentFrameNumber;
executed: return d->currentFrameNumber;
Execution Count:3
3
819} -
820 -
821/*! -
822 Jumps to the next frame. Returns true on success; otherwise returns false. -
823*/ -
824bool QMovie::jumpToNextFrame() -
825{ -
826 Q_D(QMovie);
never executed (the execution status of this line is deduced): QMoviePrivate * const d = d_func();
-
827 return d->jumpToNextFrame();
never executed: return d->jumpToNextFrame();
0
828} -
829 -
830/*! -
831 Jumps to frame number \a frameNumber. Returns true on success; otherwise -
832 returns false. -
833*/ -
834bool QMovie::jumpToFrame(int frameNumber) -
835{ -
836 Q_D(QMovie);
executed (the execution status of this line is deduced): QMoviePrivate * const d = d_func();
-
837 return d->jumpToFrame(frameNumber);
executed: return d->jumpToFrame(frameNumber);
Execution Count:4
4
838} -
839 -
840/*! -
841 Returns the number of times the movie will loop before it finishes. -
842 If the movie will only play once (no looping), loopCount returns 0. -
843 If the movie loops forever, loopCount returns -1. -
844 -
845 Note that, if the image data comes from a sequential device (e.g. a -
846 socket), QMovie can only loop the movie if the cacheMode is set to -
847 QMovie::CacheAll. -
848*/ -
849int QMovie::loopCount() const -
850{ -
851 Q_D(const QMovie);
never executed (the execution status of this line is deduced): const QMoviePrivate * const d = d_func();
-
852 return d->reader->loopCount();
never executed: return d->reader->loopCount();
0
853} -
854 -
855/*! -
856 If \a paused is true, QMovie will enter \l Paused state and emit -
857 stateChanged(Paused); otherwise it will enter \l Running state and emit -
858 stateChanged(Running). -
859 -
860 \sa state() -
861*/ -
862void QMovie::setPaused(bool paused) -
863{ -
864 Q_D(QMovie);
executed (the execution status of this line is deduced): QMoviePrivate * const d = d_func();
-
865 if (paused) {
evaluated: paused
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
866 if (d->movieState == NotRunning)
partially evaluated: d->movieState == NotRunning
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
867 return;
never executed: return;
0
868 d->enterState(Paused);
executed (the execution status of this line is deduced): d->enterState(Paused);
-
869 d->nextImageTimer.stop();
executed (the execution status of this line is deduced): d->nextImageTimer.stop();
-
870 } else {
executed: }
Execution Count:2
2
871 if (d->movieState == Running)
partially evaluated: d->movieState == Running
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
872 return;
never executed: return;
0
873 d->enterState(Running);
executed (the execution status of this line is deduced): d->enterState(Running);
-
874 d->nextImageTimer.start(nextFrameDelay());
executed (the execution status of this line is deduced): d->nextImageTimer.start(nextFrameDelay());
-
875 }
executed: }
Execution Count:2
2
876} -
877 -
878/*! -
879 \property QMovie::speed -
880 \brief the movie's speed -
881 -
882 The speed is measured in percentage of the original movie speed. -
883 The default speed is 100%. -
884 Example: -
885 -
886 \snippet code/src_gui_image_qmovie.cpp 1 -
887*/ -
888void QMovie::setSpeed(int percentSpeed) -
889{ -
890 Q_D(QMovie);
executed (the execution status of this line is deduced): QMoviePrivate * const d = d_func();
-
891 d->speed = percentSpeed;
executed (the execution status of this line is deduced): d->speed = percentSpeed;
-
892}
executed: }
Execution Count:5
5
893 -
894int QMovie::speed() const -
895{ -
896 Q_D(const QMovie);
executed (the execution status of this line is deduced): const QMoviePrivate * const d = d_func();
-
897 return d->speed;
executed: return d->speed;
Execution Count:3
3
898} -
899 -
900/*! -
901 Starts the movie. QMovie will enter \l Running state, and start emitting -
902 updated() and resized() as the movie progresses. -
903 -
904 If QMovie is in the \l Paused state, this function is equivalent -
905 to calling setPaused(false). If QMovie is already in the \l -
906 Running state, this function does nothing. -
907 -
908 \sa stop(), setPaused() -
909*/ -
910void QMovie::start() -
911{ -
912 Q_D(QMovie);
executed (the execution status of this line is deduced): QMoviePrivate * const d = d_func();
-
913 if (d->movieState == NotRunning) {
evaluated: d->movieState == NotRunning
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:2
2-10
914 d->_q_loadNextFrame(true);
executed (the execution status of this line is deduced): d->_q_loadNextFrame(true);
-
915 } else if (d->movieState == Paused) {
executed: }
Execution Count:10
partially evaluated: d->movieState == Paused
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-10
916 setPaused(false);
executed (the execution status of this line is deduced): setPaused(false);
-
917 }
executed: }
Execution Count:2
2
918} -
919 -
920/*! -
921 Stops the movie. QMovie enters \l NotRunning state, and stops emitting -
922 updated() and resized(). If start() is called again, the movie will -
923 restart from the beginning. -
924 -
925 If QMovie is already in the \l NotRunning state, this function -
926 does nothing. -
927 -
928 \sa start(), setPaused() -
929*/ -
930void QMovie::stop() -
931{ -
932 Q_D(QMovie);
executed (the execution status of this line is deduced): QMoviePrivate * const d = d_func();
-
933 if (d->movieState == NotRunning)
evaluated: d->movieState == NotRunning
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:5
1-5
934 return;
executed: return;
Execution Count:1
1
935 d->enterState(NotRunning);
executed (the execution status of this line is deduced): d->enterState(NotRunning);
-
936 d->nextImageTimer.stop();
executed (the execution status of this line is deduced): d->nextImageTimer.stop();
-
937 d->nextFrameNumber = 0;
executed (the execution status of this line is deduced): d->nextFrameNumber = 0;
-
938}
executed: }
Execution Count:5
5
939 -
940/*! -
941 \since 4.1 -
942 -
943 Returns the scaled size of frames. -
944 -
945 \sa QImageReader::scaledSize() -
946*/ -
947QSize QMovie::scaledSize() -
948{ -
949 Q_D(QMovie);
never executed (the execution status of this line is deduced): QMoviePrivate * const d = d_func();
-
950 return d->reader->scaledSize();
never executed: return d->reader->scaledSize();
0
951} -
952 -
953/*! -
954 \since 4.1 -
955 -
956 Sets the scaled frame size to \a size. -
957 -
958 \sa QImageReader::setScaledSize() -
959*/ -
960void QMovie::setScaledSize(const QSize &size) -
961{ -
962 Q_D(QMovie);
never executed (the execution status of this line is deduced): QMoviePrivate * const d = d_func();
-
963 d->reader->setScaledSize(size);
never executed (the execution status of this line is deduced): d->reader->setScaledSize(size);
-
964}
never executed: }
0
965 -
966/*! -
967 \since 4.1 -
968 -
969 Returns the list of image formats supported by QMovie. -
970 -
971 \sa QImageReader::supportedImageFormats() -
972*/ -
973QList<QByteArray> QMovie::supportedFormats() -
974{ -
975 QList<QByteArray> list = QImageReader::supportedImageFormats();
never executed (the execution status of this line is deduced): QList<QByteArray> list = QImageReader::supportedImageFormats();
-
976 QMutableListIterator<QByteArray> it(list);
never executed (the execution status of this line is deduced): QMutableListIterator<QByteArray> it(list);
-
977 QBuffer buffer;
never executed (the execution status of this line is deduced): QBuffer buffer;
-
978 buffer.open(QIODevice::ReadOnly);
never executed (the execution status of this line is deduced): buffer.open(QIODevice::ReadOnly);
-
979 while (it.hasNext()) {
never evaluated: it.hasNext()
0
980 QImageReader reader(&buffer, it.next());
never executed (the execution status of this line is deduced): QImageReader reader(&buffer, it.next());
-
981 if (!reader.supportsAnimation())
never evaluated: !reader.supportsAnimation()
0
982 it.remove();
never executed: it.remove();
0
983 }
never executed: }
0
984 return list;
never executed: return list;
0
985} -
986 -
987/*! -
988 \property QMovie::cacheMode -
989 \brief the movie's cache mode -
990 -
991 Caching frames can be useful when the underlying animation format handler -
992 that QMovie relies on to decode the animation data does not support -
993 jumping to particular frames in the animation, or even "rewinding" the -
994 animation to the beginning (for looping). Furthermore, if the image data -
995 comes from a sequential device, it is not possible for the underlying -
996 animation handler to seek back to frames whose data has already been read -
997 (making looping altogether impossible). -
998 -
999 To aid in such situations, a QMovie object can be instructed to cache the -
1000 frames, at the added memory cost of keeping the frames in memory for the -
1001 lifetime of the object. -
1002 -
1003 By default, this property is set to \l CacheNone. -
1004 -
1005 \sa QMovie::CacheMode -
1006*/ -
1007 -
1008QMovie::CacheMode QMovie::cacheMode() const -
1009{ -
1010 Q_D(const QMovie);
executed (the execution status of this line is deduced): const QMoviePrivate * const d = d_func();
-
1011 return d->cacheMode;
executed: return d->cacheMode;
Execution Count:2
2
1012} -
1013 -
1014void QMovie::setCacheMode(CacheMode cacheMode) -
1015{ -
1016 Q_D(QMovie);
executed (the execution status of this line is deduced): QMoviePrivate * const d = d_func();
-
1017 d->cacheMode = cacheMode;
executed (the execution status of this line is deduced): d->cacheMode = cacheMode;
-
1018}
executed: }
Execution Count:2
2
1019 -
1020QT_END_NAMESPACE -
1021 -
1022#include "moc_qmovie.cpp" -
1023 -
1024#endif // QT_NO_MOVIE -
1025 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial