OpenCoverage

qquickimagebase.cpp

Absolute File Name:/home/opencoverage/opencoverage/guest-scripts/qtdeclarative/src/qtdeclarative/src/quick/items/qquickimagebase.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtQuick 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 The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/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 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40#include "qquickimagebase_p.h"-
41#include "qquickimagebase_p_p.h"-
42-
43#include <QtGui/qguiapplication.h>-
44#include <QtGui/qscreen.h>-
45#include <QtGui/qicon.h>-
46-
47#include <QtQml/qqmlinfo.h>-
48#include <QtQml/qqmlfile.h>-
49-
50QT_BEGIN_NAMESPACE-
51-
52// This function gives derived classes the chance set the devicePixelRatio-
53// if they're not happy with our implementation of it.-
54bool QQuickImageBasePrivate::updateDevicePixelRatio(qreal targetDevicePixelRatio)-
55{-
56 // QQuickImageProvider and SVG can generate a high resolution image when-
57 // sourceSize is set (this function is only called if it's set).-
58 // If sourceSize is not set then the provider default size will be used, as usual.-
59 bool setDevicePixelRatio = false;-
60 if (url.scheme() == QLatin1String("image")) {
url.scheme() =...tring("image")Description
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qquickimageprovider
  • tst_sharedimage
FALSEevaluated 22 times by 3 tests
Evaluated by:
  • tst_qquickimage
  • tst_qquickshadereffect
  • tst_sharedimage
12-22
61 setDevicePixelRatio = true;-
62 } else {
executed 12 times by 2 tests: end of block
Executed by:
  • tst_qquickimageprovider
  • tst_sharedimage
12
63 QString stringUrl = url.path(QUrl::PrettyDecoded);-
64 if (stringUrl.endsWith(QLatin1String("svg")) ||
stringUrl.ends...String("svg"))Description
TRUEnever evaluated
FALSEevaluated 22 times by 3 tests
Evaluated by:
  • tst_qquickimage
  • tst_qquickshadereffect
  • tst_sharedimage
0-22
65 stringUrl.endsWith(QLatin1String("svgz"))) {
stringUrl.ends...tring("svgz"))Description
TRUEnever evaluated
FALSEevaluated 22 times by 3 tests
Evaluated by:
  • tst_qquickimage
  • tst_qquickshadereffect
  • tst_sharedimage
0-22
66 setDevicePixelRatio = true;-
67 }
never executed: end of block
0
68 }
executed 22 times by 3 tests: end of block
Executed by:
  • tst_qquickimage
  • tst_qquickshadereffect
  • tst_sharedimage
22
69-
70 if (setDevicePixelRatio)
setDevicePixelRatioDescription
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qquickimageprovider
  • tst_sharedimage
FALSEevaluated 22 times by 3 tests
Evaluated by:
  • tst_qquickimage
  • tst_qquickshadereffect
  • tst_sharedimage
12-22
71 devicePixelRatio = targetDevicePixelRatio;
executed 12 times by 2 tests: devicePixelRatio = targetDevicePixelRatio;
Executed by:
  • tst_qquickimageprovider
  • tst_sharedimage
12
72-
73 return setDevicePixelRatio;
executed 34 times by 4 tests: return setDevicePixelRatio;
Executed by:
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickshadereffect
  • tst_sharedimage
34
74}-
75-
76QQuickImageBase::QQuickImageBase(QQuickItem *parent)-
77: QQuickImplicitSizeItem(*(new QQuickImageBasePrivate), parent)-
78{-
79 setFlag(ItemHasContents);-
80}
never executed: end of block
0
81-
82QQuickImageBase::QQuickImageBase(QQuickImageBasePrivate &dd, QQuickItem *parent)-
83: QQuickImplicitSizeItem(dd, parent)-
84{-
85 setFlag(ItemHasContents);-
86}
executed 5624 times by 15 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmlinfo
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitem
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
5624
87-
88QQuickImageBase::~QQuickImageBase()-
89{-
90}-
91-
92QQuickImageBase::Status QQuickImageBase::status() const-
93{-
94 Q_D(const QQuickImageBase);-
95 return d->status;
executed 1341 times by 5 tests: return d->status;
Executed by:
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickshadereffect
1341
96}-
97-
98-
99qreal QQuickImageBase::progress() const-
100{-
101 Q_D(const QQuickImageBase);-
102 return d->progress;
executed 260 times by 4 tests: return d->progress;
Executed by:
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickimage
  • tst_qquickimageprovider
260
103}-
104-
105-
106bool QQuickImageBase::asynchronous() const-
107{-
108 Q_D(const QQuickImageBase);-
109 return d->async;
executed 28 times by 1 test: return d->async;
Executed by:
  • tst_qquickimage
28
110}-
111-
112void QQuickImageBase::setAsynchronous(bool async)-
113{-
114 Q_D(QQuickImageBase);-
115 if (d->async != async) {
d->async != asyncDescription
TRUEevaluated 66 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_sharedimage
FALSEevaluated 22 times by 2 tests
Evaluated by:
  • tst_qquickimage
  • tst_sharedimage
22-66
116 d->async = async;-
117 emit asynchronousChanged();-
118 }
executed 66 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_sharedimage
66
119}
executed 88 times by 5 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_sharedimage
88
120-
121QUrl QQuickImageBase::source() const-
122{-
123 Q_D(const QQuickImageBase);-
124 return d->url;
executed 363 times by 7 tests: return d->url;
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickstates
363
125}-
126-
127void QQuickImageBase::setSource(const QUrl &url)-
128{-
129 Q_D(QQuickImageBase);-
130-
131 if (url == d->url)
url == d->urlDescription
TRUEevaluated 14 times by 1 test
Evaluated by:
  • tst_qquickimage
FALSEevaluated 5440 times by 12 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
14-5440
132 return;
executed 14 times by 1 test: return;
Executed by:
  • tst_qquickimage
14
133-
134 d->url = url;-
135 emit sourceChanged(d->url);-
136-
137 if (isComponentComplete())
isComponentComplete()Description
TRUEevaluated 74 times by 3 tests
Evaluated by:
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickstates
FALSEevaluated 5366 times by 12 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
74-5366
138 load();
executed 74 times by 3 tests: load();
Executed by:
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickstates
74
139}
executed 5440 times by 12 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
5440
140-
141void QQuickImageBase::setSourceSize(const QSize& size)-
142{-
143 Q_D(QQuickImageBase);-
144 if (d->sourcesize == size)
d->sourcesize == sizeDescription
TRUEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qquickimage
  • tst_qquickshadereffect
FALSEevaluated 42 times by 4 tests
Evaluated by:
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickshadereffect
  • tst_sharedimage
12-42
145 return;
executed 12 times by 2 tests: return;
Executed by:
  • tst_qquickimage
  • tst_qquickshadereffect
12
146-
147 d->sourcesize = size;-
148 emit sourceSizeChanged();-
149 if (isComponentComplete())
isComponentComplete()Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickshadereffect
FALSEevaluated 38 times by 4 tests
Evaluated by:
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickshadereffect
  • tst_sharedimage
4-38
150 load();
executed 4 times by 1 test: load();
Executed by:
  • tst_qquickshadereffect
4
151}
executed 42 times by 4 tests: end of block
Executed by:
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickshadereffect
  • tst_sharedimage
42
152-
153QSize QQuickImageBase::sourceSize() const-
154{-
155 Q_D(const QQuickImageBase);-
156-
157 int width = d->sourcesize.width();-
158 int height = d->sourcesize.height();-
159 return QSize(width != -1 ? width : d->pix.width(), height != -1 ? height : d->pix.height());
executed 11286 times by 10 tests: return QSize(width != -1 ? width : d->pix.width(), height != -1 ? height : d->pix.height());
Executed by:
  • tst_examples
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
11286
160}-
161-
162void QQuickImageBase::resetSourceSize()-
163{-
164 setSourceSize(QSize());-
165}
never executed: end of block
0
166-
167bool QQuickImageBase::cache() const-
168{-
169 Q_D(const QQuickImageBase);-
170 return d->cache;
executed 30 times by 2 tests: return d->cache;
Executed by:
  • tst_qquickanimatedimage
  • tst_qquickimage
30
171}-
172-
173void QQuickImageBase::setCache(bool cache)-
174{-
175 Q_D(QQuickImageBase);-
176 if (d->cache == cache)
d->cache == cacheDescription
TRUEevaluated 26 times by 1 test
Evaluated by:
  • tst_qquickimage
FALSEevaluated 24 times by 3 tests
Evaluated by:
  • tst_qquickanimatedimage
  • tst_qquickimage
  • tst_sharedimage
24-26
177 return;
executed 26 times by 1 test: return;
Executed by:
  • tst_qquickimage
26
178-
179 d->cache = cache;-
180 emit cacheChanged();-
181 if (isComponentComplete())
isComponentComplete()Description
TRUEnever evaluated
FALSEevaluated 24 times by 3 tests
Evaluated by:
  • tst_qquickanimatedimage
  • tst_qquickimage
  • tst_sharedimage
0-24
182 load();
never executed: load();
0
183}
executed 24 times by 3 tests: end of block
Executed by:
  • tst_qquickanimatedimage
  • tst_qquickimage
  • tst_sharedimage
24
184-
185QImage QQuickImageBase::image() const-
186{-
187 Q_D(const QQuickImageBase);-
188 return d->pix.image();
executed 84 times by 1 test: return d->pix.image();
Executed by:
  • tst_sharedimage
84
189}-
190-
191void QQuickImageBase::setMirror(bool mirror)-
192{-
193 Q_D(QQuickImageBase);-
194 if (mirror == d->mirror)
mirror == d->mirrorDescription
TRUEnever evaluated
FALSEevaluated 24 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickimage
0-24
195 return;
never executed: return;
0
196-
197 d->mirror = mirror;-
198-
199 if (isComponentComplete())
isComponentComplete()Description
TRUEevaluated 22 times by 3 tests
Evaluated by:
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickimage
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_examples
2-22
200 update();
executed 22 times by 3 tests: update();
Executed by:
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickimage
22
201-
202 emit mirrorChanged();-
203}
executed 24 times by 4 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickimage
24
204-
205bool QQuickImageBase::mirror() const-
206{-
207 Q_D(const QQuickImageBase);-
208 return d->mirror;
never executed: return d->mirror;
0
209}-
210-
211void QQuickImageBase::load()-
212{-
213 Q_D(QQuickImageBase);-
214-
215 if (d->url.isEmpty()) {
d->url.isEmpty()Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickimage
FALSEevaluated 5444 times by 12 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
8-5444
216 d->pix.clear(this);-
217 if (d->progress != 0.0) {
d->progress != 0.0Description
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickimage
FALSEnever evaluated
0-8
218 d->progress = 0.0;-
219 emit progressChanged(d->progress);-
220 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickimage
8
221 pixmapChange();-
222 d->status = Null;-
223 emit statusChanged(d->status);-
224-
225 if (sourceSize() != d->oldSourceSize) {
sourceSize() !...>oldSourceSizeDescription
TRUEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickimage
FALSEnever evaluated
0-8
226 d->oldSourceSize = sourceSize();-
227 emit sourceSizeChanged();-
228 }
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickimage
8
229 if (autoTransform() != d->oldAutoTransform) {
autoTransform(...dAutoTransformDescription
TRUEnever evaluated
FALSEevaluated 8 times by 1 test
Evaluated by:
  • tst_qquickimage
0-8
230 d->oldAutoTransform = autoTransform();-
231 emitAutoTransformBaseChanged();-
232 }
never executed: end of block
0
233 update();-
234-
235 } else {
executed 8 times by 1 test: end of block
Executed by:
  • tst_qquickimage
8
236 QQuickPixmap::Options options;-
237 if (d->async)
d->asyncDescription
TRUEevaluated 66 times by 4 tests
Evaluated by:
  • tst_examples
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_sharedimage
FALSEevaluated 5378 times by 12 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
66-5378
238 options |= QQuickPixmap::Asynchronous;
executed 66 times by 4 tests: options |= QQuickPixmap::Asynchronous;
Executed by:
  • tst_examples
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_sharedimage
66
239 if (d->cache)
d->cacheDescription
TRUEevaluated 5402 times by 11 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
FALSEevaluated 42 times by 2 tests
Evaluated by:
  • tst_qquickimage
  • tst_sharedimage
42-5402
240 options |= QQuickPixmap::Cache;
executed 5402 times by 11 tests: options |= QQuickPixmap::Cache;
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
5402
241 d->pix.clear(this);-
242-
243 const qreal targetDevicePixelRatio = (window() ? window()->effectiveDevicePixelRatio() : qApp->devicePixelRatio());
window()Description
TRUEevaluated 2384 times by 2 tests
Evaluated by:
  • tst_examples
  • tst_qquickimage
FALSEevaluated 3060 times by 12 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
2384-3060
244 d->devicePixelRatio = 1.0;-
245-
246 QUrl loadUrl = d->url;-
247-
248 bool updatedDevicePixelRatio = false;-
249 if (d->sourcesize.isValid())
d->sourcesize.isValid()Description
TRUEevaluated 34 times by 4 tests
Evaluated by:
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickshadereffect
  • tst_sharedimage
FALSEevaluated 5410 times by 12 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
34-5410
250 updatedDevicePixelRatio = d->updateDevicePixelRatio(targetDevicePixelRatio);
executed 34 times by 4 tests: updatedDevicePixelRatio = d->updateDevicePixelRatio(targetDevicePixelRatio);
Executed by:
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickshadereffect
  • tst_sharedimage
34
251-
252 if (!updatedDevicePixelRatio) {
!updatedDevicePixelRatioDescription
TRUEevaluated 5432 times by 12 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
FALSEevaluated 12 times by 2 tests
Evaluated by:
  • tst_qquickimageprovider
  • tst_sharedimage
12-5432
253 // (possible) local file: loadUrl and d->devicePixelRatio will be modified if-
254 // an "@2x" file is found.-
255 resolve2xLocalFile(d->url, targetDevicePixelRatio, &loadUrl, &d->devicePixelRatio);-
256 }
executed 5432 times by 12 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
5432
257-
258 d->pix.load(qmlEngine(this), loadUrl, d->sourcesize * d->devicePixelRatio, options, d->providerOptions);-
259-
260 if (d->pix.isLoading()) {
d->pix.isLoading()Description
TRUEevaluated 126 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_sharedimage
FALSEevaluated 5318 times by 10 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
126-5318
261 if (d->progress != 0.0) {
d->progress != 0.0Description
TRUEevaluated 10 times by 1 test
Evaluated by:
  • tst_qquickimage
FALSEevaluated 116 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_sharedimage
10-116
262 d->progress = 0.0;-
263 emit progressChanged(d->progress);-
264 }
executed 10 times by 1 test: end of block
Executed by:
  • tst_qquickimage
10
265 if (d->status != Loading) {
d->status != LoadingDescription
TRUEevaluated 126 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_sharedimage
FALSEnever evaluated
0-126
266 d->status = Loading;-
267 emit statusChanged(d->status);-
268 }
executed 126 times by 6 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_sharedimage
126
269-
270 static int thisRequestProgress = -1;-
271 static int thisRequestFinished = -1;-
272 if (thisRequestProgress == -1) {
thisRequestProgress == -1Description
TRUEevaluated 12 times by 6 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_sharedimage
FALSEevaluated 114 times by 5 tests
Evaluated by:
  • tst_examples
  • tst_qquickanchors
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_sharedimage
12-114
273 thisRequestProgress =-
274 QQuickImageBase::staticMetaObject.indexOfSlot("requestProgress(qint64,qint64)");-
275 thisRequestFinished =-
276 QQuickImageBase::staticMetaObject.indexOfSlot("requestFinished()");-
277 }
executed 12 times by 6 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_sharedimage
12
278-
279 d->pix.connectFinished(this, thisRequestFinished);-
280 d->pix.connectDownloadProgress(this, thisRequestProgress);-
281 update(); //pixmap may have invalidated texture, updatePaintNode needs to be called before the next repaint-
282 } else {
executed 126 times by 6 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_sharedimage
126
283 requestFinished();-
284 }
executed 5318 times by 10 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
5318
285 }-
286}-
287-
288void QQuickImageBase::requestFinished()-
289{-
290 Q_D(QQuickImageBase);-
291-
292 if (d->pix.isError()) {
d->pix.isError()Description
TRUEevaluated 92 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickimage
  • tst_qquickimageprovider
FALSEevaluated 5314 times by 10 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
92-5314
293 qmlWarning(this) << d->pix.error();-
294 d->pix.clear(this);-
295 d->status = Error;-
296 if (d->progress != 0.0) {
d->progress != 0.0Description
TRUEevaluated 4 times by 1 test
Evaluated by:
  • tst_qquickimageprovider
FALSEevaluated 88 times by 3 tests
Evaluated by:
  • tst_examples
  • tst_qquickimage
  • tst_qquickimageprovider
4-88
297 d->progress = 0.0;-
298 emit progressChanged(d->progress);-
299 }
executed 4 times by 1 test: end of block
Executed by:
  • tst_qquickimageprovider
4
300 } else {
executed 92 times by 3 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickimage
  • tst_qquickimageprovider
92
301 d->status = Ready;-
302 if (d->progress != 1.0) {
d->progress != 1.0Description
TRUEevaluated 5254 times by 10 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
FALSEevaluated 60 times by 2 tests
Evaluated by:
  • tst_qquickimage
  • tst_qquickshadereffect
60-5254
303 d->progress = 1.0;-
304 emit progressChanged(d->progress);-
305 }
executed 5254 times by 10 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
5254
306 }
executed 5314 times by 10 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
5314
307 pixmapChange();-
308 emit statusChanged(d->status);-
309 if (sourceSize() != d->oldSourceSize) {
sourceSize() !...>oldSourceSizeDescription
TRUEevaluated 5386 times by 10 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
FALSEevaluated 20 times by 2 tests
Evaluated by:
  • tst_qquickimage
  • tst_qquickshadereffect
20-5386
310 d->oldSourceSize = sourceSize();-
311 emit sourceSizeChanged();-
312 }
executed 5386 times by 10 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
5386
313 if (autoTransform() != d->oldAutoTransform) {
autoTransform(...dAutoTransformDescription
TRUEnever evaluated
FALSEevaluated 5406 times by 10 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
0-5406
314 d->oldAutoTransform = autoTransform();-
315 emitAutoTransformBaseChanged();-
316 }
never executed: end of block
0
317 update();-
318}
executed 5406 times by 10 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
5406
319-
320void QQuickImageBase::requestProgress(qint64 received, qint64 total)-
321{-
322 Q_D(QQuickImageBase);-
323 if (d->status == Loading && total > 0) {
d->status == LoadingDescription
TRUEevaluated 38 times by 3 tests
Evaluated by:
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickimage
FALSEnever evaluated
total > 0Description
TRUEevaluated 36 times by 3 tests
Evaluated by:
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickimage
FALSEevaluated 2 times by 1 test
Evaluated by:
  • tst_qquickborderimage
0-38
324 d->progress = qreal(received)/total;-
325 emit progressChanged(d->progress);-
326 }
executed 36 times by 3 tests: end of block
Executed by:
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickimage
36
327}
executed 38 times by 3 tests: end of block
Executed by:
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickimage
38
328-
329void QQuickImageBase::itemChange(ItemChange change, const ItemChangeData &value)-
330{-
331 Q_D(QQuickImageBase);-
332 // If the screen DPI changed, reload image.-
333 if (change == ItemDevicePixelRatioHasChanged && value.realValue != d->devicePixelRatio) {
change == Item...atioHasChangedDescription
TRUEnever evaluated
FALSEevaluated 48482 times by 13 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitem
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
value.realValu...vicePixelRatioDescription
TRUEnever evaluated
FALSEnever evaluated
0-48482
334 // ### how can we get here with !qmlEngine(this)? that implies-
335 // itemChange() on an item pending deletion, which seems strange.-
336 if (qmlEngine(this) && isComponentComplete() && d->url.isValid()) {
qmlEngine(this)Description
TRUEnever evaluated
FALSEnever evaluated
isComponentComplete()Description
TRUEnever evaluated
FALSEnever evaluated
d->url.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
337 load();-
338 }
never executed: end of block
0
339 }
never executed: end of block
0
340 QQuickItem::itemChange(change, value);-
341}
executed 48482 times by 13 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitem
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
48482
342-
343void QQuickImageBase::componentComplete()-
344{-
345 Q_D(QQuickImageBase);-
346 QQuickItem::componentComplete();-
347 if (d->url.isValid())
d->url.isValid()Description
TRUEevaluated 5490 times by 12 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
FALSEevaluated 44 times by 7 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmlinfo
  • tst_qquickborderimage
  • tst_qquickimage
  • tst_qquickitem
  • tst_qquickstates
44-5490
348 load();
executed 5490 times by 12 tests: load();
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
5490
349}
executed 5534 times by 14 tests: end of block
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qqmlinfo
  • tst_qquickanchors
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitem
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
5534
350-
351void QQuickImageBase::pixmapChange()-
352{-
353 Q_D(QQuickImageBase);-
354 setImplicitSize(d->pix.width() / d->devicePixelRatio, d->pix.height() / d->devicePixelRatio);-
355}
executed 5980 times by 11 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
5980
356-
357void QQuickImageBase::resolve2xLocalFile(const QUrl &url, qreal targetDevicePixelRatio, QUrl *sourceUrl, qreal *sourceDevicePixelRatio)-
358{-
359 Q_ASSERT(sourceUrl);-
360 Q_ASSERT(sourceDevicePixelRatio);-
361-
362 // Bail out if "@2x" image loading is disabled, don't change the source url or devicePixelRatio.-
363 static const bool disable2xImageLoading = !qEnvironmentVariableIsEmpty("QT_HIGHDPI_DISABLE_2X_IMAGE_LOADING");-
364 if (disable2xImageLoading)
disable2xImageLoadingDescription
TRUEnever evaluated
FALSEevaluated 5802 times by 17 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageparticle
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickspritegoal
  • tst_qquickspritesequence
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
0-5802
365 return;
never executed: return;
0
366-
367 const QString localFile = QQmlFile::urlToLocalFileOrQrc(url);-
368-
369 // Non-local file path: @2x loading is not supported.-
370 if (localFile.isEmpty())
localFile.isEmpty()Description
TRUEevaluated 192 times by 9 tests
Evaluated by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickborderimage
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_sharedimage
FALSEevaluated 5610 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickspritegoal
  • tst_qquickspritesequence
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
192-5610
371 return;
executed 192 times by 9 tests: return;
Executed by:
  • tst_examples
  • tst_qqmlecmascript
  • tst_qquickanchors
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickborderimage
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_sharedimage
192
372-
373 // Special case: the url in the QML source refers directly to an "@2x" file.-
374 int atLocation = localFile.lastIndexOf(QLatin1Char('@'));-
375 if (atLocation > 0 && atLocation + 3 < localFile.size()) {
atLocation > 0Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickimage
FALSEevaluated 5590 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickspritegoal
  • tst_qquickspritesequence
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
atLocation + 3...calFile.size()Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickimage
FALSEnever evaluated
0-5590
376 if (localFile[atLocation + 1].isDigit()
localFile[atLo...+ 1].isDigit()Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickimage
FALSEnever evaluated
0-20
377 && localFile[atLocation + 2] == QLatin1Char('x')
localFile[atLo...atin1Char('x')Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickimage
FALSEnever evaluated
0-20
378 && localFile[atLocation + 3] == QLatin1Char('.')) {
localFile[atLo...atin1Char('.')Description
TRUEevaluated 20 times by 1 test
Evaluated by:
  • tst_qquickimage
FALSEnever evaluated
0-20
379 *sourceDevicePixelRatio = localFile[atLocation + 1].digitValue();-
380 return;
executed 20 times by 1 test: return;
Executed by:
  • tst_qquickimage
20
381 }-
382 }
never executed: end of block
0
383-
384 // Look for an @2x version-
385 QString localFileX = qt_findAtNxFile(localFile, targetDevicePixelRatio, sourceDevicePixelRatio);-
386 if (localFileX != localFile)
localFileX != localFileDescription
TRUEnever evaluated
FALSEevaluated 5590 times by 14 tests
Evaluated by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickspritegoal
  • tst_qquickspritesequence
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
0-5590
387 *sourceUrl = QUrl::fromLocalFile(localFileX);
never executed: *sourceUrl = QUrl::fromLocalFile(localFileX);
0
388}
executed 5590 times by 14 tests: end of block
Executed by:
  • tst_examples
  • tst_qquickanimatedimage
  • tst_qquickanimatedsprite
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageparticle
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickspritegoal
  • tst_qquickspritesequence
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
5590
389-
390bool QQuickImageBase::autoTransform() const-
391{-
392 Q_D(const QQuickImageBase);-
393 if (d->providerOptions.autoTransform() == QQuickImageProviderOptions::UsePluginDefaultTransform)
d->providerOpt...faultTransformDescription
TRUEevaluated 5414 times by 10 tests
Evaluated by:
  • tst_examples
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
FALSEnever evaluated
0-5414
394 return d->pix.autoTransform() == QQuickImageProviderOptions::ApplyTransform;
executed 5414 times by 10 tests: return d->pix.autoTransform() == QQuickImageProviderOptions::ApplyTransform;
Executed by:
  • tst_examples
  • tst_qquickborderimage
  • tst_qquickcustomparticle
  • tst_qquickimage
  • tst_qquickimageprovider
  • tst_qquickitemparticle
  • tst_qquickshadereffect
  • tst_qquickstates
  • tst_scenegraph
  • tst_sharedimage
5414
395 return d->providerOptions.autoTransform() == QQuickImageProviderOptions::ApplyTransform;
never executed: return d->providerOptions.autoTransform() == QQuickImageProviderOptions::ApplyTransform;
0
396}-
397-
398void QQuickImageBase::setAutoTransform(bool transform)-
399{-
400 Q_D(QQuickImageBase);-
401 if (d->providerOptions.autoTransform() != QQuickImageProviderOptions::UsePluginDefaultTransform &&
d->providerOpt...faultTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
402 transform == (d->providerOptions.autoTransform() == QQuickImageProviderOptions::ApplyTransform))
transform == (...pplyTransform)Description
TRUEnever evaluated
FALSEnever evaluated
0
403 return;
never executed: return;
0
404 d->providerOptions.setAutoTransform(transform ? QQuickImageProviderOptions::ApplyTransform : QQuickImageProviderOptions::DoNotApplyTransform);-
405 emitAutoTransformBaseChanged();-
406}
never executed: end of block
0
407-
408QT_END_NAMESPACE-
409-
410#include "moc_qquickimagebase_p.cpp"-
Source codeSwitch to Preprocessed file

Generated by Squish Coco 4.2.0