graphicsview/qgraphicsscene.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42/*! -
43 \class QGraphicsScene -
44 \brief The QGraphicsScene class provides a surface for managing a large -
45 number of 2D graphical items. -
46 \since 4.2 -
47 \ingroup graphicsview-api -
48 \inmodule QtWidgets -
49 -
50 The class serves as a container for QGraphicsItems. It is used together -
51 with QGraphicsView for visualizing graphical items, such as lines, -
52 rectangles, text, or even custom items, on a 2D surface. QGraphicsScene is -
53 part of the \l{Graphics View Framework}. -
54 -
55 QGraphicsScene also provides functionality that lets you efficiently -
56 determine both the location of items, and for determining what items are -
57 visible within an arbitrary area on the scene. With the QGraphicsView -
58 widget, you can either visualize the whole scene, or zoom in and view only -
59 parts of the scene. -
60 -
61 Example: -
62 -
63 \snippet code/src_gui_graphicsview_qgraphicsscene.cpp 0 -
64 -
65 Note that QGraphicsScene has no visual appearance of its own; it only -
66 manages the items. You need to create a QGraphicsView widget to visualize -
67 the scene. -
68 -
69 To add items to a scene, you start off by constructing a QGraphicsScene -
70 object. Then, you have two options: either add your existing QGraphicsItem -
71 objects by calling addItem(), or you can call one of the convenience -
72 functions addEllipse(), addLine(), addPath(), addPixmap(), addPolygon(), -
73 addRect(), or addText(), which all return a pointer to the newly added item. -
74 The dimensions of the items added with these functions are relative to the -
75 item's coordinate system, and the items position is initialized to (0, -
76 0) in the scene. -
77 -
78 You can then visualize the scene using QGraphicsView. When the scene -
79 changes, (e.g., when an item moves or is transformed) QGraphicsScene -
80 emits the changed() signal. To remove an item, call removeItem(). -
81 -
82 QGraphicsScene uses an indexing algorithm to manage the location of items -
83 efficiently. By default, a BSP (Binary Space Partitioning) tree is used; an -
84 algorithm suitable for large scenes where most items remain static (i.e., -
85 do not move around). You can choose to disable this index by calling -
86 setItemIndexMethod(). For more information about the available indexing -
87 algorithms, see the itemIndexMethod property. -
88 -
89 The scene's bounding rect is set by calling setSceneRect(). Items can be -
90 placed at any position on the scene, and the size of the scene is by -
91 default unlimited. The scene rect is used only for internal bookkeeping, -
92 maintaining the scene's item index. If the scene rect is unset, -
93 QGraphicsScene will use the bounding area of all items, as returned by -
94 itemsBoundingRect(), as the scene rect. However, itemsBoundingRect() is a -
95 relatively time consuming function, as it operates by collecting -
96 positional information for every item on the scene. Because of this, you -
97 should always set the scene rect when operating on large scenes. -
98 -
99 One of QGraphicsScene's greatest strengths is its ability to efficiently -
100 determine the location of items. Even with millions of items on the scene, -
101 the items() functions can determine the location of an item within a few -
102 milliseconds. There are several overloads to items(): one that finds items -
103 at a certain position, one that finds items inside or intersecting with a -
104 polygon or a rectangle, and more. The list of returned items is sorted by -
105 stacking order, with the topmost item being the first item in the list. -
106 For convenience, there is also an itemAt() function that returns the -
107 topmost item at a given position. -
108 -
109 QGraphicsScene maintains selection information for the scene. To select -
110 items, call setSelectionArea(), and to clear the current selection, call -
111 clearSelection(). Call selectedItems() to get the list of all selected -
112 items. -
113 -
114 \section1 Event Handling and Propagation -
115 -
116 Another responsibility that QGraphicsScene has, is to propagate events -
117 from QGraphicsView. To send an event to a scene, you construct an event -
118 that inherits QEvent, and then send it using, for example, -
119 QApplication::sendEvent(). event() is responsible for dispatching -
120 the event to the individual items. Some common events are handled by -
121 convenience event handlers. For example, key press events are handled by -
122 keyPressEvent(), and mouse press events are handled by mousePressEvent(). -
123 -
124 Key events are delivered to the \e {focus item}. To set the focus item, -
125 you can either call setFocusItem(), passing an item that accepts focus, or -
126 the item itself can call QGraphicsItem::setFocus(). Call focusItem() to -
127 get the current focus item. For compatibility with widgets, the scene also -
128 maintains its own focus information. By default, the scene does not have -
129 focus, and all key events are discarded. If setFocus() is called, or if an -
130 item on the scene gains focus, the scene automatically gains focus. If the -
131 scene has focus, hasFocus() will return true, and key events will be -
132 forwarded to the focus item, if any. If the scene loses focus, (i.e., -
133 someone calls clearFocus()) while an item has focus, the scene will -
134 maintain its item focus information, and once the scene regains focus, it -
135 will make sure the last focus item regains focus. -
136 -
137 For mouse-over effects, QGraphicsScene dispatches \e {hover -
138 events}. If an item accepts hover events (see -
139 QGraphicsItem::acceptHoverEvents()), it will receive a \l -
140 {QEvent::}{GraphicsSceneHoverEnter} event when the mouse enters -
141 its area. As the mouse continues moving inside the item's area, -
142 QGraphicsScene will send it \l {QEvent::}{GraphicsSceneHoverMove} -
143 events. When the mouse leaves the item's area, the item will -
144 receive a \l {QEvent::}{GraphicsSceneHoverLeave} event. -
145 -
146 All mouse events are delivered to the current \e {mouse grabber} -
147 item. An item becomes the scene's mouse grabber if it accepts -
148 mouse events (see QGraphicsItem::acceptedMouseButtons()) and it -
149 receives a mouse press. It stays the mouse grabber until it -
150 receives a mouse release when no other mouse buttons are -
151 pressed. You can call mouseGrabberItem() to determine what item is -
152 currently grabbing the mouse. -
153 -
154 \sa QGraphicsItem, QGraphicsView -
155*/ -
156 -
157/*! -
158 \enum QGraphicsScene::SceneLayer -
159 \since 4.3 -
160 -
161 This enum describes the rendering layers in a QGraphicsScene. When -
162 QGraphicsScene draws the scene contents, it renders each of these layers -
163 separately, in order. -
164 -
165 Each layer represents a flag that can be OR'ed together when calling -
166 functions such as invalidate() or QGraphicsView::invalidateScene(). -
167 -
168 \value ItemLayer The item layer. QGraphicsScene renders all items are in -
169 this layer by calling the virtual function drawItems(). The item layer is -
170 drawn after the background layer, but before the foreground layer. -
171 -
172 \value BackgroundLayer The background layer. QGraphicsScene renders the -
173 scene's background in this layer by calling the virtual function -
174 drawBackground(). The background layer is drawn first of all layers. -
175 -
176 \value ForegroundLayer The foreground layer. QGraphicsScene renders the -
177 scene's foreground in this layer by calling the virtual function -
178 drawForeground(). The foreground layer is drawn last of all layers. -
179 -
180 \value AllLayers All layers; this value represents a combination of all -
181 three layers. -
182 -
183 \sa invalidate(), QGraphicsView::invalidateScene() -
184*/ -
185 -
186/*! -
187 \enum QGraphicsScene::ItemIndexMethod -
188 -
189 This enum describes the indexing algorithms QGraphicsScene provides for -
190 managing positional information about items on the scene. -
191 -
192 \value BspTreeIndex A Binary Space Partitioning tree is applied. All -
193 QGraphicsScene's item location algorithms are of an order close to -
194 logarithmic complexity, by making use of binary search. Adding, moving and -
195 removing items is logarithmic. This approach is best for static scenes -
196 (i.e., scenes where most items do not move). -
197 -
198 \value NoIndex No index is applied. Item location is of linear complexity, -
199 as all items on the scene are searched. Adding, moving and removing items, -
200 however, is done in constant time. This approach is ideal for dynamic -
201 scenes, where many items are added, moved or removed continuously. -
202 -
203 \sa setItemIndexMethod(), bspTreeDepth -
204*/ -
205 -
206#include "qgraphicsscene.h" -
207 -
208#ifndef QT_NO_GRAPHICSVIEW -
209 -
210#include "qgraphicsitem.h" -
211#include "qgraphicsitem_p.h" -
212#include "qgraphicslayout.h" -
213#include "qgraphicsscene_p.h" -
214#include "qgraphicssceneevent.h" -
215#include "qgraphicsview.h" -
216#include "qgraphicsview_p.h" -
217#include "qgraphicswidget.h" -
218#include "qgraphicswidget_p.h" -
219#include "qgraphicssceneindex_p.h" -
220#include "qgraphicsscenebsptreeindex_p.h" -
221#include "qgraphicsscenelinearindex_p.h" -
222 -
223#include <QtCore/qdebug.h> -
224#include <QtCore/qlist.h> -
225#include <QtCore/qmath.h> -
226#include <QtCore/qrect.h> -
227#include <QtCore/qset.h> -
228#include <QtCore/qstack.h> -
229#include <QtCore/qtimer.h> -
230#include <QtCore/qvarlengtharray.h> -
231#include <QtCore/QMetaMethod> -
232#include <QtWidgets/qapplication.h> -
233#include <QtWidgets/qdesktopwidget.h> -
234#include <QtGui/qevent.h> -
235#include <QtWidgets/qgraphicslayout.h> -
236#include <QtWidgets/qgraphicsproxywidget.h> -
237#include <QtWidgets/qgraphicswidget.h> -
238#include <QtGui/qmatrix.h> -
239#include <QtGui/qpaintengine.h> -
240#include <QtGui/qpainter.h> -
241#include <QtGui/qpixmapcache.h> -
242#include <QtGui/qpolygon.h> -
243#include <QtWidgets/qstyleoption.h> -
244#include <QtWidgets/qtooltip.h> -
245#include <QtGui/qtransform.h> -
246#include <QtGui/qinputmethod.h> -
247#include <QtWidgets/qgraphicseffect.h> -
248#ifndef QT_NO_ACCESSIBILITY -
249# include <QtGui/qaccessible.h> -
250#endif -
251#include <private/qapplication_p.h> -
252#include <private/qobject_p.h> -
253#include <private/qgraphicseffect_p.h> -
254#include <private/qgesturemanager_p.h> -
255#include <private/qpathclipper_p.h> -
256 -
257// #define GESTURE_DEBUG -
258#ifndef GESTURE_DEBUG -
259# define DEBUG if (0) qDebug -
260#else -
261# define DEBUG qDebug -
262#endif -
263 -
264QT_BEGIN_NAMESPACE -
265 -
266bool qt_sendSpontaneousEvent(QObject *receiver, QEvent *event); -
267 -
268static void _q_hoverFromMouseEvent(QGraphicsSceneHoverEvent *hover, const QGraphicsSceneMouseEvent *mouseEvent) -
269{ -
270 hover->setWidget(mouseEvent->widget());
executed (the execution status of this line is deduced): hover->setWidget(mouseEvent->widget());
-
271 hover->setPos(mouseEvent->pos());
executed (the execution status of this line is deduced): hover->setPos(mouseEvent->pos());
-
272 hover->setScenePos(mouseEvent->scenePos());
executed (the execution status of this line is deduced): hover->setScenePos(mouseEvent->scenePos());
-
273 hover->setScreenPos(mouseEvent->screenPos());
executed (the execution status of this line is deduced): hover->setScreenPos(mouseEvent->screenPos());
-
274 hover->setLastPos(mouseEvent->lastPos());
executed (the execution status of this line is deduced): hover->setLastPos(mouseEvent->lastPos());
-
275 hover->setLastScenePos(mouseEvent->lastScenePos());
executed (the execution status of this line is deduced): hover->setLastScenePos(mouseEvent->lastScenePos());
-
276 hover->setLastScreenPos(mouseEvent->lastScreenPos());
executed (the execution status of this line is deduced): hover->setLastScreenPos(mouseEvent->lastScreenPos());
-
277 hover->setModifiers(mouseEvent->modifiers());
executed (the execution status of this line is deduced): hover->setModifiers(mouseEvent->modifiers());
-
278 hover->setAccepted(mouseEvent->isAccepted());
executed (the execution status of this line is deduced): hover->setAccepted(mouseEvent->isAccepted());
-
279}
executed: }
Execution Count:4
4
280 -
281/*! -
282 \internal -
283*/ -
284QGraphicsScenePrivate::QGraphicsScenePrivate() -
285 : indexMethod(QGraphicsScene::BspTreeIndex), -
286 index(0), -
287 lastItemCount(0), -
288 hasSceneRect(false), -
289 dirtyGrowingItemsBoundingRect(true), -
290 updateAll(false), -
291 calledEmitUpdated(false), -
292 processDirtyItemsEmitted(false), -
293 needSortTopLevelItems(true), -
294 holesInTopLevelSiblingIndex(false), -
295 topLevelSequentialOrdering(true), -
296 scenePosDescendantsUpdatePending(false), -
297 stickyFocus(false), -
298 hasFocus(false), -
299 lastMouseGrabberItemHasImplicitMouseGrab(false), -
300 allItemsIgnoreHoverEvents(true), -
301 allItemsUseDefaultCursor(true), -
302 painterStateProtection(true), -
303 sortCacheEnabled(false), -
304 allItemsIgnoreTouchEvents(true), -
305 selectionChanging(0), -
306 rectAdjust(2), -
307 focusItem(0), -
308 lastFocusItem(0), -
309 passiveFocusItem(0), -
310 tabFocusFirst(0), -
311 activePanel(0), -
312 lastActivePanel(0), -
313 activationRefCount(0), -
314 childExplicitActivation(0), -
315 lastMouseGrabberItem(0), -
316 dragDropItem(0), -
317 enterWidget(0), -
318 lastDropAction(Qt::IgnoreAction), -
319 style(0) -
320{ -
321}
executed: }
Execution Count:233
233
322 -
323/*! -
324 \internal -
325*/ -
326void QGraphicsScenePrivate::init() -
327{ -
328 Q_Q(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScene * const q = q_func();
-
329 -
330 index = new QGraphicsSceneBspTreeIndex(q);
executed (the execution status of this line is deduced): index = new QGraphicsSceneBspTreeIndex(q);
-
331 -
332 // Keep this index so we can check for connected slots later on. -
333 changedSignalIndex = signalIndex("changed(QList<QRectF>)");
executed (the execution status of this line is deduced): changedSignalIndex = signalIndex("changed(QList<QRectF>)");
-
334 processDirtyItemsIndex = q->metaObject()->indexOfSlot("_q_processDirtyItems()");
executed (the execution status of this line is deduced): processDirtyItemsIndex = q->metaObject()->indexOfSlot("_q_processDirtyItems()");
-
335 polishItemsIndex = q->metaObject()->indexOfSlot("_q_polishItems()");
executed (the execution status of this line is deduced): polishItemsIndex = q->metaObject()->indexOfSlot("_q_polishItems()");
-
336 -
337 qApp->d_func()->scene_list.append(q);
executed (the execution status of this line is deduced): (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->scene_list.append(q);
-
338 q->update();
executed (the execution status of this line is deduced): q->update();
-
339}
executed: }
Execution Count:233
233
340 -
341/*! -
342 \internal -
343*/ -
344QGraphicsScenePrivate *QGraphicsScenePrivate::get(QGraphicsScene *q) -
345{ -
346 return q->d_func();
never executed: return q->d_func();
0
347} -
348 -
349void QGraphicsScenePrivate::_q_emitUpdated() -
350{ -
351 Q_Q(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScene * const q = q_func();
-
352 calledEmitUpdated = false;
executed (the execution status of this line is deduced): calledEmitUpdated = false;
-
353 -
354 if (dirtyGrowingItemsBoundingRect) {
evaluated: dirtyGrowingItemsBoundingRect
TRUEFALSE
yes
Evaluation Count:108
yes
Evaluation Count:69
69-108
355 if (!hasSceneRect) {
evaluated: !hasSceneRect
TRUEFALSE
yes
Evaluation Count:106
yes
Evaluation Count:2
2-106
356 const QRectF oldGrowingItemsBoundingRect = growingItemsBoundingRect;
executed (the execution status of this line is deduced): const QRectF oldGrowingItemsBoundingRect = growingItemsBoundingRect;
-
357 growingItemsBoundingRect |= q->itemsBoundingRect();
executed (the execution status of this line is deduced): growingItemsBoundingRect |= q->itemsBoundingRect();
-
358 if (oldGrowingItemsBoundingRect != growingItemsBoundingRect)
evaluated: oldGrowingItemsBoundingRect != growingItemsBoundingRect
TRUEFALSE
yes
Evaluation Count:105
yes
Evaluation Count:1
1-105
359 emit q->sceneRectChanged(growingItemsBoundingRect);
executed: q->sceneRectChanged(growingItemsBoundingRect);
Execution Count:105
105
360 }
executed: }
Execution Count:106
106
361 dirtyGrowingItemsBoundingRect = false;
executed (the execution status of this line is deduced): dirtyGrowingItemsBoundingRect = false;
-
362 }
executed: }
Execution Count:108
108
363 -
364 // Ensure all views are connected if anything is connected. This disables -
365 // the optimization that items send updates directly to the views, but it -
366 // needs to happen in order to keep compatibility with the behavior from -
367 // Qt 4.4 and backward. -
368 if (isSignalConnected(changedSignalIndex)) {
partially evaluated: isSignalConnected(changedSignalIndex)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:177
0-177
369 for (int i = 0; i < views.size(); ++i) {
never evaluated: i < views.size()
0
370 QGraphicsView *view = views.at(i);
never executed (the execution status of this line is deduced): QGraphicsView *view = views.at(i);
-
371 if (!view->d_func()->connectedToScene) {
never evaluated: !view->d_func()->connectedToScene
0
372 view->d_func()->connectedToScene = true;
never executed (the execution status of this line is deduced): view->d_func()->connectedToScene = true;
-
373 q->connect(q, SIGNAL(changed(QList<QRectF>)),
never executed (the execution status of this line is deduced): q->connect(q, "2""changed(QList<QRectF>)",
-
374 views.at(i), SLOT(updateScene(QList<QRectF>)));
never executed (the execution status of this line is deduced): views.at(i), "1""updateScene(QList<QRectF>)");
-
375 }
never executed: }
0
376 }
never executed: }
0
377 } else {
never executed: }
0
378 if (views.isEmpty()) {
evaluated: views.isEmpty()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:172
5-172
379 updateAll = false;
executed (the execution status of this line is deduced): updateAll = false;
-
380 return;
executed: return;
Execution Count:5
5
381 } -
382 for (int i = 0; i < views.size(); ++i)
evaluated: i < views.size()
TRUEFALSE
yes
Evaluation Count:172
yes
Evaluation Count:172
172
383 views.at(i)->d_func()->processPendingUpdates();
executed: views.at(i)->d_func()->processPendingUpdates();
Execution Count:172
172
384 // It's important that we update all views before we dispatch, hence two for-loops. -
385 for (int i = 0; i < views.size(); ++i)
evaluated: i < views.size()
TRUEFALSE
yes
Evaluation Count:172
yes
Evaluation Count:172
172
386 views.at(i)->d_func()->dispatchPendingUpdateRequests();
executed: views.at(i)->d_func()->dispatchPendingUpdateRequests();
Execution Count:172
172
387 return;
executed: return;
Execution Count:172
172
388 } -
389 -
390 // Notify the changes to anybody interested. -
391 QList<QRectF> oldUpdatedRects;
never executed (the execution status of this line is deduced): QList<QRectF> oldUpdatedRects;
-
392 oldUpdatedRects = updateAll ? (QList<QRectF>() << q->sceneRect()) : updatedRects;
never evaluated: updateAll
0
393 updateAll = false;
never executed (the execution status of this line is deduced): updateAll = false;
-
394 updatedRects.clear();
never executed (the execution status of this line is deduced): updatedRects.clear();
-
395 emit q->changed(oldUpdatedRects);
never executed (the execution status of this line is deduced): q->changed(oldUpdatedRects);
-
396}
never executed: }
0
397 -
398/*! -
399 \internal -
400 -
401 ### This function is almost identical to QGraphicsItemPrivate::addChild(). -
402*/ -
403void QGraphicsScenePrivate::registerTopLevelItem(QGraphicsItem *item) -
404{ -
405 item->d_ptr->ensureSequentialSiblingIndex();
executed (the execution status of this line is deduced): item->d_ptr->ensureSequentialSiblingIndex();
-
406 needSortTopLevelItems = true; // ### maybe false
executed (the execution status of this line is deduced): needSortTopLevelItems = true;
-
407 item->d_ptr->siblingIndex = topLevelItems.size();
executed (the execution status of this line is deduced): item->d_ptr->siblingIndex = topLevelItems.size();
-
408 topLevelItems.append(item);
executed (the execution status of this line is deduced): topLevelItems.append(item);
-
409}
executed: }
Execution Count:273
273
410 -
411/*! -
412 \internal -
413 -
414 ### This function is almost identical to QGraphicsItemPrivate::removeChild(). -
415*/ -
416void QGraphicsScenePrivate::unregisterTopLevelItem(QGraphicsItem *item) -
417{ -
418 if (!holesInTopLevelSiblingIndex)
evaluated: !holesInTopLevelSiblingIndex
TRUEFALSE
yes
Evaluation Count:232
yes
Evaluation Count:30
30-232
419 holesInTopLevelSiblingIndex = item->d_ptr->siblingIndex != topLevelItems.size() - 1;
executed: holesInTopLevelSiblingIndex = item->d_ptr->siblingIndex != topLevelItems.size() - 1;
Execution Count:232
232
420 if (topLevelSequentialOrdering && !holesInTopLevelSiblingIndex)
evaluated: topLevelSequentialOrdering
TRUEFALSE
yes
Evaluation Count:232
yes
Evaluation Count:30
evaluated: !holesInTopLevelSiblingIndex
TRUEFALSE
yes
Evaluation Count:208
yes
Evaluation Count:24
24-232
421 topLevelItems.removeAt(item->d_ptr->siblingIndex);
executed: topLevelItems.removeAt(item->d_ptr->siblingIndex);
Execution Count:208
208
422 else -
423 topLevelItems.removeOne(item);
executed: topLevelItems.removeOne(item);
Execution Count:54
54
424 // NB! Do not use topLevelItems.removeAt(item->d_ptr->siblingIndex) because -
425 // the item is not guaranteed to be at the index after the list is sorted -
426 // (see ensureSortedTopLevelItems()). -
427 item->d_ptr->siblingIndex = -1;
executed (the execution status of this line is deduced): item->d_ptr->siblingIndex = -1;
-
428 if (topLevelSequentialOrdering)
evaluated: topLevelSequentialOrdering
TRUEFALSE
yes
Evaluation Count:232
yes
Evaluation Count:30
30-232
429 topLevelSequentialOrdering = !holesInTopLevelSiblingIndex;
executed: topLevelSequentialOrdering = !holesInTopLevelSiblingIndex;
Execution Count:232
232
430}
executed: }
Execution Count:262
262
431 -
432/*! -
433 \internal -
434*/ -
435void QGraphicsScenePrivate::_q_polishItems() -
436{ -
437 if (unpolishedItems.isEmpty())
evaluated: unpolishedItems.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:185
2-185
438 return;
executed: return;
Execution Count:2
2
439 -
440 const QVariant booleanTrueVariant(true);
executed (the execution status of this line is deduced): const QVariant booleanTrueVariant(true);
-
441 QGraphicsItem *item = 0;
executed (the execution status of this line is deduced): QGraphicsItem *item = 0;
-
442 QGraphicsItemPrivate *itemd = 0;
executed (the execution status of this line is deduced): QGraphicsItemPrivate *itemd = 0;
-
443 const int oldUnpolishedCount = unpolishedItems.count();
executed (the execution status of this line is deduced): const int oldUnpolishedCount = unpolishedItems.count();
-
444 -
445 for (int i = 0; i < oldUnpolishedCount; ++i) {
evaluated: i < oldUnpolishedCount
TRUEFALSE
yes
Evaluation Count:817
yes
Evaluation Count:185
185-817
446 item = unpolishedItems.at(i);
executed (the execution status of this line is deduced): item = unpolishedItems.at(i);
-
447 if (!item)
evaluated: !item
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:813
4-813
448 continue;
executed: continue;
Execution Count:4
4
449 itemd = item->d_ptr.data();
executed (the execution status of this line is deduced): itemd = item->d_ptr.data();
-
450 itemd->pendingPolish = false;
executed (the execution status of this line is deduced): itemd->pendingPolish = false;
-
451 if (!itemd->explicitlyHidden) {
evaluated: !itemd->explicitlyHidden
TRUEFALSE
yes
Evaluation Count:812
yes
Evaluation Count:1
1-812
452 item->itemChange(QGraphicsItem::ItemVisibleChange, booleanTrueVariant);
executed (the execution status of this line is deduced): item->itemChange(QGraphicsItem::ItemVisibleChange, booleanTrueVariant);
-
453 item->itemChange(QGraphicsItem::ItemVisibleHasChanged, booleanTrueVariant);
executed (the execution status of this line is deduced): item->itemChange(QGraphicsItem::ItemVisibleHasChanged, booleanTrueVariant);
-
454 }
executed: }
Execution Count:812
812
455 if (itemd->isWidget) {
evaluated: itemd->isWidget
TRUEFALSE
yes
Evaluation Count:741
yes
Evaluation Count:72
72-741
456 QEvent event(QEvent::Polish);
executed (the execution status of this line is deduced): QEvent event(QEvent::Polish);
-
457 QApplication::sendEvent((QGraphicsWidget *)item, &event);
executed (the execution status of this line is deduced): QApplication::sendEvent((QGraphicsWidget *)item, &event);
-
458 }
executed: }
Execution Count:741
741
459 }
executed: }
Execution Count:813
813
460 -
461 if (unpolishedItems.count() == oldUnpolishedCount) {
partially evaluated: unpolishedItems.count() == oldUnpolishedCount
TRUEFALSE
yes
Evaluation Count:185
no
Evaluation Count:0
0-185
462 // No new items were added to the vector. -
463 unpolishedItems.clear();
executed (the execution status of this line is deduced): unpolishedItems.clear();
-
464 } else {
executed: }
Execution Count:185
185
465 // New items were appended; keep them and remove the old ones. -
466 unpolishedItems.remove(0, oldUnpolishedCount);
never executed (the execution status of this line is deduced): unpolishedItems.remove(0, oldUnpolishedCount);
-
467 unpolishedItems.squeeze();
never executed (the execution status of this line is deduced): unpolishedItems.squeeze();
-
468 QMetaObject::invokeMethod(q_ptr, "_q_polishItems", Qt::QueuedConnection);
never executed (the execution status of this line is deduced): QMetaObject::invokeMethod(q_ptr, "_q_polishItems", Qt::QueuedConnection);
-
469 }
never executed: }
0
470} -
471 -
472void QGraphicsScenePrivate::_q_processDirtyItems() -
473{ -
474 processDirtyItemsEmitted = false;
executed (the execution status of this line is deduced): processDirtyItemsEmitted = false;
-
475 -
476 if (updateAll) {
evaluated: updateAll
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:73
2-73
477 Q_ASSERT(calledEmitUpdated);
executed (the execution status of this line is deduced): qt_noop();
-
478 // No need for further processing (except resetting the dirty states). -
479 // The growingItemsBoundingRect is updated in _q_emitUpdated. -
480 for (int i = 0; i < topLevelItems.size(); ++i)
evaluated: i < topLevelItems.size()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
481 resetDirtyItem(topLevelItems.at(i), /*recursive=*/true);
executed: resetDirtyItem(topLevelItems.at(i), true);
Execution Count:2
2
482 return;
executed: return;
Execution Count:2
2
483 } -
484 -
485 const bool wasPendingSceneUpdate = calledEmitUpdated;
executed (the execution status of this line is deduced): const bool wasPendingSceneUpdate = calledEmitUpdated;
-
486 const QRectF oldGrowingItemsBoundingRect = growingItemsBoundingRect;
executed (the execution status of this line is deduced): const QRectF oldGrowingItemsBoundingRect = growingItemsBoundingRect;
-
487 -
488 // Process items recursively. -
489 for (int i = 0; i < topLevelItems.size(); ++i)
evaluated: i < topLevelItems.size()
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:73
72-73
490 processDirtyItemsRecursive(topLevelItems.at(i));
executed: processDirtyItemsRecursive(topLevelItems.at(i));
Execution Count:72
72
491 -
492 dirtyGrowingItemsBoundingRect = false;
executed (the execution status of this line is deduced): dirtyGrowingItemsBoundingRect = false;
-
493 if (!hasSceneRect && oldGrowingItemsBoundingRect != growingItemsBoundingRect)
evaluated: !hasSceneRect
TRUEFALSE
yes
Evaluation Count:71
yes
Evaluation Count:2
evaluated: oldGrowingItemsBoundingRect != growingItemsBoundingRect
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:52
2-71
494 emit q_func()->sceneRectChanged(growingItemsBoundingRect);
executed: q_func()->sceneRectChanged(growingItemsBoundingRect);
Execution Count:19
19
495 -
496 if (wasPendingSceneUpdate)
partially evaluated: wasPendingSceneUpdate
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:73
0-73
497 return;
never executed: return;
0
498 -
499 for (int i = 0; i < views.size(); ++i)
evaluated: i < views.size()
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:73
72-73
500 views.at(i)->d_func()->processPendingUpdates();
executed: views.at(i)->d_func()->processPendingUpdates();
Execution Count:72
72
501 -
502 if (calledEmitUpdated) {
evaluated: calledEmitUpdated
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:72
1-72
503 // We did a compatibility QGraphicsScene::update in processDirtyItemsRecursive -
504 // and we cannot wait for the control to reach the eventloop before the -
505 // changed signal is emitted, so we emit it now. -
506 _q_emitUpdated();
executed (the execution status of this line is deduced): _q_emitUpdated();
-
507 }
executed: }
Execution Count:1
1
508 -
509 // Immediately dispatch all pending update requests on the views. -
510 for (int i = 0; i < views.size(); ++i)
evaluated: i < views.size()
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:73
72-73
511 views.at(i)->d_func()->dispatchPendingUpdateRequests();
executed: views.at(i)->d_func()->dispatchPendingUpdateRequests();
Execution Count:72
72
512}
executed: }
Execution Count:73
73
513 -
514/*! -
515 \internal -
516*/ -
517void QGraphicsScenePrivate::setScenePosItemEnabled(QGraphicsItem *item, bool enabled) -
518{ -
519 QGraphicsItem *p = item->d_ptr->parent;
never executed (the execution status of this line is deduced): QGraphicsItem *p = item->d_ptr->parent;
-
520 while (p) {
never evaluated: p
0
521 p->d_ptr->scenePosDescendants = enabled;
never executed (the execution status of this line is deduced): p->d_ptr->scenePosDescendants = enabled;
-
522 p = p->d_ptr->parent;
never executed (the execution status of this line is deduced): p = p->d_ptr->parent;
-
523 }
never executed: }
0
524 if (!enabled && !scenePosDescendantsUpdatePending) {
never evaluated: !enabled
never evaluated: !scenePosDescendantsUpdatePending
0
525 scenePosDescendantsUpdatePending = true;
never executed (the execution status of this line is deduced): scenePosDescendantsUpdatePending = true;
-
526 QMetaObject::invokeMethod(q_func(), "_q_updateScenePosDescendants", Qt::QueuedConnection);
never executed (the execution status of this line is deduced): QMetaObject::invokeMethod(q_func(), "_q_updateScenePosDescendants", Qt::QueuedConnection);
-
527 }
never executed: }
0
528}
never executed: }
0
529 -
530/*! -
531 \internal -
532*/ -
533void QGraphicsScenePrivate::registerScenePosItem(QGraphicsItem *item) -
534{ -
535 scenePosItems.insert(item);
never executed (the execution status of this line is deduced): scenePosItems.insert(item);
-
536 setScenePosItemEnabled(item, true);
never executed (the execution status of this line is deduced): setScenePosItemEnabled(item, true);
-
537}
never executed: }
0
538 -
539/*! -
540 \internal -
541*/ -
542void QGraphicsScenePrivate::unregisterScenePosItem(QGraphicsItem *item) -
543{ -
544 scenePosItems.remove(item);
never executed (the execution status of this line is deduced): scenePosItems.remove(item);
-
545 setScenePosItemEnabled(item, false);
never executed (the execution status of this line is deduced): setScenePosItemEnabled(item, false);
-
546}
never executed: }
0
547 -
548/*! -
549 \internal -
550*/ -
551void QGraphicsScenePrivate::_q_updateScenePosDescendants() -
552{ -
553 foreach (QGraphicsItem *item, scenePosItems) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(scenePosItems)> _container_(scenePosItems); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
554 QGraphicsItem *p = item->d_ptr->parent;
never executed (the execution status of this line is deduced): QGraphicsItem *p = item->d_ptr->parent;
-
555 while (p) {
never evaluated: p
0
556 p->d_ptr->scenePosDescendants = 1;
never executed (the execution status of this line is deduced): p->d_ptr->scenePosDescendants = 1;
-
557 p = p->d_ptr->parent;
never executed (the execution status of this line is deduced): p = p->d_ptr->parent;
-
558 }
never executed: }
0
559 }
never executed: }
0
560 scenePosDescendantsUpdatePending = false;
never executed (the execution status of this line is deduced): scenePosDescendantsUpdatePending = false;
-
561}
never executed: }
0
562 -
563/*! -
564 \internal -
565 -
566 Schedules an item for removal. This function leaves some stale indexes -
567 around in the BSP tree if called from the item's destructor; these will -
568 be cleaned up the next time someone triggers purgeRemovedItems(). -
569 -
570 Note: This function might get called from QGraphicsItem's destructor. \a item is -
571 being destroyed, so we cannot call any pure virtual functions on it (such -
572 as boundingRect()). Also, it is unnecessary to update the item's own state -
573 in any way. -
574*/ -
575void QGraphicsScenePrivate::removeItemHelper(QGraphicsItem *item) -
576{ -
577 Q_Q(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScene * const q = q_func();
-
578 -
579 // Clear focus on the item to remove any reference in the focusWidget chain. -
580 item->clearFocus();
executed (the execution status of this line is deduced): item->clearFocus();
-
581 -
582 markDirty(item, QRectF(), /*invalidateChildren=*/false, /*force=*/false,
executed (the execution status of this line is deduced): markDirty(item, QRectF(), false, false,
-
583 /*ignoreOpacity=*/false, /*removingItemFromScene=*/true);
executed (the execution status of this line is deduced): false, true);
-
584 -
585 if (item->d_ptr->inDestructor) {
evaluated: item->d_ptr->inDestructor
TRUEFALSE
yes
Evaluation Count:994
yes
Evaluation Count:7
7-994
586 // The item is actually in its destructor, we call the special method in the index. -
587 index->deleteItem(item);
executed (the execution status of this line is deduced): index->deleteItem(item);
-
588 } else {
executed: }
Execution Count:994
994
589 // Can potentially call item->boundingRect() (virtual function), that's why -
590 // we only can call this function if the item is not in its destructor. -
591 index->removeItem(item);
executed (the execution status of this line is deduced): index->removeItem(item);
-
592 }
executed: }
Execution Count:7
7
593 -
594 item->d_ptr->clearSubFocus();
executed (the execution status of this line is deduced): item->d_ptr->clearSubFocus();
-
595 -
596 if (item->flags() & QGraphicsItem::ItemSendsScenePositionChanges)
partially evaluated: item->flags() & QGraphicsItem::ItemSendsScenePositionChanges
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1001
0-1001
597 unregisterScenePosItem(item);
never executed: unregisterScenePosItem(item);
0
598 -
599 QGraphicsScene *oldScene = item->d_func()->scene;
executed (the execution status of this line is deduced): QGraphicsScene *oldScene = item->d_func()->scene;
-
600 item->d_func()->scene = 0;
executed (the execution status of this line is deduced): item->d_func()->scene = 0;
-
601 -
602 //We need to remove all children first because they might use their parent -
603 //attributes (e.g. sceneTransform). -
604 if (!item->d_ptr->inDestructor) {
evaluated: !item->d_ptr->inDestructor
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:994
7-994
605 // Remove all children recursively -
606 for (int i = 0; i < item->d_ptr->children.size(); ++i)
partially evaluated: i < item->d_ptr->children.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
607 q->removeItem(item->d_ptr->children.at(i));
never executed: q->removeItem(item->d_ptr->children.at(i));
0
608 }
executed: }
Execution Count:7
7
609 -
610 if (!item->d_ptr->inDestructor && item == tabFocusFirst) {
evaluated: !item->d_ptr->inDestructor
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:994
partially evaluated: item == tabFocusFirst
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-994
611 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
never executed (the execution status of this line is deduced): QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
-
612 widget->d_func()->fixFocusChainBeforeReparenting(0, oldScene, 0);
never executed (the execution status of this line is deduced): widget->d_func()->fixFocusChainBeforeReparenting(0, oldScene, 0);
-
613 }
never executed: }
0
614 -
615 // Unregister focus proxy. -
616 item->d_ptr->resetFocusProxy();
executed (the execution status of this line is deduced): item->d_ptr->resetFocusProxy();
-
617 -
618 // Remove from parent, or unregister from toplevels. -
619 if (QGraphicsItem *parentItem = item->parentItem()) {
evaluated: QGraphicsItem *parentItem = item->parentItem()
TRUEFALSE
yes
Evaluation Count:748
yes
Evaluation Count:253
253-748
620 if (parentItem->scene()) {
evaluated: parentItem->scene()
TRUEFALSE
yes
Evaluation Count:741
yes
Evaluation Count:7
7-741
621 Q_ASSERT_X(parentItem->scene() == q, "QGraphicsScene::removeItem",
executed (the execution status of this line is deduced): qt_noop();
-
622 "Parent item's scene is different from this item's scene"); -
623 item->setParentItem(0);
executed (the execution status of this line is deduced): item->setParentItem(0);
-
624 }
executed: }
Execution Count:741
741
625 } else {
executed: }
Execution Count:748
748
626 unregisterTopLevelItem(item);
executed (the execution status of this line is deduced): unregisterTopLevelItem(item);
-
627 }
executed: }
Execution Count:253
253
628 -
629 // Reset the mouse grabber and focus item data. -
630 if (item == focusItem)
partially evaluated: item == focusItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1001
0-1001
631 focusItem = 0;
never executed: focusItem = 0;
0
632 if (item == lastFocusItem)
partially evaluated: item == lastFocusItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1001
0-1001
633 lastFocusItem = 0;
never executed: lastFocusItem = 0;
0
634 if (item == passiveFocusItem)
partially evaluated: item == passiveFocusItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1001
0-1001
635 passiveFocusItem = 0;
never executed: passiveFocusItem = 0;
0
636 if (item == activePanel) {
evaluated: item == activePanel
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:984
17-984
637 // ### deactivate... -
638 activePanel = 0;
executed (the execution status of this line is deduced): activePanel = 0;
-
639 }
executed: }
Execution Count:17
17
640 if (item == lastActivePanel)
evaluated: item == lastActivePanel
TRUEFALSE
yes
Evaluation Count:161
yes
Evaluation Count:840
161-840
641 lastActivePanel = 0;
executed: lastActivePanel = 0;
Execution Count:161
161
642 -
643 // Cancel active touches -
644 { -
645 QMap<int, QGraphicsItem *>::iterator it = itemForTouchPointId.begin();
executed (the execution status of this line is deduced): QMap<int, QGraphicsItem *>::iterator it = itemForTouchPointId.begin();
-
646 while (it != itemForTouchPointId.end()) {
partially evaluated: it != itemForTouchPointId.end()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1001
0-1001
647 if (it.value() == item) {
never evaluated: it.value() == item
0
648 sceneCurrentTouchPoints.remove(it.key());
never executed (the execution status of this line is deduced): sceneCurrentTouchPoints.remove(it.key());
-
649 it = itemForTouchPointId.erase(it);
never executed (the execution status of this line is deduced): it = itemForTouchPointId.erase(it);
-
650 } else {
never executed: }
0
651 ++it;
never executed (the execution status of this line is deduced): ++it;
-
652 }
never executed: }
0
653 } -
654 } -
655 -
656 // Disable selectionChanged() for individual items -
657 ++selectionChanging;
executed (the execution status of this line is deduced): ++selectionChanging;
-
658 int oldSelectedItemsSize = selectedItems.size();
executed (the execution status of this line is deduced): int oldSelectedItemsSize = selectedItems.size();
-
659 -
660 // Update selected & hovered item bookkeeping -
661 selectedItems.remove(item);
executed (the execution status of this line is deduced): selectedItems.remove(item);
-
662 hoverItems.removeAll(item);
executed (the execution status of this line is deduced): hoverItems.removeAll(item);
-
663 cachedItemsUnderMouse.removeAll(item);
executed (the execution status of this line is deduced): cachedItemsUnderMouse.removeAll(item);
-
664 if (item->d_ptr->pendingPolish) {
evaluated: item->d_ptr->pendingPolish
TRUEFALSE
yes
Evaluation Count:199
yes
Evaluation Count:802
199-802
665 const int unpolishedIndex = unpolishedItems.indexOf(item);
executed (the execution status of this line is deduced): const int unpolishedIndex = unpolishedItems.indexOf(item);
-
666 if (unpolishedIndex != -1)
partially evaluated: unpolishedIndex != -1
TRUEFALSE
yes
Evaluation Count:199
no
Evaluation Count:0
0-199
667 unpolishedItems[unpolishedIndex] = 0;
executed: unpolishedItems[unpolishedIndex] = 0;
Execution Count:199
199
668 item->d_ptr->pendingPolish = false;
executed (the execution status of this line is deduced): item->d_ptr->pendingPolish = false;
-
669 }
executed: }
Execution Count:199
199
670 resetDirtyItem(item);
executed (the execution status of this line is deduced): resetDirtyItem(item);
-
671 -
672 //We remove all references of item from the sceneEventFilter arrays -
673 QMultiMap<QGraphicsItem*, QGraphicsItem*>::iterator iterator = sceneEventFilters.begin();
executed (the execution status of this line is deduced): QMultiMap<QGraphicsItem*, QGraphicsItem*>::iterator iterator = sceneEventFilters.begin();
-
674 while (iterator != sceneEventFilters.end()) {
partially evaluated: iterator != sceneEventFilters.end()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1001
0-1001
675 if (iterator.value() == item || iterator.key() == item)
never evaluated: iterator.value() == item
never evaluated: iterator.key() == item
0
676 iterator = sceneEventFilters.erase(iterator);
never executed: iterator = sceneEventFilters.erase(iterator);
0
677 else -
678 ++iterator;
never executed: ++iterator;
0
679 } -
680 -
681 if (item->isPanel() && item->isVisible() && item->panelModality() != QGraphicsItem::NonModal)
evaluated: item->isPanel()
TRUEFALSE
yes
Evaluation Count:176
yes
Evaluation Count:825
partially evaluated: item->isVisible()
TRUEFALSE
yes
Evaluation Count:176
no
Evaluation Count:0
evaluated: item->panelModality() != QGraphicsItem::NonModal
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:174
0-825
682 leaveModal(item);
executed: leaveModal(item);
Execution Count:2
2
683 -
684 // Reset the mouse grabber and focus item data. -
685 if (mouseGrabberItems.contains(item))
partially evaluated: mouseGrabberItems.contains(item)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1001
0-1001
686 ungrabMouse(item, /* item is dying */ item->d_ptr->inDestructor);
never executed: ungrabMouse(item, item->d_ptr->inDestructor);
0
687 -
688 // Reset the keyboard grabber -
689 if (keyboardGrabberItems.contains(item))
partially evaluated: keyboardGrabberItems.contains(item)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1001
0-1001
690 ungrabKeyboard(item, /* item is dying */ item->d_ptr->inDestructor);
never executed: ungrabKeyboard(item, item->d_ptr->inDestructor);
0
691 -
692 // Reset the last mouse grabber item -
693 if (item == lastMouseGrabberItem)
partially evaluated: item == lastMouseGrabberItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1001
0-1001
694 lastMouseGrabberItem = 0;
never executed: lastMouseGrabberItem = 0;
0
695 -
696 // Reset the current drop item -
697 if (item == dragDropItem)
partially evaluated: item == dragDropItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1001
0-1001
698 dragDropItem = 0;
never executed: dragDropItem = 0;
0
699 -
700 // Reenable selectionChanged() for individual items -
701 --selectionChanging;
executed (the execution status of this line is deduced): --selectionChanging;
-
702 if (!selectionChanging && selectedItems.size() != oldSelectedItemsSize)
partially evaluated: !selectionChanging
TRUEFALSE
yes
Evaluation Count:1001
no
Evaluation Count:0
partially evaluated: selectedItems.size() != oldSelectedItemsSize
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1001
0-1001
703 emit q->selectionChanged();
never executed: q->selectionChanged();
0
704 -
705#ifndef QT_NO_GESTURES -
706 QHash<QGesture *, QGraphicsObject *>::iterator it;
executed (the execution status of this line is deduced): QHash<QGesture *, QGraphicsObject *>::iterator it;
-
707 for (it = gestureTargets.begin(); it != gestureTargets.end();) {
evaluated: it != gestureTargets.end()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1001
2-1001
708 if (it.value() == item)
partially evaluated: it.value() == item
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
709 it = gestureTargets.erase(it);
executed: it = gestureTargets.erase(it);
Execution Count:2
2
710 else -
711 ++it;
never executed: ++it;
0
712 } -
713 -
714 QGraphicsObject *dummy = static_cast<QGraphicsObject *>(item);
executed (the execution status of this line is deduced): QGraphicsObject *dummy = static_cast<QGraphicsObject *>(item);
-
715 cachedTargetItems.removeOne(dummy);
executed (the execution status of this line is deduced): cachedTargetItems.removeOne(dummy);
-
716 cachedItemGestures.remove(dummy);
executed (the execution status of this line is deduced): cachedItemGestures.remove(dummy);
-
717 cachedAlreadyDeliveredGestures.remove(dummy);
executed (the execution status of this line is deduced): cachedAlreadyDeliveredGestures.remove(dummy);
-
718 -
719 foreach (Qt::GestureType gesture, item->d_ptr->gestureContext.keys())
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(item->d_ptr->gestureContext.keys())> _container_(item->d_ptr->gestureContext.keys()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (Qt::GestureType gesture = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
720 ungrabGesture(item, gesture);
executed: ungrabGesture(item, gesture);
Execution Count:50
50
721#endif // QT_NO_GESTURES -
722}
executed: }
Execution Count:1001
1001
723 -
724/*! -
725 \internal -
726*/ -
727void QGraphicsScenePrivate::setActivePanelHelper(QGraphicsItem *item, bool duringActivationEvent) -
728{ -
729 Q_Q(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScene * const q = q_func();
-
730 if (item && item->scene() != q) {
partially evaluated: item
TRUEFALSE
yes
Evaluation Count:20
no
Evaluation Count:0
partially evaluated: item->scene() != q
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
731 qWarning("QGraphicsScene::setActivePanel: item %p must be part of this scene",
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsscene.cpp", 731, __PRETTY_FUNCTION__).warning("QGraphicsScene::setActivePanel: item %p must be part of this scene",
-
732 item);
never executed (the execution status of this line is deduced): item);
-
733 return;
never executed: return;
0
734 } -
735 -
736 // Ensure the scene has focus when we change panel activation. -
737 q->setFocus(Qt::ActiveWindowFocusReason);
executed (the execution status of this line is deduced): q->setFocus(Qt::ActiveWindowFocusReason);
-
738 -
739 // Find the item's panel. -
740 QGraphicsItem *panel = item ? item->panel() : 0;
partially evaluated: item
TRUEFALSE
yes
Evaluation Count:20
no
Evaluation Count:0
0-20
741 lastActivePanel = panel ? activePanel : 0;
evaluated: panel
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:1
1-19
742 if (panel == activePanel || (!q->isActive() && !duringActivationEvent))
evaluated: panel == activePanel
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:17
partially evaluated: !q->isActive()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
never evaluated: !duringActivationEvent
0-17
743 return;
executed: return;
Execution Count:3
3
744 -
745 // Deactivate the last active panel. -
746 if (activePanel) {
partially evaluated: activePanel
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
0-17
747 if (QGraphicsItem *fi = activePanel->focusItem()) {
never evaluated: QGraphicsItem *fi = activePanel->focusItem()
0
748 // Remove focus from the current focus item. -
749 if (fi == q->focusItem())
never evaluated: fi == q->focusItem()
0
750 q->setFocusItem(0, Qt::ActiveWindowFocusReason);
never executed: q->setFocusItem(0, Qt::ActiveWindowFocusReason);
0
751 }
never executed: }
0
752 -
753 QEvent event(QEvent::WindowDeactivate);
never executed (the execution status of this line is deduced): QEvent event(QEvent::WindowDeactivate);
-
754 q->sendEvent(activePanel, &event);
never executed (the execution status of this line is deduced): q->sendEvent(activePanel, &event);
-
755 } else if (panel && !duringActivationEvent) {
never executed: }
partially evaluated: panel
TRUEFALSE
yes
Evaluation Count:17
no
Evaluation Count:0
evaluated: !duringActivationEvent
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:15
0-17
756 // Deactivate the scene if changing activation to a panel. -
757 QEvent event(QEvent::WindowDeactivate);
executed (the execution status of this line is deduced): QEvent event(QEvent::WindowDeactivate);
-
758 foreach (QGraphicsItem *item, q->items()) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(q->items())> _container_(q->items()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
759 if (item->isVisible() && !item->isPanel() && !item->parentItem())
partially evaluated: item->isVisible()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: !item->isPanel()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
never evaluated: !item->parentItem()
0-2
760 q->sendEvent(item, &event);
never executed: q->sendEvent(item, &event);
0
761 }
executed: }
Execution Count:2
2
762 }
executed: }
Execution Count:2
2
763 -
764 // Update activate state. -
765 activePanel = panel;
never executed (the execution status of this line is deduced): activePanel = panel;
-
766 QEvent event(QEvent::ActivationChange);
never executed (the execution status of this line is deduced): QEvent event(QEvent::ActivationChange);
-
767 QApplication::sendEvent(q, &event);
never executed (the execution status of this line is deduced): QApplication::sendEvent(q, &event);
-
768 -
769 // Activate -
770 if (panel) {
partially evaluated: panel
TRUEFALSE
yes
Evaluation Count:17
no
Evaluation Count:0
0-17
771 QEvent event(QEvent::WindowActivate);
executed (the execution status of this line is deduced): QEvent event(QEvent::WindowActivate);
-
772 q->sendEvent(panel, &event);
executed (the execution status of this line is deduced): q->sendEvent(panel, &event);
-
773 -
774 // Set focus on the panel's focus item. -
775 if (QGraphicsItem *focusItem = panel->focusItem())
partially evaluated: QGraphicsItem *focusItem = panel->focusItem()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
0-17
776 focusItem->setFocus(Qt::ActiveWindowFocusReason);
never executed: focusItem->setFocus(Qt::ActiveWindowFocusReason);
0
777 } else if (q->isActive()) {
executed: }
Execution Count:17
never evaluated: q->isActive()
0-17
778 // Activate the scene -
779 QEvent event(QEvent::WindowActivate);
never executed (the execution status of this line is deduced): QEvent event(QEvent::WindowActivate);
-
780 foreach (QGraphicsItem *item, q->items()) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(q->items())> _container_(q->items()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
781 if (item->isVisible() && !item->isPanel() && !item->parentItem())
never evaluated: item->isVisible()
never evaluated: !item->isPanel()
never evaluated: !item->parentItem()
0
782 q->sendEvent(item, &event);
never executed: q->sendEvent(item, &event);
0
783 }
never executed: }
0
784 }
never executed: }
0
785} -
786 -
787/*! -
788 \internal -
789*/ -
790void QGraphicsScenePrivate::setFocusItemHelper(QGraphicsItem *item, -
791 Qt::FocusReason focusReason) -
792{ -
793 Q_Q(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScene * const q = q_func();
-
794 if (item == focusItem)
partially evaluated: item == focusItem
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
795 return;
executed: return;
Execution Count:4
4
796 -
797 // Clear focus if asked to set focus on something that can't -
798 // accept input focus. -
799 if (item && (!(item->flags() & QGraphicsItem::ItemIsFocusable)
never evaluated: item
never evaluated: !(item->flags() & QGraphicsItem::ItemIsFocusable)
0
800 || !item->isVisible() || !item->isEnabled())) {
never evaluated: !item->isVisible()
never evaluated: !item->isEnabled()
0
801 item = 0;
never executed (the execution status of this line is deduced): item = 0;
-
802 }
never executed: }
0
803 -
804 // Set focus on the scene if an item requests focus. -
805 if (item) {
never evaluated: item
0
806 q->setFocus(focusReason);
never executed (the execution status of this line is deduced): q->setFocus(focusReason);
-
807 if (item == focusItem)
never evaluated: item == focusItem
0
808 return;
never executed: return;
0
809 }
never executed: }
0
810 -
811 if (focusItem) {
never evaluated: focusItem
0
812 lastFocusItem = focusItem;
never executed (the execution status of this line is deduced): lastFocusItem = focusItem;
-
813 -
814#ifndef QT_NO_IM -
815 if (lastFocusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod) {
never evaluated: lastFocusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod
0
816 // Close any external input method panel. This happens -
817 // automatically by removing WA_InputMethodEnabled on -
818 // the views, but if we are changing focus, we have to -
819 // do it ourselves. -
820 if (qApp)
never evaluated: (static_cast<QApplication *>(QCoreApplication::instance()))
0
821 qApp->inputMethod()->commit();
never executed: (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->commit();
0
822 }
never executed: }
0
823#endif //QT_NO_IM -
824 -
825 focusItem = 0;
never executed (the execution status of this line is deduced): focusItem = 0;
-
826 QFocusEvent event(QEvent::FocusOut, focusReason);
never executed (the execution status of this line is deduced): QFocusEvent event(QEvent::FocusOut, focusReason);
-
827 sendEvent(lastFocusItem, &event);
never executed (the execution status of this line is deduced): sendEvent(lastFocusItem, &event);
-
828 }
never executed: }
0
829 -
830 // This handles the case that the item has been removed from the -
831 // scene in response to the FocusOut event. -
832 if (item && item->scene() != q)
never evaluated: item
never evaluated: item->scene() != q
0
833 item = 0;
never executed: item = 0;
0
834 -
835 if (item)
never evaluated: item
0
836 focusItem = item;
never executed: focusItem = item;
0
837 updateInputMethodSensitivityInViews();
never executed (the execution status of this line is deduced): updateInputMethodSensitivityInViews();
-
838 -
839#ifndef QT_NO_ACCESSIBILITY -
840 if (focusItem) {
never evaluated: focusItem
0
841 if (QGraphicsObject *focusObj = focusItem->toGraphicsObject()) {
never evaluated: QGraphicsObject *focusObj = focusItem->toGraphicsObject()
0
842 QAccessibleEvent event(focusObj, QAccessible::Focus);
never executed (the execution status of this line is deduced): QAccessibleEvent event(focusObj, QAccessible::Focus);
-
843 QAccessible::updateAccessibility(&event);
never executed (the execution status of this line is deduced): QAccessible::updateAccessibility(&event);
-
844 }
never executed: }
0
845 }
never executed: }
0
846#endif -
847 if (item) {
never evaluated: item
0
848 QFocusEvent event(QEvent::FocusIn, focusReason);
never executed (the execution status of this line is deduced): QFocusEvent event(QEvent::FocusIn, focusReason);
-
849 sendEvent(item, &event);
never executed (the execution status of this line is deduced): sendEvent(item, &event);
-
850 }
never executed: }
0
851}
never executed: }
0
852 -
853/*! -
854 \internal -
855*/ -
856void QGraphicsScenePrivate::addPopup(QGraphicsWidget *widget) -
857{ -
858 Q_ASSERT(widget);
never executed (the execution status of this line is deduced): qt_noop();
-
859 Q_ASSERT(!popupWidgets.contains(widget));
never executed (the execution status of this line is deduced): qt_noop();
-
860 popupWidgets << widget;
never executed (the execution status of this line is deduced): popupWidgets << widget;
-
861 if (QGraphicsWidget *focusWidget = widget->focusWidget()) {
never evaluated: QGraphicsWidget *focusWidget = widget->focusWidget()
0
862 focusWidget->setFocus(Qt::PopupFocusReason);
never executed (the execution status of this line is deduced): focusWidget->setFocus(Qt::PopupFocusReason);
-
863 } else {
never executed: }
0
864 grabKeyboard((QGraphicsItem *)widget);
never executed (the execution status of this line is deduced): grabKeyboard((QGraphicsItem *)widget);
-
865 if (focusItem && popupWidgets.size() == 1) {
never evaluated: focusItem
never evaluated: popupWidgets.size() == 1
0
866 QFocusEvent event(QEvent::FocusOut, Qt::PopupFocusReason);
never executed (the execution status of this line is deduced): QFocusEvent event(QEvent::FocusOut, Qt::PopupFocusReason);
-
867 sendEvent(focusItem, &event);
never executed (the execution status of this line is deduced): sendEvent(focusItem, &event);
-
868 }
never executed: }
0
869 }
never executed: }
0
870 grabMouse((QGraphicsItem *)widget);
never executed (the execution status of this line is deduced): grabMouse((QGraphicsItem *)widget);
-
871}
never executed: }
0
872 -
873/*! -
874 \internal -
875 -
876 Remove \a widget from the popup list. Important notes: -
877 -
878 \a widget is guaranteed to be in the list of popups, but it might not be -
879 the last entry; you can hide any item in the pop list before the others, -
880 and this must cause all later mouse grabbers to lose the grab. -
881*/ -
882void QGraphicsScenePrivate::removePopup(QGraphicsWidget *widget, bool itemIsDying) -
883{ -
884 Q_ASSERT(widget);
never executed (the execution status of this line is deduced): qt_noop();
-
885 int index = popupWidgets.indexOf(widget);
never executed (the execution status of this line is deduced): int index = popupWidgets.indexOf(widget);
-
886 Q_ASSERT(index != -1);
never executed (the execution status of this line is deduced): qt_noop();
-
887 -
888 for (int i = popupWidgets.size() - 1; i >= index; --i) {
never evaluated: i >= index
0
889 QGraphicsWidget *widget = popupWidgets.takeLast();
never executed (the execution status of this line is deduced): QGraphicsWidget *widget = popupWidgets.takeLast();
-
890 ungrabMouse(widget, itemIsDying);
never executed (the execution status of this line is deduced): ungrabMouse(widget, itemIsDying);
-
891 if (focusItem && popupWidgets.isEmpty()) {
never evaluated: focusItem
never evaluated: popupWidgets.isEmpty()
0
892 QFocusEvent event(QEvent::FocusIn, Qt::PopupFocusReason);
never executed (the execution status of this line is deduced): QFocusEvent event(QEvent::FocusIn, Qt::PopupFocusReason);
-
893 sendEvent(focusItem, &event);
never executed (the execution status of this line is deduced): sendEvent(focusItem, &event);
-
894 } else if (keyboardGrabberItems.contains(static_cast<QGraphicsItem *>(widget))) {
never executed: }
never evaluated: keyboardGrabberItems.contains(static_cast<QGraphicsItem *>(widget))
0
895 ungrabKeyboard(static_cast<QGraphicsItem *>(widget), itemIsDying);
never executed (the execution status of this line is deduced): ungrabKeyboard(static_cast<QGraphicsItem *>(widget), itemIsDying);
-
896 }
never executed: }
0
897 if (!itemIsDying && widget->isVisible()) {
never evaluated: !itemIsDying
never evaluated: widget->isVisible()
0
898 widget->QGraphicsItem::d_ptr->setVisibleHelper(false, /* explicit = */ false);
never executed (the execution status of this line is deduced): widget->QGraphicsItem::d_ptr->setVisibleHelper(false, false);
-
899 }
never executed: }
0
900 }
never executed: }
0
901}
never executed: }
0
902 -
903/*! -
904 \internal -
905*/ -
906void QGraphicsScenePrivate::grabMouse(QGraphicsItem *item, bool implicit) -
907{ -
908 // Append to list of mouse grabber items, and send a mouse grab event. -
909 if (mouseGrabberItems.contains(item)) {
partially evaluated: mouseGrabberItems.contains(item)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
910 if (mouseGrabberItems.last() == item) {
never evaluated: mouseGrabberItems.last() == item
0
911 Q_ASSERT(!implicit);
never executed (the execution status of this line is deduced): qt_noop();
-
912 if (!lastMouseGrabberItemHasImplicitMouseGrab) {
never evaluated: !lastMouseGrabberItemHasImplicitMouseGrab
0
913 qWarning("QGraphicsItem::grabMouse: already a mouse grabber");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsscene.cpp", 913, __PRETTY_FUNCTION__).warning("QGraphicsItem::grabMouse: already a mouse grabber");
-
914 } else {
never executed: }
0
915 // Upgrade to an explicit mouse grab -
916 lastMouseGrabberItemHasImplicitMouseGrab = false;
never executed (the execution status of this line is deduced): lastMouseGrabberItemHasImplicitMouseGrab = false;
-
917 }
never executed: }
0
918 } else { -
919 qWarning("QGraphicsItem::grabMouse: already blocked by mouse grabber: %p",
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsscene.cpp", 919, __PRETTY_FUNCTION__).warning("QGraphicsItem::grabMouse: already blocked by mouse grabber: %p",
-
920 mouseGrabberItems.last());
never executed (the execution status of this line is deduced): mouseGrabberItems.last());
-
921 }
never executed: }
0
922 return;
never executed: return;
0
923 } -
924 -
925 // Send ungrab event to the last grabber. -
926 if (!mouseGrabberItems.isEmpty()) {
partially evaluated: !mouseGrabberItems.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
927 QGraphicsItem *last = mouseGrabberItems.last();
never executed (the execution status of this line is deduced): QGraphicsItem *last = mouseGrabberItems.last();
-
928 if (lastMouseGrabberItemHasImplicitMouseGrab) {
never evaluated: lastMouseGrabberItemHasImplicitMouseGrab
0
929 // Implicit mouse grab is immediately lost. -
930 last->ungrabMouse();
never executed (the execution status of this line is deduced): last->ungrabMouse();
-
931 } else {
never executed: }
0
932 // Just send ungrab event to current grabber. -
933 QEvent ungrabEvent(QEvent::UngrabMouse);
never executed (the execution status of this line is deduced): QEvent ungrabEvent(QEvent::UngrabMouse);
-
934 sendEvent(last, &ungrabEvent);
never executed (the execution status of this line is deduced): sendEvent(last, &ungrabEvent);
-
935 }
never executed: }
0
936 } -
937 -
938 mouseGrabberItems << item;
executed (the execution status of this line is deduced): mouseGrabberItems << item;
-
939 lastMouseGrabberItemHasImplicitMouseGrab = implicit;
executed (the execution status of this line is deduced): lastMouseGrabberItemHasImplicitMouseGrab = implicit;
-
940 -
941 // Send grab event to current grabber. -
942 QEvent grabEvent(QEvent::GrabMouse);
executed (the execution status of this line is deduced): QEvent grabEvent(QEvent::GrabMouse);
-
943 sendEvent(item, &grabEvent);
executed (the execution status of this line is deduced): sendEvent(item, &grabEvent);
-
944}
executed: }
Execution Count:2
2
945 -
946/*! -
947 \internal -
948*/ -
949void QGraphicsScenePrivate::ungrabMouse(QGraphicsItem *item, bool itemIsDying) -
950{ -
951 int index = mouseGrabberItems.indexOf(item);
executed (the execution status of this line is deduced): int index = mouseGrabberItems.indexOf(item);
-
952 if (index == -1) {
partially evaluated: index == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
953 qWarning("QGraphicsItem::ungrabMouse: not a mouse grabber");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsscene.cpp", 953, __PRETTY_FUNCTION__).warning("QGraphicsItem::ungrabMouse: not a mouse grabber");
-
954 return;
never executed: return;
0
955 } -
956 -
957 if (item != mouseGrabberItems.last()) {
partially evaluated: item != mouseGrabberItems.last()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
958 // Recursively ungrab the next mouse grabber until we reach this item -
959 // to ensure state consistency. -
960 ungrabMouse(mouseGrabberItems.at(index + 1), itemIsDying);
never executed (the execution status of this line is deduced): ungrabMouse(mouseGrabberItems.at(index + 1), itemIsDying);
-
961 }
never executed: }
0
962 if (!popupWidgets.isEmpty() && item == popupWidgets.last()) {
partially evaluated: !popupWidgets.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
never evaluated: item == popupWidgets.last()
0-2
963 // If the item is a popup, go via removePopup to ensure state -
964 // consistency and that it gets hidden correctly - beware that -
965 // removePopup() reenters this function to continue removing the grab. -
966 removePopup((QGraphicsWidget *)item, itemIsDying);
never executed (the execution status of this line is deduced): removePopup((QGraphicsWidget *)item, itemIsDying);
-
967 return;
never executed: return;
0
968 } -
969 -
970 // Send notification about mouse ungrab. -
971 if (!itemIsDying) {
partially evaluated: !itemIsDying
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
972 QEvent event(QEvent::UngrabMouse);
executed (the execution status of this line is deduced): QEvent event(QEvent::UngrabMouse);
-
973 sendEvent(item, &event);
executed (the execution status of this line is deduced): sendEvent(item, &event);
-
974 }
executed: }
Execution Count:2
2
975 -
976 // Remove the item from the list of grabbers. Whenever this happens, we -
977 // reset the implicitGrab (there can be only ever be one implicit grabber -
978 // in a scene, and it is always the latest grabber; if the implicit grab -
979 // is lost, it is not automatically regained. -
980 mouseGrabberItems.takeLast();
executed (the execution status of this line is deduced): mouseGrabberItems.takeLast();
-
981 lastMouseGrabberItemHasImplicitMouseGrab = false;
executed (the execution status of this line is deduced): lastMouseGrabberItemHasImplicitMouseGrab = false;
-
982 -
983 // Send notification about mouse regrab. ### It's unfortunate that all the -
984 // items get a GrabMouse event, but this is a rare case with a simple -
985 // implementation and it does ensure a consistent state. -
986 if (!itemIsDying && !mouseGrabberItems.isEmpty()) {
partially evaluated: !itemIsDying
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: !mouseGrabberItems.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
987 QGraphicsItem *last = mouseGrabberItems.last();
never executed (the execution status of this line is deduced): QGraphicsItem *last = mouseGrabberItems.last();
-
988 QEvent event(QEvent::GrabMouse);
never executed (the execution status of this line is deduced): QEvent event(QEvent::GrabMouse);
-
989 sendEvent(last, &event);
never executed (the execution status of this line is deduced): sendEvent(last, &event);
-
990 }
never executed: }
0
991}
executed: }
Execution Count:2
2
992 -
993/*! -
994 \internal -
995*/ -
996void QGraphicsScenePrivate::clearMouseGrabber() -
997{ -
998 if (!mouseGrabberItems.isEmpty())
never evaluated: !mouseGrabberItems.isEmpty()
0
999 mouseGrabberItems.first()->ungrabMouse();
never executed: mouseGrabberItems.first()->ungrabMouse();
0
1000 lastMouseGrabberItem = 0;
never executed (the execution status of this line is deduced): lastMouseGrabberItem = 0;
-
1001}
never executed: }
0
1002 -
1003/*! -
1004 \internal -
1005*/ -
1006void QGraphicsScenePrivate::grabKeyboard(QGraphicsItem *item) -
1007{ -
1008 if (keyboardGrabberItems.contains(item)) {
never evaluated: keyboardGrabberItems.contains(item)
0
1009 if (keyboardGrabberItems.last() == item)
never evaluated: keyboardGrabberItems.last() == item
0
1010 qWarning("QGraphicsItem::grabKeyboard: already a keyboard grabber");
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 1010, __PRETTY_FUNCTION__).warning("QGraphicsItem::grabKeyboard: already a keyboard grabber");
0
1011 else -
1012 qWarning("QGraphicsItem::grabKeyboard: already blocked by keyboard grabber: %p",
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 1012, __PRETTY_FUNCTION__).warning("QGraphicsItem::grabKeyboard: already blocked by keyboard grabber: %p", keyboardGrabberItems.last());
0
1013 keyboardGrabberItems.last());
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 1012, __PRETTY_FUNCTION__).warning("QGraphicsItem::grabKeyboard: already blocked by keyboard grabber: %p", keyboardGrabberItems.last());
0
1014 return;
never executed: return;
0
1015 } -
1016 -
1017 // Send ungrab event to the last grabber. -
1018 if (!keyboardGrabberItems.isEmpty()) {
never evaluated: !keyboardGrabberItems.isEmpty()
0
1019 // Just send ungrab event to current grabber. -
1020 QEvent ungrabEvent(QEvent::UngrabKeyboard);
never executed (the execution status of this line is deduced): QEvent ungrabEvent(QEvent::UngrabKeyboard);
-
1021 sendEvent(keyboardGrabberItems.last(), &ungrabEvent);
never executed (the execution status of this line is deduced): sendEvent(keyboardGrabberItems.last(), &ungrabEvent);
-
1022 }
never executed: }
0
1023 -
1024 keyboardGrabberItems << item;
never executed (the execution status of this line is deduced): keyboardGrabberItems << item;
-
1025 -
1026 // Send grab event to current grabber. -
1027 QEvent grabEvent(QEvent::GrabKeyboard);
never executed (the execution status of this line is deduced): QEvent grabEvent(QEvent::GrabKeyboard);
-
1028 sendEvent(item, &grabEvent);
never executed (the execution status of this line is deduced): sendEvent(item, &grabEvent);
-
1029}
never executed: }
0
1030 -
1031/*! -
1032 \internal -
1033*/ -
1034void QGraphicsScenePrivate::ungrabKeyboard(QGraphicsItem *item, bool itemIsDying) -
1035{ -
1036 int index = keyboardGrabberItems.lastIndexOf(item);
never executed (the execution status of this line is deduced): int index = keyboardGrabberItems.lastIndexOf(item);
-
1037 if (index == -1) {
never evaluated: index == -1
0
1038 qWarning("QGraphicsItem::ungrabKeyboard: not a keyboard grabber");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsscene.cpp", 1038, __PRETTY_FUNCTION__).warning("QGraphicsItem::ungrabKeyboard: not a keyboard grabber");
-
1039 return;
never executed: return;
0
1040 } -
1041 if (item != keyboardGrabberItems.last()) {
never evaluated: item != keyboardGrabberItems.last()
0
1042 // Recursively ungrab the topmost keyboard grabber until we reach this -
1043 // item to ensure state consistency. -
1044 ungrabKeyboard(keyboardGrabberItems.at(index + 1), itemIsDying);
never executed (the execution status of this line is deduced): ungrabKeyboard(keyboardGrabberItems.at(index + 1), itemIsDying);
-
1045 }
never executed: }
0
1046 -
1047 // Send notification about keyboard ungrab. -
1048 if (!itemIsDying) {
never evaluated: !itemIsDying
0
1049 QEvent event(QEvent::UngrabKeyboard);
never executed (the execution status of this line is deduced): QEvent event(QEvent::UngrabKeyboard);
-
1050 sendEvent(item, &event);
never executed (the execution status of this line is deduced): sendEvent(item, &event);
-
1051 }
never executed: }
0
1052 -
1053 // Remove the item from the list of grabbers. -
1054 keyboardGrabberItems.takeLast();
never executed (the execution status of this line is deduced): keyboardGrabberItems.takeLast();
-
1055 -
1056 // Send notification about mouse regrab. -
1057 if (!itemIsDying && !keyboardGrabberItems.isEmpty()) {
never evaluated: !itemIsDying
never evaluated: !keyboardGrabberItems.isEmpty()
0
1058 QGraphicsItem *last = keyboardGrabberItems.last();
never executed (the execution status of this line is deduced): QGraphicsItem *last = keyboardGrabberItems.last();
-
1059 QEvent event(QEvent::GrabKeyboard);
never executed (the execution status of this line is deduced): QEvent event(QEvent::GrabKeyboard);
-
1060 sendEvent(last, &event);
never executed (the execution status of this line is deduced): sendEvent(last, &event);
-
1061 }
never executed: }
0
1062}
never executed: }
0
1063 -
1064/*! -
1065 \internal -
1066*/ -
1067void QGraphicsScenePrivate::clearKeyboardGrabber() -
1068{ -
1069 if (!keyboardGrabberItems.isEmpty())
never evaluated: !keyboardGrabberItems.isEmpty()
0
1070 ungrabKeyboard(keyboardGrabberItems.first());
never executed: ungrabKeyboard(keyboardGrabberItems.first());
0
1071}
never executed: }
0
1072 -
1073void QGraphicsScenePrivate::enableMouseTrackingOnViews() -
1074{ -
1075 foreach (QGraphicsView *view, views)
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(views)> _container_(views); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsView *view = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
1076 view->viewport()->setMouseTracking(true);
executed: view->viewport()->setMouseTracking(true);
Execution Count:173
173
1077}
executed: }
Execution Count:175
175
1078 -
1079/*! -
1080 Returns all items for the screen position in \a event. -
1081*/ -
1082QList<QGraphicsItem *> QGraphicsScenePrivate::itemsAtPosition(const QPoint &screenPos, -
1083 const QPointF &scenePos, -
1084 QWidget *widget) const -
1085{ -
1086 Q_Q(const QGraphicsScene);
executed (the execution status of this line is deduced): const QGraphicsScene * const q = q_func();
-
1087 QGraphicsView *view = widget ? qobject_cast<QGraphicsView *>(widget->parentWidget()) : 0;
evaluated: widget
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:67
2-67
1088 if (!view)
evaluated: !view
TRUEFALSE
yes
Evaluation Count:67
yes
Evaluation Count:2
2-67
1089 return q->items(scenePos, Qt::IntersectsItemShape, Qt::DescendingOrder, QTransform());
executed: return q->items(scenePos, Qt::IntersectsItemShape, Qt::DescendingOrder, QTransform());
Execution Count:67
67
1090 -
1091 const QRectF pointRect(QPointF(widget->mapFromGlobal(screenPos)), QSizeF(1, 1));
executed (the execution status of this line is deduced): const QRectF pointRect(QPointF(widget->mapFromGlobal(screenPos)), QSizeF(1, 1));
-
1092 if (!view->isTransformed())
partially evaluated: !view->isTransformed()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1093 return q->items(pointRect, Qt::IntersectsItemShape, Qt::DescendingOrder);
never executed: return q->items(pointRect, Qt::IntersectsItemShape, Qt::DescendingOrder);
0
1094 -
1095 const QTransform viewTransform = view->viewportTransform();
executed (the execution status of this line is deduced): const QTransform viewTransform = view->viewportTransform();
-
1096 if (viewTransform.type() <= QTransform::TxScale) {
partially evaluated: viewTransform.type() <= QTransform::TxScale
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1097 return q->items(viewTransform.inverted().mapRect(pointRect), Qt::IntersectsItemShape,
executed: return q->items(viewTransform.inverted().mapRect(pointRect), Qt::IntersectsItemShape, Qt::DescendingOrder, viewTransform);
Execution Count:2
2
1098 Qt::DescendingOrder, viewTransform);
executed: return q->items(viewTransform.inverted().mapRect(pointRect), Qt::IntersectsItemShape, Qt::DescendingOrder, viewTransform);
Execution Count:2
2
1099 } -
1100 return q->items(viewTransform.inverted().map(pointRect), Qt::IntersectsItemShape,
never executed: return q->items(viewTransform.inverted().map(pointRect), Qt::IntersectsItemShape, Qt::DescendingOrder, viewTransform);
0
1101 Qt::DescendingOrder, viewTransform);
never executed: return q->items(viewTransform.inverted().map(pointRect), Qt::IntersectsItemShape, Qt::DescendingOrder, viewTransform);
0
1102} -
1103 -
1104/*! -
1105 \internal -
1106*/ -
1107void QGraphicsScenePrivate::storeMouseButtonsForMouseGrabber(QGraphicsSceneMouseEvent *event) -
1108{ -
1109 for (int i = 0x1; i <= 0x10; i <<= 1) {
evaluated: i <= 0x10
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:2
2-10
1110 if (event->buttons() & i) {
evaluated: event->buttons() & i
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:8
2-8
1111 mouseGrabberButtonDownPos.insert(Qt::MouseButton(i),
executed (the execution status of this line is deduced): mouseGrabberButtonDownPos.insert(Qt::MouseButton(i),
-
1112 mouseGrabberItems.last()->d_ptr->genericMapFromScene(event->scenePos(),
executed (the execution status of this line is deduced): mouseGrabberItems.last()->d_ptr->genericMapFromScene(event->scenePos(),
-
1113 event->widget()));
executed (the execution status of this line is deduced): event->widget()));
-
1114 mouseGrabberButtonDownScenePos.insert(Qt::MouseButton(i), event->scenePos());
executed (the execution status of this line is deduced): mouseGrabberButtonDownScenePos.insert(Qt::MouseButton(i), event->scenePos());
-
1115 mouseGrabberButtonDownScreenPos.insert(Qt::MouseButton(i), event->screenPos());
executed (the execution status of this line is deduced): mouseGrabberButtonDownScreenPos.insert(Qt::MouseButton(i), event->screenPos());
-
1116 }
executed: }
Execution Count:2
2
1117 }
executed: }
Execution Count:10
10
1118}
executed: }
Execution Count:2
2
1119 -
1120/*! -
1121 \internal -
1122*/ -
1123void QGraphicsScenePrivate::installSceneEventFilter(QGraphicsItem *watched, QGraphicsItem *filter) -
1124{ -
1125 sceneEventFilters.insert(watched, filter);
never executed (the execution status of this line is deduced): sceneEventFilters.insert(watched, filter);
-
1126}
never executed: }
0
1127 -
1128/*! -
1129 \internal -
1130*/ -
1131void QGraphicsScenePrivate::removeSceneEventFilter(QGraphicsItem *watched, QGraphicsItem *filter) -
1132{ -
1133 if (!sceneEventFilters.contains(watched))
never evaluated: !sceneEventFilters.contains(watched)
0
1134 return;
never executed: return;
0
1135 -
1136 QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator it = sceneEventFilters.lowerBound(watched);
never executed (the execution status of this line is deduced): QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator it = sceneEventFilters.lowerBound(watched);
-
1137 QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator end = sceneEventFilters.upperBound(watched);
never executed (the execution status of this line is deduced): QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator end = sceneEventFilters.upperBound(watched);
-
1138 do { -
1139 if (it.value() == filter)
never evaluated: it.value() == filter
0
1140 it = sceneEventFilters.erase(it);
never executed: it = sceneEventFilters.erase(it);
0
1141 else -
1142 ++it;
never executed: ++it;
0
1143 } while (it != end);
never evaluated: it != end
0
1144}
never executed: }
0
1145 -
1146/*! -
1147 \internal -
1148*/ -
1149bool QGraphicsScenePrivate::filterDescendantEvent(QGraphicsItem *item, QEvent *event) -
1150{ -
1151 if (item && (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorFiltersChildEvents)) {
partially evaluated: item
TRUEFALSE
yes
Evaluation Count:609
no
Evaluation Count:0
partially evaluated: (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorFiltersChildEvents)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:609
0-609
1152 QGraphicsItem *parent = item->parentItem();
never executed (the execution status of this line is deduced): QGraphicsItem *parent = item->parentItem();
-
1153 while (parent) {
never evaluated: parent
0
1154 if (parent->d_ptr->filtersDescendantEvents && parent->sceneEventFilter(item, event))
never evaluated: parent->d_ptr->filtersDescendantEvents
never evaluated: parent->sceneEventFilter(item, event)
0
1155 return true;
never executed: return true;
0
1156 if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorFiltersChildEvents))
never evaluated: !(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorFiltersChildEvents)
0
1157 return false;
never executed: return false;
0
1158 parent = parent->parentItem();
never executed (the execution status of this line is deduced): parent = parent->parentItem();
-
1159 }
never executed: }
0
1160 }
never executed: }
0
1161 return false;
executed: return false;
Execution Count:609
609
1162} -
1163 -
1164/*! -
1165 \internal -
1166*/ -
1167bool QGraphicsScenePrivate::filterEvent(QGraphicsItem *item, QEvent *event) -
1168{ -
1169 if (item && !sceneEventFilters.contains(item))
partially evaluated: item
TRUEFALSE
yes
Evaluation Count:609
no
Evaluation Count:0
partially evaluated: !sceneEventFilters.contains(item)
TRUEFALSE
yes
Evaluation Count:609
no
Evaluation Count:0
0-609
1170 return false;
executed: return false;
Execution Count:609
609
1171 -
1172 QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator it = sceneEventFilters.lowerBound(item);
never executed (the execution status of this line is deduced): QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator it = sceneEventFilters.lowerBound(item);
-
1173 QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator end = sceneEventFilters.upperBound(item);
never executed (the execution status of this line is deduced): QMultiMap<QGraphicsItem *, QGraphicsItem *>::Iterator end = sceneEventFilters.upperBound(item);
-
1174 while (it != end) {
never evaluated: it != end
0
1175 // ### The filterer and filteree might both be deleted. -
1176 if (it.value()->sceneEventFilter(it.key(), event))
never evaluated: it.value()->sceneEventFilter(it.key(), event)
0
1177 return true;
never executed: return true;
0
1178 ++it;
never executed (the execution status of this line is deduced): ++it;
-
1179 }
never executed: }
0
1180 return false;
never executed: return false;
0
1181} -
1182 -
1183/*! -
1184 \internal -
1185 -
1186 This is the final dispatch point for any events from the scene to the -
1187 item. It filters the event first - if the filter returns true, the event -
1188 is considered to have been eaten by the filter, and is therefore stopped -
1189 (the default filter returns false). Then/otherwise, if the item is -
1190 enabled, the event is sent; otherwise it is stopped. -
1191*/ -
1192bool QGraphicsScenePrivate::sendEvent(QGraphicsItem *item, QEvent *event) -
1193{ -
1194 if (QGraphicsObject *object = item->toGraphicsObject()) {
evaluated: QGraphicsObject *object = item->toGraphicsObject()
TRUEFALSE
yes
Evaluation Count:598
yes
Evaluation Count:11
11-598
1195#ifndef QT_NO_GESTURES -
1196 QGestureManager *gestureManager = QApplicationPrivate::instance()->gestureManager;
executed (the execution status of this line is deduced): QGestureManager *gestureManager = QApplicationPrivate::instance()->gestureManager;
-
1197 if (gestureManager) {
evaluated: gestureManager
TRUEFALSE
yes
Evaluation Count:597
yes
Evaluation Count:1
1-597
1198 if (gestureManager->filterEvent(object, event))
partially evaluated: gestureManager->filterEvent(object, event)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:597
0-597
1199 return true;
never executed: return true;
0
1200 }
executed: }
Execution Count:597
597
1201#endif // QT_NO_GESTURES -
1202 }
executed: }
Execution Count:598
598
1203 -
1204 if (filterEvent(item, event))
partially evaluated: filterEvent(item, event)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:609
0-609
1205 return false;
never executed: return false;
0
1206 if (filterDescendantEvent(item, event))
partially evaluated: filterDescendantEvent(item, event)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:609
0-609
1207 return false;
never executed: return false;
0
1208 if (!item || !item->isEnabled())
partially evaluated: !item
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:609
partially evaluated: !item->isEnabled()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:609
0-609
1209 return false;
never executed: return false;
0
1210 if (QGraphicsObject *o = item->toGraphicsObject()) {
evaluated: QGraphicsObject *o = item->toGraphicsObject()
TRUEFALSE
yes
Evaluation Count:598
yes
Evaluation Count:11
11-598
1211 bool spont = event->spontaneous();
executed (the execution status of this line is deduced): bool spont = event->spontaneous();
-
1212 if (spont ? qt_sendSpontaneousEvent(o, event) : QApplication::sendEvent(o, event))
evaluated: spont
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:593
5-593
1213 return true;
executed: return true;
Execution Count:428
428
1214 event->spont = spont;
executed (the execution status of this line is deduced): event->spont = spont;
-
1215 }
executed: }
Execution Count:170
170
1216 return item->sceneEvent(event);
executed: return item->sceneEvent(event);
Execution Count:181
181
1217} -
1218 -
1219/*! -
1220 \internal -
1221*/ -
1222void QGraphicsScenePrivate::cloneDragDropEvent(QGraphicsSceneDragDropEvent *dest, -
1223 QGraphicsSceneDragDropEvent *source) -
1224{ -
1225 dest->setWidget(source->widget());
never executed (the execution status of this line is deduced): dest->setWidget(source->widget());
-
1226 dest->setPos(source->pos());
never executed (the execution status of this line is deduced): dest->setPos(source->pos());
-
1227 dest->setScenePos(source->scenePos());
never executed (the execution status of this line is deduced): dest->setScenePos(source->scenePos());
-
1228 dest->setScreenPos(source->screenPos());
never executed (the execution status of this line is deduced): dest->setScreenPos(source->screenPos());
-
1229 dest->setButtons(source->buttons());
never executed (the execution status of this line is deduced): dest->setButtons(source->buttons());
-
1230 dest->setModifiers(source->modifiers());
never executed (the execution status of this line is deduced): dest->setModifiers(source->modifiers());
-
1231 dest->setPossibleActions(source->possibleActions());
never executed (the execution status of this line is deduced): dest->setPossibleActions(source->possibleActions());
-
1232 dest->setProposedAction(source->proposedAction());
never executed (the execution status of this line is deduced): dest->setProposedAction(source->proposedAction());
-
1233 dest->setDropAction(source->dropAction());
never executed (the execution status of this line is deduced): dest->setDropAction(source->dropAction());
-
1234 dest->setSource(source->source());
never executed (the execution status of this line is deduced): dest->setSource(source->source());
-
1235 dest->setMimeData(source->mimeData());
never executed (the execution status of this line is deduced): dest->setMimeData(source->mimeData());
-
1236}
never executed: }
0
1237 -
1238/*! -
1239 \internal -
1240*/ -
1241void QGraphicsScenePrivate::sendDragDropEvent(QGraphicsItem *item, -
1242 QGraphicsSceneDragDropEvent *dragDropEvent) -
1243{ -
1244 dragDropEvent->setPos(item->d_ptr->genericMapFromScene(dragDropEvent->scenePos(), dragDropEvent->widget()));
never executed (the execution status of this line is deduced): dragDropEvent->setPos(item->d_ptr->genericMapFromScene(dragDropEvent->scenePos(), dragDropEvent->widget()));
-
1245 sendEvent(item, dragDropEvent);
never executed (the execution status of this line is deduced): sendEvent(item, dragDropEvent);
-
1246}
never executed: }
0
1247 -
1248/*! -
1249 \internal -
1250*/ -
1251void QGraphicsScenePrivate::sendHoverEvent(QEvent::Type type, QGraphicsItem *item, -
1252 QGraphicsSceneHoverEvent *hoverEvent) -
1253{ -
1254 QGraphicsSceneHoverEvent event(type);
never executed (the execution status of this line is deduced): QGraphicsSceneHoverEvent event(type);
-
1255 event.setWidget(hoverEvent->widget());
never executed (the execution status of this line is deduced): event.setWidget(hoverEvent->widget());
-
1256 event.setPos(item->d_ptr->genericMapFromScene(hoverEvent->scenePos(), hoverEvent->widget()));
never executed (the execution status of this line is deduced): event.setPos(item->d_ptr->genericMapFromScene(hoverEvent->scenePos(), hoverEvent->widget()));
-
1257 event.setScenePos(hoverEvent->scenePos());
never executed (the execution status of this line is deduced): event.setScenePos(hoverEvent->scenePos());
-
1258 event.setScreenPos(hoverEvent->screenPos());
never executed (the execution status of this line is deduced): event.setScreenPos(hoverEvent->screenPos());
-
1259 event.setLastPos(item->d_ptr->genericMapFromScene(hoverEvent->lastScenePos(), hoverEvent->widget()));
never executed (the execution status of this line is deduced): event.setLastPos(item->d_ptr->genericMapFromScene(hoverEvent->lastScenePos(), hoverEvent->widget()));
-
1260 event.setLastScenePos(hoverEvent->lastScenePos());
never executed (the execution status of this line is deduced): event.setLastScenePos(hoverEvent->lastScenePos());
-
1261 event.setLastScreenPos(hoverEvent->lastScreenPos());
never executed (the execution status of this line is deduced): event.setLastScreenPos(hoverEvent->lastScreenPos());
-
1262 event.setModifiers(hoverEvent->modifiers());
never executed (the execution status of this line is deduced): event.setModifiers(hoverEvent->modifiers());
-
1263 sendEvent(item, &event);
never executed (the execution status of this line is deduced): sendEvent(item, &event);
-
1264}
never executed: }
0
1265 -
1266/*! -
1267 \internal -
1268*/ -
1269void QGraphicsScenePrivate::sendMouseEvent(QGraphicsSceneMouseEvent *mouseEvent) -
1270{ -
1271 if (mouseEvent->button() == 0 && mouseEvent->buttons() == 0 && lastMouseGrabberItemHasImplicitMouseGrab) {
partially evaluated: mouseEvent->button() == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
never evaluated: mouseEvent->buttons() == 0
never evaluated: lastMouseGrabberItemHasImplicitMouseGrab
0-5
1272 // ### This is a temporary fix for until we get proper mouse -
1273 // grab events. -
1274 clearMouseGrabber();
never executed (the execution status of this line is deduced): clearMouseGrabber();
-
1275 return;
never executed: return;
0
1276 } -
1277 -
1278 QGraphicsItem *item = mouseGrabberItems.last();
executed (the execution status of this line is deduced): QGraphicsItem *item = mouseGrabberItems.last();
-
1279 if (item->isBlockedByModalPanel())
partially evaluated: item->isBlockedByModalPanel()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-5
1280 return;
never executed: return;
0
1281 -
1282 for (int i = 0x1; i <= 0x10; i <<= 1) {
evaluated: i <= 0x10
TRUEFALSE
yes
Evaluation Count:25
yes
Evaluation Count:5
5-25
1283 Qt::MouseButton button = Qt::MouseButton(i);
executed (the execution status of this line is deduced): Qt::MouseButton button = Qt::MouseButton(i);
-
1284 mouseEvent->setButtonDownPos(button, mouseGrabberButtonDownPos.value(button, item->d_ptr->genericMapFromScene(mouseEvent->scenePos(), mouseEvent->widget())));
executed (the execution status of this line is deduced): mouseEvent->setButtonDownPos(button, mouseGrabberButtonDownPos.value(button, item->d_ptr->genericMapFromScene(mouseEvent->scenePos(), mouseEvent->widget())));
-
1285 mouseEvent->setButtonDownScenePos(button, mouseGrabberButtonDownScenePos.value(button, mouseEvent->scenePos()));
executed (the execution status of this line is deduced): mouseEvent->setButtonDownScenePos(button, mouseGrabberButtonDownScenePos.value(button, mouseEvent->scenePos()));
-
1286 mouseEvent->setButtonDownScreenPos(button, mouseGrabberButtonDownScreenPos.value(button, mouseEvent->screenPos()));
executed (the execution status of this line is deduced): mouseEvent->setButtonDownScreenPos(button, mouseGrabberButtonDownScreenPos.value(button, mouseEvent->screenPos()));
-
1287 }
executed: }
Execution Count:25
25
1288 mouseEvent->setPos(item->d_ptr->genericMapFromScene(mouseEvent->scenePos(), mouseEvent->widget()));
executed (the execution status of this line is deduced): mouseEvent->setPos(item->d_ptr->genericMapFromScene(mouseEvent->scenePos(), mouseEvent->widget()));
-
1289 mouseEvent->setLastPos(item->d_ptr->genericMapFromScene(mouseEvent->lastScenePos(), mouseEvent->widget()));
executed (the execution status of this line is deduced): mouseEvent->setLastPos(item->d_ptr->genericMapFromScene(mouseEvent->lastScenePos(), mouseEvent->widget()));
-
1290 sendEvent(item, mouseEvent);
executed (the execution status of this line is deduced): sendEvent(item, mouseEvent);
-
1291}
executed: }
Execution Count:5
5
1292 -
1293/*! -
1294 \internal -
1295*/ -
1296void QGraphicsScenePrivate::mousePressEventHandler(QGraphicsSceneMouseEvent *mouseEvent) -
1297{ -
1298 Q_Q(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScene * const q = q_func();
-
1299 -
1300 // Ignore by default, unless we find a mouse grabber that accepts it. -
1301 mouseEvent->ignore();
executed (the execution status of this line is deduced): mouseEvent->ignore();
-
1302 -
1303 // Deliver to any existing mouse grabber. -
1304 if (!mouseGrabberItems.isEmpty()) {
evaluated: !mouseGrabberItems.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
1305 if (mouseGrabberItems.last()->isBlockedByModalPanel())
partially evaluated: mouseGrabberItems.last()->isBlockedByModalPanel()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1306 return;
never executed: return;
0
1307 // The event is ignored by default, but we disregard the event's -
1308 // accepted state after delivery; the mouse is grabbed, after all. -
1309 sendMouseEvent(mouseEvent);
executed (the execution status of this line is deduced): sendMouseEvent(mouseEvent);
-
1310 return;
executed: return;
Execution Count:1
1
1311 } -
1312 -
1313 // Start by determining the number of items at the current position. -
1314 // Reuse value from earlier calculations if possible. -
1315 if (cachedItemsUnderMouse.isEmpty()) {
partially evaluated: cachedItemsUnderMouse.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1316 cachedItemsUnderMouse = itemsAtPosition(mouseEvent->screenPos(),
executed (the execution status of this line is deduced): cachedItemsUnderMouse = itemsAtPosition(mouseEvent->screenPos(),
-
1317 mouseEvent->scenePos(),
executed (the execution status of this line is deduced): mouseEvent->scenePos(),
-
1318 mouseEvent->widget());
executed (the execution status of this line is deduced): mouseEvent->widget());
-
1319 }
executed: }
Execution Count:2
2
1320 -
1321 // Update window activation. -
1322 QGraphicsItem *topItem = cachedItemsUnderMouse.value(0);
executed (the execution status of this line is deduced): QGraphicsItem *topItem = cachedItemsUnderMouse.value(0);
-
1323 QGraphicsWidget *newActiveWindow = topItem ? topItem->window() : 0;
partially evaluated: topItem
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1324 if (newActiveWindow && newActiveWindow->isBlockedByModalPanel(&topItem)) {
partially evaluated: newActiveWindow
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
never evaluated: newActiveWindow->isBlockedByModalPanel(&topItem)
0-2
1325 // pass activation to the blocking modal window -
1326 newActiveWindow = topItem ? topItem->window() : 0;
never evaluated: topItem
0
1327 }
never executed: }
0
1328 -
1329 if (newActiveWindow != q->activeWindow())
partially evaluated: newActiveWindow != q->activeWindow()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1330 q->setActiveWindow(newActiveWindow);
never executed: q->setActiveWindow(newActiveWindow);
0
1331 -
1332 // Set focus on the topmost enabled item that can take focus. -
1333 bool setFocus = false;
executed (the execution status of this line is deduced): bool setFocus = false;
-
1334 -
1335 foreach (QGraphicsItem *item, cachedItemsUnderMouse) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(cachedItemsUnderMouse)> _container_(cachedItemsUnderMouse); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
1336 if (item->isBlockedByModalPanel()
partially evaluated: item->isBlockedByModalPanel()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
1337 || (item->d_ptr->flags & QGraphicsItem::ItemStopsFocusHandling)) {
partially evaluated: (item->d_ptr->flags & QGraphicsItem::ItemStopsFocusHandling)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
1338 // Make sure we don't clear focus. -
1339 setFocus = true;
never executed (the execution status of this line is deduced): setFocus = true;
-
1340 break;
never executed: break;
0
1341 } -
1342 if (item->isEnabled() && ((item->flags() & QGraphicsItem::ItemIsFocusable))) {
partially evaluated: item->isEnabled()
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
partially evaluated: ((item->flags() & QGraphicsItem::ItemIsFocusable))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
1343 if (!item->isWidget() || ((QGraphicsWidget *)item)->focusPolicy() & Qt::ClickFocus) {
never evaluated: !item->isWidget()
never evaluated: ((QGraphicsWidget *)item)->focusPolicy() & Qt::ClickFocus
0
1344 setFocus = true;
never executed (the execution status of this line is deduced): setFocus = true;
-
1345 if (item != q->focusItem() && item->d_ptr->mouseSetsFocus)
never evaluated: item != q->focusItem()
never evaluated: item->d_ptr->mouseSetsFocus
0
1346 q->setFocusItem(item, Qt::MouseFocusReason);
never executed: q->setFocusItem(item, Qt::MouseFocusReason);
0
1347 break;
never executed: break;
0
1348 } -
1349 }
never executed: }
0
1350 if (item->isPanel())
partially evaluated: item->isPanel()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
1351 break;
never executed: break;
0
1352 if (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation)
partially evaluated: item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
1353 break;
never executed: break;
0
1354 }
executed: }
Execution Count:4
4
1355 -
1356 // Check for scene modality. -
1357 bool sceneModality = false;
executed (the execution status of this line is deduced): bool sceneModality = false;
-
1358 for (int i = 0; i < modalPanels.size(); ++i) {
partially evaluated: i < modalPanels.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1359 if (modalPanels.at(i)->panelModality() == QGraphicsItem::SceneModal) {
never evaluated: modalPanels.at(i)->panelModality() == QGraphicsItem::SceneModal
0
1360 sceneModality = true;
never executed (the execution status of this line is deduced): sceneModality = true;
-
1361 break;
never executed: break;
0
1362 } -
1363 }
never executed: }
0
1364 -
1365 // If nobody could take focus, clear it. -
1366 if (!stickyFocus && !setFocus && !sceneModality)
partially evaluated: !stickyFocus
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: !setFocus
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: !sceneModality
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1367 q->setFocusItem(0, Qt::MouseFocusReason);
executed: q->setFocusItem(0, Qt::MouseFocusReason);
Execution Count:2
2
1368 -
1369 // Any item will do. -
1370 if (sceneModality && cachedItemsUnderMouse.isEmpty())
partially evaluated: sceneModality
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
never evaluated: cachedItemsUnderMouse.isEmpty()
0-2
1371 cachedItemsUnderMouse << modalPanels.first();
never executed: cachedItemsUnderMouse << modalPanels.first();
0
1372 -
1373 // Find a mouse grabber by sending mouse press events to all mouse grabber -
1374 // candidates one at a time, until the event is accepted. It's accepted by -
1375 // default, so the receiver has to explicitly ignore it for it to pass -
1376 // through. -
1377 foreach (QGraphicsItem *item, cachedItemsUnderMouse) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(cachedItemsUnderMouse)> _container_(cachedItemsUnderMouse); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
1378 if (!(item->acceptedMouseButtons() & mouseEvent->button())) {
partially evaluated: !(item->acceptedMouseButtons() & mouseEvent->button())
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1379 // Skip items that don't accept the event's mouse button. -
1380 continue;
never executed: continue;
0
1381 } -
1382 -
1383 // Check if this item is blocked by a modal panel and deliver the mouse event to the -
1384 // blocking panel instead of this item if blocked. -
1385 (void) item->isBlockedByModalPanel(&item);
executed (the execution status of this line is deduced): (void) item->isBlockedByModalPanel(&item);
-
1386 -
1387 grabMouse(item, /* implicit = */ true);
executed (the execution status of this line is deduced): grabMouse(item, true);
-
1388 mouseEvent->accept();
executed (the execution status of this line is deduced): mouseEvent->accept();
-
1389 -
1390 // check if the item we are sending to are disabled (before we send the event) -
1391 bool disabled = !item->isEnabled();
executed (the execution status of this line is deduced): bool disabled = !item->isEnabled();
-
1392 bool isPanel = item->isPanel();
executed (the execution status of this line is deduced): bool isPanel = item->isPanel();
-
1393 if (mouseEvent->type() == QEvent::GraphicsSceneMouseDoubleClick
partially evaluated: mouseEvent->type() == QEvent::GraphicsSceneMouseDoubleClick
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1394 && item != lastMouseGrabberItem && lastMouseGrabberItem) {
never evaluated: item != lastMouseGrabberItem
never evaluated: lastMouseGrabberItem
0
1395 // If this item is different from the item that received the last -
1396 // mouse event, and mouseEvent is a doubleclick event, then the -
1397 // event is converted to a press. Known limitation: -
1398 // Triple-clicking will not generate a doubleclick, though. -
1399 QGraphicsSceneMouseEvent mousePress(QEvent::GraphicsSceneMousePress);
never executed (the execution status of this line is deduced): QGraphicsSceneMouseEvent mousePress(QEvent::GraphicsSceneMousePress);
-
1400 mousePress.spont = mouseEvent->spont;
never executed (the execution status of this line is deduced): mousePress.spont = mouseEvent->spont;
-
1401 mousePress.accept();
never executed (the execution status of this line is deduced): mousePress.accept();
-
1402 mousePress.setButton(mouseEvent->button());
never executed (the execution status of this line is deduced): mousePress.setButton(mouseEvent->button());
-
1403 mousePress.setButtons(mouseEvent->buttons());
never executed (the execution status of this line is deduced): mousePress.setButtons(mouseEvent->buttons());
-
1404 mousePress.setScreenPos(mouseEvent->screenPos());
never executed (the execution status of this line is deduced): mousePress.setScreenPos(mouseEvent->screenPos());
-
1405 mousePress.setScenePos(mouseEvent->scenePos());
never executed (the execution status of this line is deduced): mousePress.setScenePos(mouseEvent->scenePos());
-
1406 mousePress.setModifiers(mouseEvent->modifiers());
never executed (the execution status of this line is deduced): mousePress.setModifiers(mouseEvent->modifiers());
-
1407 mousePress.setWidget(mouseEvent->widget());
never executed (the execution status of this line is deduced): mousePress.setWidget(mouseEvent->widget());
-
1408 mousePress.setButtonDownPos(mouseEvent->button(),
never executed (the execution status of this line is deduced): mousePress.setButtonDownPos(mouseEvent->button(),
-
1409 mouseEvent->buttonDownPos(mouseEvent->button()));
never executed (the execution status of this line is deduced): mouseEvent->buttonDownPos(mouseEvent->button()));
-
1410 mousePress.setButtonDownScenePos(mouseEvent->button(),
never executed (the execution status of this line is deduced): mousePress.setButtonDownScenePos(mouseEvent->button(),
-
1411 mouseEvent->buttonDownScenePos(mouseEvent->button()));
never executed (the execution status of this line is deduced): mouseEvent->buttonDownScenePos(mouseEvent->button()));
-
1412 mousePress.setButtonDownScreenPos(mouseEvent->button(),
never executed (the execution status of this line is deduced): mousePress.setButtonDownScreenPos(mouseEvent->button(),
-
1413 mouseEvent->buttonDownScreenPos(mouseEvent->button()));
never executed (the execution status of this line is deduced): mouseEvent->buttonDownScreenPos(mouseEvent->button()));
-
1414 sendMouseEvent(&mousePress);
never executed (the execution status of this line is deduced): sendMouseEvent(&mousePress);
-
1415 mouseEvent->setAccepted(mousePress.isAccepted());
never executed (the execution status of this line is deduced): mouseEvent->setAccepted(mousePress.isAccepted());
-
1416 } else {
never executed: }
0
1417 sendMouseEvent(mouseEvent);
executed (the execution status of this line is deduced): sendMouseEvent(mouseEvent);
-
1418 }
executed: }
Execution Count:2
2
1419 -
1420 bool dontSendUngrabEvents = mouseGrabberItems.isEmpty() || mouseGrabberItems.last() != item;
partially evaluated: mouseGrabberItems.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
partially evaluated: mouseGrabberItems.last() != item
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1421 if (disabled) {
partially evaluated: disabled
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1422 ungrabMouse(item, /* itemIsDying = */ dontSendUngrabEvents);
never executed (the execution status of this line is deduced): ungrabMouse(item, dontSendUngrabEvents);
-
1423 break;
never executed: break;
0
1424 } -
1425 if (mouseEvent->isAccepted()) {
partially evaluated: mouseEvent->isAccepted()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1426 if (!mouseGrabberItems.isEmpty())
partially evaluated: !mouseGrabberItems.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1427 storeMouseButtonsForMouseGrabber(mouseEvent);
executed: storeMouseButtonsForMouseGrabber(mouseEvent);
Execution Count:2
2
1428 lastMouseGrabberItem = item;
executed (the execution status of this line is deduced): lastMouseGrabberItem = item;
-
1429 return;
executed: return;
Execution Count:2
2
1430 } -
1431 ungrabMouse(item, /* itemIsDying = */ dontSendUngrabEvents);
never executed (the execution status of this line is deduced): ungrabMouse(item, dontSendUngrabEvents);
-
1432 -
1433 // Don't propagate through panels. -
1434 if (isPanel)
never evaluated: isPanel
0
1435 break;
never executed: break;
0
1436 }
never executed: }
0
1437 -
1438 // Is the event still ignored? Then the mouse press goes to the scene. -
1439 // Reset the mouse grabber, clear the selection, clear focus, and leave -
1440 // the event ignored so that it can propagate through the originating -
1441 // view. -
1442 if (!mouseEvent->isAccepted()) {
never evaluated: !mouseEvent->isAccepted()
0
1443 clearMouseGrabber();
never executed (the execution status of this line is deduced): clearMouseGrabber();
-
1444 -
1445 QGraphicsView *view = mouseEvent->widget() ? qobject_cast<QGraphicsView *>(mouseEvent->widget()->parentWidget()) : 0;
never evaluated: mouseEvent->widget()
0
1446 bool dontClearSelection = view && view->dragMode() == QGraphicsView::ScrollHandDrag;
never evaluated: view
never evaluated: view->dragMode() == QGraphicsView::ScrollHandDrag
0
1447 if (!dontClearSelection) {
never evaluated: !dontClearSelection
0
1448 // Clear the selection if the originating view isn't in scroll -
1449 // hand drag mode. The view will clear the selection if no drag -
1450 // happened. -
1451 q->clearSelection();
never executed (the execution status of this line is deduced): q->clearSelection();
-
1452 }
never executed: }
0
1453 }
never executed: }
0
1454}
never executed: }
0
1455 -
1456/*! -
1457 \internal -
1458 -
1459 Ensures that the list of toplevels is sorted by insertion order, and that -
1460 the siblingIndexes are packed (no gaps), and start at 0. -
1461 -
1462 ### This function is almost identical to -
1463 QGraphicsItemPrivate::ensureSequentialSiblingIndex(). -
1464*/ -
1465void QGraphicsScenePrivate::ensureSequentialTopLevelSiblingIndexes() -
1466{ -
1467 if (!topLevelSequentialOrdering) {
never evaluated: !topLevelSequentialOrdering
0
1468 std::sort(topLevelItems.begin(), topLevelItems.end(), QGraphicsItemPrivate::insertionOrder);
never executed (the execution status of this line is deduced): std::sort(topLevelItems.begin(), topLevelItems.end(), QGraphicsItemPrivate::insertionOrder);
-
1469 topLevelSequentialOrdering = true;
never executed (the execution status of this line is deduced): topLevelSequentialOrdering = true;
-
1470 needSortTopLevelItems = 1;
never executed (the execution status of this line is deduced): needSortTopLevelItems = 1;
-
1471 }
never executed: }
0
1472 if (holesInTopLevelSiblingIndex) {
never evaluated: holesInTopLevelSiblingIndex
0
1473 holesInTopLevelSiblingIndex = 0;
never executed (the execution status of this line is deduced): holesInTopLevelSiblingIndex = 0;
-
1474 for (int i = 0; i < topLevelItems.size(); ++i)
never evaluated: i < topLevelItems.size()
0
1475 topLevelItems[i]->d_ptr->siblingIndex = i;
never executed: topLevelItems[i]->d_ptr->siblingIndex = i;
0
1476 }
never executed: }
0
1477}
never executed: }
0
1478 -
1479/*! -
1480 \internal -
1481 -
1482 Set the font and propagate the changes if the font is different from the -
1483 current font. -
1484*/ -
1485void QGraphicsScenePrivate::setFont_helper(const QFont &font) -
1486{ -
1487 if (this->font == font && this->font.resolve() == font.resolve())
never evaluated: this->font == font
never evaluated: this->font.resolve() == font.resolve()
0
1488 return;
never executed: return;
0
1489 updateFont(font);
never executed (the execution status of this line is deduced): updateFont(font);
-
1490}
never executed: }
0
1491 -
1492/*! -
1493 \internal -
1494 -
1495 Resolve the scene's font against the application font, and propagate the -
1496 changes too all items in the scene. -
1497*/ -
1498void QGraphicsScenePrivate::resolveFont() -
1499{ -
1500 QFont naturalFont = QApplication::font();
never executed (the execution status of this line is deduced): QFont naturalFont = QApplication::font();
-
1501 naturalFont.resolve(0);
never executed (the execution status of this line is deduced): naturalFont.resolve(0);
-
1502 QFont resolvedFont = font.resolve(naturalFont);
never executed (the execution status of this line is deduced): QFont resolvedFont = font.resolve(naturalFont);
-
1503 updateFont(resolvedFont);
never executed (the execution status of this line is deduced): updateFont(resolvedFont);
-
1504}
never executed: }
0
1505 -
1506/*! -
1507 \internal -
1508 -
1509 Update the font, and whether or not it has changed, reresolve all fonts in -
1510 the scene. -
1511*/ -
1512void QGraphicsScenePrivate::updateFont(const QFont &font) -
1513{ -
1514 Q_Q(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScene * const q = q_func();
-
1515 -
1516 // Update local font setting. -
1517 this->font = font;
never executed (the execution status of this line is deduced): this->font = font;
-
1518 -
1519 // Resolve the fonts of all top-level widget items, or widget items -
1520 // whose parent is not a widget. -
1521 foreach (QGraphicsItem *item, q->items()) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(q->items())> _container_(q->items()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
1522 if (!item->parentItem()) {
never evaluated: !item->parentItem()
0
1523 // Resolvefont for an item is a noop operation, but -
1524 // every item can be a widget, or can have a widget -
1525 // childre. -
1526 item->d_ptr->resolveFont(font.resolve());
never executed (the execution status of this line is deduced): item->d_ptr->resolveFont(font.resolve());
-
1527 }
never executed: }
0
1528 }
never executed: }
0
1529 -
1530 // Send the scene a FontChange event. -
1531 QEvent event(QEvent::FontChange);
never executed (the execution status of this line is deduced): QEvent event(QEvent::FontChange);
-
1532 QApplication::sendEvent(q, &event);
never executed (the execution status of this line is deduced): QApplication::sendEvent(q, &event);
-
1533}
never executed: }
0
1534 -
1535/*! -
1536 \internal -
1537 -
1538 Set the palette and propagate the changes if the palette is different from -
1539 the current palette. -
1540*/ -
1541void QGraphicsScenePrivate::setPalette_helper(const QPalette &palette) -
1542{ -
1543 if (this->palette == palette && this->palette.resolve() == palette.resolve())
never evaluated: this->palette == palette
never evaluated: this->palette.resolve() == palette.resolve()
0
1544 return;
never executed: return;
0
1545 updatePalette(palette);
never executed (the execution status of this line is deduced): updatePalette(palette);
-
1546}
never executed: }
0
1547 -
1548/*! -
1549 \internal -
1550 -
1551 Resolve the scene's palette against the application palette, and propagate -
1552 the changes too all items in the scene. -
1553*/ -
1554void QGraphicsScenePrivate::resolvePalette() -
1555{ -
1556 QPalette naturalPalette = QApplication::palette();
never executed (the execution status of this line is deduced): QPalette naturalPalette = QApplication::palette();
-
1557 naturalPalette.resolve(0);
never executed (the execution status of this line is deduced): naturalPalette.resolve(0);
-
1558 QPalette resolvedPalette = palette.resolve(naturalPalette);
never executed (the execution status of this line is deduced): QPalette resolvedPalette = palette.resolve(naturalPalette);
-
1559 updatePalette(resolvedPalette);
never executed (the execution status of this line is deduced): updatePalette(resolvedPalette);
-
1560}
never executed: }
0
1561 -
1562/*! -
1563 \internal -
1564 -
1565 Update the palette, and whether or not it has changed, reresolve all -
1566 palettes in the scene. -
1567*/ -
1568void QGraphicsScenePrivate::updatePalette(const QPalette &palette) -
1569{ -
1570 Q_Q(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScene * const q = q_func();
-
1571 -
1572 // Update local palette setting. -
1573 this->palette = palette;
never executed (the execution status of this line is deduced): this->palette = palette;
-
1574 -
1575 // Resolve the palettes of all top-level widget items, or widget items -
1576 // whose parent is not a widget. -
1577 foreach (QGraphicsItem *item, q->items()) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(q->items())> _container_(q->items()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
1578 if (!item->parentItem()) {
never evaluated: !item->parentItem()
0
1579 // Resolvefont for an item is a noop operation, but -
1580 // every item can be a widget, or can have a widget -
1581 // childre. -
1582 item->d_ptr->resolvePalette(palette.resolve());
never executed (the execution status of this line is deduced): item->d_ptr->resolvePalette(palette.resolve());
-
1583 }
never executed: }
0
1584 }
never executed: }
0
1585 -
1586 // Send the scene a PaletteChange event. -
1587 QEvent event(QEvent::PaletteChange);
never executed (the execution status of this line is deduced): QEvent event(QEvent::PaletteChange);
-
1588 QApplication::sendEvent(q, &event);
never executed (the execution status of this line is deduced): QApplication::sendEvent(q, &event);
-
1589}
never executed: }
0
1590 -
1591/*! -
1592 Constructs a QGraphicsScene object. The \a parent parameter is -
1593 passed to QObject's constructor. -
1594*/ -
1595QGraphicsScene::QGraphicsScene(QObject *parent) -
1596 : QObject(*new QGraphicsScenePrivate, parent) -
1597{ -
1598 d_func()->init();
executed (the execution status of this line is deduced): d_func()->init();
-
1599}
executed: }
Execution Count:233
233
1600 -
1601/*! -
1602 Constructs a QGraphicsScene object, using \a sceneRect for its -
1603 scene rectangle. The \a parent parameter is passed to QObject's -
1604 constructor. -
1605 -
1606 \sa sceneRect -
1607*/ -
1608QGraphicsScene::QGraphicsScene(const QRectF &sceneRect, QObject *parent) -
1609 : QObject(*new QGraphicsScenePrivate, parent) -
1610{ -
1611 d_func()->init();
never executed (the execution status of this line is deduced): d_func()->init();
-
1612 setSceneRect(sceneRect);
never executed (the execution status of this line is deduced): setSceneRect(sceneRect);
-
1613}
never executed: }
0
1614 -
1615/*! -
1616 Constructs a QGraphicsScene object, using the rectangle specified -
1617 by (\a x, \a y), and the given \a width and \a height for its -
1618 scene rectangle. The \a parent parameter is passed to QObject's -
1619 constructor. -
1620 -
1621 \sa sceneRect -
1622*/ -
1623QGraphicsScene::QGraphicsScene(qreal x, qreal y, qreal width, qreal height, QObject *parent) -
1624 : QObject(*new QGraphicsScenePrivate, parent) -
1625{ -
1626 d_func()->init();
never executed (the execution status of this line is deduced): d_func()->init();
-
1627 setSceneRect(x, y, width, height);
never executed (the execution status of this line is deduced): setSceneRect(x, y, width, height);
-
1628}
never executed: }
0
1629 -
1630/*! -
1631 Removes and deletes all items from the scene object -
1632 before destroying the scene object. The scene object -
1633 is removed from the application's global scene list, -
1634 and it is removed from all associated views. -
1635*/ -
1636QGraphicsScene::~QGraphicsScene() -
1637{ -
1638 Q_D(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
1639 -
1640 // Remove this scene from qApp's global scene list. -
1641 if (!QApplicationPrivate::is_app_closing)
partially evaluated: !QApplicationPrivate::is_app_closing
TRUEFALSE
yes
Evaluation Count:221
no
Evaluation Count:0
0-221
1642 qApp->d_func()->scene_list.removeAll(this);
executed: (static_cast<QApplication *>(QCoreApplication::instance()))->d_func()->scene_list.removeAll(this);
Execution Count:221
221
1643 -
1644 clear();
executed (the execution status of this line is deduced): clear();
-
1645 -
1646 // Remove this scene from all associated views. -
1647 for (int j = 0; j < d->views.size(); ++j)
evaluated: j < d->views.size()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:221
3-221
1648 d->views.at(j)->setScene(0);
executed: d->views.at(j)->setScene(0);
Execution Count:3
3
1649}
executed: }
Execution Count:221
221
1650 -
1651/*! -
1652 \property QGraphicsScene::sceneRect -
1653 \brief the scene rectangle; the bounding rectangle of the scene -
1654 -
1655 The scene rectangle defines the extent of the scene. It is -
1656 primarily used by QGraphicsView to determine the view's default -
1657 scrollable area, and by QGraphicsScene to manage item indexing. -
1658 -
1659 If unset, or if set to a null QRectF, sceneRect() will return the largest -
1660 bounding rect of all items on the scene since the scene was created (i.e., -
1661 a rectangle that grows when items are added to or moved in the scene, but -
1662 never shrinks). -
1663 -
1664 \sa width(), height(), QGraphicsView::sceneRect -
1665*/ -
1666QRectF QGraphicsScene::sceneRect() const -
1667{ -
1668 Q_D(const QGraphicsScene);
executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
1669 if (d->hasSceneRect)
evaluated: d->hasSceneRect
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:1262
11-1262
1670 return d->sceneRect;
executed: return d->sceneRect;
Execution Count:11
11
1671 -
1672 if (d->dirtyGrowingItemsBoundingRect) {
evaluated: d->dirtyGrowingItemsBoundingRect
TRUEFALSE
yes
Evaluation Count:480
yes
Evaluation Count:782
480-782
1673 // Lazily update the growing items bounding rect -
1674 QGraphicsScenePrivate *thatd = const_cast<QGraphicsScenePrivate *>(d);
executed (the execution status of this line is deduced): QGraphicsScenePrivate *thatd = const_cast<QGraphicsScenePrivate *>(d);
-
1675 QRectF oldGrowingBoundingRect = thatd->growingItemsBoundingRect;
executed (the execution status of this line is deduced): QRectF oldGrowingBoundingRect = thatd->growingItemsBoundingRect;
-
1676 thatd->growingItemsBoundingRect |= itemsBoundingRect();
executed (the execution status of this line is deduced): thatd->growingItemsBoundingRect |= itemsBoundingRect();
-
1677 thatd->dirtyGrowingItemsBoundingRect = false;
executed (the execution status of this line is deduced): thatd->dirtyGrowingItemsBoundingRect = false;
-
1678 if (oldGrowingBoundingRect != thatd->growingItemsBoundingRect)
evaluated: oldGrowingBoundingRect != thatd->growingItemsBoundingRect
TRUEFALSE
yes
Evaluation Count:174
yes
Evaluation Count:306
174-306
1679 emit const_cast<QGraphicsScene *>(this)->sceneRectChanged(thatd->growingItemsBoundingRect);
executed: const_cast<QGraphicsScene *>(this)->sceneRectChanged(thatd->growingItemsBoundingRect);
Execution Count:174
174
1680 }
executed: }
Execution Count:480
480
1681 return d->growingItemsBoundingRect;
executed: return d->growingItemsBoundingRect;
Execution Count:1262
1262
1682} -
1683void QGraphicsScene::setSceneRect(const QRectF &rect) -
1684{ -
1685 Q_D(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
1686 if (rect != d->sceneRect) {
partially evaluated: rect != d->sceneRect
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1687 d->hasSceneRect = !rect.isNull();
executed (the execution status of this line is deduced): d->hasSceneRect = !rect.isNull();
-
1688 d->sceneRect = rect;
executed (the execution status of this line is deduced): d->sceneRect = rect;
-
1689 emit sceneRectChanged(d->hasSceneRect ? rect : d->growingItemsBoundingRect);
executed (the execution status of this line is deduced): sceneRectChanged(d->hasSceneRect ? rect : d->growingItemsBoundingRect);
-
1690 }
executed: }
Execution Count:2
2
1691}
executed: }
Execution Count:2
2
1692 -
1693/*! -
1694 \fn qreal QGraphicsScene::width() const -
1695 -
1696 This convenience function is equivalent to calling sceneRect().width(). -
1697 -
1698 \sa height() -
1699*/ -
1700 -
1701/*! -
1702 \fn qreal QGraphicsScene::height() const -
1703 -
1704 This convenience function is equivalent to calling \c sceneRect().height(). -
1705 -
1706 \sa width() -
1707*/ -
1708 -
1709/*! -
1710 Renders the \a source rect from scene into \a target, using \a painter. This -
1711 function is useful for capturing the contents of the scene onto a paint -
1712 device, such as a QImage (e.g., to take a screenshot), or for printing -
1713 with QPrinter. For example: -
1714 -
1715 \snippet code/src_gui_graphicsview_qgraphicsscene.cpp 1 -
1716 -
1717 If \a source is a null rect, this function will use sceneRect() to -
1718 determine what to render. If \a target is a null rect, the dimensions of \a -
1719 painter's paint device will be used. -
1720 -
1721 The source rect contents will be transformed according to \a -
1722 aspectRatioMode to fit into the target rect. By default, the aspect ratio -
1723 is kept, and \a source is scaled to fit in \a target. -
1724 -
1725 \sa QGraphicsView::render() -
1726*/ -
1727void QGraphicsScene::render(QPainter *painter, const QRectF &target, const QRectF &source, -
1728 Qt::AspectRatioMode aspectRatioMode) -
1729{ -
1730 // ### Switch to using the recursive rendering algorithm instead. -
1731 -
1732 // Default source rect = scene rect -
1733 QRectF sourceRect = source;
executed (the execution status of this line is deduced): QRectF sourceRect = source;
-
1734 if (sourceRect.isNull())
partially evaluated: sourceRect.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
1735 sourceRect = sceneRect();
never executed: sourceRect = sceneRect();
0
1736 -
1737 // Default target rect = device rect -
1738 QRectF targetRect = target;
executed (the execution status of this line is deduced): QRectF targetRect = target;
-
1739 if (targetRect.isNull()) {
partially evaluated: targetRect.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
1740 if (painter->device()->devType() == QInternal::Picture)
never evaluated: painter->device()->devType() == QInternal::Picture
0
1741 targetRect = sourceRect;
never executed: targetRect = sourceRect;
0
1742 else -
1743 targetRect.setRect(0, 0, painter->device()->width(), painter->device()->height());
never executed: targetRect.setRect(0, 0, painter->device()->width(), painter->device()->height());
0
1744 } -
1745 -
1746 // Find the ideal x / y scaling ratio to fit \a source into \a target. -
1747 qreal xratio = targetRect.width() / sourceRect.width();
executed (the execution status of this line is deduced): qreal xratio = targetRect.width() / sourceRect.width();
-
1748 qreal yratio = targetRect.height() / sourceRect.height();
executed (the execution status of this line is deduced): qreal yratio = targetRect.height() / sourceRect.height();
-
1749 -
1750 // Scale according to the aspect ratio mode. -
1751 switch (aspectRatioMode) { -
1752 case Qt::KeepAspectRatio: -
1753 xratio = yratio = qMin(xratio, yratio);
executed (the execution status of this line is deduced): xratio = yratio = qMin(xratio, yratio);
-
1754 break;
executed: break;
Execution Count:7
7
1755 case Qt::KeepAspectRatioByExpanding: -
1756 xratio = yratio = qMax(xratio, yratio);
never executed (the execution status of this line is deduced): xratio = yratio = qMax(xratio, yratio);
-
1757 break;
never executed: break;
0
1758 case Qt::IgnoreAspectRatio: -
1759 break;
never executed: break;
0
1760 } -
1761 -
1762 // Find all items to draw, and reverse the list (we want to draw -
1763 // in reverse order). -
1764 QList<QGraphicsItem *> itemList = items(sourceRect, Qt::IntersectsItemBoundingRect);
executed (the execution status of this line is deduced): QList<QGraphicsItem *> itemList = items(sourceRect, Qt::IntersectsItemBoundingRect);
-
1765 QGraphicsItem **itemArray = new QGraphicsItem *[itemList.size()];
executed (the execution status of this line is deduced): QGraphicsItem **itemArray = new QGraphicsItem *[itemList.size()];
-
1766 int numItems = itemList.size();
executed (the execution status of this line is deduced): int numItems = itemList.size();
-
1767 for (int i = 0; i < numItems; ++i)
evaluated: i < numItems
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:7
7
1768 itemArray[numItems - i - 1] = itemList.at(i);
executed: itemArray[numItems - i - 1] = itemList.at(i);
Execution Count:7
7
1769 itemList.clear();
executed (the execution status of this line is deduced): itemList.clear();
-
1770 -
1771 painter->save();
executed (the execution status of this line is deduced): painter->save();
-
1772 -
1773 // Transform the painter. -
1774 painter->setClipRect(targetRect, Qt::IntersectClip);
executed (the execution status of this line is deduced): painter->setClipRect(targetRect, Qt::IntersectClip);
-
1775 QTransform painterTransform;
executed (the execution status of this line is deduced): QTransform painterTransform;
-
1776 painterTransform *= QTransform()
executed (the execution status of this line is deduced): painterTransform *= QTransform()
-
1777 .translate(targetRect.left(), targetRect.top())
executed (the execution status of this line is deduced): .translate(targetRect.left(), targetRect.top())
-
1778 .scale(xratio, yratio)
executed (the execution status of this line is deduced): .scale(xratio, yratio)
-
1779 .translate(-sourceRect.left(), -sourceRect.top());
executed (the execution status of this line is deduced): .translate(-sourceRect.left(), -sourceRect.top());
-
1780 painter->setWorldTransform(painterTransform, true);
executed (the execution status of this line is deduced): painter->setWorldTransform(painterTransform, true);
-
1781 -
1782 // Two unit vectors. -
1783 QLineF v1(0, 0, 1, 0);
executed (the execution status of this line is deduced): QLineF v1(0, 0, 1, 0);
-
1784 QLineF v2(0, 0, 0, 1);
executed (the execution status of this line is deduced): QLineF v2(0, 0, 0, 1);
-
1785 -
1786 // Generate the style options -
1787 QStyleOptionGraphicsItem *styleOptionArray = new QStyleOptionGraphicsItem[numItems];
executed (the execution status of this line is deduced): QStyleOptionGraphicsItem *styleOptionArray = new QStyleOptionGraphicsItem[numItems];
-
1788 for (int i = 0; i < numItems; ++i)
evaluated: i < numItems
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:7
7
1789 itemArray[i]->d_ptr->initStyleOption(&styleOptionArray[i], painterTransform, targetRect.toRect());
executed: itemArray[i]->d_ptr->initStyleOption(&styleOptionArray[i], painterTransform, targetRect.toRect());
Execution Count:7
7
1790 -
1791 // Render the scene. -
1792 drawBackground(painter, sourceRect);
executed (the execution status of this line is deduced): drawBackground(painter, sourceRect);
-
1793 drawItems(painter, numItems, itemArray, styleOptionArray);
executed (the execution status of this line is deduced): drawItems(painter, numItems, itemArray, styleOptionArray);
-
1794 drawForeground(painter, sourceRect);
executed (the execution status of this line is deduced): drawForeground(painter, sourceRect);
-
1795 -
1796 delete [] itemArray;
executed (the execution status of this line is deduced): delete [] itemArray;
-
1797 delete [] styleOptionArray;
executed (the execution status of this line is deduced): delete [] styleOptionArray;
-
1798 -
1799 painter->restore();
executed (the execution status of this line is deduced): painter->restore();
-
1800}
executed: }
Execution Count:7
7
1801 -
1802/*! -
1803 \property QGraphicsScene::itemIndexMethod -
1804 \brief the item indexing method. -
1805 -
1806 QGraphicsScene applies an indexing algorithm to the scene, to speed up -
1807 item discovery functions like items() and itemAt(). Indexing is most -
1808 efficient for static scenes (i.e., where items don't move around). For -
1809 dynamic scenes, or scenes with many animated items, the index bookkeeping -
1810 can outweight the fast lookup speeds. -
1811 -
1812 For the common case, the default index method BspTreeIndex works fine. If -
1813 your scene uses many animations and you are experiencing slowness, you can -
1814 disable indexing by calling \c setItemIndexMethod(NoIndex). -
1815 -
1816 \sa bspTreeDepth -
1817*/ -
1818QGraphicsScene::ItemIndexMethod QGraphicsScene::itemIndexMethod() const -
1819{ -
1820 Q_D(const QGraphicsScene);
never executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
1821 return d->indexMethod;
never executed: return d->indexMethod;
0
1822} -
1823void QGraphicsScene::setItemIndexMethod(ItemIndexMethod method) -
1824{ -
1825 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
1826 if (d->indexMethod == method)
never evaluated: d->indexMethod == method
0
1827 return;
never executed: return;
0
1828 -
1829 d->indexMethod = method;
never executed (the execution status of this line is deduced): d->indexMethod = method;
-
1830 -
1831 QList<QGraphicsItem *> oldItems = d->index->items(Qt::DescendingOrder);
never executed (the execution status of this line is deduced): QList<QGraphicsItem *> oldItems = d->index->items(Qt::DescendingOrder);
-
1832 delete d->index;
never executed (the execution status of this line is deduced): delete d->index;
-
1833 if (method == BspTreeIndex)
never evaluated: method == BspTreeIndex
0
1834 d->index = new QGraphicsSceneBspTreeIndex(this);
never executed: d->index = new QGraphicsSceneBspTreeIndex(this);
0
1835 else -
1836 d->index = new QGraphicsSceneLinearIndex(this);
never executed: d->index = new QGraphicsSceneLinearIndex(this);
0
1837 for (int i = oldItems.size() - 1; i >= 0; --i)
never evaluated: i >= 0
0
1838 d->index->addItem(oldItems.at(i));
never executed: d->index->addItem(oldItems.at(i));
0
1839}
never executed: }
0
1840 -
1841/*! -
1842 \property QGraphicsScene::bspTreeDepth -
1843 \brief the depth of QGraphicsScene's BSP index tree -
1844 \since 4.3 -
1845 -
1846 This property has no effect when NoIndex is used. -
1847 -
1848 This value determines the depth of QGraphicsScene's BSP tree. The depth -
1849 directly affects QGraphicsScene's performance and memory usage; the latter -
1850 growing exponentially with the depth of the tree. With an optimal tree -
1851 depth, QGraphicsScene can instantly determine the locality of items, even -
1852 for scenes with thousands or millions of items. This also greatly improves -
1853 rendering performance. -
1854 -
1855 By default, the value is 0, in which case Qt will guess a reasonable -
1856 default depth based on the size, location and number of items in the -
1857 scene. If these parameters change frequently, however, you may experience -
1858 slowdowns as QGraphicsScene retunes the depth internally. You can avoid -
1859 potential slowdowns by fixating the tree depth through setting this -
1860 property. -
1861 -
1862 The depth of the tree and the size of the scene rectangle decide the -
1863 granularity of the scene's partitioning. The size of each scene segment is -
1864 determined by the following algorithm: -
1865 -
1866 \snippet code/src_gui_graphicsview_qgraphicsscene.cpp 2 -
1867 -
1868 The BSP tree has an optimal size when each segment contains between 0 and -
1869 10 items. -
1870 -
1871 \sa itemIndexMethod -
1872*/ -
1873int QGraphicsScene::bspTreeDepth() const -
1874{ -
1875 Q_D(const QGraphicsScene);
never executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
1876 QGraphicsSceneBspTreeIndex *bspTree = qobject_cast<QGraphicsSceneBspTreeIndex *>(d->index);
never executed (the execution status of this line is deduced): QGraphicsSceneBspTreeIndex *bspTree = qobject_cast<QGraphicsSceneBspTreeIndex *>(d->index);
-
1877 return bspTree ? bspTree->bspTreeDepth() : 0;
never executed: return bspTree ? bspTree->bspTreeDepth() : 0;
0
1878} -
1879void QGraphicsScene::setBspTreeDepth(int depth) -
1880{ -
1881 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
1882 if (depth < 0) {
never evaluated: depth < 0
0
1883 qWarning("QGraphicsScene::setBspTreeDepth: invalid depth %d ignored; must be >= 0", depth);
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsscene.cpp", 1883, __PRETTY_FUNCTION__).warning("QGraphicsScene::setBspTreeDepth: invalid depth %d ignored; must be >= 0", depth);
-
1884 return;
never executed: return;
0
1885 } -
1886 -
1887 QGraphicsSceneBspTreeIndex *bspTree = qobject_cast<QGraphicsSceneBspTreeIndex *>(d->index);
never executed (the execution status of this line is deduced): QGraphicsSceneBspTreeIndex *bspTree = qobject_cast<QGraphicsSceneBspTreeIndex *>(d->index);
-
1888 if (!bspTree) {
never evaluated: !bspTree
0
1889 qWarning("QGraphicsScene::setBspTreeDepth: can not apply if indexing method is not BSP");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsscene.cpp", 1889, __PRETTY_FUNCTION__).warning("QGraphicsScene::setBspTreeDepth: can not apply if indexing method is not BSP");
-
1890 return;
never executed: return;
0
1891 } -
1892 bspTree->setBspTreeDepth(depth);
never executed (the execution status of this line is deduced): bspTree->setBspTreeDepth(depth);
-
1893}
never executed: }
0
1894 -
1895/*! -
1896 \property QGraphicsScene::sortCacheEnabled -
1897 \brief whether sort caching is enabled -
1898 \since 4.5 -
1899 \obsolete -
1900 -
1901 Since Qt 4.6, this property has no effect. -
1902*/ -
1903bool QGraphicsScene::isSortCacheEnabled() const -
1904{ -
1905 Q_D(const QGraphicsScene);
never executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
1906 return d->sortCacheEnabled;
never executed: return d->sortCacheEnabled;
0
1907} -
1908void QGraphicsScene::setSortCacheEnabled(bool enabled) -
1909{ -
1910 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
1911 if (d->sortCacheEnabled == enabled)
never evaluated: d->sortCacheEnabled == enabled
0
1912 return;
never executed: return;
0
1913 d->sortCacheEnabled = enabled;
never executed (the execution status of this line is deduced): d->sortCacheEnabled = enabled;
-
1914}
never executed: }
0
1915 -
1916/*! -
1917 Calculates and returns the bounding rect of all items on the scene. This -
1918 function works by iterating over all items, and because of this, it can -
1919 be slow for large scenes. -
1920 -
1921 \sa sceneRect() -
1922*/ -
1923QRectF QGraphicsScene::itemsBoundingRect() const -
1924{ -
1925 // Does not take untransformable items into account. -
1926 QRectF boundingRect;
executed (the execution status of this line is deduced): QRectF boundingRect;
-
1927 foreach (QGraphicsItem *item, items())
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(items())> _container_(items()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
1928 boundingRect |= item->sceneBoundingRect();
executed: boundingRect |= item->sceneBoundingRect();
Execution Count:1889
1889
1929 return boundingRect;
executed: return boundingRect;
Execution Count:598
598
1930} -
1931 -
1932/*! -
1933 Returns an ordered list of all items on the scene. \a order decides the -
1934 stacking order. -
1935 -
1936 \sa addItem(), removeItem(), {QGraphicsItem#Sorting}{Sorting} -
1937*/ -
1938QList<QGraphicsItem *> QGraphicsScene::items(Qt::SortOrder order) const -
1939{ -
1940 Q_D(const QGraphicsScene);
executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
1941 return d->index->items(order);
executed: return d->index->items(order);
Execution Count:643
643
1942} -
1943 -
1944/*! -
1945 \fn QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode) const -
1946 \obsolete -
1947 \since 4.3 -
1948 -
1949 This convenience function is equivalent to calling items(QRectF(\a x, \a y, \a w, \a h), \a mode). -
1950 -
1951 This function is deprecated and returns incorrect results if the scene -
1952 contains items that ignore transformations. Use the overload that takes -
1953 a QTransform instead. -
1954*/ -
1955 -
1956/*! -
1957 \fn QList<QGraphicsItem *> QGraphicsScene::items(qreal x, qreal y, qreal w, qreal h, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const -
1958 \overload -
1959 \since 4.6 -
1960 -
1961 \brief Returns all visible items that, depending on \a mode, are -
1962 either inside or intersect with the rectangle defined by \a x, \a y, -
1963 \a w and \a h, in a list sorted using \a order. In this case, "visible" defines items for which: -
1964 isVisible() returns true, effectiveOpacity() returns a value greater than 0.0 -
1965 (which is fully transparent) and the parent item does not clip it. -
1966 -
1967 \a deviceTransform is the transformation that applies to the view, and needs to -
1968 be provided if the scene contains items that ignore transformations. -
1969*/ -
1970 -
1971/*! -
1972 \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const -
1973 \since 4.6 -
1974 -
1975 \brief Returns all visible items that, depending on \a mode, are at -
1976 the specified \a pos in a list sorted using \a order. In this case, "visible" defines items for which: -
1977 isVisible() returns true, effectiveOpacity() returns a value greater than 0.0 -
1978 (which is fully transparent) and the parent item does not clip it. -
1979 -
1980 The default value for \a mode is Qt::IntersectsItemShape; all items whose -
1981 exact shape intersects with \a pos are returned. -
1982 -
1983 \a deviceTransform is the transformation that applies to the view, and needs to -
1984 be provided if the scene contains items that ignore transformations. -
1985 -
1986 \sa itemAt(), {QGraphicsItem#Sorting}{Sorting} -
1987*/ -
1988QList<QGraphicsItem *> QGraphicsScene::items(const QPointF &pos, Qt::ItemSelectionMode mode, -
1989 Qt::SortOrder order, const QTransform &deviceTransform) const -
1990{ -
1991 Q_D(const QGraphicsScene);
executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
1992 return d->index->items(pos, mode, order, deviceTransform);
executed: return d->index->items(pos, mode, order, deviceTransform);
Execution Count:67
67
1993} -
1994 -
1995/*! -
1996 \fn QList<QGraphicsItem *> QGraphicsScene::items(const QRectF &rect, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const -
1997 \overload -
1998 \since 4.6 -
1999 -
2000 \brief Returns all visible items that, depending on \a mode, are -
2001 either inside or intersect with the specified \a rect, in a -
2002 list sorted using \a order. In this case, "visible" defines items for which: -
2003 isVisible() returns true, effectiveOpacity() returns a value greater than 0.0 -
2004 (which is fully transparent) and the parent item does not clip it. -
2005 -
2006 The default value for \a mode is Qt::IntersectsItemShape; all items whose -
2007 exact shape intersects with or is contained by \a rect are returned. -
2008 -
2009 \a deviceTransform is the transformation that applies to the view, and needs to -
2010 be provided if the scene contains items that ignore transformations. -
2011 -
2012 \sa itemAt(), {QGraphicsItem#Sorting}{Sorting} -
2013*/ -
2014QList<QGraphicsItem *> QGraphicsScene::items(const QRectF &rect, Qt::ItemSelectionMode mode, -
2015 Qt::SortOrder order, const QTransform &deviceTransform) const -
2016{ -
2017 Q_D(const QGraphicsScene);
executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
2018 return d->index->items(rect, mode, order, deviceTransform);
executed: return d->index->items(rect, mode, order, deviceTransform);
Execution Count:9
9
2019} -
2020 -
2021/*! -
2022 \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const -
2023 \overload -
2024 \since 4.6 -
2025 -
2026 \brief Returns all visible items that, depending on \a mode, are -
2027 either inside or intersect with the specified \a polygon, in -
2028 a list sorted using \a order. In this case, "visible" defines items for which: -
2029 isVisible() returns true, effectiveOpacity() returns a value greater than 0.0 -
2030 (which is fully transparent) and the parent item does not clip it. -
2031 -
2032 The default value for \a mode is Qt::IntersectsItemShape; all items whose -
2033 exact shape intersects with or is contained by \a polygon are returned. -
2034 -
2035 \a deviceTransform is the transformation that applies to the view, and needs to -
2036 be provided if the scene contains items that ignore transformations. -
2037 -
2038 \sa itemAt(), {QGraphicsItem#Sorting}{Sorting} -
2039*/ -
2040QList<QGraphicsItem *> QGraphicsScene::items(const QPolygonF &polygon, Qt::ItemSelectionMode mode, -
2041 Qt::SortOrder order, const QTransform &deviceTransform) const -
2042{ -
2043 Q_D(const QGraphicsScene);
never executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
2044 return d->index->items(polygon, mode, order, deviceTransform);
never executed: return d->index->items(polygon, mode, order, deviceTransform);
0
2045} -
2046 -
2047/*! -
2048 \fn QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode, Qt::SortOrder order, const QTransform &deviceTransform) const -
2049 \overload -
2050 \since 4.6 -
2051 -
2052 \brief Returns all visible items that, depending on \a mode, are -
2053 either inside or intersect with the specified \a path, in a -
2054 list sorted using \a order. In this case, "visible" defines items for which: -
2055 isVisible() returns true, effectiveOpacity() returns a value greater than 0.0 -
2056 (which is fully transparent) and the parent item does not clip it. -
2057 -
2058 The default value for \a mode is Qt::IntersectsItemShape; all items whose -
2059 exact shape intersects with or is contained by \a path are returned. -
2060 -
2061 \a deviceTransform is the transformation that applies to the view, and needs to -
2062 be provided if the scene contains items that ignore transformations. -
2063 -
2064 \sa itemAt(), {QGraphicsItem#Sorting}{Sorting} -
2065*/ -
2066QList<QGraphicsItem *> QGraphicsScene::items(const QPainterPath &path, Qt::ItemSelectionMode mode, -
2067 Qt::SortOrder order, const QTransform &deviceTransform) const -
2068{ -
2069 Q_D(const QGraphicsScene);
never executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
2070 return d->index->items(path, mode, order, deviceTransform);
never executed: return d->index->items(path, mode, order, deviceTransform);
0
2071} -
2072 -
2073/*! -
2074 Returns a list of all items that collide with \a item. Collisions are -
2075 determined by calling QGraphicsItem::collidesWithItem(); the collision -
2076 detection is determined by \a mode. By default, all items whose shape -
2077 intersects \a item or is contained inside \a item's shape are returned. -
2078 -
2079 The items are returned in descending stacking order (i.e., the first item -
2080 in the list is the uppermost item, and the last item is the lowermost -
2081 item). -
2082 -
2083 \sa items(), itemAt(), QGraphicsItem::collidesWithItem(), {QGraphicsItem#Sorting}{Sorting} -
2084*/ -
2085QList<QGraphicsItem *> QGraphicsScene::collidingItems(const QGraphicsItem *item, -
2086 Qt::ItemSelectionMode mode) const -
2087{ -
2088 Q_D(const QGraphicsScene);
never executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
2089 if (!item) {
never evaluated: !item
0
2090 qWarning("QGraphicsScene::collidingItems: cannot find collisions for null item");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsscene.cpp", 2090, __PRETTY_FUNCTION__).warning("QGraphicsScene::collidingItems: cannot find collisions for null item");
-
2091 return QList<QGraphicsItem *>();
never executed: return QList<QGraphicsItem *>();
0
2092 } -
2093 -
2094 // Does not support ItemIgnoresTransformations. -
2095 QList<QGraphicsItem *> tmp;
never executed (the execution status of this line is deduced): QList<QGraphicsItem *> tmp;
-
2096 foreach (QGraphicsItem *itemInVicinity, d->index->estimateItems(item->sceneBoundingRect(), Qt::DescendingOrder)) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(d->index->estimateItems(item->sceneBoundingRect(), Qt::DescendingOrder))> _container_(d->index->estimateItems(item->sceneBoundingRect(), Qt::DescendingOrder)); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *itemInVicinity = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
2097 if (item != itemInVicinity && item->collidesWithItem(itemInVicinity, mode))
never evaluated: item != itemInVicinity
never evaluated: item->collidesWithItem(itemInVicinity, mode)
0
2098 tmp << itemInVicinity;
never executed: tmp << itemInVicinity;
0
2099 }
never executed: }
0
2100 return tmp;
never executed: return tmp;
0
2101} -
2102 -
2103/*! -
2104 \fn QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position) const -
2105 \overload -
2106 \obsolete -
2107 -
2108 Returns the topmost visible item at the specified \a position, or 0 if -
2109 there are no items at this position. -
2110 -
2111 This function is deprecated and returns incorrect results if the scene -
2112 contains items that ignore transformations. Use the overload that takes -
2113 a QTransform instead. -
2114 -
2115 Note: See items() for a definition of which items are considered visible by this function. -
2116 -
2117 \sa items(), collidingItems(), {QGraphicsItem#Sorting}{Sorting} -
2118*/ -
2119 -
2120/*! -
2121 \since 4.6 -
2122 -
2123 Returns the topmost visible item at the specified \a position, or 0 -
2124 if there are no items at this position. -
2125 -
2126 \a deviceTransform is the transformation that applies to the view, and needs to -
2127 be provided if the scene contains items that ignore transformations. -
2128 -
2129 Note: See items() for a definition of which items are considered visible by this function. -
2130 -
2131 \sa items(), collidingItems(), {QGraphicsItem#Sorting}{Sorting} -
2132*/ -
2133QGraphicsItem *QGraphicsScene::itemAt(const QPointF &position, const QTransform &deviceTransform) const -
2134{ -
2135 QList<QGraphicsItem *> itemsAtPoint = items(position, Qt::IntersectsItemShape,
never executed (the execution status of this line is deduced): QList<QGraphicsItem *> itemsAtPoint = items(position, Qt::IntersectsItemShape,
-
2136 Qt::DescendingOrder, deviceTransform);
never executed (the execution status of this line is deduced): Qt::DescendingOrder, deviceTransform);
-
2137 return itemsAtPoint.isEmpty() ? 0 : itemsAtPoint.first();
never executed: return itemsAtPoint.isEmpty() ? 0 : itemsAtPoint.first();
0
2138} -
2139 -
2140/*! -
2141 \fn QGraphicsScene::itemAt(qreal x, qreal y, const QTransform &deviceTransform) const -
2142 \overload -
2143 \since 4.6 -
2144 -
2145 Returns the topmost visible item at the position specified by (\a x, \a -
2146 y), or 0 if there are no items at this position. -
2147 -
2148 \a deviceTransform is the transformation that applies to the view, and needs to -
2149 be provided if the scene contains items that ignore transformations. -
2150 -
2151 This convenience function is equivalent to calling \c -
2152 {itemAt(QPointF(x, y), deviceTransform)}. -
2153 -
2154 Note: See items() for a definition of which items are considered visible by this function. -
2155*/ -
2156 -
2157/*! -
2158 \fn QGraphicsScene::itemAt(qreal x, qreal y) const -
2159 \overload -
2160 \obsolete -
2161 -
2162 Returns the topmost visible item at the position specified by (\a x, \a -
2163 y), or 0 if there are no items at this position. -
2164 -
2165 This convenience function is equivalent to calling \c -
2166 {itemAt(QPointF(x, y))}. -
2167 -
2168 This function is deprecated and returns incorrect results if the scene -
2169 contains items that ignore transformations. Use the overload that takes -
2170 a QTransform instead. -
2171 -
2172 Note: See items() for a definition of which items are considered visible by this function. -
2173*/ -
2174 -
2175/*! -
2176 Returns a list of all currently selected items. The items are -
2177 returned in no particular order. -
2178 -
2179 \sa setSelectionArea() -
2180*/ -
2181QList<QGraphicsItem *> QGraphicsScene::selectedItems() const -
2182{ -
2183 Q_D(const QGraphicsScene);
never executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
2184 -
2185 // Optimization: Lazily removes items that are not selected. -
2186 QGraphicsScene *that = const_cast<QGraphicsScene *>(this);
never executed (the execution status of this line is deduced): QGraphicsScene *that = const_cast<QGraphicsScene *>(this);
-
2187 QSet<QGraphicsItem *> actuallySelectedSet;
never executed (the execution status of this line is deduced): QSet<QGraphicsItem *> actuallySelectedSet;
-
2188 foreach (QGraphicsItem *item, that->d_func()->selectedItems) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(that->d_func()->selectedItems)> _container_(that->d_func()->selectedItems); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
2189 if (item->isSelected())
never evaluated: item->isSelected()
0
2190 actuallySelectedSet << item;
never executed: actuallySelectedSet << item;
0
2191 }
never executed: }
0
2192 -
2193 that->d_func()->selectedItems = actuallySelectedSet;
never executed (the execution status of this line is deduced): that->d_func()->selectedItems = actuallySelectedSet;
-
2194 -
2195 return d->selectedItems.values();
never executed: return d->selectedItems.values();
0
2196} -
2197 -
2198/*! -
2199 Returns the selection area that was previously set with -
2200 setSelectionArea(), or an empty QPainterPath if no selection area has been -
2201 set. -
2202 -
2203 \sa setSelectionArea() -
2204*/ -
2205QPainterPath QGraphicsScene::selectionArea() const -
2206{ -
2207 Q_D(const QGraphicsScene);
never executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
2208 return d->selectionArea;
never executed: return d->selectionArea;
0
2209} -
2210 -
2211/*! -
2212 \since 4.6 -
2213 -
2214 Sets the selection area to \a path. All items within this area are -
2215 immediately selected, and all items outside are unselected. You can get -
2216 the list of all selected items by calling selectedItems(). -
2217 -
2218 \a deviceTransform is the transformation that applies to the view, and needs to -
2219 be provided if the scene contains items that ignore transformations. -
2220 -
2221 For an item to be selected, it must be marked as \e selectable -
2222 (QGraphicsItem::ItemIsSelectable). -
2223 -
2224 \sa clearSelection(), selectionArea() -
2225*/ -
2226void QGraphicsScene::setSelectionArea(const QPainterPath &path, const QTransform &deviceTransform) -
2227{ -
2228 setSelectionArea(path, Qt::IntersectsItemShape, deviceTransform);
never executed (the execution status of this line is deduced): setSelectionArea(path, Qt::IntersectsItemShape, deviceTransform);
-
2229}
never executed: }
0
2230 -
2231/*! -
2232 \overload -
2233 \since 4.6 -
2234 -
2235 Sets the selection area to \a path using \a mode to determine if items are -
2236 included in the selection area. -
2237 -
2238 \a deviceTransform is the transformation that applies to the view, and needs to -
2239 be provided if the scene contains items that ignore transformations. -
2240 -
2241 \sa clearSelection(), selectionArea() -
2242*/ -
2243void QGraphicsScene::setSelectionArea(const QPainterPath &path, Qt::ItemSelectionMode mode, -
2244 const QTransform &deviceTransform) -
2245{ -
2246 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
2247 -
2248 // Note: with boolean path operations, we can improve performance here -
2249 // quite a lot by "growing" the old path instead of replacing it. That -
2250 // allows us to only check the intersect area for changes, instead of -
2251 // reevaluating the whole path over again. -
2252 d->selectionArea = path;
never executed (the execution status of this line is deduced): d->selectionArea = path;
-
2253 -
2254 QSet<QGraphicsItem *> unselectItems = d->selectedItems;
never executed (the execution status of this line is deduced): QSet<QGraphicsItem *> unselectItems = d->selectedItems;
-
2255 -
2256 // Disable emitting selectionChanged() for individual items. -
2257 ++d->selectionChanging;
never executed (the execution status of this line is deduced): ++d->selectionChanging;
-
2258 bool changed = false;
never executed (the execution status of this line is deduced): bool changed = false;
-
2259 -
2260 // Set all items in path to selected. -
2261 foreach (QGraphicsItem *item, items(path, mode, Qt::DescendingOrder, deviceTransform)) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(items(path, mode, Qt::DescendingOrder, deviceTransform))> _container_(items(path, mode, Qt::DescendingOrder, deviceTransform)); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
2262 if (item->flags() & QGraphicsItem::ItemIsSelectable) {
never evaluated: item->flags() & QGraphicsItem::ItemIsSelectable
0
2263 if (!item->isSelected())
never evaluated: !item->isSelected()
0
2264 changed = true;
never executed: changed = true;
0
2265 unselectItems.remove(item);
never executed (the execution status of this line is deduced): unselectItems.remove(item);
-
2266 item->setSelected(true);
never executed (the execution status of this line is deduced): item->setSelected(true);
-
2267 }
never executed: }
0
2268 }
never executed: }
0
2269 -
2270 // Unselect all items outside path. -
2271 foreach (QGraphicsItem *item, unselectItems) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(unselectItems)> _container_(unselectItems); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
2272 item->setSelected(false);
never executed (the execution status of this line is deduced): item->setSelected(false);
-
2273 changed = true;
never executed (the execution status of this line is deduced): changed = true;
-
2274 }
never executed: }
0
2275 -
2276 // Reenable emitting selectionChanged() for individual items. -
2277 --d->selectionChanging;
never executed (the execution status of this line is deduced): --d->selectionChanging;
-
2278 -
2279 if (!d->selectionChanging && changed)
never evaluated: !d->selectionChanging
never evaluated: changed
0
2280 emit selectionChanged();
never executed: selectionChanged();
0
2281}
never executed: }
0
2282 -
2283/*! -
2284 Clears the current selection. -
2285 -
2286 \sa setSelectionArea(), selectedItems() -
2287*/ -
2288void QGraphicsScene::clearSelection() -
2289{ -
2290 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
2291 -
2292 // Disable emitting selectionChanged -
2293 ++d->selectionChanging;
never executed (the execution status of this line is deduced): ++d->selectionChanging;
-
2294 bool changed = !d->selectedItems.isEmpty();
never executed (the execution status of this line is deduced): bool changed = !d->selectedItems.isEmpty();
-
2295 -
2296 foreach (QGraphicsItem *item, d->selectedItems)
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(d->selectedItems)> _container_(d->selectedItems); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
2297 item->setSelected(false);
never executed: item->setSelected(false);
0
2298 d->selectedItems.clear();
never executed (the execution status of this line is deduced): d->selectedItems.clear();
-
2299 -
2300 // Reenable emitting selectionChanged() for individual items. -
2301 --d->selectionChanging;
never executed (the execution status of this line is deduced): --d->selectionChanging;
-
2302 -
2303 if (!d->selectionChanging && changed)
never evaluated: !d->selectionChanging
never evaluated: changed
0
2304 emit selectionChanged();
never executed: selectionChanged();
0
2305}
never executed: }
0
2306 -
2307/*! -
2308 \since 4.4 -
2309 -
2310 Removes and deletes all items from the scene, but otherwise leaves the -
2311 state of the scene unchanged. -
2312 -
2313 \sa addItem() -
2314*/ -
2315void QGraphicsScene::clear() -
2316{ -
2317 Q_D(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
2318 // NB! We have to clear the index before deleting items; otherwise the -
2319 // index might try to access dangling item pointers. -
2320 d->index->clear();
executed (the execution status of this line is deduced): d->index->clear();
-
2321 // NB! QGraphicsScenePrivate::unregisterTopLevelItem() removes items -
2322 while (!d->topLevelItems.isEmpty())
evaluated: !d->topLevelItems.isEmpty()
TRUEFALSE
yes
Evaluation Count:93
yes
Evaluation Count:221
93-221
2323 delete d->topLevelItems.first();
executed: delete d->topLevelItems.first();
Execution Count:93
93
2324 Q_ASSERT(d->topLevelItems.isEmpty());
executed (the execution status of this line is deduced): qt_noop();
-
2325 d->lastItemCount = 0;
executed (the execution status of this line is deduced): d->lastItemCount = 0;
-
2326 d->allItemsIgnoreHoverEvents = true;
executed (the execution status of this line is deduced): d->allItemsIgnoreHoverEvents = true;
-
2327 d->allItemsUseDefaultCursor = true;
executed (the execution status of this line is deduced): d->allItemsUseDefaultCursor = true;
-
2328 d->allItemsIgnoreTouchEvents = true;
executed (the execution status of this line is deduced): d->allItemsIgnoreTouchEvents = true;
-
2329}
executed: }
Execution Count:221
221
2330 -
2331/*! -
2332 Groups all items in \a items into a new QGraphicsItemGroup, and returns a -
2333 pointer to the group. The group is created with the common ancestor of \a -
2334 items as its parent, and with position (0, 0). The items are all -
2335 reparented to the group, and their positions and transformations are -
2336 mapped to the group. If \a items is empty, this function will return an -
2337 empty top-level QGraphicsItemGroup. -
2338 -
2339 QGraphicsScene has ownership of the group item; you do not need to delete -
2340 it. To dismantle (ungroup) a group, call destroyItemGroup(). -
2341 -
2342 \sa destroyItemGroup(), QGraphicsItemGroup::addToGroup() -
2343*/ -
2344QGraphicsItemGroup *QGraphicsScene::createItemGroup(const QList<QGraphicsItem *> &items) -
2345{ -
2346 // Build a list of the first item's ancestors -
2347 QList<QGraphicsItem *> ancestors;
never executed (the execution status of this line is deduced): QList<QGraphicsItem *> ancestors;
-
2348 int n = 0;
never executed (the execution status of this line is deduced): int n = 0;
-
2349 if (!items.isEmpty()) {
never evaluated: !items.isEmpty()
0
2350 QGraphicsItem *parent = items.at(n++);
never executed (the execution status of this line is deduced): QGraphicsItem *parent = items.at(n++);
-
2351 while ((parent = parent->parentItem()))
never evaluated: (parent = parent->parentItem())
0
2352 ancestors.append(parent);
never executed: ancestors.append(parent);
0
2353 }
never executed: }
0
2354 -
2355 // Find the common ancestor for all items -
2356 QGraphicsItem *commonAncestor = 0;
never executed (the execution status of this line is deduced): QGraphicsItem *commonAncestor = 0;
-
2357 if (!ancestors.isEmpty()) {
never evaluated: !ancestors.isEmpty()
0
2358 while (n < items.size()) {
never evaluated: n < items.size()
0
2359 int commonIndex = -1;
never executed (the execution status of this line is deduced): int commonIndex = -1;
-
2360 QGraphicsItem *parent = items.at(n++);
never executed (the execution status of this line is deduced): QGraphicsItem *parent = items.at(n++);
-
2361 do { -
2362 int index = ancestors.indexOf(parent, qMax(0, commonIndex));
never executed (the execution status of this line is deduced): int index = ancestors.indexOf(parent, qMax(0, commonIndex));
-
2363 if (index != -1) {
never evaluated: index != -1
0
2364 commonIndex = index;
never executed (the execution status of this line is deduced): commonIndex = index;
-
2365 break;
never executed: break;
0
2366 } -
2367 } while ((parent = parent->parentItem()));
never executed: }
never evaluated: (parent = parent->parentItem())
0
2368 -
2369 if (commonIndex == -1) {
never evaluated: commonIndex == -1
0
2370 commonAncestor = 0;
never executed (the execution status of this line is deduced): commonAncestor = 0;
-
2371 break;
never executed: break;
0
2372 } -
2373 -
2374 commonAncestor = ancestors.at(commonIndex);
never executed (the execution status of this line is deduced): commonAncestor = ancestors.at(commonIndex);
-
2375 }
never executed: }
0
2376 }
never executed: }
0
2377 -
2378 // Create a new group at that level -
2379 QGraphicsItemGroup *group = new QGraphicsItemGroup(commonAncestor);
never executed (the execution status of this line is deduced): QGraphicsItemGroup *group = new QGraphicsItemGroup(commonAncestor);
-
2380 if (!commonAncestor)
never evaluated: !commonAncestor
0
2381 addItem(group);
never executed: addItem(group);
0
2382 foreach (QGraphicsItem *item, items)
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(items)> _container_(items); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
2383 group->addToGroup(item);
never executed: group->addToGroup(item);
0
2384 return group;
never executed: return group;
0
2385} -
2386 -
2387/*! -
2388 Reparents all items in \a group to \a group's parent item, then removes \a -
2389 group from the scene, and finally deletes it. The items' positions and -
2390 transformations are mapped from the group to the group's parent. -
2391 -
2392 \sa createItemGroup(), QGraphicsItemGroup::removeFromGroup() -
2393*/ -
2394void QGraphicsScene::destroyItemGroup(QGraphicsItemGroup *group) -
2395{ -
2396 foreach (QGraphicsItem *item, group->childItems())
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(group->childItems())> _container_(group->childItems()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
2397 group->removeFromGroup(item);
never executed: group->removeFromGroup(item);
0
2398 removeItem(group);
never executed (the execution status of this line is deduced): removeItem(group);
-
2399 delete group;
never executed (the execution status of this line is deduced): delete group;
-
2400}
never executed: }
0
2401 -
2402/*! -
2403 Adds or moves the \a item and all its childen to this scene. -
2404 This scene takes ownership of the \a item. -
2405 -
2406 If the item is visible (i.e., QGraphicsItem::isVisible() returns -
2407 true), QGraphicsScene will emit changed() once control goes back -
2408 to the event loop. -
2409 -
2410 If the item is already in a different scene, it will first be -
2411 removed from its old scene, and then added to this scene as a -
2412 top-level. -
2413 -
2414 QGraphicsScene will send ItemSceneChange notifications to \a item -
2415 while it is added to the scene. If item does not currently belong -
2416 to a scene, only one notification is sent. If it does belong to -
2417 scene already (i.e., it is moved to this scene), QGraphicsScene -
2418 will send an addition notification as the item is removed from its -
2419 previous scene. -
2420 -
2421 If the item is a panel, the scene is active, and there is no -
2422 active panel in the scene, then the item will be activated. -
2423 -
2424 \sa removeItem(), addEllipse(), addLine(), addPath(), addPixmap(), -
2425 addRect(), addText(), addWidget(), {QGraphicsItem#Sorting}{Sorting} -
2426*/ -
2427void QGraphicsScene::addItem(QGraphicsItem *item) -
2428{ -
2429 Q_D(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
2430 if (!item) {
partially evaluated: !item
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1018
0-1018
2431 qWarning("QGraphicsScene::addItem: cannot add null item");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsscene.cpp", 2431, __PRETTY_FUNCTION__).warning("QGraphicsScene::addItem: cannot add null item");
-
2432 return;
never executed: return;
0
2433 } -
2434 if (item->d_ptr->scene == this) {
partially evaluated: item->d_ptr->scene == this
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1018
0-1018
2435 qWarning("QGraphicsScene::addItem: item has already been added to this scene");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsscene.cpp", 2435, __PRETTY_FUNCTION__).warning("QGraphicsScene::addItem: item has already been added to this scene");
-
2436 return;
never executed: return;
0
2437 } -
2438 // Remove this item from its existing scene -
2439 if (QGraphicsScene *oldScene = item->d_ptr->scene)
partially evaluated: QGraphicsScene *oldScene = item->d_ptr->scene
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1018
0-1018
2440 oldScene->removeItem(item);
never executed: oldScene->removeItem(item);
0
2441 -
2442 // Notify the item that its scene is changing, and allow the item to -
2443 // react. -
2444 const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange,
executed (the execution status of this line is deduced): const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange,
-
2445 QVariant::fromValue<QGraphicsScene *>(this)));
executed (the execution status of this line is deduced): QVariant::fromValue<QGraphicsScene *>(this)));
-
2446 QGraphicsScene *targetScene = qvariant_cast<QGraphicsScene *>(newSceneVariant);
executed (the execution status of this line is deduced): QGraphicsScene *targetScene = qvariant_cast<QGraphicsScene *>(newSceneVariant);
-
2447 if (targetScene != this) {
partially evaluated: targetScene != this
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1018
0-1018
2448 if (targetScene && item->d_ptr->scene != targetScene)
never evaluated: targetScene
never evaluated: item->d_ptr->scene != targetScene
0
2449 targetScene->addItem(item);
never executed: targetScene->addItem(item);
0
2450 return;
never executed: return;
0
2451 } -
2452 -
2453 // QDeclarativeItems do not rely on initial itemChanged message, as the componentComplete -
2454 // function allows far more opportunity for delayed-construction optimization. -
2455 if (!item->d_ptr->isDeclarativeItem) {
partially evaluated: !item->d_ptr->isDeclarativeItem
TRUEFALSE
yes
Evaluation Count:1018
no
Evaluation Count:0
0-1018
2456 if (d->unpolishedItems.isEmpty()) {
evaluated: d->unpolishedItems.isEmpty()
TRUEFALSE
yes
Evaluation Count:239
yes
Evaluation Count:779
239-779
2457 QMetaMethod method = metaObject()->method(d->polishItemsIndex);
executed (the execution status of this line is deduced): QMetaMethod method = metaObject()->method(d->polishItemsIndex);
-
2458 method.invoke(this, Qt::QueuedConnection);
executed (the execution status of this line is deduced): method.invoke(this, Qt::QueuedConnection);
-
2459 }
executed: }
Execution Count:239
239
2460 d->unpolishedItems.append(item);
executed (the execution status of this line is deduced): d->unpolishedItems.append(item);
-
2461 item->d_ptr->pendingPolish = true;
executed (the execution status of this line is deduced): item->d_ptr->pendingPolish = true;
-
2462 }
executed: }
Execution Count:1018
1018
2463 -
2464 // Detach this item from its parent if the parent's scene is different -
2465 // from this scene. -
2466 if (QGraphicsItem *itemParent = item->d_ptr->parent) {
evaluated: QGraphicsItem *itemParent = item->d_ptr->parent
TRUEFALSE
yes
Evaluation Count:745
yes
Evaluation Count:273
273-745
2467 if (itemParent->d_ptr->scene != this)
partially evaluated: itemParent->d_ptr->scene != this
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:745
0-745
2468 item->setParentItem(0);
never executed: item->setParentItem(0);
0
2469 }
executed: }
Execution Count:745
745
2470 -
2471 // Add the item to this scene -
2472 item->d_func()->scene = targetScene;
executed (the execution status of this line is deduced): item->d_func()->scene = targetScene;
-
2473 -
2474 // Add the item in the index -
2475 d->index->addItem(item);
executed (the execution status of this line is deduced): d->index->addItem(item);
-
2476 -
2477 // Add to list of toplevels if this item is a toplevel. -
2478 if (!item->d_ptr->parent)
evaluated: !item->d_ptr->parent
TRUEFALSE
yes
Evaluation Count:273
yes
Evaluation Count:745
273-745
2479 d->registerTopLevelItem(item);
executed: d->registerTopLevelItem(item);
Execution Count:273
273
2480 -
2481 // Add to list of items that require an update. We cannot assume that the -
2482 // item is fully constructed, so calling item->update() can lead to a pure -
2483 // virtual function call to boundingRect(). -
2484 d->markDirty(item);
executed (the execution status of this line is deduced): d->markDirty(item);
-
2485 d->dirtyGrowingItemsBoundingRect = true;
executed (the execution status of this line is deduced): d->dirtyGrowingItemsBoundingRect = true;
-
2486 -
2487 // Disable selectionChanged() for individual items -
2488 ++d->selectionChanging;
executed (the execution status of this line is deduced): ++d->selectionChanging;
-
2489 int oldSelectedItemSize = d->selectedItems.size();
executed (the execution status of this line is deduced): int oldSelectedItemSize = d->selectedItems.size();
-
2490 -
2491 // Enable mouse tracking if the item accepts hover events or has a cursor set. -
2492 if (d->allItemsIgnoreHoverEvents && d->itemAcceptsHoverEvents_helper(item)) {
evaluated: d->allItemsIgnoreHoverEvents
TRUEFALSE
yes
Evaluation Count:316
yes
Evaluation Count:702
evaluated: d->itemAcceptsHoverEvents_helper(item)
TRUEFALSE
yes
Evaluation Count:175
yes
Evaluation Count:141
141-702
2493 d->allItemsIgnoreHoverEvents = false;
executed (the execution status of this line is deduced): d->allItemsIgnoreHoverEvents = false;
-
2494 d->enableMouseTrackingOnViews();
executed (the execution status of this line is deduced): d->enableMouseTrackingOnViews();
-
2495 }
executed: }
Execution Count:175
175
2496#ifndef QT_NO_CURSOR -
2497 if (d->allItemsUseDefaultCursor && item->d_ptr->hasCursor) {
partially evaluated: d->allItemsUseDefaultCursor
TRUEFALSE
yes
Evaluation Count:1018
no
Evaluation Count:0
partially evaluated: item->d_ptr->hasCursor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1018
0-1018
2498 d->allItemsUseDefaultCursor = false;
never executed (the execution status of this line is deduced): d->allItemsUseDefaultCursor = false;
-
2499 if (d->allItemsIgnoreHoverEvents) // already enabled otherwise
never evaluated: d->allItemsIgnoreHoverEvents
0
2500 d->enableMouseTrackingOnViews();
never executed: d->enableMouseTrackingOnViews();
0
2501 }
never executed: }
0
2502#endif //QT_NO_CURSOR -
2503 -
2504 // Enable touch events if the item accepts touch events. -
2505 if (d->allItemsIgnoreTouchEvents && item->d_ptr->acceptTouchEvents) {
partially evaluated: d->allItemsIgnoreTouchEvents
TRUEFALSE
yes
Evaluation Count:1018
no
Evaluation Count:0
partially evaluated: item->d_ptr->acceptTouchEvents
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1018
0-1018
2506 d->allItemsIgnoreTouchEvents = false;
never executed (the execution status of this line is deduced): d->allItemsIgnoreTouchEvents = false;
-
2507 d->enableTouchEventsOnViews();
never executed (the execution status of this line is deduced): d->enableTouchEventsOnViews();
-
2508 }
never executed: }
0
2509 -
2510#ifndef QT_NO_GESTURES -
2511 foreach (Qt::GestureType gesture, item->d_ptr->gestureContext.keys())
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(item->d_ptr->gestureContext.keys())> _container_(item->d_ptr->gestureContext.keys()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (Qt::GestureType gesture = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
2512 d->grabGesture(item, gesture);
executed: d->grabGesture(item, gesture);
Execution Count:31
31
2513#endif -
2514 -
2515 // Update selection lists -
2516 if (item->isSelected())
partially evaluated: item->isSelected()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1018
0-1018
2517 d->selectedItems << item;
never executed: d->selectedItems << item;
0
2518 if (item->isWidget() && item->isVisible() && static_cast<QGraphicsWidget *>(item)->windowType() == Qt::Popup)
evaluated: item->isWidget()
TRUEFALSE
yes
Evaluation Count:930
yes
Evaluation Count:88
evaluated: item->isVisible()
TRUEFALSE
yes
Evaluation Count:929
yes
Evaluation Count:1
partially evaluated: static_cast<QGraphicsWidget *>(item)->windowType() == Qt::Popup
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:929
0-930
2519 d->addPopup(static_cast<QGraphicsWidget *>(item));
never executed: d->addPopup(static_cast<QGraphicsWidget *>(item));
0
2520 if (item->isPanel() && item->isVisible() && item->panelModality() != QGraphicsItem::NonModal)
evaluated: item->isPanel()
TRUEFALSE
yes
Evaluation Count:176
yes
Evaluation Count:842
partially evaluated: item->isVisible()
TRUEFALSE
yes
Evaluation Count:176
no
Evaluation Count:0
evaluated: item->panelModality() != QGraphicsItem::NonModal
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:175
0-842
2521 d->enterModal(item);
executed: d->enterModal(item);
Execution Count:1
1
2522 -
2523 // Update creation order focus chain. Make sure to leave the widget's -
2524 // internal tab order intact. -
2525 if (item->isWidget()) {
evaluated: item->isWidget()
TRUEFALSE
yes
Evaluation Count:930
yes
Evaluation Count:88
88-930
2526 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
executed (the execution status of this line is deduced): QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
-
2527 if (!d->tabFocusFirst) {
evaluated: !d->tabFocusFirst
TRUEFALSE
yes
Evaluation Count:195
yes
Evaluation Count:735
195-735
2528 // No first tab focus widget - make this the first tab focus -
2529 // widget. -
2530 d->tabFocusFirst = widget;
executed (the execution status of this line is deduced): d->tabFocusFirst = widget;
-
2531 } else if (!widget->parentWidget()) {
executed: }
Execution Count:195
evaluated: !widget->parentWidget()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:729
6-729
2532 // Adding a widget that is not part of a tab focus chain. -
2533 QGraphicsWidget *last = d->tabFocusFirst->d_func()->focusPrev;
executed (the execution status of this line is deduced): QGraphicsWidget *last = d->tabFocusFirst->d_func()->focusPrev;
-
2534 QGraphicsWidget *lastNew = widget->d_func()->focusPrev;
executed (the execution status of this line is deduced): QGraphicsWidget *lastNew = widget->d_func()->focusPrev;
-
2535 last->d_func()->focusNext = widget;
executed (the execution status of this line is deduced): last->d_func()->focusNext = widget;
-
2536 widget->d_func()->focusPrev = last;
executed (the execution status of this line is deduced): widget->d_func()->focusPrev = last;
-
2537 d->tabFocusFirst->d_func()->focusPrev = lastNew;
executed (the execution status of this line is deduced): d->tabFocusFirst->d_func()->focusPrev = lastNew;
-
2538 lastNew->d_func()->focusNext = d->tabFocusFirst;
executed (the execution status of this line is deduced): lastNew->d_func()->focusNext = d->tabFocusFirst;
-
2539 }
executed: }
Execution Count:6
6
2540 } -
2541 -
2542 // Add all children recursively -
2543 item->d_ptr->ensureSortedChildren();
executed (the execution status of this line is deduced): item->d_ptr->ensureSortedChildren();
-
2544 for (int i = 0; i < item->d_ptr->children.size(); ++i)
evaluated: i < item->d_ptr->children.size()
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:1018
24-1018
2545 addItem(item->d_ptr->children.at(i));
executed: addItem(item->d_ptr->children.at(i));
Execution Count:24
24
2546 -
2547 // Resolve font and palette. -
2548 item->d_ptr->resolveFont(d->font.resolve());
executed (the execution status of this line is deduced): item->d_ptr->resolveFont(d->font.resolve());
-
2549 item->d_ptr->resolvePalette(d->palette.resolve());
executed (the execution status of this line is deduced): item->d_ptr->resolvePalette(d->palette.resolve());
-
2550 -
2551 -
2552 // Reenable selectionChanged() for individual items -
2553 --d->selectionChanging;
executed (the execution status of this line is deduced): --d->selectionChanging;
-
2554 if (!d->selectionChanging && d->selectedItems.size() != oldSelectedItemSize)
evaluated: !d->selectionChanging
TRUEFALSE
yes
Evaluation Count:994
yes
Evaluation Count:24
partially evaluated: d->selectedItems.size() != oldSelectedItemSize
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:994
0-994
2555 emit selectionChanged();
never executed: selectionChanged();
0
2556 -
2557 // Deliver post-change notification -
2558 item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant);
executed (the execution status of this line is deduced): item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant);
-
2559 -
2560 // Update explicit activation -
2561 bool autoActivate = true;
executed (the execution status of this line is deduced): bool autoActivate = true;
-
2562 if (!d->childExplicitActivation && item->d_ptr->explicitActivate)
partially evaluated: !d->childExplicitActivation
TRUEFALSE
yes
Evaluation Count:1018
no
Evaluation Count:0
partially evaluated: item->d_ptr->explicitActivate
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1018
0-1018
2563 d->childExplicitActivation = item->d_ptr->wantsActive ? 1 : 2;
never executed: d->childExplicitActivation = item->d_ptr->wantsActive ? 1 : 2;
never evaluated: item->d_ptr->wantsActive
0
2564 if (d->childExplicitActivation && item->isPanel()) {
partially evaluated: d->childExplicitActivation
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1018
never evaluated: item->isPanel()
0-1018
2565 if (d->childExplicitActivation == 1)
never evaluated: d->childExplicitActivation == 1
0
2566 setActivePanel(item);
never executed: setActivePanel(item);
0
2567 else -
2568 autoActivate = false;
never executed: autoActivate = false;
0
2569 d->childExplicitActivation = 0;
never executed (the execution status of this line is deduced): d->childExplicitActivation = 0;
-
2570 } else if (!item->d_ptr->parent) {
never executed: }
evaluated: !item->d_ptr->parent
TRUEFALSE
yes
Evaluation Count:273
yes
Evaluation Count:745
0-745
2571 d->childExplicitActivation = 0;
executed (the execution status of this line is deduced): d->childExplicitActivation = 0;
-
2572 }
executed: }
Execution Count:273
273
2573 -
2574 // Auto-activate this item's panel if nothing else has been activated -
2575 if (autoActivate) {
partially evaluated: autoActivate
TRUEFALSE
yes
Evaluation Count:1018
no
Evaluation Count:0
0-1018
2576 if (!d->lastActivePanel && !d->activePanel && item->isPanel()) {
evaluated: !d->lastActivePanel
TRUEFALSE
yes
Evaluation Count:328
yes
Evaluation Count:690
evaluated: !d->activePanel
TRUEFALSE
yes
Evaluation Count:326
yes
Evaluation Count:2
evaluated: item->isPanel()
TRUEFALSE
yes
Evaluation Count:176
yes
Evaluation Count:150
2-690
2577 if (isActive())
evaluated: isActive()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:174
2-174
2578 setActivePanel(item);
executed: setActivePanel(item);
Execution Count:2
2
2579 else -
2580 d->lastActivePanel = item;
executed: d->lastActivePanel = item;
Execution Count:174
174
2581 } -
2582 }
executed: }
Execution Count:1018
1018
2583 -
2584 if (item->d_ptr->flags & QGraphicsItem::ItemSendsScenePositionChanges)
partially evaluated: item->d_ptr->flags & QGraphicsItem::ItemSendsScenePositionChanges
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1018
0-1018
2585 d->registerScenePosItem(item);
never executed: d->registerScenePosItem(item);
0
2586 -
2587 // Ensure that newly added items that have subfocus set, gain -
2588 // focus automatically if there isn't a focus item already. -
2589 if (!d->focusItem && item != d->lastFocusItem && item->focusItem() == item)
partially evaluated: !d->focusItem
TRUEFALSE
yes
Evaluation Count:1018
no
Evaluation Count:0
partially evaluated: item != d->lastFocusItem
TRUEFALSE
yes
Evaluation Count:1018
no
Evaluation Count:0
partially evaluated: item->focusItem() == item
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1018
0-1018
2590 item->focusItem()->setFocus();
never executed: item->focusItem()->setFocus();
0
2591 -
2592 d->updateInputMethodSensitivityInViews();
executed (the execution status of this line is deduced): d->updateInputMethodSensitivityInViews();
-
2593}
executed: }
Execution Count:1018
1018
2594 -
2595/*! -
2596 Creates and adds an ellipse item to the scene, and returns the item -
2597 pointer. The geometry of the ellipse is defined by \a rect, and its pen -
2598 and brush are initialized to \a pen and \a brush. -
2599 -
2600 Note that the item's geometry is provided in item coordinates, and its -
2601 position is initialized to (0, 0). -
2602 -
2603 If the item is visible (i.e., QGraphicsItem::isVisible() returns true), -
2604 QGraphicsScene will emit changed() once control goes back to the event -
2605 loop. -
2606 -
2607 \sa addLine(), addPath(), addPixmap(), addRect(), addText(), addItem(), -
2608 addWidget() -
2609*/ -
2610QGraphicsEllipseItem *QGraphicsScene::addEllipse(const QRectF &rect, const QPen &pen, const QBrush &brush) -
2611{ -
2612 QGraphicsEllipseItem *item = new QGraphicsEllipseItem(rect);
never executed (the execution status of this line is deduced): QGraphicsEllipseItem *item = new QGraphicsEllipseItem(rect);
-
2613 item->setPen(pen);
never executed (the execution status of this line is deduced): item->setPen(pen);
-
2614 item->setBrush(brush);
never executed (the execution status of this line is deduced): item->setBrush(brush);
-
2615 addItem(item);
never executed (the execution status of this line is deduced): addItem(item);
-
2616 return item;
never executed: return item;
0
2617} -
2618 -
2619/*! -
2620 \fn QGraphicsEllipseItem *QGraphicsScene::addEllipse(qreal x, qreal y, qreal w, qreal h, const QPen &pen, const QBrush &brush) -
2621 \since 4.3 -
2622 -
2623 This convenience function is equivalent to calling addEllipse(QRectF(\a x, -
2624 \a y, \a w, \a h), \a pen, \a brush). -
2625*/ -
2626 -
2627/*! -
2628 Creates and adds a line item to the scene, and returns the item -
2629 pointer. The geometry of the line is defined by \a line, and its pen -
2630 is initialized to \a pen. -
2631 -
2632 Note that the item's geometry is provided in item coordinates, and its -
2633 position is initialized to (0, 0). -
2634 -
2635 If the item is visible (i.e., QGraphicsItem::isVisible() returns true), -
2636 QGraphicsScene will emit changed() once control goes back to the event -
2637 loop. -
2638 -
2639 \sa addEllipse(), addPath(), addPixmap(), addRect(), addText(), addItem(), -
2640 addWidget() -
2641*/ -
2642QGraphicsLineItem *QGraphicsScene::addLine(const QLineF &line, const QPen &pen) -
2643{ -
2644 QGraphicsLineItem *item = new QGraphicsLineItem(line);
never executed (the execution status of this line is deduced): QGraphicsLineItem *item = new QGraphicsLineItem(line);
-
2645 item->setPen(pen);
never executed (the execution status of this line is deduced): item->setPen(pen);
-
2646 addItem(item);
never executed (the execution status of this line is deduced): addItem(item);
-
2647 return item;
never executed: return item;
0
2648} -
2649 -
2650/*! -
2651 \fn QGraphicsLineItem *QGraphicsScene::addLine(qreal x1, qreal y1, qreal x2, qreal y2, const QPen &pen) -
2652 \since 4.3 -
2653 -
2654 This convenience function is equivalent to calling addLine(QLineF(\a x1, -
2655 \a y1, \a x2, \a y2), \a pen). -
2656*/ -
2657 -
2658/*! -
2659 Creates and adds a path item to the scene, and returns the item -
2660 pointer. The geometry of the path is defined by \a path, and its pen and -
2661 brush are initialized to \a pen and \a brush. -
2662 -
2663 Note that the item's geometry is provided in item coordinates, and its -
2664 position is initialized to (0, 0). -
2665 -
2666 If the item is visible (i.e., QGraphicsItem::isVisible() returns true), -
2667 QGraphicsScene will emit changed() once control goes back to the event -
2668 loop. -
2669 -
2670 \sa addEllipse(), addLine(), addPixmap(), addRect(), addText(), addItem(), -
2671 addWidget() -
2672*/ -
2673QGraphicsPathItem *QGraphicsScene::addPath(const QPainterPath &path, const QPen &pen, const QBrush &brush) -
2674{ -
2675 QGraphicsPathItem *item = new QGraphicsPathItem(path);
never executed (the execution status of this line is deduced): QGraphicsPathItem *item = new QGraphicsPathItem(path);
-
2676 item->setPen(pen);
never executed (the execution status of this line is deduced): item->setPen(pen);
-
2677 item->setBrush(brush);
never executed (the execution status of this line is deduced): item->setBrush(brush);
-
2678 addItem(item);
never executed (the execution status of this line is deduced): addItem(item);
-
2679 return item;
never executed: return item;
0
2680} -
2681 -
2682/*! -
2683 Creates and adds a pixmap item to the scene, and returns the item -
2684 pointer. The pixmap is defined by \a pixmap. -
2685 -
2686 Note that the item's geometry is provided in item coordinates, and its -
2687 position is initialized to (0, 0). -
2688 -
2689 If the item is visible (i.e., QGraphicsItem::isVisible() returns true), -
2690 QGraphicsScene will emit changed() once control goes back to the event -
2691 loop. -
2692 -
2693 \sa addEllipse(), addLine(), addPath(), addRect(), addText(), addItem(), -
2694 addWidget() -
2695*/ -
2696QGraphicsPixmapItem *QGraphicsScene::addPixmap(const QPixmap &pixmap) -
2697{ -
2698 QGraphicsPixmapItem *item = new QGraphicsPixmapItem(pixmap);
never executed (the execution status of this line is deduced): QGraphicsPixmapItem *item = new QGraphicsPixmapItem(pixmap);
-
2699 addItem(item);
never executed (the execution status of this line is deduced): addItem(item);
-
2700 return item;
never executed: return item;
0
2701} -
2702 -
2703/*! -
2704 Creates and adds a polygon item to the scene, and returns the item -
2705 pointer. The polygon is defined by \a polygon, and its pen and -
2706 brush are initialized to \a pen and \a brush. -
2707 -
2708 Note that the item's geometry is provided in item coordinates, and its -
2709 position is initialized to (0, 0). -
2710 -
2711 If the item is visible (i.e., QGraphicsItem::isVisible() returns true), -
2712 QGraphicsScene will emit changed() once control goes back to the event -
2713 loop. -
2714 -
2715 \sa addEllipse(), addLine(), addPath(), addRect(), addText(), addItem(), -
2716 addWidget() -
2717*/ -
2718QGraphicsPolygonItem *QGraphicsScene::addPolygon(const QPolygonF &polygon, -
2719 const QPen &pen, const QBrush &brush) -
2720{ -
2721 QGraphicsPolygonItem *item = new QGraphicsPolygonItem(polygon);
never executed (the execution status of this line is deduced): QGraphicsPolygonItem *item = new QGraphicsPolygonItem(polygon);
-
2722 item->setPen(pen);
never executed (the execution status of this line is deduced): item->setPen(pen);
-
2723 item->setBrush(brush);
never executed (the execution status of this line is deduced): item->setBrush(brush);
-
2724 addItem(item);
never executed (the execution status of this line is deduced): addItem(item);
-
2725 return item;
never executed: return item;
0
2726} -
2727 -
2728/*! -
2729 Creates and adds a rectangle item to the scene, and returns the item -
2730 pointer. The geometry of the rectangle is defined by \a rect, and its pen -
2731 and brush are initialized to \a pen and \a brush. -
2732 -
2733 Note that the item's geometry is provided in item coordinates, and its -
2734 position is initialized to (0, 0). For example, if a QRect(50, 50, 100, -
2735 100) is added, its top-left corner will be at (50, 50) relative to the -
2736 origin in the items coordinate system. -
2737 -
2738 If the item is visible (i.e., QGraphicsItem::isVisible() returns true), -
2739 QGraphicsScene will emit changed() once control goes back to the event -
2740 loop. -
2741 -
2742 \sa addEllipse(), addLine(), addPixmap(), addPixmap(), addText(), -
2743 addItem(), addWidget() -
2744*/ -
2745QGraphicsRectItem *QGraphicsScene::addRect(const QRectF &rect, const QPen &pen, const QBrush &brush) -
2746{ -
2747 QGraphicsRectItem *item = new QGraphicsRectItem(rect);
never executed (the execution status of this line is deduced): QGraphicsRectItem *item = new QGraphicsRectItem(rect);
-
2748 item->setPen(pen);
never executed (the execution status of this line is deduced): item->setPen(pen);
-
2749 item->setBrush(brush);
never executed (the execution status of this line is deduced): item->setBrush(brush);
-
2750 addItem(item);
never executed (the execution status of this line is deduced): addItem(item);
-
2751 return item;
never executed: return item;
0
2752} -
2753 -
2754/*! -
2755 \fn QGraphicsRectItem *QGraphicsScene::addRect(qreal x, qreal y, qreal w, qreal h, const QPen &pen, const QBrush &brush) -
2756 \since 4.3 -
2757 -
2758 This convenience function is equivalent to calling addRect(QRectF(\a x, -
2759 \a y, \a w, \a h), \a pen, \a brush). -
2760*/ -
2761 -
2762/*! -
2763 Creates and adds a text item to the scene, and returns the item -
2764 pointer. The text string is initialized to \a text, and its font -
2765 is initialized to \a font. -
2766 -
2767 The item's position is initialized to (0, 0). -
2768 -
2769 If the item is visible (i.e., QGraphicsItem::isVisible() returns true), -
2770 QGraphicsScene will emit changed() once control goes back to the event -
2771 loop. -
2772 -
2773 \sa addEllipse(), addLine(), addPixmap(), addPixmap(), addRect(), -
2774 addItem(), addWidget() -
2775*/ -
2776QGraphicsTextItem *QGraphicsScene::addText(const QString &text, const QFont &font) -
2777{ -
2778 QGraphicsTextItem *item = new QGraphicsTextItem(text);
executed (the execution status of this line is deduced): QGraphicsTextItem *item = new QGraphicsTextItem(text);
-
2779 item->setFont(font);
executed (the execution status of this line is deduced): item->setFont(font);
-
2780 addItem(item);
executed (the execution status of this line is deduced): addItem(item);
-
2781 return item;
executed: return item;
Execution Count:1
1
2782} -
2783 -
2784/*! -
2785 Creates and adds a QGraphicsSimpleTextItem to the scene, and returns the -
2786 item pointer. The text string is initialized to \a text, and its font is -
2787 initialized to \a font. -
2788 -
2789 The item's position is initialized to (0, 0). -
2790 -
2791 If the item is visible (i.e., QGraphicsItem::isVisible() returns true), -
2792 QGraphicsScene will emit changed() once control goes back to the event -
2793 loop. -
2794 -
2795 \sa addEllipse(), addLine(), addPixmap(), addPixmap(), addRect(), -
2796 addItem(), addWidget() -
2797*/ -
2798QGraphicsSimpleTextItem *QGraphicsScene::addSimpleText(const QString &text, const QFont &font) -
2799{ -
2800 QGraphicsSimpleTextItem *item = new QGraphicsSimpleTextItem(text);
never executed (the execution status of this line is deduced): QGraphicsSimpleTextItem *item = new QGraphicsSimpleTextItem(text);
-
2801 item->setFont(font);
never executed (the execution status of this line is deduced): item->setFont(font);
-
2802 addItem(item);
never executed (the execution status of this line is deduced): addItem(item);
-
2803 return item;
never executed: return item;
0
2804} -
2805 -
2806/*! -
2807 Creates a new QGraphicsProxyWidget for \a widget, adds it to the scene, -
2808 and returns a pointer to the proxy. \a wFlags set the default window flags -
2809 for the embedding proxy widget. -
2810 -
2811 The item's position is initialized to (0, 0). -
2812 -
2813 If the item is visible (i.e., QGraphicsItem::isVisible() returns true), -
2814 QGraphicsScene will emit changed() once control goes back to the event -
2815 loop. -
2816 -
2817 Note that widgets with the Qt::WA_PaintOnScreen widget attribute -
2818 set and widgets that wrap an external application or controller -
2819 are not supported. Examples are QGLWidget and QAxWidget. -
2820 -
2821 \sa addEllipse(), addLine(), addPixmap(), addPixmap(), addRect(), -
2822 addText(), addSimpleText(), addItem() -
2823*/ -
2824QGraphicsProxyWidget *QGraphicsScene::addWidget(QWidget *widget, Qt::WindowFlags wFlags) -
2825{ -
2826 QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(0, wFlags);
executed (the execution status of this line is deduced): QGraphicsProxyWidget *proxy = new QGraphicsProxyWidget(0, wFlags);
-
2827 proxy->setWidget(widget);
executed (the execution status of this line is deduced): proxy->setWidget(widget);
-
2828 addItem(proxy);
executed (the execution status of this line is deduced): addItem(proxy);
-
2829 return proxy;
executed: return proxy;
Execution Count:2
2
2830} -
2831 -
2832/*! -
2833 Removes the item \a item and all its children from the scene. The -
2834 ownership of \a item is passed on to the caller (i.e., -
2835 QGraphicsScene will no longer delete \a item when destroyed). -
2836 -
2837 \sa addItem() -
2838*/ -
2839void QGraphicsScene::removeItem(QGraphicsItem *item) -
2840{ -
2841 // ### Refactoring: This function shares much functionality with _q_removeItemLater() -
2842 Q_D(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
2843 if (!item) {
partially evaluated: !item
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
2844 qWarning("QGraphicsScene::removeItem: cannot remove 0-item");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsscene.cpp", 2844, __PRETTY_FUNCTION__).warning("QGraphicsScene::removeItem: cannot remove 0-item");
-
2845 return;
never executed: return;
0
2846 } -
2847 if (item->scene() != this) {
partially evaluated: item->scene() != this
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
2848 qWarning("QGraphicsScene::removeItem: item %p's scene (%p)"
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsscene.cpp", 2848, __PRETTY_FUNCTION__).warning("QGraphicsScene::removeItem: item %p's scene (%p)"
-
2849 " is different from this scene (%p)",
never executed (the execution status of this line is deduced): " is different from this scene (%p)",
-
2850 item, item->scene(), this);
never executed (the execution status of this line is deduced): item, item->scene(), this);
-
2851 return;
never executed: return;
0
2852 } -
2853 -
2854 // Notify the item that it's scene is changing to 0, allowing the item to -
2855 // react. -
2856 const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange,
executed (the execution status of this line is deduced): const QVariant newSceneVariant(item->itemChange(QGraphicsItem::ItemSceneChange,
-
2857 QVariant::fromValue<QGraphicsScene *>(0)));
executed (the execution status of this line is deduced): QVariant::fromValue<QGraphicsScene *>(0)));
-
2858 QGraphicsScene *targetScene = qvariant_cast<QGraphicsScene *>(newSceneVariant);
executed (the execution status of this line is deduced): QGraphicsScene *targetScene = qvariant_cast<QGraphicsScene *>(newSceneVariant);
-
2859 if (targetScene != 0 && targetScene != this) {
partially evaluated: targetScene != 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
never evaluated: targetScene != this
0-7
2860 targetScene->addItem(item);
never executed (the execution status of this line is deduced): targetScene->addItem(item);
-
2861 return;
never executed: return;
0
2862 } -
2863 -
2864 d->removeItemHelper(item);
executed (the execution status of this line is deduced): d->removeItemHelper(item);
-
2865 -
2866 // Deliver post-change notification -
2867 item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant);
executed (the execution status of this line is deduced): item->itemChange(QGraphicsItem::ItemSceneHasChanged, newSceneVariant);
-
2868 -
2869 d->updateInputMethodSensitivityInViews();
executed (the execution status of this line is deduced): d->updateInputMethodSensitivityInViews();
-
2870}
executed: }
Execution Count:7
7
2871 -
2872/*! -
2873 When the scene is active, this functions returns the scene's current focus -
2874 item, or 0 if no item currently has focus. When the scene is inactive, this -
2875 functions returns the item that will gain input focus when the scene becomes -
2876 active. -
2877 -
2878 The focus item receives keyboard input when the scene receives a -
2879 key event. -
2880 -
2881 \sa setFocusItem(), QGraphicsItem::hasFocus(), isActive() -
2882*/ -
2883QGraphicsItem *QGraphicsScene::focusItem() const -
2884{ -
2885 Q_D(const QGraphicsScene);
executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
2886 return isActive() ? d->focusItem : d->passiveFocusItem;
executed: return isActive() ? d->focusItem : d->passiveFocusItem;
Execution Count:1209
1209
2887} -
2888 -
2889/*! -
2890 Sets the scene's focus item to \a item, with the focus reason \a -
2891 focusReason, after removing focus from any previous item that may have had -
2892 focus. -
2893 -
2894 If \a item is 0, or if it either does not accept focus (i.e., it does not -
2895 have the QGraphicsItem::ItemIsFocusable flag enabled), or is not visible -
2896 or not enabled, this function only removes focus from any previous -
2897 focusitem. -
2898 -
2899 If item is not 0, and the scene does not currently have focus (i.e., -
2900 hasFocus() returns false), this function will call setFocus() -
2901 automatically. -
2902 -
2903 \sa focusItem(), hasFocus(), setFocus() -
2904*/ -
2905void QGraphicsScene::setFocusItem(QGraphicsItem *item, Qt::FocusReason focusReason) -
2906{ -
2907 Q_D(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
2908 if (item)
partially evaluated: item
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
2909 item->setFocus(focusReason);
never executed: item->setFocus(focusReason);
0
2910 else -
2911 d->setFocusItemHelper(item, focusReason);
executed: d->setFocusItemHelper(item, focusReason);
Execution Count:4
4
2912} -
2913 -
2914/*! -
2915 Returns true if the scene has focus; otherwise returns false. If the scene -
2916 has focus, it will will forward key events from QKeyEvent to any item that -
2917 has focus. -
2918 -
2919 \sa setFocus(), setFocusItem() -
2920*/ -
2921bool QGraphicsScene::hasFocus() const -
2922{ -
2923 Q_D(const QGraphicsScene);
never executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
2924 return d->hasFocus;
never executed: return d->hasFocus;
0
2925} -
2926 -
2927/*! -
2928 Sets focus on the scene by sending a QFocusEvent to the scene, passing \a -
2929 focusReason as the reason. If the scene regains focus after having -
2930 previously lost it while an item had focus, the last focus item will -
2931 receive focus with \a focusReason as the reason. -
2932 -
2933 If the scene already has focus, this function does nothing. -
2934 -
2935 \sa hasFocus(), clearFocus(), setFocusItem() -
2936*/ -
2937void QGraphicsScene::setFocus(Qt::FocusReason focusReason) -
2938{ -
2939 Q_D(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
2940 if (d->hasFocus || !isActive())
evaluated: d->hasFocus
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:15
partially evaluated: !isActive()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
2941 return;
executed: return;
Execution Count:5
5
2942 QFocusEvent event(QEvent::FocusIn, focusReason);
executed (the execution status of this line is deduced): QFocusEvent event(QEvent::FocusIn, focusReason);
-
2943 QCoreApplication::sendEvent(this, &event);
executed (the execution status of this line is deduced): QCoreApplication::sendEvent(this, &event);
-
2944}
executed: }
Execution Count:15
15
2945 -
2946/*! -
2947 Clears focus from the scene. If any item has focus when this function is -
2948 called, it will lose focus, and regain focus again once the scene regains -
2949 focus. -
2950 -
2951 A scene that does not have focus ignores key events. -
2952 -
2953 \sa hasFocus(), setFocus(), setFocusItem() -
2954*/ -
2955void QGraphicsScene::clearFocus() -
2956{ -
2957 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
2958 if (d->hasFocus) {
never evaluated: d->hasFocus
0
2959 d->hasFocus = false;
never executed (the execution status of this line is deduced): d->hasFocus = false;
-
2960 d->passiveFocusItem = d->focusItem;
never executed (the execution status of this line is deduced): d->passiveFocusItem = d->focusItem;
-
2961 setFocusItem(0, Qt::OtherFocusReason);
never executed (the execution status of this line is deduced): setFocusItem(0, Qt::OtherFocusReason);
-
2962 }
never executed: }
0
2963}
never executed: }
0
2964 -
2965/*! -
2966 \property QGraphicsScene::stickyFocus -
2967 \brief whether clicking into the scene background will clear focus -
2968 -
2969 \since 4.6 -
2970 -
2971 In a QGraphicsScene with stickyFocus set to true, focus will remain -
2972 unchanged when the user clicks into the scene background or on an item -
2973 that does not accept focus. Otherwise, focus will be cleared. -
2974 -
2975 By default, this property is false. -
2976 -
2977 Focus changes in response to a mouse press. You can reimplement -
2978 mousePressEvent() in a subclass of QGraphicsScene to toggle this property -
2979 based on where the user has clicked. -
2980 -
2981 \sa clearFocus(), setFocusItem() -
2982*/ -
2983void QGraphicsScene::setStickyFocus(bool enabled) -
2984{ -
2985 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
2986 d->stickyFocus = enabled;
never executed (the execution status of this line is deduced): d->stickyFocus = enabled;
-
2987}
never executed: }
0
2988bool QGraphicsScene::stickyFocus() const -
2989{ -
2990 Q_D(const QGraphicsScene);
never executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
2991 return d->stickyFocus;
never executed: return d->stickyFocus;
0
2992} -
2993 -
2994/*! -
2995 Returns the current mouse grabber item, or 0 if no item is currently -
2996 grabbing the mouse. The mouse grabber item is the item that receives all -
2997 mouse events sent to the scene. -
2998 -
2999 An item becomes a mouse grabber when it receives and accepts a -
3000 mouse press event, and it stays the mouse grabber until either of -
3001 the following events occur: -
3002 -
3003 \list -
3004 \li If the item receives a mouse release event when there are no other -
3005 buttons pressed, it loses the mouse grab. -
3006 \li If the item becomes invisible (i.e., someone calls \c {item->setVisible(false)}), -
3007 or if it becomes disabled (i.e., someone calls \c {item->setEnabled(false)}), -
3008 it loses the mouse grab. -
3009 \li If the item is removed from the scene, it loses the mouse grab. -
3010 \endlist -
3011 -
3012 If the item loses its mouse grab, the scene will ignore all mouse events -
3013 until a new item grabs the mouse (i.e., until a new item receives a mouse -
3014 press event). -
3015*/ -
3016QGraphicsItem *QGraphicsScene::mouseGrabberItem() const -
3017{ -
3018 Q_D(const QGraphicsScene);
executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
3019 return !d->mouseGrabberItems.isEmpty() ? d->mouseGrabberItems.last() : 0;
executed: return !d->mouseGrabberItems.isEmpty() ? d->mouseGrabberItems.last() : 0;
Execution Count:412
412
3020} -
3021 -
3022/*! -
3023 \property QGraphicsScene::backgroundBrush -
3024 \brief the background brush of the scene. -
3025 -
3026 Set this property to changes the scene's background to a different color, -
3027 gradient or texture. The default background brush is Qt::NoBrush. The -
3028 background is drawn before (behind) the items. -
3029 -
3030 Example: -
3031 -
3032 \snippet code/src_gui_graphicsview_qgraphicsscene.cpp 3 -
3033 -
3034 QGraphicsScene::render() calls drawBackground() to draw the scene -
3035 background. For more detailed control over how the background is drawn, -
3036 you can reimplement drawBackground() in a subclass of QGraphicsScene. -
3037*/ -
3038QBrush QGraphicsScene::backgroundBrush() const -
3039{ -
3040 Q_D(const QGraphicsScene);
never executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
3041 return d->backgroundBrush;
never executed: return d->backgroundBrush;
0
3042} -
3043void QGraphicsScene::setBackgroundBrush(const QBrush &brush) -
3044{ -
3045 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
3046 d->backgroundBrush = brush;
never executed (the execution status of this line is deduced): d->backgroundBrush = brush;
-
3047 foreach (QGraphicsView *view, d->views) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(d->views)> _container_(d->views); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsView *view = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
3048 view->resetCachedContent();
never executed (the execution status of this line is deduced): view->resetCachedContent();
-
3049 view->viewport()->update();
never executed (the execution status of this line is deduced): view->viewport()->update();
-
3050 }
never executed: }
0
3051 update();
never executed (the execution status of this line is deduced): update();
-
3052}
never executed: }
0
3053 -
3054/*! -
3055 \property QGraphicsScene::foregroundBrush -
3056 \brief the foreground brush of the scene. -
3057 -
3058 Change this property to set the scene's foreground to a different -
3059 color, gradient or texture. -
3060 -
3061 The foreground is drawn after (on top of) the items. The default -
3062 foreground brush is Qt::NoBrush ( i.e. the foreground is not -
3063 drawn). -
3064 -
3065 Example: -
3066 -
3067 \snippet code/src_gui_graphicsview_qgraphicsscene.cpp 4 -
3068 -
3069 QGraphicsScene::render() calls drawForeground() to draw the scene -
3070 foreground. For more detailed control over how the foreground is -
3071 drawn, you can reimplement the drawForeground() function in a -
3072 QGraphicsScene subclass. -
3073*/ -
3074QBrush QGraphicsScene::foregroundBrush() const -
3075{ -
3076 Q_D(const QGraphicsScene);
never executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
3077 return d->foregroundBrush;
never executed: return d->foregroundBrush;
0
3078} -
3079void QGraphicsScene::setForegroundBrush(const QBrush &brush) -
3080{ -
3081 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
3082 d->foregroundBrush = brush;
never executed (the execution status of this line is deduced): d->foregroundBrush = brush;
-
3083 foreach (QGraphicsView *view, views())
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(views())> _container_(views()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsView *view = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
3084 view->viewport()->update();
never executed: view->viewport()->update();
0
3085 update();
never executed (the execution status of this line is deduced): update();
-
3086}
never executed: }
0
3087 -
3088/*! -
3089 This method is used by input methods to query a set of properties of -
3090 the scene to be able to support complex input method operations as support -
3091 for surrounding text and reconversions. -
3092 -
3093 The \a query parameter specifies which property is queried. -
3094 -
3095 \sa QWidget::inputMethodQuery() -
3096*/ -
3097QVariant QGraphicsScene::inputMethodQuery(Qt::InputMethodQuery query) const -
3098{ -
3099 Q_D(const QGraphicsScene);
never executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
3100 if (!d->focusItem || !(d->focusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod))
never evaluated: !d->focusItem
never evaluated: !(d->focusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod)
0
3101 return QVariant();
never executed: return QVariant();
0
3102 const QTransform matrix = d->focusItem->sceneTransform();
never executed (the execution status of this line is deduced): const QTransform matrix = d->focusItem->sceneTransform();
-
3103 QVariant value = d->focusItem->inputMethodQuery(query);
never executed (the execution status of this line is deduced): QVariant value = d->focusItem->inputMethodQuery(query);
-
3104 if (value.type() == QVariant::RectF)
never evaluated: value.type() == QVariant::RectF
0
3105 value = matrix.mapRect(value.toRectF());
never executed: value = matrix.mapRect(value.toRectF());
0
3106 else if (value.type() == QVariant::PointF)
never evaluated: value.type() == QVariant::PointF
0
3107 value = matrix.map(value.toPointF());
never executed: value = matrix.map(value.toPointF());
0
3108 else if (value.type() == QVariant::Rect)
never evaluated: value.type() == QVariant::Rect
0
3109 value = matrix.mapRect(value.toRect());
never executed: value = matrix.mapRect(value.toRect());
0
3110 else if (value.type() == QVariant::Point)
never evaluated: value.type() == QVariant::Point
0
3111 value = matrix.map(value.toPoint());
never executed: value = matrix.map(value.toPoint());
0
3112 return value;
never executed: return value;
0
3113} -
3114 -
3115/*! -
3116 \fn void QGraphicsScene::update(const QRectF &rect) -
3117 Schedules a redraw of the area \a rect on the scene. -
3118 -
3119 \sa sceneRect(), changed() -
3120*/ -
3121void QGraphicsScene::update(const QRectF &rect) -
3122{ -
3123 Q_D(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
3124 if (d->updateAll || (rect.isEmpty() && !rect.isNull()))
evaluated: d->updateAll
TRUEFALSE
yes
Evaluation Count:46
yes
Evaluation Count:277
evaluated: rect.isEmpty()
TRUEFALSE
yes
Evaluation Count:275
yes
Evaluation Count:2
partially evaluated: !rect.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:275
0-277
3125 return;
executed: return;
Execution Count:46
46
3126 -
3127 // Check if anyone's connected; if not, we can send updates directly to -
3128 // the views. Otherwise or if there are no views, use old behavior. -
3129 bool directUpdates = !(d->isSignalConnected(d->changedSignalIndex)) && !d->views.isEmpty();
partially evaluated: !(d->isSignalConnected(d->changedSignalIndex))
TRUEFALSE
yes
Evaluation Count:277
no
Evaluation Count:0
partially evaluated: !d->views.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:277
0-277
3130 if (rect.isNull()) {
evaluated: rect.isNull()
TRUEFALSE
yes
Evaluation Count:275
yes
Evaluation Count:2
2-275
3131 d->updateAll = true;
executed (the execution status of this line is deduced): d->updateAll = true;
-
3132 d->updatedRects.clear();
executed (the execution status of this line is deduced): d->updatedRects.clear();
-
3133 if (directUpdates) {
partially evaluated: directUpdates
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:275
0-275
3134 // Update all views. -
3135 for (int i = 0; i < d->views.size(); ++i)
never evaluated: i < d->views.size()
0
3136 d->views.at(i)->d_func()->fullUpdatePending = true;
never executed: d->views.at(i)->d_func()->fullUpdatePending = true;
0
3137 }
never executed: }
0
3138 } else {
executed: }
Execution Count:275
275
3139 if (directUpdates) {
partially evaluated: directUpdates
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
3140 // Update all views. -
3141 for (int i = 0; i < d->views.size(); ++i) {
never evaluated: i < d->views.size()
0
3142 QGraphicsView *view = d->views.at(i);
never executed (the execution status of this line is deduced): QGraphicsView *view = d->views.at(i);
-
3143 if (view->isTransformed())
never evaluated: view->isTransformed()
0
3144 view->d_func()->updateRectF(view->viewportTransform().mapRect(rect));
never executed: view->d_func()->updateRectF(view->viewportTransform().mapRect(rect));
0
3145 else -
3146 view->d_func()->updateRectF(rect);
never executed: view->d_func()->updateRectF(rect);
0
3147 } -
3148 } else {
never executed: }
0
3149 d->updatedRects << rect;
executed (the execution status of this line is deduced): d->updatedRects << rect;
-
3150 }
executed: }
Execution Count:2
2
3151 } -
3152 -
3153 if (!d->calledEmitUpdated) {
evaluated: !d->calledEmitUpdated
TRUEFALSE
yes
Evaluation Count:276
yes
Evaluation Count:1
1-276
3154 d->calledEmitUpdated = true;
executed (the execution status of this line is deduced): d->calledEmitUpdated = true;
-
3155 QMetaObject::invokeMethod(this, "_q_emitUpdated", Qt::QueuedConnection);
executed (the execution status of this line is deduced): QMetaObject::invokeMethod(this, "_q_emitUpdated", Qt::QueuedConnection);
-
3156 }
executed: }
Execution Count:276
276
3157}
executed: }
Execution Count:277
277
3158 -
3159/*! -
3160 \fn void QGraphicsScene::update(qreal x, qreal y, qreal w, qreal h) -
3161 \overload -
3162 \since 4.3 -
3163 -
3164 This function is equivalent to calling update(QRectF(\a x, \a y, \a w, -
3165 \a h)); -
3166*/ -
3167 -
3168/*! -
3169 Invalidates and schedules a redraw of the \a layers in \a rect on the -
3170 scene. Any cached content in \a layers is unconditionally invalidated and -
3171 redrawn. -
3172 -
3173 You can use this function overload to notify QGraphicsScene of changes to -
3174 the background or the foreground of the scene. This function is commonly -
3175 used for scenes with tile-based backgrounds to notify changes when -
3176 QGraphicsView has enabled -
3177 \l{QGraphicsView::CacheBackground}{CacheBackground}. -
3178 -
3179 Example: -
3180 -
3181 \snippet code/src_gui_graphicsview_qgraphicsscene.cpp 5 -
3182 -
3183 Note that QGraphicsView currently supports background caching only (see -
3184 QGraphicsView::CacheBackground). This function is equivalent to calling -
3185 update() if any layer but BackgroundLayer is passed. -
3186 -
3187 \sa QGraphicsView::resetCachedContent() -
3188*/ -
3189void QGraphicsScene::invalidate(const QRectF &rect, SceneLayers layers) -
3190{ -
3191 foreach (QGraphicsView *view, views())
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(views())> _container_(views()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsView *view = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
3192 view->invalidateScene(rect, layers);
never executed: view->invalidateScene(rect, layers);
0
3193 update(rect);
never executed (the execution status of this line is deduced): update(rect);
-
3194}
never executed: }
0
3195 -
3196/*! -
3197 \fn void QGraphicsScene::invalidate(qreal x, qreal y, qreal w, qreal h, SceneLayers layers) -
3198 \overload -
3199 \since 4.3 -
3200 -
3201 This convenience function is equivalent to calling invalidate(QRectF(\a x, \a -
3202 y, \a w, \a h), \a layers); -
3203*/ -
3204 -
3205/*! -
3206 Returns a list of all the views that display this scene. -
3207 -
3208 \sa QGraphicsView::scene() -
3209*/ -
3210QList <QGraphicsView *> QGraphicsScene::views() const -
3211{ -
3212 Q_D(const QGraphicsScene);
executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
3213 return d->views;
executed: return d->views;
Execution Count:147
147
3214} -
3215 -
3216/*! -
3217 This slot \e advances the scene by one step, by calling -
3218 QGraphicsItem::advance() for all items on the scene. This is done in two -
3219 phases: in the first phase, all items are notified that the scene is about -
3220 to change, and in the second phase all items are notified that they can -
3221 move. In the first phase, QGraphicsItem::advance() is called passing a -
3222 value of 0 as an argument, and 1 is passed in the second phase. -
3223 -
3224 Note that you can also use the \l{The Animation Framework}{Animation -
3225 Framework} for animations. -
3226 -
3227 \sa QGraphicsItem::advance(), QTimeLine -
3228*/ -
3229void QGraphicsScene::advance() -
3230{ -
3231 for (int i = 0; i < 2; ++i) {
never evaluated: i < 2
0
3232 foreach (QGraphicsItem *item, items())
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(items())> _container_(items()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
3233 item->advance(i);
never executed: item->advance(i);
0
3234 }
never executed: }
0
3235}
never executed: }
0
3236 -
3237/*! -
3238 Processes the event \a event, and dispatches it to the respective -
3239 event handlers. -
3240 -
3241 In addition to calling the convenience event handlers, this -
3242 function is responsible for converting mouse move events to hover -
3243 events for when there is no mouse grabber item. Hover events are -
3244 delivered directly to items; there is no convenience function for -
3245 them. -
3246 -
3247 Unlike QWidget, QGraphicsScene does not have the convenience functions -
3248 \l{QWidget::}{enterEvent()} and \l{QWidget::}{leaveEvent()}. Use this -
3249 function to obtain those events instead. -
3250 -
3251 \sa contextMenuEvent(), keyPressEvent(), keyReleaseEvent(), -
3252 mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(), -
3253 mouseDoubleClickEvent(), focusInEvent(), focusOutEvent() -
3254*/ -
3255bool QGraphicsScene::event(QEvent *event) -
3256{ -
3257 Q_D(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
3258 -
3259 switch (event->type()) { -
3260 case QEvent::GraphicsSceneMousePress: -
3261 case QEvent::GraphicsSceneMouseMove: -
3262 case QEvent::GraphicsSceneMouseRelease: -
3263 case QEvent::GraphicsSceneMouseDoubleClick: -
3264 case QEvent::GraphicsSceneHoverEnter: -
3265 case QEvent::GraphicsSceneHoverLeave: -
3266 case QEvent::GraphicsSceneHoverMove: -
3267 case QEvent::TouchBegin: -
3268 case QEvent::TouchUpdate: -
3269 case QEvent::TouchEnd: -
3270 // Reset the under-mouse list to ensure that this event gets fresh -
3271 // item-under-mouse data. Be careful about this list; if people delete -
3272 // items from inside event handlers, this list can quickly end up -
3273 // having stale pointers in it. We need to clear it before dispatching -
3274 // events that use it. -
3275 // ### this should only be cleared if we received a new mouse move event, -
3276 // which relies on us fixing the replay mechanism in QGraphicsView. -
3277 d->cachedItemsUnderMouse.clear();
executed (the execution status of this line is deduced): d->cachedItemsUnderMouse.clear();
-
3278 default: -
3279 break;
executed: break;
Execution Count:1008
1008
3280 } -
3281 -
3282 switch (event->type()) { -
3283 case QEvent::GraphicsSceneDragEnter: -
3284 dragEnterEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
never executed (the execution status of this line is deduced): dragEnterEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
-
3285 break;
never executed: break;
0
3286 case QEvent::GraphicsSceneDragMove: -
3287 dragMoveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
never executed (the execution status of this line is deduced): dragMoveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
-
3288 break;
never executed: break;
0
3289 case QEvent::GraphicsSceneDragLeave: -
3290 dragLeaveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
never executed (the execution status of this line is deduced): dragLeaveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
-
3291 break;
never executed: break;
0
3292 case QEvent::GraphicsSceneDrop: -
3293 dropEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
never executed (the execution status of this line is deduced): dropEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
-
3294 break;
never executed: break;
0
3295 case QEvent::GraphicsSceneContextMenu: -
3296 contextMenuEvent(static_cast<QGraphicsSceneContextMenuEvent *>(event));
never executed (the execution status of this line is deduced): contextMenuEvent(static_cast<QGraphicsSceneContextMenuEvent *>(event));
-
3297 break;
never executed: break;
0
3298 case QEvent::KeyPress: -
3299 if (!d->focusItem) {
never evaluated: !d->focusItem
0
3300 QKeyEvent *k = static_cast<QKeyEvent *>(event);
never executed (the execution status of this line is deduced): QKeyEvent *k = static_cast<QKeyEvent *>(event);
-
3301 if (k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) {
never evaluated: k->key() == Qt::Key_Tab
never evaluated: k->key() == Qt::Key_Backtab
0
3302 if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
never evaluated: !(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))
0
3303 bool res = false;
never executed (the execution status of this line is deduced): bool res = false;
-
3304 if (k->key() == Qt::Key_Backtab
never evaluated: k->key() == Qt::Key_Backtab
0
3305 || (k->key() == Qt::Key_Tab && (k->modifiers() & Qt::ShiftModifier))) {
never evaluated: k->key() == Qt::Key_Tab
never evaluated: (k->modifiers() & Qt::ShiftModifier)
0
3306 res = focusNextPrevChild(false);
never executed (the execution status of this line is deduced): res = focusNextPrevChild(false);
-
3307 } else if (k->key() == Qt::Key_Tab) {
never executed: }
never evaluated: k->key() == Qt::Key_Tab
0
3308 res = focusNextPrevChild(true);
never executed (the execution status of this line is deduced): res = focusNextPrevChild(true);
-
3309 }
never executed: }
0
3310 if (!res)
never evaluated: !res
0
3311 event->ignore();
never executed: event->ignore();
0
3312 return true;
never executed: return true;
0
3313 } -
3314 }
never executed: }
0
3315 }
never executed: }
0
3316 keyPressEvent(static_cast<QKeyEvent *>(event));
never executed (the execution status of this line is deduced): keyPressEvent(static_cast<QKeyEvent *>(event));
-
3317 break;
never executed: break;
0
3318 case QEvent::KeyRelease: -
3319 keyReleaseEvent(static_cast<QKeyEvent *>(event));
never executed (the execution status of this line is deduced): keyReleaseEvent(static_cast<QKeyEvent *>(event));
-
3320 break;
never executed: break;
0
3321 case QEvent::ShortcutOverride: { -
3322 QGraphicsItem *parent = focusItem();
never executed (the execution status of this line is deduced): QGraphicsItem *parent = focusItem();
-
3323 while (parent) {
never evaluated: parent
0
3324 d->sendEvent(parent, event);
never executed (the execution status of this line is deduced): d->sendEvent(parent, event);
-
3325 if (event->isAccepted())
never evaluated: event->isAccepted()
0
3326 return true;
never executed: return true;
0
3327 parent = parent->parentItem();
never executed (the execution status of this line is deduced): parent = parent->parentItem();
-
3328 }
never executed: }
0
3329 } -
3330 return false;
never executed: return false;
0
3331 case QEvent::GraphicsSceneMouseMove: -
3332 { -
3333 QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
never executed (the execution status of this line is deduced): QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
-
3334 d->lastSceneMousePos = mouseEvent->scenePos();
never executed (the execution status of this line is deduced): d->lastSceneMousePos = mouseEvent->scenePos();
-
3335 mouseMoveEvent(mouseEvent);
never executed (the execution status of this line is deduced): mouseMoveEvent(mouseEvent);
-
3336 break;
never executed: break;
0
3337 } -
3338 case QEvent::GraphicsSceneMousePress: -
3339 mousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
executed (the execution status of this line is deduced): mousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
-
3340 break;
executed: break;
Execution Count:3
3
3341 case QEvent::GraphicsSceneMouseRelease: -
3342 mouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
executed (the execution status of this line is deduced): mouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
-
3343 break;
executed: break;
Execution Count:3
3
3344 case QEvent::GraphicsSceneMouseDoubleClick: -
3345 mouseDoubleClickEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
never executed (the execution status of this line is deduced): mouseDoubleClickEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
-
3346 break;
never executed: break;
0
3347 case QEvent::GraphicsSceneWheel: -
3348 wheelEvent(static_cast<QGraphicsSceneWheelEvent *>(event));
never executed (the execution status of this line is deduced): wheelEvent(static_cast<QGraphicsSceneWheelEvent *>(event));
-
3349 break;
never executed: break;
0
3350 case QEvent::FocusIn: -
3351 focusInEvent(static_cast<QFocusEvent *>(event));
executed (the execution status of this line is deduced): focusInEvent(static_cast<QFocusEvent *>(event));
-
3352 break;
executed: break;
Execution Count:65
65
3353 case QEvent::FocusOut: -
3354 focusOutEvent(static_cast<QFocusEvent *>(event));
executed (the execution status of this line is deduced): focusOutEvent(static_cast<QFocusEvent *>(event));
-
3355 break;
executed: break;
Execution Count:2
2
3356 case QEvent::GraphicsSceneHoverEnter: -
3357 case QEvent::GraphicsSceneHoverLeave: -
3358 case QEvent::GraphicsSceneHoverMove: -
3359 { -
3360 QGraphicsSceneHoverEvent *hoverEvent = static_cast<QGraphicsSceneHoverEvent *>(event);
never executed (the execution status of this line is deduced): QGraphicsSceneHoverEvent *hoverEvent = static_cast<QGraphicsSceneHoverEvent *>(event);
-
3361 d->lastSceneMousePos = hoverEvent->scenePos();
never executed (the execution status of this line is deduced): d->lastSceneMousePos = hoverEvent->scenePos();
-
3362 d->dispatchHoverEvent(hoverEvent);
never executed (the execution status of this line is deduced): d->dispatchHoverEvent(hoverEvent);
-
3363 break;
never executed: break;
0
3364 } -
3365 case QEvent::Leave: -
3366 // hackieshly unpacking the viewport pointer from the leave event. -
3367 d->leaveScene(reinterpret_cast<QWidget *>(event->d));
never executed (the execution status of this line is deduced): d->leaveScene(reinterpret_cast<QWidget *>(event->d));
-
3368 break;
never executed: break;
0
3369 case QEvent::GraphicsSceneHelp: -
3370 helpEvent(static_cast<QGraphicsSceneHelpEvent *>(event));
never executed (the execution status of this line is deduced): helpEvent(static_cast<QGraphicsSceneHelpEvent *>(event));
-
3371 break;
never executed: break;
0
3372 case QEvent::InputMethod: -
3373 inputMethodEvent(static_cast<QInputMethodEvent *>(event));
never executed (the execution status of this line is deduced): inputMethodEvent(static_cast<QInputMethodEvent *>(event));
-
3374 break;
never executed: break;
0
3375 case QEvent::WindowActivate: -
3376 if (!d->activationRefCount++) {
evaluated: !d->activationRefCount++
TRUEFALSE
yes
Evaluation Count:51
yes
Evaluation Count:1
1-51
3377 if (d->lastActivePanel) {
evaluated: d->lastActivePanel
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:36
15-36
3378 // Activate the last panel. -
3379 d->setActivePanelHelper(d->lastActivePanel, true);
executed (the execution status of this line is deduced): d->setActivePanelHelper(d->lastActivePanel, true);
-
3380 } else if (d->tabFocusFirst && d->tabFocusFirst->isPanel()) {
executed: }
Execution Count:15
evaluated: d->tabFocusFirst
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:28
partially evaluated: d->tabFocusFirst->isPanel()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-28
3381 // Activate the panel of the first item in the tab focus -
3382 // chain. -
3383 d->setActivePanelHelper(d->tabFocusFirst, true);
never executed (the execution status of this line is deduced): d->setActivePanelHelper(d->tabFocusFirst, true);
-
3384 } else {
never executed: }
0
3385 // Activate all toplevel items. -
3386 QEvent event(QEvent::WindowActivate);
executed (the execution status of this line is deduced): QEvent event(QEvent::WindowActivate);
-
3387 foreach (QGraphicsItem *item, items()) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(items())> _container_(items()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
3388 if (item->isVisible() && !item->isPanel() && !item->parentItem())
evaluated: item->isVisible()
TRUEFALSE
yes
Evaluation Count:71
yes
Evaluation Count:1
partially evaluated: !item->isPanel()
TRUEFALSE
yes
Evaluation Count:71
no
Evaluation Count:0
evaluated: !item->parentItem()
TRUEFALSE
yes
Evaluation Count:54
yes
Evaluation Count:17
0-71
3389 sendEvent(item, &event);
executed: sendEvent(item, &event);
Execution Count:54
54
3390 }
executed: }
Execution Count:72
72
3391 }
executed: }
Execution Count:36
36
3392 } -
3393 break;
executed: break;
Execution Count:52
52
3394 case QEvent::WindowDeactivate: -
3395 if (!--d->activationRefCount) {
evaluated: !--d->activationRefCount
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
3396 if (d->activePanel) {
partially evaluated: d->activePanel
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
3397 // Deactivate the active panel (but keep it so we can -
3398 // reactivate it later). -
3399 QGraphicsItem *lastActivePanel = d->activePanel;
never executed (the execution status of this line is deduced): QGraphicsItem *lastActivePanel = d->activePanel;
-
3400 d->setActivePanelHelper(0, true);
never executed (the execution status of this line is deduced): d->setActivePanelHelper(0, true);
-
3401 d->lastActivePanel = lastActivePanel;
never executed (the execution status of this line is deduced): d->lastActivePanel = lastActivePanel;
-
3402 } else {
never executed: }
0
3403 // Activate all toplevel items. -
3404 QEvent event(QEvent::WindowDeactivate);
executed (the execution status of this line is deduced): QEvent event(QEvent::WindowDeactivate);
-
3405 foreach (QGraphicsItem *item, items()) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(items())> _container_(items()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
3406 if (item->isVisible() && !item->isPanel() && !item->parentItem())
partially evaluated: item->isVisible()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: !item->isPanel()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
evaluated: !item->parentItem()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
0-2
3407 sendEvent(item, &event);
executed: sendEvent(item, &event);
Execution Count:1
1
3408 }
executed: }
Execution Count:2
2
3409 }
executed: }
Execution Count:2
2
3410 } -
3411 break;
executed: break;
Execution Count:3
3
3412 case QEvent::ApplicationFontChange: { -
3413 // Resolve the existing scene font. -
3414 d->resolveFont();
never executed (the execution status of this line is deduced): d->resolveFont();
-
3415 break;
never executed: break;
0
3416 } -
3417 case QEvent::FontChange: -
3418 // Update the entire scene when the font changes. -
3419 update();
never executed (the execution status of this line is deduced): update();
-
3420 break;
never executed: break;
0
3421 case QEvent::ApplicationPaletteChange: { -
3422 // Resolve the existing scene palette. -
3423 d->resolvePalette();
never executed (the execution status of this line is deduced): d->resolvePalette();
-
3424 break;
never executed: break;
0
3425 } -
3426 case QEvent::PaletteChange: -
3427 // Update the entire scene when the palette changes. -
3428 update();
never executed (the execution status of this line is deduced): update();
-
3429 break;
never executed: break;
0
3430 case QEvent::StyleChange: -
3431 // Reresolve all widgets' styles. Update all top-level widgets' -
3432 // geometries that do not have an explicit style set. -
3433 update();
never executed (the execution status of this line is deduced): update();
-
3434 break;
never executed: break;
0
3435 case QEvent::StyleAnimationUpdate: -
3436 // Because QGraphicsItem is not a QObject, QStyle driven -
3437 // animations are forced to update the whole scene -
3438 update();
never executed (the execution status of this line is deduced): update();
-
3439 break;
never executed: break;
0
3440 case QEvent::TouchBegin: -
3441 case QEvent::TouchUpdate: -
3442 case QEvent::TouchEnd: -
3443 d->touchEventHandler(static_cast<QTouchEvent *>(event));
never executed (the execution status of this line is deduced): d->touchEventHandler(static_cast<QTouchEvent *>(event));
-
3444 break;
never executed: break;
0
3445#ifndef QT_NO_GESTURES -
3446 case QEvent::Gesture: -
3447 case QEvent::GestureOverride: -
3448 d->gestureEventHandler(static_cast<QGestureEvent *>(event));
executed (the execution status of this line is deduced): d->gestureEventHandler(static_cast<QGestureEvent *>(event));
-
3449 break;
executed: break;
Execution Count:144
144
3450#endif // QT_NO_GESTURES -
3451 default: -
3452 return QObject::event(event);
executed: return QObject::event(event);
Execution Count:736
736
3453 } -
3454 return true;
executed: return true;
Execution Count:272
272
3455} -
3456 -
3457/*! -
3458 \reimp -
3459 -
3460 QGraphicsScene filters QApplication's events to detect palette and font -
3461 changes. -
3462*/ -
3463bool QGraphicsScene::eventFilter(QObject *watched, QEvent *event) -
3464{ -
3465 if (watched != qApp)
never evaluated: watched != (static_cast<QApplication *>(QCoreApplication::instance()))
0
3466 return false;
never executed: return false;
0
3467 -
3468 switch (event->type()) { -
3469 case QEvent::ApplicationPaletteChange: -
3470 QApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange));
never executed (the execution status of this line is deduced): QApplication::postEvent(this, new QEvent(QEvent::ApplicationPaletteChange));
-
3471 break;
never executed: break;
0
3472 case QEvent::ApplicationFontChange: -
3473 QApplication::postEvent(this, new QEvent(QEvent::ApplicationFontChange));
never executed (the execution status of this line is deduced): QApplication::postEvent(this, new QEvent(QEvent::ApplicationFontChange));
-
3474 break;
never executed: break;
0
3475 default: -
3476 break;
never executed: break;
0
3477 } -
3478 return false;
never executed: return false;
0
3479} -
3480 -
3481/*! -
3482 This event handler, for event \a contextMenuEvent, can be reimplemented in -
3483 a subclass to receive context menu events. The default implementation -
3484 forwards the event to the topmost visible item that accepts context menu events at -
3485 the position of the event. If no items accept context menu events at this -
3486 position, the event is ignored. -
3487 -
3488 Note: See items() for a definition of which items are considered visible by this function. -
3489 -
3490 \sa QGraphicsItem::contextMenuEvent() -
3491*/ -
3492void QGraphicsScene::contextMenuEvent(QGraphicsSceneContextMenuEvent *contextMenuEvent) -
3493{ -
3494 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
3495 // Ignore by default. -
3496 contextMenuEvent->ignore();
never executed (the execution status of this line is deduced): contextMenuEvent->ignore();
-
3497 -
3498 // Send the event to all items at this position until one item accepts the -
3499 // event. -
3500 foreach (QGraphicsItem *item, d->itemsAtPosition(contextMenuEvent->screenPos(),
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(d->itemsAtPosition(contextMenuEvent->screenPos(), contextMenuEvent->scenePos(), contextMenuEvent->widget()))> _container_(d->itemsAtPosition(contextMenuEvent->screenPos(), contextMenuEvent->scenePos(), contextMenuEvent->widget())); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
3501 contextMenuEvent->scenePos(), -
3502 contextMenuEvent->widget())) { -
3503 contextMenuEvent->setPos(item->d_ptr->genericMapFromScene(contextMenuEvent->scenePos(),
never executed (the execution status of this line is deduced): contextMenuEvent->setPos(item->d_ptr->genericMapFromScene(contextMenuEvent->scenePos(),
-
3504 contextMenuEvent->widget()));
never executed (the execution status of this line is deduced): contextMenuEvent->widget()));
-
3505 contextMenuEvent->accept();
never executed (the execution status of this line is deduced): contextMenuEvent->accept();
-
3506 if (!d->sendEvent(item, contextMenuEvent))
never evaluated: !d->sendEvent(item, contextMenuEvent)
0
3507 break;
never executed: break;
0
3508 -
3509 if (contextMenuEvent->isAccepted())
never evaluated: contextMenuEvent->isAccepted()
0
3510 break;
never executed: break;
0
3511 }
never executed: }
0
3512}
never executed: }
0
3513 -
3514/*! -
3515 This event handler, for event \a event, can be reimplemented in a subclass -
3516 to receive drag enter events for the scene. -
3517 -
3518 The default implementation accepts the event and prepares the scene to -
3519 accept drag move events. -
3520 -
3521 \sa QGraphicsItem::dragEnterEvent(), dragMoveEvent(), dragLeaveEvent(), -
3522 dropEvent() -
3523*/ -
3524void QGraphicsScene::dragEnterEvent(QGraphicsSceneDragDropEvent *event) -
3525{ -
3526 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
3527 d->dragDropItem = 0;
never executed (the execution status of this line is deduced): d->dragDropItem = 0;
-
3528 d->lastDropAction = Qt::IgnoreAction;
never executed (the execution status of this line is deduced): d->lastDropAction = Qt::IgnoreAction;
-
3529 event->accept();
never executed (the execution status of this line is deduced): event->accept();
-
3530}
never executed: }
0
3531 -
3532/*! -
3533 This event handler, for event \a event, can be reimplemented in a subclass -
3534 to receive drag move events for the scene. -
3535 -
3536 Note: See items() for a definition of which items are considered visible by this function. -
3537 -
3538 \sa QGraphicsItem::dragMoveEvent(), dragEnterEvent(), dragLeaveEvent(), -
3539 dropEvent() -
3540*/ -
3541void QGraphicsScene::dragMoveEvent(QGraphicsSceneDragDropEvent *event) -
3542{ -
3543 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
3544 event->ignore();
never executed (the execution status of this line is deduced): event->ignore();
-
3545 -
3546 if (!d->mouseGrabberItems.isEmpty()) {
never evaluated: !d->mouseGrabberItems.isEmpty()
0
3547 // Mouse grabbers that start drag events lose the mouse grab. -
3548 d->clearMouseGrabber();
never executed (the execution status of this line is deduced): d->clearMouseGrabber();
-
3549 d->mouseGrabberButtonDownPos.clear();
never executed (the execution status of this line is deduced): d->mouseGrabberButtonDownPos.clear();
-
3550 d->mouseGrabberButtonDownScenePos.clear();
never executed (the execution status of this line is deduced): d->mouseGrabberButtonDownScenePos.clear();
-
3551 d->mouseGrabberButtonDownScreenPos.clear();
never executed (the execution status of this line is deduced): d->mouseGrabberButtonDownScreenPos.clear();
-
3552 }
never executed: }
0
3553 -
3554 bool eventDelivered = false;
never executed (the execution status of this line is deduced): bool eventDelivered = false;
-
3555 -
3556 // Find the topmost enabled items under the cursor. They are all -
3557 // candidates for accepting drag & drop events. -
3558 foreach (QGraphicsItem *item, d->itemsAtPosition(event->screenPos(),
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(d->itemsAtPosition(event->screenPos(), event->scenePos(), event->widget()))> _container_(d->itemsAtPosition(event->screenPos(), event->scenePos(), event->widget())); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
3559 event->scenePos(), -
3560 event->widget())) { -
3561 if (!item->isEnabled() || !item->acceptDrops())
never evaluated: !item->isEnabled()
never evaluated: !item->acceptDrops()
0
3562 continue;
never executed: continue;
0
3563 -
3564 if (item != d->dragDropItem) {
never evaluated: item != d->dragDropItem
0
3565 // Enter the new drag drop item. If it accepts the event, we send -
3566 // the leave to the parent item. -
3567 QGraphicsSceneDragDropEvent dragEnter(QEvent::GraphicsSceneDragEnter);
never executed (the execution status of this line is deduced): QGraphicsSceneDragDropEvent dragEnter(QEvent::GraphicsSceneDragEnter);
-
3568 d->cloneDragDropEvent(&dragEnter, event);
never executed (the execution status of this line is deduced): d->cloneDragDropEvent(&dragEnter, event);
-
3569 dragEnter.setDropAction(event->proposedAction());
never executed (the execution status of this line is deduced): dragEnter.setDropAction(event->proposedAction());
-
3570 d->sendDragDropEvent(item, &dragEnter);
never executed (the execution status of this line is deduced): d->sendDragDropEvent(item, &dragEnter);
-
3571 event->setAccepted(dragEnter.isAccepted());
never executed (the execution status of this line is deduced): event->setAccepted(dragEnter.isAccepted());
-
3572 event->setDropAction(dragEnter.dropAction());
never executed (the execution status of this line is deduced): event->setDropAction(dragEnter.dropAction());
-
3573 if (!event->isAccepted()) {
never evaluated: !event->isAccepted()
0
3574 // Propagate to the item under -
3575 continue;
never executed: continue;
0
3576 } -
3577 -
3578 d->lastDropAction = event->dropAction();
never executed (the execution status of this line is deduced): d->lastDropAction = event->dropAction();
-
3579 -
3580 if (d->dragDropItem) {
never evaluated: d->dragDropItem
0
3581 // Leave the last drag drop item. A perfect implementation -
3582 // would set the position of this event to the point where -
3583 // this event and the last event intersect with the item's -
3584 // shape, but that's not easy to do. :-) -
3585 QGraphicsSceneDragDropEvent dragLeave(QEvent::GraphicsSceneDragLeave);
never executed (the execution status of this line is deduced): QGraphicsSceneDragDropEvent dragLeave(QEvent::GraphicsSceneDragLeave);
-
3586 d->cloneDragDropEvent(&dragLeave, event);
never executed (the execution status of this line is deduced): d->cloneDragDropEvent(&dragLeave, event);
-
3587 d->sendDragDropEvent(d->dragDropItem, &dragLeave);
never executed (the execution status of this line is deduced): d->sendDragDropEvent(d->dragDropItem, &dragLeave);
-
3588 }
never executed: }
0
3589 -
3590 // We've got a new drag & drop item -
3591 d->dragDropItem = item;
never executed (the execution status of this line is deduced): d->dragDropItem = item;
-
3592 }
never executed: }
0
3593 -
3594 // Send the move event. -
3595 event->setDropAction(d->lastDropAction);
never executed (the execution status of this line is deduced): event->setDropAction(d->lastDropAction);
-
3596 event->accept();
never executed (the execution status of this line is deduced): event->accept();
-
3597 d->sendDragDropEvent(item, event);
never executed (the execution status of this line is deduced): d->sendDragDropEvent(item, event);
-
3598 if (event->isAccepted())
never evaluated: event->isAccepted()
0
3599 d->lastDropAction = event->dropAction();
never executed: d->lastDropAction = event->dropAction();
0
3600 eventDelivered = true;
never executed (the execution status of this line is deduced): eventDelivered = true;
-
3601 break;
never executed: break;
0
3602 } -
3603 -
3604 if (!eventDelivered) {
never evaluated: !eventDelivered
0
3605 if (d->dragDropItem) {
never evaluated: d->dragDropItem
0
3606 // Leave the last drag drop item -
3607 QGraphicsSceneDragDropEvent dragLeave(QEvent::GraphicsSceneDragLeave);
never executed (the execution status of this line is deduced): QGraphicsSceneDragDropEvent dragLeave(QEvent::GraphicsSceneDragLeave);
-
3608 d->cloneDragDropEvent(&dragLeave, event);
never executed (the execution status of this line is deduced): d->cloneDragDropEvent(&dragLeave, event);
-
3609 d->sendDragDropEvent(d->dragDropItem, &dragLeave);
never executed (the execution status of this line is deduced): d->sendDragDropEvent(d->dragDropItem, &dragLeave);
-
3610 d->dragDropItem = 0;
never executed (the execution status of this line is deduced): d->dragDropItem = 0;
-
3611 }
never executed: }
0
3612 // Propagate -
3613 event->setDropAction(Qt::IgnoreAction);
never executed (the execution status of this line is deduced): event->setDropAction(Qt::IgnoreAction);
-
3614 }
never executed: }
0
3615}
never executed: }
0
3616 -
3617/*! -
3618 This event handler, for event \a event, can be reimplemented in a subclass -
3619 to receive drag leave events for the scene. -
3620 -
3621 \sa QGraphicsItem::dragLeaveEvent(), dragEnterEvent(), dragMoveEvent(), -
3622 dropEvent() -
3623*/ -
3624void QGraphicsScene::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) -
3625{ -
3626 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
3627 if (d->dragDropItem) {
never evaluated: d->dragDropItem
0
3628 // Leave the last drag drop item -
3629 d->sendDragDropEvent(d->dragDropItem, event);
never executed (the execution status of this line is deduced): d->sendDragDropEvent(d->dragDropItem, event);
-
3630 d->dragDropItem = 0;
never executed (the execution status of this line is deduced): d->dragDropItem = 0;
-
3631 }
never executed: }
0
3632}
never executed: }
0
3633 -
3634/*! -
3635 This event handler, for event \a event, can be reimplemented in a subclass -
3636 to receive drop events for the scene. -
3637 -
3638 \sa QGraphicsItem::dropEvent(), dragEnterEvent(), dragMoveEvent(), -
3639 dragLeaveEvent() -
3640*/ -
3641void QGraphicsScene::dropEvent(QGraphicsSceneDragDropEvent *event) -
3642{ -
3643 Q_UNUSED(event);
never executed (the execution status of this line is deduced): (void)event;;
-
3644 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
3645 if (d->dragDropItem) {
never evaluated: d->dragDropItem
0
3646 // Drop on the last drag drop item -
3647 d->sendDragDropEvent(d->dragDropItem, event);
never executed (the execution status of this line is deduced): d->sendDragDropEvent(d->dragDropItem, event);
-
3648 d->dragDropItem = 0;
never executed (the execution status of this line is deduced): d->dragDropItem = 0;
-
3649 }
never executed: }
0
3650}
never executed: }
0
3651 -
3652/*! -
3653 This event handler, for event \a focusEvent, can be reimplemented in a -
3654 subclass to receive focus in events. -
3655 -
3656 The default implementation sets focus on the scene, and then on the last -
3657 focus item. -
3658 -
3659 \sa QGraphicsItem::focusOutEvent() -
3660*/ -
3661void QGraphicsScene::focusInEvent(QFocusEvent *focusEvent) -
3662{ -
3663 Q_D(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
3664 -
3665 d->hasFocus = true;
executed (the execution status of this line is deduced): d->hasFocus = true;
-
3666 switch (focusEvent->reason()) { -
3667 case Qt::TabFocusReason: -
3668 if (!focusNextPrevChild(true))
never evaluated: !focusNextPrevChild(true)
0
3669 focusEvent->ignore();
never executed: focusEvent->ignore();
0
3670 break;
never executed: break;
0
3671 case Qt::BacktabFocusReason: -
3672 if (!focusNextPrevChild(false))
never evaluated: !focusNextPrevChild(false)
0
3673 focusEvent->ignore();
never executed: focusEvent->ignore();
0
3674 break;
never executed: break;
0
3675 default: -
3676 if (d->passiveFocusItem) {
partially evaluated: d->passiveFocusItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:65
0-65
3677 // Set focus on the last focus item -
3678 setFocusItem(d->passiveFocusItem, focusEvent->reason());
never executed (the execution status of this line is deduced): setFocusItem(d->passiveFocusItem, focusEvent->reason());
-
3679 }
never executed: }
0
3680 break;
executed: break;
Execution Count:65
65
3681 } -
3682}
executed: }
Execution Count:65
65
3683 -
3684/*! -
3685 This event handler, for event \a focusEvent, can be reimplemented in a -
3686 subclass to receive focus out events. -
3687 -
3688 The default implementation removes focus from any focus item, then removes -
3689 focus from the scene. -
3690 -
3691 \sa QGraphicsItem::focusInEvent() -
3692*/ -
3693void QGraphicsScene::focusOutEvent(QFocusEvent *focusEvent) -
3694{ -
3695 Q_D(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
3696 d->hasFocus = false;
executed (the execution status of this line is deduced): d->hasFocus = false;
-
3697 d->passiveFocusItem = d->focusItem;
executed (the execution status of this line is deduced): d->passiveFocusItem = d->focusItem;
-
3698 setFocusItem(0, focusEvent->reason());
executed (the execution status of this line is deduced): setFocusItem(0, focusEvent->reason());
-
3699 -
3700 // Remove all popups when the scene loses focus. -
3701 if (!d->popupWidgets.isEmpty())
partially evaluated: !d->popupWidgets.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
3702 d->removePopup(d->popupWidgets.first());
never executed: d->removePopup(d->popupWidgets.first());
0
3703}
executed: }
Execution Count:2
2
3704 -
3705/*! -
3706 This event handler, for event \a helpEvent, can be -
3707 reimplemented in a subclass to receive help events. The events -
3708 are of type QEvent::ToolTip, which are created when a tooltip is -
3709 requested. -
3710 -
3711 The default implementation shows the tooltip of the topmost -
3712 visible item, i.e., the item with the highest z-value, at the mouse -
3713 cursor position. If no item has a tooltip set, this function -
3714 does nothing. -
3715 -
3716 Note: See items() for a definition of which items are considered visible by this function. -
3717 -
3718 \sa QGraphicsItem::toolTip(), QGraphicsSceneHelpEvent -
3719*/ -
3720void QGraphicsScene::helpEvent(QGraphicsSceneHelpEvent *helpEvent) -
3721{ -
3722#ifdef QT_NO_TOOLTIP -
3723 Q_UNUSED(helpEvent); -
3724#else -
3725 // Find the first item that does tooltips -
3726 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
3727 QList<QGraphicsItem *> itemsAtPos = d->itemsAtPosition(helpEvent->screenPos(),
never executed (the execution status of this line is deduced): QList<QGraphicsItem *> itemsAtPos = d->itemsAtPosition(helpEvent->screenPos(),
-
3728 helpEvent->scenePos(),
never executed (the execution status of this line is deduced): helpEvent->scenePos(),
-
3729 helpEvent->widget());
never executed (the execution status of this line is deduced): helpEvent->widget());
-
3730 QGraphicsItem *toolTipItem = 0;
never executed (the execution status of this line is deduced): QGraphicsItem *toolTipItem = 0;
-
3731 for (int i = 0; i < itemsAtPos.size(); ++i) {
never evaluated: i < itemsAtPos.size()
0
3732 QGraphicsItem *tmp = itemsAtPos.at(i);
never executed (the execution status of this line is deduced): QGraphicsItem *tmp = itemsAtPos.at(i);
-
3733 if (tmp->d_func()->isProxyWidget()) {
never evaluated: tmp->d_func()->isProxyWidget()
0
3734 // if the item is a proxy widget, the event is forwarded to it -
3735 sendEvent(tmp, helpEvent);
never executed (the execution status of this line is deduced): sendEvent(tmp, helpEvent);
-
3736 if (helpEvent->isAccepted())
never evaluated: helpEvent->isAccepted()
0
3737 return;
never executed: return;
0
3738 }
never executed: }
0
3739 if (!tmp->toolTip().isEmpty()) {
never evaluated: !tmp->toolTip().isEmpty()
0
3740 toolTipItem = tmp;
never executed (the execution status of this line is deduced): toolTipItem = tmp;
-
3741 break;
never executed: break;
0
3742 } -
3743 }
never executed: }
0
3744 -
3745 // Show or hide the tooltip -
3746 QString text;
never executed (the execution status of this line is deduced): QString text;
-
3747 QPoint point;
never executed (the execution status of this line is deduced): QPoint point;
-
3748 if (toolTipItem && !toolTipItem->toolTip().isEmpty()) {
never evaluated: toolTipItem
never evaluated: !toolTipItem->toolTip().isEmpty()
0
3749 text = toolTipItem->toolTip();
never executed (the execution status of this line is deduced): text = toolTipItem->toolTip();
-
3750 point = helpEvent->screenPos();
never executed (the execution status of this line is deduced): point = helpEvent->screenPos();
-
3751 }
never executed: }
0
3752 QToolTip::showText(point, text, helpEvent->widget());
never executed (the execution status of this line is deduced): QToolTip::showText(point, text, helpEvent->widget());
-
3753 helpEvent->setAccepted(!text.isEmpty());
never executed (the execution status of this line is deduced): helpEvent->setAccepted(!text.isEmpty());
-
3754#endif -
3755}
never executed: }
0
3756 -
3757bool QGraphicsScenePrivate::itemAcceptsHoverEvents_helper(const QGraphicsItem *item) const -
3758{ -
3759 return (item->d_ptr->acceptsHover
executed: return (item->d_ptr->acceptsHover || (item->d_ptr->isWidget && static_cast<const QGraphicsWidget *>(item)->d_func()->hasDecoration())) && !item->isBlockedByModalPanel();
Execution Count:316
316
3760 || (item->d_ptr->isWidget
executed: return (item->d_ptr->acceptsHover || (item->d_ptr->isWidget && static_cast<const QGraphicsWidget *>(item)->d_func()->hasDecoration())) && !item->isBlockedByModalPanel();
Execution Count:316
316
3761 && static_cast<const QGraphicsWidget *>(item)->d_func()->hasDecoration()))
executed: return (item->d_ptr->acceptsHover || (item->d_ptr->isWidget && static_cast<const QGraphicsWidget *>(item)->d_func()->hasDecoration())) && !item->isBlockedByModalPanel();
Execution Count:316
316
3762 && !item->isBlockedByModalPanel();
executed: return (item->d_ptr->acceptsHover || (item->d_ptr->isWidget && static_cast<const QGraphicsWidget *>(item)->d_func()->hasDecoration())) && !item->isBlockedByModalPanel();
Execution Count:316
316
3763} -
3764 -
3765/*! -
3766 This event handler, for event \a hoverEvent, can be reimplemented in a -
3767 subclass to receive hover enter events. The default implementation -
3768 forwards the event to the topmost visible item that accepts hover events at the -
3769 scene position from the event. -
3770 -
3771 Note: See items() for a definition of which items are considered visible by this function. -
3772 -
3773 \sa QGraphicsItem::hoverEvent(), QGraphicsItem::setAcceptHoverEvents() -
3774*/ -
3775bool QGraphicsScenePrivate::dispatchHoverEvent(QGraphicsSceneHoverEvent *hoverEvent) -
3776{ -
3777 if (allItemsIgnoreHoverEvents)
partially evaluated: allItemsIgnoreHoverEvents
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
3778 return false;
executed: return false;
Execution Count:6
6
3779 -
3780 // Find the first item that accepts hover events, reusing earlier -
3781 // calculated data is possible. -
3782 if (cachedItemsUnderMouse.isEmpty()) {
never evaluated: cachedItemsUnderMouse.isEmpty()
0
3783 cachedItemsUnderMouse = itemsAtPosition(hoverEvent->screenPos(),
never executed (the execution status of this line is deduced): cachedItemsUnderMouse = itemsAtPosition(hoverEvent->screenPos(),
-
3784 hoverEvent->scenePos(),
never executed (the execution status of this line is deduced): hoverEvent->scenePos(),
-
3785 hoverEvent->widget());
never executed (the execution status of this line is deduced): hoverEvent->widget());
-
3786 }
never executed: }
0
3787 -
3788 QGraphicsItem *item = 0;
never executed (the execution status of this line is deduced): QGraphicsItem *item = 0;
-
3789 for (int i = 0; i < cachedItemsUnderMouse.size(); ++i) {
never evaluated: i < cachedItemsUnderMouse.size()
0
3790 QGraphicsItem *tmp = cachedItemsUnderMouse.at(i);
never executed (the execution status of this line is deduced): QGraphicsItem *tmp = cachedItemsUnderMouse.at(i);
-
3791 if (itemAcceptsHoverEvents_helper(tmp)) {
never evaluated: itemAcceptsHoverEvents_helper(tmp)
0
3792 item = tmp;
never executed (the execution status of this line is deduced): item = tmp;
-
3793 break;
never executed: break;
0
3794 } -
3795 }
never executed: }
0
3796 -
3797 // Find the common ancestor item for the new topmost hoverItem and the -
3798 // last item in the hoverItem list. -
3799 QGraphicsItem *commonAncestorItem = (item && !hoverItems.isEmpty()) ? item->commonAncestorItem(hoverItems.last()) : 0;
never evaluated: item
never evaluated: !hoverItems.isEmpty()
0
3800 while (commonAncestorItem && !itemAcceptsHoverEvents_helper(commonAncestorItem))
never evaluated: commonAncestorItem
never evaluated: !itemAcceptsHoverEvents_helper(commonAncestorItem)
0
3801 commonAncestorItem = commonAncestorItem->parentItem();
never executed: commonAncestorItem = commonAncestorItem->parentItem();
0
3802 if (commonAncestorItem && commonAncestorItem->panel() != item->panel()) {
never evaluated: commonAncestorItem
never evaluated: commonAncestorItem->panel() != item->panel()
0
3803 // The common ancestor isn't in the same panel as the two hovered -
3804 // items. -
3805 commonAncestorItem = 0;
never executed (the execution status of this line is deduced): commonAncestorItem = 0;
-
3806 }
never executed: }
0
3807 -
3808 // Check if the common ancestor item is known. -
3809 int index = commonAncestorItem ? hoverItems.indexOf(commonAncestorItem) : -1;
never evaluated: commonAncestorItem
0
3810 // Send hover leaves to any existing hovered children of the common -
3811 // ancestor item. -
3812 for (int i = hoverItems.size() - 1; i > index; --i) {
never evaluated: i > index
0
3813 QGraphicsItem *lastItem = hoverItems.takeLast();
never executed (the execution status of this line is deduced): QGraphicsItem *lastItem = hoverItems.takeLast();
-
3814 if (itemAcceptsHoverEvents_helper(lastItem))
never evaluated: itemAcceptsHoverEvents_helper(lastItem)
0
3815 sendHoverEvent(QEvent::GraphicsSceneHoverLeave, lastItem, hoverEvent);
never executed: sendHoverEvent(QEvent::GraphicsSceneHoverLeave, lastItem, hoverEvent);
0
3816 }
never executed: }
0
3817 -
3818 // Item is a child of a known item. Generate enter events for the -
3819 // missing links. -
3820 QList<QGraphicsItem *> parents;
never executed (the execution status of this line is deduced): QList<QGraphicsItem *> parents;
-
3821 QGraphicsItem *parent = item;
never executed (the execution status of this line is deduced): QGraphicsItem *parent = item;
-
3822 while (parent && parent != commonAncestorItem) {
never evaluated: parent
never evaluated: parent != commonAncestorItem
0
3823 parents.prepend(parent);
never executed (the execution status of this line is deduced): parents.prepend(parent);
-
3824 if (parent->isPanel()) {
never evaluated: parent->isPanel()
0
3825 // Stop at the panel - we don't deliver beyond this point. -
3826 break;
never executed: break;
0
3827 } -
3828 parent = parent->parentItem();
never executed (the execution status of this line is deduced): parent = parent->parentItem();
-
3829 }
never executed: }
0
3830 for (int i = 0; i < parents.size(); ++i) {
never evaluated: i < parents.size()
0
3831 parent = parents.at(i);
never executed (the execution status of this line is deduced): parent = parents.at(i);
-
3832 hoverItems << parent;
never executed (the execution status of this line is deduced): hoverItems << parent;
-
3833 if (itemAcceptsHoverEvents_helper(parent))
never evaluated: itemAcceptsHoverEvents_helper(parent)
0
3834 sendHoverEvent(QEvent::GraphicsSceneHoverEnter, parent, hoverEvent);
never executed: sendHoverEvent(QEvent::GraphicsSceneHoverEnter, parent, hoverEvent);
0
3835 }
never executed: }
0
3836 -
3837 // Generate a move event for the item itself -
3838 if (item
never evaluated: item
0
3839 && !hoverItems.isEmpty()
never evaluated: !hoverItems.isEmpty()
0
3840 && item == hoverItems.last()) {
never evaluated: item == hoverItems.last()
0
3841 sendHoverEvent(QEvent::GraphicsSceneHoverMove, item, hoverEvent);
never executed (the execution status of this line is deduced): sendHoverEvent(QEvent::GraphicsSceneHoverMove, item, hoverEvent);
-
3842 return true;
never executed: return true;
0
3843 } -
3844 return false;
never executed: return false;
0
3845} -
3846 -
3847/*! -
3848 \internal -
3849 -
3850 Handles all actions necessary to clean up the scene when the mouse leaves -
3851 the view. -
3852*/ -
3853void QGraphicsScenePrivate::leaveScene(QWidget *viewport) -
3854{ -
3855#ifndef QT_NO_TOOLTIP -
3856 QToolTip::hideText();
never executed (the execution status of this line is deduced): QToolTip::hideText();
-
3857#endif -
3858 QGraphicsView *view = qobject_cast<QGraphicsView *>(viewport->parent());
never executed (the execution status of this line is deduced): QGraphicsView *view = qobject_cast<QGraphicsView *>(viewport->parent());
-
3859 // Send HoverLeave events to all existing hover items, topmost first. -
3860 QGraphicsSceneHoverEvent hoverEvent;
never executed (the execution status of this line is deduced): QGraphicsSceneHoverEvent hoverEvent;
-
3861 hoverEvent.setWidget(viewport);
never executed (the execution status of this line is deduced): hoverEvent.setWidget(viewport);
-
3862 -
3863 if (view) {
never evaluated: view
0
3864 QPoint cursorPos = QCursor::pos();
never executed (the execution status of this line is deduced): QPoint cursorPos = QCursor::pos();
-
3865 hoverEvent.setScenePos(view->mapToScene(viewport->mapFromGlobal(cursorPos)));
never executed (the execution status of this line is deduced): hoverEvent.setScenePos(view->mapToScene(viewport->mapFromGlobal(cursorPos)));
-
3866 hoverEvent.setLastScenePos(hoverEvent.scenePos());
never executed (the execution status of this line is deduced): hoverEvent.setLastScenePos(hoverEvent.scenePos());
-
3867 hoverEvent.setScreenPos(cursorPos);
never executed (the execution status of this line is deduced): hoverEvent.setScreenPos(cursorPos);
-
3868 hoverEvent.setLastScreenPos(hoverEvent.screenPos());
never executed (the execution status of this line is deduced): hoverEvent.setLastScreenPos(hoverEvent.screenPos());
-
3869 }
never executed: }
0
3870 -
3871 while (!hoverItems.isEmpty()) {
never evaluated: !hoverItems.isEmpty()
0
3872 QGraphicsItem *lastItem = hoverItems.takeLast();
never executed (the execution status of this line is deduced): QGraphicsItem *lastItem = hoverItems.takeLast();
-
3873 if (itemAcceptsHoverEvents_helper(lastItem))
never evaluated: itemAcceptsHoverEvents_helper(lastItem)
0
3874 sendHoverEvent(QEvent::GraphicsSceneHoverLeave, lastItem, &hoverEvent);
never executed: sendHoverEvent(QEvent::GraphicsSceneHoverLeave, lastItem, &hoverEvent);
0
3875 }
never executed: }
0
3876}
never executed: }
0
3877 -
3878/*! -
3879 This event handler, for event \a keyEvent, can be reimplemented in a -
3880 subclass to receive keypress events. The default implementation forwards -
3881 the event to current focus item. -
3882 -
3883 \sa QGraphicsItem::keyPressEvent(), focusItem() -
3884*/ -
3885void QGraphicsScene::keyPressEvent(QKeyEvent *keyEvent) -
3886{ -
3887 // ### Merge this function with keyReleaseEvent; they are identical -
3888 // ### (except this comment). -
3889 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
3890 QGraphicsItem *item = !d->keyboardGrabberItems.isEmpty() ? d->keyboardGrabberItems.last() : 0;
never evaluated: !d->keyboardGrabberItems.isEmpty()
0
3891 if (!item)
never evaluated: !item
0
3892 item = focusItem();
never executed: item = focusItem();
0
3893 if (item) {
never evaluated: item
0
3894 QGraphicsItem *p = item;
never executed (the execution status of this line is deduced): QGraphicsItem *p = item;
-
3895 do { -
3896 // Accept the event by default -
3897 keyEvent->accept();
never executed (the execution status of this line is deduced): keyEvent->accept();
-
3898 // Send it; QGraphicsItem::keyPressEvent ignores it. If the event -
3899 // is filtered out, stop propagating it. -
3900 if (p->isBlockedByModalPanel())
never evaluated: p->isBlockedByModalPanel()
0
3901 break;
never executed: break;
0
3902 if (!d->sendEvent(p, keyEvent))
never evaluated: !d->sendEvent(p, keyEvent)
0
3903 break;
never executed: break;
0
3904 } while (!keyEvent->isAccepted() && !p->isPanel() && (p = p->parentItem()));
never executed: }
never evaluated: !keyEvent->isAccepted()
never evaluated: !p->isPanel()
never evaluated: (p = p->parentItem())
0
3905 } else {
never executed: }
0
3906 keyEvent->ignore();
never executed (the execution status of this line is deduced): keyEvent->ignore();
-
3907 }
never executed: }
0
3908} -
3909 -
3910/*! -
3911 This event handler, for event \a keyEvent, can be reimplemented in a -
3912 subclass to receive key release events. The default implementation -
3913 forwards the event to current focus item. -
3914 -
3915 \sa QGraphicsItem::keyReleaseEvent(), focusItem() -
3916*/ -
3917void QGraphicsScene::keyReleaseEvent(QKeyEvent *keyEvent) -
3918{ -
3919 // ### Merge this function with keyPressEvent; they are identical (except -
3920 // ### this comment). -
3921 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
3922 QGraphicsItem *item = !d->keyboardGrabberItems.isEmpty() ? d->keyboardGrabberItems.last() : 0;
never evaluated: !d->keyboardGrabberItems.isEmpty()
0
3923 if (!item)
never evaluated: !item
0
3924 item = focusItem();
never executed: item = focusItem();
0
3925 if (item) {
never evaluated: item
0
3926 QGraphicsItem *p = item;
never executed (the execution status of this line is deduced): QGraphicsItem *p = item;
-
3927 do { -
3928 // Accept the event by default -
3929 keyEvent->accept();
never executed (the execution status of this line is deduced): keyEvent->accept();
-
3930 // Send it; QGraphicsItem::keyPressEvent ignores it. If the event -
3931 // is filtered out, stop propagating it. -
3932 if (p->isBlockedByModalPanel())
never evaluated: p->isBlockedByModalPanel()
0
3933 break;
never executed: break;
0
3934 if (!d->sendEvent(p, keyEvent))
never evaluated: !d->sendEvent(p, keyEvent)
0
3935 break;
never executed: break;
0
3936 } while (!keyEvent->isAccepted() && !p->isPanel() && (p = p->parentItem()));
never executed: }
never evaluated: !keyEvent->isAccepted()
never evaluated: !p->isPanel()
never evaluated: (p = p->parentItem())
0
3937 } else {
never executed: }
0
3938 keyEvent->ignore();
never executed (the execution status of this line is deduced): keyEvent->ignore();
-
3939 }
never executed: }
0
3940} -
3941 -
3942/*! -
3943 This event handler, for event \a mouseEvent, can be reimplemented -
3944 in a subclass to receive mouse press events for the scene. -
3945 -
3946 The default implementation depends on the state of the scene. If -
3947 there is a mouse grabber item, then the event is sent to the mouse -
3948 grabber. Otherwise, it is forwarded to the topmost visible item that -
3949 accepts mouse events at the scene position from the event, and -
3950 that item promptly becomes the mouse grabber item. -
3951 -
3952 If there is no item at the given position on the scene, the -
3953 selection area is reset, any focus item loses its input focus, and -
3954 the event is then ignored. -
3955 -
3956 Note: See items() for a definition of which items are considered visible by this function. -
3957 -
3958 \sa QGraphicsItem::mousePressEvent(), -
3959 QGraphicsItem::setAcceptedMouseButtons() -
3960*/ -
3961void QGraphicsScene::mousePressEvent(QGraphicsSceneMouseEvent *mouseEvent) -
3962{ -
3963 Q_D(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
3964 if (d->mouseGrabberItems.isEmpty()) {
evaluated: d->mouseGrabberItems.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
3965 // Dispatch hover events -
3966 QGraphicsSceneHoverEvent hover;
executed (the execution status of this line is deduced): QGraphicsSceneHoverEvent hover;
-
3967 _q_hoverFromMouseEvent(&hover, mouseEvent);
executed (the execution status of this line is deduced): _q_hoverFromMouseEvent(&hover, mouseEvent);
-
3968 d->dispatchHoverEvent(&hover);
executed (the execution status of this line is deduced): d->dispatchHoverEvent(&hover);
-
3969 }
executed: }
Execution Count:2
2
3970 -
3971 d->mousePressEventHandler(mouseEvent);
executed (the execution status of this line is deduced): d->mousePressEventHandler(mouseEvent);
-
3972}
executed: }
Execution Count:3
3
3973 -
3974/*! -
3975 This event handler, for event \a mouseEvent, can be reimplemented -
3976 in a subclass to receive mouse move events for the scene. -
3977 -
3978 The default implementation depends on the mouse grabber state. If there is -
3979 a mouse grabber item, the event is sent to the mouse grabber. If there -
3980 are any items that accept hover events at the current position, the event -
3981 is translated into a hover event and accepted; otherwise it's ignored. -
3982 -
3983 \sa QGraphicsItem::mousePressEvent(), QGraphicsItem::mouseReleaseEvent(), -
3984 QGraphicsItem::mouseDoubleClickEvent(), QGraphicsItem::setAcceptedMouseButtons() -
3985*/ -
3986void QGraphicsScene::mouseMoveEvent(QGraphicsSceneMouseEvent *mouseEvent) -
3987{ -
3988 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
3989 if (d->mouseGrabberItems.isEmpty()) {
never evaluated: d->mouseGrabberItems.isEmpty()
0
3990 if (mouseEvent->buttons())
never evaluated: mouseEvent->buttons()
0
3991 return;
never executed: return;
0
3992 QGraphicsSceneHoverEvent hover;
never executed (the execution status of this line is deduced): QGraphicsSceneHoverEvent hover;
-
3993 _q_hoverFromMouseEvent(&hover, mouseEvent);
never executed (the execution status of this line is deduced): _q_hoverFromMouseEvent(&hover, mouseEvent);
-
3994 mouseEvent->setAccepted(d->dispatchHoverEvent(&hover));
never executed (the execution status of this line is deduced): mouseEvent->setAccepted(d->dispatchHoverEvent(&hover));
-
3995 return;
never executed: return;
0
3996 } -
3997 -
3998 // Forward the event to the mouse grabber -
3999 d->sendMouseEvent(mouseEvent);
never executed (the execution status of this line is deduced): d->sendMouseEvent(mouseEvent);
-
4000 mouseEvent->accept();
never executed (the execution status of this line is deduced): mouseEvent->accept();
-
4001}
never executed: }
0
4002 -
4003/*! -
4004 This event handler, for event \a mouseEvent, can be reimplemented -
4005 in a subclass to receive mouse release events for the scene. -
4006 -
4007 The default implementation depends on the mouse grabber state. If -
4008 there is no mouse grabber, the event is ignored. Otherwise, if -
4009 there is a mouse grabber item, the event is sent to the mouse -
4010 grabber. If this mouse release represents the last pressed button -
4011 on the mouse, the mouse grabber item then loses the mouse grab. -
4012 -
4013 \sa QGraphicsItem::mousePressEvent(), QGraphicsItem::mouseMoveEvent(), -
4014 QGraphicsItem::mouseDoubleClickEvent(), QGraphicsItem::setAcceptedMouseButtons() -
4015*/ -
4016void QGraphicsScene::mouseReleaseEvent(QGraphicsSceneMouseEvent *mouseEvent) -
4017{ -
4018 Q_D(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
4019 if (d->mouseGrabberItems.isEmpty()) {
evaluated: d->mouseGrabberItems.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
4020 mouseEvent->ignore();
executed (the execution status of this line is deduced): mouseEvent->ignore();
-
4021 return;
executed: return;
Execution Count:1
1
4022 } -
4023 -
4024 // Forward the event to the mouse grabber -
4025 d->sendMouseEvent(mouseEvent);
executed (the execution status of this line is deduced): d->sendMouseEvent(mouseEvent);
-
4026 mouseEvent->accept();
executed (the execution status of this line is deduced): mouseEvent->accept();
-
4027 -
4028 // Reset the mouse grabber when the last mouse button has been released. -
4029 if (!mouseEvent->buttons()) {
partially evaluated: !mouseEvent->buttons()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
4030 if (!d->mouseGrabberItems.isEmpty()) {
partially evaluated: !d->mouseGrabberItems.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
4031 d->lastMouseGrabberItem = d->mouseGrabberItems.last();
executed (the execution status of this line is deduced): d->lastMouseGrabberItem = d->mouseGrabberItems.last();
-
4032 if (d->lastMouseGrabberItemHasImplicitMouseGrab)
partially evaluated: d->lastMouseGrabberItemHasImplicitMouseGrab
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
4033 d->mouseGrabberItems.last()->ungrabMouse();
executed: d->mouseGrabberItems.last()->ungrabMouse();
Execution Count:2
2
4034 } else {
executed: }
Execution Count:2
2
4035 d->lastMouseGrabberItem = 0;
never executed (the execution status of this line is deduced): d->lastMouseGrabberItem = 0;
-
4036 }
never executed: }
0
4037 -
4038 // Generate a hoverevent -
4039 QGraphicsSceneHoverEvent hoverEvent;
executed (the execution status of this line is deduced): QGraphicsSceneHoverEvent hoverEvent;
-
4040 _q_hoverFromMouseEvent(&hoverEvent, mouseEvent);
executed (the execution status of this line is deduced): _q_hoverFromMouseEvent(&hoverEvent, mouseEvent);
-
4041 d->dispatchHoverEvent(&hoverEvent);
executed (the execution status of this line is deduced): d->dispatchHoverEvent(&hoverEvent);
-
4042 }
executed: }
Execution Count:2
2
4043}
executed: }
Execution Count:2
2
4044 -
4045/*! -
4046 This event handler, for event \a mouseEvent, can be reimplemented -
4047 in a subclass to receive mouse doubleclick events for the scene. -
4048 -
4049 If someone doubleclicks on the scene, the scene will first receive -
4050 a mouse press event, followed by a release event (i.e., a click), -
4051 then a doubleclick event, and finally a release event. If the -
4052 doubleclick event is delivered to a different item than the one -
4053 that received the first press and release, it will be delivered as -
4054 a press event. However, tripleclick events are not delivered as -
4055 doubleclick events in this case. -
4056 -
4057 The default implementation is similar to mousePressEvent(). -
4058 -
4059 Note: See items() for a definition of which items are considered visible by this function. -
4060 -
4061 \sa QGraphicsItem::mousePressEvent(), QGraphicsItem::mouseMoveEvent(), -
4062 QGraphicsItem::mouseReleaseEvent(), QGraphicsItem::setAcceptedMouseButtons() -
4063*/ -
4064void QGraphicsScene::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *mouseEvent) -
4065{ -
4066 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
4067 d->mousePressEventHandler(mouseEvent);
never executed (the execution status of this line is deduced): d->mousePressEventHandler(mouseEvent);
-
4068}
never executed: }
0
4069 -
4070/*! -
4071 This event handler, for event \a wheelEvent, can be reimplemented in a -
4072 subclass to receive mouse wheel events for the scene. -
4073 -
4074 By default, the event is delivered to the topmost visible item under the -
4075 cursor. If ignored, the event propagates to the item beneath, and again -
4076 until the event is accepted, or it reaches the scene. If no items accept -
4077 the event, it is ignored. -
4078 -
4079 Note: See items() for a definition of which items are considered visible by this function. -
4080 -
4081 \sa QGraphicsItem::wheelEvent() -
4082*/ -
4083void QGraphicsScene::wheelEvent(QGraphicsSceneWheelEvent *wheelEvent) -
4084{ -
4085 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
4086 QList<QGraphicsItem *> wheelCandidates = d->itemsAtPosition(wheelEvent->screenPos(),
never executed (the execution status of this line is deduced): QList<QGraphicsItem *> wheelCandidates = d->itemsAtPosition(wheelEvent->screenPos(),
-
4087 wheelEvent->scenePos(),
never executed (the execution status of this line is deduced): wheelEvent->scenePos(),
-
4088 wheelEvent->widget());
never executed (the execution status of this line is deduced): wheelEvent->widget());
-
4089 -
4090#ifdef Q_WS_MAC -
4091 // On Mac, ignore the event if the first item under the mouse is not the last opened -
4092 // popup (or one of its descendant) -
4093 if (!d->popupWidgets.isEmpty() && !wheelCandidates.isEmpty() && wheelCandidates.first() != d->popupWidgets.back() && !d->popupWidgets.back()->isAncestorOf(wheelCandidates.first())) { -
4094 wheelEvent->accept(); -
4095 return; -
4096 } -
4097#else -
4098 // Find the first popup under the mouse (including the popup's descendants) starting from the last. -
4099 // Remove all popups after the one found, or all or them if no popup is under the mouse. -
4100 // Then continue with the event. -
4101 QList<QGraphicsWidget *>::const_iterator iter = d->popupWidgets.constEnd();
never executed (the execution status of this line is deduced): QList<QGraphicsWidget *>::const_iterator iter = d->popupWidgets.constEnd();
-
4102 while (--iter >= d->popupWidgets.constBegin() && !wheelCandidates.isEmpty()) {
never evaluated: --iter >= d->popupWidgets.constBegin()
never evaluated: !wheelCandidates.isEmpty()
0
4103 if (wheelCandidates.first() == *iter || (*iter)->isAncestorOf(wheelCandidates.first()))
never evaluated: wheelCandidates.first() == *iter
never evaluated: (*iter)->isAncestorOf(wheelCandidates.first())
0
4104 break;
never executed: break;
0
4105 d->removePopup(*iter);
never executed (the execution status of this line is deduced): d->removePopup(*iter);
-
4106 }
never executed: }
0
4107#endif -
4108 -
4109 bool hasSetFocus = false;
never executed (the execution status of this line is deduced): bool hasSetFocus = false;
-
4110 foreach (QGraphicsItem *item, wheelCandidates) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(wheelCandidates)> _container_(wheelCandidates); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
4111 if (!hasSetFocus && item->isEnabled()
never evaluated: !hasSetFocus
never evaluated: item->isEnabled()
0
4112 && ((item->flags() & QGraphicsItem::ItemIsFocusable) && item->d_ptr->mouseSetsFocus)) {
never evaluated: (item->flags() & QGraphicsItem::ItemIsFocusable)
never evaluated: item->d_ptr->mouseSetsFocus
0
4113 if (item->isWidget() && static_cast<QGraphicsWidget *>(item)->focusPolicy() == Qt::WheelFocus) {
never evaluated: item->isWidget()
never evaluated: static_cast<QGraphicsWidget *>(item)->focusPolicy() == Qt::WheelFocus
0
4114 hasSetFocus = true;
never executed (the execution status of this line is deduced): hasSetFocus = true;
-
4115 if (item != focusItem())
never evaluated: item != focusItem()
0
4116 setFocusItem(item, Qt::MouseFocusReason);
never executed: setFocusItem(item, Qt::MouseFocusReason);
0
4117 }
never executed: }
0
4118 }
never executed: }
0
4119 -
4120 wheelEvent->setPos(item->d_ptr->genericMapFromScene(wheelEvent->scenePos(),
never executed (the execution status of this line is deduced): wheelEvent->setPos(item->d_ptr->genericMapFromScene(wheelEvent->scenePos(),
-
4121 wheelEvent->widget()));
never executed (the execution status of this line is deduced): wheelEvent->widget()));
-
4122 wheelEvent->accept();
never executed (the execution status of this line is deduced): wheelEvent->accept();
-
4123 bool isPanel = item->isPanel();
never executed (the execution status of this line is deduced): bool isPanel = item->isPanel();
-
4124 d->sendEvent(item, wheelEvent);
never executed (the execution status of this line is deduced): d->sendEvent(item, wheelEvent);
-
4125 if (isPanel || wheelEvent->isAccepted())
never evaluated: isPanel
never evaluated: wheelEvent->isAccepted()
0
4126 break;
never executed: break;
0
4127 }
never executed: }
0
4128}
never executed: }
0
4129 -
4130/*! -
4131 This event handler, for event \a event, can be reimplemented in a -
4132 subclass to receive input method events for the scene. -
4133 -
4134 The default implementation forwards the event to the focusItem(). -
4135 If no item currently has focus or the current focus item does not -
4136 accept input methods, this function does nothing. -
4137 -
4138 \sa QGraphicsItem::inputMethodEvent() -
4139*/ -
4140void QGraphicsScene::inputMethodEvent(QInputMethodEvent *event) -
4141{ -
4142 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
4143 if (d->focusItem && (d->focusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod))
never evaluated: d->focusItem
never evaluated: (d->focusItem->flags() & QGraphicsItem::ItemAcceptsInputMethod)
0
4144 d->sendEvent(d->focusItem, event);
never executed: d->sendEvent(d->focusItem, event);
0
4145}
never executed: }
0
4146 -
4147/*! -
4148 Draws the background of the scene using \a painter, before any items and -
4149 the foreground are drawn. Reimplement this function to provide a custom -
4150 background for the scene. -
4151 -
4152 All painting is done in \e scene coordinates. The \a rect -
4153 parameter is the exposed rectangle. -
4154 -
4155 If all you want is to define a color, texture, or gradient for the -
4156 background, you can call setBackgroundBrush() instead. -
4157 -
4158 \sa drawForeground(), drawItems() -
4159*/ -
4160void QGraphicsScene::drawBackground(QPainter *painter, const QRectF &rect) -
4161{ -
4162 Q_D(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
4163 -
4164 if (d->backgroundBrush.style() != Qt::NoBrush) {
partially evaluated: d->backgroundBrush.style() != Qt::NoBrush
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:132
0-132
4165 if (d->painterStateProtection)
never evaluated: d->painterStateProtection
0
4166 painter->save();
never executed: painter->save();
0
4167 painter->setBrushOrigin(0, 0);
never executed (the execution status of this line is deduced): painter->setBrushOrigin(0, 0);
-
4168 painter->fillRect(rect, backgroundBrush());
never executed (the execution status of this line is deduced): painter->fillRect(rect, backgroundBrush());
-
4169 if (d->painterStateProtection)
never evaluated: d->painterStateProtection
0
4170 painter->restore();
never executed: painter->restore();
0
4171 }
never executed: }
0
4172}
executed: }
Execution Count:132
132
4173 -
4174/*! -
4175 Draws the foreground of the scene using \a painter, after the background -
4176 and all items have been drawn. Reimplement this function to provide a -
4177 custom foreground for the scene. -
4178 -
4179 All painting is done in \e scene coordinates. The \a rect -
4180 parameter is the exposed rectangle. -
4181 -
4182 If all you want is to define a color, texture or gradient for the -
4183 foreground, you can call setForegroundBrush() instead. -
4184 -
4185 \sa drawBackground(), drawItems() -
4186*/ -
4187void QGraphicsScene::drawForeground(QPainter *painter, const QRectF &rect) -
4188{ -
4189 Q_D(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
4190 -
4191 if (d->foregroundBrush.style() != Qt::NoBrush) {
partially evaluated: d->foregroundBrush.style() != Qt::NoBrush
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:132
0-132
4192 if (d->painterStateProtection)
never evaluated: d->painterStateProtection
0
4193 painter->save();
never executed: painter->save();
0
4194 painter->setBrushOrigin(0, 0);
never executed (the execution status of this line is deduced): painter->setBrushOrigin(0, 0);
-
4195 painter->fillRect(rect, foregroundBrush());
never executed (the execution status of this line is deduced): painter->fillRect(rect, foregroundBrush());
-
4196 if (d->painterStateProtection)
never evaluated: d->painterStateProtection
0
4197 painter->restore();
never executed: painter->restore();
0
4198 }
never executed: }
0
4199}
executed: }
Execution Count:132
132
4200 -
4201static void _q_paintItem(QGraphicsItem *item, QPainter *painter, -
4202 const QStyleOptionGraphicsItem *option, QWidget *widget, -
4203 bool useWindowOpacity, bool painterStateProtection) -
4204{ -
4205 if (!item->isWidget()) {
partially evaluated: !item->isWidget()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:240
0-240
4206 item->paint(painter, option, widget);
never executed (the execution status of this line is deduced): item->paint(painter, option, widget);
-
4207 return;
never executed: return;
0
4208 } -
4209 QGraphicsWidget *widgetItem = static_cast<QGraphicsWidget *>(item);
executed (the execution status of this line is deduced): QGraphicsWidget *widgetItem = static_cast<QGraphicsWidget *>(item);
-
4210 QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(widgetItem);
executed (the execution status of this line is deduced): QGraphicsProxyWidget *proxy = qobject_cast<QGraphicsProxyWidget *>(widgetItem);
-
4211 const qreal windowOpacity = (proxy && proxy->widget() && useWindowOpacity)
evaluated: proxy
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:239
partially evaluated: proxy->widget()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: useWindowOpacity
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-239
4212 ? proxy->widget()->windowOpacity() : 1.0;
executed (the execution status of this line is deduced): ? proxy->widget()->windowOpacity() : 1.0;
-
4213 const qreal oldPainterOpacity = painter->opacity();
executed (the execution status of this line is deduced): const qreal oldPainterOpacity = painter->opacity();
-
4214 -
4215 if (qFuzzyIsNull(windowOpacity))
partially evaluated: qFuzzyIsNull(windowOpacity)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:240
0-240
4216 return;
never executed: return;
0
4217 // Set new painter opacity. -
4218 if (windowOpacity < 1.0)
partially evaluated: windowOpacity < 1.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:240
0-240
4219 painter->setOpacity(oldPainterOpacity * windowOpacity);
never executed: painter->setOpacity(oldPainterOpacity * windowOpacity);
0
4220 -
4221 // set layoutdirection on the painter -
4222 Qt::LayoutDirection oldLayoutDirection = painter->layoutDirection();
executed (the execution status of this line is deduced): Qt::LayoutDirection oldLayoutDirection = painter->layoutDirection();
-
4223 painter->setLayoutDirection(widgetItem->layoutDirection());
executed (the execution status of this line is deduced): painter->setLayoutDirection(widgetItem->layoutDirection());
-
4224 -
4225 if (widgetItem->isWindow() && widgetItem->windowType() != Qt::Popup && widgetItem->windowType() != Qt::ToolTip
evaluated: widgetItem->isWindow()
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:210
partially evaluated: widgetItem->windowType() != Qt::Popup
TRUEFALSE
yes
Evaluation Count:30
no
Evaluation Count:0
partially evaluated: widgetItem->windowType() != Qt::ToolTip
TRUEFALSE
yes
Evaluation Count:30
no
Evaluation Count:0
0-210
4226 && !(widgetItem->windowFlags() & Qt::FramelessWindowHint)) {
partially evaluated: !(widgetItem->windowFlags() & Qt::FramelessWindowHint)
TRUEFALSE
yes
Evaluation Count:30
no
Evaluation Count:0
0-30
4227 if (painterStateProtection)
partially evaluated: painterStateProtection
TRUEFALSE
yes
Evaluation Count:30
no
Evaluation Count:0
0-30
4228 painter->save();
executed: painter->save();
Execution Count:30
30
4229 widgetItem->paintWindowFrame(painter, option, widget);
executed (the execution status of this line is deduced): widgetItem->paintWindowFrame(painter, option, widget);
-
4230 if (painterStateProtection)
partially evaluated: painterStateProtection
TRUEFALSE
yes
Evaluation Count:30
no
Evaluation Count:0
0-30
4231 painter->restore();
executed: painter->restore();
Execution Count:30
30
4232 } else if (widgetItem->autoFillBackground()) {
executed: }
Execution Count:30
partially evaluated: widgetItem->autoFillBackground()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:210
0-210
4233 painter->fillRect(option->exposedRect, widgetItem->palette().window());
never executed (the execution status of this line is deduced): painter->fillRect(option->exposedRect, widgetItem->palette().window());
-
4234 }
never executed: }
0
4235 -
4236 widgetItem->paint(painter, option, widget);
executed (the execution status of this line is deduced): widgetItem->paint(painter, option, widget);
-
4237 -
4238 // Restore layoutdirection on the painter. -
4239 painter->setLayoutDirection(oldLayoutDirection);
executed (the execution status of this line is deduced): painter->setLayoutDirection(oldLayoutDirection);
-
4240 // Restore painter opacity. -
4241 if (windowOpacity < 1.0)
partially evaluated: windowOpacity < 1.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:240
0-240
4242 painter->setOpacity(oldPainterOpacity);
never executed: painter->setOpacity(oldPainterOpacity);
0
4243}
executed: }
Execution Count:240
240
4244 -
4245static void _q_paintIntoCache(QPixmap *pix, QGraphicsItem *item, const QRegion &pixmapExposed, -
4246 const QTransform &itemToPixmap, QPainter::RenderHints renderHints, -
4247 const QStyleOptionGraphicsItem *option, bool painterStateProtection) -
4248{ -
4249 QPixmap subPix;
never executed (the execution status of this line is deduced): QPixmap subPix;
-
4250 QPainter pixmapPainter;
never executed (the execution status of this line is deduced): QPainter pixmapPainter;
-
4251 QRect br = pixmapExposed.boundingRect();
never executed (the execution status of this line is deduced): QRect br = pixmapExposed.boundingRect();
-
4252 -
4253 // Don't use subpixmap if we get a full update. -
4254 if (pixmapExposed.isEmpty() || (pixmapExposed.rectCount() == 1 && br.contains(pix->rect()))) {
never evaluated: pixmapExposed.isEmpty()
never evaluated: pixmapExposed.rectCount() == 1
never evaluated: br.contains(pix->rect())
0
4255 pix->fill(Qt::transparent);
never executed (the execution status of this line is deduced): pix->fill(Qt::transparent);
-
4256 pixmapPainter.begin(pix);
never executed (the execution status of this line is deduced): pixmapPainter.begin(pix);
-
4257 } else {
never executed: }
0
4258 subPix = QPixmap(br.size());
never executed (the execution status of this line is deduced): subPix = QPixmap(br.size());
-
4259 subPix.fill(Qt::transparent);
never executed (the execution status of this line is deduced): subPix.fill(Qt::transparent);
-
4260 pixmapPainter.begin(&subPix);
never executed (the execution status of this line is deduced): pixmapPainter.begin(&subPix);
-
4261 pixmapPainter.translate(-br.topLeft());
never executed (the execution status of this line is deduced): pixmapPainter.translate(-br.topLeft());
-
4262 if (!pixmapExposed.isEmpty()) {
never evaluated: !pixmapExposed.isEmpty()
0
4263 // Applied to subPix; paint is adjusted to the coordinate space is -
4264 // correct. -
4265 pixmapPainter.setClipRegion(pixmapExposed);
never executed (the execution status of this line is deduced): pixmapPainter.setClipRegion(pixmapExposed);
-
4266 }
never executed: }
0
4267 }
never executed: }
0
4268 -
4269 pixmapPainter.setRenderHints(pixmapPainter.renderHints(), false);
never executed (the execution status of this line is deduced): pixmapPainter.setRenderHints(pixmapPainter.renderHints(), false);
-
4270 pixmapPainter.setRenderHints(renderHints, true);
never executed (the execution status of this line is deduced): pixmapPainter.setRenderHints(renderHints, true);
-
4271 pixmapPainter.setWorldTransform(itemToPixmap, true);
never executed (the execution status of this line is deduced): pixmapPainter.setWorldTransform(itemToPixmap, true);
-
4272 -
4273 // Render. -
4274 _q_paintItem(item, &pixmapPainter, option, 0, false, painterStateProtection);
never executed (the execution status of this line is deduced): _q_paintItem(item, &pixmapPainter, option, 0, false, painterStateProtection);
-
4275 pixmapPainter.end();
never executed (the execution status of this line is deduced): pixmapPainter.end();
-
4276 -
4277 if (!subPix.isNull()) {
never evaluated: !subPix.isNull()
0
4278 // Blit the subpixmap into the main pixmap. -
4279 pixmapPainter.begin(pix);
never executed (the execution status of this line is deduced): pixmapPainter.begin(pix);
-
4280 pixmapPainter.setCompositionMode(QPainter::CompositionMode_Source);
never executed (the execution status of this line is deduced): pixmapPainter.setCompositionMode(QPainter::CompositionMode_Source);
-
4281 pixmapPainter.setClipRegion(pixmapExposed);
never executed (the execution status of this line is deduced): pixmapPainter.setClipRegion(pixmapExposed);
-
4282 pixmapPainter.drawPixmap(br.topLeft(), subPix);
never executed (the execution status of this line is deduced): pixmapPainter.drawPixmap(br.topLeft(), subPix);
-
4283 pixmapPainter.end();
never executed (the execution status of this line is deduced): pixmapPainter.end();
-
4284 }
never executed: }
0
4285}
never executed: }
0
4286 -
4287// Copied from qpaintengine_vg.cpp -
4288// Returns true for 90, 180, and 270 degree rotations. -
4289static inline bool transformIsSimple(const QTransform& transform) -
4290{ -
4291 QTransform::TransformationType type = transform.type();
never executed (the execution status of this line is deduced): QTransform::TransformationType type = transform.type();
-
4292 if (type <= QTransform::TxScale) {
never evaluated: type <= QTransform::TxScale
0
4293 return true;
never executed: return true;
0
4294 } else if (type == QTransform::TxRotate) {
never evaluated: type == QTransform::TxRotate
0
4295 // Check for 90, and 270 degree rotations. -
4296 qreal m11 = transform.m11();
never executed (the execution status of this line is deduced): qreal m11 = transform.m11();
-
4297 qreal m12 = transform.m12();
never executed (the execution status of this line is deduced): qreal m12 = transform.m12();
-
4298 qreal m21 = transform.m21();
never executed (the execution status of this line is deduced): qreal m21 = transform.m21();
-
4299 qreal m22 = transform.m22();
never executed (the execution status of this line is deduced): qreal m22 = transform.m22();
-
4300 if (m11 == 0.0f && m22 == 0.0f) {
never evaluated: m11 == 0.0f
never evaluated: m22 == 0.0f
0
4301 if (m12 == 1.0f && m21 == -1.0f)
never evaluated: m12 == 1.0f
never evaluated: m21 == -1.0f
0
4302 return true; // 90 degrees.
never executed: return true;
0
4303 else if (m12 == -1.0f && m21 == 1.0f)
never evaluated: m12 == -1.0f
never evaluated: m21 == 1.0f
0
4304 return true; // 270 degrees.
never executed: return true;
0
4305 else if (m12 == -1.0f && m21 == -1.0f)
never evaluated: m12 == -1.0f
never evaluated: m21 == -1.0f
0
4306 return true; // 90 degrees inverted y.
never executed: return true;
0
4307 else if (m12 == 1.0f && m21 == 1.0f)
never evaluated: m12 == 1.0f
never evaluated: m21 == 1.0f
0
4308 return true; // 270 degrees inverted y.
never executed: return true;
0
4309 } -
4310 }
never executed: }
0
4311 return false;
never executed: return false;
0
4312} -
4313 -
4314/*! -
4315 \internal -
4316 -
4317 Draws items directly, or using cache. -
4318*/ -
4319void QGraphicsScenePrivate::drawItemHelper(QGraphicsItem *item, QPainter *painter, -
4320 const QStyleOptionGraphicsItem *option, QWidget *widget, -
4321 bool painterStateProtection) -
4322{ -
4323 QGraphicsItemPrivate *itemd = item->d_ptr.data();
executed (the execution status of this line is deduced): QGraphicsItemPrivate *itemd = item->d_ptr.data();
-
4324 QGraphicsItem::CacheMode cacheMode = QGraphicsItem::CacheMode(itemd->cacheMode);
executed (the execution status of this line is deduced): QGraphicsItem::CacheMode cacheMode = QGraphicsItem::CacheMode(itemd->cacheMode);
-
4325 -
4326 // Render directly, using no cache. -
4327 if (cacheMode == QGraphicsItem::NoCache
partially evaluated: cacheMode == QGraphicsItem::NoCache
TRUEFALSE
yes
Evaluation Count:240
no
Evaluation Count:0
0-240
4328#ifdef Q_WS_X11 -
4329 || !X11->use_xrender -
4330#endif -
4331 ) { -
4332 _q_paintItem(static_cast<QGraphicsWidget *>(item), painter, option, widget, true, painterStateProtection);
executed (the execution status of this line is deduced): _q_paintItem(static_cast<QGraphicsWidget *>(item), painter, option, widget, true, painterStateProtection);
-
4333 return;
executed: return;
Execution Count:240
240
4334 } -
4335 -
4336 const qreal oldPainterOpacity = painter->opacity();
never executed (the execution status of this line is deduced): const qreal oldPainterOpacity = painter->opacity();
-
4337 qreal newPainterOpacity = oldPainterOpacity;
never executed (the execution status of this line is deduced): qreal newPainterOpacity = oldPainterOpacity;
-
4338 QGraphicsProxyWidget *proxy = item->isWidget() ? qobject_cast<QGraphicsProxyWidget *>(static_cast<QGraphicsWidget *>(item)) : 0;
never evaluated: item->isWidget()
0
4339 if (proxy && proxy->widget()) {
never evaluated: proxy
never evaluated: proxy->widget()
0
4340 const qreal windowOpacity = proxy->widget()->windowOpacity();
never executed (the execution status of this line is deduced): const qreal windowOpacity = proxy->widget()->windowOpacity();
-
4341 if (windowOpacity < 1.0)
never evaluated: windowOpacity < 1.0
0
4342 newPainterOpacity *= windowOpacity;
never executed: newPainterOpacity *= windowOpacity;
0
4343 }
never executed: }
0
4344 -
4345 // Item's (local) bounding rect -
4346 QRectF brect = item->boundingRect();
never executed (the execution status of this line is deduced): QRectF brect = item->boundingRect();
-
4347 QRectF adjustedBrect(brect);
never executed (the execution status of this line is deduced): QRectF adjustedBrect(brect);
-
4348 _q_adjustRect(&adjustedBrect);
never executed (the execution status of this line is deduced): _q_adjustRect(&adjustedBrect);
-
4349 if (adjustedBrect.isEmpty())
never evaluated: adjustedBrect.isEmpty()
0
4350 return;
never executed: return;
0
4351 -
4352 // Fetch the off-screen transparent buffer and exposed area info. -
4353 QPixmapCache::Key pixmapKey;
never executed (the execution status of this line is deduced): QPixmapCache::Key pixmapKey;
-
4354 QPixmap pix;
never executed (the execution status of this line is deduced): QPixmap pix;
-
4355 bool pixmapFound;
never executed (the execution status of this line is deduced): bool pixmapFound;
-
4356 QGraphicsItemCache *itemCache = itemd->extraItemCache();
never executed (the execution status of this line is deduced): QGraphicsItemCache *itemCache = itemd->extraItemCache();
-
4357 if (cacheMode == QGraphicsItem::ItemCoordinateCache) {
never evaluated: cacheMode == QGraphicsItem::ItemCoordinateCache
0
4358 pixmapKey = itemCache->key;
never executed (the execution status of this line is deduced): pixmapKey = itemCache->key;
-
4359 } else {
never executed: }
0
4360 pixmapKey = itemCache->deviceData.value(widget).key;
never executed (the execution status of this line is deduced): pixmapKey = itemCache->deviceData.value(widget).key;
-
4361 }
never executed: }
0
4362 -
4363 // Find pixmap in cache. -
4364 pixmapFound = QPixmapCache::find(pixmapKey, &pix);
never executed (the execution status of this line is deduced): pixmapFound = QPixmapCache::find(pixmapKey, &pix);
-
4365 -
4366 // Render using item coordinate cache mode. -
4367 if (cacheMode == QGraphicsItem::ItemCoordinateCache) {
never evaluated: cacheMode == QGraphicsItem::ItemCoordinateCache
0
4368 QSize pixmapSize;
never executed (the execution status of this line is deduced): QSize pixmapSize;
-
4369 bool fixedCacheSize = false;
never executed (the execution status of this line is deduced): bool fixedCacheSize = false;
-
4370 QRect br = brect.toAlignedRect();
never executed (the execution status of this line is deduced): QRect br = brect.toAlignedRect();
-
4371 if ((fixedCacheSize = itemCache->fixedSize.isValid())) {
never evaluated: (fixedCacheSize = itemCache->fixedSize.isValid())
0
4372 pixmapSize = itemCache->fixedSize;
never executed (the execution status of this line is deduced): pixmapSize = itemCache->fixedSize;
-
4373 } else {
never executed: }
0
4374 pixmapSize = br.size();
never executed (the execution status of this line is deduced): pixmapSize = br.size();
-
4375 }
never executed: }
0
4376 -
4377 // Create or recreate the pixmap. -
4378 int adjust = itemCache->fixedSize.isValid() ? 0 : 2;
never evaluated: itemCache->fixedSize.isValid()
0
4379 QSize adjustSize(adjust*2, adjust*2);
never executed (the execution status of this line is deduced): QSize adjustSize(adjust*2, adjust*2);
-
4380 br.adjust(-adjust, -adjust, adjust, adjust);
never executed (the execution status of this line is deduced): br.adjust(-adjust, -adjust, adjust, adjust);
-
4381 if (pix.isNull() || (!fixedCacheSize && (pixmapSize + adjustSize) != pix.size())) {
never evaluated: pix.isNull()
never evaluated: !fixedCacheSize
never evaluated: (pixmapSize + adjustSize) != pix.size()
0
4382 pix = QPixmap(pixmapSize + adjustSize);
never executed (the execution status of this line is deduced): pix = QPixmap(pixmapSize + adjustSize);
-
4383 itemCache->boundingRect = br;
never executed (the execution status of this line is deduced): itemCache->boundingRect = br;
-
4384 itemCache->exposed.clear();
never executed (the execution status of this line is deduced): itemCache->exposed.clear();
-
4385 itemCache->allExposed = true;
never executed (the execution status of this line is deduced): itemCache->allExposed = true;
-
4386 } else if (itemCache->boundingRect != br) {
never executed: }
never evaluated: itemCache->boundingRect != br
0
4387 itemCache->boundingRect = br;
never executed (the execution status of this line is deduced): itemCache->boundingRect = br;
-
4388 itemCache->exposed.clear();
never executed (the execution status of this line is deduced): itemCache->exposed.clear();
-
4389 itemCache->allExposed = true;
never executed (the execution status of this line is deduced): itemCache->allExposed = true;
-
4390 }
never executed: }
0
4391 -
4392 // Redraw any newly exposed areas. -
4393 if (itemCache->allExposed || !itemCache->exposed.isEmpty()) {
never evaluated: itemCache->allExposed
never evaluated: !itemCache->exposed.isEmpty()
0
4394 -
4395 //We know that we will modify the pixmap, removing it from the cache -
4396 //will detach the one we have and avoid a deep copy -
4397 if (pixmapFound)
never evaluated: pixmapFound
0
4398 QPixmapCache::remove(pixmapKey);
never executed: QPixmapCache::remove(pixmapKey);
0
4399 -
4400 // Fit the item's bounding rect into the pixmap's coordinates. -
4401 QTransform itemToPixmap;
never executed (the execution status of this line is deduced): QTransform itemToPixmap;
-
4402 if (fixedCacheSize) {
never evaluated: fixedCacheSize
0
4403 const QPointF scale(pixmapSize.width() / brect.width(), pixmapSize.height() / brect.height());
never executed (the execution status of this line is deduced): const QPointF scale(pixmapSize.width() / brect.width(), pixmapSize.height() / brect.height());
-
4404 itemToPixmap.scale(scale.x(), scale.y());
never executed (the execution status of this line is deduced): itemToPixmap.scale(scale.x(), scale.y());
-
4405 }
never executed: }
0
4406 itemToPixmap.translate(-br.x(), -br.y());
never executed (the execution status of this line is deduced): itemToPixmap.translate(-br.x(), -br.y());
-
4407 -
4408 // Generate the item's exposedRect and map its list of expose -
4409 // rects to device coordinates. -
4410 styleOptionTmp = *option;
never executed (the execution status of this line is deduced): styleOptionTmp = *option;
-
4411 QRegion pixmapExposed;
never executed (the execution status of this line is deduced): QRegion pixmapExposed;
-
4412 QRectF exposedRect;
never executed (the execution status of this line is deduced): QRectF exposedRect;
-
4413 if (!itemCache->allExposed) {
never evaluated: !itemCache->allExposed
0
4414 for (int i = 0; i < itemCache->exposed.size(); ++i) {
never evaluated: i < itemCache->exposed.size()
0
4415 QRectF r = itemCache->exposed.at(i);
never executed (the execution status of this line is deduced): QRectF r = itemCache->exposed.at(i);
-
4416 exposedRect |= r;
never executed (the execution status of this line is deduced): exposedRect |= r;
-
4417 pixmapExposed += itemToPixmap.mapRect(r).toAlignedRect();
never executed (the execution status of this line is deduced): pixmapExposed += itemToPixmap.mapRect(r).toAlignedRect();
-
4418 }
never executed: }
0
4419 } else {
never executed: }
0
4420 exposedRect = brect;
never executed (the execution status of this line is deduced): exposedRect = brect;
-
4421 }
never executed: }
0
4422 styleOptionTmp.exposedRect = exposedRect;
never executed (the execution status of this line is deduced): styleOptionTmp.exposedRect = exposedRect;
-
4423 -
4424 // Render. -
4425 _q_paintIntoCache(&pix, item, pixmapExposed, itemToPixmap, painter->renderHints(),
never executed (the execution status of this line is deduced): _q_paintIntoCache(&pix, item, pixmapExposed, itemToPixmap, painter->renderHints(),
-
4426 &styleOptionTmp, painterStateProtection);
never executed (the execution status of this line is deduced): &styleOptionTmp, painterStateProtection);
-
4427 -
4428 // insert this pixmap into the cache. -
4429 itemCache->key = QPixmapCache::insert(pix);
never executed (the execution status of this line is deduced): itemCache->key = QPixmapCache::insert(pix);
-
4430 -
4431 // Reset expose data. -
4432 itemCache->allExposed = false;
never executed (the execution status of this line is deduced): itemCache->allExposed = false;
-
4433 itemCache->exposed.clear();
never executed (the execution status of this line is deduced): itemCache->exposed.clear();
-
4434 }
never executed: }
0
4435 -
4436 // Redraw the exposed area using the transformed painter. Depending on -
4437 // the hardware, this may be a server-side operation, or an expensive -
4438 // qpixmap-image-transform-pixmap roundtrip. -
4439 if (newPainterOpacity != oldPainterOpacity) {
never evaluated: newPainterOpacity != oldPainterOpacity
0
4440 painter->setOpacity(newPainterOpacity);
never executed (the execution status of this line is deduced): painter->setOpacity(newPainterOpacity);
-
4441 painter->drawPixmap(br.topLeft(), pix);
never executed (the execution status of this line is deduced): painter->drawPixmap(br.topLeft(), pix);
-
4442 painter->setOpacity(oldPainterOpacity);
never executed (the execution status of this line is deduced): painter->setOpacity(oldPainterOpacity);
-
4443 } else {
never executed: }
0
4444 painter->drawPixmap(br.topLeft(), pix);
never executed (the execution status of this line is deduced): painter->drawPixmap(br.topLeft(), pix);
-
4445 }
never executed: }
0
4446 return;
never executed: return;
0
4447 } -
4448 -
4449 // Render using device coordinate cache mode. -
4450 if (cacheMode == QGraphicsItem::DeviceCoordinateCache) {
never evaluated: cacheMode == QGraphicsItem::DeviceCoordinateCache
0
4451 // Find the item's bounds in device coordinates. -
4452 QRectF deviceBounds = painter->worldTransform().mapRect(brect);
never executed (the execution status of this line is deduced): QRectF deviceBounds = painter->worldTransform().mapRect(brect);
-
4453 QRect deviceRect = deviceBounds.toRect().adjusted(-1, -1, 1, 1);
never executed (the execution status of this line is deduced): QRect deviceRect = deviceBounds.toRect().adjusted(-1, -1, 1, 1);
-
4454 if (deviceRect.isEmpty())
never evaluated: deviceRect.isEmpty()
0
4455 return;
never executed: return;
0
4456 QRect viewRect = widget ? widget->rect() : QRect();
never evaluated: widget
0
4457 if (widget && !viewRect.intersects(deviceRect))
never evaluated: widget
never evaluated: !viewRect.intersects(deviceRect)
0
4458 return;
never executed: return;
0
4459 -
4460 // Resort to direct rendering if the device rect exceeds the -
4461 // (optional) maximum bounds. (QGraphicsSvgItem uses this). -
4462 QSize maximumCacheSize =
never executed (the execution status of this line is deduced): QSize maximumCacheSize =
-
4463 itemd->extra(QGraphicsItemPrivate::ExtraMaxDeviceCoordCacheSize).toSize();
never executed (the execution status of this line is deduced): itemd->extra(QGraphicsItemPrivate::ExtraMaxDeviceCoordCacheSize).toSize();
-
4464 if (!maximumCacheSize.isEmpty()
never evaluated: !maximumCacheSize.isEmpty()
0
4465 && (deviceRect.width() > maximumCacheSize.width()
never evaluated: deviceRect.width() > maximumCacheSize.width()
0
4466 || deviceRect.height() > maximumCacheSize.height())) {
never evaluated: deviceRect.height() > maximumCacheSize.height()
0
4467 _q_paintItem(static_cast<QGraphicsWidget *>(item), painter, option, widget,
never executed (the execution status of this line is deduced): _q_paintItem(static_cast<QGraphicsWidget *>(item), painter, option, widget,
-
4468 oldPainterOpacity != newPainterOpacity, painterStateProtection);
never executed (the execution status of this line is deduced): oldPainterOpacity != newPainterOpacity, painterStateProtection);
-
4469 return;
never executed: return;
0
4470 } -
4471 -
4472 // Create or reuse offscreen pixmap, possibly scroll/blit from the old one. -
4473 // If the world transform is rotated we always recreate the cache to avoid -
4474 // wrong blending. -
4475 bool pixModified = false;
never executed (the execution status of this line is deduced): bool pixModified = false;
-
4476 QGraphicsItemCache::DeviceData *deviceData = &itemCache->deviceData[widget];
never executed (the execution status of this line is deduced): QGraphicsItemCache::DeviceData *deviceData = &itemCache->deviceData[widget];
-
4477 bool invertable = true;
never executed (the execution status of this line is deduced): bool invertable = true;
-
4478 QTransform diff = deviceData->lastTransform.inverted(&invertable);
never executed (the execution status of this line is deduced): QTransform diff = deviceData->lastTransform.inverted(&invertable);
-
4479 if (invertable)
never evaluated: invertable
0
4480 diff *= painter->worldTransform();
never executed: diff *= painter->worldTransform();
0
4481 deviceData->lastTransform = painter->worldTransform();
never executed (the execution status of this line is deduced): deviceData->lastTransform = painter->worldTransform();
-
4482 bool allowPartialCacheExposure = false;
never executed (the execution status of this line is deduced): bool allowPartialCacheExposure = false;
-
4483 bool simpleTransform = invertable && diff.type() <= QTransform::TxTranslate
never evaluated: invertable
never evaluated: diff.type() <= QTransform::TxTranslate
0
4484 && transformIsSimple(painter->worldTransform());
never evaluated: transformIsSimple(painter->worldTransform())
0
4485 if (!simpleTransform) {
never evaluated: !simpleTransform
0
4486 pixModified = true;
never executed (the execution status of this line is deduced): pixModified = true;
-
4487 itemCache->allExposed = true;
never executed (the execution status of this line is deduced): itemCache->allExposed = true;
-
4488 itemCache->exposed.clear();
never executed (the execution status of this line is deduced): itemCache->exposed.clear();
-
4489 deviceData->cacheIndent = QPoint();
never executed (the execution status of this line is deduced): deviceData->cacheIndent = QPoint();
-
4490 pix = QPixmap();
never executed (the execution status of this line is deduced): pix = QPixmap();
-
4491 } else if (!viewRect.isNull()) {
never executed: }
never evaluated: !viewRect.isNull()
0
4492 allowPartialCacheExposure = deviceData->cacheIndent != QPoint();
never executed (the execution status of this line is deduced): allowPartialCacheExposure = deviceData->cacheIndent != QPoint();
-
4493 }
never executed: }
0
4494 -
4495 // Allow partial cache exposure if the device rect isn't fully contained and -
4496 // deviceRect is 20% taller or wider than the viewRect. -
4497 if (!allowPartialCacheExposure && !viewRect.isNull() && !viewRect.contains(deviceRect)) {
never evaluated: !allowPartialCacheExposure
never evaluated: !viewRect.isNull()
never evaluated: !viewRect.contains(deviceRect)
0
4498 allowPartialCacheExposure = (viewRect.width() * 1.2 < deviceRect.width())
never evaluated: (viewRect.width() * 1.2 < deviceRect.width())
0
4499 || (viewRect.height() * 1.2 < deviceRect.height());
never evaluated: (viewRect.height() * 1.2 < deviceRect.height())
0
4500 }
never executed: }
0
4501 -
4502 QRegion scrollExposure;
never executed (the execution status of this line is deduced): QRegion scrollExposure;
-
4503 if (allowPartialCacheExposure) {
never evaluated: allowPartialCacheExposure
0
4504 // Part of pixmap is drawn. Either device contains viewrect (big -
4505 // item covers whole screen) or parts of device are outside the -
4506 // viewport. In either case the device rect must be the intersect -
4507 // between the two. -
4508 int dx = deviceRect.left() < viewRect.left() ? viewRect.left() - deviceRect.left() : 0;
never evaluated: deviceRect.left() < viewRect.left()
0
4509 int dy = deviceRect.top() < viewRect.top() ? viewRect.top() - deviceRect.top() : 0;
never evaluated: deviceRect.top() < viewRect.top()
0
4510 QPoint newCacheIndent(dx, dy);
never executed (the execution status of this line is deduced): QPoint newCacheIndent(dx, dy);
-
4511 deviceRect &= viewRect;
never executed (the execution status of this line is deduced): deviceRect &= viewRect;
-
4512 -
4513 if (pix.isNull()) {
never evaluated: pix.isNull()
0
4514 deviceData->cacheIndent = QPoint();
never executed (the execution status of this line is deduced): deviceData->cacheIndent = QPoint();
-
4515 itemCache->allExposed = true;
never executed (the execution status of this line is deduced): itemCache->allExposed = true;
-
4516 itemCache->exposed.clear();
never executed (the execution status of this line is deduced): itemCache->exposed.clear();
-
4517 pixModified = true;
never executed (the execution status of this line is deduced): pixModified = true;
-
4518 }
never executed: }
0
4519 -
4520 // Copy / "scroll" the old pixmap onto the new ole and calculate -
4521 // scrolled exposure. -
4522 if (newCacheIndent != deviceData->cacheIndent || deviceRect.size() != pix.size()) {
never evaluated: newCacheIndent != deviceData->cacheIndent
never evaluated: deviceRect.size() != pix.size()
0
4523 QPoint diff = newCacheIndent - deviceData->cacheIndent;
never executed (the execution status of this line is deduced): QPoint diff = newCacheIndent - deviceData->cacheIndent;
-
4524 QPixmap newPix(deviceRect.size());
never executed (the execution status of this line is deduced): QPixmap newPix(deviceRect.size());
-
4525 // ### Investigate removing this fill (test with Plasma and -
4526 // graphicssystem raster). -
4527 newPix.fill(Qt::transparent);
never executed (the execution status of this line is deduced): newPix.fill(Qt::transparent);
-
4528 if (!pix.isNull()) {
never evaluated: !pix.isNull()
0
4529 QPainter newPixPainter(&newPix);
never executed (the execution status of this line is deduced): QPainter newPixPainter(&newPix);
-
4530 newPixPainter.drawPixmap(-diff, pix);
never executed (the execution status of this line is deduced): newPixPainter.drawPixmap(-diff, pix);
-
4531 newPixPainter.end();
never executed (the execution status of this line is deduced): newPixPainter.end();
-
4532 }
never executed: }
0
4533 QRegion exposed;
never executed (the execution status of this line is deduced): QRegion exposed;
-
4534 exposed += newPix.rect();
never executed (the execution status of this line is deduced): exposed += newPix.rect();
-
4535 if (!pix.isNull())
never evaluated: !pix.isNull()
0
4536 exposed -= QRect(-diff, pix.size());
never executed: exposed -= QRect(-diff, pix.size());
0
4537 scrollExposure = exposed;
never executed (the execution status of this line is deduced): scrollExposure = exposed;
-
4538 -
4539 pix = newPix;
never executed (the execution status of this line is deduced): pix = newPix;
-
4540 pixModified = true;
never executed (the execution status of this line is deduced): pixModified = true;
-
4541 }
never executed: }
0
4542 deviceData->cacheIndent = newCacheIndent;
never executed (the execution status of this line is deduced): deviceData->cacheIndent = newCacheIndent;
-
4543 } else {
never executed: }
0
4544 // Full pixmap is drawn. -
4545 deviceData->cacheIndent = QPoint();
never executed (the execution status of this line is deduced): deviceData->cacheIndent = QPoint();
-
4546 -
4547 // Auto-adjust the pixmap size. -
4548 if (deviceRect.size() != pix.size()) {
never evaluated: deviceRect.size() != pix.size()
0
4549 // exposed needs to cover the whole pixmap -
4550 pix = QPixmap(deviceRect.size());
never executed (the execution status of this line is deduced): pix = QPixmap(deviceRect.size());
-
4551 pixModified = true;
never executed (the execution status of this line is deduced): pixModified = true;
-
4552 itemCache->allExposed = true;
never executed (the execution status of this line is deduced): itemCache->allExposed = true;
-
4553 itemCache->exposed.clear();
never executed (the execution status of this line is deduced): itemCache->exposed.clear();
-
4554 }
never executed: }
0
4555 }
never executed: }
0
4556 -
4557 // Check for newly invalidated areas. -
4558 if (itemCache->allExposed || !itemCache->exposed.isEmpty() || !scrollExposure.isEmpty()) {
never evaluated: itemCache->allExposed
never evaluated: !itemCache->exposed.isEmpty()
never evaluated: !scrollExposure.isEmpty()
0
4559 //We know that we will modify the pixmap, removing it from the cache -
4560 //will detach the one we have and avoid a deep copy -
4561 if (pixmapFound)
never evaluated: pixmapFound
0
4562 QPixmapCache::remove(pixmapKey);
never executed: QPixmapCache::remove(pixmapKey);
0
4563 -
4564 // Construct an item-to-pixmap transform. -
4565 QPointF p = deviceRect.topLeft();
never executed (the execution status of this line is deduced): QPointF p = deviceRect.topLeft();
-
4566 QTransform itemToPixmap = painter->worldTransform();
never executed (the execution status of this line is deduced): QTransform itemToPixmap = painter->worldTransform();
-
4567 if (!p.isNull())
never evaluated: !p.isNull()
0
4568 itemToPixmap *= QTransform::fromTranslate(-p.x(), -p.y());
never executed: itemToPixmap *= QTransform::fromTranslate(-p.x(), -p.y());
0
4569 -
4570 // Map the item's logical expose to pixmap coordinates. -
4571 QRegion pixmapExposed = scrollExposure;
never executed (the execution status of this line is deduced): QRegion pixmapExposed = scrollExposure;
-
4572 if (!itemCache->allExposed) {
never evaluated: !itemCache->allExposed
0
4573 const QVector<QRectF> &exposed = itemCache->exposed;
never executed (the execution status of this line is deduced): const QVector<QRectF> &exposed = itemCache->exposed;
-
4574 for (int i = 0; i < exposed.size(); ++i)
never evaluated: i < exposed.size()
0
4575 pixmapExposed += itemToPixmap.mapRect(exposed.at(i)).toRect().adjusted(-1, -1, 1, 1);
never executed: pixmapExposed += itemToPixmap.mapRect(exposed.at(i)).toRect().adjusted(-1, -1, 1, 1);
0
4576 }
never executed: }
0
4577 -
4578 // Calculate the style option's exposedRect. -
4579 QRectF br;
never executed (the execution status of this line is deduced): QRectF br;
-
4580 if (itemCache->allExposed) {
never evaluated: itemCache->allExposed
0
4581 br = item->boundingRect();
never executed (the execution status of this line is deduced): br = item->boundingRect();
-
4582 } else {
never executed: }
0
4583 const QVector<QRectF> &exposed = itemCache->exposed;
never executed (the execution status of this line is deduced): const QVector<QRectF> &exposed = itemCache->exposed;
-
4584 for (int i = 0; i < exposed.size(); ++i)
never evaluated: i < exposed.size()
0
4585 br |= exposed.at(i);
never executed: br |= exposed.at(i);
0
4586 QTransform pixmapToItem = itemToPixmap.inverted();
never executed (the execution status of this line is deduced): QTransform pixmapToItem = itemToPixmap.inverted();
-
4587 foreach (const QRect &r, scrollExposure.rects())
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(scrollExposure.rects())> _container_(scrollExposure.rects()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QRect &r = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
4588 br |= pixmapToItem.mapRect(r);
never executed: br |= pixmapToItem.mapRect(r);
0
4589 }
never executed: }
0
4590 styleOptionTmp = *option;
never executed (the execution status of this line is deduced): styleOptionTmp = *option;
-
4591 styleOptionTmp.exposedRect = br.adjusted(-1, -1, 1, 1);
never executed (the execution status of this line is deduced): styleOptionTmp.exposedRect = br.adjusted(-1, -1, 1, 1);
-
4592 -
4593 // Render the exposed areas. -
4594 _q_paintIntoCache(&pix, item, pixmapExposed, itemToPixmap, painter->renderHints(),
never executed (the execution status of this line is deduced): _q_paintIntoCache(&pix, item, pixmapExposed, itemToPixmap, painter->renderHints(),
-
4595 &styleOptionTmp, painterStateProtection);
never executed (the execution status of this line is deduced): &styleOptionTmp, painterStateProtection);
-
4596 -
4597 // Reset expose data. -
4598 pixModified = true;
never executed (the execution status of this line is deduced): pixModified = true;
-
4599 itemCache->allExposed = false;
never executed (the execution status of this line is deduced): itemCache->allExposed = false;
-
4600 itemCache->exposed.clear();
never executed (the execution status of this line is deduced): itemCache->exposed.clear();
-
4601 }
never executed: }
0
4602 -
4603 if (pixModified) {
never evaluated: pixModified
0
4604 // Insert this pixmap into the cache. -
4605 deviceData->key = QPixmapCache::insert(pix);
never executed (the execution status of this line is deduced): deviceData->key = QPixmapCache::insert(pix);
-
4606 }
never executed: }
0
4607 -
4608 // Redraw the exposed area using an untransformed painter. This -
4609 // effectively becomes a bitblit that does not transform the cache. -
4610 QTransform restoreTransform = painter->worldTransform();
never executed (the execution status of this line is deduced): QTransform restoreTransform = painter->worldTransform();
-
4611 painter->setWorldTransform(QTransform());
never executed (the execution status of this line is deduced): painter->setWorldTransform(QTransform());
-
4612 if (newPainterOpacity != oldPainterOpacity) {
never evaluated: newPainterOpacity != oldPainterOpacity
0
4613 painter->setOpacity(newPainterOpacity);
never executed (the execution status of this line is deduced): painter->setOpacity(newPainterOpacity);
-
4614 painter->drawPixmap(deviceRect.topLeft(), pix);
never executed (the execution status of this line is deduced): painter->drawPixmap(deviceRect.topLeft(), pix);
-
4615 painter->setOpacity(oldPainterOpacity);
never executed (the execution status of this line is deduced): painter->setOpacity(oldPainterOpacity);
-
4616 } else {
never executed: }
0
4617 painter->drawPixmap(deviceRect.topLeft(), pix);
never executed (the execution status of this line is deduced): painter->drawPixmap(deviceRect.topLeft(), pix);
-
4618 }
never executed: }
0
4619 painter->setWorldTransform(restoreTransform);
never executed (the execution status of this line is deduced): painter->setWorldTransform(restoreTransform);
-
4620 return;
never executed: return;
0
4621 } -
4622}
never executed: }
0
4623 -
4624void QGraphicsScenePrivate::drawItems(QPainter *painter, const QTransform *const viewTransform, -
4625 QRegion *exposedRegion, QWidget *widget) -
4626{ -
4627 // Make sure we don't have unpolished items before we draw. -
4628 if (!unpolishedItems.isEmpty())
evaluated: !unpolishedItems.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:123
2-123
4629 _q_polishItems();
executed: _q_polishItems();
Execution Count:2
2
4630 -
4631 updateAll = false;
executed (the execution status of this line is deduced): updateAll = false;
-
4632 QRectF exposedSceneRect;
executed (the execution status of this line is deduced): QRectF exposedSceneRect;
-
4633 if (exposedRegion && indexMethod != QGraphicsScene::NoIndex) {
partially evaluated: exposedRegion
TRUEFALSE
yes
Evaluation Count:125
no
Evaluation Count:0
partially evaluated: indexMethod != QGraphicsScene::NoIndex
TRUEFALSE
yes
Evaluation Count:125
no
Evaluation Count:0
0-125
4634 exposedSceneRect = exposedRegion->boundingRect().adjusted(-1, -1, 1, 1);
executed (the execution status of this line is deduced): exposedSceneRect = exposedRegion->boundingRect().adjusted(-1, -1, 1, 1);
-
4635 if (viewTransform)
evaluated: viewTransform
TRUEFALSE
yes
Evaluation Count:96
yes
Evaluation Count:29
29-96
4636 exposedSceneRect = viewTransform->inverted().mapRect(exposedSceneRect);
executed: exposedSceneRect = viewTransform->inverted().mapRect(exposedSceneRect);
Execution Count:96
96
4637 }
executed: }
Execution Count:125
125
4638 const QList<QGraphicsItem *> tli = index->estimateTopLevelItems(exposedSceneRect, Qt::AscendingOrder);
executed (the execution status of this line is deduced): const QList<QGraphicsItem *> tli = index->estimateTopLevelItems(exposedSceneRect, Qt::AscendingOrder);
-
4639 for (int i = 0; i < tli.size(); ++i)
evaluated: i < tli.size()
TRUEFALSE
yes
Evaluation Count:143
yes
Evaluation Count:125
125-143
4640 drawSubtreeRecursive(tli.at(i), painter, viewTransform, exposedRegion, widget);
executed: drawSubtreeRecursive(tli.at(i), painter, viewTransform, exposedRegion, widget);
Execution Count:143
143
4641}
executed: }
Execution Count:125
125
4642 -
4643void QGraphicsScenePrivate::drawSubtreeRecursive(QGraphicsItem *item, QPainter *painter, -
4644 const QTransform *const viewTransform, -
4645 QRegion *exposedRegion, QWidget *widget, -
4646 qreal parentOpacity, const QTransform *const effectTransform) -
4647{ -
4648 Q_ASSERT(item);
executed (the execution status of this line is deduced): qt_noop();
-
4649 -
4650 if (!item->d_ptr->visible)
evaluated: !item->d_ptr->visible
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:423
2-423
4651 return;
executed: return;
Execution Count:2
2
4652 -
4653 const bool itemHasContents = !(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents);
executed (the execution status of this line is deduced): const bool itemHasContents = !(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents);
-
4654 const bool itemHasChildren = !item->d_ptr->children.isEmpty();
executed (the execution status of this line is deduced): const bool itemHasChildren = !item->d_ptr->children.isEmpty();
-
4655 if (!itemHasContents && !itemHasChildren)
evaluated: !itemHasContents
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:418
partially evaluated: !itemHasChildren
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:5
0-418
4656 return; // Item has neither contents nor children!(?)
never executed: return;
0
4657 -
4658 const qreal opacity = item->d_ptr->combineOpacityFromParent(parentOpacity);
executed (the execution status of this line is deduced): const qreal opacity = item->d_ptr->combineOpacityFromParent(parentOpacity);
-
4659 const bool itemIsFullyTransparent = QGraphicsItemPrivate::isOpacityNull(opacity);
executed (the execution status of this line is deduced): const bool itemIsFullyTransparent = QGraphicsItemPrivate::isOpacityNull(opacity);
-
4660 if (itemIsFullyTransparent && (!itemHasChildren || item->d_ptr->childrenCombineOpacity()))
partially evaluated: itemIsFullyTransparent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:423
never evaluated: !itemHasChildren
never evaluated: item->d_ptr->childrenCombineOpacity()
0-423
4661 return;
never executed: return;
0
4662 -
4663 QTransform transform(Qt::Uninitialized);
executed (the execution status of this line is deduced): QTransform transform(Qt::Uninitialized);
-
4664 QTransform *transformPtr = 0;
executed (the execution status of this line is deduced): QTransform *transformPtr = 0;
-
4665 bool translateOnlyTransform = false;
executed (the execution status of this line is deduced): bool translateOnlyTransform = false;
-
4666#define ENSURE_TRANSFORM_PTR \ -
4667 if (!transformPtr) { \ -
4668 Q_ASSERT(!itemIsUntransformable); \ -
4669 if (viewTransform) { \ -
4670 transform = item->d_ptr->sceneTransform; \ -
4671 transform *= *viewTransform; \ -
4672 transformPtr = &transform; \ -
4673 } else { \ -
4674 transformPtr = &item->d_ptr->sceneTransform; \ -
4675 translateOnlyTransform = item->d_ptr->sceneTransformTranslateOnly; \ -
4676 } \ -
4677 } -
4678 -
4679 // Update the item's scene transform if the item is transformable; -
4680 // otherwise calculate the full transform, -
4681 bool wasDirtyParentSceneTransform = false;
executed (the execution status of this line is deduced): bool wasDirtyParentSceneTransform = false;
-
4682 const bool itemIsUntransformable = item->d_ptr->itemIsUntransformable();
executed (the execution status of this line is deduced): const bool itemIsUntransformable = item->d_ptr->itemIsUntransformable();
-
4683 if (itemIsUntransformable) {
partially evaluated: itemIsUntransformable
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:423
0-423
4684 transform = item->deviceTransform(viewTransform ? *viewTransform : QTransform());
never executed (the execution status of this line is deduced): transform = item->deviceTransform(viewTransform ? *viewTransform : QTransform());
-
4685 transformPtr = &transform;
never executed (the execution status of this line is deduced): transformPtr = &transform;
-
4686 } else if (item->d_ptr->dirtySceneTransform) {
never executed: }
evaluated: item->d_ptr->dirtySceneTransform
TRUEFALSE
yes
Evaluation Count:165
yes
Evaluation Count:258
0-258
4687 item->d_ptr->updateSceneTransformFromParent();
executed (the execution status of this line is deduced): item->d_ptr->updateSceneTransformFromParent();
-
4688 Q_ASSERT(!item->d_ptr->dirtySceneTransform);
executed (the execution status of this line is deduced): qt_noop();
-
4689 wasDirtyParentSceneTransform = true;
executed (the execution status of this line is deduced): wasDirtyParentSceneTransform = true;
-
4690 }
executed: }
Execution Count:165
165
4691 -
4692 const bool itemClipsChildrenToShape = (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape);
executed (the execution status of this line is deduced): const bool itemClipsChildrenToShape = (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape);
-
4693 bool drawItem = itemHasContents && !itemIsFullyTransparent;
evaluated: itemHasContents
TRUEFALSE
yes
Evaluation Count:418
yes
Evaluation Count:5
partially evaluated: !itemIsFullyTransparent
TRUEFALSE
yes
Evaluation Count:418
no
Evaluation Count:0
0-418
4694 if (drawItem) {
evaluated: drawItem
TRUEFALSE
yes
Evaluation Count:418
yes
Evaluation Count:5
5-418
4695 const QRectF brect = adjustedItemEffectiveBoundingRect(item);
executed (the execution status of this line is deduced): const QRectF brect = adjustedItemEffectiveBoundingRect(item);
-
4696 ENSURE_TRANSFORM_PTR
executed: }
Execution Count:244
executed: }
Execution Count:174
partially evaluated: !transformPtr
TRUEFALSE
yes
Evaluation Count:418
no
Evaluation Count:0
evaluated: viewTransform
TRUEFALSE
yes
Evaluation Count:244
yes
Evaluation Count:174
0-418
4697 QRect viewBoundingRect = translateOnlyTransform ? brect.translated(transformPtr->dx(), transformPtr->dy()).toAlignedRect()
evaluated: translateOnlyTransform
TRUEFALSE
yes
Evaluation Count:174
yes
Evaluation Count:244
174-244
4698 : transformPtr->mapRect(brect).toAlignedRect();
executed (the execution status of this line is deduced): : transformPtr->mapRect(brect).toAlignedRect();
-
4699 viewBoundingRect.adjust(-int(rectAdjust), -int(rectAdjust), rectAdjust, rectAdjust);
executed (the execution status of this line is deduced): viewBoundingRect.adjust(-int(rectAdjust), -int(rectAdjust), rectAdjust, rectAdjust);
-
4700 if (widget)
evaluated: widget
TRUEFALSE
yes
Evaluation Count:410
yes
Evaluation Count:8
8-410
4701 item->d_ptr->paintedViewBoundingRects.insert(widget, viewBoundingRect);
executed: item->d_ptr->paintedViewBoundingRects.insert(widget, viewBoundingRect);
Execution Count:410
410
4702 drawItem = exposedRegion ? exposedRegion->intersects(viewBoundingRect)
evaluated: exposedRegion
TRUEFALSE
yes
Evaluation Count:408
yes
Evaluation Count:10
10-408
4703 : !viewBoundingRect.normalized().isEmpty();
executed (the execution status of this line is deduced): : !viewBoundingRect.normalized().isEmpty();
-
4704 if (!drawItem) {
evaluated: !drawItem
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:411
7-411
4705 if (!itemHasChildren)
partially evaluated: !itemHasChildren
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
4706 return;
executed: return;
Execution Count:7
7
4707 if (itemClipsChildrenToShape) {
never evaluated: itemClipsChildrenToShape
0
4708 if (wasDirtyParentSceneTransform)
never evaluated: wasDirtyParentSceneTransform
0
4709 item->d_ptr->invalidateChildrenSceneTransform();
never executed: item->d_ptr->invalidateChildrenSceneTransform();
0
4710 return;
never executed: return;
0
4711 } -
4712 }
never executed: }
0
4713 } // else we know for sure this item has children we must process.
executed: }
Execution Count:411
411
4714 -
4715 if (itemHasChildren && itemClipsChildrenToShape)
evaluated: itemHasChildren
TRUEFALSE
yes
Evaluation Count:75
yes
Evaluation Count:341
evaluated: itemClipsChildrenToShape
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:72
3-341
4716 ENSURE_TRANSFORM_PTR;
never executed: }
never executed: }
partially evaluated: !transformPtr
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
never evaluated: viewTransform
0-3
4717 -
4718#ifndef QT_NO_GRAPHICSEFFECT -
4719 if (item->d_ptr->graphicsEffect && item->d_ptr->graphicsEffect->isEnabled()) {
evaluated: item->d_ptr->graphicsEffect
TRUEFALSE
yes
Evaluation Count:37
yes
Evaluation Count:379
evaluated: item->d_ptr->graphicsEffect->isEnabled()
TRUEFALSE
yes
Evaluation Count:36
yes
Evaluation Count:1
1-379
4720 ENSURE_TRANSFORM_PTR;
never executed: }
executed: }
Execution Count:4
evaluated: !transformPtr
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:32
partially evaluated: viewTransform
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-32
4721 QGraphicsItemPaintInfo info(viewTransform, transformPtr, effectTransform, exposedRegion, widget, &styleOptionTmp,
executed (the execution status of this line is deduced): QGraphicsItemPaintInfo info(viewTransform, transformPtr, effectTransform, exposedRegion, widget, &styleOptionTmp,
-
4722 painter, opacity, wasDirtyParentSceneTransform, itemHasContents && !itemIsFullyTransparent);
executed (the execution status of this line is deduced): painter, opacity, wasDirtyParentSceneTransform, itemHasContents && !itemIsFullyTransparent);
-
4723 QGraphicsEffectSource *source = item->d_ptr->graphicsEffect->d_func()->source;
executed (the execution status of this line is deduced): QGraphicsEffectSource *source = item->d_ptr->graphicsEffect->d_func()->source;
-
4724 QGraphicsItemEffectSourcePrivate *sourced = static_cast<QGraphicsItemEffectSourcePrivate *>
executed (the execution status of this line is deduced): QGraphicsItemEffectSourcePrivate *sourced = static_cast<QGraphicsItemEffectSourcePrivate *>
-
4725 (source->d_func());
executed (the execution status of this line is deduced): (source->d_func());
-
4726 sourced->info = &info;
executed (the execution status of this line is deduced): sourced->info = &info;
-
4727 const QTransform restoreTransform = painter->worldTransform();
executed (the execution status of this line is deduced): const QTransform restoreTransform = painter->worldTransform();
-
4728 if (effectTransform)
partially evaluated: effectTransform
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:36
0-36
4729 painter->setWorldTransform(*transformPtr * *effectTransform);
never executed: painter->setWorldTransform(*transformPtr * *effectTransform);
0
4730 else -
4731 painter->setWorldTransform(*transformPtr);
executed: painter->setWorldTransform(*transformPtr);
Execution Count:36
36
4732 painter->setOpacity(opacity);
executed (the execution status of this line is deduced): painter->setOpacity(opacity);
-
4733 -
4734 if (sourced->currentCachedSystem() != Qt::LogicalCoordinates
partially evaluated: sourced->currentCachedSystem() != Qt::LogicalCoordinates
TRUEFALSE
yes
Evaluation Count:36
no
Evaluation Count:0
0-36
4735 && sourced->lastEffectTransform != painter->worldTransform())
evaluated: sourced->lastEffectTransform != painter->worldTransform()
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:20
16-20
4736 { -
4737 if (sourced->lastEffectTransform.type() <= QTransform::TxTranslate
partially evaluated: sourced->lastEffectTransform.type() <= QTransform::TxTranslate
TRUEFALSE
yes
Evaluation Count:16
no
Evaluation Count:0
0-16
4738 && painter->worldTransform().type() <= QTransform::TxTranslate)
evaluated: painter->worldTransform().type() <= QTransform::TxTranslate
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:7
7-9
4739 { -
4740 QRectF sourceRect = sourced->boundingRect(Qt::DeviceCoordinates);
executed (the execution status of this line is deduced): QRectF sourceRect = sourced->boundingRect(Qt::DeviceCoordinates);
-
4741 QRect effectRect = sourced->paddedEffectRect(Qt::DeviceCoordinates, sourced->currentCachedMode(), sourceRect);
executed (the execution status of this line is deduced): QRect effectRect = sourced->paddedEffectRect(Qt::DeviceCoordinates, sourced->currentCachedMode(), sourceRect);
-
4742 -
4743 sourced->setCachedOffset(effectRect.topLeft());
executed (the execution status of this line is deduced): sourced->setCachedOffset(effectRect.topLeft());
-
4744 } else {
executed: }
Execution Count:9
9
4745 sourced->invalidateCache(QGraphicsEffectSourcePrivate::TransformChanged);
executed (the execution status of this line is deduced): sourced->invalidateCache(QGraphicsEffectSourcePrivate::TransformChanged);
-
4746 }
executed: }
Execution Count:7
7
4747 -
4748 sourced->lastEffectTransform = painter->worldTransform();
executed (the execution status of this line is deduced): sourced->lastEffectTransform = painter->worldTransform();
-
4749 }
executed: }
Execution Count:16
16
4750 -
4751 item->d_ptr->graphicsEffect->draw(painter);
executed (the execution status of this line is deduced): item->d_ptr->graphicsEffect->draw(painter);
-
4752 painter->setWorldTransform(restoreTransform);
executed (the execution status of this line is deduced): painter->setWorldTransform(restoreTransform);
-
4753 sourced->info = 0;
executed (the execution status of this line is deduced): sourced->info = 0;
-
4754 } else
executed: }
Execution Count:36
36
4755#endif //QT_NO_GRAPHICSEFFECT -
4756 { -
4757 draw(item, painter, viewTransform, transformPtr, exposedRegion, widget, opacity,
executed (the execution status of this line is deduced): draw(item, painter, viewTransform, transformPtr, exposedRegion, widget, opacity,
-
4758 effectTransform, wasDirtyParentSceneTransform, drawItem);
executed (the execution status of this line is deduced): effectTransform, wasDirtyParentSceneTransform, drawItem);
-
4759 }
executed: }
Execution Count:380
380
4760} -
4761 -
4762static inline void setClip(QPainter *painter, QGraphicsItem *item) -
4763{ -
4764 painter->save();
executed (the execution status of this line is deduced): painter->save();
-
4765 QRectF clipRect;
executed (the execution status of this line is deduced): QRectF clipRect;
-
4766 const QPainterPath clipPath(item->shape());
executed (the execution status of this line is deduced): const QPainterPath clipPath(item->shape());
-
4767 if (QPathClipper::pathToRect(clipPath, &clipRect))
partially evaluated: QPathClipper::pathToRect(clipPath, &clipRect)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
4768 painter->setClipRect(clipRect, Qt::IntersectClip);
never executed: painter->setClipRect(clipRect, Qt::IntersectClip);
0
4769 else -
4770 painter->setClipPath(clipPath, Qt::IntersectClip);
executed: painter->setClipPath(clipPath, Qt::IntersectClip);
Execution Count:2
2
4771} -
4772 -
4773static inline void setWorldTransform(QPainter *painter, const QTransform *const transformPtr, -
4774 const QTransform *effectTransform) -
4775{ -
4776 Q_ASSERT(transformPtr);
executed (the execution status of this line is deduced): qt_noop();
-
4777 if (effectTransform)
evaluated: effectTransform
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:385
20-385
4778 painter->setWorldTransform(*transformPtr * *effectTransform);
executed: painter->setWorldTransform(*transformPtr * *effectTransform);
Execution Count:20
20
4779 else -
4780 painter->setWorldTransform(*transformPtr);
executed: painter->setWorldTransform(*transformPtr);
Execution Count:385
385
4781} -
4782 -
4783void QGraphicsScenePrivate::draw(QGraphicsItem *item, QPainter *painter, const QTransform *const viewTransform, -
4784 const QTransform *const transformPtr, QRegion *exposedRegion, QWidget *widget, -
4785 qreal opacity, const QTransform *effectTransform, -
4786 bool wasDirtyParentSceneTransform, bool drawItem) -
4787{ -
4788 const bool itemIsFullyTransparent = QGraphicsItemPrivate::isOpacityNull(opacity);
executed (the execution status of this line is deduced): const bool itemIsFullyTransparent = QGraphicsItemPrivate::isOpacityNull(opacity);
-
4789 const bool itemClipsChildrenToShape = (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape);
executed (the execution status of this line is deduced): const bool itemClipsChildrenToShape = (item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape);
-
4790 const bool itemHasChildren = !item->d_ptr->children.isEmpty();
executed (the execution status of this line is deduced): const bool itemHasChildren = !item->d_ptr->children.isEmpty();
-
4791 bool setChildClip = itemClipsChildrenToShape;
executed (the execution status of this line is deduced): bool setChildClip = itemClipsChildrenToShape;
-
4792 bool itemHasChildrenStackedBehind = false;
executed (the execution status of this line is deduced): bool itemHasChildrenStackedBehind = false;
-
4793 -
4794 int i = 0;
executed (the execution status of this line is deduced): int i = 0;
-
4795 if (itemHasChildren) {
evaluated: itemHasChildren
TRUEFALSE
yes
Evaluation Count:74
yes
Evaluation Count:336
74-336
4796 if (itemClipsChildrenToShape)
evaluated: itemClipsChildrenToShape
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:72
2-72
4797 setWorldTransform(painter, transformPtr, effectTransform);
executed: setWorldTransform(painter, transformPtr, effectTransform);
Execution Count:2
2
4798 -
4799 item->d_ptr->ensureSortedChildren();
executed (the execution status of this line is deduced): item->d_ptr->ensureSortedChildren();
-
4800 // Items with the 'ItemStacksBehindParent' flag are put in front of the list -
4801 // so all we have to do is to check the first item. -
4802 itemHasChildrenStackedBehind = (item->d_ptr->children.at(0)->d_ptr->flags
executed (the execution status of this line is deduced): itemHasChildrenStackedBehind = (item->d_ptr->children.at(0)->d_ptr->flags
-
4803 & QGraphicsItem::ItemStacksBehindParent);
executed (the execution status of this line is deduced): & QGraphicsItem::ItemStacksBehindParent);
-
4804 -
4805 if (itemHasChildrenStackedBehind) {
evaluated: itemHasChildrenStackedBehind
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:73
1-73
4806 if (itemClipsChildrenToShape) {
partially evaluated: itemClipsChildrenToShape
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
4807 setClip(painter, item);
never executed (the execution status of this line is deduced): setClip(painter, item);
-
4808 setChildClip = false;
never executed (the execution status of this line is deduced): setChildClip = false;
-
4809 }
never executed: }
0
4810 -
4811 // Draw children behind -
4812 for (i = 0; i < item->d_ptr->children.size(); ++i) {
evaluated: i < item->d_ptr->children.size()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
4813 QGraphicsItem *child = item->d_ptr->children.at(i);
executed (the execution status of this line is deduced): QGraphicsItem *child = item->d_ptr->children.at(i);
-
4814 if (wasDirtyParentSceneTransform)
partially evaluated: wasDirtyParentSceneTransform
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
4815 child->d_ptr->dirtySceneTransform = 1;
executed: child->d_ptr->dirtySceneTransform = 1;
Execution Count:1
1
4816 if (!(child->d_ptr->flags & QGraphicsItem::ItemStacksBehindParent))
partially evaluated: !(child->d_ptr->flags & QGraphicsItem::ItemStacksBehindParent)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
4817 break;
never executed: break;
0
4818 if (itemIsFullyTransparent && !(child->d_ptr->flags & QGraphicsItem::ItemIgnoresParentOpacity))
partially evaluated: itemIsFullyTransparent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
never evaluated: !(child->d_ptr->flags & QGraphicsItem::ItemIgnoresParentOpacity)
0-1
4819 continue;
never executed: continue;
0
4820 drawSubtreeRecursive(child, painter, viewTransform, exposedRegion, widget, opacity, effectTransform);
executed (the execution status of this line is deduced): drawSubtreeRecursive(child, painter, viewTransform, exposedRegion, widget, opacity, effectTransform);
-
4821 }
executed: }
Execution Count:1
1
4822 }
executed: }
Execution Count:1
1
4823 }
executed: }
Execution Count:74
74
4824 -
4825 // Draw item -
4826 if (drawItem) {
evaluated: drawItem
TRUEFALSE
yes
Evaluation Count:405
yes
Evaluation Count:5
5-405
4827 Q_ASSERT(!itemIsFullyTransparent);
executed (the execution status of this line is deduced): qt_noop();
-
4828 Q_ASSERT(!(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents));
executed (the execution status of this line is deduced): qt_noop();
-
4829 Q_ASSERT(transformPtr);
executed (the execution status of this line is deduced): qt_noop();
-
4830 item->d_ptr->initStyleOption(&styleOptionTmp, *transformPtr, exposedRegion
executed (the execution status of this line is deduced): item->d_ptr->initStyleOption(&styleOptionTmp, *transformPtr, exposedRegion
-
4831 ? *exposedRegion : QRegion(), exposedRegion == 0);
executed (the execution status of this line is deduced): ? *exposedRegion : QRegion(), exposedRegion == 0);
-
4832 -
4833 const bool itemClipsToShape = item->d_ptr->flags & QGraphicsItem::ItemClipsToShape;
executed (the execution status of this line is deduced): const bool itemClipsToShape = item->d_ptr->flags & QGraphicsItem::ItemClipsToShape;
-
4834 bool restorePainterClip = false;
executed (the execution status of this line is deduced): bool restorePainterClip = false;
-
4835 -
4836 if (!itemHasChildren || !itemClipsChildrenToShape) {
evaluated: !itemHasChildren
TRUEFALSE
yes
Evaluation Count:336
yes
Evaluation Count:69
evaluated: !itemClipsChildrenToShape
TRUEFALSE
yes
Evaluation Count:67
yes
Evaluation Count:2
2-336
4837 // Item does not have children or clip children to shape. -
4838 setWorldTransform(painter, transformPtr, effectTransform);
executed (the execution status of this line is deduced): setWorldTransform(painter, transformPtr, effectTransform);
-
4839 if ((restorePainterClip = itemClipsToShape))
partially evaluated: (restorePainterClip = itemClipsToShape)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:403
0-403
4840 setClip(painter, item);
never executed: setClip(painter, item);
0
4841 } else if (itemHasChildrenStackedBehind){
executed: }
Execution Count:403
partially evaluated: itemHasChildrenStackedBehind
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-403
4842 // Item clips children to shape and has children stacked behind, which means -
4843 // the painter is already clipped to the item's shape. -
4844 if (itemClipsToShape) {
never evaluated: itemClipsToShape
0
4845 // The clip is already correct. Ensure correct world transform. -
4846 setWorldTransform(painter, transformPtr, effectTransform);
never executed (the execution status of this line is deduced): setWorldTransform(painter, transformPtr, effectTransform);
-
4847 } else {
never executed: }
0
4848 // Remove clip (this also ensures correct world transform). -
4849 painter->restore();
never executed (the execution status of this line is deduced): painter->restore();
-
4850 setChildClip = true;
never executed (the execution status of this line is deduced): setChildClip = true;
-
4851 }
never executed: }
0
4852 } else if (itemClipsToShape) {
partially evaluated: itemClipsToShape
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
4853 // Item clips children and itself to shape. It does not have hildren stacked -
4854 // behind, which means the clip has not yet been set. We set it now and re-use it -
4855 // for the children. -
4856 setClip(painter, item);
never executed (the execution status of this line is deduced): setClip(painter, item);
-
4857 setChildClip = false;
never executed (the execution status of this line is deduced): setChildClip = false;
-
4858 }
never executed: }
0
4859 -
4860 if (painterStateProtection && !restorePainterClip)
partially evaluated: painterStateProtection
TRUEFALSE
yes
Evaluation Count:405
no
Evaluation Count:0
partially evaluated: !restorePainterClip
TRUEFALSE
yes
Evaluation Count:405
no
Evaluation Count:0
0-405
4861 painter->save();
executed: painter->save();
Execution Count:405
405
4862 -
4863 painter->setOpacity(opacity);
executed (the execution status of this line is deduced): painter->setOpacity(opacity);
-
4864 if (!item->d_ptr->cacheMode && !item->d_ptr->isWidget)
partially evaluated: !item->d_ptr->cacheMode
TRUEFALSE
yes
Evaluation Count:405
no
Evaluation Count:0
evaluated: !item->d_ptr->isWidget
TRUEFALSE
yes
Evaluation Count:165
yes
Evaluation Count:240
0-405
4865 item->paint(painter, &styleOptionTmp, widget);
executed: item->paint(painter, &styleOptionTmp, widget);
Execution Count:165
165
4866 else -
4867 drawItemHelper(item, painter, &styleOptionTmp, widget, painterStateProtection);
executed: drawItemHelper(item, painter, &styleOptionTmp, widget, painterStateProtection);
Execution Count:240
240
4868 -
4869 if (painterStateProtection || restorePainterClip)
partially evaluated: painterStateProtection
TRUEFALSE
yes
Evaluation Count:405
no
Evaluation Count:0
never evaluated: restorePainterClip
0-405
4870 painter->restore();
executed: painter->restore();
Execution Count:405
405
4871 -
4872 static int drawRect = qgetenv("QT_DRAW_SCENE_ITEM_RECTS").toInt(); -
4873 if (drawRect) {
partially evaluated: drawRect
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:405
0-405
4874 QPen oldPen = painter->pen();
never executed (the execution status of this line is deduced): QPen oldPen = painter->pen();
-
4875 QBrush oldBrush = painter->brush();
never executed (the execution status of this line is deduced): QBrush oldBrush = painter->brush();
-
4876 quintptr ptr = reinterpret_cast<quintptr>(item);
never executed (the execution status of this line is deduced): quintptr ptr = reinterpret_cast<quintptr>(item);
-
4877 const QColor color = QColor::fromHsv(ptr % 255, 255, 255);
never executed (the execution status of this line is deduced): const QColor color = QColor::fromHsv(ptr % 255, 255, 255);
-
4878 painter->setPen(color);
never executed (the execution status of this line is deduced): painter->setPen(color);
-
4879 painter->setBrush(Qt::NoBrush);
never executed (the execution status of this line is deduced): painter->setBrush(Qt::NoBrush);
-
4880 painter->drawRect(adjustedItemBoundingRect(item));
never executed (the execution status of this line is deduced): painter->drawRect(adjustedItemBoundingRect(item));
-
4881 painter->setPen(oldPen);
never executed (the execution status of this line is deduced): painter->setPen(oldPen);
-
4882 painter->setBrush(oldBrush);
never executed (the execution status of this line is deduced): painter->setBrush(oldBrush);
-
4883 }
never executed: }
0
4884 }
executed: }
Execution Count:405
405
4885 -
4886 // Draw children in front -
4887 if (itemHasChildren) {
evaluated: itemHasChildren
TRUEFALSE
yes
Evaluation Count:74
yes
Evaluation Count:336
74-336
4888 if (setChildClip)
evaluated: setChildClip
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:72
2-72
4889 setClip(painter, item);
executed: setClip(painter, item);
Execution Count:2
2
4890 -
4891 for (; i < item->d_ptr->children.size(); ++i) {
evaluated: i < item->d_ptr->children.size()
TRUEFALSE
yes
Evaluation Count:274
yes
Evaluation Count:74
74-274
4892 QGraphicsItem *child = item->d_ptr->children.at(i);
executed (the execution status of this line is deduced): QGraphicsItem *child = item->d_ptr->children.at(i);
-
4893 if (wasDirtyParentSceneTransform)
evaluated: wasDirtyParentSceneTransform
TRUEFALSE
yes
Evaluation Count:102
yes
Evaluation Count:172
102-172
4894 child->d_ptr->dirtySceneTransform = 1;
executed: child->d_ptr->dirtySceneTransform = 1;
Execution Count:102
102
4895 if (itemIsFullyTransparent && !(child->d_ptr->flags & QGraphicsItem::ItemIgnoresParentOpacity))
partially evaluated: itemIsFullyTransparent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:274
never evaluated: !(child->d_ptr->flags & QGraphicsItem::ItemIgnoresParentOpacity)
0-274
4896 continue;
never executed: continue;
0
4897 drawSubtreeRecursive(child, painter, viewTransform, exposedRegion, widget, opacity, effectTransform);
executed (the execution status of this line is deduced): drawSubtreeRecursive(child, painter, viewTransform, exposedRegion, widget, opacity, effectTransform);
-
4898 }
executed: }
Execution Count:274
274
4899 -
4900 // Restore child clip -
4901 if (itemClipsChildrenToShape)
evaluated: itemClipsChildrenToShape
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:72
2-72
4902 painter->restore();
executed: painter->restore();
Execution Count:2
2
4903 }
executed: }
Execution Count:74
74
4904}
executed: }
Execution Count:410
410
4905 -
4906void QGraphicsScenePrivate::markDirty(QGraphicsItem *item, const QRectF &rect, bool invalidateChildren, -
4907 bool force, bool ignoreOpacity, bool removingItemFromScene, -
4908 bool updateBoundingRect) -
4909{ -
4910 Q_ASSERT(item);
executed (the execution status of this line is deduced): qt_noop();
-
4911 if (updateAll)
evaluated: updateAll
TRUEFALSE
yes
Evaluation Count:4682
yes
Evaluation Count:404
404-4682
4912 return;
executed: return;
Execution Count:4682
4682
4913 -
4914 if (removingItemFromScene && !ignoreOpacity && !item->d_ptr->ignoreOpacity) {
evaluated: removingItemFromScene
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:332
partially evaluated: !ignoreOpacity
TRUEFALSE
yes
Evaluation Count:72
no
Evaluation Count:0
partially evaluated: !item->d_ptr->ignoreOpacity
TRUEFALSE
yes
Evaluation Count:72
no
Evaluation Count:0
0-332
4915 // If any of the item's ancestors ignore opacity, it means that the opacity -
4916 // was set to 0 (and the update request has not yet been processed). That -
4917 // also means that we have to ignore the opacity for the item itself; otherwise -
4918 // things like: parent->setOpacity(0); scene->removeItem(child) won't work. -
4919 // Note that we only do this when removing items from the scene. In all other -
4920 // cases the ignoreOpacity bit propagates properly in processDirtyItems, but -
4921 // since the item is removed immediately it won't be processed there. -
4922 QGraphicsItem *p = item->d_ptr->parent;
executed (the execution status of this line is deduced): QGraphicsItem *p = item->d_ptr->parent;
-
4923 while (p) {
evaluated: p
TRUEFALSE
yes
Evaluation Count:34
yes
Evaluation Count:72
34-72
4924 if (p->d_ptr->ignoreOpacity) {
partially evaluated: p->d_ptr->ignoreOpacity
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:34
0-34
4925 item->d_ptr->ignoreOpacity = true;
never executed (the execution status of this line is deduced): item->d_ptr->ignoreOpacity = true;
-
4926 break;
never executed: break;
0
4927 } -
4928 p = p->d_ptr->parent;
executed (the execution status of this line is deduced): p = p->d_ptr->parent;
-
4929 }
executed: }
Execution Count:34
34
4930 }
executed: }
Execution Count:72
72
4931 -
4932 if (item->d_ptr->discardUpdateRequest(/*ignoreVisibleBit=*/force,
evaluated: item->d_ptr->discardUpdateRequest( force, removingItemFromScene || invalidateChildren, ignoreOpacity)
TRUEFALSE
yes
Evaluation Count:91
yes
Evaluation Count:313
91-313
4933 /*ignoreDirtyBit=*/removingItemFromScene || invalidateChildren,
evaluated: item->d_ptr->discardUpdateRequest( force, removingItemFromScene || invalidateChildren, ignoreOpacity)
TRUEFALSE
yes
Evaluation Count:91
yes
Evaluation Count:313
91-313
4934 /*ignoreOpacity=*/ignoreOpacity)) {
evaluated: item->d_ptr->discardUpdateRequest( force, removingItemFromScene || invalidateChildren, ignoreOpacity)
TRUEFALSE
yes
Evaluation Count:91
yes
Evaluation Count:313
91-313
4935 if (item->d_ptr->dirty) {
partially evaluated: item->d_ptr->dirty
TRUEFALSE
yes
Evaluation Count:91
no
Evaluation Count:0
0-91
4936 // The item is already marked as dirty and will be processed later. However, -
4937 // we have to make sure ignoreVisible and ignoreOpacity are set properly; -
4938 // otherwise things like: item->update(); item->hide() (force is now true) -
4939 // won't work as expected. -
4940 if (force)
partially evaluated: force
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:91
0-91
4941 item->d_ptr->ignoreVisible = 1;
never executed: item->d_ptr->ignoreVisible = 1;
0
4942 if (ignoreOpacity)
partially evaluated: ignoreOpacity
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:91
0-91
4943 item->d_ptr->ignoreOpacity = 1;
never executed: item->d_ptr->ignoreOpacity = 1;
0
4944 }
executed: }
Execution Count:91
91
4945 return;
executed: return;
Execution Count:91
91
4946 } -
4947 -
4948 const bool fullItemUpdate = rect.isNull();
executed (the execution status of this line is deduced): const bool fullItemUpdate = rect.isNull();
-
4949 if (!fullItemUpdate && rect.isEmpty())
partially evaluated: !fullItemUpdate
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:313
never evaluated: rect.isEmpty()
0-313
4950 return;
never executed: return;
0
4951 -
4952 if (!processDirtyItemsEmitted) {
evaluated: !processDirtyItemsEmitted
TRUEFALSE
yes
Evaluation Count:124
yes
Evaluation Count:189
124-189
4953 QMetaMethod method = q_ptr->metaObject()->method(processDirtyItemsIndex);
executed (the execution status of this line is deduced): QMetaMethod method = q_ptr->metaObject()->method(processDirtyItemsIndex);
-
4954 method.invoke(q_ptr, Qt::QueuedConnection);
executed (the execution status of this line is deduced): method.invoke(q_ptr, Qt::QueuedConnection);
-
4955// QMetaObject::invokeMethod(q_ptr, "_q_processDirtyItems", Qt::QueuedConnection); -
4956 processDirtyItemsEmitted = true;
executed (the execution status of this line is deduced): processDirtyItemsEmitted = true;
-
4957 }
executed: }
Execution Count:124
124
4958 -
4959 if (removingItemFromScene) {
evaluated: removingItemFromScene
TRUEFALSE
yes
Evaluation Count:72
yes
Evaluation Count:241
72-241
4960 // Note that this function can be called from the item's destructor, so -
4961 // do NOT call any virtual functions on it within this block. -
4962 if (isSignalConnected(changedSignalIndex) || views.isEmpty()) {
partially evaluated: isSignalConnected(changedSignalIndex)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:72
evaluated: views.isEmpty()
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:32
0-72
4963 // This block of code is kept for compatibility. Since 4.5, by default -
4964 // QGraphicsView does not connect the signal and we use the below -
4965 // method of delivering updates. -
4966 q_func()->update();
executed (the execution status of this line is deduced): q_func()->update();
-
4967 return;
executed: return;
Execution Count:40
40
4968 } -
4969 -
4970 for (int i = 0; i < views.size(); ++i) {
evaluated: i < views.size()
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:32
32
4971 QGraphicsViewPrivate *viewPrivate = views.at(i)->d_func();
executed (the execution status of this line is deduced): QGraphicsViewPrivate *viewPrivate = views.at(i)->d_func();
-
4972 QRect rect = item->d_ptr->paintedViewBoundingRects.value(viewPrivate->viewport);
executed (the execution status of this line is deduced): QRect rect = item->d_ptr->paintedViewBoundingRects.value(viewPrivate->viewport);
-
4973 rect.translate(viewPrivate->dirtyScrollOffset);
executed (the execution status of this line is deduced): rect.translate(viewPrivate->dirtyScrollOffset);
-
4974 viewPrivate->updateRect(rect);
executed (the execution status of this line is deduced): viewPrivate->updateRect(rect);
-
4975 }
executed: }
Execution Count:32
32
4976 return;
executed: return;
Execution Count:32
32
4977 } -
4978 -
4979 bool hasNoContents = item->d_ptr->flags & QGraphicsItem::ItemHasNoContents;
executed (the execution status of this line is deduced): bool hasNoContents = item->d_ptr->flags & QGraphicsItem::ItemHasNoContents;
-
4980 if (!hasNoContents) {
evaluated: !hasNoContents
TRUEFALSE
yes
Evaluation Count:237
yes
Evaluation Count:4
4-237
4981 item->d_ptr->dirty = 1;
never executed (the execution status of this line is deduced): item->d_ptr->dirty = 1;
-
4982 if (fullItemUpdate)
partially evaluated: fullItemUpdate
TRUEFALSE
yes
Evaluation Count:237
no
Evaluation Count:0
0-237
4983 item->d_ptr->fullUpdatePending = 1;
executed: item->d_ptr->fullUpdatePending = 1;
Execution Count:237
237
4984 else if (!item->d_ptr->fullUpdatePending)
never evaluated: !item->d_ptr->fullUpdatePending
0
4985 item->d_ptr->needsRepaint |= rect;
never executed: item->d_ptr->needsRepaint |= rect;
0
4986 } else if (item->d_ptr->graphicsEffect) {
partially evaluated: item->d_ptr->graphicsEffect
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
4987 invalidateChildren = true;
executed (the execution status of this line is deduced): invalidateChildren = true;
-
4988 }
executed: }
Execution Count:4
4
4989 -
4990 if (invalidateChildren) {
evaluated: invalidateChildren
TRUEFALSE
yes
Evaluation Count:117
yes
Evaluation Count:124
117-124
4991 item->d_ptr->allChildrenDirty = 1;
executed (the execution status of this line is deduced): item->d_ptr->allChildrenDirty = 1;
-
4992 item->d_ptr->dirtyChildren = 1;
executed (the execution status of this line is deduced): item->d_ptr->dirtyChildren = 1;
-
4993 }
executed: }
Execution Count:117
117
4994 -
4995 if (force)
evaluated: force
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:240
1-240
4996 item->d_ptr->ignoreVisible = 1;
executed: item->d_ptr->ignoreVisible = 1;
Execution Count:1
1
4997 if (ignoreOpacity)
partially evaluated: ignoreOpacity
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:241
0-241
4998 item->d_ptr->ignoreOpacity = 1;
never executed: item->d_ptr->ignoreOpacity = 1;
0
4999 -
5000 if (!updateBoundingRect)
evaluated: !updateBoundingRect
TRUEFALSE
yes
Evaluation Count:129
yes
Evaluation Count:112
112-129
5001 item->d_ptr->markParentDirty();
executed: item->d_ptr->markParentDirty();
Execution Count:129
129
5002}
executed: }
Execution Count:241
241
5003 -
5004static inline bool updateHelper(QGraphicsViewPrivate *view, QGraphicsItemPrivate *item, -
5005 const QRectF &rect, bool itemIsUntransformable) -
5006{ -
5007 Q_ASSERT(view);
executed (the execution status of this line is deduced): qt_noop();
-
5008 Q_ASSERT(item);
executed (the execution status of this line is deduced): qt_noop();
-
5009 -
5010 QGraphicsItem *itemq = static_cast<QGraphicsItem *>(item->q_ptr);
executed (the execution status of this line is deduced): QGraphicsItem *itemq = static_cast<QGraphicsItem *>(item->q_ptr);
-
5011 QGraphicsView *viewq = static_cast<QGraphicsView *>(view->q_ptr);
executed (the execution status of this line is deduced): QGraphicsView *viewq = static_cast<QGraphicsView *>(view->q_ptr);
-
5012 -
5013 if (itemIsUntransformable) {
partially evaluated: itemIsUntransformable
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:204
0-204
5014 const QTransform xform = itemq->deviceTransform(viewq->viewportTransform());
never executed (the execution status of this line is deduced): const QTransform xform = itemq->deviceTransform(viewq->viewportTransform());
-
5015 if (!item->hasBoundingRegionGranularity)
never evaluated: !item->hasBoundingRegionGranularity
0
5016 return view->updateRectF(xform.mapRect(rect));
never executed: return view->updateRectF(xform.mapRect(rect));
0
5017 return view->updateRegion(rect, xform);
never executed: return view->updateRegion(rect, xform);
0
5018 } -
5019 -
5020 if (item->sceneTransformTranslateOnly && view->identityMatrix) {
evaluated: item->sceneTransformTranslateOnly
TRUEFALSE
yes
Evaluation Count:203
yes
Evaluation Count:1
partially evaluated: view->identityMatrix
TRUEFALSE
yes
Evaluation Count:203
no
Evaluation Count:0
0-203
5021 const qreal dx = item->sceneTransform.dx();
executed (the execution status of this line is deduced): const qreal dx = item->sceneTransform.dx();
-
5022 const qreal dy = item->sceneTransform.dy();
executed (the execution status of this line is deduced): const qreal dy = item->sceneTransform.dy();
-
5023 QRectF r(rect);
executed (the execution status of this line is deduced): QRectF r(rect);
-
5024 r.translate(dx - view->horizontalScroll(), dy - view->verticalScroll());
executed (the execution status of this line is deduced): r.translate(dx - view->horizontalScroll(), dy - view->verticalScroll());
-
5025 return view->updateRectF(r);
executed: return view->updateRectF(r);
Execution Count:203
203
5026 } -
5027 -
5028 if (!viewq->isTransformed()) {
partially evaluated: !viewq->isTransformed()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
5029 if (!item->hasBoundingRegionGranularity)
never evaluated: !item->hasBoundingRegionGranularity
0
5030 return view->updateRectF(item->sceneTransform.mapRect(rect));
never executed: return view->updateRectF(item->sceneTransform.mapRect(rect));
0
5031 return view->updateRegion(rect, item->sceneTransform);
never executed: return view->updateRegion(rect, item->sceneTransform);
0
5032 } -
5033 -
5034 QTransform xform = item->sceneTransform;
executed (the execution status of this line is deduced): QTransform xform = item->sceneTransform;
-
5035 xform *= viewq->viewportTransform();
executed (the execution status of this line is deduced): xform *= viewq->viewportTransform();
-
5036 if (!item->hasBoundingRegionGranularity)
partially evaluated: !item->hasBoundingRegionGranularity
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
5037 return view->updateRectF(xform.mapRect(rect));
executed: return view->updateRectF(xform.mapRect(rect));
Execution Count:1
1
5038 return view->updateRegion(rect, xform);
never executed: return view->updateRegion(rect, xform);
0
5039} -
5040 -
5041void QGraphicsScenePrivate::processDirtyItemsRecursive(QGraphicsItem *item, bool dirtyAncestorContainsChildren, -
5042 qreal parentOpacity) -
5043{ -
5044 Q_Q(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScene * const q = q_func();
-
5045 Q_ASSERT(item);
executed (the execution status of this line is deduced): qt_noop();
-
5046 Q_ASSERT(!updateAll);
executed (the execution status of this line is deduced): qt_noop();
-
5047 -
5048 if (!item->d_ptr->dirty && !item->d_ptr->dirtyChildren) {
evaluated: !item->d_ptr->dirty
TRUEFALSE
yes
Evaluation Count:33
yes
Evaluation Count:208
evaluated: !item->d_ptr->dirtyChildren
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:30
3-208
5049 resetDirtyItem(item);
executed (the execution status of this line is deduced): resetDirtyItem(item);
-
5050 return;
executed: return;
Execution Count:3
3
5051 } -
5052 -
5053 const bool itemIsHidden = !item->d_ptr->ignoreVisible && !item->d_ptr->visible;
evaluated: !item->d_ptr->ignoreVisible
TRUEFALSE
yes
Evaluation Count:237
yes
Evaluation Count:1
evaluated: !item->d_ptr->visible
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:236
1-237
5054 if (itemIsHidden) {
evaluated: itemIsHidden
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:237
1-237
5055 resetDirtyItem(item, /*recursive=*/true);
executed (the execution status of this line is deduced): resetDirtyItem(item, true);
-
5056 return;
executed: return;
Execution Count:1
1
5057 } -
5058 -
5059 bool itemHasContents = !(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents);
executed (the execution status of this line is deduced): bool itemHasContents = !(item->d_ptr->flags & QGraphicsItem::ItemHasNoContents);
-
5060 const bool itemHasChildren = !item->d_ptr->children.isEmpty();
executed (the execution status of this line is deduced): const bool itemHasChildren = !item->d_ptr->children.isEmpty();
-
5061 if (!itemHasContents) {
evaluated: !itemHasContents
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:233
4-233
5062 if (!itemHasChildren) {
partially evaluated: !itemHasChildren
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
5063 resetDirtyItem(item);
never executed (the execution status of this line is deduced): resetDirtyItem(item);
-
5064 return; // Item has neither contents nor children!(?)
never executed: return;
0
5065 } -
5066 if (item->d_ptr->graphicsEffect)
partially evaluated: item->d_ptr->graphicsEffect
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
5067 itemHasContents = true;
executed: itemHasContents = true;
Execution Count:4
4
5068 }
executed: }
Execution Count:4
4
5069 -
5070 const qreal opacity = item->d_ptr->combineOpacityFromParent(parentOpacity);
executed (the execution status of this line is deduced): const qreal opacity = item->d_ptr->combineOpacityFromParent(parentOpacity);
-
5071 const bool itemIsFullyTransparent = !item->d_ptr->ignoreOpacity
partially evaluated: !item->d_ptr->ignoreOpacity
TRUEFALSE
yes
Evaluation Count:237
no
Evaluation Count:0
0-237
5072 && QGraphicsItemPrivate::isOpacityNull(opacity);
partially evaluated: QGraphicsItemPrivate::isOpacityNull(opacity)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:237
0-237
5073 if (itemIsFullyTransparent && (!itemHasChildren || item->d_ptr->childrenCombineOpacity())) {
partially evaluated: itemIsFullyTransparent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:237
never evaluated: !itemHasChildren
never evaluated: item->d_ptr->childrenCombineOpacity()
0-237
5074 resetDirtyItem(item, /*recursive=*/itemHasChildren);
never executed (the execution status of this line is deduced): resetDirtyItem(item, itemHasChildren);
-
5075 return;
never executed: return;
0
5076 } -
5077 -
5078 bool wasDirtyParentSceneTransform = item->d_ptr->dirtySceneTransform;
executed (the execution status of this line is deduced): bool wasDirtyParentSceneTransform = item->d_ptr->dirtySceneTransform;
-
5079 const bool itemIsUntransformable = item->d_ptr->itemIsUntransformable();
executed (the execution status of this line is deduced): const bool itemIsUntransformable = item->d_ptr->itemIsUntransformable();
-
5080 if (wasDirtyParentSceneTransform && !itemIsUntransformable) {
evaluated: wasDirtyParentSceneTransform
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:225
partially evaluated: !itemIsUntransformable
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-225
5081 item->d_ptr->updateSceneTransformFromParent();
executed (the execution status of this line is deduced): item->d_ptr->updateSceneTransformFromParent();
-
5082 Q_ASSERT(!item->d_ptr->dirtySceneTransform);
executed (the execution status of this line is deduced): qt_noop();
-
5083 }
executed: }
Execution Count:12
12
5084 -
5085 const bool wasDirtyParentViewBoundingRects = item->d_ptr->paintedViewBoundingRectsNeedRepaint;
executed (the execution status of this line is deduced): const bool wasDirtyParentViewBoundingRects = item->d_ptr->paintedViewBoundingRectsNeedRepaint;
-
5086 if (itemIsFullyTransparent || !itemHasContents || dirtyAncestorContainsChildren) {
partially evaluated: itemIsFullyTransparent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:237
partially evaluated: !itemHasContents
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:237
evaluated: dirtyAncestorContainsChildren
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:236
0-237
5087 // Make sure we don't process invisible items or items with no content. -
5088 item->d_ptr->dirty = 0;
executed (the execution status of this line is deduced): item->d_ptr->dirty = 0;
-
5089 item->d_ptr->fullUpdatePending = 0;
executed (the execution status of this line is deduced): item->d_ptr->fullUpdatePending = 0;
-
5090 // Might have a dirty view bounding rect otherwise. -
5091 if (itemIsFullyTransparent || !itemHasContents)
partially evaluated: itemIsFullyTransparent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: !itemHasContents
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
5092 item->d_ptr->paintedViewBoundingRectsNeedRepaint = 0;
never executed: item->d_ptr->paintedViewBoundingRectsNeedRepaint = 0;
0
5093 }
executed: }
Execution Count:1
1
5094 -
5095 if (!hasSceneRect && item->d_ptr->geometryChanged && item->d_ptr->visible) {
evaluated: !hasSceneRect
TRUEFALSE
yes
Evaluation Count:233
yes
Evaluation Count:4
evaluated: item->d_ptr->geometryChanged
TRUEFALSE
yes
Evaluation Count:194
yes
Evaluation Count:39
partially evaluated: item->d_ptr->visible
TRUEFALSE
yes
Evaluation Count:194
no
Evaluation Count:0
0-233
5096 // Update growingItemsBoundingRect. -
5097 if (item->d_ptr->sceneTransformTranslateOnly) {
evaluated: item->d_ptr->sceneTransformTranslateOnly
TRUEFALSE
yes
Evaluation Count:193
yes
Evaluation Count:1
1-193
5098 growingItemsBoundingRect |= item->boundingRect().translated(item->d_ptr->sceneTransform.dx(),
executed (the execution status of this line is deduced): growingItemsBoundingRect |= item->boundingRect().translated(item->d_ptr->sceneTransform.dx(),
-
5099 item->d_ptr->sceneTransform.dy());
executed (the execution status of this line is deduced): item->d_ptr->sceneTransform.dy());
-
5100 } else {
executed: }
Execution Count:193
193
5101 growingItemsBoundingRect |= item->d_ptr->sceneTransform.mapRect(item->boundingRect());
executed (the execution status of this line is deduced): growingItemsBoundingRect |= item->d_ptr->sceneTransform.mapRect(item->boundingRect());
-
5102 }
executed: }
Execution Count:1
1
5103 } -
5104 -
5105 // Process item. -
5106 if (item->d_ptr->dirty || item->d_ptr->paintedViewBoundingRectsNeedRepaint) {
evaluated: item->d_ptr->dirty
TRUEFALSE
yes
Evaluation Count:206
yes
Evaluation Count:31
evaluated: item->d_ptr->paintedViewBoundingRectsNeedRepaint
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:30
1-206
5107 const bool useCompatUpdate = views.isEmpty() || isSignalConnected(changedSignalIndex);
evaluated: views.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:205
partially evaluated: isSignalConnected(changedSignalIndex)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:205
0-205
5108 const QRectF itemBoundingRect = adjustedItemEffectiveBoundingRect(item);
executed (the execution status of this line is deduced): const QRectF itemBoundingRect = adjustedItemEffectiveBoundingRect(item);
-
5109 -
5110 if (useCompatUpdate && !itemIsUntransformable && qFuzzyIsNull(item->boundingRegionGranularity())) {
evaluated: useCompatUpdate
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:205
partially evaluated: !itemIsUntransformable
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: qFuzzyIsNull(item->boundingRegionGranularity())
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-205
5111 // This block of code is kept for compatibility. Since 4.5, by default -
5112 // QGraphicsView does not connect the signal and we use the below -
5113 // method of delivering updates. -
5114 if (item->d_ptr->sceneTransformTranslateOnly) {
partially evaluated: item->d_ptr->sceneTransformTranslateOnly
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
5115 q->update(itemBoundingRect.translated(item->d_ptr->sceneTransform.dx(),
executed (the execution status of this line is deduced): q->update(itemBoundingRect.translated(item->d_ptr->sceneTransform.dx(),
-
5116 item->d_ptr->sceneTransform.dy()));
executed (the execution status of this line is deduced): item->d_ptr->sceneTransform.dy()));
-
5117 } else {
executed: }
Execution Count:2
2
5118 QRectF rect = item->d_ptr->sceneTransform.mapRect(itemBoundingRect);
never executed (the execution status of this line is deduced): QRectF rect = item->d_ptr->sceneTransform.mapRect(itemBoundingRect);
-
5119 if (!rect.isEmpty())
never evaluated: !rect.isEmpty()
0
5120 q->update(rect);
never executed: q->update(rect);
0
5121 }
never executed: }
0
5122 } else { -
5123 QRectF dirtyRect;
executed (the execution status of this line is deduced): QRectF dirtyRect;
-
5124 bool uninitializedDirtyRect = true;
executed (the execution status of this line is deduced): bool uninitializedDirtyRect = true;
-
5125 -
5126 for (int j = 0; j < views.size(); ++j) {
evaluated: j < views.size()
TRUEFALSE
yes
Evaluation Count:205
yes
Evaluation Count:205
205
5127 QGraphicsView *view = views.at(j);
executed (the execution status of this line is deduced): QGraphicsView *view = views.at(j);
-
5128 QGraphicsViewPrivate *viewPrivate = view->d_func();
executed (the execution status of this line is deduced): QGraphicsViewPrivate *viewPrivate = view->d_func();
-
5129 QRect &paintedViewBoundingRect = item->d_ptr->paintedViewBoundingRects[viewPrivate->viewport];
executed (the execution status of this line is deduced): QRect &paintedViewBoundingRect = item->d_ptr->paintedViewBoundingRects[viewPrivate->viewport];
-
5130 if (viewPrivate->fullUpdatePending
partially evaluated: viewPrivate->fullUpdatePending
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:205
0-205
5131 || viewPrivate->viewportUpdateMode == QGraphicsView::NoViewportUpdate) {
partially evaluated: viewPrivate->viewportUpdateMode == QGraphicsView::NoViewportUpdate
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:205
0-205
5132 // Okay, if we have a full update pending or no viewport update, this item's -
5133 // paintedViewBoundingRect will be updated correctly in the next paintEvent if -
5134 // it is inside the viewport, but for now we can pretend that it is outside. -
5135 paintedViewBoundingRect = QRect(-1, -1, -1, -1);
never executed (the execution status of this line is deduced): paintedViewBoundingRect = QRect(-1, -1, -1, -1);
-
5136 continue;
never executed: continue;
0
5137 } -
5138 -
5139 if (item->d_ptr->paintedViewBoundingRectsNeedRepaint) {
evaluated: item->d_ptr->paintedViewBoundingRectsNeedRepaint
TRUEFALSE
yes
Evaluation Count:188
yes
Evaluation Count:17
17-188
5140 paintedViewBoundingRect.translate(viewPrivate->dirtyScrollOffset);
executed (the execution status of this line is deduced): paintedViewBoundingRect.translate(viewPrivate->dirtyScrollOffset);
-
5141 if (!viewPrivate->updateRect(paintedViewBoundingRect))
evaluated: !viewPrivate->updateRect(paintedViewBoundingRect)
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:179
9-179
5142 paintedViewBoundingRect = QRect(-1, -1, -1, -1); // Outside viewport.
executed: paintedViewBoundingRect = QRect(-1, -1, -1, -1);
Execution Count:9
9
5143 }
executed: }
Execution Count:188
188
5144 -
5145 if (!item->d_ptr->dirty)
evaluated: !item->d_ptr->dirty
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:204
1-204
5146 continue;
executed: continue;
Execution Count:1
1
5147 -
5148 if (!item->d_ptr->paintedViewBoundingRectsNeedRepaint
evaluated: !item->d_ptr->paintedViewBoundingRectsNeedRepaint
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:187
17-187
5149 && paintedViewBoundingRect.x() == -1 && paintedViewBoundingRect.y() == -1
partially evaluated: paintedViewBoundingRect.x() == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
never evaluated: paintedViewBoundingRect.y() == -1
0-17
5150 && paintedViewBoundingRect.width() == -1 && paintedViewBoundingRect.height() == -1) {
never evaluated: paintedViewBoundingRect.width() == -1
never evaluated: paintedViewBoundingRect.height() == -1
0
5151 continue; // Outside viewport.
never executed: continue;
0
5152 } -
5153 -
5154 if (uninitializedDirtyRect) {
partially evaluated: uninitializedDirtyRect
TRUEFALSE
yes
Evaluation Count:204
no
Evaluation Count:0
0-204
5155 dirtyRect = itemBoundingRect;
executed (the execution status of this line is deduced): dirtyRect = itemBoundingRect;
-
5156 if (!item->d_ptr->fullUpdatePending) {
partially evaluated: !item->d_ptr->fullUpdatePending
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:204
0-204
5157 _q_adjustRect(&item->d_ptr->needsRepaint);
never executed (the execution status of this line is deduced): _q_adjustRect(&item->d_ptr->needsRepaint);
-
5158 dirtyRect &= item->d_ptr->needsRepaint;
never executed (the execution status of this line is deduced): dirtyRect &= item->d_ptr->needsRepaint;
-
5159 }
never executed: }
0
5160 uninitializedDirtyRect = false;
executed (the execution status of this line is deduced): uninitializedDirtyRect = false;
-
5161 }
executed: }
Execution Count:204
204
5162 -
5163 if (dirtyRect.isEmpty())
partially evaluated: dirtyRect.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:204
0-204
5164 continue; // Discard updates outside the bounding rect.
never executed: continue;
0
5165 -
5166 if (!updateHelper(viewPrivate, item->d_ptr.data(), dirtyRect, itemIsUntransformable)
evaluated: !updateHelper(viewPrivate, item->d_ptr.data(), dirtyRect, itemIsUntransformable)
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:199
5-199
5167 && item->d_ptr->paintedViewBoundingRectsNeedRepaint) {
partially evaluated: item->d_ptr->paintedViewBoundingRectsNeedRepaint
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
5168 paintedViewBoundingRect = QRect(-1, -1, -1, -1); // Outside viewport.
executed (the execution status of this line is deduced): paintedViewBoundingRect = QRect(-1, -1, -1, -1);
-
5169 }
executed: }
Execution Count:5
5
5170 }
executed: }
Execution Count:204
204
5171 }
executed: }
Execution Count:205
205
5172 } -
5173 -
5174 // Process children. -
5175 if (itemHasChildren && item->d_ptr->dirtyChildren) {
evaluated: itemHasChildren
TRUEFALSE
yes
Evaluation Count:49
yes
Evaluation Count:188
evaluated: item->d_ptr->dirtyChildren
TRUEFALSE
yes
Evaluation Count:48
yes
Evaluation Count:1
1-188
5176 const bool itemClipsChildrenToShape = item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape;
executed (the execution status of this line is deduced): const bool itemClipsChildrenToShape = item->d_ptr->flags & QGraphicsItem::ItemClipsChildrenToShape;
-
5177 // Items with no content are threated as 'dummy' items which means they are never drawn and -
5178 // 'processed', so the painted view bounding rect is never up-to-date. This means that whenever -
5179 // such an item changes geometry, its children have to take care of the update regardless -
5180 // of whether the item clips children to shape or not. -
5181 const bool bypassUpdateClip = !itemHasContents && wasDirtyParentViewBoundingRects;
partially evaluated: !itemHasContents
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:48
never evaluated: wasDirtyParentViewBoundingRects
0-48
5182 if (itemClipsChildrenToShape && !bypassUpdateClip) {
evaluated: itemClipsChildrenToShape
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:47
partially evaluated: !bypassUpdateClip
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-47
5183 // Make sure child updates are clipped to the item's bounding rect. -
5184 for (int i = 0; i < views.size(); ++i)
evaluated: i < views.size()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
5185 views.at(i)->d_func()->setUpdateClip(item);
executed: views.at(i)->d_func()->setUpdateClip(item);
Execution Count:1
1
5186 }
executed: }
Execution Count:1
1
5187 if (!dirtyAncestorContainsChildren) {
partially evaluated: !dirtyAncestorContainsChildren
TRUEFALSE
yes
Evaluation Count:48
no
Evaluation Count:0
0-48
5188 dirtyAncestorContainsChildren = item->d_ptr->fullUpdatePending
evaluated: item->d_ptr->fullUpdatePending
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:30
18-30
5189 && itemClipsChildrenToShape;
evaluated: itemClipsChildrenToShape
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:17
1-17
5190 }
executed: }
Execution Count:48
48
5191 const bool allChildrenDirty = item->d_ptr->allChildrenDirty;
executed (the execution status of this line is deduced): const bool allChildrenDirty = item->d_ptr->allChildrenDirty;
-
5192 const bool parentIgnoresVisible = item->d_ptr->ignoreVisible;
executed (the execution status of this line is deduced): const bool parentIgnoresVisible = item->d_ptr->ignoreVisible;
-
5193 const bool parentIgnoresOpacity = item->d_ptr->ignoreOpacity;
executed (the execution status of this line is deduced): const bool parentIgnoresOpacity = item->d_ptr->ignoreOpacity;
-
5194 for (int i = 0; i < item->d_ptr->children.size(); ++i) {
evaluated: i < item->d_ptr->children.size()
TRUEFALSE
yes
Evaluation Count:169
yes
Evaluation Count:48
48-169
5195 QGraphicsItem *child = item->d_ptr->children.at(i);
executed (the execution status of this line is deduced): QGraphicsItem *child = item->d_ptr->children.at(i);
-
5196 if (wasDirtyParentSceneTransform)
evaluated: wasDirtyParentSceneTransform
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:167
2-167
5197 child->d_ptr->dirtySceneTransform = 1;
executed: child->d_ptr->dirtySceneTransform = 1;
Execution Count:2
2
5198 if (wasDirtyParentViewBoundingRects)
evaluated: wasDirtyParentViewBoundingRects
TRUEFALSE
yes
Evaluation Count:83
yes
Evaluation Count:86
83-86
5199 child->d_ptr->paintedViewBoundingRectsNeedRepaint = 1;
executed: child->d_ptr->paintedViewBoundingRectsNeedRepaint = 1;
Execution Count:83
83
5200 if (parentIgnoresVisible)
partially evaluated: parentIgnoresVisible
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:169
0-169
5201 child->d_ptr->ignoreVisible = 1;
never executed: child->d_ptr->ignoreVisible = 1;
0
5202 if (parentIgnoresOpacity)
partially evaluated: parentIgnoresOpacity
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:169
0-169
5203 child->d_ptr->ignoreOpacity = 1;
never executed: child->d_ptr->ignoreOpacity = 1;
0
5204 if (allChildrenDirty) {
evaluated: allChildrenDirty
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:153
16-153
5205 child->d_ptr->dirty = 1;
executed (the execution status of this line is deduced): child->d_ptr->dirty = 1;
-
5206 child->d_ptr->fullUpdatePending = 1;
executed (the execution status of this line is deduced): child->d_ptr->fullUpdatePending = 1;
-
5207 child->d_ptr->dirtyChildren = 1;
executed (the execution status of this line is deduced): child->d_ptr->dirtyChildren = 1;
-
5208 child->d_ptr->allChildrenDirty = 1;
executed (the execution status of this line is deduced): child->d_ptr->allChildrenDirty = 1;
-
5209 }
executed: }
Execution Count:16
16
5210 processDirtyItemsRecursive(child, dirtyAncestorContainsChildren, opacity);
executed (the execution status of this line is deduced): processDirtyItemsRecursive(child, dirtyAncestorContainsChildren, opacity);
-
5211 }
executed: }
Execution Count:169
169
5212 -
5213 if (itemClipsChildrenToShape) {
evaluated: itemClipsChildrenToShape
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:47
1-47
5214 // Reset updateClip. -
5215 for (int i = 0; i < views.size(); ++i)
evaluated: i < views.size()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
5216 views.at(i)->d_func()->setUpdateClip(0);
executed: views.at(i)->d_func()->setUpdateClip(0);
Execution Count:1
1
5217 }
executed: }
Execution Count:1
1
5218 } else if (wasDirtyParentSceneTransform) {
executed: }
Execution Count:48
evaluated: wasDirtyParentSceneTransform
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:179
10-179
5219 item->d_ptr->invalidateChildrenSceneTransform();
executed (the execution status of this line is deduced): item->d_ptr->invalidateChildrenSceneTransform();
-
5220 }
executed: }
Execution Count:10
10
5221 -
5222 resetDirtyItem(item);
executed (the execution status of this line is deduced): resetDirtyItem(item);
-
5223}
executed: }
Execution Count:237
237
5224 -
5225/*! -
5226 \obsolete -
5227 -
5228 Paints the given \a items using the provided \a painter, after the -
5229 background has been drawn, and before the foreground has been -
5230 drawn. All painting is done in \e scene coordinates. Before -
5231 drawing each item, the painter must be transformed using -
5232 QGraphicsItem::sceneTransform(). -
5233 -
5234 The \a options parameter is the list of style option objects for -
5235 each item in \a items. The \a numItems parameter is the number of -
5236 items in \a items and options in \a options. The \a widget -
5237 parameter is optional; if specified, it should point to the widget -
5238 that is being painted on. -
5239 -
5240 The default implementation prepares the painter matrix, and calls -
5241 QGraphicsItem::paint() on all items. Reimplement this function to -
5242 provide custom painting of all items for the scene; gaining -
5243 complete control over how each item is drawn. In some cases this -
5244 can increase drawing performance significantly. -
5245 -
5246 Example: -
5247 -
5248 \snippet graphicssceneadditemsnippet.cpp 0 -
5249 -
5250 Since Qt 4.6, this function is not called anymore unless -
5251 the QGraphicsView::IndirectPainting flag is given as an Optimization -
5252 flag. -
5253 -
5254 \sa drawBackground(), drawForeground() -
5255*/ -
5256void QGraphicsScene::drawItems(QPainter *painter, -
5257 int numItems, -
5258 QGraphicsItem *items[], -
5259 const QStyleOptionGraphicsItem options[], QWidget *widget) -
5260{ -
5261 Q_D(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
5262 // Make sure we don't have unpolished items before we draw. -
5263 if (!d->unpolishedItems.isEmpty())
partially evaluated: !d->unpolishedItems.isEmpty()
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
5264 d->_q_polishItems();
executed: d->_q_polishItems();
Execution Count:7
7
5265 -
5266 const qreal opacity = painter->opacity();
executed (the execution status of this line is deduced): const qreal opacity = painter->opacity();
-
5267 QTransform viewTransform = painter->worldTransform();
executed (the execution status of this line is deduced): QTransform viewTransform = painter->worldTransform();
-
5268 Q_UNUSED(options);
executed (the execution status of this line is deduced): (void)options;;
-
5269 -
5270 // Determine view, expose and flags. -
5271 QGraphicsView *view = widget ? qobject_cast<QGraphicsView *>(widget->parentWidget()) : 0;
partially evaluated: widget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
5272 QRegion *expose = 0;
executed (the execution status of this line is deduced): QRegion *expose = 0;
-
5273 const quint32 oldRectAdjust = d->rectAdjust;
executed (the execution status of this line is deduced): const quint32 oldRectAdjust = d->rectAdjust;
-
5274 if (view) {
partially evaluated: view
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
5275 d->updateAll = false;
never executed (the execution status of this line is deduced): d->updateAll = false;
-
5276 expose = &view->d_func()->exposedRegion;
never executed (the execution status of this line is deduced): expose = &view->d_func()->exposedRegion;
-
5277 if (view->d_func()->optimizationFlags & QGraphicsView::DontAdjustForAntialiasing)
never evaluated: view->d_func()->optimizationFlags & QGraphicsView::DontAdjustForAntialiasing
0
5278 d->rectAdjust = 1;
never executed: d->rectAdjust = 1;
0
5279 else -
5280 d->rectAdjust = 2;
never executed: d->rectAdjust = 2;
0
5281 } -
5282 -
5283 // Find all toplevels, they are already sorted. -
5284 QList<QGraphicsItem *> topLevelItems;
executed (the execution status of this line is deduced): QList<QGraphicsItem *> topLevelItems;
-
5285 for (int i = 0; i < numItems; ++i) {
evaluated: i < numItems
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:7
7
5286 QGraphicsItem *item = items[i]->topLevelItem();
executed (the execution status of this line is deduced): QGraphicsItem *item = items[i]->topLevelItem();
-
5287 if (!item->d_ptr->itemDiscovered) {
partially evaluated: !item->d_ptr->itemDiscovered
TRUEFALSE
yes
Evaluation Count:7
no
Evaluation Count:0
0-7
5288 topLevelItems << item;
executed (the execution status of this line is deduced): topLevelItems << item;
-
5289 item->d_ptr->itemDiscovered = 1;
executed (the execution status of this line is deduced): item->d_ptr->itemDiscovered = 1;
-
5290 d->drawSubtreeRecursive(item, painter, &viewTransform, expose, widget);
executed (the execution status of this line is deduced): d->drawSubtreeRecursive(item, painter, &viewTransform, expose, widget);
-
5291 }
executed: }
Execution Count:7
7
5292 }
executed: }
Execution Count:7
7
5293 -
5294 d->rectAdjust = oldRectAdjust;
executed (the execution status of this line is deduced): d->rectAdjust = oldRectAdjust;
-
5295 // Reset discovery bits. -
5296 for (int i = 0; i < topLevelItems.size(); ++i)
evaluated: i < topLevelItems.size()
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:7
7
5297 topLevelItems.at(i)->d_ptr->itemDiscovered = 0;
executed: topLevelItems.at(i)->d_ptr->itemDiscovered = 0;
Execution Count:7
7
5298 -
5299 painter->setWorldTransform(viewTransform);
executed (the execution status of this line is deduced): painter->setWorldTransform(viewTransform);
-
5300 painter->setOpacity(opacity);
executed (the execution status of this line is deduced): painter->setOpacity(opacity);
-
5301}
executed: }
Execution Count:7
7
5302 -
5303/*! -
5304 \since 4.4 -
5305 -
5306 Finds a new widget to give the keyboard focus to, as appropriate for Tab -
5307 and Shift+Tab, and returns true if it can find a new widget, or false if -
5308 it cannot. If \a next is true, this function searches forward; if \a next -
5309 is false, it searches backward. -
5310 -
5311 You can reimplement this function in a subclass of QGraphicsScene to -
5312 provide fine-grained control over how tab focus passes inside your -
5313 scene. The default implementation is based on the tab focus chain defined -
5314 by QGraphicsWidget::setTabOrder(). -
5315*/ -
5316bool QGraphicsScene::focusNextPrevChild(bool next) -
5317{ -
5318 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
5319 -
5320 QGraphicsItem *item = focusItem();
never executed (the execution status of this line is deduced): QGraphicsItem *item = focusItem();
-
5321 if (item && !item->isWidget()) {
never evaluated: item
never evaluated: !item->isWidget()
0
5322 // Tab out of the scene. -
5323 return false;
never executed: return false;
0
5324 } -
5325 if (!item) {
never evaluated: !item
0
5326 if (d->lastFocusItem && !d->lastFocusItem->isWidget()) {
never evaluated: d->lastFocusItem
never evaluated: !d->lastFocusItem->isWidget()
0
5327 // Restore focus to the last focusable non-widget item that had -
5328 // focus. -
5329 setFocusItem(d->lastFocusItem, next ? Qt::TabFocusReason : Qt::BacktabFocusReason);
never executed (the execution status of this line is deduced): setFocusItem(d->lastFocusItem, next ? Qt::TabFocusReason : Qt::BacktabFocusReason);
-
5330 return true;
never executed: return true;
0
5331 } -
5332 }
never executed: }
0
5333 if (!d->tabFocusFirst) {
never evaluated: !d->tabFocusFirst
0
5334 // No widgets... -
5335 return false;
never executed: return false;
0
5336 } -
5337 -
5338 // The item must be a widget. -
5339 QGraphicsWidget *widget = 0;
never executed (the execution status of this line is deduced): QGraphicsWidget *widget = 0;
-
5340 if (!item) {
never evaluated: !item
0
5341 widget = next ? d->tabFocusFirst : d->tabFocusFirst->d_func()->focusPrev;
never evaluated: next
0
5342 } else {
never executed: }
0
5343 QGraphicsWidget *test = static_cast<QGraphicsWidget *>(item);
never executed (the execution status of this line is deduced): QGraphicsWidget *test = static_cast<QGraphicsWidget *>(item);
-
5344 widget = next ? test->d_func()->focusNext : test->d_func()->focusPrev;
never evaluated: next
0
5345 if ((next && widget == d->tabFocusFirst) || (!next && widget == d->tabFocusFirst->d_func()->focusPrev))
never evaluated: next
never evaluated: widget == d->tabFocusFirst
never evaluated: !next
never evaluated: widget == d->tabFocusFirst->d_func()->focusPrev
0
5346 return false;
never executed: return false;
0
5347 }
never executed: }
0
5348 QGraphicsWidget *widgetThatHadFocus = widget;
never executed (the execution status of this line is deduced): QGraphicsWidget *widgetThatHadFocus = widget;
-
5349 -
5350 // Run around the focus chain until we find a widget that can take tab focus. -
5351 do { -
5352 if (widget->flags() & QGraphicsItem::ItemIsFocusable
never evaluated: widget->flags() & QGraphicsItem::ItemIsFocusable
0
5353 && widget->isEnabled() && widget->isVisibleTo(0)
never evaluated: widget->isEnabled()
never evaluated: widget->isVisibleTo(0)
0
5354 && (widget->focusPolicy() & Qt::TabFocus)
never evaluated: (widget->focusPolicy() & Qt::TabFocus)
0
5355 && (!item || !item->isPanel() || item->isAncestorOf(widget))
never evaluated: !item
never evaluated: !item->isPanel()
never evaluated: item->isAncestorOf(widget)
0
5356 ) { -
5357 setFocusItem(widget, next ? Qt::TabFocusReason : Qt::BacktabFocusReason);
never executed (the execution status of this line is deduced): setFocusItem(widget, next ? Qt::TabFocusReason : Qt::BacktabFocusReason);
-
5358 return true;
never executed: return true;
0
5359 } -
5360 widget = next ? widget->d_func()->focusNext : widget->d_func()->focusPrev;
never evaluated: next
0
5361 if ((next && widget == d->tabFocusFirst) || (!next && widget == d->tabFocusFirst->d_func()->focusPrev))
never evaluated: next
never evaluated: widget == d->tabFocusFirst
never evaluated: !next
never evaluated: widget == d->tabFocusFirst->d_func()->focusPrev
0
5362 return false;
never executed: return false;
0
5363 } while (widget != widgetThatHadFocus);
never executed: }
never evaluated: widget != widgetThatHadFocus
0
5364 -
5365 return false;
never executed: return false;
0
5366} -
5367 -
5368/*! -
5369 \fn QGraphicsScene::changed(const QList<QRectF> &region) -
5370 -
5371 This signal is emitted by QGraphicsScene when control reaches the -
5372 event loop, if the scene content changes. The \a region parameter -
5373 contains a list of scene rectangles that indicate the area that -
5374 has been changed. -
5375 -
5376 \sa QGraphicsView::updateScene() -
5377*/ -
5378 -
5379/*! -
5380 \fn QGraphicsScene::sceneRectChanged(const QRectF &rect) -
5381 -
5382 This signal is emitted by QGraphicsScene whenever the scene rect changes. -
5383 The \a rect parameter is the new scene rectangle. -
5384 -
5385 \sa QGraphicsView::updateSceneRect() -
5386*/ -
5387 -
5388/*! -
5389 \fn QGraphicsScene::selectionChanged() -
5390 \since 4.3 -
5391 -
5392 This signal is emitted by QGraphicsScene whenever the selection -
5393 changes. You can call selectedItems() to get the new list of selected -
5394 items. -
5395 -
5396 The selection changes whenever an item is selected or unselected, a -
5397 selection area is set, cleared or otherwise changed, if a preselected item -
5398 is added to the scene, or if a selected item is removed from the scene. -
5399 -
5400 QGraphicsScene emits this signal only once for group selection operations. -
5401 For example, if you set a selection area, select or unselect a -
5402 QGraphicsItemGroup, or if you add or remove from the scene a parent item -
5403 that contains several selected items, selectionChanged() is emitted only -
5404 once after the operation has completed (instead of once for each item). -
5405 -
5406 \sa setSelectionArea(), selectedItems(), QGraphicsItem::setSelected() -
5407*/ -
5408 -
5409/*! -
5410 \since 4.4 -
5411 -
5412 Returns the scene's style, or the same as QApplication::style() if the -
5413 scene has not been explicitly assigned a style. -
5414 -
5415 \sa setStyle() -
5416*/ -
5417QStyle *QGraphicsScene::style() const -
5418{ -
5419 Q_D(const QGraphicsScene);
executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
5420 // ### This function, and the use of styles in general, is non-reentrant. -
5421 return d->style ? d->style : QApplication::style();
executed: return d->style ? d->style : QApplication::style();
Execution Count:2392
2392
5422} -
5423 -
5424/*! -
5425 \since 4.4 -
5426 -
5427 Sets or replaces the style of the scene to \a style, and reparents the -
5428 style to this scene. Any previously assigned style is deleted. The scene's -
5429 style defaults to QApplication::style(), and serves as the default for all -
5430 QGraphicsWidget items in the scene. -
5431 -
5432 Changing the style, either directly by calling this function, or -
5433 indirectly by calling QApplication::setStyle(), will automatically update -
5434 the style for all widgets in the scene that do not have a style explicitly -
5435 assigned to them. -
5436 -
5437 If \a style is 0, QGraphicsScene will revert to QApplication::style(). -
5438 -
5439 \sa style() -
5440*/ -
5441void QGraphicsScene::setStyle(QStyle *style) -
5442{ -
5443 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
5444 // ### This function, and the use of styles in general, is non-reentrant. -
5445 if (style == d->style)
never evaluated: style == d->style
0
5446 return;
never executed: return;
0
5447 -
5448 // Delete the old style, -
5449 delete d->style;
never executed (the execution status of this line is deduced): delete d->style;
-
5450 if ((d->style = style))
never evaluated: (d->style = style)
0
5451 d->style->setParent(this);
never executed: d->style->setParent(this);
0
5452 -
5453 // Notify the scene. -
5454 QEvent event(QEvent::StyleChange);
never executed (the execution status of this line is deduced): QEvent event(QEvent::StyleChange);
-
5455 QApplication::sendEvent(this, &event);
never executed (the execution status of this line is deduced): QApplication::sendEvent(this, &event);
-
5456 -
5457 // Notify all widgets that don't have a style explicitly set. -
5458 foreach (QGraphicsItem *item, items()) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(items())> _container_(items()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
5459 if (item->isWidget()) {
never evaluated: item->isWidget()
0
5460 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
never executed (the execution status of this line is deduced): QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(item);
-
5461 if (!widget->testAttribute(Qt::WA_SetStyle))
never evaluated: !widget->testAttribute(Qt::WA_SetStyle)
0
5462 QApplication::sendEvent(widget, &event);
never executed: QApplication::sendEvent(widget, &event);
0
5463 }
never executed: }
0
5464 }
never executed: }
0
5465}
never executed: }
0
5466 -
5467/*! -
5468 \property QGraphicsScene::font -
5469 \since 4.4 -
5470 \brief the scene's default font -
5471 -
5472 This property provides the scene's font. The scene font defaults to, -
5473 and resolves all its entries from, QApplication::font. -
5474 -
5475 If the scene's font changes, either directly through setFont() or -
5476 indirectly when the application font changes, QGraphicsScene first -
5477 sends itself a \l{QEvent::FontChange}{FontChange} event, and it then -
5478 sends \l{QEvent::FontChange}{FontChange} events to all top-level -
5479 widget items in the scene. These items respond by resolving their own -
5480 fonts to the scene, and they then notify their children, who again -
5481 notify their children, and so on, until all widget items have updated -
5482 their fonts. -
5483 -
5484 Changing the scene font, (directly or indirectly through -
5485 QApplication::setFont(),) automatically schedules a redraw the entire -
5486 scene. -
5487 -
5488 \sa QWidget::font, QApplication::setFont(), palette, style() -
5489*/ -
5490QFont QGraphicsScene::font() const -
5491{ -
5492 Q_D(const QGraphicsScene);
executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
5493 return d->font;
executed: return d->font;
Execution Count:203
203
5494} -
5495void QGraphicsScene::setFont(const QFont &font) -
5496{ -
5497 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
5498 QFont naturalFont = QApplication::font();
never executed (the execution status of this line is deduced): QFont naturalFont = QApplication::font();
-
5499 naturalFont.resolve(0);
never executed (the execution status of this line is deduced): naturalFont.resolve(0);
-
5500 QFont resolvedFont = font.resolve(naturalFont);
never executed (the execution status of this line is deduced): QFont resolvedFont = font.resolve(naturalFont);
-
5501 d->setFont_helper(resolvedFont);
never executed (the execution status of this line is deduced): d->setFont_helper(resolvedFont);
-
5502}
never executed: }
0
5503 -
5504/*! -
5505 \property QGraphicsScene::palette -
5506 \since 4.4 -
5507 \brief the scene's default palette -
5508 -
5509 This property provides the scene's palette. The scene palette defaults to, -
5510 and resolves all its entries from, QApplication::palette. -
5511 -
5512 If the scene's palette changes, either directly through setPalette() or -
5513 indirectly when the application palette changes, QGraphicsScene first -
5514 sends itself a \l{QEvent::PaletteChange}{PaletteChange} event, and it then -
5515 sends \l{QEvent::PaletteChange}{PaletteChange} events to all top-level -
5516 widget items in the scene. These items respond by resolving their own -
5517 palettes to the scene, and they then notify their children, who again -
5518 notify their children, and so on, until all widget items have updated -
5519 their palettes. -
5520 -
5521 Changing the scene palette, (directly or indirectly through -
5522 QApplication::setPalette(),) automatically schedules a redraw the entire -
5523 scene. -
5524 -
5525 \sa QWidget::palette, QApplication::setPalette(), font, style() -
5526*/ -
5527QPalette QGraphicsScene::palette() const -
5528{ -
5529 Q_D(const QGraphicsScene);
executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
5530 return d->palette;
executed: return d->palette;
Execution Count:201
201
5531} -
5532void QGraphicsScene::setPalette(const QPalette &palette) -
5533{ -
5534 Q_D(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
5535 QPalette naturalPalette = QApplication::palette();
never executed (the execution status of this line is deduced): QPalette naturalPalette = QApplication::palette();
-
5536 naturalPalette.resolve(0);
never executed (the execution status of this line is deduced): naturalPalette.resolve(0);
-
5537 QPalette resolvedPalette = palette.resolve(naturalPalette);
never executed (the execution status of this line is deduced): QPalette resolvedPalette = palette.resolve(naturalPalette);
-
5538 d->setPalette_helper(resolvedPalette);
never executed (the execution status of this line is deduced): d->setPalette_helper(resolvedPalette);
-
5539}
never executed: }
0
5540 -
5541/*! -
5542 \since 4.6 -
5543 -
5544 Returns true if the scene is active (e.g., it's viewed by -
5545 at least one QGraphicsView that is active); otherwise returns false. -
5546 -
5547 \sa QGraphicsItem::isActive(), QWidget::isActiveWindow() -
5548*/ -
5549bool QGraphicsScene::isActive() const -
5550{ -
5551 Q_D(const QGraphicsScene);
executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
5552 return d->activationRefCount > 0;
executed: return d->activationRefCount > 0;
Execution Count:5739
5739
5553} -
5554 -
5555/*! -
5556 \since 4.6 -
5557 Returns the current active panel, or 0 if no panel is currently active. -
5558 -
5559 \sa QGraphicsScene::setActivePanel() -
5560*/ -
5561QGraphicsItem *QGraphicsScene::activePanel() const -
5562{ -
5563 Q_D(const QGraphicsScene);
executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
5564 return d->activePanel;
executed: return d->activePanel;
Execution Count:99
99
5565} -
5566 -
5567/*! -
5568 \since 4.6 -
5569 Activates \a item, which must be an item in this scene. You -
5570 can also pass 0 for \a item, in which case QGraphicsScene will -
5571 deactivate any currently active panel. -
5572 -
5573 If the scene is currently inactive, \a item remains inactive until the -
5574 scene becomes active (or, ir \a item is 0, no item will be activated). -
5575 -
5576 \sa activePanel(), isActive(), QGraphicsItem::isActive() -
5577*/ -
5578void QGraphicsScene::setActivePanel(QGraphicsItem *item) -
5579{ -
5580 Q_D(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
5581 d->setActivePanelHelper(item, false);
executed (the execution status of this line is deduced): d->setActivePanelHelper(item, false);
-
5582}
executed: }
Execution Count:5
5
5583 -
5584/*! -
5585 \since 4.4 -
5586 -
5587 Returns the current active window, or 0 if no window is currently -
5588 active. -
5589 -
5590 \sa QGraphicsScene::setActiveWindow() -
5591*/ -
5592QGraphicsWidget *QGraphicsScene::activeWindow() const -
5593{ -
5594 Q_D(const QGraphicsScene);
executed (the execution status of this line is deduced): const QGraphicsScenePrivate * const d = d_func();
-
5595 if (d->activePanel && d->activePanel->isWindow())
partially evaluated: d->activePanel
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
never evaluated: d->activePanel->isWindow()
0-2
5596 return static_cast<QGraphicsWidget *>(d->activePanel);
never executed: return static_cast<QGraphicsWidget *>(d->activePanel);
0
5597 return 0;
executed: return 0;
Execution Count:2
2
5598} -
5599 -
5600/*! -
5601 \since 4.4 -
5602 Activates \a widget, which must be a widget in this scene. You can also -
5603 pass 0 for \a widget, in which case QGraphicsScene will deactivate any -
5604 currently active window. -
5605 -
5606 \sa activeWindow(), QGraphicsWidget::isActiveWindow() -
5607*/ -
5608void QGraphicsScene::setActiveWindow(QGraphicsWidget *widget) -
5609{ -
5610 if (widget && widget->scene() != this) {
never evaluated: widget
never evaluated: widget->scene() != this
0
5611 qWarning("QGraphicsScene::setActiveWindow: widget %p must be part of this scene",
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsscene.cpp", 5611, __PRETTY_FUNCTION__).warning("QGraphicsScene::setActiveWindow: widget %p must be part of this scene",
-
5612 widget);
never executed (the execution status of this line is deduced): widget);
-
5613 return;
never executed: return;
0
5614 } -
5615 -
5616 // Activate the widget's panel (all windows are panels). -
5617 QGraphicsItem *panel = widget ? widget->panel() : 0;
never evaluated: widget
0
5618 setActivePanel(panel);
never executed (the execution status of this line is deduced): setActivePanel(panel);
-
5619 -
5620 // Raise -
5621 if (panel) {
never evaluated: panel
0
5622 QList<QGraphicsItem *> siblingWindows;
never executed (the execution status of this line is deduced): QList<QGraphicsItem *> siblingWindows;
-
5623 QGraphicsItem *parent = panel->parentItem();
never executed (the execution status of this line is deduced): QGraphicsItem *parent = panel->parentItem();
-
5624 // Raise ### inefficient for toplevels -
5625 foreach (QGraphicsItem *sibling, parent ? parent->childItems() : items()) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(parent ? parent->childItems() : items())> _container_(parent ? parent->childItems() : items()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *sibling = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
5626 if (sibling != panel && sibling->isWindow())
never evaluated: sibling != panel
never evaluated: sibling->isWindow()
0
5627 siblingWindows << sibling;
never executed: siblingWindows << sibling;
0
5628 }
never executed: }
0
5629 -
5630 // Find the highest z value. -
5631 qreal z = panel->zValue();
never executed (the execution status of this line is deduced): qreal z = panel->zValue();
-
5632 for (int i = 0; i < siblingWindows.size(); ++i)
never evaluated: i < siblingWindows.size()
0
5633 z = qMax(z, siblingWindows.at(i)->zValue());
never executed: z = qMax(z, siblingWindows.at(i)->zValue());
0
5634 -
5635 // This will probably never overflow. -
5636 const qreal litt = qreal(0.001);
never executed (the execution status of this line is deduced): const qreal litt = qreal(0.001);
-
5637 panel->setZValue(z + litt);
never executed (the execution status of this line is deduced): panel->setZValue(z + litt);
-
5638 }
never executed: }
0
5639}
never executed: }
0
5640 -
5641/*! -
5642 \since 4.6 -
5643 -
5644 Sends event \a event to item \a item through possible event filters. -
5645 -
5646 The event is sent only if the item is enabled. -
5647 -
5648 Returns \c false if the event was filtered or if the item is disabled. -
5649 Otherwise returns the value that was returned from the event handler. -
5650 -
5651 \sa QGraphicsItem::sceneEvent(), QGraphicsItem::sceneEventFilter() -
5652*/ -
5653bool QGraphicsScene::sendEvent(QGraphicsItem *item, QEvent *event) -
5654{ -
5655 Q_D(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScenePrivate * const d = d_func();
-
5656 if (!item) {
partially evaluated: !item
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:393
0-393
5657 qWarning("QGraphicsScene::sendEvent: cannot send event to a null item");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsscene.cpp", 5657, __PRETTY_FUNCTION__).warning("QGraphicsScene::sendEvent: cannot send event to a null item");
-
5658 return false;
never executed: return false;
0
5659 } -
5660 if (item->scene() != this) {
partially evaluated: item->scene() != this
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:393
0-393
5661 qWarning("QGraphicsScene::sendEvent: item %p's scene (%p)"
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsscene.cpp", 5661, __PRETTY_FUNCTION__).warning("QGraphicsScene::sendEvent: item %p's scene (%p)"
-
5662 " is different from this scene (%p)",
never executed (the execution status of this line is deduced): " is different from this scene (%p)",
-
5663 item, item->scene(), this);
never executed (the execution status of this line is deduced): item, item->scene(), this);
-
5664 return false;
never executed: return false;
0
5665 } -
5666 return d->sendEvent(item, event);
executed: return d->sendEvent(item, event);
Execution Count:393
393
5667} -
5668 -
5669void QGraphicsScenePrivate::addView(QGraphicsView *view) -
5670{ -
5671 views << view;
executed (the execution status of this line is deduced): views << view;
-
5672#ifndef QT_NO_GESTURES -
5673 foreach (Qt::GestureType gesture, grabbedGestures.keys())
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(grabbedGestures.keys())> _container_(grabbedGestures.keys()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (Qt::GestureType gesture = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
5674 view->viewport()->grabGesture(gesture);
never executed: view->viewport()->grabGesture(gesture);
0
5675#endif -
5676}
executed: }
Execution Count:213
213
5677 -
5678void QGraphicsScenePrivate::removeView(QGraphicsView *view) -
5679{ -
5680 views.removeAll(view);
executed (the execution status of this line is deduced): views.removeAll(view);
-
5681}
executed: }
Execution Count:4
4
5682 -
5683void QGraphicsScenePrivate::updateTouchPointsForItem(QGraphicsItem *item, QTouchEvent *touchEvent) -
5684{ -
5685 QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
never executed (the execution status of this line is deduced): QList<QTouchEvent::TouchPoint> touchPoints = touchEvent->touchPoints();
-
5686 for (int i = 0; i < touchPoints.count(); ++i) {
never evaluated: i < touchPoints.count()
0
5687 QTouchEvent::TouchPoint &touchPoint = touchPoints[i];
never executed (the execution status of this line is deduced): QTouchEvent::TouchPoint &touchPoint = touchPoints[i];
-
5688 touchPoint.setRect(item->mapFromScene(touchPoint.sceneRect()).boundingRect());
never executed (the execution status of this line is deduced): touchPoint.setRect(item->mapFromScene(touchPoint.sceneRect()).boundingRect());
-
5689 touchPoint.setStartPos(item->d_ptr->genericMapFromScene(touchPoint.startScenePos(), static_cast<QWidget *>(touchEvent->target())));
never executed (the execution status of this line is deduced): touchPoint.setStartPos(item->d_ptr->genericMapFromScene(touchPoint.startScenePos(), static_cast<QWidget *>(touchEvent->target())));
-
5690 touchPoint.setLastPos(item->d_ptr->genericMapFromScene(touchPoint.lastScenePos(), static_cast<QWidget *>(touchEvent->target())));
never executed (the execution status of this line is deduced): touchPoint.setLastPos(item->d_ptr->genericMapFromScene(touchPoint.lastScenePos(), static_cast<QWidget *>(touchEvent->target())));
-
5691 }
never executed: }
0
5692 touchEvent->setTouchPoints(touchPoints);
never executed (the execution status of this line is deduced): touchEvent->setTouchPoints(touchPoints);
-
5693}
never executed: }
0
5694 -
5695int QGraphicsScenePrivate::findClosestTouchPointId(const QPointF &scenePos) -
5696{ -
5697 int closestTouchPointId = -1;
never executed (the execution status of this line is deduced): int closestTouchPointId = -1;
-
5698 qreal closestDistance = qreal(0.);
never executed (the execution status of this line is deduced): qreal closestDistance = qreal(0.);
-
5699 foreach (const QTouchEvent::TouchPoint &touchPoint, sceneCurrentTouchPoints) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(sceneCurrentTouchPoints)> _container_(sceneCurrentTouchPoints); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QTouchEvent::TouchPoint &touchPoint = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
5700 qreal distance = QLineF(scenePos, touchPoint.scenePos()).length();
never executed (the execution status of this line is deduced): qreal distance = QLineF(scenePos, touchPoint.scenePos()).length();
-
5701 if (closestTouchPointId == -1|| distance < closestDistance) {
never evaluated: closestTouchPointId == -1
never evaluated: distance < closestDistance
0
5702 closestTouchPointId = touchPoint.id();
never executed (the execution status of this line is deduced): closestTouchPointId = touchPoint.id();
-
5703 closestDistance = distance;
never executed (the execution status of this line is deduced): closestDistance = distance;
-
5704 }
never executed: }
0
5705 }
never executed: }
0
5706 return closestTouchPointId;
never executed: return closestTouchPointId;
0
5707} -
5708 -
5709void QGraphicsScenePrivate::touchEventHandler(QTouchEvent *sceneTouchEvent) -
5710{ -
5711 typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints;
never executed (the execution status of this line is deduced): typedef QPair<Qt::TouchPointStates, QList<QTouchEvent::TouchPoint> > StatesAndTouchPoints;
-
5712 QHash<QGraphicsItem *, StatesAndTouchPoints> itemsNeedingEvents;
never executed (the execution status of this line is deduced): QHash<QGraphicsItem *, StatesAndTouchPoints> itemsNeedingEvents;
-
5713 -
5714 for (int i = 0; i < sceneTouchEvent->touchPoints().count(); ++i) {
never evaluated: i < sceneTouchEvent->touchPoints().count()
0
5715 const QTouchEvent::TouchPoint &touchPoint = sceneTouchEvent->touchPoints().at(i);
never executed (the execution status of this line is deduced): const QTouchEvent::TouchPoint &touchPoint = sceneTouchEvent->touchPoints().at(i);
-
5716 -
5717 // update state -
5718 QGraphicsItem *item = 0;
never executed (the execution status of this line is deduced): QGraphicsItem *item = 0;
-
5719 if (touchPoint.state() == Qt::TouchPointPressed) {
never evaluated: touchPoint.state() == Qt::TouchPointPressed
0
5720 if (sceneTouchEvent->device()->type() == QTouchDevice::TouchPad) {
never evaluated: sceneTouchEvent->device()->type() == QTouchDevice::TouchPad
0
5721 // on touch-pad devices, send all touch points to the same item -
5722 item = itemForTouchPointId.isEmpty()
never evaluated: itemForTouchPointId.isEmpty()
0
5723 ? 0
never executed (the execution status of this line is deduced): ? 0
-
5724 : itemForTouchPointId.constBegin().value();
never executed (the execution status of this line is deduced): : itemForTouchPointId.constBegin().value();
-
5725 }
never executed: }
0
5726 -
5727 if (!item) {
never evaluated: !item
0
5728 // determine which item this touch point will go to -
5729 cachedItemsUnderMouse = itemsAtPosition(touchPoint.screenPos().toPoint(),
never executed (the execution status of this line is deduced): cachedItemsUnderMouse = itemsAtPosition(touchPoint.screenPos().toPoint(),
-
5730 touchPoint.scenePos(),
never executed (the execution status of this line is deduced): touchPoint.scenePos(),
-
5731 static_cast<QWidget *>(sceneTouchEvent->target()));
never executed (the execution status of this line is deduced): static_cast<QWidget *>(sceneTouchEvent->target()));
-
5732 item = cachedItemsUnderMouse.isEmpty() ? 0 : cachedItemsUnderMouse.first();
never evaluated: cachedItemsUnderMouse.isEmpty()
0
5733 }
never executed: }
0
5734 -
5735 if (sceneTouchEvent->device()->type() == QTouchDevice::TouchScreen) {
never evaluated: sceneTouchEvent->device()->type() == QTouchDevice::TouchScreen
0
5736 // on touch-screens, combine this touch point with the closest one we find -
5737 int closestTouchPointId = findClosestTouchPointId(touchPoint.scenePos());
never executed (the execution status of this line is deduced): int closestTouchPointId = findClosestTouchPointId(touchPoint.scenePos());
-
5738 QGraphicsItem *closestItem = itemForTouchPointId.value(closestTouchPointId);
never executed (the execution status of this line is deduced): QGraphicsItem *closestItem = itemForTouchPointId.value(closestTouchPointId);
-
5739 if (!item || (closestItem && cachedItemsUnderMouse.contains(closestItem)))
never evaluated: !item
never evaluated: closestItem
never evaluated: cachedItemsUnderMouse.contains(closestItem)
0
5740 item = closestItem;
never executed: item = closestItem;
0
5741 }
never executed: }
0
5742 if (!item)
never evaluated: !item
0
5743 continue;
never executed: continue;
0
5744 -
5745 itemForTouchPointId.insert(touchPoint.id(), item);
never executed (the execution status of this line is deduced): itemForTouchPointId.insert(touchPoint.id(), item);
-
5746 sceneCurrentTouchPoints.insert(touchPoint.id(), touchPoint);
never executed (the execution status of this line is deduced): sceneCurrentTouchPoints.insert(touchPoint.id(), touchPoint);
-
5747 } else if (touchPoint.state() == Qt::TouchPointReleased) {
never executed: }
never evaluated: touchPoint.state() == Qt::TouchPointReleased
0
5748 item = itemForTouchPointId.take(touchPoint.id());
never executed (the execution status of this line is deduced): item = itemForTouchPointId.take(touchPoint.id());
-
5749 if (!item)
never evaluated: !item
0
5750 continue;
never executed: continue;
0
5751 -
5752 sceneCurrentTouchPoints.remove(touchPoint.id());
never executed (the execution status of this line is deduced): sceneCurrentTouchPoints.remove(touchPoint.id());
-
5753 } else {
never executed: }
0
5754 item = itemForTouchPointId.value(touchPoint.id());
never executed (the execution status of this line is deduced): item = itemForTouchPointId.value(touchPoint.id());
-
5755 if (!item)
never evaluated: !item
0
5756 continue;
never executed: continue;
0
5757 Q_ASSERT(sceneCurrentTouchPoints.contains(touchPoint.id()));
never executed (the execution status of this line is deduced): qt_noop();
-
5758 sceneCurrentTouchPoints[touchPoint.id()] = touchPoint;
never executed (the execution status of this line is deduced): sceneCurrentTouchPoints[touchPoint.id()] = touchPoint;
-
5759 }
never executed: }
0
5760 -
5761 StatesAndTouchPoints &statesAndTouchPoints = itemsNeedingEvents[item];
never executed (the execution status of this line is deduced): StatesAndTouchPoints &statesAndTouchPoints = itemsNeedingEvents[item];
-
5762 statesAndTouchPoints.first |= touchPoint.state();
never executed (the execution status of this line is deduced): statesAndTouchPoints.first |= touchPoint.state();
-
5763 statesAndTouchPoints.second.append(touchPoint);
never executed (the execution status of this line is deduced): statesAndTouchPoints.second.append(touchPoint);
-
5764 }
never executed: }
0
5765 -
5766 if (itemsNeedingEvents.isEmpty()) {
never evaluated: itemsNeedingEvents.isEmpty()
0
5767 sceneTouchEvent->accept();
never executed (the execution status of this line is deduced): sceneTouchEvent->accept();
-
5768 return;
never executed: return;
0
5769 } -
5770 -
5771 bool ignoreSceneTouchEvent = true;
never executed (the execution status of this line is deduced): bool ignoreSceneTouchEvent = true;
-
5772 QHash<QGraphicsItem *, StatesAndTouchPoints>::ConstIterator it = itemsNeedingEvents.constBegin();
never executed (the execution status of this line is deduced): QHash<QGraphicsItem *, StatesAndTouchPoints>::ConstIterator it = itemsNeedingEvents.constBegin();
-
5773 const QHash<QGraphicsItem *, StatesAndTouchPoints>::ConstIterator end = itemsNeedingEvents.constEnd();
never executed (the execution status of this line is deduced): const QHash<QGraphicsItem *, StatesAndTouchPoints>::ConstIterator end = itemsNeedingEvents.constEnd();
-
5774 for (; it != end; ++it) {
never evaluated: it != end
0
5775 QGraphicsItem *item = it.key();
never executed (the execution status of this line is deduced): QGraphicsItem *item = it.key();
-
5776 -
5777 (void) item->isBlockedByModalPanel(&item);
never executed (the execution status of this line is deduced): (void) item->isBlockedByModalPanel(&item);
-
5778 -
5779 // determine event type from the state mask -
5780 QEvent::Type eventType;
never executed (the execution status of this line is deduced): QEvent::Type eventType;
-
5781 switch (it.value().first) { -
5782 case Qt::TouchPointPressed: -
5783 // all touch points have pressed state -
5784 eventType = QEvent::TouchBegin;
never executed (the execution status of this line is deduced): eventType = QEvent::TouchBegin;
-
5785 break;
never executed: break;
0
5786 case Qt::TouchPointReleased: -
5787 // all touch points have released state -
5788 eventType = QEvent::TouchEnd;
never executed (the execution status of this line is deduced): eventType = QEvent::TouchEnd;
-
5789 break;
never executed: break;
0
5790 case Qt::TouchPointStationary: -
5791 // don't send the event if nothing changed -
5792 continue;
never executed: continue;
0
5793 default: -
5794 // all other combinations -
5795 eventType = QEvent::TouchUpdate;
never executed (the execution status of this line is deduced): eventType = QEvent::TouchUpdate;
-
5796 break;
never executed: break;
0
5797 } -
5798 -
5799 QTouchEvent touchEvent(eventType);
never executed (the execution status of this line is deduced): QTouchEvent touchEvent(eventType);
-
5800 touchEvent.setWindow(sceneTouchEvent->window());
never executed (the execution status of this line is deduced): touchEvent.setWindow(sceneTouchEvent->window());
-
5801 touchEvent.setTarget(sceneTouchEvent->target());
never executed (the execution status of this line is deduced): touchEvent.setTarget(sceneTouchEvent->target());
-
5802 touchEvent.setDevice(sceneTouchEvent->device());
never executed (the execution status of this line is deduced): touchEvent.setDevice(sceneTouchEvent->device());
-
5803 touchEvent.setModifiers(sceneTouchEvent->modifiers());
never executed (the execution status of this line is deduced): touchEvent.setModifiers(sceneTouchEvent->modifiers());
-
5804 touchEvent.setTouchPointStates(it.value().first);
never executed (the execution status of this line is deduced): touchEvent.setTouchPointStates(it.value().first);
-
5805 touchEvent.setTouchPoints(it.value().second);
never executed (the execution status of this line is deduced): touchEvent.setTouchPoints(it.value().second);
-
5806 touchEvent.setTimestamp(sceneTouchEvent->timestamp());
never executed (the execution status of this line is deduced): touchEvent.setTimestamp(sceneTouchEvent->timestamp());
-
5807 -
5808 switch (touchEvent.type()) { -
5809 case QEvent::TouchBegin: -
5810 { -
5811 // if the TouchBegin handler recurses, we assume that means the event -
5812 // has been implicitly accepted and continue to send touch events -
5813 item->d_ptr->acceptedTouchBeginEvent = true;
never executed (the execution status of this line is deduced): item->d_ptr->acceptedTouchBeginEvent = true;
-
5814 bool res = sendTouchBeginEvent(item, &touchEvent)
never evaluated: sendTouchBeginEvent(item, &touchEvent)
0
5815 && touchEvent.isAccepted();
never evaluated: touchEvent.isAccepted()
0
5816 if (!res) {
never evaluated: !res
0
5817 // forget about these touch points, we didn't handle them -
5818 for (int i = 0; i < touchEvent.touchPoints().count(); ++i) {
never evaluated: i < touchEvent.touchPoints().count()
0
5819 const QTouchEvent::TouchPoint &touchPoint = touchEvent.touchPoints().at(i);
never executed (the execution status of this line is deduced): const QTouchEvent::TouchPoint &touchPoint = touchEvent.touchPoints().at(i);
-
5820 itemForTouchPointId.remove(touchPoint.id());
never executed (the execution status of this line is deduced): itemForTouchPointId.remove(touchPoint.id());
-
5821 sceneCurrentTouchPoints.remove(touchPoint.id());
never executed (the execution status of this line is deduced): sceneCurrentTouchPoints.remove(touchPoint.id());
-
5822 }
never executed: }
0
5823 ignoreSceneTouchEvent = false;
never executed (the execution status of this line is deduced): ignoreSceneTouchEvent = false;
-
5824 }
never executed: }
0
5825 break;
never executed: break;
0
5826 } -
5827 default: -
5828 if (item->d_ptr->acceptedTouchBeginEvent) {
never evaluated: item->d_ptr->acceptedTouchBeginEvent
0
5829 updateTouchPointsForItem(item, &touchEvent);
never executed (the execution status of this line is deduced): updateTouchPointsForItem(item, &touchEvent);
-
5830 (void) sendEvent(item, &touchEvent);
never executed (the execution status of this line is deduced): (void) sendEvent(item, &touchEvent);
-
5831 ignoreSceneTouchEvent = false;
never executed (the execution status of this line is deduced): ignoreSceneTouchEvent = false;
-
5832 }
never executed: }
0
5833 break;
never executed: break;
0
5834 } -
5835 }
never executed: }
0
5836 sceneTouchEvent->setAccepted(ignoreSceneTouchEvent);
never executed (the execution status of this line is deduced): sceneTouchEvent->setAccepted(ignoreSceneTouchEvent);
-
5837}
never executed: }
0
5838 -
5839bool QGraphicsScenePrivate::sendTouchBeginEvent(QGraphicsItem *origin, QTouchEvent *touchEvent) -
5840{ -
5841 Q_Q(QGraphicsScene);
never executed (the execution status of this line is deduced): QGraphicsScene * const q = q_func();
-
5842 -
5843 if (cachedItemsUnderMouse.isEmpty() || cachedItemsUnderMouse.first() != origin) {
never evaluated: cachedItemsUnderMouse.isEmpty()
never evaluated: cachedItemsUnderMouse.first() != origin
0
5844 const QTouchEvent::TouchPoint &firstTouchPoint = touchEvent->touchPoints().first();
never executed (the execution status of this line is deduced): const QTouchEvent::TouchPoint &firstTouchPoint = touchEvent->touchPoints().first();
-
5845 cachedItemsUnderMouse = itemsAtPosition(firstTouchPoint.screenPos().toPoint(),
never executed (the execution status of this line is deduced): cachedItemsUnderMouse = itemsAtPosition(firstTouchPoint.screenPos().toPoint(),
-
5846 firstTouchPoint.scenePos(),
never executed (the execution status of this line is deduced): firstTouchPoint.scenePos(),
-
5847 static_cast<QWidget *>(touchEvent->target()));
never executed (the execution status of this line is deduced): static_cast<QWidget *>(touchEvent->target()));
-
5848 }
never executed: }
0
5849 -
5850 // Set focus on the topmost enabled item that can take focus. -
5851 bool setFocus = false;
never executed (the execution status of this line is deduced): bool setFocus = false;
-
5852 -
5853 foreach (QGraphicsItem *item, cachedItemsUnderMouse) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(cachedItemsUnderMouse)> _container_(cachedItemsUnderMouse); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
5854 if (item->isEnabled() && ((item->flags() & QGraphicsItem::ItemIsFocusable) && item->d_ptr->mouseSetsFocus)) {
never evaluated: item->isEnabled()
never evaluated: (item->flags() & QGraphicsItem::ItemIsFocusable)
never evaluated: item->d_ptr->mouseSetsFocus
0
5855 if (!item->isWidget() || ((QGraphicsWidget *)item)->focusPolicy() & Qt::ClickFocus) {
never evaluated: !item->isWidget()
never evaluated: ((QGraphicsWidget *)item)->focusPolicy() & Qt::ClickFocus
0
5856 setFocus = true;
never executed (the execution status of this line is deduced): setFocus = true;
-
5857 if (item != q->focusItem())
never evaluated: item != q->focusItem()
0
5858 q->setFocusItem(item, Qt::MouseFocusReason);
never executed: q->setFocusItem(item, Qt::MouseFocusReason);
0
5859 break;
never executed: break;
0
5860 } -
5861 }
never executed: }
0
5862 if (item->isPanel())
never evaluated: item->isPanel()
0
5863 break;
never executed: break;
0
5864 if (item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation)
never evaluated: item->d_ptr->flags & QGraphicsItem::ItemStopsClickFocusPropagation
0
5865 break;
never executed: break;
0
5866 if (item->d_ptr->flags & QGraphicsItem::ItemStopsFocusHandling) {
never evaluated: item->d_ptr->flags & QGraphicsItem::ItemStopsFocusHandling
0
5867 // Make sure we don't clear focus. -
5868 setFocus = true;
never executed (the execution status of this line is deduced): setFocus = true;
-
5869 break;
never executed: break;
0
5870 } -
5871 }
never executed: }
0
5872 -
5873 // If nobody could take focus, clear it. -
5874 if (!stickyFocus && !setFocus)
never evaluated: !stickyFocus
never evaluated: !setFocus
0
5875 q->setFocusItem(0, Qt::MouseFocusReason);
never executed: q->setFocusItem(0, Qt::MouseFocusReason);
0
5876 -
5877 bool res = false;
never executed (the execution status of this line is deduced): bool res = false;
-
5878 bool eventAccepted = touchEvent->isAccepted();
never executed (the execution status of this line is deduced): bool eventAccepted = touchEvent->isAccepted();
-
5879 foreach (QGraphicsItem *item, cachedItemsUnderMouse) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(cachedItemsUnderMouse)> _container_(cachedItemsUnderMouse); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
5880 // first, try to deliver the touch event -
5881 updateTouchPointsForItem(item, touchEvent);
never executed (the execution status of this line is deduced): updateTouchPointsForItem(item, touchEvent);
-
5882 bool acceptTouchEvents = item->acceptTouchEvents();
never executed (the execution status of this line is deduced): bool acceptTouchEvents = item->acceptTouchEvents();
-
5883 touchEvent->setAccepted(acceptTouchEvents);
never executed (the execution status of this line is deduced): touchEvent->setAccepted(acceptTouchEvents);
-
5884 res = acceptTouchEvents && sendEvent(item, touchEvent);
never evaluated: acceptTouchEvents
never evaluated: sendEvent(item, touchEvent)
0
5885 eventAccepted = touchEvent->isAccepted();
never executed (the execution status of this line is deduced): eventAccepted = touchEvent->isAccepted();
-
5886 if (itemForTouchPointId.value(touchEvent->touchPoints().first().id()) == 0) {
never evaluated: itemForTouchPointId.value(touchEvent->touchPoints().first().id()) == 0
0
5887 // item was deleted -
5888 item = 0;
never executed (the execution status of this line is deduced): item = 0;
-
5889 } else {
never executed: }
0
5890 item->d_ptr->acceptedTouchBeginEvent = (res && eventAccepted);
never evaluated: res
never evaluated: eventAccepted
0
5891 }
never executed: }
0
5892 touchEvent->spont = false;
never executed (the execution status of this line is deduced): touchEvent->spont = false;
-
5893 if (res && eventAccepted) {
never evaluated: res
never evaluated: eventAccepted
0
5894 // the first item to accept the TouchBegin gets an implicit grab. -
5895 for (int i = 0; i < touchEvent->touchPoints().count(); ++i) {
never evaluated: i < touchEvent->touchPoints().count()
0
5896 const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().at(i);
never executed (the execution status of this line is deduced): const QTouchEvent::TouchPoint &touchPoint = touchEvent->touchPoints().at(i);
-
5897 itemForTouchPointId[touchPoint.id()] = item; // can be zero
never executed (the execution status of this line is deduced): itemForTouchPointId[touchPoint.id()] = item;
-
5898 }
never executed: }
0
5899 break;
never executed: break;
0
5900 } -
5901 if (item && item->isPanel())
never evaluated: item
never evaluated: item->isPanel()
0
5902 break;
never executed: break;
0
5903 }
never executed: }
0
5904 -
5905 touchEvent->setAccepted(eventAccepted);
never executed (the execution status of this line is deduced): touchEvent->setAccepted(eventAccepted);
-
5906 return res;
never executed: return res;
0
5907} -
5908 -
5909void QGraphicsScenePrivate::enableTouchEventsOnViews() -
5910{ -
5911 foreach (QGraphicsView *view, views)
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(views)> _container_(views); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsView *view = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
5912 view->viewport()->setAttribute(Qt::WA_AcceptTouchEvents, true);
never executed: view->viewport()->setAttribute(Qt::WA_AcceptTouchEvents, true);
0
5913}
never executed: }
0
5914 -
5915void QGraphicsScenePrivate::updateInputMethodSensitivityInViews() -
5916{ -
5917 for (int i = 0; i < views.size(); ++i)
evaluated: i < views.size()
TRUEFALSE
yes
Evaluation Count:946
yes
Evaluation Count:1025
946-1025
5918 views.at(i)->d_func()->updateInputMethodSensitivity();
executed: views.at(i)->d_func()->updateInputMethodSensitivity();
Execution Count:946
946
5919}
executed: }
Execution Count:1025
1025
5920 -
5921void QGraphicsScenePrivate::enterModal(QGraphicsItem *panel, QGraphicsItem::PanelModality previousModality) -
5922{ -
5923 Q_Q(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScene * const q = q_func();
-
5924 Q_ASSERT(panel && panel->isPanel());
executed (the execution status of this line is deduced): qt_noop();
-
5925 -
5926 QGraphicsItem::PanelModality panelModality = panel->d_ptr->panelModality;
executed (the execution status of this line is deduced): QGraphicsItem::PanelModality panelModality = panel->d_ptr->panelModality;
-
5927 if (previousModality != QGraphicsItem::NonModal) {
evaluated: previousModality != QGraphicsItem::NonModal
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
5928 // the panel is changing from one modality type to another... temporarily set it back so -
5929 // that blockedPanels is populated correctly -
5930 panel->d_ptr->panelModality = previousModality;
executed (the execution status of this line is deduced): panel->d_ptr->panelModality = previousModality;
-
5931 }
executed: }
Execution Count:1
1
5932 -
5933 QSet<QGraphicsItem *> blockedPanels;
executed (the execution status of this line is deduced): QSet<QGraphicsItem *> blockedPanels;
-
5934 QList<QGraphicsItem *> items = q->items(); // ### store panels separately
executed (the execution status of this line is deduced): QList<QGraphicsItem *> items = q->items();
-
5935 for (int i = 0; i < items.count(); ++i) {
evaluated: i < items.count()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:3
3-10
5936 QGraphicsItem *item = items.at(i);
executed (the execution status of this line is deduced): QGraphicsItem *item = items.at(i);
-
5937 if (item->isPanel() && item->isBlockedByModalPanel())
evaluated: item->isPanel()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:7
partially evaluated: item->isBlockedByModalPanel()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-7
5938 blockedPanels.insert(item);
never executed: blockedPanels.insert(item);
0
5939 }
executed: }
Execution Count:10
10
5940 // blockedPanels contains all currently blocked panels -
5941 -
5942 if (previousModality != QGraphicsItem::NonModal) {
evaluated: previousModality != QGraphicsItem::NonModal
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
5943 // reset the modality to the proper value, since we changed it above -
5944 panel->d_ptr->panelModality = panelModality;
executed (the execution status of this line is deduced): panel->d_ptr->panelModality = panelModality;
-
5945 // remove this panel so that it will be reinserted at the front of the stack -
5946 modalPanels.removeAll(panel);
executed (the execution status of this line is deduced): modalPanels.removeAll(panel);
-
5947 }
executed: }
Execution Count:1
1
5948 -
5949 modalPanels.prepend(panel);
executed (the execution status of this line is deduced): modalPanels.prepend(panel);
-
5950 -
5951 if (!hoverItems.isEmpty()) {
partially evaluated: !hoverItems.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
5952 // send GraphicsSceneHoverLeave events to newly blocked hoverItems -
5953 QGraphicsSceneHoverEvent hoverEvent;
never executed (the execution status of this line is deduced): QGraphicsSceneHoverEvent hoverEvent;
-
5954 hoverEvent.setScenePos(lastSceneMousePos);
never executed (the execution status of this line is deduced): hoverEvent.setScenePos(lastSceneMousePos);
-
5955 dispatchHoverEvent(&hoverEvent);
never executed (the execution status of this line is deduced): dispatchHoverEvent(&hoverEvent);
-
5956 }
never executed: }
0
5957 -
5958 if (!mouseGrabberItems.isEmpty() && lastMouseGrabberItemHasImplicitMouseGrab) {
partially evaluated: !mouseGrabberItems.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
never evaluated: lastMouseGrabberItemHasImplicitMouseGrab
0-3
5959 QGraphicsItem *item = mouseGrabberItems.last();
never executed (the execution status of this line is deduced): QGraphicsItem *item = mouseGrabberItems.last();
-
5960 if (item->isBlockedByModalPanel())
never evaluated: item->isBlockedByModalPanel()
0
5961 ungrabMouse(item, /*itemIsDying =*/ false);
never executed: ungrabMouse(item, false);
0
5962 }
never executed: }
0
5963 -
5964 QEvent windowBlockedEvent(QEvent::WindowBlocked);
executed (the execution status of this line is deduced): QEvent windowBlockedEvent(QEvent::WindowBlocked);
-
5965 QEvent windowUnblockedEvent(QEvent::WindowUnblocked);
executed (the execution status of this line is deduced): QEvent windowUnblockedEvent(QEvent::WindowUnblocked);
-
5966 for (int i = 0; i < items.count(); ++i) {
evaluated: i < items.count()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:3
3-10
5967 QGraphicsItem *item = items.at(i);
executed (the execution status of this line is deduced): QGraphicsItem *item = items.at(i);
-
5968 if (item->isPanel()) {
evaluated: item->isPanel()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:7
3-7
5969 if (!blockedPanels.contains(item) && item->isBlockedByModalPanel()) {
partially evaluated: !blockedPanels.contains(item)
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
partially evaluated: item->isBlockedByModalPanel()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
5970 // send QEvent::WindowBlocked to newly blocked panels -
5971 sendEvent(item, &windowBlockedEvent);
never executed (the execution status of this line is deduced): sendEvent(item, &windowBlockedEvent);
-
5972 } else if (blockedPanels.contains(item) && !item->isBlockedByModalPanel()) {
never executed: }
partially evaluated: blockedPanels.contains(item)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
never evaluated: !item->isBlockedByModalPanel()
0-3
5973 // send QEvent::WindowUnblocked to unblocked panels when downgrading -
5974 // a panel from SceneModal to PanelModal -
5975 sendEvent(item, &windowUnblockedEvent);
never executed (the execution status of this line is deduced): sendEvent(item, &windowUnblockedEvent);
-
5976 }
never executed: }
0
5977 } -
5978 }
executed: }
Execution Count:10
10
5979}
executed: }
Execution Count:3
3
5980 -
5981void QGraphicsScenePrivate::leaveModal(QGraphicsItem *panel) -
5982{ -
5983 Q_Q(QGraphicsScene);
executed (the execution status of this line is deduced): QGraphicsScene * const q = q_func();
-
5984 Q_ASSERT(panel && panel->isPanel());
executed (the execution status of this line is deduced): qt_noop();
-
5985 -
5986 QSet<QGraphicsItem *> blockedPanels;
executed (the execution status of this line is deduced): QSet<QGraphicsItem *> blockedPanels;
-
5987 QList<QGraphicsItem *> items = q->items(); // ### same as above
executed (the execution status of this line is deduced): QList<QGraphicsItem *> items = q->items();
-
5988 for (int i = 0; i < items.count(); ++i) {
partially evaluated: i < items.count()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
5989 QGraphicsItem *item = items.at(i);
never executed (the execution status of this line is deduced): QGraphicsItem *item = items.at(i);
-
5990 if (item->isPanel() && item->isBlockedByModalPanel())
never evaluated: item->isPanel()
never evaluated: item->isBlockedByModalPanel()
0
5991 blockedPanels.insert(item);
never executed: blockedPanels.insert(item);
0
5992 }
never executed: }
0
5993 -
5994 modalPanels.removeAll(panel);
executed (the execution status of this line is deduced): modalPanels.removeAll(panel);
-
5995 -
5996 QEvent e(QEvent::WindowUnblocked);
executed (the execution status of this line is deduced): QEvent e(QEvent::WindowUnblocked);
-
5997 for (int i = 0; i < items.count(); ++i) {
partially evaluated: i < items.count()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
5998 QGraphicsItem *item = items.at(i);
never executed (the execution status of this line is deduced): QGraphicsItem *item = items.at(i);
-
5999 if (item->isPanel() && blockedPanels.contains(item) && !item->isBlockedByModalPanel())
never evaluated: item->isPanel()
never evaluated: blockedPanels.contains(item)
never evaluated: !item->isBlockedByModalPanel()
0
6000 sendEvent(item, &e);
never executed: sendEvent(item, &e);
0
6001 }
never executed: }
0
6002 -
6003 // send GraphicsSceneHoverEnter events to newly unblocked items -
6004 QGraphicsSceneHoverEvent hoverEvent;
executed (the execution status of this line is deduced): QGraphicsSceneHoverEvent hoverEvent;
-
6005 hoverEvent.setScenePos(lastSceneMousePos);
executed (the execution status of this line is deduced): hoverEvent.setScenePos(lastSceneMousePos);
-
6006 dispatchHoverEvent(&hoverEvent);
executed (the execution status of this line is deduced): dispatchHoverEvent(&hoverEvent);
-
6007}
executed: }
Execution Count:2
2
6008 -
6009#ifndef QT_NO_GESTURES -
6010void QGraphicsScenePrivate::gestureTargetsAtHotSpots(const QSet<QGesture *> &gestures, -
6011 Qt::GestureFlag flag, -
6012 QHash<QGraphicsObject *, QSet<QGesture *> > *targets, -
6013 QSet<QGraphicsObject *> *itemsSet, -
6014 QSet<QGesture *> *normal, -
6015 QSet<QGesture *> *conflicts) -
6016{ -
6017 QSet<QGesture *> normalGestures; // that are not in conflicted state.
executed (the execution status of this line is deduced): QSet<QGesture *> normalGestures;
-
6018 foreach (QGesture *gesture, gestures) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(gestures)> _container_(gestures); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGesture *gesture = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
6019 if (!gesture->hasHotSpot())
partially evaluated: !gesture->hasHotSpot()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:67
0-67
6020 continue;
never executed: continue;
0
6021 const Qt::GestureType gestureType = gesture->gestureType();
executed (the execution status of this line is deduced): const Qt::GestureType gestureType = gesture->gestureType();
-
6022 QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), gesture->d_func()->sceneHotSpot, 0);
executed (the execution status of this line is deduced): QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), gesture->d_func()->sceneHotSpot, 0);
-
6023 for (int j = 0; j < items.size(); ++j) {
evaluated: j < items.size()
TRUEFALSE
yes
Evaluation Count:142
yes
Evaluation Count:63
63-142
6024 QGraphicsItem *item = items.at(j);
executed (the execution status of this line is deduced): QGraphicsItem *item = items.at(j);
-
6025 -
6026 // Check if the item is blocked by a modal panel and use it as -
6027 // a target instead of this item. -
6028 (void) item->isBlockedByModalPanel(&item);
executed (the execution status of this line is deduced): (void) item->isBlockedByModalPanel(&item);
-
6029 -
6030 if (QGraphicsObject *itemobj = item->toGraphicsObject()) {
partially evaluated: QGraphicsObject *itemobj = item->toGraphicsObject()
TRUEFALSE
yes
Evaluation Count:142
no
Evaluation Count:0
0-142
6031 QGraphicsItemPrivate *d = item->QGraphicsItem::d_func();
executed (the execution status of this line is deduced): QGraphicsItemPrivate *d = item->QGraphicsItem::d_func();
-
6032 QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator it =
executed (the execution status of this line is deduced): QMap<Qt::GestureType, Qt::GestureFlags>::const_iterator it =
-
6033 d->gestureContext.constFind(gestureType);
executed (the execution status of this line is deduced): d->gestureContext.constFind(gestureType);
-
6034 if (it != d->gestureContext.constEnd() && (!flag || (it.value() & flag))) {
evaluated: it != d->gestureContext.constEnd()
TRUEFALSE
yes
Evaluation Count:117
yes
Evaluation Count:25
evaluated: !flag
TRUEFALSE
yes
Evaluation Count:67
yes
Evaluation Count:50
evaluated: (it.value() & flag)
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:42
8-117
6035 if (normalGestures.contains(gesture)) {
evaluated: normalGestures.contains(gesture)
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:49
26-49
6036 normalGestures.remove(gesture);
executed (the execution status of this line is deduced): normalGestures.remove(gesture);
-
6037 if (conflicts)
evaluated: conflicts
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:2
2-24
6038 conflicts->insert(gesture);
executed: conflicts->insert(gesture);
Execution Count:24
24
6039 } else {
executed: }
Execution Count:26
26
6040 normalGestures.insert(gesture);
executed (the execution status of this line is deduced): normalGestures.insert(gesture);
-
6041 }
executed: }
Execution Count:49
49
6042 if (targets)
partially evaluated: targets
TRUEFALSE
yes
Evaluation Count:75
no
Evaluation Count:0
0-75
6043 (*targets)[itemobj].insert(gesture);
executed: (*targets)[itemobj].insert(gesture);
Execution Count:75
75
6044 if (itemsSet)
evaluated: itemsSet
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:67
8-67
6045 (*itemsSet).insert(itemobj);
executed: (*itemsSet).insert(itemobj);
Execution Count:8
8
6046 }
executed: }
Execution Count:75
75
6047 }
executed: }
Execution Count:142
142
6048 // Don't propagate through panels. -
6049 if (item->isPanel())
evaluated: item->isPanel()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:138
4-138
6050 break;
executed: break;
Execution Count:4
4
6051 }
executed: }
Execution Count:138
138
6052 }
executed: }
Execution Count:67
67
6053 if (normal)
evaluated: normal
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:30
30-39
6054 *normal = normalGestures;
executed: *normal = normalGestures;
Execution Count:39
39
6055}
executed: }
Execution Count:69
69
6056 -
6057void QGraphicsScenePrivate::gestureEventHandler(QGestureEvent *event) -
6058{ -
6059 QWidget *viewport = event->widget();
executed (the execution status of this line is deduced): QWidget *viewport = event->widget();
-
6060 if (!viewport)
partially evaluated: !viewport
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:144
0-144
6061 return;
never executed: return;
0
6062 QGraphicsView *graphicsView = qobject_cast<QGraphicsView *>(viewport->parent());
executed (the execution status of this line is deduced): QGraphicsView *graphicsView = qobject_cast<QGraphicsView *>(viewport->parent());
-
6063 if (!graphicsView)
partially evaluated: !graphicsView
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:144
0-144
6064 return;
never executed: return;
0
6065 -
6066 QList<QGesture *> allGestures = event->gestures();
executed (the execution status of this line is deduced): QList<QGesture *> allGestures = event->gestures();
-
6067 DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 6067, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "Gestures:" << allGestures;
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:144
0-144
6068 << "Gestures:" << allGestures;
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 6067, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "Gestures:" << allGestures;
0
6069 -
6070 QSet<QGesture *> startedGestures;
executed (the execution status of this line is deduced): QSet<QGesture *> startedGestures;
-
6071 QPoint delta = viewport->mapFromGlobal(QPoint());
executed (the execution status of this line is deduced): QPoint delta = viewport->mapFromGlobal(QPoint());
-
6072 QTransform toScene = QTransform::fromTranslate(delta.x(), delta.y())
executed (the execution status of this line is deduced): QTransform toScene = QTransform::fromTranslate(delta.x(), delta.y())
-
6073 * graphicsView->viewportTransform().inverted();
executed (the execution status of this line is deduced): * graphicsView->viewportTransform().inverted();
-
6074 foreach (QGesture *gesture, allGestures) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(allGestures)> _container_(allGestures); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGesture *gesture = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
6075 // cache scene coordinates of the hot spot -
6076 if (gesture->hasHotSpot()) {
partially evaluated: gesture->hasHotSpot()
TRUEFALSE
yes
Evaluation Count:146
no
Evaluation Count:0
0-146
6077 gesture->d_func()->sceneHotSpot = toScene.map(gesture->hotSpot());
executed (the execution status of this line is deduced): gesture->d_func()->sceneHotSpot = toScene.map(gesture->hotSpot());
-
6078 } else {
executed: }
Execution Count:146
146
6079 gesture->d_func()->sceneHotSpot = QPointF();
never executed (the execution status of this line is deduced): gesture->d_func()->sceneHotSpot = QPointF();
-
6080 }
never executed: }
0
6081 -
6082 QGraphicsObject *target = gestureTargets.value(gesture, 0);
executed (the execution status of this line is deduced): QGraphicsObject *target = gestureTargets.value(gesture, 0);
-
6083 if (!target) {
evaluated: !target
TRUEFALSE
yes
Evaluation Count:44
yes
Evaluation Count:102
44-102
6084 // when we are not in started mode but don't have a target -
6085 // then the only one interested in gesture is the view/scene -
6086 if (gesture->state() == Qt::GestureStarted)
evaluated: gesture->state() == Qt::GestureStarted
TRUEFALSE
yes
Evaluation Count:40
yes
Evaluation Count:4
4-40
6087 startedGestures.insert(gesture);
executed: startedGestures.insert(gesture);
Execution Count:40
40
6088 }
executed: }
Execution Count:44
44
6089 }
executed: }
Execution Count:146
146
6090 -
6091 if (!startedGestures.isEmpty()) {
evaluated: !startedGestures.isEmpty()
TRUEFALSE
yes
Evaluation Count:39
yes
Evaluation Count:105
39-105
6092 QSet<QGesture *> normalGestures; // that have just one target
executed (the execution status of this line is deduced): QSet<QGesture *> normalGestures;
-
6093 QSet<QGesture *> conflictedGestures; // that have multiple possible targets
executed (the execution status of this line is deduced): QSet<QGesture *> conflictedGestures;
-
6094 gestureTargetsAtHotSpots(startedGestures, Qt::GestureFlag(0), &cachedItemGestures, 0,
executed (the execution status of this line is deduced): gestureTargetsAtHotSpots(startedGestures, Qt::GestureFlag(0), &cachedItemGestures, 0,
-
6095 &normalGestures, &conflictedGestures);
executed (the execution status of this line is deduced): &normalGestures, &conflictedGestures);
-
6096 cachedTargetItems = cachedItemGestures.keys();
executed (the execution status of this line is deduced): cachedTargetItems = cachedItemGestures.keys();
-
6097 std::sort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst);
executed (the execution status of this line is deduced): std::sort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst);
-
6098 DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 6098, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "Normal gestures:" << normalGestures << "Conflicting gestures:" << conflictedGestures;
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:39
0-39
6099 << "Normal gestures:" << normalGestures
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 6098, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "Normal gestures:" << normalGestures << "Conflicting gestures:" << conflictedGestures;
0
6100 << "Conflicting gestures:" << conflictedGestures;
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 6098, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "Normal gestures:" << normalGestures << "Conflicting gestures:" << conflictedGestures;
0
6101 -
6102 // deliver conflicted gestures as override events AND remember -
6103 // initial gesture targets -
6104 if (!conflictedGestures.isEmpty()) {
evaluated: !conflictedGestures.isEmpty()
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:17
17-22
6105 for (int i = 0; i < cachedTargetItems.size(); ++i) {
evaluated: i < cachedTargetItems.size()
TRUEFALSE
yes
Evaluation Count:48
yes
Evaluation Count:20
20-48
6106 QPointer<QGraphicsObject> item = cachedTargetItems.at(i);
executed (the execution status of this line is deduced): QPointer<QGraphicsObject> item = cachedTargetItems.at(i);
-
6107 -
6108 // get gestures to deliver to the current item -
6109 QSet<QGesture *> gestures = conflictedGestures & cachedItemGestures.value(item.data());
executed (the execution status of this line is deduced): QSet<QGesture *> gestures = conflictedGestures & cachedItemGestures.value(item.data());
-
6110 if (gestures.isEmpty())
partially evaluated: gestures.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:48
0-48
6111 continue;
never executed: continue;
0
6112 -
6113 DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 6113, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "delivering override to" << item.data() << gestures;
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:48
0-48
6114 << "delivering override to"
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 6113, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "delivering override to" << item.data() << gestures;
0
6115 << item.data() << gestures;
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 6113, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "delivering override to" << item.data() << gestures;
0
6116 // send gesture override -
6117 QGestureEvent ev(gestures.toList());
executed (the execution status of this line is deduced): QGestureEvent ev(gestures.toList());
-
6118 ev.t = QEvent::GestureOverride;
executed (the execution status of this line is deduced): ev.t = QEvent::GestureOverride;
-
6119 ev.setWidget(event->widget());
executed (the execution status of this line is deduced): ev.setWidget(event->widget());
-
6120 // mark event and individual gestures as ignored -
6121 ev.ignore();
executed (the execution status of this line is deduced): ev.ignore();
-
6122 foreach(QGesture *g, gestures)
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(gestures)> _container_(gestures); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGesture *g = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
6123 ev.setAccepted(g, false);
executed: ev.setAccepted(g, false);
Execution Count:48
48
6124 sendEvent(item.data(), &ev);
executed (the execution status of this line is deduced): sendEvent(item.data(), &ev);
-
6125 // mark all accepted gestures to deliver them as normal gesture events -
6126 foreach (QGesture *g, gestures) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(gestures)> _container_(gestures); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGesture *g = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
6127 if (ev.isAccepted() || ev.isAccepted(g)) {
evaluated: ev.isAccepted()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:46
partially evaluated: ev.isAccepted(g)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:46
0-46
6128 conflictedGestures.remove(g);
executed (the execution status of this line is deduced): conflictedGestures.remove(g);
-
6129 // mark the item as a gesture target -
6130 if (item) {
partially evaluated: item
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
6131 gestureTargets.insert(g, item.data());
executed (the execution status of this line is deduced): gestureTargets.insert(g, item.data());
-
6132 QHash<QGraphicsObject *, QSet<QGesture *> >::iterator it, e;
executed (the execution status of this line is deduced): QHash<QGraphicsObject *, QSet<QGesture *> >::iterator it, e;
-
6133 it = cachedItemGestures.begin();
executed (the execution status of this line is deduced): it = cachedItemGestures.begin();
-
6134 e = cachedItemGestures.end();
executed (the execution status of this line is deduced): e = cachedItemGestures.end();
-
6135 for(; it != e; ++it)
evaluated: it != e
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2
2-4
6136 it.value().remove(g);
executed: it.value().remove(g);
Execution Count:4
4
6137 cachedItemGestures[item.data()].insert(g);
executed (the execution status of this line is deduced): cachedItemGestures[item.data()].insert(g);
-
6138 }
executed: }
Execution Count:2
2
6139 DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 6139, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "override was accepted:" << g << item.data();
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
6140 << "override was accepted:"
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 6139, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "override was accepted:" << g << item.data();
0
6141 << g << item.data();
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 6139, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "override was accepted:" << g << item.data();
0
6142 }
executed: }
Execution Count:2
2
6143 // remember the first item that received the override event -
6144 // as it most likely become a target if no one else accepts -
6145 // the override event -
6146 if (!gestureTargets.contains(g) && item)
evaluated: !gestureTargets.contains(g)
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:27
partially evaluated: item
TRUEFALSE
yes
Evaluation Count:21
no
Evaluation Count:0
0-27
6147 gestureTargets.insert(g, item.data());
executed: gestureTargets.insert(g, item.data());
Execution Count:21
21
6148 -
6149 }
executed: }
Execution Count:48
48
6150 if (conflictedGestures.isEmpty())
evaluated: conflictedGestures.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:46
2-46
6151 break;
executed: break;
Execution Count:2
2
6152 }
executed: }
Execution Count:46
46
6153 }
executed: }
Execution Count:22
22
6154 // remember the initial target item for each gesture that was not in -
6155 // the conflicted state. -
6156 if (!normalGestures.isEmpty()) {
evaluated: !normalGestures.isEmpty()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:21
18-21
6157 for (int i = 0; i < cachedTargetItems.size() && !normalGestures.isEmpty(); ++i) {
evaluated: i < cachedTargetItems.size()
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:18
partially evaluated: !normalGestures.isEmpty()
TRUEFALSE
yes
Evaluation Count:21
no
Evaluation Count:0
0-21
6158 QGraphicsObject *item = cachedTargetItems.at(i);
executed (the execution status of this line is deduced): QGraphicsObject *item = cachedTargetItems.at(i);
-
6159 -
6160 // get gestures to deliver to the current item -
6161 foreach (QGesture *g, cachedItemGestures.value(item)) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(cachedItemGestures.value(item))> _container_(cachedItemGestures.value(item)); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGesture *g = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
6162 if (!gestureTargets.contains(g)) {
evaluated: !gestureTargets.contains(g)
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:3
3-18
6163 gestureTargets.insert(g, item);
executed (the execution status of this line is deduced): gestureTargets.insert(g, item);
-
6164 normalGestures.remove(g);
executed (the execution status of this line is deduced): normalGestures.remove(g);
-
6165 }
executed: }
Execution Count:18
18
6166 }
executed: }
Execution Count:21
21
6167 }
executed: }
Execution Count:21
21
6168 }
executed: }
Execution Count:18
18
6169 }
executed: }
Execution Count:39
39
6170 -
6171 -
6172 // deliver all gesture events -
6173 QSet<QGesture *> undeliveredGestures;
executed (the execution status of this line is deduced): QSet<QGesture *> undeliveredGestures;
-
6174 QSet<QGesture *> parentPropagatedGestures;
executed (the execution status of this line is deduced): QSet<QGesture *> parentPropagatedGestures;
-
6175 foreach (QGesture *gesture, allGestures) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(allGestures)> _container_(allGestures); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGesture *gesture = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
6176 if (QGraphicsObject *target = gestureTargets.value(gesture, 0)) {
evaluated: QGraphicsObject *target = gestureTargets.value(gesture, 0)
TRUEFALSE
yes
Evaluation Count:142
yes
Evaluation Count:4
4-142
6177 cachedItemGestures[target].insert(gesture);
executed (the execution status of this line is deduced): cachedItemGestures[target].insert(gesture);
-
6178 cachedTargetItems.append(target);
executed (the execution status of this line is deduced): cachedTargetItems.append(target);
-
6179 undeliveredGestures.insert(gesture);
executed (the execution status of this line is deduced): undeliveredGestures.insert(gesture);
-
6180 QGraphicsItemPrivate *d = target->QGraphicsItem::d_func();
executed (the execution status of this line is deduced): QGraphicsItemPrivate *d = target->QGraphicsItem::d_func();
-
6181 const Qt::GestureFlags flags = d->gestureContext.value(gesture->gestureType());
executed (the execution status of this line is deduced): const Qt::GestureFlags flags = d->gestureContext.value(gesture->gestureType());
-
6182 if (flags & Qt::IgnoredGesturesPropagateToParent)
evaluated: flags & Qt::IgnoredGesturesPropagateToParent
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:138
4-138
6183 parentPropagatedGestures.insert(gesture);
executed: parentPropagatedGestures.insert(gesture);
Execution Count:4
4
6184 } else {
executed: }
Execution Count:142
142
6185 DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 6185, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "no target for" << gesture << "at" << gesture->hotSpot() << gesture->d_func()->sceneHotSpot;
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
6186 << "no target for" << gesture << "at"
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 6185, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "no target for" << gesture << "at" << gesture->hotSpot() << gesture->d_func()->sceneHotSpot;
0
6187 << gesture->hotSpot() << gesture->d_func()->sceneHotSpot;
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 6185, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "no target for" << gesture << "at" << gesture->hotSpot() << gesture->d_func()->sceneHotSpot;
0
6188 }
executed: }
Execution Count:4
4
6189 } -
6190 std::sort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst);
executed (the execution status of this line is deduced): std::sort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst);
-
6191 for (int i = 0; i < cachedTargetItems.size(); ++i) {
evaluated: i < cachedTargetItems.size()
TRUEFALSE
yes
Evaluation Count:189
yes
Evaluation Count:32
32-189
6192 QPointer<QGraphicsObject> receiver = cachedTargetItems.at(i);
executed (the execution status of this line is deduced): QPointer<QGraphicsObject> receiver = cachedTargetItems.at(i);
-
6193 QSet<QGesture *> gestures =
executed (the execution status of this line is deduced): QSet<QGesture *> gestures =
-
6194 undeliveredGestures & cachedItemGestures.value(receiver.data());
executed (the execution status of this line is deduced): undeliveredGestures & cachedItemGestures.value(receiver.data());
-
6195 gestures -= cachedAlreadyDeliveredGestures.value(receiver.data());
executed (the execution status of this line is deduced): gestures -= cachedAlreadyDeliveredGestures.value(receiver.data());
-
6196 -
6197 if (gestures.isEmpty())
evaluated: gestures.isEmpty()
TRUEFALSE
yes
Evaluation Count:32
yes
Evaluation Count:157
32-157
6198 continue;
executed: continue;
Execution Count:32
32
6199 -
6200 cachedAlreadyDeliveredGestures[receiver.data()] += gestures;
executed (the execution status of this line is deduced): cachedAlreadyDeliveredGestures[receiver.data()] += gestures;
-
6201 const bool isPanel = receiver.data()->isPanel();
executed (the execution status of this line is deduced): const bool isPanel = receiver.data()->isPanel();
-
6202 -
6203 DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 6203, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "delivering to" << receiver.data() << gestures;
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:157
0-157
6204 << "delivering to"
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 6203, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "delivering to" << receiver.data() << gestures;
0
6205 << receiver.data() << gestures;
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 6203, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "delivering to" << receiver.data() << gestures;
0
6206 QGestureEvent ev(gestures.toList());
executed (the execution status of this line is deduced): QGestureEvent ev(gestures.toList());
-
6207 ev.setWidget(event->widget());
executed (the execution status of this line is deduced): ev.setWidget(event->widget());
-
6208 sendEvent(receiver.data(), &ev);
executed (the execution status of this line is deduced): sendEvent(receiver.data(), &ev);
-
6209 QSet<QGesture *> ignoredGestures;
executed (the execution status of this line is deduced): QSet<QGesture *> ignoredGestures;
-
6210 foreach (QGesture *g, gestures) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(gestures)> _container_(gestures); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGesture *g = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
6211 if (!ev.isAccepted() && !ev.isAccepted(g)) {
evaluated: !ev.isAccepted()
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:114
partially evaluated: !ev.isAccepted(g)
TRUEFALSE
yes
Evaluation Count:43
no
Evaluation Count:0
0-114
6212 // if the gesture was ignored by its target, we will update the -
6213 // targetItems list with a possible target items (items that -
6214 // want to receive partial gestures). -
6215 // ### wont' work if the target was destroyed in the event -
6216 // we will just stop delivering it. -
6217 if (receiver && receiver.data() == gestureTargets.value(g, 0))
evaluated: receiver
TRUEFALSE
yes
Evaluation Count:42
yes
Evaluation Count:1
evaluated: receiver.data() == gestureTargets.value(g, 0)
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:12
1-42
6218 ignoredGestures.insert(g);
executed: ignoredGestures.insert(g);
Execution Count:30
30
6219 } else {
executed: }
Execution Count:43
43
6220 if (receiver && g->state() == Qt::GestureStarted) {
evaluated: receiver
TRUEFALSE
yes
Evaluation Count:113
yes
Evaluation Count:1
evaluated: g->state() == Qt::GestureStarted
TRUEFALSE
yes
Evaluation Count:35
yes
Evaluation Count:78
1-113
6221 // someone accepted the propagated initial GestureStarted -
6222 // event, let it be the new target for all following events. -
6223 gestureTargets[g] = receiver.data();
executed (the execution status of this line is deduced): gestureTargets[g] = receiver.data();
-
6224 }
executed: }
Execution Count:35
35
6225 undeliveredGestures.remove(g);
executed (the execution status of this line is deduced): undeliveredGestures.remove(g);
-
6226 }
executed: }
Execution Count:114
114
6227 } -
6228 if (undeliveredGestures.isEmpty())
evaluated: undeliveredGestures.isEmpty()
TRUEFALSE
yes
Evaluation Count:112
yes
Evaluation Count:45
45-112
6229 break;
executed: break;
Execution Count:112
112
6230 -
6231 // ignoredGestures list is only filled when delivering to the gesture -
6232 // target item, so it is safe to assume item == target. -
6233 if (!ignoredGestures.isEmpty() && !isPanel) {
evaluated: !ignoredGestures.isEmpty()
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:15
partially evaluated: !isPanel
TRUEFALSE
yes
Evaluation Count:30
no
Evaluation Count:0
0-30
6234 // look for new potential targets for gestures that were ignored -
6235 // and should be propagated. -
6236 -
6237 QSet<QGraphicsObject *> targetsSet = cachedTargetItems.toSet();
executed (the execution status of this line is deduced): QSet<QGraphicsObject *> targetsSet = cachedTargetItems.toSet();
-
6238 -
6239 if (receiver) {
partially evaluated: receiver
TRUEFALSE
yes
Evaluation Count:30
no
Evaluation Count:0
0-30
6240 // first if the gesture should be propagated to parents only -
6241 for (QSet<QGesture *>::iterator it = ignoredGestures.begin();
executed (the execution status of this line is deduced): for (QSet<QGesture *>::iterator it = ignoredGestures.begin();
-
6242 it != ignoredGestures.end();) {
evaluated: it != ignoredGestures.end()
TRUEFALSE
yes
Evaluation Count:30
yes
Evaluation Count:30
30
6243 if (parentPropagatedGestures.contains(*it)) {
evaluated: parentPropagatedGestures.contains(*it)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:27
3-27
6244 QGesture *gesture = *it;
executed (the execution status of this line is deduced): QGesture *gesture = *it;
-
6245 const Qt::GestureType gestureType = gesture->gestureType();
executed (the execution status of this line is deduced): const Qt::GestureType gestureType = gesture->gestureType();
-
6246 QGraphicsItem *item = receiver.data();
executed (the execution status of this line is deduced): QGraphicsItem *item = receiver.data();
-
6247 while (item) {
evaluated: item
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:3
3-9
6248 if (QGraphicsObject *obj = item->toGraphicsObject()) {
partially evaluated: QGraphicsObject *obj = item->toGraphicsObject()
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
6249 if (item->d_func()->gestureContext.contains(gestureType)) {
partially evaluated: item->d_func()->gestureContext.contains(gestureType)
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
0-9
6250 targetsSet.insert(obj);
executed (the execution status of this line is deduced): targetsSet.insert(obj);
-
6251 cachedItemGestures[obj].insert(gesture);
executed (the execution status of this line is deduced): cachedItemGestures[obj].insert(gesture);
-
6252 }
executed: }
Execution Count:9
9
6253 }
executed: }
Execution Count:9
9
6254 if (item->isPanel())
partially evaluated: item->isPanel()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
6255 break;
never executed: break;
0
6256 item = item->parentItem();
executed (the execution status of this line is deduced): item = item->parentItem();
-
6257 }
executed: }
Execution Count:9
9
6258 -
6259 it = ignoredGestures.erase(it);
executed (the execution status of this line is deduced): it = ignoredGestures.erase(it);
-
6260 continue;
executed: continue;
Execution Count:3
3
6261 } -
6262 ++it;
executed (the execution status of this line is deduced): ++it;
-
6263 }
executed: }
Execution Count:27
27
6264 }
executed: }
Execution Count:30
30
6265 -
6266 gestureTargetsAtHotSpots(ignoredGestures, Qt::ReceivePartialGestures,
executed (the execution status of this line is deduced): gestureTargetsAtHotSpots(ignoredGestures, Qt::ReceivePartialGestures,
-
6267 &cachedItemGestures, &targetsSet, 0, 0);
executed (the execution status of this line is deduced): &cachedItemGestures, &targetsSet, 0, 0);
-
6268 -
6269 cachedTargetItems = targetsSet.toList();
executed (the execution status of this line is deduced): cachedTargetItems = targetsSet.toList();
-
6270 std::sort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst);
executed (the execution status of this line is deduced): std::sort(cachedTargetItems.begin(), cachedTargetItems.end(), qt_closestItemFirst);
-
6271 DEBUG() << "QGraphicsScenePrivate::gestureEventHandler:"
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 6271, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "new targets:" << cachedTargetItems;
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:30
0-30
6272 << "new targets:" << cachedTargetItems;
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 6271, __PRETTY_FUNCTION__).debug() << "QGraphicsScenePrivate::gestureEventHandler:" << "new targets:" << cachedTargetItems;
0
6273 i = -1; // start delivery again
executed (the execution status of this line is deduced): i = -1;
-
6274 continue;
executed: continue;
Execution Count:30
30
6275 } -
6276 }
executed: }
Execution Count:15
15
6277 -
6278 foreach (QGesture *g, startedGestures) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(startedGestures)> _container_(startedGestures); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGesture *g = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
6279 if (g->gestureCancelPolicy() == QGesture::CancelAllInContext) {
evaluated: g->gestureCancelPolicy() == QGesture::CancelAllInContext
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:38
2-38
6280 DEBUG() << "lets try to cancel some";
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 6280, __PRETTY_FUNCTION__).debug() << "lets try to cancel some";
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
6281 // find gestures in context in Qt::GestureStarted or Qt::GestureUpdated state and cancel them -
6282 cancelGesturesForChildren(g);
executed (the execution status of this line is deduced): cancelGesturesForChildren(g);
-
6283 }
executed: }
Execution Count:2
2
6284 }
executed: }
Execution Count:40
40
6285 -
6286 // forget about targets for gestures that have ended -
6287 foreach (QGesture *g, allGestures) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(allGestures)> _container_(allGestures); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGesture *g = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
6288 switch (g->state()) { -
6289 case Qt::GestureFinished: -
6290 case Qt::GestureCanceled: -
6291 gestureTargets.remove(g);
executed (the execution status of this line is deduced): gestureTargets.remove(g);
-
6292 break;
executed: break;
Execution Count:38
38
6293 default: -
6294 break;
executed: break;
Execution Count:108
108
6295 } -
6296 }
executed: }
Execution Count:146
146
6297 -
6298 cachedTargetItems.clear();
executed (the execution status of this line is deduced): cachedTargetItems.clear();
-
6299 cachedItemGestures.clear();
executed (the execution status of this line is deduced): cachedItemGestures.clear();
-
6300 cachedAlreadyDeliveredGestures.clear();
executed (the execution status of this line is deduced): cachedAlreadyDeliveredGestures.clear();
-
6301}
executed: }
Execution Count:144
144
6302 -
6303void QGraphicsScenePrivate::cancelGesturesForChildren(QGesture *original) -
6304{ -
6305 Q_ASSERT(original);
executed (the execution status of this line is deduced): qt_noop();
-
6306 QGraphicsItem *originalItem = gestureTargets.value(original);
executed (the execution status of this line is deduced): QGraphicsItem *originalItem = gestureTargets.value(original);
-
6307 if (originalItem == 0) // we only act on accepted gestures, which implies it has a target.
partially evaluated: originalItem == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
6308 return;
never executed: return;
0
6309 -
6310 // iterate over all active gestures and for each find the owner -
6311 // if the owner is part of our sub-hierarchy, cancel it. -
6312 -
6313 QSet<QGesture *> canceledGestures;
executed (the execution status of this line is deduced): QSet<QGesture *> canceledGestures;
-
6314 QHash<QGesture *, QGraphicsObject *>::Iterator iter = gestureTargets.begin();
executed (the execution status of this line is deduced): QHash<QGesture *, QGraphicsObject *>::Iterator iter = gestureTargets.begin();
-
6315 while (iter != gestureTargets.end()) {
evaluated: iter != gestureTargets.end()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:2
2-4
6316 QGraphicsObject *item = iter.value();
executed (the execution status of this line is deduced): QGraphicsObject *item = iter.value();
-
6317 // note that we don't touch the gestures for our originalItem -
6318 if (item != originalItem && originalItem->isAncestorOf(item)) {
evaluated: item != originalItem
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
partially evaluated: originalItem->isAncestorOf(item)
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
6319 DEBUG() << " found a gesture to cancel" << iter.key();
never executed: QMessageLogger("graphicsview/qgraphicsscene.cpp", 6319, __PRETTY_FUNCTION__).debug() << " found a gesture to cancel" << iter.key();
partially evaluated: 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
6320 iter.key()->d_func()->state = Qt::GestureCanceled;
executed (the execution status of this line is deduced): iter.key()->d_func()->state = Qt::GestureCanceled;
-
6321 canceledGestures << iter.key();
executed (the execution status of this line is deduced): canceledGestures << iter.key();
-
6322 }
executed: }
Execution Count:2
2
6323 ++iter;
executed (the execution status of this line is deduced): ++iter;
-
6324 }
executed: }
Execution Count:4
4
6325 -
6326 // sort them per target item by cherry picking from almostCanceledGestures and delivering -
6327 QSet<QGesture *> almostCanceledGestures = canceledGestures;
executed (the execution status of this line is deduced): QSet<QGesture *> almostCanceledGestures = canceledGestures;
-
6328 QSet<QGesture *>::Iterator setIter;
executed (the execution status of this line is deduced): QSet<QGesture *>::Iterator setIter;
-
6329 while (!almostCanceledGestures.isEmpty()) {
evaluated: !almostCanceledGestures.isEmpty()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
6330 QGraphicsObject *target = 0;
executed (the execution status of this line is deduced): QGraphicsObject *target = 0;
-
6331 QSet<QGesture*> gestures;
executed (the execution status of this line is deduced): QSet<QGesture*> gestures;
-
6332 setIter = almostCanceledGestures.begin();
executed (the execution status of this line is deduced): setIter = almostCanceledGestures.begin();
-
6333 // sort per target item -
6334 while (setIter != almostCanceledGestures.end()) {
evaluated: setIter != almostCanceledGestures.end()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
6335 QGraphicsObject *item = gestureTargets.value(*setIter);
executed (the execution status of this line is deduced): QGraphicsObject *item = gestureTargets.value(*setIter);
-
6336 if (target == 0)
partially evaluated: target == 0
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
6337 target = item;
executed: target = item;
Execution Count:2
2
6338 if (target == item) {
partially evaluated: target == item
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
6339 gestures << *setIter;
executed (the execution status of this line is deduced): gestures << *setIter;
-
6340 setIter = almostCanceledGestures.erase(setIter);
executed (the execution status of this line is deduced): setIter = almostCanceledGestures.erase(setIter);
-
6341 } else {
executed: }
Execution Count:2
2
6342 ++setIter;
never executed (the execution status of this line is deduced): ++setIter;
-
6343 }
never executed: }
0
6344 } -
6345 Q_ASSERT(target);
executed (the execution status of this line is deduced): qt_noop();
-
6346 -
6347 QList<QGesture *> list = gestures.toList();
executed (the execution status of this line is deduced): QList<QGesture *> list = gestures.toList();
-
6348 QGestureEvent ev(list);
executed (the execution status of this line is deduced): QGestureEvent ev(list);
-
6349 sendEvent(target, &ev);
executed (the execution status of this line is deduced): sendEvent(target, &ev);
-
6350 -
6351 foreach (QGesture *g, list) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(list)> _container_(list); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGesture *g = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
6352 if (ev.isAccepted() || ev.isAccepted(g))
partially evaluated: ev.isAccepted()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
never evaluated: ev.isAccepted(g)
0-2
6353 gestures.remove(g);
executed: gestures.remove(g);
Execution Count:2
2
6354 }
executed: }
Execution Count:2
2
6355 -
6356 foreach (QGesture *g, gestures) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(gestures)> _container_(gestures); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGesture *g = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
6357 if (!g->hasHotSpot())
never evaluated: !g->hasHotSpot()
0
6358 continue;
never executed: continue;
0
6359 -
6360 QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), g->d_func()->sceneHotSpot, 0);
never executed (the execution status of this line is deduced): QList<QGraphicsItem *> items = itemsAtPosition(QPoint(), g->d_func()->sceneHotSpot, 0);
-
6361 for (int j = 0; j < items.size(); ++j) {
never evaluated: j < items.size()
0
6362 QGraphicsObject *item = items.at(j)->toGraphicsObject();
never executed (the execution status of this line is deduced): QGraphicsObject *item = items.at(j)->toGraphicsObject();
-
6363 if (!item)
never evaluated: !item
0
6364 continue;
never executed: continue;
0
6365 QGraphicsItemPrivate *d = item->QGraphicsItem::d_func();
never executed (the execution status of this line is deduced): QGraphicsItemPrivate *d = item->QGraphicsItem::d_func();
-
6366 if (d->gestureContext.contains(g->gestureType())) {
never evaluated: d->gestureContext.contains(g->gestureType())
0
6367 QList<QGesture *> list;
never executed (the execution status of this line is deduced): QList<QGesture *> list;
-
6368 list << g;
never executed (the execution status of this line is deduced): list << g;
-
6369 QGestureEvent ev(list);
never executed (the execution status of this line is deduced): QGestureEvent ev(list);
-
6370 sendEvent(item, &ev);
never executed (the execution status of this line is deduced): sendEvent(item, &ev);
-
6371 if (ev.isAccepted() || ev.isAccepted(g))
never evaluated: ev.isAccepted()
never evaluated: ev.isAccepted(g)
0
6372 break; // successfully delivered
never executed: break;
0
6373 }
never executed: }
0
6374 }
never executed: }
0
6375 }
never executed: }
0
6376 }
executed: }
Execution Count:2
2
6377 -
6378 QGestureManager *gestureManager = QApplicationPrivate::instance()->gestureManager;
executed (the execution status of this line is deduced): QGestureManager *gestureManager = QApplicationPrivate::instance()->gestureManager;
-
6379 Q_ASSERT(gestureManager); // it would be very odd if we got called without a manager.
executed (the execution status of this line is deduced): qt_noop();
-
6380 for (setIter = canceledGestures.begin(); setIter != canceledGestures.end(); ++setIter) {
evaluated: setIter != canceledGestures.end()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
6381 gestureManager->recycle(*setIter);
executed (the execution status of this line is deduced): gestureManager->recycle(*setIter);
-
6382 gestureTargets.remove(*setIter);
executed (the execution status of this line is deduced): gestureTargets.remove(*setIter);
-
6383 }
executed: }
Execution Count:2
2
6384}
executed: }
Execution Count:2
2
6385 -
6386void QGraphicsScenePrivate::grabGesture(QGraphicsItem *, Qt::GestureType gesture) -
6387{ -
6388 (void)QGestureManager::instance(); // create a gesture manager
executed (the execution status of this line is deduced): (void)QGestureManager::instance();
-
6389 if (!grabbedGestures[gesture]++) {
evaluated: !grabbedGestures[gesture]++
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:26
26
6390 foreach (QGraphicsView *view, views)
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(views)> _container_(views); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsView *view = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
6391 view->viewport()->grabGesture(gesture);
executed: view->viewport()->grabGesture(gesture);
Execution Count:26
26
6392 }
executed: }
Execution Count:26
26
6393}
executed: }
Execution Count:52
52
6394 -
6395void QGraphicsScenePrivate::ungrabGesture(QGraphicsItem *item, Qt::GestureType gesture) -
6396{ -
6397 // we know this can only be an object -
6398 Q_ASSERT(item->d_ptr->isObject);
executed (the execution status of this line is deduced): qt_noop();
-
6399 QGraphicsObject *obj = static_cast<QGraphicsObject *>(item);
executed (the execution status of this line is deduced): QGraphicsObject *obj = static_cast<QGraphicsObject *>(item);
-
6400 QGestureManager::instance()->cleanupCachedGestures(obj, gesture);
executed (the execution status of this line is deduced): QGestureManager::instance()->cleanupCachedGestures(obj, gesture);
-
6401 if (!--grabbedGestures[gesture]) {
evaluated: !--grabbedGestures[gesture]
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:26
24-26
6402 foreach (QGraphicsView *view, views)
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(views)> _container_(views); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsView *view = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
6403 view->viewport()->ungrabGesture(gesture);
executed: view->viewport()->ungrabGesture(gesture);
Execution Count:1
1
6404 }
executed: }
Execution Count:24
24
6405}
executed: }
Execution Count:50
50
6406#endif // QT_NO_GESTURES -
6407 -
6408QT_END_NAMESPACE -
6409 -
6410#include "moc_qgraphicsscene.cpp" -
6411 -
6412#endif // QT_NO_GRAPHICSVIEW -
6413 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial