Line | Source Code | Coverage |
---|
1 | static const int QGRAPHICSVIEW_REGION_RECT_THRESHOLD = 50; | - |
2 | | - |
3 | static const int QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS = 503; | - |
4 | | - |
5 | | - |
6 | | - |
7 | | - |
8 | | - |
9 | | - |
10 | | - |
11 | | - |
12 | | - |
13 | bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); | - |
14 | | - |
15 | inline int q_round_bound(qreal d) | - |
16 | { | - |
17 | if (d <= (qreal) (-2147483647 - 1)) evaluated: d <= (qreal) (-2147483647 - 1) yes Evaluation Count:2 | yes Evaluation Count:14810 |
| 2-14810 |
18 | return (-2147483647 - 1); executed: return (-2147483647 - 1); Execution Count:2 | 2 |
19 | else if (d >= (qreal) 2147483647) evaluated: d >= (qreal) 2147483647 yes Evaluation Count:2 | yes Evaluation Count:14808 |
| 2-14808 |
20 | return 2147483647; executed: return 2147483647; Execution Count:2 | 2 |
21 | return d >= 0.0 ? int(d + 0.5) : int(d - int(d-1) + 0.5) + int(d-1); executed: return d >= 0.0 ? int(d + 0.5) : int(d - int(d-1) + 0.5) + int(d-1); Execution Count:14808 | 14808 |
22 | } | - |
23 | | - |
24 | void QGraphicsViewPrivate::translateTouchEvent(QGraphicsViewPrivate *d, QTouchEvent *touchEvent) | - |
25 | { | - |
26 | QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints(); | - |
27 | for (int i = 0; i < touchPoints.count(); ++i) { never evaluated: i < touchPoints.count() | 0 |
28 | QTouchEvent::TouchPoint &touchPoint = touchPoints[i]; | - |
29 | | - |
30 | | - |
31 | touchPoint.setSceneRect(d->mapToScene(touchPoint.rect())); | - |
32 | touchPoint.setStartScenePos(d->mapToScene(touchPoint.startPos())); | - |
33 | touchPoint.setLastScenePos(d->mapToScene(touchPoint.lastPos())); | - |
34 | | - |
35 | | - |
36 | } | 0 |
37 | | - |
38 | touchEvent->setTouchPoints(touchPoints); | - |
39 | } | 0 |
40 | | - |
41 | | - |
42 | | - |
43 | | - |
44 | QGraphicsViewPrivate::QGraphicsViewPrivate() | - |
45 | : renderHints(QPainter::TextAntialiasing), | - |
46 | dragMode(QGraphicsView::NoDrag), | - |
47 | sceneInteractionAllowed(true), hasSceneRect(false), | - |
48 | connectedToScene(false), | - |
49 | useLastMouseEvent(false), | - |
50 | identityMatrix(true), | - |
51 | dirtyScroll(true), | - |
52 | accelerateScrolling(true), | - |
53 | keepLastCenterPoint(true), | - |
54 | transforming(false), | - |
55 | handScrolling(false), | - |
56 | mustAllocateStyleOptions(false), | - |
57 | mustResizeBackgroundPixmap(true), | - |
58 | fullUpdatePending(true), | - |
59 | hasUpdateClip(false), | - |
60 | mousePressButton(Qt::NoButton), | - |
61 | leftIndent(0), topIndent(0), | - |
62 | lastMouseEvent(QEvent::None, QPointF(), QPointF(), QPointF(), Qt::NoButton, 0, 0), | - |
63 | alignment(Qt::AlignCenter), | - |
64 | transformationAnchor(QGraphicsView::AnchorViewCenter), resizeAnchor(QGraphicsView::NoAnchor), | - |
65 | viewportUpdateMode(QGraphicsView::MinimalViewportUpdate), | - |
66 | optimizationFlags(0), | - |
67 | scene(0), | - |
68 | | - |
69 | rubberBanding(false), | - |
70 | rubberBandSelectionMode(Qt::IntersectsItemShape), | - |
71 | | - |
72 | handScrollMotions(0), cacheMode(0), | - |
73 | | - |
74 | hasStoredOriginalCursor(false), | - |
75 | | - |
76 | lastDragDropEvent(0), | - |
77 | updateSceneSlotReimplementedChecked(false) | - |
78 | { | - |
79 | styleOptions.reserve(QGRAPHICSVIEW_PREALLOC_STYLE_OPTIONS); | - |
80 | } executed: } Execution Count:799 | 799 |
81 | | - |
82 | | - |
83 | | - |
84 | | - |
85 | void QGraphicsViewPrivate::recalculateContentSize() | - |
86 | { | - |
87 | QGraphicsView * const q = q_func(); | - |
88 | | - |
89 | QSize maxSize = q->maximumViewportSize(); | - |
90 | int width = maxSize.width(); | - |
91 | int height = maxSize.height(); | - |
92 | QRectF viewRect = matrix.mapRect(q->sceneRect()); | - |
93 | | - |
94 | bool frameOnlyAround = (q->style()->styleHint(QStyle::SH_ScrollView_FrameOnlyAroundContents, 0, q)); | - |
95 | if (frameOnlyAround) { partially evaluated: frameOnlyAround no Evaluation Count:0 | yes Evaluation Count:3703 |
| 0-3703 |
96 | if (hbarpolicy == Qt::ScrollBarAlwaysOn) never evaluated: hbarpolicy == Qt::ScrollBarAlwaysOn | 0 |
97 | height -= frameWidth * 2; never executed: height -= frameWidth * 2; | 0 |
98 | if (vbarpolicy == Qt::ScrollBarAlwaysOn) never evaluated: vbarpolicy == Qt::ScrollBarAlwaysOn | 0 |
99 | width -= frameWidth * 2; never executed: width -= frameWidth * 2; | 0 |
100 | } | 0 |
101 | | - |
102 | | - |
103 | | - |
104 | int scrollBarExtent = q->style()->pixelMetric(QStyle::PM_ScrollBarExtent, 0, q); | - |
105 | if (frameOnlyAround) partially evaluated: frameOnlyAround no Evaluation Count:0 | yes Evaluation Count:3703 |
| 0-3703 |
106 | scrollBarExtent += frameWidth * 2; never executed: scrollBarExtent += frameWidth * 2; | 0 |
107 | | - |
108 | | - |
109 | | - |
110 | bool useHorizontalScrollBar = (viewRect.width() > width) && hbarpolicy == Qt::ScrollBarAsNeeded; evaluated: (viewRect.width() > width) yes Evaluation Count:702 | yes Evaluation Count:3001 |
evaluated: hbarpolicy == Qt::ScrollBarAsNeeded yes Evaluation Count:414 | yes Evaluation Count:288 |
| 288-3001 |
111 | bool useVerticalScrollBar = (viewRect.height() > height) && vbarpolicy == Qt::ScrollBarAsNeeded; evaluated: (viewRect.height() > height) yes Evaluation Count:876 | yes Evaluation Count:2827 |
evaluated: vbarpolicy == Qt::ScrollBarAsNeeded yes Evaluation Count:612 | yes Evaluation Count:264 |
| 264-2827 |
112 | if (useHorizontalScrollBar && vbarpolicy == Qt::ScrollBarAsNeeded) { evaluated: useHorizontalScrollBar yes Evaluation Count:414 | yes Evaluation Count:3289 |
partially evaluated: vbarpolicy == Qt::ScrollBarAsNeeded yes Evaluation Count:414 | no Evaluation Count:0 |
| 0-3289 |
113 | if (viewRect.height() > height - scrollBarExtent) evaluated: viewRect.height() > height - scrollBarExtent yes Evaluation Count:393 | yes Evaluation Count:21 |
| 21-393 |
114 | useVerticalScrollBar = true; executed: useVerticalScrollBar = true; Execution Count:393 | 393 |
115 | } executed: } Execution Count:414 | 414 |
116 | if (useVerticalScrollBar && hbarpolicy == Qt::ScrollBarAsNeeded) { evaluated: useVerticalScrollBar yes Evaluation Count:626 | yes Evaluation Count:3077 |
partially evaluated: hbarpolicy == Qt::ScrollBarAsNeeded yes Evaluation Count:626 | no Evaluation Count:0 |
| 0-3077 |
117 | if (viewRect.width() > width - scrollBarExtent) evaluated: viewRect.width() > width - scrollBarExtent yes Evaluation Count:407 | yes Evaluation Count:219 |
| 219-407 |
118 | useHorizontalScrollBar = true; executed: useHorizontalScrollBar = true; Execution Count:407 | 407 |
119 | } executed: } Execution Count:626 | 626 |
120 | if (useHorizontalScrollBar) evaluated: useHorizontalScrollBar yes Evaluation Count:428 | yes Evaluation Count:3275 |
| 428-3275 |
121 | height -= scrollBarExtent; executed: height -= scrollBarExtent; Execution Count:428 | 428 |
122 | if (useVerticalScrollBar) evaluated: useVerticalScrollBar yes Evaluation Count:626 | yes Evaluation Count:3077 |
| 626-3077 |
123 | width -= scrollBarExtent; executed: width -= scrollBarExtent; Execution Count:626 | 626 |
124 | | - |
125 | | - |
126 | | - |
127 | | - |
128 | QPointF savedLastCenterPoint = lastCenterPoint; | - |
129 | | - |
130 | | - |
131 | qreal oldLeftIndent = leftIndent; | - |
132 | qreal oldTopIndent = topIndent; | - |
133 | | - |
134 | | - |
135 | | - |
136 | int left = q_round_bound(viewRect.left()); | - |
137 | int right = q_round_bound(viewRect.right() - width); | - |
138 | if (left >= right) { evaluated: left >= right yes Evaluation Count:2987 | yes Evaluation Count:716 |
| 716-2987 |
139 | hbar->setRange(0, 0); | - |
140 | | - |
141 | switch (alignment & Qt::AlignHorizontal_Mask) { | - |
142 | case Qt::AlignLeft: | - |
143 | leftIndent = -viewRect.left(); | - |
144 | break; executed: break; Execution Count:14 | 14 |
145 | case Qt::AlignRight: | - |
146 | leftIndent = width - viewRect.width() - viewRect.left() - 1; | - |
147 | break; executed: break; Execution Count:16 | 16 |
148 | case Qt::AlignHCenter: | - |
149 | default: | - |
150 | leftIndent = width / 2 - (viewRect.left() + viewRect.right()) / 2; | - |
151 | break; executed: break; Execution Count:2957 | 2957 |
152 | } | - |
153 | } else { executed: } Execution Count:2987 | 2987 |
154 | hbar->setRange(left, right); | - |
155 | hbar->setPageStep(width); | - |
156 | hbar->setSingleStep(width / 20); | - |
157 | leftIndent = 0; | - |
158 | } executed: } Execution Count:716 | 716 |
159 | | - |
160 | | - |
161 | | - |
162 | int top = q_round_bound(viewRect.top()); | - |
163 | int bottom = q_round_bound(viewRect.bottom() - height); | - |
164 | if (top >= bottom) { evaluated: top >= bottom yes Evaluation Count:2813 | yes Evaluation Count:890 |
| 890-2813 |
165 | vbar->setRange(0, 0); | - |
166 | | - |
167 | switch (alignment & Qt::AlignVertical_Mask) { | - |
168 | case Qt::AlignTop: | - |
169 | topIndent = -viewRect.top(); | - |
170 | break; executed: break; Execution Count:16 | 16 |
171 | case Qt::AlignBottom: | - |
172 | topIndent = height - viewRect.height() - viewRect.top() - 1; | - |
173 | break; executed: break; Execution Count:14 | 14 |
174 | case Qt::AlignVCenter: | - |
175 | default: | - |
176 | topIndent = height / 2 - (viewRect.top() + viewRect.bottom()) / 2; | - |
177 | break; executed: break; Execution Count:2783 | 2783 |
178 | } | - |
179 | } else { executed: } Execution Count:2813 | 2813 |
180 | vbar->setRange(top, bottom); | - |
181 | vbar->setPageStep(height); | - |
182 | vbar->setSingleStep(height / 20); | - |
183 | topIndent = 0; | - |
184 | } executed: } Execution Count:890 | 890 |
185 | | - |
186 | | - |
187 | lastCenterPoint = savedLastCenterPoint; | - |
188 | | - |
189 | | - |
190 | | - |
191 | | - |
192 | if (oldLeftIndent != leftIndent || oldTopIndent != topIndent) { evaluated: oldLeftIndent != leftIndent yes Evaluation Count:2305 | yes Evaluation Count:1398 |
evaluated: oldTopIndent != topIndent yes Evaluation Count:85 | yes Evaluation Count:1313 |
| 85-2305 |
193 | dirtyScroll = true; | - |
194 | updateAll(); | - |
195 | } else if (q->isRightToLeft() && !leftIndent) { executed: } Execution Count:2390 evaluated: q->isRightToLeft() yes Evaluation Count:4 | yes Evaluation Count:1309 |
partially evaluated: !leftIndent yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-2390 |
196 | | - |
197 | | - |
198 | | - |
199 | | - |
200 | dirtyScroll = true; | - |
201 | } executed: } Execution Count:4 | 4 |
202 | | - |
203 | if (cacheMode & QGraphicsView::CacheBackground) { partially evaluated: cacheMode & QGraphicsView::CacheBackground no Evaluation Count:0 | yes Evaluation Count:3703 |
| 0-3703 |
204 | | - |
205 | mustResizeBackgroundPixmap = true; | - |
206 | } | 0 |
207 | } executed: } Execution Count:3703 | 3703 |
208 | | - |
209 | | - |
210 | | - |
211 | | - |
212 | void QGraphicsViewPrivate::centerView(QGraphicsView::ViewportAnchor anchor) | - |
213 | { | - |
214 | QGraphicsView * const q = q_func(); | - |
215 | switch (anchor) { | - |
216 | case QGraphicsView::AnchorUnderMouse: { | - |
217 | if (q->underMouse()) { evaluated: q->underMouse() yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
218 | | - |
219 | | - |
220 | QPointF transformationDiff = q->mapToScene(viewport->rect().center()) | - |
221 | - q->mapToScene(viewport->mapFromGlobal(QCursor::pos())); | - |
222 | q->centerOn(lastMouseMoveScenePoint + transformationDiff); | - |
223 | } else { executed: } Execution Count:1 | 1 |
224 | q->centerOn(lastCenterPoint); | - |
225 | } executed: } Execution Count:1 | 1 |
226 | break; executed: break; Execution Count:2 | 2 |
227 | } | - |
228 | case QGraphicsView::AnchorViewCenter: | - |
229 | q->centerOn(lastCenterPoint); | - |
230 | break; executed: break; Execution Count:1165 | 1165 |
231 | case QGraphicsView::NoAnchor: | - |
232 | break; executed: break; Execution Count:926 | 926 |
233 | } | - |
234 | } executed: } Execution Count:2093 | 2093 |
235 | | - |
236 | | - |
237 | | - |
238 | | - |
239 | void QGraphicsViewPrivate::updateLastCenterPoint() | - |
240 | { | - |
241 | QGraphicsView * const q = q_func(); | - |
242 | lastCenterPoint = q->mapToScene(viewport->rect().center()); | - |
243 | } executed: } Execution Count:2598 | 2598 |
244 | | - |
245 | | - |
246 | | - |
247 | | - |
248 | | - |
249 | | - |
250 | | - |
251 | qint64 QGraphicsViewPrivate::horizontalScroll() const | - |
252 | { | - |
253 | if (dirtyScroll) evaluated: dirtyScroll yes Evaluation Count:2555 | yes Evaluation Count:473161 |
| 2555-473161 |
254 | const_cast<QGraphicsViewPrivate *>(this)->updateScroll(); executed: const_cast<QGraphicsViewPrivate *>(this)->updateScroll(); Execution Count:2555 | 2555 |
255 | return scrollX; executed: return scrollX; Execution Count:475716 | 475716 |
256 | } | - |
257 | | - |
258 | | - |
259 | | - |
260 | | - |
261 | | - |
262 | | - |
263 | | - |
264 | qint64 QGraphicsViewPrivate::verticalScroll() const | - |
265 | { | - |
266 | if (dirtyScroll) evaluated: dirtyScroll yes Evaluation Count:692 | yes Evaluation Count:473569 |
| 692-473569 |
267 | const_cast<QGraphicsViewPrivate *>(this)->updateScroll(); executed: const_cast<QGraphicsViewPrivate *>(this)->updateScroll(); Execution Count:692 | 692 |
268 | return scrollY; executed: return scrollY; Execution Count:474261 | 474261 |
269 | } | - |
270 | | - |
271 | | - |
272 | | - |
273 | | - |
274 | | - |
275 | | - |
276 | QRectF QGraphicsViewPrivate::mapRectToScene(const QRect &rect) const | - |
277 | { | - |
278 | if (dirtyScroll) partially evaluated: dirtyScroll no Evaluation Count:0 | yes Evaluation Count:89 |
| 0-89 |
279 | const_cast<QGraphicsViewPrivate *>(this)->updateScroll(); never executed: const_cast<QGraphicsViewPrivate *>(this)->updateScroll(); | 0 |
280 | QRectF scrolled = QRectF(rect.translated(scrollX, scrollY)); | - |
281 | return identityMatrix ? scrolled : matrix.inverted().mapRect(scrolled); executed: return identityMatrix ? scrolled : matrix.inverted().mapRect(scrolled); Execution Count:89 | 89 |
282 | } | - |
283 | | - |
284 | | - |
285 | | - |
286 | | - |
287 | | - |
288 | | - |
289 | | - |
290 | QRectF QGraphicsViewPrivate::mapRectFromScene(const QRectF &rect) const | - |
291 | { | - |
292 | if (dirtyScroll) evaluated: dirtyScroll yes Evaluation Count:5 | yes Evaluation Count:86 |
| 5-86 |
293 | const_cast<QGraphicsViewPrivate *>(this)->updateScroll(); executed: const_cast<QGraphicsViewPrivate *>(this)->updateScroll(); Execution Count:5 | 5 |
294 | return (identityMatrix ? rect : matrix.mapRect(rect)).translated(-scrollX, -scrollY); executed: return (identityMatrix ? rect : matrix.mapRect(rect)).translated(-scrollX, -scrollY); Execution Count:91 | 91 |
295 | } | - |
296 | | - |
297 | | - |
298 | | - |
299 | | - |
300 | void QGraphicsViewPrivate::updateScroll() | - |
301 | { | - |
302 | QGraphicsView * const q = q_func(); | - |
303 | scrollX = qint64(-leftIndent); | - |
304 | if (q->isRightToLeft()) { evaluated: q->isRightToLeft() yes Evaluation Count:6 | yes Evaluation Count:3246 |
| 6-3246 |
305 | if (!leftIndent) { partially evaluated: !leftIndent yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
306 | scrollX += hbar->minimum(); | - |
307 | scrollX += hbar->maximum(); | - |
308 | scrollX -= hbar->value(); | - |
309 | } executed: } Execution Count:6 | 6 |
310 | } else { executed: } Execution Count:6 | 6 |
311 | scrollX += hbar->value(); | - |
312 | } executed: } Execution Count:3246 | 3246 |
313 | | - |
314 | scrollY = qint64(vbar->value() - topIndent); | - |
315 | | - |
316 | dirtyScroll = false; | - |
317 | } executed: } Execution Count:3252 | 3252 |
318 | | - |
319 | | - |
320 | | - |
321 | | - |
322 | void QGraphicsViewPrivate::replayLastMouseEvent() | - |
323 | { | - |
324 | if (!useLastMouseEvent || !scene) evaluated: !useLastMouseEvent yes Evaluation Count:2822 | yes Evaluation Count:23 |
evaluated: !scene yes Evaluation Count:8 | yes Evaluation Count:15 |
| 8-2822 |
325 | return; executed: return; Execution Count:2830 | 2830 |
326 | mouseMoveEventHandler(&lastMouseEvent); | - |
327 | } executed: } Execution Count:15 | 15 |
328 | | - |
329 | | - |
330 | | - |
331 | | - |
332 | void QGraphicsViewPrivate::storeMouseEvent(QMouseEvent *event) | - |
333 | { | - |
334 | useLastMouseEvent = true; | - |
335 | lastMouseEvent = QMouseEvent(QEvent::MouseMove, event->localPos(), event->windowPos(), event->screenPos(), | - |
336 | event->button(), event->buttons(), event->modifiers()); | - |
337 | } executed: } Execution Count:548 | 548 |
338 | | - |
339 | void QGraphicsViewPrivate::mouseMoveEventHandler(QMouseEvent *event) | - |
340 | { | - |
341 | QGraphicsView * const q = q_func(); | - |
342 | | - |
343 | | - |
344 | updateRubberBand(event); | - |
345 | | - |
346 | | - |
347 | storeMouseEvent(event); | - |
348 | lastMouseEvent.setAccepted(false); | - |
349 | | - |
350 | if (!sceneInteractionAllowed) evaluated: !sceneInteractionAllowed yes Evaluation Count:16 | yes Evaluation Count:83 |
| 16-83 |
351 | return; executed: return; Execution Count:16 | 16 |
352 | if (handScrolling) evaluated: handScrolling yes Evaluation Count:24 | yes Evaluation Count:59 |
| 24-59 |
353 | return; executed: return; Execution Count:24 | 24 |
354 | if (!scene) evaluated: !scene yes Evaluation Count:2 | yes Evaluation Count:57 |
| 2-57 |
355 | return; executed: return; Execution Count:2 | 2 |
356 | | - |
357 | QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseMove); | - |
358 | mouseEvent.setWidget(viewport); | - |
359 | mouseEvent.setButtonDownScenePos(mousePressButton, mousePressScenePoint); | - |
360 | mouseEvent.setButtonDownScreenPos(mousePressButton, mousePressScreenPoint); | - |
361 | mouseEvent.setScenePos(q->mapToScene(event->pos())); | - |
362 | mouseEvent.setScreenPos(event->globalPos()); | - |
363 | mouseEvent.setLastScenePos(lastMouseMoveScenePoint); | - |
364 | mouseEvent.setLastScreenPos(lastMouseMoveScreenPoint); | - |
365 | mouseEvent.setButtons(event->buttons()); | - |
366 | mouseEvent.setButton(event->button()); | - |
367 | mouseEvent.setModifiers(event->modifiers()); | - |
368 | lastMouseMoveScenePoint = mouseEvent.scenePos(); | - |
369 | lastMouseMoveScreenPoint = mouseEvent.screenPos(); | - |
370 | mouseEvent.setAccepted(false); | - |
371 | if (event->spontaneous()) evaluated: event->spontaneous() yes Evaluation Count:18 | yes Evaluation Count:39 |
| 18-39 |
372 | qt_sendSpontaneousEvent(scene, &mouseEvent); executed: qt_sendSpontaneousEvent(scene, &mouseEvent); Execution Count:18 | 18 |
373 | else | - |
374 | QApplication::sendEvent(scene, &mouseEvent); executed: QApplication::sendEvent(scene, &mouseEvent); Execution Count:39 | 39 |
375 | | - |
376 | | - |
377 | lastMouseEvent.setAccepted(mouseEvent.isAccepted()); | - |
378 | | - |
379 | if (mouseEvent.isAccepted() && mouseEvent.buttons() != 0) { evaluated: mouseEvent.isAccepted() yes Evaluation Count:1 | yes Evaluation Count:56 |
partially evaluated: mouseEvent.buttons() != 0 yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-56 |
380 | | - |
381 | | - |
382 | return; executed: return; Execution Count:1 | 1 |
383 | } | - |
384 | | - |
385 | | - |
386 | | - |
387 | | - |
388 | | - |
389 | | - |
390 | if (scene->d_func()->allItemsIgnoreHoverEvents && !scene->d_func()->allItemsUseDefaultCursor partially evaluated: scene->d_func()->allItemsIgnoreHoverEvents yes Evaluation Count:56 | no Evaluation Count:0 |
evaluated: !scene->d_func()->allItemsUseDefaultCursor yes Evaluation Count:37 | yes Evaluation Count:19 |
| 0-56 |
391 | && scene->d_func()->cachedItemsUnderMouse.isEmpty()) { partially evaluated: scene->d_func()->cachedItemsUnderMouse.isEmpty() yes Evaluation Count:37 | no Evaluation Count:0 |
| 0-37 |
392 | scene->d_func()->cachedItemsUnderMouse = scene->d_func()->itemsAtPosition(mouseEvent.screenPos(), | - |
393 | mouseEvent.scenePos(), | - |
394 | mouseEvent.widget()); | - |
395 | } executed: } Execution Count:37 | 37 |
396 | | - |
397 | for (QForeachContainer<__typeof__(scene->d_func()->cachedItemsUnderMouse)> _container_(scene->d_func()->cachedItemsUnderMouse); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
398 | if (item->hasCursor()) { evaluated: item->hasCursor() yes Evaluation Count:20 | yes Evaluation Count:4 |
| 4-20 |
399 | _q_setViewportCursor(item->cursor()); | - |
400 | return; executed: return; Execution Count:20 | 20 |
401 | } | - |
402 | } executed: } Execution Count:4 | 4 |
403 | | - |
404 | | - |
405 | if (hasStoredOriginalCursor) { evaluated: hasStoredOriginalCursor yes Evaluation Count:6 | yes Evaluation Count:30 |
| 6-30 |
406 | | - |
407 | hasStoredOriginalCursor = false; | - |
408 | viewport->setCursor(originalCursor); | - |
409 | } executed: } Execution Count:6 | 6 |
410 | | - |
411 | } executed: } Execution Count:36 | 36 |
412 | | - |
413 | | - |
414 | | - |
415 | | - |
416 | | - |
417 | QRegion QGraphicsViewPrivate::rubberBandRegion(const QWidget *widget, const QRect &rect) const | - |
418 | { | - |
419 | QStyleHintReturnMask mask; | - |
420 | QStyleOptionRubberBand option; | - |
421 | option.initFrom(widget); | - |
422 | option.rect = rect; | - |
423 | option.opaque = false; | - |
424 | option.shape = QRubberBand::Rectangle; | - |
425 | | - |
426 | QRegion tmp; | - |
427 | tmp += rect; | - |
428 | if (widget->style()->styleHint(QStyle::SH_RubberBand_Mask, &option, widget, &mask)) partially evaluated: widget->style()->styleHint(QStyle::SH_RubberBand_Mask, &option, widget, &mask) yes Evaluation Count:13 | no Evaluation Count:0 |
| 0-13 |
429 | tmp &= mask.region; executed: tmp &= mask.region; Execution Count:13 | 13 |
430 | return tmp; executed: return tmp; Execution Count:13 | 13 |
431 | } | - |
432 | | - |
433 | void QGraphicsViewPrivate::updateRubberBand(QMouseEvent *event) | - |
434 | { | - |
435 | QGraphicsView * const q = q_func(); | - |
436 | if (dragMode == QGraphicsView::RubberBandDrag && sceneInteractionAllowed) { evaluated: dragMode == QGraphicsView::RubberBandDrag yes Evaluation Count:7 | yes Evaluation Count:92 |
partially evaluated: sceneInteractionAllowed yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-92 |
437 | storeMouseEvent(event); | - |
438 | if (rubberBanding) { partially evaluated: rubberBanding yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
439 | | - |
440 | if ((mousePressViewPoint - event->pos()).manhattanLength() | 0-7 |
441 | < QApplication::startDragDistance()) { partially evaluated: (mousePressViewPoint - event->pos()).manhattanLength() < QApplication::startDragDistance() no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
442 | return; | 0 |
443 | } | - |
444 | | - |
445 | | - |
446 | if (viewportUpdateMode != QGraphicsView::NoViewportUpdate && !rubberBandRect.isEmpty()) { partially evaluated: viewportUpdateMode != QGraphicsView::NoViewportUpdate yes Evaluation Count:7 | no Evaluation Count:0 |
evaluated: !rubberBandRect.isEmpty() yes Evaluation Count:4 | yes Evaluation Count:3 |
| 0-7 |
447 | if (viewportUpdateMode != QGraphicsView::FullViewportUpdate) partially evaluated: viewportUpdateMode != QGraphicsView::FullViewportUpdate yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
448 | q->viewport()->update(rubberBandRegion(q->viewport(), rubberBandRect)); executed: q->viewport()->update(rubberBandRegion(q->viewport(), rubberBandRect)); Execution Count:4 | 4 |
449 | else | - |
450 | updateAll(); never executed: updateAll(); | 0 |
451 | } | - |
452 | | - |
453 | | - |
454 | | - |
455 | if (!event->buttons()) { partially evaluated: !event->buttons() no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
456 | rubberBanding = false; | - |
457 | rubberBandRect = QRect(); | - |
458 | return; | 0 |
459 | } | - |
460 | | - |
461 | | - |
462 | const QPoint mp = q->mapFromScene(mousePressScenePoint); | - |
463 | const QPoint ep = event->pos(); | - |
464 | rubberBandRect = QRect(qMin(mp.x(), ep.x()), qMin(mp.y(), ep.y()), | - |
465 | qAbs(mp.x() - ep.x()) + 1, qAbs(mp.y() - ep.y()) + 1); | - |
466 | | - |
467 | | - |
468 | if (viewportUpdateMode != QGraphicsView::NoViewportUpdate){ partially evaluated: viewportUpdateMode != QGraphicsView::NoViewportUpdate yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
469 | if (viewportUpdateMode != QGraphicsView::FullViewportUpdate) partially evaluated: viewportUpdateMode != QGraphicsView::FullViewportUpdate yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
470 | q->viewport()->update(rubberBandRegion(q->viewport(), rubberBandRect)); executed: q->viewport()->update(rubberBandRegion(q->viewport(), rubberBandRect)); Execution Count:7 | 7 |
471 | else | - |
472 | updateAll(); never executed: updateAll(); | 0 |
473 | } | - |
474 | | - |
475 | QPainterPath selectionArea; | - |
476 | selectionArea.addPolygon(mapToScene(rubberBandRect)); | - |
477 | selectionArea.closeSubpath(); | - |
478 | if (scene) evaluated: scene yes Evaluation Count:5 | yes Evaluation Count:2 |
| 2-5 |
479 | scene->setSelectionArea(selectionArea, rubberBandSelectionMode, | 5 |
480 | q->viewportTransform()); executed: scene->setSelectionArea(selectionArea, rubberBandSelectionMode, q->viewportTransform()); Execution Count:5 | 5 |
481 | } executed: } Execution Count:7 | 7 |
482 | } executed: } Execution Count:7 | 7 |
483 | } executed: } Execution Count:99 | 99 |
484 | | - |
485 | | - |
486 | | - |
487 | | - |
488 | | - |
489 | | - |
490 | void QGraphicsViewPrivate::_q_setViewportCursor(const QCursor &cursor) | - |
491 | { | - |
492 | if (!hasStoredOriginalCursor) { evaluated: !hasStoredOriginalCursor yes Evaluation Count:7 | yes Evaluation Count:14 |
| 7-14 |
493 | hasStoredOriginalCursor = true; | - |
494 | originalCursor = viewport->cursor(); | - |
495 | } executed: } Execution Count:7 | 7 |
496 | viewport->setCursor(cursor); | - |
497 | } executed: } Execution Count:21 | 21 |
498 | | - |
499 | | - |
500 | | - |
501 | | - |
502 | | - |
503 | | - |
504 | void QGraphicsViewPrivate::_q_unsetViewportCursor() | - |
505 | { | - |
506 | QGraphicsView * const q = q_func(); | - |
507 | for (QForeachContainer<__typeof__(q->items(lastMouseEvent.pos()))> _container_(q->items(lastMouseEvent.pos())); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
508 | if (item->hasCursor()) { partially evaluated: item->hasCursor() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
509 | _q_setViewportCursor(item->cursor()); | - |
510 | return; | 0 |
511 | } | - |
512 | } executed: } Execution Count:1 | 1 |
513 | | - |
514 | | - |
515 | if (hasStoredOriginalCursor) { partially evaluated: hasStoredOriginalCursor no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
516 | hasStoredOriginalCursor = false; | - |
517 | if (dragMode == QGraphicsView::ScrollHandDrag) never evaluated: dragMode == QGraphicsView::ScrollHandDrag | 0 |
518 | viewport->setCursor(Qt::OpenHandCursor); never executed: viewport->setCursor(Qt::OpenHandCursor); | 0 |
519 | else | - |
520 | viewport->setCursor(originalCursor); never executed: viewport->setCursor(originalCursor); | 0 |
521 | } | - |
522 | } executed: } Execution Count:1 | 1 |
523 | | - |
524 | | - |
525 | | - |
526 | | - |
527 | | - |
528 | void QGraphicsViewPrivate::storeDragDropEvent(const QGraphicsSceneDragDropEvent *event) | - |
529 | { | - |
530 | delete lastDragDropEvent; | - |
531 | lastDragDropEvent = new QGraphicsSceneDragDropEvent(event->type()); | - |
532 | lastDragDropEvent->setScenePos(event->scenePos()); | - |
533 | lastDragDropEvent->setScreenPos(event->screenPos()); | - |
534 | lastDragDropEvent->setButtons(event->buttons()); | - |
535 | lastDragDropEvent->setModifiers(event->modifiers()); | - |
536 | lastDragDropEvent->setPossibleActions(event->possibleActions()); | - |
537 | lastDragDropEvent->setProposedAction(event->proposedAction()); | - |
538 | lastDragDropEvent->setDropAction(event->dropAction()); | - |
539 | lastDragDropEvent->setMimeData(event->mimeData()); | - |
540 | lastDragDropEvent->setWidget(event->widget()); | - |
541 | lastDragDropEvent->setSource(event->source()); | - |
542 | } | 0 |
543 | | - |
544 | | - |
545 | | - |
546 | | - |
547 | void QGraphicsViewPrivate::populateSceneDragDropEvent(QGraphicsSceneDragDropEvent *dest, | - |
548 | QDropEvent *source) | - |
549 | { | - |
550 | | - |
551 | QGraphicsView * const q = q_func(); | - |
552 | dest->setScenePos(q->mapToScene(source->pos())); | - |
553 | dest->setScreenPos(q->mapToGlobal(source->pos())); | - |
554 | dest->setButtons(source->mouseButtons()); | - |
555 | dest->setModifiers(source->keyboardModifiers()); | - |
556 | dest->setPossibleActions(source->possibleActions()); | - |
557 | dest->setProposedAction(source->proposedAction()); | - |
558 | dest->setDropAction(source->dropAction()); | - |
559 | dest->setMimeData(source->mimeData()); | - |
560 | dest->setWidget(viewport); | - |
561 | dest->setSource(qobject_cast<QWidget *>(source->source())); | - |
562 | | - |
563 | | - |
564 | | - |
565 | | - |
566 | } | 0 |
567 | | - |
568 | | - |
569 | | - |
570 | | - |
571 | QRect QGraphicsViewPrivate::mapToViewRect(const QGraphicsItem *item, const QRectF &rect) const | - |
572 | { | - |
573 | const QGraphicsView * const q = q_func(); | - |
574 | if (dirtyScroll) never evaluated: dirtyScroll | 0 |
575 | const_cast<QGraphicsViewPrivate *>(this)->updateScroll(); never executed: const_cast<QGraphicsViewPrivate *>(this)->updateScroll(); | 0 |
576 | | - |
577 | if (item->d_ptr->itemIsUntransformable()) { never evaluated: item->d_ptr->itemIsUntransformable() | 0 |
578 | QTransform itv = item->deviceTransform(q->viewportTransform()); | - |
579 | return itv.mapRect(rect).toAlignedRect(); never executed: return itv.mapRect(rect).toAlignedRect(); | 0 |
580 | } | - |
581 | | - |
582 | | - |
583 | | - |
584 | QPointF offset; | - |
585 | const QGraphicsItem *parentItem = item; | - |
586 | const QGraphicsItemPrivate *itemd; | - |
587 | do { | - |
588 | itemd = parentItem->d_ptr.data(); | - |
589 | if (itemd->transformData) never evaluated: itemd->transformData | 0 |
590 | break; | 0 |
591 | offset += itemd->pos; | - |
592 | } while ((parentItem = itemd->parent)); never evaluated: (parentItem = itemd->parent) | 0 |
593 | | - |
594 | QRectF baseRect = rect.translated(offset.x(), offset.y()); | - |
595 | if (!parentItem) { never evaluated: !parentItem | 0 |
596 | if (identityMatrix) { never evaluated: identityMatrix | 0 |
597 | baseRect.translate(-scrollX, -scrollY); | - |
598 | return baseRect.toAlignedRect(); never executed: return baseRect.toAlignedRect(); | 0 |
599 | } | - |
600 | return matrix.mapRect(baseRect).translated(-scrollX, -scrollY).toAlignedRect(); never executed: return matrix.mapRect(baseRect).translated(-scrollX, -scrollY).toAlignedRect(); | 0 |
601 | } | - |
602 | | - |
603 | QTransform tr = parentItem->sceneTransform(); | - |
604 | if (!identityMatrix) never evaluated: !identityMatrix | 0 |
605 | tr *= matrix; never executed: tr *= matrix; | 0 |
606 | QRectF r = tr.mapRect(baseRect); | - |
607 | r.translate(-scrollX, -scrollY); | - |
608 | return r.toAlignedRect(); never executed: return r.toAlignedRect(); | 0 |
609 | } | - |
610 | | - |
611 | | - |
612 | | - |
613 | | - |
614 | QRegion QGraphicsViewPrivate::mapToViewRegion(const QGraphicsItem *item, const QRectF &rect) const | - |
615 | { | - |
616 | const QGraphicsView * const q = q_func(); | - |
617 | if (dirtyScroll) never evaluated: dirtyScroll | 0 |
618 | const_cast<QGraphicsViewPrivate *>(this)->updateScroll(); never executed: const_cast<QGraphicsViewPrivate *>(this)->updateScroll(); | 0 |
619 | | - |
620 | | - |
621 | QTransform itv = item->deviceTransform(q->viewportTransform()); | - |
622 | return item->boundingRegion(itv) & itv.mapRect(rect).toAlignedRect(); never executed: return item->boundingRegion(itv) & itv.mapRect(rect).toAlignedRect(); | 0 |
623 | } | - |
624 | | - |
625 | | - |
626 | | - |
627 | | - |
628 | void QGraphicsViewPrivate::processPendingUpdates() | - |
629 | { | - |
630 | if (!scene) partially evaluated: !scene no Evaluation Count:0 | yes Evaluation Count:965 |
| 0-965 |
631 | return; | 0 |
632 | | - |
633 | if (fullUpdatePending) { evaluated: fullUpdatePending yes Evaluation Count:759 | yes Evaluation Count:206 |
| 206-759 |
634 | viewport->update(); | - |
635 | } else if (viewportUpdateMode == QGraphicsView::BoundingRectViewportUpdate) { partially evaluated: viewportUpdateMode == QGraphicsView::BoundingRectViewportUpdate no Evaluation Count:0 | yes Evaluation Count:206 |
executed: } Execution Count:759 | 0-759 |
636 | viewport->update(dirtyBoundingRect); | - |
637 | } else { | 0 |
638 | viewport->update(dirtyRegion); | - |
639 | } executed: } Execution Count:206 | 206 |
640 | | - |
641 | dirtyBoundingRect = QRect(); | - |
642 | dirtyRegion = QRegion(); | - |
643 | } executed: } Execution Count:965 | 965 |
644 | | - |
645 | static inline bool intersectsViewport(const QRect &r, int width, int height) | - |
646 | { return !(r.left() > width) && !(r.right() < 0) && !(r.top() >= height) && !(r.bottom() < 0); } executed: return !(r.left() > width) && !(r.right() < 0) && !(r.top() >= height) && !(r.bottom() < 0); Execution Count:824 | 824 |
647 | | - |
648 | static inline bool containsViewport(const QRect &r, int width, int height) | - |
649 | { return r.left() <= 0 && r.top() <= 0 && r.right() >= width - 1 && r.bottom() >= height - 1; } never executed: return r.left() <= 0 && r.top() <= 0 && r.right() >= width - 1 && r.bottom() >= height - 1; | 0 |
650 | | - |
651 | static inline void QRect_unite(QRect *rect, const QRect &other) | - |
652 | { | - |
653 | if (rect->isEmpty()) { never evaluated: rect->isEmpty() | 0 |
654 | *rect = other; | - |
655 | } else { | 0 |
656 | rect->setCoords(qMin(rect->left(), other.left()), qMin(rect->top(), other.top()), | - |
657 | qMax(rect->right(), other.right()), qMax(rect->bottom(), other.bottom())); | - |
658 | } | 0 |
659 | } | - |
660 | | - |
661 | | - |
662 | | - |
663 | | - |
664 | | - |
665 | | - |
666 | void QGraphicsViewPrivate::setUpdateClip(QGraphicsItem *item) | - |
667 | { | - |
668 | QGraphicsView * const q = q_func(); | - |
669 | | - |
670 | | - |
671 | if (!item || viewportUpdateMode == QGraphicsView::NoViewportUpdate evaluated: !item yes Evaluation Count:8 | yes Evaluation Count:7 |
partially evaluated: viewportUpdateMode == QGraphicsView::NoViewportUpdate no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-8 |
672 | || viewportUpdateMode == QGraphicsView::FullViewportUpdate) { partially evaluated: viewportUpdateMode == QGraphicsView::FullViewportUpdate no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
673 | hasUpdateClip = false; | - |
674 | return; executed: return; Execution Count:8 | 8 |
675 | } | - |
676 | | - |
677 | | - |
678 | | - |
679 | | - |
680 | | - |
681 | QRect clip; | - |
682 | if (item->d_ptr->itemIsUntransformable()) { partially evaluated: item->d_ptr->itemIsUntransformable() no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
683 | QTransform xform = item->deviceTransform(q->viewportTransform()); | - |
684 | clip = xform.mapRect(item->boundingRect()).toAlignedRect(); | - |
685 | } else if (item->d_ptr->sceneTransformTranslateOnly && identityMatrix) { partially evaluated: item->d_ptr->sceneTransformTranslateOnly yes Evaluation Count:7 | no Evaluation Count:0 |
partially evaluated: identityMatrix yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
686 | QRectF r(item->boundingRect()); | - |
687 | r.translate(item->d_ptr->sceneTransform.dx() - horizontalScroll(), | - |
688 | item->d_ptr->sceneTransform.dy() - verticalScroll()); | - |
689 | clip = r.toAlignedRect(); | - |
690 | } else if (!q->isTransformed()) { executed: } Execution Count:7 never evaluated: !q->isTransformed() | 0-7 |
691 | clip = item->d_ptr->sceneTransform.mapRect(item->boundingRect()).toAlignedRect(); | - |
692 | } else { | 0 |
693 | QTransform xform = item->d_ptr->sceneTransform; | - |
694 | xform *= q->viewportTransform(); | - |
695 | clip = xform.mapRect(item->boundingRect()).toAlignedRect(); | - |
696 | } | 0 |
697 | | - |
698 | if (hasUpdateClip) { evaluated: hasUpdateClip yes Evaluation Count:2 | yes Evaluation Count:5 |
| 2-5 |
699 | | - |
700 | updateClip &= clip; | - |
701 | } else { executed: } Execution Count:2 | 2 |
702 | updateClip = clip; | - |
703 | hasUpdateClip = true; | - |
704 | } executed: } Execution Count:5 | 5 |
705 | } | - |
706 | | - |
707 | bool QGraphicsViewPrivate::updateRegion(const QRectF &rect, const QTransform &xform) | - |
708 | { | - |
709 | if (rect.isEmpty()) never evaluated: rect.isEmpty() | 0 |
710 | return false; never executed: return false; | 0 |
711 | | - |
712 | if (viewportUpdateMode != QGraphicsView::MinimalViewportUpdate never evaluated: viewportUpdateMode != QGraphicsView::MinimalViewportUpdate | 0 |
713 | && viewportUpdateMode != QGraphicsView::SmartViewportUpdate) { never evaluated: viewportUpdateMode != QGraphicsView::SmartViewportUpdate | 0 |
714 | | - |
715 | return updateRectF(xform.mapRect(rect)); never executed: return updateRectF(xform.mapRect(rect)); | 0 |
716 | } | - |
717 | | - |
718 | | - |
719 | | - |
720 | const QRegion region = xform.map(QRegion(rect.toAlignedRect())); | - |
721 | QRect viewRect = region.boundingRect(); | - |
722 | const bool dontAdjustForAntialiasing = optimizationFlags & QGraphicsView::DontAdjustForAntialiasing; | - |
723 | if (dontAdjustForAntialiasing) never evaluated: dontAdjustForAntialiasing | 0 |
724 | viewRect.adjust(-1, -1, 1, 1); never executed: viewRect.adjust(-1, -1, 1, 1); | 0 |
725 | else | - |
726 | viewRect.adjust(-2, -2, 2, 2); never executed: viewRect.adjust(-2, -2, 2, 2); | 0 |
727 | if (!intersectsViewport(viewRect, viewport->width(), viewport->height())) never evaluated: !intersectsViewport(viewRect, viewport->width(), viewport->height()) | 0 |
728 | return false; never executed: return false; | 0 |
729 | | - |
730 | const QVector<QRect> &rects = region.rects(); | - |
731 | for (int i = 0; i < rects.size(); ++i) { never evaluated: i < rects.size() | 0 |
732 | viewRect = rects.at(i); | - |
733 | if (dontAdjustForAntialiasing) never evaluated: dontAdjustForAntialiasing | 0 |
734 | viewRect.adjust(-1, -1, 1, 1); never executed: viewRect.adjust(-1, -1, 1, 1); | 0 |
735 | else | - |
736 | viewRect.adjust(-2, -2, 2, 2); never executed: viewRect.adjust(-2, -2, 2, 2); | 0 |
737 | if (hasUpdateClip) never evaluated: hasUpdateClip | 0 |
738 | viewRect &= updateClip; never executed: viewRect &= updateClip; | 0 |
739 | dirtyRegion += viewRect; | - |
740 | } | 0 |
741 | | - |
742 | return true; never executed: return true; | 0 |
743 | } | - |
744 | | - |
745 | | - |
746 | | - |
747 | bool QGraphicsViewPrivate::updateRect(const QRect &r) | - |
748 | { | - |
749 | if (fullUpdatePending || viewportUpdateMode == QGraphicsView::NoViewportUpdate evaluated: fullUpdatePending yes Evaluation Count:5 | yes Evaluation Count:827 |
evaluated: viewportUpdateMode == QGraphicsView::NoViewportUpdate yes Evaluation Count:3 | yes Evaluation Count:824 |
| 3-827 |
750 | || !intersectsViewport(r, viewport->width(), viewport->height())) { evaluated: !intersectsViewport(r, viewport->width(), viewport->height()) yes Evaluation Count:28 | yes Evaluation Count:796 |
| 28-796 |
751 | return false; executed: return false; Execution Count:36 | 36 |
752 | } | - |
753 | | - |
754 | switch (viewportUpdateMode) { | - |
755 | case QGraphicsView::FullViewportUpdate: | - |
756 | fullUpdatePending = true; | - |
757 | viewport->update(); | - |
758 | break; executed: break; Execution Count:1 | 1 |
759 | case QGraphicsView::BoundingRectViewportUpdate: | - |
760 | if (hasUpdateClip) never evaluated: hasUpdateClip | 0 |
761 | QRect_unite(&dirtyBoundingRect, r & updateClip); never executed: QRect_unite(&dirtyBoundingRect, r & updateClip); | 0 |
762 | else | - |
763 | QRect_unite(&dirtyBoundingRect, r); never executed: QRect_unite(&dirtyBoundingRect, r); | 0 |
764 | if (containsViewport(dirtyBoundingRect, viewport->width(), viewport->height())) { never evaluated: containsViewport(dirtyBoundingRect, viewport->width(), viewport->height()) | 0 |
765 | fullUpdatePending = true; | - |
766 | viewport->update(); | - |
767 | } | 0 |
768 | break; | 0 |
769 | case QGraphicsView::SmartViewportUpdate: | - |
770 | case QGraphicsView::MinimalViewportUpdate: | - |
771 | if (hasUpdateClip) evaluated: hasUpdateClip yes Evaluation Count:2 | yes Evaluation Count:793 |
| 2-793 |
772 | dirtyRegion += r & updateClip; executed: dirtyRegion += r & updateClip; Execution Count:2 | 2 |
773 | else | - |
774 | dirtyRegion += r; executed: dirtyRegion += r; Execution Count:793 | 793 |
775 | break; executed: break; Execution Count:795 | 795 |
776 | default: | - |
777 | break; | 0 |
778 | } | - |
779 | | - |
780 | return true; executed: return true; Execution Count:796 | 796 |
781 | } | - |
782 | | - |
783 | QStyleOptionGraphicsItem *QGraphicsViewPrivate::allocStyleOptionsArray(int numItems) | - |
784 | { | - |
785 | if (mustAllocateStyleOptions || (numItems > styleOptions.capacity())) partially evaluated: mustAllocateStyleOptions no Evaluation Count:0 | yes Evaluation Count:7 |
partially evaluated: (numItems > styleOptions.capacity()) no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
786 | | - |
787 | return new QStyleOptionGraphicsItem[numItems]; never executed: return new QStyleOptionGraphicsItem[numItems]; | 0 |
788 | | - |
789 | | - |
790 | if (numItems > styleOptions.size()) evaluated: numItems > styleOptions.size() yes Evaluation Count:4 | yes Evaluation Count:3 |
| 3-4 |
791 | styleOptions.resize(numItems); executed: styleOptions.resize(numItems); Execution Count:4 | 4 |
792 | | - |
793 | mustAllocateStyleOptions = true; | - |
794 | return styleOptions.data(); executed: return styleOptions.data(); Execution Count:7 | 7 |
795 | } | - |
796 | | - |
797 | void QGraphicsViewPrivate::freeStyleOptionsArray(QStyleOptionGraphicsItem *array) | - |
798 | { | - |
799 | mustAllocateStyleOptions = false; | - |
800 | if (array != styleOptions.data()) partially evaluated: array != styleOptions.data() no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
801 | delete [] array; never executed: delete [] array; | 0 |
802 | } executed: } Execution Count:7 | 7 |
803 | | - |
804 | extern QPainterPath qt_regionToPath(const QRegion ®ion); | - |
805 | QList<QGraphicsItem *> QGraphicsViewPrivate::findItems(const QRegion &exposedRegion, bool *allItems, | - |
806 | const QTransform &viewTransform) const | - |
807 | { | - |
808 | const QGraphicsView * const q = q_func(); | - |
809 | | - |
810 | | - |
811 | | - |
812 | | - |
813 | const QRectF exposedRegionSceneBounds = q->mapToScene(exposedRegion.boundingRect().adjusted(-1, -1, 1, 1)) | - |
814 | .boundingRect(); | - |
815 | if (exposedRegionSceneBounds.contains(scene->sceneRect())) { partially evaluated: exposedRegionSceneBounds.contains(scene->sceneRect()) yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
816 | qt_noop(); | - |
817 | *allItems = true; | - |
818 | | - |
819 | | - |
820 | return scene->items(Qt::AscendingOrder); executed: return scene->items(Qt::AscendingOrder); Execution Count:6 | 6 |
821 | } | - |
822 | | - |
823 | | - |
824 | | - |
825 | | - |
826 | bool simpleRectLookup = exposedRegion.rectCount() == 1 && matrix.type() <= QTransform::TxScale; never evaluated: exposedRegion.rectCount() == 1 never evaluated: matrix.type() <= QTransform::TxScale | 0 |
827 | if (simpleRectLookup) { never evaluated: simpleRectLookup | 0 |
828 | return scene->items(exposedRegionSceneBounds, | 0 |
829 | Qt::IntersectsItemBoundingRect, | 0 |
830 | Qt::AscendingOrder, viewTransform); never executed: return scene->items(exposedRegionSceneBounds, Qt::IntersectsItemBoundingRect, Qt::AscendingOrder, viewTransform); | 0 |
831 | } | - |
832 | | - |
833 | | - |
834 | | - |
835 | | - |
836 | QRegion adjustedRegion; | - |
837 | for (QForeachContainer<__typeof__(exposedRegion.rects())> _container_(exposedRegion.rects()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QRect &r = *_container_.i;; __extension__ ({--_container_.brk; break;})) | - |
838 | adjustedRegion += r.adjusted(-1, -1, 1, 1); never executed: adjustedRegion += r.adjusted(-1, -1, 1, 1); | 0 |
839 | | - |
840 | const QPainterPath exposedScenePath(q->mapToScene(qt_regionToPath(adjustedRegion))); | - |
841 | return scene->items(exposedScenePath, Qt::IntersectsItemBoundingRect, | 0 |
842 | Qt::AscendingOrder, viewTransform); never executed: return scene->items(exposedScenePath, Qt::IntersectsItemBoundingRect, Qt::AscendingOrder, viewTransform); | 0 |
843 | } | - |
844 | void QGraphicsViewPrivate::updateInputMethodSensitivity() | - |
845 | { | - |
846 | QGraphicsView * const q = q_func(); | - |
847 | QGraphicsItem *focusItem = 0; | - |
848 | bool enabled = scene && (focusItem = scene->focusItem()) evaluated: scene yes Evaluation Count:2736 | yes Evaluation Count:33 |
evaluated: (focusItem = scene->focusItem()) yes Evaluation Count:17 | yes Evaluation Count:2719 |
| 17-2736 |
849 | && (focusItem->d_ptr->flags & QGraphicsItem::ItemAcceptsInputMethod); evaluated: (focusItem->d_ptr->flags & QGraphicsItem::ItemAcceptsInputMethod) yes Evaluation Count:11 | yes Evaluation Count:6 |
| 6-11 |
850 | q->setAttribute(Qt::WA_InputMethodEnabled, enabled); | - |
851 | q->viewport()->setAttribute(Qt::WA_InputMethodEnabled, enabled); | - |
852 | | - |
853 | if (!enabled) { evaluated: !enabled yes Evaluation Count:2758 | yes Evaluation Count:11 |
| 11-2758 |
854 | q->setInputMethodHints(0); | - |
855 | return; executed: return; Execution Count:2758 | 2758 |
856 | } | - |
857 | | - |
858 | QGraphicsProxyWidget *proxy = focusItem->d_ptr->isWidget && focusItem->d_ptr->isProxyWidget() partially evaluated: focusItem->d_ptr->isWidget no Evaluation Count:0 | yes Evaluation Count:11 |
never evaluated: focusItem->d_ptr->isProxyWidget() | 0-11 |
859 | ? static_cast<QGraphicsProxyWidget *>(focusItem) : 0; | - |
860 | if (!proxy) { partially evaluated: !proxy yes Evaluation Count:11 | no Evaluation Count:0 |
| 0-11 |
861 | q->setInputMethodHints(focusItem->inputMethodHints()); | - |
862 | } else if (QWidget *widget = proxy->widget()) { executed: } Execution Count:11 never evaluated: QWidget *widget = proxy->widget() | 0-11 |
863 | if (QWidget *fw = widget->focusWidget()) never evaluated: QWidget *fw = widget->focusWidget() | 0 |
864 | widget = fw; never executed: widget = fw; | 0 |
865 | q->setInputMethodHints(widget->inputMethodHints()); | - |
866 | } else { | 0 |
867 | q->setInputMethodHints(0); | - |
868 | } | 0 |
869 | } | - |
870 | | - |
871 | | - |
872 | | - |
873 | | - |
874 | QGraphicsView::QGraphicsView(QWidget *parent) | - |
875 | : QAbstractScrollArea(*new QGraphicsViewPrivate, parent) | - |
876 | { | - |
877 | setViewport(0); | - |
878 | setAcceptDrops(true); | - |
879 | setBackgroundRole(QPalette::Base); | - |
880 | | - |
881 | setAttribute(Qt::WA_InputMethodEnabled); | - |
882 | viewport()->setAttribute(Qt::WA_InputMethodEnabled); | - |
883 | } executed: } Execution Count:45 | 45 |
884 | | - |
885 | | - |
886 | | - |
887 | | - |
888 | | - |
889 | QGraphicsView::QGraphicsView(QGraphicsScene *scene, QWidget *parent) | - |
890 | : QAbstractScrollArea(*new QGraphicsViewPrivate, parent) | - |
891 | { | - |
892 | setScene(scene); | - |
893 | setViewport(0); | - |
894 | setAcceptDrops(true); | - |
895 | setBackgroundRole(QPalette::Base); | - |
896 | | - |
897 | setAttribute(Qt::WA_InputMethodEnabled); | - |
898 | viewport()->setAttribute(Qt::WA_InputMethodEnabled); | - |
899 | } executed: } Execution Count:754 | 754 |
900 | | - |
901 | | - |
902 | | - |
903 | | - |
904 | QGraphicsView::QGraphicsView(QGraphicsViewPrivate &dd, QWidget *parent) | - |
905 | : QAbstractScrollArea(dd, parent) | - |
906 | { | - |
907 | setViewport(0); | - |
908 | setAcceptDrops(true); | - |
909 | setBackgroundRole(QPalette::Base); | - |
910 | | - |
911 | setAttribute(Qt::WA_InputMethodEnabled); | - |
912 | viewport()->setAttribute(Qt::WA_InputMethodEnabled); | - |
913 | } | 0 |
914 | | - |
915 | | - |
916 | | - |
917 | | - |
918 | QGraphicsView::~QGraphicsView() | - |
919 | { | - |
920 | QGraphicsViewPrivate * const d = d_func(); | - |
921 | if (d->scene) evaluated: d->scene yes Evaluation Count:761 | yes Evaluation Count:31 |
| 31-761 |
922 | d->scene->d_func()->views.removeAll(this); executed: d->scene->d_func()->views.removeAll(this); Execution Count:761 | 761 |
923 | delete d->lastDragDropEvent; | - |
924 | } executed: } Execution Count:792 | 792 |
925 | | - |
926 | | - |
927 | | - |
928 | | - |
929 | QSize QGraphicsView::sizeHint() const | - |
930 | { | - |
931 | const QGraphicsViewPrivate * const d = d_func(); | - |
932 | if (d->scene) { evaluated: d->scene yes Evaluation Count:210 | yes Evaluation Count:46 |
| 46-210 |
933 | QSizeF baseSize = d->matrix.mapRect(sceneRect()).size(); | - |
934 | baseSize += QSizeF(d->frameWidth * 2, d->frameWidth * 2); | - |
935 | return baseSize.boundedTo((3 * QApplication::desktop()->size()) / 4).toSize(); executed: return baseSize.boundedTo((3 * QApplication::desktop()->size()) / 4).toSize(); Execution Count:210 | 210 |
936 | } | - |
937 | return QAbstractScrollArea::sizeHint(); executed: return QAbstractScrollArea::sizeHint(); Execution Count:46 | 46 |
938 | } | - |
939 | QPainter::RenderHints QGraphicsView::renderHints() const | - |
940 | { | - |
941 | const QGraphicsViewPrivate * const d = d_func(); | - |
942 | return d->renderHints; executed: return d->renderHints; Execution Count:15 | 15 |
943 | } | - |
944 | void QGraphicsView::setRenderHints(QPainter::RenderHints hints) | - |
945 | { | - |
946 | QGraphicsViewPrivate * const d = d_func(); | - |
947 | if (hints == d->renderHints) partially evaluated: hints == d->renderHints no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
948 | return; | 0 |
949 | d->renderHints = hints; | - |
950 | d->updateAll(); | - |
951 | } executed: } Execution Count:3 | 3 |
952 | | - |
953 | | - |
954 | | - |
955 | | - |
956 | | - |
957 | | - |
958 | | - |
959 | void QGraphicsView::setRenderHint(QPainter::RenderHint hint, bool enabled) | - |
960 | { | - |
961 | QGraphicsViewPrivate * const d = d_func(); | - |
962 | QPainter::RenderHints oldHints = d->renderHints; | - |
963 | if (enabled) evaluated: enabled yes Evaluation Count:402 | yes Evaluation Count:21 |
| 21-402 |
964 | d->renderHints |= hint; executed: d->renderHints |= hint; Execution Count:402 | 402 |
965 | else | - |
966 | d->renderHints &= ~hint; executed: d->renderHints &= ~hint; Execution Count:21 | 21 |
967 | if (oldHints != d->renderHints) evaluated: oldHints != d->renderHints yes Evaluation Count:403 | yes Evaluation Count:20 |
| 20-403 |
968 | d->updateAll(); executed: d->updateAll(); Execution Count:403 | 403 |
969 | } executed: } Execution Count:423 | 423 |
970 | Qt::Alignment QGraphicsView::alignment() const | - |
971 | { | - |
972 | const QGraphicsViewPrivate * const d = d_func(); | - |
973 | return d->alignment; executed: return d->alignment; Execution Count:9 | 9 |
974 | } | - |
975 | void QGraphicsView::setAlignment(Qt::Alignment alignment) | - |
976 | { | - |
977 | QGraphicsViewPrivate * const d = d_func(); | - |
978 | if (d->alignment != alignment) { partially evaluated: d->alignment != alignment yes Evaluation Count:15 | no Evaluation Count:0 |
| 0-15 |
979 | d->alignment = alignment; | - |
980 | d->recalculateContentSize(); | - |
981 | } executed: } Execution Count:15 | 15 |
982 | } executed: } Execution Count:15 | 15 |
983 | QGraphicsView::ViewportAnchor QGraphicsView::transformationAnchor() const | - |
984 | { | - |
985 | const QGraphicsViewPrivate * const d = d_func(); | - |
986 | return d->transformationAnchor; executed: return d->transformationAnchor; Execution Count:2 | 2 |
987 | } | - |
988 | void QGraphicsView::setTransformationAnchor(ViewportAnchor anchor) | - |
989 | { | - |
990 | QGraphicsViewPrivate * const d = d_func(); | - |
991 | d->transformationAnchor = anchor; | - |
992 | | - |
993 | | - |
994 | | - |
995 | if (d->transformationAnchor == AnchorUnderMouse) evaluated: d->transformationAnchor == AnchorUnderMouse yes Evaluation Count:5 | yes Evaluation Count:12 |
| 5-12 |
996 | d->viewport->setMouseTracking(true); executed: d->viewport->setMouseTracking(true); Execution Count:5 | 5 |
997 | } executed: } Execution Count:17 | 17 |
998 | QGraphicsView::ViewportAnchor QGraphicsView::resizeAnchor() const | - |
999 | { | - |
1000 | const QGraphicsViewPrivate * const d = d_func(); | - |
1001 | return d->resizeAnchor; executed: return d->resizeAnchor; Execution Count:2 | 2 |
1002 | } | - |
1003 | void QGraphicsView::setResizeAnchor(ViewportAnchor anchor) | - |
1004 | { | - |
1005 | QGraphicsViewPrivate * const d = d_func(); | - |
1006 | d->resizeAnchor = anchor; | - |
1007 | | - |
1008 | | - |
1009 | | - |
1010 | if (d->resizeAnchor == AnchorUnderMouse) evaluated: d->resizeAnchor == AnchorUnderMouse yes Evaluation Count:4 | yes Evaluation Count:11 |
| 4-11 |
1011 | d->viewport->setMouseTracking(true); executed: d->viewport->setMouseTracking(true); Execution Count:4 | 4 |
1012 | } executed: } Execution Count:15 | 15 |
1013 | QGraphicsView::ViewportUpdateMode QGraphicsView::viewportUpdateMode() const | - |
1014 | { | - |
1015 | const QGraphicsViewPrivate * const d = d_func(); | - |
1016 | return d->viewportUpdateMode; executed: return d->viewportUpdateMode; Execution Count:4 | 4 |
1017 | } | - |
1018 | void QGraphicsView::setViewportUpdateMode(ViewportUpdateMode mode) | - |
1019 | { | - |
1020 | QGraphicsViewPrivate * const d = d_func(); | - |
1021 | d->viewportUpdateMode = mode; | - |
1022 | } executed: } Execution Count:5 | 5 |
1023 | QGraphicsView::OptimizationFlags QGraphicsView::optimizationFlags() const | - |
1024 | { | - |
1025 | const QGraphicsViewPrivate * const d = d_func(); | - |
1026 | return d->optimizationFlags; executed: return d->optimizationFlags; Execution Count:8 | 8 |
1027 | } | - |
1028 | void QGraphicsView::setOptimizationFlags(OptimizationFlags flags) | - |
1029 | { | - |
1030 | QGraphicsViewPrivate * const d = d_func(); | - |
1031 | d->optimizationFlags = flags; | - |
1032 | } executed: } Execution Count:2 | 2 |
1033 | | - |
1034 | | - |
1035 | | - |
1036 | | - |
1037 | | - |
1038 | | - |
1039 | void QGraphicsView::setOptimizationFlag(OptimizationFlag flag, bool enabled) | - |
1040 | { | - |
1041 | QGraphicsViewPrivate * const d = d_func(); | - |
1042 | if (enabled) evaluated: enabled yes Evaluation Count:30 | yes Evaluation Count:20 |
| 20-30 |
1043 | d->optimizationFlags |= flag; executed: d->optimizationFlags |= flag; Execution Count:30 | 30 |
1044 | else | - |
1045 | d->optimizationFlags &= ~flag; executed: d->optimizationFlags &= ~flag; Execution Count:20 | 20 |
1046 | } | - |
1047 | QGraphicsView::DragMode QGraphicsView::dragMode() const | - |
1048 | { | - |
1049 | const QGraphicsViewPrivate * const d = d_func(); | - |
1050 | return d->dragMode; executed: return d->dragMode; Execution Count:14 | 14 |
1051 | } | - |
1052 | void QGraphicsView::setDragMode(DragMode mode) | - |
1053 | { | - |
1054 | QGraphicsViewPrivate * const d = d_func(); | - |
1055 | if (d->dragMode == mode) partially evaluated: d->dragMode == mode no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
1056 | return; | 0 |
1057 | | - |
1058 | | - |
1059 | if (d->dragMode == ScrollHandDrag) evaluated: d->dragMode == ScrollHandDrag yes Evaluation Count:2 | yes Evaluation Count:9 |
| 2-9 |
1060 | viewport()->unsetCursor(); executed: viewport()->unsetCursor(); Execution Count:2 | 2 |
1061 | | - |
1062 | | - |
1063 | | - |
1064 | | - |
1065 | | - |
1066 | | - |
1067 | if (d->dragMode == ScrollHandDrag && mode == NoDrag && d->handScrolling) evaluated: d->dragMode == ScrollHandDrag yes Evaluation Count:2 | yes Evaluation Count:9 |
partially evaluated: mode == NoDrag yes Evaluation Count:2 | no Evaluation Count:0 |
evaluated: d->handScrolling yes Evaluation Count:1 | yes Evaluation Count:1 |
| 0-9 |
1068 | d->handScrolling = false; executed: d->handScrolling = false; Execution Count:1 | 1 |
1069 | | - |
1070 | d->dragMode = mode; | - |
1071 | | - |
1072 | | - |
1073 | if (d->dragMode == ScrollHandDrag) { evaluated: d->dragMode == ScrollHandDrag yes Evaluation Count:6 | yes Evaluation Count:5 |
| 5-6 |
1074 | | - |
1075 | d->hasStoredOriginalCursor = false; | - |
1076 | viewport()->setCursor(Qt::OpenHandCursor); | - |
1077 | } executed: } Execution Count:6 | 6 |
1078 | | - |
1079 | } executed: } Execution Count:11 | 11 |
1080 | Qt::ItemSelectionMode QGraphicsView::rubberBandSelectionMode() const | - |
1081 | { | - |
1082 | const QGraphicsViewPrivate * const d = d_func(); | - |
1083 | return d->rubberBandSelectionMode; executed: return d->rubberBandSelectionMode; Execution Count:2 | 2 |
1084 | } | - |
1085 | void QGraphicsView::setRubberBandSelectionMode(Qt::ItemSelectionMode mode) | - |
1086 | { | - |
1087 | QGraphicsViewPrivate * const d = d_func(); | - |
1088 | d->rubberBandSelectionMode = mode; | - |
1089 | } executed: } Execution Count:1 | 1 |
1090 | QGraphicsView::CacheMode QGraphicsView::cacheMode() const | - |
1091 | { | - |
1092 | const QGraphicsViewPrivate * const d = d_func(); | - |
1093 | return d->cacheMode; never executed: return d->cacheMode; | 0 |
1094 | } | - |
1095 | void QGraphicsView::setCacheMode(CacheMode mode) | - |
1096 | { | - |
1097 | QGraphicsViewPrivate * const d = d_func(); | - |
1098 | if (mode == d->cacheMode) partially evaluated: mode == d->cacheMode no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1099 | return; | 0 |
1100 | d->cacheMode = mode; | - |
1101 | resetCachedContent(); | - |
1102 | } executed: } Execution Count:1 | 1 |
1103 | void QGraphicsView::resetCachedContent() | - |
1104 | { | - |
1105 | QGraphicsViewPrivate * const d = d_func(); | - |
1106 | if (d->cacheMode == CacheNone) evaluated: d->cacheMode == CacheNone yes Evaluation Count:153 | yes Evaluation Count:1 |
| 1-153 |
1107 | return; executed: return; Execution Count:153 | 153 |
1108 | | - |
1109 | if (d->cacheMode & CacheBackground) { partially evaluated: d->cacheMode & CacheBackground yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1110 | | - |
1111 | d->mustResizeBackgroundPixmap = true; | - |
1112 | d->updateAll(); | - |
1113 | } else if (d->mustResizeBackgroundPixmap) { executed: } Execution Count:1 never evaluated: d->mustResizeBackgroundPixmap | 0-1 |
1114 | | - |
1115 | | - |
1116 | d->mustResizeBackgroundPixmap = false; | - |
1117 | d->backgroundPixmap = QPixmap(); | - |
1118 | d->backgroundPixmapExposed = QRegion(); | - |
1119 | } | 0 |
1120 | } | - |
1121 | void QGraphicsView::invalidateScene(const QRectF &rect, QGraphicsScene::SceneLayers layers) | - |
1122 | { | - |
1123 | QGraphicsViewPrivate * const d = d_func(); | - |
1124 | if ((layers & QGraphicsScene::BackgroundLayer) && !d->mustResizeBackgroundPixmap) { never evaluated: (layers & QGraphicsScene::BackgroundLayer) never evaluated: !d->mustResizeBackgroundPixmap | 0 |
1125 | QRect viewRect = mapFromScene(rect).boundingRect(); | - |
1126 | if (viewport()->rect().intersects(viewRect)) { never evaluated: viewport()->rect().intersects(viewRect) | 0 |
1127 | | - |
1128 | | - |
1129 | d->backgroundPixmapExposed += viewRect; | - |
1130 | if (d->scene) never evaluated: d->scene | 0 |
1131 | d->scene->update(rect); never executed: d->scene->update(rect); | 0 |
1132 | } | 0 |
1133 | } | 0 |
1134 | } | 0 |
1135 | bool QGraphicsView::isInteractive() const | - |
1136 | { | - |
1137 | const QGraphicsViewPrivate * const d = d_func(); | - |
1138 | return d->sceneInteractionAllowed; executed: return d->sceneInteractionAllowed; Execution Count:5 | 5 |
1139 | } | - |
1140 | void QGraphicsView::setInteractive(bool allowed) | - |
1141 | { | - |
1142 | QGraphicsViewPrivate * const d = d_func(); | - |
1143 | d->sceneInteractionAllowed = allowed; | - |
1144 | } executed: } Execution Count:3 | 3 |
1145 | | - |
1146 | | - |
1147 | | - |
1148 | | - |
1149 | | - |
1150 | | - |
1151 | | - |
1152 | QGraphicsScene *QGraphicsView::scene() const | - |
1153 | { | - |
1154 | const QGraphicsViewPrivate * const d = d_func(); | - |
1155 | return d->scene; executed: return d->scene; Execution Count:32 | 32 |
1156 | } | - |
1157 | void QGraphicsView::setScene(QGraphicsScene *scene) | - |
1158 | { | - |
1159 | QGraphicsViewPrivate * const d = d_func(); | - |
1160 | if (d->scene == scene) evaluated: d->scene == scene yes Evaluation Count:28 | yes Evaluation Count:806 |
| 28-806 |
1161 | return; executed: return; Execution Count:28 | 28 |
1162 | | - |
1163 | | - |
1164 | d->updateAll(); | - |
1165 | | - |
1166 | | - |
1167 | if (d->scene) { evaluated: d->scene yes Evaluation Count:22 | yes Evaluation Count:784 |
| 22-784 |
1168 | disconnect(d->scene, "2""changed(QList<QRectF>)", | - |
1169 | this, "1""updateScene(QList<QRectF>)"); | - |
1170 | disconnect(d->scene, "2""sceneRectChanged(QRectF)", | - |
1171 | this, "1""updateSceneRect(QRectF)"); | - |
1172 | d->scene->d_func()->removeView(this); | - |
1173 | d->connectedToScene = false; | - |
1174 | | - |
1175 | if (isActiveWindow() && isVisible()) { evaluated: isActiveWindow() yes Evaluation Count:10 | yes Evaluation Count:12 |
partially evaluated: isVisible() yes Evaluation Count:10 | no Evaluation Count:0 |
| 0-12 |
1176 | QEvent windowDeactivate(QEvent::WindowDeactivate); | - |
1177 | QApplication::sendEvent(d->scene, &windowDeactivate); | - |
1178 | } executed: } Execution Count:10 | 10 |
1179 | if(hasFocus()) evaluated: hasFocus() yes Evaluation Count:8 | yes Evaluation Count:14 |
| 8-14 |
1180 | d->scene->clearFocus(); executed: d->scene->clearFocus(); Execution Count:8 | 8 |
1181 | } executed: } Execution Count:22 | 22 |
1182 | | - |
1183 | | - |
1184 | if ((d->scene = scene)) { evaluated: (d->scene = scene) yes Evaluation Count:786 | yes Evaluation Count:20 |
| 20-786 |
1185 | connect(d->scene, "2""sceneRectChanged(QRectF)", | - |
1186 | this, "1""updateSceneRect(QRectF)"); | - |
1187 | d->updateSceneSlotReimplementedChecked = false; | - |
1188 | d->scene->d_func()->addView(this); | - |
1189 | d->recalculateContentSize(); | - |
1190 | d->lastCenterPoint = sceneRect().center(); | - |
1191 | d->keepLastCenterPoint = true; | - |
1192 | | - |
1193 | | - |
1194 | if (!d->scene->d_func()->allItemsIgnoreHoverEvents evaluated: !d->scene->d_func()->allItemsIgnoreHoverEvents yes Evaluation Count:6 | yes Evaluation Count:780 |
| 6-780 |
1195 | || !d->scene->d_func()->allItemsUseDefaultCursor) { evaluated: !d->scene->d_func()->allItemsUseDefaultCursor yes Evaluation Count:3 | yes Evaluation Count:777 |
| 3-777 |
1196 | d->viewport->setMouseTracking(true); | - |
1197 | } executed: } Execution Count:9 | 9 |
1198 | | - |
1199 | | - |
1200 | if (!d->scene->d_func()->allItemsIgnoreTouchEvents) partially evaluated: !d->scene->d_func()->allItemsIgnoreTouchEvents no Evaluation Count:0 | yes Evaluation Count:786 |
| 0-786 |
1201 | d->viewport->setAttribute(Qt::WA_AcceptTouchEvents); never executed: d->viewport->setAttribute(Qt::WA_AcceptTouchEvents); | 0 |
1202 | | - |
1203 | if (isActiveWindow() && isVisible()) { evaluated: isActiveWindow() yes Evaluation Count:7 | yes Evaluation Count:779 |
partially evaluated: isVisible() yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-779 |
1204 | QEvent windowActivate(QEvent::WindowActivate); | - |
1205 | QApplication::sendEvent(d->scene, &windowActivate); | - |
1206 | } executed: } Execution Count:7 | 7 |
1207 | } else { executed: } Execution Count:786 | 786 |
1208 | d->recalculateContentSize(); | - |
1209 | } executed: } Execution Count:20 | 20 |
1210 | | - |
1211 | d->updateInputMethodSensitivity(); | - |
1212 | | - |
1213 | if (d->scene && hasFocus()) evaluated: d->scene yes Evaluation Count:786 | yes Evaluation Count:20 |
evaluated: hasFocus() yes Evaluation Count:6 | yes Evaluation Count:780 |
| 6-786 |
1214 | d->scene->setFocus(); executed: d->scene->setFocus(); Execution Count:6 | 6 |
1215 | } executed: } Execution Count:806 | 806 |
1216 | QRectF QGraphicsView::sceneRect() const | - |
1217 | { | - |
1218 | const QGraphicsViewPrivate * const d = d_func(); | - |
1219 | if (d->hasSceneRect) evaluated: d->hasSceneRect yes Evaluation Count:170 | yes Evaluation Count:4552 |
| 170-4552 |
1220 | return d->sceneRect; executed: return d->sceneRect; Execution Count:170 | 170 |
1221 | if (d->scene) evaluated: d->scene yes Evaluation Count:4498 | yes Evaluation Count:54 |
| 54-4498 |
1222 | return d->scene->sceneRect(); executed: return d->scene->sceneRect(); Execution Count:4498 | 4498 |
1223 | return QRectF(); executed: return QRectF(); Execution Count:54 | 54 |
1224 | } | - |
1225 | void QGraphicsView::setSceneRect(const QRectF &rect) | - |
1226 | { | - |
1227 | QGraphicsViewPrivate * const d = d_func(); | - |
1228 | d->hasSceneRect = !rect.isNull(); | - |
1229 | d->sceneRect = rect; | - |
1230 | d->recalculateContentSize(); | - |
1231 | } executed: } Execution Count:49 | 49 |
1232 | | - |
1233 | | - |
1234 | | - |
1235 | | - |
1236 | | - |
1237 | | - |
1238 | | - |
1239 | QMatrix QGraphicsView::matrix() const | - |
1240 | { | - |
1241 | const QGraphicsViewPrivate * const d = d_func(); | - |
1242 | return d->matrix.toAffine(); executed: return d->matrix.toAffine(); Execution Count:10 | 10 |
1243 | } | - |
1244 | void QGraphicsView::setMatrix(const QMatrix &matrix, bool combine) | - |
1245 | { | - |
1246 | setTransform(QTransform(matrix), combine); | - |
1247 | } executed: } Execution Count:8 | 8 |
1248 | | - |
1249 | | - |
1250 | | - |
1251 | | - |
1252 | | - |
1253 | | - |
1254 | void QGraphicsView::resetMatrix() | - |
1255 | { | - |
1256 | resetTransform(); | - |
1257 | } executed: } Execution Count:1 | 1 |
1258 | | - |
1259 | | - |
1260 | | - |
1261 | | - |
1262 | | - |
1263 | | - |
1264 | void QGraphicsView::rotate(qreal angle) | - |
1265 | { | - |
1266 | QGraphicsViewPrivate * const d = d_func(); | - |
1267 | QTransform matrix = d->matrix; | - |
1268 | matrix.rotate(angle); | - |
1269 | setTransform(matrix); | - |
1270 | } executed: } Execution Count:245 | 245 |
1271 | | - |
1272 | | - |
1273 | | - |
1274 | | - |
1275 | | - |
1276 | | - |
1277 | void QGraphicsView::scale(qreal sx, qreal sy) | - |
1278 | { | - |
1279 | QGraphicsViewPrivate * const d = d_func(); | - |
1280 | QTransform matrix = d->matrix; | - |
1281 | matrix.scale(sx, sy); | - |
1282 | setTransform(matrix); | - |
1283 | } executed: } Execution Count:76 | 76 |
1284 | | - |
1285 | | - |
1286 | | - |
1287 | | - |
1288 | | - |
1289 | | - |
1290 | void QGraphicsView::shear(qreal sh, qreal sv) | - |
1291 | { | - |
1292 | QGraphicsViewPrivate * const d = d_func(); | - |
1293 | QTransform matrix = d->matrix; | - |
1294 | matrix.shear(sh, sv); | - |
1295 | setTransform(matrix); | - |
1296 | } executed: } Execution Count:7 | 7 |
1297 | | - |
1298 | | - |
1299 | | - |
1300 | | - |
1301 | | - |
1302 | | - |
1303 | void QGraphicsView::translate(qreal dx, qreal dy) | - |
1304 | { | - |
1305 | QGraphicsViewPrivate * const d = d_func(); | - |
1306 | QTransform matrix = d->matrix; | - |
1307 | matrix.translate(dx, dy); | - |
1308 | setTransform(matrix); | - |
1309 | } executed: } Execution Count:12 | 12 |
1310 | void QGraphicsView::centerOn(const QPointF &pos) | - |
1311 | { | - |
1312 | QGraphicsViewPrivate * const d = d_func(); | - |
1313 | qreal width = viewport()->width(); | - |
1314 | qreal height = viewport()->height(); | - |
1315 | QPointF viewPoint = d->matrix.map(pos); | - |
1316 | QPointF oldCenterPoint = pos; | - |
1317 | | - |
1318 | if (!d->leftIndent) { evaluated: !d->leftIndent yes Evaluation Count:743 | yes Evaluation Count:1019 |
| 743-1019 |
1319 | if (isRightToLeft()) { evaluated: isRightToLeft() yes Evaluation Count:1 | yes Evaluation Count:742 |
| 1-742 |
1320 | qint64 horizontal = 0; | - |
1321 | horizontal += horizontalScrollBar()->minimum(); | - |
1322 | horizontal += horizontalScrollBar()->maximum(); | - |
1323 | horizontal -= int(viewPoint.x() - width / 2.0); | - |
1324 | horizontalScrollBar()->setValue(horizontal); | - |
1325 | } else { executed: } Execution Count:1 | 1 |
1326 | horizontalScrollBar()->setValue(int(viewPoint.x() - width / 2.0)); | - |
1327 | } executed: } Execution Count:742 | 742 |
1328 | } | - |
1329 | if (!d->topIndent) evaluated: !d->topIndent yes Evaluation Count:901 | yes Evaluation Count:861 |
| 861-901 |
1330 | verticalScrollBar()->setValue(int(viewPoint.y() - height / 2.0)); executed: verticalScrollBar()->setValue(int(viewPoint.y() - height / 2.0)); Execution Count:901 | 901 |
1331 | d->lastCenterPoint = oldCenterPoint; | - |
1332 | } executed: } Execution Count:1762 | 1762 |
1333 | void QGraphicsView::centerOn(const QGraphicsItem *item) | - |
1334 | { | - |
1335 | centerOn(item->sceneBoundingRect().center()); | - |
1336 | } executed: } Execution Count:14 | 14 |
1337 | void QGraphicsView::ensureVisible(const QRectF &rect, int xmargin, int ymargin) | - |
1338 | { | - |
1339 | QGraphicsViewPrivate * const d = d_func(); | - |
1340 | qreal width = viewport()->width(); | - |
1341 | qreal height = viewport()->height(); | - |
1342 | QRectF viewRect = d->matrix.mapRect(rect); | - |
1343 | | - |
1344 | qreal left = d->horizontalScroll(); | - |
1345 | qreal right = left + width; | - |
1346 | qreal top = d->verticalScroll(); | - |
1347 | qreal bottom = top + height; | - |
1348 | | - |
1349 | if (viewRect.left() <= left + xmargin) { evaluated: viewRect.left() <= left + xmargin yes Evaluation Count:278 | yes Evaluation Count:257 |
| 257-278 |
1350 | | - |
1351 | if (!d->leftIndent) evaluated: !d->leftIndent yes Evaluation Count:259 | yes Evaluation Count:19 |
| 19-259 |
1352 | horizontalScrollBar()->setValue(int(viewRect.left() - xmargin - 0.5)); executed: horizontalScrollBar()->setValue(int(viewRect.left() - xmargin - 0.5)); Execution Count:259 | 259 |
1353 | } executed: } Execution Count:278 | 278 |
1354 | if (viewRect.right() >= right - xmargin) { evaluated: viewRect.right() >= right - xmargin yes Evaluation Count:269 | yes Evaluation Count:266 |
| 266-269 |
1355 | | - |
1356 | if (!d->leftIndent) evaluated: !d->leftIndent yes Evaluation Count:250 | yes Evaluation Count:19 |
| 19-250 |
1357 | horizontalScrollBar()->setValue(int(viewRect.right() - width + xmargin + 0.5)); executed: horizontalScrollBar()->setValue(int(viewRect.right() - width + xmargin + 0.5)); Execution Count:250 | 250 |
1358 | } executed: } Execution Count:269 | 269 |
1359 | if (viewRect.top() <= top + ymargin) { evaluated: viewRect.top() <= top + ymargin yes Evaluation Count:271 | yes Evaluation Count:264 |
| 264-271 |
1360 | | - |
1361 | if (!d->topIndent) evaluated: !d->topIndent yes Evaluation Count:265 | yes Evaluation Count:6 |
| 6-265 |
1362 | verticalScrollBar()->setValue(int(viewRect.top() - ymargin - 0.5)); executed: verticalScrollBar()->setValue(int(viewRect.top() - ymargin - 0.5)); Execution Count:265 | 265 |
1363 | } executed: } Execution Count:271 | 271 |
1364 | if (viewRect.bottom() >= bottom - ymargin) { evaluated: viewRect.bottom() >= bottom - ymargin yes Evaluation Count:279 | yes Evaluation Count:256 |
| 256-279 |
1365 | | - |
1366 | if (!d->topIndent) evaluated: !d->topIndent yes Evaluation Count:273 | yes Evaluation Count:6 |
| 6-273 |
1367 | verticalScrollBar()->setValue(int(viewRect.bottom() - height + ymargin + 0.5)); executed: verticalScrollBar()->setValue(int(viewRect.bottom() - height + ymargin + 0.5)); Execution Count:273 | 273 |
1368 | } executed: } Execution Count:279 | 279 |
1369 | } executed: } Execution Count:535 | 535 |
1370 | void QGraphicsView::ensureVisible(const QGraphicsItem *item, int xmargin, int ymargin) | - |
1371 | { | - |
1372 | ensureVisible(item->sceneBoundingRect(), xmargin, ymargin); | - |
1373 | } | 0 |
1374 | void QGraphicsView::fitInView(const QRectF &rect, Qt::AspectRatioMode aspectRatioMode) | - |
1375 | { | - |
1376 | QGraphicsViewPrivate * const d = d_func(); | - |
1377 | if (!d->scene || rect.isNull()) partially evaluated: !d->scene no Evaluation Count:0 | yes Evaluation Count:7 |
partially evaluated: rect.isNull() no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
1378 | return; | 0 |
1379 | | - |
1380 | | - |
1381 | QRectF unity = d->matrix.mapRect(QRectF(0, 0, 1, 1)); | - |
1382 | if (unity.isEmpty()) evaluated: unity.isEmpty() yes Evaluation Count:1 | yes Evaluation Count:6 |
| 1-6 |
1383 | return; executed: return; Execution Count:1 | 1 |
1384 | scale(1 / unity.width(), 1 / unity.height()); | - |
1385 | | - |
1386 | | - |
1387 | int margin = 2; | - |
1388 | QRectF viewRect = viewport()->rect().adjusted(margin, margin, -margin, -margin); | - |
1389 | if (viewRect.isEmpty()) evaluated: viewRect.isEmpty() yes Evaluation Count:2 | yes Evaluation Count:4 |
| 2-4 |
1390 | return; executed: return; Execution Count:2 | 2 |
1391 | QRectF sceneRect = d->matrix.mapRect(rect); | - |
1392 | if (sceneRect.isEmpty()) partially evaluated: sceneRect.isEmpty() no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
1393 | return; | 0 |
1394 | qreal xratio = viewRect.width() / sceneRect.width(); | - |
1395 | qreal yratio = viewRect.height() / sceneRect.height(); | - |
1396 | | - |
1397 | | - |
1398 | switch (aspectRatioMode) { | - |
1399 | case Qt::KeepAspectRatio: | - |
1400 | xratio = yratio = qMin(xratio, yratio); | - |
1401 | break; executed: break; Execution Count:1 | 1 |
1402 | case Qt::KeepAspectRatioByExpanding: | - |
1403 | xratio = yratio = qMax(xratio, yratio); | - |
1404 | break; executed: break; Execution Count:1 | 1 |
1405 | case Qt::IgnoreAspectRatio: | - |
1406 | break; executed: break; Execution Count:2 | 2 |
1407 | } | - |
1408 | | - |
1409 | | - |
1410 | scale(xratio, yratio); | - |
1411 | centerOn(rect.center()); | - |
1412 | } executed: } Execution Count:4 | 4 |
1413 | void QGraphicsView::fitInView(const QGraphicsItem *item, Qt::AspectRatioMode aspectRatioMode) | - |
1414 | { | - |
1415 | QPainterPath path = item->isClipped() ? item->clipPath() : item->shape(); partially evaluated: item->isClipped() no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
1416 | if (item->d_ptr->hasTranslateOnlySceneTransform()) { partially evaluated: item->d_ptr->hasTranslateOnlySceneTransform() no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
1417 | path.translate(item->d_ptr->sceneTransform.dx(), item->d_ptr->sceneTransform.dy()); | - |
1418 | fitInView(path.boundingRect(), aspectRatioMode); | - |
1419 | } else { | 0 |
1420 | fitInView(item->d_ptr->sceneTransform.map(path).boundingRect(), aspectRatioMode); | - |
1421 | } executed: } Execution Count:3 | 3 |
1422 | } | - |
1423 | void QGraphicsView::render(QPainter *painter, const QRectF &target, const QRect &source, | - |
1424 | Qt::AspectRatioMode aspectRatioMode) | - |
1425 | { | - |
1426 | | - |
1427 | | - |
1428 | QGraphicsViewPrivate * const d = d_func(); | - |
1429 | if (!d->scene || !(painter && painter->isActive())) partially evaluated: !d->scene no Evaluation Count:0 | yes Evaluation Count:1 |
partially evaluated: painter yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: painter->isActive() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1430 | return; | 0 |
1431 | | - |
1432 | | - |
1433 | QRect sourceRect = source; | - |
1434 | if (source.isNull()) partially evaluated: source.isNull() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1435 | sourceRect = viewport()->rect(); executed: sourceRect = viewport()->rect(); Execution Count:1 | 1 |
1436 | | - |
1437 | | - |
1438 | QRectF targetRect = target; | - |
1439 | if (target.isNull()) { partially evaluated: target.isNull() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1440 | if (painter->device()->devType() == QInternal::Picture) partially evaluated: painter->device()->devType() == QInternal::Picture no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1441 | targetRect = sourceRect; never executed: targetRect = sourceRect; | 0 |
1442 | else | - |
1443 | targetRect.setRect(0, 0, painter->device()->width(), painter->device()->height()); executed: targetRect.setRect(0, 0, painter->device()->width(), painter->device()->height()); Execution Count:1 | 1 |
1444 | } | - |
1445 | | - |
1446 | | - |
1447 | qreal xratio = targetRect.width() / sourceRect.width(); | - |
1448 | qreal yratio = targetRect.height() / sourceRect.height(); | - |
1449 | | - |
1450 | | - |
1451 | switch (aspectRatioMode) { | - |
1452 | case Qt::KeepAspectRatio: | - |
1453 | xratio = yratio = qMin(xratio, yratio); | - |
1454 | break; executed: break; Execution Count:1 | 1 |
1455 | case Qt::KeepAspectRatioByExpanding: | - |
1456 | xratio = yratio = qMax(xratio, yratio); | - |
1457 | break; | 0 |
1458 | case Qt::IgnoreAspectRatio: | - |
1459 | break; | 0 |
1460 | } | - |
1461 | | - |
1462 | | - |
1463 | | - |
1464 | QPolygonF sourceScenePoly = mapToScene(sourceRect.adjusted(-1, -1, 1, 1)); | - |
1465 | QList<QGraphicsItem *> itemList = d->scene->items(sourceScenePoly, | - |
1466 | Qt::IntersectsItemBoundingRect); | - |
1467 | QGraphicsItem **itemArray = new QGraphicsItem *[itemList.size()]; | - |
1468 | int numItems = itemList.size(); | - |
1469 | for (int i = 0; i < numItems; ++i) evaluated: i < numItems yes Evaluation Count:4 | yes Evaluation Count:1 |
| 1-4 |
1470 | itemArray[numItems - i - 1] = itemList.at(i); executed: itemArray[numItems - i - 1] = itemList.at(i); Execution Count:4 | 4 |
1471 | itemList.clear(); | - |
1472 | | - |
1473 | | - |
1474 | QTransform moveMatrix = QTransform::fromTranslate(-d->horizontalScroll(), -d->verticalScroll()); | - |
1475 | QTransform painterMatrix = d->matrix * moveMatrix; | - |
1476 | painterMatrix *= QTransform() | - |
1477 | .translate(targetRect.left(), targetRect.top()) | - |
1478 | .scale(xratio, yratio) | - |
1479 | .translate(-sourceRect.left(), -sourceRect.top()); | - |
1480 | | - |
1481 | | - |
1482 | QStyleOptionGraphicsItem *styleOptionArray = d->allocStyleOptionsArray(numItems); | - |
1483 | for (int i = 0; i < numItems; ++i) evaluated: i < numItems yes Evaluation Count:4 | yes Evaluation Count:1 |
| 1-4 |
1484 | itemArray[i]->d_ptr->initStyleOption(&styleOptionArray[i], painterMatrix, targetRect.toRect()); executed: itemArray[i]->d_ptr->initStyleOption(&styleOptionArray[i], painterMatrix, targetRect.toRect()); Execution Count:4 | 4 |
1485 | | - |
1486 | painter->save(); | - |
1487 | | - |
1488 | | - |
1489 | painter->setClipRect(targetRect); | - |
1490 | QPainterPath path; | - |
1491 | path.addPolygon(sourceScenePoly); | - |
1492 | path.closeSubpath(); | - |
1493 | painter->setClipPath(painterMatrix.map(path), Qt::IntersectClip); | - |
1494 | | - |
1495 | | - |
1496 | painter->setTransform(painterMatrix, true); | - |
1497 | | - |
1498 | | - |
1499 | QRectF sourceSceneRect = sourceScenePoly.boundingRect(); | - |
1500 | drawBackground(painter, sourceSceneRect); | - |
1501 | drawItems(painter, numItems, itemArray, styleOptionArray); | - |
1502 | drawForeground(painter, sourceSceneRect); | - |
1503 | | - |
1504 | delete [] itemArray; | - |
1505 | d->freeStyleOptionsArray(styleOptionArray); | - |
1506 | | - |
1507 | painter->restore(); | - |
1508 | } executed: } Execution Count:1 | 1 |
1509 | QList<QGraphicsItem *> QGraphicsView::items() const | - |
1510 | { | - |
1511 | const QGraphicsViewPrivate * const d = d_func(); | - |
1512 | if (!d->scene) partially evaluated: !d->scene yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1513 | return QList<QGraphicsItem *>(); executed: return QList<QGraphicsItem *>(); Execution Count:1 | 1 |
1514 | return d->scene->items(); never executed: return d->scene->items(); | 0 |
1515 | } | - |
1516 | QList<QGraphicsItem *> QGraphicsView::items(const QPoint &pos) const | - |
1517 | { | - |
1518 | const QGraphicsViewPrivate * const d = d_func(); | - |
1519 | if (!d->scene) evaluated: !d->scene yes Evaluation Count:2 | yes Evaluation Count:72 |
| 2-72 |
1520 | return QList<QGraphicsItem *>(); executed: return QList<QGraphicsItem *>(); Execution Count:2 | 2 |
1521 | | - |
1522 | | - |
1523 | | - |
1524 | if ((d->identityMatrix || d->matrix.type() <= QTransform::TxScale)) { evaluated: d->identityMatrix yes Evaluation Count:40 | yes Evaluation Count:32 |
evaluated: d->matrix.type() <= QTransform::TxScale yes Evaluation Count:31 | yes Evaluation Count:1 |
| 1-40 |
1525 | | - |
1526 | QTransform xinv = viewportTransform().inverted(); | - |
1527 | return d->scene->items(xinv.mapRect(QRectF(pos.x(), pos.y(), 1, 1)), | 71 |
1528 | Qt::IntersectsItemShape, | 71 |
1529 | Qt::DescendingOrder, | 71 |
1530 | viewportTransform()); executed: return d->scene->items(xinv.mapRect(QRectF(pos.x(), pos.y(), 1, 1)), Qt::IntersectsItemShape, Qt::DescendingOrder, viewportTransform()); Execution Count:71 | 71 |
1531 | } | - |
1532 | | - |
1533 | return d->scene->items(mapToScene(pos.x(), pos.y(), 1, 1), | 1 |
1534 | Qt::IntersectsItemShape, | 1 |
1535 | Qt::DescendingOrder, | 1 |
1536 | viewportTransform()); executed: return d->scene->items(mapToScene(pos.x(), pos.y(), 1, 1), Qt::IntersectsItemShape, Qt::DescendingOrder, viewportTransform()); Execution Count:1 | 1 |
1537 | } | - |
1538 | QList<QGraphicsItem *> QGraphicsView::items(const QRect &rect, Qt::ItemSelectionMode mode) const | - |
1539 | { | - |
1540 | const QGraphicsViewPrivate * const d = d_func(); | - |
1541 | if (!d->scene) evaluated: !d->scene yes Evaluation Count:2 | yes Evaluation Count:6 |
| 2-6 |
1542 | return QList<QGraphicsItem *>(); executed: return QList<QGraphicsItem *>(); Execution Count:2 | 2 |
1543 | return d->scene->items(mapToScene(rect), mode, Qt::DescendingOrder, viewportTransform()); executed: return d->scene->items(mapToScene(rect), mode, Qt::DescendingOrder, viewportTransform()); Execution Count:6 | 6 |
1544 | } | - |
1545 | QList<QGraphicsItem *> QGraphicsView::items(const QPolygon &polygon, Qt::ItemSelectionMode mode) const | - |
1546 | { | - |
1547 | const QGraphicsViewPrivate * const d = d_func(); | - |
1548 | if (!d->scene) evaluated: !d->scene yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
1549 | return QList<QGraphicsItem *>(); executed: return QList<QGraphicsItem *>(); Execution Count:2 | 2 |
1550 | return d->scene->items(mapToScene(polygon), mode, Qt::DescendingOrder, viewportTransform()); executed: return d->scene->items(mapToScene(polygon), mode, Qt::DescendingOrder, viewportTransform()); Execution Count:2 | 2 |
1551 | } | - |
1552 | QList<QGraphicsItem *> QGraphicsView::items(const QPainterPath &path, Qt::ItemSelectionMode mode) const | - |
1553 | { | - |
1554 | const QGraphicsViewPrivate * const d = d_func(); | - |
1555 | if (!d->scene) evaluated: !d->scene yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
1556 | return QList<QGraphicsItem *>(); executed: return QList<QGraphicsItem *>(); Execution Count:2 | 2 |
1557 | return d->scene->items(mapToScene(path), mode, Qt::DescendingOrder, viewportTransform()); executed: return d->scene->items(mapToScene(path), mode, Qt::DescendingOrder, viewportTransform()); Execution Count:2 | 2 |
1558 | } | - |
1559 | QGraphicsItem *QGraphicsView::itemAt(const QPoint &pos) const | - |
1560 | { | - |
1561 | const QGraphicsViewPrivate * const d = d_func(); | - |
1562 | if (!d->scene) evaluated: !d->scene yes Evaluation Count:2 | yes Evaluation Count:50 |
| 2-50 |
1563 | return 0; executed: return 0; Execution Count:2 | 2 |
1564 | QList<QGraphicsItem *> itemsAtPos = items(pos); | - |
1565 | return itemsAtPos.isEmpty() ? 0 : itemsAtPos.first(); executed: return itemsAtPos.isEmpty() ? 0 : itemsAtPos.first(); Execution Count:50 | 50 |
1566 | } | - |
1567 | QPointF QGraphicsView::mapToScene(const QPoint &point) const | - |
1568 | { | - |
1569 | const QGraphicsViewPrivate * const d = d_func(); | - |
1570 | QPointF p = point; | - |
1571 | p.rx() += d->horizontalScroll(); | - |
1572 | p.ry() += d->verticalScroll(); | - |
1573 | return d->identityMatrix ? p : d->matrix.inverted().map(p); executed: return d->identityMatrix ? p : d->matrix.inverted().map(p); Execution Count:237441 | 237441 |
1574 | } | - |
1575 | QPolygonF QGraphicsView::mapToScene(const QRect &rect) const | - |
1576 | { | - |
1577 | const QGraphicsViewPrivate * const d = d_func(); | - |
1578 | if (!rect.isValid()) evaluated: !rect.isValid() yes Evaluation Count:3 | yes Evaluation Count:2044 |
| 3-2044 |
1579 | return QPolygonF(); executed: return QPolygonF(); Execution Count:3 | 3 |
1580 | | - |
1581 | QPointF scrollOffset(d->horizontalScroll(), d->verticalScroll()); | - |
1582 | QRect r = rect.adjusted(0, 0, 1, 1); | - |
1583 | QPointF tl = scrollOffset + r.topLeft(); | - |
1584 | QPointF tr = scrollOffset + r.topRight(); | - |
1585 | QPointF br = scrollOffset + r.bottomRight(); | - |
1586 | QPointF bl = scrollOffset + r.bottomLeft(); | - |
1587 | | - |
1588 | QPolygonF poly(4); | - |
1589 | if (!d->identityMatrix) { evaluated: !d->identityMatrix yes Evaluation Count:891 | yes Evaluation Count:1153 |
| 891-1153 |
1590 | QTransform x = d->matrix.inverted(); | - |
1591 | poly[0] = x.map(tl); | - |
1592 | poly[1] = x.map(tr); | - |
1593 | poly[2] = x.map(br); | - |
1594 | poly[3] = x.map(bl); | - |
1595 | } else { executed: } Execution Count:891 | 891 |
1596 | poly[0] = tl; | - |
1597 | poly[1] = tr; | - |
1598 | poly[2] = br; | - |
1599 | poly[3] = bl; | - |
1600 | } executed: } Execution Count:1153 | 1153 |
1601 | return poly; executed: return poly; Execution Count:2044 | 2044 |
1602 | } | - |
1603 | QPolygonF QGraphicsView::mapToScene(const QPolygon &polygon) const | - |
1604 | { | - |
1605 | QPolygonF poly; | - |
1606 | for (QForeachContainer<__typeof__(polygon)> _container_(polygon); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QPoint &point = *_container_.i;; __extension__ ({--_container_.brk; break;})) | - |
1607 | poly << mapToScene(point); executed: poly << mapToScene(point); Execution Count:12 | 12 |
1608 | return poly; executed: return poly; Execution Count:4 | 4 |
1609 | } | - |
1610 | | - |
1611 | | - |
1612 | | - |
1613 | | - |
1614 | | - |
1615 | | - |
1616 | | - |
1617 | QPainterPath QGraphicsView::mapToScene(const QPainterPath &path) const | - |
1618 | { | - |
1619 | const QGraphicsViewPrivate * const d = d_func(); | - |
1620 | QTransform matrix = QTransform::fromTranslate(d->horizontalScroll(), d->verticalScroll()); | - |
1621 | matrix *= d->matrix.inverted(); | - |
1622 | return matrix.map(path); executed: return matrix.map(path); Execution Count:3 | 3 |
1623 | } | - |
1624 | | - |
1625 | | - |
1626 | | - |
1627 | | - |
1628 | | - |
1629 | | - |
1630 | QPoint QGraphicsView::mapFromScene(const QPointF &point) const | - |
1631 | { | - |
1632 | const QGraphicsViewPrivate * const d = d_func(); | - |
1633 | QPointF p = d->identityMatrix ? point : d->matrix.map(point); evaluated: d->identityMatrix yes Evaluation Count:230563 | yes Evaluation Count:568 |
| 568-230563 |
1634 | p.rx() -= d->horizontalScroll(); | - |
1635 | p.ry() -= d->verticalScroll(); | - |
1636 | return p.toPoint(); executed: return p.toPoint(); Execution Count:231131 | 231131 |
1637 | } | - |
1638 | QPolygon QGraphicsView::mapFromScene(const QRectF &rect) const | - |
1639 | { | - |
1640 | const QGraphicsViewPrivate * const d = d_func(); | - |
1641 | QPointF tl; | - |
1642 | QPointF tr; | - |
1643 | QPointF br; | - |
1644 | QPointF bl; | - |
1645 | if (!d->identityMatrix) { evaluated: !d->identityMatrix yes Evaluation Count:2 | yes Evaluation Count:5 |
| 2-5 |
1646 | const QTransform &x = d->matrix; | - |
1647 | tl = x.map(rect.topLeft()); | - |
1648 | tr = x.map(rect.topRight()); | - |
1649 | br = x.map(rect.bottomRight()); | - |
1650 | bl = x.map(rect.bottomLeft()); | - |
1651 | } else { executed: } Execution Count:2 | 2 |
1652 | tl = rect.topLeft(); | - |
1653 | tr = rect.topRight(); | - |
1654 | br = rect.bottomRight(); | - |
1655 | bl = rect.bottomLeft(); | - |
1656 | } executed: } Execution Count:5 | 5 |
1657 | QPointF scrollOffset(d->horizontalScroll(), d->verticalScroll()); | - |
1658 | tl -= scrollOffset; | - |
1659 | tr -= scrollOffset; | - |
1660 | br -= scrollOffset; | - |
1661 | bl -= scrollOffset; | - |
1662 | | - |
1663 | QPolygon poly(4); | - |
1664 | poly[0] = tl.toPoint(); | - |
1665 | poly[1] = tr.toPoint(); | - |
1666 | poly[2] = br.toPoint(); | - |
1667 | poly[3] = bl.toPoint(); | - |
1668 | return poly; executed: return poly; Execution Count:7 | 7 |
1669 | } | - |
1670 | QPolygon QGraphicsView::mapFromScene(const QPolygonF &polygon) const | - |
1671 | { | - |
1672 | QPolygon poly; | - |
1673 | for (QForeachContainer<__typeof__(polygon)> _container_(polygon); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QPointF &point = *_container_.i;; __extension__ ({--_container_.brk; break;})) | - |
1674 | poly << mapFromScene(point); executed: poly << mapFromScene(point); Execution Count:4 | 4 |
1675 | return poly; executed: return poly; Execution Count:2 | 2 |
1676 | } | - |
1677 | | - |
1678 | | - |
1679 | | - |
1680 | | - |
1681 | | - |
1682 | | - |
1683 | | - |
1684 | QPainterPath QGraphicsView::mapFromScene(const QPainterPath &path) const | - |
1685 | { | - |
1686 | const QGraphicsViewPrivate * const d = d_func(); | - |
1687 | QTransform matrix = d->matrix; | - |
1688 | matrix *= QTransform::fromTranslate(-d->horizontalScroll(), -d->verticalScroll()); | - |
1689 | return matrix.map(path); executed: return matrix.map(path); Execution Count:1 | 1 |
1690 | } | - |
1691 | | - |
1692 | | - |
1693 | | - |
1694 | | - |
1695 | QVariant QGraphicsView::inputMethodQuery(Qt::InputMethodQuery query) const | - |
1696 | { | - |
1697 | const QGraphicsViewPrivate * const d = d_func(); | - |
1698 | if (!d->scene) partially evaluated: !d->scene no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
1699 | return QVariant(); never executed: return QVariant(); | 0 |
1700 | | - |
1701 | QVariant value = d->scene->inputMethodQuery(query); | - |
1702 | if (value.type() == QVariant::RectF) evaluated: value.type() == QVariant::RectF yes Evaluation Count:2 | yes Evaluation Count:9 |
| 2-9 |
1703 | value = d->mapRectFromScene(value.toRectF()); executed: value = d->mapRectFromScene(value.toRectF()); Execution Count:2 | 2 |
1704 | else if (value.type() == QVariant::PointF) partially evaluated: value.type() == QVariant::PointF no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
1705 | value = mapFromScene(value.toPointF()); never executed: value = mapFromScene(value.toPointF()); | 0 |
1706 | else if (value.type() == QVariant::Rect) partially evaluated: value.type() == QVariant::Rect no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
1707 | value = d->mapRectFromScene(value.toRect()).toRect(); never executed: value = d->mapRectFromScene(value.toRect()).toRect(); | 0 |
1708 | else if (value.type() == QVariant::Point) partially evaluated: value.type() == QVariant::Point no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
1709 | value = mapFromScene(value.toPoint()); never executed: value = mapFromScene(value.toPoint()); | 0 |
1710 | return value; executed: return value; Execution Count:11 | 11 |
1711 | } | - |
1712 | QBrush QGraphicsView::backgroundBrush() const | - |
1713 | { | - |
1714 | const QGraphicsViewPrivate * const d = d_func(); | - |
1715 | return d->backgroundBrush; never executed: return d->backgroundBrush; | 0 |
1716 | } | - |
1717 | void QGraphicsView::setBackgroundBrush(const QBrush &brush) | - |
1718 | { | - |
1719 | QGraphicsViewPrivate * const d = d_func(); | - |
1720 | d->backgroundBrush = brush; | - |
1721 | d->updateAll(); | - |
1722 | | - |
1723 | if (d->cacheMode & CacheBackground) { partially evaluated: d->cacheMode & CacheBackground no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1724 | | - |
1725 | d->mustResizeBackgroundPixmap = true; | - |
1726 | } | 0 |
1727 | } executed: } Execution Count:2 | 2 |
1728 | QBrush QGraphicsView::foregroundBrush() const | - |
1729 | { | - |
1730 | const QGraphicsViewPrivate * const d = d_func(); | - |
1731 | return d->foregroundBrush; never executed: return d->foregroundBrush; | 0 |
1732 | } | - |
1733 | void QGraphicsView::setForegroundBrush(const QBrush &brush) | - |
1734 | { | - |
1735 | QGraphicsViewPrivate * const d = d_func(); | - |
1736 | d->foregroundBrush = brush; | - |
1737 | d->updateAll(); | - |
1738 | } | 0 |
1739 | | - |
1740 | | - |
1741 | | - |
1742 | | - |
1743 | | - |
1744 | | - |
1745 | void QGraphicsView::updateScene(const QList<QRectF> &rects) | - |
1746 | { | - |
1747 | | - |
1748 | | - |
1749 | | - |
1750 | | - |
1751 | | - |
1752 | QGraphicsViewPrivate * const d = d_func(); | - |
1753 | if (d->fullUpdatePending || d->viewportUpdateMode == QGraphicsView::NoViewportUpdate) evaluated: d->fullUpdatePending yes Evaluation Count:12 | yes Evaluation Count:12 |
partially evaluated: d->viewportUpdateMode == QGraphicsView::NoViewportUpdate no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
1754 | return; executed: return; Execution Count:12 | 12 |
1755 | | - |
1756 | | - |
1757 | QVector<QRect> dirtyViewportRects; | - |
1758 | const QVector<QRect> &dirtyRects = d->dirtyRegion.rects(); | - |
1759 | for (int i = 0; i < dirtyRects.size(); ++i) partially evaluated: i < dirtyRects.size() no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
1760 | dirtyViewportRects += dirtyRects.at(i); never executed: dirtyViewportRects += dirtyRects.at(i); | 0 |
1761 | d->dirtyRegion = QRegion(); | - |
1762 | d->dirtyBoundingRect = QRect(); | - |
1763 | | - |
1764 | bool fullUpdate = !d->accelerateScrolling || d->viewportUpdateMode == QGraphicsView::FullViewportUpdate; partially evaluated: !d->accelerateScrolling no Evaluation Count:0 | yes Evaluation Count:12 |
partially evaluated: d->viewportUpdateMode == QGraphicsView::FullViewportUpdate no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
1765 | bool boundingRectUpdate = (d->viewportUpdateMode == QGraphicsView::BoundingRectViewportUpdate) partially evaluated: (d->viewportUpdateMode == QGraphicsView::BoundingRectViewportUpdate) no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
1766 | || (d->viewportUpdateMode == QGraphicsView::SmartViewportUpdate partially evaluated: d->viewportUpdateMode == QGraphicsView::SmartViewportUpdate no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
1767 | && ((dirtyViewportRects.size() + rects.size()) >= QGRAPHICSVIEW_REGION_RECT_THRESHOLD)); never evaluated: ((dirtyViewportRects.size() + rects.size()) >= QGRAPHICSVIEW_REGION_RECT_THRESHOLD) | 0 |
1768 | | - |
1769 | QRegion updateRegion; | - |
1770 | QRect boundingRect; | - |
1771 | QRect viewportRect = viewport()->rect(); | - |
1772 | bool redraw = false; | - |
1773 | QTransform transform = viewportTransform(); | - |
1774 | | - |
1775 | | - |
1776 | for (QForeachContainer<__typeof__(rects)> _container_(rects); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QRectF &rect = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
1777 | QRect xrect = transform.mapRect(rect).toAlignedRect(); | - |
1778 | if (!(d->optimizationFlags & DontAdjustForAntialiasing)) evaluated: !(d->optimizationFlags & DontAdjustForAntialiasing) yes Evaluation Count:6 | yes Evaluation Count:4 |
| 4-6 |
1779 | xrect.adjust(-2, -2, 2, 2); executed: xrect.adjust(-2, -2, 2, 2); Execution Count:6 | 6 |
1780 | else | - |
1781 | xrect.adjust(-1, -1, 1, 1); executed: xrect.adjust(-1, -1, 1, 1); Execution Count:4 | 4 |
1782 | if (!viewportRect.intersects(xrect)) partially evaluated: !viewportRect.intersects(xrect) no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
1783 | continue; never executed: continue; | 0 |
1784 | dirtyViewportRects << xrect; | - |
1785 | } executed: } Execution Count:10 | 10 |
1786 | | - |
1787 | for (QForeachContainer<__typeof__(dirtyViewportRects)> _container_(dirtyViewportRects); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QRect &rect = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
1788 | | - |
1789 | | - |
1790 | if (!boundingRectUpdate) { partially evaluated: !boundingRectUpdate yes Evaluation Count:10 | no Evaluation Count:0 |
| 0-10 |
1791 | updateRegion += rect; | - |
1792 | } else { executed: } Execution Count:10 | 10 |
1793 | boundingRect |= rect; | - |
1794 | } | 0 |
1795 | redraw = true; | - |
1796 | if (fullUpdate) { partially evaluated: fullUpdate no Evaluation Count:0 | yes Evaluation Count:10 |
| 0-10 |
1797 | | - |
1798 | | - |
1799 | break; | 0 |
1800 | } | - |
1801 | } executed: } Execution Count:10 | 10 |
1802 | | - |
1803 | if (!redraw) evaluated: !redraw yes Evaluation Count:4 | yes Evaluation Count:8 |
| 4-8 |
1804 | return; executed: return; Execution Count:4 | 4 |
1805 | | - |
1806 | if (fullUpdate) partially evaluated: fullUpdate no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
1807 | viewport()->update(); never executed: viewport()->update(); | 0 |
1808 | else if (boundingRectUpdate) partially evaluated: boundingRectUpdate no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
1809 | viewport()->update(boundingRect); never executed: viewport()->update(boundingRect); | 0 |
1810 | else | - |
1811 | viewport()->update(updateRegion); executed: viewport()->update(updateRegion); Execution Count:8 | 8 |
1812 | } | - |
1813 | void QGraphicsView::updateSceneRect(const QRectF &rect) | - |
1814 | { | - |
1815 | QGraphicsViewPrivate * const d = d_func(); | - |
1816 | if (!d->hasSceneRect) { evaluated: !d->hasSceneRect yes Evaluation Count:740 | yes Evaluation Count:12 |
| 12-740 |
1817 | d->sceneRect = rect; | - |
1818 | d->recalculateContentSize(); | - |
1819 | } executed: } Execution Count:740 | 740 |
1820 | } executed: } Execution Count:752 | 752 |
1821 | void QGraphicsView::setupViewport(QWidget *widget) | - |
1822 | { | - |
1823 | QGraphicsViewPrivate * const d = d_func(); | - |
1824 | | - |
1825 | if (!widget) { partially evaluated: !widget no Evaluation Count:0 | yes Evaluation Count:807 |
| 0-807 |
1826 | QMessageLogger("graphicsview/qgraphicsview.cpp", 2719, __PRETTY_FUNCTION__).warning("QGraphicsView::setupViewport: cannot initialize null widget"); | - |
1827 | return; | 0 |
1828 | } | - |
1829 | | - |
1830 | const bool isGLWidget = widget->inherits("QGLWidget"); | - |
1831 | | - |
1832 | d->accelerateScrolling = !(isGLWidget); | - |
1833 | | - |
1834 | widget->setFocusPolicy(Qt::StrongFocus); | - |
1835 | | - |
1836 | if (!isGLWidget) { partially evaluated: !isGLWidget yes Evaluation Count:807 | no Evaluation Count:0 |
| 0-807 |
1837 | | - |
1838 | widget->setAutoFillBackground(true); | - |
1839 | } executed: } Execution Count:807 | 807 |
1840 | | - |
1841 | | - |
1842 | | - |
1843 | | - |
1844 | if ((d->scene && (!d->scene->d_func()->allItemsIgnoreHoverEvents evaluated: d->scene yes Evaluation Count:733 | yes Evaluation Count:74 |
evaluated: !d->scene->d_func()->allItemsIgnoreHoverEvents yes Evaluation Count:8 | yes Evaluation Count:725 |
| 8-733 |
1845 | || !d->scene->d_func()->allItemsUseDefaultCursor)) evaluated: !d->scene->d_func()->allItemsUseDefaultCursor yes Evaluation Count:3 | yes Evaluation Count:722 |
| 3-722 |
1846 | || d->transformationAnchor == AnchorUnderMouse evaluated: d->transformationAnchor == AnchorUnderMouse yes Evaluation Count:1 | yes Evaluation Count:795 |
| 1-795 |
1847 | || d->resizeAnchor == AnchorUnderMouse) { evaluated: d->resizeAnchor == AnchorUnderMouse yes Evaluation Count:1 | yes Evaluation Count:794 |
| 1-794 |
1848 | widget->setMouseTracking(true); | - |
1849 | } executed: } Execution Count:13 | 13 |
1850 | | - |
1851 | | - |
1852 | if (d->scene && !d->scene->d_func()->allItemsIgnoreTouchEvents) evaluated: d->scene yes Evaluation Count:733 | yes Evaluation Count:74 |
partially evaluated: !d->scene->d_func()->allItemsIgnoreTouchEvents no Evaluation Count:0 | yes Evaluation Count:733 |
| 0-733 |
1853 | widget->setAttribute(Qt::WA_AcceptTouchEvents); never executed: widget->setAttribute(Qt::WA_AcceptTouchEvents); | 0 |
1854 | | - |
1855 | | - |
1856 | if (d->scene) { evaluated: d->scene yes Evaluation Count:733 | yes Evaluation Count:74 |
| 74-733 |
1857 | for (QForeachContainer<__typeof__(d->scene->d_func()->grabbedGestures.keys())> _container_(d->scene->d_func()->grabbedGestures.keys()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (Qt::GestureType gesture = *_container_.i;; __extension__ ({--_container_.brk; break;})) | - |
1858 | widget->grabGesture(gesture); executed: widget->grabGesture(gesture); Execution Count:1 | 1 |
1859 | } executed: } Execution Count:733 | 733 |
1860 | | - |
1861 | | - |
1862 | widget->setAcceptDrops(acceptDrops()); | - |
1863 | } executed: } Execution Count:807 | 807 |
1864 | | - |
1865 | | - |
1866 | | - |
1867 | | - |
1868 | bool QGraphicsView::event(QEvent *event) | - |
1869 | { | - |
1870 | QGraphicsViewPrivate * const d = d_func(); | - |
1871 | | - |
1872 | if (d->sceneInteractionAllowed) { evaluated: d->sceneInteractionAllowed yes Evaluation Count:21900 | yes Evaluation Count:12 |
| 12-21900 |
1873 | switch (event->type()) { | - |
1874 | case QEvent::ShortcutOverride: | - |
1875 | if (d->scene) evaluated: d->scene yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
1876 | return QApplication::sendEvent(d->scene, event); executed: return QApplication::sendEvent(d->scene, event); Execution Count:1 | 1 |
1877 | break; executed: break; Execution Count:1 | 1 |
1878 | case QEvent::KeyPress: | - |
1879 | if (d->scene) { partially evaluated: d->scene yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
1880 | QKeyEvent *k = static_cast<QKeyEvent *>(event); | - |
1881 | if (k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) { partially evaluated: k->key() == Qt::Key_Tab no Evaluation Count:0 | yes Evaluation Count:1 |
partially evaluated: k->key() == Qt::Key_Backtab no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1882 | | - |
1883 | | - |
1884 | | - |
1885 | | - |
1886 | | - |
1887 | | - |
1888 | QApplication::sendEvent(d->scene, event); | - |
1889 | if (event->isAccepted()) never evaluated: event->isAccepted() | 0 |
1890 | return true; never executed: return true; | 0 |
1891 | | - |
1892 | | - |
1893 | | - |
1894 | event->accept(); | - |
1895 | } | 0 |
1896 | } executed: } Execution Count:1 | 1 |
1897 | break; executed: break; Execution Count:1 | 1 |
1898 | default: | - |
1899 | break; executed: break; Execution Count:21897 | 21897 |
1900 | } | - |
1901 | } executed: } Execution Count:21899 | 21899 |
1902 | | - |
1903 | return QAbstractScrollArea::event(event); executed: return QAbstractScrollArea::event(event); Execution Count:21911 | 21911 |
1904 | } | - |
1905 | | - |
1906 | | - |
1907 | | - |
1908 | | - |
1909 | bool QGraphicsView::viewportEvent(QEvent *event) | - |
1910 | { | - |
1911 | QGraphicsViewPrivate * const d = d_func(); | - |
1912 | if (!d->scene) evaluated: !d->scene yes Evaluation Count:288 | yes Evaluation Count:10474 |
| 288-10474 |
1913 | return QAbstractScrollArea::viewportEvent(event); executed: return QAbstractScrollArea::viewportEvent(event); Execution Count:288 | 288 |
1914 | | - |
1915 | switch (event->type()) { | - |
1916 | case QEvent::Enter: | - |
1917 | QApplication::sendEvent(d->scene, event); | - |
1918 | break; executed: break; Execution Count:500 | 500 |
1919 | case QEvent::WindowActivate: | - |
1920 | QApplication::sendEvent(d->scene, event); | - |
1921 | break; executed: break; Execution Count:562 | 562 |
1922 | case QEvent::WindowDeactivate: | - |
1923 | | - |
1924 | | - |
1925 | | - |
1926 | | - |
1927 | if (!d->scene->d_func()->popupWidgets.isEmpty()) partially evaluated: !d->scene->d_func()->popupWidgets.isEmpty() no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
1928 | d->scene->d_func()->removePopup(d->scene->d_func()->popupWidgets.first()); never executed: d->scene->d_func()->removePopup(d->scene->d_func()->popupWidgets.first()); | 0 |
1929 | QApplication::sendEvent(d->scene, event); | - |
1930 | break; executed: break; Execution Count:3 | 3 |
1931 | case QEvent::Show: | - |
1932 | if (d->scene && isActiveWindow()) { partially evaluated: d->scene yes Evaluation Count:722 | no Evaluation Count:0 |
evaluated: isActiveWindow() yes Evaluation Count:3 | yes Evaluation Count:719 |
| 0-722 |
1933 | QEvent windowActivate(QEvent::WindowActivate); | - |
1934 | QApplication::sendEvent(d->scene, &windowActivate); | - |
1935 | } executed: } Execution Count:3 | 3 |
1936 | break; executed: break; Execution Count:722 | 722 |
1937 | case QEvent::Hide: | - |
1938 | | - |
1939 | if (!event->spontaneous() && d->scene && isActiveWindow()) { partially evaluated: !event->spontaneous() yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: d->scene yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: isActiveWindow() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1940 | QEvent windowDeactivate(QEvent::WindowDeactivate); | - |
1941 | QApplication::sendEvent(d->scene, &windowDeactivate); | - |
1942 | } | 0 |
1943 | break; executed: break; Execution Count:1 | 1 |
1944 | case QEvent::Leave: { | - |
1945 | | - |
1946 | | - |
1947 | | - |
1948 | if ((QApplication::activePopupWidget() && QApplication::activePopupWidget() != window()) partially evaluated: QApplication::activePopupWidget() no Evaluation Count:0 | yes Evaluation Count:2 |
never evaluated: QApplication::activePopupWidget() != window() | 0-2 |
1949 | || (QApplication::activeModalWidget() && QApplication::activeModalWidget() != window()) partially evaluated: QApplication::activeModalWidget() no Evaluation Count:0 | yes Evaluation Count:2 |
never evaluated: QApplication::activeModalWidget() != window() | 0-2 |
1950 | || (QApplication::activeWindow() != window())) { partially evaluated: (QApplication::activeWindow() != window()) no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1951 | if (!d->scene->d_func()->popupWidgets.isEmpty()) never evaluated: !d->scene->d_func()->popupWidgets.isEmpty() | 0 |
1952 | d->scene->d_func()->removePopup(d->scene->d_func()->popupWidgets.first()); never executed: d->scene->d_func()->removePopup(d->scene->d_func()->popupWidgets.first()); | 0 |
1953 | } | 0 |
1954 | d->useLastMouseEvent = false; | - |
1955 | | - |
1956 | qt_noop(); | - |
1957 | QScopedValueRollback<QEventPrivate *> rb(event->d); | - |
1958 | event->d = reinterpret_cast<QEventPrivate *>(viewport()); | - |
1959 | QApplication::sendEvent(d->scene, event); | - |
1960 | break; executed: break; Execution Count:2 | 2 |
1961 | } | - |
1962 | | - |
1963 | case QEvent::ToolTip: { | - |
1964 | QHelpEvent *toolTip = static_cast<QHelpEvent *>(event); | - |
1965 | QGraphicsSceneHelpEvent helpEvent(QEvent::GraphicsSceneHelp); | - |
1966 | helpEvent.setWidget(viewport()); | - |
1967 | helpEvent.setScreenPos(toolTip->globalPos()); | - |
1968 | helpEvent.setScenePos(mapToScene(toolTip->pos())); | - |
1969 | QApplication::sendEvent(d->scene, &helpEvent); | - |
1970 | toolTip->setAccepted(helpEvent.isAccepted()); | - |
1971 | return true; never executed: return true; | 0 |
1972 | } | - |
1973 | | - |
1974 | case QEvent::Paint: | - |
1975 | | - |
1976 | d->fullUpdatePending = false; | - |
1977 | d->dirtyScrollOffset = QPoint(); | - |
1978 | if (d->scene) { partially evaluated: d->scene yes Evaluation Count:2023 | no Evaluation Count:0 |
| 0-2023 |
1979 | | - |
1980 | | - |
1981 | | - |
1982 | if (!d->updateSceneSlotReimplementedChecked) { evaluated: !d->updateSceneSlotReimplementedChecked yes Evaluation Count:568 | yes Evaluation Count:1455 |
| 568-1455 |
1983 | d->updateSceneSlotReimplementedChecked = true; | - |
1984 | const QMetaObject *mo = metaObject(); | - |
1985 | if (mo != &QGraphicsView::staticMetaObject) { evaluated: mo != &QGraphicsView::staticMetaObject yes Evaluation Count:43 | yes Evaluation Count:525 |
| 43-525 |
1986 | if (mo->indexOfSlot("updateScene(QList<QRectF>)") | 0-43 |
1987 | != QGraphicsView::staticMetaObject.indexOfSlot("updateScene(QList<QRectF>)")) { partially evaluated: mo->indexOfSlot("updateScene(QList<QRectF>)") != QGraphicsView::staticMetaObject.indexOfSlot("updateScene(QList<QRectF>)") no Evaluation Count:0 | yes Evaluation Count:43 |
| 0-43 |
1988 | connect(d->scene, "2""changed(QList<QRectF>)", | - |
1989 | this, "1""updateScene(QList<QRectF>)"); | - |
1990 | } | 0 |
1991 | } executed: } Execution Count:43 | 43 |
1992 | } executed: } Execution Count:568 | 568 |
1993 | } executed: } Execution Count:2023 | 2023 |
1994 | break; executed: break; Execution Count:2023 | 2023 |
1995 | case QEvent::TouchBegin: | - |
1996 | case QEvent::TouchUpdate: | - |
1997 | case QEvent::TouchEnd: | - |
1998 | { | - |
1999 | if (!isEnabled()) never evaluated: !isEnabled() | 0 |
2000 | return false; never executed: return false; | 0 |
2001 | | - |
2002 | if (d->scene && d->sceneInteractionAllowed) { never evaluated: d->scene never evaluated: d->sceneInteractionAllowed | 0 |
2003 | | - |
2004 | QTouchEvent *touchEvent = static_cast<QTouchEvent *>(event); | - |
2005 | touchEvent->setTarget(viewport()); | - |
2006 | QGraphicsViewPrivate::translateTouchEvent(d, touchEvent); | - |
2007 | (void) QApplication::sendEvent(d->scene, touchEvent); | - |
2008 | } | 0 |
2009 | | - |
2010 | return true; never executed: return true; | 0 |
2011 | } | - |
2012 | | - |
2013 | case QEvent::Gesture: | - |
2014 | case QEvent::GestureOverride: | - |
2015 | { | - |
2016 | if (!isEnabled()) partially evaluated: !isEnabled() no Evaluation Count:0 | yes Evaluation Count:144 |
| 0-144 |
2017 | return false; never executed: return false; | 0 |
2018 | | - |
2019 | if (d->scene && d->sceneInteractionAllowed) { partially evaluated: d->scene yes Evaluation Count:144 | no Evaluation Count:0 |
partially evaluated: d->sceneInteractionAllowed yes Evaluation Count:144 | no Evaluation Count:0 |
| 0-144 |
2020 | QGestureEvent *gestureEvent = static_cast<QGestureEvent *>(event); | - |
2021 | gestureEvent->setWidget(viewport()); | - |
2022 | (void) QApplication::sendEvent(d->scene, gestureEvent); | - |
2023 | } executed: } Execution Count:144 | 144 |
2024 | return true; executed: return true; Execution Count:144 | 144 |
2025 | } | - |
2026 | | - |
2027 | default: | - |
2028 | break; executed: break; Execution Count:6517 | 6517 |
2029 | } | - |
2030 | | - |
2031 | return QAbstractScrollArea::viewportEvent(event); executed: return QAbstractScrollArea::viewportEvent(event); Execution Count:10330 | 10330 |
2032 | } | - |
2033 | | - |
2034 | | - |
2035 | | - |
2036 | | - |
2037 | | - |
2038 | void QGraphicsView::contextMenuEvent(QContextMenuEvent *event) | - |
2039 | { | - |
2040 | QGraphicsViewPrivate * const d = d_func(); | - |
2041 | if (!d->scene || !d->sceneInteractionAllowed) partially evaluated: !d->scene no Evaluation Count:0 | yes Evaluation Count:200 |
evaluated: !d->sceneInteractionAllowed yes Evaluation Count:100 | yes Evaluation Count:100 |
| 0-200 |
2042 | return; executed: return; Execution Count:100 | 100 |
2043 | | - |
2044 | d->mousePressViewPoint = event->pos(); | - |
2045 | d->mousePressScenePoint = mapToScene(d->mousePressViewPoint); | - |
2046 | d->mousePressScreenPoint = event->globalPos(); | - |
2047 | d->lastMouseMoveScenePoint = d->mousePressScenePoint; | - |
2048 | d->lastMouseMoveScreenPoint = d->mousePressScreenPoint; | - |
2049 | | - |
2050 | QGraphicsSceneContextMenuEvent contextEvent(QEvent::GraphicsSceneContextMenu); | - |
2051 | contextEvent.setWidget(viewport()); | - |
2052 | contextEvent.setScenePos(d->mousePressScenePoint); | - |
2053 | contextEvent.setScreenPos(d->mousePressScreenPoint); | - |
2054 | contextEvent.setModifiers(event->modifiers()); | - |
2055 | contextEvent.setReason((QGraphicsSceneContextMenuEvent::Reason)(event->reason())); | - |
2056 | contextEvent.setAccepted(event->isAccepted()); | - |
2057 | QApplication::sendEvent(d->scene, &contextEvent); | - |
2058 | event->setAccepted(contextEvent.isAccepted()); | - |
2059 | } executed: } Execution Count:100 | 100 |
2060 | | - |
2061 | | - |
2062 | | - |
2063 | | - |
2064 | | - |
2065 | void QGraphicsView::dropEvent(QDropEvent *event) | - |
2066 | { | - |
2067 | | - |
2068 | QGraphicsViewPrivate * const d = d_func(); | - |
2069 | if (!d->scene || !d->sceneInteractionAllowed) never evaluated: !d->scene never evaluated: !d->sceneInteractionAllowed | 0 |
2070 | return; | 0 |
2071 | | - |
2072 | | - |
2073 | QGraphicsSceneDragDropEvent sceneEvent(QEvent::GraphicsSceneDrop); | - |
2074 | d->populateSceneDragDropEvent(&sceneEvent, event); | - |
2075 | | - |
2076 | | - |
2077 | QApplication::sendEvent(d->scene, &sceneEvent); | - |
2078 | | - |
2079 | | - |
2080 | event->setAccepted(sceneEvent.isAccepted()); | - |
2081 | if (sceneEvent.isAccepted()) never evaluated: sceneEvent.isAccepted() | 0 |
2082 | event->setDropAction(sceneEvent.dropAction()); never executed: event->setDropAction(sceneEvent.dropAction()); | 0 |
2083 | | - |
2084 | delete d->lastDragDropEvent; | - |
2085 | d->lastDragDropEvent = 0; | - |
2086 | | - |
2087 | | - |
2088 | | - |
2089 | | - |
2090 | } | 0 |
2091 | | - |
2092 | | - |
2093 | | - |
2094 | | - |
2095 | void QGraphicsView::dragEnterEvent(QDragEnterEvent *event) | - |
2096 | { | - |
2097 | | - |
2098 | QGraphicsViewPrivate * const d = d_func(); | - |
2099 | if (!d->scene || !d->sceneInteractionAllowed) never evaluated: !d->scene never evaluated: !d->sceneInteractionAllowed | 0 |
2100 | return; | 0 |
2101 | | - |
2102 | | - |
2103 | d->useLastMouseEvent = false; | - |
2104 | | - |
2105 | | - |
2106 | QGraphicsSceneDragDropEvent sceneEvent(QEvent::GraphicsSceneDragEnter); | - |
2107 | d->populateSceneDragDropEvent(&sceneEvent, event); | - |
2108 | | - |
2109 | | - |
2110 | d->storeDragDropEvent(&sceneEvent); | - |
2111 | | - |
2112 | | - |
2113 | QApplication::sendEvent(d->scene, &sceneEvent); | - |
2114 | | - |
2115 | | - |
2116 | if (sceneEvent.isAccepted()) { never evaluated: sceneEvent.isAccepted() | 0 |
2117 | event->setAccepted(true); | - |
2118 | event->setDropAction(sceneEvent.dropAction()); | - |
2119 | } | 0 |
2120 | | - |
2121 | | - |
2122 | | - |
2123 | } | 0 |
2124 | | - |
2125 | | - |
2126 | | - |
2127 | | - |
2128 | void QGraphicsView::dragLeaveEvent(QDragLeaveEvent *event) | - |
2129 | { | - |
2130 | | - |
2131 | QGraphicsViewPrivate * const d = d_func(); | - |
2132 | if (!d->scene || !d->sceneInteractionAllowed) never evaluated: !d->scene never evaluated: !d->sceneInteractionAllowed | 0 |
2133 | return; | 0 |
2134 | if (!d->lastDragDropEvent) { never evaluated: !d->lastDragDropEvent | 0 |
2135 | QMessageLogger("graphicsview/qgraphicsview.cpp", 3028, __PRETTY_FUNCTION__).warning("QGraphicsView::dragLeaveEvent: drag leave received before drag enter"); | - |
2136 | return; | 0 |
2137 | } | - |
2138 | | - |
2139 | | - |
2140 | QGraphicsSceneDragDropEvent sceneEvent(QEvent::GraphicsSceneDragLeave); | - |
2141 | sceneEvent.setScenePos(d->lastDragDropEvent->scenePos()); | - |
2142 | sceneEvent.setScreenPos(d->lastDragDropEvent->screenPos()); | - |
2143 | sceneEvent.setButtons(d->lastDragDropEvent->buttons()); | - |
2144 | sceneEvent.setModifiers(d->lastDragDropEvent->modifiers()); | - |
2145 | sceneEvent.setPossibleActions(d->lastDragDropEvent->possibleActions()); | - |
2146 | sceneEvent.setProposedAction(d->lastDragDropEvent->proposedAction()); | - |
2147 | sceneEvent.setDropAction(d->lastDragDropEvent->dropAction()); | - |
2148 | sceneEvent.setMimeData(d->lastDragDropEvent->mimeData()); | - |
2149 | sceneEvent.setWidget(d->lastDragDropEvent->widget()); | - |
2150 | sceneEvent.setSource(d->lastDragDropEvent->source()); | - |
2151 | delete d->lastDragDropEvent; | - |
2152 | d->lastDragDropEvent = 0; | - |
2153 | | - |
2154 | | - |
2155 | QApplication::sendEvent(d->scene, &sceneEvent); | - |
2156 | | - |
2157 | | - |
2158 | if (sceneEvent.isAccepted()) never evaluated: sceneEvent.isAccepted() | 0 |
2159 | event->setAccepted(true); never executed: event->setAccepted(true); | 0 |
2160 | | - |
2161 | | - |
2162 | | - |
2163 | } | 0 |
2164 | | - |
2165 | | - |
2166 | | - |
2167 | | - |
2168 | void QGraphicsView::dragMoveEvent(QDragMoveEvent *event) | - |
2169 | { | - |
2170 | | - |
2171 | QGraphicsViewPrivate * const d = d_func(); | - |
2172 | if (!d->scene || !d->sceneInteractionAllowed) never evaluated: !d->scene never evaluated: !d->sceneInteractionAllowed | 0 |
2173 | return; | 0 |
2174 | | - |
2175 | | - |
2176 | QGraphicsSceneDragDropEvent sceneEvent(QEvent::GraphicsSceneDragMove); | - |
2177 | d->populateSceneDragDropEvent(&sceneEvent, event); | - |
2178 | | - |
2179 | | - |
2180 | d->storeDragDropEvent(&sceneEvent); | - |
2181 | | - |
2182 | | - |
2183 | QApplication::sendEvent(d->scene, &sceneEvent); | - |
2184 | | - |
2185 | | - |
2186 | event->setAccepted(sceneEvent.isAccepted()); | - |
2187 | if (sceneEvent.isAccepted()) never evaluated: sceneEvent.isAccepted() | 0 |
2188 | event->setDropAction(sceneEvent.dropAction()); never executed: event->setDropAction(sceneEvent.dropAction()); | 0 |
2189 | | - |
2190 | | - |
2191 | | - |
2192 | } | 0 |
2193 | | - |
2194 | | - |
2195 | | - |
2196 | | - |
2197 | void QGraphicsView::focusInEvent(QFocusEvent *event) | - |
2198 | { | - |
2199 | QGraphicsViewPrivate * const d = d_func(); | - |
2200 | d->updateInputMethodSensitivity(); | - |
2201 | QAbstractScrollArea::focusInEvent(event); | - |
2202 | if (d->scene) evaluated: d->scene yes Evaluation Count:561 | yes Evaluation Count:13 |
| 13-561 |
2203 | QApplication::sendEvent(d->scene, event); executed: QApplication::sendEvent(d->scene, event); Execution Count:561 | 561 |
2204 | | - |
2205 | if (!d->scene || !event->isAccepted()) evaluated: !d->scene yes Evaluation Count:13 | yes Evaluation Count:561 |
partially evaluated: !event->isAccepted() no Evaluation Count:0 | yes Evaluation Count:561 |
| 0-561 |
2206 | QAbstractScrollArea::focusInEvent(event); executed: QAbstractScrollArea::focusInEvent(event); Execution Count:13 | 13 |
2207 | } executed: } Execution Count:574 | 574 |
2208 | | - |
2209 | | - |
2210 | | - |
2211 | | - |
2212 | bool QGraphicsView::focusNextPrevChild(bool next) | - |
2213 | { | - |
2214 | return QAbstractScrollArea::focusNextPrevChild(next); never executed: return QAbstractScrollArea::focusNextPrevChild(next); | 0 |
2215 | } | - |
2216 | | - |
2217 | | - |
2218 | | - |
2219 | | - |
2220 | void QGraphicsView::focusOutEvent(QFocusEvent *event) | - |
2221 | { | - |
2222 | QGraphicsViewPrivate * const d = d_func(); | - |
2223 | QAbstractScrollArea::focusOutEvent(event); | - |
2224 | if (d->scene) evaluated: d->scene yes Evaluation Count:4 | yes Evaluation Count:6 |
| 4-6 |
2225 | QApplication::sendEvent(d->scene, event); executed: QApplication::sendEvent(d->scene, event); Execution Count:4 | 4 |
2226 | } executed: } Execution Count:10 | 10 |
2227 | | - |
2228 | | - |
2229 | | - |
2230 | | - |
2231 | void QGraphicsView::keyPressEvent(QKeyEvent *event) | - |
2232 | { | - |
2233 | QGraphicsViewPrivate * const d = d_func(); | - |
2234 | if (!d->scene || !d->sceneInteractionAllowed) { partially evaluated: !d->scene no Evaluation Count:0 | yes Evaluation Count:1 |
partially evaluated: !d->sceneInteractionAllowed no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
2235 | QAbstractScrollArea::keyPressEvent(event); | - |
2236 | return; | 0 |
2237 | } | - |
2238 | QApplication::sendEvent(d->scene, event); | - |
2239 | if (!event->isAccepted()) partially evaluated: !event->isAccepted() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
2240 | QAbstractScrollArea::keyPressEvent(event); executed: QAbstractScrollArea::keyPressEvent(event); Execution Count:1 | 1 |
2241 | } executed: } Execution Count:1 | 1 |
2242 | | - |
2243 | | - |
2244 | | - |
2245 | | - |
2246 | void QGraphicsView::keyReleaseEvent(QKeyEvent *event) | - |
2247 | { | - |
2248 | QGraphicsViewPrivate * const d = d_func(); | - |
2249 | if (!d->scene || !d->sceneInteractionAllowed) never evaluated: !d->scene never evaluated: !d->sceneInteractionAllowed | 0 |
2250 | return; | 0 |
2251 | QApplication::sendEvent(d->scene, event); | - |
2252 | if (!event->isAccepted()) never evaluated: !event->isAccepted() | 0 |
2253 | QAbstractScrollArea::keyReleaseEvent(event); never executed: QAbstractScrollArea::keyReleaseEvent(event); | 0 |
2254 | } | 0 |
2255 | | - |
2256 | | - |
2257 | | - |
2258 | | - |
2259 | void QGraphicsView::mouseDoubleClickEvent(QMouseEvent *event) | - |
2260 | { | - |
2261 | QGraphicsViewPrivate * const d = d_func(); | - |
2262 | if (!d->scene || !d->sceneInteractionAllowed) never evaluated: !d->scene never evaluated: !d->sceneInteractionAllowed | 0 |
2263 | return; | 0 |
2264 | | - |
2265 | d->storeMouseEvent(event); | - |
2266 | d->mousePressViewPoint = event->pos(); | - |
2267 | d->mousePressScenePoint = mapToScene(d->mousePressViewPoint); | - |
2268 | d->mousePressScreenPoint = event->globalPos(); | - |
2269 | d->lastMouseMoveScenePoint = d->mousePressScenePoint; | - |
2270 | d->lastMouseMoveScreenPoint = d->mousePressScreenPoint; | - |
2271 | d->mousePressButton = event->button(); | - |
2272 | | - |
2273 | QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseDoubleClick); | - |
2274 | mouseEvent.setWidget(viewport()); | - |
2275 | mouseEvent.setButtonDownScenePos(d->mousePressButton, d->mousePressScenePoint); | - |
2276 | mouseEvent.setButtonDownScreenPos(d->mousePressButton, d->mousePressScreenPoint); | - |
2277 | mouseEvent.setScenePos(mapToScene(d->mousePressViewPoint)); | - |
2278 | mouseEvent.setScreenPos(d->mousePressScreenPoint); | - |
2279 | mouseEvent.setLastScenePos(d->lastMouseMoveScenePoint); | - |
2280 | mouseEvent.setLastScreenPos(d->lastMouseMoveScreenPoint); | - |
2281 | mouseEvent.setButtons(event->buttons()); | - |
2282 | mouseEvent.setButtons(event->buttons()); | - |
2283 | mouseEvent.setAccepted(false); | - |
2284 | mouseEvent.setButton(event->button()); | - |
2285 | mouseEvent.setModifiers(event->modifiers()); | - |
2286 | if (event->spontaneous()) never evaluated: event->spontaneous() | 0 |
2287 | qt_sendSpontaneousEvent(d->scene, &mouseEvent); never executed: qt_sendSpontaneousEvent(d->scene, &mouseEvent); | 0 |
2288 | else | - |
2289 | QApplication::sendEvent(d->scene, &mouseEvent); never executed: QApplication::sendEvent(d->scene, &mouseEvent); | 0 |
2290 | } | - |
2291 | | - |
2292 | | - |
2293 | | - |
2294 | | - |
2295 | void QGraphicsView::mousePressEvent(QMouseEvent *event) | - |
2296 | { | - |
2297 | QGraphicsViewPrivate * const d = d_func(); | - |
2298 | | - |
2299 | | - |
2300 | | - |
2301 | | - |
2302 | d->storeMouseEvent(event); | - |
2303 | d->lastMouseEvent.setAccepted(false); | - |
2304 | | - |
2305 | if (d->sceneInteractionAllowed) { evaluated: d->sceneInteractionAllowed yes Evaluation Count:119 | yes Evaluation Count:104 |
| 104-119 |
2306 | | - |
2307 | d->mousePressViewPoint = event->pos(); | - |
2308 | d->mousePressScenePoint = mapToScene(d->mousePressViewPoint); | - |
2309 | d->mousePressScreenPoint = event->globalPos(); | - |
2310 | d->lastMouseMoveScenePoint = d->mousePressScenePoint; | - |
2311 | d->lastMouseMoveScreenPoint = d->mousePressScreenPoint; | - |
2312 | d->mousePressButton = event->button(); | - |
2313 | | - |
2314 | if (d->scene) { evaluated: d->scene yes Evaluation Count:116 | yes Evaluation Count:3 |
| 3-116 |
2315 | | - |
2316 | QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMousePress); | - |
2317 | mouseEvent.setWidget(viewport()); | - |
2318 | mouseEvent.setButtonDownScenePos(d->mousePressButton, d->mousePressScenePoint); | - |
2319 | mouseEvent.setButtonDownScreenPos(d->mousePressButton, d->mousePressScreenPoint); | - |
2320 | mouseEvent.setScenePos(d->mousePressScenePoint); | - |
2321 | mouseEvent.setScreenPos(d->mousePressScreenPoint); | - |
2322 | mouseEvent.setLastScenePos(d->lastMouseMoveScenePoint); | - |
2323 | mouseEvent.setLastScreenPos(d->lastMouseMoveScreenPoint); | - |
2324 | mouseEvent.setButtons(event->buttons()); | - |
2325 | mouseEvent.setButton(event->button()); | - |
2326 | mouseEvent.setModifiers(event->modifiers()); | - |
2327 | mouseEvent.setAccepted(false); | - |
2328 | if (event->spontaneous()) evaluated: event->spontaneous() yes Evaluation Count:3 | yes Evaluation Count:113 |
| 3-113 |
2329 | qt_sendSpontaneousEvent(d->scene, &mouseEvent); executed: qt_sendSpontaneousEvent(d->scene, &mouseEvent); Execution Count:3 | 3 |
2330 | else | - |
2331 | QApplication::sendEvent(d->scene, &mouseEvent); executed: QApplication::sendEvent(d->scene, &mouseEvent); Execution Count:113 | 113 |
2332 | | - |
2333 | | - |
2334 | bool isAccepted = mouseEvent.isAccepted(); | - |
2335 | event->setAccepted(isAccepted); | - |
2336 | | - |
2337 | | - |
2338 | d->lastMouseEvent.setAccepted(isAccepted); | - |
2339 | | - |
2340 | if (isAccepted) evaluated: isAccepted yes Evaluation Count:105 | yes Evaluation Count:11 |
| 11-105 |
2341 | return; executed: return; Execution Count:105 | 105 |
2342 | } executed: } Execution Count:11 | 11 |
2343 | } executed: } Execution Count:14 | 14 |
2344 | | - |
2345 | | - |
2346 | if (d->dragMode == QGraphicsView::RubberBandDrag && !d->rubberBanding) { evaluated: d->dragMode == QGraphicsView::RubberBandDrag yes Evaluation Count:5 | yes Evaluation Count:113 |
evaluated: !d->rubberBanding yes Evaluation Count:4 | yes Evaluation Count:1 |
| 1-113 |
2347 | if (d->sceneInteractionAllowed) { partially evaluated: d->sceneInteractionAllowed yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
2348 | | - |
2349 | event->accept(); | - |
2350 | d->rubberBanding = true; | - |
2351 | d->rubberBandRect = QRect(); | - |
2352 | if (d->scene) { evaluated: d->scene yes Evaluation Count:3 | yes Evaluation Count:1 |
| 1-3 |
2353 | | - |
2354 | d->scene->clearSelection(); | - |
2355 | } executed: } Execution Count:3 | 3 |
2356 | } executed: } Execution Count:4 | 4 |
2357 | } else executed: } Execution Count:4 | 4 |
2358 | | - |
2359 | if (d->dragMode == QGraphicsView::ScrollHandDrag && event->button() == Qt::LeftButton) { evaluated: d->dragMode == QGraphicsView::ScrollHandDrag yes Evaluation Count:9 | yes Evaluation Count:105 |
partially evaluated: event->button() == Qt::LeftButton yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-105 |
2360 | | - |
2361 | event->accept(); | - |
2362 | d->handScrolling = true; | - |
2363 | d->handScrollMotions = 0; | - |
2364 | | - |
2365 | viewport()->setCursor(Qt::ClosedHandCursor); | - |
2366 | | - |
2367 | } executed: } Execution Count:9 | 9 |
2368 | } | - |
2369 | | - |
2370 | | - |
2371 | | - |
2372 | | - |
2373 | void QGraphicsView::mouseMoveEvent(QMouseEvent *event) | - |
2374 | { | - |
2375 | QGraphicsViewPrivate * const d = d_func(); | - |
2376 | | - |
2377 | if (d->dragMode == QGraphicsView::ScrollHandDrag) { evaluated: d->dragMode == QGraphicsView::ScrollHandDrag yes Evaluation Count:43 | yes Evaluation Count:41 |
| 41-43 |
2378 | if (d->handScrolling) { evaluated: d->handScrolling yes Evaluation Count:32 | yes Evaluation Count:11 |
| 11-32 |
2379 | QScrollBar *hBar = horizontalScrollBar(); | - |
2380 | QScrollBar *vBar = verticalScrollBar(); | - |
2381 | QPoint delta = event->pos() - d->lastMouseEvent.pos(); | - |
2382 | hBar->setValue(hBar->value() + (isRightToLeft() ? delta.x() : -delta.x())); | - |
2383 | vBar->setValue(vBar->value() - delta.y()); | - |
2384 | | - |
2385 | | - |
2386 | | - |
2387 | ++d->handScrollMotions; | - |
2388 | } executed: } Execution Count:32 | 32 |
2389 | } executed: } Execution Count:43 | 43 |
2390 | | - |
2391 | d->mouseMoveEventHandler(event); | - |
2392 | } executed: } Execution Count:84 | 84 |
2393 | | - |
2394 | | - |
2395 | | - |
2396 | | - |
2397 | void QGraphicsView::mouseReleaseEvent(QMouseEvent *event) | - |
2398 | { | - |
2399 | QGraphicsViewPrivate * const d = d_func(); | - |
2400 | | - |
2401 | | - |
2402 | if (d->dragMode == QGraphicsView::RubberBandDrag && d->sceneInteractionAllowed && !event->buttons()) { evaluated: d->dragMode == QGraphicsView::RubberBandDrag yes Evaluation Count:4 | yes Evaluation Count:215 |
partially evaluated: d->sceneInteractionAllowed yes Evaluation Count:4 | no Evaluation Count:0 |
evaluated: !event->buttons() yes Evaluation Count:2 | yes Evaluation Count:2 |
| 0-215 |
2403 | if (d->rubberBanding) { partially evaluated: d->rubberBanding yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
2404 | if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate){ partially evaluated: d->viewportUpdateMode != QGraphicsView::NoViewportUpdate yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
2405 | if (d->viewportUpdateMode != FullViewportUpdate) partially evaluated: d->viewportUpdateMode != FullViewportUpdate yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
2406 | viewport()->update(d->rubberBandRegion(viewport(), d->rubberBandRect)); executed: viewport()->update(d->rubberBandRegion(viewport(), d->rubberBandRect)); Execution Count:2 | 2 |
2407 | else | - |
2408 | d->updateAll(); never executed: d->updateAll(); | 0 |
2409 | } | - |
2410 | d->rubberBanding = false; | - |
2411 | d->rubberBandRect = QRect(); | - |
2412 | } executed: } Execution Count:2 | 2 |
2413 | } else executed: } Execution Count:2 | 2 |
2414 | | - |
2415 | if (d->dragMode == QGraphicsView::ScrollHandDrag && event->button() == Qt::LeftButton) { evaluated: d->dragMode == QGraphicsView::ScrollHandDrag yes Evaluation Count:8 | yes Evaluation Count:209 |
partially evaluated: event->button() == Qt::LeftButton yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-209 |
2416 | | - |
2417 | | - |
2418 | | - |
2419 | | - |
2420 | viewport()->setCursor(Qt::OpenHandCursor); | - |
2421 | | - |
2422 | d->handScrolling = false; | - |
2423 | | - |
2424 | if (d->scene && d->sceneInteractionAllowed && !d->lastMouseEvent.isAccepted() && d->handScrollMotions <= 6) { evaluated: d->scene yes Evaluation Count:4 | yes Evaluation Count:4 |
evaluated: d->sceneInteractionAllowed yes Evaluation Count:2 | yes Evaluation Count:2 |
partially evaluated: !d->lastMouseEvent.isAccepted() yes Evaluation Count:2 | no Evaluation Count:0 |
evaluated: d->handScrollMotions <= 6 yes Evaluation Count:1 | yes Evaluation Count:1 |
| 0-4 |
2425 | | - |
2426 | | - |
2427 | | - |
2428 | d->scene->clearSelection(); | - |
2429 | } executed: } Execution Count:1 | 1 |
2430 | } executed: } Execution Count:8 | 8 |
2431 | | - |
2432 | d->storeMouseEvent(event); | - |
2433 | | - |
2434 | if (!d->sceneInteractionAllowed) evaluated: !d->sceneInteractionAllowed yes Evaluation Count:104 | yes Evaluation Count:115 |
| 104-115 |
2435 | return; executed: return; Execution Count:104 | 104 |
2436 | | - |
2437 | if (!d->scene) evaluated: !d->scene yes Evaluation Count:3 | yes Evaluation Count:112 |
| 3-112 |
2438 | return; executed: return; Execution Count:3 | 3 |
2439 | | - |
2440 | QGraphicsSceneMouseEvent mouseEvent(QEvent::GraphicsSceneMouseRelease); | - |
2441 | mouseEvent.setWidget(viewport()); | - |
2442 | mouseEvent.setButtonDownScenePos(d->mousePressButton, d->mousePressScenePoint); | - |
2443 | mouseEvent.setButtonDownScreenPos(d->mousePressButton, d->mousePressScreenPoint); | - |
2444 | mouseEvent.setScenePos(mapToScene(event->pos())); | - |
2445 | mouseEvent.setScreenPos(event->globalPos()); | - |
2446 | mouseEvent.setLastScenePos(d->lastMouseMoveScenePoint); | - |
2447 | mouseEvent.setLastScreenPos(d->lastMouseMoveScreenPoint); | - |
2448 | mouseEvent.setButtons(event->buttons()); | - |
2449 | mouseEvent.setButton(event->button()); | - |
2450 | mouseEvent.setModifiers(event->modifiers()); | - |
2451 | mouseEvent.setAccepted(false); | - |
2452 | if (event->spontaneous()) evaluated: event->spontaneous() yes Evaluation Count:3 | yes Evaluation Count:109 |
| 3-109 |
2453 | qt_sendSpontaneousEvent(d->scene, &mouseEvent); executed: qt_sendSpontaneousEvent(d->scene, &mouseEvent); Execution Count:3 | 3 |
2454 | else | - |
2455 | QApplication::sendEvent(d->scene, &mouseEvent); executed: QApplication::sendEvent(d->scene, &mouseEvent); Execution Count:109 | 109 |
2456 | | - |
2457 | | - |
2458 | d->lastMouseEvent.setAccepted(mouseEvent.isAccepted()); | - |
2459 | | - |
2460 | | - |
2461 | if (mouseEvent.isAccepted() && mouseEvent.buttons() == 0 && viewport()->testAttribute(Qt::WA_SetCursor)) { evaluated: mouseEvent.isAccepted() yes Evaluation Count:104 | yes Evaluation Count:8 |
partially evaluated: mouseEvent.buttons() == 0 yes Evaluation Count:104 | no Evaluation Count:0 |
evaluated: viewport()->testAttribute(Qt::WA_SetCursor) yes Evaluation Count:1 | yes Evaluation Count:103 |
| 0-104 |
2462 | | - |
2463 | d->_q_unsetViewportCursor(); | - |
2464 | } executed: } Execution Count:1 | 1 |
2465 | | - |
2466 | } executed: } Execution Count:112 | 112 |
2467 | | - |
2468 | | - |
2469 | | - |
2470 | | - |
2471 | | - |
2472 | void QGraphicsView::wheelEvent(QWheelEvent *event) | - |
2473 | { | - |
2474 | QGraphicsViewPrivate * const d = d_func(); | - |
2475 | if (!d->scene || !d->sceneInteractionAllowed) { partially evaluated: !d->scene no Evaluation Count:0 | yes Evaluation Count:2 |
partially evaluated: !d->sceneInteractionAllowed no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
2476 | QAbstractScrollArea::wheelEvent(event); | - |
2477 | return; | 0 |
2478 | } | - |
2479 | | - |
2480 | event->ignore(); | - |
2481 | | - |
2482 | QGraphicsSceneWheelEvent wheelEvent(QEvent::GraphicsSceneWheel); | - |
2483 | wheelEvent.setWidget(viewport()); | - |
2484 | wheelEvent.setScenePos(mapToScene(event->pos())); | - |
2485 | wheelEvent.setScreenPos(event->globalPos()); | - |
2486 | wheelEvent.setButtons(event->buttons()); | - |
2487 | wheelEvent.setModifiers(event->modifiers()); | - |
2488 | wheelEvent.setDelta(event->delta()); | - |
2489 | wheelEvent.setOrientation(event->orientation()); | - |
2490 | wheelEvent.setAccepted(false); | - |
2491 | QApplication::sendEvent(d->scene, &wheelEvent); | - |
2492 | event->setAccepted(wheelEvent.isAccepted()); | - |
2493 | if (!event->isAccepted()) partially evaluated: !event->isAccepted() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
2494 | QAbstractScrollArea::wheelEvent(event); executed: QAbstractScrollArea::wheelEvent(event); Execution Count:2 | 2 |
2495 | } executed: } Execution Count:2 | 2 |
2496 | | - |
2497 | | - |
2498 | | - |
2499 | | - |
2500 | | - |
2501 | void QGraphicsView::paintEvent(QPaintEvent *event) | - |
2502 | { | - |
2503 | QGraphicsViewPrivate * const d = d_func(); | - |
2504 | if (!d->scene) { evaluated: !d->scene yes Evaluation Count:20 | yes Evaluation Count:2023 |
| 20-2023 |
2505 | QAbstractScrollArea::paintEvent(event); | - |
2506 | return; executed: return; Execution Count:20 | 20 |
2507 | } | - |
2508 | | - |
2509 | | - |
2510 | d->scene->d_func()->painterStateProtection = !(d->optimizationFlags & DontSavePainterState); | - |
2511 | | - |
2512 | | - |
2513 | d->exposedRegion = event->region(); | - |
2514 | QRectF exposedSceneRect = mapToScene(d->exposedRegion.boundingRect()).boundingRect(); | - |
2515 | | - |
2516 | | - |
2517 | QPainter painter(viewport()); | - |
2518 | | - |
2519 | if (d->rubberBanding && !d->rubberBandRect.isEmpty()) evaluated: d->rubberBanding yes Evaluation Count:3 | yes Evaluation Count:2020 |
partially evaluated: !d->rubberBandRect.isEmpty() yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-2020 |
2520 | painter.save(); executed: painter.save(); Execution Count:3 | 3 |
2521 | | - |
2522 | | - |
2523 | painter.setRenderHints(painter.renderHints(), false); | - |
2524 | painter.setRenderHints(d->renderHints, true); | - |
2525 | | - |
2526 | | - |
2527 | const bool viewTransformed = isTransformed(); | - |
2528 | if (viewTransformed) evaluated: viewTransformed yes Evaluation Count:1985 | yes Evaluation Count:38 |
| 38-1985 |
2529 | painter.setWorldTransform(viewportTransform()); executed: painter.setWorldTransform(viewportTransform()); Execution Count:1985 | 1985 |
2530 | const QTransform viewTransform = painter.worldTransform(); | - |
2531 | | - |
2532 | | - |
2533 | if ((d->cacheMode & CacheBackground) evaluated: (d->cacheMode & CacheBackground) yes Evaluation Count:1 | yes Evaluation Count:2022 |
| 1-2022 |
2534 | | - |
2535 | | - |
2536 | | - |
2537 | ) { | - |
2538 | | - |
2539 | | - |
2540 | if (d->mustResizeBackgroundPixmap) { partially evaluated: d->mustResizeBackgroundPixmap yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
2541 | d->backgroundPixmap = QPixmap(viewport()->size()); | - |
2542 | QBrush bgBrush = viewport()->palette().brush(viewport()->backgroundRole()); | - |
2543 | if (!bgBrush.isOpaque()) partially evaluated: !bgBrush.isOpaque() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
2544 | d->backgroundPixmap.fill(Qt::transparent); never executed: d->backgroundPixmap.fill(Qt::transparent); | 0 |
2545 | QPainter p(&d->backgroundPixmap); | - |
2546 | p.fillRect(0, 0, d->backgroundPixmap.width(), d->backgroundPixmap.height(), bgBrush); | - |
2547 | d->backgroundPixmapExposed = QRegion(viewport()->rect()); | - |
2548 | d->mustResizeBackgroundPixmap = false; | - |
2549 | } executed: } Execution Count:1 | 1 |
2550 | | - |
2551 | | - |
2552 | if (!d->backgroundPixmapExposed.isEmpty()) { partially evaluated: !d->backgroundPixmapExposed.isEmpty() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
2553 | QPainter backgroundPainter(&d->backgroundPixmap); | - |
2554 | backgroundPainter.setClipRegion(d->backgroundPixmapExposed, Qt::ReplaceClip); | - |
2555 | if (viewTransformed) partially evaluated: viewTransformed yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
2556 | backgroundPainter.setTransform(viewTransform); executed: backgroundPainter.setTransform(viewTransform); Execution Count:1 | 1 |
2557 | QRectF backgroundExposedSceneRect = mapToScene(d->backgroundPixmapExposed.boundingRect()).boundingRect(); | - |
2558 | drawBackground(&backgroundPainter, backgroundExposedSceneRect); | - |
2559 | d->backgroundPixmapExposed = QRegion(); | - |
2560 | } executed: } Execution Count:1 | 1 |
2561 | | - |
2562 | | - |
2563 | if (viewTransformed) { partially evaluated: viewTransformed yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
2564 | painter.setWorldTransform(QTransform()); | - |
2565 | painter.drawPixmap(QPoint(), d->backgroundPixmap); | - |
2566 | painter.setWorldTransform(viewTransform); | - |
2567 | } else { executed: } Execution Count:1 | 1 |
2568 | painter.drawPixmap(QPoint(), d->backgroundPixmap); | - |
2569 | } | 0 |
2570 | } else { | - |
2571 | if (!(d->optimizationFlags & DontSavePainterState)) evaluated: !(d->optimizationFlags & DontSavePainterState) yes Evaluation Count:2016 | yes Evaluation Count:6 |
| 6-2016 |
2572 | painter.save(); executed: painter.save(); Execution Count:2016 | 2016 |
2573 | drawBackground(&painter, exposedSceneRect); | - |
2574 | if (!(d->optimizationFlags & DontSavePainterState)) evaluated: !(d->optimizationFlags & DontSavePainterState) yes Evaluation Count:2016 | yes Evaluation Count:6 |
| 6-2016 |
2575 | painter.restore(); executed: painter.restore(); Execution Count:2016 | 2016 |
2576 | } executed: } Execution Count:2022 | 2022 |
2577 | | - |
2578 | | - |
2579 | if (!(d->optimizationFlags & IndirectPainting)) { evaluated: !(d->optimizationFlags & IndirectPainting) yes Evaluation Count:2017 | yes Evaluation Count:6 |
| 6-2017 |
2580 | const quint32 oldRectAdjust = d->scene->d_func()->rectAdjust; | - |
2581 | if (d->optimizationFlags & QGraphicsView::DontAdjustForAntialiasing) evaluated: d->optimizationFlags & QGraphicsView::DontAdjustForAntialiasing yes Evaluation Count:42 | yes Evaluation Count:1975 |
| 42-1975 |
2582 | d->scene->d_func()->rectAdjust = 1; executed: d->scene->d_func()->rectAdjust = 1; Execution Count:42 | 42 |
2583 | else | - |
2584 | d->scene->d_func()->rectAdjust = 2; executed: d->scene->d_func()->rectAdjust = 2; Execution Count:1975 | 1975 |
2585 | d->scene->d_func()->drawItems(&painter, viewTransformed ? &viewTransform : 0, | - |
2586 | &d->exposedRegion, viewport()); | - |
2587 | d->scene->d_func()->rectAdjust = oldRectAdjust; | - |
2588 | | - |
2589 | | - |
2590 | | - |
2591 | | - |
2592 | | - |
2593 | | - |
2594 | if (!d->scene->d_func()->painterStateProtection) evaluated: !d->scene->d_func()->painterStateProtection yes Evaluation Count:4 | yes Evaluation Count:2013 |
| 4-2013 |
2595 | painter.setOpacity(1.0); executed: painter.setOpacity(1.0); Execution Count:4 | 4 |
2596 | painter.setWorldTransform(viewTransform); | - |
2597 | } else { executed: } Execution Count:2017 | 2017 |
2598 | | - |
2599 | if (!d->scene->d_func()->unpolishedItems.isEmpty()) partially evaluated: !d->scene->d_func()->unpolishedItems.isEmpty() no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
2600 | d->scene->d_func()->_q_polishItems(); never executed: d->scene->d_func()->_q_polishItems(); | 0 |
2601 | | - |
2602 | | - |
2603 | d->scene->d_func()->updateAll = false; | - |
2604 | | - |
2605 | | - |
2606 | bool allItems = false; | - |
2607 | QList<QGraphicsItem *> itemList = d->findItems(d->exposedRegion, &allItems, viewTransform); | - |
2608 | if (!itemList.isEmpty()) { partially evaluated: !itemList.isEmpty() yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
2609 | | - |
2610 | const int numItems = itemList.size(); | - |
2611 | QGraphicsItem **itemArray = &itemList[0]; | - |
2612 | QStyleOptionGraphicsItem *styleOptionArray = d->allocStyleOptionsArray(numItems); | - |
2613 | QTransform transform(Qt::Uninitialized); | - |
2614 | for (int i = 0; i < numItems; ++i) { evaluated: i < numItems yes Evaluation Count:10 | yes Evaluation Count:6 |
| 6-10 |
2615 | QGraphicsItem *item = itemArray[i]; | - |
2616 | QGraphicsItemPrivate *itemd = item->d_ptr.data(); | - |
2617 | itemd->initStyleOption(&styleOptionArray[i], viewTransform, d->exposedRegion, allItems); | - |
2618 | | - |
2619 | | - |
2620 | | - |
2621 | | - |
2622 | | - |
2623 | const QRectF brect = adjustedItemEffectiveBoundingRect(item); | - |
2624 | if (!itemd->itemIsUntransformable()) { partially evaluated: !itemd->itemIsUntransformable() yes Evaluation Count:10 | no Evaluation Count:0 |
| 0-10 |
2625 | transform = item->sceneTransform(); | - |
2626 | if (viewTransformed) partially evaluated: viewTransformed yes Evaluation Count:10 | no Evaluation Count:0 |
| 0-10 |
2627 | transform *= viewTransform; executed: transform *= viewTransform; Execution Count:10 | 10 |
2628 | } else { executed: } Execution Count:10 | 10 |
2629 | transform = item->deviceTransform(viewTransform); | - |
2630 | } | 0 |
2631 | itemd->paintedViewBoundingRects.insert(d->viewport, transform.mapRect(brect).toRect()); | - |
2632 | } executed: } Execution Count:10 | 10 |
2633 | | - |
2634 | drawItems(&painter, numItems, itemArray, styleOptionArray); | - |
2635 | d->freeStyleOptionsArray(styleOptionArray); | - |
2636 | } executed: } Execution Count:6 | 6 |
2637 | } executed: } Execution Count:6 | 6 |
2638 | | - |
2639 | | - |
2640 | drawForeground(&painter, exposedSceneRect); | - |
2641 | | - |
2642 | | - |
2643 | | - |
2644 | if (d->rubberBanding && !d->rubberBandRect.isEmpty()) { evaluated: d->rubberBanding yes Evaluation Count:3 | yes Evaluation Count:2020 |
partially evaluated: !d->rubberBandRect.isEmpty() yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-2020 |
2645 | painter.restore(); | - |
2646 | QStyleOptionRubberBand option; | - |
2647 | option.initFrom(viewport()); | - |
2648 | option.rect = d->rubberBandRect; | - |
2649 | option.shape = QRubberBand::Rectangle; | - |
2650 | | - |
2651 | QStyleHintReturnMask mask; | - |
2652 | if (viewport()->style()->styleHint(QStyle::SH_RubberBand_Mask, &option, viewport(), &mask)) { partially evaluated: viewport()->style()->styleHint(QStyle::SH_RubberBand_Mask, &option, viewport(), &mask) yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
2653 | | - |
2654 | painter.setClipRegion(mask.region, Qt::IntersectClip); | - |
2655 | } executed: } Execution Count:3 | 3 |
2656 | | - |
2657 | viewport()->style()->drawControl(QStyle::CE_RubberBand, &option, &painter, viewport()); | - |
2658 | } executed: } Execution Count:3 | 3 |
2659 | | - |
2660 | | - |
2661 | painter.end(); | - |
2662 | | - |
2663 | | - |
2664 | d->scene->d_func()->painterStateProtection = true; | - |
2665 | } executed: } Execution Count:2023 | 2023 |
2666 | | - |
2667 | | - |
2668 | | - |
2669 | | - |
2670 | void QGraphicsView::resizeEvent(QResizeEvent *event) | - |
2671 | { | - |
2672 | QGraphicsViewPrivate * const d = d_func(); | - |
2673 | | - |
2674 | | - |
2675 | QPointF oldLastCenterPoint = d->lastCenterPoint; | - |
2676 | | - |
2677 | QAbstractScrollArea::resizeEvent(event); | - |
2678 | d->recalculateContentSize(); | - |
2679 | | - |
2680 | | - |
2681 | if (d->resizeAnchor == NoAnchor && !d->keepLastCenterPoint) { evaluated: d->resizeAnchor == NoAnchor yes Evaluation Count:911 | yes Evaluation Count:9 |
evaluated: !d->keepLastCenterPoint yes Evaluation Count:176 | yes Evaluation Count:735 |
| 9-911 |
2682 | d->updateLastCenterPoint(); | - |
2683 | } else { executed: } Execution Count:176 | 176 |
2684 | d->lastCenterPoint = oldLastCenterPoint; | - |
2685 | } executed: } Execution Count:744 | 744 |
2686 | d->centerView(d->resizeAnchor); | - |
2687 | d->keepLastCenterPoint = false; | - |
2688 | | - |
2689 | if (d->cacheMode & CacheBackground) { partially evaluated: d->cacheMode & CacheBackground no Evaluation Count:0 | yes Evaluation Count:920 |
| 0-920 |
2690 | | - |
2691 | d->mustResizeBackgroundPixmap = true; | - |
2692 | } | 0 |
2693 | } executed: } Execution Count:920 | 920 |
2694 | | - |
2695 | | - |
2696 | | - |
2697 | | - |
2698 | void QGraphicsView::scrollContentsBy(int dx, int dy) | - |
2699 | { | - |
2700 | QGraphicsViewPrivate * const d = d_func(); | - |
2701 | d->dirtyScroll = true; | - |
2702 | if (d->transforming) evaluated: d->transforming yes Evaluation Count:326 | yes Evaluation Count:2413 |
| 326-2413 |
2703 | return; executed: return; Execution Count:326 | 326 |
2704 | if (isRightToLeft()) evaluated: isRightToLeft() yes Evaluation Count:5 | yes Evaluation Count:2408 |
| 5-2408 |
2705 | dx = -dx; executed: dx = -dx; Execution Count:5 | 5 |
2706 | | - |
2707 | if (d->viewportUpdateMode != QGraphicsView::NoViewportUpdate) { partially evaluated: d->viewportUpdateMode != QGraphicsView::NoViewportUpdate yes Evaluation Count:2413 | no Evaluation Count:0 |
| 0-2413 |
2708 | if (d->viewportUpdateMode != QGraphicsView::FullViewportUpdate) { partially evaluated: d->viewportUpdateMode != QGraphicsView::FullViewportUpdate yes Evaluation Count:2413 | no Evaluation Count:0 |
| 0-2413 |
2709 | if (d->accelerateScrolling) { partially evaluated: d->accelerateScrolling yes Evaluation Count:2413 | no Evaluation Count:0 |
| 0-2413 |
2710 | | - |
2711 | | - |
2712 | if (!d->rubberBandRect.isEmpty()) { partially evaluated: !d->rubberBandRect.isEmpty() no Evaluation Count:0 | yes Evaluation Count:2413 |
| 0-2413 |
2713 | QRegion rubberBandRegion(d->rubberBandRegion(viewport(), d->rubberBandRect)); | - |
2714 | rubberBandRegion += rubberBandRegion.translated(-dx, -dy); | - |
2715 | viewport()->update(rubberBandRegion); | - |
2716 | } | 0 |
2717 | | - |
2718 | d->dirtyScrollOffset.rx() += dx; | - |
2719 | d->dirtyScrollOffset.ry() += dy; | - |
2720 | d->dirtyRegion.translate(dx, dy); | - |
2721 | viewport()->scroll(dx, dy); | - |
2722 | } else { executed: } Execution Count:2413 | 2413 |
2723 | d->updateAll(); | - |
2724 | } | 0 |
2725 | } else { | - |
2726 | d->updateAll(); | - |
2727 | } | 0 |
2728 | } | - |
2729 | | - |
2730 | d->updateLastCenterPoint(); | - |
2731 | | - |
2732 | if ((d->cacheMode & CacheBackground) partially evaluated: (d->cacheMode & CacheBackground) no Evaluation Count:0 | yes Evaluation Count:2413 |
| 0-2413 |
2733 | | - |
2734 | | - |
2735 | | - |
2736 | ) { | - |
2737 | | - |
2738 | QRegion exposed; | - |
2739 | if (!d->backgroundPixmap.isNull()) never evaluated: !d->backgroundPixmap.isNull() | 0 |
2740 | d->backgroundPixmap.scroll(dx, dy, d->backgroundPixmap.rect(), &exposed); never executed: d->backgroundPixmap.scroll(dx, dy, d->backgroundPixmap.rect(), &exposed); | 0 |
2741 | | - |
2742 | | - |
2743 | d->backgroundPixmapExposed.translate(dx, dy); | - |
2744 | d->backgroundPixmapExposed += exposed; | - |
2745 | } | 0 |
2746 | | - |
2747 | | - |
2748 | if (d->sceneInteractionAllowed) evaluated: d->sceneInteractionAllowed yes Evaluation Count:2397 | yes Evaluation Count:16 |
| 16-2397 |
2749 | d->replayLastMouseEvent(); executed: d->replayLastMouseEvent(); Execution Count:2397 | 2397 |
2750 | } executed: } Execution Count:2413 | 2413 |
2751 | | - |
2752 | | - |
2753 | | - |
2754 | | - |
2755 | void QGraphicsView::showEvent(QShowEvent *event) | - |
2756 | { | - |
2757 | QGraphicsViewPrivate * const d = d_func(); | - |
2758 | d->recalculateContentSize(); | - |
2759 | d->centerView(d->transformationAnchor); | - |
2760 | QAbstractScrollArea::showEvent(event); | - |
2761 | } executed: } Execution Count:734 | 734 |
2762 | | - |
2763 | | - |
2764 | | - |
2765 | | - |
2766 | void QGraphicsView::inputMethodEvent(QInputMethodEvent *event) | - |
2767 | { | - |
2768 | QGraphicsViewPrivate * const d = d_func(); | - |
2769 | if (d->scene) partially evaluated: d->scene yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
2770 | QApplication::sendEvent(d->scene, event); executed: QApplication::sendEvent(d->scene, event); Execution Count:3 | 3 |
2771 | } executed: } Execution Count:3 | 3 |
2772 | void QGraphicsView::drawBackground(QPainter *painter, const QRectF &rect) | - |
2773 | { | - |
2774 | QGraphicsViewPrivate * const d = d_func(); | - |
2775 | if (d->scene && d->backgroundBrush.style() == Qt::NoBrush) { partially evaluated: d->scene yes Evaluation Count:2020 | no Evaluation Count:0 |
evaluated: d->backgroundBrush.style() == Qt::NoBrush yes Evaluation Count:2017 | yes Evaluation Count:3 |
| 0-2020 |
2776 | d->scene->drawBackground(painter, rect); | - |
2777 | return; executed: return; Execution Count:2017 | 2017 |
2778 | } | - |
2779 | | - |
2780 | painter->fillRect(rect, d->backgroundBrush); | - |
2781 | } executed: } Execution Count:3 | 3 |
2782 | void QGraphicsView::drawForeground(QPainter *painter, const QRectF &rect) | - |
2783 | { | - |
2784 | QGraphicsViewPrivate * const d = d_func(); | - |
2785 | if (d->scene && d->foregroundBrush.style() == Qt::NoBrush) { partially evaluated: d->scene yes Evaluation Count:2024 | no Evaluation Count:0 |
partially evaluated: d->foregroundBrush.style() == Qt::NoBrush yes Evaluation Count:2024 | no Evaluation Count:0 |
| 0-2024 |
2786 | d->scene->drawForeground(painter, rect); | - |
2787 | return; executed: return; Execution Count:2024 | 2024 |
2788 | } | - |
2789 | | - |
2790 | painter->fillRect(rect, d->foregroundBrush); | - |
2791 | } | 0 |
2792 | void QGraphicsView::drawItems(QPainter *painter, int numItems, | - |
2793 | QGraphicsItem *items[], | - |
2794 | const QStyleOptionGraphicsItem options[]) | - |
2795 | { | - |
2796 | QGraphicsViewPrivate * const d = d_func(); | - |
2797 | if (d->scene) { partially evaluated: d->scene yes Evaluation Count:7 | no Evaluation Count:0 |
| 0-7 |
2798 | QWidget *widget = painter->device() == viewport() ? viewport() : 0; evaluated: painter->device() == viewport() yes Evaluation Count:6 | yes Evaluation Count:1 |
| 1-6 |
2799 | d->scene->drawItems(painter, numItems, items, options, widget); | - |
2800 | } executed: } Execution Count:7 | 7 |
2801 | } executed: } Execution Count:7 | 7 |
2802 | | - |
2803 | | - |
2804 | | - |
2805 | | - |
2806 | | - |
2807 | | - |
2808 | | - |
2809 | QTransform QGraphicsView::transform() const | - |
2810 | { | - |
2811 | const QGraphicsViewPrivate * const d = d_func(); | - |
2812 | return d->matrix; never executed: return d->matrix; | 0 |
2813 | } | - |
2814 | | - |
2815 | | - |
2816 | | - |
2817 | | - |
2818 | | - |
2819 | | - |
2820 | QTransform QGraphicsView::viewportTransform() const | - |
2821 | { | - |
2822 | const QGraphicsViewPrivate * const d = d_func(); | - |
2823 | QTransform moveMatrix = QTransform::fromTranslate(-d->horizontalScroll(), -d->verticalScroll()); | - |
2824 | return d->identityMatrix ? moveMatrix : d->matrix * moveMatrix; executed: return d->identityMatrix ? moveMatrix : d->matrix * moveMatrix; Execution Count:2790 | 2790 |
2825 | } | - |
2826 | bool QGraphicsView::isTransformed() const | - |
2827 | { | - |
2828 | const QGraphicsViewPrivate * const d = d_func(); | - |
2829 | return !d->identityMatrix || d->horizontalScroll() || d->verticalScroll(); executed: return !d->identityMatrix || d->horizontalScroll() || d->verticalScroll(); Execution Count:2489 | 2489 |
2830 | } | - |
2831 | void QGraphicsView::setTransform(const QTransform &matrix, bool combine ) | - |
2832 | { | - |
2833 | QGraphicsViewPrivate * const d = d_func(); | - |
2834 | QTransform oldMatrix = d->matrix; | - |
2835 | if (!combine) evaluated: !combine yes Evaluation Count:742 | yes Evaluation Count:5 |
| 5-742 |
2836 | d->matrix = matrix; executed: d->matrix = matrix; Execution Count:742 | 742 |
2837 | else | - |
2838 | d->matrix = matrix * d->matrix; executed: d->matrix = matrix * d->matrix; Execution Count:5 | 5 |
2839 | if (oldMatrix == d->matrix) evaluated: oldMatrix == d->matrix yes Evaluation Count:299 | yes Evaluation Count:448 |
| 299-448 |
2840 | return; executed: return; Execution Count:299 | 299 |
2841 | | - |
2842 | d->identityMatrix = d->matrix.isIdentity(); | - |
2843 | d->transforming = true; | - |
2844 | if (d->scene) { evaluated: d->scene yes Evaluation Count:439 | yes Evaluation Count:9 |
| 9-439 |
2845 | d->recalculateContentSize(); | - |
2846 | d->centerView(d->transformationAnchor); | - |
2847 | } else { executed: } Execution Count:439 | 439 |
2848 | d->updateLastCenterPoint(); | - |
2849 | } executed: } Execution Count:9 | 9 |
2850 | | - |
2851 | if (d->sceneInteractionAllowed) partially evaluated: d->sceneInteractionAllowed yes Evaluation Count:448 | no Evaluation Count:0 |
| 0-448 |
2852 | d->replayLastMouseEvent(); executed: d->replayLastMouseEvent(); Execution Count:448 | 448 |
2853 | d->transforming = false; | - |
2854 | | - |
2855 | | - |
2856 | d->updateAll(); | - |
2857 | } executed: } Execution Count:448 | 448 |
2858 | | - |
2859 | | - |
2860 | | - |
2861 | | - |
2862 | | - |
2863 | | - |
2864 | void QGraphicsView::resetTransform() | - |
2865 | { | - |
2866 | setTransform(QTransform()); | - |
2867 | } executed: } Execution Count:1 | 1 |
2868 | | - |
2869 | QPointF QGraphicsViewPrivate::mapToScene(const QPointF &point) const | - |
2870 | { | - |
2871 | QPointF p = point; | - |
2872 | p.rx() += horizontalScroll(); | - |
2873 | p.ry() += verticalScroll(); | - |
2874 | return identityMatrix ? p : matrix.inverted().map(p); never executed: return identityMatrix ? p : matrix.inverted().map(p); | 0 |
2875 | } | - |
2876 | | - |
2877 | QRectF QGraphicsViewPrivate::mapToScene(const QRectF &rect) const | - |
2878 | { | - |
2879 | QPointF scrollOffset(horizontalScroll(), verticalScroll()); | - |
2880 | QPointF tl = scrollOffset + rect.topLeft(); | - |
2881 | QPointF tr = scrollOffset + rect.topRight(); | - |
2882 | QPointF br = scrollOffset + rect.bottomRight(); | - |
2883 | QPointF bl = scrollOffset + rect.bottomLeft(); | - |
2884 | | - |
2885 | QPolygonF poly(4); | - |
2886 | if (!identityMatrix) { partially evaluated: !identityMatrix no Evaluation Count:0 | yes Evaluation Count:7 |
| 0-7 |
2887 | QTransform x = matrix.inverted(); | - |
2888 | poly[0] = x.map(tl); | - |
2889 | poly[1] = x.map(tr); | - |
2890 | poly[2] = x.map(br); | - |
2891 | poly[3] = x.map(bl); | - |
2892 | } else { | 0 |
2893 | poly[0] = tl; | - |
2894 | poly[1] = tr; | - |
2895 | poly[2] = br; | - |
2896 | poly[3] = bl; | - |
2897 | } executed: } Execution Count:7 | 7 |
2898 | return poly.boundingRect(); executed: return poly.boundingRect(); Execution Count:7 | 7 |
2899 | } | - |
2900 | | - |
2901 | | - |
2902 | | - |
2903 | | - |
| | |