Line | Source Code | Coverage |
---|
1 | | - |
2 | | - |
3 | | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | static const int MaxBits = 8 * sizeof(QSizePolicy::ControlType); | - |
9 | | - |
10 | static int unpackControlTypes(QSizePolicy::ControlTypes controls, QSizePolicy::ControlType *array) | - |
11 | { | - |
12 | if (!controls) partially evaluated: !controls no Evaluation Count:0 | yes Evaluation Count:4114 |
| 0-4114 |
13 | return 0; never executed: return 0; | 0 |
14 | | - |
15 | | - |
16 | if ((controls & (controls - 1)) == 0) { partially evaluated: (controls & (controls - 1)) == 0 yes Evaluation Count:4114 | no Evaluation Count:0 |
| 0-4114 |
17 | array[0] = QSizePolicy::ControlType(uint(controls)); | - |
18 | return 1; executed: return 1; Execution Count:4114 | 4114 |
19 | } | - |
20 | | - |
21 | int count = 0; | - |
22 | for (int i = 0; i < MaxBits; ++i) { never evaluated: i < MaxBits | 0 |
23 | if (uint bit = (controls & (0x1 << i))) never evaluated: uint bit = (controls & (0x1 << i)) | 0 |
24 | array[count++] = QSizePolicy::ControlType(bit); never executed: array[count++] = QSizePolicy::ControlType(bit); | 0 |
25 | } | 0 |
26 | return count; never executed: return count; | 0 |
27 | } | - |
28 | QStyle::QStyle() | - |
29 | : QObject(*new QStylePrivate) | - |
30 | { | - |
31 | QStylePrivate * const d = d_func(); | - |
32 | d->proxyStyle = this; | - |
33 | } | 0 |
34 | | - |
35 | | - |
36 | | - |
37 | | - |
38 | | - |
39 | | - |
40 | QStyle::QStyle(QStylePrivate &dd) | - |
41 | : QObject(dd) | - |
42 | { | - |
43 | QStylePrivate * const d = d_func(); | - |
44 | d->proxyStyle = this; | - |
45 | } executed: } Execution Count:1164 | 1164 |
46 | | - |
47 | | - |
48 | | - |
49 | | - |
50 | QStyle::~QStyle() | - |
51 | { | - |
52 | } | - |
53 | void QStyle::polish(QWidget * ) | - |
54 | { | - |
55 | } | - |
56 | void QStyle::unpolish(QWidget * ) | - |
57 | { | - |
58 | } | - |
59 | | - |
60 | | - |
61 | | - |
62 | | - |
63 | | - |
64 | | - |
65 | | - |
66 | void QStyle::polish(QApplication * ) | - |
67 | { | - |
68 | } | - |
69 | | - |
70 | | - |
71 | | - |
72 | | - |
73 | | - |
74 | | - |
75 | | - |
76 | void QStyle::unpolish(QApplication * ) | - |
77 | { | - |
78 | } | - |
79 | void QStyle::polish(QPalette & ) | - |
80 | { | - |
81 | } | - |
82 | QRect QStyle::itemTextRect(const QFontMetrics &metrics, const QRect &rect, int alignment, bool enabled, | - |
83 | const QString &text) const | - |
84 | { | - |
85 | QRect result; | - |
86 | int x, y, w, h; | - |
87 | rect.getRect(&x, &y, &w, &h); | - |
88 | if (!text.isEmpty()) { evaluated: !text.isEmpty() yes Evaluation Count:44 | yes Evaluation Count:18 |
| 18-44 |
89 | result = metrics.boundingRect(x, y, w, h, alignment, text); | - |
90 | if (!enabled && proxy()->styleHint(SH_EtchDisabledText)) { evaluated: !enabled yes Evaluation Count:35 | yes Evaluation Count:9 |
partially evaluated: proxy()->styleHint(SH_EtchDisabledText) yes Evaluation Count:35 | no Evaluation Count:0 |
| 0-35 |
91 | result.setWidth(result.width()+1); | - |
92 | result.setHeight(result.height()+1); | - |
93 | } executed: } Execution Count:35 | 35 |
94 | } else { executed: } Execution Count:44 | 44 |
95 | result = QRect(x, y, w, h); | - |
96 | } executed: } Execution Count:18 | 18 |
97 | return result; executed: return result; Execution Count:62 | 62 |
98 | } | - |
99 | | - |
100 | | - |
101 | | - |
102 | | - |
103 | | - |
104 | | - |
105 | | - |
106 | QRect QStyle::itemPixmapRect(const QRect &rect, int alignment, const QPixmap &pixmap) const | - |
107 | { | - |
108 | QRect result; | - |
109 | int x, y, w, h; | - |
110 | rect.getRect(&x, &y, &w, &h); | - |
111 | if ((alignment & Qt::AlignVCenter) == Qt::AlignVCenter) evaluated: (alignment & Qt::AlignVCenter) == Qt::AlignVCenter yes Evaluation Count:130 | yes Evaluation Count:4 |
| 4-130 |
112 | y += h/2 - pixmap.height()/2; executed: y += h/2 - pixmap.height()/2; Execution Count:130 | 130 |
113 | else if ((alignment & Qt::AlignBottom) == Qt::AlignBottom) partially evaluated: (alignment & Qt::AlignBottom) == Qt::AlignBottom no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
114 | y += h - pixmap.height(); never executed: y += h - pixmap.height(); | 0 |
115 | if ((alignment & Qt::AlignRight) == Qt::AlignRight) partially evaluated: (alignment & Qt::AlignRight) == Qt::AlignRight no Evaluation Count:0 | yes Evaluation Count:134 |
| 0-134 |
116 | x += w - pixmap.width(); never executed: x += w - pixmap.width(); | 0 |
117 | else if ((alignment & Qt::AlignHCenter) == Qt::AlignHCenter) evaluated: (alignment & Qt::AlignHCenter) == Qt::AlignHCenter yes Evaluation Count:4 | yes Evaluation Count:130 |
| 4-130 |
118 | x += w/2 - pixmap.width()/2; executed: x += w/2 - pixmap.width()/2; Execution Count:4 | 4 |
119 | else if ((alignment & Qt::AlignLeft) != Qt::AlignLeft && QApplication::isRightToLeft()) partially evaluated: (alignment & Qt::AlignLeft) != Qt::AlignLeft no Evaluation Count:0 | yes Evaluation Count:130 |
never evaluated: QApplication::isRightToLeft() | 0-130 |
120 | x += w - pixmap.width(); never executed: x += w - pixmap.width(); | 0 |
121 | result = QRect(x, y, pixmap.width(), pixmap.height()); | - |
122 | return result; executed: return result; Execution Count:134 | 134 |
123 | } | - |
124 | void QStyle::drawItemText(QPainter *painter, const QRect &rect, int alignment, const QPalette &pal, | - |
125 | bool enabled, const QString& text, QPalette::ColorRole textRole) const | - |
126 | { | - |
127 | if (text.isEmpty()) evaluated: text.isEmpty() yes Evaluation Count:350 | yes Evaluation Count:3509 |
| 350-3509 |
128 | return; executed: return; Execution Count:350 | 350 |
129 | QPen savedPen; | - |
130 | if (textRole != QPalette::NoRole) { evaluated: textRole != QPalette::NoRole yes Evaluation Count:3350 | yes Evaluation Count:159 |
| 159-3350 |
131 | savedPen = painter->pen(); | - |
132 | painter->setPen(QPen(pal.brush(textRole), savedPen.widthF())); | - |
133 | } executed: } Execution Count:3350 | 3350 |
134 | if (!enabled) { evaluated: !enabled yes Evaluation Count:43 | yes Evaluation Count:3466 |
| 43-3466 |
135 | if (proxy()->styleHint(SH_DitherDisabledText)) { partially evaluated: proxy()->styleHint(SH_DitherDisabledText) no Evaluation Count:0 | yes Evaluation Count:43 |
| 0-43 |
136 | QRect br; | - |
137 | painter->drawText(rect, alignment, text, &br); | - |
138 | painter->fillRect(br, QBrush(painter->background().color(), Qt::Dense5Pattern)); | - |
139 | return; | 0 |
140 | } else if (proxy()->styleHint(SH_EtchDisabledText)) { partially evaluated: proxy()->styleHint(SH_EtchDisabledText) yes Evaluation Count:43 | no Evaluation Count:0 |
| 0-43 |
141 | QPen pen = painter->pen(); | - |
142 | painter->setPen(pal.light().color()); | - |
143 | painter->drawText(rect.adjusted(1, 1, 1, 1), alignment, text); | - |
144 | painter->setPen(pen); | - |
145 | } executed: } Execution Count:43 | 43 |
146 | } | - |
147 | painter->drawText(rect, alignment, text); | - |
148 | if (textRole != QPalette::NoRole) evaluated: textRole != QPalette::NoRole yes Evaluation Count:3350 | yes Evaluation Count:159 |
| 159-3350 |
149 | painter->setPen(savedPen); executed: painter->setPen(savedPen); Execution Count:3350 | 3350 |
150 | } executed: } Execution Count:3509 | 3509 |
151 | void QStyle::drawItemPixmap(QPainter *painter, const QRect &rect, int alignment, | - |
152 | const QPixmap &pixmap) const | - |
153 | { | - |
154 | int scale = pixmap.devicePixelRatio(); | - |
155 | QRect aligned = alignedRect(QApplication::layoutDirection(), QFlag(alignment), pixmap.size() / scale, rect); | - |
156 | QRect inter = aligned.intersected(rect); | - |
157 | | - |
158 | painter->drawPixmap(inter.x(), inter.y(), pixmap, inter.x() - aligned.x(), inter.y() - aligned.y(), inter.width() * scale, inter.height() *scale); | - |
159 | } executed: } Execution Count:1251 | 1251 |
160 | QRect QStyle::visualRect(Qt::LayoutDirection direction, const QRect &boundingRect, const QRect &logicalRect) | - |
161 | { | - |
162 | if (direction == Qt::LeftToRight) evaluated: direction == Qt::LeftToRight yes Evaluation Count:142533 | yes Evaluation Count:596 |
| 596-142533 |
163 | return logicalRect; executed: return logicalRect; Execution Count:142533 | 142533 |
164 | QRect rect = logicalRect; | - |
165 | rect.translate(2 * (boundingRect.right() - logicalRect.right()) + | - |
166 | logicalRect.width() - boundingRect.width(), 0); | - |
167 | return rect; executed: return rect; Execution Count:596 | 596 |
168 | } | - |
169 | QPoint QStyle::visualPos(Qt::LayoutDirection direction, const QRect &boundingRect, const QPoint &logicalPos) | - |
170 | { | - |
171 | if (direction == Qt::LeftToRight) never evaluated: direction == Qt::LeftToRight | 0 |
172 | return logicalPos; never executed: return logicalPos; | 0 |
173 | return QPoint(boundingRect.right() - logicalPos.x(), logicalPos.y()); never executed: return QPoint(boundingRect.right() - logicalPos.x(), logicalPos.y()); | 0 |
174 | } | - |
175 | | - |
176 | | - |
177 | | - |
178 | | - |
179 | | - |
180 | QRect QStyle::alignedRect(Qt::LayoutDirection direction, Qt::Alignment alignment, const QSize &size, const QRect &rectangle) | - |
181 | { | - |
182 | alignment = visualAlignment(direction, alignment); | - |
183 | int x = rectangle.x(); | - |
184 | int y = rectangle.y(); | - |
185 | int w = size.width(); | - |
186 | int h = size.height(); | - |
187 | if ((alignment & Qt::AlignVCenter) == Qt::AlignVCenter) evaluated: (alignment & Qt::AlignVCenter) == Qt::AlignVCenter yes Evaluation Count:55831 | yes Evaluation Count:448 |
| 448-55831 |
188 | y += rectangle.size().height()/2 - h/2; executed: y += rectangle.size().height()/2 - h/2; Execution Count:55831 | 55831 |
189 | else if ((alignment & Qt::AlignBottom) == Qt::AlignBottom) partially evaluated: (alignment & Qt::AlignBottom) == Qt::AlignBottom no Evaluation Count:0 | yes Evaluation Count:448 |
| 0-448 |
190 | y += rectangle.size().height() - h; never executed: y += rectangle.size().height() - h; | 0 |
191 | if ((alignment & Qt::AlignRight) == Qt::AlignRight) evaluated: (alignment & Qt::AlignRight) == Qt::AlignRight yes Evaluation Count:228 | yes Evaluation Count:56051 |
| 228-56051 |
192 | x += rectangle.size().width() - w; executed: x += rectangle.size().width() - w; Execution Count:228 | 228 |
193 | else if ((alignment & Qt::AlignHCenter) == Qt::AlignHCenter) evaluated: (alignment & Qt::AlignHCenter) == Qt::AlignHCenter yes Evaluation Count:40506 | yes Evaluation Count:15545 |
| 15545-40506 |
194 | x += rectangle.size().width()/2 - w/2; executed: x += rectangle.size().width()/2 - w/2; Execution Count:40506 | 40506 |
195 | return QRect(x, y, w, h); executed: return QRect(x, y, w, h); Execution Count:56279 | 56279 |
196 | } | - |
197 | Qt::Alignment QStyle::visualAlignment(Qt::LayoutDirection direction, Qt::Alignment alignment) | - |
198 | { | - |
199 | return QGuiApplicationPrivate::visualAlignment(direction, alignment); executed: return QGuiApplicationPrivate::visualAlignment(direction, alignment); Execution Count:89647 | 89647 |
200 | } | - |
201 | int QStyle::sliderPositionFromValue(int min, int max, int logicalValue, int span, bool upsideDown) | - |
202 | { | - |
203 | if (span <= 0 || logicalValue < min || max <= min) evaluated: span <= 0 yes Evaluation Count:1705 | yes Evaluation Count:19544 |
partially evaluated: logicalValue < min no Evaluation Count:0 | yes Evaluation Count:19544 |
partially evaluated: max <= min no Evaluation Count:0 | yes Evaluation Count:19544 |
| 0-19544 |
204 | return 0; executed: return 0; Execution Count:1705 | 1705 |
205 | if (logicalValue > max) partially evaluated: logicalValue > max no Evaluation Count:0 | yes Evaluation Count:19544 |
| 0-19544 |
206 | return upsideDown ? span : min; never executed: return upsideDown ? span : min; | 0 |
207 | | - |
208 | uint range = max - min; | - |
209 | uint p = upsideDown ? max - logicalValue : logicalValue - min; evaluated: upsideDown yes Evaluation Count:8 | yes Evaluation Count:19536 |
| 8-19536 |
210 | | - |
211 | if (range > (uint)2147483647/4096) { evaluated: range > (uint)2147483647/4096 yes Evaluation Count:56 | yes Evaluation Count:19488 |
| 56-19488 |
212 | double dpos = (double(p))/(double(range)/span); | - |
213 | return int(dpos); executed: return int(dpos); Execution Count:56 | 56 |
214 | } else if (range > (uint)span) { evaluated: range > (uint)span yes Evaluation Count:15384 | yes Evaluation Count:4104 |
| 4104-15384 |
215 | return (2 * p * span + range) / (2*range); executed: return (2 * p * span + range) / (2*range); Execution Count:15384 | 15384 |
216 | } else { | - |
217 | uint div = span / range; | - |
218 | uint mod = span % range; | - |
219 | return p * div + (2 * p * mod + range) / (2 * range); executed: return p * div + (2 * p * mod + range) / (2 * range); Execution Count:4104 | 4104 |
220 | } | - |
221 | | - |
222 | | - |
223 | | - |
224 | } | - |
225 | int QStyle::sliderValueFromPosition(int min, int max, int pos, int span, bool upsideDown) | - |
226 | { | - |
227 | if (span <= 0 || pos <= 0) partially evaluated: span <= 0 no Evaluation Count:0 | yes Evaluation Count:5 |
partially evaluated: pos <= 0 no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
228 | return upsideDown ? max : min; never executed: return upsideDown ? max : min; | 0 |
229 | if (pos >= span) evaluated: pos >= span yes Evaluation Count:2 | yes Evaluation Count:3 |
| 2-3 |
230 | return upsideDown ? min : max; executed: return upsideDown ? min : max; Execution Count:2 | 2 |
231 | | - |
232 | uint range = max - min; | - |
233 | | - |
234 | if ((uint)span > range) { partially evaluated: (uint)span > range yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
235 | int tmp = (2 * pos * range + span) / (2 * span); | - |
236 | return upsideDown ? max - tmp : tmp + min; executed: return upsideDown ? max - tmp : tmp + min; Execution Count:3 | 3 |
237 | } else { | - |
238 | uint div = range / span; | - |
239 | uint mod = range % span; | - |
240 | int tmp = pos * div + (2 * pos * mod + span) / (2 * span); | - |
241 | return upsideDown ? max - tmp : tmp + min; never executed: return upsideDown ? max - tmp : tmp + min; | 0 |
242 | } | - |
243 | | - |
244 | | - |
245 | | - |
246 | } | - |
247 | QPalette QStyle::standardPalette() const | - |
248 | { | - |
249 | QColor background = QColor(0xd4, 0xd0, 0xc8); | - |
250 | | - |
251 | QColor light(background.lighter()); | - |
252 | QColor dark(background.darker()); | - |
253 | QColor mid(Qt::gray); | - |
254 | QPalette palette(Qt::black, background, light, dark, mid, Qt::black, Qt::white); | - |
255 | palette.setBrush(QPalette::Disabled, QPalette::WindowText, dark); | - |
256 | palette.setBrush(QPalette::Disabled, QPalette::Text, dark); | - |
257 | palette.setBrush(QPalette::Disabled, QPalette::ButtonText, dark); | - |
258 | palette.setBrush(QPalette::Disabled, QPalette::Base, background); | - |
259 | return palette; executed: return palette; Execution Count:215 | 215 |
260 | } | - |
261 | int QStyle::combinedLayoutSpacing(QSizePolicy::ControlTypes controls1, | - |
262 | QSizePolicy::ControlTypes controls2, Qt::Orientation orientation, | - |
263 | QStyleOption *option, QWidget *widget) const | - |
264 | { | - |
265 | QSizePolicy::ControlType array1[MaxBits]; | - |
266 | QSizePolicy::ControlType array2[MaxBits]; | - |
267 | int count1 = unpackControlTypes(controls1, array1); | - |
268 | int count2 = unpackControlTypes(controls2, array2); | - |
269 | int result = -1; | - |
270 | | - |
271 | for (int i = 0; i < count1; ++i) { evaluated: i < count1 yes Evaluation Count:2057 | yes Evaluation Count:2057 |
| 2057 |
272 | for (int j = 0; j < count2; ++j) { evaluated: j < count2 yes Evaluation Count:2057 | yes Evaluation Count:2057 |
| 2057 |
273 | int spacing = layoutSpacing(array1[i], array2[j], orientation, option, widget); | - |
274 | result = qMax(spacing, result); | - |
275 | } executed: } Execution Count:2057 | 2057 |
276 | } executed: } Execution Count:2057 | 2057 |
277 | return result; executed: return result; Execution Count:2057 | 2057 |
278 | } | - |
279 | | - |
280 | | - |
281 | | - |
282 | | - |
283 | | - |
284 | QDebug operator<<(QDebug debug, QStyle::State state) | - |
285 | { | - |
286 | (void)state;; | - |
287 | | - |
288 | return debug; never executed: return debug; | 0 |
289 | } | - |
290 | const QStyle * QStyle::proxy() const | - |
291 | { | - |
292 | const QStylePrivate * const d = d_func(); | - |
293 | return d->proxyStyle; executed: return d->proxyStyle; Execution Count:224293 | 224293 |
294 | } | - |
295 | | - |
296 | | - |
297 | | - |
298 | | - |
299 | | - |
300 | | - |
301 | void QStyle::setProxy(QStyle *style) | - |
302 | { | - |
303 | QStylePrivate * const d = d_func(); | - |
304 | d->proxyStyle = style; | - |
305 | } executed: } Execution Count:67 | 67 |
306 | | - |
307 | | - |
308 | | - |
| | |