graphicsview/qgraphicsitem.cpp

Source codeSwitch to Preprocessed file
LineSource CodeCoverage
1/**************************************************************************** -
2** -
3** Copyright (C) 2013 Digia Plc and/or its subsidiary(-ies). -
4** Contact: http://www.qt-project.org/legal -
5** -
6** This file is part of the QtGui module of the Qt Toolkit. -
7** -
8** $QT_BEGIN_LICENSE:LGPL$ -
9** Commercial License Usage -
10** Licensees holding valid commercial Qt licenses may use this file in -
11** accordance with the commercial license agreement provided with the -
12** Software or, alternatively, in accordance with the terms contained in -
13** a written agreement between you and Digia. For licensing terms and -
14** conditions see http://qt.digia.com/licensing. For further information -
15** use the contact form at http://qt.digia.com/contact-us. -
16** -
17** GNU Lesser General Public License Usage -
18** Alternatively, this file may be used under the terms of the GNU Lesser -
19** General Public License version 2.1 as published by the Free Software -
20** Foundation and appearing in the file LICENSE.LGPL included in the -
21** packaging of this file. Please review the following information to -
22** ensure the GNU Lesser General Public License version 2.1 requirements -
23** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. -
24** -
25** In addition, as a special exception, Digia gives you certain additional -
26** rights. These rights are described in the Digia Qt LGPL Exception -
27** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. -
28** -
29** GNU General Public License Usage -
30** Alternatively, this file may be used under the terms of the GNU -
31** General Public License version 3.0 as published by the Free Software -
32** Foundation and appearing in the file LICENSE.GPL included in the -
33** packaging of this file. Please review the following information to -
34** ensure the GNU General Public License version 3.0 requirements will be -
35** met: http://www.gnu.org/copyleft/gpl.html. -
36** -
37** -
38** $QT_END_LICENSE$ -
39** -
40****************************************************************************/ -
41 -
42/*! -
43 \class QGraphicsItem -
44 \brief The QGraphicsItem class is the base class for all graphical -
45 items in a QGraphicsScene. -
46 \since 4.2 -
47 -
48 \ingroup graphicsview-api -
49 \inmodule QtWidgets -
50 -
51 It provides a light-weight foundation for writing your own custom items. -
52 This includes defining the item's geometry, collision detection, its -
53 painting implementation and item interaction through its event handlers. -
54 QGraphicsItem is part of the \l{Graphics View Framework} -
55 -
56 \image graphicsview-items.png -
57 -
58 For convenience, Qt provides a set of standard graphics items for the most -
59 common shapes. These are: -
60 -
61 \list -
62 \li QGraphicsEllipseItem provides an ellipse item -
63 \li QGraphicsLineItem provides a line item -
64 \li QGraphicsPathItem provides an arbitrary path item -
65 \li QGraphicsPixmapItem provides a pixmap item -
66 \li QGraphicsPolygonItem provides a polygon item -
67 \li QGraphicsRectItem provides a rectangular item -
68 \li QGraphicsSimpleTextItem provides a simple text label item -
69 \li QGraphicsTextItem provides an advanced text browser item -
70 \endlist -
71 -
72 All of an item's geometric information is based on its local coordinate -
73 system. The item's position, pos(), is the only function that does not -
74 operate in local coordinates, as it returns a position in parent -
75 coordinates. \l {The Graphics View Coordinate System} describes the coordinate -
76 system in detail. -
77 -
78 You can set whether an item should be visible (i.e., drawn, and accepting -
79 events), by calling setVisible(). Hiding an item will also hide its -
80 children. Similarly, you can enable or disable an item by calling -
81 setEnabled(). If you disable an item, all its children will also be -
82 disabled. By default, items are both visible and enabled. To toggle -
83 whether an item is selected or not, first enable selection by setting -
84 the ItemIsSelectable flag, and then call setSelected(). Normally, -
85 selection is toggled by the scene, as a result of user interaction. -
86 -
87 To write your own graphics item, you first create a subclass of -
88 QGraphicsItem, and then start by implementing its two pure virtual public -
89 functions: boundingRect(), which returns an estimate of the area painted -
90 by the item, and paint(), which implements the actual painting. For -
91 example: -
92 -
93 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 0 -
94 -
95 The boundingRect() function has many different purposes. -
96 QGraphicsScene bases its item index on boundingRect(), and -
97 QGraphicsView uses it both for culling invisible items, and for -
98 determining the area that needs to be recomposed when drawing -
99 overlapping items. In addition, QGraphicsItem's collision -
100 detection mechanisms use boundingRect() to provide an efficient -
101 cut-off. The fine grained collision algorithm in -
102 collidesWithItem() is based on calling shape(), which returns an -
103 accurate outline of the item's shape as a QPainterPath. -
104 -
105 QGraphicsScene expects all items boundingRect() and shape() to -
106 remain unchanged unless it is notified. If you want to change an -
107 item's geometry in any way, you must first call -
108 prepareGeometryChange() to allow QGraphicsScene to update its -
109 bookkeeping. -
110 -
111 Collision detection can be done in two ways: -
112 -
113 \list 1 -
114 -
115 \li Reimplement shape() to return an accurate shape for your item, -
116 and rely on the default implementation of collidesWithItem() to do -
117 shape-shape intersection. This can be rather expensive if the -
118 shapes are complex. -
119 -
120 \li Reimplement collidesWithItem() to provide your own custom item -
121 and shape collision algorithm. -
122 -
123 \endlist -
124 -
125 The contains() function can be called to determine whether the item \e -
126 contains a point or not. This function can also be reimplemented by the -
127 item. The default behavior of contains() is based on calling shape(). -
128 -
129 Items can contain other items, and also be contained by other items. All -
130 items can have a parent item and a list of children. Unless the item has -
131 no parent, its position is in \e parent coordinates (i.e., the parent's -
132 local coordinates). Parent items propagate both their position and their -
133 transformation to all children. -
134 -
135 \image graphicsview-parentchild.png -
136 -
137 \target Transformations -
138 \section1 Transformations -
139 -
140 QGraphicsItem supports projective transformations in addition to its base -
141 position, pos(). There are several ways to change an item's transformation. -
142 For simple transformations, you can call either of the convenience -
143 functions setRotation() or setScale(), or you can pass any transformation -
144 matrix to setTransform(). For advanced transformation control you also have -
145 the option of setting several combined transformations by calling -
146 setTransformations(). -
147 -
148 Item transformations accumulate from parent to child, so if both a parent -
149 and child item are rotated 90 degrees, the child's total transformation -
150 will be 180 degrees. Similarly, if the item's parent is scaled to 2x its -
151 original size, its children will also be twice as large. An item's -
152 transformation does not affect its own local geometry; all geometry -
153 functions (e.g., contains(), update(), and all the mapping functions) still -
154 operate in local coordinates. For convenience, QGraphicsItem provides the -
155 functions sceneTransform(), which returns the item's total transformation -
156 matrix (including its position and all parents' positions and -
157 transformations), and scenePos(), which returns its position in scene -
158 coordinates. To reset an item's matrix, call resetTransform(). -
159 -
160 Certain transformation operations produce a different outcome depending on -
161 the order in which they are applied. For example, if you scale an -
162 transform, and then rotate it, you may get a different result than if the -
163 transform was rotated first. However, the order you set the transformation -
164 properties on QGraphicsItem does not affect the resulting transformation; -
165 QGraphicsItem always applies the properties in a fixed, defined order: -
166 -
167 \list -
168 \li The item's base transform is applied (transform()) -
169 \li The item's transformations list is applied in order (transformations()) -
170 \li The item is rotated relative to its transform origin point (rotation(), transformOriginPoint()) -
171 \li The item is scaled relative to its transform origin point (scale(), transformOriginPoint()) -
172 \endlist -
173 -
174 \section1 Painting -
175 -
176 The paint() function is called by QGraphicsView to paint the item's -
177 contents. The item has no background or default fill of its own; whatever -
178 is behind the item will shine through all areas that are not explicitly -
179 painted in this function. You can call update() to schedule a repaint, -
180 optionally passing the rectangle that needs a repaint. Depending on -
181 whether or not the item is visible in a view, the item may or may not be -
182 repainted; there is no equivalent to QWidget::repaint() in QGraphicsItem. -
183 -
184 Items are painted by the view, starting with the parent items and then -
185 drawing children, in ascending stacking order. You can set an item's -
186 stacking order by calling setZValue(), and test it by calling -
187 zValue(), where items with low z-values are painted before items with -
188 high z-values. Stacking order applies to sibling items; parents are always -
189 drawn before their children. -
190 -
191 \section1 Sorting -
192 -
193 All items are drawn in a defined, stable order, and this same order decides -
194 which items will receive mouse input first when you click on the scene. -
195 Normally you don't have to worry about sorting, as the items follow a -
196 "natural order", following the logical structure of the scene. -
197 -
198 An item's children are stacked on top of the parent, and sibling items are -
199 stacked by insertion order (i.e., in the same order that they were either -
200 added to the scene, or added to the same parent). If you add item A, and -
201 then B, then B will be on top of A. If you then add C, the items' stacking -
202 order will be A, then B, then C. -
203 -
204 \image graphicsview-zorder.png -
205 -
206 This example shows the stacking order of all limbs of the robot from the -
207 \l{graphicsview/dragdroprobot}{Drag and Drop Robot} example. The torso is -
208 the root item (all other items are children or descendants of the torso), -
209 so it is drawn first. Next, the head is drawn, as it is the first item in -
210 the torso's list of children. Then the upper left arm is drawn. As the -
211 lower arm is a child of the upper arm, the lower arm is then drawn, -
212 followed by the upper arm's next sibling, which is the upper right arm, and -
213 so on. -
214 -
215 For advanced users, there are ways to alter how your items are sorted: -
216 -
217 \list -
218 \li You can call setZValue() on an item to explicitly stack it on top of, or -
219 under, other sibling items. The default Z value for an item is 0. Items -
220 with the same Z value are stacked by insertion order. -
221 -
222 \li You can call stackBefore() to reorder the list of children. This will -
223 directly modify the insertion order. -
224 -
225 \li You can set the ItemStacksBehindParent flag to stack a child item behind -
226 its parent. -
227 \endlist -
228 -
229 The stacking order of two sibling items also counts for each item's -
230 children and descendant items. So if one item is on top of another, then -
231 all its children will also be on top of all the other item's children as -
232 well. -
233 -
234 \section1 Events -
235 -
236 QGraphicsItem receives events from QGraphicsScene through the virtual -
237 function sceneEvent(). This function distributes the most common events -
238 to a set of convenience event handlers: -
239 -
240 \list -
241 \li contextMenuEvent() handles context menu events -
242 \li focusInEvent() and focusOutEvent() handle focus in and out events -
243 \li hoverEnterEvent(), hoverMoveEvent(), and hoverLeaveEvent() handles -
244 hover enter, move and leave events -
245 \li inputMethodEvent() handles input events, for accessibility support -
246 \li keyPressEvent() and keyReleaseEvent() handle key press and release events -
247 \li mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(), and -
248 mouseDoubleClickEvent() handles mouse press, move, release, click and -
249 doubleclick events -
250 \endlist -
251 -
252 You can filter events for any other item by installing event filters. This -
253 functionality is separate from Qt's regular event filters (see -
254 QObject::installEventFilter()), which only work on subclasses of QObject. After -
255 installing your item as an event filter for another item by calling -
256 installSceneEventFilter(), the filtered events will be received by the virtual -
257 function sceneEventFilter(). You can remove item event filters by calling -
258 removeSceneEventFilter(). -
259 -
260 \section1 Custom Data -
261 -
262 Sometimes it's useful to register custom data with an item, be it a custom -
263 item, or a standard item. You can call setData() on any item to store data -
264 in it using a key-value pair (the key being an integer, and the value is a -
265 QVariant). To get custom data from an item, call data(). This -
266 functionality is completely untouched by Qt itself; it is provided for the -
267 user's convenience. -
268 -
269 \sa QGraphicsScene, QGraphicsView, {Graphics View Framework} -
270*/ -
271 -
272/*! -
273 \variable QGraphicsItem::Type -
274 -
275 The type value returned by the virtual type() function in standard -
276 graphics item classes in Qt. All such standard graphics item -
277 classes in Qt are associated with a unique value for Type, -
278 e.g. the value returned by QGraphicsPathItem::type() is 2. -
279 -
280 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 18 -
281*/ -
282 -
283/*! -
284 \variable QGraphicsItem::UserType -
285 -
286 The lowest permitted type value for custom items (subclasses -
287 of QGraphicsItem or any of the standard items). This value is -
288 used in conjunction with a reimplementation of QGraphicsItem::type() -
289 and declaring a Type enum value. Example: -
290 -
291 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 1 -
292 -
293 \note UserType = 65536 -
294*/ -
295 -
296/*! -
297 \enum QGraphicsItem::GraphicsItemFlag -
298 -
299 This enum describes different flags that you can set on an item to -
300 toggle different features in the item's behavior. -
301 -
302 All flags are disabled by default. -
303 -
304 \value ItemIsMovable The item supports interactive movement using -
305 the mouse. By clicking on the item and then dragging, the item -
306 will move together with the mouse cursor. If the item has -
307 children, all children are also moved. If the item is part of a -
308 selection, all selected items are also moved. This feature is -
309 provided as a convenience through the base implementation of -
310 QGraphicsItem's mouse event handlers. -
311 -
312 \value ItemIsSelectable The item supports selection. Enabling this -
313 feature will enable setSelected() to toggle selection for the -
314 item. It will also let the item be selected automatically as a -
315 result of calling QGraphicsScene::setSelectionArea(), by clicking -
316 on an item, or by using rubber band selection in QGraphicsView. -
317 -
318 \value ItemIsFocusable The item supports keyboard input focus (i.e., it is -
319 an input item). Enabling this flag will allow the item to accept focus, -
320 which again allows the delivery of key events to -
321 QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent(). -
322 -
323 \value ItemClipsToShape The item clips to its own shape. The item cannot -
324 draw or receive mouse, tablet, drag and drop or hover events outside its -
325 shape. It is disabled by default. This behavior is enforced by -
326 QGraphicsView::drawItems() or QGraphicsScene::drawItems(). This flag was -
327 introduced in Qt 4.3. -
328 -
329 \value ItemClipsChildrenToShape The item clips the painting of all its -
330 descendants to its own shape. Items that are either direct or indirect -
331 children of this item cannot draw outside this item's shape. By default, -
332 this flag is disabled; children can draw anywhere. This behavior is -
333 enforced by QGraphicsView::drawItems() or -
334 QGraphicsScene::drawItems(). This flag was introduced in Qt 4.3. -
335 -
336 \value ItemIgnoresTransformations The item ignores inherited -
337 transformations (i.e., its position is still anchored to its parent, but -
338 the parent or view rotation, zoom or shear transformations are ignored). -
339 This flag is useful for keeping text label items horizontal and unscaled, -
340 so they will still be readable if the view is transformed. When set, the -
341 item's view geometry and scene geometry will be maintained separately. You -
342 must call deviceTransform() to map coordinates and detect collisions in -
343 the view. By default, this flag is disabled. This flag was introduced in -
344 Qt 4.3. \note With this flag set you can still scale the item itself, and -
345 that scale transformation will influence the item's children. -
346 -
347 \value ItemIgnoresParentOpacity The item ignores its parent's opacity. The -
348 item's effective opacity is the same as its own; it does not combine with -
349 the parent's opacity. This flags allows your item to keep its absolute -
350 opacity even if the parent is semitransparent. This flag was introduced in -
351 Qt 4.5. -
352 -
353 \value ItemDoesntPropagateOpacityToChildren The item doesn't propagate its -
354 opacity to its children. This flag allows you to create a semitransparent -
355 item that does not affect the opacity of its children. This flag was -
356 introduced in Qt 4.5. -
357 -
358 \value ItemStacksBehindParent The item is stacked behind its parent. By -
359 default, child items are stacked on top of the parent item. But setting -
360 this flag, the child will be stacked behind it. This flag is useful for -
361 drop shadow effects and for decoration objects that follow the parent -
362 item's geometry without drawing on top of it. This flag was introduced -
363 in Qt 4.5. -
364 -
365 \value ItemUsesExtendedStyleOption The item makes use of either -
366 \l{QStyleOptionGraphicsItem::} {exposedRect} or -
367 \l{QStyleOptionGraphicsItem::} {matrix} in -
368 QStyleOptionGraphicsItem. By default, the -
369 \l{QStyleOptionGraphicsItem::} {exposedRect} is initialized to the -
370 item's boundingRect() and the -
371 \l{QStyleOptionGraphicsItem::}{matrix} is untransformed. You can -
372 enable this flag for the style options to be set up with more -
373 fine-grained values. Note that -
374 QStyleOptionGraphicsItem::levelOfDetail is unaffected by this flag -
375 and always initialized to 1. Use -
376 QStyleOptionGraphicsItem::levelOfDetailFromTransform() if you need -
377 a higher value. This flag was introduced in Qt 4.6. -
378 -
379 \value ItemHasNoContents The item does not paint anything (i.e., calling -
380 paint() on the item has no effect). You should set this flag on items that -
381 do not need to be painted to ensure that Graphics View avoids unnecessary -
382 painting preparations. This flag was introduced in Qt 4.6. -
383 -
384 \value ItemSendsGeometryChanges The item enables itemChange() -
385 notifications for ItemPositionChange, ItemPositionHasChanged, -
386 ItemMatrixChange, ItemTransformChange, ItemTransformHasChanged, -
387 ItemRotationChange, ItemRotationHasChanged, ItemScaleChange, ItemScaleHasChanged, -
388 ItemTransformOriginPointChange, and ItemTransformOriginPointHasChanged. For -
389 performance reasons, these notifications are disabled by default. You must -
390 enable this flag to receive notifications for position and transform -
391 changes. This flag was introduced in Qt 4.6. -
392 -
393 \value ItemAcceptsInputMethod The item supports input methods typically -
394 used for Asian languages. -
395 This flag was introduced in Qt 4.6. -
396 -
397 \value ItemNegativeZStacksBehindParent The item automatically -
398 stacks behind it's parent if it's z-value is negative. This flag -
399 enables setZValue() to toggle ItemStacksBehindParent. This flag -
400 was introduced in Qt 4.6. -
401 -
402 \value ItemIsPanel The item is a panel. A panel provides activation and -
403 contained focus handling. Only one panel can be active at a time (see -
404 QGraphicsItem::isActive()). When no panel is active, QGraphicsScene -
405 activates all non-panel items. Window items (i.e., -
406 QGraphicsItem::isWindow() returns true) are panels. This flag was -
407 introduced in Qt 4.6. -
408 -
409 \omitvalue ItemIsFocusScope \omit Internal only (for now). \endomit -
410 -
411 \value ItemSendsScenePositionChanges The item enables itemChange() -
412 notifications for ItemScenePositionHasChanged. For performance reasons, -
413 these notifications are disabled by default. You must enable this flag -
414 to receive notifications for scene position changes. This flag was -
415 introduced in Qt 4.6. -
416 -
417 \omitvalue ItemStopsClickFocusPropagation \omit The item stops propagating -
418 click focus to items underneath when being clicked on. This flag -
419 allows you create a non-focusable item that can be clicked on without -
420 changing the focus. \endomit -
421 -
422 \omitvalue ItemStopsFocusHandling \omit Same as -
423 ItemStopsClickFocusPropagation, but also suppresses focus-out. This flag -
424 allows you to completely take over focus handling. -
425 This flag was introduced in Qt 4.7. \endomit -
426*/ -
427 -
428/*! -
429 \enum QGraphicsItem::GraphicsItemChange -
430 -
431 This enum describes the state changes that are notified by -
432 QGraphicsItem::itemChange(). The notifications are sent as the state -
433 changes, and in some cases, adjustments can be made (see the documentation -
434 for each change for details). -
435 -
436 Note: Be careful with calling functions on the QGraphicsItem itself inside -
437 itemChange(), as certain function calls can lead to unwanted -
438 recursion. For example, you cannot call setPos() in itemChange() on an -
439 ItemPositionChange notification, as the setPos() function will again call -
440 itemChange(ItemPositionChange). Instead, you can return the new, adjusted -
441 position from itemChange(). -
442 -
443 \value ItemEnabledChange The item's enabled state changes. If the item is -
444 presently enabled, it will become disabled, and vice verca. The value -
445 argument is the new enabled state (i.e., true or false). Do not call -
446 setEnabled() in itemChange() as this notification is delivered. Instead, -
447 you can return the new state from itemChange(). -
448 -
449 \value ItemEnabledHasChanged The item's enabled state has changed. The -
450 value argument is the new enabled state (i.e., true or false). Do not call -
451 setEnabled() in itemChange() as this notification is delivered. The return -
452 value is ignored. -
453 -
454 \value ItemMatrixChange The item's affine transformation matrix is -
455 changing. This value is obsolete; you can use ItemTransformChange instead. -
456 -
457 \value ItemPositionChange The item's position changes. This notification -
458 is sent if the ItemSendsGeometryChanges flag is enabled, and when the -
459 item's local position changes, relative to its parent (i.e., as a result -
460 of calling setPos() or moveBy()). The value argument is the new position -
461 (i.e., a QPointF). You can call pos() to get the original position. Do -
462 not call setPos() or moveBy() in itemChange() as this notification is -
463 delivered; instead, you can return the new, adjusted position from -
464 itemChange(). After this notification, QGraphicsItem immediately sends the -
465 ItemPositionHasChanged notification if the position changed. -
466 -
467 \value ItemPositionHasChanged The item's position has changed. This -
468 notification is sent if the ItemSendsGeometryChanges flag is enabled, and -
469 after the item's local position, relative to its parent, has changed. The -
470 value argument is the new position (the same as pos()), and QGraphicsItem -
471 ignores the return value for this notification (i.e., a read-only -
472 notification). -
473 -
474 \value ItemTransformChange The item's transformation matrix changes. This -
475 notification is send if the ItemSendsGeometryChanges flag is enabled, and -
476 when the item's local transformation matrix changes (i.e., as a result of -
477 calling setTransform(). The value argument is the new matrix (i.e., a -
478 QTransform); to get the old matrix, call transform(). Do not call -
479 setTransform() or set any of the transformation properties in itemChange() -
480 as this notification is delivered; instead, you can return the new matrix -
481 from itemChange(). This notification is not sent if you change the -
482 transformation properties. -
483 -
484 \value ItemTransformHasChanged The item's transformation matrix has -
485 changed either because setTransform is called, or one of the -
486 transformation properties is changed. This notification is sent if the -
487 ItemSendsGeometryChanges flag is enabled, and after the item's local -
488 transformation matrix has changed. The value argument is the new matrix -
489 (same as transform()), and QGraphicsItem ignores the return value for this -
490 notification (i.e., a read-only notification). -
491 -
492 \value ItemRotationChange The item's rotation property changes. This -
493 notification is sent if the ItemSendsGeometryChanges flag is enabled, and -
494 when the item's rotation property changes (i.e., as a result of calling -
495 setRotation()). The value argument is the new rotation (i.e., a double); -
496 to get the old rotation, call rotation(). Do not call setRotation() in -
497 itemChange() as this notification is delivered; instead, you can return -
498 the new rotation from itemChange(). -
499 -
500 \value ItemRotationHasChanged The item's rotation property has changed. -
501 This notification is sent if the ItemSendsGeometryChanges flag is enabled, -
502 and after the item's rotation property has changed. The value argument is -
503 the new rotation (i.e., a double), and QGraphicsItem ignores the return -
504 value for this notification (i.e., a read-only notification). Do not call -
505 setRotation() in itemChange() as this notification is delivered. -
506 -
507 \value ItemScaleChange The item's scale property changes. This notification -
508 is sent if the ItemSendsGeometryChanges flag is enabled, and when the item's -
509 scale property changes (i.e., as a result of calling setScale()). The value -
510 argument is the new scale (i.e., a double); to get the old scale, call -
511 scale(). Do not call setScale() in itemChange() as this notification is -
512 delivered; instead, you can return the new scale from itemChange(). -
513 -
514 \value ItemScaleHasChanged The item's scale property has changed. This -
515 notification is sent if the ItemSendsGeometryChanges flag is enabled, and -
516 after the item's scale property has changed. The value argument is the new -
517 scale (i.e., a double), and QGraphicsItem ignores the return value for this -
518 notification (i.e., a read-only notification). Do not call setScale() in -
519 itemChange() as this notification is delivered. -
520 -
521 \value ItemTransformOriginPointChange The item's transform origin point -
522 property changes. This notification is sent if the ItemSendsGeometryChanges -
523 flag is enabled, and when the item's transform origin point property changes -
524 (i.e., as a result of calling setTransformOriginPoint()). The value argument -
525 is the new origin point (i.e., a QPointF); to get the old origin point, call -
526 transformOriginPoint(). Do not call setTransformOriginPoint() in itemChange() -
527 as this notification is delivered; instead, you can return the new transform -
528 origin point from itemChange(). -
529 -
530 \value ItemTransformOriginPointHasChanged The item's transform origin point -
531 property has changed. This notification is sent if the ItemSendsGeometryChanges -
532 flag is enabled, and after the item's transform origin point property has -
533 changed. The value argument is the new origin point (i.e., a QPointF), and -
534 QGraphicsItem ignores the return value for this notification (i.e., a read-only -
535 notification). Do not call setTransformOriginPoint() in itemChange() as this -
536 notification is delivered. -
537 -
538 \value ItemSelectedChange The item's selected state changes. If the item is -
539 presently selected, it will become unselected, and vice verca. The value -
540 argument is the new selected state (i.e., true or false). Do not call -
541 setSelected() in itemChange() as this notification is delivered; instead, you -
542 can return the new selected state from itemChange(). -
543 -
544 \value ItemSelectedHasChanged The item's selected state has changed. The -
545 value argument is the new selected state (i.e., true or false). Do not -
546 call setSelected() in itemChange() as this notification is delivered. The -
547 return value is ignored. -
548 -
549 \value ItemVisibleChange The item's visible state changes. If the item is -
550 presently visible, it will become invisible, and vice verca. The value -
551 argument is the new visible state (i.e., true or false). Do not call -
552 setVisible() in itemChange() as this notification is delivered; instead, -
553 you can return the new visible state from itemChange(). -
554 -
555 \value ItemVisibleHasChanged The item's visible state has changed. The -
556 value argument is the new visible state (i.e., true or false). Do not call -
557 setVisible() in itemChange() as this notification is delivered. The return -
558 value is ignored. -
559 -
560 \value ItemParentChange The item's parent changes. The value argument is -
561 the new parent item (i.e., a QGraphicsItem pointer). Do not call -
562 setParentItem() in itemChange() as this notification is delivered; -
563 instead, you can return the new parent from itemChange(). -
564 -
565 \value ItemParentHasChanged The item's parent has changed. The value -
566 argument is the new parent (i.e., a pointer to a QGraphicsItem). Do not -
567 call setParentItem() in itemChange() as this notification is -
568 delivered. The return value is ignored. -
569 -
570 \value ItemChildAddedChange A child is added to this item. The value -
571 argument is the new child item (i.e., a QGraphicsItem pointer). Do not -
572 pass this item to any item's setParentItem() function as this notification -
573 is delivered. The return value is unused; you cannot adjust anything in -
574 this notification. Note that the new child might not be fully constructed -
575 when this notification is sent; calling pure virtual functions on -
576 the child can lead to a crash. -
577 -
578 \value ItemChildRemovedChange A child is removed from this item. The value -
579 argument is the child item that is about to be removed (i.e., a -
580 QGraphicsItem pointer). The return value is unused; you cannot adjust -
581 anything in this notification. -
582 -
583 \value ItemSceneChange The item is moved to a new scene. This notification is -
584 also sent when the item is added to its initial scene, and when it is removed. -
585 The item's scene() is the old scene (or 0 if the item has not been added to a -
586 scene yet). The value argument is the new scene (i.e., a QGraphicsScene -
587 pointer), or a null pointer if the item is removed from a scene. Do not -
588 override this change by passing this item to QGraphicsScene::addItem() as this -
589 notification is delivered; instead, you can return the new scene from -
590 itemChange(). Use this feature with caution; objecting to a scene change can -
591 quickly lead to unwanted recursion. -
592 -
593 \value ItemSceneHasChanged The item's scene has changed. The item's scene() is -
594 the new scene. This notification is also sent when the item is added to its -
595 initial scene, and when it is removed.The value argument is the new scene -
596 (i.e., a pointer to a QGraphicsScene). Do not call setScene() in itemChange() -
597 as this notification is delivered. The return value is ignored. -
598 -
599 \value ItemCursorChange The item's cursor changes. The value argument is -
600 the new cursor (i.e., a QCursor). Do not call setCursor() in itemChange() -
601 as this notification is delivered. Instead, you can return a new cursor -
602 from itemChange(). -
603 -
604 \value ItemCursorHasChanged The item's cursor has changed. The value -
605 argument is the new cursor (i.e., a QCursor). Do not call setCursor() as -
606 this notification is delivered. The return value is ignored. -
607 -
608 \value ItemToolTipChange The item's tooltip changes. The value argument is -
609 the new tooltip (i.e., a QToolTip). Do not call setToolTip() in -
610 itemChange() as this notification is delivered. Instead, you can return a -
611 new tooltip from itemChange(). -
612 -
613 \value ItemToolTipHasChanged The item's tooltip has changed. The value -
614 argument is the new tooltip (i.e., a QToolTip). Do not call setToolTip() -
615 as this notification is delivered. The return value is ignored. -
616 -
617 \value ItemFlagsChange The item's flags change. The value argument is the -
618 new flags (i.e., a quint32). Do not call setFlags() in itemChange() as -
619 this notification is delivered. Instead, you can return the new flags from -
620 itemChange(). -
621 -
622 \value ItemFlagsHaveChanged The item's flags have changed. The value -
623 argument is the new flags (i.e., a quint32). Do not call setFlags() in -
624 itemChange() as this notification is delivered. The return value is -
625 ignored. -
626 -
627 \value ItemZValueChange The item's Z-value changes. The value argument is -
628 the new Z-value (i.e., a double). Do not call setZValue() in itemChange() -
629 as this notification is delivered. Instead, you can return a new Z-value -
630 from itemChange(). -
631 -
632 \value ItemZValueHasChanged The item's Z-value has changed. The value -
633 argument is the new Z-value (i.e., a double). Do not call setZValue() as -
634 this notification is delivered. The return value is ignored. -
635 -
636 \value ItemOpacityChange The item's opacity changes. The value argument is -
637 the new opacity (i.e., a double). Do not call setOpacity() in itemChange() -
638 as this notification is delivered. Instead, you can return a new opacity -
639 from itemChange(). -
640 -
641 \value ItemOpacityHasChanged The item's opacity has changed. The value -
642 argument is the new opacity (i.e., a double). Do not call setOpacity() as -
643 this notification is delivered. The return value is ignored. -
644 -
645 \value ItemScenePositionHasChanged The item's scene position has changed. -
646 This notification is sent if the ItemSendsScenePositionChanges flag is -
647 enabled, and after the item's scene position has changed (i.e., the -
648 position or transformation of the item itself or the position or -
649 transformation of any ancestor has changed). The value argument is the -
650 new scene position (the same as scenePos()), and QGraphicsItem ignores -
651 the return value for this notification (i.e., a read-only notification). -
652*/ -
653 -
654/*! -
655 \enum QGraphicsItem::CacheMode -
656 \since 4.4 -
657 -
658 This enum describes QGraphicsItem's cache modes. Caching is used to speed -
659 up rendering by allocating and rendering to an off-screen pixel buffer, -
660 which can be reused when the item requires redrawing. For some paint -
661 devices, the cache is stored directly in graphics memory, which makes -
662 rendering very quick. -
663 -
664 \value NoCache The default; all item caching is -
665 disabled. QGraphicsItem::paint() is called every time the item needs -
666 redrawing. -
667 -
668 \value ItemCoordinateCache Caching is enabled for the item's logical -
669 (local) coordinate system. QGraphicsItem creates an off-screen pixel -
670 buffer with a configurable size / resolution that you can pass to -
671 QGraphicsItem::setCacheMode(). Rendering quality will typically degrade, -
672 depending on the resolution of the cache and the item transformation. The -
673 first time the item is redrawn, it will render itself into the cache, and -
674 the cache is then reused for every subsequent expose. The cache is also -
675 reused as the item is transformed. To adjust the resolution of the cache, -
676 you can call setCacheMode() again. -
677 -
678 \value DeviceCoordinateCache Caching is enabled at the paint device level, -
679 in device coordinates. This mode is for items that can move, but are not -
680 rotated, scaled or sheared. If the item is transformed directly or -
681 indirectly, the cache will be regenerated automatically. Unlike -
682 ItemCoordinateCacheMode, DeviceCoordinateCache always renders at maximum -
683 quality. -
684 -
685 \sa QGraphicsItem::setCacheMode() -
686*/ -
687 -
688/*! -
689 \enum QGraphicsItem::Extension -
690 \internal -
691 -
692 Note: This is provided as a hook to avoid future problems related -
693 to adding virtual functions. See also extension(), -
694 supportsExtension() and setExtension(). -
695*/ -
696 -
697/*! -
698 \enum QGraphicsItem::PanelModality -
699 \since 4.6 -
700 -
701 This enum specifies the behavior of a modal panel. A modal panel -
702 is one that blocks input to other panels. Note that items that -
703 are children of a modal panel are not blocked. -
704 -
705 The values are: -
706 -
707 \value NonModal The panel is not modal and does not block input to -
708 other panels. This is the default value for panels. -
709 -
710 \value PanelModal The panel is modal to a single item hierarchy -
711 and blocks input to its parent pane, all grandparent panels, and -
712 all siblings of its parent and grandparent panels. -
713 -
714 \value SceneModal The window is modal to the entire scene and -
715 blocks input to all panels. -
716 -
717 \sa QGraphicsItem::setPanelModality(), QGraphicsItem::panelModality(), QGraphicsItem::ItemIsPanel -
718*/ -
719 -
720#include "qgraphicsitem.h" -
721 -
722#ifndef QT_NO_GRAPHICSVIEW -
723 -
724#include "qgraphicsscene.h" -
725#include "qgraphicsscene_p.h" -
726#include "qgraphicssceneevent.h" -
727#include "qgraphicsview.h" -
728#include "qgraphicswidget.h" -
729#include "qgraphicsproxywidget.h" -
730#include "qgraphicsscenebsptreeindex_p.h" -
731#include <QtCore/qbitarray.h> -
732#include <QtCore/qdebug.h> -
733#include <QtCore/qpoint.h> -
734#include <QtCore/qstack.h> -
735#include <QtCore/qtimer.h> -
736#include <QtCore/qvariant.h> -
737#include <QtCore/qvarlengtharray.h> -
738#include <QtCore/qnumeric.h> -
739#include <QtWidgets/qapplication.h> -
740#include <QtGui/qbitmap.h> -
741#include <QtGui/qpainter.h> -
742#include <QtGui/qpainterpath.h> -
743#include <QtGui/qpixmapcache.h> -
744#include <QtWidgets/qstyleoption.h> -
745#include <QtGui/qevent.h> -
746#include <QtGui/qinputmethod.h> -
747#include <QtWidgets/qgraphicseffect.h> -
748 -
749#include <private/qgraphicsitem_p.h> -
750#include <private/qgraphicswidget_p.h> -
751#include <private/qwidgettextcontrol_p.h> -
752#include <private/qtextdocumentlayout_p.h> -
753#include <private/qtextengine_p.h> -
754#include <private/qwidget_p.h> -
755#include <private/qapplication_p.h> -
756#include <private/qgesturemanager_p.h> -
757 -
758#include <math.h> -
759 -
760QT_BEGIN_NAMESPACE -
761 -
762static inline void _q_adjustRect(QRect *rect) -
763{ -
764 Q_ASSERT(rect);
never executed (the execution status of this line is deduced): qt_noop();
-
765 if (!rect->width())
never evaluated: !rect->width()
0
766 rect->adjust(0, 0, 1, 0);
never executed: rect->adjust(0, 0, 1, 0);
0
767 if (!rect->height())
never evaluated: !rect->height()
0
768 rect->adjust(0, 0, 0, 1);
never executed: rect->adjust(0, 0, 0, 1);
0
769}
never executed: }
0
770 -
771/* -
772 ### Move this into QGraphicsItemPrivate -
773 */ -
774class QGraphicsItemCustomDataStore -
775{ -
776public: -
777 QHash<const QGraphicsItem *, QMap<int, QVariant> > data; -
778}; -
779Q_GLOBAL_STATIC(QGraphicsItemCustomDataStore, qt_dataStore)
never executed: delete x;
executed: return thisGlobalStatic.pointer.load();
Execution Count:1764
partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
evaluated: !thisGlobalStatic.pointer.load()
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:1752
partially evaluated: !thisGlobalStatic.destroyed
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-1764
780 -
781/*! -
782 \internal -
783 -
784 Returns a QPainterPath of \a path when stroked with the \a pen. -
785 Ignoring dash pattern. -
786*/ -
787static QPainterPath qt_graphicsItem_shapeFromPath(const QPainterPath &path, const QPen &pen) -
788{ -
789 // We unfortunately need this hack as QPainterPathStroker will set a width of 1.0 -
790 // if we pass a value of 0.0 to QPainterPathStroker::setWidth() -
791 const qreal penWidthZero = qreal(0.00000001);
executed (the execution status of this line is deduced): const qreal penWidthZero = qreal(0.00000001);
-
792 -
793 if (path == QPainterPath())
evaluated: path == QPainterPath()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:1889
5-1889
794 return path;
executed: return path;
Execution Count:5
5
795 QPainterPathStroker ps;
executed (the execution status of this line is deduced): QPainterPathStroker ps;
-
796 ps.setCapStyle(pen.capStyle());
executed (the execution status of this line is deduced): ps.setCapStyle(pen.capStyle());
-
797 if (pen.widthF() <= 0.0)
partially evaluated: pen.widthF() <= 0.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1889
0-1889
798 ps.setWidth(penWidthZero);
never executed: ps.setWidth(penWidthZero);
0
799 else -
800 ps.setWidth(pen.widthF());
executed: ps.setWidth(pen.widthF());
Execution Count:1889
1889
801 ps.setJoinStyle(pen.joinStyle());
executed (the execution status of this line is deduced): ps.setJoinStyle(pen.joinStyle());
-
802 ps.setMiterLimit(pen.miterLimit());
executed (the execution status of this line is deduced): ps.setMiterLimit(pen.miterLimit());
-
803 QPainterPath p = ps.createStroke(path);
executed (the execution status of this line is deduced): QPainterPath p = ps.createStroke(path);
-
804 p.addPath(path);
executed (the execution status of this line is deduced): p.addPath(path);
-
805 return p;
executed: return p;
Execution Count:1889
1889
806} -
807 -
808/*! -
809 \internal -
810 -
811 Propagates the ancestor flag \a flag with value \a enabled to all this -
812 item's children. If \a root is false, the flag is also set on this item -
813 (default is true). -
814*/ -
815void QGraphicsItemPrivate::updateAncestorFlag(QGraphicsItem::GraphicsItemFlag childFlag, -
816 AncestorFlag flag, bool enabled, bool root) -
817{ -
818 Q_Q(QGraphicsItem);
executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func();
-
819 if (root) {
evaluated: root
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:9
9-17
820 // For root items only. This is the item that has either enabled or -
821 // disabled \a childFlag, or has been reparented. -
822 switch (int(childFlag)) { -
823 case -2: -
824 flag = AncestorFiltersChildEvents;
never executed (the execution status of this line is deduced): flag = AncestorFiltersChildEvents;
-
825 enabled = q->filtersChildEvents();
never executed (the execution status of this line is deduced): enabled = q->filtersChildEvents();
-
826 break;
never executed: break;
0
827 case -1: -
828 flag = AncestorHandlesChildEvents;
never executed (the execution status of this line is deduced): flag = AncestorHandlesChildEvents;
-
829 enabled = q->handlesChildEvents();
never executed (the execution status of this line is deduced): enabled = q->handlesChildEvents();
-
830 break;
never executed: break;
0
831 case QGraphicsItem::ItemClipsChildrenToShape: -
832 flag = AncestorClipsChildren;
executed (the execution status of this line is deduced): flag = AncestorClipsChildren;
-
833 enabled = flags & QGraphicsItem::ItemClipsChildrenToShape;
executed (the execution status of this line is deduced): enabled = flags & QGraphicsItem::ItemClipsChildrenToShape;
-
834 break;
executed: break;
Execution Count:13
13
835 case QGraphicsItem::ItemIgnoresTransformations: -
836 flag = AncestorIgnoresTransformations;
executed (the execution status of this line is deduced): flag = AncestorIgnoresTransformations;
-
837 enabled = flags & QGraphicsItem::ItemIgnoresTransformations;
executed (the execution status of this line is deduced): enabled = flags & QGraphicsItem::ItemIgnoresTransformations;
-
838 break;
executed: break;
Execution Count:4
4
839 default: -
840 return;
never executed: return;
0
841 } -
842 -
843 if (parent) {
evaluated: parent
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:10
7-10
844 // Inherit the enabled-state from our parents. -
845 if ((parent->d_ptr->ancestorFlags & flag)
partially evaluated: (parent->d_ptr->ancestorFlags & flag)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:7
0-7
846 || (int(parent->d_ptr->flags & childFlag) == childFlag)
evaluated: (int(parent->d_ptr->flags & childFlag) == childFlag)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:6
1-6
847 || (childFlag == -1 && parent->d_ptr->handlesChildEvents)
partially evaluated: childFlag == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
never evaluated: parent->d_ptr->handlesChildEvents
0-6
848 || (childFlag == -2 && parent->d_ptr->filtersDescendantEvents)) {
partially evaluated: childFlag == -2
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
never evaluated: parent->d_ptr->filtersDescendantEvents
0-6
849 enabled = true;
executed (the execution status of this line is deduced): enabled = true;
-
850 ancestorFlags |= flag;
executed (the execution status of this line is deduced): ancestorFlags |= flag;
-
851 } else {
executed: }
Execution Count:1
1
852 ancestorFlags &= ~flag;
executed (the execution status of this line is deduced): ancestorFlags &= ~flag;
-
853 }
executed: }
Execution Count:6
6
854 } else { -
855 // Top-level root items don't have any ancestors, so there are no -
856 // ancestor flags either. -
857 ancestorFlags = 0;
executed (the execution status of this line is deduced): ancestorFlags = 0;
-
858 }
executed: }
Execution Count:10
10
859 } else { -
860 // Don't set or propagate the ancestor flag if it's already correct. -
861 if (((ancestorFlags & flag) && enabled) || (!(ancestorFlags & flag) && !enabled))
evaluated: (ancestorFlags & flag)
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:6
partially evaluated: enabled
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
evaluated: !(ancestorFlags & flag)
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:3
partially evaluated: !enabled
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
862 return;
never executed: return;
0
863 -
864 // Set the flag. -
865 if (enabled)
evaluated: enabled
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:3
3-6
866 ancestorFlags |= flag;
executed: ancestorFlags |= flag;
Execution Count:6
6
867 else -
868 ancestorFlags &= ~flag;
executed: ancestorFlags &= ~flag;
Execution Count:3
3
869 -
870 // Don't process children if the item has the main flag set on itself. -
871 if ((childFlag != -1 && int(flags & childFlag) == childFlag)
partially evaluated: childFlag != -1
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
partially evaluated: int(flags & childFlag) == childFlag
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
872 || (int(childFlag) == -1 && handlesChildEvents)
partially evaluated: int(childFlag) == -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
never evaluated: handlesChildEvents
0-9
873 || (int(childFlag) == -2 && filtersDescendantEvents))
partially evaluated: int(childFlag) == -2
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
never evaluated: filtersDescendantEvents
0-9
874 return;
never executed: return;
0
875 }
executed: }
Execution Count:9
9
876 -
877 for (int i = 0; i < children.size(); ++i)
evaluated: i < children.size()
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:26
9-26
878 children.at(i)->d_ptr->updateAncestorFlag(childFlag, flag, enabled, false);
executed: children.at(i)->d_ptr->updateAncestorFlag(childFlag, flag, enabled, false);
Execution Count:9
9
879}
executed: }
Execution Count:26
26
880 -
881void QGraphicsItemPrivate::updateAncestorFlags() -
882{ -
883 int flags = 0;
executed (the execution status of this line is deduced): int flags = 0;
-
884 if (parent) {
evaluated: parent
TRUEFALSE
yes
Evaluation Count:804
yes
Evaluation Count:756
756-804
885 // Inherit the parent's ancestor flags. -
886 QGraphicsItemPrivate *pd = parent->d_ptr.data();
executed (the execution status of this line is deduced): QGraphicsItemPrivate *pd = parent->d_ptr.data();
-
887 flags = pd->ancestorFlags;
executed (the execution status of this line is deduced): flags = pd->ancestorFlags;
-
888 -
889 // Add in flags from the parent. -
890 if (pd->filtersDescendantEvents)
partially evaluated: pd->filtersDescendantEvents
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:804
0-804
891 flags |= AncestorFiltersChildEvents;
never executed: flags |= AncestorFiltersChildEvents;
0
892 if (pd->handlesChildEvents)
partially evaluated: pd->handlesChildEvents
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:804
0-804
893 flags |= AncestorHandlesChildEvents;
never executed: flags |= AncestorHandlesChildEvents;
0
894 if (pd->flags & QGraphicsItem::ItemClipsChildrenToShape)
evaluated: pd->flags & QGraphicsItem::ItemClipsChildrenToShape
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:799
5-799
895 flags |= AncestorClipsChildren;
executed: flags |= AncestorClipsChildren;
Execution Count:5
5
896 if (pd->flags & QGraphicsItem::ItemIgnoresTransformations)
partially evaluated: pd->flags & QGraphicsItem::ItemIgnoresTransformations
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:804
0-804
897 flags |= AncestorIgnoresTransformations;
never executed: flags |= AncestorIgnoresTransformations;
0
898 }
executed: }
Execution Count:804
804
899 -
900 if (ancestorFlags == flags)
evaluated: ancestorFlags == flags
TRUEFALSE
yes
Evaluation Count:1548
yes
Evaluation Count:12
12-1548
901 return; // No change; stop propagation.
executed: return;
Execution Count:1548
1548
902 ancestorFlags = flags;
executed (the execution status of this line is deduced): ancestorFlags = flags;
-
903 -
904 // Propagate to children recursively. -
905 for (int i = 0; i < children.size(); ++i)
partially evaluated: i < children.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
906 children.at(i)->d_ptr->updateAncestorFlags();
never executed: children.at(i)->d_ptr->updateAncestorFlags();
0
907}
executed: }
Execution Count:12
12
908 -
909/*! -
910 \internal -
911 -
912 Propagates item group membership. -
913*/ -
914void QGraphicsItemPrivate::setIsMemberOfGroup(bool enabled) -
915{ -
916 Q_Q(QGraphicsItem);
never executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func();
-
917 isMemberOfGroup = enabled;
never executed (the execution status of this line is deduced): isMemberOfGroup = enabled;
-
918 if (!qgraphicsitem_cast<QGraphicsItemGroup *>(q)) {
never evaluated: !qgraphicsitem_cast<QGraphicsItemGroup *>(q)
0
919 foreach (QGraphicsItem *child, children)
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(children)> _container_(children); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *child = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
920 child->d_func()->setIsMemberOfGroup(enabled);
never executed: child->d_func()->setIsMemberOfGroup(enabled);
0
921 }
never executed: }
0
922}
never executed: }
0
923 -
924/*! -
925 \internal -
926 -
927 Maps any item pos properties of \a event to \a item's coordinate system. -
928*/ -
929void QGraphicsItemPrivate::remapItemPos(QEvent *event, QGraphicsItem *item) -
930{ -
931 Q_Q(QGraphicsItem);
never executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func();
-
932 switch (event->type()) { -
933 case QEvent::GraphicsSceneMouseMove: -
934 case QEvent::GraphicsSceneMousePress: -
935 case QEvent::GraphicsSceneMouseRelease: -
936 case QEvent::GraphicsSceneMouseDoubleClick: { -
937 QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
never executed (the execution status of this line is deduced): QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);
-
938 mouseEvent->setPos(item->mapFromItem(q, mouseEvent->pos()));
never executed (the execution status of this line is deduced): mouseEvent->setPos(item->mapFromItem(q, mouseEvent->pos()));
-
939 mouseEvent->setLastPos(item->mapFromItem(q, mouseEvent->pos()));
never executed (the execution status of this line is deduced): mouseEvent->setLastPos(item->mapFromItem(q, mouseEvent->pos()));
-
940 for (int i = 0x1; i <= 0x10; i <<= 1) {
never evaluated: i <= 0x10
0
941 if (mouseEvent->buttons() & i) {
never evaluated: mouseEvent->buttons() & i
0
942 Qt::MouseButton button = Qt::MouseButton(i);
never executed (the execution status of this line is deduced): Qt::MouseButton button = Qt::MouseButton(i);
-
943 mouseEvent->setButtonDownPos(button, item->mapFromItem(q, mouseEvent->buttonDownPos(button)));
never executed (the execution status of this line is deduced): mouseEvent->setButtonDownPos(button, item->mapFromItem(q, mouseEvent->buttonDownPos(button)));
-
944 }
never executed: }
0
945 }
never executed: }
0
946 break;
never executed: break;
0
947 } -
948 case QEvent::GraphicsSceneWheel: { -
949 QGraphicsSceneWheelEvent *wheelEvent = static_cast<QGraphicsSceneWheelEvent *>(event);
never executed (the execution status of this line is deduced): QGraphicsSceneWheelEvent *wheelEvent = static_cast<QGraphicsSceneWheelEvent *>(event);
-
950 wheelEvent->setPos(item->mapFromItem(q, wheelEvent->pos()));
never executed (the execution status of this line is deduced): wheelEvent->setPos(item->mapFromItem(q, wheelEvent->pos()));
-
951 break;
never executed: break;
0
952 } -
953 case QEvent::GraphicsSceneContextMenu: { -
954 QGraphicsSceneContextMenuEvent *contextEvent = static_cast<QGraphicsSceneContextMenuEvent *>(event);
never executed (the execution status of this line is deduced): QGraphicsSceneContextMenuEvent *contextEvent = static_cast<QGraphicsSceneContextMenuEvent *>(event);
-
955 contextEvent->setPos(item->mapFromItem(q, contextEvent->pos()));
never executed (the execution status of this line is deduced): contextEvent->setPos(item->mapFromItem(q, contextEvent->pos()));
-
956 break;
never executed: break;
0
957 } -
958 case QEvent::GraphicsSceneHoverMove: { -
959 QGraphicsSceneHoverEvent *hoverEvent = static_cast<QGraphicsSceneHoverEvent *>(event);
never executed (the execution status of this line is deduced): QGraphicsSceneHoverEvent *hoverEvent = static_cast<QGraphicsSceneHoverEvent *>(event);
-
960 hoverEvent->setPos(item->mapFromItem(q, hoverEvent->pos()));
never executed (the execution status of this line is deduced): hoverEvent->setPos(item->mapFromItem(q, hoverEvent->pos()));
-
961 break;
never executed: break;
0
962 } -
963 default: -
964 break;
never executed: break;
0
965 } -
966}
never executed: }
0
967 -
968/*! -
969 \internal -
970 -
971 Maps the point \a pos from scene to item coordinates. If \a view is passed and the item -
972 is untransformable, this function will correctly map \a pos from the scene using the -
973 view's transformation. -
974*/ -
975QPointF QGraphicsItemPrivate::genericMapFromScene(const QPointF &pos, -
976 const QWidget *viewport) const -
977{ -
978 Q_Q(const QGraphicsItem);
executed (the execution status of this line is deduced): const QGraphicsItem * const q = q_func();
-
979 if (!itemIsUntransformable())
partially evaluated: !itemIsUntransformable()
TRUEFALSE
yes
Evaluation Count:1581
no
Evaluation Count:0
0-1581
980 return q->mapFromScene(pos);
executed: return q->mapFromScene(pos);
Execution Count:1581
1581
981 QGraphicsView *view = 0;
never executed (the execution status of this line is deduced): QGraphicsView *view = 0;
-
982 if (viewport)
never evaluated: viewport
0
983 view = qobject_cast<QGraphicsView *>(viewport->parentWidget());
never executed: view = qobject_cast<QGraphicsView *>(viewport->parentWidget());
0
984 if (!view)
never evaluated: !view
0
985 return q->mapFromScene(pos);
never executed: return q->mapFromScene(pos);
0
986 // ### More ping pong than needed. -
987 return q->deviceTransform(view->viewportTransform()).inverted().map(view->mapFromScene(pos));
never executed: return q->deviceTransform(view->viewportTransform()).inverted().map(view->mapFromScene(pos));
0
988} -
989 -
990/*! -
991 \internal -
992 -
993 Combines this item's position and transform onto \a transform. -
994 -
995 If you need to change this function (e.g., adding more transformation -
996 modes / options), make sure to change all places marked with COMBINE. -
997*/ -
998void QGraphicsItemPrivate::combineTransformToParent(QTransform *x, const QTransform *viewTransform) const -
999{ -
1000 // COMBINE -
1001 if (viewTransform && itemIsUntransformable()) {
never evaluated: viewTransform
never evaluated: itemIsUntransformable()
0
1002 *x = q_ptr->deviceTransform(*viewTransform);
never executed (the execution status of this line is deduced): *x = q_ptr->deviceTransform(*viewTransform);
-
1003 } else {
never executed: }
0
1004 if (transformData)
never evaluated: transformData
0
1005 *x *= transformData->computedFullTransform();
never executed: *x *= transformData->computedFullTransform();
0
1006 if (!pos.isNull())
never evaluated: !pos.isNull()
0
1007 *x *= QTransform::fromTranslate(pos.x(), pos.y());
never executed: *x *= QTransform::fromTranslate(pos.x(), pos.y());
0
1008 }
never executed: }
0
1009} -
1010 -
1011/*! -
1012 \internal -
1013 -
1014 Combines this item's position and transform onto \a transform. -
1015 -
1016 If you need to change this function (e.g., adding more transformation -
1017 modes / options), make sure to change QGraphicsItem::deviceTransform() as -
1018 well. -
1019*/ -
1020void QGraphicsItemPrivate::combineTransformFromParent(QTransform *x, const QTransform *viewTransform) const -
1021{ -
1022 // COMBINE -
1023 if (viewTransform && itemIsUntransformable()) {
partially evaluated: viewTransform
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
never evaluated: itemIsUntransformable()
0-20
1024 *x = q_ptr->deviceTransform(*viewTransform);
never executed (the execution status of this line is deduced): *x = q_ptr->deviceTransform(*viewTransform);
-
1025 } else {
never executed: }
0
1026 x->translate(pos.x(), pos.y());
executed (the execution status of this line is deduced): x->translate(pos.x(), pos.y());
-
1027 if (transformData)
partially evaluated: transformData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
1028 *x = transformData->computedFullTransform(x);
never executed: *x = transformData->computedFullTransform(x);
0
1029 }
executed: }
Execution Count:20
20
1030} -
1031 -
1032void QGraphicsItemPrivate::updateSceneTransformFromParent() -
1033{ -
1034 if (parent) {
evaluated: parent
TRUEFALSE
yes
Evaluation Count:142
yes
Evaluation Count:549
142-549
1035 Q_ASSERT(!parent->d_ptr->dirtySceneTransform);
executed (the execution status of this line is deduced): qt_noop();
-
1036 if (parent->d_ptr->sceneTransformTranslateOnly) {
partially evaluated: parent->d_ptr->sceneTransformTranslateOnly
TRUEFALSE
yes
Evaluation Count:142
no
Evaluation Count:0
0-142
1037 sceneTransform = QTransform::fromTranslate(parent->d_ptr->sceneTransform.dx() + pos.x(),
executed (the execution status of this line is deduced): sceneTransform = QTransform::fromTranslate(parent->d_ptr->sceneTransform.dx() + pos.x(),
-
1038 parent->d_ptr->sceneTransform.dy() + pos.y());
executed (the execution status of this line is deduced): parent->d_ptr->sceneTransform.dy() + pos.y());
-
1039 } else {
executed: }
Execution Count:142
142
1040 sceneTransform = parent->d_ptr->sceneTransform;
never executed (the execution status of this line is deduced): sceneTransform = parent->d_ptr->sceneTransform;
-
1041 sceneTransform.translate(pos.x(), pos.y());
never executed (the execution status of this line is deduced): sceneTransform.translate(pos.x(), pos.y());
-
1042 }
never executed: }
0
1043 if (transformData) {
partially evaluated: transformData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:142
0-142
1044 sceneTransform = transformData->computedFullTransform(&sceneTransform);
never executed (the execution status of this line is deduced): sceneTransform = transformData->computedFullTransform(&sceneTransform);
-
1045 sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);
never executed (the execution status of this line is deduced): sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);
-
1046 } else {
never executed: }
0
1047 sceneTransformTranslateOnly = parent->d_ptr->sceneTransformTranslateOnly;
executed (the execution status of this line is deduced): sceneTransformTranslateOnly = parent->d_ptr->sceneTransformTranslateOnly;
-
1048 }
executed: }
Execution Count:142
142
1049 } else if (!transformData) {
evaluated: !transformData
TRUEFALSE
yes
Evaluation Count:526
yes
Evaluation Count:23
23-526
1050 sceneTransform = QTransform::fromTranslate(pos.x(), pos.y());
executed (the execution status of this line is deduced): sceneTransform = QTransform::fromTranslate(pos.x(), pos.y());
-
1051 sceneTransformTranslateOnly = 1;
executed (the execution status of this line is deduced): sceneTransformTranslateOnly = 1;
-
1052 } else if (transformData->onlyTransform) {
executed: }
Execution Count:526
partially evaluated: transformData->onlyTransform
TRUEFALSE
yes
Evaluation Count:23
no
Evaluation Count:0
0-526
1053 sceneTransform = transformData->transform;
executed (the execution status of this line is deduced): sceneTransform = transformData->transform;
-
1054 if (!pos.isNull())
evaluated: !pos.isNull()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:19
4-19
1055 sceneTransform *= QTransform::fromTranslate(pos.x(), pos.y());
executed: sceneTransform *= QTransform::fromTranslate(pos.x(), pos.y());
Execution Count:4
4
1056 sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);
executed (the execution status of this line is deduced): sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);
-
1057 } else if (pos.isNull()) {
executed: }
Execution Count:23
never evaluated: pos.isNull()
0-23
1058 sceneTransform = transformData->computedFullTransform();
never executed (the execution status of this line is deduced): sceneTransform = transformData->computedFullTransform();
-
1059 sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);
never executed (the execution status of this line is deduced): sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);
-
1060 } else {
never executed: }
0
1061 sceneTransform = QTransform::fromTranslate(pos.x(), pos.y());
never executed (the execution status of this line is deduced): sceneTransform = QTransform::fromTranslate(pos.x(), pos.y());
-
1062 sceneTransform = transformData->computedFullTransform(&sceneTransform);
never executed (the execution status of this line is deduced): sceneTransform = transformData->computedFullTransform(&sceneTransform);
-
1063 sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);
never executed (the execution status of this line is deduced): sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);
-
1064 }
never executed: }
0
1065 dirtySceneTransform = 0;
executed (the execution status of this line is deduced): dirtySceneTransform = 0;
-
1066}
executed: }
Execution Count:691
691
1067 -
1068/*! -
1069 \internal -
1070 -
1071 Make sure not to trigger any pure virtual function calls (e.g., -
1072 prepareGeometryChange) if the item is in its destructor, i.e. -
1073 inDestructor is 1. -
1074*/ -
1075void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const QVariant *newParentVariant, -
1076 const QVariant *thisPointerVariant) -
1077{ -
1078 Q_Q(QGraphicsItem);
executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func();
-
1079 if (newParent == parent)
partially evaluated: newParent == parent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1560
0-1560
1080 return;
never executed: return;
0
1081 -
1082 if (isWidget)
evaluated: isWidget
TRUEFALSE
yes
Evaluation Count:1507
yes
Evaluation Count:53
53-1507
1083 static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent &&
executed: static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent && newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0, scene);
Execution Count:1507
1507
1084 newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0,
executed: static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent && newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0, scene);
Execution Count:1507
1507
1085 scene);
executed: static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent && newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0, scene);
Execution Count:1507
1507
1086 if (scene) {
evaluated: scene
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:1545
15-1545
1087 // Deliver the change to the index -
1088 if (scene->d_func()->indexMethod != QGraphicsScene::NoIndex)
partially evaluated: scene->d_func()->indexMethod != QGraphicsScene::NoIndex
TRUEFALSE
yes
Evaluation Count:15
no
Evaluation Count:0
0-15
1089 scene->d_func()->index->itemChange(q, QGraphicsItem::ItemParentChange, newParent);
executed: scene->d_func()->index->itemChange(q, QGraphicsItem::ItemParentChange, newParent);
Execution Count:15
15
1090 -
1091 // Disable scene pos notifications for old ancestors -
1092 if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges))
partially evaluated: scenePosDescendants
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
partially evaluated: (flags & QGraphicsItem::ItemSendsScenePositionChanges)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
1093 scene->d_func()->setScenePosItemEnabled(q, false);
never executed: scene->d_func()->setScenePosItemEnabled(q, false);
0
1094 }
executed: }
Execution Count:15
15
1095 -
1096 if (subFocusItem && parent) {
partially evaluated: subFocusItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1560
never evaluated: parent
0-1560
1097 // Make sure none of the old parents point to this guy. -
1098 subFocusItem->d_ptr->clearSubFocus(parent);
never executed (the execution status of this line is deduced): subFocusItem->d_ptr->clearSubFocus(parent);
-
1099 }
never executed: }
0
1100 -
1101 // We anticipate geometry changes. If the item is deleted, it will be -
1102 // removed from the index at a later stage, and the whole scene will be -
1103 // updated. -
1104 if (!inDestructor)
evaluated: !inDestructor
TRUEFALSE
yes
Evaluation Count:804
yes
Evaluation Count:756
756-804
1105 q_ptr->prepareGeometryChange();
executed: q_ptr->prepareGeometryChange();
Execution Count:804
804
1106 -
1107 if (parent) {
evaluated: parent
TRUEFALSE
yes
Evaluation Count:759
yes
Evaluation Count:801
759-801
1108 // Remove from current parent -
1109 parent->d_ptr->removeChild(q);
executed (the execution status of this line is deduced): parent->d_ptr->removeChild(q);
-
1110 if (thisPointerVariant)
partially evaluated: thisPointerVariant
TRUEFALSE
yes
Evaluation Count:759
no
Evaluation Count:0
0-759
1111 parent->itemChange(QGraphicsItem::ItemChildRemovedChange, *thisPointerVariant);
executed: parent->itemChange(QGraphicsItem::ItemChildRemovedChange, *thisPointerVariant);
Execution Count:759
759
1112 }
executed: }
Execution Count:759
759
1113 -
1114 // Update toplevelitem list. If this item is being deleted, its parent -
1115 // will be 0 but we don't want to register/unregister it in the TLI list. -
1116 if (scene && !inDestructor) {
evaluated: scene
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:1545
partially evaluated: !inDestructor
TRUEFALSE
yes
Evaluation Count:15
no
Evaluation Count:0
0-1545
1117 if (parent && !newParent) {
evaluated: parent
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:12
partially evaluated: !newParent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-12
1118 scene->d_func()->registerTopLevelItem(q);
never executed (the execution status of this line is deduced): scene->d_func()->registerTopLevelItem(q);
-
1119 } else if (!parent && newParent) {
never executed: }
evaluated: !parent
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:3
partially evaluated: newParent
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
1120 scene->d_func()->unregisterTopLevelItem(q);
executed (the execution status of this line is deduced): scene->d_func()->unregisterTopLevelItem(q);
-
1121 }
executed: }
Execution Count:12
12
1122 } -
1123 -
1124 // Ensure any last parent focus scope does not point to this item or any of -
1125 // its descendents. -
1126 QGraphicsItem *p = parent;
executed (the execution status of this line is deduced): QGraphicsItem *p = parent;
-
1127 QGraphicsItem *parentFocusScopeItem = 0;
executed (the execution status of this line is deduced): QGraphicsItem *parentFocusScopeItem = 0;
-
1128 while (p) {
evaluated: p
TRUEFALSE
yes
Evaluation Count:767
yes
Evaluation Count:1560
767-1560
1129 if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) {
partially evaluated: p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:767
0-767
1130 // If this item's focus scope's focus scope item points -
1131 // to this item or a descendent, then clear it. -
1132 QGraphicsItem *fsi = p->d_ptr->focusScopeItem;
never executed (the execution status of this line is deduced): QGraphicsItem *fsi = p->d_ptr->focusScopeItem;
-
1133 if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) {
never evaluated: q_ptr == fsi
never evaluated: q_ptr->isAncestorOf(fsi)
0
1134 parentFocusScopeItem = fsi;
never executed (the execution status of this line is deduced): parentFocusScopeItem = fsi;
-
1135 p->d_ptr->focusScopeItem = 0;
never executed (the execution status of this line is deduced): p->d_ptr->focusScopeItem = 0;
-
1136 fsi->d_ptr->focusScopeItemChange(false);
never executed (the execution status of this line is deduced): fsi->d_ptr->focusScopeItemChange(false);
-
1137 }
never executed: }
0
1138 break;
never executed: break;
0
1139 } -
1140 p = p->d_ptr->parent;
executed (the execution status of this line is deduced): p = p->d_ptr->parent;
-
1141 }
executed: }
Execution Count:767
767
1142 -
1143 // Update graphics effect optimization flag -
1144 if (newParent && (graphicsEffect || mayHaveChildWithGraphicsEffect))
evaluated: newParent
TRUEFALSE
yes
Evaluation Count:804
yes
Evaluation Count:756
partially evaluated: graphicsEffect
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:804
partially evaluated: mayHaveChildWithGraphicsEffect
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:804
0-804
1145 newParent->d_ptr->updateChildWithGraphicsEffectFlagRecursively();
never executed: newParent->d_ptr->updateChildWithGraphicsEffectFlagRecursively();
0
1146 -
1147 // Update focus scope item ptr in new scope. -
1148 QGraphicsItem *newFocusScopeItem = subFocusItem ? subFocusItem : parentFocusScopeItem;
partially evaluated: subFocusItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1560
0-1560
1149 if (newFocusScopeItem && newParent) {
partially evaluated: newFocusScopeItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1560
never evaluated: newParent
0-1560
1150 QGraphicsItem *p = newParent;
never executed (the execution status of this line is deduced): QGraphicsItem *p = newParent;
-
1151 while (p) {
never evaluated: p
0
1152 if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) {
never evaluated: p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope
0
1153 if (subFocusItem && subFocusItem != q_ptr) {
never evaluated: subFocusItem
never evaluated: subFocusItem != q_ptr
0
1154 // Find the subFocusItem's topmost focus scope within the new parent's focusscope -
1155 QGraphicsItem *ancestorScope = 0;
never executed (the execution status of this line is deduced): QGraphicsItem *ancestorScope = 0;
-
1156 QGraphicsItem *p2 = subFocusItem->d_ptr->parent;
never executed (the execution status of this line is deduced): QGraphicsItem *p2 = subFocusItem->d_ptr->parent;
-
1157 while (p2 && p2 != p) {
never evaluated: p2
never evaluated: p2 != p
0
1158 if (p2->d_ptr->flags & QGraphicsItem::ItemIsFocusScope)
never evaluated: p2->d_ptr->flags & QGraphicsItem::ItemIsFocusScope
0
1159 ancestorScope = p2;
never executed: ancestorScope = p2;
0
1160 if (p2->d_ptr->flags & QGraphicsItem::ItemIsPanel)
never evaluated: p2->d_ptr->flags & QGraphicsItem::ItemIsPanel
0
1161 break;
never executed: break;
0
1162 if (p2 == q_ptr)
never evaluated: p2 == q_ptr
0
1163 break;
never executed: break;
0
1164 p2 = p2->d_ptr->parent;
never executed (the execution status of this line is deduced): p2 = p2->d_ptr->parent;
-
1165 }
never executed: }
0
1166 if (ancestorScope)
never evaluated: ancestorScope
0
1167 newFocusScopeItem = ancestorScope;
never executed: newFocusScopeItem = ancestorScope;
0
1168 }
never executed: }
0
1169 -
1170 p->d_ptr->focusScopeItem = newFocusScopeItem;
never executed (the execution status of this line is deduced): p->d_ptr->focusScopeItem = newFocusScopeItem;
-
1171 newFocusScopeItem->d_ptr->focusScopeItemChange(true);
never executed (the execution status of this line is deduced): newFocusScopeItem->d_ptr->focusScopeItemChange(true);
-
1172 // Ensure the new item is no longer the subFocusItem. The -
1173 // only way to set focus on a child of a focus scope is -
1174 // by setting focus on the scope itself. -
1175 if (subFocusItem && !p->focusItem())
never evaluated: subFocusItem
never evaluated: !p->focusItem()
0
1176 subFocusItem->d_ptr->clearSubFocus();
never executed: subFocusItem->d_ptr->clearSubFocus();
0
1177 break;
never executed: break;
0
1178 } -
1179 p = p->d_ptr->parent;
never executed (the execution status of this line is deduced): p = p->d_ptr->parent;
-
1180 }
never executed: }
0
1181 }
never executed: }
0
1182 -
1183 // Resolve depth. -
1184 invalidateDepthRecursively();
executed (the execution status of this line is deduced): invalidateDepthRecursively();
-
1185 -
1186 if ((parent = newParent)) {
evaluated: (parent = newParent)
TRUEFALSE
yes
Evaluation Count:804
yes
Evaluation Count:756
756-804
1187 if (parent->d_func()->scene && parent->d_func()->scene != scene) {
evaluated: parent->d_func()->scene
TRUEFALSE
yes
Evaluation Count:730
yes
Evaluation Count:74
evaluated: parent->d_func()->scene != scene
TRUEFALSE
yes
Evaluation Count:722
yes
Evaluation Count:8
8-730
1188 // Move this item to its new parent's scene -
1189 parent->d_func()->scene->addItem(q);
executed (the execution status of this line is deduced): parent->d_func()->scene->addItem(q);
-
1190 } else if (!parent->d_func()->scene && scene) {
executed: }
Execution Count:722
evaluated: !parent->d_func()->scene
TRUEFALSE
yes
Evaluation Count:74
yes
Evaluation Count:8
evaluated: scene
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:67
7-722
1191 // Remove this item from its former scene -
1192 scene->removeItem(q);
executed (the execution status of this line is deduced): scene->removeItem(q);
-
1193 }
executed: }
Execution Count:7
7
1194 -
1195 parent->d_ptr->addChild(q);
executed (the execution status of this line is deduced): parent->d_ptr->addChild(q);
-
1196 if (thisPointerVariant)
evaluated: thisPointerVariant
TRUEFALSE
yes
Evaluation Count:494
yes
Evaluation Count:310
310-494
1197 parent->itemChange(QGraphicsItem::ItemChildAddedChange, *thisPointerVariant);
executed: parent->itemChange(QGraphicsItem::ItemChildAddedChange, *thisPointerVariant);
Execution Count:494
494
1198 if (scene) {
evaluated: scene
TRUEFALSE
yes
Evaluation Count:730
yes
Evaluation Count:74
74-730
1199 // Re-enable scene pos notifications for new ancestors -
1200 if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges))
partially evaluated: scenePosDescendants
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:730
partially evaluated: (flags & QGraphicsItem::ItemSendsScenePositionChanges)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:730
0-730
1201 scene->d_func()->setScenePosItemEnabled(q, true);
never executed: scene->d_func()->setScenePosItemEnabled(q, true);
0
1202 }
executed: }
Execution Count:730
730
1203 -
1204 // Propagate dirty flags to the new parent -
1205 markParentDirty(/*updateBoundingRect=*/true);
executed (the execution status of this line is deduced): markParentDirty( true);
-
1206 -
1207 // Inherit ancestor flags from the new parent. -
1208 updateAncestorFlags();
executed (the execution status of this line is deduced): updateAncestorFlags();
-
1209 -
1210 // Update item visible / enabled. -
1211 if (parent->d_ptr->visible != visible) {
partially evaluated: parent->d_ptr->visible != visible
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:804
0-804
1212 if (!parent->d_ptr->visible || !explicitlyHidden)
never evaluated: !parent->d_ptr->visible
never evaluated: !explicitlyHidden
0
1213 setVisibleHelper(parent->d_ptr->visible, /* explicit = */ false, /* update = */ false);
never executed: setVisibleHelper(parent->d_ptr->visible, false, false);
0
1214 }
never executed: }
0
1215 if (parent->isEnabled() != enabled) {
partially evaluated: parent->isEnabled() != enabled
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:804
0-804
1216 if (!parent->d_ptr->enabled || !explicitlyDisabled)
never evaluated: !parent->d_ptr->enabled
never evaluated: !explicitlyDisabled
0
1217 setEnabledHelper(parent->d_ptr->enabled, /* explicit = */ false, /* update = */ false);
never executed: setEnabledHelper(parent->d_ptr->enabled, false, false);
0
1218 }
never executed: }
0
1219 -
1220 // Auto-activate if visible and the parent is active. -
1221 if (visible && parent->isActive())
partially evaluated: visible
TRUEFALSE
yes
Evaluation Count:804
no
Evaluation Count:0
evaluated: parent->isActive()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:801
0-804
1222 q->setActive(true);
executed: q->setActive(true);
Execution Count:3
3
1223 } else {
executed: }
Execution Count:804
804
1224 // Inherit ancestor flags from the new parent. -
1225 updateAncestorFlags();
executed (the execution status of this line is deduced): updateAncestorFlags();
-
1226 -
1227 if (!inDestructor) {
partially evaluated: !inDestructor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:756
0-756
1228 // Update item visible / enabled. -
1229 if (!visible && !explicitlyHidden)
never evaluated: !visible
never evaluated: !explicitlyHidden
0
1230 setVisibleHelper(true, /* explicit = */ false);
never executed: setVisibleHelper(true, false);
0
1231 if (!enabled && !explicitlyDisabled)
never evaluated: !enabled
never evaluated: !explicitlyDisabled
0
1232 setEnabledHelper(true, /* explicit = */ false);
never executed: setEnabledHelper(true, false);
0
1233 }
never executed: }
0
1234 }
executed: }
Execution Count:756
756
1235 -
1236 dirtySceneTransform = 1;
executed (the execution status of this line is deduced): dirtySceneTransform = 1;
-
1237 if (!inDestructor && (transformData || (newParent && newParent->d_ptr->transformData)))
evaluated: !inDestructor
TRUEFALSE
yes
Evaluation Count:804
yes
Evaluation Count:756
partially evaluated: transformData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:804
partially evaluated: newParent
TRUEFALSE
yes
Evaluation Count:804
no
Evaluation Count:0
partially evaluated: newParent->d_ptr->transformData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:804
0-804
1238 transformChanged();
never executed: transformChanged();
0
1239 -
1240 // Restore the sub focus chain. -
1241 if (subFocusItem) {
partially evaluated: subFocusItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1560
0-1560
1242 subFocusItem->d_ptr->setSubFocus(newParent);
never executed (the execution status of this line is deduced): subFocusItem->d_ptr->setSubFocus(newParent);
-
1243 if (parent && parent->isActive())
never evaluated: parent
never evaluated: parent->isActive()
0
1244 subFocusItem->setFocus();
never executed: subFocusItem->setFocus();
0
1245 }
never executed: }
0
1246 -
1247 // Deliver post-change notification -
1248 if (newParentVariant)
evaluated: newParentVariant
TRUEFALSE
yes
Evaluation Count:1250
yes
Evaluation Count:310
310-1250
1249 q->itemChange(QGraphicsItem::ItemParentHasChanged, *newParentVariant);
executed: q->itemChange(QGraphicsItem::ItemParentHasChanged, *newParentVariant);
Execution Count:1250
1250
1250 -
1251 if (isObject)
evaluated: isObject
TRUEFALSE
yes
Evaluation Count:1528
yes
Evaluation Count:32
32-1528
1252 emit static_cast<QGraphicsObject *>(q)->parentChanged();
executed: static_cast<QGraphicsObject *>(q)->parentChanged();
Execution Count:1528
1528
1253}
executed: }
Execution Count:1560
1560
1254 -
1255/*! -
1256 \internal -
1257 -
1258 Returns the bounding rect of this item's children (excluding itself). -
1259*/ -
1260void QGraphicsItemPrivate::childrenBoundingRectHelper(QTransform *x, QRectF *rect, QGraphicsItem *topMostEffectItem) -
1261{ -
1262 Q_Q(QGraphicsItem);
executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func();
-
1263 -
1264 QRectF childrenRect;
executed (the execution status of this line is deduced): QRectF childrenRect;
-
1265 QRectF *result = rect;
executed (the execution status of this line is deduced): QRectF *result = rect;
-
1266 rect = &childrenRect;
executed (the execution status of this line is deduced): rect = &childrenRect;
-
1267 const bool setTopMostEffectItem = !topMostEffectItem;
executed (the execution status of this line is deduced): const bool setTopMostEffectItem = !topMostEffectItem;
-
1268 -
1269 for (int i = 0; i < children.size(); ++i) {
evaluated: i < children.size()
TRUEFALSE
yes
Evaluation Count:18
yes
Evaluation Count:18
18
1270 QGraphicsItem *child = children.at(i);
executed (the execution status of this line is deduced): QGraphicsItem *child = children.at(i);
-
1271 QGraphicsItemPrivate *childd = child->d_ptr.data();
executed (the execution status of this line is deduced): QGraphicsItemPrivate *childd = child->d_ptr.data();
-
1272 if (setTopMostEffectItem)
evaluated: setTopMostEffectItem
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:8
8-10
1273 topMostEffectItem = child;
executed: topMostEffectItem = child;
Execution Count:10
10
1274 bool hasPos = !childd->pos.isNull();
executed (the execution status of this line is deduced): bool hasPos = !childd->pos.isNull();
-
1275 if (hasPos || childd->transformData) {
partially evaluated: hasPos
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
partially evaluated: childd->transformData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
0-18
1276 // COMBINE -
1277 QTransform matrix = childd->transformToParent();
never executed (the execution status of this line is deduced): QTransform matrix = childd->transformToParent();
-
1278 if (x)
never evaluated: x
0
1279 matrix *= *x;
never executed: matrix *= *x;
0
1280 *rect |= matrix.mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem));
never executed (the execution status of this line is deduced): *rect |= matrix.mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem));
-
1281 if (!childd->children.isEmpty())
never evaluated: !childd->children.isEmpty()
0
1282 childd->childrenBoundingRectHelper(&matrix, rect, topMostEffectItem);
never executed: childd->childrenBoundingRectHelper(&matrix, rect, topMostEffectItem);
0
1283 } else {
never executed: }
0
1284 if (x)
partially evaluated: x
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:18
0-18
1285 *rect |= x->mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem));
never executed: *rect |= x->mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem));
0
1286 else -
1287 *rect |= child->d_ptr->effectiveBoundingRect(topMostEffectItem);
executed: *rect |= child->d_ptr->effectiveBoundingRect(topMostEffectItem);
Execution Count:18
18
1288 if (!childd->children.isEmpty())
evaluated: !childd->children.isEmpty()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:10
8-10
1289 childd->childrenBoundingRectHelper(x, rect, topMostEffectItem);
executed: childd->childrenBoundingRectHelper(x, rect, topMostEffectItem);
Execution Count:8
8
1290 }
executed: }
Execution Count:18
18
1291 } -
1292 -
1293 if (flags & QGraphicsItem::ItemClipsChildrenToShape){
evaluated: flags & QGraphicsItem::ItemClipsChildrenToShape
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:14
4-14
1294 if (x)
partially evaluated: x
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
1295 *rect &= x->mapRect(q->boundingRect());
never executed: *rect &= x->mapRect(q->boundingRect());
0
1296 else -
1297 *rect &= q->boundingRect();
executed: *rect &= q->boundingRect();
Execution Count:4
4
1298 } -
1299 -
1300 *result |= *rect;
executed (the execution status of this line is deduced): *result |= *rect;
-
1301}
executed: }
Execution Count:18
18
1302 -
1303void QGraphicsItemPrivate::initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform, -
1304 const QRegion &exposedRegion, bool allItems) const -
1305{ -
1306 Q_ASSERT(option);
executed (the execution status of this line is deduced): qt_noop();
-
1307 Q_Q(const QGraphicsItem);
executed (the execution status of this line is deduced): const QGraphicsItem * const q = q_func();
-
1308 -
1309 // Initialize standard QStyleOption values. -
1310 const QRectF brect = q->boundingRect();
executed (the execution status of this line is deduced): const QRectF brect = q->boundingRect();
-
1311 option->state = QStyle::State_None;
executed (the execution status of this line is deduced): option->state = QStyle::State_None;
-
1312 option->rect = brect.toRect();
executed (the execution status of this line is deduced): option->rect = brect.toRect();
-
1313 option->levelOfDetail = 1;
executed (the execution status of this line is deduced): option->levelOfDetail = 1;
-
1314 option->exposedRect = brect;
executed (the execution status of this line is deduced): option->exposedRect = brect;
-
1315 -
1316 // Style animations require a QObject-based animation target. -
1317 // If a plain QGraphicsItem is used to draw animated controls, -
1318 // QStyle is let to send animation updates to the whole scene. -
1319 option->styleObject = q_ptr->toGraphicsObject();
executed (the execution status of this line is deduced): option->styleObject = q_ptr->toGraphicsObject();
-
1320 if (!option->styleObject)
evaluated: !option->styleObject
TRUEFALSE
yes
Evaluation Count:2219
yes
Evaluation Count:460
460-2219
1321 option->styleObject = scene;
executed: option->styleObject = scene;
Execution Count:2219
2219
1322 -
1323 if (selected)
evaluated: selected
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2678
1-2678
1324 option->state |= QStyle::State_Selected;
executed: option->state |= QStyle::State_Selected;
Execution Count:1
1
1325 if (enabled)
partially evaluated: enabled
TRUEFALSE
yes
Evaluation Count:2679
no
Evaluation Count:0
0-2679
1326 option->state |= QStyle::State_Enabled;
executed: option->state |= QStyle::State_Enabled;
Execution Count:2679
2679
1327 if (q->hasFocus())
partially evaluated: q->hasFocus()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2679
0-2679
1328 option->state |= QStyle::State_HasFocus;
never executed: option->state |= QStyle::State_HasFocus;
0
1329 if (scene) {
partially evaluated: scene
TRUEFALSE
yes
Evaluation Count:2679
no
Evaluation Count:0
0-2679
1330 if (scene->d_func()->hoverItems.contains(q_ptr))
partially evaluated: scene->d_func()->hoverItems.contains(q_ptr)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2679
0-2679
1331 option->state |= QStyle::State_MouseOver;
never executed: option->state |= QStyle::State_MouseOver;
0
1332 if (q == scene->mouseGrabberItem())
partially evaluated: q == scene->mouseGrabberItem()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2679
0-2679
1333 option->state |= QStyle::State_Sunken;
never executed: option->state |= QStyle::State_Sunken;
0
1334 }
executed: }
Execution Count:2679
2679
1335 -
1336 if (!(flags & QGraphicsItem::ItemUsesExtendedStyleOption))
evaluated: !(flags & QGraphicsItem::ItemUsesExtendedStyleOption)
TRUEFALSE
yes
Evaluation Count:2269
yes
Evaluation Count:410
410-2269
1337 return;
executed: return;
Execution Count:2269
2269
1338 -
1339 // Initialize QStyleOptionGraphicsItem specific values (matrix, exposedRect). -
1340 option->matrix = worldTransform.toAffine(); //### discards perspective
executed (the execution status of this line is deduced): option->matrix = worldTransform.toAffine();
-
1341 -
1342 if (!allItems) {
evaluated: !allItems
TRUEFALSE
yes
Evaluation Count:405
yes
Evaluation Count:5
5-405
1343 // Determine the item's exposed area -
1344 option->exposedRect = QRectF();
executed (the execution status of this line is deduced): option->exposedRect = QRectF();
-
1345 const QTransform reverseMap = worldTransform.inverted();
executed (the execution status of this line is deduced): const QTransform reverseMap = worldTransform.inverted();
-
1346 const QVector<QRect> exposedRects(exposedRegion.rects());
executed (the execution status of this line is deduced): const QVector<QRect> exposedRects(exposedRegion.rects());
-
1347 for (int i = 0; i < exposedRects.size(); ++i) {
evaluated: i < exposedRects.size()
TRUEFALSE
yes
Evaluation Count:453
yes
Evaluation Count:122
122-453
1348 option->exposedRect |= reverseMap.mapRect(QRectF(exposedRects.at(i)));
executed (the execution status of this line is deduced): option->exposedRect |= reverseMap.mapRect(QRectF(exposedRects.at(i)));
-
1349 if (option->exposedRect.contains(brect))
evaluated: option->exposedRect.contains(brect)
TRUEFALSE
yes
Evaluation Count:283
yes
Evaluation Count:170
170-283
1350 break;
executed: break;
Execution Count:283
283
1351 }
executed: }
Execution Count:170
170
1352 option->exposedRect &= brect;
executed (the execution status of this line is deduced): option->exposedRect &= brect;
-
1353 }
executed: }
Execution Count:405
405
1354}
executed: }
Execution Count:410
410
1355 -
1356/*! -
1357 \internal -
1358 -
1359 Empty all cached pixmaps from the pixmap cache. -
1360*/ -
1361void QGraphicsItemCache::purge() -
1362{ -
1363 QPixmapCache::remove(key);
never executed (the execution status of this line is deduced): QPixmapCache::remove(key);
-
1364 key = QPixmapCache::Key();
never executed (the execution status of this line is deduced): key = QPixmapCache::Key();
-
1365 QMutableHashIterator<QPaintDevice *, DeviceData> it(deviceData);
never executed (the execution status of this line is deduced): QMutableHashIterator<QPaintDevice *, DeviceData> it(deviceData);
-
1366 while (it.hasNext()) {
never evaluated: it.hasNext()
0
1367 DeviceData &data = it.next().value();
never executed (the execution status of this line is deduced): DeviceData &data = it.next().value();
-
1368 QPixmapCache::remove(data.key);
never executed (the execution status of this line is deduced): QPixmapCache::remove(data.key);
-
1369 data.cacheIndent = QPoint();
never executed (the execution status of this line is deduced): data.cacheIndent = QPoint();
-
1370 }
never executed: }
0
1371 deviceData.clear();
never executed (the execution status of this line is deduced): deviceData.clear();
-
1372 allExposed = true;
never executed (the execution status of this line is deduced): allExposed = true;
-
1373 exposed.clear();
never executed (the execution status of this line is deduced): exposed.clear();
-
1374}
never executed: }
0
1375 -
1376/*! -
1377 Constructs a QGraphicsItem with the given \a parent item. -
1378 It does not modify the parent object returned by QObject::parent(). -
1379 -
1380 If \a parent is 0, you can add the item to a scene by calling -
1381 QGraphicsScene::addItem(). The item will then become a top-level item. -
1382 -
1383 \sa QGraphicsScene::addItem(), setParentItem() -
1384*/ -
1385QGraphicsItem::QGraphicsItem(QGraphicsItem *parent) -
1386 : d_ptr(new QGraphicsItemPrivate) -
1387{ -
1388 d_ptr->q_ptr = this;
executed (the execution status of this line is deduced): d_ptr->q_ptr = this;
-
1389 setParentItem(parent);
executed (the execution status of this line is deduced): setParentItem(parent);
-
1390}
executed: }
Execution Count:66
66
1391 -
1392/*! -
1393 \internal -
1394*/ -
1395QGraphicsItem::QGraphicsItem(QGraphicsItemPrivate &dd, QGraphicsItem *parent) -
1396 : d_ptr(&dd) -
1397{ -
1398 d_ptr->q_ptr = this;
executed (the execution status of this line is deduced): d_ptr->q_ptr = this;
-
1399 setParentItem(parent);
executed (the execution status of this line is deduced): setParentItem(parent);
-
1400}
executed: }
Execution Count:2215
2215
1401 -
1402/*! -
1403 Destroys the QGraphicsItem and all its children. If this item is currently -
1404 associated with a scene, the item will be removed from the scene before it -
1405 is deleted. -
1406 -
1407 \note It is more efficient to remove the item from the QGraphicsScene before -
1408 destroying the item. -
1409*/ -
1410QGraphicsItem::~QGraphicsItem() -
1411{ -
1412 if (d_ptr->isObject) {
evaluated: d_ptr->isObject
TRUEFALSE
yes
Evaluation Count:1102
yes
Evaluation Count:655
655-1102
1413 QGraphicsObject *o = static_cast<QGraphicsObject *>(this);
executed (the execution status of this line is deduced): QGraphicsObject *o = static_cast<QGraphicsObject *>(this);
-
1414 QObjectPrivate *p = QObjectPrivate::get(o);
executed (the execution status of this line is deduced): QObjectPrivate *p = QObjectPrivate::get(o);
-
1415 p->wasDeleted = true;
executed (the execution status of this line is deduced): p->wasDeleted = true;
-
1416 if (p->declarativeData) {
partially evaluated: p->declarativeData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1102
0-1102
1417 QAbstractDeclarativeData::destroyed(p->declarativeData, o);
never executed (the execution status of this line is deduced): QAbstractDeclarativeData::destroyed(p->declarativeData, o);
-
1418 p->declarativeData = 0;
never executed (the execution status of this line is deduced): p->declarativeData = 0;
-
1419 }
never executed: }
0
1420 }
executed: }
Execution Count:1102
1102
1421 -
1422 d_ptr->inDestructor = 1;
executed (the execution status of this line is deduced): d_ptr->inDestructor = 1;
-
1423 d_ptr->removeExtraItemCache();
executed (the execution status of this line is deduced): d_ptr->removeExtraItemCache();
-
1424 -
1425#ifndef QT_NO_GESTURES -
1426 if (d_ptr->isObject && !d_ptr->gestureContext.isEmpty()) {
evaluated: d_ptr->isObject
TRUEFALSE
yes
Evaluation Count:1102
yes
Evaluation Count:655
evaluated: !d_ptr->gestureContext.isEmpty()
TRUEFALSE
yes
Evaluation Count:50
yes
Evaluation Count:1052
50-1102
1427 QGraphicsObject *o = static_cast<QGraphicsObject *>(this);
executed (the execution status of this line is deduced): QGraphicsObject *o = static_cast<QGraphicsObject *>(this);
-
1428 if (QGestureManager *manager = QGestureManager::instance()) {
partially evaluated: QGestureManager *manager = QGestureManager::instance()
TRUEFALSE
yes
Evaluation Count:50
no
Evaluation Count:0
0-50
1429 foreach (Qt::GestureType type, d_ptr->gestureContext.keys())
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(d_ptr->gestureContext.keys())> _container_(d_ptr->gestureContext.keys()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (Qt::GestureType type = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
1430 manager->cleanupCachedGestures(o, type);
executed: manager->cleanupCachedGestures(o, type);
Execution Count:50
50
1431 }
executed: }
Execution Count:50
50
1432 }
executed: }
Execution Count:50
50
1433#endif -
1434 -
1435 clearFocus();
executed (the execution status of this line is deduced): clearFocus();
-
1436 setFocusProxy(0);
executed (the execution status of this line is deduced): setFocusProxy(0);
-
1437 -
1438 // Update focus scope item ptr. -
1439 QGraphicsItem *p = d_ptr->parent;
executed (the execution status of this line is deduced): QGraphicsItem *p = d_ptr->parent;
-
1440 while (p) {
evaluated: p
TRUEFALSE
yes
Evaluation Count:764
yes
Evaluation Count:1757
764-1757
1441 if (p->flags() & ItemIsFocusScope) {
partially evaluated: p->flags() & ItemIsFocusScope
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:764
0-764
1442 if (p->d_ptr->focusScopeItem == this)
never evaluated: p->d_ptr->focusScopeItem == this
0
1443 p->d_ptr->focusScopeItem = 0;
never executed: p->d_ptr->focusScopeItem = 0;
0
1444 break;
never executed: break;
0
1445 } -
1446 p = p->d_ptr->parent;
executed (the execution status of this line is deduced): p = p->d_ptr->parent;
-
1447 }
executed: }
Execution Count:764
764
1448 -
1449 if (!d_ptr->children.isEmpty()) {
evaluated: !d_ptr->children.isEmpty()
TRUEFALSE
yes
Evaluation Count:199
yes
Evaluation Count:1558
199-1558
1450 while (!d_ptr->children.isEmpty())
evaluated: !d_ptr->children.isEmpty()
TRUEFALSE
yes
Evaluation Count:748
yes
Evaluation Count:199
199-748
1451 delete d_ptr->children.first();
executed: delete d_ptr->children.first();
Execution Count:748
748
1452 Q_ASSERT(d_ptr->children.isEmpty());
executed (the execution status of this line is deduced): qt_noop();
-
1453 }
executed: }
Execution Count:199
199
1454 -
1455 if (d_ptr->scene) {
evaluated: d_ptr->scene
TRUEFALSE
yes
Evaluation Count:1686
yes
Evaluation Count:71
71-1686
1456 d_ptr->scene->d_func()->removeItemHelper(this);
executed (the execution status of this line is deduced): d_ptr->scene->d_func()->removeItemHelper(this);
-
1457 } else {
executed: }
Execution Count:1686
1686
1458 d_ptr->resetFocusProxy();
executed (the execution status of this line is deduced): d_ptr->resetFocusProxy();
-
1459 setParentItem(0);
executed (the execution status of this line is deduced): setParentItem(0);
-
1460 }
executed: }
Execution Count:71
71
1461 -
1462#ifndef QT_NO_GRAPHICSEFFECT -
1463 delete d_ptr->graphicsEffect;
executed (the execution status of this line is deduced): delete d_ptr->graphicsEffect;
-
1464#endif //QT_NO_GRAPHICSEFFECT -
1465 if (d_ptr->transformData) {
evaluated: d_ptr->transformData
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:1745
12-1745
1466 for(int i = 0; i < d_ptr->transformData->graphicsTransforms.size(); ++i) {
partially evaluated: i < d_ptr->transformData->graphicsTransforms.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
1467 QGraphicsTransform *t = d_ptr->transformData->graphicsTransforms.at(i);
never executed (the execution status of this line is deduced): QGraphicsTransform *t = d_ptr->transformData->graphicsTransforms.at(i);
-
1468 static_cast<QGraphicsTransformPrivate *>(t->d_ptr.data())->item = 0;
never executed (the execution status of this line is deduced): static_cast<QGraphicsTransformPrivate *>(t->d_ptr.data())->item = 0;
-
1469 delete t;
never executed (the execution status of this line is deduced): delete t;
-
1470 }
never executed: }
0
1471 }
executed: }
Execution Count:12
12
1472 delete d_ptr->transformData;
executed (the execution status of this line is deduced): delete d_ptr->transformData;
-
1473 -
1474 if (QGraphicsItemCustomDataStore *dataStore = qt_dataStore())
partially evaluated: QGraphicsItemCustomDataStore *dataStore = qt_dataStore()
TRUEFALSE
yes
Evaluation Count:1757
no
Evaluation Count:0
0-1757
1475 dataStore->data.remove(this);
executed: dataStore->data.remove(this);
Execution Count:1757
1757
1476}
executed: }
Execution Count:1757
1757
1477 -
1478/*! -
1479 Returns the current scene for the item, or 0 if the item is not stored in -
1480 a scene. -
1481 -
1482 To add or move an item to a scene, call QGraphicsScene::addItem(). -
1483*/ -
1484QGraphicsScene *QGraphicsItem::scene() const -
1485{ -
1486 return d_ptr->scene;
executed: return d_ptr->scene;
Execution Count:8897
8897
1487} -
1488 -
1489/*! -
1490 Returns a pointer to this item's item group, or 0 if this item is not -
1491 member of a group. -
1492 -
1493 \sa QGraphicsItemGroup, QGraphicsScene::createItemGroup() -
1494*/ -
1495QGraphicsItemGroup *QGraphicsItem::group() const -
1496{ -
1497 if (!d_ptr->isMemberOfGroup)
partially evaluated: !d_ptr->isMemberOfGroup
TRUEFALSE
yes
Evaluation Count:1967
no
Evaluation Count:0
0-1967
1498 return 0;
executed: return 0;
Execution Count:1967
1967
1499 QGraphicsItem *parent = const_cast<QGraphicsItem *>(this);
never executed (the execution status of this line is deduced): QGraphicsItem *parent = const_cast<QGraphicsItem *>(this);
-
1500 while ((parent = parent->d_ptr->parent)) {
never evaluated: (parent = parent->d_ptr->parent)
0
1501 if (QGraphicsItemGroup *group = qgraphicsitem_cast<QGraphicsItemGroup *>(parent))
never evaluated: QGraphicsItemGroup *group = qgraphicsitem_cast<QGraphicsItemGroup *>(parent)
0
1502 return group;
never executed: return group;
0
1503 }
never executed: }
0
1504 // Unreachable; if d_ptr->isMemberOfGroup is != 0, then one parent of this -
1505 // item is a group item. -
1506 return 0;
never executed: return 0;
0
1507} -
1508 -
1509/*! -
1510 Adds this item to the item group \a group. If \a group is 0, this item is -
1511 removed from any current group and added as a child of the previous -
1512 group's parent. -
1513 -
1514 \sa group(), QGraphicsScene::createItemGroup() -
1515*/ -
1516void QGraphicsItem::setGroup(QGraphicsItemGroup *group) -
1517{ -
1518 if (!group) {
never evaluated: !group
0
1519 if (QGraphicsItemGroup *group = this->group())
never evaluated: QGraphicsItemGroup *group = this->group()
0
1520 group->removeFromGroup(this);
never executed: group->removeFromGroup(this);
0
1521 } else {
never executed: }
0
1522 group->addToGroup(this);
never executed (the execution status of this line is deduced): group->addToGroup(this);
-
1523 }
never executed: }
0
1524} -
1525 -
1526/*! -
1527 Returns a pointer to this item's parent item. If this item does not have a -
1528 parent, 0 is returned. -
1529 -
1530 \sa setParentItem(), childItems() -
1531*/ -
1532QGraphicsItem *QGraphicsItem::parentItem() const -
1533{ -
1534 return d_ptr->parent;
executed: return d_ptr->parent;
Execution Count:15829
15829
1535} -
1536 -
1537/*! -
1538 Returns this item's top-level item. The top-level item is the item's -
1539 topmost ancestor item whose parent is 0. If an item has no parent, its own -
1540 pointer is returned (i.e., a top-level item is its own top-level item). -
1541 -
1542 \sa parentItem() -
1543*/ -
1544QGraphicsItem *QGraphicsItem::topLevelItem() const -
1545{ -
1546 QGraphicsItem *parent = const_cast<QGraphicsItem *>(this);
executed (the execution status of this line is deduced): QGraphicsItem *parent = const_cast<QGraphicsItem *>(this);
-
1547 while (QGraphicsItem *grandPa = parent->parentItem())
evaluated: QGraphicsItem *grandPa = parent->parentItem()
TRUEFALSE
yes
Evaluation Count:2678
yes
Evaluation Count:3361
2678-3361
1548 parent = grandPa;
executed: parent = grandPa;
Execution Count:2678
2678
1549 return parent;
executed: return parent;
Execution Count:3361
3361
1550} -
1551 -
1552/*! -
1553 \since 4.6 -
1554 -
1555 Returns a pointer to the item's parent, cast to a QGraphicsObject. returns 0 if the parent item -
1556 is not a QGraphicsObject. -
1557 -
1558 \sa parentItem(), childItems() -
1559*/ -
1560QGraphicsObject *QGraphicsItem::parentObject() const -
1561{ -
1562 QGraphicsItem *p = d_ptr->parent;
executed (the execution status of this line is deduced): QGraphicsItem *p = d_ptr->parent;
-
1563 return (p && p->d_ptr->isObject) ? static_cast<QGraphicsObject *>(p) : 0;
executed: return (p && p->d_ptr->isObject) ? static_cast<QGraphicsObject *>(p) : 0;
Execution Count:885
885
1564} -
1565 -
1566/*! -
1567 \since 4.4 -
1568 -
1569 Returns a pointer to the item's parent widget. The item's parent widget is -
1570 the closest parent item that is a widget. -
1571 -
1572 \sa parentItem(), childItems() -
1573*/ -
1574QGraphicsWidget *QGraphicsItem::parentWidget() const -
1575{ -
1576 QGraphicsItem *p = parentItem();
executed (the execution status of this line is deduced): QGraphicsItem *p = parentItem();
-
1577 while (p && !p->isWidget())
evaluated: p
TRUEFALSE
yes
Evaluation Count:4727
yes
Evaluation Count:1783
evaluated: !p->isWidget()
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:4717
10-4727
1578 p = p->parentItem();
executed: p = p->parentItem();
Execution Count:10
10
1579 return (p && p->isWidget()) ? static_cast<QGraphicsWidget *>(p) : 0;
executed: return (p && p->isWidget()) ? static_cast<QGraphicsWidget *>(p) : 0;
Execution Count:6500
6500
1580} -
1581 -
1582/*! -
1583 \since 4.4 -
1584 -
1585 Returns a pointer to the item's top level widget (i.e., the item's -
1586 ancestor whose parent is 0, or whose parent is not a widget), or 0 if this -
1587 item does not have a top level widget. If the item is its own top level -
1588 widget, this function returns a pointer to the item itself. -
1589*/ -
1590QGraphicsWidget *QGraphicsItem::topLevelWidget() const -
1591{ -
1592 if (const QGraphicsWidget *p = parentWidget())
never evaluated: const QGraphicsWidget *p = parentWidget()
0
1593 return p->topLevelWidget();
never executed: return p->topLevelWidget();
0
1594 return isWidget() ? static_cast<QGraphicsWidget *>(const_cast<QGraphicsItem *>(this)) : 0;
never executed: return isWidget() ? static_cast<QGraphicsWidget *>(const_cast<QGraphicsItem *>(this)) : 0;
0
1595} -
1596 -
1597/*! -
1598 \since 4.4 -
1599 -
1600 Returns the item's window, or 0 if this item does not have a window. If -
1601 the item is a window, it will return itself. Otherwise it will return the -
1602 closest ancestor that is a window. -
1603 -
1604 \sa QGraphicsWidget::isWindow() -
1605*/ -
1606QGraphicsWidget *QGraphicsItem::window() const -
1607{ -
1608 QGraphicsItem *p = panel();
executed (the execution status of this line is deduced): QGraphicsItem *p = panel();
-
1609 if (p && p->isWindow())
evaluated: p
TRUEFALSE
yes
Evaluation Count:56
yes
Evaluation Count:290
partially evaluated: p->isWindow()
TRUEFALSE
yes
Evaluation Count:56
no
Evaluation Count:0
0-290
1610 return static_cast<QGraphicsWidget *>(p);
executed: return static_cast<QGraphicsWidget *>(p);
Execution Count:56
56
1611 return 0;
executed: return 0;
Execution Count:290
290
1612} -
1613 -
1614/*! -
1615 \since 4.6 -
1616 -
1617 Returns the item's panel, or 0 if this item does not have a panel. If the -
1618 item is a panel, it will return itself. Otherwise it will return the -
1619 closest ancestor that is a panel. -
1620 -
1621 \sa isPanel(), ItemIsPanel -
1622*/ -
1623QGraphicsItem *QGraphicsItem::panel() const -
1624{ -
1625 if (d_ptr->flags & ItemIsPanel)
evaluated: d_ptr->flags & ItemIsPanel
TRUEFALSE
yes
Evaluation Count:172
yes
Evaluation Count:393
172-393
1626 return const_cast<QGraphicsItem *>(this);
executed: return const_cast<QGraphicsItem *>(this);
Execution Count:172
172
1627 return d_ptr->parent ? d_ptr->parent->panel() : 0;
executed: return d_ptr->parent ? d_ptr->parent->panel() : 0;
Execution Count:393
393
1628} -
1629 -
1630/*! -
1631 \since 4.6 -
1632 -
1633 Return the graphics item cast to a QGraphicsObject, if the class is actually a -
1634 graphics object, 0 otherwise. -
1635*/ -
1636QGraphicsObject *QGraphicsItem::toGraphicsObject() -
1637{ -
1638 return d_ptr->isObject ? static_cast<QGraphicsObject *>(this) : 0;
executed: return d_ptr->isObject ? static_cast<QGraphicsObject *>(this) : 0;
Execution Count:5617
5617
1639} -
1640 -
1641/*! -
1642 \since 4.6 -
1643 -
1644 Return the graphics item cast to a QGraphicsObject, if the class is actually a -
1645 graphics object, 0 otherwise. -
1646*/ -
1647const QGraphicsObject *QGraphicsItem::toGraphicsObject() const -
1648{ -
1649 return d_ptr->isObject ? static_cast<const QGraphicsObject *>(this) : 0;
never executed: return d_ptr->isObject ? static_cast<const QGraphicsObject *>(this) : 0;
0
1650} -
1651 -
1652/*! -
1653 Sets this item's parent item to \a newParent. If this item already -
1654 has a parent, it is first removed from the previous parent. If \a -
1655 newParent is 0, this item will become a top-level item. -
1656 -
1657 Note that this implicitly adds this graphics item to the scene of -
1658 the parent. You should not \l{QGraphicsScene::addItem()}{add} the -
1659 item to the scene yourself. -
1660 -
1661 Calling this function on an item that is an ancestor of \a newParent -
1662 have undefined behaviour. -
1663 -
1664 \sa parentItem(), childItems() -
1665*/ -
1666void QGraphicsItem::setParentItem(QGraphicsItem *newParent) -
1667{ -
1668 if (newParent == this) {
partially evaluated: newParent == this
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3591
0-3591
1669 qWarning("QGraphicsItem::setParentItem: cannot assign %p as a parent of itself", this);
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 1669, __PRETTY_FUNCTION__).warning("QGraphicsItem::setParentItem: cannot assign %p as a parent of itself", this);
-
1670 return;
never executed: return;
0
1671 } -
1672 if (newParent == d_ptr->parent)
evaluated: newParent == d_ptr->parent
TRUEFALSE
yes
Evaluation Count:2341
yes
Evaluation Count:1250
1250-2341
1673 return;
executed: return;
Execution Count:2341
2341
1674 -
1675 const QVariant newParentVariant(itemChange(QGraphicsItem::ItemParentChange,
executed (the execution status of this line is deduced): const QVariant newParentVariant(itemChange(QGraphicsItem::ItemParentChange,
-
1676 QVariant::fromValue<QGraphicsItem *>(newParent)));
executed (the execution status of this line is deduced): QVariant::fromValue<QGraphicsItem *>(newParent)));
-
1677 newParent = qvariant_cast<QGraphicsItem *>(newParentVariant);
executed (the execution status of this line is deduced): newParent = qvariant_cast<QGraphicsItem *>(newParentVariant);
-
1678 if (newParent == d_ptr->parent)
partially evaluated: newParent == d_ptr->parent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1250
0-1250
1679 return;
never executed: return;
0
1680 -
1681 const QVariant thisPointerVariant(QVariant::fromValue<QGraphicsItem *>(this));
executed (the execution status of this line is deduced): const QVariant thisPointerVariant(QVariant::fromValue<QGraphicsItem *>(this));
-
1682 d_ptr->setParentItemHelper(newParent, &newParentVariant, &thisPointerVariant);
executed (the execution status of this line is deduced): d_ptr->setParentItemHelper(newParent, &newParentVariant, &thisPointerVariant);
-
1683}
executed: }
Execution Count:1250
1250
1684 -
1685/*! -
1686 \fn QList<QGraphicsItem *> QGraphicsItem::children() const -
1687 \obsolete -
1688 -
1689 Use childItems() instead. -
1690 -
1691 \sa setParentItem() -
1692*/ -
1693 -
1694/*! -
1695 \since 4.4 -
1696 -
1697 Returns a list of this item's children. -
1698 -
1699 The items are sorted by stacking order. This takes into account both the -
1700 items' insertion order and their Z-values. -
1701 -
1702 \sa setParentItem(), zValue(), {QGraphicsItem#Sorting}{Sorting} -
1703*/ -
1704QList<QGraphicsItem *> QGraphicsItem::childItems() const -
1705{ -
1706 const_cast<QGraphicsItem *>(this)->d_ptr->ensureSortedChildren();
executed (the execution status of this line is deduced): const_cast<QGraphicsItem *>(this)->d_ptr->ensureSortedChildren();
-
1707 return d_ptr->children;
executed: return d_ptr->children;
Execution Count:188
188
1708} -
1709 -
1710/*! -
1711 \since 4.4 -
1712 Returns true if this item is a widget (i.e., QGraphicsWidget); otherwise, -
1713 returns false. -
1714*/ -
1715bool QGraphicsItem::isWidget() const -
1716{ -
1717 return d_ptr->isWidget;
executed: return d_ptr->isWidget;
Execution Count:26161
26161
1718} -
1719 -
1720/*! -
1721 \since 4.4 -
1722 Returns true if the item is a QGraphicsWidget window, otherwise returns -
1723 false. -
1724 -
1725 \sa QGraphicsWidget::windowFlags() -
1726*/ -
1727bool QGraphicsItem::isWindow() const -
1728{ -
1729 return d_ptr->isWidget && (static_cast<const QGraphicsWidget *>(this)->windowType() & Qt::Window);
executed: return d_ptr->isWidget && (static_cast<const QGraphicsWidget *>(this)->windowType() & Qt::Window);
Execution Count:3456
3456
1730} -
1731 -
1732/*! -
1733 \since 4.6 -
1734 Returns true if the item is a panel; otherwise returns false. -
1735 -
1736 \sa QGraphicsItem::panel(), ItemIsPanel -
1737*/ -
1738bool QGraphicsItem::isPanel() const -
1739{ -
1740 return d_ptr->flags & ItemIsPanel;
executed: return d_ptr->flags & ItemIsPanel;
Execution Count:5638
5638
1741} -
1742 -
1743/*! -
1744 Returns this item's flags. The flags describe what configurable features -
1745 of the item are enabled and not. For example, if the flags include -
1746 ItemIsFocusable, the item can accept input focus. -
1747 -
1748 By default, no flags are enabled. -
1749 -
1750 \sa setFlags(), setFlag() -
1751*/ -
1752QGraphicsItem::GraphicsItemFlags QGraphicsItem::flags() const -
1753{ -
1754 return GraphicsItemFlags(d_ptr->flags);
executed: return GraphicsItemFlags(d_ptr->flags);
Execution Count:3675
3675
1755} -
1756 -
1757/*! -
1758 If \a enabled is true, the item flag \a flag is enabled; otherwise, it is -
1759 disabled. -
1760 -
1761 \sa flags(), setFlags() -
1762*/ -
1763void QGraphicsItem::setFlag(GraphicsItemFlag flag, bool enabled) -
1764{ -
1765 if (enabled)
evaluated: enabled
TRUEFALSE
yes
Evaluation Count:43
yes
Evaluation Count:11
11-43
1766 setFlags(GraphicsItemFlags(d_ptr->flags) | flag);
executed: setFlags(GraphicsItemFlags(d_ptr->flags) | flag);
Execution Count:43
43
1767 else -
1768 setFlags(GraphicsItemFlags(d_ptr->flags) & ~flag);
executed: setFlags(GraphicsItemFlags(d_ptr->flags) & ~flag);
Execution Count:11
11
1769} -
1770 -
1771/*! -
1772 Sets the item flags to \a flags. All flags in \a flags are enabled; all -
1773 flags not in \a flags are disabled. -
1774 -
1775 If the item had focus and \a flags does not enable ItemIsFocusable, the -
1776 item loses focus as a result of calling this function. Similarly, if the -
1777 item was selected, and \a flags does not enabled ItemIsSelectable, the -
1778 item is automatically unselected. -
1779 -
1780 By default, no flags are enabled. (QGraphicsWidget enables the -
1781 ItemSendsGeometryChanges flag by default in order to track position -
1782 changes.) -
1783 -
1784 \sa flags(), setFlag() -
1785*/ -
1786void QGraphicsItem::setFlags(GraphicsItemFlags flags) -
1787{ -
1788 // Notify change and check for adjustment. -
1789 if (quint32(d_ptr->flags) == quint32(flags))
evaluated: quint32(d_ptr->flags) == quint32(flags)
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:159
7-159
1790 return;
executed: return;
Execution Count:7
7
1791 flags = GraphicsItemFlags(itemChange(ItemFlagsChange, quint32(flags)).toUInt());
executed (the execution status of this line is deduced): flags = GraphicsItemFlags(itemChange(ItemFlagsChange, quint32(flags)).toUInt());
-
1792 if (quint32(d_ptr->flags) == quint32(flags))
partially evaluated: quint32(d_ptr->flags) == quint32(flags)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:159
0-159
1793 return;
never executed: return;
0
1794 if (d_ptr->scene && d_ptr->scene->d_func()->indexMethod != QGraphicsScene::NoIndex)
evaluated: d_ptr->scene
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:133
partially evaluated: d_ptr->scene->d_func()->indexMethod != QGraphicsScene::NoIndex
TRUEFALSE
yes
Evaluation Count:26
no
Evaluation Count:0
0-133
1795 d_ptr->scene->d_func()->index->itemChange(this, ItemFlagsChange, &flags);
executed: d_ptr->scene->d_func()->index->itemChange(this, ItemFlagsChange, &flags);
Execution Count:26
26
1796 -
1797 // Flags that alter the geometry of the item (or its children). -
1798 const quint32 geomChangeFlagsMask = (ItemClipsChildrenToShape | ItemClipsToShape | ItemIgnoresTransformations | ItemIsSelectable);
executed (the execution status of this line is deduced): const quint32 geomChangeFlagsMask = (ItemClipsChildrenToShape | ItemClipsToShape | ItemIgnoresTransformations | ItemIsSelectable);
-
1799 bool fullUpdate = (quint32(flags) & geomChangeFlagsMask) != (d_ptr->flags & geomChangeFlagsMask);
executed (the execution status of this line is deduced): bool fullUpdate = (quint32(flags) & geomChangeFlagsMask) != (d_ptr->flags & geomChangeFlagsMask);
-
1800 if (fullUpdate)
evaluated: fullUpdate
TRUEFALSE
yes
Evaluation Count:24
yes
Evaluation Count:135
24-135
1801 d_ptr->updatePaintedViewBoundingRects(/*children=*/true);
executed: d_ptr->updatePaintedViewBoundingRects( true);
Execution Count:24
24
1802 -
1803 // Keep the old flags to compare the diff. -
1804 GraphicsItemFlags oldFlags = GraphicsItemFlags(d_ptr->flags);
executed (the execution status of this line is deduced): GraphicsItemFlags oldFlags = GraphicsItemFlags(d_ptr->flags);
-
1805 -
1806 // Update flags. -
1807 d_ptr->flags = flags;
executed (the execution status of this line is deduced): d_ptr->flags = flags;
-
1808 -
1809 if (!(d_ptr->flags & ItemIsFocusable) && hasFocus()) {
evaluated: !(d_ptr->flags & ItemIsFocusable)
TRUEFALSE
yes
Evaluation Count:137
yes
Evaluation Count:22
partially evaluated: hasFocus()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:137
0-137
1810 // Clear focus on the item if it has focus when the focusable flag -
1811 // is unset. -
1812 clearFocus();
never executed (the execution status of this line is deduced): clearFocus();
-
1813 }
never executed: }
0
1814 -
1815 if (!(d_ptr->flags & ItemIsSelectable) && isSelected()) {
evaluated: !(d_ptr->flags & ItemIsSelectable)
TRUEFALSE
yes
Evaluation Count:152
yes
Evaluation Count:7
partially evaluated: isSelected()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:152
0-152
1816 // Unselect the item if it is selected when the selectable flag is -
1817 // unset. -
1818 setSelected(false);
never executed (the execution status of this line is deduced): setSelected(false);
-
1819 }
never executed: }
0
1820 -
1821 if ((flags & ItemClipsChildrenToShape) != (oldFlags & ItemClipsChildrenToShape)) {
evaluated: (flags & ItemClipsChildrenToShape) != (oldFlags & ItemClipsChildrenToShape)
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:146
13-146
1822 // Item children clipping changes. Propagate the ancestor flag to -
1823 // all children. -
1824 d_ptr->updateAncestorFlag(ItemClipsChildrenToShape);
executed (the execution status of this line is deduced): d_ptr->updateAncestorFlag(ItemClipsChildrenToShape);
-
1825 // The childrenBoundingRect is clipped to the boundingRect in case of ItemClipsChildrenToShape, -
1826 // which means we have to invalidate the cached childrenBoundingRect whenever this flag changes. -
1827 d_ptr->dirtyChildrenBoundingRect = 1;
executed (the execution status of this line is deduced): d_ptr->dirtyChildrenBoundingRect = 1;
-
1828 d_ptr->markParentDirty(true);
executed (the execution status of this line is deduced): d_ptr->markParentDirty(true);
-
1829 }
executed: }
Execution Count:13
13
1830 -
1831 if ((flags & ItemIgnoresTransformations) != (oldFlags & ItemIgnoresTransformations)) {
evaluated: (flags & ItemIgnoresTransformations) != (oldFlags & ItemIgnoresTransformations)
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:155
4-155
1832 // Item children clipping changes. Propagate the ancestor flag to -
1833 // all children. -
1834 d_ptr->updateAncestorFlag(ItemIgnoresTransformations);
executed (the execution status of this line is deduced): d_ptr->updateAncestorFlag(ItemIgnoresTransformations);
-
1835 }
executed: }
Execution Count:4
4
1836 -
1837 if ((flags & ItemNegativeZStacksBehindParent) != (oldFlags & ItemNegativeZStacksBehindParent)) {
partially evaluated: (flags & ItemNegativeZStacksBehindParent) != (oldFlags & ItemNegativeZStacksBehindParent)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:159
0-159
1838 // NB! We change the flags directly here, so we must also update d_ptr->flags. -
1839 // Note that this has do be done before the ItemStacksBehindParent check -
1840 // below; otherwise we will loose the change. -
1841 -
1842 // Update stack-behind. -
1843 if (d_ptr->z < qreal(0.0))
never evaluated: d_ptr->z < qreal(0.0)
0
1844 flags |= ItemStacksBehindParent;
never executed: flags |= ItemStacksBehindParent;
0
1845 else -
1846 flags &= ~ItemStacksBehindParent;
never executed: flags &= ~ItemStacksBehindParent;
0
1847 d_ptr->flags = flags;
never executed (the execution status of this line is deduced): d_ptr->flags = flags;
-
1848 }
never executed: }
0
1849 -
1850 if ((flags & ItemStacksBehindParent) != (oldFlags & ItemStacksBehindParent)) {
evaluated: (flags & ItemStacksBehindParent) != (oldFlags & ItemStacksBehindParent)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:158
1-158
1851 // NB! This check has to come after the ItemNegativeZStacksBehindParent -
1852 // check above. Be careful. -
1853 -
1854 // Ensure child item sorting is up to date when toggling this flag. -
1855 if (d_ptr->parent)
partially evaluated: d_ptr->parent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1856 d_ptr->parent->d_ptr->needSortChildren = 1;
never executed: d_ptr->parent->d_ptr->needSortChildren = 1;
0
1857 else if (d_ptr->scene)
partially evaluated: d_ptr->scene
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
1858 d_ptr->scene->d_func()->needSortTopLevelItems = 1;
never executed: d_ptr->scene->d_func()->needSortTopLevelItems = 1;
0
1859 } -
1860 -
1861 if ((flags & ItemAcceptsInputMethod) != (oldFlags & ItemAcceptsInputMethod)) {
evaluated: (flags & ItemAcceptsInputMethod) != (oldFlags & ItemAcceptsInputMethod)
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:152
7-152
1862 // Update input method sensitivity in any views. -
1863 if (d_ptr->scene)
evaluated: d_ptr->scene
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:4
3-4
1864 d_ptr->scene->d_func()->updateInputMethodSensitivityInViews();
executed: d_ptr->scene->d_func()->updateInputMethodSensitivityInViews();
Execution Count:3
3
1865 }
executed: }
Execution Count:7
7
1866 -
1867 -
1868 if ((d_ptr->panelModality != NonModal)
partially evaluated: (d_ptr->panelModality != NonModal)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:159
0-159
1869 && d_ptr->scene
never evaluated: d_ptr->scene
0
1870 && (flags & ItemIsPanel) != (oldFlags & ItemIsPanel)) {
never evaluated: (flags & ItemIsPanel) != (oldFlags & ItemIsPanel)
0
1871 // update the panel's modal state -
1872 if (flags & ItemIsPanel)
never evaluated: flags & ItemIsPanel
0
1873 d_ptr->scene->d_func()->enterModal(this);
never executed: d_ptr->scene->d_func()->enterModal(this);
0
1874 else -
1875 d_ptr->scene->d_func()->leaveModal(this);
never executed: d_ptr->scene->d_func()->leaveModal(this);
0
1876 } -
1877 -
1878 if (d_ptr->scene) {
evaluated: d_ptr->scene
TRUEFALSE
yes
Evaluation Count:26
yes
Evaluation Count:133
26-133
1879 if ((flags & ItemSendsScenePositionChanges) != (oldFlags & ItemSendsScenePositionChanges)) {
partially evaluated: (flags & ItemSendsScenePositionChanges) != (oldFlags & ItemSendsScenePositionChanges)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:26
0-26
1880 if (flags & ItemSendsScenePositionChanges)
never evaluated: flags & ItemSendsScenePositionChanges
0
1881 d_ptr->scene->d_func()->registerScenePosItem(this);
never executed: d_ptr->scene->d_func()->registerScenePosItem(this);
0
1882 else -
1883 d_ptr->scene->d_func()->unregisterScenePosItem(this);
never executed: d_ptr->scene->d_func()->unregisterScenePosItem(this);
0
1884 } -
1885 d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true);
executed (the execution status of this line is deduced): d_ptr->scene->d_func()->markDirty(this, QRectF(), true);
-
1886 }
executed: }
Execution Count:26
26
1887 -
1888 // Notify change. -
1889 itemChange(ItemFlagsHaveChanged, quint32(flags));
executed (the execution status of this line is deduced): itemChange(ItemFlagsHaveChanged, quint32(flags));
-
1890}
executed: }
Execution Count:159
159
1891 -
1892/*! -
1893 \since 4.4 -
1894 Returns the cache mode for this item. The default mode is NoCache (i.e., -
1895 cache is disabled and all painting is immediate). -
1896 -
1897 \sa setCacheMode() -
1898*/ -
1899QGraphicsItem::CacheMode QGraphicsItem::cacheMode() const -
1900{ -
1901 return QGraphicsItem::CacheMode(d_ptr->cacheMode);
never executed: return QGraphicsItem::CacheMode(d_ptr->cacheMode);
0
1902} -
1903 -
1904/*! -
1905 \since 4.4 -
1906 Sets the item's cache mode to \a mode. -
1907 -
1908 The optional \a logicalCacheSize argument is used only by -
1909 ItemCoordinateCache mode, and describes the resolution of the cache -
1910 buffer; if \a logicalCacheSize is (100, 100), QGraphicsItem will fit the -
1911 item into 100x100 pixels in graphics memory, regardless of the logical -
1912 size of the item itself. By default QGraphicsItem uses the size of -
1913 boundingRect(). For all other cache modes than ItemCoordinateCache, \a -
1914 logicalCacheSize is ignored. -
1915 -
1916 Caching can speed up rendering if your item spends a significant time -
1917 redrawing itself. In some cases the cache can also slow down rendering, in -
1918 particular when the item spends less time redrawing than QGraphicsItem -
1919 spends redrawing from the cache. When enabled, the item's paint() function -
1920 will be called only once for each call to update(); for any subsequent -
1921 repaint requests, the Graphics View framework will redraw from the -
1922 cache. This approach works particularly well with QGLWidget, which stores -
1923 all the cache as OpenGL textures. -
1924 -
1925 Be aware that QPixmapCache's cache limit may need to be changed to obtain -
1926 optimal performance. -
1927 -
1928 You can read more about the different cache modes in the CacheMode -
1929 documentation. -
1930 -
1931 \sa CacheMode, QPixmapCache::setCacheLimit() -
1932*/ -
1933void QGraphicsItem::setCacheMode(CacheMode mode, const QSize &logicalCacheSize) -
1934{ -
1935 CacheMode lastMode = CacheMode(d_ptr->cacheMode);
never executed (the execution status of this line is deduced): CacheMode lastMode = CacheMode(d_ptr->cacheMode);
-
1936 d_ptr->cacheMode = mode;
never executed (the execution status of this line is deduced): d_ptr->cacheMode = mode;
-
1937 bool noVisualChange = (mode == NoCache && lastMode == NoCache)
never evaluated: mode == NoCache
never evaluated: lastMode == NoCache
0
1938 || (mode == NoCache && lastMode == DeviceCoordinateCache)
never evaluated: mode == NoCache
never evaluated: lastMode == DeviceCoordinateCache
0
1939 || (mode == DeviceCoordinateCache && lastMode == NoCache)
never evaluated: mode == DeviceCoordinateCache
never evaluated: lastMode == NoCache
0
1940 || (mode == DeviceCoordinateCache && lastMode == DeviceCoordinateCache);
never evaluated: mode == DeviceCoordinateCache
never evaluated: lastMode == DeviceCoordinateCache
0
1941 if (mode == NoCache) {
never evaluated: mode == NoCache
0
1942 d_ptr->removeExtraItemCache();
never executed (the execution status of this line is deduced): d_ptr->removeExtraItemCache();
-
1943 } else {
never executed: }
0
1944 QGraphicsItemCache *cache = d_ptr->extraItemCache();
never executed (the execution status of this line is deduced): QGraphicsItemCache *cache = d_ptr->extraItemCache();
-
1945 -
1946 // Reset old cache -
1947 cache->purge();
never executed (the execution status of this line is deduced): cache->purge();
-
1948 -
1949 if (mode == ItemCoordinateCache) {
never evaluated: mode == ItemCoordinateCache
0
1950 if (lastMode == mode && cache->fixedSize == logicalCacheSize)
never evaluated: lastMode == mode
never evaluated: cache->fixedSize == logicalCacheSize
0
1951 noVisualChange = true;
never executed: noVisualChange = true;
0
1952 cache->fixedSize = logicalCacheSize;
never executed (the execution status of this line is deduced): cache->fixedSize = logicalCacheSize;
-
1953 }
never executed: }
0
1954 }
never executed: }
0
1955 if (!noVisualChange)
never evaluated: !noVisualChange
0
1956 update();
never executed: update();
0
1957}
never executed: }
0
1958 -
1959/*! -
1960 \since 4.6 -
1961 -
1962 Returns the modality for this item. -
1963*/ -
1964QGraphicsItem::PanelModality QGraphicsItem::panelModality() const -
1965{ -
1966 return d_ptr->panelModality;
executed: return d_ptr->panelModality;
Execution Count:361
361
1967} -
1968 -
1969/*! -
1970 \since 4.6 -
1971 -
1972 Sets the modality for this item to \a panelModality. -
1973 -
1974 Changing the modality of a visible item takes effect immediately. -
1975*/ -
1976void QGraphicsItem::setPanelModality(PanelModality panelModality) -
1977{ -
1978 if (d_ptr->panelModality == panelModality)
evaluated: d_ptr->panelModality == panelModality
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:3
1-3
1979 return;
executed: return;
Execution Count:1
1
1980 -
1981 PanelModality previousModality = d_ptr->panelModality;
executed (the execution status of this line is deduced): PanelModality previousModality = d_ptr->panelModality;
-
1982 bool enterLeaveModal = (isPanel() && d_ptr->scene && isVisible());
partially evaluated: isPanel()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
evaluated: d_ptr->scene
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
partially evaluated: isVisible()
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-3
1983 if (enterLeaveModal && panelModality == NonModal)
evaluated: enterLeaveModal
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
partially evaluated: panelModality == NonModal
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
1984 d_ptr->scene->d_func()->leaveModal(this);
never executed: d_ptr->scene->d_func()->leaveModal(this);
0
1985 d_ptr->panelModality = panelModality;
executed (the execution status of this line is deduced): d_ptr->panelModality = panelModality;
-
1986 if (enterLeaveModal && d_ptr->panelModality != NonModal)
evaluated: enterLeaveModal
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
partially evaluated: d_ptr->panelModality != NonModal
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
1987 d_ptr->scene->d_func()->enterModal(this, previousModality);
executed: d_ptr->scene->d_func()->enterModal(this, previousModality);
Execution Count:2
2
1988}
executed: }
Execution Count:3
3
1989 -
1990/*! -
1991 \since 4.6 -
1992 -
1993 Returns true if this item is blocked by a modal panel, false otherwise. If \a blockingPanel is -
1994 non-zero, \a blockingPanel will be set to the modal panel that is blocking this item. If this -
1995 item is not blocked, \a blockingPanel will not be set by this function. -
1996 -
1997 This function always returns false for items not in a scene. -
1998 -
1999 \sa panelModality(), setPanelModality(), PanelModality -
2000*/ -
2001bool QGraphicsItem::isBlockedByModalPanel(QGraphicsItem **blockingPanel) const -
2002{ -
2003 if (!d_ptr->scene)
partially evaluated: !d_ptr->scene
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:758
0-758
2004 return false;
never executed: return false;
0
2005 -
2006 -
2007 QGraphicsItem *dummy = 0;
executed (the execution status of this line is deduced): QGraphicsItem *dummy = 0;
-
2008 if (!blockingPanel)
evaluated: !blockingPanel
TRUEFALSE
yes
Evaluation Count:511
yes
Evaluation Count:247
247-511
2009 blockingPanel = &dummy;
executed: blockingPanel = &dummy;
Execution Count:511
511
2010 -
2011 QGraphicsScenePrivate *scene_d = d_ptr->scene->d_func();
executed (the execution status of this line is deduced): QGraphicsScenePrivate *scene_d = d_ptr->scene->d_func();
-
2012 if (scene_d->modalPanels.isEmpty())
evaluated: scene_d->modalPanels.isEmpty()
TRUEFALSE
yes
Evaluation Count:750
yes
Evaluation Count:8
8-750
2013 return false;
executed: return false;
Execution Count:750
750
2014 -
2015 // ### -
2016 if (!scene_d->popupWidgets.isEmpty() && scene_d->popupWidgets.first() == this)
partially evaluated: !scene_d->popupWidgets.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
never evaluated: scene_d->popupWidgets.first() == this
0-8
2017 return false;
never executed: return false;
0
2018 -
2019 for (int i = 0; i < scene_d->modalPanels.count(); ++i) {
evaluated: i < scene_d->modalPanels.count()
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:5
5-8
2020 QGraphicsItem *modalPanel = scene_d->modalPanels.at(i);
executed (the execution status of this line is deduced): QGraphicsItem *modalPanel = scene_d->modalPanels.at(i);
-
2021 if (modalPanel->panelModality() == QGraphicsItem::SceneModal) {
evaluated: modalPanel->panelModality() == QGraphicsItem::SceneModal
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:6
2-6
2022 // Scene modal panels block all non-descendents. -
2023 if (modalPanel != this && !modalPanel->isAncestorOf(this)) {
evaluated: modalPanel != this
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
partially evaluated: !modalPanel->isAncestorOf(this)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
2024 *blockingPanel = modalPanel;
executed (the execution status of this line is deduced): *blockingPanel = modalPanel;
-
2025 return true;
executed: return true;
Execution Count:1
1
2026 } -
2027 } else {
executed: }
Execution Count:1
1
2028 // Window modal panels block ancestors and siblings/cousins. -
2029 if (modalPanel != this
evaluated: modalPanel != this
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3
3
2030 && !modalPanel->isAncestorOf(this)
partially evaluated: !modalPanel->isAncestorOf(this)
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2031 && commonAncestorItem(modalPanel)) {
evaluated: commonAncestorItem(modalPanel)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
2032 *blockingPanel = modalPanel;
executed (the execution status of this line is deduced): *blockingPanel = modalPanel;
-
2033 return true;
executed: return true;
Execution Count:2
2
2034 } -
2035 }
executed: }
Execution Count:4
4
2036 } -
2037 return false;
executed: return false;
Execution Count:5
5
2038} -
2039 -
2040#ifndef QT_NO_TOOLTIP -
2041/*! -
2042 Returns the item's tool tip, or an empty QString if no tool tip has been -
2043 set. -
2044 -
2045 \sa setToolTip(), QToolTip -
2046*/ -
2047QString QGraphicsItem::toolTip() const -
2048{ -
2049 return d_ptr->extra(QGraphicsItemPrivate::ExtraToolTip).toString();
never executed: return d_ptr->extra(QGraphicsItemPrivate::ExtraToolTip).toString();
0
2050} -
2051 -
2052/*! -
2053 Sets the item's tool tip to \a toolTip. If \a toolTip is empty, the item's -
2054 tool tip is cleared. -
2055 -
2056 \sa toolTip(), QToolTip -
2057*/ -
2058void QGraphicsItem::setToolTip(const QString &toolTip) -
2059{ -
2060 const QVariant toolTipVariant(itemChange(ItemToolTipChange, toolTip));
executed (the execution status of this line is deduced): const QVariant toolTipVariant(itemChange(ItemToolTipChange, toolTip));
-
2061 d_ptr->setExtra(QGraphicsItemPrivate::ExtraToolTip, toolTipVariant.toString());
executed (the execution status of this line is deduced): d_ptr->setExtra(QGraphicsItemPrivate::ExtraToolTip, toolTipVariant.toString());
-
2062 itemChange(ItemToolTipHasChanged, toolTipVariant);
executed (the execution status of this line is deduced): itemChange(ItemToolTipHasChanged, toolTipVariant);
-
2063}
executed: }
Execution Count:52
52
2064#endif // QT_NO_TOOLTIP -
2065 -
2066#ifndef QT_NO_CURSOR -
2067/*! -
2068 Returns the current cursor shape for the item. The mouse cursor -
2069 will assume this shape when it's over this item. -
2070 See the \l{Qt::CursorShape}{list of predefined cursor objects} for a -
2071 range of useful shapes. -
2072 -
2073 An editor item might want to use an I-beam cursor: -
2074 -
2075 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 2 -
2076 -
2077 If no cursor has been set, the cursor of the item beneath is used. -
2078 -
2079 \sa setCursor(), hasCursor(), unsetCursor(), QWidget::cursor, -
2080 QApplication::overrideCursor() -
2081*/ -
2082QCursor QGraphicsItem::cursor() const -
2083{ -
2084 return qvariant_cast<QCursor>(d_ptr->extra(QGraphicsItemPrivate::ExtraCursor));
executed: return qvariant_cast<QCursor>(d_ptr->extra(QGraphicsItemPrivate::ExtraCursor));
Execution Count:21
21
2085} -
2086 -
2087/*! -
2088 Sets the current cursor shape for the item to \a cursor. The mouse cursor -
2089 will assume this shape when it's over this item. -
2090 See the \l{Qt::CursorShape}{list of predefined cursor objects} for a -
2091 range of useful shapes. -
2092 -
2093 An editor item might want to use an I-beam cursor: -
2094 -
2095 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 3 -
2096 -
2097 If no cursor has been set, the cursor of the item beneath is used. -
2098 -
2099 \sa cursor(), hasCursor(), unsetCursor(), QWidget::cursor, -
2100 QApplication::overrideCursor() -
2101*/ -
2102void QGraphicsItem::setCursor(const QCursor &cursor) -
2103{ -
2104 const QVariant cursorVariant(itemChange(ItemCursorChange, QVariant::fromValue<QCursor>(cursor)));
executed (the execution status of this line is deduced): const QVariant cursorVariant(itemChange(ItemCursorChange, QVariant::fromValue<QCursor>(cursor)));
-
2105 d_ptr->setExtra(QGraphicsItemPrivate::ExtraCursor, qvariant_cast<QCursor>(cursorVariant));
executed (the execution status of this line is deduced): d_ptr->setExtra(QGraphicsItemPrivate::ExtraCursor, qvariant_cast<QCursor>(cursorVariant));
-
2106 d_ptr->hasCursor = 1;
executed (the execution status of this line is deduced): d_ptr->hasCursor = 1;
-
2107 if (d_ptr->scene) {
evaluated: d_ptr->scene
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:4
3-4
2108 d_ptr->scene->d_func()->allItemsUseDefaultCursor = false;
executed (the execution status of this line is deduced): d_ptr->scene->d_func()->allItemsUseDefaultCursor = false;
-
2109 foreach (QGraphicsView *view, d_ptr->scene->views()) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(d_ptr->scene->views())> _container_(d_ptr->scene->views()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsView *view = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
2110 view->viewport()->setMouseTracking(true);
executed (the execution status of this line is deduced): view->viewport()->setMouseTracking(true);
-
2111 // Note: Some of this logic is duplicated in QGraphicsView's mouse events. -
2112 if (view->underMouse()) {
partially evaluated: view->underMouse()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
2113 foreach (QGraphicsItem *itemUnderCursor, view->items(view->mapFromGlobal(QCursor::pos()))) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(view->items(view->mapFromGlobal(QCursor::pos())))> _container_(view->items(view->mapFromGlobal(QCursor::pos()))); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *itemUnderCursor = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
2114 if (itemUnderCursor->hasCursor()) {
partially evaluated: itemUnderCursor->hasCursor()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
2115 QMetaObject::invokeMethod(view, "_q_setViewportCursor",
executed (the execution status of this line is deduced): QMetaObject::invokeMethod(view, "_q_setViewportCursor",
-
2116 Q_ARG(QCursor, itemUnderCursor->cursor()));
executed (the execution status of this line is deduced): QArgument<QCursor >("QCursor", itemUnderCursor->cursor()));
-
2117 break;
executed: break;
Execution Count:1
1
2118 } -
2119 }
never executed: }
0
2120 break;
executed: break;
Execution Count:1
1
2121 } -
2122 }
never executed: }
0
2123 }
executed: }
Execution Count:3
3
2124 itemChange(ItemCursorHasChanged, cursorVariant);
executed (the execution status of this line is deduced): itemChange(ItemCursorHasChanged, cursorVariant);
-
2125}
executed: }
Execution Count:7
7
2126 -
2127/*! -
2128 Returns true if this item has a cursor set; otherwise, false is returned. -
2129 -
2130 By default, items don't have any cursor set. cursor() will return a -
2131 standard pointing arrow cursor. -
2132 -
2133 \sa unsetCursor() -
2134*/ -
2135bool QGraphicsItem::hasCursor() const -
2136{ -
2137 return d_ptr->hasCursor;
executed: return d_ptr->hasCursor;
Execution Count:26
26
2138} -
2139 -
2140/*! -
2141 Clears the cursor from this item. -
2142 -
2143 \sa hasCursor(), setCursor() -
2144*/ -
2145void QGraphicsItem::unsetCursor() -
2146{ -
2147 if (!d_ptr->hasCursor)
never evaluated: !d_ptr->hasCursor
0
2148 return;
never executed: return;
0
2149 d_ptr->unsetExtra(QGraphicsItemPrivate::ExtraCursor);
never executed (the execution status of this line is deduced): d_ptr->unsetExtra(QGraphicsItemPrivate::ExtraCursor);
-
2150 d_ptr->hasCursor = 0;
never executed (the execution status of this line is deduced): d_ptr->hasCursor = 0;
-
2151 if (d_ptr->scene) {
never evaluated: d_ptr->scene
0
2152 foreach (QGraphicsView *view, d_ptr->scene->views()) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(d_ptr->scene->views())> _container_(d_ptr->scene->views()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsView *view = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
2153 if (view->underMouse() && view->itemAt(view->mapFromGlobal(QCursor::pos())) == this) {
never evaluated: view->underMouse()
never evaluated: view->itemAt(view->mapFromGlobal(QCursor::pos())) == this
0
2154 QMetaObject::invokeMethod(view, "_q_unsetViewportCursor");
never executed (the execution status of this line is deduced): QMetaObject::invokeMethod(view, "_q_unsetViewportCursor");
-
2155 break;
never executed: break;
0
2156 } -
2157 }
never executed: }
0
2158 }
never executed: }
0
2159}
never executed: }
0
2160 -
2161#endif // QT_NO_CURSOR -
2162 -
2163/*! -
2164 Returns true if the item is visible; otherwise, false is returned. -
2165 -
2166 Note that the item's general visibility is unrelated to whether or not it -
2167 is actually being visualized by a QGraphicsView. -
2168 -
2169 \sa setVisible() -
2170*/ -
2171bool QGraphicsItem::isVisible() const -
2172{ -
2173 return d_ptr->visible;
executed: return d_ptr->visible;
Execution Count:1746
1746
2174} -
2175 -
2176/*! -
2177 \since 4.4 -
2178 Returns true if the item is visible to \a parent; otherwise, false is -
2179 returned. \a parent can be 0, in which case this function will return -
2180 whether the item is visible to the scene or not. -
2181 -
2182 An item may not be visible to its ancestors even if isVisible() is true. It -
2183 may also be visible to its ancestors even if isVisible() is false. If -
2184 any ancestor is hidden, the item itself will be implicitly hidden, in which -
2185 case this function will return false. -
2186 -
2187 \sa isVisible(), setVisible() -
2188*/ -
2189bool QGraphicsItem::isVisibleTo(const QGraphicsItem *parent) const -
2190{ -
2191 const QGraphicsItem *p = this;
never executed (the execution status of this line is deduced): const QGraphicsItem *p = this;
-
2192 if (d_ptr->explicitlyHidden)
never evaluated: d_ptr->explicitlyHidden
0
2193 return false;
never executed: return false;
0
2194 do { -
2195 if (p == parent)
never evaluated: p == parent
0
2196 return true;
never executed: return true;
0
2197 if (p->d_ptr->explicitlyHidden)
never evaluated: p->d_ptr->explicitlyHidden
0
2198 return false;
never executed: return false;
0
2199 } while ((p = p->d_ptr->parent));
never executed: }
never evaluated: (p = p->d_ptr->parent)
0
2200 return parent == 0;
never executed: return parent == 0;
0
2201} -
2202 -
2203/*! -
2204 \internal -
2205 -
2206 Sets this item's visibility to \a newVisible. If \a explicitly is true, -
2207 this item will be "explicitly" \a newVisible; otherwise, it.. will not be. -
2208*/ -
2209void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, -
2210 bool update, bool hiddenByPanel) -
2211{ -
2212 Q_Q(QGraphicsItem);
executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func();
-
2213 -
2214 // Update explicit bit. -
2215 if (explicitly)
evaluated: explicitly
TRUEFALSE
yes
Evaluation Count:150
yes
Evaluation Count:2
2-150
2216 explicitlyHidden = newVisible ? 0 : 1;
executed: explicitlyHidden = newVisible ? 0 : 1;
Execution Count:150
evaluated: newVisible
TRUEFALSE
yes
Evaluation Count:142
yes
Evaluation Count:8
8-150
2217 -
2218 // Check if there's nothing to do. -
2219 if (visible == quint32(newVisible))
evaluated: visible == quint32(newVisible)
TRUEFALSE
yes
Evaluation Count:140
yes
Evaluation Count:12
12-140
2220 return;
executed: return;
Execution Count:140
140
2221 -
2222 // Don't show child if parent is not visible -
2223 if (parent && newVisible && !parent->d_ptr->visible)
evaluated: parent
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:6
evaluated: newVisible
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:4
partially evaluated: !parent->d_ptr->visible
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-6
2224 return;
never executed: return;
0
2225 -
2226 // Modify the property. -
2227 const QVariant newVisibleVariant(q_ptr->itemChange(QGraphicsItem::ItemVisibleChange,
executed (the execution status of this line is deduced): const QVariant newVisibleVariant(q_ptr->itemChange(QGraphicsItem::ItemVisibleChange,
-
2228 quint32(newVisible)));
executed (the execution status of this line is deduced): quint32(newVisible)));
-
2229 newVisible = newVisibleVariant.toBool();
executed (the execution status of this line is deduced): newVisible = newVisibleVariant.toBool();
-
2230 if (visible == quint32(newVisible))
partially evaluated: visible == quint32(newVisible)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
2231 return;
never executed: return;
0
2232 visible = newVisible;
executed (the execution status of this line is deduced): visible = newVisible;
-
2233 -
2234 // Schedule redrawing -
2235 if (update) {
partially evaluated: update
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
2236 QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
executed (the execution status of this line is deduced): QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
-
2237 if (c)
partially evaluated: c
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
2238 c->purge();
never executed: c->purge();
0
2239 if (scene) {
evaluated: scene
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:3
3-9
2240#ifndef QT_NO_GRAPHICSEFFECT -
2241 invalidateParentGraphicsEffectsRecursively();
executed (the execution status of this line is deduced): invalidateParentGraphicsEffectsRecursively();
-
2242#endif //QT_NO_GRAPHICSEFFECT -
2243 scene->d_func()->markDirty(q_ptr, QRectF(), /*invalidateChildren=*/false, /*force=*/true);
executed (the execution status of this line is deduced): scene->d_func()->markDirty(q_ptr, QRectF(), false, true);
-
2244 }
executed: }
Execution Count:9
9
2245 }
executed: }
Execution Count:12
12
2246 -
2247 // Certain properties are dropped as an item becomes invisible. -
2248 bool hasFocus = q_ptr->hasFocus();
executed (the execution status of this line is deduced): bool hasFocus = q_ptr->hasFocus();
-
2249 if (!newVisible) {
evaluated: !newVisible
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:4
4-8
2250 if (scene) {
evaluated: scene
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2
2-6
2251 if (scene->d_func()->mouseGrabberItems.contains(q))
partially evaluated: scene->d_func()->mouseGrabberItems.contains(q)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
2252 q->ungrabMouse();
never executed: q->ungrabMouse();
0
2253 if (scene->d_func()->keyboardGrabberItems.contains(q))
partially evaluated: scene->d_func()->keyboardGrabberItems.contains(q)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
2254 q->ungrabKeyboard();
never executed: q->ungrabKeyboard();
0
2255 if (q->isPanel() && panelModality != QGraphicsItem::NonModal)
partially evaluated: q->isPanel()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
never evaluated: panelModality != QGraphicsItem::NonModal
0-6
2256 scene->d_func()->leaveModal(q_ptr);
never executed: scene->d_func()->leaveModal(q_ptr);
0
2257 }
executed: }
Execution Count:6
6
2258 if (hasFocus && scene) {
partially evaluated: hasFocus
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
never evaluated: scene
0-8
2259 // Hiding the closest non-panel ancestor of the focus item -
2260 QGraphicsItem *focusItem = scene->focusItem();
never executed (the execution status of this line is deduced): QGraphicsItem *focusItem = scene->focusItem();
-
2261 bool clear = true;
never executed (the execution status of this line is deduced): bool clear = true;
-
2262 if (isWidget && !focusItem->isPanel()) {
never evaluated: isWidget
never evaluated: !focusItem->isPanel()
0
2263 do { -
2264 if (focusItem == q_ptr) {
never evaluated: focusItem == q_ptr
0
2265 clear = !static_cast<QGraphicsWidget *>(q_ptr)->focusNextPrevChild(true);
never executed (the execution status of this line is deduced): clear = !static_cast<QGraphicsWidget *>(q_ptr)->focusNextPrevChild(true);
-
2266 break;
never executed: break;
0
2267 } -
2268 } while ((focusItem = focusItem->parentWidget()) && !focusItem->isPanel());
never executed: }
never evaluated: (focusItem = focusItem->parentWidget())
never evaluated: !focusItem->isPanel()
0
2269 }
never executed: }
0
2270 if (clear)
never evaluated: clear
0
2271 clearFocusHelper(/* giveFocusToParent = */ false, hiddenByPanel);
never executed: clearFocusHelper( false, hiddenByPanel);
0
2272 }
never executed: }
0
2273 if (q_ptr->isSelected())
partially evaluated: q_ptr->isSelected()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
2274 q_ptr->setSelected(false);
never executed: q_ptr->setSelected(false);
0
2275 } else {
executed: }
Execution Count:8
8
2276 geometryChanged = 1;
executed (the execution status of this line is deduced): geometryChanged = 1;
-
2277 paintedViewBoundingRectsNeedRepaint = 1;
executed (the execution status of this line is deduced): paintedViewBoundingRectsNeedRepaint = 1;
-
2278 if (scene) {
evaluated: scene
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:1
1-3
2279 if (isWidget) {
partially evaluated: isWidget
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2280 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(q_ptr);
executed (the execution status of this line is deduced): QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(q_ptr);
-
2281 if (widget->windowType() == Qt::Popup)
partially evaluated: widget->windowType() == Qt::Popup
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
2282 scene->d_func()->addPopup(widget);
never executed: scene->d_func()->addPopup(widget);
0
2283 }
executed: }
Execution Count:3
3
2284 if (q->isPanel() && panelModality != QGraphicsItem::NonModal) {
partially evaluated: q->isPanel()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
never evaluated: panelModality != QGraphicsItem::NonModal
0-3
2285 scene->d_func()->enterModal(q_ptr);
never executed (the execution status of this line is deduced): scene->d_func()->enterModal(q_ptr);
-
2286 }
never executed: }
0
2287 }
executed: }
Execution Count:3
3
2288 }
executed: }
Execution Count:4
4
2289 -
2290 // Update children with explicitly = false. -
2291 const bool updateChildren = update && !((flags & QGraphicsItem::ItemClipsChildrenToShape)
partially evaluated: update
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
partially evaluated: (flags & QGraphicsItem::ItemClipsChildrenToShape)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
2292 && !(flags & QGraphicsItem::ItemHasNoContents));
never evaluated: !(flags & QGraphicsItem::ItemHasNoContents)
0
2293 foreach (QGraphicsItem *child, children) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(children)> _container_(children); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *child = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
2294 if (!newVisible || !child->d_ptr->explicitlyHidden)
evaluated: !newVisible
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
partially evaluated: !child->d_ptr->explicitlyHidden
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
2295 child->d_ptr->setVisibleHelper(newVisible, false, updateChildren, hiddenByPanel);
executed: child->d_ptr->setVisibleHelper(newVisible, false, updateChildren, hiddenByPanel);
Execution Count:2
2
2296 }
executed: }
Execution Count:2
2
2297 -
2298 // Update activation -
2299 if (scene && q->isPanel()) {
evaluated: scene
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:3
partially evaluated: q->isPanel()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
2300 if (newVisible) {
never evaluated: newVisible
0
2301 if (parent && parent->isActive())
never evaluated: parent
never evaluated: parent->isActive()
0
2302 q->setActive(true);
never executed: q->setActive(true);
0
2303 } else {
never executed: }
0
2304 if (q->isActive())
never evaluated: q->isActive()
0
2305 scene->setActivePanel(parent);
never executed: scene->setActivePanel(parent);
0
2306 }
never executed: }
0
2307 } -
2308 -
2309 // Enable subfocus -
2310 if (scene) {
evaluated: scene
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:3
3-9
2311 if (newVisible) {
evaluated: newVisible
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:6
3-6
2312 // Item is shown -
2313 QGraphicsItem *p = parent;
executed (the execution status of this line is deduced): QGraphicsItem *p = parent;
-
2314 bool done = false;
executed (the execution status of this line is deduced): bool done = false;
-
2315 while (p) {
evaluated: p
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:3
2-3
2316 if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
partially evaluated: p->flags() & QGraphicsItem::ItemIsFocusScope
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
2317 QGraphicsItem *fsi = p->d_ptr->focusScopeItem;
never executed (the execution status of this line is deduced): QGraphicsItem *fsi = p->d_ptr->focusScopeItem;
-
2318 if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) {
never evaluated: q_ptr == fsi
never evaluated: q_ptr->isAncestorOf(fsi)
0
2319 done = true;
never executed (the execution status of this line is deduced): done = true;
-
2320 while (fsi->d_ptr->focusScopeItem && fsi->d_ptr->focusScopeItem->isVisible())
never evaluated: fsi->d_ptr->focusScopeItem
never evaluated: fsi->d_ptr->focusScopeItem->isVisible()
0
2321 fsi = fsi->d_ptr->focusScopeItem;
never executed: fsi = fsi->d_ptr->focusScopeItem;
0
2322 fsi->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ true,
never executed (the execution status of this line is deduced): fsi->d_ptr->setFocusHelper(Qt::OtherFocusReason, true,
-
2323 /* focusFromHide = */ false);
never executed (the execution status of this line is deduced): false);
-
2324 }
never executed: }
0
2325 break;
never executed: break;
0
2326 } -
2327 p = p->d_ptr->parent;
executed (the execution status of this line is deduced): p = p->d_ptr->parent;
-
2328 }
executed: }
Execution Count:2
2
2329 if (!done) {
partially evaluated: !done
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
2330 QGraphicsItem *fi = subFocusItem;
executed (the execution status of this line is deduced): QGraphicsItem *fi = subFocusItem;
-
2331 if (fi && fi != scene->focusItem()) {
partially evaluated: fi
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
never evaluated: fi != scene->focusItem()
0-3
2332 scene->setFocusItem(fi);
never executed (the execution status of this line is deduced): scene->setFocusItem(fi);
-
2333 } else if (flags & QGraphicsItem::ItemIsFocusScope &&
never executed: }
partially evaluated: flags & QGraphicsItem::ItemIsFocusScope
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
2334 !scene->focusItem() &&
never evaluated: !scene->focusItem()
0
2335 q->isAncestorOf(scene->d_func()->lastFocusItem)) {
never evaluated: q->isAncestorOf(scene->d_func()->lastFocusItem)
0
2336 q_ptr->setFocus();
never executed (the execution status of this line is deduced): q_ptr->setFocus();
-
2337 }
never executed: }
0
2338 } -
2339 } else {
executed: }
Execution Count:3
3
2340 // Item is hidden -
2341 if (hasFocus) {
partially evaluated: hasFocus
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
2342 QGraphicsItem *p = parent;
never executed (the execution status of this line is deduced): QGraphicsItem *p = parent;
-
2343 while (p) {
never evaluated: p
0
2344 if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
never evaluated: p->flags() & QGraphicsItem::ItemIsFocusScope
0
2345 if (p->d_ptr->visible) {
never evaluated: p->d_ptr->visible
0
2346 p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ true,
never executed (the execution status of this line is deduced): p->d_ptr->setFocusHelper(Qt::OtherFocusReason, true,
-
2347 /* focusFromHide = */ true);
never executed (the execution status of this line is deduced): true);
-
2348 }
never executed: }
0
2349 break;
never executed: break;
0
2350 } -
2351 p = p->d_ptr->parent;
never executed (the execution status of this line is deduced): p = p->d_ptr->parent;
-
2352 }
never executed: }
0
2353 }
never executed: }
0
2354 }
executed: }
Execution Count:6
6
2355 } -
2356 -
2357 // Deliver post-change notification. -
2358 q_ptr->itemChange(QGraphicsItem::ItemVisibleHasChanged, newVisibleVariant);
executed (the execution status of this line is deduced): q_ptr->itemChange(QGraphicsItem::ItemVisibleHasChanged, newVisibleVariant);
-
2359 -
2360 if (isObject)
partially evaluated: isObject
TRUEFALSE
yes
Evaluation Count:12
no
Evaluation Count:0
0-12
2361 emit static_cast<QGraphicsObject *>(q_ptr)->visibleChanged();
executed: static_cast<QGraphicsObject *>(q_ptr)->visibleChanged();
Execution Count:12
12
2362}
executed: }
Execution Count:12
12
2363 -
2364/*! -
2365 If \a visible is true, the item is made visible. Otherwise, the item is -
2366 made invisible. Invisible items are not painted, nor do they receive any -
2367 events. In particular, mouse events pass right through invisible items, -
2368 and are delivered to any item that may be behind. Invisible items are also -
2369 unselectable, they cannot take input focus, and are not detected by -
2370 QGraphicsScene's item location functions. -
2371 -
2372 If an item becomes invisible while grabbing the mouse, (i.e., while it is -
2373 receiving mouse events,) it will automatically lose the mouse grab, and -
2374 the grab is not regained by making the item visible again; it must receive -
2375 a new mouse press to regain the mouse grab. -
2376 -
2377 Similarly, an invisible item cannot have focus, so if the item has focus -
2378 when it becomes invisible, it will lose focus, and the focus is not -
2379 regained by simply making the item visible again. -
2380 -
2381 If you hide a parent item, all its children will also be hidden. If you -
2382 show a parent item, all children will be shown, unless they have been -
2383 explicitly hidden (i.e., if you call setVisible(false) on a child, it will -
2384 not be reshown even if its parent is hidden, and then shown again). -
2385 -
2386 Items are visible by default; it is unnecessary to call -
2387 setVisible() on a new item. -
2388 -
2389 \sa isVisible(), show(), hide() -
2390*/ -
2391void QGraphicsItem::setVisible(bool visible) -
2392{ -
2393 d_ptr->setVisibleHelper(visible,
executed (the execution status of this line is deduced): d_ptr->setVisibleHelper(visible,
-
2394 /* explicit = */ true,
executed (the execution status of this line is deduced): true,
-
2395 /* update = */ true,
executed (the execution status of this line is deduced): true,
-
2396 /* hiddenByPanel = */ isPanel());
executed (the execution status of this line is deduced): isPanel());
-
2397}
executed: }
Execution Count:150
150
2398 -
2399/*! -
2400 \fn void QGraphicsItem::hide() -
2401 -
2402 Hides the item (items are visible by default). -
2403 -
2404 This convenience function is equivalent to calling \c setVisible(false). -
2405 -
2406 \sa show(), setVisible() -
2407*/ -
2408 -
2409/*! -
2410 \fn void QGraphicsItem::show() -
2411 -
2412 Shows the item (items are visible by default). -
2413 -
2414 This convenience function is equivalent to calling \c setVisible(true). -
2415 -
2416 \sa hide(), setVisible() -
2417*/ -
2418 -
2419/*! -
2420 Returns true if the item is enabled; otherwise, false is returned. -
2421 -
2422 \sa setEnabled() -
2423*/ -
2424bool QGraphicsItem::isEnabled() const -
2425{ -
2426 return d_ptr->enabled;
executed: return d_ptr->enabled;
Execution Count:2924
2924
2427} -
2428 -
2429/*! -
2430 \internal -
2431 -
2432 Sets this item's visibility to \a newEnabled. If \a explicitly is true, -
2433 this item will be "explicitly" \a newEnabled; otherwise, it.. will not be. -
2434*/ -
2435void QGraphicsItemPrivate::setEnabledHelper(bool newEnabled, bool explicitly, bool update) -
2436{ -
2437 // Update explicit bit. -
2438 if (explicitly)
partially evaluated: explicitly
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
2439 explicitlyDisabled = newEnabled ? 0 : 1;
executed: explicitlyDisabled = newEnabled ? 0 : 1;
Execution Count:11
evaluated: newEnabled
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:2
2-11
2440 -
2441 // Check if there's nothing to do. -
2442 if (enabled == quint32(newEnabled))
evaluated: enabled == quint32(newEnabled)
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:2
2-9
2443 return;
executed: return;
Execution Count:9
9
2444 -
2445 // Certain properties are dropped when an item is disabled. -
2446 if (!newEnabled) {
evaluated: !newEnabled
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
2447 if (scene && scene->mouseGrabberItem() == q_ptr)
partially evaluated: scene
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
never evaluated: scene->mouseGrabberItem() == q_ptr
0-1
2448 q_ptr->ungrabMouse();
never executed: q_ptr->ungrabMouse();
0
2449 if (q_ptr->hasFocus()) {
partially evaluated: q_ptr->hasFocus()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
2450 // Disabling the closest non-panel ancestor of the focus item -
2451 // causes focus to pop to the next item, otherwise it's cleared. -
2452 QGraphicsItem *focusItem = scene->focusItem();
never executed (the execution status of this line is deduced): QGraphicsItem *focusItem = scene->focusItem();
-
2453 bool clear = true;
never executed (the execution status of this line is deduced): bool clear = true;
-
2454 if (isWidget && !focusItem->isPanel() && q_ptr->isAncestorOf(focusItem)) {
never evaluated: isWidget
never evaluated: !focusItem->isPanel()
never evaluated: q_ptr->isAncestorOf(focusItem)
0
2455 do { -
2456 if (focusItem == q_ptr) {
never evaluated: focusItem == q_ptr
0
2457 clear = !static_cast<QGraphicsWidget *>(q_ptr)->focusNextPrevChild(true);
never executed (the execution status of this line is deduced): clear = !static_cast<QGraphicsWidget *>(q_ptr)->focusNextPrevChild(true);
-
2458 break;
never executed: break;
0
2459 } -
2460 } while ((focusItem = focusItem->parentWidget()) && !focusItem->isPanel());
never executed: }
never evaluated: (focusItem = focusItem->parentWidget())
never evaluated: !focusItem->isPanel()
0
2461 }
never executed: }
0
2462 if (clear)
never evaluated: clear
0
2463 q_ptr->clearFocus();
never executed: q_ptr->clearFocus();
0
2464 }
never executed: }
0
2465 if (q_ptr->isSelected())
partially evaluated: q_ptr->isSelected()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
2466 q_ptr->setSelected(false);
never executed: q_ptr->setSelected(false);
0
2467 }
executed: }
Execution Count:1
1
2468 -
2469 // Modify the property. -
2470 const QVariant newEnabledVariant(q_ptr->itemChange(QGraphicsItem::ItemEnabledChange,
executed (the execution status of this line is deduced): const QVariant newEnabledVariant(q_ptr->itemChange(QGraphicsItem::ItemEnabledChange,
-
2471 quint32(newEnabled)));
executed (the execution status of this line is deduced): quint32(newEnabled)));
-
2472 enabled = newEnabledVariant.toBool();
executed (the execution status of this line is deduced): enabled = newEnabledVariant.toBool();
-
2473 -
2474 // Schedule redraw. -
2475 if (update)
partially evaluated: update
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
2476 q_ptr->update();
executed: q_ptr->update();
Execution Count:2
2
2477 -
2478 foreach (QGraphicsItem *child, children) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(children)> _container_(children); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *child = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
2479 if (!newEnabled || !child->d_ptr->explicitlyDisabled)
never evaluated: !newEnabled
never evaluated: !child->d_ptr->explicitlyDisabled
0
2480 child->d_ptr->setEnabledHelper(newEnabled, /* explicitly = */ false);
never executed: child->d_ptr->setEnabledHelper(newEnabled, false);
0
2481 }
never executed: }
0
2482 -
2483 // Deliver post-change notification. -
2484 q_ptr->itemChange(QGraphicsItem::ItemEnabledHasChanged, newEnabledVariant);
executed (the execution status of this line is deduced): q_ptr->itemChange(QGraphicsItem::ItemEnabledHasChanged, newEnabledVariant);
-
2485 -
2486 if (isObject)
partially evaluated: isObject
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
2487 emit static_cast<QGraphicsObject *>(q_ptr)->enabledChanged();
executed: static_cast<QGraphicsObject *>(q_ptr)->enabledChanged();
Execution Count:2
2
2488}
executed: }
Execution Count:2
2
2489 -
2490/*! -
2491 If \a enabled is true, the item is enabled; otherwise, it is disabled. -
2492 -
2493 Disabled items are visible, but they do not receive any events, and cannot -
2494 take focus nor be selected. Mouse events are discarded; they are not -
2495 propagated unless the item is also invisible, or if it does not accept -
2496 mouse events (see acceptedMouseButtons()). A disabled item cannot become the -
2497 mouse grabber, and as a result of this, an item loses the grab if it -
2498 becomes disabled when grabbing the mouse, just like it loses focus if it -
2499 had focus when it was disabled. -
2500 -
2501 Disabled items are traditionally drawn using grayed-out colors (see \l -
2502 QPalette::Disabled). -
2503 -
2504 If you disable a parent item, all its children will also be disabled. If -
2505 you enable a parent item, all children will be enabled, unless they have -
2506 been explicitly disabled (i.e., if you call setEnabled(false) on a child, -
2507 it will not be reenabled if its parent is disabled, and then enabled -
2508 again). -
2509 -
2510 Items are enabled by default. -
2511 -
2512 \note If you install an event filter, you can still intercept events -
2513 before they are delivered to items; this mechanism disregards the item's -
2514 enabled state. -
2515 -
2516 \sa isEnabled() -
2517*/ -
2518void QGraphicsItem::setEnabled(bool enabled) -
2519{ -
2520 d_ptr->setEnabledHelper(enabled, /* explicitly = */ true);
executed (the execution status of this line is deduced): d_ptr->setEnabledHelper(enabled, true);
-
2521}
executed: }
Execution Count:11
11
2522 -
2523/*! -
2524 Returns true if this item is selected; otherwise, false is returned. -
2525 -
2526 Items that are in a group inherit the group's selected state. -
2527 -
2528 Items are not selected by default. -
2529 -
2530 \sa setSelected(), QGraphicsScene::setSelectionArea() -
2531*/ -
2532bool QGraphicsItem::isSelected() const -
2533{ -
2534 if (QGraphicsItemGroup *group = this->group())
partially evaluated: QGraphicsItemGroup *group = this->group()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1959
0-1959
2535 return group->isSelected();
never executed: return group->isSelected();
0
2536 return d_ptr->selected;
executed: return d_ptr->selected;
Execution Count:1959
1959
2537} -
2538 -
2539/*! -
2540 If \a selected is true and this item is selectable, this item is selected; -
2541 otherwise, it is unselected. -
2542 -
2543 If the item is in a group, the whole group's selected state is toggled by -
2544 this function. If the group is selected, all items in the group are also -
2545 selected, and if the group is not selected, no item in the group is -
2546 selected. -
2547 -
2548 Only visible, enabled, selectable items can be selected. If \a selected -
2549 is true and this item is either invisible or disabled or unselectable, -
2550 this function does nothing. -
2551 -
2552 By default, items cannot be selected. To enable selection, set the -
2553 ItemIsSelectable flag. -
2554 -
2555 This function is provided for convenience, allowing individual toggling of -
2556 the selected state of an item. However, a more common way of selecting -
2557 items is to call QGraphicsScene::setSelectionArea(), which will call this -
2558 function for all visible, enabled, and selectable items within a specified -
2559 area on the scene. -
2560 -
2561 \sa isSelected(), QGraphicsScene::selectedItems() -
2562*/ -
2563void QGraphicsItem::setSelected(bool selected) -
2564{ -
2565 if (QGraphicsItemGroup *group = this->group()) {
partially evaluated: QGraphicsItemGroup *group = this->group()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
2566 group->setSelected(selected);
never executed (the execution status of this line is deduced): group->setSelected(selected);
-
2567 return;
never executed: return;
0
2568 } -
2569 -
2570 if (!(d_ptr->flags & ItemIsSelectable) || !d_ptr->enabled || !d_ptr->visible)
partially evaluated: !(d_ptr->flags & ItemIsSelectable)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
partially evaluated: !d_ptr->enabled
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
partially evaluated: !d_ptr->visible
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
2571 selected = false;
never executed: selected = false;
0
2572 if (d_ptr->selected == selected)
partially evaluated: d_ptr->selected == selected
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
2573 return;
never executed: return;
0
2574 const QVariant newSelectedVariant(itemChange(ItemSelectedChange, quint32(selected)));
executed (the execution status of this line is deduced): const QVariant newSelectedVariant(itemChange(ItemSelectedChange, quint32(selected)));
-
2575 bool newSelected = newSelectedVariant.toBool();
executed (the execution status of this line is deduced): bool newSelected = newSelectedVariant.toBool();
-
2576 if (d_ptr->selected == newSelected)
partially evaluated: d_ptr->selected == newSelected
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
2577 return;
never executed: return;
0
2578 d_ptr->selected = newSelected;
executed (the execution status of this line is deduced): d_ptr->selected = newSelected;
-
2579 -
2580 update();
executed (the execution status of this line is deduced): update();
-
2581 if (d_ptr->scene) {
partially evaluated: d_ptr->scene
TRUEFALSE
yes
Evaluation Count:8
no
Evaluation Count:0
0-8
2582 QGraphicsScenePrivate *sceneD = d_ptr->scene->d_func();
executed (the execution status of this line is deduced): QGraphicsScenePrivate *sceneD = d_ptr->scene->d_func();
-
2583 if (selected) {
evaluated: selected
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:2
2-6
2584 sceneD->selectedItems << this;
executed (the execution status of this line is deduced): sceneD->selectedItems << this;
-
2585 } else {
executed: }
Execution Count:6
6
2586 // QGraphicsScene::selectedItems() lazily pulls out all items that are -
2587 // no longer selected. -
2588 }
executed: }
Execution Count:2
2
2589 if (!sceneD->selectionChanging)
evaluated: !sceneD->selectionChanging
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:5
3-5
2590 emit d_ptr->scene->selectionChanged();
executed: d_ptr->scene->selectionChanged();
Execution Count:3
3
2591 }
executed: }
Execution Count:8
8
2592 -
2593 // Deliver post-change notification. -
2594 itemChange(QGraphicsItem::ItemSelectedHasChanged, newSelectedVariant);
executed (the execution status of this line is deduced): itemChange(QGraphicsItem::ItemSelectedHasChanged, newSelectedVariant);
-
2595}
executed: }
Execution Count:8
8
2596 -
2597/*! -
2598 \since 4.5 -
2599 -
2600 Returns this item's local opacity, which is between 0.0 (transparent) and -
2601 1.0 (opaque). This value is combined with parent and ancestor values into -
2602 the effectiveOpacity(). The effective opacity decides how the item is -
2603 rendered and also affects its visibility when queried by functions such as -
2604 QGraphicsView::items(). -
2605 -
2606 The opacity property decides the state of the painter passed to the -
2607 paint() function. If the item is cached, i.e., ItemCoordinateCache or -
2608 DeviceCoordinateCache, the effective property will be applied to the item's -
2609 cache as it is rendered. -
2610 -
2611 The default opacity is 1.0; fully opaque. -
2612 -
2613 \sa setOpacity(), paint(), ItemIgnoresParentOpacity, -
2614 ItemDoesntPropagateOpacityToChildren -
2615*/ -
2616qreal QGraphicsItem::opacity() const -
2617{ -
2618 return d_ptr->opacity;
executed: return d_ptr->opacity;
Execution Count:3
3
2619} -
2620 -
2621/*! -
2622 \since 4.5 -
2623 -
2624 Returns this item's \e effective opacity, which is between 0.0 -
2625 (transparent) and 1.0 (opaque). This value is a combination of this item's -
2626 local opacity, and its parent and ancestors' opacities. The effective -
2627 opacity decides how the item is rendered. -
2628 -
2629 \sa opacity(), setOpacity(), paint(), ItemIgnoresParentOpacity, -
2630 ItemDoesntPropagateOpacityToChildren -
2631*/ -
2632qreal QGraphicsItem::effectiveOpacity() const -
2633{ -
2634 return d_ptr->effectiveOpacity();
never executed: return d_ptr->effectiveOpacity();
0
2635} -
2636 -
2637/*! -
2638 \since 4.5 -
2639 -
2640 Sets this item's local \a opacity, between 0.0 (transparent) and 1.0 -
2641 (opaque). The item's local opacity is combined with parent and ancestor -
2642 opacities into the effectiveOpacity(). -
2643 -
2644 By default, opacity propagates from parent to child, so if a parent's -
2645 opacity is 0.5 and the child is also 0.5, the child's effective opacity -
2646 will be 0.25. -
2647 -
2648 The opacity property decides the state of the painter passed to the -
2649 paint() function. If the item is cached, i.e., ItemCoordinateCache or -
2650 DeviceCoordinateCache, the effective property will be applied to the -
2651 item's cache as it is rendered. -
2652 -
2653 There are two item flags that affect how the item's opacity is combined -
2654 with the parent: ItemIgnoresParentOpacity and -
2655 ItemDoesntPropagateOpacityToChildren. -
2656 -
2657 \sa opacity(), effectiveOpacity() -
2658*/ -
2659void QGraphicsItem::setOpacity(qreal opacity) -
2660{ -
2661 // Notify change. -
2662 const QVariant newOpacityVariant(itemChange(ItemOpacityChange, opacity));
executed (the execution status of this line is deduced): const QVariant newOpacityVariant(itemChange(ItemOpacityChange, opacity));
-
2663 -
2664 // Normalized opacity -
2665 qreal newOpacity = qBound(qreal(0), newOpacityVariant.toReal(), qreal(1));
executed (the execution status of this line is deduced): qreal newOpacity = qBound(qreal(0), newOpacityVariant.toReal(), qreal(1));
-
2666 -
2667 // No change? Done. -
2668 if (newOpacity == d_ptr->opacity)
evaluated: newOpacity == d_ptr->opacity
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:13
1-13
2669 return;
executed: return;
Execution Count:1
1
2670 -
2671 bool wasFullyTransparent = d_ptr->isOpacityNull();
executed (the execution status of this line is deduced): bool wasFullyTransparent = d_ptr->isOpacityNull();
-
2672 d_ptr->opacity = newOpacity;
executed (the execution status of this line is deduced): d_ptr->opacity = newOpacity;
-
2673 -
2674 // Notify change. -
2675 itemChange(ItemOpacityHasChanged, newOpacityVariant);
executed (the execution status of this line is deduced): itemChange(ItemOpacityHasChanged, newOpacityVariant);
-
2676 -
2677 // Update. -
2678 if (d_ptr->scene) {
evaluated: d_ptr->scene
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:3
3-10
2679#ifndef QT_NO_GRAPHICSEFFECT -
2680 d_ptr->invalidateParentGraphicsEffectsRecursively();
executed (the execution status of this line is deduced): d_ptr->invalidateParentGraphicsEffectsRecursively();
-
2681 if (!(d_ptr->flags & ItemDoesntPropagateOpacityToChildren))
partially evaluated: !(d_ptr->flags & ItemDoesntPropagateOpacityToChildren)
TRUEFALSE
yes
Evaluation Count:10
no
Evaluation Count:0
0-10
2682 d_ptr->invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::OpacityChanged);
executed: d_ptr->invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::OpacityChanged);
Execution Count:10
10
2683#endif //QT_NO_GRAPHICSEFFECT -
2684 d_ptr->scene->d_func()->markDirty(this, QRectF(),
executed (the execution status of this line is deduced): d_ptr->scene->d_func()->markDirty(this, QRectF(),
-
2685 /*invalidateChildren=*/true,
executed (the execution status of this line is deduced): true,
-
2686 /*force=*/false,
executed (the execution status of this line is deduced): false,
-
2687 /*ignoreOpacity=*/d_ptr->isOpacityNull());
executed (the execution status of this line is deduced): d_ptr->isOpacityNull());
-
2688 if (wasFullyTransparent)
partially evaluated: wasFullyTransparent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:10
0-10
2689 d_ptr->paintedViewBoundingRectsNeedRepaint = 1;
never executed: d_ptr->paintedViewBoundingRectsNeedRepaint = 1;
0
2690 }
executed: }
Execution Count:10
10
2691 -
2692 if (d_ptr->isObject)
evaluated: d_ptr->isObject
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:11
2-11
2693 emit static_cast<QGraphicsObject *>(this)->opacityChanged();
executed: static_cast<QGraphicsObject *>(this)->opacityChanged();
Execution Count:2
2
2694}
executed: }
Execution Count:13
13
2695 -
2696/*! -
2697 Returns a pointer to this item's effect if it has one; otherwise 0. -
2698 -
2699 \since 4.6 -
2700*/ -
2701#ifndef QT_NO_GRAPHICSEFFECT -
2702QGraphicsEffect *QGraphicsItem::graphicsEffect() const -
2703{ -
2704 return d_ptr->graphicsEffect;
executed: return d_ptr->graphicsEffect;
Execution Count:16
16
2705} -
2706 -
2707/*! -
2708 Sets \a effect as the item's effect. If there already is an effect installed -
2709 on this item, QGraphicsItem will delete the existing effect before installing -
2710 the new \a effect. You can delete an existing effect by calling -
2711 setGraphicsEffect(0). -
2712 -
2713 If \a effect is the installed on a different item, setGraphicsEffect() will remove -
2714 the effect from the item and install it on this item. -
2715 -
2716 QGraphicsItem takes ownership of \a effect. -
2717 -
2718 \note This function will apply the effect on itself and all its children. -
2719 -
2720 \since 4.6 -
2721*/ -
2722void QGraphicsItem::setGraphicsEffect(QGraphicsEffect *effect) -
2723{ -
2724 if (d_ptr->graphicsEffect == effect)
partially evaluated: d_ptr->graphicsEffect == effect
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:26
0-26
2725 return;
never executed: return;
0
2726 -
2727 if (d_ptr->graphicsEffect) {
evaluated: d_ptr->graphicsEffect
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:22
4-22
2728 delete d_ptr->graphicsEffect;
executed (the execution status of this line is deduced): delete d_ptr->graphicsEffect;
-
2729 d_ptr->graphicsEffect = 0;
executed (the execution status of this line is deduced): d_ptr->graphicsEffect = 0;
-
2730 } else if (d_ptr->parent) {
executed: }
Execution Count:4
evaluated: d_ptr->parent
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:20
2-20
2731 d_ptr->parent->d_ptr->updateChildWithGraphicsEffectFlagRecursively();
executed (the execution status of this line is deduced): d_ptr->parent->d_ptr->updateChildWithGraphicsEffectFlagRecursively();
-
2732 }
executed: }
Execution Count:2
2
2733 -
2734 if (effect) {
evaluated: effect
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:4
4-22
2735 // Set new effect. -
2736 QGraphicsEffectSourcePrivate *sourced = new QGraphicsItemEffectSourcePrivate(this);
executed (the execution status of this line is deduced): QGraphicsEffectSourcePrivate *sourced = new QGraphicsItemEffectSourcePrivate(this);
-
2737 QGraphicsEffectSource *source = new QGraphicsEffectSource(*sourced);
executed (the execution status of this line is deduced): QGraphicsEffectSource *source = new QGraphicsEffectSource(*sourced);
-
2738 d_ptr->graphicsEffect = effect;
executed (the execution status of this line is deduced): d_ptr->graphicsEffect = effect;
-
2739 effect->d_func()->setGraphicsEffectSource(source);
executed (the execution status of this line is deduced): effect->d_func()->setGraphicsEffectSource(source);
-
2740 prepareGeometryChange();
executed (the execution status of this line is deduced): prepareGeometryChange();
-
2741 }
executed: }
Execution Count:22
22
2742}
executed: }
Execution Count:26
26
2743#endif //QT_NO_GRAPHICSEFFECT -
2744 -
2745void QGraphicsItemPrivate::updateChildWithGraphicsEffectFlagRecursively() -
2746{ -
2747#ifndef QT_NO_GRAPHICSEFFECT -
2748 QGraphicsItemPrivate *itemPrivate = this;
executed (the execution status of this line is deduced): QGraphicsItemPrivate *itemPrivate = this;
-
2749 do { -
2750 // parent chain already notified? -
2751 if (itemPrivate->mayHaveChildWithGraphicsEffect)
partially evaluated: itemPrivate->mayHaveChildWithGraphicsEffect
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
2752 return;
never executed: return;
0
2753 itemPrivate->mayHaveChildWithGraphicsEffect = 1;
executed (the execution status of this line is deduced): itemPrivate->mayHaveChildWithGraphicsEffect = 1;
-
2754 } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : 0));
executed: }
Execution Count:2
partially evaluated: itemPrivate->parent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
2755#endif -
2756}
executed: }
Execution Count:2
2
2757 -
2758/*! -
2759 \internal -
2760 \since 4.6 -
2761 Returns the effective bounding rect of the given item space rect. -
2762 If the item has no effect, the rect is returned unmodified. -
2763 If the item has an effect, the effective rect can be extend beyond the -
2764 item's bounding rect, depending on the effect. -
2765 -
2766 \sa boundingRect() -
2767*/ -
2768QRectF QGraphicsItemPrivate::effectiveBoundingRect(const QRectF &rect) const -
2769{ -
2770#ifndef QT_NO_GRAPHICSEFFECT -
2771 Q_Q(const QGraphicsItem);
executed (the execution status of this line is deduced): const QGraphicsItem * const q = q_func();
-
2772 QGraphicsEffect *effect = graphicsEffect;
executed (the execution status of this line is deduced): QGraphicsEffect *effect = graphicsEffect;
-
2773 if (scene && effect && effect->isEnabled()) {
evaluated: scene
TRUEFALSE
yes
Evaluation Count:5630
yes
Evaluation Count:4
evaluated: effect
TRUEFALSE
yes
Evaluation Count:107
yes
Evaluation Count:5523
evaluated: effect->isEnabled()
TRUEFALSE
yes
Evaluation Count:103
yes
Evaluation Count:4
4-5630
2774 if (scene->d_func()->views.isEmpty())
evaluated: scene->d_func()->views.isEmpty()
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:89
14-89
2775 return effect->boundingRectFor(rect);
executed: return effect->boundingRectFor(rect);
Execution Count:14
14
2776 QRectF sceneRect = q->mapRectToScene(rect);
executed (the execution status of this line is deduced): QRectF sceneRect = q->mapRectToScene(rect);
-
2777 QRectF sceneEffectRect;
executed (the execution status of this line is deduced): QRectF sceneEffectRect;
-
2778 foreach (QGraphicsView *view, scene->views()) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(scene->views())> _container_(scene->views()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsView *view = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
2779 QRectF deviceRect = view->d_func()->mapRectFromScene(sceneRect);
executed (the execution status of this line is deduced): QRectF deviceRect = view->d_func()->mapRectFromScene(sceneRect);
-
2780 QRect deviceEffectRect = effect->boundingRectFor(deviceRect).toAlignedRect();
executed (the execution status of this line is deduced): QRect deviceEffectRect = effect->boundingRectFor(deviceRect).toAlignedRect();
-
2781 sceneEffectRect |= view->d_func()->mapRectToScene(deviceEffectRect);
executed (the execution status of this line is deduced): sceneEffectRect |= view->d_func()->mapRectToScene(deviceEffectRect);
-
2782 }
executed: }
Execution Count:89
89
2783 return q->mapRectFromScene(sceneEffectRect);
executed: return q->mapRectFromScene(sceneEffectRect);
Execution Count:89
89
2784 } -
2785#endif //QT_NO_GRAPHICSEFFECT -
2786 return rect;
executed: return rect;
Execution Count:5531
5531
2787} -
2788 -
2789/*! -
2790 \internal -
2791 \since 4.6 -
2792 Returns the effective bounding rect of the item. -
2793 If the item has no effect, this is the same as the item's bounding rect. -
2794 If the item has an effect, the effective rect can be larger than the item's -
2795 bouding rect, depending on the effect. -
2796 -
2797 \sa boundingRect() -
2798*/ -
2799QRectF QGraphicsItemPrivate::effectiveBoundingRect(QGraphicsItem *topMostEffectItem) const -
2800{ -
2801#ifndef QT_NO_GRAPHICSEFFECT -
2802 Q_Q(const QGraphicsItem);
executed (the execution status of this line is deduced): const QGraphicsItem * const q = q_func();
-
2803 QRectF brect = effectiveBoundingRect(q_ptr->boundingRect());
executed (the execution status of this line is deduced): QRectF brect = effectiveBoundingRect(q_ptr->boundingRect());
-
2804 if (ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren || topMostEffectItem == q)
evaluated: ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren
TRUEFALSE
yes
Evaluation Count:22
yes
Evaluation Count:5597
evaluated: topMostEffectItem == q
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:5588
9-5597
2805 return brect;
executed: return brect;
Execution Count:31
31
2806 -
2807 const QGraphicsItem *effectParent = parent;
executed (the execution status of this line is deduced): const QGraphicsItem *effectParent = parent;
-
2808 while (effectParent) {
evaluated: effectParent
TRUEFALSE
yes
Evaluation Count:823
yes
Evaluation Count:5583
823-5583
2809 QGraphicsEffect *effect = effectParent->d_ptr->graphicsEffect;
executed (the execution status of this line is deduced): QGraphicsEffect *effect = effectParent->d_ptr->graphicsEffect;
-
2810 if (scene && effect && effect->isEnabled()) {
evaluated: scene
TRUEFALSE
yes
Evaluation Count:822
yes
Evaluation Count:1
evaluated: effect
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:807
partially evaluated: effect->isEnabled()
TRUEFALSE
yes
Evaluation Count:15
no
Evaluation Count:0
0-822
2811 const QRectF brectInParentSpace = q->mapRectToItem(effectParent, brect);
executed (the execution status of this line is deduced): const QRectF brectInParentSpace = q->mapRectToItem(effectParent, brect);
-
2812 const QRectF effectRectInParentSpace = effectParent->d_ptr->effectiveBoundingRect(brectInParentSpace);
executed (the execution status of this line is deduced): const QRectF effectRectInParentSpace = effectParent->d_ptr->effectiveBoundingRect(brectInParentSpace);
-
2813 brect = effectParent->mapRectToItem(q, effectRectInParentSpace);
executed (the execution status of this line is deduced): brect = effectParent->mapRectToItem(q, effectRectInParentSpace);
-
2814 }
executed: }
Execution Count:15
15
2815 if (effectParent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren
partially evaluated: effectParent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:823
0-823
2816 || topMostEffectItem == effectParent) {
evaluated: topMostEffectItem == effectParent
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:818
5-818
2817 return brect;
executed: return brect;
Execution Count:5
5
2818 } -
2819 effectParent = effectParent->d_ptr->parent;
executed (the execution status of this line is deduced): effectParent = effectParent->d_ptr->parent;
-
2820 }
executed: }
Execution Count:818
818
2821 -
2822 return brect;
executed: return brect;
Execution Count:5583
5583
2823#else //QT_NO_GRAPHICSEFFECT -
2824 return q_ptr->boundingRect(); -
2825#endif //QT_NO_GRAPHICSEFFECT -
2826 -
2827} -
2828 -
2829/*! -
2830 \internal -
2831 \since 4.6 -
2832 Returns the effective bounding rect of this item in scene coordinates, -
2833 by combining sceneTransform() with boundingRect(), taking into account -
2834 the effect that the item might have. -
2835 -
2836 If the item has no effect, this is the same as sceneBoundingRect(). -
2837 -
2838 \sa effectiveBoundingRect(), sceneBoundingRect() -
2839*/ -
2840QRectF QGraphicsItemPrivate::sceneEffectiveBoundingRect() const -
2841{ -
2842 // Find translate-only offset -
2843 // COMBINE -
2844 QPointF offset;
executed (the execution status of this line is deduced): QPointF offset;
-
2845 const QGraphicsItem *parentItem = q_ptr;
executed (the execution status of this line is deduced): const QGraphicsItem *parentItem = q_ptr;
-
2846 const QGraphicsItemPrivate *itemd;
executed (the execution status of this line is deduced): const QGraphicsItemPrivate *itemd;
-
2847 do { -
2848 itemd = parentItem->d_ptr.data();
executed (the execution status of this line is deduced): itemd = parentItem->d_ptr.data();
-
2849 if (itemd->transformData)
evaluated: itemd->transformData
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:1408
15-1408
2850 break;
executed: break;
Execution Count:15
15
2851 offset += itemd->pos;
executed (the execution status of this line is deduced): offset += itemd->pos;
-
2852 } while ((parentItem = itemd->parent));
executed: }
Execution Count:1408
evaluated: (parentItem = itemd->parent)
TRUEFALSE
yes
Evaluation Count:367
yes
Evaluation Count:1041
367-1408
2853 -
2854 QRectF br = effectiveBoundingRect();
executed (the execution status of this line is deduced): QRectF br = effectiveBoundingRect();
-
2855 br.translate(offset);
executed (the execution status of this line is deduced): br.translate(offset);
-
2856 return !parentItem ? br : parentItem->sceneTransform().mapRect(br);
executed: return !parentItem ? br : parentItem->sceneTransform().mapRect(br);
Execution Count:1056
1056
2857} -
2858 -
2859/*! -
2860 Returns true if this item can accept drag and drop events; otherwise, -
2861 returns false. By default, items do not accept drag and drop events; items -
2862 are transparent to drag and drop. -
2863 -
2864 \sa setAcceptDrops() -
2865*/ -
2866bool QGraphicsItem::acceptDrops() const -
2867{ -
2868 return d_ptr->acceptDrops;
never executed: return d_ptr->acceptDrops;
0
2869} -
2870 -
2871/*! -
2872 If \a on is true, this item will accept drag and drop events; otherwise, -
2873 it is transparent for drag and drop events. By default, items do not -
2874 accept drag and drop events. -
2875 -
2876 \sa acceptDrops() -
2877*/ -
2878void QGraphicsItem::setAcceptDrops(bool on) -
2879{ -
2880 d_ptr->acceptDrops = on;
executed (the execution status of this line is deduced): d_ptr->acceptDrops = on;
-
2881}
executed: }
Execution Count:112
112
2882 -
2883/*! -
2884 Returns the mouse buttons that this item accepts mouse events for. By -
2885 default, all mouse buttons are accepted. -
2886 -
2887 If an item accepts a mouse button, it will become the mouse -
2888 grabber item when a mouse press event is delivered for that mouse -
2889 button. However, if the item does not accept the button, -
2890 QGraphicsScene will forward the mouse events to the first item -
2891 beneath it that does. -
2892 -
2893 \sa setAcceptedMouseButtons(), mousePressEvent() -
2894*/ -
2895Qt::MouseButtons QGraphicsItem::acceptedMouseButtons() const -
2896{ -
2897 return Qt::MouseButtons(d_ptr->acceptedMouseButtons);
executed: return Qt::MouseButtons(d_ptr->acceptedMouseButtons);
Execution Count:105
105
2898} -
2899 -
2900/*! -
2901 Sets the mouse \a buttons that this item accepts mouse events for. -
2902 -
2903 By default, all mouse buttons are accepted. If an item accepts a -
2904 mouse button, it will become the mouse grabber item when a mouse -
2905 press event is delivered for that button. However, if the item -
2906 does not accept the mouse button, QGraphicsScene will forward the -
2907 mouse events to the first item beneath it that does. -
2908 -
2909 To disable mouse events for an item (i.e., make it transparent for mouse -
2910 events), call setAcceptedMouseButtons(0). -
2911 -
2912 \sa acceptedMouseButtons(), mousePressEvent() -
2913*/ -
2914void QGraphicsItem::setAcceptedMouseButtons(Qt::MouseButtons buttons) -
2915{ -
2916 if (Qt::MouseButtons(d_ptr->acceptedMouseButtons) != buttons) {
never evaluated: Qt::MouseButtons(d_ptr->acceptedMouseButtons) != buttons
0
2917 if (buttons == 0 && d_ptr->scene && d_ptr->scene->mouseGrabberItem() == this
never evaluated: buttons == 0
never evaluated: d_ptr->scene
never evaluated: d_ptr->scene->mouseGrabberItem() == this
0
2918 && d_ptr->scene->d_func()->lastMouseGrabberItemHasImplicitMouseGrab) {
never evaluated: d_ptr->scene->d_func()->lastMouseGrabberItemHasImplicitMouseGrab
0
2919 ungrabMouse();
never executed (the execution status of this line is deduced): ungrabMouse();
-
2920 }
never executed: }
0
2921 d_ptr->acceptedMouseButtons = quint32(buttons);
never executed (the execution status of this line is deduced): d_ptr->acceptedMouseButtons = quint32(buttons);
-
2922 }
never executed: }
0
2923}
never executed: }
0
2924 -
2925/*! -
2926 \since 4.4 -
2927 -
2928 Returns true if an item accepts hover events -
2929 (QGraphicsSceneHoverEvent); otherwise, returns false. By default, -
2930 items do not accept hover events. -
2931 -
2932 \sa setAcceptedMouseButtons() -
2933*/ -
2934bool QGraphicsItem::acceptHoverEvents() const -
2935{ -
2936 return d_ptr->acceptsHover;
never executed: return d_ptr->acceptsHover;
0
2937} -
2938 -
2939/*! -
2940 \fn bool QGraphicsItem::acceptsHoverEvents() const -
2941 \obsolete -
2942 -
2943 Call acceptHoverEvents() instead. -
2944*/ -
2945 -
2946/*! -
2947 \since 4.4 -
2948 -
2949 If \a enabled is true, this item will accept hover events; -
2950 otherwise, it will ignore them. By default, items do not accept -
2951 hover events. -
2952 -
2953 Hover events are delivered when there is no current mouse grabber -
2954 item. They are sent when the mouse cursor enters an item, when it -
2955 moves around inside the item, and when the cursor leaves an -
2956 item. Hover events are commonly used to highlight an item when -
2957 it's entered, and for tracking the mouse cursor as it hovers over -
2958 the item (equivalent to QWidget::mouseTracking). -
2959 -
2960 Parent items receive hover enter events before their children, and -
2961 leave events after their children. The parent does not receive a -
2962 hover leave event if the cursor enters a child, though; the parent -
2963 stays "hovered" until the cursor leaves its area, including its -
2964 children's areas. -
2965 -
2966 If a parent item handles child events, it will receive hover move, -
2967 drag move, and drop events as the cursor passes through its -
2968 children, but it does not receive hover enter and hover leave, nor -
2969 drag enter and drag leave events on behalf of its children. -
2970 -
2971 A QGraphicsWidget with window decorations will accept hover events -
2972 regardless of the value of acceptHoverEvents(). -
2973 -
2974 \sa acceptHoverEvents(), hoverEnterEvent(), hoverMoveEvent(), -
2975 hoverLeaveEvent() -
2976*/ -
2977void QGraphicsItem::setAcceptHoverEvents(bool enabled) -
2978{ -
2979 if (d_ptr->acceptsHover == quint32(enabled))
partially evaluated: d_ptr->acceptsHover == quint32(enabled)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:115
0-115
2980 return;
never executed: return;
0
2981 d_ptr->acceptsHover = quint32(enabled);
executed (the execution status of this line is deduced): d_ptr->acceptsHover = quint32(enabled);
-
2982 if (d_ptr->acceptsHover && d_ptr->scene && d_ptr->scene->d_func()->allItemsIgnoreHoverEvents) {
partially evaluated: d_ptr->acceptsHover
TRUEFALSE
yes
Evaluation Count:115
no
Evaluation Count:0
partially evaluated: d_ptr->scene
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:115
never evaluated: d_ptr->scene->d_func()->allItemsIgnoreHoverEvents
0-115
2983 d_ptr->scene->d_func()->allItemsIgnoreHoverEvents = false;
never executed (the execution status of this line is deduced): d_ptr->scene->d_func()->allItemsIgnoreHoverEvents = false;
-
2984 d_ptr->scene->d_func()->enableMouseTrackingOnViews();
never executed (the execution status of this line is deduced): d_ptr->scene->d_func()->enableMouseTrackingOnViews();
-
2985 }
never executed: }
0
2986}
executed: }
Execution Count:115
115
2987 -
2988/*! -
2989 \fn void QGraphicsItem::setAcceptsHoverEvents(bool enabled) -
2990 \obsolete -
2991 -
2992 Use setAcceptHoverEvents(\a enabled) instead. -
2993*/ -
2994 -
2995/*! \since 4.6 -
2996 -
2997 Returns true if an item accepts \l{QTouchEvent}{touch events}; -
2998 otherwise, returns false. By default, items do not accept touch events. -
2999 -
3000 \sa setAcceptTouchEvents() -
3001*/ -
3002bool QGraphicsItem::acceptTouchEvents() const -
3003{ -
3004 return d_ptr->acceptTouchEvents;
never executed: return d_ptr->acceptTouchEvents;
0
3005} -
3006 -
3007/*! -
3008 \since 4.6 -
3009 -
3010 If \a enabled is true, this item will accept \l{QTouchEvent}{touch events}; -
3011 otherwise, it will ignore them. By default, items do not accept -
3012 touch events. -
3013*/ -
3014void QGraphicsItem::setAcceptTouchEvents(bool enabled) -
3015{ -
3016 if (d_ptr->acceptTouchEvents == quint32(enabled))
never evaluated: d_ptr->acceptTouchEvents == quint32(enabled)
0
3017 return;
never executed: return;
0
3018 d_ptr->acceptTouchEvents = quint32(enabled);
never executed (the execution status of this line is deduced): d_ptr->acceptTouchEvents = quint32(enabled);
-
3019 if (d_ptr->acceptTouchEvents && d_ptr->scene && d_ptr->scene->d_func()->allItemsIgnoreTouchEvents) {
never evaluated: d_ptr->acceptTouchEvents
never evaluated: d_ptr->scene
never evaluated: d_ptr->scene->d_func()->allItemsIgnoreTouchEvents
0
3020 d_ptr->scene->d_func()->allItemsIgnoreTouchEvents = false;
never executed (the execution status of this line is deduced): d_ptr->scene->d_func()->allItemsIgnoreTouchEvents = false;
-
3021 d_ptr->scene->d_func()->enableTouchEventsOnViews();
never executed (the execution status of this line is deduced): d_ptr->scene->d_func()->enableTouchEventsOnViews();
-
3022 }
never executed: }
0
3023}
never executed: }
0
3024 -
3025/*! -
3026 \since 4.6 -
3027 -
3028 Returns true if this item filters child events (i.e., all events -
3029 intended for any of its children are instead sent to this item); -
3030 otherwise, false is returned. -
3031 -
3032 The default value is false; child events are not filtered. -
3033 -
3034 \sa setFiltersChildEvents() -
3035*/ -
3036bool QGraphicsItem::filtersChildEvents() const -
3037{ -
3038 return d_ptr->filtersDescendantEvents;
never executed: return d_ptr->filtersDescendantEvents;
0
3039} -
3040 -
3041/*! -
3042 \since 4.6 -
3043 -
3044 If \a enabled is true, this item is set to filter all events for -
3045 all its children (i.e., all events intented for any of its -
3046 children are instead sent to this item); otherwise, if \a enabled -
3047 is false, this item will only handle its own events. The default -
3048 value is false. -
3049 -
3050 \sa filtersChildEvents() -
3051*/ -
3052void QGraphicsItem::setFiltersChildEvents(bool enabled) -
3053{ -
3054 if (d_ptr->filtersDescendantEvents == enabled)
never evaluated: d_ptr->filtersDescendantEvents == enabled
0
3055 return;
never executed: return;
0
3056 -
3057 d_ptr->filtersDescendantEvents = enabled;
never executed (the execution status of this line is deduced): d_ptr->filtersDescendantEvents = enabled;
-
3058 d_ptr->updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-2));
never executed (the execution status of this line is deduced): d_ptr->updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-2));
-
3059}
never executed: }
0
3060 -
3061/*! -
3062 \obsolete -
3063 -
3064 Returns true if this item handles child events (i.e., all events -
3065 intended for any of its children are instead sent to this item); -
3066 otherwise, false is returned. -
3067 -
3068 This property is useful for item groups; it allows one item to -
3069 handle events on behalf of its children, as opposed to its -
3070 children handling their events individually. -
3071 -
3072 The default is to return false; children handle their own events. -
3073 The exception for this is if the item is a QGraphicsItemGroup, then -
3074 it defaults to return true. -
3075 -
3076 \sa setHandlesChildEvents() -
3077*/ -
3078bool QGraphicsItem::handlesChildEvents() const -
3079{ -
3080 return d_ptr->handlesChildEvents;
never executed: return d_ptr->handlesChildEvents;
0
3081} -
3082 -
3083/*! -
3084 \obsolete -
3085 -
3086 If \a enabled is true, this item is set to handle all events for -
3087 all its children (i.e., all events intented for any of its -
3088 children are instead sent to this item); otherwise, if \a enabled -
3089 is false, this item will only handle its own events. The default -
3090 value is false. -
3091 -
3092 This property is useful for item groups; it allows one item to -
3093 handle events on behalf of its children, as opposed to its -
3094 children handling their events individually. -
3095 -
3096 If a child item accepts hover events, its parent will receive -
3097 hover move events as the cursor passes through the child, but it -
3098 does not receive hover enter and hover leave events on behalf of -
3099 its child. -
3100 -
3101 \sa handlesChildEvents() -
3102*/ -
3103void QGraphicsItem::setHandlesChildEvents(bool enabled) -
3104{ -
3105 if (d_ptr->handlesChildEvents == enabled)
never evaluated: d_ptr->handlesChildEvents == enabled
0
3106 return;
never executed: return;
0
3107 -
3108 d_ptr->handlesChildEvents = enabled;
never executed (the execution status of this line is deduced): d_ptr->handlesChildEvents = enabled;
-
3109 d_ptr->updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-1));
never executed (the execution status of this line is deduced): d_ptr->updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-1));
-
3110}
never executed: }
0
3111/*! -
3112 \since 4.6 -
3113 Returns true if this item is active; otherwise returns false. -
3114 -
3115 An item can only be active if the scene is active. An item is active -
3116 if it is, or is a descendent of, an active panel. Items in non-active -
3117 panels are not active. -
3118 -
3119 Items that are not part of a panel follow scene activation when the -
3120 scene has no active panel. -
3121 -
3122 Only active items can gain input focus. -
3123 -
3124 \sa QGraphicsScene::isActive(), QGraphicsScene::activePanel(), panel(), isPanel() -
3125*/ -
3126bool QGraphicsItem::isActive() const -
3127{ -
3128 if (!d_ptr->scene || !d_ptr->scene->isActive())
evaluated: !d_ptr->scene
TRUEFALSE
yes
Evaluation Count:471
yes
Evaluation Count:984
evaluated: !d_ptr->scene->isActive()
TRUEFALSE
yes
Evaluation Count:867
yes
Evaluation Count:117
117-984
3129 return false;
executed: return false;
Execution Count:1338
1338
3130 return panel() == d_ptr->scene->activePanel();
executed: return panel() == d_ptr->scene->activePanel();
Execution Count:117
117
3131} -
3132 -
3133/*! -
3134 \since 4.6 -
3135 -
3136 If \a active is true, and the scene is active, this item's panel will be -
3137 activated. Otherwise, the panel is deactivated. -
3138 -
3139 If the item is not part of an active scene, \a active will decide what -
3140 happens to the panel when the scene becomes active or the item is added to -
3141 the scene. If true, the item's panel will be activated when the item is -
3142 either added to the scene or the scene is activated. Otherwise, the item -
3143 will stay inactive independent of the scene's activated state. -
3144 -
3145 \sa isPanel(), QGraphicsScene::setActivePanel(), QGraphicsScene::isActive() -
3146*/ -
3147void QGraphicsItem::setActive(bool active) -
3148{ -
3149 d_ptr->explicitActivate = 1;
executed (the execution status of this line is deduced): d_ptr->explicitActivate = 1;
-
3150 d_ptr->wantsActive = active;
executed (the execution status of this line is deduced): d_ptr->wantsActive = active;
-
3151 if (d_ptr->scene) {
partially evaluated: d_ptr->scene
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
3152 if (active) {
partially evaluated: active
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
3153 // Activate this item. -
3154 d_ptr->scene->setActivePanel(this);
executed (the execution status of this line is deduced): d_ptr->scene->setActivePanel(this);
-
3155 } else {
executed: }
Execution Count:3
3
3156 // Deactivate this item, and reactivate the parent panel, -
3157 // or the last active panel (if any). -
3158 QGraphicsItem *nextToActivate = 0;
never executed (the execution status of this line is deduced): QGraphicsItem *nextToActivate = 0;
-
3159 if (d_ptr->parent)
never evaluated: d_ptr->parent
0
3160 nextToActivate = d_ptr->parent->panel();
never executed: nextToActivate = d_ptr->parent->panel();
0
3161 if (!nextToActivate)
never evaluated: !nextToActivate
0
3162 nextToActivate = d_ptr->scene->d_func()->lastActivePanel;
never executed: nextToActivate = d_ptr->scene->d_func()->lastActivePanel;
0
3163 if (nextToActivate == this || isAncestorOf(nextToActivate))
never evaluated: nextToActivate == this
never evaluated: isAncestorOf(nextToActivate)
0
3164 nextToActivate = 0;
never executed: nextToActivate = 0;
0
3165 d_ptr->scene->setActivePanel(nextToActivate);
never executed (the execution status of this line is deduced): d_ptr->scene->setActivePanel(nextToActivate);
-
3166 }
never executed: }
0
3167 } -
3168}
executed: }
Execution Count:3
3
3169 -
3170/*! -
3171 Returns true if this item is active, and it or its \l{focusProxy()}{focus -
3172 proxy} has keyboard input focus; otherwise, returns false. -
3173 -
3174 \sa focusItem(), setFocus(), QGraphicsScene::setFocusItem(), isActive() -
3175*/ -
3176bool QGraphicsItem::hasFocus() const -
3177{ -
3178 if (!d_ptr->scene || !d_ptr->scene->isActive())
evaluated: !d_ptr->scene
TRUEFALSE
yes
Evaluation Count:537
yes
Evaluation Count:7125
evaluated: !d_ptr->scene->isActive()
TRUEFALSE
yes
Evaluation Count:2965
yes
Evaluation Count:4160
537-7125
3179 return false;
executed: return false;
Execution Count:3502
3502
3180 -
3181 if (d_ptr->focusProxy)
partially evaluated: d_ptr->focusProxy
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4160
0-4160
3182 return d_ptr->focusProxy->hasFocus();
never executed: return d_ptr->focusProxy->hasFocus();
0
3183 -
3184 if (d_ptr->scene->d_func()->focusItem != this)
evaluated: d_ptr->scene->d_func()->focusItem != this
TRUEFALSE
yes
Evaluation Count:4154
yes
Evaluation Count:6
6-4154
3185 return false;
executed: return false;
Execution Count:4154
4154
3186 -
3187 return panel() == d_ptr->scene->d_func()->activePanel;
executed: return panel() == d_ptr->scene->d_func()->activePanel;
Execution Count:6
6
3188} -
3189 -
3190/*! -
3191 Gives keyboard input focus to this item. The \a focusReason argument will -
3192 be passed into any \l{QFocusEvent}{focus event} generated by this function; -
3193 it is used to give an explanation of what caused the item to get focus. -
3194 -
3195 Only enabled items that set the ItemIsFocusable flag can accept keyboard -
3196 focus. -
3197 -
3198 If this item is not visible, not active, or not associated with a scene, -
3199 it will not gain immediate input focus. However, it will be registered as -
3200 the preferred focus item for its subtree of items, should it later become -
3201 visible. -
3202 -
3203 As a result of calling this function, this item will receive a -
3204 \l{focusInEvent()}{focus in event} with \a focusReason. If another item -
3205 already has focus, that item will first receive a \l{focusOutEvent()} -
3206 {focus out event} indicating that it has lost input focus. -
3207 -
3208 \sa clearFocus(), hasFocus(), focusItem(), focusProxy() -
3209*/ -
3210void QGraphicsItem::setFocus(Qt::FocusReason focusReason) -
3211{ -
3212 d_ptr->setFocusHelper(focusReason, /* climb = */ true, /* focusFromHide = */ false);
executed (the execution status of this line is deduced): d_ptr->setFocusHelper(focusReason, true, false);
-
3213}
executed: }
Execution Count:15
15
3214 -
3215/*! -
3216 \internal -
3217*/ -
3218void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromHide) -
3219{ -
3220 // Disabled / unfocusable items cannot accept focus. -
3221 if (!q_ptr->isEnabled() || !(flags & QGraphicsItem::ItemIsFocusable))
partially evaluated: !q_ptr->isEnabled()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
evaluated: !(flags & QGraphicsItem::ItemIsFocusable)
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:14
0-15
3222 return;
executed: return;
Execution Count:1
1
3223 -
3224 // Find focus proxy. -
3225 QGraphicsItem *f = q_ptr;
executed (the execution status of this line is deduced): QGraphicsItem *f = q_ptr;
-
3226 while (f->d_ptr->focusProxy)
partially evaluated: f->d_ptr->focusProxy
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
3227 f = f->d_ptr->focusProxy;
never executed: f = f->d_ptr->focusProxy;
0
3228 -
3229 // Return if it already has focus. -
3230 if (scene && scene->focusItem() == f)
partially evaluated: scene
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
partially evaluated: scene->focusItem() == f
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
3231 return;
never executed: return;
0
3232 -
3233 // Update focus scope item ptr. -
3234 QGraphicsItem *p = parent;
executed (the execution status of this line is deduced): QGraphicsItem *p = parent;
-
3235 while (p) {
partially evaluated: p
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
3236 if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
never evaluated: p->flags() & QGraphicsItem::ItemIsFocusScope
0
3237 QGraphicsItem *oldFocusScopeItem = p->d_ptr->focusScopeItem;
never executed (the execution status of this line is deduced): QGraphicsItem *oldFocusScopeItem = p->d_ptr->focusScopeItem;
-
3238 p->d_ptr->focusScopeItem = q_ptr;
never executed (the execution status of this line is deduced): p->d_ptr->focusScopeItem = q_ptr;
-
3239 if (oldFocusScopeItem)
never evaluated: oldFocusScopeItem
0
3240 oldFocusScopeItem->d_ptr->focusScopeItemChange(false);
never executed: oldFocusScopeItem->d_ptr->focusScopeItemChange(false);
0
3241 focusScopeItemChange(true);
never executed (the execution status of this line is deduced): focusScopeItemChange(true);
-
3242 if (!p->focusItem() && !focusFromHide) {
never evaluated: !p->focusItem()
never evaluated: !focusFromHide
0
3243 // Calling setFocus() on a child of a focus scope that does -
3244 // not have focus changes only the focus scope pointer, -
3245 // so that focus is restored the next time the scope gains -
3246 // focus. -
3247 return;
never executed: return;
0
3248 } -
3249 break;
never executed: break;
0
3250 } -
3251 p = p->d_ptr->parent;
never executed (the execution status of this line is deduced): p = p->d_ptr->parent;
-
3252 }
never executed: }
0
3253 -
3254 if (climb) {
partially evaluated: climb
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
3255 while (f->d_ptr->focusScopeItem && f->d_ptr->focusScopeItem->isVisible())
partially evaluated: f->d_ptr->focusScopeItem
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
never evaluated: f->d_ptr->focusScopeItem->isVisible()
0-14
3256 f = f->d_ptr->focusScopeItem;
never executed: f = f->d_ptr->focusScopeItem;
0
3257 }
executed: }
Execution Count:14
14
3258 -
3259 // Update the child focus chain. -
3260 QGraphicsItem *commonAncestor = 0;
executed (the execution status of this line is deduced): QGraphicsItem *commonAncestor = 0;
-
3261 if (scene && scene->focusItem() && scene->focusItem()->panel() == q_ptr->panel()) {
partially evaluated: scene
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
evaluated: scene->focusItem()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:8
partially evaluated: scene->focusItem()->panel() == q_ptr->panel()
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-14
3262 commonAncestor = scene->focusItem()->commonAncestorItem(f);
executed (the execution status of this line is deduced): commonAncestor = scene->focusItem()->commonAncestorItem(f);
-
3263 scene->focusItem()->d_ptr->clearSubFocus(scene->focusItem(), commonAncestor);
executed (the execution status of this line is deduced): scene->focusItem()->d_ptr->clearSubFocus(scene->focusItem(), commonAncestor);
-
3264 }
executed: }
Execution Count:6
6
3265 -
3266 f->d_ptr->setSubFocus(f, commonAncestor);
executed (the execution status of this line is deduced): f->d_ptr->setSubFocus(f, commonAncestor);
-
3267 -
3268 // Update the scene's focus item. -
3269 if (scene) {
partially evaluated: scene
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
3270 QGraphicsItem *p = q_ptr->panel();
executed (the execution status of this line is deduced): QGraphicsItem *p = q_ptr->panel();
-
3271 if ((!p && scene->isActive()) || (p && p->isActive())) {
partially evaluated: !p
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
evaluated: scene->isActive()
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:1
partially evaluated: p
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
never evaluated: p->isActive()
0-14
3272 // Visible items immediately gain focus from scene. -
3273 scene->d_func()->setFocusItemHelper(f, focusReason);
executed (the execution status of this line is deduced): scene->d_func()->setFocusItemHelper(f, focusReason);
-
3274 }
executed: }
Execution Count:13
13
3275 }
executed: }
Execution Count:14
14
3276}
executed: }
Execution Count:14
14
3277 -
3278/*! -
3279 Takes keyboard input focus from the item. -
3280 -
3281 If it has focus, a \l{focusOutEvent()}{focus out event} is sent to this -
3282 item to tell it that it is about to lose the focus. -
3283 -
3284 Only items that set the ItemIsFocusable flag, or widgets that set an -
3285 appropriate focus policy, can accept keyboard focus. -
3286 -
3287 \sa setFocus(), hasFocus(), QGraphicsWidget::focusPolicy -
3288*/ -
3289void QGraphicsItem::clearFocus() -
3290{ -
3291 d_ptr->clearFocusHelper(/* giveFocusToParent = */ true,
executed (the execution status of this line is deduced): d_ptr->clearFocusHelper( true,
-
3292 /* hiddenByParentPanel = */ false);
executed (the execution status of this line is deduced): false);
-
3293}
executed: }
Execution Count:4393
4393
3294 -
3295/*! -
3296 \internal -
3297*/ -
3298void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent, bool hiddenByParentPanel) -
3299{ -
3300 QGraphicsItem *subFocusItem = q_ptr;
executed (the execution status of this line is deduced): QGraphicsItem *subFocusItem = q_ptr;
-
3301 if (flags & QGraphicsItem::ItemIsFocusScope) {
partially evaluated: flags & QGraphicsItem::ItemIsFocusScope
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4393
0-4393
3302 while (subFocusItem->d_ptr->focusScopeItem)
never evaluated: subFocusItem->d_ptr->focusScopeItem
0
3303 subFocusItem = subFocusItem->d_ptr->focusScopeItem;
never executed: subFocusItem = subFocusItem->d_ptr->focusScopeItem;
0
3304 }
never executed: }
0
3305 -
3306 if (giveFocusToParent) {
partially evaluated: giveFocusToParent
TRUEFALSE
yes
Evaluation Count:4393
no
Evaluation Count:0
0-4393
3307 // Pass focus to the closest parent focus scope -
3308 if (!inDestructor) {
evaluated: !inDestructor
TRUEFALSE
yes
Evaluation Count:950
yes
Evaluation Count:3443
950-3443
3309 QGraphicsItem *p = parent;
executed (the execution status of this line is deduced): QGraphicsItem *p = parent;
-
3310 while (p) {
evaluated: p
TRUEFALSE
yes
Evaluation Count:741
yes
Evaluation Count:950
741-950
3311 if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
partially evaluated: p->flags() & QGraphicsItem::ItemIsFocusScope
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:741
0-741
3312 if (p->d_ptr->focusScopeItem == q_ptr) {
never evaluated: p->d_ptr->focusScopeItem == q_ptr
0
3313 p->d_ptr->focusScopeItem = 0;
never executed (the execution status of this line is deduced): p->d_ptr->focusScopeItem = 0;
-
3314 if (!subFocusItem->hasFocus()) //if it has focus, focusScopeItemChange is called elsewhere
never evaluated: !subFocusItem->hasFocus()
0
3315 focusScopeItemChange(false);
never executed: focusScopeItemChange(false);
0
3316 }
never executed: }
0
3317 if (subFocusItem->hasFocus())
never evaluated: subFocusItem->hasFocus()
0
3318 p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ false,
never executed: p->d_ptr->setFocusHelper(Qt::OtherFocusReason, false, false);
0
3319 /* focusFromHide = */ false);
never executed: p->d_ptr->setFocusHelper(Qt::OtherFocusReason, false, false);
0
3320 return;
never executed: return;
0
3321 } -
3322 p = p->d_ptr->parent;
executed (the execution status of this line is deduced): p = p->d_ptr->parent;
-
3323 }
executed: }
Execution Count:741
741
3324 }
executed: }
Execution Count:950
950
3325 }
executed: }
Execution Count:4393
4393
3326 -
3327 if (subFocusItem->hasFocus()) {
evaluated: subFocusItem->hasFocus()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:4388
5-4388
3328 // Invisible items with focus must explicitly clear subfocus. -
3329 if (!hiddenByParentPanel)
partially evaluated: !hiddenByParentPanel
TRUEFALSE
yes
Evaluation Count:5
no
Evaluation Count:0
0-5
3330 clearSubFocus(q_ptr);
executed: clearSubFocus(q_ptr);
Execution Count:5
5
3331 -
3332 // If this item has the scene's input focus, clear it. -
3333 scene->setFocusItem(0);
executed (the execution status of this line is deduced): scene->setFocusItem(0);
-
3334 }
executed: }
Execution Count:5
5
3335}
executed: }
Execution Count:4393
4393
3336 -
3337/*! -
3338 \since 4.6 -
3339 -
3340 Returns this item's focus proxy, or 0 if this item has no -
3341 focus proxy. -
3342 -
3343 \sa setFocusProxy(), setFocus(), hasFocus() -
3344*/ -
3345QGraphicsItem *QGraphicsItem::focusProxy() const -
3346{ -
3347 return d_ptr->focusProxy;
never executed: return d_ptr->focusProxy;
0
3348} -
3349 -
3350/*! -
3351 \since 4.6 -
3352 -
3353 Sets the item's focus proxy to \a item. -
3354 -
3355 If an item has a focus proxy, the focus proxy will receive -
3356 input focus when the item gains input focus. The item itself -
3357 will still have focus (i.e., hasFocus() will return true), -
3358 but only the focus proxy will receive the keyboard input. -
3359 -
3360 A focus proxy can itself have a focus proxy, and so on. In -
3361 such case, keyboard input will be handled by the outermost -
3362 focus proxy. -
3363 -
3364 The focus proxy \a item must belong to the same scene as -
3365 this item. -
3366 -
3367 \sa focusProxy(), setFocus(), hasFocus() -
3368*/ -
3369void QGraphicsItem::setFocusProxy(QGraphicsItem *item) -
3370{ -
3371 if (item == d_ptr->focusProxy)
partially evaluated: item == d_ptr->focusProxy
TRUEFALSE
yes
Evaluation Count:1757
no
Evaluation Count:0
0-1757
3372 return;
executed: return;
Execution Count:1757
1757
3373 if (item == this) {
never evaluated: item == this
0
3374 qWarning("QGraphicsItem::setFocusProxy: cannot assign self as focus proxy");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 3374, __PRETTY_FUNCTION__).warning("QGraphicsItem::setFocusProxy: cannot assign self as focus proxy");
-
3375 return;
never executed: return;
0
3376 } -
3377 if (item) {
never evaluated: item
0
3378 if (item->d_ptr->scene != d_ptr->scene) {
never evaluated: item->d_ptr->scene != d_ptr->scene
0
3379 qWarning("QGraphicsItem::setFocusProxy: focus proxy must be in same scene");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 3379, __PRETTY_FUNCTION__).warning("QGraphicsItem::setFocusProxy: focus proxy must be in same scene");
-
3380 return;
never executed: return;
0
3381 } -
3382 for (QGraphicsItem *f = item->focusProxy(); f != 0; f = f->focusProxy()) {
never evaluated: f != 0
0
3383 if (f == this) {
never evaluated: f == this
0
3384 qWarning("QGraphicsItem::setFocusProxy: %p is already in the focus proxy chain", item);
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 3384, __PRETTY_FUNCTION__).warning("QGraphicsItem::setFocusProxy: %p is already in the focus proxy chain", item);
-
3385 return;
never executed: return;
0
3386 } -
3387 }
never executed: }
0
3388 }
never executed: }
0
3389 -
3390 QGraphicsItem *lastFocusProxy = d_ptr->focusProxy;
never executed (the execution status of this line is deduced): QGraphicsItem *lastFocusProxy = d_ptr->focusProxy;
-
3391 if (lastFocusProxy)
never evaluated: lastFocusProxy
0
3392 lastFocusProxy->d_ptr->focusProxyRefs.removeOne(&d_ptr->focusProxy);
never executed: lastFocusProxy->d_ptr->focusProxyRefs.removeOne(&d_ptr->focusProxy);
0
3393 d_ptr->focusProxy = item;
never executed (the execution status of this line is deduced): d_ptr->focusProxy = item;
-
3394 if (item)
never evaluated: item
0
3395 item->d_ptr->focusProxyRefs << &d_ptr->focusProxy;
never executed: item->d_ptr->focusProxyRefs << &d_ptr->focusProxy;
0
3396}
never executed: }
0
3397 -
3398/*! -
3399 \since 4.6 -
3400 -
3401 If this item, a child or descendant of this item currently has input -
3402 focus, this function will return a pointer to that item. If -
3403 no descendant has input focus, 0 is returned. -
3404 -
3405 \sa hasFocus(), setFocus(), QWidget::focusWidget() -
3406*/ -
3407QGraphicsItem *QGraphicsItem::focusItem() const -
3408{ -
3409 return d_ptr->subFocusItem;
executed: return d_ptr->subFocusItem;
Execution Count:1741
1741
3410} -
3411 -
3412/*! -
3413 \internal -
3414 -
3415 Returns this item's focus scope item. -
3416*/ -
3417QGraphicsItem *QGraphicsItem::focusScopeItem() const -
3418{ -
3419 return d_ptr->focusScopeItem;
never executed: return d_ptr->focusScopeItem;
0
3420} -
3421 -
3422/*! -
3423 \since 4.4 -
3424 Grabs the mouse input. -
3425 -
3426 This item will receive all mouse events for the scene until any of the -
3427 following events occurs: -
3428 -
3429 \list -
3430 \li The item becomes invisible -
3431 \li The item is removed from the scene -
3432 \li The item is deleted -
3433 \li The item call ungrabMouse() -
3434 \li Another item calls grabMouse(); the item will regain the mouse grab -
3435 when the other item calls ungrabMouse(). -
3436 \endlist -
3437 -
3438 When an item gains the mouse grab, it receives a QEvent::GrabMouse -
3439 event. When it loses the mouse grab, it receives a QEvent::UngrabMouse -
3440 event. These events can be used to detect when your item gains or loses -
3441 the mouse grab through other means than receiving mouse button events. -
3442 -
3443 It is almost never necessary to explicitly grab the mouse in Qt, as Qt -
3444 grabs and releases it sensibly. In particular, Qt grabs the mouse when you -
3445 press a mouse button, and keeps the mouse grabbed until you release the -
3446 last mouse button. Also, Qt::Popup widgets implicitly call grabMouse() -
3447 when shown, and ungrabMouse() when hidden. -
3448 -
3449 Note that only visible items can grab mouse input. Calling grabMouse() on -
3450 an invisible item has no effect. -
3451 -
3452 Keyboard events are not affected. -
3453 -
3454 \sa QGraphicsScene::mouseGrabberItem(), ungrabMouse(), grabKeyboard() -
3455*/ -
3456void QGraphicsItem::grabMouse() -
3457{ -
3458 if (!d_ptr->scene) {
never evaluated: !d_ptr->scene
0
3459 qWarning("QGraphicsItem::grabMouse: cannot grab mouse without scene");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 3459, __PRETTY_FUNCTION__).warning("QGraphicsItem::grabMouse: cannot grab mouse without scene");
-
3460 return;
never executed: return;
0
3461 } -
3462 if (!d_ptr->visible) {
never evaluated: !d_ptr->visible
0
3463 qWarning("QGraphicsItem::grabMouse: cannot grab mouse while invisible");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 3463, __PRETTY_FUNCTION__).warning("QGraphicsItem::grabMouse: cannot grab mouse while invisible");
-
3464 return;
never executed: return;
0
3465 } -
3466 d_ptr->scene->d_func()->grabMouse(this);
never executed (the execution status of this line is deduced): d_ptr->scene->d_func()->grabMouse(this);
-
3467}
never executed: }
0
3468 -
3469/*! -
3470 \since 4.4 -
3471 Releases the mouse grab. -
3472 -
3473 \sa grabMouse(), ungrabKeyboard() -
3474*/ -
3475void QGraphicsItem::ungrabMouse() -
3476{ -
3477 if (!d_ptr->scene) {
partially evaluated: !d_ptr->scene
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:104
0-104
3478 qWarning("QGraphicsItem::ungrabMouse: cannot ungrab mouse without scene");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 3478, __PRETTY_FUNCTION__).warning("QGraphicsItem::ungrabMouse: cannot ungrab mouse without scene");
-
3479 return;
never executed: return;
0
3480 } -
3481 d_ptr->scene->d_func()->ungrabMouse(this);
executed (the execution status of this line is deduced): d_ptr->scene->d_func()->ungrabMouse(this);
-
3482}
executed: }
Execution Count:104
104
3483 -
3484/*! -
3485 \since 4.4 -
3486 Grabs the keyboard input. -
3487 -
3488 The item will receive all keyboard input to the scene until one of the -
3489 following events occur: -
3490 -
3491 \list -
3492 \li The item becomes invisible -
3493 \li The item is removed from the scene -
3494 \li The item is deleted -
3495 \li The item calls ungrabKeyboard() -
3496 \li Another item calls grabKeyboard(); the item will regain the keyboard grab -
3497 when the other item calls ungrabKeyboard(). -
3498 \endlist -
3499 -
3500 When an item gains the keyboard grab, it receives a QEvent::GrabKeyboard -
3501 event. When it loses the keyboard grab, it receives a -
3502 QEvent::UngrabKeyboard event. These events can be used to detect when your -
3503 item gains or loses the keyboard grab through other means than gaining -
3504 input focus. -
3505 -
3506 It is almost never necessary to explicitly grab the keyboard in Qt, as Qt -
3507 grabs and releases it sensibly. In particular, Qt grabs the keyboard when -
3508 your item gains input focus, and releases it when your item loses input -
3509 focus, or when the item is hidden. -
3510 -
3511 Note that only visible items can grab keyboard input. Calling -
3512 grabKeyboard() on an invisible item has no effect. -
3513 -
3514 Keyboard events are not affected. -
3515 -
3516 \sa ungrabKeyboard(), grabMouse(), setFocus() -
3517*/ -
3518void QGraphicsItem::grabKeyboard() -
3519{ -
3520 if (!d_ptr->scene) {
never evaluated: !d_ptr->scene
0
3521 qWarning("QGraphicsItem::grabKeyboard: cannot grab keyboard without scene");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 3521, __PRETTY_FUNCTION__).warning("QGraphicsItem::grabKeyboard: cannot grab keyboard without scene");
-
3522 return;
never executed: return;
0
3523 } -
3524 if (!d_ptr->visible) {
never evaluated: !d_ptr->visible
0
3525 qWarning("QGraphicsItem::grabKeyboard: cannot grab keyboard while invisible");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 3525, __PRETTY_FUNCTION__).warning("QGraphicsItem::grabKeyboard: cannot grab keyboard while invisible");
-
3526 return;
never executed: return;
0
3527 } -
3528 d_ptr->scene->d_func()->grabKeyboard(this);
never executed (the execution status of this line is deduced): d_ptr->scene->d_func()->grabKeyboard(this);
-
3529}
never executed: }
0
3530 -
3531/*! -
3532 \since 4.4 -
3533 Releases the keyboard grab. -
3534 -
3535 \sa grabKeyboard(), ungrabMouse() -
3536*/ -
3537void QGraphicsItem::ungrabKeyboard() -
3538{ -
3539 if (!d_ptr->scene) {
never evaluated: !d_ptr->scene
0
3540 qWarning("QGraphicsItem::ungrabKeyboard: cannot ungrab keyboard without scene");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 3540, __PRETTY_FUNCTION__).warning("QGraphicsItem::ungrabKeyboard: cannot ungrab keyboard without scene");
-
3541 return;
never executed: return;
0
3542 } -
3543 d_ptr->scene->d_func()->ungrabKeyboard(this);
never executed (the execution status of this line is deduced): d_ptr->scene->d_func()->ungrabKeyboard(this);
-
3544}
never executed: }
0
3545 -
3546/*! -
3547 Returns the position of the item in parent coordinates. If the item has no -
3548 parent, its position is given in scene coordinates. -
3549 -
3550 The position of the item describes its origin (local coordinate -
3551 (0, 0)) in parent coordinates; this function returns the same as -
3552 mapToParent(0, 0). -
3553 -
3554 For convenience, you can also call scenePos() to determine the -
3555 item's position in scene coordinates, regardless of its parent. -
3556 -
3557 \sa x(), y(), setPos(), transform(), {The Graphics View Coordinate System} -
3558*/ -
3559QPointF QGraphicsItem::pos() const -
3560{ -
3561 return d_ptr->pos;
executed: return d_ptr->pos;
Execution Count:8007
8007
3562} -
3563 -
3564/*! -
3565 \fn QGraphicsItem::x() const -
3566 -
3567 This convenience function is equivalent to calling pos().x(). -
3568 -
3569 \sa y() -
3570*/ -
3571 -
3572/*! -
3573 \since 4.6 -
3574 -
3575 Set's the \a x coordinate of the item's position. Equivalent to -
3576 calling setPos(x, y()). -
3577 -
3578 \sa x(), setPos() -
3579*/ -
3580void QGraphicsItem::setX(qreal x) -
3581{ -
3582 if (d_ptr->inDestructor)
partially evaluated: d_ptr->inDestructor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
3583 return;
never executed: return;
0
3584 -
3585 if (qIsNaN(x))
partially evaluated: qIsNaN(x)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
3586 return;
never executed: return;
0
3587 -
3588 setPos(QPointF(x, d_ptr->pos.y()));
executed (the execution status of this line is deduced): setPos(QPointF(x, d_ptr->pos.y()));
-
3589}
executed: }
Execution Count:3
3
3590 -
3591/*! -
3592 \fn QGraphicsItem::y() const -
3593 -
3594 This convenience function is equivalent to calling pos().y(). -
3595 -
3596 \sa x() -
3597*/ -
3598 -
3599/*! -
3600 \since 4.6 -
3601 -
3602 Set's the \a y coordinate of the item's position. Equivalent to -
3603 calling setPos(x(), y). -
3604 -
3605 \sa x(), setPos() -
3606*/ -
3607void QGraphicsItem::setY(qreal y) -
3608{ -
3609 if (d_ptr->inDestructor)
partially evaluated: d_ptr->inDestructor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
3610 return;
never executed: return;
0
3611 -
3612 if (qIsNaN(y))
partially evaluated: qIsNaN(y)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
3613 return;
never executed: return;
0
3614 -
3615 setPos(QPointF(d_ptr->pos.x(), y));
executed (the execution status of this line is deduced): setPos(QPointF(d_ptr->pos.x(), y));
-
3616}
executed: }
Execution Count:3
3
3617 -
3618/*! -
3619 Returns the item's position in scene coordinates. This is -
3620 equivalent to calling \c mapToScene(0, 0). -
3621 -
3622 \sa pos(), sceneTransform(), {The Graphics View Coordinate System} -
3623*/ -
3624QPointF QGraphicsItem::scenePos() const -
3625{ -
3626 return mapToScene(0, 0);
executed: return mapToScene(0, 0);
Execution Count:3
3
3627} -
3628 -
3629/*! -
3630 \internal -
3631 -
3632 Sets the position \a pos. -
3633*/ -
3634void QGraphicsItemPrivate::setPosHelper(const QPointF &pos) -
3635{ -
3636 Q_Q(QGraphicsItem);
executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func();
-
3637 inSetPosHelper = 1;
executed (the execution status of this line is deduced): inSetPosHelper = 1;
-
3638 if (scene)
evaluated: scene
TRUEFALSE
yes
Evaluation Count:998
yes
Evaluation Count:38
38-998
3639 q->prepareGeometryChange();
executed: q->prepareGeometryChange();
Execution Count:998
998
3640 QPointF oldPos = this->pos;
executed (the execution status of this line is deduced): QPointF oldPos = this->pos;
-
3641 this->pos = pos;
executed (the execution status of this line is deduced): this->pos = pos;
-
3642 dirtySceneTransform = 1;
executed (the execution status of this line is deduced): dirtySceneTransform = 1;
-
3643 inSetPosHelper = 0;
executed (the execution status of this line is deduced): inSetPosHelper = 0;
-
3644 if (isObject) {
evaluated: isObject
TRUEFALSE
yes
Evaluation Count:878
yes
Evaluation Count:158
158-878
3645 if (pos.x() != oldPos.x())
evaluated: pos.x() != oldPos.x()
TRUEFALSE
yes
Evaluation Count:613
yes
Evaluation Count:265
265-613
3646 emit static_cast<QGraphicsObject *>(q_ptr)->xChanged();
executed: static_cast<QGraphicsObject *>(q_ptr)->xChanged();
Execution Count:613
613
3647 if (pos.y() != oldPos.y())
evaluated: pos.y() != oldPos.y()
TRUEFALSE
yes
Evaluation Count:585
yes
Evaluation Count:293
293-585
3648 emit static_cast<QGraphicsObject *>(q_ptr)->yChanged();
executed: static_cast<QGraphicsObject *>(q_ptr)->yChanged();
Execution Count:585
585
3649 }
executed: }
Execution Count:878
878
3650}
executed: }
Execution Count:1036
1036
3651 -
3652/*! -
3653 \internal -
3654 -
3655 Sets the transform \a transform. -
3656*/ -
3657void QGraphicsItemPrivate::setTransformHelper(const QTransform &transform) -
3658{ -
3659 q_ptr->prepareGeometryChange();
executed (the execution status of this line is deduced): q_ptr->prepareGeometryChange();
-
3660 transformData->transform = transform;
executed (the execution status of this line is deduced): transformData->transform = transform;
-
3661 dirtySceneTransform = 1;
executed (the execution status of this line is deduced): dirtySceneTransform = 1;
-
3662 transformChanged();
executed (the execution status of this line is deduced): transformChanged();
-
3663}
executed: }
Execution Count:14
14
3664 -
3665/*! -
3666 Sets the position of the item to \a pos, which is in parent -
3667 coordinates. For items with no parent, \a pos is in scene -
3668 coordinates. -
3669 -
3670 The position of the item describes its origin (local coordinate -
3671 (0, 0)) in parent coordinates. -
3672 -
3673 \sa pos(), scenePos(), {The Graphics View Coordinate System} -
3674*/ -
3675void QGraphicsItem::setPos(const QPointF &pos) -
3676{ -
3677 if (d_ptr->pos == pos)
evaluated: d_ptr->pos == pos
TRUEFALSE
yes
Evaluation Count:1228
yes
Evaluation Count:1036
1036-1228
3678 return;
executed: return;
Execution Count:1228
1228
3679 -
3680 if (d_ptr->inDestructor)
partially evaluated: d_ptr->inDestructor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1036
0-1036
3681 return;
never executed: return;
0
3682 -
3683 // Update and repositition. -
3684 if (!(d_ptr->flags & (ItemSendsGeometryChanges | ItemSendsScenePositionChanges))) {
evaluated: !(d_ptr->flags & (ItemSendsGeometryChanges | ItemSendsScenePositionChanges))
TRUEFALSE
yes
Evaluation Count:283
yes
Evaluation Count:753
283-753
3685 d_ptr->setPosHelper(pos);
executed (the execution status of this line is deduced): d_ptr->setPosHelper(pos);
-
3686 if (d_ptr->isWidget)
partially evaluated: d_ptr->isWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:283
0-283
3687 static_cast<QGraphicsWidget *>(this)->d_func()->setGeometryFromSetPos();
never executed: static_cast<QGraphicsWidget *>(this)->d_func()->setGeometryFromSetPos();
0
3688 if (d_ptr->scenePosDescendants)
partially evaluated: d_ptr->scenePosDescendants
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:283
0-283
3689 d_ptr->sendScenePosChange();
never executed: d_ptr->sendScenePosChange();
0
3690 return;
executed: return;
Execution Count:283
283
3691 } -
3692 -
3693 // Notify the item that the position is changing. -
3694 const QVariant newPosVariant(itemChange(ItemPositionChange, QVariant::fromValue<QPointF>(pos)));
executed (the execution status of this line is deduced): const QVariant newPosVariant(itemChange(ItemPositionChange, QVariant::fromValue<QPointF>(pos)));
-
3695 QPointF newPos = newPosVariant.toPointF();
executed (the execution status of this line is deduced): QPointF newPos = newPosVariant.toPointF();
-
3696 if (newPos == d_ptr->pos)
partially evaluated: newPos == d_ptr->pos
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:753
0-753
3697 return;
never executed: return;
0
3698 -
3699 // Update and repositition. -
3700 d_ptr->setPosHelper(newPos);
executed (the execution status of this line is deduced): d_ptr->setPosHelper(newPos);
-
3701 -
3702 // Send post-notification. -
3703 itemChange(QGraphicsItem::ItemPositionHasChanged, newPosVariant);
executed (the execution status of this line is deduced): itemChange(QGraphicsItem::ItemPositionHasChanged, newPosVariant);
-
3704 d_ptr->sendScenePosChange();
executed (the execution status of this line is deduced): d_ptr->sendScenePosChange();
-
3705}
executed: }
Execution Count:753
753
3706 -
3707/*! -
3708 \fn void QGraphicsItem::setPos(qreal x, qreal y) -
3709 \overload -
3710 -
3711 This convenience function is equivalent to calling setPos(QPointF(\a x, \a -
3712 y)). -
3713*/ -
3714 -
3715/*! -
3716 \fn void QGraphicsItem::moveBy(qreal dx, qreal dy) -
3717 -
3718 Moves the item by \a dx points horizontally, and \a dy point -
3719 vertically. This function is equivalent to calling setPos(pos() + -
3720 QPointF(\a dx, \a dy)). -
3721*/ -
3722 -
3723/*! -
3724 If this item is part of a scene that is viewed by a QGraphicsView, this -
3725 convenience function will attempt to scroll the view to ensure that \a -
3726 rect is visible inside the view's viewport. If \a rect is a null rect (the -
3727 default), QGraphicsItem will default to the item's bounding rect. \a xmargin -
3728 and \a ymargin are the number of pixels the view should use for margins. -
3729 -
3730 If the specified rect cannot be reached, the contents are scrolled to the -
3731 nearest valid position. -
3732 -
3733 If this item is not viewed by a QGraphicsView, this function does nothing. -
3734 -
3735 \sa QGraphicsView::ensureVisible() -
3736*/ -
3737void QGraphicsItem::ensureVisible(const QRectF &rect, int xmargin, int ymargin) -
3738{ -
3739 if (d_ptr->scene) {
never evaluated: d_ptr->scene
0
3740 QRectF sceneRect;
never executed (the execution status of this line is deduced): QRectF sceneRect;
-
3741 if (!rect.isNull())
never evaluated: !rect.isNull()
0
3742 sceneRect = sceneTransform().mapRect(rect);
never executed: sceneRect = sceneTransform().mapRect(rect);
0
3743 else -
3744 sceneRect = sceneBoundingRect();
never executed: sceneRect = sceneBoundingRect();
0
3745 foreach (QGraphicsView *view, d_ptr->scene->d_func()->views)
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(d_ptr->scene->d_func()->views)> _container_(d_ptr->scene->d_func()->views); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsView *view = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
3746 view->ensureVisible(sceneRect, xmargin, ymargin);
never executed: view->ensureVisible(sceneRect, xmargin, ymargin);
0
3747 }
never executed: }
0
3748}
never executed: }
0
3749 -
3750/*! -
3751 \fn void QGraphicsItem::ensureVisible(qreal x, qreal y, qreal w, qreal h, -
3752 int xmargin = 50, int ymargin = 50) -
3753 -
3754 This convenience function is equivalent to calling -
3755 ensureVisible(QRectF(\a x, \a y, \a w, \a h), \a xmargin, \a ymargin). -
3756*/ -
3757 -
3758/*! -
3759 \obsolete -
3760 -
3761 Returns the item's affine transformation matrix. This is a subset or the -
3762 item's full transformation matrix, and might not represent the item's full -
3763 transformation. -
3764 -
3765 Use transform() instead. -
3766 -
3767 \sa setTransform(), sceneTransform() -
3768*/ -
3769QMatrix QGraphicsItem::matrix() const -
3770{ -
3771 return transform().toAffine();
never executed: return transform().toAffine();
0
3772} -
3773 -
3774/*! -
3775 \since 4.3 -
3776 -
3777 Returns this item's transformation matrix. -
3778 -
3779 The transformation matrix is combined with the item's rotation(), scale() -
3780 and transformations() into a combined transformations for the item. -
3781 -
3782 The default transformation matrix is an identity matrix. -
3783 -
3784 \sa setTransform(), sceneTransform() -
3785*/ -
3786QTransform QGraphicsItem::transform() const -
3787{ -
3788 if (!d_ptr->transformData)
never evaluated: !d_ptr->transformData
0
3789 return QTransform();
never executed: return QTransform();
0
3790 return d_ptr->transformData->transform;
never executed: return d_ptr->transformData->transform;
0
3791} -
3792 -
3793/*! -
3794 \since 4.6 -
3795 -
3796 Returns the clockwise rotation, in degrees, around the Z axis. The default -
3797 value is 0 (i.e., the item is not rotated). -
3798 -
3799 The rotation is combined with the item's scale(), transform() and -
3800 transformations() to map the item's coordinate system to the parent item. -
3801 -
3802 \sa setRotation(), transformOriginPoint(), {Transformations} -
3803*/ -
3804qreal QGraphicsItem::rotation() const -
3805{ -
3806 if (!d_ptr->transformData)
never evaluated: !d_ptr->transformData
0
3807 return 0;
never executed: return 0;
0
3808 return d_ptr->transformData->rotation;
never executed: return d_ptr->transformData->rotation;
0
3809} -
3810 -
3811/*! -
3812 \since 4.6 -
3813 -
3814 Sets the clockwise rotation \a angle, in degrees, around the Z axis. The -
3815 default value is 0 (i.e., the item is not rotated). Assigning a negative -
3816 value will rotate the item counter-clockwise. Normally the rotation angle -
3817 is in the range (-360, 360), but it's also possible to assign values -
3818 outside of this range (e.g., a rotation of 370 degrees is the same as a -
3819 rotation of 10 degrees). -
3820 -
3821 The item is rotated around its transform origin point, which by default -
3822 is (0, 0). You can select a different transformation origin by calling -
3823 setTransformOriginPoint(). -
3824 -
3825 The rotation is combined with the item's scale(), transform() and -
3826 transformations() to map the item's coordinate system to the parent item. -
3827 -
3828 \sa rotation(), setTransformOriginPoint(), {Transformations} -
3829*/ -
3830void QGraphicsItem::setRotation(qreal angle) -
3831{ -
3832 prepareGeometryChange();
never executed (the execution status of this line is deduced): prepareGeometryChange();
-
3833 qreal newRotation = angle;
never executed (the execution status of this line is deduced): qreal newRotation = angle;
-
3834 -
3835 if (d_ptr->flags & ItemSendsGeometryChanges) {
never evaluated: d_ptr->flags & ItemSendsGeometryChanges
0
3836 // Notify the item that the rotation is changing. -
3837 const QVariant newRotationVariant(itemChange(ItemRotationChange, angle));
never executed (the execution status of this line is deduced): const QVariant newRotationVariant(itemChange(ItemRotationChange, angle));
-
3838 newRotation = newRotationVariant.toReal();
never executed (the execution status of this line is deduced): newRotation = newRotationVariant.toReal();
-
3839 }
never executed: }
0
3840 -
3841 if (!d_ptr->transformData)
never evaluated: !d_ptr->transformData
0
3842 d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
0
3843 -
3844 if (d_ptr->transformData->rotation == newRotation)
never evaluated: d_ptr->transformData->rotation == newRotation
0
3845 return;
never executed: return;
0
3846 -
3847 d_ptr->transformData->rotation = newRotation;
never executed (the execution status of this line is deduced): d_ptr->transformData->rotation = newRotation;
-
3848 d_ptr->transformData->onlyTransform = false;
never executed (the execution status of this line is deduced): d_ptr->transformData->onlyTransform = false;
-
3849 d_ptr->dirtySceneTransform = 1;
never executed (the execution status of this line is deduced): d_ptr->dirtySceneTransform = 1;
-
3850 -
3851 // Send post-notification. -
3852 if (d_ptr->flags & ItemSendsGeometryChanges)
never evaluated: d_ptr->flags & ItemSendsGeometryChanges
0
3853 itemChange(ItemRotationHasChanged, newRotation);
never executed: itemChange(ItemRotationHasChanged, newRotation);
0
3854 -
3855 if (d_ptr->isObject)
never evaluated: d_ptr->isObject
0
3856 emit static_cast<QGraphicsObject *>(this)->rotationChanged();
never executed: static_cast<QGraphicsObject *>(this)->rotationChanged();
0
3857 -
3858 d_ptr->transformChanged();
never executed (the execution status of this line is deduced): d_ptr->transformChanged();
-
3859}
never executed: }
0
3860 -
3861/*! -
3862 \since 4.6 -
3863 -
3864 Returns the scale factor of the item. The default scale factor is 1.0 -
3865 (i.e., the item is not scaled). -
3866 -
3867 The scale is combined with the item's rotation(), transform() and -
3868 transformations() to map the item's coordinate system to the parent item. -
3869 -
3870 \sa setScale(), rotation(), {Transformations} -
3871*/ -
3872qreal QGraphicsItem::scale() const -
3873{ -
3874 if (!d_ptr->transformData)
never evaluated: !d_ptr->transformData
0
3875 return 1.;
never executed: return 1.;
0
3876 return d_ptr->transformData->scale;
never executed: return d_ptr->transformData->scale;
0
3877} -
3878 -
3879/*! -
3880 \since 4.6 -
3881 -
3882 Sets the scale \a factor of the item. The default scale factor is 1.0 -
3883 (i.e., the item is not scaled). A scale factor of 0.0 will collapse the -
3884 item to a single point. If you provide a negative scale factor, the -
3885 item will be flipped and mirrored (i.e., rotated 180 degrees). -
3886 -
3887 The item is scaled around its transform origin point, which by default -
3888 is (0, 0). You can select a different transformation origin by calling -
3889 setTransformOriginPoint(). -
3890 -
3891 The scale is combined with the item's rotation(), transform() and -
3892 transformations() to map the item's coordinate system to the parent item. -
3893 -
3894 \sa scale(), setTransformOriginPoint(), {Transformations Example} -
3895*/ -
3896void QGraphicsItem::setScale(qreal factor) -
3897{ -
3898 prepareGeometryChange();
never executed (the execution status of this line is deduced): prepareGeometryChange();
-
3899 qreal newScale = factor;
never executed (the execution status of this line is deduced): qreal newScale = factor;
-
3900 -
3901 if (d_ptr->flags & ItemSendsGeometryChanges) {
never evaluated: d_ptr->flags & ItemSendsGeometryChanges
0
3902 // Notify the item that the scale is changing. -
3903 const QVariant newScaleVariant(itemChange(ItemScaleChange, factor));
never executed (the execution status of this line is deduced): const QVariant newScaleVariant(itemChange(ItemScaleChange, factor));
-
3904 newScale = newScaleVariant.toReal();
never executed (the execution status of this line is deduced): newScale = newScaleVariant.toReal();
-
3905 }
never executed: }
0
3906 -
3907 if (!d_ptr->transformData)
never evaluated: !d_ptr->transformData
0
3908 d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
0
3909 -
3910 if (d_ptr->transformData->scale == newScale)
never evaluated: d_ptr->transformData->scale == newScale
0
3911 return;
never executed: return;
0
3912 -
3913 d_ptr->transformData->scale = newScale;
never executed (the execution status of this line is deduced): d_ptr->transformData->scale = newScale;
-
3914 d_ptr->transformData->onlyTransform = false;
never executed (the execution status of this line is deduced): d_ptr->transformData->onlyTransform = false;
-
3915 d_ptr->dirtySceneTransform = 1;
never executed (the execution status of this line is deduced): d_ptr->dirtySceneTransform = 1;
-
3916 -
3917 // Send post-notification. -
3918 if (d_ptr->flags & ItemSendsGeometryChanges)
never evaluated: d_ptr->flags & ItemSendsGeometryChanges
0
3919 itemChange(ItemScaleHasChanged, newScale);
never executed: itemChange(ItemScaleHasChanged, newScale);
0
3920 -
3921 if (d_ptr->isObject)
never evaluated: d_ptr->isObject
0
3922 emit static_cast<QGraphicsObject *>(this)->scaleChanged();
never executed: static_cast<QGraphicsObject *>(this)->scaleChanged();
0
3923 -
3924 d_ptr->transformChanged();
never executed (the execution status of this line is deduced): d_ptr->transformChanged();
-
3925}
never executed: }
0
3926 -
3927 -
3928/*! -
3929 \since 4.6 -
3930 -
3931 Returns a list of graphics transforms that currently apply to this item. -
3932 -
3933 QGraphicsTransform is for applying and controlling a chain of individual -
3934 transformation operations on an item. It's particularly useful in -
3935 animations, where each transform operation needs to be interpolated -
3936 independently, or differently. -
3937 -
3938 The transformations are combined with the item's rotation(), scale() and -
3939 transform() to map the item's coordinate system to the parent item. -
3940 -
3941 \sa scale(), rotation(), transformOriginPoint(), {Transformations} -
3942*/ -
3943QList<QGraphicsTransform *> QGraphicsItem::transformations() const -
3944{ -
3945 if (!d_ptr->transformData)
never evaluated: !d_ptr->transformData
0
3946 return QList<QGraphicsTransform *>();
never executed: return QList<QGraphicsTransform *>();
0
3947 return d_ptr->transformData->graphicsTransforms;
never executed: return d_ptr->transformData->graphicsTransforms;
0
3948} -
3949 -
3950/*! -
3951 \since 4.6 -
3952 -
3953 Sets a list of graphics \a transformations (QGraphicsTransform) that -
3954 currently apply to this item. -
3955 -
3956 If all you want is to rotate or scale an item, you should call setRotation() -
3957 or setScale() instead. If you want to set an arbitrary transformation on -
3958 an item, you can call setTransform(). -
3959 -
3960 QGraphicsTransform is for applying and controlling a chain of individual -
3961 transformation operations on an item. It's particularly useful in -
3962 animations, where each transform operation needs to be interpolated -
3963 independently, or differently. -
3964 -
3965 The transformations are combined with the item's rotation(), scale() and -
3966 transform() to map the item's coordinate system to the parent item. -
3967 -
3968 \sa scale(), setTransformOriginPoint(), {Transformations} -
3969*/ -
3970void QGraphicsItem::setTransformations(const QList<QGraphicsTransform *> &transformations) -
3971{ -
3972 prepareGeometryChange();
never executed (the execution status of this line is deduced): prepareGeometryChange();
-
3973 if (!d_ptr->transformData)
never evaluated: !d_ptr->transformData
0
3974 d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
0
3975 d_ptr->transformData->graphicsTransforms = transformations;
never executed (the execution status of this line is deduced): d_ptr->transformData->graphicsTransforms = transformations;
-
3976 for (int i = 0; i < transformations.size(); ++i)
never evaluated: i < transformations.size()
0
3977 transformations.at(i)->d_func()->setItem(this);
never executed: transformations.at(i)->d_func()->setItem(this);
0
3978 d_ptr->transformData->onlyTransform = false;
never executed (the execution status of this line is deduced): d_ptr->transformData->onlyTransform = false;
-
3979 d_ptr->dirtySceneTransform = 1;
never executed (the execution status of this line is deduced): d_ptr->dirtySceneTransform = 1;
-
3980 d_ptr->transformChanged();
never executed (the execution status of this line is deduced): d_ptr->transformChanged();
-
3981}
never executed: }
0
3982 -
3983/*! -
3984 \internal -
3985*/ -
3986void QGraphicsItemPrivate::prependGraphicsTransform(QGraphicsTransform *t) -
3987{ -
3988 if (!transformData)
never evaluated: !transformData
0
3989 transformData = new QGraphicsItemPrivate::TransformData;
never executed: transformData = new QGraphicsItemPrivate::TransformData;
0
3990 if (!transformData->graphicsTransforms.contains(t))
never evaluated: !transformData->graphicsTransforms.contains(t)
0
3991 transformData->graphicsTransforms.prepend(t);
never executed: transformData->graphicsTransforms.prepend(t);
0
3992 -
3993 Q_Q(QGraphicsItem);
never executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func();
-
3994 t->d_func()->setItem(q);
never executed (the execution status of this line is deduced): t->d_func()->setItem(q);
-
3995 transformData->onlyTransform = false;
never executed (the execution status of this line is deduced): transformData->onlyTransform = false;
-
3996 dirtySceneTransform = 1;
never executed (the execution status of this line is deduced): dirtySceneTransform = 1;
-
3997 transformChanged();
never executed (the execution status of this line is deduced): transformChanged();
-
3998}
never executed: }
0
3999 -
4000/*! -
4001 \internal -
4002*/ -
4003void QGraphicsItemPrivate::appendGraphicsTransform(QGraphicsTransform *t) -
4004{ -
4005 if (!transformData)
never evaluated: !transformData
0
4006 transformData = new QGraphicsItemPrivate::TransformData;
never executed: transformData = new QGraphicsItemPrivate::TransformData;
0
4007 if (!transformData->graphicsTransforms.contains(t))
never evaluated: !transformData->graphicsTransforms.contains(t)
0
4008 transformData->graphicsTransforms.append(t);
never executed: transformData->graphicsTransforms.append(t);
0
4009 -
4010 Q_Q(QGraphicsItem);
never executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func();
-
4011 t->d_func()->setItem(q);
never executed (the execution status of this line is deduced): t->d_func()->setItem(q);
-
4012 transformData->onlyTransform = false;
never executed (the execution status of this line is deduced): transformData->onlyTransform = false;
-
4013 dirtySceneTransform = 1;
never executed (the execution status of this line is deduced): dirtySceneTransform = 1;
-
4014 transformChanged();
never executed (the execution status of this line is deduced): transformChanged();
-
4015}
never executed: }
0
4016 -
4017/*! -
4018 \since 4.6 -
4019 -
4020 Returns the origin point for the transformation in item coordinates. -
4021 -
4022 The default is QPointF(0,0). -
4023 -
4024 \sa setTransformOriginPoint(), {Transformations} -
4025*/ -
4026QPointF QGraphicsItem::transformOriginPoint() const -
4027{ -
4028 if (!d_ptr->transformData)
never evaluated: !d_ptr->transformData
0
4029 return QPointF(0,0);
never executed: return QPointF(0,0);
0
4030 return QPointF(d_ptr->transformData->xOrigin, d_ptr->transformData->yOrigin);
never executed: return QPointF(d_ptr->transformData->xOrigin, d_ptr->transformData->yOrigin);
0
4031} -
4032 -
4033/*! -
4034 \since 4.6 -
4035 -
4036 Sets the \a origin point for the transformation in item coordinates. -
4037 -
4038 \sa transformOriginPoint(), {Transformations} -
4039*/ -
4040void QGraphicsItem::setTransformOriginPoint(const QPointF &origin) -
4041{ -
4042 prepareGeometryChange();
never executed (the execution status of this line is deduced): prepareGeometryChange();
-
4043 QPointF newOrigin = origin;
never executed (the execution status of this line is deduced): QPointF newOrigin = origin;
-
4044 -
4045 if (d_ptr->flags & ItemSendsGeometryChanges) {
never evaluated: d_ptr->flags & ItemSendsGeometryChanges
0
4046 // Notify the item that the origin point is changing. -
4047 const QVariant newOriginVariant(itemChange(ItemTransformOriginPointChange,
never executed (the execution status of this line is deduced): const QVariant newOriginVariant(itemChange(ItemTransformOriginPointChange,
-
4048 QVariant::fromValue<QPointF>(origin)));
never executed (the execution status of this line is deduced): QVariant::fromValue<QPointF>(origin)));
-
4049 newOrigin = newOriginVariant.toPointF();
never executed (the execution status of this line is deduced): newOrigin = newOriginVariant.toPointF();
-
4050 }
never executed: }
0
4051 -
4052 if (!d_ptr->transformData)
never evaluated: !d_ptr->transformData
0
4053 d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
0
4054 -
4055 if (d_ptr->transformData->xOrigin == newOrigin.x()
never evaluated: d_ptr->transformData->xOrigin == newOrigin.x()
0
4056 && d_ptr->transformData->yOrigin == newOrigin.y()) {
never evaluated: d_ptr->transformData->yOrigin == newOrigin.y()
0
4057 return;
never executed: return;
0
4058 } -
4059 -
4060 d_ptr->transformData->xOrigin = newOrigin.x();
never executed (the execution status of this line is deduced): d_ptr->transformData->xOrigin = newOrigin.x();
-
4061 d_ptr->transformData->yOrigin = newOrigin.y();
never executed (the execution status of this line is deduced): d_ptr->transformData->yOrigin = newOrigin.y();
-
4062 d_ptr->transformData->onlyTransform = false;
never executed (the execution status of this line is deduced): d_ptr->transformData->onlyTransform = false;
-
4063 d_ptr->dirtySceneTransform = 1;
never executed (the execution status of this line is deduced): d_ptr->dirtySceneTransform = 1;
-
4064 -
4065 // Send post-notification. -
4066 if (d_ptr->flags & ItemSendsGeometryChanges)
never evaluated: d_ptr->flags & ItemSendsGeometryChanges
0
4067 itemChange(ItemTransformOriginPointHasChanged, QVariant::fromValue<QPointF>(newOrigin));
never executed: itemChange(ItemTransformOriginPointHasChanged, QVariant::fromValue<QPointF>(newOrigin));
0
4068}
never executed: }
0
4069 -
4070/*! -
4071 \fn void QGraphicsItem::setTransformOriginPoint(qreal x, qreal y) -
4072 -
4073 \since 4.6 -
4074 \overload -
4075 -
4076 Sets the origin point for the transformation in item coordinates. -
4077 This is equivalent to calling setTransformOriginPoint(QPointF(\a x, \a y)). -
4078 -
4079 \sa setTransformOriginPoint(), {Transformations} -
4080*/ -
4081 -
4082 -
4083/*! -
4084 \obsolete -
4085 -
4086 Use sceneTransform() instead. -
4087 -
4088 \sa transform(), setTransform(), scenePos(), {The Graphics View Coordinate System} -
4089*/ -
4090QMatrix QGraphicsItem::sceneMatrix() const -
4091{ -
4092 d_ptr->ensureSceneTransform();
never executed (the execution status of this line is deduced): d_ptr->ensureSceneTransform();
-
4093 return d_ptr->sceneTransform.toAffine();
never executed: return d_ptr->sceneTransform.toAffine();
0
4094} -
4095 -
4096 -
4097/*! -
4098 \since 4.3 -
4099 -
4100 Returns this item's scene transformation matrix. This matrix can be used -
4101 to map coordinates and geometrical shapes from this item's local -
4102 coordinate system to the scene's coordinate system. To map coordinates -
4103 from the scene, you must first invert the returned matrix. -
4104 -
4105 Example: -
4106 -
4107 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 4 -
4108 -
4109 Unlike transform(), which returns only an item's local transformation, this -
4110 function includes the item's (and any parents') position, and all the transfomation properties. -
4111 -
4112 \sa transform(), setTransform(), scenePos(), {The Graphics View Coordinate System}, {Transformations} -
4113*/ -
4114QTransform QGraphicsItem::sceneTransform() const -
4115{ -
4116 d_ptr->ensureSceneTransform();
executed (the execution status of this line is deduced): d_ptr->ensureSceneTransform();
-
4117 return d_ptr->sceneTransform;
executed: return d_ptr->sceneTransform;
Execution Count:35
35
4118} -
4119 -
4120/*! -
4121 \since 4.3 -
4122 -
4123 Returns this item's device transformation matrix, using \a -
4124 viewportTransform to map from scene to device coordinates. This matrix can -
4125 be used to map coordinates and geometrical shapes from this item's local -
4126 coordinate system to the viewport's (or any device's) coordinate -
4127 system. To map coordinates from the viewport, you must first invert the -
4128 returned matrix. -
4129 -
4130 Example: -
4131 -
4132 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 5 -
4133 -
4134 This function is the same as combining this item's scene transform with -
4135 the view's viewport transform, but it also understands the -
4136 ItemIgnoresTransformations flag. The device transform can be used to do -
4137 accurate coordinate mapping (and collision detection) for untransformable -
4138 items. -
4139 -
4140 \sa transform(), setTransform(), scenePos(), {The Graphics View Coordinate -
4141 System}, itemTransform() -
4142*/ -
4143QTransform QGraphicsItem::deviceTransform(const QTransform &viewportTransform) const -
4144{ -
4145 // Ensure we return the standard transform if we're not untransformable. -
4146 if (!d_ptr->itemIsUntransformable()) {
evaluated: !d_ptr->itemIsUntransformable()
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:8
8-19
4147 d_ptr->ensureSceneTransform();
executed (the execution status of this line is deduced): d_ptr->ensureSceneTransform();
-
4148 return d_ptr->sceneTransform * viewportTransform;
executed: return d_ptr->sceneTransform * viewportTransform;
Execution Count:19
19
4149 } -
4150 -
4151 // Find the topmost item that ignores view transformations. -
4152 const QGraphicsItem *untransformedAncestor = this;
executed (the execution status of this line is deduced): const QGraphicsItem *untransformedAncestor = this;
-
4153 QList<const QGraphicsItem *> parents;
executed (the execution status of this line is deduced): QList<const QGraphicsItem *> parents;
-
4154 while (untransformedAncestor && ((untransformedAncestor->d_ptr->ancestorFlags
partially evaluated: untransformedAncestor
TRUEFALSE
yes
Evaluation Count:9
no
Evaluation Count:0
evaluated: ((untransformedAncestor->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorIgnoresTransformations))
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:8
0-9
4155 & QGraphicsItemPrivate::AncestorIgnoresTransformations))) {
evaluated: ((untransformedAncestor->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorIgnoresTransformations))
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:8
1-8
4156 parents.prepend(untransformedAncestor);
executed (the execution status of this line is deduced): parents.prepend(untransformedAncestor);
-
4157 untransformedAncestor = untransformedAncestor->parentItem();
executed (the execution status of this line is deduced): untransformedAncestor = untransformedAncestor->parentItem();
-
4158 }
executed: }
Execution Count:1
1
4159 -
4160 if (!untransformedAncestor) {
partially evaluated: !untransformedAncestor
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
4161 // Assert in debug mode, continue in release. -
4162 Q_ASSERT_X(untransformedAncestor, "QGraphicsItem::deviceTransform",
never executed (the execution status of this line is deduced): qt_noop();
-
4163 "Invalid object structure!"); -
4164 return QTransform();
never executed: return QTransform();
0
4165 } -
4166 -
4167 // First translate the base untransformable item. -
4168 untransformedAncestor->d_ptr->ensureSceneTransform();
executed (the execution status of this line is deduced): untransformedAncestor->d_ptr->ensureSceneTransform();
-
4169 QPointF mappedPoint = (untransformedAncestor->d_ptr->sceneTransform * viewportTransform).map(QPointF(0, 0));
executed (the execution status of this line is deduced): QPointF mappedPoint = (untransformedAncestor->d_ptr->sceneTransform * viewportTransform).map(QPointF(0, 0));
-
4170 -
4171 // COMBINE -
4172 QTransform matrix = QTransform::fromTranslate(mappedPoint.x(), mappedPoint.y());
executed (the execution status of this line is deduced): QTransform matrix = QTransform::fromTranslate(mappedPoint.x(), mappedPoint.y());
-
4173 if (untransformedAncestor->d_ptr->transformData)
partially evaluated: untransformedAncestor->d_ptr->transformData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:8
0-8
4174 matrix = untransformedAncestor->d_ptr->transformData->computedFullTransform(&matrix);
never executed: matrix = untransformedAncestor->d_ptr->transformData->computedFullTransform(&matrix);
0
4175 -
4176 // Then transform and translate all children. -
4177 for (int i = 0; i < parents.size(); ++i) {
evaluated: i < parents.size()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:8
1-8
4178 const QGraphicsItem *parent = parents.at(i);
executed (the execution status of this line is deduced): const QGraphicsItem *parent = parents.at(i);
-
4179 parent->d_ptr->combineTransformFromParent(&matrix);
executed (the execution status of this line is deduced): parent->d_ptr->combineTransformFromParent(&matrix);
-
4180 }
executed: }
Execution Count:1
1
4181 -
4182 return matrix;
executed: return matrix;
Execution Count:8
8
4183} -
4184 -
4185/*! -
4186 \since 4.5 -
4187 -
4188 Returns a QTransform that maps coordinates from this item to \a other. If -
4189 \a ok is not null, and if there is no such transform, the boolean pointed -
4190 to by \a ok will be set to false; otherwise it will be set to true. -
4191 -
4192 This transform provides an alternative to the mapToItem() or mapFromItem() -
4193 functions, by returning the appropriate transform so that you can map -
4194 shapes and coordinates yourself. It also helps you write more efficient -
4195 code when repeatedly mapping between the same two items. -
4196 -
4197 \note In rare circumstances, there is no transform that maps between two -
4198 items. -
4199 -
4200 \sa mapToItem(), mapFromItem(), deviceTransform() -
4201*/ -
4202QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) const -
4203{ -
4204 // Catch simple cases first. -
4205 if (other == 0) {
partially evaluated: other == 0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:44
0-44
4206 qWarning("QGraphicsItem::itemTransform: null pointer passed");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 4206, __PRETTY_FUNCTION__).warning("QGraphicsItem::itemTransform: null pointer passed");
-
4207 return QTransform();
never executed: return QTransform();
0
4208 } -
4209 if (other == this) {
partially evaluated: other == this
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:44
0-44
4210 if (ok)
never evaluated: ok
0
4211 *ok = true;
never executed: *ok = true;
0
4212 return QTransform();
never executed: return QTransform();
0
4213 } -
4214 -
4215 QGraphicsItem *parent = d_ptr->parent;
executed (the execution status of this line is deduced): QGraphicsItem *parent = d_ptr->parent;
-
4216 const QGraphicsItem *otherParent = other->d_ptr->parent;
executed (the execution status of this line is deduced): const QGraphicsItem *otherParent = other->d_ptr->parent;
-
4217 -
4218 // This is other's child -
4219 if (parent == other) {
evaluated: parent == other
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:25
19-25
4220 if (ok)
partially evaluated: ok
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:19
0-19
4221 *ok = true;
never executed: *ok = true;
0
4222 QTransform x;
executed (the execution status of this line is deduced): QTransform x;
-
4223 d_ptr->combineTransformFromParent(&x);
executed (the execution status of this line is deduced): d_ptr->combineTransformFromParent(&x);
-
4224 return x;
executed: return x;
Execution Count:19
19
4225 } -
4226 -
4227 // This is other's parent -
4228 if (otherParent == this) {
evaluated: otherParent == this
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:6
6-19
4229 const QPointF &otherPos = other->d_ptr->pos;
executed (the execution status of this line is deduced): const QPointF &otherPos = other->d_ptr->pos;
-
4230 if (other->d_ptr->transformData) {
partially evaluated: other->d_ptr->transformData
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:19
0-19
4231 QTransform otherToParent;
never executed (the execution status of this line is deduced): QTransform otherToParent;
-
4232 other->d_ptr->combineTransformFromParent(&otherToParent);
never executed (the execution status of this line is deduced): other->d_ptr->combineTransformFromParent(&otherToParent);
-
4233 return otherToParent.inverted(ok);
never executed: return otherToParent.inverted(ok);
0
4234 } -
4235 if (ok)
partially evaluated: ok
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:19
0-19
4236 *ok = true;
never executed: *ok = true;
0
4237 return QTransform::fromTranslate(-otherPos.x(), -otherPos.y());
executed: return QTransform::fromTranslate(-otherPos.x(), -otherPos.y());
Execution Count:19
19
4238 } -
4239 -
4240 // Siblings -
4241 if (parent == otherParent) {
partially evaluated: parent == otherParent
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
4242 // COMBINE -
4243 const QPointF &itemPos = d_ptr->pos;
executed (the execution status of this line is deduced): const QPointF &itemPos = d_ptr->pos;
-
4244 const QPointF &otherPos = other->d_ptr->pos;
executed (the execution status of this line is deduced): const QPointF &otherPos = other->d_ptr->pos;
-
4245 if (!d_ptr->transformData && !other->d_ptr->transformData) {
partially evaluated: !d_ptr->transformData
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
partially evaluated: !other->d_ptr->transformData
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
4246 QPointF delta = itemPos - otherPos;
executed (the execution status of this line is deduced): QPointF delta = itemPos - otherPos;
-
4247 if (ok)
partially evaluated: ok
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:6
0-6
4248 *ok = true;
never executed: *ok = true;
0
4249 return QTransform::fromTranslate(delta.x(), delta.y());
executed: return QTransform::fromTranslate(delta.x(), delta.y());
Execution Count:6
6
4250 } -
4251 -
4252 QTransform itemToParent;
never executed (the execution status of this line is deduced): QTransform itemToParent;
-
4253 d_ptr->combineTransformFromParent(&itemToParent);
never executed (the execution status of this line is deduced): d_ptr->combineTransformFromParent(&itemToParent);
-
4254 QTransform otherToParent;
never executed (the execution status of this line is deduced): QTransform otherToParent;
-
4255 other->d_ptr->combineTransformFromParent(&otherToParent);
never executed (the execution status of this line is deduced): other->d_ptr->combineTransformFromParent(&otherToParent);
-
4256 return itemToParent * otherToParent.inverted(ok);
never executed: return itemToParent * otherToParent.inverted(ok);
0
4257 } -
4258 -
4259 // Find the closest common ancestor. If the two items don't share an -
4260 // ancestor, then the only way is to combine their scene transforms. -
4261 const QGraphicsItem *commonAncestor = commonAncestorItem(other);
never executed (the execution status of this line is deduced): const QGraphicsItem *commonAncestor = commonAncestorItem(other);
-
4262 if (!commonAncestor) {
never evaluated: !commonAncestor
0
4263 d_ptr->ensureSceneTransform();
never executed (the execution status of this line is deduced): d_ptr->ensureSceneTransform();
-
4264 other->d_ptr->ensureSceneTransform();
never executed (the execution status of this line is deduced): other->d_ptr->ensureSceneTransform();
-
4265 return d_ptr->sceneTransform * other->d_ptr->sceneTransform.inverted(ok);
never executed: return d_ptr->sceneTransform * other->d_ptr->sceneTransform.inverted(ok);
0
4266 } -
4267 -
4268 // If the two items are cousins (in sibling branches), map both to the -
4269 // common ancestor, and combine the two transforms. -
4270 bool cousins = other != commonAncestor && this != commonAncestor;
never evaluated: other != commonAncestor
never evaluated: this != commonAncestor
0
4271 if (cousins) {
never evaluated: cousins
0
4272 bool good = false;
never executed (the execution status of this line is deduced): bool good = false;
-
4273 QTransform thisToScene = itemTransform(commonAncestor, &good);
never executed (the execution status of this line is deduced): QTransform thisToScene = itemTransform(commonAncestor, &good);
-
4274 QTransform otherToScene(Qt::Uninitialized);
never executed (the execution status of this line is deduced): QTransform otherToScene(Qt::Uninitialized);
-
4275 if (good)
never evaluated: good
0
4276 otherToScene = other->itemTransform(commonAncestor, &good);
never executed: otherToScene = other->itemTransform(commonAncestor, &good);
0
4277 if (!good) {
never evaluated: !good
0
4278 if (ok)
never evaluated: ok
0
4279 *ok = false;
never executed: *ok = false;
0
4280 return QTransform();
never executed: return QTransform();
0
4281 } -
4282 return thisToScene * otherToScene.inverted(ok);
never executed: return thisToScene * otherToScene.inverted(ok);
0
4283 } -
4284 -
4285 // One is an ancestor of the other; walk the chain. -
4286 bool parentOfOther = isAncestorOf(other);
never executed (the execution status of this line is deduced): bool parentOfOther = isAncestorOf(other);
-
4287 const QGraphicsItem *child = parentOfOther ? other : this;
never evaluated: parentOfOther
0
4288 const QGraphicsItem *root = parentOfOther ? this : other;
never evaluated: parentOfOther
0
4289 -
4290 QTransform x;
never executed (the execution status of this line is deduced): QTransform x;
-
4291 const QGraphicsItem *p = child;
never executed (the execution status of this line is deduced): const QGraphicsItem *p = child;
-
4292 do { -
4293 p->d_ptr.data()->combineTransformToParent(&x);
never executed (the execution status of this line is deduced): p->d_ptr.data()->combineTransformToParent(&x);
-
4294 } while ((p = p->d_ptr->parent) && p != root);
never executed: }
never evaluated: (p = p->d_ptr->parent)
never evaluated: p != root
0
4295 if (parentOfOther)
never evaluated: parentOfOther
0
4296 return x.inverted(ok);
never executed: return x.inverted(ok);
0
4297 if (ok)
never evaluated: ok
0
4298 *ok = true;
never executed: *ok = true;
0
4299 return x;
never executed: return x;
0
4300} -
4301 -
4302/*! -
4303 \obsolete -
4304 -
4305 Sets the item's affine transformation matrix. This is a subset or the -
4306 item's full transformation matrix, and might not represent the item's full -
4307 transformation. -
4308 -
4309 Use setTransform() instead. -
4310 -
4311 \sa transform(), {The Graphics View Coordinate System} -
4312*/ -
4313void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine) -
4314{ -
4315 if (!d_ptr->transformData)
never evaluated: !d_ptr->transformData
0
4316 d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
0
4317 -
4318 QTransform newTransform(combine ? QTransform(matrix) * d_ptr->transformData->transform : QTransform(matrix));
never executed (the execution status of this line is deduced): QTransform newTransform(combine ? QTransform(matrix) * d_ptr->transformData->transform : QTransform(matrix));
-
4319 if (d_ptr->transformData->transform == newTransform)
never evaluated: d_ptr->transformData->transform == newTransform
0
4320 return;
never executed: return;
0
4321 -
4322 // Update and set the new transformation. -
4323 if (!(d_ptr->flags & ItemSendsGeometryChanges)) {
never evaluated: !(d_ptr->flags & ItemSendsGeometryChanges)
0
4324 d_ptr->setTransformHelper(newTransform);
never executed (the execution status of this line is deduced): d_ptr->setTransformHelper(newTransform);
-
4325 return;
never executed: return;
0
4326 } -
4327 -
4328 // Notify the item that the transformation matrix is changing. -
4329 const QVariant newMatrixVariant = QVariant::fromValue<QMatrix>(newTransform.toAffine());
never executed (the execution status of this line is deduced): const QVariant newMatrixVariant = QVariant::fromValue<QMatrix>(newTransform.toAffine());
-
4330 newTransform = QTransform(qvariant_cast<QMatrix>(itemChange(ItemMatrixChange, newMatrixVariant)));
never executed (the execution status of this line is deduced): newTransform = QTransform(qvariant_cast<QMatrix>(itemChange(ItemMatrixChange, newMatrixVariant)));
-
4331 if (d_ptr->transformData->transform == newTransform)
never evaluated: d_ptr->transformData->transform == newTransform
0
4332 return;
never executed: return;
0
4333 -
4334 // Update and set the new transformation. -
4335 d_ptr->setTransformHelper(newTransform);
never executed (the execution status of this line is deduced): d_ptr->setTransformHelper(newTransform);
-
4336 -
4337 // Send post-notification. -
4338 itemChange(ItemTransformHasChanged, QVariant::fromValue<QTransform>(newTransform));
never executed (the execution status of this line is deduced): itemChange(ItemTransformHasChanged, QVariant::fromValue<QTransform>(newTransform));
-
4339}
never executed: }
0
4340 -
4341/*! -
4342 \since 4.3 -
4343 -
4344 Sets the item's current transformation matrix to \a matrix. -
4345 -
4346 If \a combine is true, then \a matrix is combined with the current matrix; -
4347 otherwise, \a matrix \e replaces the current matrix. \a combine is false -
4348 by default. -
4349 -
4350 To simplify interation with items using a transformed view, QGraphicsItem -
4351 provides mapTo... and mapFrom... functions that can translate between -
4352 items' and the scene's coordinates. For example, you can call mapToScene() -
4353 to map an item coordiate to a scene coordinate, or mapFromScene() to map -
4354 from scene coordinates to item coordinates. -
4355 -
4356 The transformation matrix is combined with the item's rotation(), scale() -
4357 and transformations() into a combined transformation that maps the item's -
4358 coordinate system to its parent. -
4359 -
4360 \sa transform(), setRotation(), setScale(), setTransformOriginPoint(), {The Graphics View Coordinate System}, {Transformations} -
4361*/ -
4362void QGraphicsItem::setTransform(const QTransform &matrix, bool combine) -
4363{ -
4364 if (!d_ptr->transformData)
partially evaluated: !d_ptr->transformData
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
4365 d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
Execution Count:14
14
4366 -
4367 QTransform newTransform(combine ? matrix * d_ptr->transformData->transform : matrix);
executed (the execution status of this line is deduced): QTransform newTransform(combine ? matrix * d_ptr->transformData->transform : matrix);
-
4368 if (d_ptr->transformData->transform == newTransform)
partially evaluated: d_ptr->transformData->transform == newTransform
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
4369 return;
never executed: return;
0
4370 -
4371 // Update and set the new transformation. -
4372 if (!(d_ptr->flags & (ItemSendsGeometryChanges | ItemSendsScenePositionChanges))) {
evaluated: !(d_ptr->flags & (ItemSendsGeometryChanges | ItemSendsScenePositionChanges))
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:2
2-12
4373 d_ptr->setTransformHelper(newTransform);
executed (the execution status of this line is deduced): d_ptr->setTransformHelper(newTransform);
-
4374 if (d_ptr->scenePosDescendants)
partially evaluated: d_ptr->scenePosDescendants
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:12
0-12
4375 d_ptr->sendScenePosChange();
never executed: d_ptr->sendScenePosChange();
0
4376 return;
executed: return;
Execution Count:12
12
4377 } -
4378 -
4379 // Notify the item that the transformation matrix is changing. -
4380 const QVariant newTransformVariant(itemChange(ItemTransformChange,
executed (the execution status of this line is deduced): const QVariant newTransformVariant(itemChange(ItemTransformChange,
-
4381 QVariant::fromValue<QTransform>(newTransform)));
executed (the execution status of this line is deduced): QVariant::fromValue<QTransform>(newTransform)));
-
4382 newTransform = qvariant_cast<QTransform>(newTransformVariant);
executed (the execution status of this line is deduced): newTransform = qvariant_cast<QTransform>(newTransformVariant);
-
4383 if (d_ptr->transformData->transform == newTransform)
partially evaluated: d_ptr->transformData->transform == newTransform
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
4384 return;
never executed: return;
0
4385 -
4386 // Update and set the new transformation. -
4387 d_ptr->setTransformHelper(newTransform);
executed (the execution status of this line is deduced): d_ptr->setTransformHelper(newTransform);
-
4388 -
4389 // Send post-notification. -
4390 itemChange(ItemTransformHasChanged, newTransformVariant);
executed (the execution status of this line is deduced): itemChange(ItemTransformHasChanged, newTransformVariant);
-
4391 d_ptr->sendScenePosChange();
executed (the execution status of this line is deduced): d_ptr->sendScenePosChange();
-
4392}
executed: }
Execution Count:2
2
4393 -
4394/*! -
4395 \obsolete -
4396 -
4397 Use resetTransform() instead. -
4398*/ -
4399void QGraphicsItem::resetMatrix() -
4400{ -
4401 resetTransform();
never executed (the execution status of this line is deduced): resetTransform();
-
4402}
never executed: }
0
4403 -
4404/*! -
4405 \since 4.3 -
4406 -
4407 Resets this item's transformation matrix to the identity matrix or -
4408 all the transformation properties to their default values. -
4409 This is equivalent to calling \c setTransform(QTransform()). -
4410 -
4411 \sa setTransform(), transform() -
4412*/ -
4413void QGraphicsItem::resetTransform() -
4414{ -
4415 setTransform(QTransform(), false);
never executed (the execution status of this line is deduced): setTransform(QTransform(), false);
-
4416}
never executed: }
0
4417 -
4418/*! -
4419 \fn void QGraphicsItem::rotate(qreal angle) -
4420 \obsolete -
4421 -
4422 Use -
4423 -
4424 \code -
4425 setRotation(rotation() + angle); -
4426 \endcode -
4427 -
4428 instead. -
4429 -
4430 Rotates the current item transformation \a angle degrees clockwise around -
4431 its origin. To translate around an arbitrary point (x, y), you need to -
4432 combine translation and rotation with setTransform(). -
4433 -
4434 Example: -
4435 -
4436 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 6 -
4437 -
4438 \sa setTransform(), transform(), scale(), shear(), translate() -
4439*/ -
4440 -
4441/*! -
4442 \fn void QGraphicsItem::scale(qreal sx, qreal sy) -
4443 \obsolete -
4444 -
4445 Use -
4446 -
4447 \code -
4448 setTransform(QTransform::fromScale(sx, sy), true); -
4449 \endcode -
4450 -
4451 instead. -
4452 -
4453 Scales the current item transformation by (\a sx, \a sy) around its -
4454 origin. To scale from an arbitrary point (x, y), you need to combine -
4455 translation and scaling with setTransform(). -
4456 -
4457 Example: -
4458 -
4459 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 7 -
4460 -
4461 \sa setTransform(), transform() -
4462*/ -
4463 -
4464/*! -
4465 \fn void QGraphicsItem::shear(qreal sh, qreal sv) -
4466 \obsolete -
4467 -
4468 Use -
4469 -
4470 \code -
4471 setTransform(QTransform().shear(sh, sv), true); -
4472 \endcode -
4473 -
4474 instead. -
4475 -
4476 Shears the current item transformation by (\a sh, \a sv). -
4477 -
4478 \sa setTransform(), transform() -
4479*/ -
4480 -
4481/*! -
4482 \fn void QGraphicsItem::translate(qreal dx, qreal dy) -
4483 \obsolete -
4484 -
4485 Use setPos() or setTransformOriginPoint() instead. For identical -
4486 behavior, use -
4487 -
4488 \code -
4489 setTransform(QTransform::fromTranslate(dx, dy), true); -
4490 \endcode -
4491 -
4492 Translates the current item transformation by (\a dx, \a dy). -
4493 -
4494 If all you want is to move an item, you should call moveBy() or -
4495 setPos() instead; this function changes the item's translation, -
4496 which is conceptually separate from its position. -
4497 -
4498 \sa setTransform(), transform() -
4499*/ -
4500 -
4501/*! -
4502 This virtual function is called twice for all items by the -
4503 QGraphicsScene::advance() slot. In the first phase, all items are called -
4504 with \a phase == 0, indicating that items on the scene are about to -
4505 advance, and then all items are called with \a phase == 1. Reimplement -
4506 this function to update your item if you need simple scene-controlled -
4507 animation. -
4508 -
4509 The default implementation does nothing. -
4510 -
4511 This function is intended for animations. An alternative is to -
4512 multiple-inherit from QObject and QGraphicsItem and use the \l{The Animation -
4513 Framework}{Animation Framework}. -
4514 -
4515 \sa QGraphicsScene::advance(), QTimeLine -
4516*/ -
4517void QGraphicsItem::advance(int phase) -
4518{ -
4519 Q_UNUSED(phase);
never executed (the execution status of this line is deduced): (void)phase;;
-
4520}
never executed: }
0
4521 -
4522/*! -
4523 Returns the Z-value of the item. The Z-value affects the stacking order of -
4524 sibling (neighboring) items. -
4525 -
4526 The default Z-value is 0. -
4527 -
4528 \sa setZValue(), {QGraphicsItem#Sorting}{Sorting}, stackBefore(), ItemStacksBehindParent -
4529*/ -
4530qreal QGraphicsItem::zValue() const -
4531{ -
4532 return d_ptr->z;
executed: return d_ptr->z;
Execution Count:39
39
4533} -
4534 -
4535/*! -
4536 Sets the Z-value of the item to \a z. The Z value decides the stacking -
4537 order of sibling (neighboring) items. A sibling item of high Z value will -
4538 always be drawn on top of another sibling item with a lower Z value. -
4539 -
4540 If you restore the Z value, the item's insertion order will decide its -
4541 stacking order. -
4542 -
4543 The Z-value does not affect the item's size in any way. -
4544 -
4545 The default Z-value is 0. -
4546 -
4547 \sa zValue(), {QGraphicsItem#Sorting}{Sorting}, stackBefore(), ItemStacksBehindParent -
4548*/ -
4549void QGraphicsItem::setZValue(qreal z) -
4550{ -
4551 const QVariant newZVariant(itemChange(ItemZValueChange, z));
executed (the execution status of this line is deduced): const QVariant newZVariant(itemChange(ItemZValueChange, z));
-
4552 qreal newZ = newZVariant.toReal();
executed (the execution status of this line is deduced): qreal newZ = newZVariant.toReal();
-
4553 if (newZ == d_ptr->z)
evaluated: newZ == d_ptr->z
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:87
8-87
4554 return;
executed: return;
Execution Count:8
8
4555 -
4556 if (d_ptr->scene && d_ptr->scene->d_func()->indexMethod != QGraphicsScene::NoIndex) {
evaluated: d_ptr->scene
TRUEFALSE
yes
Evaluation Count:55
yes
Evaluation Count:32
partially evaluated: d_ptr->scene->d_func()->indexMethod != QGraphicsScene::NoIndex
TRUEFALSE
yes
Evaluation Count:55
no
Evaluation Count:0
0-55
4557 // Z Value has changed, we have to notify the index. -
4558 d_ptr->scene->d_func()->index->itemChange(this, ItemZValueChange, &newZ);
executed (the execution status of this line is deduced): d_ptr->scene->d_func()->index->itemChange(this, ItemZValueChange, &newZ);
-
4559 }
executed: }
Execution Count:55
55
4560 -
4561 d_ptr->z = newZ;
executed (the execution status of this line is deduced): d_ptr->z = newZ;
-
4562 if (d_ptr->parent)
evaluated: d_ptr->parent
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:83
4-83
4563 d_ptr->parent->d_ptr->needSortChildren = 1;
executed: d_ptr->parent->d_ptr->needSortChildren = 1;
Execution Count:4
4
4564 else if (d_ptr->scene)
evaluated: d_ptr->scene
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:31
31-52
4565 d_ptr->scene->d_func()->needSortTopLevelItems = 1;
executed: d_ptr->scene->d_func()->needSortTopLevelItems = 1;
Execution Count:52
52
4566 -
4567 if (d_ptr->scene)
evaluated: d_ptr->scene
TRUEFALSE
yes
Evaluation Count:55
yes
Evaluation Count:32
32-55
4568 d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true);
executed: d_ptr->scene->d_func()->markDirty(this, QRectF(), true);
Execution Count:55
55
4569 -
4570 itemChange(ItemZValueHasChanged, newZVariant);
executed (the execution status of this line is deduced): itemChange(ItemZValueHasChanged, newZVariant);
-
4571 -
4572 if (d_ptr->flags & ItemNegativeZStacksBehindParent)
partially evaluated: d_ptr->flags & ItemNegativeZStacksBehindParent
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:87
0-87
4573 setFlag(QGraphicsItem::ItemStacksBehindParent, z < qreal(0.0));
never executed: setFlag(QGraphicsItem::ItemStacksBehindParent, z < qreal(0.0));
0
4574 -
4575 if (d_ptr->isObject)
evaluated: d_ptr->isObject
TRUEFALSE
yes
Evaluation Count:44
yes
Evaluation Count:43
43-44
4576 emit static_cast<QGraphicsObject *>(this)->zChanged();
executed: static_cast<QGraphicsObject *>(this)->zChanged();
Execution Count:44
44
4577}
executed: }
Execution Count:87
87
4578 -
4579/*! -
4580 \internal -
4581 -
4582 Ensures that the list of children is sorted by insertion order, and that -
4583 the siblingIndexes are packed (no gaps), and start at 0. -
4584 -
4585 ### This function is almost identical to -
4586 QGraphicsScenePrivate::ensureSequentialTopLevelSiblingIndexes(). -
4587*/ -
4588void QGraphicsItemPrivate::ensureSequentialSiblingIndex() -
4589{ -
4590 if (!sequentialOrdering) {
partially evaluated: !sequentialOrdering
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1777
0-1777
4591 std::sort(children.begin(), children.end(), insertionOrder);
never executed (the execution status of this line is deduced): std::sort(children.begin(), children.end(), insertionOrder);
-
4592 sequentialOrdering = 1;
never executed (the execution status of this line is deduced): sequentialOrdering = 1;
-
4593 needSortChildren = 1;
never executed (the execution status of this line is deduced): needSortChildren = 1;
-
4594 }
never executed: }
0
4595 if (holesInSiblingIndex) {
partially evaluated: holesInSiblingIndex
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1777
0-1777
4596 holesInSiblingIndex = 0;
never executed (the execution status of this line is deduced): holesInSiblingIndex = 0;
-
4597 for (int i = 0; i < children.size(); ++i)
never evaluated: i < children.size()
0
4598 children[i]->d_ptr->siblingIndex = i;
never executed: children[i]->d_ptr->siblingIndex = i;
0
4599 }
never executed: }
0
4600}
executed: }
Execution Count:1777
1777
4601 -
4602/*! -
4603 \internal -
4604*/ -
4605inline void QGraphicsItemPrivate::sendScenePosChange() -
4606{ -
4607 Q_Q(QGraphicsItem);
executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func();
-
4608 if (scene) {
evaluated: scene
TRUEFALSE
yes
Evaluation Count:730
yes
Evaluation Count:25
25-730
4609 if (flags & QGraphicsItem::ItemSendsScenePositionChanges)
partially evaluated: flags & QGraphicsItem::ItemSendsScenePositionChanges
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:730
0-730
4610 q->itemChange(QGraphicsItem::ItemScenePositionHasChanged, q->scenePos());
never executed: q->itemChange(QGraphicsItem::ItemScenePositionHasChanged, q->scenePos());
0
4611 if (scenePosDescendants) {
partially evaluated: scenePosDescendants
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:730
0-730
4612 foreach (QGraphicsItem *item, scene->d_func()->scenePosItems) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(scene->d_func()->scenePosItems)> _container_(scene->d_func()->scenePosItems); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
4613 if (q->isAncestorOf(item))
never evaluated: q->isAncestorOf(item)
0
4614 item->itemChange(QGraphicsItem::ItemScenePositionHasChanged, item->scenePos());
never executed: item->itemChange(QGraphicsItem::ItemScenePositionHasChanged, item->scenePos());
0
4615 }
never executed: }
0
4616 }
never executed: }
0
4617 }
executed: }
Execution Count:730
730
4618}
executed: }
Execution Count:755
755
4619 -
4620/*! -
4621 \since 4.6 -
4622 -
4623 Stacks this item before \a sibling, which must be a sibling item (i.e., the -
4624 two items must share the same parent item, or must both be toplevel items). -
4625 The \a sibling must have the same Z value as this item, otherwise calling -
4626 this function will have no effect. -
4627 -
4628 By default, all sibling items are stacked by insertion order (i.e., the -
4629 first item you add is drawn before the next item you add). If two items' Z -
4630 values are different, then the item with the highest Z value is drawn on -
4631 top. When the Z values are the same, the insertion order will decide the -
4632 stacking order. -
4633 -
4634 \sa setZValue(), ItemStacksBehindParent, {QGraphicsItem#Sorting}{Sorting} -
4635*/ -
4636void QGraphicsItem::stackBefore(const QGraphicsItem *sibling) -
4637{ -
4638 if (sibling == this)
never evaluated: sibling == this
0
4639 return;
never executed: return;
0
4640 if (!sibling || d_ptr->parent != sibling->parentItem()) {
never evaluated: !sibling
never evaluated: d_ptr->parent != sibling->parentItem()
0
4641 qWarning("QGraphicsItem::stackUnder: cannot stack under %p, which must be a sibling", sibling);
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 4641, __PRETTY_FUNCTION__).warning("QGraphicsItem::stackUnder: cannot stack under %p, which must be a sibling", sibling);
-
4642 return;
never executed: return;
0
4643 } -
4644 QList<QGraphicsItem *> *siblings = d_ptr->parent
never evaluated: d_ptr->parent
0
4645 ? &d_ptr->parent->d_ptr->children
never executed (the execution status of this line is deduced): ? &d_ptr->parent->d_ptr->children
-
4646 : (d_ptr->scene ? &d_ptr->scene->d_func()->topLevelItems : 0);
never executed (the execution status of this line is deduced): : (d_ptr->scene ? &d_ptr->scene->d_func()->topLevelItems : 0);
-
4647 if (!siblings) {
never evaluated: !siblings
0
4648 qWarning("QGraphicsItem::stackUnder: cannot stack under %p, which must be a sibling", sibling);
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 4648, __PRETTY_FUNCTION__).warning("QGraphicsItem::stackUnder: cannot stack under %p, which must be a sibling", sibling);
-
4649 return;
never executed: return;
0
4650 } -
4651 -
4652 // First, make sure that the sibling indexes have no holes. This also -
4653 // marks the children list for sorting. -
4654 if (d_ptr->parent)
never evaluated: d_ptr->parent
0
4655 d_ptr->parent->d_ptr->ensureSequentialSiblingIndex();
never executed: d_ptr->parent->d_ptr->ensureSequentialSiblingIndex();
0
4656 else -
4657 d_ptr->scene->d_func()->ensureSequentialTopLevelSiblingIndexes();
never executed: d_ptr->scene->d_func()->ensureSequentialTopLevelSiblingIndexes();
0
4658 -
4659 // Only move items with the same Z value, and that need moving. -
4660 int siblingIndex = sibling->d_ptr->siblingIndex;
never executed (the execution status of this line is deduced): int siblingIndex = sibling->d_ptr->siblingIndex;
-
4661 int myIndex = d_ptr->siblingIndex;
never executed (the execution status of this line is deduced): int myIndex = d_ptr->siblingIndex;
-
4662 if (myIndex >= siblingIndex) {
never evaluated: myIndex >= siblingIndex
0
4663 siblings->move(myIndex, siblingIndex);
never executed (the execution status of this line is deduced): siblings->move(myIndex, siblingIndex);
-
4664 // Fixup the insertion ordering. -
4665 for (int i = 0; i < siblings->size(); ++i) {
never evaluated: i < siblings->size()
0
4666 int &index = siblings->at(i)->d_ptr->siblingIndex;
never executed (the execution status of this line is deduced): int &index = siblings->at(i)->d_ptr->siblingIndex;
-
4667 if (i != siblingIndex && index >= siblingIndex && index <= myIndex)
never evaluated: i != siblingIndex
never evaluated: index >= siblingIndex
never evaluated: index <= myIndex
0
4668 ++index;
never executed: ++index;
0
4669 }
never executed: }
0
4670 d_ptr->siblingIndex = siblingIndex;
never executed (the execution status of this line is deduced): d_ptr->siblingIndex = siblingIndex;
-
4671 for (int i = 0; i < siblings->size(); ++i) {
never evaluated: i < siblings->size()
0
4672 int &index = siblings->at(i)->d_ptr->siblingIndex;
never executed (the execution status of this line is deduced): int &index = siblings->at(i)->d_ptr->siblingIndex;
-
4673 if (i != siblingIndex && index >= siblingIndex && index <= myIndex)
never evaluated: i != siblingIndex
never evaluated: index >= siblingIndex
never evaluated: index <= myIndex
0
4674 siblings->at(i)->d_ptr->siblingOrderChange();
never executed: siblings->at(i)->d_ptr->siblingOrderChange();
0
4675 }
never executed: }
0
4676 d_ptr->siblingOrderChange();
never executed (the execution status of this line is deduced): d_ptr->siblingOrderChange();
-
4677 }
never executed: }
0
4678}
never executed: }
0
4679 -
4680/*! -
4681 Returns the bounding rect of this item's descendants (i.e., its -
4682 children, their children, etc.) in local coordinates. The -
4683 rectangle will contain all descendants after they have been mapped -
4684 to local coordinates. If the item has no children, this function -
4685 returns an empty QRectF. -
4686 -
4687 This does not include this item's own bounding rect; it only returns -
4688 its descendants' accumulated bounding rect. If you need to include this -
4689 item's bounding rect, you can add boundingRect() to childrenBoundingRect() -
4690 using QRectF::operator|(). -
4691 -
4692 This function is linear in complexity; it determines the size of the -
4693 returned bounding rect by iterating through all descendants. -
4694 -
4695 \sa boundingRect(), sceneBoundingRect() -
4696*/ -
4697QRectF QGraphicsItem::childrenBoundingRect() const -
4698{ -
4699 if (!d_ptr->dirtyChildrenBoundingRect)
evaluated: !d_ptr->dirtyChildrenBoundingRect
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:10
9-10
4700 return d_ptr->childrenBoundingRect;
executed: return d_ptr->childrenBoundingRect;
Execution Count:9
9
4701 -
4702 d_ptr->childrenBoundingRect = QRectF();
executed (the execution status of this line is deduced): d_ptr->childrenBoundingRect = QRectF();
-
4703 d_ptr->childrenBoundingRectHelper(0, &d_ptr->childrenBoundingRect, 0);
executed (the execution status of this line is deduced): d_ptr->childrenBoundingRectHelper(0, &d_ptr->childrenBoundingRect, 0);
-
4704 d_ptr->dirtyChildrenBoundingRect = 0;
executed (the execution status of this line is deduced): d_ptr->dirtyChildrenBoundingRect = 0;
-
4705 return d_ptr->childrenBoundingRect;
executed: return d_ptr->childrenBoundingRect;
Execution Count:10
10
4706} -
4707 -
4708/*! -
4709 \fn virtual QRectF QGraphicsItem::boundingRect() const = 0 -
4710 -
4711 This pure virtual function defines the outer bounds of the item as -
4712 a rectangle; all painting must be restricted to inside an item's -
4713 bounding rect. QGraphicsView uses this to determine whether the -
4714 item requires redrawing. -
4715 -
4716 Although the item's shape can be arbitrary, the bounding rect is -
4717 always rectangular, and it is unaffected by the items' -
4718 transformation. -
4719 -
4720 If you want to change the item's bounding rectangle, you must first call -
4721 prepareGeometryChange(). This notifies the scene of the imminent change, -
4722 so that it can update its item geometry index; otherwise, the scene will -
4723 be unaware of the item's new geometry, and the results are undefined -
4724 (typically, rendering artifacts are left within the view). -
4725 -
4726 Reimplement this function to let QGraphicsView determine what -
4727 parts of the widget, if any, need to be redrawn. -
4728 -
4729 Note: For shapes that paint an outline / stroke, it is important -
4730 to include half the pen width in the bounding rect. It is not -
4731 necessary to compensate for antialiasing, though. -
4732 -
4733 Example: -
4734 -
4735 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 8 -
4736 -
4737 \sa boundingRegion(), shape(), contains(), {The Graphics View Coordinate -
4738 System}, prepareGeometryChange() -
4739*/ -
4740 -
4741/*! -
4742 Returns the bounding rect of this item in scene coordinates, by combining -
4743 sceneTransform() with boundingRect(). -
4744 -
4745 \sa boundingRect(), {The Graphics View Coordinate System} -
4746*/ -
4747QRectF QGraphicsItem::sceneBoundingRect() const -
4748{ -
4749 // Find translate-only offset -
4750 // COMBINE -
4751 QPointF offset;
executed (the execution status of this line is deduced): QPointF offset;
-
4752 const QGraphicsItem *parentItem = this;
executed (the execution status of this line is deduced): const QGraphicsItem *parentItem = this;
-
4753 const QGraphicsItemPrivate *itemd;
executed (the execution status of this line is deduced): const QGraphicsItemPrivate *itemd;
-
4754 do { -
4755 itemd = parentItem->d_ptr.data();
executed (the execution status of this line is deduced): itemd = parentItem->d_ptr.data();
-
4756 if (itemd->transformData)
evaluated: itemd->transformData
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:3628
14-3628
4757 break;
executed: break;
Execution Count:14
14
4758 offset += itemd->pos;
executed (the execution status of this line is deduced): offset += itemd->pos;
-
4759 } while ((parentItem = itemd->parent));
executed: }
Execution Count:3628
evaluated: (parentItem = itemd->parent)
TRUEFALSE
yes
Evaluation Count:1487
yes
Evaluation Count:2141
1487-3628
4760 -
4761 QRectF br = boundingRect();
executed (the execution status of this line is deduced): QRectF br = boundingRect();
-
4762 br.translate(offset);
executed (the execution status of this line is deduced): br.translate(offset);
-
4763 if (!parentItem)
evaluated: !parentItem
TRUEFALSE
yes
Evaluation Count:2141
yes
Evaluation Count:14
14-2141
4764 return br;
executed: return br;
Execution Count:2141
2141
4765 if (parentItem->d_ptr->hasTranslateOnlySceneTransform()) {
evaluated: parentItem->d_ptr->hasTranslateOnlySceneTransform()
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:9
5-9
4766 br.translate(parentItem->d_ptr->sceneTransform.dx(), parentItem->d_ptr->sceneTransform.dy());
executed (the execution status of this line is deduced): br.translate(parentItem->d_ptr->sceneTransform.dx(), parentItem->d_ptr->sceneTransform.dy());
-
4767 return br;
executed: return br;
Execution Count:5
5
4768 } -
4769 return parentItem->d_ptr->sceneTransform.mapRect(br);
executed: return parentItem->d_ptr->sceneTransform.mapRect(br);
Execution Count:9
9
4770} -
4771 -
4772/*! -
4773 Returns the shape of this item as a QPainterPath in local -
4774 coordinates. The shape is used for many things, including collision -
4775 detection, hit tests, and for the QGraphicsScene::items() functions. -
4776 -
4777 The default implementation calls boundingRect() to return a simple -
4778 rectangular shape, but subclasses can reimplement this function to return -
4779 a more accurate shape for non-rectangular items. For example, a round item -
4780 may choose to return an elliptic shape for better collision detection. For -
4781 example: -
4782 -
4783 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 9 -
4784 -
4785 The outline of a shape can vary depending on the width and style of the -
4786 pen used when drawing. If you want to include this outline in the item's -
4787 shape, you can create a shape from the stroke using QPainterPathStroker. -
4788 -
4789 This function is called by the default implementations of contains() and -
4790 collidesWithPath(). -
4791 -
4792 \sa boundingRect(), contains(), prepareGeometryChange(), QPainterPathStroker -
4793*/ -
4794QPainterPath QGraphicsItem::shape() const -
4795{ -
4796 QPainterPath path;
executed (the execution status of this line is deduced): QPainterPath path;
-
4797 path.addRect(boundingRect());
executed (the execution status of this line is deduced): path.addRect(boundingRect());
-
4798 return path;
executed: return path;
Execution Count:342
342
4799} -
4800 -
4801/*! -
4802 Returns true if this item is clipped. An item is clipped if it has either -
4803 set the \l ItemClipsToShape flag, or if it or any of its ancestors has set -
4804 the \l ItemClipsChildrenToShape flag. -
4805 -
4806 Clipping affects the item's appearance (i.e., painting), as well as mouse -
4807 and hover event delivery. -
4808 -
4809 \sa clipPath(), shape(), setFlags() -
4810*/ -
4811bool QGraphicsItem::isClipped() const -
4812{ -
4813 Q_D(const QGraphicsItem);
executed (the execution status of this line is deduced): const QGraphicsItemPrivate * const d = d_func();
-
4814 return (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)
executed: return (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) || (d->flags & QGraphicsItem::ItemClipsToShape);
Execution Count:582
582
4815 || (d->flags & QGraphicsItem::ItemClipsToShape);
executed: return (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) || (d->flags & QGraphicsItem::ItemClipsToShape);
Execution Count:582
582
4816} -
4817 -
4818/*! -
4819 \since 4.5 -
4820 -
4821 Returns this item's clip path, or an empty QPainterPath if this item is -
4822 not clipped. The clip path constrains the item's appearance and -
4823 interaction (i.e., restricts the area the item can draw within and receive -
4824 events for). -
4825 -
4826 You can enable clipping by setting the ItemClipsToShape or -
4827 ItemClipsChildrenToShape flags. The item's clip path is calculated by -
4828 intersecting all clipping ancestors' shapes. If the item sets -
4829 ItemClipsToShape, the final clip is intersected with the item's own shape. -
4830 -
4831 \note Clipping introduces a performance penalty for all items involved; -
4832 you should generally avoid using clipping if you can (e.g., if your items -
4833 always draw inside boundingRect() or shape() boundaries, clipping is not -
4834 necessary). -
4835 -
4836 \sa isClipped(), shape(), setFlags() -
4837*/ -
4838QPainterPath QGraphicsItem::clipPath() const -
4839{ -
4840 Q_D(const QGraphicsItem);
executed (the execution status of this line is deduced): const QGraphicsItemPrivate * const d = d_func();
-
4841 if (!isClipped())
partially evaluated: !isClipped()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
4842 return QPainterPath();
never executed: return QPainterPath();
0
4843 -
4844 const QRectF thisBoundingRect(boundingRect());
executed (the execution status of this line is deduced): const QRectF thisBoundingRect(boundingRect());
-
4845 if (thisBoundingRect.isEmpty())
partially evaluated: thisBoundingRect.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
4846 return QPainterPath();
never executed: return QPainterPath();
0
4847 -
4848 QPainterPath clip;
executed (the execution status of this line is deduced): QPainterPath clip;
-
4849 // Start with the item's bounding rect. -
4850 clip.addRect(thisBoundingRect);
executed (the execution status of this line is deduced): clip.addRect(thisBoundingRect);
-
4851 -
4852 if (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) {
partially evaluated: d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
4853 const QGraphicsItem *parent = this;
executed (the execution status of this line is deduced): const QGraphicsItem *parent = this;
-
4854 const QGraphicsItem *lastParent = this;
executed (the execution status of this line is deduced): const QGraphicsItem *lastParent = this;
-
4855 -
4856 // Intersect any in-between clips starting at the top and moving downwards. -
4857 while ((parent = parent->d_ptr->parent)) {
partially evaluated: (parent = parent->d_ptr->parent)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
4858 if (parent->d_ptr->flags & ItemClipsChildrenToShape) {
partially evaluated: parent->d_ptr->flags & ItemClipsChildrenToShape
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
4859 // Map clip to the current parent and intersect with its shape/clipPath -
4860 clip = lastParent->itemTransform(parent).map(clip);
executed (the execution status of this line is deduced): clip = lastParent->itemTransform(parent).map(clip);
-
4861 clip = clip.intersected(parent->shape());
executed (the execution status of this line is deduced): clip = clip.intersected(parent->shape());
-
4862 if (clip.isEmpty())
partially evaluated: clip.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
4863 return clip;
never executed: return clip;
0
4864 lastParent = parent;
executed (the execution status of this line is deduced): lastParent = parent;
-
4865 }
executed: }
Execution Count:4
4
4866 -
4867 if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren))
partially evaluated: !(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
4868 break;
executed: break;
Execution Count:4
4
4869 }
never executed: }
0
4870 -
4871 if (lastParent != this) {
partially evaluated: lastParent != this
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
4872 // Map clip back to the item's transform. -
4873 // ### what if itemtransform fails -
4874 clip = lastParent->itemTransform(this).map(clip);
executed (the execution status of this line is deduced): clip = lastParent->itemTransform(this).map(clip);
-
4875 }
executed: }
Execution Count:4
4
4876 }
executed: }
Execution Count:4
4
4877 -
4878 if (d->flags & ItemClipsToShape)
partially evaluated: d->flags & ItemClipsToShape
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
4879 clip = clip.intersected(shape());
never executed: clip = clip.intersected(shape());
0
4880 -
4881 return clip;
executed: return clip;
Execution Count:4
4
4882} -
4883 -
4884/*! -
4885 Returns true if this item contains \a point, which is in local -
4886 coordinates; otherwise, false is returned. It is most often called from -
4887 QGraphicsView to determine what item is under the cursor, and for that -
4888 reason, the implementation of this function should be as light-weight as -
4889 possible. -
4890 -
4891 By default, this function calls shape(), but you can reimplement it in a -
4892 subclass to provide a (perhaps more efficient) implementation. -
4893 -
4894 \sa shape(), boundingRect(), collidesWithPath() -
4895*/ -
4896bool QGraphicsItem::contains(const QPointF &point) const -
4897{ -
4898 return isClipped() ? clipPath().contains(point) : shape().contains(point);
executed: return isClipped() ? clipPath().contains(point) : shape().contains(point);
Execution Count:211
211
4899} -
4900 -
4901/*! -
4902 -
4903 Returns true if this item collides with \a other; otherwise -
4904 returns false. -
4905 -
4906 The \a mode is applied to \a other, and the resulting shape or -
4907 bounding rectangle is then compared to this item's shape. The -
4908 default value for \a mode is Qt::IntersectsItemShape; \a other -
4909 collides with this item if it either intersects, contains, or is -
4910 contained by this item's shape (see Qt::ItemSelectionMode for -
4911 details). -
4912 -
4913 The default implementation is based on shape intersection, and it calls -
4914 shape() on both items. Because the complexity of arbitrary shape-shape -
4915 intersection grows with an order of magnitude when the shapes are complex, -
4916 this operation can be noticably time consuming. You have the option of -
4917 reimplementing this function in a subclass of QGraphicsItem to provide a -
4918 custom algorithm. This allows you to make use of natural constraints in -
4919 the shapes of your own items, in order to improve the performance of the -
4920 collision detection. For instance, two untransformed perfectly circular -
4921 items' collision can be determined very efficiently by comparing their -
4922 positions and radii. -
4923 -
4924 Keep in mind that when reimplementing this function and calling shape() or -
4925 boundingRect() on \a other, the returned coordinates must be mapped to -
4926 this item's coordinate system before any intersection can take place. -
4927 -
4928 \sa contains(), shape() -
4929*/ -
4930bool QGraphicsItem::collidesWithItem(const QGraphicsItem *other, Qt::ItemSelectionMode mode) const -
4931{ -
4932 if (other == this)
never evaluated: other == this
0
4933 return true;
never executed: return true;
0
4934 if (!other)
never evaluated: !other
0
4935 return false;
never executed: return false;
0
4936 // The items share the same clip if their closest clipper is the same, or -
4937 // if one clips the other. -
4938 bool clips = (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren);
never executed (the execution status of this line is deduced): bool clips = (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren);
-
4939 bool otherClips = (other->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren);
never executed (the execution status of this line is deduced): bool otherClips = (other->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren);
-
4940 if (clips || otherClips) {
never evaluated: clips
never evaluated: otherClips
0
4941 const QGraphicsItem *closestClipper = isAncestorOf(other) ? this : parentItem();
never evaluated: isAncestorOf(other)
0
4942 while (closestClipper && !(closestClipper->flags() & ItemClipsChildrenToShape))
never evaluated: closestClipper
never evaluated: !(closestClipper->flags() & ItemClipsChildrenToShape)
0
4943 closestClipper = closestClipper->parentItem();
never executed: closestClipper = closestClipper->parentItem();
0
4944 const QGraphicsItem *otherClosestClipper = other->isAncestorOf(this) ? other : other->parentItem();
never evaluated: other->isAncestorOf(this)
0
4945 while (otherClosestClipper && !(otherClosestClipper->flags() & ItemClipsChildrenToShape))
never evaluated: otherClosestClipper
never evaluated: !(otherClosestClipper->flags() & ItemClipsChildrenToShape)
0
4946 otherClosestClipper = otherClosestClipper->parentItem();
never executed: otherClosestClipper = otherClosestClipper->parentItem();
0
4947 if (closestClipper == otherClosestClipper) {
never evaluated: closestClipper == otherClosestClipper
0
4948 d_ptr->localCollisionHack = 1;
never executed (the execution status of this line is deduced): d_ptr->localCollisionHack = 1;
-
4949 bool res = collidesWithPath(mapFromItem(other, other->shape()), mode);
never executed (the execution status of this line is deduced): bool res = collidesWithPath(mapFromItem(other, other->shape()), mode);
-
4950 d_ptr->localCollisionHack = 0;
never executed (the execution status of this line is deduced): d_ptr->localCollisionHack = 0;
-
4951 return res;
never executed: return res;
0
4952 } -
4953 }
never executed: }
0
4954 -
4955 QPainterPath otherShape = other->isClipped() ? other->clipPath() : other->shape();
never evaluated: other->isClipped()
0
4956 return collidesWithPath(mapFromItem(other, otherShape), mode);
never executed: return collidesWithPath(mapFromItem(other, otherShape), mode);
0
4957} -
4958 -
4959/*! -
4960 Returns true if this item collides with \a path. -
4961 -
4962 The collision is determined by \a mode. The default value for \a mode is -
4963 Qt::IntersectsItemShape; \a path collides with this item if it either -
4964 intersects, contains, or is contained by this item's shape. -
4965 -
4966 Note that this function checks whether the item's shape or -
4967 bounding rectangle (depending on \a mode) is contained within \a -
4968 path, and not whether \a path is contained within the items shape -
4969 or bounding rectangle. -
4970 -
4971 \sa collidesWithItem(), contains(), shape() -
4972*/ -
4973bool QGraphicsItem::collidesWithPath(const QPainterPath &path, Qt::ItemSelectionMode mode) const -
4974{ -
4975 if (path.isEmpty()) {
partially evaluated: path.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:372
0-372
4976 // No collision with empty paths. -
4977 return false;
never executed: return false;
0
4978 } -
4979 -
4980 QRectF rectA(boundingRect());
executed (the execution status of this line is deduced): QRectF rectA(boundingRect());
-
4981 _q_adjustRect(&rectA);
executed (the execution status of this line is deduced): _q_adjustRect(&rectA);
-
4982 QRectF rectB(path.controlPointRect());
executed (the execution status of this line is deduced): QRectF rectB(path.controlPointRect());
-
4983 _q_adjustRect(&rectB);
executed (the execution status of this line is deduced): _q_adjustRect(&rectB);
-
4984 if (!rectA.intersects(rectB)) {
evaluated: !rectA.intersects(rectB)
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:364
8-364
4985 // This we can determine efficiently. If the two rects neither -
4986 // intersect nor contain eachother, then the two items do not collide. -
4987 return false;
executed: return false;
Execution Count:8
8
4988 } -
4989 -
4990 // For further testing, we need this item's shape or bounding rect. -
4991 QPainterPath thisShape;
executed (the execution status of this line is deduced): QPainterPath thisShape;
-
4992 if (mode == Qt::IntersectsItemShape || mode == Qt::ContainsItemShape)
evaluated: mode == Qt::IntersectsItemShape
TRUEFALSE
yes
Evaluation Count:363
yes
Evaluation Count:1
partially evaluated: mode == Qt::ContainsItemShape
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-363
4993 thisShape = (isClipped() && !d_ptr->localCollisionHack) ? clipPath() : shape();
executed: thisShape = (isClipped() && !d_ptr->localCollisionHack) ? clipPath() : shape();
Execution Count:364
evaluated: isClipped()
TRUEFALSE
yes
Evaluation Count:4
yes
Evaluation Count:360
partially evaluated: !d_ptr->localCollisionHack
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-364
4994 else -
4995 thisShape.addRect(rectA);
never executed: thisShape.addRect(rectA);
0
4996 -
4997 if (thisShape == QPainterPath()) {
partially evaluated: thisShape == QPainterPath()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:364
0-364
4998 // Empty shape? No collision. -
4999 return false;
never executed: return false;
0
5000 } -
5001 -
5002 // Use QPainterPath boolean operations to determine the collision, O(N*logN). -
5003 if (mode == Qt::IntersectsItemShape || mode == Qt::IntersectsItemBoundingRect)
evaluated: mode == Qt::IntersectsItemShape
TRUEFALSE
yes
Evaluation Count:363
yes
Evaluation Count:1
partially evaluated: mode == Qt::IntersectsItemBoundingRect
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-363
5004 return path.intersects(thisShape);
executed: return path.intersects(thisShape);
Execution Count:363
363
5005 return path.contains(thisShape);
executed: return path.contains(thisShape);
Execution Count:1
1
5006} -
5007 -
5008/*! -
5009 Returns a list of all items that collide with this item. -
5010 -
5011 The way collisions are detected is determined by applying \a mode -
5012 to items that are compared to this item, i.e., each item's shape -
5013 or bounding rectangle is checked against this item's shape. The -
5014 default value for \a mode is Qt::IntersectsItemShape. -
5015 -
5016 \sa collidesWithItem() -
5017*/ -
5018QList<QGraphicsItem *> QGraphicsItem::collidingItems(Qt::ItemSelectionMode mode) const -
5019{ -
5020 if (d_ptr->scene)
never evaluated: d_ptr->scene
0
5021 return d_ptr->scene->collidingItems(this, mode);
never executed: return d_ptr->scene->collidingItems(this, mode);
0
5022 return QList<QGraphicsItem *>();
never executed: return QList<QGraphicsItem *>();
0
5023} -
5024 -
5025/*! -
5026 \internal -
5027 -
5028 Item obscurity helper function. -
5029 -
5030 Returns true if the subrect \a rect of \a item's bounding rect is obscured -
5031 by \a other (i.e., \a other's opaque area covers \a item's \a rect -
5032 completely. \a other is assumed to already be "on top of" \a item -
5033 wrt. stacking order. -
5034*/ -
5035static bool qt_QGraphicsItem_isObscured(const QGraphicsItem *item, -
5036 const QGraphicsItem *other, -
5037 const QRectF &rect) -
5038{ -
5039 return other->mapToItem(item, other->opaqueArea()).contains(rect);
executed: return other->mapToItem(item, other->opaqueArea()).contains(rect);
Execution Count:6
6
5040} -
5041 -
5042/*! -
5043 \overload -
5044 \since 4.3 -
5045 -
5046 Returns true if \a rect is completely obscured by the opaque shape of any -
5047 of colliding items above it (i.e., with a higher Z value than this item). -
5048 -
5049 \sa opaqueArea() -
5050*/ -
5051bool QGraphicsItem::isObscured(const QRectF &rect) const -
5052{ -
5053 Q_D(const QGraphicsItem);
never executed (the execution status of this line is deduced): const QGraphicsItemPrivate * const d = d_func();
-
5054 if (!d->scene)
never evaluated: !d->scene
0
5055 return false;
never executed: return false;
0
5056 -
5057 QRectF br = boundingRect();
never executed (the execution status of this line is deduced): QRectF br = boundingRect();
-
5058 QRectF testRect = rect.isNull() ? br : rect;
never evaluated: rect.isNull()
0
5059 -
5060 foreach (QGraphicsItem *item, d->scene->items(mapToScene(br), Qt::IntersectsItemBoundingRect)) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(d->scene->items(mapToScene(br), Qt::IntersectsItemBoundingRect))> _container_(d->scene->items(mapToScene(br), Qt::IntersectsItemBoundingRect)); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
5061 if (item == this)
never evaluated: item == this
0
5062 break;
never executed: break;
0
5063 if (qt_QGraphicsItem_isObscured(this, item, testRect))
never evaluated: qt_QGraphicsItem_isObscured(this, item, testRect)
0
5064 return true;
never executed: return true;
0
5065 }
never executed: }
0
5066 return false;
never executed: return false;
0
5067} -
5068 -
5069/*! -
5070 \fn bool QGraphicsItem::isObscured(qreal x, qreal y, qreal w, qreal h) const -
5071 \overload -
5072 \since 4.3 -
5073 -
5074 This convenience function is equivalent to calling isObscured(QRectF(\a x, \a y, \a w, \a h)). -
5075*/ -
5076 -
5077/*! -
5078 Returns true if this item's bounding rect is completely obscured by the -
5079 opaque shape of \a item. -
5080 -
5081 The base implementation maps \a item's opaqueArea() to this item's -
5082 coordinate system, and then checks if this item's boundingRect() is fully -
5083 contained within the mapped shape. -
5084 -
5085 You can reimplement this function to provide a custom algorithm for -
5086 determining whether this item is obscured by \a item. -
5087 -
5088 \sa opaqueArea(), isObscured() -
5089*/ -
5090bool QGraphicsItem::isObscuredBy(const QGraphicsItem *item) const -
5091{ -
5092 if (!item)
evaluated: !item
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:7
2-7
5093 return false;
executed: return false;
Execution Count:2
2
5094 return qt_closestItemFirst(item, this)
executed: return qt_closestItemFirst(item, this) && qt_QGraphicsItem_isObscured(this, item, boundingRect());
Execution Count:7
7
5095 && qt_QGraphicsItem_isObscured(this, item, boundingRect());
executed: return qt_closestItemFirst(item, this) && qt_QGraphicsItem_isObscured(this, item, boundingRect());
Execution Count:7
7
5096} -
5097 -
5098/*! -
5099 This virtual function returns a shape representing the area where this -
5100 item is opaque. An area is opaque if it is filled using an opaque brush or -
5101 color (i.e., not transparent). -
5102 -
5103 This function is used by isObscuredBy(), which is called by underlying -
5104 items to determine if they are obscured by this item. -
5105 -
5106 The default implementation returns an empty QPainterPath, indicating that -
5107 this item is completely transparent and does not obscure any other items. -
5108 -
5109 \sa isObscuredBy(), isObscured(), shape() -
5110*/ -
5111QPainterPath QGraphicsItem::opaqueArea() const -
5112{ -
5113 return QPainterPath();
executed: return QPainterPath();
Execution Count:2
2
5114} -
5115 -
5116/*! -
5117 \since 4.4 -
5118 -
5119 Returns the bounding region for this item. The coordinate space of the -
5120 returned region depends on \a itemToDeviceTransform. If you pass an -
5121 identity QTransform as a parameter, this function will return a local -
5122 coordinate region. -
5123 -
5124 The bounding region describes a coarse outline of the item's visual -
5125 contents. Although it's expensive to calculate, it's also more precise -
5126 than boundingRect(), and it can help to avoid unnecessary repainting when -
5127 an item is updated. This is particularly efficient for thin items (e.g., -
5128 lines or simple polygons). You can tune the granularity for the bounding -
5129 region by calling setBoundingRegionGranularity(). The default granularity -
5130 is 0; in which the item's bounding region is the same as its bounding -
5131 rect. -
5132 -
5133 \a itemToDeviceTransform is the transformation from item coordinates to -
5134 device coordinates. If you want this function to return a QRegion in scene -
5135 coordinates, you can pass sceneTransform() as an argument. -
5136 -
5137 \sa boundingRegionGranularity() -
5138*/ -
5139QRegion QGraphicsItem::boundingRegion(const QTransform &itemToDeviceTransform) const -
5140{ -
5141 // ### Ideally we would have a better way to generate this region, -
5142 // preferably something in the lines of QPainterPath::toRegion(QTransform) -
5143 // coupled with a way to generate a painter path from a set of painter -
5144 // operations (e.g., QPicture::toPainterPath() or so). The current -
5145 // approach generates a bitmap with the size of the item's bounding rect -
5146 // in device coordinates, scaled by b.r.granularity, then paints the item -
5147 // into the bitmap, converts the result to a QRegion and scales the region -
5148 // back to device space with inverse granularity. -
5149 qreal granularity = boundingRegionGranularity();
never executed (the execution status of this line is deduced): qreal granularity = boundingRegionGranularity();
-
5150 QRect deviceRect = itemToDeviceTransform.mapRect(boundingRect()).toRect();
never executed (the execution status of this line is deduced): QRect deviceRect = itemToDeviceTransform.mapRect(boundingRect()).toRect();
-
5151 _q_adjustRect(&deviceRect);
never executed (the execution status of this line is deduced): _q_adjustRect(&deviceRect);
-
5152 if (granularity == 0.0)
never evaluated: granularity == 0.0
0
5153 return QRegion(deviceRect);
never executed: return QRegion(deviceRect);
0
5154 -
5155 int pad = 1;
never executed (the execution status of this line is deduced): int pad = 1;
-
5156 QSize bitmapSize(qMax(1, int(deviceRect.width() * granularity) + pad * 2),
never executed (the execution status of this line is deduced): QSize bitmapSize(qMax(1, int(deviceRect.width() * granularity) + pad * 2),
-
5157 qMax(1, int(deviceRect.height() * granularity) + pad * 2));
never executed (the execution status of this line is deduced): qMax(1, int(deviceRect.height() * granularity) + pad * 2));
-
5158 QImage mask(bitmapSize, QImage::Format_ARGB32_Premultiplied);
never executed (the execution status of this line is deduced): QImage mask(bitmapSize, QImage::Format_ARGB32_Premultiplied);
-
5159 mask.fill(0);
never executed (the execution status of this line is deduced): mask.fill(0);
-
5160 QPainter p(&mask);
never executed (the execution status of this line is deduced): QPainter p(&mask);
-
5161 p.setRenderHints(QPainter::Antialiasing);
never executed (the execution status of this line is deduced): p.setRenderHints(QPainter::Antialiasing);
-
5162 -
5163 // Transform painter (### this code is from QGraphicsScene::drawItemHelper -
5164 // and doesn't work properly with perspective transformations). -
5165 QPointF viewOrigo = itemToDeviceTransform.map(QPointF(0, 0));
never executed (the execution status of this line is deduced): QPointF viewOrigo = itemToDeviceTransform.map(QPointF(0, 0));
-
5166 QPointF offset = viewOrigo - deviceRect.topLeft();
never executed (the execution status of this line is deduced): QPointF offset = viewOrigo - deviceRect.topLeft();
-
5167 p.scale(granularity, granularity);
never executed (the execution status of this line is deduced): p.scale(granularity, granularity);
-
5168 p.translate(offset);
never executed (the execution status of this line is deduced): p.translate(offset);
-
5169 p.translate(pad, pad);
never executed (the execution status of this line is deduced): p.translate(pad, pad);
-
5170 p.setWorldTransform(itemToDeviceTransform, true);
never executed (the execution status of this line is deduced): p.setWorldTransform(itemToDeviceTransform, true);
-
5171 p.translate(itemToDeviceTransform.inverted().map(QPointF(0, 0)));
never executed (the execution status of this line is deduced): p.translate(itemToDeviceTransform.inverted().map(QPointF(0, 0)));
-
5172 -
5173 // Render -
5174 QStyleOptionGraphicsItem option;
never executed (the execution status of this line is deduced): QStyleOptionGraphicsItem option;
-
5175 const_cast<QGraphicsItem *>(this)->paint(&p, &option, 0);
never executed (the execution status of this line is deduced): const_cast<QGraphicsItem *>(this)->paint(&p, &option, 0);
-
5176 p.end();
never executed (the execution status of this line is deduced): p.end();
-
5177 -
5178 // Transform QRegion back to device space -
5179 QTransform unscale = QTransform::fromScale(1 / granularity, 1 / granularity);
never executed (the execution status of this line is deduced): QTransform unscale = QTransform::fromScale(1 / granularity, 1 / granularity);
-
5180 QRegion r;
never executed (the execution status of this line is deduced): QRegion r;
-
5181 QBitmap colorMask = QBitmap::fromImage(mask.createMaskFromColor(0));
never executed (the execution status of this line is deduced): QBitmap colorMask = QBitmap::fromImage(mask.createMaskFromColor(0));
-
5182 foreach (const QRect &rect, QRegion( colorMask ).rects()) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(QRegion( colorMask ).rects())> _container_(QRegion( colorMask ).rects()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QRect &rect = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
5183 QRect xrect = unscale.mapRect(rect).translated(deviceRect.topLeft() - QPoint(pad, pad));
never executed (the execution status of this line is deduced): QRect xrect = unscale.mapRect(rect).translated(deviceRect.topLeft() - QPoint(pad, pad));
-
5184 r += xrect.adjusted(-1, -1, 1, 1) & deviceRect;
never executed (the execution status of this line is deduced): r += xrect.adjusted(-1, -1, 1, 1) & deviceRect;
-
5185 }
never executed: }
0
5186 return r;
never executed: return r;
0
5187} -
5188 -
5189/*! -
5190 \since 4.4 -
5191 -
5192 Returns the item's bounding region granularity; a value between and -
5193 including 0 and 1. The default value is 0 (i.e., the lowest granularity, -
5194 where the bounding region corresponds to the item's bounding rectangle). -
5195 -
5196\omit -
5197### NOTE -
5198\endomit -
5199 -
5200 \sa setBoundingRegionGranularity() -
5201*/ -
5202qreal QGraphicsItem::boundingRegionGranularity() const -
5203{ -
5204 return d_ptr->hasBoundingRegionGranularity
executed: return d_ptr->hasBoundingRegionGranularity ? qvariant_cast<qreal>(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity)) : 0;
Execution Count:10
10
5205 ? qvariant_cast<qreal>(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity))
executed: return d_ptr->hasBoundingRegionGranularity ? qvariant_cast<qreal>(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity)) : 0;
Execution Count:10
10
5206 : 0;
executed: return d_ptr->hasBoundingRegionGranularity ? qvariant_cast<qreal>(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity)) : 0;
Execution Count:10
10
5207} -
5208 -
5209/*! -
5210 \since 4.4 -
5211 Sets the bounding region granularity to \a granularity; a value between -
5212 and including 0 and 1. The default value is 0 (i.e., the lowest -
5213 granularity, where the bounding region corresponds to the item's bounding -
5214 rectangle). -
5215 -
5216 The granularity is used by boundingRegion() to calculate how fine the -
5217 bounding region of the item should be. The highest achievable granularity -
5218 is 1, where boundingRegion() will return the finest outline possible for -
5219 the respective device (e.g., for a QGraphicsView viewport, this gives you -
5220 a pixel-perfect bounding region). The lowest possible granularity is -
5221 0. The value of \a granularity describes the ratio between device -
5222 resolution and the resolution of the bounding region (e.g., a value of -
5223 0.25 will provide a region where each chunk corresponds to 4x4 device -
5224 units / pixels). -
5225 -
5226 \sa boundingRegionGranularity() -
5227*/ -
5228void QGraphicsItem::setBoundingRegionGranularity(qreal granularity) -
5229{ -
5230 if (granularity < 0.0 || granularity > 1.0) {
never evaluated: granularity < 0.0
never evaluated: granularity > 1.0
0
5231 qWarning("QGraphicsItem::setBoundingRegionGranularity: invalid granularity %g", granularity);
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 5231, __PRETTY_FUNCTION__).warning("QGraphicsItem::setBoundingRegionGranularity: invalid granularity %g", granularity);
-
5232 return;
never executed: return;
0
5233 } -
5234 if (granularity == 0.0) {
never evaluated: granularity == 0.0
0
5235 d_ptr->unsetExtra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity);
never executed (the execution status of this line is deduced): d_ptr->unsetExtra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity);
-
5236 d_ptr->hasBoundingRegionGranularity = 0;
never executed (the execution status of this line is deduced): d_ptr->hasBoundingRegionGranularity = 0;
-
5237 return;
never executed: return;
0
5238 } -
5239 d_ptr->hasBoundingRegionGranularity = 1;
never executed (the execution status of this line is deduced): d_ptr->hasBoundingRegionGranularity = 1;
-
5240 d_ptr->setExtra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity,
never executed (the execution status of this line is deduced): d_ptr->setExtra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity,
-
5241 QVariant::fromValue<qreal>(granularity));
never executed (the execution status of this line is deduced): QVariant::fromValue<qreal>(granularity));
-
5242}
never executed: }
0
5243 -
5244/*! -
5245 \fn virtual void QGraphicsItem::paint(QPainter *painter, const -
5246 QStyleOptionGraphicsItem *option, QWidget *widget = 0) = 0 -
5247 -
5248 This function, which is usually called by QGraphicsView, paints the -
5249 contents of an item in local coordinates. -
5250 -
5251 Reimplement this function in a QGraphicsItem subclass to provide the -
5252 item's painting implementation, using \a painter. The \a option parameter -
5253 provides style options for the item, such as its state, exposed area and -
5254 its level-of-detail hints. The \a widget argument is optional. If -
5255 provided, it points to the widget that is being painted on; otherwise, it -
5256 is 0. For cached painting, \a widget is always 0. -
5257 -
5258 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 10 -
5259 -
5260 The painter's pen is 0-width by default, and its pen is initialized to the -
5261 QPalette::Text brush from the paint device's palette. The brush is -
5262 initialized to QPalette::Window. -
5263 -
5264 Make sure to constrain all painting inside the boundaries of -
5265 boundingRect() to avoid rendering artifacts (as QGraphicsView does not -
5266 clip the painter for you). In particular, when QPainter renders the -
5267 outline of a shape using an assigned QPen, half of the outline will be -
5268 drawn outside, and half inside, the shape you're rendering (e.g., with a -
5269 pen width of 2 units, you must draw outlines 1 unit inside -
5270 boundingRect()). QGraphicsItem does not support use of cosmetic pens with -
5271 a non-zero width. -
5272 -
5273 All painting is done in local coordinates. -
5274 -
5275 \sa setCacheMode(), QPen::width(), {Item Coordinates}, ItemUsesExtendedStyleOption -
5276*/ -
5277 -
5278/*! -
5279 \internal -
5280 Returns true if we can discard an update request; otherwise false. -
5281*/ -
5282bool QGraphicsItemPrivate::discardUpdateRequest(bool ignoreVisibleBit, bool ignoreDirtyBit, -
5283 bool ignoreOpacity) const -
5284{ -
5285 // No scene, or if the scene is updating everything, means we have nothing -
5286 // to do. The only exception is if the scene tracks the growing scene rect. -
5287 return !scene
executed: return !scene || (!visible && !ignoreVisibleBit && !this->ignoreVisible) || (!ignoreDirtyBit && fullUpdatePending) || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent());
Execution Count:1499
1499
5288 || (!visible && !ignoreVisibleBit && !this->ignoreVisible)
executed: return !scene || (!visible && !ignoreVisibleBit && !this->ignoreVisible) || (!ignoreDirtyBit && fullUpdatePending) || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent());
Execution Count:1499
1499
5289 || (!ignoreDirtyBit && fullUpdatePending)
executed: return !scene || (!visible && !ignoreVisibleBit && !this->ignoreVisible) || (!ignoreDirtyBit && fullUpdatePending) || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent());
Execution Count:1499
1499
5290 || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent());
executed: return !scene || (!visible && !ignoreVisibleBit && !this->ignoreVisible) || (!ignoreDirtyBit && fullUpdatePending) || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent());
Execution Count:1499
1499
5291} -
5292 -
5293/*! -
5294 \internal -
5295*/ -
5296int QGraphicsItemPrivate::depth() const -
5297{ -
5298 if (itemDepth == -1)
evaluated: itemDepth == -1
TRUEFALSE
yes
Evaluation Count:222
yes
Evaluation Count:756
222-756
5299 const_cast<QGraphicsItemPrivate *>(this)->resolveDepth();
executed: const_cast<QGraphicsItemPrivate *>(this)->resolveDepth();
Execution Count:222
222
5300 -
5301 return itemDepth;
executed: return itemDepth;
Execution Count:978
978
5302} -
5303 -
5304/*! -
5305 \internal -
5306*/ -
5307#ifndef QT_NO_GRAPHICSEFFECT -
5308void QGraphicsItemPrivate::invalidateParentGraphicsEffectsRecursively() -
5309{ -
5310 QGraphicsItemPrivate *itemPrivate = this;
executed (the execution status of this line is deduced): QGraphicsItemPrivate *itemPrivate = this;
-
5311 do { -
5312 if (itemPrivate->graphicsEffect) {
evaluated: itemPrivate->graphicsEffect
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:5159
19-5159
5313 itemPrivate->notifyInvalidated = 1;
executed (the execution status of this line is deduced): itemPrivate->notifyInvalidated = 1;
-
5314 -
5315 if (!itemPrivate->updateDueToGraphicsEffect)
evaluated: !itemPrivate->updateDueToGraphicsEffect
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:8
8-11
5316 static_cast<QGraphicsItemEffectSourcePrivate *>(itemPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache();
executed: static_cast<QGraphicsItemEffectSourcePrivate *>(itemPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache();
Execution Count:11
11
5317 }
executed: }
Execution Count:19
19
5318 } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : 0));
executed: }
Execution Count:5178
evaluated: itemPrivate->parent
TRUEFALSE
yes
Evaluation Count:1426
yes
Evaluation Count:3752
1426-5178
5319}
executed: }
Execution Count:3752
3752
5320 -
5321void QGraphicsItemPrivate::invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::InvalidateReason reason) -
5322{ -
5323 if (!mayHaveChildWithGraphicsEffect)
evaluated: !mayHaveChildWithGraphicsEffect
TRUEFALSE
yes
Evaluation Count:10
yes
Evaluation Count:2
2-10
5324 return;
executed: return;
Execution Count:10
10
5325 -
5326 for (int i = 0; i < children.size(); ++i) {
evaluated: i < children.size()
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
5327 QGraphicsItemPrivate *childPrivate = children.at(i)->d_ptr.data();
executed (the execution status of this line is deduced): QGraphicsItemPrivate *childPrivate = children.at(i)->d_ptr.data();
-
5328 if (reason == OpacityChanged && (childPrivate->flags & QGraphicsItem::ItemIgnoresParentOpacity))
partially evaluated: reason == OpacityChanged
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
partially evaluated: (childPrivate->flags & QGraphicsItem::ItemIgnoresParentOpacity)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
5329 continue;
never executed: continue;
0
5330 if (childPrivate->graphicsEffect) {
partially evaluated: childPrivate->graphicsEffect
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
5331 childPrivate->notifyInvalidated = 1;
executed (the execution status of this line is deduced): childPrivate->notifyInvalidated = 1;
-
5332 static_cast<QGraphicsItemEffectSourcePrivate *>(childPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache();
executed (the execution status of this line is deduced): static_cast<QGraphicsItemEffectSourcePrivate *>(childPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache();
-
5333 }
executed: }
Execution Count:2
2
5334 -
5335 childPrivate->invalidateChildGraphicsEffectsRecursively(reason);
executed (the execution status of this line is deduced): childPrivate->invalidateChildGraphicsEffectsRecursively(reason);
-
5336 }
executed: }
Execution Count:2
2
5337}
executed: }
Execution Count:2
2
5338#endif //QT_NO_GRAPHICSEFFECT -
5339 -
5340/*! -
5341 \internal -
5342*/ -
5343void QGraphicsItemPrivate::invalidateDepthRecursively() -
5344{ -
5345 if (itemDepth == -1)
evaluated: itemDepth == -1
TRUEFALSE
yes
Evaluation Count:1357
yes
Evaluation Count:203
203-1357
5346 return;
executed: return;
Execution Count:1357
1357
5347 -
5348 itemDepth = -1;
executed (the execution status of this line is deduced): itemDepth = -1;
-
5349 for (int i = 0; i < children.size(); ++i)
partially evaluated: i < children.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:203
0-203
5350 children.at(i)->d_ptr->invalidateDepthRecursively();
never executed: children.at(i)->d_ptr->invalidateDepthRecursively();
0
5351}
executed: }
Execution Count:203
203
5352 -
5353/*! -
5354 \internal -
5355 -
5356 Resolves the stacking depth of this object and all its ancestors. -
5357*/ -
5358void QGraphicsItemPrivate::resolveDepth() -
5359{ -
5360 if (!parent)
evaluated: !parent
TRUEFALSE
yes
Evaluation Count:195
yes
Evaluation Count:197
195-197
5361 itemDepth = 0;
executed: itemDepth = 0;
Execution Count:195
195
5362 else { -
5363 if (parent->d_ptr->itemDepth == -1)
evaluated: parent->d_ptr->itemDepth == -1
TRUEFALSE
yes
Evaluation Count:170
yes
Evaluation Count:27
27-170
5364 parent->d_ptr->resolveDepth();
executed: parent->d_ptr->resolveDepth();
Execution Count:170
170
5365 itemDepth = parent->d_ptr->itemDepth + 1;
executed (the execution status of this line is deduced): itemDepth = parent->d_ptr->itemDepth + 1;
-
5366 }
executed: }
Execution Count:197
197
5367} -
5368 -
5369/*! -
5370 \internal -
5371 -
5372 ### This function is almost identical to -
5373 QGraphicsScenePrivate::registerTopLevelItem(). -
5374*/ -
5375void QGraphicsItemPrivate::addChild(QGraphicsItem *child) -
5376{ -
5377 // Remove all holes from the sibling index list. Now the max index -
5378 // number is equal to the size of the children list. -
5379 ensureSequentialSiblingIndex();
executed (the execution status of this line is deduced): ensureSequentialSiblingIndex();
-
5380 needSortChildren = 1; // ### maybe 0
executed (the execution status of this line is deduced): needSortChildren = 1;
-
5381 child->d_ptr->siblingIndex = children.size();
executed (the execution status of this line is deduced): child->d_ptr->siblingIndex = children.size();
-
5382 children.append(child);
executed (the execution status of this line is deduced): children.append(child);
-
5383 if (isObject)
evaluated: isObject
TRUEFALSE
yes
Evaluation Count:790
yes
Evaluation Count:14
14-790
5384 emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged();
executed: static_cast<QGraphicsObject *>(q_ptr)->childrenChanged();
Execution Count:790
790
5385}
executed: }
Execution Count:804
804
5386 -
5387/*! -
5388 \internal -
5389 -
5390 ### This function is almost identical to -
5391 QGraphicsScenePrivate::unregisterTopLevelItem(). -
5392*/ -
5393void QGraphicsItemPrivate::removeChild(QGraphicsItem *child) -
5394{ -
5395 // When removing elements in the middle of the children list, -
5396 // there will be a "gap" in the list of sibling indexes (0,1,3,4). -
5397 if (!holesInSiblingIndex)
evaluated: !holesInSiblingIndex
TRUEFALSE
yes
Evaluation Count:205
yes
Evaluation Count:554
205-554
5398 holesInSiblingIndex = child->d_ptr->siblingIndex != children.size() - 1;
executed: holesInSiblingIndex = child->d_ptr->siblingIndex != children.size() - 1;
Execution Count:205
205
5399 if (sequentialOrdering && !holesInSiblingIndex)
partially evaluated: sequentialOrdering
TRUEFALSE
yes
Evaluation Count:759
no
Evaluation Count:0
evaluated: !holesInSiblingIndex
TRUEFALSE
yes
Evaluation Count:55
yes
Evaluation Count:704
0-759
5400 children.removeAt(child->d_ptr->siblingIndex);
executed: children.removeAt(child->d_ptr->siblingIndex);
Execution Count:55
55
5401 else -
5402 children.removeOne(child);
executed: children.removeOne(child);
Execution Count:704
704
5403 // NB! Do not use children.removeAt(child->d_ptr->siblingIndex) because -
5404 // the child is not guaranteed to be at the index after the list is sorted. -
5405 // (see ensureSortedChildren()). -
5406 child->d_ptr->siblingIndex = -1;
executed (the execution status of this line is deduced): child->d_ptr->siblingIndex = -1;
-
5407 if (isObject)
evaluated: isObject
TRUEFALSE
yes
Evaluation Count:746
yes
Evaluation Count:13
13-746
5408 emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged();
executed: static_cast<QGraphicsObject *>(q_ptr)->childrenChanged();
Execution Count:746
746
5409}
executed: }
Execution Count:759
759
5410 -
5411/*! -
5412 \internal -
5413*/ -
5414QGraphicsItemCache *QGraphicsItemPrivate::maybeExtraItemCache() const -
5415{ -
5416 return (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
never executed: return (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
0
5417} -
5418 -
5419/*! -
5420 \internal -
5421*/ -
5422QGraphicsItemCache *QGraphicsItemPrivate::extraItemCache() const -
5423{ -
5424 QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
never executed (the execution status of this line is deduced): QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
-
5425 if (!c) {
never evaluated: !c
0
5426 QGraphicsItemPrivate *that = const_cast<QGraphicsItemPrivate *>(this);
never executed (the execution status of this line is deduced): QGraphicsItemPrivate *that = const_cast<QGraphicsItemPrivate *>(this);
-
5427 c = new QGraphicsItemCache;
never executed (the execution status of this line is deduced): c = new QGraphicsItemCache;
-
5428 that->setExtra(ExtraCacheData, QVariant::fromValue<void *>(c));
never executed (the execution status of this line is deduced): that->setExtra(ExtraCacheData, QVariant::fromValue<void *>(c));
-
5429 }
never executed: }
0
5430 return c;
never executed: return c;
0
5431} -
5432 -
5433/*! -
5434 \internal -
5435*/ -
5436void QGraphicsItemPrivate::removeExtraItemCache() -
5437{ -
5438 QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
executed (the execution status of this line is deduced): QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
-
5439 if (c) {
partially evaluated: c
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1757
0-1757
5440 c->purge();
never executed (the execution status of this line is deduced): c->purge();
-
5441 delete c;
never executed (the execution status of this line is deduced): delete c;
-
5442 }
never executed: }
0
5443 unsetExtra(ExtraCacheData);
executed (the execution status of this line is deduced): unsetExtra(ExtraCacheData);
-
5444}
executed: }
Execution Count:1757
1757
5445 -
5446void QGraphicsItemPrivate::updatePaintedViewBoundingRects(bool updateChildren) -
5447{ -
5448 if (!scene)
evaluated: !scene
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:23
7-23
5449 return;
executed: return;
Execution Count:7
7
5450 -
5451 for (int i = 0; i < scene->d_func()->views.size(); ++i) {
evaluated: i < scene->d_func()->views.size()
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:23
7-23
5452 QGraphicsViewPrivate *viewPrivate = scene->d_func()->views.at(i)->d_func();
executed (the execution status of this line is deduced): QGraphicsViewPrivate *viewPrivate = scene->d_func()->views.at(i)->d_func();
-
5453 QRect rect = paintedViewBoundingRects.value(viewPrivate->viewport);
executed (the execution status of this line is deduced): QRect rect = paintedViewBoundingRects.value(viewPrivate->viewport);
-
5454 rect.translate(viewPrivate->dirtyScrollOffset);
executed (the execution status of this line is deduced): rect.translate(viewPrivate->dirtyScrollOffset);
-
5455 viewPrivate->updateRect(rect);
executed (the execution status of this line is deduced): viewPrivate->updateRect(rect);
-
5456 }
executed: }
Execution Count:7
7
5457 -
5458 if (updateChildren) {
partially evaluated: updateChildren
TRUEFALSE
yes
Evaluation Count:23
no
Evaluation Count:0
0-23
5459 for (int i = 0; i < children.size(); ++i)
evaluated: i < children.size()
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:23
6-23
5460 children.at(i)->d_ptr->updatePaintedViewBoundingRects(true);
executed: children.at(i)->d_ptr->updatePaintedViewBoundingRects(true);
Execution Count:6
6
5461 }
executed: }
Execution Count:23
23
5462}
executed: }
Execution Count:23
23
5463 -
5464// Traverses all the ancestors up to the top-level and updates the pointer to -
5465// always point to the top-most item that has a dirty scene transform. -
5466// It then backtracks to the top-most dirty item and start calculating the -
5467// scene transform by combining the item's transform (+pos) with the parent's -
5468// cached scene transform (which we at this point know for sure is valid). -
5469void QGraphicsItemPrivate::ensureSceneTransformRecursive(QGraphicsItem **topMostDirtyItem) -
5470{ -
5471 Q_ASSERT(topMostDirtyItem);
executed (the execution status of this line is deduced): qt_noop();
-
5472 -
5473 if (dirtySceneTransform)
evaluated: dirtySceneTransform
TRUEFALSE
yes
Evaluation Count:195
yes
Evaluation Count:2015
195-2015
5474 *topMostDirtyItem = q_ptr;
executed: *topMostDirtyItem = q_ptr;
Execution Count:195
195
5475 -
5476 if (parent)
evaluated: parent
TRUEFALSE
yes
Evaluation Count:92
yes
Evaluation Count:2118
92-2118
5477 parent->d_ptr->ensureSceneTransformRecursive(topMostDirtyItem);
executed: parent->d_ptr->ensureSceneTransformRecursive(topMostDirtyItem);
Execution Count:92
92
5478 -
5479 if (*topMostDirtyItem == q_ptr) {
evaluated: *topMostDirtyItem == q_ptr
TRUEFALSE
yes
Evaluation Count:2118
yes
Evaluation Count:92
92-2118
5480 if (!dirtySceneTransform)
evaluated: !dirtySceneTransform
TRUEFALSE
yes
Evaluation Count:1931
yes
Evaluation Count:187
187-1931
5481 return; // OK, neither my ancestors nor I have dirty scene transforms.
executed: return;
Execution Count:1931
1931
5482 *topMostDirtyItem = 0;
executed (the execution status of this line is deduced): *topMostDirtyItem = 0;
-
5483 } else if (*topMostDirtyItem) {
executed: }
Execution Count:187
evaluated: *topMostDirtyItem
TRUEFALSE
yes
Evaluation Count:84
yes
Evaluation Count:8
8-187
5484 return; // Continue backtrack.
executed: return;
Execution Count:84
84
5485 } -
5486 -
5487 // This item and all its descendants have dirty scene transforms. -
5488 // We're about to validate this item's scene transform, so we have to -
5489 // invalidate all the children; otherwise there's no way for the descendants -
5490 // to detect that the ancestor has changed. -
5491 invalidateChildrenSceneTransform();
executed (the execution status of this line is deduced): invalidateChildrenSceneTransform();
-
5492 -
5493 // COMBINE my transform with the parent's scene transform. -
5494 updateSceneTransformFromParent();
executed (the execution status of this line is deduced): updateSceneTransformFromParent();
-
5495 Q_ASSERT(!dirtySceneTransform);
executed (the execution status of this line is deduced): qt_noop();
-
5496}
executed: }
Execution Count:195
195
5497 -
5498/*! -
5499 \internal -
5500*/ -
5501void QGraphicsItemPrivate::setSubFocus(QGraphicsItem *rootItem, QGraphicsItem *stopItem) -
5502{ -
5503 // Update focus child chain. Stop at panels, or if this item -
5504 // is hidden, stop at the first item with a visible parent. -
5505 QGraphicsItem *parent = rootItem ? rootItem : q_ptr;
partially evaluated: rootItem
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
0-14
5506 if (parent->panel() != q_ptr->panel())
partially evaluated: parent->panel() != q_ptr->panel()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
5507 return;
never executed: return;
0
5508 -
5509 do { -
5510 // Clear any existing ancestor's subFocusItem. -
5511 if (parent != q_ptr && parent->d_ptr->subFocusItem) {
partially evaluated: parent != q_ptr
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
never evaluated: parent->d_ptr->subFocusItem
0-14
5512 if (parent->d_ptr->subFocusItem == q_ptr)
never evaluated: parent->d_ptr->subFocusItem == q_ptr
0
5513 break;
never executed: break;
0
5514 parent->d_ptr->subFocusItem->d_ptr->clearSubFocus(0, stopItem);
never executed (the execution status of this line is deduced): parent->d_ptr->subFocusItem->d_ptr->clearSubFocus(0, stopItem);
-
5515 }
never executed: }
0
5516 parent->d_ptr->subFocusItem = q_ptr;
executed (the execution status of this line is deduced): parent->d_ptr->subFocusItem = q_ptr;
-
5517 parent->d_ptr->subFocusItemChange();
executed (the execution status of this line is deduced): parent->d_ptr->subFocusItemChange();
-
5518 } while (!parent->isPanel() && (parent = parent->d_ptr->parent) && (visible || !parent->d_ptr->visible));
executed: }
Execution Count:14
partially evaluated: !parent->isPanel()
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
partially evaluated: (parent = parent->d_ptr->parent)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
never evaluated: visible
never evaluated: !parent->d_ptr->visible
0-14
5519 -
5520 if (scene && !scene->isActive()) {
partially evaluated: scene
TRUEFALSE
yes
Evaluation Count:14
no
Evaluation Count:0
evaluated: !scene->isActive()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:13
0-14
5521 scene->d_func()->passiveFocusItem = subFocusItem;
executed (the execution status of this line is deduced): scene->d_func()->passiveFocusItem = subFocusItem;
-
5522 scene->d_func()->lastFocusItem = subFocusItem;
executed (the execution status of this line is deduced): scene->d_func()->lastFocusItem = subFocusItem;
-
5523 }
executed: }
Execution Count:1
1
5524}
executed: }
Execution Count:14
14
5525 -
5526/*! -
5527 \internal -
5528*/ -
5529void QGraphicsItemPrivate::clearSubFocus(QGraphicsItem *rootItem, QGraphicsItem *stopItem) -
5530{ -
5531 // Reset sub focus chain. -
5532 QGraphicsItem *parent = rootItem ? rootItem : q_ptr;
evaluated: rootItem
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:1700
11-1700
5533 do { -
5534 if (parent->d_ptr->subFocusItem != q_ptr)
evaluated: parent->d_ptr->subFocusItem != q_ptr
TRUEFALSE
yes
Evaluation Count:1700
yes
Evaluation Count:11
11-1700
5535 break;
executed: break;
Execution Count:1700
1700
5536 parent->d_ptr->subFocusItem = 0;
executed (the execution status of this line is deduced): parent->d_ptr->subFocusItem = 0;
-
5537 if (parent != stopItem && !parent->isAncestorOf(stopItem))
partially evaluated: parent != stopItem
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
partially evaluated: !parent->isAncestorOf(stopItem)
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
0-11
5538 parent->d_ptr->subFocusItemChange();
executed: parent->d_ptr->subFocusItemChange();
Execution Count:11
11
5539 } while (!parent->isPanel() && (parent = parent->d_ptr->parent));
executed: }
Execution Count:11
partially evaluated: !parent->isPanel()
TRUEFALSE
yes
Evaluation Count:11
no
Evaluation Count:0
partially evaluated: (parent = parent->d_ptr->parent)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:11
0-11
5540}
executed: }
Execution Count:1711
1711
5541 -
5542/*! -
5543 \internal -
5544 -
5545 Sets the focusProxy pointer to 0 for all items that have this item as their -
5546 focusProxy. -
5547*/ -
5548void QGraphicsItemPrivate::resetFocusProxy() -
5549{ -
5550 for (int i = 0; i < focusProxyRefs.size(); ++i)
partially evaluated: i < focusProxyRefs.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1771
0-1771
5551 *focusProxyRefs.at(i) = 0;
never executed: *focusProxyRefs.at(i) = 0;
0
5552 focusProxyRefs.clear();
executed (the execution status of this line is deduced): focusProxyRefs.clear();
-
5553}
executed: }
Execution Count:1771
1771
5554 -
5555/*! -
5556 \internal -
5557 -
5558 Subclasses can reimplement this function to be notified when subFocusItem -
5559 changes. -
5560*/ -
5561void QGraphicsItemPrivate::subFocusItemChange() -
5562{ -
5563} -
5564 -
5565/*! -
5566 \internal -
5567 -
5568 Subclasses can reimplement this function to be notified when an item -
5569 becomes a focusScopeItem (or is no longer a focusScopeItem). -
5570*/ -
5571void QGraphicsItemPrivate::focusScopeItemChange(bool isSubFocusItem) -
5572{ -
5573 Q_UNUSED(isSubFocusItem);
never executed (the execution status of this line is deduced): (void)isSubFocusItem;;
-
5574}
never executed: }
0
5575 -
5576/*! -
5577 \internal -
5578 -
5579 Subclasses can reimplement this function to be notified when its -
5580 siblingIndex order is changed. -
5581*/ -
5582void QGraphicsItemPrivate::siblingOrderChange() -
5583{ -
5584} -
5585 -
5586/*! -
5587 \internal -
5588 -
5589 Tells us if it is a proxy widget -
5590*/ -
5591bool QGraphicsItemPrivate::isProxyWidget() const -
5592{ -
5593 return false;
never executed: return false;
0
5594} -
5595 -
5596/*! -
5597 Schedules a redraw of the area covered by \a rect in this item. You can -
5598 call this function whenever your item needs to be redrawn, such as if it -
5599 changes appearance or size. -
5600 -
5601 This function does not cause an immediate paint; instead it schedules a -
5602 paint request that is processed by QGraphicsView after control reaches the -
5603 event loop. The item will only be redrawn if it is visible in any -
5604 associated view. -
5605 -
5606 As a side effect of the item being repainted, other items that overlap the -
5607 area \a rect may also be repainted. -
5608 -
5609 If the item is invisible (i.e., isVisible() returns false), this function -
5610 does nothing. -
5611 -
5612 \sa paint(), boundingRect() -
5613*/ -
5614void QGraphicsItem::update(const QRectF &rect) -
5615{ -
5616 if (rect.isEmpty() && !rect.isNull())
evaluated: rect.isEmpty()
TRUEFALSE
yes
Evaluation Count:3416
yes
Evaluation Count:317
partially evaluated: !rect.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3416
0-3416
5617 return;
never executed: return;
0
5618 -
5619 // Make sure we notify effects about invalidated source. -
5620#ifndef QT_NO_GRAPHICSEFFECT -
5621 d_ptr->invalidateParentGraphicsEffectsRecursively();
executed (the execution status of this line is deduced): d_ptr->invalidateParentGraphicsEffectsRecursively();
-
5622#endif //QT_NO_GRAPHICSEFFECT -
5623 -
5624 if (CacheMode(d_ptr->cacheMode) != NoCache) {
partially evaluated: CacheMode(d_ptr->cacheMode) != NoCache
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3733
0-3733
5625 // Invalidate cache. -
5626 QGraphicsItemCache *cache = d_ptr->extraItemCache();
never executed (the execution status of this line is deduced): QGraphicsItemCache *cache = d_ptr->extraItemCache();
-
5627 if (!cache->allExposed) {
never evaluated: !cache->allExposed
0
5628 if (rect.isNull()) {
never evaluated: rect.isNull()
0
5629 cache->allExposed = true;
never executed (the execution status of this line is deduced): cache->allExposed = true;
-
5630 cache->exposed.clear();
never executed (the execution status of this line is deduced): cache->exposed.clear();
-
5631 } else {
never executed: }
0
5632 cache->exposed.append(rect);
never executed (the execution status of this line is deduced): cache->exposed.append(rect);
-
5633 }
never executed: }
0
5634 } -
5635 // Only invalidate cache; item is already dirty. -
5636 if (d_ptr->fullUpdatePending)
never evaluated: d_ptr->fullUpdatePending
0
5637 return;
never executed: return;
0
5638 }
never executed: }
0
5639 -
5640 if (d_ptr->scene)
evaluated: d_ptr->scene
TRUEFALSE
yes
Evaluation Count:1648
yes
Evaluation Count:2085
1648-2085
5641 d_ptr->scene->d_func()->markDirty(this, rect);
executed: d_ptr->scene->d_func()->markDirty(this, rect);
Execution Count:1648
1648
5642}
executed: }
Execution Count:3733
3733
5643 -
5644/*! -
5645 \since 4.4 -
5646 Scrolls the contents of \a rect by \a dx, \a dy. If \a rect is a null rect -
5647 (the default), the item's bounding rect is scrolled. -
5648 -
5649 Scrolling provides a fast alternative to simply redrawing when the -
5650 contents of the item (or parts of the item) are shifted vertically or -
5651 horizontally. Depending on the current transformation and the capabilities -
5652 of the paint device (i.e., the viewport), this operation may consist of -
5653 simply moving pixels from one location to another using memmove(). In most -
5654 cases this is faster than rerendering the entire area. -
5655 -
5656 After scrolling, the item will issue an update for the newly exposed -
5657 areas. If scrolling is not supported (e.g., you are rendering to an OpenGL -
5658 viewport, which does not benefit from scroll optimizations), this function -
5659 is equivalent to calling update(\a rect). -
5660 -
5661 \b{Note:} Scrolling is only supported when QGraphicsItem::ItemCoordinateCache -
5662 is enabled; in all other cases calling this function is equivalent to calling -
5663 update(\a rect). If you for sure know that the item is opaque and not overlapped -
5664 by other items, you can map the \a rect to viewport coordinates and scroll the -
5665 viewport. -
5666 -
5667 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 19 -
5668 -
5669 \sa boundingRect() -
5670*/ -
5671void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect) -
5672{ -
5673 Q_D(QGraphicsItem);
never executed (the execution status of this line is deduced): QGraphicsItemPrivate * const d = d_func();
-
5674 if (dx == 0.0 && dy == 0.0)
never evaluated: dx == 0.0
never evaluated: dy == 0.0
0
5675 return;
never executed: return;
0
5676 if (!d->scene)
never evaluated: !d->scene
0
5677 return;
never executed: return;
0
5678 -
5679 // Accelerated scrolling means moving pixels from one location to another -
5680 // and only redraw the newly exposed area. The following requirements must -
5681 // be fulfilled in order to do that: -
5682 // -
5683 // 1) Item is opaque. -
5684 // 2) Item is not overlapped by other items. -
5685 // -
5686 // There's (yet) no way to detect whether an item is opaque or not, which means -
5687 // we cannot do accelerated scrolling unless the cache is enabled. In case of using -
5688 // DeviceCoordinate cache we also have to take the device transform into account in -
5689 // order to determine whether we can do accelerated scrolling or not. That's left out -
5690 // for simplicity here, but it is definitely something we can consider in the future -
5691 // as a performance improvement. -
5692 if (d->cacheMode != QGraphicsItem::ItemCoordinateCache
never evaluated: d->cacheMode != QGraphicsItem::ItemCoordinateCache
0
5693 || !qFuzzyIsNull(dx - int(dx)) || !qFuzzyIsNull(dy - int(dy))) {
never evaluated: !qFuzzyIsNull(dx - int(dx))
never evaluated: !qFuzzyIsNull(dy - int(dy))
0
5694 update(rect);
never executed (the execution status of this line is deduced): update(rect);
-
5695 return;
never executed: return;
0
5696 } -
5697 -
5698 QGraphicsItemCache *cache = d->extraItemCache();
never executed (the execution status of this line is deduced): QGraphicsItemCache *cache = d->extraItemCache();
-
5699 if (cache->allExposed || cache->fixedSize.isValid()) {
never evaluated: cache->allExposed
never evaluated: cache->fixedSize.isValid()
0
5700 // Cache is either invalidated or item is scaled (see QGraphicsItem::setCacheMode). -
5701 update(rect);
never executed (the execution status of this line is deduced): update(rect);
-
5702 return;
never executed: return;
0
5703 } -
5704 -
5705 // Find pixmap in cache. -
5706 QPixmap cachedPixmap;
never executed (the execution status of this line is deduced): QPixmap cachedPixmap;
-
5707 if (!QPixmapCache::find(cache->key, &cachedPixmap)) {
never evaluated: !QPixmapCache::find(cache->key, &cachedPixmap)
0
5708 update(rect);
never executed (the execution status of this line is deduced): update(rect);
-
5709 return;
never executed: return;
0
5710 } -
5711 -
5712 QRect scrollRect = (rect.isNull() ? boundingRect() : rect).toAlignedRect();
never evaluated: rect.isNull()
0
5713 if (!scrollRect.intersects(cache->boundingRect))
never evaluated: !scrollRect.intersects(cache->boundingRect)
0
5714 return; // Nothing to scroll.
never executed: return;
0
5715 -
5716 // Remove from cache to avoid deep copy when modifying. -
5717 QPixmapCache::remove(cache->key);
never executed (the execution status of this line is deduced): QPixmapCache::remove(cache->key);
-
5718 -
5719 QRegion exposed;
never executed (the execution status of this line is deduced): QRegion exposed;
-
5720 cachedPixmap.scroll(dx, dy, scrollRect.translated(-cache->boundingRect.topLeft()), &exposed);
never executed (the execution status of this line is deduced): cachedPixmap.scroll(dx, dy, scrollRect.translated(-cache->boundingRect.topLeft()), &exposed);
-
5721 -
5722 // Reinsert into cache. -
5723 cache->key = QPixmapCache::insert(cachedPixmap);
never executed (the execution status of this line is deduced): cache->key = QPixmapCache::insert(cachedPixmap);
-
5724 -
5725 // Translate the existing expose. -
5726 for (int i = 0; i < cache->exposed.size(); ++i) {
never evaluated: i < cache->exposed.size()
0
5727 QRectF &e = cache->exposed[i];
never executed (the execution status of this line is deduced): QRectF &e = cache->exposed[i];
-
5728 if (!rect.isNull() && !e.intersects(rect))
never evaluated: !rect.isNull()
never evaluated: !e.intersects(rect)
0
5729 continue;
never executed: continue;
0
5730 e.translate(dx, dy);
never executed (the execution status of this line is deduced): e.translate(dx, dy);
-
5731 }
never executed: }
0
5732 -
5733 // Append newly exposed areas. Note that the exposed region is currently -
5734 // in pixmap coordinates, so we have to translate it to item coordinates. -
5735 exposed.translate(cache->boundingRect.topLeft());
never executed (the execution status of this line is deduced): exposed.translate(cache->boundingRect.topLeft());
-
5736 const QVector<QRect> exposedRects = exposed.rects();
never executed (the execution status of this line is deduced): const QVector<QRect> exposedRects = exposed.rects();
-
5737 for (int i = 0; i < exposedRects.size(); ++i)
never evaluated: i < exposedRects.size()
0
5738 cache->exposed += exposedRects.at(i);
never executed: cache->exposed += exposedRects.at(i);
0
5739 -
5740 // Trigger update. This will redraw the newly exposed area and make sure -
5741 // the pixmap is re-blitted in case there are overlapping items. -
5742 d->scene->d_func()->markDirty(this, rect);
never executed (the execution status of this line is deduced): d->scene->d_func()->markDirty(this, rect);
-
5743}
never executed: }
0
5744 -
5745/*! -
5746 \fn void QGraphicsItem::update(qreal x, qreal y, qreal width, qreal height) -
5747 \overload -
5748 -
5749 This convenience function is equivalent to calling update(QRectF(\a x, \a -
5750 y, \a width, \a height)). -
5751*/ -
5752 -
5753/*! -
5754 Maps the point \a point, which is in this item's coordinate system, to \a -
5755 item's coordinate system, and returns the mapped coordinate. -
5756 -
5757 If \a item is 0, this function returns the same as mapToScene(). -
5758 -
5759 \sa itemTransform(), mapToParent(), mapToScene(), transform(), mapFromItem(), {The Graphics -
5760 View Coordinate System} -
5761*/ -
5762QPointF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPointF &point) const -
5763{ -
5764 if (item)
never evaluated: item
0
5765 return itemTransform(item).map(point);
never executed: return itemTransform(item).map(point);
0
5766 return mapToScene(point);
never executed: return mapToScene(point);
0
5767} -
5768 -
5769/*! -
5770 \fn QPointF QGraphicsItem::mapToItem(const QGraphicsItem *item, qreal x, qreal y) const -
5771 \overload -
5772 -
5773 This convenience function is equivalent to calling mapToItem(\a item, -
5774 QPointF(\a x, \a y)). -
5775*/ -
5776 -
5777/*! -
5778 Maps the point \a point, which is in this item's coordinate system, to its -
5779 parent's coordinate system, and returns the mapped coordinate. If the item -
5780 has no parent, \a point will be mapped to the scene's coordinate system. -
5781 -
5782 \sa mapToItem(), mapToScene(), transform(), mapFromParent(), {The Graphics -
5783 View Coordinate System} -
5784*/ -
5785QPointF QGraphicsItem::mapToParent(const QPointF &point) const -
5786{ -
5787 // COMBINE -
5788 if (!d_ptr->transformData)
partially evaluated: !d_ptr->transformData
TRUEFALSE
yes
Evaluation Count:2
no
Evaluation Count:0
0-2
5789 return point + d_ptr->pos;
executed: return point + d_ptr->pos;
Execution Count:2
2
5790 return d_ptr->transformToParent().map(point);
never executed: return d_ptr->transformToParent().map(point);
0
5791} -
5792 -
5793/*! -
5794 \fn QPointF QGraphicsItem::mapToParent(qreal x, qreal y) const -
5795 \overload -
5796 -
5797 This convenience function is equivalent to calling mapToParent(QPointF(\a -
5798 x, \a y)). -
5799*/ -
5800 -
5801/*! -
5802 Maps the point \a point, which is in this item's coordinate system, to the -
5803 scene's coordinate system, and returns the mapped coordinate. -
5804 -
5805 \sa mapToItem(), mapToParent(), transform(), mapFromScene(), {The Graphics -
5806 View Coordinate System} -
5807*/ -
5808QPointF QGraphicsItem::mapToScene(const QPointF &point) const -
5809{ -
5810 if (d_ptr->hasTranslateOnlySceneTransform())
partially evaluated: d_ptr->hasTranslateOnlySceneTransform()
TRUEFALSE
yes
Evaluation Count:37
no
Evaluation Count:0
0-37
5811 return QPointF(point.x() + d_ptr->sceneTransform.dx(), point.y() + d_ptr->sceneTransform.dy());
executed: return QPointF(point.x() + d_ptr->sceneTransform.dx(), point.y() + d_ptr->sceneTransform.dy());
Execution Count:37
37
5812 return d_ptr->sceneTransform.map(point);
never executed: return d_ptr->sceneTransform.map(point);
0
5813} -
5814 -
5815/*! -
5816 \fn QPointF QGraphicsItem::mapToScene(qreal x, qreal y) const -
5817 \overload -
5818 -
5819 This convenience function is equivalent to calling mapToScene(QPointF(\a -
5820 x, \a y)). -
5821*/ -
5822 -
5823/*! -
5824 Maps the rectangle \a rect, which is in this item's coordinate system, to -
5825 \a item's coordinate system, and returns the mapped rectangle as a polygon. -
5826 -
5827 If \a item is 0, this function returns the same as mapToScene(). -
5828 -
5829 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The -
5830 Graphics View Coordinate System} -
5831*/ -
5832QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QRectF &rect) const -
5833{ -
5834 if (item)
never evaluated: item
0
5835 return itemTransform(item).map(rect);
never executed: return itemTransform(item).map(rect);
0
5836 return mapToScene(rect);
never executed: return mapToScene(rect);
0
5837} -
5838 -
5839/*! -
5840 \fn QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const -
5841 \since 4.3 -
5842 -
5843 This convenience function is equivalent to calling mapToItem(item, QRectF(\a x, \a y, \a w, \a h)). -
5844*/ -
5845 -
5846/*! -
5847 Maps the rectangle \a rect, which is in this item's coordinate system, to -
5848 its parent's coordinate system, and returns the mapped rectangle as a -
5849 polygon. If the item has no parent, \a rect will be mapped to the scene's -
5850 coordinate system. -
5851 -
5852 \sa mapToScene(), mapToItem(), mapFromParent(), {The Graphics View -
5853 Coordinate System} -
5854*/ -
5855QPolygonF QGraphicsItem::mapToParent(const QRectF &rect) const -
5856{ -
5857 // COMBINE -
5858 if (!d_ptr->transformData)
never evaluated: !d_ptr->transformData
0
5859 return rect.translated(d_ptr->pos);
never executed: return rect.translated(d_ptr->pos);
0
5860 return d_ptr->transformToParent().map(rect);
never executed: return d_ptr->transformToParent().map(rect);
0
5861} -
5862 -
5863/*! -
5864 \fn QPolygonF QGraphicsItem::mapToParent(qreal x, qreal y, qreal w, qreal h) const -
5865 \since 4.3 -
5866 -
5867 This convenience function is equivalent to calling mapToParent(QRectF(\a x, \a y, \a w, \a h)). -
5868*/ -
5869 -
5870/*! -
5871 Maps the rectangle \a rect, which is in this item's coordinate system, to -
5872 the scene's coordinate system, and returns the mapped rectangle as a polygon. -
5873 -
5874 \sa mapToParent(), mapToItem(), mapFromScene(), {The Graphics View -
5875 Coordinate System} -
5876*/ -
5877QPolygonF QGraphicsItem::mapToScene(const QRectF &rect) const -
5878{ -
5879 if (d_ptr->hasTranslateOnlySceneTransform())
never evaluated: d_ptr->hasTranslateOnlySceneTransform()
0
5880 return rect.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
never executed: return rect.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
0
5881 return d_ptr->sceneTransform.map(rect);
never executed: return d_ptr->sceneTransform.map(rect);
0
5882} -
5883 -
5884/*! -
5885 \fn QPolygonF QGraphicsItem::mapToScene(qreal x, qreal y, qreal w, qreal h) const -
5886 \since 4.3 -
5887 -
5888 This convenience function is equivalent to calling mapToScene(QRectF(\a x, \a y, \a w, \a h)). -
5889*/ -
5890 -
5891/*! -
5892 \since 4.5 -
5893 -
5894 Maps the rectangle \a rect, which is in this item's coordinate system, to -
5895 \a item's coordinate system, and returns the mapped rectangle as a new -
5896 rectangle (i.e., the bounding rectangle of the resulting polygon). -
5897 -
5898 If \a item is 0, this function returns the same as mapRectToScene(). -
5899 -
5900 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The -
5901 Graphics View Coordinate System} -
5902*/ -
5903QRectF QGraphicsItem::mapRectToItem(const QGraphicsItem *item, const QRectF &rect) const -
5904{ -
5905 if (item)
partially evaluated: item
TRUEFALSE
yes
Evaluation Count:30
no
Evaluation Count:0
0-30
5906 return itemTransform(item).mapRect(rect);
executed: return itemTransform(item).mapRect(rect);
Execution Count:30
30
5907 return mapRectToScene(rect);
never executed: return mapRectToScene(rect);
0
5908} -
5909 -
5910/*! -
5911 \fn QRectF QGraphicsItem::mapRectToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const -
5912 \since 4.5 -
5913 -
5914 This convenience function is equivalent to calling mapRectToItem(item, QRectF(\a x, \a y, \a w, \a h)). -
5915*/ -
5916 -
5917/*! -
5918 \since 4.5 -
5919 -
5920 Maps the rectangle \a rect, which is in this item's coordinate system, to -
5921 its parent's coordinate system, and returns the mapped rectangle as a new -
5922 rectangle (i.e., the bounding rectangle of the resulting polygon). -
5923 -
5924 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The -
5925 Graphics View Coordinate System} -
5926*/ -
5927QRectF QGraphicsItem::mapRectToParent(const QRectF &rect) const -
5928{ -
5929 // COMBINE -
5930 if (!d_ptr->transformData)
never evaluated: !d_ptr->transformData
0
5931 return rect.translated(d_ptr->pos);
never executed: return rect.translated(d_ptr->pos);
0
5932 return d_ptr->transformToParent().mapRect(rect);
never executed: return d_ptr->transformToParent().mapRect(rect);
0
5933} -
5934 -
5935/*! -
5936 \fn QRectF QGraphicsItem::mapRectToParent(qreal x, qreal y, qreal w, qreal h) const -
5937 \since 4.5 -
5938 -
5939 This convenience function is equivalent to calling mapRectToParent(QRectF(\a x, \a y, \a w, \a h)). -
5940*/ -
5941 -
5942/*! -
5943 \since 4.5 -
5944 -
5945 Maps the rectangle \a rect, which is in this item's coordinate system, to -
5946 the scene coordinate system, and returns the mapped rectangle as a new -
5947 rectangle (i.e., the bounding rectangle of the resulting polygon). -
5948 -
5949 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The -
5950 Graphics View Coordinate System} -
5951*/ -
5952QRectF QGraphicsItem::mapRectToScene(const QRectF &rect) const -
5953{ -
5954 if (d_ptr->hasTranslateOnlySceneTransform())
evaluated: d_ptr->hasTranslateOnlySceneTransform()
TRUEFALSE
yes
Evaluation Count:86
yes
Evaluation Count:3
3-86
5955 return rect.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
executed: return rect.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
Execution Count:86
86
5956 return d_ptr->sceneTransform.mapRect(rect);
executed: return d_ptr->sceneTransform.mapRect(rect);
Execution Count:3
3
5957} -
5958 -
5959/*! -
5960 \fn QRectF QGraphicsItem::mapRectToScene(qreal x, qreal y, qreal w, qreal h) const -
5961 \since 4.5 -
5962 -
5963 This convenience function is equivalent to calling mapRectToScene(QRectF(\a x, \a y, \a w, \a h)). -
5964*/ -
5965 -
5966/*! -
5967 \since 4.5 -
5968 -
5969 Maps the rectangle \a rect, which is in \a item's coordinate system, to -
5970 this item's coordinate system, and returns the mapped rectangle as a new -
5971 rectangle (i.e., the bounding rectangle of the resulting polygon). -
5972 -
5973 If \a item is 0, this function returns the same as mapRectFromScene(). -
5974 -
5975 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The -
5976 Graphics View Coordinate System} -
5977*/ -
5978QRectF QGraphicsItem::mapRectFromItem(const QGraphicsItem *item, const QRectF &rect) const -
5979{ -
5980 if (item)
never evaluated: item
0
5981 return item->itemTransform(this).mapRect(rect);
never executed: return item->itemTransform(this).mapRect(rect);
0
5982 return mapRectFromScene(rect);
never executed: return mapRectFromScene(rect);
0
5983} -
5984 -
5985/*! -
5986 \fn QRectF QGraphicsItem::mapRectFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const -
5987 \since 4.5 -
5988 -
5989 This convenience function is equivalent to calling mapRectFromItem(item, QRectF(\a x, \a y, \a w, \a h)). -
5990*/ -
5991 -
5992/*! -
5993 \since 4.5 -
5994 -
5995 Maps the rectangle \a rect, which is in this item's parent's coordinate -
5996 system, to this item's coordinate system, and returns the mapped rectangle -
5997 as a new rectangle (i.e., the bounding rectangle of the resulting -
5998 polygon). -
5999 -
6000 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The -
6001 Graphics View Coordinate System} -
6002*/ -
6003QRectF QGraphicsItem::mapRectFromParent(const QRectF &rect) const -
6004{ -
6005 // COMBINE -
6006 if (!d_ptr->transformData)
never evaluated: !d_ptr->transformData
0
6007 return rect.translated(-d_ptr->pos);
never executed: return rect.translated(-d_ptr->pos);
0
6008 return d_ptr->transformToParent().inverted().mapRect(rect);
never executed: return d_ptr->transformToParent().inverted().mapRect(rect);
0
6009} -
6010 -
6011/*! -
6012 \fn QRectF QGraphicsItem::mapRectFromParent(qreal x, qreal y, qreal w, qreal h) const -
6013 \since 4.5 -
6014 -
6015 This convenience function is equivalent to calling mapRectFromParent(QRectF(\a x, \a y, \a w, \a h)). -
6016*/ -
6017 -
6018/*! -
6019 \since 4.5 -
6020 -
6021 Maps the rectangle \a rect, which is in scene coordinates, to this item's -
6022 coordinate system, and returns the mapped rectangle as a new rectangle -
6023 (i.e., the bounding rectangle of the resulting polygon). -
6024 -
6025 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The -
6026 Graphics View Coordinate System} -
6027*/ -
6028QRectF QGraphicsItem::mapRectFromScene(const QRectF &rect) const -
6029{ -
6030 if (d_ptr->hasTranslateOnlySceneTransform())
evaluated: d_ptr->hasTranslateOnlySceneTransform()
TRUEFALSE
yes
Evaluation Count:86
yes
Evaluation Count:3
3-86
6031 return rect.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
executed: return rect.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
Execution Count:86
86
6032 return d_ptr->sceneTransform.inverted().mapRect(rect);
executed: return d_ptr->sceneTransform.inverted().mapRect(rect);
Execution Count:3
3
6033} -
6034 -
6035/*! -
6036 \fn QRectF QGraphicsItem::mapRectFromScene(qreal x, qreal y, qreal w, qreal h) const -
6037 \since 4.5 -
6038 -
6039 This convenience function is equivalent to calling mapRectFromScene(QRectF(\a x, \a y, \a w, \a h)). -
6040*/ -
6041 -
6042/*! -
6043 Maps the polygon \a polygon, which is in this item's coordinate system, to -
6044 \a item's coordinate system, and returns the mapped polygon. -
6045 -
6046 If \a item is 0, this function returns the same as mapToScene(). -
6047 -
6048 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The -
6049 Graphics View Coordinate System} -
6050*/ -
6051QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPolygonF &polygon) const -
6052{ -
6053 if (item)
never evaluated: item
0
6054 return itemTransform(item).map(polygon);
never executed: return itemTransform(item).map(polygon);
0
6055 return mapToScene(polygon);
never executed: return mapToScene(polygon);
0
6056} -
6057 -
6058/*! -
6059 Maps the polygon \a polygon, which is in this item's coordinate system, to -
6060 its parent's coordinate system, and returns the mapped polygon. If the -
6061 item has no parent, \a polygon will be mapped to the scene's coordinate -
6062 system. -
6063 -
6064 \sa mapToScene(), mapToItem(), mapFromParent(), {The Graphics View -
6065 Coordinate System} -
6066*/ -
6067QPolygonF QGraphicsItem::mapToParent(const QPolygonF &polygon) const -
6068{ -
6069 // COMBINE -
6070 if (!d_ptr->transformData)
never evaluated: !d_ptr->transformData
0
6071 return polygon.translated(d_ptr->pos);
never executed: return polygon.translated(d_ptr->pos);
0
6072 return d_ptr->transformToParent().map(polygon);
never executed: return d_ptr->transformToParent().map(polygon);
0
6073} -
6074 -
6075/*! -
6076 Maps the polygon \a polygon, which is in this item's coordinate system, to -
6077 the scene's coordinate system, and returns the mapped polygon. -
6078 -
6079 \sa mapToParent(), mapToItem(), mapFromScene(), {The Graphics View -
6080 Coordinate System} -
6081*/ -
6082QPolygonF QGraphicsItem::mapToScene(const QPolygonF &polygon) const -
6083{ -
6084 if (d_ptr->hasTranslateOnlySceneTransform())
never evaluated: d_ptr->hasTranslateOnlySceneTransform()
0
6085 return polygon.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
never executed: return polygon.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
0
6086 return d_ptr->sceneTransform.map(polygon);
never executed: return d_ptr->sceneTransform.map(polygon);
0
6087} -
6088 -
6089/*! -
6090 Maps the path \a path, which is in this item's coordinate system, to -
6091 \a item's coordinate system, and returns the mapped path. -
6092 -
6093 If \a item is 0, this function returns the same as mapToScene(). -
6094 -
6095 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The -
6096 Graphics View Coordinate System} -
6097*/ -
6098QPainterPath QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPainterPath &path) const -
6099{ -
6100 if (item)
partially evaluated: item
TRUEFALSE
yes
Evaluation Count:6
no
Evaluation Count:0
0-6
6101 return itemTransform(item).map(path);
executed: return itemTransform(item).map(path);
Execution Count:6
6
6102 return mapToScene(path);
never executed: return mapToScene(path);
0
6103} -
6104 -
6105/*! -
6106 Maps the path \a path, which is in this item's coordinate system, to -
6107 its parent's coordinate system, and returns the mapped path. If the -
6108 item has no parent, \a path will be mapped to the scene's coordinate -
6109 system. -
6110 -
6111 \sa mapToScene(), mapToItem(), mapFromParent(), {The Graphics View -
6112 Coordinate System} -
6113*/ -
6114QPainterPath QGraphicsItem::mapToParent(const QPainterPath &path) const -
6115{ -
6116 // COMBINE -
6117 if (!d_ptr->transformData)
never evaluated: !d_ptr->transformData
0
6118 return path.translated(d_ptr->pos);
never executed: return path.translated(d_ptr->pos);
0
6119 return d_ptr->transformToParent().map(path);
never executed: return d_ptr->transformToParent().map(path);
0
6120} -
6121 -
6122/*! -
6123 Maps the path \a path, which is in this item's coordinate system, to -
6124 the scene's coordinate system, and returns the mapped path. -
6125 -
6126 \sa mapToParent(), mapToItem(), mapFromScene(), {The Graphics View -
6127 Coordinate System} -
6128*/ -
6129QPainterPath QGraphicsItem::mapToScene(const QPainterPath &path) const -
6130{ -
6131 if (d_ptr->hasTranslateOnlySceneTransform())
never evaluated: d_ptr->hasTranslateOnlySceneTransform()
0
6132 return path.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
never executed: return path.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
0
6133 return d_ptr->sceneTransform.map(path);
never executed: return d_ptr->sceneTransform.map(path);
0
6134} -
6135 -
6136/*! -
6137 Maps the point \a point, which is in \a item's coordinate system, to this -
6138 item's coordinate system, and returns the mapped coordinate. -
6139 -
6140 If \a item is 0, this function returns the same as mapFromScene(). -
6141 -
6142 \sa itemTransform(), mapFromParent(), mapFromScene(), transform(), mapToItem(), {The Graphics -
6143 View Coordinate System} -
6144*/ -
6145QPointF QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QPointF &point) const -
6146{ -
6147 if (item)
never evaluated: item
0
6148 return item->itemTransform(this).map(point);
never executed: return item->itemTransform(this).map(point);
0
6149 return mapFromScene(point);
never executed: return mapFromScene(point);
0
6150} -
6151 -
6152/*! -
6153 \fn QPointF QGraphicsItem::mapFromItem(const QGraphicsItem *item, qreal x, qreal y) const -
6154 \overload -
6155 -
6156 This convenience function is equivalent to calling mapFromItem(\a item, -
6157 QPointF(\a x, \a y)). -
6158*/ -
6159 -
6160/*! -
6161 Maps the point \a point, which is in this item's parent's coordinate -
6162 system, to this item's coordinate system, and returns the mapped -
6163 coordinate. -
6164 -
6165 \sa mapFromItem(), mapFromScene(), transform(), mapToParent(), {The Graphics -
6166 View Coordinate System} -
6167*/ -
6168QPointF QGraphicsItem::mapFromParent(const QPointF &point) const -
6169{ -
6170 // COMBINE -
6171 if (d_ptr->transformData)
never evaluated: d_ptr->transformData
0
6172 return d_ptr->transformToParent().inverted().map(point);
never executed: return d_ptr->transformToParent().inverted().map(point);
0
6173 return point - d_ptr->pos;
never executed: return point - d_ptr->pos;
0
6174} -
6175 -
6176/*! -
6177 \fn QPointF QGraphicsItem::mapFromParent(qreal x, qreal y) const -
6178 \overload -
6179 -
6180 This convenience function is equivalent to calling -
6181 mapFromParent(QPointF(\a x, \a y)). -
6182*/ -
6183 -
6184/*! -
6185 Maps the point \a point, which is in this item's scene's coordinate -
6186 system, to this item's coordinate system, and returns the mapped -
6187 coordinate. -
6188 -
6189 \sa mapFromItem(), mapFromParent(), transform(), mapToScene(), {The Graphics -
6190 View Coordinate System} -
6191*/ -
6192QPointF QGraphicsItem::mapFromScene(const QPointF &point) const -
6193{ -
6194 if (d_ptr->hasTranslateOnlySceneTransform())
partially evaluated: d_ptr->hasTranslateOnlySceneTransform()
TRUEFALSE
yes
Evaluation Count:1640
no
Evaluation Count:0
0-1640
6195 return QPointF(point.x() - d_ptr->sceneTransform.dx(), point.y() - d_ptr->sceneTransform.dy());
executed: return QPointF(point.x() - d_ptr->sceneTransform.dx(), point.y() - d_ptr->sceneTransform.dy());
Execution Count:1640
1640
6196 return d_ptr->sceneTransform.inverted().map(point);
never executed: return d_ptr->sceneTransform.inverted().map(point);
0
6197} -
6198 -
6199/*! -
6200 \fn QPointF QGraphicsItem::mapFromScene(qreal x, qreal y) const -
6201 \overload -
6202 -
6203 This convenience function is equivalent to calling mapFromScene(QPointF(\a -
6204 x, \a y)). -
6205*/ -
6206 -
6207/*! -
6208 Maps the rectangle \a rect, which is in \a item's coordinate system, to -
6209 this item's coordinate system, and returns the mapped rectangle as a -
6210 polygon. -
6211 -
6212 If \a item is 0, this function returns the same as mapFromScene() -
6213 -
6214 \sa itemTransform(), mapToItem(), mapFromParent(), transform(), {The Graphics View Coordinate -
6215 System} -
6216*/ -
6217QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QRectF &rect) const -
6218{ -
6219 if (item)
never evaluated: item
0
6220 return item->itemTransform(this).map(rect);
never executed: return item->itemTransform(this).map(rect);
0
6221 return mapFromScene(rect);
never executed: return mapFromScene(rect);
0
6222} -
6223 -
6224/*! -
6225 \fn QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const -
6226 \since 4.3 -
6227 -
6228 This convenience function is equivalent to calling mapFromItem(item, QRectF(\a x, \a y, \a w, \a h)). -
6229*/ -
6230 -
6231/*! -
6232 Maps the rectangle \a rect, which is in this item's parent's coordinate -
6233 system, to this item's coordinate system, and returns the mapped rectangle -
6234 as a polygon. -
6235 -
6236 \sa mapToParent(), mapFromItem(), transform(), {The Graphics View Coordinate -
6237 System} -
6238*/ -
6239QPolygonF QGraphicsItem::mapFromParent(const QRectF &rect) const -
6240{ -
6241 // COMBINE -
6242 if (!d_ptr->transformData)
never evaluated: !d_ptr->transformData
0
6243 return rect.translated(-d_ptr->pos);
never executed: return rect.translated(-d_ptr->pos);
0
6244 return d_ptr->transformToParent().inverted().map(rect);
never executed: return d_ptr->transformToParent().inverted().map(rect);
0
6245} -
6246 -
6247/*! -
6248 \fn QPolygonF QGraphicsItem::mapFromParent(qreal x, qreal y, qreal w, qreal h) const -
6249 \since 4.3 -
6250 -
6251 This convenience function is equivalent to calling mapFromItem(QRectF(\a x, \a y, \a w, \a h)). -
6252*/ -
6253 -
6254/*! -
6255 Maps the rectangle \a rect, which is in this item's scene's coordinate -
6256 system, to this item's coordinate system, and returns the mapped rectangle -
6257 as a polygon. -
6258 -
6259 \sa mapToScene(), mapFromItem(), transform(), {The Graphics View Coordinate -
6260 System} -
6261*/ -
6262QPolygonF QGraphicsItem::mapFromScene(const QRectF &rect) const -
6263{ -
6264 if (d_ptr->hasTranslateOnlySceneTransform())
never evaluated: d_ptr->hasTranslateOnlySceneTransform()
0
6265 return rect.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
never executed: return rect.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
0
6266 return d_ptr->sceneTransform.inverted().map(rect);
never executed: return d_ptr->sceneTransform.inverted().map(rect);
0
6267} -
6268 -
6269/*! -
6270 \fn QPolygonF QGraphicsItem::mapFromScene(qreal x, qreal y, qreal w, qreal h) const -
6271 \since 4.3 -
6272 -
6273 This convenience function is equivalent to calling mapFromScene(QRectF(\a x, \a y, \a w, \a h)). -
6274*/ -
6275 -
6276/*! -
6277 Maps the polygon \a polygon, which is in \a item's coordinate system, to -
6278 this item's coordinate system, and returns the mapped polygon. -
6279 -
6280 If \a item is 0, this function returns the same as mapFromScene(). -
6281 -
6282 \sa itemTransform(), mapToItem(), mapFromParent(), transform(), {The -
6283 Graphics View Coordinate System} -
6284*/ -
6285QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QPolygonF &polygon) const -
6286{ -
6287 if (item)
never evaluated: item
0
6288 return item->itemTransform(this).map(polygon);
never executed: return item->itemTransform(this).map(polygon);
0
6289 return mapFromScene(polygon);
never executed: return mapFromScene(polygon);
0
6290} -
6291 -
6292/*! -
6293 Maps the polygon \a polygon, which is in this item's parent's coordinate -
6294 system, to this item's coordinate system, and returns the mapped polygon. -
6295 -
6296 \sa mapToParent(), mapToItem(), transform(), {The Graphics View Coordinate -
6297 System} -
6298*/ -
6299QPolygonF QGraphicsItem::mapFromParent(const QPolygonF &polygon) const -
6300{ -
6301 // COMBINE -
6302 if (!d_ptr->transformData)
never evaluated: !d_ptr->transformData
0
6303 return polygon.translated(-d_ptr->pos);
never executed: return polygon.translated(-d_ptr->pos);
0
6304 return d_ptr->transformToParent().inverted().map(polygon);
never executed: return d_ptr->transformToParent().inverted().map(polygon);
0
6305} -
6306 -
6307/*! -
6308 Maps the polygon \a polygon, which is in this item's scene's coordinate -
6309 system, to this item's coordinate system, and returns the mapped polygon. -
6310 -
6311 \sa mapToScene(), mapFromParent(), transform(), {The Graphics View Coordinate -
6312 System} -
6313*/ -
6314QPolygonF QGraphicsItem::mapFromScene(const QPolygonF &polygon) const -
6315{ -
6316 if (d_ptr->hasTranslateOnlySceneTransform())
never evaluated: d_ptr->hasTranslateOnlySceneTransform()
0
6317 return polygon.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
never executed: return polygon.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
0
6318 return d_ptr->sceneTransform.inverted().map(polygon);
never executed: return d_ptr->sceneTransform.inverted().map(polygon);
0
6319} -
6320 -
6321/*! -
6322 Maps the path \a path, which is in \a item's coordinate system, to -
6323 this item's coordinate system, and returns the mapped path. -
6324 -
6325 If \a item is 0, this function returns the same as mapFromScene(). -
6326 -
6327 \sa itemTransform(), mapFromParent(), mapFromScene(), mapToItem(), {The -
6328 Graphics View Coordinate System} -
6329*/ -
6330QPainterPath QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QPainterPath &path) const -
6331{ -
6332 if (item)
never evaluated: item
0
6333 return item->itemTransform(this).map(path);
never executed: return item->itemTransform(this).map(path);
0
6334 return mapFromScene(path);
never executed: return mapFromScene(path);
0
6335} -
6336 -
6337/*! -
6338 Maps the path \a path, which is in this item's parent's coordinate -
6339 system, to this item's coordinate system, and returns the mapped path. -
6340 -
6341 \sa mapFromScene(), mapFromItem(), mapToParent(), {The Graphics View -
6342 Coordinate System} -
6343*/ -
6344QPainterPath QGraphicsItem::mapFromParent(const QPainterPath &path) const -
6345{ -
6346 // COMBINE -
6347 if (!d_ptr->transformData)
never evaluated: !d_ptr->transformData
0
6348 return path.translated(-d_ptr->pos);
never executed: return path.translated(-d_ptr->pos);
0
6349 return d_ptr->transformToParent().inverted().map(path);
never executed: return d_ptr->transformToParent().inverted().map(path);
0
6350} -
6351 -
6352/*! -
6353 Maps the path \a path, which is in this item's scene's coordinate -
6354 system, to this item's coordinate system, and returns the mapped path. -
6355 -
6356 \sa mapFromParent(), mapFromItem(), mapToScene(), {The Graphics View -
6357 Coordinate System} -
6358*/ -
6359QPainterPath QGraphicsItem::mapFromScene(const QPainterPath &path) const -
6360{ -
6361 if (d_ptr->hasTranslateOnlySceneTransform())
never evaluated: d_ptr->hasTranslateOnlySceneTransform()
0
6362 return path.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
never executed: return path.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
0
6363 return d_ptr->sceneTransform.inverted().map(path);
never executed: return d_ptr->sceneTransform.inverted().map(path);
0
6364} -
6365 -
6366/*! -
6367 Returns true if this item is an ancestor of \a child (i.e., if this item -
6368 is \a child's parent, or one of \a child's parent's ancestors). -
6369 -
6370 \sa parentItem() -
6371*/ -
6372bool QGraphicsItem::isAncestorOf(const QGraphicsItem *child) const -
6373{ -
6374 if (!child || child == this)
evaluated: !child
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:23
partially evaluated: child == this
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:23
0-23
6375 return false;
executed: return false;
Execution Count:11
11
6376 if (child->d_ptr->depth() < d_ptr->depth())
evaluated: child->d_ptr->depth() < d_ptr->depth()
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:12
11-12
6377 return false;
executed: return false;
Execution Count:11
11
6378 const QGraphicsItem *ancestor = child;
executed (the execution status of this line is deduced): const QGraphicsItem *ancestor = child;
-
6379 while ((ancestor = ancestor->d_ptr->parent)) {
evaluated: (ancestor = ancestor->d_ptr->parent)
TRUEFALSE
yes
Evaluation Count:8
yes
Evaluation Count:10
8-10
6380 if (ancestor == this)
evaluated: ancestor == this
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:6
2-6
6381 return true;
executed: return true;
Execution Count:2
2
6382 }
executed: }
Execution Count:6
6
6383 return false;
executed: return false;
Execution Count:10
10
6384} -
6385 -
6386/*! -
6387 \since 4.4 -
6388 -
6389 Returns the closest common ancestor item of this item and \a other, or 0 -
6390 if either \a other is 0, or there is no common ancestor. -
6391 -
6392 \sa isAncestorOf() -
6393*/ -
6394QGraphicsItem *QGraphicsItem::commonAncestorItem(const QGraphicsItem *other) const -
6395{ -
6396 if (!other)
partially evaluated: !other
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
6397 return 0;
never executed: return 0;
0
6398 if (other == this)
partially evaluated: other == this
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
6399 return const_cast<QGraphicsItem *>(this);
never executed: return const_cast<QGraphicsItem *>(this);
0
6400 const QGraphicsItem *thisw = this;
executed (the execution status of this line is deduced): const QGraphicsItem *thisw = this;
-
6401 const QGraphicsItem *otherw = other;
executed (the execution status of this line is deduced): const QGraphicsItem *otherw = other;
-
6402 int thisDepth = d_ptr->depth();
executed (the execution status of this line is deduced): int thisDepth = d_ptr->depth();
-
6403 int otherDepth = other->d_ptr->depth();
executed (the execution status of this line is deduced): int otherDepth = other->d_ptr->depth();
-
6404 while (thisDepth > otherDepth) {
partially evaluated: thisDepth > otherDepth
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:9
0-9
6405 thisw = thisw->d_ptr->parent;
never executed (the execution status of this line is deduced): thisw = thisw->d_ptr->parent;
-
6406 --thisDepth;
never executed (the execution status of this line is deduced): --thisDepth;
-
6407 }
never executed: }
0
6408 while (otherDepth > thisDepth) {
evaluated: otherDepth > thisDepth
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:9
3-9
6409 otherw = otherw->d_ptr->parent;
executed (the execution status of this line is deduced): otherw = otherw->d_ptr->parent;
-
6410 --otherDepth;
executed (the execution status of this line is deduced): --otherDepth;
-
6411 }
executed: }
Execution Count:3
3
6412 while (thisw && thisw != otherw) {
evaluated: thisw
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:7
evaluated: thisw != otherw
TRUEFALSE
yes
Evaluation Count:7
yes
Evaluation Count:2
2-9
6413 thisw = thisw->d_ptr->parent;
executed (the execution status of this line is deduced): thisw = thisw->d_ptr->parent;
-
6414 otherw = otherw->d_ptr->parent;
executed (the execution status of this line is deduced): otherw = otherw->d_ptr->parent;
-
6415 }
executed: }
Execution Count:7
7
6416 return const_cast<QGraphicsItem *>(thisw);
executed: return const_cast<QGraphicsItem *>(thisw);
Execution Count:9
9
6417} -
6418 -
6419/*! -
6420 \since 4,4 -
6421 Returns true if this item is currently under the mouse cursor in one of -
6422 the views; otherwise, false is returned. -
6423 -
6424 \sa QGraphicsScene::views(), QCursor::pos() -
6425*/ -
6426bool QGraphicsItem::isUnderMouse() const -
6427{ -
6428 Q_D(const QGraphicsItem);
executed (the execution status of this line is deduced): const QGraphicsItemPrivate * const d = d_func();
-
6429 if (!d->scene)
evaluated: !d->scene
TRUEFALSE
yes
Evaluation Count:184
yes
Evaluation Count:57
57-184
6430 return false;
executed: return false;
Execution Count:184
184
6431 -
6432 QPoint cursorPos = QCursor::pos();
executed (the execution status of this line is deduced): QPoint cursorPos = QCursor::pos();
-
6433 foreach (QGraphicsView *view, d->scene->views()) {
executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(d->scene->views())> _container_(d->scene->views()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsView *view = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
6434 if (contains(mapFromScene(view->mapToScene(view->mapFromGlobal(cursorPos)))))
evaluated: contains(mapFromScene(view->mapToScene(view->mapFromGlobal(cursorPos))))
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:45
12-45
6435 return true;
executed: return true;
Execution Count:12
12
6436 }
executed: }
Execution Count:45
45
6437 return false;
executed: return false;
Execution Count:45
45
6438} -
6439 -
6440/*! -
6441 Returns this item's custom data for the key \a key as a QVariant. -
6442 -
6443 Custom item data is useful for storing arbitrary properties in any -
6444 item. Example: -
6445 -
6446 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 11 -
6447 -
6448 Qt does not use this feature for storing data; it is provided solely -
6449 for the convenience of the user. -
6450 -
6451 \sa setData() -
6452*/ -
6453QVariant QGraphicsItem::data(int key) const -
6454{ -
6455 QGraphicsItemCustomDataStore *store = qt_dataStore();
never executed (the execution status of this line is deduced): QGraphicsItemCustomDataStore *store = qt_dataStore();
-
6456 if (!store->data.contains(this))
never evaluated: !store->data.contains(this)
0
6457 return QVariant();
never executed: return QVariant();
0
6458 return store->data.value(this).value(key);
never executed: return store->data.value(this).value(key);
0
6459} -
6460 -
6461/*! -
6462 Sets this item's custom data for the key \a key to \a value. -
6463 -
6464 Custom item data is useful for storing arbitrary properties for any -
6465 item. Qt does not use this feature for storing data; it is provided solely -
6466 for the convenience of the user. -
6467 -
6468 \sa data() -
6469*/ -
6470void QGraphicsItem::setData(int key, const QVariant &value) -
6471{ -
6472 qt_dataStore()->data[this][key] = value;
executed (the execution status of this line is deduced): qt_dataStore()->data[this][key] = value;
-
6473}
executed: }
Execution Count:7
7
6474 -
6475/*! -
6476 \fn T qgraphicsitem_cast(QGraphicsItem *item) -
6477 \relates QGraphicsItem -
6478 \since 4.2 -
6479 -
6480 Returns the given \a item cast to type T if \a item is of type T; -
6481 otherwise, 0 is returned. -
6482 -
6483 \note To make this function work correctly with custom items, reimplement -
6484 the \l{QGraphicsItem::}{type()} function for each custom QGraphicsItem -
6485 subclass. -
6486 -
6487 \sa QGraphicsItem::type(), QGraphicsItem::UserType -
6488*/ -
6489 -
6490/*! -
6491 Returns the type of an item as an int. All standard graphicsitem classes -
6492 are associated with a unique value; see QGraphicsItem::Type. This type -
6493 information is used by qgraphicsitem_cast() to distinguish between types. -
6494 -
6495 The default implementation (in QGraphicsItem) returns UserType. -
6496 -
6497 To enable use of qgraphicsitem_cast() with a custom item, reimplement this -
6498 function and declare a Type enum value equal to your custom item's type. -
6499 Custom items must return a value larger than or equal to UserType (65536). -
6500 -
6501 For example: -
6502 -
6503 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp QGraphicsItem type -
6504 -
6505 \sa UserType -
6506*/ -
6507int QGraphicsItem::type() const -
6508{ -
6509 return (int)UserType;
never executed: return (int)UserType;
0
6510} -
6511 -
6512/*! -
6513 Installs an event filter for this item on \a filterItem, causing -
6514 all events for this item to first pass through \a filterItem's -
6515 sceneEventFilter() function. -
6516 -
6517 To filter another item's events, install this item as an event filter -
6518 for the other item. Example: -
6519 -
6520 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 12 -
6521 -
6522 An item can only filter events for other items in the same -
6523 scene. Also, an item cannot filter its own events; instead, you -
6524 can reimplement sceneEvent() directly. -
6525 -
6526 Items must belong to a scene for scene event filters to be installed and -
6527 used. -
6528 -
6529 \sa removeSceneEventFilter(), sceneEventFilter(), sceneEvent() -
6530*/ -
6531void QGraphicsItem::installSceneEventFilter(QGraphicsItem *filterItem) -
6532{ -
6533 if (!d_ptr->scene) {
never evaluated: !d_ptr->scene
0
6534 qWarning("QGraphicsItem::installSceneEventFilter: event filters can only be installed"
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 6534, __PRETTY_FUNCTION__).warning("QGraphicsItem::installSceneEventFilter: event filters can only be installed"
-
6535 " on items in a scene.");
never executed (the execution status of this line is deduced): " on items in a scene.");
-
6536 return;
never executed: return;
0
6537 } -
6538 if (d_ptr->scene != filterItem->scene()) {
never evaluated: d_ptr->scene != filterItem->scene()
0
6539 qWarning("QGraphicsItem::installSceneEventFilter: event filters can only be installed"
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 6539, __PRETTY_FUNCTION__).warning("QGraphicsItem::installSceneEventFilter: event filters can only be installed"
-
6540 " on items in the same scene.");
never executed (the execution status of this line is deduced): " on items in the same scene.");
-
6541 return;
never executed: return;
0
6542 } -
6543 d_ptr->scene->d_func()->installSceneEventFilter(this, filterItem);
never executed (the execution status of this line is deduced): d_ptr->scene->d_func()->installSceneEventFilter(this, filterItem);
-
6544}
never executed: }
0
6545 -
6546/*! -
6547 Removes an event filter on this item from \a filterItem. -
6548 -
6549 \sa installSceneEventFilter() -
6550*/ -
6551void QGraphicsItem::removeSceneEventFilter(QGraphicsItem *filterItem) -
6552{ -
6553 if (!d_ptr->scene || d_ptr->scene != filterItem->scene())
never evaluated: !d_ptr->scene
never evaluated: d_ptr->scene != filterItem->scene()
0
6554 return;
never executed: return;
0
6555 d_ptr->scene->d_func()->removeSceneEventFilter(this, filterItem);
never executed (the execution status of this line is deduced): d_ptr->scene->d_func()->removeSceneEventFilter(this, filterItem);
-
6556}
never executed: }
0
6557 -
6558/*! -
6559 Filters events for the item \a watched. \a event is the filtered -
6560 event. -
6561 -
6562 Reimplementing this function in a subclass makes it possible -
6563 for the item to be used as an event filter for other items, -
6564 intercepting all the events send to those items before they are -
6565 able to respond. -
6566 -
6567 Reimplementations must return true to prevent further processing of -
6568 a given event, ensuring that it will not be delivered to the watched -
6569 item, or return false to indicate that the event should be propagated -
6570 further by the event system. -
6571 -
6572 \sa installSceneEventFilter() -
6573*/ -
6574bool QGraphicsItem::sceneEventFilter(QGraphicsItem *watched, QEvent *event) -
6575{ -
6576 Q_UNUSED(watched);
never executed (the execution status of this line is deduced): (void)watched;;
-
6577 Q_UNUSED(event);
never executed (the execution status of this line is deduced): (void)event;;
-
6578 return false;
never executed: return false;
0
6579} -
6580 -
6581/*! -
6582 This virtual function receives events to this item. Reimplement -
6583 this function to intercept events before they are dispatched to -
6584 the specialized event handlers contextMenuEvent(), focusInEvent(), -
6585 focusOutEvent(), hoverEnterEvent(), hoverMoveEvent(), -
6586 hoverLeaveEvent(), keyPressEvent(), keyReleaseEvent(), -
6587 mousePressEvent(), mouseReleaseEvent(), mouseMoveEvent(), and -
6588 mouseDoubleClickEvent(). -
6589 -
6590 Returns true if the event was recognized and handled; otherwise, (e.g., if -
6591 the event type was not recognized,) false is returned. -
6592 -
6593 \a event is the intercepted event. -
6594*/ -
6595bool QGraphicsItem::sceneEvent(QEvent *event) -
6596{ -
6597 if (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents) {
partially evaluated: d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:965
0-965
6598 if (event->type() == QEvent::HoverEnter || event->type() == QEvent::HoverLeave
never evaluated: event->type() == QEvent::HoverEnter
never evaluated: event->type() == QEvent::HoverLeave
0
6599 || event->type() == QEvent::DragEnter || event->type() == QEvent::DragLeave) {
never evaluated: event->type() == QEvent::DragEnter
never evaluated: event->type() == QEvent::DragLeave
0
6600 // Hover enter and hover leave events for children are ignored; -
6601 // hover move events are forwarded. -
6602 return true;
never executed: return true;
0
6603 } -
6604 -
6605 QGraphicsItem *handler = this;
never executed (the execution status of this line is deduced): QGraphicsItem *handler = this;
-
6606 do { -
6607 handler = handler->d_ptr->parent;
never executed (the execution status of this line is deduced): handler = handler->d_ptr->parent;
-
6608 Q_ASSERT(handler);
never executed (the execution status of this line is deduced): qt_noop();
-
6609 } while (handler->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents);
never executed: }
never evaluated: handler->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents
0
6610 // Forward the event to the closest parent that handles child -
6611 // events, mapping existing item-local coordinates to its -
6612 // coordinate system. -
6613 d_ptr->remapItemPos(event, handler);
never executed (the execution status of this line is deduced): d_ptr->remapItemPos(event, handler);
-
6614 handler->sceneEvent(event);
never executed (the execution status of this line is deduced): handler->sceneEvent(event);
-
6615 return true;
never executed: return true;
0
6616 } -
6617 -
6618 if (event->type() == QEvent::FocusOut) {
evaluated: event->type() == QEvent::FocusOut
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:952
13-952
6619 focusOutEvent(static_cast<QFocusEvent *>(event));
executed (the execution status of this line is deduced): focusOutEvent(static_cast<QFocusEvent *>(event));
-
6620 return true;
executed: return true;
Execution Count:13
13
6621 } -
6622 -
6623 if (!d_ptr->visible) {
partially evaluated: !d_ptr->visible
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:952
0-952
6624 // Eaten -
6625 return true;
never executed: return true;
0
6626 } -
6627 -
6628 switch (event->type()) { -
6629 case QEvent::FocusIn: -
6630 focusInEvent(static_cast<QFocusEvent *>(event));
executed (the execution status of this line is deduced): focusInEvent(static_cast<QFocusEvent *>(event));
-
6631 break;
executed: break;
Execution Count:13
13
6632 case QEvent::GraphicsSceneContextMenu: -
6633 contextMenuEvent(static_cast<QGraphicsSceneContextMenuEvent *>(event));
executed (the execution status of this line is deduced): contextMenuEvent(static_cast<QGraphicsSceneContextMenuEvent *>(event));
-
6634 break;
executed: break;
Execution Count:100
100
6635 case QEvent::GraphicsSceneDragEnter: -
6636 dragEnterEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
never executed (the execution status of this line is deduced): dragEnterEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
-
6637 break;
never executed: break;
0
6638 case QEvent::GraphicsSceneDragMove: -
6639 dragMoveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
never executed (the execution status of this line is deduced): dragMoveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
-
6640 break;
never executed: break;
0
6641 case QEvent::GraphicsSceneDragLeave: -
6642 dragLeaveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
never executed (the execution status of this line is deduced): dragLeaveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
-
6643 break;
never executed: break;
0
6644 case QEvent::GraphicsSceneDrop: -
6645 dropEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
never executed (the execution status of this line is deduced): dropEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));
-
6646 break;
never executed: break;
0
6647 case QEvent::GraphicsSceneHoverEnter: -
6648 hoverEnterEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
never executed (the execution status of this line is deduced): hoverEnterEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
-
6649 break;
never executed: break;
0
6650 case QEvent::GraphicsSceneHoverMove: -
6651 hoverMoveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
never executed (the execution status of this line is deduced): hoverMoveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
-
6652 break;
never executed: break;
0
6653 case QEvent::GraphicsSceneHoverLeave: -
6654 hoverLeaveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
never executed (the execution status of this line is deduced): hoverLeaveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));
-
6655 break;
never executed: break;
0
6656 case QEvent::GraphicsSceneMouseMove: -
6657 mouseMoveEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
executed (the execution status of this line is deduced): mouseMoveEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
-
6658 break;
executed: break;
Execution Count:2
2
6659 case QEvent::GraphicsSceneMousePress: -
6660 mousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
executed (the execution status of this line is deduced): mousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
-
6661 break;
executed: break;
Execution Count:103
103
6662 case QEvent::GraphicsSceneMouseRelease: -
6663 mouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
executed (the execution status of this line is deduced): mouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
-
6664 break;
executed: break;
Execution Count:104
104
6665 case QEvent::GraphicsSceneMouseDoubleClick: -
6666 mouseDoubleClickEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
never executed (the execution status of this line is deduced): mouseDoubleClickEvent(static_cast<QGraphicsSceneMouseEvent *>(event));
-
6667 break;
never executed: break;
0
6668 case QEvent::GraphicsSceneWheel: -
6669 wheelEvent(static_cast<QGraphicsSceneWheelEvent *>(event));
executed (the execution status of this line is deduced): wheelEvent(static_cast<QGraphicsSceneWheelEvent *>(event));
-
6670 break;
executed: break;
Execution Count:2
2
6671 case QEvent::KeyPress: { -
6672 QKeyEvent *k = static_cast<QKeyEvent *>(event);
executed (the execution status of this line is deduced): QKeyEvent *k = static_cast<QKeyEvent *>(event);
-
6673 if (k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) {
partially evaluated: k->key() == Qt::Key_Tab
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: k->key() == Qt::Key_Backtab
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
6674 if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
never evaluated: !(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))
0
6675 bool res = false;
never executed (the execution status of this line is deduced): bool res = false;
-
6676 if (k->key() == Qt::Key_Backtab
never evaluated: k->key() == Qt::Key_Backtab
0
6677 || (k->key() == Qt::Key_Tab && (k->modifiers() & Qt::ShiftModifier))) {
never evaluated: k->key() == Qt::Key_Tab
never evaluated: (k->modifiers() & Qt::ShiftModifier)
0
6678 if (d_ptr->isWidget) {
never evaluated: d_ptr->isWidget
0
6679 res = static_cast<QGraphicsWidget *>(this)->focusNextPrevChild(false);
never executed (the execution status of this line is deduced): res = static_cast<QGraphicsWidget *>(this)->focusNextPrevChild(false);
-
6680 } else if (d_ptr->scene) {
never executed: }
never evaluated: d_ptr->scene
0
6681 res = d_ptr->scene->focusNextPrevChild(false);
never executed (the execution status of this line is deduced): res = d_ptr->scene->focusNextPrevChild(false);
-
6682 }
never executed: }
0
6683 } else if (k->key() == Qt::Key_Tab) {
never evaluated: k->key() == Qt::Key_Tab
0
6684 if (d_ptr->isWidget) {
never evaluated: d_ptr->isWidget
0
6685 res = static_cast<QGraphicsWidget *>(this)->focusNextPrevChild(true);
never executed (the execution status of this line is deduced): res = static_cast<QGraphicsWidget *>(this)->focusNextPrevChild(true);
-
6686 } else if (d_ptr->scene) {
never executed: }
never evaluated: d_ptr->scene
0
6687 res = d_ptr->scene->focusNextPrevChild(true);
never executed (the execution status of this line is deduced): res = d_ptr->scene->focusNextPrevChild(true);
-
6688 }
never executed: }
0
6689 } -
6690 if (!res)
never evaluated: !res
0
6691 event->ignore();
never executed: event->ignore();
0
6692 return true;
never executed: return true;
0
6693 } -
6694 }
never executed: }
0
6695 keyPressEvent(static_cast<QKeyEvent *>(event));
executed (the execution status of this line is deduced): keyPressEvent(static_cast<QKeyEvent *>(event));
-
6696 break;
executed: break;
Execution Count:1
1
6697 } -
6698 case QEvent::KeyRelease: -
6699 keyReleaseEvent(static_cast<QKeyEvent *>(event));
never executed (the execution status of this line is deduced): keyReleaseEvent(static_cast<QKeyEvent *>(event));
-
6700 break;
never executed: break;
0
6701 case QEvent::InputMethod: -
6702 inputMethodEvent(static_cast<QInputMethodEvent *>(event));
executed (the execution status of this line is deduced): inputMethodEvent(static_cast<QInputMethodEvent *>(event));
-
6703 break;
executed: break;
Execution Count:2
2
6704 case QEvent::WindowActivate: -
6705 case QEvent::WindowDeactivate: -
6706 // Propagate panel activation. -
6707 if (d_ptr->scene) {
partially evaluated: d_ptr->scene
TRUEFALSE
yes
Evaluation Count:415
no
Evaluation Count:0
0-415
6708 for (int i = 0; i < d_ptr->children.size(); ++i) {
evaluated: i < d_ptr->children.size()
TRUEFALSE
yes
Evaluation Count:112
yes
Evaluation Count:415
112-415
6709 QGraphicsItem *child = d_ptr->children.at(i);
executed (the execution status of this line is deduced): QGraphicsItem *child = d_ptr->children.at(i);
-
6710 if (child->isVisible() && !child->isPanel()) {
evaluated: child->isVisible()
TRUEFALSE
yes
Evaluation Count:111
yes
Evaluation Count:1
partially evaluated: !child->isPanel()
TRUEFALSE
yes
Evaluation Count:111
no
Evaluation Count:0
0-111
6711 if (!(child->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents))
partially evaluated: !(child->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents)
TRUEFALSE
yes
Evaluation Count:111
no
Evaluation Count:0
0-111
6712 d_ptr->scene->sendEvent(child, event);
executed: d_ptr->scene->sendEvent(child, event);
Execution Count:111
111
6713 }
executed: }
Execution Count:111
111
6714 }
executed: }
Execution Count:112
112
6715 }
executed: }
Execution Count:415
415
6716 break;
executed: break;
Execution Count:415
415
6717 default: -
6718 return false;
executed: return false;
Execution Count:210
210
6719 } -
6720 -
6721 return true;
executed: return true;
Execution Count:742
742
6722} -
6723 -
6724/*! -
6725 This event handler can be reimplemented in a subclass to process context -
6726 menu events. The \a event parameter contains details about the event to -
6727 be handled. -
6728 -
6729 If you ignore the event (i.e., by calling QEvent::ignore()), \a event -
6730 will propagate to any item beneath this item. If no items accept the -
6731 event, it will be ignored by the scene and propagate to the view. -
6732 -
6733 It's common to open a QMenu in response to receiving a context menu -
6734 event. Example: -
6735 -
6736 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 13 -
6737 -
6738 The default implementation ignores the event. -
6739 -
6740 \sa sceneEvent() -
6741*/ -
6742void QGraphicsItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -
6743{ -
6744 event->ignore();
executed (the execution status of this line is deduced): event->ignore();
-
6745}
executed: }
Execution Count:100
100
6746 -
6747/*! -
6748 This event handler, for event \a event, can be reimplemented to receive -
6749 drag enter events for this item. Drag enter events are generated as the -
6750 cursor enters the item's area. -
6751 -
6752 By accepting the event (i.e., by calling QEvent::accept()), the item will -
6753 accept drop events, in addition to receiving drag move and drag -
6754 leave. Otherwise, the event will be ignored and propagate to the item -
6755 beneath. If the event is accepted, the item will receive a drag move event -
6756 before control goes back to the event loop. -
6757 -
6758 A common implementation of dragEnterEvent accepts or ignores \a event -
6759 depending on the associated mime data in \a event. Example: -
6760 -
6761 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 14 -
6762 -
6763 Items do not receive drag and drop events by default; to enable this -
6764 feature, call \c setAcceptDrops(true). -
6765 -
6766 The default implementation does nothing. -
6767 -
6768 \sa dropEvent(), dragMoveEvent(), dragLeaveEvent() -
6769*/ -
6770void QGraphicsItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event) -
6771{ -
6772 Q_D(QGraphicsItem);
never executed (the execution status of this line is deduced): QGraphicsItemPrivate * const d = d_func();
-
6773 // binary compatibility workaround between 4.4 and 4.5 -
6774 if (d->isProxyWidget())
never evaluated: d->isProxyWidget()
0
6775 static_cast<QGraphicsProxyWidget*>(this)->dragEnterEvent(event);
never executed: static_cast<QGraphicsProxyWidget*>(this)->dragEnterEvent(event);
0
6776}
never executed: }
0
6777 -
6778/*! -
6779 This event handler, for event \a event, can be reimplemented to receive -
6780 drag leave events for this item. Drag leave events are generated as the -
6781 cursor leaves the item's area. Most often you will not need to reimplement -
6782 this function, but it can be useful for resetting state in your item -
6783 (e.g., highlighting). -
6784 -
6785 Calling QEvent::ignore() or QEvent::accept() on \a event has no effect. -
6786 -
6787 Items do not receive drag and drop events by default; to enable this -
6788 feature, call \c setAcceptDrops(true). -
6789 -
6790 The default implementation does nothing. -
6791 -
6792 \sa dragEnterEvent(), dropEvent(), dragMoveEvent() -
6793*/ -
6794void QGraphicsItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) -
6795{ -
6796 Q_D(QGraphicsItem);
never executed (the execution status of this line is deduced): QGraphicsItemPrivate * const d = d_func();
-
6797 // binary compatibility workaround between 4.4 and 4.5 -
6798 if (d->isProxyWidget())
never evaluated: d->isProxyWidget()
0
6799 static_cast<QGraphicsProxyWidget*>(this)->dragLeaveEvent(event);
never executed: static_cast<QGraphicsProxyWidget*>(this)->dragLeaveEvent(event);
0
6800}
never executed: }
0
6801 -
6802/*! -
6803 This event handler, for event \a event, can be reimplemented to receive -
6804 drag move events for this item. Drag move events are generated as the -
6805 cursor moves around inside the item's area. Most often you will not need -
6806 to reimplement this function; it is used to indicate that only parts of -
6807 the item can accept drops. -
6808 -
6809 Calling QEvent::ignore() or QEvent::accept() on \a event toggles whether -
6810 or not the item will accept drops at the position from the event. By -
6811 default, \a event is accepted, indicating that the item allows drops at -
6812 the specified position. -
6813 -
6814 Items do not receive drag and drop events by default; to enable this -
6815 feature, call \c setAcceptDrops(true). -
6816 -
6817 The default implementation does nothing. -
6818 -
6819 \sa dropEvent(), dragEnterEvent(), dragLeaveEvent() -
6820*/ -
6821void QGraphicsItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event) -
6822{ -
6823 Q_D(QGraphicsItem);
never executed (the execution status of this line is deduced): QGraphicsItemPrivate * const d = d_func();
-
6824 // binary compatibility workaround between 4.4 and 4.5 -
6825 if (d->isProxyWidget())
never evaluated: d->isProxyWidget()
0
6826 static_cast<QGraphicsProxyWidget*>(this)->dragMoveEvent(event);
never executed: static_cast<QGraphicsProxyWidget*>(this)->dragMoveEvent(event);
0
6827}
never executed: }
0
6828 -
6829/*! -
6830 This event handler, for event \a event, can be reimplemented to receive -
6831 drop events for this item. Items can only receive drop events if the last -
6832 drag move event was accepted. -
6833 -
6834 Calling QEvent::ignore() or QEvent::accept() on \a event has no effect. -
6835 -
6836 Items do not receive drag and drop events by default; to enable this -
6837 feature, call \c setAcceptDrops(true). -
6838 -
6839 The default implementation does nothing. -
6840 -
6841 \sa dragEnterEvent(), dragMoveEvent(), dragLeaveEvent() -
6842*/ -
6843void QGraphicsItem::dropEvent(QGraphicsSceneDragDropEvent *event) -
6844{ -
6845 Q_D(QGraphicsItem);
never executed (the execution status of this line is deduced): QGraphicsItemPrivate * const d = d_func();
-
6846 // binary compatibility workaround between 4.4 and 4.5 -
6847 if (d->isProxyWidget())
never evaluated: d->isProxyWidget()
0
6848 static_cast<QGraphicsProxyWidget*>(this)->dropEvent(event);
never executed: static_cast<QGraphicsProxyWidget*>(this)->dropEvent(event);
0
6849}
never executed: }
0
6850 -
6851/*! -
6852 This event handler, for event \a event, can be reimplemented to receive -
6853 focus in events for this item. The default implementation calls -
6854 ensureVisible(). -
6855 -
6856 \sa focusOutEvent(), sceneEvent(), setFocus() -
6857*/ -
6858void QGraphicsItem::focusInEvent(QFocusEvent *event) -
6859{ -
6860 Q_UNUSED(event);
executed (the execution status of this line is deduced): (void)event;;
-
6861 update();
executed (the execution status of this line is deduced): update();
-
6862}
executed: }
Execution Count:6
6
6863 -
6864/*! -
6865 This event handler, for event \a event, can be reimplemented to receive -
6866 focus out events for this item. The default implementation does nothing. -
6867 -
6868 \sa focusInEvent(), sceneEvent(), setFocus() -
6869*/ -
6870void QGraphicsItem::focusOutEvent(QFocusEvent *event) -
6871{ -
6872 Q_UNUSED(event);
executed (the execution status of this line is deduced): (void)event;;
-
6873 update();
executed (the execution status of this line is deduced): update();
-
6874}
executed: }
Execution Count:12
12
6875 -
6876/*! -
6877 This event handler, for event \a event, can be reimplemented to receive -
6878 hover enter events for this item. The default implementation calls -
6879 update(); otherwise it does nothing. -
6880 -
6881 Calling QEvent::ignore() or QEvent::accept() on \a event has no effect. -
6882 -
6883 \sa hoverMoveEvent(), hoverLeaveEvent(), sceneEvent(), setAcceptHoverEvents() -
6884*/ -
6885void QGraphicsItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) -
6886{ -
6887 Q_UNUSED(event);
never executed (the execution status of this line is deduced): (void)event;;
-
6888 update();
never executed (the execution status of this line is deduced): update();
-
6889}
never executed: }
0
6890 -
6891/*! -
6892 This event handler, for event \a event, can be reimplemented to receive -
6893 hover move events for this item. The default implementation does nothing. -
6894 -
6895 Calling QEvent::ignore() or QEvent::accept() on \a event has no effect. -
6896 -
6897 \sa hoverEnterEvent(), hoverLeaveEvent(), sceneEvent(), setAcceptHoverEvents() -
6898*/ -
6899void QGraphicsItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -
6900{ -
6901 Q_UNUSED(event);
never executed (the execution status of this line is deduced): (void)event;;
-
6902}
never executed: }
0
6903 -
6904/*! -
6905 This event handler, for event \a event, can be reimplemented to receive -
6906 hover leave events for this item. The default implementation calls -
6907 update(); otherwise it does nothing. -
6908 -
6909 Calling QEvent::ignore() or QEvent::accept() on \a event has no effect. -
6910 -
6911 \sa hoverEnterEvent(), hoverMoveEvent(), sceneEvent(), setAcceptHoverEvents() -
6912*/ -
6913void QGraphicsItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -
6914{ -
6915 Q_UNUSED(event);
never executed (the execution status of this line is deduced): (void)event;;
-
6916 update();
never executed (the execution status of this line is deduced): update();
-
6917}
never executed: }
0
6918 -
6919/*! -
6920 This event handler, for event \a event, can be reimplemented to -
6921 receive key press events for this item. The default implementation -
6922 ignores the event. If you reimplement this handler, the event will by -
6923 default be accepted. -
6924 -
6925 Note that key events are only received for items that set the -
6926 ItemIsFocusable flag, and that have keyboard input focus. -
6927 -
6928 \sa keyReleaseEvent(), setFocus(), QGraphicsScene::setFocusItem(), -
6929 sceneEvent() -
6930*/ -
6931void QGraphicsItem::keyPressEvent(QKeyEvent *event) -
6932{ -
6933 event->ignore();
executed (the execution status of this line is deduced): event->ignore();
-
6934}
executed: }
Execution Count:1
1
6935 -
6936/*! -
6937 This event handler, for event \a event, can be reimplemented to receive -
6938 key release events for this item. The default implementation -
6939 ignores the event. If you reimplement this handler, the event will by -
6940 default be accepted. -
6941 -
6942 Note that key events are only received for items that set the -
6943 ItemIsFocusable flag, and that have keyboard input focus. -
6944 -
6945 \sa keyPressEvent(), setFocus(), QGraphicsScene::setFocusItem(), -
6946 sceneEvent() -
6947*/ -
6948void QGraphicsItem::keyReleaseEvent(QKeyEvent *event) -
6949{ -
6950 event->ignore();
never executed (the execution status of this line is deduced): event->ignore();
-
6951}
never executed: }
0
6952 -
6953/*! -
6954 This event handler, for event \a event, can be reimplemented to -
6955 receive mouse press events for this item. Mouse press events are -
6956 only delivered to items that accept the mouse button that is -
6957 pressed. By default, an item accepts all mouse buttons, but you -
6958 can change this by calling setAcceptedMouseButtons(). -
6959 -
6960 The mouse press event decides which item should become the mouse -
6961 grabber (see QGraphicsScene::mouseGrabberItem()). If you do not -
6962 reimplement this function, the press event will propagate to any -
6963 topmost item beneath this item, and no other mouse events will be -
6964 delivered to this item. -
6965 -
6966 If you do reimplement this function, \a event will by default be -
6967 accepted (see QEvent::accept()), and this item is then the mouse -
6968 grabber. This allows the item to receive future move, release and -
6969 doubleclick events. If you call QEvent::ignore() on \a event, this -
6970 item will lose the mouse grab, and \a event will propagate to any -
6971 topmost item beneath. No further mouse events will be delivered to -
6972 this item unless a new mouse press event is received. -
6973 -
6974 The default implementation handles basic item interaction, such as -
6975 selection and moving. If you want to keep the base implementation -
6976 when reimplementing this function, call -
6977 QGraphicsItem::mousePressEvent() in your reimplementation. -
6978 -
6979 The event is \l{QEvent::ignore()}d for items that are neither -
6980 \l{QGraphicsItem::ItemIsMovable}{movable} nor -
6981 \l{QGraphicsItem::ItemIsSelectable}{selectable}. -
6982 -
6983 \sa mouseMoveEvent(), mouseReleaseEvent(), -
6984 mouseDoubleClickEvent(), sceneEvent() -
6985*/ -
6986void QGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event) -
6987{ -
6988 if (event->button() == Qt::LeftButton && (flags() & ItemIsSelectable)) {
partially evaluated: event->button() == Qt::LeftButton
TRUEFALSE
yes
Evaluation Count:103
no
Evaluation Count:0
partially evaluated: (flags() & ItemIsSelectable)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:103
0-103
6989 bool multiSelect = (event->modifiers() & Qt::ControlModifier) != 0;
never executed (the execution status of this line is deduced): bool multiSelect = (event->modifiers() & Qt::ControlModifier) != 0;
-
6990 if (!multiSelect) {
never evaluated: !multiSelect
0
6991 if (!d_ptr->selected) {
never evaluated: !d_ptr->selected
0
6992 if (QGraphicsScene *scene = d_ptr->scene) {
never evaluated: QGraphicsScene *scene = d_ptr->scene
0
6993 ++scene->d_func()->selectionChanging;
never executed (the execution status of this line is deduced): ++scene->d_func()->selectionChanging;
-
6994 scene->clearSelection();
never executed (the execution status of this line is deduced): scene->clearSelection();
-
6995 --scene->d_func()->selectionChanging;
never executed (the execution status of this line is deduced): --scene->d_func()->selectionChanging;
-
6996 }
never executed: }
0
6997 setSelected(true);
never executed (the execution status of this line is deduced): setSelected(true);
-
6998 }
never executed: }
0
6999 }
never executed: }
0
7000 } else if (!(flags() & ItemIsMovable)) {
never executed: }
partially evaluated: !(flags() & ItemIsMovable)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:103
0-103
7001 event->ignore();
never executed (the execution status of this line is deduced): event->ignore();
-
7002 }
never executed: }
0
7003 if (d_ptr->isWidget) {
partially evaluated: d_ptr->isWidget
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:103
0-103
7004 // Qt::Popup closes when you click outside. -
7005 QGraphicsWidget *w = static_cast<QGraphicsWidget *>(this);
never executed (the execution status of this line is deduced): QGraphicsWidget *w = static_cast<QGraphicsWidget *>(this);
-
7006 if ((w->windowFlags() & Qt::Popup) == Qt::Popup) {
never evaluated: (w->windowFlags() & Qt::Popup) == Qt::Popup
0
7007 event->accept();
never executed (the execution status of this line is deduced): event->accept();
-
7008 if (!w->rect().contains(event->pos()))
never evaluated: !w->rect().contains(event->pos())
0
7009 w->close();
never executed: w->close();
0
7010 }
never executed: }
0
7011 }
never executed: }
0
7012}
executed: }
Execution Count:103
103
7013 -
7014/*! -
7015 obsolete -
7016*/ -
7017bool _qt_movableAncestorIsSelected(const QGraphicsItem *item) -
7018{ -
7019 const QGraphicsItem *parent = item->parentItem();
never executed (the execution status of this line is deduced): const QGraphicsItem *parent = item->parentItem();
-
7020 return parent && (((parent->flags() & QGraphicsItem::ItemIsMovable) && parent->isSelected()) || _qt_movableAncestorIsSelected(parent));
never executed: return parent && (((parent->flags() & QGraphicsItem::ItemIsMovable) && parent->isSelected()) || _qt_movableAncestorIsSelected(parent));
0
7021} -
7022 -
7023bool QGraphicsItemPrivate::movableAncestorIsSelected(const QGraphicsItem *item) -
7024{ -
7025 const QGraphicsItem *parent = item->d_ptr->parent;
executed (the execution status of this line is deduced): const QGraphicsItem *parent = item->d_ptr->parent;
-
7026 return parent && (((parent->flags() & QGraphicsItem::ItemIsMovable) && parent->isSelected()) || _qt_movableAncestorIsSelected(parent));
executed: return parent && (((parent->flags() & QGraphicsItem::ItemIsMovable) && parent->isSelected()) || _qt_movableAncestorIsSelected(parent));
Execution Count:1
1
7027} -
7028 -
7029/*! -
7030 This event handler, for event \a event, can be reimplemented to -
7031 receive mouse move events for this item. If you do receive this -
7032 event, you can be certain that this item also received a mouse -
7033 press event, and that this item is the current mouse grabber. -
7034 -
7035 Calling QEvent::ignore() or QEvent::accept() on \a event has no -
7036 effect. -
7037 -
7038 The default implementation handles basic item interaction, such as -
7039 selection and moving. If you want to keep the base implementation -
7040 when reimplementing this function, call -
7041 QGraphicsItem::mouseMoveEvent() in your reimplementation. -
7042 -
7043 Please note that mousePressEvent() decides which graphics item it -
7044 is that receives mouse events. See the mousePressEvent() -
7045 description for details. -
7046 -
7047 \sa mousePressEvent(), mouseReleaseEvent(), -
7048 mouseDoubleClickEvent(), sceneEvent() -
7049*/ -
7050void QGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -
7051{ -
7052 if ((event->buttons() & Qt::LeftButton) && (flags() & ItemIsMovable)) {
partially evaluated: (event->buttons() & Qt::LeftButton)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: (flags() & ItemIsMovable)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
7053 // Determine the list of items that need to be moved. -
7054 QList<QGraphicsItem *> selectedItems;
executed (the execution status of this line is deduced): QList<QGraphicsItem *> selectedItems;
-
7055 QHash<QGraphicsItem *, QPointF> initialPositions;
executed (the execution status of this line is deduced): QHash<QGraphicsItem *, QPointF> initialPositions;
-
7056 if (d_ptr->scene) {
partially evaluated: d_ptr->scene
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
7057 selectedItems = d_ptr->scene->selectedItems();
executed (the execution status of this line is deduced): selectedItems = d_ptr->scene->selectedItems();
-
7058 initialPositions = d_ptr->scene->d_func()->movingItemsInitialPositions;
executed (the execution status of this line is deduced): initialPositions = d_ptr->scene->d_func()->movingItemsInitialPositions;
-
7059 if (initialPositions.isEmpty()) {
partially evaluated: initialPositions.isEmpty()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
7060 foreach (QGraphicsItem *item, selectedItems)
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(selectedItems)> _container_(selectedItems); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;}))
-
7061 initialPositions[item] = item->pos();
never executed: initialPositions[item] = item->pos();
0
7062 initialPositions[this] = pos();
executed (the execution status of this line is deduced): initialPositions[this] = pos();
-
7063 }
executed: }
Execution Count:1
1
7064 d_ptr->scene->d_func()->movingItemsInitialPositions = initialPositions;
executed (the execution status of this line is deduced): d_ptr->scene->d_func()->movingItemsInitialPositions = initialPositions;
-
7065 }
executed: }
Execution Count:1
1
7066 -
7067 // Find the active view. -
7068 QGraphicsView *view = 0;
executed (the execution status of this line is deduced): QGraphicsView *view = 0;
-
7069 if (event->widget())
partially evaluated: event->widget()
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
7070 view = qobject_cast<QGraphicsView *>(event->widget()->parentWidget());
executed: view = qobject_cast<QGraphicsView *>(event->widget()->parentWidget());
Execution Count:1
1
7071 -
7072 // Move all selected items -
7073 int i = 0;
executed (the execution status of this line is deduced): int i = 0;
-
7074 bool movedMe = false;
executed (the execution status of this line is deduced): bool movedMe = false;
-
7075 while (i <= selectedItems.size()) {
evaluated: i <= selectedItems.size()
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:1
1
7076 QGraphicsItem *item = 0;
executed (the execution status of this line is deduced): QGraphicsItem *item = 0;
-
7077 if (i < selectedItems.size())
partially evaluated: i < selectedItems.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
7078 item = selectedItems.at(i);
never executed: item = selectedItems.at(i);
0
7079 else -
7080 item = this;
executed: item = this;
Execution Count:1
1
7081 if (item == this) {
partially evaluated: item == this
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
7082 // Slightly clumsy-looking way to ensure that "this" is part -
7083 // of the list of items to move, this is to avoid allocations -
7084 // (appending this item to the list of selected items causes a -
7085 // detach). -
7086 if (movedMe)
partially evaluated: movedMe
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
7087 break;
never executed: break;
0
7088 movedMe = true;
executed (the execution status of this line is deduced): movedMe = true;
-
7089 }
executed: }
Execution Count:1
1
7090 -
7091 if ((item->flags() & ItemIsMovable) && !QGraphicsItemPrivate::movableAncestorIsSelected(item)) {
partially evaluated: (item->flags() & ItemIsMovable)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
partially evaluated: !QGraphicsItemPrivate::movableAncestorIsSelected(item)
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
7092 QPointF currentParentPos;
executed (the execution status of this line is deduced): QPointF currentParentPos;
-
7093 QPointF buttonDownParentPos;
executed (the execution status of this line is deduced): QPointF buttonDownParentPos;
-
7094 if (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorIgnoresTransformations) {
partially evaluated: item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorIgnoresTransformations
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
7095 // Items whose ancestors ignore transformations need to -
7096 // map screen coordinates to local coordinates, then map -
7097 // those to the parent. -
7098 QTransform viewToItemTransform = (item->deviceTransform(view->viewportTransform())).inverted();
never executed (the execution status of this line is deduced): QTransform viewToItemTransform = (item->deviceTransform(view->viewportTransform())).inverted();
-
7099 currentParentPos = mapToParent(viewToItemTransform.map(QPointF(view->mapFromGlobal(event->screenPos()))));
never executed (the execution status of this line is deduced): currentParentPos = mapToParent(viewToItemTransform.map(QPointF(view->mapFromGlobal(event->screenPos()))));
-
7100 buttonDownParentPos = mapToParent(viewToItemTransform.map(QPointF(view->mapFromGlobal(event->buttonDownScreenPos(Qt::LeftButton)))));
never executed (the execution status of this line is deduced): buttonDownParentPos = mapToParent(viewToItemTransform.map(QPointF(view->mapFromGlobal(event->buttonDownScreenPos(Qt::LeftButton)))));
-
7101 } else if (item->flags() & ItemIgnoresTransformations) {
never executed: }
partially evaluated: item->flags() & ItemIgnoresTransformations
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
7102 // Root items that ignore transformations need to -
7103 // calculate their diff by mapping viewport coordinates -
7104 // directly to parent coordinates. -
7105 // COMBINE -
7106 QTransform itemTransform;
never executed (the execution status of this line is deduced): QTransform itemTransform;
-
7107 if (item->d_ptr->transformData)
never evaluated: item->d_ptr->transformData
0
7108 itemTransform = item->d_ptr->transformData->computedFullTransform();
never executed: itemTransform = item->d_ptr->transformData->computedFullTransform();
0
7109 itemTransform.translate(item->d_ptr->pos.x(), item->d_ptr->pos.y());
never executed (the execution status of this line is deduced): itemTransform.translate(item->d_ptr->pos.x(), item->d_ptr->pos.y());
-
7110 QTransform viewToParentTransform = itemTransform
never executed (the execution status of this line is deduced): QTransform viewToParentTransform = itemTransform
-
7111 * (item->sceneTransform() * view->viewportTransform()).inverted();
never executed (the execution status of this line is deduced): * (item->sceneTransform() * view->viewportTransform()).inverted();
-
7112 currentParentPos = viewToParentTransform.map(QPointF(view->mapFromGlobal(event->screenPos())));
never executed (the execution status of this line is deduced): currentParentPos = viewToParentTransform.map(QPointF(view->mapFromGlobal(event->screenPos())));
-
7113 buttonDownParentPos = viewToParentTransform.map(QPointF(view->mapFromGlobal(event->buttonDownScreenPos(Qt::LeftButton))));
never executed (the execution status of this line is deduced): buttonDownParentPos = viewToParentTransform.map(QPointF(view->mapFromGlobal(event->buttonDownScreenPos(Qt::LeftButton))));
-
7114 } else {
never executed: }
0
7115 // All other items simply map from the scene. -
7116 currentParentPos = item->mapToParent(item->mapFromScene(event->scenePos()));
executed (the execution status of this line is deduced): currentParentPos = item->mapToParent(item->mapFromScene(event->scenePos()));
-
7117 buttonDownParentPos = item->mapToParent(item->mapFromScene(event->buttonDownScenePos(Qt::LeftButton)));
executed (the execution status of this line is deduced): buttonDownParentPos = item->mapToParent(item->mapFromScene(event->buttonDownScenePos(Qt::LeftButton)));
-
7118 }
executed: }
Execution Count:1
1
7119 -
7120 item->setPos(initialPositions.value(item) + currentParentPos - buttonDownParentPos);
executed (the execution status of this line is deduced): item->setPos(initialPositions.value(item) + currentParentPos - buttonDownParentPos);
-
7121 -
7122 if (item->flags() & ItemIsSelectable)
partially evaluated: item->flags() & ItemIsSelectable
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
7123 item->setSelected(true);
never executed: item->setSelected(true);
0
7124 }
executed: }
Execution Count:1
1
7125 ++i;
executed (the execution status of this line is deduced): ++i;
-
7126 }
executed: }
Execution Count:1
1
7127 -
7128 } else {
executed: }
Execution Count:1
1
7129 event->ignore();
never executed (the execution status of this line is deduced): event->ignore();
-
7130 }
never executed: }
0
7131} -
7132 -
7133/*! -
7134 This event handler, for event \a event, can be reimplemented to -
7135 receive mouse release events for this item. -
7136 -
7137 Calling QEvent::ignore() or QEvent::accept() on \a event has no -
7138 effect. -
7139 -
7140 The default implementation handles basic item interaction, such as -
7141 selection and moving. If you want to keep the base implementation -
7142 when reimplementing this function, call -
7143 QGraphicsItem::mouseReleaseEvent() in your reimplementation. -
7144 -
7145 Please note that mousePressEvent() decides which graphics item it -
7146 is that receives mouse events. See the mousePressEvent() -
7147 description for details. -
7148 -
7149 \sa mousePressEvent(), mouseMoveEvent(), mouseDoubleClickEvent(), -
7150 sceneEvent() -
7151*/ -
7152void QGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -
7153{ -
7154 if (flags() & ItemIsSelectable) {
partially evaluated: flags() & ItemIsSelectable
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:104
0-104
7155 bool multiSelect = (event->modifiers() & Qt::ControlModifier) != 0;
never executed (the execution status of this line is deduced): bool multiSelect = (event->modifiers() & Qt::ControlModifier) != 0;
-
7156 if (event->scenePos() == event->buttonDownScenePos(Qt::LeftButton)) {
never evaluated: event->scenePos() == event->buttonDownScenePos(Qt::LeftButton)
0
7157 // The item didn't move -
7158 if (multiSelect) {
never evaluated: multiSelect
0
7159 setSelected(!isSelected());
never executed (the execution status of this line is deduced): setSelected(!isSelected());
-
7160 } else {
never executed: }
0
7161 bool selectionChanged = false;
never executed (the execution status of this line is deduced): bool selectionChanged = false;
-
7162 if (QGraphicsScene *scene = d_ptr->scene) {
never evaluated: QGraphicsScene *scene = d_ptr->scene
0
7163 ++scene->d_func()->selectionChanging;
never executed (the execution status of this line is deduced): ++scene->d_func()->selectionChanging;
-
7164 // Clear everything but this item. Bypass -
7165 // QGraphicsScene::clearSelection()'s default behavior by -
7166 // temporarily removing this item from the selection list. -
7167 if (d_ptr->selected) {
never evaluated: d_ptr->selected
0
7168 scene->d_func()->selectedItems.remove(this);
never executed (the execution status of this line is deduced): scene->d_func()->selectedItems.remove(this);
-
7169 foreach (QGraphicsItem *item, scene->d_func()->selectedItems) {
never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(scene->d_func()->selectedItems)> _container_(scene->d_func()->selectedItems); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) {
-
7170 if (item->isSelected()) {
never evaluated: item->isSelected()
0
7171 selectionChanged = true;
never executed (the execution status of this line is deduced): selectionChanged = true;
-
7172 break;
never executed: break;
0
7173 } -
7174 }
never executed: }
0
7175 }
never executed: }
0
7176 scene->clearSelection();
never executed (the execution status of this line is deduced): scene->clearSelection();
-
7177 if (d_ptr->selected)
never evaluated: d_ptr->selected
0
7178 scene->d_func()->selectedItems.insert(this);
never executed: scene->d_func()->selectedItems.insert(this);
0
7179 --scene->d_func()->selectionChanging;
never executed (the execution status of this line is deduced): --scene->d_func()->selectionChanging;
-
7180 if (selectionChanged)
never evaluated: selectionChanged
0
7181 emit d_ptr->scene->selectionChanged();
never executed: d_ptr->scene->selectionChanged();
0
7182 }
never executed: }
0
7183 setSelected(true);
never executed (the execution status of this line is deduced): setSelected(true);
-
7184 }
never executed: }
0
7185 } -
7186 }
never executed: }
0
7187 if (d_ptr->scene && !event->buttons())
partially evaluated: d_ptr->scene
TRUEFALSE
yes
Evaluation Count:104
no
Evaluation Count:0
partially evaluated: !event->buttons()
TRUEFALSE
yes
Evaluation Count:104
no
Evaluation Count:0
0-104
7188 d_ptr->scene->d_func()->movingItemsInitialPositions.clear();
executed: d_ptr->scene->d_func()->movingItemsInitialPositions.clear();
Execution Count:104
104
7189}
executed: }
Execution Count:104
104
7190 -
7191/*! -
7192 This event handler, for event \a event, can be reimplemented to -
7193 receive mouse doubleclick events for this item. -
7194 -
7195 When doubleclicking an item, the item will first receive a mouse -
7196 press event, followed by a release event (i.e., a click), then a -
7197 doubleclick event, and finally a release event. -
7198 -
7199 Calling QEvent::ignore() or QEvent::accept() on \a event has no -
7200 effect. -
7201 -
7202 The default implementation calls mousePressEvent(). If you want to -
7203 keep the base implementation when reimplementing this function, -
7204 call QGraphicsItem::mouseDoubleClickEvent() in your -
7205 reimplementation. -
7206 -
7207 Note that an item will not receive double click events if it is -
7208 neither \l {QGraphicsItem::ItemIsSelectable}{selectable} nor -
7209 \l{QGraphicsItem::ItemIsMovable}{movable} (single mouse clicks are -
7210 ignored in this case, and that stops the generation of double -
7211 clicks). -
7212 -
7213 \sa mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(), sceneEvent() -
7214*/ -
7215void QGraphicsItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) -
7216{ -
7217 mousePressEvent(event);
never executed (the execution status of this line is deduced): mousePressEvent(event);
-
7218}
never executed: }
0
7219 -
7220/*! -
7221 This event handler, for event \a event, can be reimplemented to receive -
7222 wheel events for this item. If you reimplement this function, \a event -
7223 will be accepted by default. -
7224 -
7225 If you ignore the event, (i.e., by calling QEvent::ignore(),) it will -
7226 propagate to any item beneath this item. If no items accept the event, it -
7227 will be ignored by the scene, and propagate to the view (e.g., the view's -
7228 vertical scroll bar). -
7229 -
7230 The default implementation ignores the event. -
7231 -
7232 \sa sceneEvent() -
7233*/ -
7234void QGraphicsItem::wheelEvent(QGraphicsSceneWheelEvent *event) -
7235{ -
7236 event->ignore();
executed (the execution status of this line is deduced): event->ignore();
-
7237}
executed: }
Execution Count:2
2
7238 -
7239/*! -
7240 This event handler, for event \a event, can be reimplemented to receive -
7241 input method events for this item. The default implementation ignores the -
7242 event. -
7243 -
7244 \sa inputMethodQuery(), sceneEvent() -
7245*/ -
7246void QGraphicsItem::inputMethodEvent(QInputMethodEvent *event) -
7247{ -
7248 event->ignore();
executed (the execution status of this line is deduced): event->ignore();
-
7249}
executed: }
Execution Count:2
2
7250 -
7251/*! -
7252 This method is only relevant for input items. It is used by the -
7253 input method to query a set of properties of the item to be able -
7254 to support complex input method operations, such as support for -
7255 surrounding text and reconversions. \a query specifies which -
7256 property is queried. -
7257 -
7258 \sa inputMethodEvent(), QInputMethodEvent -
7259*/ -
7260QVariant QGraphicsItem::inputMethodQuery(Qt::InputMethodQuery query) const -
7261{ -
7262 Q_UNUSED(query);
executed (the execution status of this line is deduced): (void)query;;
-
7263 return QVariant();
executed: return QVariant();
Execution Count:7
7
7264} -
7265 -
7266/*! -
7267 Returns the current input method hints of this item. -
7268 -
7269 Input method hints are only relevant for input items. -
7270 The hints are used by the input method to indicate how it should operate. -
7271 For example, if the Qt::ImhNumbersOnly flag is set, the input method may change -
7272 its visual components to reflect that only numbers can be entered. -
7273 -
7274 The effect may vary between input method implementations. -
7275 -
7276 \since 4.6 -
7277 -
7278 \sa setInputMethodHints(), inputMethodQuery() -
7279*/ -
7280Qt::InputMethodHints QGraphicsItem::inputMethodHints() const -
7281{ -
7282 Q_D(const QGraphicsItem);
executed (the execution status of this line is deduced): const QGraphicsItemPrivate * const d = d_func();
-
7283 return d->imHints;
executed: return d->imHints;
Execution Count:11
11
7284} -
7285 -
7286/*! -
7287 Sets the current input method hints of this item to \a hints. -
7288 -
7289 \since 4.6 -
7290 -
7291 \sa inputMethodHints(), inputMethodQuery() -
7292*/ -
7293void QGraphicsItem::setInputMethodHints(Qt::InputMethodHints hints) -
7294{ -
7295 Q_D(QGraphicsItem);
never executed (the execution status of this line is deduced): QGraphicsItemPrivate * const d = d_func();
-
7296 d->imHints = hints;
never executed (the execution status of this line is deduced): d->imHints = hints;
-
7297 if (!hasFocus())
never evaluated: !hasFocus()
0
7298 return;
never executed: return;
0
7299 d->scene->d_func()->updateInputMethodSensitivityInViews();
never executed (the execution status of this line is deduced): d->scene->d_func()->updateInputMethodSensitivityInViews();
-
7300 QWidget *fw = QApplication::focusWidget();
never executed (the execution status of this line is deduced): QWidget *fw = QApplication::focusWidget();
-
7301 if (!fw)
never evaluated: !fw
0
7302 return;
never executed: return;
0
7303 qApp->inputMethod()->update(Qt::ImHints);
never executed (the execution status of this line is deduced): (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->update(Qt::ImHints);
-
7304}
never executed: }
0
7305 -
7306/*! -
7307 Updates the item's micro focus. -
7308 -
7309 \since 4.7 -
7310 -
7311 \sa QInputMethod -
7312*/ -
7313void QGraphicsItem::updateMicroFocus() -
7314{ -
7315#if !defined(QT_NO_IM) && defined(Q_WS_X11) -
7316 if (QWidget *fw = QApplication::focusWidget()) { -
7317 if (scene()) { -
7318 for (int i = 0 ; i < scene()->views().count() ; ++i) { -
7319 if (scene()->views().at(i) == fw) { -
7320 if (qApp) -
7321 qApp->inputMethod()->update(Qt::ImQueryAll); -
7322 break; -
7323 } -
7324 } -
7325 } -
7326 } -
7327 } -
7328#endif -
7329} -
7330 -
7331/*! -
7332 This virtual function is called by QGraphicsItem to notify custom items -
7333 that some part of the item's state changes. By reimplementing this -
7334 function, you can react to a change, and in some cases (depending on \a -
7335 change), adjustments can be made. -
7336 -
7337 \a change is the parameter of the item that is changing. \a value is the -
7338 new value; the type of the value depends on \a change. -
7339 -
7340 Example: -
7341 -
7342 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 15 -
7343 -
7344 The default implementation does nothing, and returns \a value. -
7345 -
7346 Note: Certain QGraphicsItem functions cannot be called in a -
7347 reimplementation of this function; see the GraphicsItemChange -
7348 documentation for details. -
7349 -
7350 \sa GraphicsItemChange -
7351*/ -
7352QVariant QGraphicsItem::itemChange(GraphicsItemChange change, const QVariant &value) -
7353{ -
7354 Q_UNUSED(change);
executed (the execution status of this line is deduced): (void)change;;
-
7355 return value;
executed: return value;
Execution Count:11572
11572
7356} -
7357 -
7358/*! -
7359 \internal -
7360 -
7361 Note: This is provided as a hook to avoid future problems related -
7362 to adding virtual functions. -
7363*/ -
7364bool QGraphicsItem::supportsExtension(Extension extension) const -
7365{ -
7366 Q_UNUSED(extension);
never executed (the execution status of this line is deduced): (void)extension;;
-
7367 return false;
never executed: return false;
0
7368} -
7369 -
7370/*! -
7371 \internal -
7372 -
7373 Note: This is provided as a hook to avoid future problems related -
7374 to adding virtual functions. -
7375*/ -
7376void QGraphicsItem::setExtension(Extension extension, const QVariant &variant) -
7377{ -
7378 Q_UNUSED(extension);
never executed (the execution status of this line is deduced): (void)extension;;
-
7379 Q_UNUSED(variant);
never executed (the execution status of this line is deduced): (void)variant;;
-
7380}
never executed: }
0
7381 -
7382/*! -
7383 \internal -
7384 -
7385 Note: This is provided as a hook to avoid future problems related -
7386 to adding virtual functions. -
7387*/ -
7388QVariant QGraphicsItem::extension(const QVariant &variant) const -
7389{ -
7390 Q_UNUSED(variant);
never executed (the execution status of this line is deduced): (void)variant;;
-
7391 return QVariant();
never executed: return QVariant();
0
7392} -
7393 -
7394/*! -
7395 \internal -
7396 -
7397 Adds this item to the scene's index. Called in conjunction with -
7398 removeFromIndex() to ensure the index bookkeeping is correct when -
7399 the item's position, transformation or shape changes. -
7400*/ -
7401void QGraphicsItem::addToIndex() -
7402{ -
7403 if (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) {
never evaluated: d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren
0
7404 // ### add to child index only if applicable -
7405 return;
never executed: return;
0
7406 } -
7407 if (d_ptr->scene)
never evaluated: d_ptr->scene
0
7408 d_ptr->scene->d_func()->index->addItem(this);
never executed: d_ptr->scene->d_func()->index->addItem(this);
0
7409}
never executed: }
0
7410 -
7411/*! -
7412 \internal -
7413 -
7414 Removes this item from the scene's index. Called in conjunction -
7415 with addToIndex() to ensure the index bookkeeping is correct when -
7416 the item's position, transformation or shape changes. -
7417*/ -
7418void QGraphicsItem::removeFromIndex() -
7419{ -
7420 if (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) {
never evaluated: d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren
0
7421 // ### remove from child index only if applicable -
7422 return;
never executed: return;
0
7423 } -
7424 if (d_ptr->scene)
never evaluated: d_ptr->scene
0
7425 d_ptr->scene->d_func()->index->removeItem(this);
never executed: d_ptr->scene->d_func()->index->removeItem(this);
0
7426}
never executed: }
0
7427 -
7428/*! -
7429 Prepares the item for a geometry change. Call this function before -
7430 changing the bounding rect of an item to keep QGraphicsScene's index up to -
7431 date. -
7432 -
7433 prepareGeometryChange() will call update() if this is necessary. -
7434 -
7435 Example: -
7436 -
7437 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 16 -
7438 -
7439 \sa boundingRect() -
7440*/ -
7441void QGraphicsItem::prepareGeometryChange() -
7442{ -
7443 if (d_ptr->inDestructor)
evaluated: d_ptr->inDestructor
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:4038
11-4038
7444 return;
executed: return;
Execution Count:11
11
7445 if (d_ptr->scene) {
evaluated: d_ptr->scene
TRUEFALSE
yes
Evaluation Count:1758
yes
Evaluation Count:2280
1758-2280
7446 d_ptr->scene->d_func()->dirtyGrowingItemsBoundingRect = true;
executed (the execution status of this line is deduced): d_ptr->scene->d_func()->dirtyGrowingItemsBoundingRect = true;
-
7447 d_ptr->geometryChanged = 1;
executed (the execution status of this line is deduced): d_ptr->geometryChanged = 1;
-
7448 d_ptr->paintedViewBoundingRectsNeedRepaint = 1;
executed (the execution status of this line is deduced): d_ptr->paintedViewBoundingRectsNeedRepaint = 1;
-
7449 d_ptr->notifyBoundingRectChanged = !d_ptr->inSetPosHelper;
executed (the execution status of this line is deduced): d_ptr->notifyBoundingRectChanged = !d_ptr->inSetPosHelper;
-
7450 -
7451 QGraphicsScenePrivate *scenePrivate = d_ptr->scene->d_func();
executed (the execution status of this line is deduced): QGraphicsScenePrivate *scenePrivate = d_ptr->scene->d_func();
-
7452 scenePrivate->index->prepareBoundingRectChange(this);
executed (the execution status of this line is deduced): scenePrivate->index->prepareBoundingRectChange(this);
-
7453 scenePrivate->markDirty(this, QRectF(), /*invalidateChildren=*/true, /*force=*/false,
executed (the execution status of this line is deduced): scenePrivate->markDirty(this, QRectF(), true, false,
-
7454 /*ignoreOpacity=*/ false, /*removingItemFromScene=*/ false,
executed (the execution status of this line is deduced): false, false,
-
7455 /*updateBoundingRect=*/true);
executed (the execution status of this line is deduced): true);
-
7456 -
7457 // For compatibility reasons, we have to update the item's old geometry -
7458 // if someone is connected to the changed signal or the scene has no views. -
7459 // Note that this has to be done *after* markDirty to ensure that -
7460 // _q_processDirtyItems is called before _q_emitUpdated. -
7461 if (scenePrivate->isSignalConnected(scenePrivate->changedSignalIndex)
evaluated: scenePrivate->isSignalConnected(scenePrivate->changedSignalIndex)
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1756
2-1756
7462 || scenePrivate->views.isEmpty()) {
evaluated: scenePrivate->views.isEmpty()
TRUEFALSE
yes
Evaluation Count:182
yes
Evaluation Count:1574
182-1574
7463 if (d_ptr->hasTranslateOnlySceneTransform()) {
evaluated: d_ptr->hasTranslateOnlySceneTransform()
TRUEFALSE
yes
Evaluation Count:180
yes
Evaluation Count:4
4-180
7464 d_ptr->scene->update(boundingRect().translated(d_ptr->sceneTransform.dx(),
executed (the execution status of this line is deduced): d_ptr->scene->update(boundingRect().translated(d_ptr->sceneTransform.dx(),
-
7465 d_ptr->sceneTransform.dy()));
executed (the execution status of this line is deduced): d_ptr->sceneTransform.dy()));
-
7466 } else {
executed: }
Execution Count:180
180
7467 d_ptr->scene->update(d_ptr->sceneTransform.mapRect(boundingRect()));
executed (the execution status of this line is deduced): d_ptr->scene->update(d_ptr->sceneTransform.mapRect(boundingRect()));
-
7468 }
executed: }
Execution Count:4
4
7469 } -
7470 }
executed: }
Execution Count:1758
1758
7471 -
7472 d_ptr->markParentDirty(/*updateBoundingRect=*/true);
executed (the execution status of this line is deduced): d_ptr->markParentDirty( true);
-
7473}
executed: }
Execution Count:4038
4038
7474 -
7475/*! -
7476 \internal -
7477 -
7478 Highlights \a item as selected. -
7479 -
7480 NOTE: This function is a duplicate of qt_graphicsItem_highlightSelected() in -
7481 qgraphicssvgitem.cpp! -
7482*/ -
7483static void qt_graphicsItem_highlightSelected( -
7484 QGraphicsItem *item, QPainter *painter, const QStyleOptionGraphicsItem *option) -
7485{ -
7486 const QRectF murect = painter->transform().mapRect(QRectF(0, 0, 1, 1));
executed (the execution status of this line is deduced): const QRectF murect = painter->transform().mapRect(QRectF(0, 0, 1, 1));
-
7487 if (qFuzzyIsNull(qMax(murect.width(), murect.height())))
partially evaluated: qFuzzyIsNull(qMax(murect.width(), murect.height()))
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
7488 return;
never executed: return;
0
7489 -
7490 const QRectF mbrect = painter->transform().mapRect(item->boundingRect());
executed (the execution status of this line is deduced): const QRectF mbrect = painter->transform().mapRect(item->boundingRect());
-
7491 if (qMin(mbrect.width(), mbrect.height()) < qreal(1.0))
partially evaluated: qMin(mbrect.width(), mbrect.height()) < qreal(1.0)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
7492 return;
never executed: return;
0
7493 -
7494 qreal itemPenWidth;
executed (the execution status of this line is deduced): qreal itemPenWidth;
-
7495 switch (item->type()) { -
7496 case QGraphicsEllipseItem::Type: -
7497 itemPenWidth = static_cast<QGraphicsEllipseItem *>(item)->pen().widthF();
never executed (the execution status of this line is deduced): itemPenWidth = static_cast<QGraphicsEllipseItem *>(item)->pen().widthF();
-
7498 break;
never executed: break;
0
7499 case QGraphicsPathItem::Type: -
7500 itemPenWidth = static_cast<QGraphicsPathItem *>(item)->pen().widthF();
never executed (the execution status of this line is deduced): itemPenWidth = static_cast<QGraphicsPathItem *>(item)->pen().widthF();
-
7501 break;
never executed: break;
0
7502 case QGraphicsPolygonItem::Type: -
7503 itemPenWidth = static_cast<QGraphicsPolygonItem *>(item)->pen().widthF();
never executed (the execution status of this line is deduced): itemPenWidth = static_cast<QGraphicsPolygonItem *>(item)->pen().widthF();
-
7504 break;
never executed: break;
0
7505 case QGraphicsRectItem::Type: -
7506 itemPenWidth = static_cast<QGraphicsRectItem *>(item)->pen().widthF();
executed (the execution status of this line is deduced): itemPenWidth = static_cast<QGraphicsRectItem *>(item)->pen().widthF();
-
7507 break;
executed: break;
Execution Count:1
1
7508 case QGraphicsSimpleTextItem::Type: -
7509 itemPenWidth = static_cast<QGraphicsSimpleTextItem *>(item)->pen().widthF();
never executed (the execution status of this line is deduced): itemPenWidth = static_cast<QGraphicsSimpleTextItem *>(item)->pen().widthF();
-
7510 break;
never executed: break;
0
7511 case QGraphicsLineItem::Type: -
7512 itemPenWidth = static_cast<QGraphicsLineItem *>(item)->pen().widthF();
never executed (the execution status of this line is deduced): itemPenWidth = static_cast<QGraphicsLineItem *>(item)->pen().widthF();
-
7513 break;
never executed: break;
0
7514 default: -
7515 itemPenWidth = 1.0;
never executed (the execution status of this line is deduced): itemPenWidth = 1.0;
-
7516 }
never executed: }
0
7517 const qreal pad = itemPenWidth / 2;
executed (the execution status of this line is deduced): const qreal pad = itemPenWidth / 2;
-
7518 -
7519 const qreal penWidth = 0; // cosmetic pen
executed (the execution status of this line is deduced): const qreal penWidth = 0;
-
7520 -
7521 const QColor fgcolor = option->palette.windowText().color();
executed (the execution status of this line is deduced): const QColor fgcolor = option->palette.windowText().color();
-
7522 const QColor bgcolor( // ensure good contrast against fgcolor
executed (the execution status of this line is deduced): const QColor bgcolor(
-
7523 fgcolor.red() > 127 ? 0 : 255,
executed (the execution status of this line is deduced): fgcolor.red() > 127 ? 0 : 255,
-
7524 fgcolor.green() > 127 ? 0 : 255,
executed (the execution status of this line is deduced): fgcolor.green() > 127 ? 0 : 255,
-
7525 fgcolor.blue() > 127 ? 0 : 255);
executed (the execution status of this line is deduced): fgcolor.blue() > 127 ? 0 : 255);
-
7526 -
7527 painter->setPen(QPen(bgcolor, penWidth, Qt::SolidLine));
executed (the execution status of this line is deduced): painter->setPen(QPen(bgcolor, penWidth, Qt::SolidLine));
-
7528 painter->setBrush(Qt::NoBrush);
executed (the execution status of this line is deduced): painter->setBrush(Qt::NoBrush);
-
7529 painter->drawRect(item->boundingRect().adjusted(pad, pad, -pad, -pad));
executed (the execution status of this line is deduced): painter->drawRect(item->boundingRect().adjusted(pad, pad, -pad, -pad));
-
7530 -
7531 painter->setPen(QPen(option->palette.windowText(), 0, Qt::DashLine));
executed (the execution status of this line is deduced): painter->setPen(QPen(option->palette.windowText(), 0, Qt::DashLine));
-
7532 painter->setBrush(Qt::NoBrush);
executed (the execution status of this line is deduced): painter->setBrush(Qt::NoBrush);
-
7533 painter->drawRect(item->boundingRect().adjusted(pad, pad, -pad, -pad));
executed (the execution status of this line is deduced): painter->drawRect(item->boundingRect().adjusted(pad, pad, -pad, -pad));
-
7534}
executed: }
Execution Count:1
1
7535 -
7536/*! -
7537 \class QGraphicsObject -
7538 \brief The QGraphicsObject class provides a base class for all graphics items that -
7539 require signals, slots and properties. -
7540 \since 4.6 -
7541 \ingroup graphicsview-api -
7542 \inmodule QtWidgets -
7543 -
7544 The class extends a QGraphicsItem with QObject's signal/slot and property mechanisms. -
7545 It maps many of QGraphicsItem's basic setters and getters to properties and adds notification -
7546 signals for many of them. -
7547 -
7548 \section1 Parents and Children -
7549 -
7550 Each graphics object can be constructed with a parent item. This ensures that the -
7551 item will be destroyed when its parent item is destroyed. Although QGraphicsObject -
7552 inherits from both QObject and QGraphicsItem, you should use the functions provided -
7553 by QGraphicsItem, \e not QObject, to manage the relationships between parent and -
7554 child items. -
7555 -
7556 The relationships between items can be explored using the parentItem() and childItems() -
7557 functions. In the hierarchy of items in a scene, the parentObject() and parentWidget() -
7558 functions are the equivalent of the QWidget::parent() and QWidget::parentWidget() -
7559 functions for QWidget subclasses. -
7560 -
7561 \sa QGraphicsWidget -
7562*/ -
7563 -
7564/*! -
7565 Constructs a QGraphicsObject with \a parent. -
7566*/ -
7567QGraphicsObject::QGraphicsObject(QGraphicsItem *parent) -
7568 : QGraphicsItem(parent) -
7569{ -
7570 QGraphicsItem::d_ptr->isObject = true;
executed (the execution status of this line is deduced): QGraphicsItem::d_ptr->isObject = true;
-
7571}
executed: }
Execution Count:62
62
7572 -
7573/*! -
7574 \internal -
7575*/ -
7576QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent) -
7577 : QGraphicsItem(dd, parent) -
7578{ -
7579 QGraphicsItem::d_ptr->isObject = true;
executed (the execution status of this line is deduced): QGraphicsItem::d_ptr->isObject = true;
-
7580}
executed: }
Execution Count:1548
1548
7581 -
7582/*! -
7583 Destructor. -
7584*/ -
7585QGraphicsObject::~QGraphicsObject() -
7586{ -
7587} -
7588 -
7589/*! -
7590 \reimp -
7591*/ -
7592bool QGraphicsObject::event(QEvent *ev) -
7593{ -
7594 if (ev->type() == QEvent::StyleAnimationUpdate) {
partially evaluated: ev->type() == QEvent::StyleAnimationUpdate
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:259
0-259
7595 update();
never executed (the execution status of this line is deduced): update();
-
7596 return true;
never executed: return true;
0
7597 } -
7598 return QObject::event(ev);
executed: return QObject::event(ev);
Execution Count:259
259
7599} -
7600 -
7601#ifndef QT_NO_GESTURES -
7602/*! -
7603 Subscribes the graphics object to the given \a gesture with specific \a flags. -
7604 -
7605 \sa ungrabGesture(), QGestureEvent -
7606*/ -
7607void QGraphicsObject::grabGesture(Qt::GestureType gesture, Qt::GestureFlags flags) -
7608{ -
7609 bool contains = QGraphicsItem::d_ptr->gestureContext.contains(gesture);
executed (the execution status of this line is deduced): bool contains = QGraphicsItem::d_ptr->gestureContext.contains(gesture);
-
7610 QGraphicsItem::d_ptr->gestureContext.insert(gesture, flags);
executed (the execution status of this line is deduced): QGraphicsItem::d_ptr->gestureContext.insert(gesture, flags);
-
7611 if (!contains && QGraphicsItem::d_ptr->scene)
evaluated: !contains
TRUEFALSE
yes
Evaluation Count:52
yes
Evaluation Count:4
evaluated: QGraphicsItem::d_ptr->scene
TRUEFALSE
yes
Evaluation Count:21
yes
Evaluation Count:31
4-52
7612 QGraphicsItem::d_ptr->scene->d_func()->grabGesture(this, gesture);
executed: QGraphicsItem::d_ptr->scene->d_func()->grabGesture(this, gesture);
Execution Count:21
21
7613}
executed: }
Execution Count:56
56
7614 -
7615/*! -
7616 Unsubscribes the graphics object from the given \a gesture. -
7617 -
7618 \sa grabGesture(), QGestureEvent -
7619*/ -
7620void QGraphicsObject::ungrabGesture(Qt::GestureType gesture) -
7621{ -
7622 if (QGraphicsItem::d_ptr->gestureContext.remove(gesture) && QGraphicsItem::d_ptr->scene)
never evaluated: QGraphicsItem::d_ptr->gestureContext.remove(gesture)
never evaluated: QGraphicsItem::d_ptr->scene
0
7623 QGraphicsItem::d_ptr->scene->d_func()->ungrabGesture(this, gesture);
never executed: QGraphicsItem::d_ptr->scene->d_func()->ungrabGesture(this, gesture);
0
7624}
never executed: }
0
7625#endif // QT_NO_GESTURES -
7626 -
7627/*! -
7628 Updates the item's micro focus. This is slot for convenience. -
7629 -
7630 \since 4.7 -
7631 -
7632 \sa QInputMethod -
7633*/ -
7634void QGraphicsObject::updateMicroFocus() -
7635{ -
7636 QGraphicsItem::updateMicroFocus();
never executed (the execution status of this line is deduced): QGraphicsItem::updateMicroFocus();
-
7637}
never executed: }
0
7638 -
7639void QGraphicsItemPrivate::children_append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item) -
7640{ -
7641 if (item) {
never evaluated: item
0
7642 QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(list->object);
never executed (the execution status of this line is deduced): QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(list->object);
-
7643 if (QGraphicsItemPrivate::get(graphicsObject)->sendParentChangeNotification) {
never evaluated: QGraphicsItemPrivate::get(graphicsObject)->sendParentChangeNotification
0
7644 item->setParentItem(graphicsObject);
never executed (the execution status of this line is deduced): item->setParentItem(graphicsObject);
-
7645 } else {
never executed: }
0
7646 QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, 0, 0);
never executed (the execution status of this line is deduced): QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, 0, 0);
-
7647 }
never executed: }
0
7648 } -
7649}
never executed: }
0
7650 -
7651int QGraphicsItemPrivate::children_count(QDeclarativeListProperty<QGraphicsObject> *list) -
7652{ -
7653 QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object));
never executed (the execution status of this line is deduced): QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object));
-
7654 return d->children.count();
never executed: return d->children.count();
0
7655} -
7656 -
7657QGraphicsObject *QGraphicsItemPrivate::children_at(QDeclarativeListProperty<QGraphicsObject> *list, int index) -
7658{ -
7659 QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object));
never executed (the execution status of this line is deduced): QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object));
-
7660 if (index >= 0 && index < d->children.count())
never evaluated: index >= 0
never evaluated: index < d->children.count()
0
7661 return d->children.at(index)->toGraphicsObject();
never executed: return d->children.at(index)->toGraphicsObject();
0
7662 else -
7663 return 0;
never executed: return 0;
0
7664} -
7665 -
7666void QGraphicsItemPrivate::children_clear(QDeclarativeListProperty<QGraphicsObject> *list) -
7667{ -
7668 QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object));
never executed (the execution status of this line is deduced): QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object));
-
7669 int childCount = d->children.count();
never executed (the execution status of this line is deduced): int childCount = d->children.count();
-
7670 if (d->sendParentChangeNotification) {
never evaluated: d->sendParentChangeNotification
0
7671 for (int index = 0; index < childCount; index++)
never evaluated: index < childCount
0
7672 d->children.at(0)->setParentItem(0);
never executed: d->children.at(0)->setParentItem(0);
0
7673 } else {
never executed: }
0
7674 for (int index = 0; index < childCount; index++)
never evaluated: index < childCount
0
7675 QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(0, 0, 0);
never executed: QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(0, 0, 0);
0
7676 }
never executed: }
0
7677} -
7678 -
7679/*! -
7680 Returns a list of this item's children. -
7681 -
7682 The items are sorted by stacking order. This takes into account both the -
7683 items' insertion order and their Z-values. -
7684 -
7685*/ -
7686QDeclarativeListProperty<QGraphicsObject> QGraphicsItemPrivate::childrenList() -
7687{ -
7688 Q_Q(QGraphicsItem);
never executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func();
-
7689 if (isObject) {
never evaluated: isObject
0
7690 QGraphicsObject *that = static_cast<QGraphicsObject *>(q);
never executed (the execution status of this line is deduced): QGraphicsObject *that = static_cast<QGraphicsObject *>(q);
-
7691 return QDeclarativeListProperty<QGraphicsObject>(that, &children, children_append,
never executed: return QDeclarativeListProperty<QGraphicsObject>(that, &children, children_append, children_count, children_at, children_clear);
0
7692 children_count, children_at, children_clear);
never executed: return QDeclarativeListProperty<QGraphicsObject>(that, &children, children_append, children_count, children_at, children_clear);
0
7693 } else { -
7694 //QGraphicsItem is not supported for this property -
7695 return QDeclarativeListProperty<QGraphicsObject>();
never executed: return QDeclarativeListProperty<QGraphicsObject>();
0
7696 } -
7697} -
7698 -
7699/*! -
7700 \internal -
7701 Returns the width of the item -
7702 Reimplemented by QGraphicsWidget -
7703*/ -
7704qreal QGraphicsItemPrivate::width() const -
7705{ -
7706 return 0;
never executed: return 0;
0
7707} -
7708 -
7709/*! -
7710 \internal -
7711 Set the width of the item -
7712 Reimplemented by QGraphicsWidget -
7713*/ -
7714void QGraphicsItemPrivate::setWidth(qreal w) -
7715{ -
7716 Q_UNUSED(w);
never executed (the execution status of this line is deduced): (void)w;;
-
7717}
never executed: }
0
7718 -
7719/*! -
7720 \internal -
7721 Reset the width of the item -
7722 Reimplemented by QGraphicsWidget -
7723*/ -
7724void QGraphicsItemPrivate::resetWidth() -
7725{ -
7726} -
7727 -
7728/*! -
7729 \internal -
7730 Returns the height of the item -
7731 Reimplemented by QGraphicsWidget -
7732*/ -
7733qreal QGraphicsItemPrivate::height() const -
7734{ -
7735 return 0;
never executed: return 0;
0
7736} -
7737 -
7738/*! -
7739 \internal -
7740 Set the height of the item -
7741 Reimplemented by QGraphicsWidget -
7742*/ -
7743void QGraphicsItemPrivate::setHeight(qreal h) -
7744{ -
7745 Q_UNUSED(h);
never executed (the execution status of this line is deduced): (void)h;;
-
7746}
never executed: }
0
7747 -
7748/*! -
7749 \internal -
7750 Reset the height of the item -
7751 Reimplemented by QGraphicsWidget -
7752*/ -
7753void QGraphicsItemPrivate::resetHeight() -
7754{ -
7755} -
7756 -
7757/*! -
7758 \property QGraphicsObject::children -
7759 \since 4.7 -
7760 \internal -
7761*/ -
7762 -
7763/*! -
7764 \property QGraphicsObject::width -
7765 \since 4.7 -
7766 \internal -
7767*/ -
7768 -
7769/*! -
7770 \property QGraphicsObject::height -
7771 \since 4.7 -
7772 \internal -
7773*/ -
7774 -
7775/*! -
7776 \property QGraphicsObject::parent -
7777 \brief the parent of the item -
7778 -
7779 \note The item's parent is set independently of the parent object returned -
7780 by QObject::parent(). -
7781 -
7782 \sa QGraphicsItem::setParentItem(), QGraphicsItem::parentObject() -
7783*/ -
7784 -
7785/*! -
7786 \property QGraphicsObject::opacity -
7787 \brief the opacity of the item -
7788 -
7789 \sa QGraphicsItem::setOpacity(), QGraphicsItem::opacity() -
7790*/ -
7791 -
7792/*! -
7793 \fn QGraphicsObject::opacityChanged() -
7794 -
7795 This signal gets emitted whenever the opacity of the item changes -
7796 -
7797 \sa QGraphicsItem::opacity() -
7798*/ -
7799 -
7800/*! -
7801 \fn QGraphicsObject::parentChanged() -
7802 -
7803 This signal gets emitted whenever the parent of the item changes -
7804*/ -
7805 -
7806/*! -
7807 \property QGraphicsObject::pos -
7808 \brief the position of the item -
7809 -
7810 Describes the items position. -
7811 -
7812 \sa QGraphicsItem::setPos(), QGraphicsItem::pos() -
7813*/ -
7814 -
7815/*! -
7816 \property QGraphicsObject::x -
7817 \brief the x position of the item -
7818 -
7819 Describes the items x position. -
7820 -
7821 \sa QGraphicsItem::setX(), setPos() -
7822*/ -
7823 -
7824/*! -
7825 \fn QGraphicsObject::xChanged() -
7826 -
7827 This signal gets emitted whenever the x position of the item changes -
7828 -
7829 \sa pos() -
7830*/ -
7831 -
7832/*! -
7833 \property QGraphicsObject::y -
7834 \brief the y position of the item -
7835 -
7836 Describes the items y position. -
7837 -
7838 \sa QGraphicsItem::setY(), setPos() -
7839*/ -
7840 -
7841/*! -
7842 \fn QGraphicsObject::yChanged() -
7843 -
7844 This signal gets emitted whenever the y position of the item changes. -
7845 -
7846 \sa pos() -
7847*/ -
7848 -
7849/*! -
7850 \property QGraphicsObject::z -
7851 \brief the z value of the item -
7852 -
7853 Describes the items z value. -
7854 -
7855 \sa QGraphicsItem::setZValue(), zValue() -
7856*/ -
7857 -
7858/*! -
7859 \fn QGraphicsObject::zChanged() -
7860 -
7861 This signal gets emitted whenever the z value of the item changes. -
7862 -
7863 \sa pos() -
7864*/ -
7865 -
7866/*! -
7867 \property QGraphicsObject::rotation -
7868 This property holds the rotation of the item in degrees. -
7869 -
7870 This specifies how many degrees to rotate the item around its transformOrigin. -
7871 The default rotation is 0 degrees (i.e. not rotated at all). -
7872*/ -
7873 -
7874/*! -
7875 \fn QGraphicsObject::rotationChanged() -
7876 -
7877 This signal gets emitted whenever the roation of the item changes. -
7878*/ -
7879 -
7880/*! -
7881 \property QGraphicsObject::scale -
7882 This property holds the scale of the item. -
7883 -
7884 A scale of less than 1 means the item will be displayed smaller than -
7885 normal, and a scale of greater than 1 means the item will be -
7886 displayed larger than normal. A negative scale means the item will -
7887 be mirrored. -
7888 -
7889 By default, items are displayed at a scale of 1 (i.e. at their -
7890 normal size). -
7891 -
7892 Scaling is from the item's transformOrigin. -
7893*/ -
7894 -
7895/*! -
7896 \fn void QGraphicsObject::scaleChanged() -
7897 -
7898 This signal is emitted when the scale of the item changes. -
7899*/ -
7900 -
7901 -
7902/*! -
7903 \property QGraphicsObject::enabled -
7904 \brief whether the item is enabled or not -
7905 -
7906 This property is declared in QGraphicsItem. -
7907 -
7908 By default, this property is true. -
7909 -
7910 \sa QGraphicsItem::isEnabled(), QGraphicsItem::setEnabled() -
7911*/ -
7912 -
7913/*! -
7914 \fn void QGraphicsObject::enabledChanged() -
7915 -
7916 This signal gets emitted whenever the item get's enabled or disabled. -
7917 -
7918 \sa isEnabled() -
7919*/ -
7920 -
7921/*! -
7922 \property QGraphicsObject::visible -
7923 \brief whether the item is visible or not -
7924 -
7925 This property is declared in QGraphicsItem. -
7926 -
7927 By default, this property is true. -
7928 -
7929 \sa QGraphicsItem::isVisible(), QGraphicsItem::setVisible() -
7930*/ -
7931 -
7932/*! -
7933 \fn QGraphicsObject::visibleChanged() -
7934 -
7935 This signal gets emitted whenever the visibility of the item changes -
7936 -
7937 \sa visible -
7938*/ -
7939 -
7940/*! -
7941 \fn const QObjectList &QGraphicsObject::children() const -
7942 \internal -
7943 -
7944 This function returns the same value as QObject::children(). It's -
7945 provided to differentiate between the obsolete member -
7946 QGraphicsItem::children() and QObject::children(). QGraphicsItem now -
7947 provides childItems() instead. -
7948*/ -
7949 -
7950/*! -
7951 \property QGraphicsObject::transformOriginPoint -
7952 \brief the transformation origin -
7953 -
7954 This property sets a specific point in the items coordiante system as the -
7955 origin for scale and rotation. -
7956 -
7957 \sa scale, rotation, QGraphicsItem::transformOriginPoint() -
7958*/ -
7959 -
7960/*! -
7961 \fn void QGraphicsObject::widthChanged() -
7962 \internal -
7963*/ -
7964 -
7965/*! -
7966 \fn void QGraphicsObject::heightChanged() -
7967 \internal -
7968*/ -
7969 -
7970/*! -
7971 -
7972 \fn QGraphicsObject::childrenChanged() -
7973 -
7974 This signal gets emitted whenever the children list changes -
7975 \internal -
7976*/ -
7977 -
7978/*! -
7979 \property QGraphicsObject::effect -
7980 \since 4.7 -
7981 \brief the effect attached to this item -
7982 -
7983 \sa QGraphicsItem::setGraphicsEffect(), QGraphicsItem::graphicsEffect() -
7984*/ -
7985 -
7986/*! -
7987 \class QAbstractGraphicsShapeItem -
7988 \brief The QAbstractGraphicsShapeItem class provides a common base for -
7989 all path items. -
7990 \since 4.2 -
7991 \ingroup graphicsview-api -
7992 \inmodule QtWidgets -
7993 -
7994 This class does not fully implement an item by itself; in particular, it -
7995 does not implement boundingRect() and paint(), which are inherited by -
7996 QGraphicsItem. -
7997 -
7998 You can subclass this item to provide a simple base implementation of -
7999 accessors for the item's pen and brush. -
8000 -
8001 \sa QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPathItem, -
8002 QGraphicsPolygonItem, QGraphicsTextItem, QGraphicsLineItem, -
8003 QGraphicsPixmapItem, {Graphics View Framework} -
8004*/ -
8005 -
8006class QAbstractGraphicsShapeItemPrivate : public QGraphicsItemPrivate -
8007{ -
8008 Q_DECLARE_PUBLIC(QAbstractGraphicsShapeItem) -
8009public: -
8010 -
8011 QBrush brush; -
8012 QPen pen; -
8013 -
8014 // Cached bounding rectangle -
8015 mutable QRectF boundingRect; -
8016}; -
8017 -
8018/*! -
8019 Constructs a QAbstractGraphicsShapeItem. \a parent is passed to -
8020 QGraphicsItem's constructor. -
8021*/ -
8022QAbstractGraphicsShapeItem::QAbstractGraphicsShapeItem(QGraphicsItem *parent) -
8023 : QGraphicsItem(*new QAbstractGraphicsShapeItemPrivate, parent) -
8024{ -
8025}
never executed: }
0
8026 -
8027/*! -
8028 \internal -
8029*/ -
8030QAbstractGraphicsShapeItem::QAbstractGraphicsShapeItem(QAbstractGraphicsShapeItemPrivate &dd, QGraphicsItem *parent) -
8031 : QGraphicsItem(dd, parent) -
8032{ -
8033}
executed: }
Execution Count:618
618
8034 -
8035/*! -
8036 Destroys a QAbstractGraphicsShapeItem. -
8037*/ -
8038QAbstractGraphicsShapeItem::~QAbstractGraphicsShapeItem() -
8039{ -
8040} -
8041 -
8042/*! -
8043 Returns the item's pen. If no pen has been set, this function returns -
8044 QPen(), a default black solid line pen with 1 width. -
8045*/ -
8046QPen QAbstractGraphicsShapeItem::pen() const -
8047{ -
8048 Q_D(const QAbstractGraphicsShapeItem);
executed (the execution status of this line is deduced): const QAbstractGraphicsShapeItemPrivate * const d = d_func();
-
8049 return d->pen;
executed: return d->pen;
Execution Count:600
600
8050} -
8051 -
8052/*! -
8053 Sets the pen for this item to \a pen. -
8054 -
8055 The pen is used to draw the item's outline. -
8056 -
8057 \sa pen() -
8058*/ -
8059void QAbstractGraphicsShapeItem::setPen(const QPen &pen) -
8060{ -
8061 Q_D(QAbstractGraphicsShapeItem);
executed (the execution status of this line is deduced): QAbstractGraphicsShapeItemPrivate * const d = d_func();
-
8062 if (d->pen == pen)
evaluated: d->pen == pen
TRUEFALSE
yes
Evaluation Count:114
yes
Evaluation Count:445
114-445
8063 return;
executed: return;
Execution Count:114
114
8064 prepareGeometryChange();
executed (the execution status of this line is deduced): prepareGeometryChange();
-
8065 d->pen = pen;
executed (the execution status of this line is deduced): d->pen = pen;
-
8066 d->boundingRect = QRectF();
executed (the execution status of this line is deduced): d->boundingRect = QRectF();
-
8067 update();
executed (the execution status of this line is deduced): update();
-
8068}
executed: }
Execution Count:445
445
8069 -
8070/*! -
8071 Returns the item's brush, or an empty brush if no brush has been set. -
8072 -
8073 \sa setBrush() -
8074*/ -
8075QBrush QAbstractGraphicsShapeItem::brush() const -
8076{ -
8077 Q_D(const QAbstractGraphicsShapeItem);
never executed (the execution status of this line is deduced): const QAbstractGraphicsShapeItemPrivate * const d = d_func();
-
8078 return d->brush;
never executed: return d->brush;
0
8079} -
8080 -
8081/*! -
8082 Sets the item's brush to \a brush. -
8083 -
8084 The item's brush is used to fill the item. -
8085 -
8086 If you use a brush with a QGradient, the gradient -
8087 is relative to the item's coordinate system. -
8088 -
8089 \sa brush() -
8090*/ -
8091void QAbstractGraphicsShapeItem::setBrush(const QBrush &brush) -
8092{ -
8093 Q_D(QAbstractGraphicsShapeItem);
executed (the execution status of this line is deduced): QAbstractGraphicsShapeItemPrivate * const d = d_func();
-
8094 if (d->brush == brush)
evaluated: d->brush == brush
TRUEFALSE
yes
Evaluation Count:104
yes
Evaluation Count:421
104-421
8095 return;
executed: return;
Execution Count:104
104
8096 d->brush = brush;
executed (the execution status of this line is deduced): d->brush = brush;
-
8097 update();
executed (the execution status of this line is deduced): update();
-
8098}
executed: }
Execution Count:421
421
8099 -
8100/*! -
8101 \reimp -
8102*/ -
8103bool QAbstractGraphicsShapeItem::isObscuredBy(const QGraphicsItem *item) const -
8104{ -
8105 return QGraphicsItem::isObscuredBy(item);
executed: return QGraphicsItem::isObscuredBy(item);
Execution Count:2
2
8106} -
8107 -
8108/*! -
8109 \reimp -
8110*/ -
8111QPainterPath QAbstractGraphicsShapeItem::opaqueArea() const -
8112{ -
8113 Q_D(const QAbstractGraphicsShapeItem);
executed (the execution status of this line is deduced): const QAbstractGraphicsShapeItemPrivate * const d = d_func();
-
8114 if (d->brush.isOpaque())
partially evaluated: d->brush.isOpaque()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:2
0-2
8115 return isClipped() ? clipPath() : shape();
never executed: return isClipped() ? clipPath() : shape();
0
8116 return QGraphicsItem::opaqueArea();
executed: return QGraphicsItem::opaqueArea();
Execution Count:2
2
8117} -
8118 -
8119/*! -
8120 \class QGraphicsPathItem -
8121 \brief The QGraphicsPathItem class provides a path item that you -
8122 can add to a QGraphicsScene. -
8123 \since 4.2 -
8124 \ingroup graphicsview-api -
8125 \inmodule QtWidgets -
8126 -
8127 To set the item's path, pass a QPainterPath to QGraphicsPathItem's -
8128 constructor, or call the setPath() function. The path() function -
8129 returns the current path. -
8130 -
8131 \image graphicsview-pathitem.png -
8132 -
8133 QGraphicsPathItem uses the path to provide a reasonable -
8134 implementation of boundingRect(), shape(), and contains(). The -
8135 paint() function draws the path using the item's associated pen -
8136 and brush, which you can set by calling the setPen() and -
8137 setBrush() functions. -
8138 -
8139 \sa QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPolygonItem, -
8140 QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics -
8141 View Framework} -
8142*/ -
8143 -
8144class QGraphicsPathItemPrivate : public QAbstractGraphicsShapeItemPrivate -
8145{ -
8146 Q_DECLARE_PUBLIC(QGraphicsPathItem) -
8147public: -
8148 QPainterPath path; -
8149}; -
8150 -
8151/*! -
8152 Constructs a QGraphicsPath item using \a path as the default path. \a -
8153 parent is passed to QAbstractGraphicsShapeItem's constructor. -
8154 -
8155 \sa QGraphicsScene::addItem() -
8156*/ -
8157QGraphicsPathItem::QGraphicsPathItem(const QPainterPath &path, -
8158 QGraphicsItem *parent) -
8159 : QAbstractGraphicsShapeItem(*new QGraphicsPathItemPrivate, parent) -
8160{ -
8161 if (!path.isEmpty())
never evaluated: !path.isEmpty()
0
8162 setPath(path);
never executed: setPath(path);
0
8163}
never executed: }
0
8164 -
8165/*! -
8166 Constructs a QGraphicsPath. \a parent is passed to -
8167 QAbstractGraphicsShapeItem's constructor. -
8168 -
8169 \sa QGraphicsScene::addItem() -
8170*/ -
8171QGraphicsPathItem::QGraphicsPathItem(QGraphicsItem *parent) -
8172 : QAbstractGraphicsShapeItem(*new QGraphicsPathItemPrivate, parent) -
8173{ -
8174}
never executed: }
0
8175 -
8176/*! -
8177 Destroys the QGraphicsPathItem. -
8178*/ -
8179QGraphicsPathItem::~QGraphicsPathItem() -
8180{ -
8181} -
8182 -
8183/*! -
8184 Returns the item's path as a QPainterPath. If no item has been set, an -
8185 empty QPainterPath is returned. -
8186 -
8187 \sa setPath() -
8188*/ -
8189QPainterPath QGraphicsPathItem::path() const -
8190{ -
8191 Q_D(const QGraphicsPathItem);
never executed (the execution status of this line is deduced): const QGraphicsPathItemPrivate * const d = d_func();
-
8192 return d->path;
never executed: return d->path;
0
8193} -
8194 -
8195/*! -
8196 Sets the item's path to be the given \a path. -
8197 -
8198 \sa path() -
8199*/ -
8200void QGraphicsPathItem::setPath(const QPainterPath &path) -
8201{ -
8202 Q_D(QGraphicsPathItem);
never executed (the execution status of this line is deduced): QGraphicsPathItemPrivate * const d = d_func();
-
8203 if (d->path == path)
never evaluated: d->path == path
0
8204 return;
never executed: return;
0
8205 prepareGeometryChange();
never executed (the execution status of this line is deduced): prepareGeometryChange();
-
8206 d->path = path;
never executed (the execution status of this line is deduced): d->path = path;
-
8207 d->boundingRect = QRectF();
never executed (the execution status of this line is deduced): d->boundingRect = QRectF();
-
8208 update();
never executed (the execution status of this line is deduced): update();
-
8209}
never executed: }
0
8210 -
8211/*! -
8212 \reimp -
8213*/ -
8214QRectF QGraphicsPathItem::boundingRect() const -
8215{ -
8216 Q_D(const QGraphicsPathItem);
never executed (the execution status of this line is deduced): const QGraphicsPathItemPrivate * const d = d_func();
-
8217 if (d->boundingRect.isNull()) {
never evaluated: d->boundingRect.isNull()
0
8218 qreal pw = pen().style() == Qt::NoPen ? qreal(0) : pen().widthF();
never evaluated: pen().style() == Qt::NoPen
0
8219 if (pw == 0.0)
never evaluated: pw == 0.0
0
8220 d->boundingRect = d->path.controlPointRect();
never executed: d->boundingRect = d->path.controlPointRect();
0
8221 else { -
8222 d->boundingRect = shape().controlPointRect();
never executed (the execution status of this line is deduced): d->boundingRect = shape().controlPointRect();
-
8223 }
never executed: }
0
8224 } -
8225 return d->boundingRect;
never executed: return d->boundingRect;
0
8226} -
8227 -
8228/*! -
8229 \reimp -
8230*/ -
8231QPainterPath QGraphicsPathItem::shape() const -
8232{ -
8233 Q_D(const QGraphicsPathItem);
never executed (the execution status of this line is deduced): const QGraphicsPathItemPrivate * const d = d_func();
-
8234 return qt_graphicsItem_shapeFromPath(d->path, d->pen);
never executed: return qt_graphicsItem_shapeFromPath(d->path, d->pen);
0
8235} -
8236 -
8237/*! -
8238 \reimp -
8239*/ -
8240bool QGraphicsPathItem::contains(const QPointF &point) const -
8241{ -
8242 return QAbstractGraphicsShapeItem::contains(point);
never executed: return QAbstractGraphicsShapeItem::contains(point);
0
8243} -
8244 -
8245/*! -
8246 \reimp -
8247*/ -
8248void QGraphicsPathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, -
8249 QWidget *widget) -
8250{ -
8251 Q_D(QGraphicsPathItem);
never executed (the execution status of this line is deduced): QGraphicsPathItemPrivate * const d = d_func();
-
8252 Q_UNUSED(widget);
never executed (the execution status of this line is deduced): (void)widget;;
-
8253 painter->setPen(d->pen);
never executed (the execution status of this line is deduced): painter->setPen(d->pen);
-
8254 painter->setBrush(d->brush);
never executed (the execution status of this line is deduced): painter->setBrush(d->brush);
-
8255 painter->drawPath(d->path);
never executed (the execution status of this line is deduced): painter->drawPath(d->path);
-
8256 -
8257 if (option->state & QStyle::State_Selected)
never evaluated: option->state & QStyle::State_Selected
0
8258 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
8259}
never executed: }
0
8260 -
8261/*! -
8262 \reimp -
8263*/ -
8264bool QGraphicsPathItem::isObscuredBy(const QGraphicsItem *item) const -
8265{ -
8266 return QAbstractGraphicsShapeItem::isObscuredBy(item);
never executed: return QAbstractGraphicsShapeItem::isObscuredBy(item);
0
8267} -
8268 -
8269/*! -
8270 \reimp -
8271*/ -
8272QPainterPath QGraphicsPathItem::opaqueArea() const -
8273{ -
8274 return QAbstractGraphicsShapeItem::opaqueArea();
never executed: return QAbstractGraphicsShapeItem::opaqueArea();
0
8275} -
8276 -
8277/*! -
8278 \reimp -
8279*/ -
8280int QGraphicsPathItem::type() const -
8281{ -
8282 return Type;
never executed: return Type;
0
8283} -
8284 -
8285/*! -
8286 \internal -
8287*/ -
8288bool QGraphicsPathItem::supportsExtension(Extension extension) const -
8289{ -
8290 Q_UNUSED(extension);
never executed (the execution status of this line is deduced): (void)extension;;
-
8291 return false;
never executed: return false;
0
8292} -
8293 -
8294/*! -
8295 \internal -
8296*/ -
8297void QGraphicsPathItem::setExtension(Extension extension, const QVariant &variant) -
8298{ -
8299 Q_UNUSED(extension);
never executed (the execution status of this line is deduced): (void)extension;;
-
8300 Q_UNUSED(variant);
never executed (the execution status of this line is deduced): (void)variant;;
-
8301}
never executed: }
0
8302 -
8303/*! -
8304 \internal -
8305*/ -
8306QVariant QGraphicsPathItem::extension(const QVariant &variant) const -
8307{ -
8308 Q_UNUSED(variant);
never executed (the execution status of this line is deduced): (void)variant;;
-
8309 return QVariant();
never executed: return QVariant();
0
8310} -
8311 -
8312/*! -
8313 \class QGraphicsRectItem -
8314 \brief The QGraphicsRectItem class provides a rectangle item that you -
8315 can add to a QGraphicsScene. -
8316 \since 4.2 -
8317 \ingroup graphicsview-api -
8318 \inmodule QtWidgets -
8319 -
8320 To set the item's rectangle, pass a QRectF to QGraphicsRectItem's -
8321 constructor, or call the setRect() function. The rect() function -
8322 returns the current rectangle. -
8323 -
8324 \image graphicsview-rectitem.png -
8325 -
8326 QGraphicsRectItem uses the rectangle and the pen width to provide -
8327 a reasonable implementation of boundingRect(), shape(), and -
8328 contains(). The paint() function draws the rectangle using the -
8329 item's associated pen and brush, which you can set by calling the -
8330 setPen() and setBrush() functions. -
8331 -
8332 \note The rendering of invalid rectangles, such as those with negative -
8333 widths or heights, is undefined. If you cannot be sure that you are -
8334 using valid rectangles (for example, if you are creating -
8335 rectangles using data from an unreliable source) then you should -
8336 use QRectF::normalized() to create normalized rectangles, and use -
8337 those instead. -
8338 -
8339 \sa QGraphicsPathItem, QGraphicsEllipseItem, QGraphicsPolygonItem, -
8340 QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics -
8341 View Framework} -
8342*/ -
8343 -
8344class QGraphicsRectItemPrivate : public QAbstractGraphicsShapeItemPrivate -
8345{ -
8346 Q_DECLARE_PUBLIC(QGraphicsRectItem) -
8347public: -
8348 QRectF rect; -
8349}; -
8350 -
8351/*! -
8352 Constructs a QGraphicsRectItem, using \a rect as the default rectangle. -
8353 \a parent is passed to QAbstractGraphicsShapeItem's constructor. -
8354 -
8355 \sa QGraphicsScene::addItem() -
8356*/ -
8357QGraphicsRectItem::QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent) -
8358 : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent) -
8359{ -
8360 setRect(rect);
executed (the execution status of this line is deduced): setRect(rect);
-
8361}
executed: }
Execution Count:552
552
8362 -
8363/*! -
8364 \fn QGraphicsRectItem::QGraphicsRectItem(qreal x, qreal y, qreal width, qreal height, -
8365 QGraphicsItem *parent) -
8366 -
8367 Constructs a QGraphicsRectItem with a default rectangle defined -
8368 by (\a x, \a y) and the given \a width and \a height. -
8369 -
8370 \a parent is passed to QAbstractGraphicsShapeItem's constructor. -
8371 -
8372 \sa QGraphicsScene::addItem() -
8373*/ -
8374QGraphicsRectItem::QGraphicsRectItem(qreal x, qreal y, qreal w, qreal h, -
8375 QGraphicsItem *parent) -
8376 : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent) -
8377{ -
8378 setRect(QRectF(x, y, w, h));
executed (the execution status of this line is deduced): setRect(QRectF(x, y, w, h));
-
8379}
executed: }
Execution Count:22
22
8380 -
8381/*! -
8382 Constructs a QGraphicsRectItem. \a parent is passed to -
8383 QAbstractGraphicsShapeItem's constructor. -
8384 -
8385 \sa QGraphicsScene::addItem() -
8386*/ -
8387QGraphicsRectItem::QGraphicsRectItem(QGraphicsItem *parent) -
8388 : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent) -
8389{ -
8390}
executed: }
Execution Count:12
12
8391 -
8392/*! -
8393 Destroys the QGraphicsRectItem. -
8394*/ -
8395QGraphicsRectItem::~QGraphicsRectItem() -
8396{ -
8397} -
8398 -
8399/*! -
8400 Returns the item's rectangle. -
8401 -
8402 \sa setRect() -
8403*/ -
8404QRectF QGraphicsRectItem::rect() const -
8405{ -
8406 Q_D(const QGraphicsRectItem);
executed (the execution status of this line is deduced): const QGraphicsRectItemPrivate * const d = d_func();
-
8407 return d->rect;
executed: return d->rect;
Execution Count:41
41
8408} -
8409 -
8410/*! -
8411 \fn void QGraphicsRectItem::setRect(const QRectF &rectangle) -
8412 -
8413 Sets the item's rectangle to be the given \a rectangle. -
8414 -
8415 \sa rect() -
8416*/ -
8417void QGraphicsRectItem::setRect(const QRectF &rect) -
8418{ -
8419 Q_D(QGraphicsRectItem);
executed (the execution status of this line is deduced): QGraphicsRectItemPrivate * const d = d_func();
-
8420 if (d->rect == rect)
evaluated: d->rect == rect
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:659
3-659
8421 return;
executed: return;
Execution Count:3
3
8422 prepareGeometryChange();
executed (the execution status of this line is deduced): prepareGeometryChange();
-
8423 d->rect = rect;
executed (the execution status of this line is deduced): d->rect = rect;
-
8424 d->boundingRect = QRectF();
executed (the execution status of this line is deduced): d->boundingRect = QRectF();
-
8425 update();
executed (the execution status of this line is deduced): update();
-
8426}
executed: }
Execution Count:659
659
8427 -
8428/*! -
8429 \fn void QGraphicsRectItem::setRect(qreal x, qreal y, qreal width, qreal height) -
8430 \fn void QGraphicsEllipseItem::setRect(qreal x, qreal y, qreal width, qreal height) -
8431 -
8432 Sets the item's rectangle to the rectangle defined by (\a x, \a y) -
8433 and the given \a width and \a height. -
8434 -
8435 This convenience function is equivalent to calling \c -
8436 {setRect(QRectF(x, y, width, height))} -
8437 -
8438 \sa rect() -
8439*/ -
8440 -
8441/*! -
8442 \reimp -
8443*/ -
8444QRectF QGraphicsRectItem::boundingRect() const -
8445{ -
8446 Q_D(const QGraphicsRectItem);
executed (the execution status of this line is deduced): const QGraphicsRectItemPrivate * const d = d_func();
-
8447 if (d->boundingRect.isNull()) {
evaluated: d->boundingRect.isNull()
TRUEFALSE
yes
Evaluation Count:282
yes
Evaluation Count:1651
282-1651
8448 qreal halfpw = pen().style() == Qt::NoPen ? qreal(0) : pen().widthF() / 2;
evaluated: pen().style() == Qt::NoPen
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:277
5-277
8449 d->boundingRect = d->rect;
executed (the execution status of this line is deduced): d->boundingRect = d->rect;
-
8450 if (halfpw > 0.0)
evaluated: halfpw > 0.0
TRUEFALSE
yes
Evaluation Count:227
yes
Evaluation Count:55
55-227
8451 d->boundingRect.adjust(-halfpw, -halfpw, halfpw, halfpw);
executed: d->boundingRect.adjust(-halfpw, -halfpw, halfpw, halfpw);
Execution Count:227
227
8452 }
executed: }
Execution Count:282
282
8453 return d->boundingRect;
executed: return d->boundingRect;
Execution Count:1933
1933
8454} -
8455 -
8456/*! -
8457 \reimp -
8458*/ -
8459QPainterPath QGraphicsRectItem::shape() const -
8460{ -
8461 Q_D(const QGraphicsRectItem);
executed (the execution status of this line is deduced): const QGraphicsRectItemPrivate * const d = d_func();
-
8462 QPainterPath path;
executed (the execution status of this line is deduced): QPainterPath path;
-
8463 path.addRect(d->rect);
executed (the execution status of this line is deduced): path.addRect(d->rect);
-
8464 return qt_graphicsItem_shapeFromPath(path, d->pen);
executed: return qt_graphicsItem_shapeFromPath(path, d->pen);
Execution Count:143
143
8465} -
8466 -
8467/*! -
8468 \reimp -
8469*/ -
8470bool QGraphicsRectItem::contains(const QPointF &point) const -
8471{ -
8472 return QAbstractGraphicsShapeItem::contains(point);
never executed: return QAbstractGraphicsShapeItem::contains(point);
0
8473} -
8474 -
8475/*! -
8476 \reimp -
8477*/ -
8478void QGraphicsRectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, -
8479 QWidget *widget) -
8480{ -
8481 Q_D(QGraphicsRectItem);
executed (the execution status of this line is deduced): QGraphicsRectItemPrivate * const d = d_func();
-
8482 Q_UNUSED(widget);
executed (the execution status of this line is deduced): (void)widget;;
-
8483 painter->setPen(d->pen);
executed (the execution status of this line is deduced): painter->setPen(d->pen);
-
8484 painter->setBrush(d->brush);
executed (the execution status of this line is deduced): painter->setBrush(d->brush);
-
8485 painter->drawRect(d->rect);
executed (the execution status of this line is deduced): painter->drawRect(d->rect);
-
8486 -
8487 if (option->state & QStyle::State_Selected)
evaluated: option->state & QStyle::State_Selected
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:343
1-343
8488 qt_graphicsItem_highlightSelected(this, painter, option);
executed: qt_graphicsItem_highlightSelected(this, painter, option);
Execution Count:1
1
8489}
executed: }
Execution Count:344
344
8490 -
8491/*! -
8492 \reimp -
8493*/ -
8494bool QGraphicsRectItem::isObscuredBy(const QGraphicsItem *item) const -
8495{ -
8496 return QAbstractGraphicsShapeItem::isObscuredBy(item);
never executed: return QAbstractGraphicsShapeItem::isObscuredBy(item);
0
8497} -
8498 -
8499/*! -
8500 \reimp -
8501*/ -
8502QPainterPath QGraphicsRectItem::opaqueArea() const -
8503{ -
8504 return QAbstractGraphicsShapeItem::opaqueArea();
never executed: return QAbstractGraphicsShapeItem::opaqueArea();
0
8505} -
8506 -
8507/*! -
8508 \reimp -
8509*/ -
8510int QGraphicsRectItem::type() const -
8511{ -
8512 return Type;
executed: return Type;
Execution Count:5
5
8513} -
8514 -
8515/*! -
8516 \internal -
8517*/ -
8518bool QGraphicsRectItem::supportsExtension(Extension extension) const -
8519{ -
8520 Q_UNUSED(extension);
never executed (the execution status of this line is deduced): (void)extension;;
-
8521 return false;
never executed: return false;
0
8522} -
8523 -
8524/*! -
8525 \internal -
8526*/ -
8527void QGraphicsRectItem::setExtension(Extension extension, const QVariant &variant) -
8528{ -
8529 Q_UNUSED(extension);
never executed (the execution status of this line is deduced): (void)extension;;
-
8530 Q_UNUSED(variant);
never executed (the execution status of this line is deduced): (void)variant;;
-
8531}
never executed: }
0
8532 -
8533/*! -
8534 \internal -
8535*/ -
8536QVariant QGraphicsRectItem::extension(const QVariant &variant) const -
8537{ -
8538 Q_UNUSED(variant);
never executed (the execution status of this line is deduced): (void)variant;;
-
8539 return QVariant();
never executed: return QVariant();
0
8540} -
8541 -
8542/*! -
8543 \class QGraphicsEllipseItem -
8544 \brief The QGraphicsEllipseItem class provides an ellipse item that you -
8545 can add to a QGraphicsScene. -
8546 \since 4.2 -
8547 \ingroup graphicsview-api -
8548 \inmodule QtWidgets -
8549 -
8550 QGraphicsEllipseItem respresents an ellipse with a fill and an outline, -
8551 and you can also use it for ellipse segments (see startAngle(), -
8552 spanAngle()). -
8553 -
8554 \table -
8555 \row -
8556 \li \inlineimage graphicsview-ellipseitem.png -
8557 \li \inlineimage graphicsview-ellipseitem-pie.png -
8558 \endtable -
8559 -
8560 To set the item's ellipse, pass a QRectF to QGraphicsEllipseItem's -
8561 constructor, or call setRect(). The rect() function returns the -
8562 current ellipse geometry. -
8563 -
8564 QGraphicsEllipseItem uses the rect and the pen width to provide a -
8565 reasonable implementation of boundingRect(), shape(), and contains(). The -
8566 paint() function draws the ellipse using the item's associated pen and -
8567 brush, which you can set by calling setPen() and setBrush(). -
8568 -
8569 \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsPolygonItem, -
8570 QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics -
8571 View Framework} -
8572*/ -
8573 -
8574class QGraphicsEllipseItemPrivate : public QAbstractGraphicsShapeItemPrivate -
8575{ -
8576 Q_DECLARE_PUBLIC(QGraphicsEllipseItem) -
8577public: -
8578 inline QGraphicsEllipseItemPrivate() -
8579 : startAngle(0), spanAngle(360 * 16) -
8580 { }
executed: }
Execution Count:17
17
8581 -
8582 QRectF rect; -
8583 int startAngle; -
8584 int spanAngle; -
8585}; -
8586 -
8587/*! -
8588 Constructs a QGraphicsEllipseItem using \a rect as the default rectangle. -
8589 \a parent is passed to QAbstractGraphicsShapeItem's constructor. -
8590 -
8591 \sa QGraphicsScene::addItem() -
8592*/ -
8593QGraphicsEllipseItem::QGraphicsEllipseItem(const QRectF &rect, QGraphicsItem *parent) -
8594 : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent) -
8595{ -
8596 setRect(rect);
executed (the execution status of this line is deduced): setRect(rect);
-
8597}
executed: }
Execution Count:17
17
8598 -
8599/*! -
8600 \fn QGraphicsEllipseItem::QGraphicsEllipseItem(qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parent) -
8601 \since 4.3 -
8602 -
8603 Constructs a QGraphicsEllipseItem using the rectangle defined by (\a x, \a -
8604 y) and the given \a width and \a height, as the default rectangle. \a -
8605 parent is passed to QAbstractGraphicsShapeItem's constructor. -
8606 -
8607 \sa QGraphicsScene::addItem() -
8608*/ -
8609QGraphicsEllipseItem::QGraphicsEllipseItem(qreal x, qreal y, qreal w, qreal h, -
8610 QGraphicsItem *parent) -
8611 : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent) -
8612{ -
8613 setRect(x,y,w,h);
never executed (the execution status of this line is deduced): setRect(x,y,w,h);
-
8614}
never executed: }
0
8615 -
8616 -
8617 -
8618/*! -
8619 Constructs a QGraphicsEllipseItem. \a parent is passed to -
8620 QAbstractGraphicsShapeItem's constructor. -
8621 -
8622 \sa QGraphicsScene::addItem() -
8623*/ -
8624QGraphicsEllipseItem::QGraphicsEllipseItem(QGraphicsItem *parent) -
8625 : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent) -
8626{ -
8627}
never executed: }
0
8628 -
8629/*! -
8630 Destroys the QGraphicsEllipseItem. -
8631*/ -
8632QGraphicsEllipseItem::~QGraphicsEllipseItem() -
8633{ -
8634} -
8635 -
8636/*! -
8637 Returns the item's ellipse geometry as a QRectF. -
8638 -
8639 \sa setRect(), QPainter::drawEllipse() -
8640*/ -
8641QRectF QGraphicsEllipseItem::rect() const -
8642{ -
8643 Q_D(const QGraphicsEllipseItem);
never executed (the execution status of this line is deduced): const QGraphicsEllipseItemPrivate * const d = d_func();
-
8644 return d->rect;
never executed: return d->rect;
0
8645} -
8646 -
8647/*! -
8648 Sets the item's ellipse geometry to \a rect. The rectangle's left edge -
8649 defines the left edge of the ellipse, and the rectangle's top edge -
8650 describes the top of the ellipse. The height and width of the rectangle -
8651 describe the height and width of the ellipse. -
8652 -
8653 \sa rect(), QPainter::drawEllipse() -
8654*/ -
8655void QGraphicsEllipseItem::setRect(const QRectF &rect) -
8656{ -
8657 Q_D(QGraphicsEllipseItem);
executed (the execution status of this line is deduced): QGraphicsEllipseItemPrivate * const d = d_func();
-
8658 if (d->rect == rect)
partially evaluated: d->rect == rect
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
0-17
8659 return;
never executed: return;
0
8660 prepareGeometryChange();
executed (the execution status of this line is deduced): prepareGeometryChange();
-
8661 d->rect = rect;
executed (the execution status of this line is deduced): d->rect = rect;
-
8662 d->boundingRect = QRectF();
executed (the execution status of this line is deduced): d->boundingRect = QRectF();
-
8663 update();
executed (the execution status of this line is deduced): update();
-
8664}
executed: }
Execution Count:17
17
8665 -
8666/*! -
8667 Returns the start angle for an ellipse segment in 16ths of a degree. This -
8668 angle is used together with spanAngle() for representing an ellipse -
8669 segment (a pie). By default, the start angle is 0. -
8670 -
8671 \sa setStartAngle(), spanAngle() -
8672*/ -
8673int QGraphicsEllipseItem::startAngle() const -
8674{ -
8675 Q_D(const QGraphicsEllipseItem);
never executed (the execution status of this line is deduced): const QGraphicsEllipseItemPrivate * const d = d_func();
-
8676 return d->startAngle;
never executed: return d->startAngle;
0
8677} -
8678 -
8679/*! -
8680 Sets the start angle for an ellipse segment to \a angle, which is in 16ths -
8681 of a degree. This angle is used together with spanAngle() for representing -
8682 an ellipse segment (a pie). By default, the start angle is 0. -
8683 -
8684 \sa startAngle(), setSpanAngle(), QPainter::drawPie() -
8685*/ -
8686void QGraphicsEllipseItem::setStartAngle(int angle) -
8687{ -
8688 Q_D(QGraphicsEllipseItem);
never executed (the execution status of this line is deduced): QGraphicsEllipseItemPrivate * const d = d_func();
-
8689 if (angle != d->startAngle) {
never evaluated: angle != d->startAngle
0
8690 prepareGeometryChange();
never executed (the execution status of this line is deduced): prepareGeometryChange();
-
8691 d->boundingRect = QRectF();
never executed (the execution status of this line is deduced): d->boundingRect = QRectF();
-
8692 d->startAngle = angle;
never executed (the execution status of this line is deduced): d->startAngle = angle;
-
8693 update();
never executed (the execution status of this line is deduced): update();
-
8694 }
never executed: }
0
8695}
never executed: }
0
8696 -
8697/*! -
8698 Returns the span angle of an ellipse segment in 16ths of a degree. This -
8699 angle is used together with startAngle() for representing an ellipse -
8700 segment (a pie). By default, this function returns 5760 (360 * 16, a full -
8701 ellipse). -
8702 -
8703 \sa setSpanAngle(), startAngle() -
8704*/ -
8705int QGraphicsEllipseItem::spanAngle() const -
8706{ -
8707 Q_D(const QGraphicsEllipseItem);
never executed (the execution status of this line is deduced): const QGraphicsEllipseItemPrivate * const d = d_func();
-
8708 return d->spanAngle;
never executed: return d->spanAngle;
0
8709} -
8710 -
8711/*! -
8712 Sets the span angle for an ellipse segment to \a angle, which is in 16ths -
8713 of a degree. This angle is used together with startAngle() to represent an -
8714 ellipse segment (a pie). By default, the span angle is 5760 (360 * 16, a -
8715 full ellipse). -
8716 -
8717 \sa spanAngle(), setStartAngle(), QPainter::drawPie() -
8718*/ -
8719void QGraphicsEllipseItem::setSpanAngle(int angle) -
8720{ -
8721 Q_D(QGraphicsEllipseItem);
never executed (the execution status of this line is deduced): QGraphicsEllipseItemPrivate * const d = d_func();
-
8722 if (angle != d->spanAngle) {
never evaluated: angle != d->spanAngle
0
8723 prepareGeometryChange();
never executed (the execution status of this line is deduced): prepareGeometryChange();
-
8724 d->boundingRect = QRectF();
never executed (the execution status of this line is deduced): d->boundingRect = QRectF();
-
8725 d->spanAngle = angle;
never executed (the execution status of this line is deduced): d->spanAngle = angle;
-
8726 update();
never executed (the execution status of this line is deduced): update();
-
8727 }
never executed: }
0
8728}
never executed: }
0
8729 -
8730/*! -
8731 \reimp -
8732*/ -
8733QRectF QGraphicsEllipseItem::boundingRect() const -
8734{ -
8735 Q_D(const QGraphicsEllipseItem);
executed (the execution status of this line is deduced): const QGraphicsEllipseItemPrivate * const d = d_func();
-
8736 if (d->boundingRect.isNull()) {
evaluated: d->boundingRect.isNull()
TRUEFALSE
yes
Evaluation Count:17
yes
Evaluation Count:3984
17-3984
8737 qreal pw = pen().style() == Qt::NoPen ? qreal(0) : pen().widthF();
partially evaluated: pen().style() == Qt::NoPen
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
0-17
8738 if (pw == 0.0 && d->spanAngle == 360 * 16)
partially evaluated: pw == 0.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
never evaluated: d->spanAngle == 360 * 16
0-17
8739 d->boundingRect = d->rect;
never executed: d->boundingRect = d->rect;
0
8740 else -
8741 d->boundingRect = shape().controlPointRect();
executed: d->boundingRect = shape().controlPointRect();
Execution Count:17
17
8742 } -
8743 return d->boundingRect;
executed: return d->boundingRect;
Execution Count:4001
4001
8744} -
8745 -
8746/*! -
8747 \reimp -
8748*/ -
8749QPainterPath QGraphicsEllipseItem::shape() const -
8750{ -
8751 Q_D(const QGraphicsEllipseItem);
executed (the execution status of this line is deduced): const QGraphicsEllipseItemPrivate * const d = d_func();
-
8752 QPainterPath path;
executed (the execution status of this line is deduced): QPainterPath path;
-
8753 if (d->rect.isNull())
partially evaluated: d->rect.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:43
0-43
8754 return path;
never executed: return path;
0
8755 if (d->spanAngle != 360 * 16) {
partially evaluated: d->spanAngle != 360 * 16
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:43
0-43
8756 path.moveTo(d->rect.center());
never executed (the execution status of this line is deduced): path.moveTo(d->rect.center());
-
8757 path.arcTo(d->rect, d->startAngle / 16.0, d->spanAngle / 16.0);
never executed (the execution status of this line is deduced): path.arcTo(d->rect, d->startAngle / 16.0, d->spanAngle / 16.0);
-
8758 } else {
never executed: }
0
8759 path.addEllipse(d->rect);
executed (the execution status of this line is deduced): path.addEllipse(d->rect);
-
8760 }
executed: }
Execution Count:43
43
8761 -
8762 return qt_graphicsItem_shapeFromPath(path, d->pen);
executed: return qt_graphicsItem_shapeFromPath(path, d->pen);
Execution Count:43
43
8763} -
8764 -
8765/*! -
8766 \reimp -
8767*/ -
8768bool QGraphicsEllipseItem::contains(const QPointF &point) const -
8769{ -
8770 return QAbstractGraphicsShapeItem::contains(point);
never executed: return QAbstractGraphicsShapeItem::contains(point);
0
8771} -
8772 -
8773/*! -
8774 \reimp -
8775*/ -
8776void QGraphicsEllipseItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, -
8777 QWidget *widget) -
8778{ -
8779 Q_D(QGraphicsEllipseItem);
executed (the execution status of this line is deduced): QGraphicsEllipseItemPrivate * const d = d_func();
-
8780 Q_UNUSED(widget);
executed (the execution status of this line is deduced): (void)widget;;
-
8781 painter->setPen(d->pen);
executed (the execution status of this line is deduced): painter->setPen(d->pen);
-
8782 painter->setBrush(d->brush);
executed (the execution status of this line is deduced): painter->setBrush(d->brush);
-
8783 if ((d->spanAngle != 0) && (qAbs(d->spanAngle) % (360 * 16) == 0))
partially evaluated: (d->spanAngle != 0)
TRUEFALSE
yes
Evaluation Count:1037
no
Evaluation Count:0
partially evaluated: (qAbs(d->spanAngle) % (360 * 16) == 0)
TRUEFALSE
yes
Evaluation Count:1037
no
Evaluation Count:0
0-1037
8784 painter->drawEllipse(d->rect);
executed: painter->drawEllipse(d->rect);
Execution Count:1037
1037
8785 else -
8786 painter->drawPie(d->rect, d->startAngle, d->spanAngle);
never executed: painter->drawPie(d->rect, d->startAngle, d->spanAngle);
0
8787 -
8788 if (option->state & QStyle::State_Selected)
partially evaluated: option->state & QStyle::State_Selected
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1037
0-1037
8789 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
8790}
executed: }
Execution Count:1037
1037
8791 -
8792/*! -
8793 \reimp -
8794*/ -
8795bool QGraphicsEllipseItem::isObscuredBy(const QGraphicsItem *item) const -
8796{ -
8797 return QAbstractGraphicsShapeItem::isObscuredBy(item);
never executed: return QAbstractGraphicsShapeItem::isObscuredBy(item);
0
8798} -
8799 -
8800/*! -
8801 \reimp -
8802*/ -
8803QPainterPath QGraphicsEllipseItem::opaqueArea() const -
8804{ -
8805 return QAbstractGraphicsShapeItem::opaqueArea();
never executed: return QAbstractGraphicsShapeItem::opaqueArea();
0
8806} -
8807 -
8808/*! -
8809 \reimp -
8810*/ -
8811int QGraphicsEllipseItem::type() const -
8812{ -
8813 return Type;
never executed: return Type;
0
8814} -
8815 -
8816 -
8817/*! -
8818 \internal -
8819*/ -
8820bool QGraphicsEllipseItem::supportsExtension(Extension extension) const -
8821{ -
8822 Q_UNUSED(extension);
never executed (the execution status of this line is deduced): (void)extension;;
-
8823 return false;
never executed: return false;
0
8824} -
8825 -
8826/*! -
8827 \internal -
8828*/ -
8829void QGraphicsEllipseItem::setExtension(Extension extension, const QVariant &variant) -
8830{ -
8831 Q_UNUSED(extension);
never executed (the execution status of this line is deduced): (void)extension;;
-
8832 Q_UNUSED(variant);
never executed (the execution status of this line is deduced): (void)variant;;
-
8833}
never executed: }
0
8834 -
8835/*! -
8836 \internal -
8837*/ -
8838QVariant QGraphicsEllipseItem::extension(const QVariant &variant) const -
8839{ -
8840 Q_UNUSED(variant);
never executed (the execution status of this line is deduced): (void)variant;;
-
8841 return QVariant();
never executed: return QVariant();
0
8842} -
8843 -
8844/*! -
8845 \class QGraphicsPolygonItem -
8846 \brief The QGraphicsPolygonItem class provides a polygon item that you -
8847 can add to a QGraphicsScene. -
8848 \since 4.2 -
8849 \ingroup graphicsview-api -
8850 \inmodule QtWidgets -
8851 -
8852 To set the item's polygon, pass a QPolygonF to -
8853 QGraphicsPolygonItem's constructor, or call the setPolygon() -
8854 function. The polygon() function returns the current polygon. -
8855 -
8856 \image graphicsview-polygonitem.png -
8857 -
8858 QGraphicsPolygonItem uses the polygon and the pen width to provide -
8859 a reasonable implementation of boundingRect(), shape(), and -
8860 contains(). The paint() function draws the polygon using the -
8861 item's associated pen and brush, which you can set by calling the -
8862 setPen() and setBrush() functions. -
8863 -
8864 \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, -
8865 QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics -
8866 View Framework} -
8867*/ -
8868 -
8869class QGraphicsPolygonItemPrivate : public QAbstractGraphicsShapeItemPrivate -
8870{ -
8871 Q_DECLARE_PUBLIC(QGraphicsPolygonItem) -
8872public: -
8873 inline QGraphicsPolygonItemPrivate() -
8874 : fillRule(Qt::OddEvenFill) -
8875 { }
executed: }
Execution Count:15
15
8876 -
8877 QPolygonF polygon; -
8878 Qt::FillRule fillRule; -
8879}; -
8880 -
8881/*! -
8882 Constructs a QGraphicsPolygonItem with \a polygon as the default -
8883 polygon. \a parent is passed to QAbstractGraphicsShapeItem's constructor. -
8884 -
8885 \sa QGraphicsScene::addItem() -
8886*/ -
8887QGraphicsPolygonItem::QGraphicsPolygonItem(const QPolygonF &polygon, QGraphicsItem *parent) -
8888 : QAbstractGraphicsShapeItem(*new QGraphicsPolygonItemPrivate, parent) -
8889{ -
8890 setPolygon(polygon);
executed (the execution status of this line is deduced): setPolygon(polygon);
-
8891}
executed: }
Execution Count:8
8
8892 -
8893/*! -
8894 Constructs a QGraphicsPolygonItem. \a parent is passed to -
8895 QAbstractGraphicsShapeItem's constructor. -
8896 -
8897 \sa QGraphicsScene::addItem() -
8898*/ -
8899QGraphicsPolygonItem::QGraphicsPolygonItem(QGraphicsItem *parent) -
8900 : QAbstractGraphicsShapeItem(*new QGraphicsPolygonItemPrivate, parent) -
8901{ -
8902}
executed: }
Execution Count:7
7
8903 -
8904/*! -
8905 Destroys the QGraphicsPolygonItem. -
8906*/ -
8907QGraphicsPolygonItem::~QGraphicsPolygonItem() -
8908{ -
8909} -
8910 -
8911/*! -
8912 Returns the item's polygon, or an empty polygon if no polygon -
8913 has been set. -
8914 -
8915 \sa setPolygon() -
8916*/ -
8917QPolygonF QGraphicsPolygonItem::polygon() const -
8918{ -
8919 Q_D(const QGraphicsPolygonItem);
executed (the execution status of this line is deduced): const QGraphicsPolygonItemPrivate * const d = d_func();
-
8920 return d->polygon;
executed: return d->polygon;
Execution Count:3
3
8921} -
8922 -
8923/*! -
8924 Sets the item's polygon to be the given \a polygon. -
8925 -
8926 \sa polygon() -
8927*/ -
8928void QGraphicsPolygonItem::setPolygon(const QPolygonF &polygon) -
8929{ -
8930 Q_D(QGraphicsPolygonItem);
executed (the execution status of this line is deduced): QGraphicsPolygonItemPrivate * const d = d_func();
-
8931 if (d->polygon == polygon)
evaluated: d->polygon == polygon
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:2
2-9
8932 return;
executed: return;
Execution Count:9
9
8933 prepareGeometryChange();
executed (the execution status of this line is deduced): prepareGeometryChange();
-
8934 d->polygon = polygon;
executed (the execution status of this line is deduced): d->polygon = polygon;
-
8935 d->boundingRect = QRectF();
executed (the execution status of this line is deduced): d->boundingRect = QRectF();
-
8936 update();
executed (the execution status of this line is deduced): update();
-
8937}
executed: }
Execution Count:2
2
8938 -
8939/*! -
8940 Returns the fill rule of the polygon. The default fill rule is -
8941 Qt::OddEvenFill. -
8942 -
8943 \sa setFillRule(), QPainterPath::fillRule(), QPainter::drawPolygon() -
8944*/ -
8945Qt::FillRule QGraphicsPolygonItem::fillRule() const -
8946{ -
8947 Q_D(const QGraphicsPolygonItem);
executed (the execution status of this line is deduced): const QGraphicsPolygonItemPrivate * const d = d_func();
-
8948 return d->fillRule;
executed: return d->fillRule;
Execution Count:3
3
8949} -
8950 -
8951/*! -
8952 Sets the fill rule of the polygon to \a rule. The default fill rule is -
8953 Qt::OddEvenFill. -
8954 -
8955 \sa fillRule(), QPainterPath::fillRule(), QPainter::drawPolygon() -
8956*/ -
8957void QGraphicsPolygonItem::setFillRule(Qt::FillRule rule) -
8958{ -
8959 Q_D(QGraphicsPolygonItem);
executed (the execution status of this line is deduced): QGraphicsPolygonItemPrivate * const d = d_func();
-
8960 if (rule != d->fillRule) {
evaluated: rule != d->fillRule
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
8961 d->fillRule = rule;
executed (the execution status of this line is deduced): d->fillRule = rule;
-
8962 update();
executed (the execution status of this line is deduced): update();
-
8963 }
executed: }
Execution Count:1
1
8964}
executed: }
Execution Count:3
3
8965 -
8966/*! -
8967 \reimp -
8968*/ -
8969QRectF QGraphicsPolygonItem::boundingRect() const -
8970{ -
8971 Q_D(const QGraphicsPolygonItem);
executed (the execution status of this line is deduced): const QGraphicsPolygonItemPrivate * const d = d_func();
-
8972 if (d->boundingRect.isNull()) {
partially evaluated: d->boundingRect.isNull()
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
8973 qreal pw = pen().style() == Qt::NoPen ? qreal(0) : pen().widthF();
partially evaluated: pen().style() == Qt::NoPen
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:3
0-3
8974 if (pw == 0.0)
evaluated: pw == 0.0
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:1
1-2
8975 d->boundingRect = d->polygon.boundingRect();
executed: d->boundingRect = d->polygon.boundingRect();
Execution Count:2
2
8976 else -
8977 d->boundingRect = shape().controlPointRect();
executed: d->boundingRect = shape().controlPointRect();
Execution Count:1
1
8978 } -
8979 return d->boundingRect;
executed: return d->boundingRect;
Execution Count:3
3
8980} -
8981 -
8982/*! -
8983 \reimp -
8984*/ -
8985QPainterPath QGraphicsPolygonItem::shape() const -
8986{ -
8987 Q_D(const QGraphicsPolygonItem);
executed (the execution status of this line is deduced): const QGraphicsPolygonItemPrivate * const d = d_func();
-
8988 QPainterPath path;
executed (the execution status of this line is deduced): QPainterPath path;
-
8989 path.addPolygon(d->polygon);
executed (the execution status of this line is deduced): path.addPolygon(d->polygon);
-
8990 return qt_graphicsItem_shapeFromPath(path, d->pen);
executed: return qt_graphicsItem_shapeFromPath(path, d->pen);
Execution Count:5
5
8991} -
8992 -
8993/*! -
8994 \reimp -
8995*/ -
8996bool QGraphicsPolygonItem::contains(const QPointF &point) const -
8997{ -
8998 return QAbstractGraphicsShapeItem::contains(point);
executed: return QAbstractGraphicsShapeItem::contains(point);
Execution Count:2
2
8999} -
9000 -
9001/*! -
9002 \reimp -
9003*/ -
9004void QGraphicsPolygonItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -
9005{ -
9006 Q_D(QGraphicsPolygonItem);
never executed (the execution status of this line is deduced): QGraphicsPolygonItemPrivate * const d = d_func();
-
9007 Q_UNUSED(widget);
never executed (the execution status of this line is deduced): (void)widget;;
-
9008 painter->setPen(d->pen);
never executed (the execution status of this line is deduced): painter->setPen(d->pen);
-
9009 painter->setBrush(d->brush);
never executed (the execution status of this line is deduced): painter->setBrush(d->brush);
-
9010 painter->drawPolygon(d->polygon, d->fillRule);
never executed (the execution status of this line is deduced): painter->drawPolygon(d->polygon, d->fillRule);
-
9011 -
9012 if (option->state & QStyle::State_Selected)
never evaluated: option->state & QStyle::State_Selected
0
9013 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
9014}
never executed: }
0
9015 -
9016/*! -
9017 \reimp -
9018*/ -
9019bool QGraphicsPolygonItem::isObscuredBy(const QGraphicsItem *item) const -
9020{ -
9021 return QAbstractGraphicsShapeItem::isObscuredBy(item);
executed: return QAbstractGraphicsShapeItem::isObscuredBy(item);
Execution Count:2
2
9022} -
9023 -
9024/*! -
9025 \reimp -
9026*/ -
9027QPainterPath QGraphicsPolygonItem::opaqueArea() const -
9028{ -
9029 return QAbstractGraphicsShapeItem::opaqueArea();
executed: return QAbstractGraphicsShapeItem::opaqueArea();
Execution Count:2
2
9030} -
9031 -
9032/*! -
9033 \reimp -
9034*/ -
9035int QGraphicsPolygonItem::type() const -
9036{ -
9037 return Type;
executed: return Type;
Execution Count:1
1
9038} -
9039 -
9040/*! -
9041 \internal -
9042*/ -
9043bool QGraphicsPolygonItem::supportsExtension(Extension extension) const -
9044{ -
9045 Q_UNUSED(extension);
executed (the execution status of this line is deduced): (void)extension;;
-
9046 return false;
executed: return false;
Execution Count:2
2
9047} -
9048 -
9049/*! -
9050 \internal -
9051*/ -
9052void QGraphicsPolygonItem::setExtension(Extension extension, const QVariant &variant) -
9053{ -
9054 Q_UNUSED(extension);
executed (the execution status of this line is deduced): (void)extension;;
-
9055 Q_UNUSED(variant);
executed (the execution status of this line is deduced): (void)variant;;
-
9056}
executed: }
Execution Count:2
2
9057 -
9058/*! -
9059 \internal -
9060*/ -
9061QVariant QGraphicsPolygonItem::extension(const QVariant &variant) const -
9062{ -
9063 Q_UNUSED(variant);
executed (the execution status of this line is deduced): (void)variant;;
-
9064 return QVariant();
executed: return QVariant();
Execution Count:2
2
9065} -
9066 -
9067/*! -
9068 \class QGraphicsLineItem -
9069 \brief The QGraphicsLineItem class provides a line item that you can add to a -
9070 QGraphicsScene. -
9071 \since 4.2 -
9072 \ingroup graphicsview-api -
9073 \inmodule QtWidgets -
9074 -
9075 To set the item's line, pass a QLineF to QGraphicsLineItem's -
9076 constructor, or call the setLine() function. The line() function -
9077 returns the current line. By default the line is black with a -
9078 width of 0, but you can change this by calling setPen(). -
9079 -
9080 \image graphicsview-lineitem.png -
9081 -
9082 QGraphicsLineItem uses the line and the pen width to provide a reasonable -
9083 implementation of boundingRect(), shape(), and contains(). The paint() -
9084 function draws the line using the item's associated pen. -
9085 -
9086 \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, -
9087 QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsPixmapItem, -
9088 {Graphics View Framework} -
9089*/ -
9090 -
9091class QGraphicsLineItemPrivate : public QGraphicsItemPrivate -
9092{ -
9093 Q_DECLARE_PUBLIC(QGraphicsLineItem) -
9094public: -
9095 QLineF line; -
9096 QPen pen; -
9097}; -
9098 -
9099/*! -
9100 Constructs a QGraphicsLineItem, using \a line as the default line. \a -
9101 parent is passed to QGraphicsItem's constructor. -
9102 -
9103 \sa QGraphicsScene::addItem() -
9104*/ -
9105QGraphicsLineItem::QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent) -
9106 : QGraphicsItem(*new QGraphicsLineItemPrivate, parent) -
9107{ -
9108 setLine(line);
executed (the execution status of this line is deduced): setLine(line);
-
9109}
executed: }
Execution Count:4
4
9110 -
9111/*! -
9112 Constructs a QGraphicsLineItem, using the line between (\a x1, \a y1) and -
9113 (\a x2, \a y2) as the default line. \a parent is passed to -
9114 QGraphicsItem's constructor. -
9115 -
9116 \sa QGraphicsScene::addItem() -
9117*/ -
9118QGraphicsLineItem::QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent) -
9119 : QGraphicsItem(*new QGraphicsLineItemPrivate, parent) -
9120{ -
9121 setLine(x1, y1, x2, y2);
never executed (the execution status of this line is deduced): setLine(x1, y1, x2, y2);
-
9122}
never executed: }
0
9123 -
9124 -
9125 -
9126/*! -
9127 Constructs a QGraphicsLineItem. \a parent is passed to QGraphicsItem's -
9128 constructor. -
9129 -
9130 \sa QGraphicsScene::addItem() -
9131*/ -
9132QGraphicsLineItem::QGraphicsLineItem(QGraphicsItem *parent) -
9133 : QGraphicsItem(*new QGraphicsLineItemPrivate, parent) -
9134{ -
9135}
never executed: }
0
9136 -
9137/*! -
9138 Destroys the QGraphicsLineItem. -
9139*/ -
9140QGraphicsLineItem::~QGraphicsLineItem() -
9141{ -
9142} -
9143 -
9144/*! -
9145 Returns the item's pen, or a black solid 0-width pen if no pen has -
9146 been set. -
9147 -
9148 \sa setPen() -
9149*/ -
9150QPen QGraphicsLineItem::pen() const -
9151{ -
9152 Q_D(const QGraphicsLineItem);
never executed (the execution status of this line is deduced): const QGraphicsLineItemPrivate * const d = d_func();
-
9153 return d->pen;
never executed: return d->pen;
0
9154} -
9155 -
9156/*! -
9157 Sets the item's pen to \a pen. If no pen is set, the line will be painted -
9158 using a black solid 0-width pen. -
9159 -
9160 \sa pen() -
9161*/ -
9162void QGraphicsLineItem::setPen(const QPen &pen) -
9163{ -
9164 Q_D(QGraphicsLineItem);
executed (the execution status of this line is deduced): QGraphicsLineItemPrivate * const d = d_func();
-
9165 if (d->pen == pen)
partially evaluated: d->pen == pen
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
9166 return;
never executed: return;
0
9167 prepareGeometryChange();
executed (the execution status of this line is deduced): prepareGeometryChange();
-
9168 d->pen = pen;
executed (the execution status of this line is deduced): d->pen = pen;
-
9169 update();
executed (the execution status of this line is deduced): update();
-
9170}
executed: }
Execution Count:4
4
9171 -
9172/*! -
9173 Returns the item's line, or a null line if no line has been set. -
9174 -
9175 \sa setLine() -
9176*/ -
9177QLineF QGraphicsLineItem::line() const -
9178{ -
9179 Q_D(const QGraphicsLineItem);
never executed (the execution status of this line is deduced): const QGraphicsLineItemPrivate * const d = d_func();
-
9180 return d->line;
never executed: return d->line;
0
9181} -
9182 -
9183/*! -
9184 Sets the item's line to be the given \a line. -
9185 -
9186 \sa line() -
9187*/ -
9188void QGraphicsLineItem::setLine(const QLineF &line) -
9189{ -
9190 Q_D(QGraphicsLineItem);
executed (the execution status of this line is deduced): QGraphicsLineItemPrivate * const d = d_func();
-
9191 if (d->line == line)
partially evaluated: d->line == line
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:4
0-4
9192 return;
never executed: return;
0
9193 prepareGeometryChange();
executed (the execution status of this line is deduced): prepareGeometryChange();
-
9194 d->line = line;
executed (the execution status of this line is deduced): d->line = line;
-
9195 update();
executed (the execution status of this line is deduced): update();
-
9196}
executed: }
Execution Count:4
4
9197 -
9198/*! -
9199 \fn void QGraphicsLineItem::setLine(qreal x1, qreal y1, qreal x2, qreal y2) -
9200 \overload -
9201 -
9202 Sets the item's line to be the line between (\a x1, \a y1) and (\a -
9203 x2, \a y2). -
9204 -
9205 This is the same as calling \c {setLine(QLineF(x1, y1, x2, y2))}. -
9206*/ -
9207 -
9208/*! -
9209 \reimp -
9210*/ -
9211QRectF QGraphicsLineItem::boundingRect() const -
9212{ -
9213 Q_D(const QGraphicsLineItem);
executed (the execution status of this line is deduced): const QGraphicsLineItemPrivate * const d = d_func();
-
9214 if (d->pen.widthF() == 0.0) {
partially evaluated: d->pen.widthF() == 0.0
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1703
0-1703
9215 const qreal x1 = d->line.p1().x();
never executed (the execution status of this line is deduced): const qreal x1 = d->line.p1().x();
-
9216 const qreal x2 = d->line.p2().x();
never executed (the execution status of this line is deduced): const qreal x2 = d->line.p2().x();
-
9217 const qreal y1 = d->line.p1().y();
never executed (the execution status of this line is deduced): const qreal y1 = d->line.p1().y();
-
9218 const qreal y2 = d->line.p2().y();
never executed (the execution status of this line is deduced): const qreal y2 = d->line.p2().y();
-
9219 qreal lx = qMin(x1, x2);
never executed (the execution status of this line is deduced): qreal lx = qMin(x1, x2);
-
9220 qreal rx = qMax(x1, x2);
never executed (the execution status of this line is deduced): qreal rx = qMax(x1, x2);
-
9221 qreal ty = qMin(y1, y2);
never executed (the execution status of this line is deduced): qreal ty = qMin(y1, y2);
-
9222 qreal by = qMax(y1, y2);
never executed (the execution status of this line is deduced): qreal by = qMax(y1, y2);
-
9223 return QRectF(lx, ty, rx - lx, by - ty);
never executed: return QRectF(lx, ty, rx - lx, by - ty);
0
9224 } -
9225 return shape().controlPointRect();
executed: return shape().controlPointRect();
Execution Count:1703
1703
9226} -
9227 -
9228/*! -
9229 \reimp -
9230*/ -
9231QPainterPath QGraphicsLineItem::shape() const -
9232{ -
9233 Q_D(const QGraphicsLineItem);
executed (the execution status of this line is deduced): const QGraphicsLineItemPrivate * const d = d_func();
-
9234 QPainterPath path;
executed (the execution status of this line is deduced): QPainterPath path;
-
9235 if (d->line == QLineF())
partially evaluated: d->line == QLineF()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1703
0-1703
9236 return path;
never executed: return path;
0
9237 -
9238 path.moveTo(d->line.p1());
executed (the execution status of this line is deduced): path.moveTo(d->line.p1());
-
9239 path.lineTo(d->line.p2());
executed (the execution status of this line is deduced): path.lineTo(d->line.p2());
-
9240 return qt_graphicsItem_shapeFromPath(path, d->pen);
executed: return qt_graphicsItem_shapeFromPath(path, d->pen);
Execution Count:1703
1703
9241} -
9242 -
9243/*! -
9244 \reimp -
9245*/ -
9246bool QGraphicsLineItem::contains(const QPointF &point) const -
9247{ -
9248 return QGraphicsItem::contains(point);
never executed: return QGraphicsItem::contains(point);
0
9249} -
9250 -
9251/*! -
9252 \reimp -
9253*/ -
9254void QGraphicsLineItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -
9255{ -
9256 Q_D(QGraphicsLineItem);
executed (the execution status of this line is deduced): QGraphicsLineItemPrivate * const d = d_func();
-
9257 Q_UNUSED(widget);
executed (the execution status of this line is deduced): (void)widget;;
-
9258 painter->setPen(d->pen);
executed (the execution status of this line is deduced): painter->setPen(d->pen);
-
9259 painter->drawLine(d->line);
executed (the execution status of this line is deduced): painter->drawLine(d->line);
-
9260 -
9261 if (option->state & QStyle::State_Selected)
partially evaluated: option->state & QStyle::State_Selected
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:764
0-764
9262 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
9263}
executed: }
Execution Count:764
764
9264 -
9265/*! -
9266 \reimp -
9267*/ -
9268bool QGraphicsLineItem::isObscuredBy(const QGraphicsItem *item) const -
9269{ -
9270 return QGraphicsItem::isObscuredBy(item);
never executed: return QGraphicsItem::isObscuredBy(item);
0
9271} -
9272 -
9273/*! -
9274 \reimp -
9275*/ -
9276QPainterPath QGraphicsLineItem::opaqueArea() const -
9277{ -
9278 return QGraphicsItem::opaqueArea();
never executed: return QGraphicsItem::opaqueArea();
0
9279} -
9280 -
9281/*! -
9282 \reimp -
9283*/ -
9284int QGraphicsLineItem::type() const -
9285{ -
9286 return Type;
never executed: return Type;
0
9287} -
9288 -
9289/*! -
9290 \internal -
9291*/ -
9292bool QGraphicsLineItem::supportsExtension(Extension extension) const -
9293{ -
9294 Q_UNUSED(extension);
never executed (the execution status of this line is deduced): (void)extension;;
-
9295 return false;
never executed: return false;
0
9296} -
9297 -
9298/*! -
9299 \internal -
9300*/ -
9301void QGraphicsLineItem::setExtension(Extension extension, const QVariant &variant) -
9302{ -
9303 Q_UNUSED(extension);
never executed (the execution status of this line is deduced): (void)extension;;
-
9304 Q_UNUSED(variant);
never executed (the execution status of this line is deduced): (void)variant;;
-
9305}
never executed: }
0
9306 -
9307/*! -
9308 \internal -
9309*/ -
9310QVariant QGraphicsLineItem::extension(const QVariant &variant) const -
9311{ -
9312 Q_UNUSED(variant);
never executed (the execution status of this line is deduced): (void)variant;;
-
9313 return QVariant();
never executed: return QVariant();
0
9314} -
9315 -
9316/*! -
9317 \class QGraphicsPixmapItem -
9318 \brief The QGraphicsPixmapItem class provides a pixmap item that you can add to -
9319 a QGraphicsScene. -
9320 \since 4.2 -
9321 \ingroup graphicsview-api -
9322 \inmodule QtWidgets -
9323 -
9324 To set the item's pixmap, pass a QPixmap to QGraphicsPixmapItem's -
9325 constructor, or call the setPixmap() function. The pixmap() -
9326 function returns the current pixmap. -
9327 -
9328 QGraphicsPixmapItem uses pixmap's optional alpha mask to provide a -
9329 reasonable implementation of boundingRect(), shape(), and contains(). -
9330 -
9331 \image graphicsview-pixmapitem.png -
9332 -
9333 The pixmap is drawn at the item's (0, 0) coordinate, as returned by -
9334 offset(). You can change the drawing offset by calling setOffset(). -
9335 -
9336 You can set the pixmap's transformation mode by calling -
9337 setTransformationMode(). By default, Qt::FastTransformation is used, which -
9338 provides fast, non-smooth scaling. Qt::SmoothTransformation enables -
9339 QPainter::SmoothPixmapTransform on the painter, and the quality depends on -
9340 the platform and viewport. The result is usually not as good as calling -
9341 QPixmap::scale() directly. Call transformationMode() to get the current -
9342 transformation mode for the item. -
9343 -
9344 \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, -
9345 QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsLineItem, -
9346 {Graphics View Framework} -
9347*/ -
9348 -
9349/*! -
9350 \enum QGraphicsPixmapItem::ShapeMode -
9351 -
9352 This enum describes how QGraphicsPixmapItem calculates its shape and -
9353 opaque area. -
9354 -
9355 The default value is MaskShape. -
9356 -
9357 \value MaskShape The shape is determined by calling QPixmap::mask(). -
9358 This shape includes only the opaque pixels of the pixmap. -
9359 Because the shape is more complex, however, it can be slower than the other modes, -
9360 and uses more memory. -
9361 -
9362 \value BoundingRectShape The shape is determined by tracing the outline of -
9363 the pixmap. This is the fastest shape mode, but it does not take into account -
9364 any transparent areas on the pixmap. -
9365 -
9366 \value HeuristicMaskShape The shape is determine by calling -
9367 QPixmap::createHeuristicMask(). The performance and memory consumption -
9368 is similar to MaskShape. -
9369*/ -
9370extern QPainterPath qt_regionToPath(const QRegion &region); -
9371 -
9372class QGraphicsPixmapItemPrivate : public QGraphicsItemPrivate -
9373{ -
9374 Q_DECLARE_PUBLIC(QGraphicsPixmapItem) -
9375public: -
9376 QGraphicsPixmapItemPrivate() -
9377 : transformationMode(Qt::FastTransformation), -
9378 shapeMode(QGraphicsPixmapItem::MaskShape), -
9379 hasShape(false) -
9380 {}
executed: }
Execution Count:45
45
9381 -
9382 QPixmap pixmap; -
9383 Qt::TransformationMode transformationMode; -
9384 QPointF offset; -
9385 QGraphicsPixmapItem::ShapeMode shapeMode; -
9386 QPainterPath shape; -
9387 bool hasShape; -
9388 -
9389 void updateShape() -
9390 { -
9391 shape = QPainterPath();
executed (the execution status of this line is deduced): shape = QPainterPath();
-
9392 switch (shapeMode) { -
9393 case QGraphicsPixmapItem::MaskShape: { -
9394 QBitmap mask = pixmap.mask();
executed (the execution status of this line is deduced): QBitmap mask = pixmap.mask();
-
9395 if (!mask.isNull()) {
partially evaluated: !mask.isNull()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:15
0-15
9396 shape = qt_regionToPath(QRegion(mask).translated(offset.toPoint()));
never executed (the execution status of this line is deduced): shape = qt_regionToPath(QRegion(mask).translated(offset.toPoint()));
-
9397 break;
never executed: break;
0
9398 } -
9399 // FALL THROUGH -
9400 } -
9401 case QGraphicsPixmapItem::BoundingRectShape:
code before this statement executed: case QGraphicsPixmapItem::BoundingRectShape:
Execution Count:15
15
9402 shape.addRect(QRectF(offset.x(), offset.y(), pixmap.width(), pixmap.height()));
executed (the execution status of this line is deduced): shape.addRect(QRectF(offset.x(), offset.y(), pixmap.width(), pixmap.height()));
-
9403 break;
executed: break;
Execution Count:15
15
9404 case QGraphicsPixmapItem::HeuristicMaskShape: -
9405#ifndef QT_NO_IMAGE_HEURISTIC_MASK -
9406 shape = qt_regionToPath(QRegion(pixmap.createHeuristicMask()).translated(offset.toPoint()));
never executed (the execution status of this line is deduced): shape = qt_regionToPath(QRegion(pixmap.createHeuristicMask()).translated(offset.toPoint()));
-
9407#else -
9408 shape.addRect(QRectF(offset.x(), offset.y(), pixmap.width(), pixmap.height())); -
9409#endif -
9410 break;
never executed: break;
0
9411 } -
9412 }
executed: }
Execution Count:15
15
9413}; -
9414 -
9415/*! -
9416 Constructs a QGraphicsPixmapItem, using \a pixmap as the default pixmap. -
9417 \a parent is passed to QGraphicsItem's constructor. -
9418 -
9419 \sa QGraphicsScene::addItem() -
9420*/ -
9421QGraphicsPixmapItem::QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent) -
9422 : QGraphicsItem(*new QGraphicsPixmapItemPrivate, parent) -
9423{ -
9424 setPixmap(pixmap);
executed (the execution status of this line is deduced): setPixmap(pixmap);
-
9425}
executed: }
Execution Count:37
37
9426 -
9427/*! -
9428 Constructs a QGraphicsPixmapItem. \a parent is passed to QGraphicsItem's -
9429 constructor. -
9430 -
9431 \sa QGraphicsScene::addItem() -
9432*/ -
9433QGraphicsPixmapItem::QGraphicsPixmapItem(QGraphicsItem *parent) -
9434 : QGraphicsItem(*new QGraphicsPixmapItemPrivate, parent) -
9435{ -
9436}
executed: }
Execution Count:8
8
9437 -
9438/*! -
9439 Destroys the QGraphicsPixmapItem. -
9440*/ -
9441QGraphicsPixmapItem::~QGraphicsPixmapItem() -
9442{ -
9443} -
9444 -
9445/*! -
9446 Sets the item's pixmap to \a pixmap. -
9447 -
9448 \sa pixmap() -
9449*/ -
9450void QGraphicsPixmapItem::setPixmap(const QPixmap &pixmap) -
9451{ -
9452 Q_D(QGraphicsPixmapItem);
executed (the execution status of this line is deduced): QGraphicsPixmapItemPrivate * const d = d_func();
-
9453 prepareGeometryChange();
executed (the execution status of this line is deduced): prepareGeometryChange();
-
9454 d->pixmap = pixmap;
executed (the execution status of this line is deduced): d->pixmap = pixmap;
-
9455 d->hasShape = false;
executed (the execution status of this line is deduced): d->hasShape = false;
-
9456 update();
executed (the execution status of this line is deduced): update();
-
9457}
executed: }
Execution Count:40
40
9458 -
9459/*! -
9460 Returns the item's pixmap, or an invalid QPixmap if no pixmap has been -
9461 set. -
9462 -
9463 \sa setPixmap() -
9464*/ -
9465QPixmap QGraphicsPixmapItem::pixmap() const -
9466{ -
9467 Q_D(const QGraphicsPixmapItem);
executed (the execution status of this line is deduced): const QGraphicsPixmapItemPrivate * const d = d_func();
-
9468 return d->pixmap;
executed: return d->pixmap;
Execution Count:10
10
9469} -
9470 -
9471/*! -
9472 Returns the transformation mode of the pixmap. The default mode is -
9473 Qt::FastTransformation, which provides quick transformation with no -
9474 smoothing. -
9475 -
9476 \sa setTransformationMode() -
9477*/ -
9478Qt::TransformationMode QGraphicsPixmapItem::transformationMode() const -
9479{ -
9480 Q_D(const QGraphicsPixmapItem);
executed (the execution status of this line is deduced): const QGraphicsPixmapItemPrivate * const d = d_func();
-
9481 return d->transformationMode;
executed: return d->transformationMode;
Execution Count:3
3
9482} -
9483 -
9484/*! -
9485 Sets the pixmap item's transformation mode to \a mode, and toggles an -
9486 update of the item. The default mode is Qt::FastTransformation, which -
9487 provides quick transformation with no smoothing. -
9488 -
9489 Qt::SmoothTransformation enables QPainter::SmoothPixmapTransform on the -
9490 painter, and the quality depends on the platform and viewport. The result -
9491 is usually not as good as calling QPixmap::scale() directly. -
9492 -
9493 \sa transformationMode() -
9494*/ -
9495void QGraphicsPixmapItem::setTransformationMode(Qt::TransformationMode mode) -
9496{ -
9497 Q_D(QGraphicsPixmapItem);
executed (the execution status of this line is deduced): QGraphicsPixmapItemPrivate * const d = d_func();
-
9498 if (mode != d->transformationMode) {
evaluated: mode != d->transformationMode
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:2
1-2
9499 d->transformationMode = mode;
executed (the execution status of this line is deduced): d->transformationMode = mode;
-
9500 update();
executed (the execution status of this line is deduced): update();
-
9501 }
executed: }
Execution Count:1
1
9502}
executed: }
Execution Count:3
3
9503 -
9504/*! -
9505 Returns the pixmap item's \e offset, which defines the point of the -
9506 top-left corner of the pixmap, in local coordinates. -
9507 -
9508 \sa setOffset() -
9509*/ -
9510QPointF QGraphicsPixmapItem::offset() const -
9511{ -
9512 Q_D(const QGraphicsPixmapItem);
executed (the execution status of this line is deduced): const QGraphicsPixmapItemPrivate * const d = d_func();
-
9513 return d->offset;
executed: return d->offset;
Execution Count:4
4
9514} -
9515 -
9516/*! -
9517 Sets the pixmap item's offset to \a offset. QGraphicsPixmapItem will draw -
9518 its pixmap using \a offset for its top-left corner. -
9519 -
9520 \sa offset() -
9521*/ -
9522void QGraphicsPixmapItem::setOffset(const QPointF &offset) -
9523{ -
9524 Q_D(QGraphicsPixmapItem);
executed (the execution status of this line is deduced): QGraphicsPixmapItemPrivate * const d = d_func();
-
9525 if (d->offset == offset)
evaluated: d->offset == offset
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:11
5-11
9526 return;
executed: return;
Execution Count:5
5
9527 prepareGeometryChange();
executed (the execution status of this line is deduced): prepareGeometryChange();
-
9528 d->offset = offset;
executed (the execution status of this line is deduced): d->offset = offset;
-
9529 d->hasShape = false;
executed (the execution status of this line is deduced): d->hasShape = false;
-
9530 update();
executed (the execution status of this line is deduced): update();
-
9531}
executed: }
Execution Count:11
11
9532 -
9533/*! -
9534 \fn void QGraphicsPixmapItem::setOffset(qreal x, qreal y) -
9535 \since 4.3 -
9536 -
9537 This convenience function is equivalent to calling setOffset(QPointF(\a x, \a y)). -
9538*/ -
9539 -
9540/*! -
9541 \reimp -
9542*/ -
9543QRectF QGraphicsPixmapItem::boundingRect() const -
9544{ -
9545 Q_D(const QGraphicsPixmapItem);
executed (the execution status of this line is deduced): const QGraphicsPixmapItemPrivate * const d = d_func();
-
9546 if (d->pixmap.isNull())
evaluated: d->pixmap.isNull()
TRUEFALSE
yes
Evaluation Count:73
yes
Evaluation Count:76
73-76
9547 return QRectF();
executed: return QRectF();
Execution Count:73
73
9548 if (d->flags & ItemIsSelectable) {
partially evaluated: d->flags & ItemIsSelectable
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:76
0-76
9549 qreal pw = 1.0;
never executed (the execution status of this line is deduced): qreal pw = 1.0;
-
9550 return QRectF(d->offset, d->pixmap.size()).adjusted(-pw/2, -pw/2, pw/2, pw/2);
never executed: return QRectF(d->offset, d->pixmap.size()).adjusted(-pw/2, -pw/2, pw/2, pw/2);
0
9551 } else { -
9552 return QRectF(d->offset, d->pixmap.size());
executed: return QRectF(d->offset, d->pixmap.size());
Execution Count:76
76
9553 } -
9554} -
9555 -
9556/*! -
9557 \reimp -
9558*/ -
9559QPainterPath QGraphicsPixmapItem::shape() const -
9560{ -
9561 Q_D(const QGraphicsPixmapItem);
executed (the execution status of this line is deduced): const QGraphicsPixmapItemPrivate * const d = d_func();
-
9562 if (!d->hasShape) {
evaluated: !d->hasShape
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:1
1-15
9563 QGraphicsPixmapItemPrivate *thatD = const_cast<QGraphicsPixmapItemPrivate *>(d);
executed (the execution status of this line is deduced): QGraphicsPixmapItemPrivate *thatD = const_cast<QGraphicsPixmapItemPrivate *>(d);
-
9564 thatD->updateShape();
executed (the execution status of this line is deduced): thatD->updateShape();
-
9565 thatD->hasShape = true;
executed (the execution status of this line is deduced): thatD->hasShape = true;
-
9566 }
executed: }
Execution Count:15
15
9567 return d_func()->shape;
executed: return d_func()->shape;
Execution Count:16
16
9568} -
9569 -
9570/*! -
9571 \reimp -
9572*/ -
9573bool QGraphicsPixmapItem::contains(const QPointF &point) const -
9574{ -
9575 return QGraphicsItem::contains(point);
executed: return QGraphicsItem::contains(point);
Execution Count:6
6
9576} -
9577 -
9578/*! -
9579 \reimp -
9580*/ -
9581void QGraphicsPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, -
9582 QWidget *widget) -
9583{ -
9584 Q_D(QGraphicsPixmapItem);
executed (the execution status of this line is deduced): QGraphicsPixmapItemPrivate * const d = d_func();
-
9585 Q_UNUSED(widget);
executed (the execution status of this line is deduced): (void)widget;;
-
9586 -
9587 painter->setRenderHint(QPainter::SmoothPixmapTransform,
executed (the execution status of this line is deduced): painter->setRenderHint(QPainter::SmoothPixmapTransform,
-
9588 (d->transformationMode == Qt::SmoothTransformation));
executed (the execution status of this line is deduced): (d->transformationMode == Qt::SmoothTransformation));
-
9589 -
9590 painter->drawPixmap(d->offset, d->pixmap);
executed (the execution status of this line is deduced): painter->drawPixmap(d->offset, d->pixmap);
-
9591 -
9592 if (option->state & QStyle::State_Selected)
partially evaluated: option->state & QStyle::State_Selected
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:19
0-19
9593 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
9594}
executed: }
Execution Count:19
19
9595 -
9596/*! -
9597 \reimp -
9598*/ -
9599bool QGraphicsPixmapItem::isObscuredBy(const QGraphicsItem *item) const -
9600{ -
9601 return QGraphicsItem::isObscuredBy(item);
executed: return QGraphicsItem::isObscuredBy(item);
Execution Count:7
7
9602} -
9603 -
9604/*! -
9605 \reimp -
9606*/ -
9607QPainterPath QGraphicsPixmapItem::opaqueArea() const -
9608{ -
9609 return shape();
executed: return shape();
Execution Count:8
8
9610} -
9611 -
9612/*! -
9613 \reimp -
9614*/ -
9615int QGraphicsPixmapItem::type() const -
9616{ -
9617 return Type;
executed: return Type;
Execution Count:6
6
9618} -
9619 -
9620/*! -
9621 Returns the item's shape mode. The shape mode describes how -
9622 QGraphicsPixmapItem calculates its shape. The default mode is MaskShape. -
9623 -
9624 \sa setShapeMode(), ShapeMode -
9625*/ -
9626QGraphicsPixmapItem::ShapeMode QGraphicsPixmapItem::shapeMode() const -
9627{ -
9628 return d_func()->shapeMode;
executed: return d_func()->shapeMode;
Execution Count:4
4
9629} -
9630 -
9631/*! -
9632 Sets the item's shape mode to \a mode. The shape mode describes how -
9633 QGraphicsPixmapItem calculates its shape. The default mode is MaskShape. -
9634 -
9635 \sa shapeMode(), ShapeMode -
9636*/ -
9637void QGraphicsPixmapItem::setShapeMode(ShapeMode mode) -
9638{ -
9639 Q_D(QGraphicsPixmapItem);
executed (the execution status of this line is deduced): QGraphicsPixmapItemPrivate * const d = d_func();
-
9640 if (d->shapeMode == mode)
evaluated: d->shapeMode == mode
TRUEFALSE
yes
Evaluation Count:2
yes
Evaluation Count:2
2
9641 return;
executed: return;
Execution Count:2
2
9642 d->shapeMode = mode;
executed (the execution status of this line is deduced): d->shapeMode = mode;
-
9643 d->hasShape = false;
executed (the execution status of this line is deduced): d->hasShape = false;
-
9644}
executed: }
Execution Count:2
2
9645 -
9646/*! -
9647 \internal -
9648*/ -
9649bool QGraphicsPixmapItem::supportsExtension(Extension extension) const -
9650{ -
9651 Q_UNUSED(extension);
executed (the execution status of this line is deduced): (void)extension;;
-
9652 return false;
executed: return false;
Execution Count:2
2
9653} -
9654 -
9655/*! -
9656 \internal -
9657*/ -
9658void QGraphicsPixmapItem::setExtension(Extension extension, const QVariant &variant) -
9659{ -
9660 Q_UNUSED(extension);
executed (the execution status of this line is deduced): (void)extension;;
-
9661 Q_UNUSED(variant);
executed (the execution status of this line is deduced): (void)variant;;
-
9662}
executed: }
Execution Count:2
2
9663 -
9664/*! -
9665 \internal -
9666*/ -
9667QVariant QGraphicsPixmapItem::extension(const QVariant &variant) const -
9668{ -
9669 Q_UNUSED(variant);
executed (the execution status of this line is deduced): (void)variant;;
-
9670 return QVariant();
executed: return QVariant();
Execution Count:2
2
9671} -
9672 -
9673/*! -
9674 \class QGraphicsTextItem -
9675 \brief The QGraphicsTextItem class provides a text item that you can add to -
9676 a QGraphicsScene to display formatted text. -
9677 \since 4.2 -
9678 \ingroup graphicsview-api -
9679 \inmodule QtWidgets -
9680 -
9681 If you only need to show plain text in an item, consider using QGraphicsSimpleTextItem -
9682 instead. -
9683 -
9684 To set the item's text, pass a QString to QGraphicsTextItem's -
9685 constructor, or call setHtml()/setPlainText(). -
9686 -
9687 QGraphicsTextItem uses the text's formatted size and the associated font -
9688 to provide a reasonable implementation of boundingRect(), shape(), -
9689 and contains(). You can set the font by calling setFont(). -
9690 -
9691 It is possible to make the item editable by setting the Qt::TextEditorInteraction flag -
9692 using setTextInteractionFlags(). -
9693 -
9694 The item's preferred text width can be set using setTextWidth() and obtained -
9695 using textWidth(). -
9696 -
9697 \note In order to align HTML text in the center, the item's text width must be set. -
9698 -
9699 \image graphicsview-textitem.png -
9700 -
9701 \note QGraphicsTextItem accepts \l{QGraphicsItem::acceptHoverEvents()}{hover events} -
9702 by default. You can change this with \l{QGraphicsItem::}{setAcceptHoverEvents()}. -
9703 -
9704 \sa QGraphicsSimpleTextItem, QGraphicsPathItem, QGraphicsRectItem, -
9705 QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem, -
9706 QGraphicsLineItem, {Graphics View Framework} -
9707*/ -
9708 -
9709class QGraphicsTextItemPrivate -
9710{ -
9711public: -
9712 QGraphicsTextItemPrivate() -
9713 : control(0), pageNumber(0), useDefaultImpl(false), tabChangesFocus(false), clickCausedFocus(0) -
9714 { }
executed: }
Execution Count:104
104
9715 -
9716 mutable QWidgetTextControl *control; -
9717 QWidgetTextControl *textControl() const; -
9718 -
9719 inline QPointF controlOffset() const -
9720 { return QPointF(0., pageNumber * control->document()->pageSize().height()); }
executed: return QPointF(0., pageNumber * control->document()->pageSize().height());
Execution Count:638
638
9721 inline void sendControlEvent(QEvent *e) -
9722 { if (control) control->processEvent(e, controlOffset()); }
executed: control->processEvent(e, controlOffset());
Execution Count:1
executed: }
Execution Count:1
partially evaluated: control
TRUEFALSE
yes
Evaluation Count:1
no
Evaluation Count:0
0-1
9723 -
9724 void _q_updateBoundingRect(const QSizeF &); -
9725 void _q_update(QRectF); -
9726 void _q_ensureVisible(QRectF); -
9727 bool _q_mouseOnEdge(QGraphicsSceneMouseEvent *); -
9728 -
9729 QRectF boundingRect; -
9730 int pageNumber; -
9731 bool useDefaultImpl; -
9732 bool tabChangesFocus; -
9733 -
9734 uint clickCausedFocus : 1; -
9735 -
9736 QGraphicsTextItem *qq; -
9737}; -
9738 -
9739 -
9740/*! -
9741 Constructs a QGraphicsTextItem, using \a text as the default plain -
9742 text. \a parent is passed to QGraphicsItem's constructor. -
9743 -
9744 \sa QGraphicsScene::addItem() -
9745*/ -
9746QGraphicsTextItem::QGraphicsTextItem(const QString &text, QGraphicsItem *parent) -
9747 : QGraphicsObject(*new QGraphicsItemPrivate, parent), -
9748 dd(new QGraphicsTextItemPrivate) -
9749{ -
9750 dd->qq = this;
executed (the execution status of this line is deduced): dd->qq = this;
-
9751 if (!text.isEmpty())
partially evaluated: !text.isEmpty()
TRUEFALSE
yes
Evaluation Count:104
no
Evaluation Count:0
0-104
9752 setPlainText(text);
executed: setPlainText(text);
Execution Count:104
104
9753 setAcceptDrops(true);
executed (the execution status of this line is deduced): setAcceptDrops(true);
-
9754 setAcceptHoverEvents(true);
executed (the execution status of this line is deduced): setAcceptHoverEvents(true);
-
9755 setFlags(ItemUsesExtendedStyleOption);
executed (the execution status of this line is deduced): setFlags(ItemUsesExtendedStyleOption);
-
9756}
executed: }
Execution Count:104
104
9757 -
9758/*! -
9759 Constructs a QGraphicsTextItem. \a parent is passed to QGraphicsItem's -
9760 constructor. -
9761 -
9762 \sa QGraphicsScene::addItem() -
9763*/ -
9764QGraphicsTextItem::QGraphicsTextItem(QGraphicsItem *parent) -
9765 : QGraphicsObject(*new QGraphicsItemPrivate, parent), -
9766 dd(new QGraphicsTextItemPrivate) -
9767{ -
9768 dd->qq = this;
never executed (the execution status of this line is deduced): dd->qq = this;
-
9769 setAcceptDrops(true);
never executed (the execution status of this line is deduced): setAcceptDrops(true);
-
9770 setAcceptHoverEvents(true);
never executed (the execution status of this line is deduced): setAcceptHoverEvents(true);
-
9771 setFlag(ItemUsesExtendedStyleOption);
never executed (the execution status of this line is deduced): setFlag(ItemUsesExtendedStyleOption);
-
9772}
never executed: }
0
9773 -
9774/*! -
9775 Destroys the QGraphicsTextItem. -
9776*/ -
9777QGraphicsTextItem::~QGraphicsTextItem() -
9778{ -
9779 delete dd;
executed (the execution status of this line is deduced): delete dd;
-
9780}
executed: }
Execution Count:104
104
9781 -
9782/*! -
9783 Returns the item's text converted to HTML, or an empty QString if no text has been set. -
9784 -
9785 \sa setHtml() -
9786*/ -
9787QString QGraphicsTextItem::toHtml() const -
9788{ -
9789#ifndef QT_NO_TEXTHTMLPARSER -
9790 if (dd->control)
never evaluated: dd->control
0
9791 return dd->control->toHtml();
never executed: return dd->control->toHtml();
0
9792#endif -
9793 return QString();
never executed: return QString();
0
9794} -
9795 -
9796/*! -
9797 Sets the item's text to \a text, assuming that text is HTML formatted. If -
9798 the item has keyboard input focus, this function will also call -
9799 ensureVisible() to ensure that the text is visible in all viewports. -
9800 -
9801 \sa toHtml(), hasFocus(), QGraphicsSimpleTextItem -
9802*/ -
9803void QGraphicsTextItem::setHtml(const QString &text) -
9804{ -
9805 dd->textControl()->setHtml(text);
never executed (the execution status of this line is deduced): dd->textControl()->setHtml(text);
-
9806}
never executed: }
0
9807 -
9808/*! -
9809 Returns the item's text converted to plain text, or an empty QString if no text has been set. -
9810 -
9811 \sa setPlainText() -
9812*/ -
9813QString QGraphicsTextItem::toPlainText() const -
9814{ -
9815 if (dd->control)
never evaluated: dd->control
0
9816 return dd->control->toPlainText();
never executed: return dd->control->toPlainText();
0
9817 return QString();
never executed: return QString();
0
9818} -
9819 -
9820/*! -
9821 Sets the item's text to \a text. If the item has keyboard input focus, -
9822 this function will also call ensureVisible() to ensure that the text is -
9823 visible in all viewports. -
9824 -
9825 \sa toHtml(), hasFocus() -
9826*/ -
9827void QGraphicsTextItem::setPlainText(const QString &text) -
9828{ -
9829 dd->textControl()->setPlainText(text);
executed (the execution status of this line is deduced): dd->textControl()->setPlainText(text);
-
9830}
executed: }
Execution Count:104
104
9831 -
9832/*! -
9833 Returns the item's font, which is used to render the text. -
9834 -
9835 \sa setFont() -
9836*/ -
9837QFont QGraphicsTextItem::font() const -
9838{ -
9839 if (!dd->control)
never evaluated: !dd->control
0
9840 return QFont();
never executed: return QFont();
0
9841 return dd->control->document()->defaultFont();
never executed: return dd->control->document()->defaultFont();
0
9842} -
9843 -
9844/*! -
9845 Sets the font used to render the text item to \a font. -
9846 -
9847 \sa font() -
9848*/ -
9849void QGraphicsTextItem::setFont(const QFont &font) -
9850{ -
9851 dd->textControl()->document()->setDefaultFont(font);
executed (the execution status of this line is deduced): dd->textControl()->document()->setDefaultFont(font);
-
9852}
executed: }
Execution Count:103
103
9853 -
9854/*! -
9855 Sets the color for unformatted text to \a col. -
9856*/ -
9857void QGraphicsTextItem::setDefaultTextColor(const QColor &col) -
9858{ -
9859 QWidgetTextControl *c = dd->textControl();
never executed (the execution status of this line is deduced): QWidgetTextControl *c = dd->textControl();
-
9860 QPalette pal = c->palette();
never executed (the execution status of this line is deduced): QPalette pal = c->palette();
-
9861 QColor old = pal.color(QPalette::Text);
never executed (the execution status of this line is deduced): QColor old = pal.color(QPalette::Text);
-
9862 pal.setColor(QPalette::Text, col);
never executed (the execution status of this line is deduced): pal.setColor(QPalette::Text, col);
-
9863 c->setPalette(pal);
never executed (the execution status of this line is deduced): c->setPalette(pal);
-
9864 if (old != col)
never evaluated: old != col
0
9865 update();
never executed: update();
0
9866}
never executed: }
0
9867 -
9868/*! -
9869 Returns the default text color that is used to for unformatted text. -
9870*/ -
9871QColor QGraphicsTextItem::defaultTextColor() const -
9872{ -
9873 return dd->textControl()->palette().color(QPalette::Text);
never executed: return dd->textControl()->palette().color(QPalette::Text);
0
9874} -
9875 -
9876/*! -
9877 \reimp -
9878*/ -
9879QRectF QGraphicsTextItem::boundingRect() const -
9880{ -
9881 return dd->boundingRect;
executed: return dd->boundingRect;
Execution Count:632
632
9882} -
9883 -
9884/*! -
9885 \reimp -
9886*/ -
9887QPainterPath QGraphicsTextItem::shape() const -
9888{ -
9889 if (!dd->control)
never evaluated: !dd->control
0
9890 return QPainterPath();
never executed: return QPainterPath();
0
9891 QPainterPath path;
never executed (the execution status of this line is deduced): QPainterPath path;
-
9892 path.addRect(dd->boundingRect);
never executed (the execution status of this line is deduced): path.addRect(dd->boundingRect);
-
9893 return path;
never executed: return path;
0
9894} -
9895 -
9896/*! -
9897 \reimp -
9898*/ -
9899bool QGraphicsTextItem::contains(const QPointF &point) const -
9900{ -
9901 return dd->boundingRect.contains(point);
never executed: return dd->boundingRect.contains(point);
0
9902} -
9903 -
9904/*! -
9905 \reimp -
9906*/ -
9907void QGraphicsTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, -
9908 QWidget *widget) -
9909{ -
9910 Q_UNUSED(widget);
executed (the execution status of this line is deduced): (void)widget;;
-
9911 if (dd->control) {
partially evaluated: dd->control
TRUEFALSE
yes
Evaluation Count:163
no
Evaluation Count:0
0-163
9912 painter->save();
executed (the execution status of this line is deduced): painter->save();
-
9913 QRectF r = option->exposedRect;
executed (the execution status of this line is deduced): QRectF r = option->exposedRect;
-
9914 painter->translate(-dd->controlOffset());
executed (the execution status of this line is deduced): painter->translate(-dd->controlOffset());
-
9915 r.translate(dd->controlOffset());
executed (the execution status of this line is deduced): r.translate(dd->controlOffset());
-
9916 -
9917 QTextDocument *doc = dd->control->document();
executed (the execution status of this line is deduced): QTextDocument *doc = dd->control->document();
-
9918 QTextDocumentLayout *layout = qobject_cast<QTextDocumentLayout *>(doc->documentLayout());
executed (the execution status of this line is deduced): QTextDocumentLayout *layout = qobject_cast<QTextDocumentLayout *>(doc->documentLayout());
-
9919 -
9920 // the layout might need to expand the root frame to -
9921 // the viewport if NoWrap is set -
9922 if (layout)
partially evaluated: layout
TRUEFALSE
yes
Evaluation Count:163
no
Evaluation Count:0
0-163
9923 layout->setViewport(dd->boundingRect);
executed: layout->setViewport(dd->boundingRect);
Execution Count:163
163
9924 -
9925 dd->control->drawContents(painter, r);
executed (the execution status of this line is deduced): dd->control->drawContents(painter, r);
-
9926 -
9927 if (layout)
partially evaluated: layout
TRUEFALSE
yes
Evaluation Count:163
no
Evaluation Count:0
0-163
9928 layout->setViewport(QRect());
executed: layout->setViewport(QRect());
Execution Count:163
163
9929 -
9930 painter->restore();
executed (the execution status of this line is deduced): painter->restore();
-
9931 }
executed: }
Execution Count:163
163
9932 -
9933 if (option->state & (QStyle::State_Selected | QStyle::State_HasFocus))
partially evaluated: option->state & (QStyle::State_Selected | QStyle::State_HasFocus)
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:163
0-163
9934 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
9935}
executed: }
Execution Count:163
163
9936 -
9937/*! -
9938 \reimp -
9939*/ -
9940bool QGraphicsTextItem::isObscuredBy(const QGraphicsItem *item) const -
9941{ -
9942 return QGraphicsItem::isObscuredBy(item);
never executed: return QGraphicsItem::isObscuredBy(item);
0
9943} -
9944 -
9945/*! -
9946 \reimp -
9947*/ -
9948QPainterPath QGraphicsTextItem::opaqueArea() const -
9949{ -
9950 return QGraphicsItem::opaqueArea();
never executed: return QGraphicsItem::opaqueArea();
0
9951} -
9952 -
9953/*! -
9954 \reimp -
9955*/ -
9956int QGraphicsTextItem::type() const -
9957{ -
9958 return Type;
never executed: return Type;
0
9959} -
9960 -
9961/*! -
9962 Sets the preferred width for the item's text. If the actual text -
9963 is wider than the specified width then it will be broken into -
9964 multiple lines. -
9965 -
9966 If \a width is set to -1 then the text will not be broken into -
9967 multiple lines unless it is enforced through an explicit line -
9968 break or a new paragraph. -
9969 -
9970 The default value is -1. -
9971 -
9972 Note that QGraphicsTextItem keeps a QTextDocument internally, -
9973 which is used to calculate the text width. -
9974 -
9975 \sa textWidth(), QTextDocument::setTextWidth() -
9976*/ -
9977void QGraphicsTextItem::setTextWidth(qreal width) -
9978{ -
9979 dd->textControl()->setTextWidth(width);
never executed (the execution status of this line is deduced): dd->textControl()->setTextWidth(width);
-
9980}
never executed: }
0
9981 -
9982/*! -
9983 Returns the text width. -
9984 -
9985 The width is calculated with the QTextDocument that -
9986 QGraphicsTextItem keeps internally. -
9987 -
9988 \sa setTextWidth(), QTextDocument::textWidth() -
9989*/ -
9990qreal QGraphicsTextItem::textWidth() const -
9991{ -
9992 if (!dd->control)
never evaluated: !dd->control
0
9993 return -1;
never executed: return -1;
0
9994 return dd->control->textWidth();
never executed: return dd->control->textWidth();
0
9995} -
9996 -
9997/*! -
9998 Adjusts the text item to a reasonable size. -
9999*/ -
10000void QGraphicsTextItem::adjustSize() -
10001{ -
10002 if (dd->control)
never evaluated: dd->control
0
10003 dd->control->adjustSize();
never executed: dd->control->adjustSize();
0
10004}
never executed: }
0
10005 -
10006/*! -
10007 Sets the text document \a document on the item. -
10008*/ -
10009void QGraphicsTextItem::setDocument(QTextDocument *document) -
10010{ -
10011 dd->textControl()->setDocument(document);
never executed (the execution status of this line is deduced): dd->textControl()->setDocument(document);
-
10012 dd->_q_updateBoundingRect(dd->control->size());
never executed (the execution status of this line is deduced): dd->_q_updateBoundingRect(dd->control->size());
-
10013}
never executed: }
0
10014 -
10015/*! -
10016 Returns the item's text document. -
10017*/ -
10018QTextDocument *QGraphicsTextItem::document() const -
10019{ -
10020 return dd->textControl()->document();
never executed: return dd->textControl()->document();
0
10021} -
10022 -
10023/*! -
10024 \reimp -
10025*/ -
10026bool QGraphicsTextItem::sceneEvent(QEvent *event) -
10027{ -
10028 QEvent::Type t = event->type();
executed (the execution status of this line is deduced): QEvent::Type t = event->type();
-
10029 if (!dd->tabChangesFocus && (t == QEvent::KeyPress || t == QEvent::KeyRelease)) {
partially evaluated: !dd->tabChangesFocus
TRUEFALSE
yes
Evaluation Count:104
no
Evaluation Count:0
partially evaluated: t == QEvent::KeyPress
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:104
partially evaluated: t == QEvent::KeyRelease
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:104
0-104
10030 int k = ((QKeyEvent *)event)->key();
never executed (the execution status of this line is deduced): int k = ((QKeyEvent *)event)->key();
-
10031 if (k == Qt::Key_Tab || k == Qt::Key_Backtab) {
never evaluated: k == Qt::Key_Tab
never evaluated: k == Qt::Key_Backtab
0
10032 dd->sendControlEvent(event);
never executed (the execution status of this line is deduced): dd->sendControlEvent(event);
-
10033 return true;
never executed: return true;
0
10034 } -
10035 }
never executed: }
0
10036 bool result = QGraphicsItem::sceneEvent(event);
executed (the execution status of this line is deduced): bool result = QGraphicsItem::sceneEvent(event);
-
10037 -
10038 // Ensure input context is updated. -
10039 switch (event->type()) { -
10040 case QEvent::ContextMenu: -
10041 case QEvent::FocusIn: -
10042 case QEvent::FocusOut: -
10043 case QEvent::GraphicsSceneDragEnter: -
10044 case QEvent::GraphicsSceneDragLeave: -
10045 case QEvent::GraphicsSceneDragMove: -
10046 case QEvent::GraphicsSceneDrop: -
10047 case QEvent::GraphicsSceneHoverEnter: -
10048 case QEvent::GraphicsSceneHoverLeave: -
10049 case QEvent::GraphicsSceneHoverMove: -
10050 case QEvent::GraphicsSceneMouseDoubleClick: -
10051 case QEvent::GraphicsSceneMousePress: -
10052 case QEvent::GraphicsSceneMouseMove: -
10053 case QEvent::GraphicsSceneMouseRelease: -
10054 case QEvent::KeyPress: -
10055 case QEvent::KeyRelease: -
10056 // Reset the focus widget's input context, regardless -
10057 // of how this item gained or lost focus. -
10058 if (event->type() == QEvent::FocusIn || event->type() == QEvent::FocusOut) {
partially evaluated: event->type() == QEvent::FocusIn
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
partially evaluated: event->type() == QEvent::FocusOut
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
10059 qApp->inputMethod()->reset();
never executed (the execution status of this line is deduced): (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->reset();
-
10060 } else {
never executed: }
0
10061 qApp->inputMethod()->update(Qt::ImQueryInput);
executed (the execution status of this line is deduced): (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->update(Qt::ImQueryInput);
-
10062 }
executed: }
Execution Count:1
1
10063 break;
executed: break;
Execution Count:1
1
10064 case QEvent::ShortcutOverride: -
10065 dd->sendControlEvent(event);
never executed (the execution status of this line is deduced): dd->sendControlEvent(event);
-
10066 return true;
never executed: return true;
0
10067 default: -
10068 break;
executed: break;
Execution Count:103
103
10069 } -
10070 -
10071 return result;
executed: return result;
Execution Count:104
104
10072} -
10073 -
10074/*! -
10075 \reimp -
10076*/ -
10077void QGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event) -
10078{ -
10079 if ((QGraphicsItem::d_ptr->flags & (ItemIsSelectable | ItemIsMovable))
never evaluated: (QGraphicsItem::d_ptr->flags & (ItemIsSelectable | ItemIsMovable))
0
10080 && (event->buttons() & Qt::LeftButton) && dd->_q_mouseOnEdge(event)) {
never evaluated: (event->buttons() & Qt::LeftButton)
never evaluated: dd->_q_mouseOnEdge(event)
0
10081 // User left-pressed on edge of selectable/movable item, use -
10082 // base impl. -
10083 dd->useDefaultImpl = true;
never executed (the execution status of this line is deduced): dd->useDefaultImpl = true;
-
10084 } else if (event->buttons() == event->button()
never executed: }
never evaluated: event->buttons() == event->button()
0
10085 && dd->control->textInteractionFlags() == Qt::NoTextInteraction) {
never evaluated: dd->control->textInteractionFlags() == Qt::NoTextInteraction
0
10086 // User pressed first button on non-interactive item. -
10087 dd->useDefaultImpl = true;
never executed (the execution status of this line is deduced): dd->useDefaultImpl = true;
-
10088 }
never executed: }
0
10089 if (dd->useDefaultImpl) {
never evaluated: dd->useDefaultImpl
0
10090 QGraphicsItem::mousePressEvent(event);
never executed (the execution status of this line is deduced): QGraphicsItem::mousePressEvent(event);
-
10091 if (!event->isAccepted())
never evaluated: !event->isAccepted()
0
10092 dd->useDefaultImpl = false;
never executed: dd->useDefaultImpl = false;
0
10093 return;
never executed: return;
0
10094 } -
10095 -
10096 dd->sendControlEvent(event);
never executed (the execution status of this line is deduced): dd->sendControlEvent(event);
-
10097}
never executed: }
0
10098 -
10099/*! -
10100 \reimp -
10101*/ -
10102void QGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) -
10103{ -
10104 if (dd->useDefaultImpl) {
partially evaluated: dd->useDefaultImpl
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-1
10105 QGraphicsItem::mouseMoveEvent(event);
never executed (the execution status of this line is deduced): QGraphicsItem::mouseMoveEvent(event);
-
10106 return;
never executed: return;
0
10107 } -
10108 -
10109 dd->sendControlEvent(event);
executed (the execution status of this line is deduced): dd->sendControlEvent(event);
-
10110}
executed: }
Execution Count:1
1
10111 -
10112/*! -
10113 \reimp -
10114*/ -
10115void QGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) -
10116{ -
10117 if (dd->useDefaultImpl) {
never evaluated: dd->useDefaultImpl
0
10118 QGraphicsItem::mouseReleaseEvent(event);
never executed (the execution status of this line is deduced): QGraphicsItem::mouseReleaseEvent(event);
-
10119 if (dd->control->textInteractionFlags() == Qt::NoTextInteraction
never evaluated: dd->control->textInteractionFlags() == Qt::NoTextInteraction
0
10120 && !event->buttons()) {
never evaluated: !event->buttons()
0
10121 // User released last button on non-interactive item. -
10122 dd->useDefaultImpl = false;
never executed (the execution status of this line is deduced): dd->useDefaultImpl = false;
-
10123 } else if ((event->buttons() & Qt::LeftButton) == 0) {
never executed: }
never evaluated: (event->buttons() & Qt::LeftButton) == 0
0
10124 // User released the left button on an interactive item. -
10125 dd->useDefaultImpl = false;
never executed (the execution status of this line is deduced): dd->useDefaultImpl = false;
-
10126 }
never executed: }
0
10127 return;
never executed: return;
0
10128 } -
10129 -
10130 QWidget *widget = event->widget();
never executed (the execution status of this line is deduced): QWidget *widget = event->widget();
-
10131 if (widget && (dd->control->textInteractionFlags() & Qt::TextEditable) && boundingRect().contains(event->pos())) {
never evaluated: widget
never evaluated: (dd->control->textInteractionFlags() & Qt::TextEditable)
never evaluated: boundingRect().contains(event->pos())
0
10132 qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), dd->clickCausedFocus);
never executed (the execution status of this line is deduced): qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), dd->clickCausedFocus);
-
10133 }
never executed: }
0
10134 dd->clickCausedFocus = 0;
never executed (the execution status of this line is deduced): dd->clickCausedFocus = 0;
-
10135 dd->sendControlEvent(event);
never executed (the execution status of this line is deduced): dd->sendControlEvent(event);
-
10136}
never executed: }
0
10137 -
10138/*! -
10139 \reimp -
10140*/ -
10141void QGraphicsTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) -
10142{ -
10143 if (dd->useDefaultImpl) {
never evaluated: dd->useDefaultImpl
0
10144 QGraphicsItem::mouseDoubleClickEvent(event);
never executed (the execution status of this line is deduced): QGraphicsItem::mouseDoubleClickEvent(event);
-
10145 return;
never executed: return;
0
10146 } -
10147 -
10148 if (!hasFocus()) {
never evaluated: !hasFocus()
0
10149 QGraphicsItem::mouseDoubleClickEvent(event);
never executed (the execution status of this line is deduced): QGraphicsItem::mouseDoubleClickEvent(event);
-
10150 return;
never executed: return;
0
10151 } -
10152 -
10153 dd->sendControlEvent(event);
never executed (the execution status of this line is deduced): dd->sendControlEvent(event);
-
10154}
never executed: }
0
10155 -
10156/*! -
10157 \reimp -
10158*/ -
10159void QGraphicsTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) -
10160{ -
10161 dd->sendControlEvent(event);
never executed (the execution status of this line is deduced): dd->sendControlEvent(event);
-
10162}
never executed: }
0
10163 -
10164/*! -
10165 \reimp -
10166*/ -
10167void QGraphicsTextItem::keyPressEvent(QKeyEvent *event) -
10168{ -
10169 dd->sendControlEvent(event);
never executed (the execution status of this line is deduced): dd->sendControlEvent(event);
-
10170}
never executed: }
0
10171 -
10172/*! -
10173 \reimp -
10174*/ -
10175void QGraphicsTextItem::keyReleaseEvent(QKeyEvent *event) -
10176{ -
10177 dd->sendControlEvent(event);
never executed (the execution status of this line is deduced): dd->sendControlEvent(event);
-
10178}
never executed: }
0
10179 -
10180/*! -
10181 \reimp -
10182*/ -
10183void QGraphicsTextItem::focusInEvent(QFocusEvent *event) -
10184{ -
10185 dd->sendControlEvent(event);
never executed (the execution status of this line is deduced): dd->sendControlEvent(event);
-
10186 if (event->reason() == Qt::MouseFocusReason) {
never evaluated: event->reason() == Qt::MouseFocusReason
0
10187 dd->clickCausedFocus = 1;
never executed (the execution status of this line is deduced): dd->clickCausedFocus = 1;
-
10188 }
never executed: }
0
10189 update();
never executed (the execution status of this line is deduced): update();
-
10190}
never executed: }
0
10191 -
10192/*! -
10193 \reimp -
10194*/ -
10195void QGraphicsTextItem::focusOutEvent(QFocusEvent *event) -
10196{ -
10197 dd->sendControlEvent(event);
never executed (the execution status of this line is deduced): dd->sendControlEvent(event);
-
10198 update();
never executed (the execution status of this line is deduced): update();
-
10199}
never executed: }
0
10200 -
10201/*! -
10202 \reimp -
10203*/ -
10204void QGraphicsTextItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event) -
10205{ -
10206 dd->sendControlEvent(event);
never executed (the execution status of this line is deduced): dd->sendControlEvent(event);
-
10207}
never executed: }
0
10208 -
10209/*! -
10210 \reimp -
10211*/ -
10212void QGraphicsTextItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) -
10213{ -
10214 dd->sendControlEvent(event);
never executed (the execution status of this line is deduced): dd->sendControlEvent(event);
-
10215}
never executed: }
0
10216 -
10217/*! -
10218 \reimp -
10219*/ -
10220void QGraphicsTextItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event) -
10221{ -
10222 dd->sendControlEvent(event);
never executed (the execution status of this line is deduced): dd->sendControlEvent(event);
-
10223}
never executed: }
0
10224 -
10225/*! -
10226 \reimp -
10227*/ -
10228void QGraphicsTextItem::dropEvent(QGraphicsSceneDragDropEvent *event) -
10229{ -
10230 dd->sendControlEvent(event);
never executed (the execution status of this line is deduced): dd->sendControlEvent(event);
-
10231}
never executed: }
0
10232 -
10233/*! -
10234 \reimp -
10235*/ -
10236void QGraphicsTextItem::inputMethodEvent(QInputMethodEvent *event) -
10237{ -
10238 dd->sendControlEvent(event);
never executed (the execution status of this line is deduced): dd->sendControlEvent(event);
-
10239}
never executed: }
0
10240 -
10241/*! -
10242 \reimp -
10243*/ -
10244void QGraphicsTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) -
10245{ -
10246 dd->sendControlEvent(event);
never executed (the execution status of this line is deduced): dd->sendControlEvent(event);
-
10247}
never executed: }
0
10248 -
10249/*! -
10250 \reimp -
10251*/ -
10252void QGraphicsTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) -
10253{ -
10254 dd->sendControlEvent(event);
never executed (the execution status of this line is deduced): dd->sendControlEvent(event);
-
10255}
never executed: }
0
10256 -
10257/*! -
10258 \reimp -
10259*/ -
10260void QGraphicsTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) -
10261{ -
10262 dd->sendControlEvent(event);
never executed (the execution status of this line is deduced): dd->sendControlEvent(event);
-
10263}
never executed: }
0
10264 -
10265/*! -
10266 \reimp -
10267*/ -
10268QVariant QGraphicsTextItem::inputMethodQuery(Qt::InputMethodQuery query) const -
10269{ -
10270 QVariant v;
never executed (the execution status of this line is deduced): QVariant v;
-
10271 if (dd->control)
never evaluated: dd->control
0
10272 v = dd->control->inputMethodQuery(query);
never executed: v = dd->control->inputMethodQuery(query);
0
10273 if (v.type() == QVariant::RectF)
never evaluated: v.type() == QVariant::RectF
0
10274 v = v.toRectF().translated(-dd->controlOffset());
never executed: v = v.toRectF().translated(-dd->controlOffset());
0
10275 else if (v.type() == QVariant::PointF)
never evaluated: v.type() == QVariant::PointF
0
10276 v = v.toPointF() - dd->controlOffset();
never executed: v = v.toPointF() - dd->controlOffset();
0
10277 else if (v.type() == QVariant::Rect)
never evaluated: v.type() == QVariant::Rect
0
10278 v = v.toRect().translated(-dd->controlOffset().toPoint());
never executed: v = v.toRect().translated(-dd->controlOffset().toPoint());
0
10279 else if (v.type() == QVariant::Point)
never evaluated: v.type() == QVariant::Point
0
10280 v = v.toPoint() - dd->controlOffset().toPoint();
never executed: v = v.toPoint() - dd->controlOffset().toPoint();
0
10281 return v;
never executed: return v;
0
10282} -
10283 -
10284/*! -
10285 \internal -
10286*/ -
10287bool QGraphicsTextItem::supportsExtension(Extension extension) const -
10288{ -
10289 Q_UNUSED(extension);
never executed (the execution status of this line is deduced): (void)extension;;
-
10290 return false;
never executed: return false;
0
10291} -
10292 -
10293/*! -
10294 \internal -
10295*/ -
10296void QGraphicsTextItem::setExtension(Extension extension, const QVariant &variant) -
10297{ -
10298 Q_UNUSED(extension);
never executed (the execution status of this line is deduced): (void)extension;;
-
10299 Q_UNUSED(variant);
never executed (the execution status of this line is deduced): (void)variant;;
-
10300}
never executed: }
0
10301 -
10302/*! -
10303 \internal -
10304*/ -
10305QVariant QGraphicsTextItem::extension(const QVariant &variant) const -
10306{ -
10307 Q_UNUSED(variant);
never executed (the execution status of this line is deduced): (void)variant;;
-
10308 return QVariant();
never executed: return QVariant();
0
10309} -
10310 -
10311/*! -
10312 \internal -
10313*/ -
10314void QGraphicsTextItemPrivate::_q_update(QRectF rect) -
10315{ -
10316 if (rect.isValid()) {
partially evaluated: rect.isValid()
TRUEFALSE
yes
Evaluation Count:311
no
Evaluation Count:0
0-311
10317 rect.translate(-controlOffset());
executed (the execution status of this line is deduced): rect.translate(-controlOffset());
-
10318 } else {
executed: }
Execution Count:311
311
10319 rect = boundingRect;
never executed (the execution status of this line is deduced): rect = boundingRect;
-
10320 }
never executed: }
0
10321 if (rect.intersects(boundingRect))
partially evaluated: rect.intersects(boundingRect)
TRUEFALSE
yes
Evaluation Count:311
no
Evaluation Count:0
0-311
10322 qq->update(rect);
executed: qq->update(rect);
Execution Count:311
311
10323}
executed: }
Execution Count:311
311
10324 -
10325/*! -
10326 \internal -
10327*/ -
10328void QGraphicsTextItemPrivate::_q_updateBoundingRect(const QSizeF &size) -
10329{ -
10330 if (!control) return; // can't happen
never executed: return;
partially evaluated: !control
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:208
0-208
10331 const QSizeF pageSize = control->document()->pageSize();
executed (the execution status of this line is deduced): const QSizeF pageSize = control->document()->pageSize();
-
10332 // paged items have a constant (page) size -
10333 if (size == boundingRect.size() || pageSize.height() != -1)
partially evaluated: size == boundingRect.size()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:208
partially evaluated: pageSize.height() != -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:208
0-208
10334 return;
never executed: return;
0
10335 qq->prepareGeometryChange();
executed (the execution status of this line is deduced): qq->prepareGeometryChange();
-
10336 boundingRect.setSize(size);
executed (the execution status of this line is deduced): boundingRect.setSize(size);
-
10337 qq->update();
executed (the execution status of this line is deduced): qq->update();
-
10338}
executed: }
Execution Count:208
208
10339 -
10340/*! -
10341 \internal -
10342*/ -
10343void QGraphicsTextItemPrivate::_q_ensureVisible(QRectF rect) -
10344{ -
10345 if (qq->hasFocus()) {
partially evaluated: qq->hasFocus()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:104
0-104
10346 rect.translate(-controlOffset());
never executed (the execution status of this line is deduced): rect.translate(-controlOffset());
-
10347 qq->ensureVisible(rect, /*xmargin=*/0, /*ymargin=*/0);
never executed (the execution status of this line is deduced): qq->ensureVisible(rect, 0, 0);
-
10348 }
never executed: }
0
10349}
executed: }
Execution Count:104
104
10350 -
10351QWidgetTextControl *QGraphicsTextItemPrivate::textControl() const -
10352{ -
10353 if (!control) {
evaluated: !control
TRUEFALSE
yes
Evaluation Count:104
yes
Evaluation Count:103
103-104
10354 QGraphicsTextItem *that = const_cast<QGraphicsTextItem *>(qq);
executed (the execution status of this line is deduced): QGraphicsTextItem *that = const_cast<QGraphicsTextItem *>(qq);
-
10355 control = new QWidgetTextControl(that);
executed (the execution status of this line is deduced): control = new QWidgetTextControl(that);
-
10356 control->setTextInteractionFlags(Qt::NoTextInteraction);
executed (the execution status of this line is deduced): control->setTextInteractionFlags(Qt::NoTextInteraction);
-
10357 -
10358 QObject::connect(control, SIGNAL(updateRequest(QRectF)),
executed (the execution status of this line is deduced): QObject::connect(control, "2""updateRequest(QRectF)",
-
10359 qq, SLOT(_q_update(QRectF)));
executed (the execution status of this line is deduced): qq, "1""_q_update(QRectF)");
-
10360 QObject::connect(control, SIGNAL(documentSizeChanged(QSizeF)),
executed (the execution status of this line is deduced): QObject::connect(control, "2""documentSizeChanged(QSizeF)",
-
10361 qq, SLOT(_q_updateBoundingRect(QSizeF)));
executed (the execution status of this line is deduced): qq, "1""_q_updateBoundingRect(QSizeF)");
-
10362 QObject::connect(control, SIGNAL(visibilityRequest(QRectF)),
executed (the execution status of this line is deduced): QObject::connect(control, "2""visibilityRequest(QRectF)",
-
10363 qq, SLOT(_q_ensureVisible(QRectF)));
executed (the execution status of this line is deduced): qq, "1""_q_ensureVisible(QRectF)");
-
10364 QObject::connect(control, SIGNAL(linkActivated(QString)),
executed (the execution status of this line is deduced): QObject::connect(control, "2""linkActivated(QString)",
-
10365 qq, SIGNAL(linkActivated(QString)));
executed (the execution status of this line is deduced): qq, "2""linkActivated(QString)");
-
10366 QObject::connect(control, SIGNAL(linkHovered(QString)),
executed (the execution status of this line is deduced): QObject::connect(control, "2""linkHovered(QString)",
-
10367 qq, SIGNAL(linkHovered(QString)));
executed (the execution status of this line is deduced): qq, "2""linkHovered(QString)");
-
10368 -
10369 const QSizeF pgSize = control->document()->pageSize();
executed (the execution status of this line is deduced): const QSizeF pgSize = control->document()->pageSize();
-
10370 if (pgSize.height() != -1) {
partially evaluated: pgSize.height() != -1
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:104
0-104
10371 qq->prepareGeometryChange();
never executed (the execution status of this line is deduced): qq->prepareGeometryChange();
-
10372 that->dd->boundingRect.setSize(pgSize);
never executed (the execution status of this line is deduced): that->dd->boundingRect.setSize(pgSize);
-
10373 qq->update();
never executed (the execution status of this line is deduced): qq->update();
-
10374 } else {
never executed: }
0
10375 that->dd->_q_updateBoundingRect(control->size());
executed (the execution status of this line is deduced): that->dd->_q_updateBoundingRect(control->size());
-
10376 }
executed: }
Execution Count:104
104
10377 } -
10378 return control;
executed: return control;
Execution Count:207
207
10379} -
10380 -
10381/*! -
10382 \internal -
10383*/ -
10384bool QGraphicsTextItemPrivate::_q_mouseOnEdge(QGraphicsSceneMouseEvent *event) -
10385{ -
10386 QPainterPath path;
never executed (the execution status of this line is deduced): QPainterPath path;
-
10387 path.addRect(qq->boundingRect());
never executed (the execution status of this line is deduced): path.addRect(qq->boundingRect());
-
10388 -
10389 QPainterPath docPath;
never executed (the execution status of this line is deduced): QPainterPath docPath;
-
10390 const QTextFrameFormat format = control->document()->rootFrame()->frameFormat();
never executed (the execution status of this line is deduced): const QTextFrameFormat format = control->document()->rootFrame()->frameFormat();
-
10391 docPath.addRect(
never executed (the execution status of this line is deduced): docPath.addRect(
-
10392 qq->boundingRect().adjusted(
never executed (the execution status of this line is deduced): qq->boundingRect().adjusted(
-
10393 format.leftMargin(),
never executed (the execution status of this line is deduced): format.leftMargin(),
-
10394 format.topMargin(),
never executed (the execution status of this line is deduced): format.topMargin(),
-
10395 -format.rightMargin(),
never executed (the execution status of this line is deduced): -format.rightMargin(),
-
10396 -format.bottomMargin()));
never executed (the execution status of this line is deduced): -format.bottomMargin()));
-
10397 -
10398 return path.subtracted(docPath).contains(event->pos());
never executed: return path.subtracted(docPath).contains(event->pos());
0
10399} -
10400 -
10401/*! -
10402 \fn QGraphicsTextItem::linkActivated(const QString &link) -
10403 -
10404 This signal is emitted when the user clicks on a link on a text item -
10405 that enables Qt::LinksAccessibleByMouse or Qt::LinksAccessibleByKeyboard. -
10406 \a link is the link that was clicked. -
10407 -
10408 \sa setTextInteractionFlags() -
10409*/ -
10410 -
10411/*! -
10412 \fn QGraphicsTextItem::linkHovered(const QString &link) -
10413 -
10414 This signal is emitted when the user hovers over a link on a text item -
10415 that enables Qt::LinksAccessibleByMouse. \a link is -
10416 the link that was hovered over. -
10417 -
10418 \sa setTextInteractionFlags() -
10419*/ -
10420 -
10421/*! -
10422 Sets the flags \a flags to specify how the text item should react to user -
10423 input. -
10424 -
10425 The default for a QGraphicsTextItem is Qt::NoTextInteraction. This function -
10426 also affects the ItemIsFocusable QGraphicsItem flag by setting it if \a flags -
10427 is different from Qt::NoTextInteraction and clearing it otherwise. -
10428 -
10429 By default, the text is read-only. To transform the item into an editor, -
10430 set the Qt::TextEditable flag. -
10431*/ -
10432void QGraphicsTextItem::setTextInteractionFlags(Qt::TextInteractionFlags flags) -
10433{ -
10434 if (flags == Qt::NoTextInteraction)
never evaluated: flags == Qt::NoTextInteraction
0
10435 setFlags(this->flags() & ~(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod));
never executed: setFlags(this->flags() & ~(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod));
0
10436 else -
10437 setFlags(this->flags() | QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod);
never executed: setFlags(this->flags() | QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod);
0
10438 -
10439 dd->textControl()->setTextInteractionFlags(flags);
never executed (the execution status of this line is deduced): dd->textControl()->setTextInteractionFlags(flags);
-
10440}
never executed: }
0
10441 -
10442/*! -
10443 Returns the current text interaction flags. -
10444 -
10445 \sa setTextInteractionFlags() -
10446*/ -
10447Qt::TextInteractionFlags QGraphicsTextItem::textInteractionFlags() const -
10448{ -
10449 if (!dd->control)
never evaluated: !dd->control
0
10450 return Qt::NoTextInteraction;
never executed: return Qt::NoTextInteraction;
0
10451 return dd->control->textInteractionFlags();
never executed: return dd->control->textInteractionFlags();
0
10452} -
10453 -
10454/*! -
10455 \since 4.5 -
10456 -
10457 If \a b is true, the \uicontrol Tab key will cause the widget to change focus; -
10458 otherwise, the tab key will insert a tab into the document. -
10459 -
10460 In some occasions text edits should not allow the user to input tabulators -
10461 or change indentation using the \uicontrol Tab key, as this breaks the focus -
10462 chain. The default is false. -
10463 -
10464 \sa tabChangesFocus(), ItemIsFocusable, textInteractionFlags() -
10465*/ -
10466void QGraphicsTextItem::setTabChangesFocus(bool b) -
10467{ -
10468 dd->tabChangesFocus = b;
never executed (the execution status of this line is deduced): dd->tabChangesFocus = b;
-
10469}
never executed: }
0
10470 -
10471/*! -
10472 \since 4.5 -
10473 -
10474 Returns true if the \uicontrol Tab key will cause the widget to change focus; -
10475 otherwise, false is returned. -
10476 -
10477 By default, this behavior is disabled, and this function will return false. -
10478 -
10479 \sa setTabChangesFocus() -
10480*/ -
10481bool QGraphicsTextItem::tabChangesFocus() const -
10482{ -
10483 return dd->tabChangesFocus;
never executed: return dd->tabChangesFocus;
0
10484} -
10485 -
10486/*! -
10487 \property QGraphicsTextItem::openExternalLinks -
10488 -
10489 Specifies whether QGraphicsTextItem should automatically open links using -
10490 QDesktopServices::openUrl() instead of emitting the -
10491 linkActivated signal. -
10492 -
10493 The default value is false. -
10494*/ -
10495void QGraphicsTextItem::setOpenExternalLinks(bool open) -
10496{ -
10497 dd->textControl()->setOpenExternalLinks(open);
never executed (the execution status of this line is deduced): dd->textControl()->setOpenExternalLinks(open);
-
10498}
never executed: }
0
10499 -
10500bool QGraphicsTextItem::openExternalLinks() const -
10501{ -
10502 if (!dd->control)
never evaluated: !dd->control
0
10503 return false;
never executed: return false;
0
10504 return dd->control->openExternalLinks();
never executed: return dd->control->openExternalLinks();
0
10505} -
10506 -
10507/*! -
10508 \property QGraphicsTextItem::textCursor -
10509 -
10510 This property represents the visible text cursor in an editable -
10511 text item. -
10512 -
10513 By default, if the item's text has not been set, this property -
10514 contains a null text cursor; otherwise it contains a text cursor -
10515 placed at the start of the item's document. -
10516*/ -
10517void QGraphicsTextItem::setTextCursor(const QTextCursor &cursor) -
10518{ -
10519 dd->textControl()->setTextCursor(cursor);
never executed (the execution status of this line is deduced): dd->textControl()->setTextCursor(cursor);
-
10520}
never executed: }
0
10521 -
10522QTextCursor QGraphicsTextItem::textCursor() const -
10523{ -
10524 if (!dd->control)
never evaluated: !dd->control
0
10525 return QTextCursor();
never executed: return QTextCursor();
0
10526 return dd->control->textCursor();
never executed: return dd->control->textCursor();
0
10527} -
10528 -
10529class QGraphicsSimpleTextItemPrivate : public QAbstractGraphicsShapeItemPrivate -
10530{ -
10531 Q_DECLARE_PUBLIC(QGraphicsSimpleTextItem) -
10532public: -
10533 inline QGraphicsSimpleTextItemPrivate() { -
10534 pen.setStyle(Qt::NoPen);
never executed (the execution status of this line is deduced): pen.setStyle(Qt::NoPen);
-
10535 brush.setStyle(Qt::SolidPattern);
never executed (the execution status of this line is deduced): brush.setStyle(Qt::SolidPattern);
-
10536 }
never executed: }
0
10537 QString text; -
10538 QFont font; -
10539 QRectF boundingRect; -
10540 -
10541 void updateBoundingRect(); -
10542}; -
10543 -
10544static QRectF setupTextLayout(QTextLayout *layout) -
10545{ -
10546 layout->setCacheEnabled(true);
never executed (the execution status of this line is deduced): layout->setCacheEnabled(true);
-
10547 layout->beginLayout();
never executed (the execution status of this line is deduced): layout->beginLayout();
-
10548 while (layout->createLine().isValid())
never evaluated: layout->createLine().isValid()
0
10549 ;
never executed: ;
0
10550 layout->endLayout();
never executed (the execution status of this line is deduced): layout->endLayout();
-
10551 qreal maxWidth = 0;
never executed (the execution status of this line is deduced): qreal maxWidth = 0;
-
10552 qreal y = 0;
never executed (the execution status of this line is deduced): qreal y = 0;
-
10553 for (int i = 0; i < layout->lineCount(); ++i) {
never evaluated: i < layout->lineCount()
0
10554 QTextLine line = layout->lineAt(i);
never executed (the execution status of this line is deduced): QTextLine line = layout->lineAt(i);
-
10555 maxWidth = qMax(maxWidth, line.naturalTextWidth());
never executed (the execution status of this line is deduced): maxWidth = qMax(maxWidth, line.naturalTextWidth());
-
10556 line.setPosition(QPointF(0, y));
never executed (the execution status of this line is deduced): line.setPosition(QPointF(0, y));
-
10557 y += line.height();
never executed (the execution status of this line is deduced): y += line.height();
-
10558 }
never executed: }
0
10559 return QRectF(0, 0, maxWidth, y);
never executed: return QRectF(0, 0, maxWidth, y);
0
10560} -
10561 -
10562void QGraphicsSimpleTextItemPrivate::updateBoundingRect() -
10563{ -
10564 Q_Q(QGraphicsSimpleTextItem);
never executed (the execution status of this line is deduced): QGraphicsSimpleTextItem * const q = q_func();
-
10565 QRectF br;
never executed (the execution status of this line is deduced): QRectF br;
-
10566 if (text.isEmpty()) {
never evaluated: text.isEmpty()
0
10567 br = QRectF();
never executed (the execution status of this line is deduced): br = QRectF();
-
10568 } else {
never executed: }
0
10569 QString tmp = text;
never executed (the execution status of this line is deduced): QString tmp = text;
-
10570 tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
never executed (the execution status of this line is deduced): tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
-
10571 QStackTextEngine engine(tmp, font);
never executed (the execution status of this line is deduced): QStackTextEngine engine(tmp, font);
-
10572 QTextLayout layout(&engine);
never executed (the execution status of this line is deduced): QTextLayout layout(&engine);
-
10573 br = setupTextLayout(&layout);
never executed (the execution status of this line is deduced): br = setupTextLayout(&layout);
-
10574 }
never executed: }
0
10575 if (br != boundingRect) {
never evaluated: br != boundingRect
0
10576 q->prepareGeometryChange();
never executed (the execution status of this line is deduced): q->prepareGeometryChange();
-
10577 boundingRect = br;
never executed (the execution status of this line is deduced): boundingRect = br;
-
10578 q->update();
never executed (the execution status of this line is deduced): q->update();
-
10579 }
never executed: }
0
10580}
never executed: }
0
10581 -
10582/*! -
10583 \class QGraphicsSimpleTextItem -
10584 \brief The QGraphicsSimpleTextItem class provides a simple text path item -
10585 that you can add to a QGraphicsScene. -
10586 \since 4.2 -
10587 \ingroup graphicsview-api -
10588 \inmodule QtWidgets -
10589 -
10590 To set the item's text, you can either pass a QString to -
10591 QGraphicsSimpleTextItem's constructor, or call setText() to change the -
10592 text later. To set the text fill color, call setBrush(). -
10593 -
10594 The simple text item can have both a fill and an outline; setBrush() will -
10595 set the text fill (i.e., text color), and setPen() sets the pen that will -
10596 be used to draw the text outline. (The latter can be slow, especially for -
10597 complex pens, and items with long text content.) If all you want is to -
10598 draw a simple line of text, you should call setBrush() only, and leave the -
10599 pen unset; QGraphicsSimpleTextItem's pen is by default Qt::NoPen. -
10600 -
10601 QGraphicsSimpleTextItem uses the text's formatted size and the associated -
10602 font to provide a reasonable implementation of boundingRect(), shape(), -
10603 and contains(). You can set the font by calling setFont(). -
10604 -
10605 QGraphicsSimpleText does not display rich text; instead, you can use -
10606 QGraphicsTextItem, which provides full text control capabilities. -
10607 -
10608 \image graphicsview-simpletextitem.png -
10609 -
10610 \sa QGraphicsTextItem, QGraphicsPathItem, QGraphicsRectItem, -
10611 QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem, -
10612 QGraphicsLineItem, {Graphics View Framework} -
10613*/ -
10614 -
10615/*! -
10616 Constructs a QGraphicsSimpleTextItem. -
10617 -
10618 \a parent is passed to QGraphicsItem's constructor. -
10619 -
10620 \sa QGraphicsScene::addItem() -
10621*/ -
10622QGraphicsSimpleTextItem::QGraphicsSimpleTextItem(QGraphicsItem *parent) -
10623 : QAbstractGraphicsShapeItem(*new QGraphicsSimpleTextItemPrivate, parent) -
10624{ -
10625}
never executed: }
0
10626 -
10627/*! -
10628 Constructs a QGraphicsSimpleTextItem, using \a text as the default plain text. -
10629 -
10630 \a parent is passed to QGraphicsItem's constructor. -
10631 -
10632 \sa QGraphicsScene::addItem() -
10633*/ -
10634QGraphicsSimpleTextItem::QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent) -
10635 : QAbstractGraphicsShapeItem(*new QGraphicsSimpleTextItemPrivate, parent) -
10636{ -
10637 setText(text);
never executed (the execution status of this line is deduced): setText(text);
-
10638}
never executed: }
0
10639 -
10640/*! -
10641 Destroys the QGraphicsSimpleTextItem. -
10642*/ -
10643QGraphicsSimpleTextItem::~QGraphicsSimpleTextItem() -
10644{ -
10645} -
10646 -
10647/*! -
10648 Sets the item's text to \a text. The text will be displayed as -
10649 plain text. Newline characters ('\\n') as well as characters of -
10650 type QChar::LineSeparator will cause item to break the text into -
10651 multiple lines. -
10652*/ -
10653void QGraphicsSimpleTextItem::setText(const QString &text) -
10654{ -
10655 Q_D(QGraphicsSimpleTextItem);
never executed (the execution status of this line is deduced): QGraphicsSimpleTextItemPrivate * const d = d_func();
-
10656 if (d->text == text)
never evaluated: d->text == text
0
10657 return;
never executed: return;
0
10658 d->text = text;
never executed (the execution status of this line is deduced): d->text = text;
-
10659 d->updateBoundingRect();
never executed (the execution status of this line is deduced): d->updateBoundingRect();
-
10660 update();
never executed (the execution status of this line is deduced): update();
-
10661}
never executed: }
0
10662 -
10663/*! -
10664 Returns the item's text. -
10665*/ -
10666QString QGraphicsSimpleTextItem::text() const -
10667{ -
10668 Q_D(const QGraphicsSimpleTextItem);
never executed (the execution status of this line is deduced): const QGraphicsSimpleTextItemPrivate * const d = d_func();
-
10669 return d->text;
never executed: return d->text;
0
10670} -
10671 -
10672/*! -
10673 Sets the font that is used to draw the item's text to \a font. -
10674*/ -
10675void QGraphicsSimpleTextItem::setFont(const QFont &font) -
10676{ -
10677 Q_D(QGraphicsSimpleTextItem);
never executed (the execution status of this line is deduced): QGraphicsSimpleTextItemPrivate * const d = d_func();
-
10678 d->font = font;
never executed (the execution status of this line is deduced): d->font = font;
-
10679 d->updateBoundingRect();
never executed (the execution status of this line is deduced): d->updateBoundingRect();
-
10680}
never executed: }
0
10681 -
10682/*! -
10683 Returns the font that is used to draw the item's text. -
10684*/ -
10685QFont QGraphicsSimpleTextItem::font() const -
10686{ -
10687 Q_D(const QGraphicsSimpleTextItem);
never executed (the execution status of this line is deduced): const QGraphicsSimpleTextItemPrivate * const d = d_func();
-
10688 return d->font;
never executed: return d->font;
0
10689} -
10690 -
10691/*! -
10692 \reimp -
10693*/ -
10694QRectF QGraphicsSimpleTextItem::boundingRect() const -
10695{ -
10696 Q_D(const QGraphicsSimpleTextItem);
never executed (the execution status of this line is deduced): const QGraphicsSimpleTextItemPrivate * const d = d_func();
-
10697 return d->boundingRect;
never executed: return d->boundingRect;
0
10698} -
10699 -
10700/*! -
10701 \reimp -
10702*/ -
10703QPainterPath QGraphicsSimpleTextItem::shape() const -
10704{ -
10705 Q_D(const QGraphicsSimpleTextItem);
never executed (the execution status of this line is deduced): const QGraphicsSimpleTextItemPrivate * const d = d_func();
-
10706 QPainterPath path;
never executed (the execution status of this line is deduced): QPainterPath path;
-
10707 path.addRect(d->boundingRect);
never executed (the execution status of this line is deduced): path.addRect(d->boundingRect);
-
10708 return path;
never executed: return path;
0
10709} -
10710 -
10711/*! -
10712 \reimp -
10713*/ -
10714bool QGraphicsSimpleTextItem::contains(const QPointF &point) const -
10715{ -
10716 Q_D(const QGraphicsSimpleTextItem);
never executed (the execution status of this line is deduced): const QGraphicsSimpleTextItemPrivate * const d = d_func();
-
10717 return d->boundingRect.contains(point);
never executed: return d->boundingRect.contains(point);
0
10718} -
10719 -
10720/*! -
10721 \reimp -
10722*/ -
10723void QGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) -
10724{ -
10725 Q_UNUSED(widget);
never executed (the execution status of this line is deduced): (void)widget;;
-
10726 Q_D(QGraphicsSimpleTextItem);
never executed (the execution status of this line is deduced): QGraphicsSimpleTextItemPrivate * const d = d_func();
-
10727 -
10728 painter->setFont(d->font);
never executed (the execution status of this line is deduced): painter->setFont(d->font);
-
10729 -
10730 QString tmp = d->text;
never executed (the execution status of this line is deduced): QString tmp = d->text;
-
10731 tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
never executed (the execution status of this line is deduced): tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);
-
10732 QStackTextEngine engine(tmp, d->font);
never executed (the execution status of this line is deduced): QStackTextEngine engine(tmp, d->font);
-
10733 QTextLayout layout(&engine);
never executed (the execution status of this line is deduced): QTextLayout layout(&engine);
-
10734 setupTextLayout(&layout);
never executed (the execution status of this line is deduced): setupTextLayout(&layout);
-
10735 -
10736 QPen p;
never executed (the execution status of this line is deduced): QPen p;
-
10737 p.setBrush(d->brush);
never executed (the execution status of this line is deduced): p.setBrush(d->brush);
-
10738 painter->setPen(p);
never executed (the execution status of this line is deduced): painter->setPen(p);
-
10739 if (d->pen.style() == Qt::NoPen && d->brush.style() == Qt::SolidPattern) {
never evaluated: d->pen.style() == Qt::NoPen
never evaluated: d->brush.style() == Qt::SolidPattern
0
10740 painter->setBrush(Qt::NoBrush);
never executed (the execution status of this line is deduced): painter->setBrush(Qt::NoBrush);
-
10741 } else {
never executed: }
0
10742 QTextLayout::FormatRange range;
never executed (the execution status of this line is deduced): QTextLayout::FormatRange range;
-
10743 range.start = 0;
never executed (the execution status of this line is deduced): range.start = 0;
-
10744 range.length = layout.text().length();
never executed (the execution status of this line is deduced): range.length = layout.text().length();
-
10745 range.format.setTextOutline(d->pen);
never executed (the execution status of this line is deduced): range.format.setTextOutline(d->pen);
-
10746 QList<QTextLayout::FormatRange> formats;
never executed (the execution status of this line is deduced): QList<QTextLayout::FormatRange> formats;
-
10747 formats.append(range);
never executed (the execution status of this line is deduced): formats.append(range);
-
10748 layout.setAdditionalFormats(formats);
never executed (the execution status of this line is deduced): layout.setAdditionalFormats(formats);
-
10749 }
never executed: }
0
10750 -
10751 layout.draw(painter, QPointF(0, 0));
never executed (the execution status of this line is deduced): layout.draw(painter, QPointF(0, 0));
-
10752 -
10753 if (option->state & (QStyle::State_Selected | QStyle::State_HasFocus))
never evaluated: option->state & (QStyle::State_Selected | QStyle::State_HasFocus)
0
10754 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
10755}
never executed: }
0
10756 -
10757/*! -
10758 \reimp -
10759*/ -
10760bool QGraphicsSimpleTextItem::isObscuredBy(const QGraphicsItem *item) const -
10761{ -
10762 return QAbstractGraphicsShapeItem::isObscuredBy(item);
never executed: return QAbstractGraphicsShapeItem::isObscuredBy(item);
0
10763} -
10764 -
10765/*! -
10766 \reimp -
10767*/ -
10768QPainterPath QGraphicsSimpleTextItem::opaqueArea() const -
10769{ -
10770 return QAbstractGraphicsShapeItem::opaqueArea();
never executed: return QAbstractGraphicsShapeItem::opaqueArea();
0
10771} -
10772 -
10773/*! -
10774 \reimp -
10775*/ -
10776int QGraphicsSimpleTextItem::type() const -
10777{ -
10778 return Type;
never executed: return Type;
0
10779} -
10780 -
10781/*! -
10782 \internal -
10783*/ -
10784bool QGraphicsSimpleTextItem::supportsExtension(Extension extension) const -
10785{ -
10786 Q_UNUSED(extension);
never executed (the execution status of this line is deduced): (void)extension;;
-
10787 return false;
never executed: return false;
0
10788} -
10789 -
10790/*! -
10791 \internal -
10792*/ -
10793void QGraphicsSimpleTextItem::setExtension(Extension extension, const QVariant &variant) -
10794{ -
10795 Q_UNUSED(extension);
never executed (the execution status of this line is deduced): (void)extension;;
-
10796 Q_UNUSED(variant);
never executed (the execution status of this line is deduced): (void)variant;;
-
10797}
never executed: }
0
10798 -
10799/*! -
10800 \internal -
10801*/ -
10802QVariant QGraphicsSimpleTextItem::extension(const QVariant &variant) const -
10803{ -
10804 Q_UNUSED(variant);
never executed (the execution status of this line is deduced): (void)variant;;
-
10805 return QVariant();
never executed: return QVariant();
0
10806} -
10807 -
10808/*! -
10809 \class QGraphicsItemGroup -
10810 \brief The QGraphicsItemGroup class provides a container that treats -
10811 a group of items as a single item. -
10812 \since 4.2 -
10813 \ingroup graphicsview-api -
10814 \inmodule QtWidgets -
10815 -
10816 A QGraphicsItemGroup is a special type of compound item that -
10817 treats itself and all its children as one item (i.e., all events -
10818 and geometries for all children are merged together). It's common -
10819 to use item groups in presentation tools, when the user wants to -
10820 group several smaller items into one big item in order to simplify -
10821 moving and copying of items. -
10822 -
10823 If all you want is to store items inside other items, you can use -
10824 any QGraphicsItem directly by passing a suitable parent to -
10825 setParentItem(). -
10826 -
10827 The boundingRect() function of QGraphicsItemGroup returns the -
10828 bounding rectangle of all items in the item group. -
10829 QGraphicsItemGroup ignores the ItemIgnoresTransformations flag on -
10830 its children (i.e., with respect to the geometry of the group -
10831 item, the children are treated as if they were transformable). -
10832 -
10833 There are two ways to construct an item group. The easiest and -
10834 most common approach is to pass a list of items (e.g., all -
10835 selected items) to QGraphicsScene::createItemGroup(), which -
10836 returns a new QGraphicsItemGroup item. The other approach is to -
10837 manually construct a QGraphicsItemGroup item, add it to the scene -
10838 calling QGraphicsScene::addItem(), and then add items to the group -
10839 manually, one at a time by calling addToGroup(). To dismantle -
10840 ("ungroup") an item group, you can either call -
10841 QGraphicsScene::destroyItemGroup(), or you can manually remove all -
10842 items from the group by calling removeFromGroup(). -
10843 -
10844 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 17 -
10845 -
10846 The operation of adding and removing items preserves the items' -
10847 scene-relative position and transformation, as opposed to calling -
10848 setParentItem(), where only the child item's parent-relative -
10849 position and transformation are kept. -
10850 -
10851 The addtoGroup() function reparents the target item to this item -
10852 group, keeping the item's position and transformation intact -
10853 relative to the scene. Visually, this means that items added via -
10854 addToGroup() will remain completely unchanged as a result of this -
10855 operation, regardless of the item or the group's current position -
10856 or transformation; although the item's position and matrix are -
10857 likely to change. -
10858 -
10859 The removeFromGroup() function has similar semantics to -
10860 setParentItem(); it reparents the item to the parent item of the -
10861 item group. As with addToGroup(), the item's scene-relative -
10862 position and transformation remain intact. -
10863 -
10864 \sa QGraphicsItem, {Graphics View Framework} -
10865*/ -
10866 -
10867class QGraphicsItemGroupPrivate : public QGraphicsItemPrivate -
10868{ -
10869public: -
10870 QRectF itemsBoundingRect; -
10871}; -
10872 -
10873/*! -
10874 Constructs a QGraphicsItemGroup. \a parent is passed to QGraphicsItem's -
10875 constructor. -
10876 -
10877 \sa QGraphicsScene::addItem() -
10878*/ -
10879QGraphicsItemGroup::QGraphicsItemGroup(QGraphicsItem *parent) -
10880 : QGraphicsItem(*new QGraphicsItemGroupPrivate, parent) -
10881{ -
10882 setHandlesChildEvents(true);
never executed (the execution status of this line is deduced): setHandlesChildEvents(true);
-
10883}
never executed: }
0
10884 -
10885/*! -
10886 Destroys the QGraphicsItemGroup. -
10887*/ -
10888QGraphicsItemGroup::~QGraphicsItemGroup() -
10889{ -
10890} -
10891 -
10892/*! -
10893 Adds the given \a item and item's child items to this item group. -
10894 The item and child items will be reparented to this group, but its -
10895 position and transformation relative to the scene will stay intact. -
10896 -
10897 \sa removeFromGroup(), QGraphicsScene::createItemGroup() -
10898*/ -
10899void QGraphicsItemGroup::addToGroup(QGraphicsItem *item) -
10900{ -
10901 Q_D(QGraphicsItemGroup);
never executed (the execution status of this line is deduced): QGraphicsItemGroupPrivate * const d = d_func();
-
10902 if (!item) {
never evaluated: !item
0
10903 qWarning("QGraphicsItemGroup::addToGroup: cannot add null item");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 10903, __PRETTY_FUNCTION__).warning("QGraphicsItemGroup::addToGroup: cannot add null item");
-
10904 return;
never executed: return;
0
10905 } -
10906 if (item == this) {
never evaluated: item == this
0
10907 qWarning("QGraphicsItemGroup::addToGroup: cannot add a group to itself");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 10907, __PRETTY_FUNCTION__).warning("QGraphicsItemGroup::addToGroup: cannot add a group to itself");
-
10908 return;
never executed: return;
0
10909 } -
10910 -
10911 // COMBINE -
10912 bool ok;
never executed (the execution status of this line is deduced): bool ok;
-
10913 QTransform itemTransform = item->itemTransform(this, &ok);
never executed (the execution status of this line is deduced): QTransform itemTransform = item->itemTransform(this, &ok);
-
10914 -
10915 if (!ok) {
never evaluated: !ok
0
10916 qWarning("QGraphicsItemGroup::addToGroup: could not find a valid transformation from item to group coordinates");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 10916, __PRETTY_FUNCTION__).warning("QGraphicsItemGroup::addToGroup: could not find a valid transformation from item to group coordinates");
-
10917 return;
never executed: return;
0
10918 } -
10919 -
10920 QTransform newItemTransform(itemTransform);
never executed (the execution status of this line is deduced): QTransform newItemTransform(itemTransform);
-
10921 item->setPos(mapFromItem(item, 0, 0));
never executed (the execution status of this line is deduced): item->setPos(mapFromItem(item, 0, 0));
-
10922 item->setParentItem(this);
never executed (the execution status of this line is deduced): item->setParentItem(this);
-
10923 -
10924 // removing position from translation component of the new transform -
10925 if (!item->pos().isNull())
never evaluated: !item->pos().isNull()
0
10926 newItemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
never executed: newItemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
0
10927 -
10928 // removing additional transformations properties applied with itemTransform() -
10929 QPointF origin = item->transformOriginPoint();
never executed (the execution status of this line is deduced): QPointF origin = item->transformOriginPoint();
-
10930 QMatrix4x4 m;
never executed (the execution status of this line is deduced): QMatrix4x4 m;
-
10931 QList<QGraphicsTransform*> transformList = item->transformations();
never executed (the execution status of this line is deduced): QList<QGraphicsTransform*> transformList = item->transformations();
-
10932 for (int i = 0; i < transformList.size(); ++i)
never evaluated: i < transformList.size()
0
10933 transformList.at(i)->applyTo(&m);
never executed: transformList.at(i)->applyTo(&m);
0
10934 newItemTransform *= m.toTransform().inverted();
never executed (the execution status of this line is deduced): newItemTransform *= m.toTransform().inverted();
-
10935 newItemTransform.translate(origin.x(), origin.y());
never executed (the execution status of this line is deduced): newItemTransform.translate(origin.x(), origin.y());
-
10936 newItemTransform.rotate(-item->rotation());
never executed (the execution status of this line is deduced): newItemTransform.rotate(-item->rotation());
-
10937 newItemTransform.scale(1/item->scale(), 1/item->scale());
never executed (the execution status of this line is deduced): newItemTransform.scale(1/item->scale(), 1/item->scale());
-
10938 newItemTransform.translate(-origin.x(), -origin.y());
never executed (the execution status of this line is deduced): newItemTransform.translate(-origin.x(), -origin.y());
-
10939 -
10940 // ### Expensive, we could maybe use dirtySceneTransform bit for optimization -
10941 -
10942 item->setTransform(newItemTransform);
never executed (the execution status of this line is deduced): item->setTransform(newItemTransform);
-
10943 item->d_func()->setIsMemberOfGroup(true);
never executed (the execution status of this line is deduced): item->d_func()->setIsMemberOfGroup(true);
-
10944 prepareGeometryChange();
never executed (the execution status of this line is deduced): prepareGeometryChange();
-
10945 d->itemsBoundingRect |= itemTransform.mapRect(item->boundingRect() | item->childrenBoundingRect());
never executed (the execution status of this line is deduced): d->itemsBoundingRect |= itemTransform.mapRect(item->boundingRect() | item->childrenBoundingRect());
-
10946 update();
never executed (the execution status of this line is deduced): update();
-
10947}
never executed: }
0
10948 -
10949/*! -
10950 Removes the specified \a item from this group. The item will be -
10951 reparented to this group's parent item, or to 0 if this group has -
10952 no parent. Its position and transformation relative to the scene -
10953 will stay intact. -
10954 -
10955 \sa addToGroup(), QGraphicsScene::destroyItemGroup() -
10956*/ -
10957void QGraphicsItemGroup::removeFromGroup(QGraphicsItem *item) -
10958{ -
10959 Q_D(QGraphicsItemGroup);
never executed (the execution status of this line is deduced): QGraphicsItemGroupPrivate * const d = d_func();
-
10960 if (!item) {
never evaluated: !item
0
10961 qWarning("QGraphicsItemGroup::removeFromGroup: cannot remove null item");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 10961, __PRETTY_FUNCTION__).warning("QGraphicsItemGroup::removeFromGroup: cannot remove null item");
-
10962 return;
never executed: return;
0
10963 } -
10964 -
10965 QGraphicsItem *newParent = d_ptr->parent;
never executed (the execution status of this line is deduced): QGraphicsItem *newParent = d_ptr->parent;
-
10966 -
10967 // COMBINE -
10968 bool ok;
never executed (the execution status of this line is deduced): bool ok;
-
10969 QTransform itemTransform;
never executed (the execution status of this line is deduced): QTransform itemTransform;
-
10970 if (newParent)
never evaluated: newParent
0
10971 itemTransform = item->itemTransform(newParent, &ok);
never executed: itemTransform = item->itemTransform(newParent, &ok);
0
10972 else -
10973 itemTransform = item->sceneTransform();
never executed: itemTransform = item->sceneTransform();
0
10974 -
10975 QPointF oldPos = item->mapToItem(newParent, 0, 0);
never executed (the execution status of this line is deduced): QPointF oldPos = item->mapToItem(newParent, 0, 0);
-
10976 item->setParentItem(newParent);
never executed (the execution status of this line is deduced): item->setParentItem(newParent);
-
10977 item->setPos(oldPos);
never executed (the execution status of this line is deduced): item->setPos(oldPos);
-
10978 -
10979 // removing position from translation component of the new transform -
10980 if (!item->pos().isNull())
never evaluated: !item->pos().isNull()
0
10981 itemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
never executed: itemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
0
10982 -
10983 // removing additional transformations properties applied -
10984 // with itemTransform() or sceneTransform() -
10985 QPointF origin = item->transformOriginPoint();
never executed (the execution status of this line is deduced): QPointF origin = item->transformOriginPoint();
-
10986 QMatrix4x4 m;
never executed (the execution status of this line is deduced): QMatrix4x4 m;
-
10987 QList<QGraphicsTransform*> transformList = item->transformations();
never executed (the execution status of this line is deduced): QList<QGraphicsTransform*> transformList = item->transformations();
-
10988 for (int i = 0; i < transformList.size(); ++i)
never evaluated: i < transformList.size()
0
10989 transformList.at(i)->applyTo(&m);
never executed: transformList.at(i)->applyTo(&m);
0
10990 itemTransform *= m.toTransform().inverted();
never executed (the execution status of this line is deduced): itemTransform *= m.toTransform().inverted();
-
10991 itemTransform.translate(origin.x(), origin.y());
never executed (the execution status of this line is deduced): itemTransform.translate(origin.x(), origin.y());
-
10992 itemTransform.rotate(-item->rotation());
never executed (the execution status of this line is deduced): itemTransform.rotate(-item->rotation());
-
10993 itemTransform.scale(1 / item->scale(), 1 / item->scale());
never executed (the execution status of this line is deduced): itemTransform.scale(1 / item->scale(), 1 / item->scale());
-
10994 itemTransform.translate(-origin.x(), -origin.y());
never executed (the execution status of this line is deduced): itemTransform.translate(-origin.x(), -origin.y());
-
10995 -
10996 // ### Expensive, we could maybe use dirtySceneTransform bit for optimization -
10997 -
10998 item->setTransform(itemTransform);
never executed (the execution status of this line is deduced): item->setTransform(itemTransform);
-
10999 item->d_func()->setIsMemberOfGroup(item->group() != 0);
never executed (the execution status of this line is deduced): item->d_func()->setIsMemberOfGroup(item->group() != 0);
-
11000 -
11001 // ### Quite expensive. But removeFromGroup() isn't called very often. -
11002 prepareGeometryChange();
never executed (the execution status of this line is deduced): prepareGeometryChange();
-
11003 d->itemsBoundingRect = childrenBoundingRect();
never executed (the execution status of this line is deduced): d->itemsBoundingRect = childrenBoundingRect();
-
11004}
never executed: }
0
11005 -
11006/*! -
11007 \reimp -
11008 -
11009 Returns the bounding rect of this group item, and all its children. -
11010*/ -
11011QRectF QGraphicsItemGroup::boundingRect() const -
11012{ -
11013 Q_D(const QGraphicsItemGroup);
never executed (the execution status of this line is deduced): const QGraphicsItemGroupPrivate * const d = d_func();
-
11014 return d->itemsBoundingRect;
never executed: return d->itemsBoundingRect;
0
11015} -
11016 -
11017/*! -
11018 \reimp -
11019*/ -
11020void QGraphicsItemGroup::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, -
11021 QWidget *widget) -
11022{ -
11023 Q_UNUSED(widget);
never executed (the execution status of this line is deduced): (void)widget;;
-
11024 if (option->state & QStyle::State_Selected) {
never evaluated: option->state & QStyle::State_Selected
0
11025 Q_D(QGraphicsItemGroup);
never executed (the execution status of this line is deduced): QGraphicsItemGroupPrivate * const d = d_func();
-
11026 painter->setBrush(Qt::NoBrush);
never executed (the execution status of this line is deduced): painter->setBrush(Qt::NoBrush);
-
11027 painter->drawRect(d->itemsBoundingRect);
never executed (the execution status of this line is deduced): painter->drawRect(d->itemsBoundingRect);
-
11028 }
never executed: }
0
11029}
never executed: }
0
11030 -
11031/*! -
11032 \reimp -
11033*/ -
11034bool QGraphicsItemGroup::isObscuredBy(const QGraphicsItem *item) const -
11035{ -
11036 return QGraphicsItem::isObscuredBy(item);
never executed: return QGraphicsItem::isObscuredBy(item);
0
11037} -
11038 -
11039/*! -
11040 \reimp -
11041*/ -
11042QPainterPath QGraphicsItemGroup::opaqueArea() const -
11043{ -
11044 return QGraphicsItem::opaqueArea();
never executed: return QGraphicsItem::opaqueArea();
0
11045} -
11046 -
11047/*! -
11048 \reimp -
11049*/ -
11050int QGraphicsItemGroup::type() const -
11051{ -
11052 return Type;
never executed: return Type;
0
11053} -
11054 -
11055#ifndef QT_NO_GRAPHICSEFFECT -
11056QRectF QGraphicsItemEffectSourcePrivate::boundingRect(Qt::CoordinateSystem system) const -
11057{ -
11058 const bool deviceCoordinates = (system == Qt::DeviceCoordinates);
executed (the execution status of this line is deduced): const bool deviceCoordinates = (system == Qt::DeviceCoordinates);
-
11059 if (!info && deviceCoordinates) {
evaluated: !info
TRUEFALSE
yes
Evaluation Count:27
yes
Evaluation Count:35
evaluated: deviceCoordinates
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:26
1-35
11060 // Device coordinates without info not yet supported. -
11061 qWarning("QGraphicsEffectSource::boundingRect: Not yet implemented, lacking device context");
executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 11061, __PRETTY_FUNCTION__).warning("QGraphicsEffectSource::boundingRect: Not yet implemented, lacking device context");
-
11062 return QRectF();
executed: return QRectF();
Execution Count:1
1
11063 } -
11064 -
11065 QRectF rect = item->boundingRect();
executed (the execution status of this line is deduced): QRectF rect = item->boundingRect();
-
11066 if (!item->d_ptr->children.isEmpty())
evaluated: !item->d_ptr->children.isEmpty()
TRUEFALSE
yes
Evaluation Count:19
yes
Evaluation Count:42
19-42
11067 rect |= item->childrenBoundingRect();
executed: rect |= item->childrenBoundingRect();
Execution Count:19
19
11068 -
11069 if (deviceCoordinates) {
evaluated: deviceCoordinates
TRUEFALSE
yes
Evaluation Count:29
yes
Evaluation Count:32
29-32
11070 Q_ASSERT(info->painter);
executed (the execution status of this line is deduced): qt_noop();
-
11071 rect = info->painter->worldTransform().mapRect(rect);
executed (the execution status of this line is deduced): rect = info->painter->worldTransform().mapRect(rect);
-
11072 }
executed: }
Execution Count:29
29
11073 -
11074 return rect;
executed: return rect;
Execution Count:61
61
11075} -
11076 -
11077void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter) -
11078{ -
11079 if (!info) {
evaluated: !info
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:13
1-13
11080 qWarning("QGraphicsEffectSource::draw: Can only begin as a result of QGraphicsEffect::draw");
executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 11080, __PRETTY_FUNCTION__).warning("QGraphicsEffectSource::draw: Can only begin as a result of QGraphicsEffect::draw");
-
11081 return;
executed: return;
Execution Count:1
1
11082 } -
11083 -
11084 Q_ASSERT(item->d_ptr->scene);
executed (the execution status of this line is deduced): qt_noop();
-
11085 QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func();
executed (the execution status of this line is deduced): QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func();
-
11086 if (painter == info->painter) {
partially evaluated: painter == info->painter
TRUEFALSE
yes
Evaluation Count:13
no
Evaluation Count:0
0-13
11087 scened->draw(item, painter, info->viewTransform, info->transformPtr, info->exposedRegion,
executed (the execution status of this line is deduced): scened->draw(item, painter, info->viewTransform, info->transformPtr, info->exposedRegion,
-
11088 info->widget, info->opacity, info->effectTransform, info->wasDirtySceneTransform,
executed (the execution status of this line is deduced): info->widget, info->opacity, info->effectTransform, info->wasDirtySceneTransform,
-
11089 info->drawItem);
executed (the execution status of this line is deduced): info->drawItem);
-
11090 } else {
executed: }
Execution Count:13
13
11091 QTransform effectTransform = info->painter->worldTransform().inverted();
never executed (the execution status of this line is deduced): QTransform effectTransform = info->painter->worldTransform().inverted();
-
11092 effectTransform *= painter->worldTransform();
never executed (the execution status of this line is deduced): effectTransform *= painter->worldTransform();
-
11093 scened->draw(item, painter, info->viewTransform, info->transformPtr, info->exposedRegion,
never executed (the execution status of this line is deduced): scened->draw(item, painter, info->viewTransform, info->transformPtr, info->exposedRegion,
-
11094 info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform,
never executed (the execution status of this line is deduced): info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform,
-
11095 info->drawItem);
never executed (the execution status of this line is deduced): info->drawItem);
-
11096 }
never executed: }
0
11097} -
11098 -
11099// sourceRect must be in the given coordinate system -
11100QRect QGraphicsItemEffectSourcePrivate::paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded) const -
11101{ -
11102 QRectF effectRectF;
executed (the execution status of this line is deduced): QRectF effectRectF;
-
11103 -
11104 if (unpadded)
evaluated: unpadded
TRUEFALSE
yes
Evaluation Count:20
yes
Evaluation Count:9
9-20
11105 *unpadded = false;
executed: *unpadded = false;
Execution Count:20
20
11106 -
11107 if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) {
evaluated: mode == QGraphicsEffect::PadToEffectiveBoundingRect
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:13
13-16
11108 if (info) {
evaluated: info
TRUEFALSE
yes
Evaluation Count:15
yes
Evaluation Count:1
1-15
11109 QRectF deviceRect = system == Qt::DeviceCoordinates ? sourceRect : info->painter->worldTransform().mapRect(sourceRect);
evaluated: system == Qt::DeviceCoordinates
TRUEFALSE
yes
Evaluation Count:12
yes
Evaluation Count:3
3-12
11110 effectRectF = item->graphicsEffect()->boundingRectFor(deviceRect);
executed (the execution status of this line is deduced): effectRectF = item->graphicsEffect()->boundingRectFor(deviceRect);
-
11111 if (unpadded)
evaluated: unpadded
TRUEFALSE
yes
Evaluation Count:13
yes
Evaluation Count:2
2-13
11112 *unpadded = (effectRectF.size() == sourceRect.size());
executed: *unpadded = (effectRectF.size() == sourceRect.size());
Execution Count:13
13
11113 if (info && system == Qt::LogicalCoordinates)
partially evaluated: info
TRUEFALSE
yes
Evaluation Count:15
no
Evaluation Count:0
evaluated: system == Qt::LogicalCoordinates
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:12
0-15
11114 effectRectF = info->painter->worldTransform().inverted().mapRect(effectRectF);
executed: effectRectF = info->painter->worldTransform().inverted().mapRect(effectRectF);
Execution Count:3
3
11115 } else {
executed: }
Execution Count:15
15
11116 // no choice but to send a logical coordinate bounding rect to boundingRectFor -
11117 effectRectF = item->graphicsEffect()->boundingRectFor(sourceRect);
executed (the execution status of this line is deduced): effectRectF = item->graphicsEffect()->boundingRectFor(sourceRect);
-
11118 }
executed: }
Execution Count:1
1
11119 } else if (mode == QGraphicsEffect::PadToTransparentBorder) {
evaluated: mode == QGraphicsEffect::PadToTransparentBorder
TRUEFALSE
yes
Evaluation Count:9
yes
Evaluation Count:4
4-9
11120 // adjust by 1.5 to account for cosmetic pens -
11121 effectRectF = sourceRect.adjusted(-1.5, -1.5, 1.5, 1.5);
executed (the execution status of this line is deduced): effectRectF = sourceRect.adjusted(-1.5, -1.5, 1.5, 1.5);
-
11122 } else {
executed: }
Execution Count:9
9
11123 effectRectF = sourceRect;
executed (the execution status of this line is deduced): effectRectF = sourceRect;
-
11124 if (unpadded)
partially evaluated: unpadded
TRUEFALSE
yes
Evaluation Count:4
no
Evaluation Count:0
0-4
11125 *unpadded = true;
executed: *unpadded = true;
Execution Count:4
4
11126 }
executed: }
Execution Count:4
4
11127 -
11128 return effectRectF.toAlignedRect();
executed: return effectRectF.toAlignedRect();
Execution Count:29
29
11129} -
11130 -
11131QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset, -
11132 QGraphicsEffect::PixmapPadMode mode) const -
11133{ -
11134 const bool deviceCoordinates = (system == Qt::DeviceCoordinates);
executed (the execution status of this line is deduced): const bool deviceCoordinates = (system == Qt::DeviceCoordinates);
-
11135 if (!info && deviceCoordinates) {
evaluated: !info
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:19
partially evaluated: deviceCoordinates
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:1
0-19
11136 // Device coordinates without info not yet supported. -
11137 qWarning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context");
never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 11137, __PRETTY_FUNCTION__).warning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context");
-
11138 return QPixmap();
never executed: return QPixmap();
0
11139 } -
11140 if (!item->d_ptr->scene)
partially evaluated: !item->d_ptr->scene
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:20
0-20
11141 return QPixmap();
never executed: return QPixmap();
0
11142 QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func();
executed (the execution status of this line is deduced): QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func();
-
11143 -
11144 bool unpadded;
executed (the execution status of this line is deduced): bool unpadded;
-
11145 const QRectF sourceRect = boundingRect(system);
executed (the execution status of this line is deduced): const QRectF sourceRect = boundingRect(system);
-
11146 QRect effectRect = paddedEffectRect(system, mode, sourceRect, &unpadded);
executed (the execution status of this line is deduced): QRect effectRect = paddedEffectRect(system, mode, sourceRect, &unpadded);
-
11147 -
11148 if (offset)
partially evaluated: offset
TRUEFALSE
yes
Evaluation Count:20
no
Evaluation Count:0
0-20
11149 *offset = effectRect.topLeft();
executed: *offset = effectRect.topLeft();
Execution Count:20
20
11150 -
11151 bool untransformed = !deviceCoordinates
evaluated: !deviceCoordinates
TRUEFALSE
yes
Evaluation Count:5
yes
Evaluation Count:15
5-15
11152 || info->painter->worldTransform().type() <= QTransform::TxTranslate;
evaluated: info->painter->worldTransform().type() <= QTransform::TxTranslate
TRUEFALSE
yes
Evaluation Count:11
yes
Evaluation Count:4
4-11
11153 if (untransformed && unpadded && isPixmap()) {
evaluated: untransformed
TRUEFALSE
yes
Evaluation Count:16
yes
Evaluation Count:4
evaluated: unpadded
TRUEFALSE
yes
Evaluation Count:6
yes
Evaluation Count:10
evaluated: isPixmap()
TRUEFALSE
yes
Evaluation Count:3
yes
Evaluation Count:3
3-16
11154 if (offset)
partially evaluated: offset
TRUEFALSE
yes
Evaluation Count:3
no
Evaluation Count:0
0-3
11155 *offset = boundingRect(system).topLeft().toPoint();
executed: *offset = boundingRect(system).topLeft().toPoint();
Execution Count:3
3
11156 return static_cast<QGraphicsPixmapItem *>(item)->pixmap();
executed: return static_cast<QGraphicsPixmapItem *>(item)->pixmap();
Execution Count:3
3
11157 } -
11158 -
11159 if (effectRect.isEmpty())
partially evaluated: effectRect.isEmpty()
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:17
0-17
11160 return QPixmap();
never executed: return QPixmap();
0
11161 -
11162 QPixmap pixmap(effectRect.size());
executed (the execution status of this line is deduced): QPixmap pixmap(effectRect.size());
-
11163 pixmap.fill(Qt::transparent);
executed (the execution status of this line is deduced): pixmap.fill(Qt::transparent);
-
11164 QPainter pixmapPainter(&pixmap);
executed (the execution status of this line is deduced): QPainter pixmapPainter(&pixmap);
-
11165 pixmapPainter.setRenderHints(info ? info->painter->renderHints() : QPainter::TextAntialiasing);
executed (the execution status of this line is deduced): pixmapPainter.setRenderHints(info ? info->painter->renderHints() : QPainter::TextAntialiasing);
-
11166 -
11167 QTransform effectTransform = QTransform::fromTranslate(-effectRect.x(), -effectRect.y());
executed (the execution status of this line is deduced): QTransform effectTransform = QTransform::fromTranslate(-effectRect.x(), -effectRect.y());
-
11168 if (deviceCoordinates && info->effectTransform)
evaluated: deviceCoordinates
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:3
partially evaluated: info->effectTransform
TRUEFALSE
no
Evaluation Count:0
yes
Evaluation Count:14
0-14
11169 effectTransform *= *info->effectTransform;
never executed: effectTransform *= *info->effectTransform;
0
11170 -
11171 if (!info) {
evaluated: !info
TRUEFALSE
yes
Evaluation Count:1
yes
Evaluation Count:16
1-16
11172 // Logical coordinates without info. -
11173 QTransform sceneTransform = item->sceneTransform();
executed (the execution status of this line is deduced): QTransform sceneTransform = item->sceneTransform();
-
11174 QTransform newEffectTransform = sceneTransform.inverted();
executed (the execution status of this line is deduced): QTransform newEffectTransform = sceneTransform.inverted();
-
11175 newEffectTransform *= effectTransform;
executed (the execution status of this line is deduced): newEffectTransform *= effectTransform;
-
11176 scened->draw(item, &pixmapPainter, 0, &sceneTransform, 0, 0, qreal(1.0),
executed (the execution status of this line is deduced): scened->draw(item, &pixmapPainter, 0, &sceneTransform, 0, 0, qreal(1.0),
-
11177 &newEffectTransform, false, true);
executed (the execution status of this line is deduced): &newEffectTransform, false, true);
-
11178 } else if (deviceCoordinates) {
executed: }
Execution Count:1
evaluated: deviceCoordinates
TRUEFALSE
yes
Evaluation Count:14
yes
Evaluation Count:2
1-14
11179 // Device coordinates with info. -
11180 scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0,
executed (the execution status of this line is deduced): scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0,
-
11181 info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform,
executed (the execution status of this line is deduced): info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform,
-
11182 info->drawItem);
executed (the execution status of this line is deduced): info->drawItem);
-
11183 } else {
executed: }
Execution Count:14
14
11184 // Item coordinates with info. -
11185 QTransform newEffectTransform = info->transformPtr->inverted();
executed (the execution status of this line is deduced): QTransform newEffectTransform = info->transformPtr->inverted();
-
11186 newEffectTransform *= effectTransform;
executed (the execution status of this line is deduced): newEffectTransform *= effectTransform;
-
11187 scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0,
executed (the execution status of this line is deduced): scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0,
-
11188 info->widget, info->opacity, &newEffectTransform, info->wasDirtySceneTransform,
executed (the execution status of this line is deduced): info->widget, info->opacity, &newEffectTransform, info->wasDirtySceneTransform,
-
11189 info->drawItem);
executed (the execution status of this line is deduced): info->drawItem);
-
11190 }
executed: }
Execution Count:2
2
11191 -
11192 pixmapPainter.end();
executed (the execution status of this line is deduced): pixmapPainter.end();
-
11193 -
11194 return pixmap;
executed: return pixmap;
Execution Count:17
17
11195} -
11196#endif //QT_NO_GRAPHICSEFFECT -
11197 -
11198#ifndef QT_NO_DEBUG_STREAM -
11199QDebug operator<<(QDebug debug, QGraphicsItem *item) -
11200{ -
11201 if (!item) {
never evaluated: !item
0
11202 debug << "QGraphicsItem(0)";
never executed (the execution status of this line is deduced): debug << "QGraphicsItem(0)";
-
11203 return debug;
never executed: return debug;
0
11204 } -
11205 -
11206 if (QGraphicsObject *o = item->toGraphicsObject())
never evaluated: QGraphicsObject *o = item->toGraphicsObject()
0
11207 debug << o->metaObject()->className();
never executed: debug << o->metaObject()->className();
0
11208 else -
11209 debug << "QGraphicsItem";
never executed: debug << "QGraphicsItem";
0
11210 debug << "(this =" << (void*)item
never executed (the execution status of this line is deduced): debug << "(this =" << (void*)item
-
11211 << ", parent =" << (void*)item->parentItem()
never executed (the execution status of this line is deduced): << ", parent =" << (void*)item->parentItem()
-
11212 << ", pos =" << item->pos()
never executed (the execution status of this line is deduced): << ", pos =" << item->pos()
-
11213 << ", z =" << item->zValue() << ", flags = "
never executed (the execution status of this line is deduced): << ", z =" << item->zValue() << ", flags = "
-
11214 << item->flags() << ")";
never executed (the execution status of this line is deduced): << item->flags() << ")";
-
11215 return debug;
never executed: return debug;
0
11216} -
11217 -
11218QDebug operator<<(QDebug debug, QGraphicsObject *item) -
11219{ -
11220 if (!item) {
never evaluated: !item
0
11221 debug << "QGraphicsObject(0)";
never executed (the execution status of this line is deduced): debug << "QGraphicsObject(0)";
-
11222 return debug;
never executed: return debug;
0
11223 } -
11224 -
11225 debug.nospace() << item->metaObject()->className() << '(' << (void*)item;
never executed (the execution status of this line is deduced): debug.nospace() << item->metaObject()->className() << '(' << (void*)item;
-
11226 if (!item->objectName().isEmpty())
never evaluated: !item->objectName().isEmpty()
0
11227 debug << ", name = " << item->objectName();
never executed: debug << ", name = " << item->objectName();
0
11228 debug.nospace() << ", parent = " << ((void*)item->parentItem())
never executed (the execution status of this line is deduced): debug.nospace() << ", parent = " << ((void*)item->parentItem())
-
11229 << ", pos = " << item->pos()
never executed (the execution status of this line is deduced): << ", pos = " << item->pos()
-
11230 << ", z = " << item->zValue() << ", flags = "
never executed (the execution status of this line is deduced): << ", z = " << item->zValue() << ", flags = "
-
11231 << item->flags() << ')';
never executed (the execution status of this line is deduced): << item->flags() << ')';
-
11232 return debug.space();
never executed: return debug.space();
0
11233} -
11234 -
11235QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemChange change) -
11236{ -
11237 const char *str = "UnknownChange";
never executed (the execution status of this line is deduced): const char *str = "UnknownChange";
-
11238 switch (change) { -
11239 case QGraphicsItem::ItemChildAddedChange: -
11240 str = "ItemChildAddedChange";
never executed (the execution status of this line is deduced): str = "ItemChildAddedChange";
-
11241 break;
never executed: break;
0
11242 case QGraphicsItem::ItemChildRemovedChange: -
11243 str = "ItemChildRemovedChange";
never executed (the execution status of this line is deduced): str = "ItemChildRemovedChange";
-
11244 break;
never executed: break;
0
11245 case QGraphicsItem::ItemCursorChange: -
11246 str = "ItemCursorChange";
never executed (the execution status of this line is deduced): str = "ItemCursorChange";
-
11247 break;
never executed: break;
0
11248 case QGraphicsItem::ItemCursorHasChanged: -
11249 str = "ItemCursorHasChanged";
never executed (the execution status of this line is deduced): str = "ItemCursorHasChanged";
-
11250 break;
never executed: break;
0
11251 case QGraphicsItem::ItemEnabledChange: -
11252 str = "ItemEnabledChange";
never executed (the execution status of this line is deduced): str = "ItemEnabledChange";
-
11253 break;
never executed: break;
0
11254 case QGraphicsItem::ItemEnabledHasChanged: -
11255 str = "ItemEnabledHasChanged";
never executed (the execution status of this line is deduced): str = "ItemEnabledHasChanged";
-
11256 break;
never executed: break;
0
11257 case QGraphicsItem::ItemFlagsChange: -
11258 str = "ItemFlagsChange";
never executed (the execution status of this line is deduced): str = "ItemFlagsChange";
-
11259 break;
never executed: break;
0
11260 case QGraphicsItem::ItemFlagsHaveChanged: -
11261 str = "ItemFlagsHaveChanged";
never executed (the execution status of this line is deduced): str = "ItemFlagsHaveChanged";
-
11262 break;
never executed: break;
0
11263 case QGraphicsItem::ItemMatrixChange: -
11264 str = "ItemMatrixChange";
never executed (the execution status of this line is deduced): str = "ItemMatrixChange";
-
11265 break;
never executed: break;
0
11266 case QGraphicsItem::ItemParentChange: -
11267 str = "ItemParentChange";
never executed (the execution status of this line is deduced): str = "ItemParentChange";
-
11268 break;
never executed: break;
0
11269 case QGraphicsItem::ItemParentHasChanged: -
11270 str = "ItemParentHasChanged";
never executed (the execution status of this line is deduced): str = "ItemParentHasChanged";
-
11271 break;
never executed: break;
0
11272 case QGraphicsItem::ItemPositionChange: -
11273 str = "ItemPositionChange";
never executed (the execution status of this line is deduced): str = "ItemPositionChange";
-
11274 break;
never executed: break;
0
11275 case QGraphicsItem::ItemPositionHasChanged: -
11276 str = "ItemPositionHasChanged";
never executed (the execution status of this line is deduced): str = "ItemPositionHasChanged";
-
11277 break;
never executed: break;
0
11278 case QGraphicsItem::ItemSceneChange: -
11279 str = "ItemSceneChange";
never executed (the execution status of this line is deduced): str = "ItemSceneChange";
-
11280 break;
never executed: break;
0
11281 case QGraphicsItem::ItemSceneHasChanged: -
11282 str = "ItemSceneHasChanged";
never executed (the execution status of this line is deduced): str = "ItemSceneHasChanged";
-
11283 break;
never executed: break;
0
11284 case QGraphicsItem::ItemSelectedChange: -
11285 str = "ItemSelectedChange";
never executed (the execution status of this line is deduced): str = "ItemSelectedChange";
-
11286 break;
never executed: break;
0
11287 case QGraphicsItem::ItemSelectedHasChanged: -
11288 str = "ItemSelectedHasChanged";
never executed (the execution status of this line is deduced): str = "ItemSelectedHasChanged";
-
11289 break;
never executed: break;
0
11290 case QGraphicsItem::ItemToolTipChange: -
11291 str = "ItemToolTipChange";
never executed (the execution status of this line is deduced): str = "ItemToolTipChange";
-
11292 break;
never executed: break;
0
11293 case QGraphicsItem::ItemToolTipHasChanged: -
11294 str = "ItemToolTipHasChanged";
never executed (the execution status of this line is deduced): str = "ItemToolTipHasChanged";
-
11295 break;
never executed: break;
0
11296 case QGraphicsItem::ItemTransformChange: -
11297 str = "ItemTransformChange";
never executed (the execution status of this line is deduced): str = "ItemTransformChange";
-
11298 break;
never executed: break;
0
11299 case QGraphicsItem::ItemTransformHasChanged: -
11300 str = "ItemTransformHasChanged";
never executed (the execution status of this line is deduced): str = "ItemTransformHasChanged";
-
11301 break;
never executed: break;
0
11302 case QGraphicsItem::ItemVisibleChange: -
11303 str = "ItemVisibleChange";
never executed (the execution status of this line is deduced): str = "ItemVisibleChange";
-
11304 break;
never executed: break;
0
11305 case QGraphicsItem::ItemVisibleHasChanged: -
11306 str = "ItemVisibleHasChanged";
never executed (the execution status of this line is deduced): str = "ItemVisibleHasChanged";
-
11307 break;
never executed: break;
0
11308 case QGraphicsItem::ItemZValueChange: -
11309 str = "ItemZValueChange";
never executed (the execution status of this line is deduced): str = "ItemZValueChange";
-
11310 break;
never executed: break;
0
11311 case QGraphicsItem::ItemZValueHasChanged: -
11312 str = "ItemZValueHasChanged";
never executed (the execution status of this line is deduced): str = "ItemZValueHasChanged";
-
11313 break;
never executed: break;
0
11314 case QGraphicsItem::ItemOpacityChange: -
11315 str = "ItemOpacityChange";
never executed (the execution status of this line is deduced): str = "ItemOpacityChange";
-
11316 break;
never executed: break;
0
11317 case QGraphicsItem::ItemOpacityHasChanged: -
11318 str = "ItemOpacityHasChanged";
never executed (the execution status of this line is deduced): str = "ItemOpacityHasChanged";
-
11319 break;
never executed: break;
0
11320 case QGraphicsItem::ItemScenePositionHasChanged: -
11321 str = "ItemScenePositionHasChanged";
never executed (the execution status of this line is deduced): str = "ItemScenePositionHasChanged";
-
11322 break;
never executed: break;
0
11323 case QGraphicsItem::ItemRotationChange: -
11324 str = "ItemRotationChange";
never executed (the execution status of this line is deduced): str = "ItemRotationChange";
-
11325 break;
never executed: break;
0
11326 case QGraphicsItem::ItemRotationHasChanged: -
11327 str = "ItemRotationHasChanged";
never executed (the execution status of this line is deduced): str = "ItemRotationHasChanged";
-
11328 break;
never executed: break;
0
11329 case QGraphicsItem::ItemScaleChange: -
11330 str = "ItemScaleChange";
never executed (the execution status of this line is deduced): str = "ItemScaleChange";
-
11331 break;
never executed: break;
0
11332 case QGraphicsItem::ItemScaleHasChanged: -
11333 str = "ItemScaleHasChanged";
never executed (the execution status of this line is deduced): str = "ItemScaleHasChanged";
-
11334 break;
never executed: break;
0
11335 case QGraphicsItem::ItemTransformOriginPointChange: -
11336 str = "ItemTransformOriginPointChange";
never executed (the execution status of this line is deduced): str = "ItemTransformOriginPointChange";
-
11337 break;
never executed: break;
0
11338 case QGraphicsItem::ItemTransformOriginPointHasChanged: -
11339 str = "ItemTransformOriginPointHasChanged";
never executed (the execution status of this line is deduced): str = "ItemTransformOriginPointHasChanged";
-
11340 break;
never executed: break;
0
11341 } -
11342 debug << str;
never executed (the execution status of this line is deduced): debug << str;
-
11343 return debug;
never executed: return debug;
0
11344} -
11345 -
11346QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlag flag) -
11347{ -
11348 const char *str = "UnknownFlag";
never executed (the execution status of this line is deduced): const char *str = "UnknownFlag";
-
11349 switch (flag) { -
11350 case QGraphicsItem::ItemIsMovable: -
11351 str = "ItemIsMovable";
never executed (the execution status of this line is deduced): str = "ItemIsMovable";
-
11352 break;
never executed: break;
0
11353 case QGraphicsItem::ItemIsSelectable: -
11354 str = "ItemIsSelectable";
never executed (the execution status of this line is deduced): str = "ItemIsSelectable";
-
11355 break;
never executed: break;
0
11356 case QGraphicsItem::ItemIsFocusable: -
11357 str = "ItemIsFocusable";
never executed (the execution status of this line is deduced): str = "ItemIsFocusable";
-
11358 break;
never executed: break;
0
11359 case QGraphicsItem::ItemClipsToShape: -
11360 str = "ItemClipsToShape";
never executed (the execution status of this line is deduced): str = "ItemClipsToShape";
-
11361 break;
never executed: break;
0
11362 case QGraphicsItem::ItemClipsChildrenToShape: -
11363 str = "ItemClipsChildrenToShape";
never executed (the execution status of this line is deduced): str = "ItemClipsChildrenToShape";
-
11364 break;
never executed: break;
0
11365 case QGraphicsItem::ItemIgnoresTransformations: -
11366 str = "ItemIgnoresTransformations";
never executed (the execution status of this line is deduced): str = "ItemIgnoresTransformations";
-
11367 break;
never executed: break;
0
11368 case QGraphicsItem::ItemIgnoresParentOpacity: -
11369 str = "ItemIgnoresParentOpacity";
never executed (the execution status of this line is deduced): str = "ItemIgnoresParentOpacity";
-
11370 break;
never executed: break;
0
11371 case QGraphicsItem::ItemDoesntPropagateOpacityToChildren: -
11372 str = "ItemDoesntPropagateOpacityToChildren";
never executed (the execution status of this line is deduced): str = "ItemDoesntPropagateOpacityToChildren";
-
11373 break;
never executed: break;
0
11374 case QGraphicsItem::ItemStacksBehindParent: -
11375 str = "ItemStacksBehindParent";
never executed (the execution status of this line is deduced): str = "ItemStacksBehindParent";
-
11376 break;
never executed: break;
0
11377 case QGraphicsItem::ItemUsesExtendedStyleOption: -
11378 str = "ItemUsesExtendedStyleOption";
never executed (the execution status of this line is deduced): str = "ItemUsesExtendedStyleOption";
-
11379 break;
never executed: break;
0
11380 case QGraphicsItem::ItemHasNoContents: -
11381 str = "ItemHasNoContents";
never executed (the execution status of this line is deduced): str = "ItemHasNoContents";
-
11382 break;
never executed: break;
0
11383 case QGraphicsItem::ItemSendsGeometryChanges: -
11384 str = "ItemSendsGeometryChanges";
never executed (the execution status of this line is deduced): str = "ItemSendsGeometryChanges";
-
11385 break;
never executed: break;
0
11386 case QGraphicsItem::ItemAcceptsInputMethod: -
11387 str = "ItemAcceptsInputMethod";
never executed (the execution status of this line is deduced): str = "ItemAcceptsInputMethod";
-
11388 break;
never executed: break;
0
11389 case QGraphicsItem::ItemNegativeZStacksBehindParent: -
11390 str = "ItemNegativeZStacksBehindParent";
never executed (the execution status of this line is deduced): str = "ItemNegativeZStacksBehindParent";
-
11391 break;
never executed: break;
0
11392 case QGraphicsItem::ItemIsPanel: -
11393 str = "ItemIsPanel";
never executed (the execution status of this line is deduced): str = "ItemIsPanel";
-
11394 break;
never executed: break;
0
11395 case QGraphicsItem::ItemIsFocusScope: -
11396 str = "ItemIsFocusScope";
never executed (the execution status of this line is deduced): str = "ItemIsFocusScope";
-
11397 break;
never executed: break;
0
11398 case QGraphicsItem::ItemSendsScenePositionChanges: -
11399 str = "ItemSendsScenePositionChanges";
never executed (the execution status of this line is deduced): str = "ItemSendsScenePositionChanges";
-
11400 break;
never executed: break;
0
11401 case QGraphicsItem::ItemStopsClickFocusPropagation: -
11402 str = "ItemStopsClickFocusPropagation";
never executed (the execution status of this line is deduced): str = "ItemStopsClickFocusPropagation";
-
11403 break;
never executed: break;
0
11404 case QGraphicsItem::ItemStopsFocusHandling: -
11405 str = "ItemStopsFocusHandling";
never executed (the execution status of this line is deduced): str = "ItemStopsFocusHandling";
-
11406 break;
never executed: break;
0
11407 } -
11408 debug << str;
never executed (the execution status of this line is deduced): debug << str;
-
11409 return debug;
never executed: return debug;
0
11410} -
11411 -
11412QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlags flags) -
11413{ -
11414 debug << '(';
never executed (the execution status of this line is deduced): debug << '(';
-
11415 bool f = false;
never executed (the execution status of this line is deduced): bool f = false;
-
11416 for (int i = 0; i < 17; ++i) {
never evaluated: i < 17
0
11417 if (flags & (1 << i)) {
never evaluated: flags & (1 << i)
0
11418 if (f)
never evaluated: f
0
11419 debug << '|';
never executed: debug << '|';
0
11420 f = true;
never executed (the execution status of this line is deduced): f = true;
-
11421 debug << QGraphicsItem::GraphicsItemFlag(int(flags & (1 << i)));
never executed (the execution status of this line is deduced): debug << QGraphicsItem::GraphicsItemFlag(int(flags & (1 << i)));
-
11422 }
never executed: }
0
11423 }
never executed: }
0
11424 debug << ')';
never executed (the execution status of this line is deduced): debug << ')';
-
11425 return debug;
never executed: return debug;
0
11426} -
11427 -
11428#endif -
11429 -
11430QT_END_NAMESPACE -
11431 -
11432#include "moc_qgraphicsitem.cpp" -
11433 -
11434#endif // QT_NO_GRAPHICSVIEW -
11435 -
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial