image/qicon.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#include "qicon.h" -
43#include "qicon_p.h" -
44#include "qiconengine.h" -
45#include "qiconengineplugin.h" -
46#include "private/qfactoryloader_p.h" -
47#include "private/qiconloader_p.h" -
48#include "qpainter.h" -
49#include "qfileinfo.h" -
50#include "qpixmapcache.h" -
51#include "qvariant.h" -
52#include "qcache.h" -
53#include "qdebug.h" -
54#include "qpalette.h" -
55 -
56#ifdef Q_WS_MAC -
57#include <private/qt_mac_p.h> -
58#include <private/qt_cocoa_helpers_mac_p.h> -
59#endif -
60 -
61#include "private/qhexstring_p.h" -
62#include "private/qguiapplication_p.h" -
63 -
64#ifndef QT_NO_ICON -
65QT_BEGIN_NAMESPACE -
66 -
67/*! -
68 \enum QIcon::Mode -
69 -
70 This enum type describes the mode for which a pixmap is intended -
71 to be used. The currently defined modes are: -
72 -
73 \value Normal -
74 Display the pixmap when the user is -
75 not interacting with the icon, but the -
76 functionality represented by the icon is available. -
77 \value Disabled -
78 Display the pixmap when the -
79 functionality represented by the icon is not available. -
80 \value Active -
81 Display the pixmap when the -
82 functionality represented by the icon is available and -
83 the user is interacting with the icon, for example, moving the -
84 mouse over it or clicking it. -
85 \value Selected -
86 Display the pixmap when the item represented by the icon is -
87 selected. -
88*/ -
89 -
90/*! -
91 \enum QIcon::State -
92 -
93 This enum describes the state for which a pixmap is intended to be -
94 used. The \e state can be: -
95 -
96 \value Off Display the pixmap when the widget is in an "off" state -
97 \value On Display the pixmap when the widget is in an "on" state -
98*/ -
99 -
100static QBasicAtomicInt serialNumCounter = Q_BASIC_ATOMIC_INITIALIZER(1); -
101 -
102static void qt_cleanup_icon_cache(); -
103namespace { -
104 struct IconCache : public QCache<QString, QIcon> -
105 { -
106 IconCache() -
107 { -
108 // ### note: won't readd if QApplication is re-created! -
109 qAddPostRoutine(qt_cleanup_icon_cache);
executed (the execution status of this line is deduced): qAddPostRoutine(qt_cleanup_icon_cache);
-
110 }
executed: }
Execution Count:1
1
111 }; -
112} -
113 -
114Q_GLOBAL_STATIC(IconCache, qtIconCache)
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:21
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:20
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-21
115 -
116static void qt_cleanup_icon_cache() -
117{ -
118 qtIconCache()->clear();
executed (the execution status of this line is deduced): qtIconCache()->clear();
-
119}
executed: }
Execution Count:1
1
120 -
121QIconPrivate::QIconPrivate() -
122 : engine(0), ref(1), -
123 serialNum(serialNumCounter.fetchAndAddRelaxed(1)), -
124 detach_no(0) -
125{ -
126}
executed: }
Execution Count:4542
4542
127 -
128QPixmapIconEngine::QPixmapIconEngine() -
129{ -
130} -
131 -
132QPixmapIconEngine::QPixmapIconEngine(const QPixmapIconEngine &other) -
133 : QIconEngine(other), pixmaps(other.pixmaps) -
134{ -
135}
executed: }
Execution Count:5
5
136 -
137QPixmapIconEngine::~QPixmapIconEngine() -
138{ -
139} -
140 -
141void QPixmapIconEngine::paint(QPainter *painter, const QRect &rect, QIcon::Mode mode, QIcon::State state) -
142{ -
143 QSize pixmapSize = rect.size();
executed (the execution status of this line is deduced): QSize pixmapSize = rect.size();
-
144#if defined(Q_WS_MAC) -
145 pixmapSize *= qt_mac_get_scalefactor(); -
146#endif -
147 painter->drawPixmap(rect, pixmap(pixmapSize, mode, state));
executed (the execution status of this line is deduced): painter->drawPixmap(rect, pixmap(pixmapSize, mode, state));
-
148}
executed: }
Execution Count:2587
2587
149 -
150static inline int area(const QSize &s) { return s.width() * s.height(); }
executed: return s.width() * s.height();
Execution Count:211485
211485
151 -
152// returns the smallest of the two that is still larger than or equal to size. -
153static QPixmapIconEngineEntry *bestSizeMatch( const QSize &size, QPixmapIconEngineEntry *pa, QPixmapIconEngineEntry *pb) -
154{ -
155 int s = area(size);
executed (the execution status of this line is deduced): int s = area(size);
-
156 if (pa->size == QSize() && pa->pixmap.isNull()) {
partially evaluated: pa->size == QSize()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:70495
never evaluated: pa->pixmap.isNull()
0-70495
157 pa->pixmap = QPixmap(pa->fileName);
never executed (the execution status of this line is deduced): pa->pixmap = QPixmap(pa->fileName);
-
158 pa->size = pa->pixmap.size();
never executed (the execution status of this line is deduced): pa->size = pa->pixmap.size();
-
159 }
never executed: }
0
160 int a = area(pa->size);
executed (the execution status of this line is deduced): int a = area(pa->size);
-
161 if (pb->size == QSize() && pb->pixmap.isNull()) {
partially evaluated: pb->size == QSize()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:70495
never evaluated: pb->pixmap.isNull()
0-70495
162 pb->pixmap = QPixmap(pb->fileName);
never executed (the execution status of this line is deduced): pb->pixmap = QPixmap(pb->fileName);
-
163 pb->size = pb->pixmap.size();
never executed (the execution status of this line is deduced): pb->size = pb->pixmap.size();
-
164 }
never executed: }
0
165 int b = area(pb->size);
executed (the execution status of this line is deduced): int b = area(pb->size);
-
166 int res = a;
executed (the execution status of this line is deduced): int res = a;
-
167 if (qMin(a,b) >= s)
evaluated: qMin(a,b) >= s
TRUEFALSE
yes
Evaluation Count:69486
yes
Evaluation Count:1009
1009-69486
168 res = qMin(a,b);
executed: res = qMin(a,b);
Execution Count:69486
69486
169 else -
170 res = qMax(a,b);
executed: res = qMax(a,b);
Execution Count:1009
1009
171 if (res == a)
evaluated: res == a
TRUEFALSE
yes
Evaluation Count:1015
yes
Evaluation Count:69480
1015-69480
172 return pa;
executed: return pa;
Execution Count:1015
1015
173 return pb;
executed: return pb;
Execution Count:69480
69480
174} -
175 -
176QPixmapIconEngineEntry *QPixmapIconEngine::tryMatch(const QSize &size, QIcon::Mode mode, QIcon::State state) -
177{ -
178 QPixmapIconEngineEntry *pe = 0;
executed (the execution status of this line is deduced): QPixmapIconEngineEntry *pe = 0;
-
179 for (int i = 0; i < pixmaps.count(); ++i)
evaluated: i < pixmaps.count()
TRUEFALSE
yes
Evaluation Count:132733
yes
Evaluation Count:47108
47108-132733
180 if (pixmaps.at(i).mode == mode && pixmaps.at(i).state == state) {
evaluated: pixmaps.at(i).mode == mode
TRUEFALSE
yes
Evaluation Count:131168
yes
Evaluation Count:1565
evaluated: pixmaps.at(i).state == state
TRUEFALSE
yes
Evaluation Count:114691
yes
Evaluation Count:16477
1565-131168
181 if (pe)
evaluated: pe
TRUEFALSE
yes
Evaluation Count:70495
yes
Evaluation Count:44196
44196-70495
182 pe = bestSizeMatch(size, &pixmaps[i], pe);
executed: pe = bestSizeMatch(size, &pixmaps[i], pe);
Execution Count:70495
70495
183 else -
184 pe = &pixmaps[i];
executed: pe = &pixmaps[i];
Execution Count:44196
44196
185 } -
186 return pe;
executed: return pe;
Execution Count:47108
47108
187} -
188 -
189 -
190QPixmapIconEngineEntry *QPixmapIconEngine::bestMatch(const QSize &size, QIcon::Mode mode, QIcon::State state, bool sizeOnly) -
191{ -
192 QPixmapIconEngineEntry *pe = tryMatch(size, mode, state);
executed (the execution status of this line is deduced): QPixmapIconEngineEntry *pe = tryMatch(size, mode, state);
-
193 while (!pe){
evaluated: !pe
TRUEFALSE
yes
Evaluation Count:227
yes
Evaluation Count:43962
227-43962
194 QIcon::State oppositeState = (state == QIcon::On) ? QIcon::Off : QIcon::On;
evaluated: (state == QIcon::On)
TRUEFALSE
yes
Evaluation Count:58
yes
Evaluation Count:169
58-169
195 if (mode == QIcon::Disabled || mode == QIcon::Selected) {
evaluated: mode == QIcon::Disabled
TRUEFALSE
yes
Evaluation Count:81
yes
Evaluation Count:146
evaluated: mode == QIcon::Selected
TRUEFALSE
yes
Evaluation Count:85
yes
Evaluation Count:61
61-146
196 QIcon::Mode oppositeMode = (mode == QIcon::Disabled) ? QIcon::Selected : QIcon::Disabled;
evaluated: (mode == QIcon::Disabled)
TRUEFALSE
yes
Evaluation Count:81
yes
Evaluation Count:85
81-85
197 if ((pe = tryMatch(size, QIcon::Normal, state)))
evaluated: (pe = tryMatch(size, QIcon::Normal, state))
TRUEFALSE
yes
Evaluation Count:142
yes
Evaluation Count:24
24-142
198 break;
executed: break;
Execution Count:142
142
199 if ((pe = tryMatch(size, QIcon::Active, state)))
evaluated: (pe = tryMatch(size, QIcon::Active, state))
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:20
4-20
200 break;
executed: break;
Execution Count:4
4
201 if ((pe = tryMatch(size, mode, oppositeState)))
evaluated: (pe = tryMatch(size, mode, oppositeState))
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:16
4-16
202 break;
executed: break;
Execution Count:4
4
203 if ((pe = tryMatch(size, QIcon::Normal, oppositeState)))
evaluated: (pe = tryMatch(size, QIcon::Normal, oppositeState))
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:12
4-12
204 break;
executed: break;
Execution Count:4
4
205 if ((pe = tryMatch(size, QIcon::Active, oppositeState)))
evaluated: (pe = tryMatch(size, QIcon::Active, oppositeState))
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:8
4-8
206 break;
executed: break;
Execution Count:4
4
207 if ((pe = tryMatch(size, oppositeMode, state)))
evaluated: (pe = tryMatch(size, oppositeMode, state))
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4
4
208 break;
executed: break;
Execution Count:4
4
209 if ((pe = tryMatch(size, oppositeMode, oppositeState)))
partially evaluated: (pe = tryMatch(size, oppositeMode, oppositeState))
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
210 break;
executed: break;
Execution Count:4
4
211 } else {
never executed: }
0
212 QIcon::Mode oppositeMode = (mode == QIcon::Normal) ? QIcon::Active : QIcon::Normal;
evaluated: (mode == QIcon::Normal)
TRUEFALSE
yes
Evaluation Count:44
yes
Evaluation Count:17
17-44
213 if ((pe = tryMatch(size, oppositeMode, state)))
evaluated: (pe = tryMatch(size, oppositeMode, state))
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:54
7-54
214 break;
executed: break;
Execution Count:7
7
215 if ((pe = tryMatch(size, mode, oppositeState)))
evaluated: (pe = tryMatch(size, mode, oppositeState))
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:20
20-34
216 break;
executed: break;
Execution Count:34
34
217 if ((pe = tryMatch(size, oppositeMode, oppositeState)))
evaluated: (pe = tryMatch(size, oppositeMode, oppositeState))
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:16
4-16
218 break;
executed: break;
Execution Count:4
4
219 if ((pe = tryMatch(size, QIcon::Disabled, state)))
evaluated: (pe = tryMatch(size, QIcon::Disabled, state))
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:12
4-12
220 break;
executed: break;
Execution Count:4
4
221 if ((pe = tryMatch(size, QIcon::Selected, state)))
evaluated: (pe = tryMatch(size, QIcon::Selected, state))
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:8
4-8
222 break;
executed: break;
Execution Count:4
4
223 if ((pe = tryMatch(size, QIcon::Disabled, oppositeState)))
evaluated: (pe = tryMatch(size, QIcon::Disabled, oppositeState))
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:4
4
224 break;
executed: break;
Execution Count:4
4
225 if ((pe = tryMatch(size, QIcon::Selected, oppositeState)))
partially evaluated: (pe = tryMatch(size, QIcon::Selected, oppositeState))
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
226 break;
executed: break;
Execution Count:4
4
227 }
never executed: }
0
228 -
229 if (!pe)
never evaluated: !pe
0
230 return pe;
never executed: return pe;
0
231 }
never executed: }
0
232 -
233 if (sizeOnly ? (pe->size.isNull() || !pe->size.isValid()) : pe->pixmap.isNull()) {
evaluated: sizeOnly
TRUEFALSE
yes
Evaluation Count:39985
yes
Evaluation Count:4204
4204-39985
234 pe->pixmap = QPixmap(pe->fileName);
executed (the execution status of this line is deduced): pe->pixmap = QPixmap(pe->fileName);
-
235 if (!pe->pixmap.isNull())
evaluated: !pe->pixmap.isNull()
TRUEFALSE
yes
Evaluation Count:330
yes
Evaluation Count:6
6-330
236 pe->size = pe->pixmap.size();
executed: pe->size = pe->pixmap.size();
Execution Count:330
330
237 }
executed: }
Execution Count:336
336
238 -
239 return pe;
executed: return pe;
Execution Count:44189
44189
240} -
241 -
242QPixmap QPixmapIconEngine::pixmap(const QSize &size, QIcon::Mode mode, QIcon::State state) -
243{ -
244 QPixmap pm;
executed (the execution status of this line is deduced): QPixmap pm;
-
245 QPixmapIconEngineEntry *pe = bestMatch(size, mode, state, false);
executed (the execution status of this line is deduced): QPixmapIconEngineEntry *pe = bestMatch(size, mode, state, false);
-
246 if (pe)
partially evaluated: pe
TRUEFALSE
yes
Evaluation Count:4204
no
Evaluation Count:0
0-4204
247 pm = pe->pixmap;
executed: pm = pe->pixmap;
Execution Count:4204
4204
248 -
249 if (pm.isNull()) {
evaluated: pm.isNull()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4202
2-4202
250 int idx = pixmaps.count();
executed (the execution status of this line is deduced): int idx = pixmaps.count();
-
251 while (--idx >= 0) {
partially evaluated: --idx >= 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
252 if (pe == &pixmaps[idx]) {
partially evaluated: pe == &pixmaps[idx]
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
253 pixmaps.remove(idx);
executed (the execution status of this line is deduced): pixmaps.remove(idx);
-
254 break;
executed: break;
Execution Count:2
2
255 } -
256 }
never executed: }
0
257 if (pixmaps.isEmpty())
evaluated: pixmaps.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
258 return pm;
executed: return pm;
Execution Count:1
1
259 else -
260 return pixmap(size, mode, state);
executed: return pixmap(size, mode, state);
Execution Count:1
1
261 } -
262 -
263 QSize actualSize = pm.size();
executed (the execution status of this line is deduced): QSize actualSize = pm.size();
-
264 if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height()))
partially evaluated: !actualSize.isNull()
TRUEFALSE
yes
Evaluation Count:4202
no
Evaluation Count:0
evaluated: actualSize.width() > size.width()
TRUEFALSE
yes
Evaluation Count:305
yes
Evaluation Count:3897
evaluated: actualSize.height() > size.height()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:3892
0-4202
265 actualSize.scale(size, Qt::KeepAspectRatio);
executed: actualSize.scale(size, Qt::KeepAspectRatio);
Execution Count:310
310
266 -
267 QString key = QLatin1String("qt_")
executed (the execution status of this line is deduced): QString key = QLatin1String("qt_")
-
268 % HexString<quint64>(pm.cacheKey())
executed (the execution status of this line is deduced): % HexString<quint64>(pm.cacheKey())
-
269 % HexString<uint>(pe->mode)
executed (the execution status of this line is deduced): % HexString<uint>(pe->mode)
-
270 % HexString<quint64>(QGuiApplication::palette().cacheKey())
executed (the execution status of this line is deduced): % HexString<quint64>(QGuiApplication::palette().cacheKey())
-
271 % HexString<uint>(actualSize.width())
executed (the execution status of this line is deduced): % HexString<uint>(actualSize.width())
-
272 % HexString<uint>(actualSize.height());
executed (the execution status of this line is deduced): % HexString<uint>(actualSize.height());
-
273 -
274 if (mode == QIcon::Active) {
evaluated: mode == QIcon::Active
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:4183
19-4183
275 if (QPixmapCache::find(key % HexString<uint>(mode), pm))
evaluated: QPixmapCache::find(key % HexString<uint>(mode), pm)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:15
4-15
276 return pm; // horray
executed: return pm;
Execution Count:4
4
277 if (QPixmapCache::find(key % HexString<uint>(QIcon::Normal), pm)) {
evaluated: QPixmapCache::find(key % HexString<uint>(QIcon::Normal), pm)
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:4
4-11
278 QPixmap active = pm;
executed (the execution status of this line is deduced): QPixmap active = pm;
-
279 if (QGuiApplication *guiApp = qobject_cast<QGuiApplication *>(qApp))
partially evaluated: QGuiApplication *guiApp = qobject_cast<QGuiApplication *>((static_cast<QGuiApplication *>(QCoreApplication::instance())))
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
280 active = static_cast<QGuiApplicationPrivate*>(QObjectPrivate::get(guiApp))->applyQIconStyleHelper(QIcon::Active, pm);
executed: active = static_cast<QGuiApplicationPrivate*>(QObjectPrivate::get(guiApp))->applyQIconStyleHelper(QIcon::Active, pm);
Execution Count:11
11
281 if (pm.cacheKey() == active.cacheKey())
partially evaluated: pm.cacheKey() == active.cacheKey()
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
282 return pm;
executed: return pm;
Execution Count:11
11
283 }
never executed: }
0
284 }
executed: }
Execution Count:4
4
285 -
286 if (!QPixmapCache::find(key % HexString<uint>(mode), pm)) {
evaluated: !QPixmapCache::find(key % HexString<uint>(mode), pm)
TRUEFALSE
yes
Evaluation Count:1168
yes
Evaluation Count:3019
1168-3019
287 if (pm.size() != actualSize)
evaluated: pm.size() != actualSize
TRUEFALSE
yes
Evaluation Count:87
yes
Evaluation Count:1081
87-1081
288 pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
executed: pm = pm.scaled(actualSize, Qt::IgnoreAspectRatio, Qt::SmoothTransformation);
Execution Count:87
87
289 if (pe->mode != mode && mode != QIcon::Normal) {
evaluated: pe->mode != mode
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:1128
evaluated: mode != QIcon::Normal
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:6
6-1128
290 QPixmap generated = pm;
executed (the execution status of this line is deduced): QPixmap generated = pm;
-
291 if (QGuiApplication *guiApp = qobject_cast<QGuiApplication *>(qApp))
partially evaluated: QGuiApplication *guiApp = qobject_cast<QGuiApplication *>((static_cast<QGuiApplication *>(QCoreApplication::instance())))
TRUEFALSE
yes
Evaluation Count:34
no
Evaluation Count:0
0-34
292 generated = static_cast<QGuiApplicationPrivate*>(QObjectPrivate::get(guiApp))->applyQIconStyleHelper(mode, pm);
executed: generated = static_cast<QGuiApplicationPrivate*>(QObjectPrivate::get(guiApp))->applyQIconStyleHelper(mode, pm);
Execution Count:34
34
293 if (!generated.isNull())
partially evaluated: !generated.isNull()
TRUEFALSE
yes
Evaluation Count:34
no
Evaluation Count:0
0-34
294 pm = generated;
executed: pm = generated;
Execution Count:34
34
295 }
executed: }
Execution Count:34
34
296 QPixmapCache::insert(key % HexString<uint>(mode), pm);
executed (the execution status of this line is deduced): QPixmapCache::insert(key % HexString<uint>(mode), pm);
-
297 }
executed: }
Execution Count:1168
1168
298 return pm;
executed: return pm;
Execution Count:4187
4187
299} -
300 -
301QSize QPixmapIconEngine::actualSize(const QSize &size, QIcon::Mode mode, QIcon::State state) -
302{ -
303 QSize actualSize;
executed (the execution status of this line is deduced): QSize actualSize;
-
304 if (QPixmapIconEngineEntry *pe = bestMatch(size, mode, state, true))
partially evaluated: QPixmapIconEngineEntry *pe = bestMatch(size, mode, state, true)
TRUEFALSE
yes
Evaluation Count:39985
no
Evaluation Count:0
0-39985
305 actualSize = pe->size;
executed: actualSize = pe->size;
Execution Count:39985
39985
306 -
307 if (actualSize.isNull())
partially evaluated: actualSize.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:39985
0-39985
308 return actualSize;
never executed: return actualSize;
0
309 -
310 if (!actualSize.isNull() && (actualSize.width() > size.width() || actualSize.height() > size.height()))
partially evaluated: !actualSize.isNull()
TRUEFALSE
yes
Evaluation Count:39985
no
Evaluation Count:0
evaluated: actualSize.width() > size.width()
TRUEFALSE
yes
Evaluation Count:479
yes
Evaluation Count:39506
evaluated: actualSize.height() > size.height()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:39501
0-39985
311 actualSize.scale(size, Qt::KeepAspectRatio);
executed: actualSize.scale(size, Qt::KeepAspectRatio);
Execution Count:484
484
312 return actualSize;
executed: return actualSize;
Execution Count:39985
39985
313} -
314 -
315void QPixmapIconEngine::addPixmap(const QPixmap &pixmap, QIcon::Mode mode, QIcon::State state) -
316{ -
317 if (!pixmap.isNull()) {
partially evaluated: !pixmap.isNull()
TRUEFALSE
yes
Evaluation Count:2494
no
Evaluation Count:0
0-2494
318 QPixmapIconEngineEntry *pe = tryMatch(pixmap.size(), mode, state);
executed (the execution status of this line is deduced): QPixmapIconEngineEntry *pe = tryMatch(pixmap.size(), mode, state);
-
319 if(pe && pe->size == pixmap.size()) {
evaluated: pe
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:2487
partially evaluated: pe->size == pixmap.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-2487
320 pe->pixmap = pixmap;
never executed (the execution status of this line is deduced): pe->pixmap = pixmap;
-
321 pe->fileName.clear();
never executed (the execution status of this line is deduced): pe->fileName.clear();
-
322 } else {
never executed: }
0
323 pixmaps += QPixmapIconEngineEntry(pixmap, mode, state);
executed (the execution status of this line is deduced): pixmaps += QPixmapIconEngineEntry(pixmap, mode, state);
-
324 }
executed: }
Execution Count:2494
2494
325 } -
326}
executed: }
Execution Count:2494
2494
327 -
328void QPixmapIconEngine::addFile(const QString &fileName, const QSize &_size, QIcon::Mode mode, QIcon::State state) -
329{ -
330 if (!fileName.isEmpty()) {
partially evaluated: !fileName.isEmpty()
TRUEFALSE
yes
Evaluation Count:6980
no
Evaluation Count:0
0-6980
331 QSize size = _size;
executed (the execution status of this line is deduced): QSize size = _size;
-
332 QPixmap pixmap;
executed (the execution status of this line is deduced): QPixmap pixmap;
-
333 -
334 QString abs = fileName;
executed (the execution status of this line is deduced): QString abs = fileName;
-
335 if (fileName.at(0) != QLatin1Char(':'))
evaluated: fileName.at(0) != QLatin1Char(':')
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:6954
26-6954
336 abs = QFileInfo(fileName).absoluteFilePath();
executed: abs = QFileInfo(fileName).absoluteFilePath();
Execution Count:26
26
337 -
338 for (int i = 0; i < pixmaps.count(); ++i) {
evaluated: i < pixmaps.count()
TRUEFALSE
yes
Evaluation Count:10705
yes
Evaluation Count:6980
6980-10705
339 if (pixmaps.at(i).mode == mode && pixmaps.at(i).state == state) {
evaluated: pixmaps.at(i).mode == mode
TRUEFALSE
yes
Evaluation Count:10692
yes
Evaluation Count:13
evaluated: pixmaps.at(i).state == state
TRUEFALSE
yes
Evaluation Count:6657
yes
Evaluation Count:4035
13-10692
340 QPixmapIconEngineEntry *pe = &pixmaps[i];
executed (the execution status of this line is deduced): QPixmapIconEngineEntry *pe = &pixmaps[i];
-
341 if(size == QSize()) {
evaluated: size == QSize()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:6652
5-6652
342 pixmap = QPixmap(abs);
executed (the execution status of this line is deduced): pixmap = QPixmap(abs);
-
343 size = pixmap.size();
executed (the execution status of this line is deduced): size = pixmap.size();
-
344 }
executed: }
Execution Count:5
5
345 if (pe->size == QSize() && pe->pixmap.isNull()) {
evaluated: pe->size == QSize()
TRUEFALSE
yes
Evaluation Count:900
yes
Evaluation Count:5757
partially evaluated: pe->pixmap.isNull()
TRUEFALSE
yes
Evaluation Count:900
no
Evaluation Count:0
0-5757
346 pe->pixmap = QPixmap(pe->fileName);
executed (the execution status of this line is deduced): pe->pixmap = QPixmap(pe->fileName);
-
347 pe->size = pe->pixmap.size();
executed (the execution status of this line is deduced): pe->size = pe->pixmap.size();
-
348 }
executed: }
Execution Count:900
900
349 if(pe->size == size) {
partially evaluated: pe->size == size
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6657
0-6657
350 pe->pixmap = pixmap;
never executed (the execution status of this line is deduced): pe->pixmap = pixmap;
-
351 pe->fileName = abs;
never executed (the execution status of this line is deduced): pe->fileName = abs;
-
352 return;
never executed: return;
0
353 } -
354 }
executed: }
Execution Count:6657
6657
355 }
executed: }
Execution Count:10705
10705
356 QPixmapIconEngineEntry e(abs, size, mode, state);
executed (the execution status of this line is deduced): QPixmapIconEngineEntry e(abs, size, mode, state);
-
357 e.pixmap = pixmap;
executed (the execution status of this line is deduced): e.pixmap = pixmap;
-
358 pixmaps += e;
executed (the execution status of this line is deduced): pixmaps += e;
-
359 }
executed: }
Execution Count:6980
6980
360}
executed: }
Execution Count:6980
6980
361 -
362QString QPixmapIconEngine::key() const -
363{ -
364 return QLatin1String("QPixmapIconEngine");
executed: return QLatin1String("QPixmapIconEngine");
Execution Count:10
10
365} -
366 -
367QIconEngine *QPixmapIconEngine::clone() const -
368{ -
369 return new QPixmapIconEngine(*this);
executed: return new QPixmapIconEngine(*this);
Execution Count:5
5
370} -
371 -
372bool QPixmapIconEngine::read(QDataStream &in) -
373{ -
374 int num_entries;
executed (the execution status of this line is deduced): int num_entries;
-
375 QPixmap pm;
executed (the execution status of this line is deduced): QPixmap pm;
-
376 QString fileName;
executed (the execution status of this line is deduced): QString fileName;
-
377 QSize sz;
executed (the execution status of this line is deduced): QSize sz;
-
378 uint mode;
executed (the execution status of this line is deduced): uint mode;
-
379 uint state;
executed (the execution status of this line is deduced): uint state;
-
380 -
381 in >> num_entries;
executed (the execution status of this line is deduced): in >> num_entries;
-
382 for (int i=0; i < num_entries; ++i) {
evaluated: i < num_entries
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:10
10-16
383 if (in.atEnd()) {
partially evaluated: in.atEnd()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-16
384 pixmaps.clear();
never executed (the execution status of this line is deduced): pixmaps.clear();
-
385 return false;
never executed: return false;
0
386 } -
387 in >> pm;
executed (the execution status of this line is deduced): in >> pm;
-
388 in >> fileName;
executed (the execution status of this line is deduced): in >> fileName;
-
389 in >> sz;
executed (the execution status of this line is deduced): in >> sz;
-
390 in >> mode;
executed (the execution status of this line is deduced): in >> mode;
-
391 in >> state;
executed (the execution status of this line is deduced): in >> state;
-
392 if (pm.isNull()) {
partially evaluated: pm.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:16
0-16
393 addFile(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
never executed (the execution status of this line is deduced): addFile(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
-
394 } else {
never executed: }
0
395 QPixmapIconEngineEntry pe(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
executed (the execution status of this line is deduced): QPixmapIconEngineEntry pe(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
-
396 pe.pixmap = pm;
executed (the execution status of this line is deduced): pe.pixmap = pm;
-
397 pixmaps += pe;
executed (the execution status of this line is deduced): pixmaps += pe;
-
398 }
executed: }
Execution Count:16
16
399 } -
400 return true;
executed: return true;
Execution Count:10
10
401} -
402 -
403bool QPixmapIconEngine::write(QDataStream &out) const -
404{ -
405 int num_entries = pixmaps.size();
executed (the execution status of this line is deduced): int num_entries = pixmaps.size();
-
406 out << num_entries;
executed (the execution status of this line is deduced): out << num_entries;
-
407 for (int i=0; i < num_entries; ++i) {
evaluated: i < num_entries
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:10
10-16
408 if (pixmaps.at(i).pixmap.isNull())
evaluated: pixmaps.at(i).pixmap.isNull()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:6
6-10
409 out << QPixmap(pixmaps.at(i).fileName);
executed: out << QPixmap(pixmaps.at(i).fileName);
Execution Count:10
10
410 else -
411 out << pixmaps.at(i).pixmap;
executed: out << pixmaps.at(i).pixmap;
Execution Count:6
6
412 out << pixmaps.at(i).fileName;
executed (the execution status of this line is deduced): out << pixmaps.at(i).fileName;
-
413 out << pixmaps.at(i).size;
executed (the execution status of this line is deduced): out << pixmaps.at(i).size;
-
414 out << (uint) pixmaps.at(i).mode;
executed (the execution status of this line is deduced): out << (uint) pixmaps.at(i).mode;
-
415 out << (uint) pixmaps.at(i).state;
executed (the execution status of this line is deduced): out << (uint) pixmaps.at(i).state;
-
416 }
executed: }
Execution Count:16
16
417 return true;
executed: return true;
Execution Count:10
10
418} -
419 -
420void QPixmapIconEngine::virtual_hook(int id, void *data) -
421{ -
422 switch (id) { -
423 case QIconEngine::AvailableSizesHook: { -
424 QIconEngine::AvailableSizesArgument &arg =
executed (the execution status of this line is deduced): QIconEngine::AvailableSizesArgument &arg =
-
425 *reinterpret_cast<QIconEngine::AvailableSizesArgument*>(data);
executed (the execution status of this line is deduced): *reinterpret_cast<QIconEngine::AvailableSizesArgument*>(data);
-
426 arg.sizes.clear();
executed (the execution status of this line is deduced): arg.sizes.clear();
-
427 for (int i = 0; i < pixmaps.size(); ++i) {
evaluated: i < pixmaps.size()
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:16
16-40
428 QPixmapIconEngineEntry &pe = pixmaps[i];
executed (the execution status of this line is deduced): QPixmapIconEngineEntry &pe = pixmaps[i];
-
429 if (pe.size == QSize() && pe.pixmap.isNull()) {
evaluated: pe.size == QSize()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:38
partially evaluated: pe.pixmap.isNull()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-38
430 pe.pixmap = QPixmap(pe.fileName);
executed (the execution status of this line is deduced): pe.pixmap = QPixmap(pe.fileName);
-
431 pe.size = pe.pixmap.size();
executed (the execution status of this line is deduced): pe.size = pe.pixmap.size();
-
432 }
executed: }
Execution Count:2
2
433 if (pe.mode == arg.mode && pe.state == arg.state && !pe.size.isEmpty())
evaluated: pe.mode == arg.mode
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:6
evaluated: pe.state == arg.state
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:4
evaluated: !pe.size.isEmpty()
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:1
1-34
434 arg.sizes.push_back(pe.size);
executed: arg.sizes.push_back(pe.size);
Execution Count:29
29
435 }
executed: }
Execution Count:40
40
436 break;
executed: break;
Execution Count:16
16
437 } -
438 default: -
439 QIconEngine::virtual_hook(id, data);
executed (the execution status of this line is deduced): QIconEngine::virtual_hook(id, data);
-
440 }
executed: }
Execution Count:1
1
441}
executed: }
Execution Count:17
17
442 -
443#ifndef QT_NO_LIBRARY -
444Q_GLOBAL_STATIC_WITH_ARGS(QFactoryLoader, loader,
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:2090
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:2075
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:15
no
Evaluation Count:0
0-2090
445 (QIconEngineFactoryInterface_iid, QLatin1String("/iconengines"), Qt::CaseInsensitive)) -
446#endif -
447 -
448 -
449 -
450/*! -
451 \class QIcon -
452 -
453 \brief The QIcon class provides scalable icons in different modes -
454 and states. -
455 -
456 \ingroup painting -
457 \ingroup shared -
458 \inmodule QtGui -
459 -
460 A QIcon can generate smaller, larger, active, and disabled pixmaps -
461 from the set of pixmaps it is given. Such pixmaps are used by Qt -
462 widgets to show an icon representing a particular action. -
463 -
464 The simplest use of QIcon is to create one from a QPixmap file or -
465 resource, and then use it, allowing Qt to work out all the required -
466 icon styles and sizes. For example: -
467 -
468 \snippet code/src_gui_image_qicon.cpp 0 -
469 -
470 To undo a QIcon, simply set a null icon in its place: -
471 -
472 \snippet code/src_gui_image_qicon.cpp 1 -
473 -
474 Use the QImageReader::supportedImageFormats() and -
475 QImageWriter::supportedImageFormats() functions to retrieve a -
476 complete list of the supported file formats. -
477 -
478 When you retrieve a pixmap using pixmap(QSize, Mode, State), and no -
479 pixmap for this given size, mode and state has been added with -
480 addFile() or addPixmap(), then QIcon will generate one on the -
481 fly. This pixmap generation happens in a QIconEngineV2. The default -
482 engine scales pixmaps down if required, but never up, and it uses -
483 the current style to calculate a disabled appearance. By using -
484 custom icon engines, you can customize every aspect of generated -
485 icons. With QIconEnginePluginV2 it is possible to register different -
486 icon engines for different file suffixes, making it possible for -
487 third parties to provide additional icon engines to those included -
488 with Qt. -
489 -
490 \note Since Qt 4.2, an icon engine that supports SVG is included. -
491 -
492 \section1 Making Classes that Use QIcon -
493 -
494 If you write your own widgets that have an option to set a small -
495 pixmap, consider allowing a QIcon to be set for that pixmap. The -
496 Qt class QToolButton is an example of such a widget. -
497 -
498 Provide a method to set a QIcon, and when you draw the icon, choose -
499 whichever pixmap is appropriate for the current state of your widget. -
500 For example: -
501 \snippet code/src_gui_image_qicon.cpp 2 -
502 -
503 You might also make use of the \c Active mode, perhaps making your -
504 widget \c Active when the mouse is over the widget (see \l -
505 QWidget::enterEvent()), while the mouse is pressed pending the -
506 release that will activate the function, or when it is the currently -
507 selected item. If the widget can be toggled, the "On" mode might be -
508 used to draw a different icon. -
509 -
510 \image icon.png QIcon -
511 -
512 \sa {fowler}{GUI Design Handbook: Iconic Label}, {Icons Example} -
513*/ -
514 -
515 -
516/*! -
517 Constructs a null icon. -
518*/ -
519QIcon::QIcon() -
520 : d(0) -
521{ -
522}
executed: }
Execution Count:510312
510312
523 -
524/*! -
525 Constructs an icon from a \a pixmap. -
526 */ -
527QIcon::QIcon(const QPixmap &pixmap) -
528 :d(0) -
529{ -
530 addPixmap(pixmap);
executed (the execution status of this line is deduced): addPixmap(pixmap);
-
531}
executed: }
Execution Count:26939
26939
532 -
533/*! -
534 Constructs a copy of \a other. This is very fast. -
535*/ -
536QIcon::QIcon(const QIcon &other) -
537 :d(other.d) -
538{ -
539 if (d)
evaluated: d
TRUEFALSE
yes
Evaluation Count:148121
yes
Evaluation Count:8583
8583-148121
540 d->ref.ref();
executed: d->ref.ref();
Execution Count:148121
148121
541}
executed: }
Execution Count:156704
156704
542 -
543/*! -
544 Constructs an icon from the file with the given \a fileName. The -
545 file will be loaded on demand. -
546 -
547 If \a fileName contains a relative path (e.g. the filename only) -
548 the relevant file must be found relative to the runtime working -
549 directory. -
550 -
551 The file name can be either refer to an actual file on disk or to -
552 one of the application's embedded resources. See the -
553 \l{resources.html}{Resource System} overview for details on how to -
554 embed images and other resource files in the application's -
555 executable. -
556 -
557 Use the QImageReader::supportedImageFormats() and -
558 QImageWriter::supportedImageFormats() functions to retrieve a -
559 complete list of the supported file formats. -
560*/ -
561QIcon::QIcon(const QString &fileName) -
562 : d(0) -
563{ -
564 addFile(fileName);
executed (the execution status of this line is deduced): addFile(fileName);
-
565}
executed: }
Execution Count:323
323
566 -
567 -
568/*! -
569 Creates an icon with a specific icon \a engine. The icon takes -
570 ownership of the engine. -
571*/ -
572QIcon::QIcon(QIconEngine *engine) -
573 :d(new QIconPrivate) -
574{ -
575 d->engine = engine;
executed (the execution status of this line is deduced): d->engine = engine;
-
576}
executed: }
Execution Count:5
5
577 -
578/*! -
579 Destroys the icon. -
580*/ -
581QIcon::~QIcon() -
582{ -
583 if (d && !d->ref.deref())
evaluated: d
TRUEFALSE
yes
Evaluation Count:194693
yes
Evaluation Count:499032
evaluated: !d->ref.deref()
TRUEFALSE
yes
Evaluation Count:4413
yes
Evaluation Count:190280
4413-499032
584 delete d;
executed: delete d;
Execution Count:4413
4413
585}
executed: }
Execution Count:693725
693725
586 -
587/*! -
588 Assigns the \a other icon to this icon and returns a reference to -
589 this icon. -
590*/ -
591QIcon &QIcon::operator=(const QIcon &other) -
592{ -
593 if (other.d)
evaluated: other.d
TRUEFALSE
yes
Evaluation Count:42658
yes
Evaluation Count:235039
42658-235039
594 other.d->ref.ref();
executed: other.d->ref.ref();
Execution Count:42658
42658
595 if (d && !d->ref.deref())
evaluated: d
TRUEFALSE
yes
Evaluation Count:613
yes
Evaluation Count:277084
evaluated: !d->ref.deref()
TRUEFALSE
yes
Evaluation Count:119
yes
Evaluation Count:494
119-277084
596 delete d;
executed: delete d;
Execution Count:119
119
597 d = other.d;
executed (the execution status of this line is deduced): d = other.d;
-
598 return *this;
executed: return *this;
Execution Count:277697
277697
599} -
600 -
601/*! -
602 \fn void QIcon::swap(QIcon &other) -
603 \since 4.8 -
604 -
605 Swaps icon \a other with this icon. This operation is very -
606 fast and never fails. -
607*/ -
608 -
609/*! -
610 Returns the icon as a QVariant. -
611*/ -
612QIcon::operator QVariant() const -
613{ -
614 return QVariant(QVariant::Icon, this);
executed: return QVariant(QVariant::Icon, this);
Execution Count:31909
31909
615} -
616 -
617/*! \fn int QIcon::serialNumber() const -
618 \obsolete -
619 -
620 Returns a number that identifies the contents of this -
621 QIcon object. Distinct QIcon objects can have -
622 the same serial number if they refer to the same contents -
623 (but they don't have to). Also, the serial number of -
624 a QIcon object may change during its lifetime. -
625 -
626 Use cacheKey() instead. -
627 -
628 A null icon always has a serial number of 0. -
629 -
630 Serial numbers are mostly useful in conjunction with caching. -
631 -
632 \sa QPixmap::serialNumber() -
633*/ -
634 -
635/*! -
636 Returns a number that identifies the contents of this QIcon -
637 object. Distinct QIcon objects can have the same key if -
638 they refer to the same contents. -
639 \since 4.3 -
640 -
641 The cacheKey() will change when the icon is altered via -
642 addPixmap() or addFile(). -
643 -
644 Cache keys are mostly useful in conjunction with caching. -
645 -
646 \sa QPixmap::cacheKey() -
647*/ -
648qint64 QIcon::cacheKey() const -
649{ -
650 if (!d)
partially evaluated: !d
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1296
0-1296
651 return 0;
never executed: return 0;
0
652 return (((qint64) d->serialNum) << 32) | ((qint64) (d->detach_no));
executed: return (((qint64) d->serialNum) << 32) | ((qint64) (d->detach_no));
Execution Count:1296
1296
653} -
654 -
655/*! -
656 Returns a pixmap with the requested \a size, \a mode, and \a -
657 state, generating one if necessary. The pixmap might be smaller than -
658 requested, but never larger. -
659 -
660 \sa actualSize(), paint() -
661*/ -
662QPixmap QIcon::pixmap(const QSize &size, Mode mode, State state) const -
663{ -
664 if (!d)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:47
yes
Evaluation Count:1620
47-1620
665 return QPixmap();
executed: return QPixmap();
Execution Count:47
47
666 return d->engine->pixmap(size, mode, state);
executed: return d->engine->pixmap(size, mode, state);
Execution Count:1620
1620
667} -
668 -
669/*! -
670 \fn QPixmap QIcon::pixmap(int w, int h, Mode mode = Normal, State state = Off) const -
671 -
672 \overload -
673 -
674 Returns a pixmap of size QSize(\a w, \a h). The pixmap might be smaller than -
675 requested, but never larger. -
676*/ -
677 -
678/*! -
679 \fn QPixmap QIcon::pixmap(int extent, Mode mode = Normal, State state = Off) const -
680 -
681 \overload -
682 -
683 Returns a pixmap of size QSize(\a extent, \a extent). The pixmap might be smaller -
684 than requested, but never larger. -
685*/ -
686 -
687/*! Returns the actual size of the icon for the requested \a size, \a -
688 mode, and \a state. The result might be smaller than requested, but -
689 never larger. -
690 -
691 \sa pixmap(), paint() -
692*/ -
693QSize QIcon::actualSize(const QSize &size, Mode mode, State state) const -
694{ -
695 if (!d)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:37398
2-37398
696 return QSize();
executed: return QSize();
Execution Count:2
2
697 return d->engine->actualSize(size, mode, state);
executed: return d->engine->actualSize(size, mode, state);
Execution Count:37398
37398
698} -
699 -
700 -
701/*! -
702 Uses the \a painter to paint the icon with specified \a alignment, -
703 required \a mode, and \a state into the rectangle \a rect. -
704 -
705 \sa actualSize(), pixmap() -
706*/ -
707void QIcon::paint(QPainter *painter, const QRect &rect, Qt::Alignment alignment, Mode mode, State state) const -
708{ -
709 if (!d || !painter)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:10914
yes
Evaluation Count:2587
partially evaluated: !painter
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2587
0-10914
710 return;
executed: return;
Execution Count:10914
10914
711 -
712 // Copy of QStyle::alignedRect -
713 const QSize size = d->engine->actualSize(rect.size(), mode, state);
never executed (the execution status of this line is deduced): const QSize size = d->engine->actualSize(rect.size(), mode, state);
-
714 alignment = QGuiApplicationPrivate::visualAlignment(painter->layoutDirection(), alignment);
never executed (the execution status of this line is deduced): alignment = QGuiApplicationPrivate::visualAlignment(painter->layoutDirection(), alignment);
-
715 int x = rect.x();
never executed (the execution status of this line is deduced): int x = rect.x();
-
716 int y = rect.y();
never executed (the execution status of this line is deduced): int y = rect.y();
-
717 int w = size.width();
never executed (the execution status of this line is deduced): int w = size.width();
-
718 int h = size.height();
never executed (the execution status of this line is deduced): int h = size.height();
-
719 if ((alignment & Qt::AlignVCenter) == Qt::AlignVCenter)
partially evaluated: (alignment & Qt::AlignVCenter) == Qt::AlignVCenter
TRUEFALSE
yes
Evaluation Count:2587
no
Evaluation Count:0
0-2587
720 y += rect.size().height()/2 - h/2;
executed: y += rect.size().height()/2 - h/2;
Execution Count:2587
2587
721 else if ((alignment & Qt::AlignBottom) == Qt::AlignBottom)
never evaluated: (alignment & Qt::AlignBottom) == Qt::AlignBottom
0
722 y += rect.size().height() - h;
never executed: y += rect.size().height() - h;
0
723 if ((alignment & Qt::AlignRight) == Qt::AlignRight)
partially evaluated: (alignment & Qt::AlignRight) == Qt::AlignRight
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2587
0-2587
724 x += rect.size().width() - w;
never executed: x += rect.size().width() - w;
0
725 else if ((alignment & Qt::AlignHCenter) == Qt::AlignHCenter)
partially evaluated: (alignment & Qt::AlignHCenter) == Qt::AlignHCenter
TRUEFALSE
yes
Evaluation Count:2587
no
Evaluation Count:0
0-2587
726 x += rect.size().width()/2 - w/2;
executed: x += rect.size().width()/2 - w/2;
Execution Count:2587
2587
727 QRect alignedRect(x, y, w, h);
executed (the execution status of this line is deduced): QRect alignedRect(x, y, w, h);
-
728 -
729 d->engine->paint(painter, alignedRect, mode, state);
executed (the execution status of this line is deduced): d->engine->paint(painter, alignedRect, mode, state);
-
730}
executed: }
Execution Count:2587
2587
731 -
732/*! -
733 \fn void QIcon::paint(QPainter *painter, int x, int y, int w, int h, Qt::Alignment alignment, -
734 Mode mode, State state) const -
735 -
736 \overload -
737 -
738 Paints the icon into the rectangle QRect(\a x, \a y, \a w, \a h). -
739*/ -
740 -
741/*! -
742 Returns true if the icon is empty; otherwise returns false. -
743 -
744 An icon is empty if it has neither a pixmap nor a filename. -
745 -
746 Note: Even a non-null icon might not be able to create valid -
747 pixmaps, eg. if the file does not exist or cannot be read. -
748*/ -
749bool QIcon::isNull() const -
750{ -
751 return !d;
executed: return !d;
Execution Count:279532
279532
752} -
753 -
754/*!\internal -
755 */ -
756bool QIcon::isDetached() const -
757{ -
758 return !d || d->ref.load() == 1;
never executed: return !d || d->ref.load() == 1;
0
759} -
760 -
761/*! \internal -
762 */ -
763void QIcon::detach() -
764{ -
765 if (d) {
partially evaluated: d
TRUEFALSE
yes
Evaluation Count:4954
no
Evaluation Count:0
0-4954
766 if (d->ref.load() != 1) {
evaluated: d->ref.load() != 1
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:4949
5-4949
767 QIconPrivate *x = new QIconPrivate;
executed (the execution status of this line is deduced): QIconPrivate *x = new QIconPrivate;
-
768 x->engine = d->engine->clone();
executed (the execution status of this line is deduced): x->engine = d->engine->clone();
-
769 if (!d->ref.deref())
partially evaluated: !d->ref.deref()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
770 delete d;
never executed: delete d;
0
771 d = x;
executed (the execution status of this line is deduced): d = x;
-
772 }
executed: }
Execution Count:5
5
773 ++d->detach_no;
executed (the execution status of this line is deduced): ++d->detach_no;
-
774 }
executed: }
Execution Count:4954
4954
775}
executed: }
Execution Count:4954
4954
776 -
777/*! -
778 Adds \a pixmap to the icon, as a specialization for \a mode and -
779 \a state. -
780 -
781 Custom icon engines are free to ignore additionally added -
782 pixmaps. -
783 -
784 \sa addFile() -
785*/ -
786void QIcon::addPixmap(const QPixmap &pixmap, Mode mode, State state) -
787{ -
788 if (pixmap.isNull())
evaluated: pixmap.isNull()
TRUEFALSE
yes
Evaluation Count:26722
yes
Evaluation Count:2494
2494-26722
789 return;
executed: return;
Execution Count:26722
26722
790 if (!d) {
evaluated: !d
TRUEFALSE
yes
Evaluation Count:2430
yes
Evaluation Count:64
64-2430
791 d = new QIconPrivate;
executed (the execution status of this line is deduced): d = new QIconPrivate;
-
792 d->engine = new QPixmapIconEngine;
executed (the execution status of this line is deduced): d->engine = new QPixmapIconEngine;
-
793 } else {
executed: }
Execution Count:2430
2430
794 detach();
executed (the execution status of this line is deduced): detach();
-
795 }
executed: }
Execution Count:64
64
796 d->engine->addPixmap(pixmap, mode, state);
executed (the execution status of this line is deduced): d->engine->addPixmap(pixmap, mode, state);
-
797}
executed: }
Execution Count:2494
2494
798 -
799 -
800/*! Adds an image from the file with the given \a fileName to the -
801 icon, as a specialization for \a size, \a mode and \a state. The -
802 file will be loaded on demand. Note: custom icon engines are free -
803 to ignore additionally added pixmaps. -
804 -
805 If \a fileName contains a relative path (e.g. the filename only) -
806 the relevant file must be found relative to the runtime working -
807 directory. -
808 -
809 The file name can be either refer to an actual file on disk or to -
810 one of the application's embedded resources. See the -
811 \l{resources.html}{Resource System} overview for details on how to -
812 embed images and other resource files in the application's -
813 executable. -
814 -
815 Use the QImageReader::supportedImageFormats() and -
816 QImageWriter::supportedImageFormats() functions to retrieve a -
817 complete list of the supported file formats. -
818 -
819 Note: When you add a non-empty filename to a QIcon, the icon becomes -
820 non-null, even if the file doesn't exist or points to a corrupt file. -
821 -
822 \sa addPixmap() -
823 */ -
824void QIcon::addFile(const QString &fileName, const QSize &size, Mode mode, State state) -
825{ -
826 if (fileName.isEmpty())
evaluated: fileName.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:6980
2-6980
827 return;
executed: return;
Execution Count:2
2
828 if (!d) {
evaluated: !d
TRUEFALSE
yes
Evaluation Count:2091
yes
Evaluation Count:4889
2091-4889
829#ifndef QT_NO_LIBRARY -
830 QFileInfo info(fileName);
executed (the execution status of this line is deduced): QFileInfo info(fileName);
-
831 QString suffix = info.suffix();
executed (the execution status of this line is deduced): QString suffix = info.suffix();
-
832 if (!suffix.isEmpty()) {
evaluated: !suffix.isEmpty()
TRUEFALSE
yes
Evaluation Count:2090
yes
Evaluation Count:1
1-2090
833 // first try version 2 engines.. -
834 const int index = loader()->indexOf(suffix);
executed (the execution status of this line is deduced): const int index = loader()->indexOf(suffix);
-
835 if (index != -1) {
partially evaluated: index != -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2090
0-2090
836 if (QIconEnginePlugin *factory = qobject_cast<QIconEnginePlugin*>(loader()->instance(index))) {
never evaluated: QIconEnginePlugin *factory = qobject_cast<QIconEnginePlugin*>(loader()->instance(index))
0
837 if (QIconEngine *engine = factory->create(fileName)) {
never evaluated: QIconEngine *engine = factory->create(fileName)
0
838 d = new QIconPrivate;
never executed (the execution status of this line is deduced): d = new QIconPrivate;
-
839 d->engine = engine;
never executed (the execution status of this line is deduced): d->engine = engine;
-
840 }
never executed: }
0
841 }
never executed: }
0
842 }
never executed: }
0
843 }
executed: }
Execution Count:2090
2090
844#endif -
845 // ...then fall back to the default engine -
846 if (!d) {
partially evaluated: !d
TRUEFALSE
yes
Evaluation Count:2091
no
Evaluation Count:0
0-2091
847 d = new QIconPrivate;
executed (the execution status of this line is deduced): d = new QIconPrivate;
-
848 d->engine = new QPixmapIconEngine;
executed (the execution status of this line is deduced): d->engine = new QPixmapIconEngine;
-
849 }
executed: }
Execution Count:2091
2091
850 } else {
executed: }
Execution Count:2091
2091
851 detach();
executed (the execution status of this line is deduced): detach();
-
852 }
executed: }
Execution Count:4889
4889
853 d->engine->addFile(fileName, size, mode, state);
executed (the execution status of this line is deduced): d->engine->addFile(fileName, size, mode, state);
-
854}
executed: }
Execution Count:6980
6980
855 -
856/*! -
857 \since 4.5 -
858 -
859 Returns a list of available icon sizes for the specified \a mode and -
860 \a state. -
861*/ -
862QList<QSize> QIcon::availableSizes(Mode mode, State state) const -
863{ -
864 if (!d || !d->engine)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:33
partially evaluated: !d->engine
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:33
0-33
865 return QList<QSize>();
executed: return QList<QSize>();
Execution Count:1
1
866 return d->engine->availableSizes(mode, state);
executed: return d->engine->availableSizes(mode, state);
Execution Count:33
33
867} -
868 -
869/*! -
870 \since 4.7 -
871 -
872 Returns the name used to create the icon, if available. -
873 -
874 Depending on the way the icon was created, it may have an associated -
875 name. This is the case for icons created with fromTheme() or icons -
876 using a QIconEngine which supports the QIconEngineV2::IconNameHook. -
877 -
878 \sa fromTheme(), QIconEngine -
879*/ -
880QString QIcon::name() const -
881{ -
882 if (!d || !d->engine)
evaluated: !d
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
partially evaluated: !d->engine
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
883 return QString();
executed: return QString();
Execution Count:1
1
884 return d->engine->iconName();
executed: return d->engine->iconName();
Execution Count:2
2
885} -
886 -
887/*! -
888 \since 4.6 -
889 -
890 Sets the search paths for icon themes to \a paths. -
891 \sa themeSearchPaths(), fromTheme(), setThemeName() -
892*/ -
893void QIcon::setThemeSearchPaths(const QStringList &paths) -
894{ -
895 QIconLoader::instance()->setThemeSearchPath(paths);
executed (the execution status of this line is deduced): QIconLoader::instance()->setThemeSearchPath(paths);
-
896}
executed: }
Execution Count:2
2
897 -
898/*! -
899 \since 4.6 -
900 -
901 Returns the search paths for icon themes. -
902 -
903 The default value will depend on the platform: -
904 -
905 On X11, the search path will use the XDG_DATA_DIRS environment -
906 variable if available. -
907 -
908 By default all platforms will have the resource directory -
909 \c{:\icons} as a fallback. You can use "rcc -project" to generate a -
910 resource file from your icon theme. -
911 -
912 \sa setThemeSearchPaths(), fromTheme(), setThemeName() -
913*/ -
914QStringList QIcon::themeSearchPaths() -
915{ -
916 return QIconLoader::instance()->themeSearchPaths();
executed: return QIconLoader::instance()->themeSearchPaths();
Execution Count:23
23
917} -
918 -
919/*! -
920 \since 4.6 -
921 -
922 Sets the current icon theme to \a name. -
923 -
924 The \a name should correspond to a directory name in the -
925 themeSearchPath() containing an index.theme -
926 file describing it's contents. -
927 -
928 \sa themeSearchPaths(), themeName() -
929*/ -
930void QIcon::setThemeName(const QString &name) -
931{ -
932 QIconLoader::instance()->setThemeName(name);
executed (the execution status of this line is deduced): QIconLoader::instance()->setThemeName(name);
-
933}
executed: }
Execution Count:3
3
934 -
935/*! -
936 \since 4.6 -
937 -
938 Returns the name of the current icon theme. -
939 -
940 On X11, the current icon theme depends on your desktop -
941 settings. On other platforms it is not set by default. -
942 -
943 \sa setThemeName(), themeSearchPaths(), fromTheme(), -
944 hasThemeIcon() -
945*/ -
946QString QIcon::themeName() -
947{ -
948 return QIconLoader::instance()->themeName();
executed: return QIconLoader::instance()->themeName();
Execution Count:6856
6856
949} -
950 -
951/*! -
952 \since 4.6 -
953 -
954 Returns the QIcon corresponding to \a name in the current -
955 icon theme. If no such icon is found in the current theme -
956 \a fallback is returned instead. -
957 -
958 The latest version of the freedesktop icon specification and naming -
959 specification can be obtained here: -
960 -
961 \list -
962 \li \l{http://standards.freedesktop.org/icon-theme-spec/icon-theme-spec-latest.html} -
963 \li \l{http://standards.freedesktop.org/icon-naming-spec/icon-naming-spec-latest.html} -
964 \endlist -
965 -
966 To fetch an icon from the current icon theme: -
967 -
968 \snippet code/src_gui_image_qicon.cpp 3 -
969 -
970 Or if you want to provide a guaranteed fallback for platforms that -
971 do not support theme icons, you can use the second argument: -
972 -
973 \snippet code/src_gui_image_qicon.cpp 4 -
974 -
975 \note By default, only X11 will support themed icons. In order to -
976 use themed icons on Mac and Windows, you will have to bundle a -
977 compliant theme in one of your themeSearchPaths() and set the -
978 appropriate themeName(). -
979 -
980 \sa themeName(), setThemeName(), themeSearchPaths() -
981*/ -
982QIcon QIcon::fromTheme(const QString &name, const QIcon &fallback) -
983{ -
984 QIcon icon;
executed (the execution status of this line is deduced): QIcon icon;
-
985 -
986 if (qtIconCache()->contains(name)) {
evaluated: qtIconCache()->contains(name)
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:5
5
987 icon = *qtIconCache()->object(name);
executed (the execution status of this line is deduced): icon = *qtIconCache()->object(name);
-
988 } else {
executed: }
Execution Count:5
5
989 QIcon *cachedIcon = new QIcon(new QIconLoaderEngine(name));
executed (the execution status of this line is deduced): QIcon *cachedIcon = new QIcon(new QIconLoaderEngine(name));
-
990 qtIconCache()->insert(name, cachedIcon);
executed (the execution status of this line is deduced): qtIconCache()->insert(name, cachedIcon);
-
991 icon = *cachedIcon;
executed (the execution status of this line is deduced): icon = *cachedIcon;
-
992 }
executed: }
Execution Count:5
5
993 -
994 // Note the qapp check is to allow lazy loading of static icons -
995 // Supporting fallbacks will not work for this case. -
996 if (qApp && icon.availableSizes().isEmpty())
evaluated: (static_cast<QGuiApplication *>(QCoreApplication::instance()))
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:1
evaluated: icon.availableSizes().isEmpty()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:4
1-9
997 return fallback;
executed: return fallback;
Execution Count:5
5
998 -
999 return icon;
executed: return icon;
Execution Count:5
5
1000} -
1001 -
1002/*! -
1003 \since 4.6 -
1004 -
1005 Returns true if there is an icon available for \a name in the -
1006 current icon theme, otherwise returns false. -
1007 -
1008 \sa themeSearchPaths(), fromTheme(), setThemeName() -
1009*/ -
1010bool QIcon::hasThemeIcon(const QString &name) -
1011{ -
1012 QIcon icon = fromTheme(name);
executed (the execution status of this line is deduced): QIcon icon = fromTheme(name);
-
1013 -
1014 return !icon.isNull();
executed: return !icon.isNull();
Execution Count:2
2
1015} -
1016 -
1017 -
1018/***************************************************************************** -
1019 QIcon stream functions -
1020 *****************************************************************************/ -
1021#if !defined(QT_NO_DATASTREAM) -
1022/*! -
1023 \fn QDataStream &operator<<(QDataStream &stream, const QIcon &icon) -
1024 \relates QIcon -
1025 \since 4.2 -
1026 -
1027 Writes the given \a icon to the given \a stream as a PNG -
1028 image. If the icon contains more than one image, all images will -
1029 be written to the stream. Note that writing the stream to a file -
1030 will not produce a valid image file. -
1031*/ -
1032 -
1033QDataStream &operator<<(QDataStream &s, const QIcon &icon) -
1034{ -
1035 if (s.version() >= QDataStream::Qt_4_3) {
partially evaluated: s.version() >= QDataStream::Qt_4_3
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
1036 if (icon.isNull()) {
partially evaluated: icon.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11
0-11
1037 s << QString();
never executed (the execution status of this line is deduced): s << QString();
-
1038 } else {
never executed: }
0
1039 s << icon.d->engine->key();
executed (the execution status of this line is deduced): s << icon.d->engine->key();
-
1040 icon.d->engine->write(s);
executed (the execution status of this line is deduced): icon.d->engine->write(s);
-
1041 }
executed: }
Execution Count:11
11
1042 } else if (s.version() == QDataStream::Qt_4_2) {
never evaluated: s.version() == QDataStream::Qt_4_2
0
1043 if (icon.isNull()) {
never evaluated: icon.isNull()
0
1044 s << 0;
never executed (the execution status of this line is deduced): s << 0;
-
1045 } else {
never executed: }
0
1046 QPixmapIconEngine *engine = static_cast<QPixmapIconEngine *>(icon.d->engine);
never executed (the execution status of this line is deduced): QPixmapIconEngine *engine = static_cast<QPixmapIconEngine *>(icon.d->engine);
-
1047 int num_entries = engine->pixmaps.size();
never executed (the execution status of this line is deduced): int num_entries = engine->pixmaps.size();
-
1048 s << num_entries;
never executed (the execution status of this line is deduced): s << num_entries;
-
1049 for (int i=0; i < num_entries; ++i) {
never evaluated: i < num_entries
0
1050 s << engine->pixmaps.at(i).pixmap;
never executed (the execution status of this line is deduced): s << engine->pixmaps.at(i).pixmap;
-
1051 s << engine->pixmaps.at(i).fileName;
never executed (the execution status of this line is deduced): s << engine->pixmaps.at(i).fileName;
-
1052 s << engine->pixmaps.at(i).size;
never executed (the execution status of this line is deduced): s << engine->pixmaps.at(i).size;
-
1053 s << (uint) engine->pixmaps.at(i).mode;
never executed (the execution status of this line is deduced): s << (uint) engine->pixmaps.at(i).mode;
-
1054 s << (uint) engine->pixmaps.at(i).state;
never executed (the execution status of this line is deduced): s << (uint) engine->pixmaps.at(i).state;
-
1055 }
never executed: }
0
1056 }
never executed: }
0
1057 } else { -
1058 s << QPixmap(icon.pixmap(22,22));
never executed (the execution status of this line is deduced): s << QPixmap(icon.pixmap(22,22));
-
1059 }
never executed: }
0
1060 return s;
executed: return s;
Execution Count:11
11
1061} -
1062 -
1063/*! -
1064 \fn QDataStream &operator>>(QDataStream &stream, QIcon &icon) -
1065 \relates QIcon -
1066 \since 4.2 -
1067 -
1068 Reads an image, or a set of images, from the given \a stream into -
1069 the given \a icon. -
1070*/ -
1071 -
1072QDataStream &operator>>(QDataStream &s, QIcon &icon) -
1073{ -
1074 if (s.version() >= QDataStream::Qt_4_3) {
partially evaluated: s.version() >= QDataStream::Qt_4_3
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
1075 icon = QIcon();
executed (the execution status of this line is deduced): icon = QIcon();
-
1076 QString key;
executed (the execution status of this line is deduced): QString key;
-
1077 s >> key;
executed (the execution status of this line is deduced): s >> key;
-
1078 if (key == QLatin1String("QPixmapIconEngine")) {
evaluated: key == QLatin1String("QPixmapIconEngine")
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:1
1-10
1079 icon.d = new QIconPrivate;
executed (the execution status of this line is deduced): icon.d = new QIconPrivate;
-
1080 QIconEngine *engine = new QPixmapIconEngine;
executed (the execution status of this line is deduced): QIconEngine *engine = new QPixmapIconEngine;
-
1081 icon.d->engine = engine;
executed (the execution status of this line is deduced): icon.d->engine = engine;
-
1082 engine->read(s);
executed (the execution status of this line is deduced): engine->read(s);
-
1083 } else if (key == QLatin1String("QIconLoaderEngine")) {
executed: }
Execution Count:10
partially evaluated: key == QLatin1String("QIconLoaderEngine")
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-10
1084 icon.d = new QIconPrivate;
executed (the execution status of this line is deduced): icon.d = new QIconPrivate;
-
1085 QIconEngine *engine = new QIconLoaderEngine();
executed (the execution status of this line is deduced): QIconEngine *engine = new QIconLoaderEngine();
-
1086 icon.d->engine = engine;
executed (the execution status of this line is deduced): icon.d->engine = engine;
-
1087 engine->read(s);
executed (the execution status of this line is deduced): engine->read(s);
-
1088#ifndef QT_NO_LIBRARY -
1089 } else {
executed: }
Execution Count:1
1
1090 const int index = loader()->indexOf(key);
never executed (the execution status of this line is deduced): const int index = loader()->indexOf(key);
-
1091 if (index != -1) {
never evaluated: index != -1
0
1092 if (QIconEnginePlugin *factory = qobject_cast<QIconEnginePlugin*>(loader()->instance(index))) {
never evaluated: QIconEnginePlugin *factory = qobject_cast<QIconEnginePlugin*>(loader()->instance(index))
0
1093 if (QIconEngine *engine= factory->create()) {
never evaluated: QIconEngine *engine= factory->create()
0
1094 icon.d = new QIconPrivate;
never executed (the execution status of this line is deduced): icon.d = new QIconPrivate;
-
1095 icon.d->engine = engine;
never executed (the execution status of this line is deduced): icon.d->engine = engine;
-
1096 engine->read(s);
never executed (the execution status of this line is deduced): engine->read(s);
-
1097 } // factory
never executed: }
0
1098 } // instance
never executed: }
0
1099 } // index
never executed: }
0
1100#endif -
1101 }
never executed: }
0
1102 } else if (s.version() == QDataStream::Qt_4_2) {
never evaluated: s.version() == QDataStream::Qt_4_2
0
1103 icon = QIcon();
never executed (the execution status of this line is deduced): icon = QIcon();
-
1104 int num_entries;
never executed (the execution status of this line is deduced): int num_entries;
-
1105 QPixmap pm;
never executed (the execution status of this line is deduced): QPixmap pm;
-
1106 QString fileName;
never executed (the execution status of this line is deduced): QString fileName;
-
1107 QSize sz;
never executed (the execution status of this line is deduced): QSize sz;
-
1108 uint mode;
never executed (the execution status of this line is deduced): uint mode;
-
1109 uint state;
never executed (the execution status of this line is deduced): uint state;
-
1110 -
1111 s >> num_entries;
never executed (the execution status of this line is deduced): s >> num_entries;
-
1112 for (int i=0; i < num_entries; ++i) {
never evaluated: i < num_entries
0
1113 s >> pm;
never executed (the execution status of this line is deduced): s >> pm;
-
1114 s >> fileName;
never executed (the execution status of this line is deduced): s >> fileName;
-
1115 s >> sz;
never executed (the execution status of this line is deduced): s >> sz;
-
1116 s >> mode;
never executed (the execution status of this line is deduced): s >> mode;
-
1117 s >> state;
never executed (the execution status of this line is deduced): s >> state;
-
1118 if (pm.isNull())
never evaluated: pm.isNull()
0
1119 icon.addFile(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
never executed: icon.addFile(fileName, sz, QIcon::Mode(mode), QIcon::State(state));
0
1120 else -
1121 icon.addPixmap(pm, QIcon::Mode(mode), QIcon::State(state));
never executed: icon.addPixmap(pm, QIcon::Mode(mode), QIcon::State(state));
0
1122 } -
1123 } else {
never executed: }
0
1124 QPixmap pm;
never executed (the execution status of this line is deduced): QPixmap pm;
-
1125 s >> pm;
never executed (the execution status of this line is deduced): s >> pm;
-
1126 icon.addPixmap(pm);
never executed (the execution status of this line is deduced): icon.addPixmap(pm);
-
1127 }
never executed: }
0
1128 return s;
executed: return s;
Execution Count:11
11
1129} -
1130 -
1131#endif //QT_NO_DATASTREAM -
1132 -
1133#ifndef QT_NO_DEBUG_STREAM -
1134QDebug operator<<(QDebug dbg, const QIcon &i) -
1135{ -
1136 dbg.nospace() << "QIcon(" << i.name() << ')';
executed (the execution status of this line is deduced): dbg.nospace() << "QIcon(" << i.name() << ')';
-
1137 return dbg.space();
executed: return dbg.space();
Execution Count:1
1
1138} -
1139#endif -
1140 -
1141/*! -
1142 \fn DataPtr &QIcon::data_ptr() -
1143 \internal -
1144*/ -
1145 -
1146/*! -
1147 \typedef QIcon::DataPtr -
1148 \internal -
1149*/ -
1150 -
1151QT_END_NAMESPACE -
1152#endif //QT_NO_ICON -
1153 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial