OpenCoverage

qgraphicsitem.cpp

Absolute File Name:/home/qt/qt5_coco/qt5/qtbase/src/widgets/graphicsview/qgraphicsitem.cpp
Source codeSwitch to Preprocessed file
LineSourceCount
1/****************************************************************************-
2**-
3** Copyright (C) 2016 The Qt Company Ltd.-
4** Contact: https://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets 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 The Qt Company. For licensing terms-
14** and conditions see https://www.qt.io/terms-conditions. For further-
15** information use the contact form at https://www.qt.io/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 3 as published by the Free Software-
20** Foundation and appearing in the file LICENSE.LGPL3 included in the-
21** packaging of this file. Please review the following information to-
22** ensure the GNU Lesser General Public License version 3 requirements-
23** will be met: https://www.gnu.org/licenses/lgpl-3.0.html.-
24**-
25** GNU General Public License Usage-
26** Alternatively, this file may be used under the terms of the GNU-
27** General Public License version 2.0 or (at your option) the GNU General-
28** Public license version 3 or any later version approved by the KDE Free-
29** Qt Foundation. The licenses are as published by the Free Software-
30** Foundation and appearing in the file LICENSE.GPL2 and LICENSE.GPL3-
31** included in the packaging of this file. Please review the following-
32** information to ensure the GNU General Public License requirements will-
33** be met: https://www.gnu.org/licenses/gpl-2.0.html and-
34** https://www.gnu.org/licenses/gpl-3.0.html.-
35**-
36** $QT_END_LICENSE$-
37**-
38****************************************************************************/-
39-
40/*!-
41 \class QGraphicsItem-
42 \brief The QGraphicsItem class is the base class for all graphical-
43 items in a QGraphicsScene.-
44 \since 4.2-
45-
46 \ingroup graphicsview-api-
47 \inmodule QtWidgets-
48-
49 It provides a light-weight foundation for writing your own custom items.-
50 This includes defining the item's geometry, collision detection, its-
51 painting implementation and item interaction through its event handlers.-
52 QGraphicsItem is part of the \l{Graphics View Framework}-
53-
54 \image graphicsview-items.png-
55-
56 For convenience, Qt provides a set of standard graphics items for the most-
57 common shapes. These are:-
58-
59 \list-
60 \li QGraphicsEllipseItem provides an ellipse item-
61 \li QGraphicsLineItem provides a line item-
62 \li QGraphicsPathItem provides an arbitrary path item-
63 \li QGraphicsPixmapItem provides a pixmap item-
64 \li QGraphicsPolygonItem provides a polygon item-
65 \li QGraphicsRectItem provides a rectangular item-
66 \li QGraphicsSimpleTextItem provides a simple text label item-
67 \li QGraphicsTextItem provides an advanced text browser item-
68 \endlist-
69-
70 All of an item's geometric information is based on its local coordinate-
71 system. The item's position, pos(), is the only function that does not-
72 operate in local coordinates, as it returns a position in parent-
73 coordinates. \l {The Graphics View Coordinate System} describes the coordinate-
74 system in detail.-
75-
76 You can set whether an item should be visible (i.e., drawn, and accepting-
77 events), by calling setVisible(). Hiding an item will also hide its-
78 children. Similarly, you can enable or disable an item by calling-
79 setEnabled(). If you disable an item, all its children will also be-
80 disabled. By default, items are both visible and enabled. To toggle-
81 whether an item is selected or not, first enable selection by setting-
82 the ItemIsSelectable flag, and then call setSelected(). Normally,-
83 selection is toggled by the scene, as a result of user interaction.-
84-
85 To write your own graphics item, you first create a subclass of-
86 QGraphicsItem, and then start by implementing its two pure virtual public-
87 functions: boundingRect(), which returns an estimate of the area painted-
88 by the item, and paint(), which implements the actual painting. For-
89 example:-
90-
91 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 0-
92-
93 The boundingRect() function has many different purposes.-
94 QGraphicsScene bases its item index on boundingRect(), and-
95 QGraphicsView uses it both for culling invisible items, and for-
96 determining the area that needs to be recomposed when drawing-
97 overlapping items. In addition, QGraphicsItem's collision-
98 detection mechanisms use boundingRect() to provide an efficient-
99 cut-off. The fine grained collision algorithm in-
100 collidesWithItem() is based on calling shape(), which returns an-
101 accurate outline of the item's shape as a QPainterPath.-
102-
103 QGraphicsScene expects all items boundingRect() and shape() to-
104 remain unchanged unless it is notified. If you want to change an-
105 item's geometry in any way, you must first call-
106 prepareGeometryChange() to allow QGraphicsScene to update its-
107 bookkeeping.-
108-
109 Collision detection can be done in two ways:-
110-
111 \list 1-
112-
113 \li Reimplement shape() to return an accurate shape for your item,-
114 and rely on the default implementation of collidesWithItem() to do-
115 shape-shape intersection. This can be rather expensive if the-
116 shapes are complex.-
117-
118 \li Reimplement collidesWithItem() to provide your own custom item-
119 and shape collision algorithm.-
120-
121 \endlist-
122-
123 The contains() function can be called to determine whether the item \e-
124 contains a point or not. This function can also be reimplemented by the-
125 item. The default behavior of contains() is based on calling shape().-
126-
127 Items can contain other items, and also be contained by other items. All-
128 items can have a parent item and a list of children. Unless the item has-
129 no parent, its position is in \e parent coordinates (i.e., the parent's-
130 local coordinates). Parent items propagate both their position and their-
131 transformation to all children.-
132-
133 \image graphicsview-parentchild.png-
134-
135 \target Transformations-
136 \section1 Transformations-
137-
138 QGraphicsItem supports projective transformations in addition to its base-
139 position, pos(). There are several ways to change an item's transformation.-
140 For simple transformations, you can call either of the convenience-
141 functions setRotation() or setScale(), or you can pass any transformation-
142 matrix to setTransform(). For advanced transformation control you also have-
143 the option of setting several combined transformations by calling-
144 setTransformations().-
145-
146 Item transformations accumulate from parent to child, so if both a parent-
147 and child item are rotated 90 degrees, the child's total transformation-
148 will be 180 degrees. Similarly, if the item's parent is scaled to 2x its-
149 original size, its children will also be twice as large. An item's-
150 transformation does not affect its own local geometry; all geometry-
151 functions (e.g., contains(), update(), and all the mapping functions) still-
152 operate in local coordinates. For convenience, QGraphicsItem provides the-
153 functions sceneTransform(), which returns the item's total transformation-
154 matrix (including its position and all parents' positions and-
155 transformations), and scenePos(), which returns its position in scene-
156 coordinates. To reset an item's matrix, call resetTransform().-
157-
158 Certain transformation operations produce a different outcome depending on-
159 the order in which they are applied. For example, if you scale an-
160 transform, and then rotate it, you may get a different result than if the-
161 transform was rotated first. However, the order you set the transformation-
162 properties on QGraphicsItem does not affect the resulting transformation;-
163 QGraphicsItem always applies the properties in a fixed, defined order:-
164-
165 \list-
166 \li The item's base transform is applied (transform())-
167 \li The item's transformations list is applied in order (transformations())-
168 \li The item is rotated relative to its transform origin point (rotation(), transformOriginPoint())-
169 \li The item is scaled relative to its transform origin point (scale(), transformOriginPoint())-
170 \endlist-
171-
172 \section1 Painting-
173-
174 The paint() function is called by QGraphicsView to paint the item's-
175 contents. The item has no background or default fill of its own; whatever-
176 is behind the item will shine through all areas that are not explicitly-
177 painted in this function. You can call update() to schedule a repaint,-
178 optionally passing the rectangle that needs a repaint. Depending on-
179 whether or not the item is visible in a view, the item may or may not be-
180 repainted; there is no equivalent to QWidget::repaint() in QGraphicsItem.-
181-
182 Items are painted by the view, starting with the parent items and then-
183 drawing children, in ascending stacking order. You can set an item's-
184 stacking order by calling setZValue(), and test it by calling-
185 zValue(), where items with low z-values are painted before items with-
186 high z-values. Stacking order applies to sibling items; parents are always-
187 drawn before their children.-
188-
189 \section1 Sorting-
190-
191 All items are drawn in a defined, stable order, and this same order decides-
192 which items will receive mouse input first when you click on the scene.-
193 Normally you don't have to worry about sorting, as the items follow a-
194 "natural order", following the logical structure of the scene.-
195-
196 An item's children are stacked on top of the parent, and sibling items are-
197 stacked by insertion order (i.e., in the same order that they were either-
198 added to the scene, or added to the same parent). If you add item A, and-
199 then B, then B will be on top of A. If you then add C, the items' stacking-
200 order will be A, then B, then C.-
201-
202 \image graphicsview-zorder.png-
203-
204 This example shows the stacking order of all limbs of the robot from the-
205 \l{graphicsview/dragdroprobot}{Drag and Drop Robot} example. The torso is-
206 the root item (all other items are children or descendants of the torso),-
207 so it is drawn first. Next, the head is drawn, as it is the first item in-
208 the torso's list of children. Then the upper left arm is drawn. As the-
209 lower arm is a child of the upper arm, the lower arm is then drawn,-
210 followed by the upper arm's next sibling, which is the upper right arm, and-
211 so on.-
212-
213 For advanced users, there are ways to alter how your items are sorted:-
214-
215 \list-
216 \li You can call setZValue() on an item to explicitly stack it on top of, or-
217 under, other sibling items. The default Z value for an item is 0. Items-
218 with the same Z value are stacked by insertion order.-
219-
220 \li You can call stackBefore() to reorder the list of children. This will-
221 directly modify the insertion order.-
222-
223 \li You can set the ItemStacksBehindParent flag to stack a child item behind-
224 its parent.-
225 \endlist-
226-
227 The stacking order of two sibling items also counts for each item's-
228 children and descendant items. So if one item is on top of another, then-
229 all its children will also be on top of all the other item's children as-
230 well.-
231-
232 \section1 Events-
233-
234 QGraphicsItem receives events from QGraphicsScene through the virtual-
235 function sceneEvent(). This function distributes the most common events-
236 to a set of convenience event handlers:-
237-
238 \list-
239 \li contextMenuEvent() handles context menu events-
240 \li focusInEvent() and focusOutEvent() handle focus in and out events-
241 \li hoverEnterEvent(), hoverMoveEvent(), and hoverLeaveEvent() handles-
242 hover enter, move and leave events-
243 \li inputMethodEvent() handles input events, for accessibility support-
244 \li keyPressEvent() and keyReleaseEvent() handle key press and release events-
245 \li mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(), and-
246 mouseDoubleClickEvent() handles mouse press, move, release, click and-
247 doubleclick events-
248 \endlist-
249-
250 You can filter events for any other item by installing event filters. This-
251 functionality is separate from Qt's regular event filters (see-
252 QObject::installEventFilter()), which only work on subclasses of QObject. After-
253 installing your item as an event filter for another item by calling-
254 installSceneEventFilter(), the filtered events will be received by the virtual-
255 function sceneEventFilter(). You can remove item event filters by calling-
256 removeSceneEventFilter().-
257-
258 \section1 Custom Data-
259-
260 Sometimes it's useful to register custom data with an item, be it a custom-
261 item, or a standard item. You can call setData() on any item to store data-
262 in it using a key-value pair (the key being an integer, and the value is a-
263 QVariant). To get custom data from an item, call data(). This-
264 functionality is completely untouched by Qt itself; it is provided for the-
265 user's convenience.-
266-
267 \sa QGraphicsScene, QGraphicsView, {Graphics View Framework}-
268*/-
269-
270/*!-
271 \variable QGraphicsItem::Type-
272-
273 The type value returned by the virtual type() function in standard-
274 graphics item classes in Qt. All such standard graphics item-
275 classes in Qt are associated with a unique value for Type,-
276 e.g. the value returned by QGraphicsPathItem::type() is 2.-
277-
278 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 18-
279*/-
280-
281/*!-
282 \variable QGraphicsItem::UserType-
283-
284 The lowest permitted type value for custom items (subclasses-
285 of QGraphicsItem or any of the standard items). This value is-
286 used in conjunction with a reimplementation of QGraphicsItem::type()-
287 and declaring a Type enum value. Example:-
288-
289 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 1-
290-
291 \note UserType = 65536-
292*/-
293-
294/*!-
295 \enum QGraphicsItem::GraphicsItemFlag-
296-
297 This enum describes different flags that you can set on an item to-
298 toggle different features in the item's behavior.-
299-
300 All flags are disabled by default.-
301-
302 \value ItemIsMovable The item supports interactive movement using-
303 the mouse. By clicking on the item and then dragging, the item-
304 will move together with the mouse cursor. If the item has-
305 children, all children are also moved. If the item is part of a-
306 selection, all selected items are also moved. This feature is-
307 provided as a convenience through the base implementation of-
308 QGraphicsItem's mouse event handlers.-
309-
310 \value ItemIsSelectable The item supports selection. Enabling this-
311 feature will enable setSelected() to toggle selection for the-
312 item. It will also let the item be selected automatically as a-
313 result of calling QGraphicsScene::setSelectionArea(), by clicking-
314 on an item, or by using rubber band selection in QGraphicsView.-
315-
316 \value ItemIsFocusable The item supports keyboard input focus (i.e., it is-
317 an input item). Enabling this flag will allow the item to accept focus,-
318 which again allows the delivery of key events to-
319 QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent().-
320-
321 \value ItemClipsToShape The item clips to its own shape. The item cannot-
322 draw or receive mouse, tablet, drag and drop or hover events outside its-
323 shape. It is disabled by default. This behavior is enforced by-
324 QGraphicsView::drawItems() or QGraphicsScene::drawItems(). This flag was-
325 introduced in Qt 4.3.-
326-
327 \value ItemClipsChildrenToShape The item clips the painting of all its-
328 descendants to its own shape. Items that are either direct or indirect-
329 children of this item cannot draw outside this item's shape. By default,-
330 this flag is disabled; children can draw anywhere. This behavior is-
331 enforced by QGraphicsView::drawItems() or-
332 QGraphicsScene::drawItems(). This flag was introduced in Qt 4.3.-
333 \note This flag is similar to ItemContainsChildrenInShape but in addition-
334 enforces the containment by clipping the children.-
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 \c 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 \value ItemContainsChildrenInShape This flag indicates that all of the-
428 item's direct or indirect children only draw within the item's shape.-
429 Unlike ItemClipsChildrenToShape, this restriction is not enforced. Set-
430 ItemContainsChildrenInShape when you manually assure that drawing-
431 is bound to the item's shape and want to avoid the cost associated with-
432 enforcing the clip. Setting this flag enables more efficient drawing and-
433 collision detection. The flag is disabled by default.-
434 \note If both this flag and ItemClipsChildrenToShape are set, the clip-
435 will be enforced. This is equivalent to just setting-
436 ItemClipsChildrenToShape.-
437-
438 This flag was introduced in Qt 5.4.-
439*/-
440-
441/*!-
442 \enum QGraphicsItem::GraphicsItemChange-
443-
444 This enum describes the state changes that are notified by-
445 QGraphicsItem::itemChange(). The notifications are sent as the state-
446 changes, and in some cases, adjustments can be made (see the documentation-
447 for each change for details).-
448-
449 Note: Be careful with calling functions on the QGraphicsItem itself inside-
450 itemChange(), as certain function calls can lead to unwanted-
451 recursion. For example, you cannot call setPos() in itemChange() on an-
452 ItemPositionChange notification, as the setPos() function will again call-
453 itemChange(ItemPositionChange). Instead, you can return the new, adjusted-
454 position from itemChange().-
455-
456 \value ItemEnabledChange The item's enabled state changes. If the item is-
457 presently enabled, it will become disabled, and vice verca. The value-
458 argument is the new enabled state (i.e., true or false). Do not call-
459 setEnabled() in itemChange() as this notification is delivered. Instead,-
460 you can return the new state from itemChange().-
461-
462 \value ItemEnabledHasChanged The item's enabled state has changed. The-
463 value argument is the new enabled state (i.e., true or false). Do not call-
464 setEnabled() in itemChange() as this notification is delivered. The return-
465 value is ignored.-
466-
467 \value ItemMatrixChange The item's affine transformation matrix is-
468 changing. This value is obsolete; you can use ItemTransformChange instead.-
469-
470 \value ItemPositionChange The item's position changes. This notification-
471 is sent if the ItemSendsGeometryChanges flag is enabled, and when the-
472 item's local position changes, relative to its parent (i.e., as a result-
473 of calling setPos() or moveBy()). The value argument is the new position-
474 (i.e., a QPointF). You can call pos() to get the original position. Do-
475 not call setPos() or moveBy() in itemChange() as this notification is-
476 delivered; instead, you can return the new, adjusted position from-
477 itemChange(). After this notification, QGraphicsItem immediately sends the-
478 ItemPositionHasChanged notification if the position changed.-
479-
480 \value ItemPositionHasChanged The item's position has changed. This-
481 notification is sent if the ItemSendsGeometryChanges flag is enabled, and-
482 after the item's local position, relative to its parent, has changed. The-
483 value argument is the new position (the same as pos()), and QGraphicsItem-
484 ignores the return value for this notification (i.e., a read-only-
485 notification).-
486-
487 \value ItemTransformChange The item's transformation matrix changes. This-
488 notification is sent if the ItemSendsGeometryChanges flag is enabled, and-
489 when the item's local transformation matrix changes (i.e., as a result of-
490 calling setTransform(). The value argument is the new matrix (i.e., a-
491 QTransform); to get the old matrix, call transform(). Do not call-
492 setTransform() or set any of the transformation properties in itemChange()-
493 as this notification is delivered; instead, you can return the new matrix-
494 from itemChange(). This notification is not sent if you change the-
495 transformation properties.-
496-
497 \value ItemTransformHasChanged The item's transformation matrix has-
498 changed either because setTransform is called, or one of the-
499 transformation properties is changed. This notification is sent if the-
500 ItemSendsGeometryChanges flag is enabled, and after the item's local-
501 transformation matrix has changed. The value argument is the new matrix-
502 (same as transform()), and QGraphicsItem ignores the return value for this-
503 notification (i.e., a read-only notification).-
504-
505 \value ItemRotationChange The item's rotation property changes. This-
506 notification is sent if the ItemSendsGeometryChanges flag is enabled, and-
507 when the item's rotation property changes (i.e., as a result of calling-
508 setRotation()). The value argument is the new rotation (i.e., a double);-
509 to get the old rotation, call rotation(). Do not call setRotation() in-
510 itemChange() as this notification is delivered; instead, you can return-
511 the new rotation from itemChange().-
512-
513 \value ItemRotationHasChanged The item's rotation property has changed.-
514 This notification is sent if the ItemSendsGeometryChanges flag is enabled,-
515 and after the item's rotation property has changed. The value argument is-
516 the new rotation (i.e., a double), and QGraphicsItem ignores the return-
517 value for this notification (i.e., a read-only notification). Do not call-
518 setRotation() in itemChange() as this notification is delivered.-
519-
520 \value ItemScaleChange The item's scale property changes. This notification-
521 is sent if the ItemSendsGeometryChanges flag is enabled, and when the item's-
522 scale property changes (i.e., as a result of calling setScale()). The value-
523 argument is the new scale (i.e., a double); to get the old scale, call-
524 scale(). Do not call setScale() in itemChange() as this notification is-
525 delivered; instead, you can return the new scale from itemChange().-
526-
527 \value ItemScaleHasChanged The item's scale property has changed. This-
528 notification is sent if the ItemSendsGeometryChanges flag is enabled, and-
529 after the item's scale property has changed. The value argument is the new-
530 scale (i.e., a double), and QGraphicsItem ignores the return value for this-
531 notification (i.e., a read-only notification). Do not call setScale() in-
532 itemChange() as this notification is delivered.-
533-
534 \value ItemTransformOriginPointChange The item's transform origin point-
535 property changes. This notification is sent if the ItemSendsGeometryChanges-
536 flag is enabled, and when the item's transform origin point property changes-
537 (i.e., as a result of calling setTransformOriginPoint()). The value argument-
538 is the new origin point (i.e., a QPointF); to get the old origin point, call-
539 transformOriginPoint(). Do not call setTransformOriginPoint() in itemChange()-
540 as this notification is delivered; instead, you can return the new transform-
541 origin point from itemChange().-
542-
543 \value ItemTransformOriginPointHasChanged The item's transform origin point-
544 property has changed. This notification is sent if the ItemSendsGeometryChanges-
545 flag is enabled, and after the item's transform origin point property has-
546 changed. The value argument is the new origin point (i.e., a QPointF), and-
547 QGraphicsItem ignores the return value for this notification (i.e., a read-only-
548 notification). Do not call setTransformOriginPoint() in itemChange() as this-
549 notification is delivered.-
550-
551 \value ItemSelectedChange The item's selected state changes. If the item is-
552 presently selected, it will become unselected, and vice verca. The value-
553 argument is the new selected state (i.e., true or false). Do not call-
554 setSelected() in itemChange() as this notification is delivered; instead, you-
555 can return the new selected state from itemChange().-
556-
557 \value ItemSelectedHasChanged The item's selected state has changed. The-
558 value argument is the new selected state (i.e., true or false). Do not-
559 call setSelected() in itemChange() as this notification is delivered. The-
560 return value is ignored.-
561-
562 \value ItemVisibleChange The item's visible state changes. If the item is-
563 presently visible, it will become invisible, and vice verca. The value-
564 argument is the new visible state (i.e., true or false). Do not call-
565 setVisible() in itemChange() as this notification is delivered; instead,-
566 you can return the new visible state from itemChange().-
567-
568 \value ItemVisibleHasChanged The item's visible state has changed. The-
569 value argument is the new visible state (i.e., true or false). Do not call-
570 setVisible() in itemChange() as this notification is delivered. The return-
571 value is ignored.-
572-
573 \value ItemParentChange The item's parent changes. The value argument is-
574 the new parent item (i.e., a QGraphicsItem pointer). Do not call-
575 setParentItem() in itemChange() as this notification is delivered;-
576 instead, you can return the new parent from itemChange().-
577-
578 \value ItemParentHasChanged The item's parent has changed. The value-
579 argument is the new parent (i.e., a pointer to a QGraphicsItem). Do not-
580 call setParentItem() in itemChange() as this notification is-
581 delivered. The return value is ignored.-
582-
583 \value ItemChildAddedChange A child is added to this item. The value-
584 argument is the new child item (i.e., a QGraphicsItem pointer). Do not-
585 pass this item to any item's setParentItem() function as this notification-
586 is delivered. The return value is unused; you cannot adjust anything in-
587 this notification. Note that the new child might not be fully constructed-
588 when this notification is sent; calling pure virtual functions on-
589 the child can lead to a crash.-
590-
591 \value ItemChildRemovedChange A child is removed from this item. The value-
592 argument is the child item that is about to be removed (i.e., a-
593 QGraphicsItem pointer). The return value is unused; you cannot adjust-
594 anything in this notification.-
595-
596 \value ItemSceneChange The item is moved to a new scene. This notification is-
597 also sent when the item is added to its initial scene, and when it is removed.-
598 The item's scene() is the old scene (or 0 if the item has not been added to a-
599 scene yet). The value argument is the new scene (i.e., a QGraphicsScene-
600 pointer), or a null pointer if the item is removed from a scene. Do not-
601 override this change by passing this item to QGraphicsScene::addItem() as this-
602 notification is delivered; instead, you can return the new scene from-
603 itemChange(). Use this feature with caution; objecting to a scene change can-
604 quickly lead to unwanted recursion.-
605-
606 \value ItemSceneHasChanged The item's scene has changed. The item's scene() is-
607 the new scene. This notification is also sent when the item is added to its-
608 initial scene, and when it is removed.The value argument is the new scene-
609 (i.e., a pointer to a QGraphicsScene). Do not call setScene() in itemChange()-
610 as this notification is delivered. The return value is ignored.-
611-
612 \value ItemCursorChange The item's cursor changes. The value argument is-
613 the new cursor (i.e., a QCursor). Do not call setCursor() in itemChange()-
614 as this notification is delivered. Instead, you can return a new cursor-
615 from itemChange().-
616-
617 \value ItemCursorHasChanged The item's cursor has changed. The value-
618 argument is the new cursor (i.e., a QCursor). Do not call setCursor() as-
619 this notification is delivered. The return value is ignored.-
620-
621 \value ItemToolTipChange The item's tooltip changes. The value argument is-
622 the new tooltip (i.e., a QToolTip). Do not call setToolTip() in-
623 itemChange() as this notification is delivered. Instead, you can return a-
624 new tooltip from itemChange().-
625-
626 \value ItemToolTipHasChanged The item's tooltip has changed. The value-
627 argument is the new tooltip (i.e., a QToolTip). Do not call setToolTip()-
628 as this notification is delivered. The return value is ignored.-
629-
630 \value ItemFlagsChange The item's flags change. The value argument is the-
631 new flags (i.e., a quint32). Do not call setFlags() in itemChange() as-
632 this notification is delivered. Instead, you can return the new flags from-
633 itemChange().-
634-
635 \value ItemFlagsHaveChanged The item's flags have changed. The value-
636 argument is the new flags (i.e., a quint32). Do not call setFlags() in-
637 itemChange() as this notification is delivered. The return value is-
638 ignored.-
639-
640 \value ItemZValueChange The item's Z-value changes. The value argument is-
641 the new Z-value (i.e., a double). Do not call setZValue() in itemChange()-
642 as this notification is delivered. Instead, you can return a new Z-value-
643 from itemChange().-
644-
645 \value ItemZValueHasChanged The item's Z-value has changed. The value-
646 argument is the new Z-value (i.e., a double). Do not call setZValue() as-
647 this notification is delivered. The return value is ignored.-
648-
649 \value ItemOpacityChange The item's opacity changes. The value argument is-
650 the new opacity (i.e., a double). Do not call setOpacity() in itemChange()-
651 as this notification is delivered. Instead, you can return a new opacity-
652 from itemChange().-
653-
654 \value ItemOpacityHasChanged The item's opacity has changed. The value-
655 argument is the new opacity (i.e., a double). Do not call setOpacity() as-
656 this notification is delivered. The return value is ignored.-
657-
658 \value ItemScenePositionHasChanged The item's scene position has changed.-
659 This notification is sent if the ItemSendsScenePositionChanges flag is-
660 enabled, and after the item's scene position has changed (i.e., the-
661 position or transformation of the item itself or the position or-
662 transformation of any ancestor has changed). The value argument is the-
663 new scene position (the same as scenePos()), and QGraphicsItem ignores-
664 the return value for this notification (i.e., a read-only notification).-
665*/-
666-
667/*!-
668 \enum QGraphicsItem::CacheMode-
669 \since 4.4-
670-
671 This enum describes QGraphicsItem's cache modes. Caching is used to speed-
672 up rendering by allocating and rendering to an off-screen pixel buffer,-
673 which can be reused when the item requires redrawing. For some paint-
674 devices, the cache is stored directly in graphics memory, which makes-
675 rendering very quick.-
676-
677 \value NoCache The default; all item caching is-
678 disabled. QGraphicsItem::paint() is called every time the item needs-
679 redrawing.-
680-
681 \value ItemCoordinateCache Caching is enabled for the item's logical-
682 (local) coordinate system. QGraphicsItem creates an off-screen pixel-
683 buffer with a configurable size / resolution that you can pass to-
684 QGraphicsItem::setCacheMode(). Rendering quality will typically degrade,-
685 depending on the resolution of the cache and the item transformation. The-
686 first time the item is redrawn, it will render itself into the cache, and-
687 the cache is then reused for every subsequent expose. The cache is also-
688 reused as the item is transformed. To adjust the resolution of the cache,-
689 you can call setCacheMode() again.-
690-
691 \value DeviceCoordinateCache Caching is enabled at the paint device level,-
692 in device coordinates. This mode is for items that can move, but are not-
693 rotated, scaled or sheared. If the item is transformed directly or-
694 indirectly, the cache will be regenerated automatically. Unlike-
695 ItemCoordinateCacheMode, DeviceCoordinateCache always renders at maximum-
696 quality.-
697-
698 \sa QGraphicsItem::setCacheMode()-
699*/-
700-
701/*!-
702 \enum QGraphicsItem::Extension-
703 \internal-
704-
705 Note: This is provided as a hook to avoid future problems related-
706 to adding virtual functions. See also extension(),-
707 supportsExtension() and setExtension().-
708*/-
709-
710/*!-
711 \enum QGraphicsItem::PanelModality-
712 \since 4.6-
713-
714 This enum specifies the behavior of a modal panel. A modal panel-
715 is one that blocks input to other panels. Note that items that-
716 are children of a modal panel are not blocked.-
717-
718 The values are:-
719-
720 \value NonModal The panel is not modal and does not block input to-
721 other panels. This is the default value for panels.-
722-
723 \value PanelModal The panel is modal to a single item hierarchy-
724 and blocks input to its parent pane, all grandparent panels, and-
725 all siblings of its parent and grandparent panels.-
726-
727 \value SceneModal The window is modal to the entire scene and-
728 blocks input to all panels.-
729-
730 \sa QGraphicsItem::setPanelModality(), QGraphicsItem::panelModality(), QGraphicsItem::ItemIsPanel-
731*/-
732-
733#include "qgraphicsitem.h"-
734-
735#ifndef QT_NO_GRAPHICSVIEW-
736-
737#include "qgraphicsscene.h"-
738#include "qgraphicsscene_p.h"-
739#include "qgraphicssceneevent.h"-
740#include "qgraphicsview.h"-
741#include "qgraphicswidget.h"-
742#include "qgraphicsproxywidget.h"-
743#include "qgraphicsscenebsptreeindex_p.h"-
744#include <QtCore/qbitarray.h>-
745#include <QtCore/qpoint.h>-
746#include <QtCore/qstack.h>-
747#include <QtCore/qtimer.h>-
748#include <QtCore/qvariant.h>-
749#include <QtCore/qvarlengtharray.h>-
750#include <QtCore/qnumeric.h>-
751#include <QtWidgets/qapplication.h>-
752#include <QtGui/qbitmap.h>-
753#include <QtGui/qpainter.h>-
754#include <QtGui/qpainterpath.h>-
755#include <QtGui/qpixmapcache.h>-
756#include <QtWidgets/qstyleoption.h>-
757#include <QtGui/qevent.h>-
758#include <QtGui/qinputmethod.h>-
759#include <QtWidgets/qgraphicseffect.h>-
760-
761#include <private/qgraphicsitem_p.h>-
762#include <private/qgraphicswidget_p.h>-
763#include <private/qwidgettextcontrol_p.h>-
764#include <private/qtextdocumentlayout_p.h>-
765#include <private/qtextengine_p.h>-
766#include <private/qwidget_p.h>-
767#include <private/qapplication_p.h>-
768#include <private/qgesturemanager_p.h>-
769#include <private/qdebug_p.h>-
770-
771QT_BEGIN_NAMESPACE-
772-
773static inline void _q_adjustRect(QRect *rect)-
774{-
775 Q_ASSERT(rect);-
776 if (!rect->width())
!rect->width()Description
TRUEnever evaluated
FALSEnever evaluated
0
777 rect->adjust(0, 0, 1, 0);
never executed: rect->adjust(0, 0, 1, 0);
0
778 if (!rect->height())
!rect->height()Description
TRUEnever evaluated
FALSEnever evaluated
0
779 rect->adjust(0, 0, 0, 1);
never executed: rect->adjust(0, 0, 0, 1);
0
780}
never executed: end of block
0
781-
782/*-
783 ### Move this into QGraphicsItemPrivate-
784 */-
785class QGraphicsItemCustomDataStore-
786{-
787public:-
788 QHash<const QGraphicsItem *, QMap<int, QVariant> > data;-
789};-
790Q_GLOBAL_STATIC(QGraphicsItemCustomDataStore, qt_dataStore)
never executed: end of block
never executed: guard.store(QtGlobalStatic::Destroyed);
never executed: return &holder.value;
guard.load() =...c::InitializedDescription
TRUEnever evaluated
FALSEnever evaluated
0
791-
792/*!-
793 \internal-
794-
795 Returns a QPainterPath of \a path when stroked with the \a pen.-
796 Ignoring dash pattern.-
797*/-
798static QPainterPath qt_graphicsItem_shapeFromPath(const QPainterPath &path, const QPen &pen)-
799{-
800 // We unfortunately need this hack as QPainterPathStroker will set a width of 1.0-
801 // if we pass a value of 0.0 to QPainterPathStroker::setWidth()-
802 const qreal penWidthZero = qreal(0.00000001);-
803-
804 if (path == QPainterPath() || pen == Qt::NoPen)
path == QPainterPath()Description
TRUEnever evaluated
FALSEnever evaluated
pen == Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
0
805 return path;
never executed: return path;
0
806 QPainterPathStroker ps;-
807 ps.setCapStyle(pen.capStyle());-
808 if (pen.widthF() <= 0.0)
pen.widthF() <= 0.0Description
TRUEnever evaluated
FALSEnever evaluated
0
809 ps.setWidth(penWidthZero);
never executed: ps.setWidth(penWidthZero);
0
810 else-
811 ps.setWidth(pen.widthF());
never executed: ps.setWidth(pen.widthF());
0
812 ps.setJoinStyle(pen.joinStyle());-
813 ps.setMiterLimit(pen.miterLimit());-
814 QPainterPath p = ps.createStroke(path);-
815 p.addPath(path);-
816 return p;
never executed: return p;
0
817}-
818-
819/*!-
820 \internal-
821*/-
822QGraphicsItemPrivate::QGraphicsItemPrivate()-
823 : z(0),-
824 opacity(1.),-
825 scene(nullptr),-
826 parent(nullptr),-
827 transformData(nullptr),-
828 graphicsEffect(nullptr),-
829 index(-1),-
830 siblingIndex(-1),-
831 itemDepth(-1),-
832 focusProxy(nullptr),-
833 subFocusItem(nullptr),-
834 focusScopeItem(nullptr),-
835 imHints(Qt::ImhNone),-
836 panelModality(QGraphicsItem::NonModal),-
837 acceptedMouseButtons(0x1f),-
838 visible(true),-
839 explicitlyHidden(false),-
840 enabled(true),-
841 explicitlyDisabled(false),-
842 selected(false),-
843 acceptsHover(false),-
844 acceptDrops(false),-
845 isMemberOfGroup(false),-
846 handlesChildEvents(false),-
847 itemDiscovered(false),-
848 hasCursor(false),-
849 ancestorFlags(0),-
850 cacheMode(0),-
851 hasBoundingRegionGranularity(false),-
852 isWidget(false),-
853 dirty(false),-
854 dirtyChildren(false),-
855 localCollisionHack(false),-
856 inSetPosHelper(false),-
857 needSortChildren(false),-
858 allChildrenDirty(false),-
859 fullUpdatePending(false),-
860 flags(0),-
861 paintedViewBoundingRectsNeedRepaint(false),-
862 dirtySceneTransform(true),-
863 geometryChanged(true),-
864 inDestructor(false),-
865 isObject(false),-
866 ignoreVisible(false),-
867 ignoreOpacity(false),-
868 acceptTouchEvents(false),-
869 acceptedTouchBeginEvent(false),-
870 filtersDescendantEvents(false),-
871 sceneTransformTranslateOnly(false),-
872 notifyBoundingRectChanged(false),-
873 notifyInvalidated(false),-
874 mouseSetsFocus(true),-
875 explicitActivate(false),-
876 wantsActive(false),-
877 holesInSiblingIndex(false),-
878 sequentialOrdering(true),-
879 updateDueToGraphicsEffect(false),-
880 scenePosDescendants(false),-
881 pendingPolish(false),-
882 mayHaveChildWithGraphicsEffect(false),-
883 isDeclarativeItem(false),-
884 sendParentChangeNotification(false),-
885 dirtyChildrenBoundingRect(true),-
886 globalStackingOrder(-1),-
887 q_ptr(nullptr)-
888{-
889}
never executed: end of block
0
890-
891/*!-
892 \internal-
893*/-
894QGraphicsItemPrivate::~QGraphicsItemPrivate()-
895{-
896}-
897-
898/*!-
899 \internal-
900-
901 Propagates the ancestor flag \a flag with value \a enabled to all this-
902 item's children. If \a root is false, the flag is also set on this item-
903 (default is true).-
904*/-
905void QGraphicsItemPrivate::updateAncestorFlag(QGraphicsItem::GraphicsItemFlag childFlag,-
906 AncestorFlag flag, bool enabled, bool root)-
907{-
908 Q_Q(QGraphicsItem);-
909 if (root) {
rootDescription
TRUEnever evaluated
FALSEnever evaluated
0
910 // For root items only. This is the item that has either enabled or-
911 // disabled \a childFlag, or has been reparented.-
912 switch (int(childFlag)) {-
913 case -2:
never executed: case -2:
0
914 flag = AncestorFiltersChildEvents;-
915 enabled = q->filtersChildEvents();-
916 break;
never executed: break;
0
917 case -1:
never executed: case -1:
0
918 flag = AncestorHandlesChildEvents;-
919 enabled = q->handlesChildEvents();-
920 break;
never executed: break;
0
921 case QGraphicsItem::ItemClipsChildrenToShape:
never executed: case QGraphicsItem::ItemClipsChildrenToShape:
0
922 flag = AncestorClipsChildren;-
923 enabled = flags & QGraphicsItem::ItemClipsChildrenToShape;-
924 break;
never executed: break;
0
925 case QGraphicsItem::ItemIgnoresTransformations:
never executed: case QGraphicsItem::ItemIgnoresTransformations:
0
926 flag = AncestorIgnoresTransformations;-
927 enabled = flags & QGraphicsItem::ItemIgnoresTransformations;-
928 break;
never executed: break;
0
929 case QGraphicsItem::ItemContainsChildrenInShape:
never executed: case QGraphicsItem::ItemContainsChildrenInShape:
0
930 flag = AncestorContainsChildren;-
931 enabled = flags & QGraphicsItem::ItemContainsChildrenInShape;-
932 break;
never executed: break;
0
933 default:
never executed: default:
0
934 return;
never executed: return;
0
935 }-
936-
937 if (parent) {
parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
938 // Inherit the enabled-state from our parents.-
939 if ((parent->d_ptr->ancestorFlags & flag)
(parent->d_ptr...rFlags & flag)Description
TRUEnever evaluated
FALSEnever evaluated
0
940 || (int(parent->d_ptr->flags & childFlag) == childFlag)
(int(parent->d... == childFlag)Description
TRUEnever evaluated
FALSEnever evaluated
0
941 || (int(childFlag) == -1 && parent->d_ptr->handlesChildEvents)
int(childFlag) == -1Description
TRUEnever evaluated
FALSEnever evaluated
parent->d_ptr-...lesChildEventsDescription
TRUEnever evaluated
FALSEnever evaluated
0
942 || (int(childFlag) == -2 && parent->d_ptr->filtersDescendantEvents)) {
int(childFlag) == -2Description
TRUEnever evaluated
FALSEnever evaluated
parent->d_ptr-...scendantEventsDescription
TRUEnever evaluated
FALSEnever evaluated
0
943 enabled = true;-
944 ancestorFlags |= flag;-
945 } else {
never executed: end of block
0
946 ancestorFlags &= ~flag;-
947 }
never executed: end of block
0
948 } else {-
949 // Top-level root items don't have any ancestors, so there are no-
950 // ancestor flags either.-
951 ancestorFlags = 0;-
952 }
never executed: end of block
0
953 } else {-
954 // Don't set or propagate the ancestor flag if it's already correct.-
955 if (((ancestorFlags & flag) && enabled) || (!(ancestorFlags & flag) && !enabled))
(ancestorFlags & flag)Description
TRUEnever evaluated
FALSEnever evaluated
enabledDescription
TRUEnever evaluated
FALSEnever evaluated
!(ancestorFlags & flag)Description
TRUEnever evaluated
FALSEnever evaluated
!enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
956 return;
never executed: return;
0
957-
958 // Set the flag.-
959 if (enabled)
enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
960 ancestorFlags |= flag;
never executed: ancestorFlags |= flag;
0
961 else-
962 ancestorFlags &= ~flag;
never executed: ancestorFlags &= ~flag;
0
963-
964 // Don't process children if the item has the main flag set on itself.-
965 if ((int(childFlag) != -1 && int(flags & childFlag) == childFlag)
int(childFlag) != -1Description
TRUEnever evaluated
FALSEnever evaluated
int(flags & ch...) == childFlagDescription
TRUEnever evaluated
FALSEnever evaluated
0
966 || (int(childFlag) == -1 && handlesChildEvents)
int(childFlag) == -1Description
TRUEnever evaluated
FALSEnever evaluated
handlesChildEventsDescription
TRUEnever evaluated
FALSEnever evaluated
0
967 || (int(childFlag) == -2 && filtersDescendantEvents))
int(childFlag) == -2Description
TRUEnever evaluated
FALSEnever evaluated
filtersDescendantEventsDescription
TRUEnever evaluated
FALSEnever evaluated
0
968 return;
never executed: return;
0
969 }
never executed: end of block
0
970-
971 for (int i = 0; i < children.size(); ++i)
i < children.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
972 children.at(i)->d_ptr->updateAncestorFlag(childFlag, flag, enabled, false);
never executed: children.at(i)->d_ptr->updateAncestorFlag(childFlag, flag, enabled, false);
0
973}
never executed: end of block
0
974-
975void QGraphicsItemPrivate::updateAncestorFlags()-
976{-
977 int flags = 0;-
978 if (parent) {
parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
979 // Inherit the parent's ancestor flags.-
980 QGraphicsItemPrivate *pd = parent->d_ptr.data();-
981 flags = pd->ancestorFlags;-
982-
983 // Add in flags from the parent.-
984 if (pd->filtersDescendantEvents)
pd->filtersDescendantEventsDescription
TRUEnever evaluated
FALSEnever evaluated
0
985 flags |= AncestorFiltersChildEvents;
never executed: flags |= AncestorFiltersChildEvents;
0
986 if (pd->handlesChildEvents)
pd->handlesChildEventsDescription
TRUEnever evaluated
FALSEnever evaluated
0
987 flags |= AncestorHandlesChildEvents;
never executed: flags |= AncestorHandlesChildEvents;
0
988 if (pd->flags & QGraphicsItem::ItemClipsChildrenToShape)
pd->flags & QG...hildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
989 flags |= AncestorClipsChildren;
never executed: flags |= AncestorClipsChildren;
0
990 if (pd->flags & QGraphicsItem::ItemIgnoresTransformations)
pd->flags & QG...ransformationsDescription
TRUEnever evaluated
FALSEnever evaluated
0
991 flags |= AncestorIgnoresTransformations;
never executed: flags |= AncestorIgnoresTransformations;
0
992 if (pd->flags & QGraphicsItem::ItemContainsChildrenInShape)
pd->flags & QG...hildrenInShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
993 flags |= AncestorContainsChildren;
never executed: flags |= AncestorContainsChildren;
0
994 }
never executed: end of block
0
995-
996 if (ancestorFlags == flags)
ancestorFlags == flagsDescription
TRUEnever evaluated
FALSEnever evaluated
0
997 return; // No change; stop propagation.
never executed: return;
0
998 ancestorFlags = flags;-
999-
1000 // Propagate to children recursively.-
1001 for (int i = 0; i < children.size(); ++i)
i < children.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1002 children.at(i)->d_ptr->updateAncestorFlags();
never executed: children.at(i)->d_ptr->updateAncestorFlags();
0
1003}
never executed: end of block
0
1004-
1005/*!-
1006 \internal-
1007-
1008 Propagates item group membership.-
1009*/-
1010void QGraphicsItemPrivate::setIsMemberOfGroup(bool enabled)-
1011{-
1012 Q_Q(QGraphicsItem);-
1013 isMemberOfGroup = enabled;-
1014 if (!qgraphicsitem_cast<QGraphicsItemGroup *>(q)) {
!qgraphicsitem...temGroup *>(q)Description
TRUEnever evaluated
FALSEnever evaluated
0
1015 foreach (QGraphicsItem *child, children)-
1016 child->d_func()->setIsMemberOfGroup(enabled);
never executed: child->d_func()->setIsMemberOfGroup(enabled);
0
1017 }
never executed: end of block
0
1018}
never executed: end of block
0
1019-
1020/*!-
1021 \internal-
1022-
1023 Maps any item pos properties of \a event to \a item's coordinate system.-
1024*/-
1025void QGraphicsItemPrivate::remapItemPos(QEvent *event, QGraphicsItem *item)-
1026{-
1027 Q_Q(QGraphicsItem);-
1028 switch (event->type()) {-
1029 case QEvent::GraphicsSceneMouseMove:
never executed: case QEvent::GraphicsSceneMouseMove:
0
1030 case QEvent::GraphicsSceneMousePress:
never executed: case QEvent::GraphicsSceneMousePress:
0
1031 case QEvent::GraphicsSceneMouseRelease:
never executed: case QEvent::GraphicsSceneMouseRelease:
0
1032 case QEvent::GraphicsSceneMouseDoubleClick: {
never executed: case QEvent::GraphicsSceneMouseDoubleClick:
0
1033 QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);-
1034 mouseEvent->setPos(item->mapFromItem(q, mouseEvent->pos()));-
1035 mouseEvent->setLastPos(item->mapFromItem(q, mouseEvent->pos()));-
1036 for (int i = 0x1; i <= 0x10; i <<= 1) {
i <= 0x10Description
TRUEnever evaluated
FALSEnever evaluated
0
1037 if (mouseEvent->buttons() & i) {
mouseEvent->buttons() & iDescription
TRUEnever evaluated
FALSEnever evaluated
0
1038 Qt::MouseButton button = Qt::MouseButton(i);-
1039 mouseEvent->setButtonDownPos(button, item->mapFromItem(q, mouseEvent->buttonDownPos(button)));-
1040 }
never executed: end of block
0
1041 }
never executed: end of block
0
1042 break;
never executed: break;
0
1043 }-
1044 case QEvent::GraphicsSceneWheel: {
never executed: case QEvent::GraphicsSceneWheel:
0
1045 QGraphicsSceneWheelEvent *wheelEvent = static_cast<QGraphicsSceneWheelEvent *>(event);-
1046 wheelEvent->setPos(item->mapFromItem(q, wheelEvent->pos()));-
1047 break;
never executed: break;
0
1048 }-
1049 case QEvent::GraphicsSceneContextMenu: {
never executed: case QEvent::GraphicsSceneContextMenu:
0
1050 QGraphicsSceneContextMenuEvent *contextEvent = static_cast<QGraphicsSceneContextMenuEvent *>(event);-
1051 contextEvent->setPos(item->mapFromItem(q, contextEvent->pos()));-
1052 break;
never executed: break;
0
1053 }-
1054 case QEvent::GraphicsSceneHoverMove: {
never executed: case QEvent::GraphicsSceneHoverMove:
0
1055 QGraphicsSceneHoverEvent *hoverEvent = static_cast<QGraphicsSceneHoverEvent *>(event);-
1056 hoverEvent->setPos(item->mapFromItem(q, hoverEvent->pos()));-
1057 break;
never executed: break;
0
1058 }-
1059 default:
never executed: default:
0
1060 break;
never executed: break;
0
1061 }-
1062}-
1063-
1064/*!-
1065 \internal-
1066-
1067 Maps the point \a pos from scene to item coordinates. If \a view is passed and the item-
1068 is untransformable, this function will correctly map \a pos from the scene using the-
1069 view's transformation.-
1070*/-
1071QPointF QGraphicsItemPrivate::genericMapFromScene(const QPointF &pos,-
1072 const QWidget *viewport) const-
1073{-
1074 Q_Q(const QGraphicsItem);-
1075 if (!itemIsUntransformable())
!itemIsUntransformable()Description
TRUEnever evaluated
FALSEnever evaluated
0
1076 return q->mapFromScene(pos);
never executed: return q->mapFromScene(pos);
0
1077 QGraphicsView *view = 0;-
1078 if (viewport)
viewportDescription
TRUEnever evaluated
FALSEnever evaluated
0
1079 view = qobject_cast<QGraphicsView *>(viewport->parentWidget());
never executed: view = qobject_cast<QGraphicsView *>(viewport->parentWidget());
0
1080 if (!view)
!viewDescription
TRUEnever evaluated
FALSEnever evaluated
0
1081 return q->mapFromScene(pos);
never executed: return q->mapFromScene(pos);
0
1082 // ### More ping pong than needed.-
1083 return q->deviceTransform(view->viewportTransform()).inverted().map(view->mapFromScene(pos));
never executed: return q->deviceTransform(view->viewportTransform()).inverted().map(view->mapFromScene(pos));
0
1084}-
1085-
1086/*!-
1087 \internal-
1088-
1089 Combines this item's position and transform onto \a transform.-
1090-
1091 If you need to change this function (e.g., adding more transformation-
1092 modes / options), make sure to change all places marked with COMBINE.-
1093*/-
1094void QGraphicsItemPrivate::combineTransformToParent(QTransform *x, const QTransform *viewTransform) const-
1095{-
1096 // COMBINE-
1097 if (viewTransform && itemIsUntransformable()) {
viewTransformDescription
TRUEnever evaluated
FALSEnever evaluated
itemIsUntransformable()Description
TRUEnever evaluated
FALSEnever evaluated
0
1098 *x = q_ptr->deviceTransform(*viewTransform);-
1099 } else {
never executed: end of block
0
1100 if (transformData)
transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
1101 *x *= transformData->computedFullTransform();
never executed: *x *= transformData->computedFullTransform();
0
1102 if (!pos.isNull())
!pos.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1103 *x *= QTransform::fromTranslate(pos.x(), pos.y());
never executed: *x *= QTransform::fromTranslate(pos.x(), pos.y());
0
1104 }
never executed: end of block
0
1105}-
1106-
1107/*!-
1108 \internal-
1109-
1110 Combines this item's position and transform onto \a transform.-
1111-
1112 If you need to change this function (e.g., adding more transformation-
1113 modes / options), make sure to change QGraphicsItem::deviceTransform() as-
1114 well.-
1115*/-
1116void QGraphicsItemPrivate::combineTransformFromParent(QTransform *x, const QTransform *viewTransform) const-
1117{-
1118 // COMBINE-
1119 if (viewTransform && itemIsUntransformable()) {
viewTransformDescription
TRUEnever evaluated
FALSEnever evaluated
itemIsUntransformable()Description
TRUEnever evaluated
FALSEnever evaluated
0
1120 *x = q_ptr->deviceTransform(*viewTransform);-
1121 } else {
never executed: end of block
0
1122 x->translate(pos.x(), pos.y());-
1123 if (transformData)
transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
1124 *x = transformData->computedFullTransform(x);
never executed: *x = transformData->computedFullTransform(x);
0
1125 }
never executed: end of block
0
1126}-
1127-
1128void QGraphicsItemPrivate::updateSceneTransformFromParent()-
1129{-
1130 if (parent) {
parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1131 Q_ASSERT(!parent->d_ptr->dirtySceneTransform);-
1132 if (parent->d_ptr->sceneTransformTranslateOnly) {
parent->d_ptr-...mTranslateOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1133 sceneTransform = QTransform::fromTranslate(parent->d_ptr->sceneTransform.dx() + pos.x(),-
1134 parent->d_ptr->sceneTransform.dy() + pos.y());-
1135 } else {
never executed: end of block
0
1136 sceneTransform = parent->d_ptr->sceneTransform;-
1137 sceneTransform.translate(pos.x(), pos.y());-
1138 }
never executed: end of block
0
1139 if (transformData) {
transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
1140 sceneTransform = transformData->computedFullTransform(&sceneTransform);-
1141 sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);-
1142 } else {
never executed: end of block
0
1143 sceneTransformTranslateOnly = parent->d_ptr->sceneTransformTranslateOnly;-
1144 }
never executed: end of block
0
1145 } else if (!transformData) {
!transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
1146 sceneTransform = QTransform::fromTranslate(pos.x(), pos.y());-
1147 sceneTransformTranslateOnly = 1;-
1148 } else if (transformData->onlyTransform) {
never executed: end of block
transformData->onlyTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
1149 sceneTransform = transformData->transform;-
1150 if (!pos.isNull())
!pos.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1151 sceneTransform *= QTransform::fromTranslate(pos.x(), pos.y());
never executed: sceneTransform *= QTransform::fromTranslate(pos.x(), pos.y());
0
1152 sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);-
1153 } else if (pos.isNull()) {
never executed: end of block
pos.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1154 sceneTransform = transformData->computedFullTransform();-
1155 sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);-
1156 } else {
never executed: end of block
0
1157 sceneTransform = QTransform::fromTranslate(pos.x(), pos.y());-
1158 sceneTransform = transformData->computedFullTransform(&sceneTransform);-
1159 sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);-
1160 }
never executed: end of block
0
1161 dirtySceneTransform = 0;-
1162}
never executed: end of block
0
1163-
1164/*!-
1165 \internal-
1166-
1167 Make sure not to trigger any pure virtual function calls (e.g.,-
1168 prepareGeometryChange) if the item is in its destructor, i.e.-
1169 inDestructor is 1.-
1170*/-
1171void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const QVariant *newParentVariant,-
1172 const QVariant *thisPointerVariant)-
1173{-
1174 Q_Q(QGraphicsItem);-
1175 if (newParent == parent)
newParent == parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1176 return;
never executed: return;
0
1177-
1178 if (isWidget)
isWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1179 static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent &&
never executed: static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent && newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0, scene);
0
1180 newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0,
never executed: static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent && newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0, scene);
0
1181 scene);
never executed: static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent && newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0, scene);
0
1182 if (scene) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
1183 // Deliver the change to the index-
1184 if (scene->d_func()->indexMethod != QGraphicsScene::NoIndex)
scene->d_func(...Scene::NoIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
1185 scene->d_func()->index->itemChange(q, QGraphicsItem::ItemParentChange, newParent);
never executed: scene->d_func()->index->itemChange(q, QGraphicsItem::ItemParentChange, newParent);
0
1186-
1187 // Disable scene pos notifications for old ancestors-
1188 if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges))
scenePosDescendantsDescription
TRUEnever evaluated
FALSEnever evaluated
(flags & QGrap...sitionChanges)Description
TRUEnever evaluated
FALSEnever evaluated
0
1189 scene->d_func()->setScenePosItemEnabled(q, false);
never executed: scene->d_func()->setScenePosItemEnabled(q, false);
0
1190 }
never executed: end of block
0
1191-
1192 if (subFocusItem && parent) {
subFocusItemDescription
TRUEnever evaluated
FALSEnever evaluated
parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1193 // Make sure none of the old parents point to this guy.-
1194 subFocusItem->d_ptr->clearSubFocus(parent);-
1195 }
never executed: end of block
0
1196-
1197 // We anticipate geometry changes. If the item is deleted, it will be-
1198 // removed from the index at a later stage, and the whole scene will be-
1199 // updated.-
1200 if (!inDestructor)
!inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
0
1201 q_ptr->prepareGeometryChange();
never executed: q_ptr->prepareGeometryChange();
0
1202-
1203 if (parent) {
parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1204 // Remove from current parent-
1205 parent->d_ptr->removeChild(q);-
1206 if (thisPointerVariant)
thisPointerVariantDescription
TRUEnever evaluated
FALSEnever evaluated
0
1207 parent->itemChange(QGraphicsItem::ItemChildRemovedChange, *thisPointerVariant);
never executed: parent->itemChange(QGraphicsItem::ItemChildRemovedChange, *thisPointerVariant);
0
1208 }
never executed: end of block
0
1209-
1210 // Update toplevelitem list. If this item is being deleted, its parent-
1211 // will be 0 but we don't want to register/unregister it in the TLI list.-
1212 if (scene && !inDestructor) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
!inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
0
1213 if (parent && !newParent) {
parentDescription
TRUEnever evaluated
FALSEnever evaluated
!newParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1214 scene->d_func()->registerTopLevelItem(q);-
1215 } else if (!parent && newParent) {
never executed: end of block
!parentDescription
TRUEnever evaluated
FALSEnever evaluated
newParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1216 scene->d_func()->unregisterTopLevelItem(q);-
1217 }
never executed: end of block
0
1218 }
never executed: end of block
0
1219-
1220 // Ensure any last parent focus scope does not point to this item or any of-
1221 // its descendents.-
1222 QGraphicsItem *p = parent;-
1223 QGraphicsItem *parentFocusScopeItem = 0;-
1224 while (p) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
0
1225 if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) {
p->d_ptr->flag...emIsFocusScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1226 // If this item's focus scope's focus scope item points-
1227 // to this item or a descendent, then clear it.-
1228 QGraphicsItem *fsi = p->d_ptr->focusScopeItem;-
1229 if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) {
q_ptr == fsiDescription
TRUEnever evaluated
FALSEnever evaluated
q_ptr->isAncestorOf(fsi)Description
TRUEnever evaluated
FALSEnever evaluated
0
1230 parentFocusScopeItem = fsi;-
1231 p->d_ptr->focusScopeItem = 0;-
1232 fsi->d_ptr->focusScopeItemChange(false);-
1233 }
never executed: end of block
0
1234 break;
never executed: break;
0
1235 }-
1236 p = p->d_ptr->parent;-
1237 }
never executed: end of block
0
1238-
1239 // Update graphics effect optimization flag-
1240 if (newParent && (graphicsEffect || mayHaveChildWithGraphicsEffect))
newParentDescription
TRUEnever evaluated
FALSEnever evaluated
graphicsEffectDescription
TRUEnever evaluated
FALSEnever evaluated
mayHaveChildWithGraphicsEffectDescription
TRUEnever evaluated
FALSEnever evaluated
0
1241 newParent->d_ptr->updateChildWithGraphicsEffectFlagRecursively();
never executed: newParent->d_ptr->updateChildWithGraphicsEffectFlagRecursively();
0
1242-
1243 // Update focus scope item ptr in new scope.-
1244 QGraphicsItem *newFocusScopeItem = subFocusItem ? subFocusItem : parentFocusScopeItem;
subFocusItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
1245 if (newFocusScopeItem && newParent) {
newFocusScopeItemDescription
TRUEnever evaluated
FALSEnever evaluated
newParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1246 QGraphicsItem *p = newParent;-
1247 while (p) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
0
1248 if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) {
p->d_ptr->flag...emIsFocusScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1249 if (subFocusItem && subFocusItem != q_ptr) {
subFocusItemDescription
TRUEnever evaluated
FALSEnever evaluated
subFocusItem != q_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
1250 // Find the subFocusItem's topmost focus scope within the new parent's focusscope-
1251 QGraphicsItem *ancestorScope = 0;-
1252 QGraphicsItem *p2 = subFocusItem->d_ptr->parent;-
1253 while (p2 && p2 != p) {
p2Description
TRUEnever evaluated
FALSEnever evaluated
p2 != pDescription
TRUEnever evaluated
FALSEnever evaluated
0
1254 if (p2->d_ptr->flags & QGraphicsItem::ItemIsFocusScope)
p2->d_ptr->fla...emIsFocusScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1255 ancestorScope = p2;
never executed: ancestorScope = p2;
0
1256 if (p2->d_ptr->flags & QGraphicsItem::ItemIsPanel)
p2->d_ptr->fla...m::ItemIsPanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1257 break;
never executed: break;
0
1258 if (p2 == q_ptr)
p2 == q_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
1259 break;
never executed: break;
0
1260 p2 = p2->d_ptr->parent;-
1261 }
never executed: end of block
0
1262 if (ancestorScope)
ancestorScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1263 newFocusScopeItem = ancestorScope;
never executed: newFocusScopeItem = ancestorScope;
0
1264 }
never executed: end of block
0
1265-
1266 p->d_ptr->focusScopeItem = newFocusScopeItem;-
1267 newFocusScopeItem->d_ptr->focusScopeItemChange(true);-
1268 // Ensure the new item is no longer the subFocusItem. The-
1269 // only way to set focus on a child of a focus scope is-
1270 // by setting focus on the scope itself.-
1271 if (subFocusItem && !p->focusItem())
subFocusItemDescription
TRUEnever evaluated
FALSEnever evaluated
!p->focusItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
1272 subFocusItem->d_ptr->clearSubFocus();
never executed: subFocusItem->d_ptr->clearSubFocus();
0
1273 break;
never executed: break;
0
1274 }-
1275 p = p->d_ptr->parent;-
1276 }
never executed: end of block
0
1277 }
never executed: end of block
0
1278-
1279 // Resolve depth.-
1280 invalidateDepthRecursively();-
1281-
1282 if ((parent = newParent)) {
(parent = newParent)Description
TRUEnever evaluated
FALSEnever evaluated
0
1283 if (parent->d_func()->scene && parent->d_func()->scene != scene) {
parent->d_func()->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
parent->d_func...scene != sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
1284 // Move this item to its new parent's scene-
1285 parent->d_func()->scene->addItem(q);-
1286 } else if (!parent->d_func()->scene && scene) {
never executed: end of block
!parent->d_func()->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
1287 // Remove this item from its former scene-
1288 scene->removeItem(q);-
1289 }
never executed: end of block
0
1290-
1291 parent->d_ptr->addChild(q);-
1292 if (thisPointerVariant)
thisPointerVariantDescription
TRUEnever evaluated
FALSEnever evaluated
0
1293 parent->itemChange(QGraphicsItem::ItemChildAddedChange, *thisPointerVariant);
never executed: parent->itemChange(QGraphicsItem::ItemChildAddedChange, *thisPointerVariant);
0
1294 if (scene) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
1295 // Re-enable scene pos notifications for new ancestors-
1296 if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges))
scenePosDescendantsDescription
TRUEnever evaluated
FALSEnever evaluated
(flags & QGrap...sitionChanges)Description
TRUEnever evaluated
FALSEnever evaluated
0
1297 scene->d_func()->setScenePosItemEnabled(q, true);
never executed: scene->d_func()->setScenePosItemEnabled(q, true);
0
1298 }
never executed: end of block
0
1299-
1300 // Propagate dirty flags to the new parent-
1301 markParentDirty(/*updateBoundingRect=*/true);-
1302-
1303 // Inherit ancestor flags from the new parent.-
1304 updateAncestorFlags();-
1305-
1306 // Update item visible / enabled.-
1307 if (parent->d_ptr->visible != visible) {
parent->d_ptr-...ble != visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1308 if (!parent->d_ptr->visible || !explicitlyHidden)
!parent->d_ptr->visibleDescription
TRUEnever evaluated
FALSEnever evaluated
!explicitlyHiddenDescription
TRUEnever evaluated
FALSEnever evaluated
0
1309 setVisibleHelper(parent->d_ptr->visible, /* explicit = */ false, /* update = */ false);
never executed: setVisibleHelper(parent->d_ptr->visible, false, false);
0
1310 }
never executed: end of block
0
1311 if (parent->isEnabled() != enabled) {
parent->isEnabled() != enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1312 if (!parent->d_ptr->enabled || !explicitlyDisabled)
!parent->d_ptr->enabledDescription
TRUEnever evaluated
FALSEnever evaluated
!explicitlyDisabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1313 setEnabledHelper(parent->d_ptr->enabled, /* explicit = */ false, /* update = */ false);
never executed: setEnabledHelper(parent->d_ptr->enabled, false, false);
0
1314 }
never executed: end of block
0
1315-
1316 // Auto-activate if visible and the parent is active.-
1317 if (visible && parent->isActive())
visibleDescription
TRUEnever evaluated
FALSEnever evaluated
parent->isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
1318 q->setActive(true);
never executed: q->setActive(true);
0
1319 } else {
never executed: end of block
0
1320 // Inherit ancestor flags from the new parent.-
1321 updateAncestorFlags();-
1322-
1323 if (!inDestructor) {
!inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
0
1324 // Update item visible / enabled.-
1325 if (!visible && !explicitlyHidden)
!visibleDescription
TRUEnever evaluated
FALSEnever evaluated
!explicitlyHiddenDescription
TRUEnever evaluated
FALSEnever evaluated
0
1326 setVisibleHelper(true, /* explicit = */ false);
never executed: setVisibleHelper(true, false);
0
1327 if (!enabled && !explicitlyDisabled)
!enabledDescription
TRUEnever evaluated
FALSEnever evaluated
!explicitlyDisabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1328 setEnabledHelper(true, /* explicit = */ false);
never executed: setEnabledHelper(true, false);
0
1329 }
never executed: end of block
0
1330 }
never executed: end of block
0
1331-
1332 dirtySceneTransform = 1;-
1333 if (!inDestructor && (transformData || (newParent && newParent->d_ptr->transformData)))
!inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
newParentDescription
TRUEnever evaluated
FALSEnever evaluated
newParent->d_p...>transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
1334 transformChanged();
never executed: transformChanged();
0
1335-
1336 // Restore the sub focus chain.-
1337 if (subFocusItem) {
subFocusItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
1338 subFocusItem->d_ptr->setSubFocus(newParent);-
1339 if (parent && parent->isActive())
parentDescription
TRUEnever evaluated
FALSEnever evaluated
parent->isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
1340 subFocusItem->setFocus();
never executed: subFocusItem->setFocus();
0
1341 }
never executed: end of block
0
1342-
1343 // Deliver post-change notification-
1344 if (newParentVariant)
newParentVariantDescription
TRUEnever evaluated
FALSEnever evaluated
0
1345 q->itemChange(QGraphicsItem::ItemParentHasChanged, *newParentVariant);
never executed: q->itemChange(QGraphicsItem::ItemParentHasChanged, *newParentVariant);
0
1346-
1347 if (isObject)
isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
1348 emit static_cast<QGraphicsObject *>(q)->parentChanged();
never executed: static_cast<QGraphicsObject *>(q)->parentChanged();
0
1349}
never executed: end of block
0
1350-
1351/*!-
1352 \internal-
1353-
1354 Returns the bounding rect of this item's children (excluding itself).-
1355*/-
1356void QGraphicsItemPrivate::childrenBoundingRectHelper(QTransform *x, QRectF *rect, QGraphicsItem *topMostEffectItem)-
1357{-
1358 Q_Q(QGraphicsItem);-
1359-
1360 QRectF childrenRect;-
1361 QRectF *result = rect;-
1362 rect = &childrenRect;-
1363 const bool setTopMostEffectItem = !topMostEffectItem;-
1364-
1365 for (int i = 0; i < children.size(); ++i) {
i < children.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1366 QGraphicsItem *child = children.at(i);-
1367 QGraphicsItemPrivate *childd = child->d_ptr.data();-
1368 if (setTopMostEffectItem)
setTopMostEffectItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
1369 topMostEffectItem = child;
never executed: topMostEffectItem = child;
0
1370 bool hasPos = !childd->pos.isNull();-
1371 if (hasPos || childd->transformData) {
hasPosDescription
TRUEnever evaluated
FALSEnever evaluated
childd->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
1372 // COMBINE-
1373 QTransform matrix = childd->transformToParent();-
1374 if (x)
xDescription
TRUEnever evaluated
FALSEnever evaluated
0
1375 matrix *= *x;
never executed: matrix *= *x;
0
1376 *rect |= matrix.mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem));-
1377 if (!childd->children.isEmpty())
!childd->children.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1378 childd->childrenBoundingRectHelper(&matrix, rect, topMostEffectItem);
never executed: childd->childrenBoundingRectHelper(&matrix, rect, topMostEffectItem);
0
1379 } else {
never executed: end of block
0
1380 if (x)
xDescription
TRUEnever evaluated
FALSEnever evaluated
0
1381 *rect |= x->mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem));
never executed: *rect |= x->mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem));
0
1382 else-
1383 *rect |= child->d_ptr->effectiveBoundingRect(topMostEffectItem);
never executed: *rect |= child->d_ptr->effectiveBoundingRect(topMostEffectItem);
0
1384 if (!childd->children.isEmpty())
!childd->children.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1385 childd->childrenBoundingRectHelper(x, rect, topMostEffectItem);
never executed: childd->childrenBoundingRectHelper(x, rect, topMostEffectItem);
0
1386 }
never executed: end of block
0
1387 }-
1388-
1389 if (flags & QGraphicsItem::ItemClipsChildrenToShape){
flags & QGraph...hildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1390 if (x)
xDescription
TRUEnever evaluated
FALSEnever evaluated
0
1391 *rect &= x->mapRect(q->boundingRect());
never executed: *rect &= x->mapRect(q->boundingRect());
0
1392 else-
1393 *rect &= q->boundingRect();
never executed: *rect &= q->boundingRect();
0
1394 }-
1395-
1396 *result |= *rect;-
1397}
never executed: end of block
0
1398-
1399void QGraphicsItemPrivate::initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform,-
1400 const QRegion &exposedRegion, bool allItems) const-
1401{-
1402 Q_ASSERT(option);-
1403 Q_Q(const QGraphicsItem);-
1404-
1405 // Initialize standard QStyleOption values.-
1406 const QRectF brect = q->boundingRect();-
1407 option->state = QStyle::State_None;-
1408 option->rect = brect.toRect();-
1409 option->levelOfDetail = 1;-
1410 option->exposedRect = brect;-
1411-
1412 // Style animations require a QObject-based animation target.-
1413 // If a plain QGraphicsItem is used to draw animated controls,-
1414 // QStyle is let to send animation updates to the whole scene.-
1415 option->styleObject = q_ptr->toGraphicsObject();-
1416 if (!option->styleObject)
!option->styleObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
1417 option->styleObject = scene;
never executed: option->styleObject = scene;
0
1418-
1419 if (selected)
selectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1420 option->state |= QStyle::State_Selected;
never executed: option->state |= QStyle::State_Selected;
0
1421 if (enabled)
enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1422 option->state |= QStyle::State_Enabled;
never executed: option->state |= QStyle::State_Enabled;
0
1423 if (q->hasFocus())
q->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
1424 option->state |= QStyle::State_HasFocus;
never executed: option->state |= QStyle::State_HasFocus;
0
1425 if (scene) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
1426 if (scene->d_func()->hoverItems.contains(q_ptr))
scene->d_func(...ontains(q_ptr)Description
TRUEnever evaluated
FALSEnever evaluated
0
1427 option->state |= QStyle::State_MouseOver;
never executed: option->state |= QStyle::State_MouseOver;
0
1428 if (q == scene->mouseGrabberItem())
q == scene->mouseGrabberItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
1429 option->state |= QStyle::State_Sunken;
never executed: option->state |= QStyle::State_Sunken;
0
1430 }
never executed: end of block
0
1431-
1432 if (!(flags & QGraphicsItem::ItemUsesExtendedStyleOption))
!(flags & QGra...edStyleOption)Description
TRUEnever evaluated
FALSEnever evaluated
0
1433 return;
never executed: return;
0
1434-
1435 // Initialize QStyleOptionGraphicsItem specific values (matrix, exposedRect).-
1436 option->matrix = worldTransform.toAffine(); //### discards perspective-
1437-
1438 if (!allItems) {
!allItemsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1439 // Determine the item's exposed area-
1440 option->exposedRect = QRectF();-
1441 const QTransform reverseMap = worldTransform.inverted();-
1442 const QVector<QRect> exposedRects(exposedRegion.rects());-
1443 for (int i = 0; i < exposedRects.size(); ++i) {
i < exposedRects.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1444 option->exposedRect |= reverseMap.mapRect(QRectF(exposedRects.at(i)));-
1445 if (option->exposedRect.contains(brect))
option->expose...ontains(brect)Description
TRUEnever evaluated
FALSEnever evaluated
0
1446 break;
never executed: break;
0
1447 }
never executed: end of block
0
1448 option->exposedRect &= brect;-
1449 }
never executed: end of block
0
1450}
never executed: end of block
0
1451-
1452/*!-
1453 \internal-
1454-
1455 Empty all cached pixmaps from the pixmap cache.-
1456*/-
1457void QGraphicsItemCache::purge()-
1458{-
1459 QPixmapCache::remove(key);-
1460 key = QPixmapCache::Key();-
1461 const auto &constDeviceData = deviceData; // avoid detach-
1462 for (const auto &data : constDeviceData)-
1463 QPixmapCache::remove(data.key);
never executed: QPixmapCache::remove(data.key);
0
1464 deviceData.clear();-
1465 allExposed = true;-
1466 exposed.clear();-
1467}
never executed: end of block
0
1468-
1469/*!-
1470 Constructs a QGraphicsItem with the given \a parent item.-
1471 It does not modify the parent object returned by QObject::parent().-
1472-
1473 If \a parent is 0, you can add the item to a scene by calling-
1474 QGraphicsScene::addItem(). The item will then become a top-level item.-
1475-
1476 \sa QGraphicsScene::addItem(), setParentItem()-
1477*/-
1478QGraphicsItem::QGraphicsItem(QGraphicsItem *parent)-
1479 : d_ptr(new QGraphicsItemPrivate)-
1480{-
1481 d_ptr->q_ptr = this;-
1482 setParentItem(parent);-
1483}
never executed: end of block
0
1484-
1485/*!-
1486 \internal-
1487*/-
1488QGraphicsItem::QGraphicsItem(QGraphicsItemPrivate &dd, QGraphicsItem *parent)-
1489 : d_ptr(&dd)-
1490{-
1491 d_ptr->q_ptr = this;-
1492 setParentItem(parent);-
1493}
never executed: end of block
0
1494-
1495/*!-
1496 Destroys the QGraphicsItem and all its children. If this item is currently-
1497 associated with a scene, the item will be removed from the scene before it-
1498 is deleted.-
1499-
1500 \note It is more efficient to remove the item from the QGraphicsScene before-
1501 destroying the item.-
1502*/-
1503QGraphicsItem::~QGraphicsItem()-
1504{-
1505 if (d_ptr->isObject) {
d_ptr->isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
1506 QGraphicsObject *o = static_cast<QGraphicsObject *>(this);-
1507 QObjectPrivate *p = QObjectPrivate::get(o);-
1508 p->wasDeleted = true;-
1509 if (p->declarativeData) {
p->declarativeDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
1510 if (static_cast<QAbstractDeclarativeDataImpl*>(p->declarativeData)->ownedByQml1) {
static_cast<QA...)->ownedByQml1Description
TRUEnever evaluated
FALSEnever evaluated
0
1511 if (QAbstractDeclarativeData::destroyed_qml1)
QAbstractDecla...destroyed_qml1Description
TRUEnever evaluated
FALSEnever evaluated
0
1512 QAbstractDeclarativeData::destroyed_qml1(p->declarativeData, o);
never executed: QAbstractDeclarativeData::destroyed_qml1(p->declarativeData, o);
0
1513 } else {
never executed: end of block
0
1514 if (QAbstractDeclarativeData::destroyed)
QAbstractDecla...ata::destroyedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1515 QAbstractDeclarativeData::destroyed(p->declarativeData, o);
never executed: QAbstractDeclarativeData::destroyed(p->declarativeData, o);
0
1516 }
never executed: end of block
0
1517 p->declarativeData = 0;-
1518 }
never executed: end of block
0
1519 }
never executed: end of block
0
1520-
1521 d_ptr->inDestructor = 1;-
1522 d_ptr->removeExtraItemCache();-
1523-
1524#ifndef QT_NO_GESTURES-
1525 if (d_ptr->isObject && !d_ptr->gestureContext.isEmpty()) {
d_ptr->isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
!d_ptr->gestur...text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1526 QGraphicsObject *o = static_cast<QGraphicsObject *>(this);-
1527 if (QGestureManager *manager = QGestureManager::instance()) {
QGestureManage...er::instance()Description
TRUEnever evaluated
FALSEnever evaluated
0
1528 const auto types = d_ptr->gestureContext.keys(); // FIXME: iterate over the map directly?-
1529 for (Qt::GestureType type : types)-
1530 manager->cleanupCachedGestures(o, type);
never executed: manager->cleanupCachedGestures(o, type);
0
1531 }
never executed: end of block
0
1532 }
never executed: end of block
0
1533#endif-
1534-
1535 clearFocus();-
1536 setFocusProxy(0);-
1537-
1538 // Update focus scope item ptr.-
1539 QGraphicsItem *p = d_ptr->parent;-
1540 while (p) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
0
1541 if (p->flags() & ItemIsFocusScope) {
p->flags() & ItemIsFocusScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1542 if (p->d_ptr->focusScopeItem == this)
p->d_ptr->focu...peItem == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1543 p->d_ptr->focusScopeItem = 0;
never executed: p->d_ptr->focusScopeItem = 0;
0
1544 break;
never executed: break;
0
1545 }-
1546 p = p->d_ptr->parent;-
1547 }
never executed: end of block
0
1548-
1549 if (!d_ptr->children.isEmpty()) {
!d_ptr->children.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1550 while (!d_ptr->children.isEmpty())
!d_ptr->children.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1551 delete d_ptr->children.first();
never executed: delete d_ptr->children.first();
0
1552 Q_ASSERT(d_ptr->children.isEmpty());-
1553 }
never executed: end of block
0
1554-
1555 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
1556 d_ptr->scene->d_func()->removeItemHelper(this);-
1557 } else {
never executed: end of block
0
1558 d_ptr->resetFocusProxy();-
1559 setParentItem(0);-
1560 }
never executed: end of block
0
1561-
1562#ifndef QT_NO_GRAPHICSEFFECT-
1563 delete d_ptr->graphicsEffect;-
1564#endif //QT_NO_GRAPHICSEFFECT-
1565 if (d_ptr->transformData) {
d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
1566 for(int i = 0; i < d_ptr->transformData->graphicsTransforms.size(); ++i) {
i < d_ptr->tra...nsforms.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1567 QGraphicsTransform *t = d_ptr->transformData->graphicsTransforms.at(i);-
1568 static_cast<QGraphicsTransformPrivate *>(t->d_ptr.data())->item = 0;-
1569 delete t;-
1570 }
never executed: end of block
0
1571 }
never executed: end of block
0
1572 delete d_ptr->transformData;-
1573-
1574 if (QGraphicsItemCustomDataStore *dataStore = qt_dataStore())
QGraphicsItemC...qt_dataStore()Description
TRUEnever evaluated
FALSEnever evaluated
0
1575 dataStore->data.remove(this);
never executed: dataStore->data.remove(this);
0
1576}
never executed: end of block
0
1577-
1578/*!-
1579 Returns the current scene for the item, or 0 if the item is not stored in-
1580 a scene.-
1581-
1582 To add or move an item to a scene, call QGraphicsScene::addItem().-
1583*/-
1584QGraphicsScene *QGraphicsItem::scene() const-
1585{-
1586 return d_ptr->scene;
never executed: return d_ptr->scene;
0
1587}-
1588-
1589/*!-
1590 Returns a pointer to this item's item group, or 0 if this item is not-
1591 member of a group.-
1592-
1593 \sa QGraphicsItemGroup, QGraphicsScene::createItemGroup()-
1594*/-
1595QGraphicsItemGroup *QGraphicsItem::group() const-
1596{-
1597 if (!d_ptr->isMemberOfGroup)
!d_ptr->isMemberOfGroupDescription
TRUEnever evaluated
FALSEnever evaluated
0
1598 return 0;
never executed: return 0;
0
1599 QGraphicsItem *parent = const_cast<QGraphicsItem *>(this);-
1600 while ((parent = parent->d_ptr->parent)) {
(parent = pare...d_ptr->parent)Description
TRUEnever evaluated
FALSEnever evaluated
0
1601 if (QGraphicsItemGroup *group = qgraphicsitem_cast<QGraphicsItemGroup *>(parent))
QGraphicsItemG...oup *>(parent)Description
TRUEnever evaluated
FALSEnever evaluated
0
1602 return group;
never executed: return group;
0
1603 }
never executed: end of block
0
1604 // Unreachable; if d_ptr->isMemberOfGroup is != 0, then one parent of this-
1605 // item is a group item.-
1606 return 0;
never executed: return 0;
0
1607}-
1608-
1609/*!-
1610 Adds this item to the item group \a group. If \a group is 0, this item is-
1611 removed from any current group and added as a child of the previous-
1612 group's parent.-
1613-
1614 \sa group(), QGraphicsScene::createItemGroup()-
1615*/-
1616void QGraphicsItem::setGroup(QGraphicsItemGroup *group)-
1617{-
1618 if (!group) {
!groupDescription
TRUEnever evaluated
FALSEnever evaluated
0
1619 if (QGraphicsItemGroup *group = this->group())
QGraphicsItemG... this->group()Description
TRUEnever evaluated
FALSEnever evaluated
0
1620 group->removeFromGroup(this);
never executed: group->removeFromGroup(this);
0
1621 } else {
never executed: end of block
0
1622 group->addToGroup(this);-
1623 }
never executed: end of block
0
1624}-
1625-
1626/*!-
1627 Returns a pointer to this item's parent item. If this item does not have a-
1628 parent, 0 is returned.-
1629-
1630 \sa setParentItem(), childItems()-
1631*/-
1632QGraphicsItem *QGraphicsItem::parentItem() const-
1633{-
1634 return d_ptr->parent;
never executed: return d_ptr->parent;
0
1635}-
1636-
1637/*!-
1638 Returns this item's top-level item. The top-level item is the item's-
1639 topmost ancestor item whose parent is 0. If an item has no parent, its own-
1640 pointer is returned (i.e., a top-level item is its own top-level item).-
1641-
1642 \sa parentItem()-
1643*/-
1644QGraphicsItem *QGraphicsItem::topLevelItem() const-
1645{-
1646 QGraphicsItem *parent = const_cast<QGraphicsItem *>(this);-
1647 while (QGraphicsItem *grandPa = parent->parentItem())
QGraphicsItem ...->parentItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
1648 parent = grandPa;
never executed: parent = grandPa;
0
1649 return parent;
never executed: return parent;
0
1650}-
1651-
1652/*!-
1653 \since 4.6-
1654-
1655 Returns a pointer to the item's parent, cast to a QGraphicsObject. returns 0 if the parent item-
1656 is not a QGraphicsObject.-
1657-
1658 \sa parentItem(), childItems()-
1659*/-
1660QGraphicsObject *QGraphicsItem::parentObject() const-
1661{-
1662 QGraphicsItem *p = d_ptr->parent;-
1663 return (p && p->d_ptr->isObject) ? static_cast<QGraphicsObject *>(p) : 0;
never executed: return (p && p->d_ptr->isObject) ? static_cast<QGraphicsObject *>(p) : 0;
0
1664}-
1665-
1666/*!-
1667 \since 4.4-
1668-
1669 Returns a pointer to the item's parent widget. The item's parent widget is-
1670 the closest parent item that is a widget.-
1671-
1672 \sa parentItem(), childItems()-
1673*/-
1674QGraphicsWidget *QGraphicsItem::parentWidget() const-
1675{-
1676 QGraphicsItem *p = parentItem();-
1677 while (p && !p->isWidget())
pDescription
TRUEnever evaluated
FALSEnever evaluated
!p->isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
1678 p = p->parentItem();
never executed: p = p->parentItem();
0
1679 return (p && p->isWidget()) ? static_cast<QGraphicsWidget *>(p) : 0;
never executed: return (p && p->isWidget()) ? static_cast<QGraphicsWidget *>(p) : 0;
0
1680}-
1681-
1682/*!-
1683 \since 4.4-
1684-
1685 Returns a pointer to the item's top level widget (i.e., the item's-
1686 ancestor whose parent is 0, or whose parent is not a widget), or 0 if this-
1687 item does not have a top level widget. If the item is its own top level-
1688 widget, this function returns a pointer to the item itself.-
1689*/-
1690QGraphicsWidget *QGraphicsItem::topLevelWidget() const-
1691{-
1692 if (const QGraphicsWidget *p = parentWidget())
const QGraphic...parentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
1693 return p->topLevelWidget();
never executed: return p->topLevelWidget();
0
1694 return isWidget() ? static_cast<QGraphicsWidget *>(const_cast<QGraphicsItem *>(this)) : 0;
never executed: return isWidget() ? static_cast<QGraphicsWidget *>(const_cast<QGraphicsItem *>(this)) : 0;
0
1695}-
1696-
1697/*!-
1698 \since 4.4-
1699-
1700 Returns the item's window, or 0 if this item does not have a window. If-
1701 the item is a window, it will return itself. Otherwise it will return the-
1702 closest ancestor that is a window.-
1703-
1704 \sa QGraphicsWidget::isWindow()-
1705*/-
1706QGraphicsWidget *QGraphicsItem::window() const-
1707{-
1708 QGraphicsItem *p = panel();-
1709 if (p && p->isWindow())
pDescription
TRUEnever evaluated
FALSEnever evaluated
p->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
1710 return static_cast<QGraphicsWidget *>(p);
never executed: return static_cast<QGraphicsWidget *>(p);
0
1711 return 0;
never executed: return 0;
0
1712}-
1713-
1714/*!-
1715 \since 4.6-
1716-
1717 Returns the item's panel, or 0 if this item does not have a panel. If the-
1718 item is a panel, it will return itself. Otherwise it will return the-
1719 closest ancestor that is a panel.-
1720-
1721 \sa isPanel(), ItemIsPanel-
1722*/-
1723QGraphicsItem *QGraphicsItem::panel() const-
1724{-
1725 if (d_ptr->flags & ItemIsPanel)
d_ptr->flags & ItemIsPanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1726 return const_cast<QGraphicsItem *>(this);
never executed: return const_cast<QGraphicsItem *>(this);
0
1727 return d_ptr->parent ? d_ptr->parent->panel() : 0;
never executed: return d_ptr->parent ? d_ptr->parent->panel() : 0;
0
1728}-
1729-
1730/*!-
1731 \since 4.6-
1732-
1733 Return the graphics item cast to a QGraphicsObject, if the class is actually a-
1734 graphics object, 0 otherwise.-
1735*/-
1736QGraphicsObject *QGraphicsItem::toGraphicsObject()-
1737{-
1738 return d_ptr->isObject ? static_cast<QGraphicsObject *>(this) : 0;
never executed: return d_ptr->isObject ? static_cast<QGraphicsObject *>(this) : 0;
0
1739}-
1740-
1741/*!-
1742 \since 4.6-
1743-
1744 Return the graphics item cast to a QGraphicsObject, if the class is actually a-
1745 graphics object, 0 otherwise.-
1746*/-
1747const QGraphicsObject *QGraphicsItem::toGraphicsObject() const-
1748{-
1749 return d_ptr->isObject ? static_cast<const QGraphicsObject *>(this) : 0;
never executed: return d_ptr->isObject ? static_cast<const QGraphicsObject *>(this) : 0;
0
1750}-
1751-
1752/*!-
1753 Sets this item's parent item to \a newParent. If this item already-
1754 has a parent, it is first removed from the previous parent. If \a-
1755 newParent is 0, this item will become a top-level item.-
1756-
1757 Note that this implicitly adds this graphics item to the scene of-
1758 the parent. You should not \l{QGraphicsScene::addItem()}{add} the-
1759 item to the scene yourself.-
1760-
1761 The behavior when calling this function on an item that is an ancestor of-
1762 \a newParent is undefined.-
1763-
1764 \sa parentItem(), childItems()-
1765*/-
1766void QGraphicsItem::setParentItem(QGraphicsItem *newParent)-
1767{-
1768 if (newParent == this) {
newParent == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1769 qWarning("QGraphicsItem::setParentItem: cannot assign %p as a parent of itself", this);-
1770 return;
never executed: return;
0
1771 }-
1772 if (newParent == d_ptr->parent)
newParent == d_ptr->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1773 return;
never executed: return;
0
1774-
1775 const QVariant newParentVariant(itemChange(QGraphicsItem::ItemParentChange,-
1776 QVariant::fromValue<QGraphicsItem *>(newParent)));-
1777 newParent = qvariant_cast<QGraphicsItem *>(newParentVariant);-
1778 if (newParent == d_ptr->parent)
newParent == d_ptr->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1779 return;
never executed: return;
0
1780-
1781 const QVariant thisPointerVariant(QVariant::fromValue<QGraphicsItem *>(this));-
1782 d_ptr->setParentItemHelper(newParent, &newParentVariant, &thisPointerVariant);-
1783}
never executed: end of block
0
1784-
1785/*!-
1786 \fn QList<QGraphicsItem *> QGraphicsItem::children() const-
1787 \obsolete-
1788-
1789 Use childItems() instead.-
1790-
1791 \sa setParentItem()-
1792*/-
1793-
1794/*!-
1795 \since 4.4-
1796-
1797 Returns a list of this item's children.-
1798-
1799 The items are sorted by stacking order. This takes into account both the-
1800 items' insertion order and their Z-values.-
1801-
1802 \sa setParentItem(), zValue(), {QGraphicsItem#Sorting}{Sorting}-
1803*/-
1804QList<QGraphicsItem *> QGraphicsItem::childItems() const-
1805{-
1806 const_cast<QGraphicsItem *>(this)->d_ptr->ensureSortedChildren();-
1807 return d_ptr->children;
never executed: return d_ptr->children;
0
1808}-
1809-
1810/*!-
1811 \since 4.4-
1812 Returns \c true if this item is a widget (i.e., QGraphicsWidget); otherwise,-
1813 returns \c false.-
1814*/-
1815bool QGraphicsItem::isWidget() const-
1816{-
1817 return d_ptr->isWidget;
never executed: return d_ptr->isWidget;
0
1818}-
1819-
1820/*!-
1821 \since 4.4-
1822 Returns \c true if the item is a QGraphicsWidget window, otherwise returns-
1823 false.-
1824-
1825 \sa QGraphicsWidget::windowFlags()-
1826*/-
1827bool QGraphicsItem::isWindow() const-
1828{-
1829 return d_ptr->isWidget && (static_cast<const QGraphicsWidget *>(this)->windowType() & Qt::Window);
never executed: return d_ptr->isWidget && (static_cast<const QGraphicsWidget *>(this)->windowType() & Qt::Window);
0
1830}-
1831-
1832/*!-
1833 \since 4.6-
1834 Returns \c true if the item is a panel; otherwise returns \c false.-
1835-
1836 \sa QGraphicsItem::panel(), ItemIsPanel-
1837*/-
1838bool QGraphicsItem::isPanel() const-
1839{-
1840 return d_ptr->flags & ItemIsPanel;
never executed: return d_ptr->flags & ItemIsPanel;
0
1841}-
1842-
1843/*!-
1844 Returns this item's flags. The flags describe what configurable features-
1845 of the item are enabled and not. For example, if the flags include-
1846 ItemIsFocusable, the item can accept input focus.-
1847-
1848 By default, no flags are enabled.-
1849-
1850 \sa setFlags(), setFlag()-
1851*/-
1852QGraphicsItem::GraphicsItemFlags QGraphicsItem::flags() const-
1853{-
1854 return GraphicsItemFlags(d_ptr->flags);
never executed: return GraphicsItemFlags(d_ptr->flags);
0
1855}-
1856-
1857/*!-
1858 If \a enabled is true, the item flag \a flag is enabled; otherwise, it is-
1859 disabled.-
1860-
1861 \sa flags(), setFlags()-
1862*/-
1863void QGraphicsItem::setFlag(GraphicsItemFlag flag, bool enabled)-
1864{-
1865 if (enabled)
enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1866 setFlags(GraphicsItemFlags(d_ptr->flags) | flag);
never executed: setFlags(GraphicsItemFlags(d_ptr->flags) | flag);
0
1867 else-
1868 setFlags(GraphicsItemFlags(d_ptr->flags) & ~flag);
never executed: setFlags(GraphicsItemFlags(d_ptr->flags) & ~flag);
0
1869}-
1870-
1871/*!-
1872 Sets the item flags to \a flags. All flags in \a flags are enabled; all-
1873 flags not in \a flags are disabled.-
1874-
1875 If the item had focus and \a flags does not enable ItemIsFocusable, the-
1876 item loses focus as a result of calling this function. Similarly, if the-
1877 item was selected, and \a flags does not enabled ItemIsSelectable, the-
1878 item is automatically unselected.-
1879-
1880 By default, no flags are enabled. (QGraphicsWidget enables the-
1881 ItemSendsGeometryChanges flag by default in order to track position-
1882 changes.)-
1883-
1884 \sa flags(), setFlag()-
1885*/-
1886void QGraphicsItem::setFlags(GraphicsItemFlags flags)-
1887{-
1888 // Notify change and check for adjustment.-
1889 if (quint32(d_ptr->flags) == quint32(flags))
quint32(d_ptr-...quint32(flags)Description
TRUEnever evaluated
FALSEnever evaluated
0
1890 return;
never executed: return;
0
1891 flags = GraphicsItemFlags(itemChange(ItemFlagsChange, quint32(flags)).toUInt());-
1892 if (quint32(d_ptr->flags) == quint32(flags))
quint32(d_ptr-...quint32(flags)Description
TRUEnever evaluated
FALSEnever evaluated
0
1893 return;
never executed: return;
0
1894 if (d_ptr->scene && d_ptr->scene->d_func()->indexMethod != QGraphicsScene::NoIndex)
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
d_ptr->scene->...Scene::NoIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
1895 d_ptr->scene->d_func()->index->itemChange(this, ItemFlagsChange, &flags);
never executed: d_ptr->scene->d_func()->index->itemChange(this, ItemFlagsChange, &flags);
0
1896-
1897 // Flags that alter the geometry of the item (or its children).-
1898 const quint32 geomChangeFlagsMask = (ItemClipsChildrenToShape | ItemClipsToShape | ItemIgnoresTransformations | ItemIsSelectable);-
1899 bool fullUpdate = (quint32(flags) & geomChangeFlagsMask) != (d_ptr->flags & geomChangeFlagsMask);-
1900 if (fullUpdate)
fullUpdateDescription
TRUEnever evaluated
FALSEnever evaluated
0
1901 d_ptr->updatePaintedViewBoundingRects(/*children=*/true);
never executed: d_ptr->updatePaintedViewBoundingRects( true);
0
1902-
1903 // Keep the old flags to compare the diff.-
1904 GraphicsItemFlags oldFlags = GraphicsItemFlags(d_ptr->flags);-
1905-
1906 // Update flags.-
1907 d_ptr->flags = flags;-
1908-
1909 if (!(d_ptr->flags & ItemIsFocusable) && hasFocus()) {
!(d_ptr->flags...emIsFocusable)Description
TRUEnever evaluated
FALSEnever evaluated
hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
1910 // Clear focus on the item if it has focus when the focusable flag-
1911 // is unset.-
1912 clearFocus();-
1913 }
never executed: end of block
0
1914-
1915 if (!(d_ptr->flags & ItemIsSelectable) && isSelected()) {
!(d_ptr->flags...mIsSelectable)Description
TRUEnever evaluated
FALSEnever evaluated
isSelected()Description
TRUEnever evaluated
FALSEnever evaluated
0
1916 // Unselect the item if it is selected when the selectable flag is-
1917 // unset.-
1918 setSelected(false);-
1919 }
never executed: end of block
0
1920-
1921 if ((flags & ItemClipsChildrenToShape) != (oldFlags & ItemClipsChildrenToShape)) {
(flags & ItemC...ildrenToShape)Description
TRUEnever evaluated
FALSEnever evaluated
0
1922 // Item children clipping changes. Propagate the ancestor flag to-
1923 // all children.-
1924 d_ptr->updateAncestorFlag(ItemClipsChildrenToShape);-
1925 // The childrenBoundingRect is clipped to the boundingRect in case of ItemClipsChildrenToShape,-
1926 // which means we have to invalidate the cached childrenBoundingRect whenever this flag changes.-
1927 d_ptr->dirtyChildrenBoundingRect = 1;-
1928 d_ptr->markParentDirty(true);-
1929 }
never executed: end of block
0
1930-
1931 if ((flags & ItemContainsChildrenInShape) != (oldFlags & ItemContainsChildrenInShape)) {
(flags & ItemC...ildrenInShape)Description
TRUEnever evaluated
FALSEnever evaluated
0
1932 // Item children containtment changes. Propagate the ancestor flag to all children.-
1933 d_ptr->updateAncestorFlag(ItemContainsChildrenInShape);-
1934 }
never executed: end of block
0
1935-
1936 if ((flags & ItemIgnoresTransformations) != (oldFlags & ItemIgnoresTransformations)) {
(flags & ItemI...ansformations)Description
TRUEnever evaluated
FALSEnever evaluated
0
1937 // Item children clipping changes. Propagate the ancestor flag to-
1938 // all children.-
1939 d_ptr->updateAncestorFlag(ItemIgnoresTransformations);-
1940 }
never executed: end of block
0
1941-
1942 if ((flags & ItemNegativeZStacksBehindParent) != (oldFlags & ItemNegativeZStacksBehindParent)) {
(flags & ItemN...sBehindParent)Description
TRUEnever evaluated
FALSEnever evaluated
0
1943 // NB! We change the flags directly here, so we must also update d_ptr->flags.-
1944 // Note that this has do be done before the ItemStacksBehindParent check-
1945 // below; otherwise we will loose the change.-
1946-
1947 // Update stack-behind.-
1948 if (d_ptr->z < qreal(0.0))
d_ptr->z < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1949 flags |= ItemStacksBehindParent;
never executed: flags |= ItemStacksBehindParent;
0
1950 else-
1951 flags &= ~ItemStacksBehindParent;
never executed: flags &= ~ItemStacksBehindParent;
0
1952 d_ptr->flags = flags;-
1953 }
never executed: end of block
0
1954-
1955 if ((flags & ItemStacksBehindParent) != (oldFlags & ItemStacksBehindParent)) {
(flags & ItemS...sBehindParent)Description
TRUEnever evaluated
FALSEnever evaluated
0
1956 // NB! This check has to come after the ItemNegativeZStacksBehindParent-
1957 // check above. Be careful.-
1958-
1959 // Ensure child item sorting is up to date when toggling this flag.-
1960 if (d_ptr->parent)
d_ptr->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1961 d_ptr->parent->d_ptr->needSortChildren = 1;
never executed: d_ptr->parent->d_ptr->needSortChildren = 1;
0
1962 else if (d_ptr->scene)
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
1963 d_ptr->scene->d_func()->needSortTopLevelItems = 1;
never executed: d_ptr->scene->d_func()->needSortTopLevelItems = 1;
0
1964 }
never executed: end of block
0
1965-
1966 if ((flags & ItemAcceptsInputMethod) != (oldFlags & ItemAcceptsInputMethod)) {
(flags & ItemA...tsInputMethod)Description
TRUEnever evaluated
FALSEnever evaluated
0
1967 // Update input method sensitivity in any views.-
1968 if (d_ptr->scene)
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
1969 d_ptr->scene->d_func()->updateInputMethodSensitivityInViews();
never executed: d_ptr->scene->d_func()->updateInputMethodSensitivityInViews();
0
1970 }
never executed: end of block
0
1971-
1972 if ((flags & ItemIsPanel) != (oldFlags & ItemIsPanel)) {
(flags & ItemI...& ItemIsPanel)Description
TRUEnever evaluated
FALSEnever evaluated
0
1973 bool becomesPanel = (flags & ItemIsPanel);-
1974 if ((d_ptr->panelModality != NonModal) && d_ptr->scene) {
(d_ptr->panelM...y != NonModal)Description
TRUEnever evaluated
FALSEnever evaluated
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
1975 // update the panel's modal state-
1976 if (becomesPanel)
becomesPanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1977 d_ptr->scene->d_func()->enterModal(this);
never executed: d_ptr->scene->d_func()->enterModal(this);
0
1978 else-
1979 d_ptr->scene->d_func()->leaveModal(this);
never executed: d_ptr->scene->d_func()->leaveModal(this);
0
1980 }-
1981 if (d_ptr->isWidget && (becomesPanel || parentWidget())) {
d_ptr->isWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
becomesPanelDescription
TRUEnever evaluated
FALSEnever evaluated
parentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
1982 QGraphicsWidget *w = static_cast<QGraphicsWidget *>(this);-
1983 QGraphicsWidget *focusFirst = w;-
1984 QGraphicsWidget *focusLast = w;-
1985 for (;;) {-
1986 QGraphicsWidget *test = focusLast->d_func()->focusNext;-
1987 if (!w->isAncestorOf(test) || test == w)
!w->isAncestorOf(test)Description
TRUEnever evaluated
FALSEnever evaluated
test == wDescription
TRUEnever evaluated
FALSEnever evaluated
0
1988 break;
never executed: break;
0
1989 focusLast = test;-
1990 }
never executed: end of block
0
1991-
1992 if (becomesPanel) {
becomesPanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1993 // unlink own widgets from focus chain-
1994 QGraphicsWidget *beforeMe = w->d_func()->focusPrev;-
1995 QGraphicsWidget *afterMe = focusLast->d_func()->focusNext;-
1996 beforeMe->d_func()->focusNext = afterMe;-
1997 afterMe->d_func()->focusPrev = beforeMe;-
1998 focusFirst->d_func()->focusPrev = focusLast;-
1999 focusLast->d_func()->focusNext = focusFirst;-
2000 if (!isAncestorOf(focusFirst->d_func()->focusNext))
!isAncestorOf(...()->focusNext)Description
TRUEnever evaluated
FALSEnever evaluated
0
2001 focusFirst->d_func()->focusNext = w;
never executed: focusFirst->d_func()->focusNext = w;
0
2002 } else if (QGraphicsWidget *pw = parentWidget()) {
never executed: end of block
QGraphicsWidge...parentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
2003 // link up own widgets to focus chain-
2004 QGraphicsWidget *beforeMe = pw;-
2005 QGraphicsWidget *afterMe = pw->d_func()->focusNext;-
2006 beforeMe->d_func()->focusNext = w;-
2007 afterMe->d_func()->focusPrev = focusLast;-
2008 w->d_func()->focusPrev = beforeMe;-
2009 focusLast->d_func()->focusNext = afterMe;-
2010 }
never executed: end of block
0
2011 }
never executed: end of block
0
2012 }
never executed: end of block
0
2013-
2014 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2015 if ((flags & ItemSendsScenePositionChanges) != (oldFlags & ItemSendsScenePositionChanges)) {
(flags & ItemS...sitionChanges)Description
TRUEnever evaluated
FALSEnever evaluated
0
2016 if (flags & ItemSendsScenePositionChanges)
flags & ItemSe...ositionChangesDescription
TRUEnever evaluated
FALSEnever evaluated
0
2017 d_ptr->scene->d_func()->registerScenePosItem(this);
never executed: d_ptr->scene->d_func()->registerScenePosItem(this);
0
2018 else-
2019 d_ptr->scene->d_func()->unregisterScenePosItem(this);
never executed: d_ptr->scene->d_func()->unregisterScenePosItem(this);
0
2020 }-
2021 d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true);-
2022 }
never executed: end of block
0
2023-
2024 // Notify change.-
2025 itemChange(ItemFlagsHaveChanged, quint32(flags));-
2026}
never executed: end of block
0
2027-
2028/*!-
2029 \since 4.4-
2030 Returns the cache mode for this item. The default mode is NoCache (i.e.,-
2031 cache is disabled and all painting is immediate).-
2032-
2033 \sa setCacheMode()-
2034*/-
2035QGraphicsItem::CacheMode QGraphicsItem::cacheMode() const-
2036{-
2037 return QGraphicsItem::CacheMode(d_ptr->cacheMode);
never executed: return QGraphicsItem::CacheMode(d_ptr->cacheMode);
0
2038}-
2039-
2040/*!-
2041 \since 4.4-
2042 Sets the item's cache mode to \a mode.-
2043-
2044 The optional \a logicalCacheSize argument is used only by-
2045 ItemCoordinateCache mode, and describes the resolution of the cache-
2046 buffer; if \a logicalCacheSize is (100, 100), QGraphicsItem will fit the-
2047 item into 100x100 pixels in graphics memory, regardless of the logical-
2048 size of the item itself. By default QGraphicsItem uses the size of-
2049 boundingRect(). For all other cache modes than ItemCoordinateCache, \a-
2050 logicalCacheSize is ignored.-
2051-
2052 Caching can speed up rendering if your item spends a significant time-
2053 redrawing itself. In some cases the cache can also slow down rendering, in-
2054 particular when the item spends less time redrawing than QGraphicsItem-
2055 spends redrawing from the cache.-
2056-
2057 When caching is enabled, an item's paint() function will generally draw into an-
2058 offscreen pixmap cache; for any subsequent-
2059 repaint requests, the Graphics View framework will redraw from the-
2060 cache. This approach works particularly well with QGLWidget, which stores-
2061 all the cache as OpenGL textures.-
2062-
2063 Be aware that QPixmapCache's cache limit may need to be changed to obtain-
2064 optimal performance.-
2065-
2066 You can read more about the different cache modes in the CacheMode-
2067 documentation.-
2068-
2069 \note Enabling caching does not imply that the item's paint() function will be-
2070 called only in response to an explicit update() call. For instance, under-
2071 memory pressure, Qt may decide to drop some of the cache information;-
2072 in such cases an item's paint() function will be called even if there-
2073 was no update() call (that is, exactly as if there were no caching enabled).-
2074-
2075 \sa CacheMode, QPixmapCache::setCacheLimit()-
2076*/-
2077void QGraphicsItem::setCacheMode(CacheMode mode, const QSize &logicalCacheSize)-
2078{-
2079 CacheMode lastMode = CacheMode(d_ptr->cacheMode);-
2080 d_ptr->cacheMode = mode;-
2081 bool noVisualChange = (mode == NoCache && lastMode == NoCache)
mode == NoCacheDescription
TRUEnever evaluated
FALSEnever evaluated
lastMode == NoCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
2082 || (mode == NoCache && lastMode == DeviceCoordinateCache)
mode == NoCacheDescription
TRUEnever evaluated
FALSEnever evaluated
lastMode == De...oordinateCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
2083 || (mode == DeviceCoordinateCache && lastMode == NoCache)
mode == DeviceCoordinateCacheDescription
TRUEnever evaluated
FALSEnever evaluated
lastMode == NoCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
2084 || (mode == DeviceCoordinateCache && lastMode == DeviceCoordinateCache);
mode == DeviceCoordinateCacheDescription
TRUEnever evaluated
FALSEnever evaluated
lastMode == De...oordinateCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
2085 if (mode == NoCache) {
mode == NoCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
2086 d_ptr->removeExtraItemCache();-
2087 } else {
never executed: end of block
0
2088 QGraphicsItemCache *cache = d_ptr->extraItemCache();-
2089-
2090 // Reset old cache-
2091 cache->purge();-
2092-
2093 if (mode == ItemCoordinateCache) {
mode == ItemCoordinateCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
2094 if (lastMode == mode && cache->fixedSize == logicalCacheSize)
lastMode == modeDescription
TRUEnever evaluated
FALSEnever evaluated
cache->fixedSi...gicalCacheSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2095 noVisualChange = true;
never executed: noVisualChange = true;
0
2096 cache->fixedSize = logicalCacheSize;-
2097 }
never executed: end of block
0
2098 }
never executed: end of block
0
2099 if (!noVisualChange)
!noVisualChangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2100 update();
never executed: update();
0
2101}
never executed: end of block
0
2102-
2103/*!-
2104 \since 4.6-
2105-
2106 Returns the modality for this item.-
2107*/-
2108QGraphicsItem::PanelModality QGraphicsItem::panelModality() const-
2109{-
2110 return d_ptr->panelModality;
never executed: return d_ptr->panelModality;
0
2111}-
2112-
2113/*!-
2114 \since 4.6-
2115-
2116 Sets the modality for this item to \a panelModality.-
2117-
2118 Changing the modality of a visible item takes effect immediately.-
2119*/-
2120void QGraphicsItem::setPanelModality(PanelModality panelModality)-
2121{-
2122 if (d_ptr->panelModality == panelModality)
d_ptr->panelMo... panelModalityDescription
TRUEnever evaluated
FALSEnever evaluated
0
2123 return;
never executed: return;
0
2124-
2125 PanelModality previousModality = d_ptr->panelModality;-
2126 bool enterLeaveModal = (isPanel() && d_ptr->scene && isVisible());
isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
2127 if (enterLeaveModal && panelModality == NonModal)
enterLeaveModalDescription
TRUEnever evaluated
FALSEnever evaluated
panelModality == NonModalDescription
TRUEnever evaluated
FALSEnever evaluated
0
2128 d_ptr->scene->d_func()->leaveModal(this);
never executed: d_ptr->scene->d_func()->leaveModal(this);
0
2129 d_ptr->panelModality = panelModality;-
2130 if (enterLeaveModal && d_ptr->panelModality != NonModal)
enterLeaveModalDescription
TRUEnever evaluated
FALSEnever evaluated
d_ptr->panelMo...ty != NonModalDescription
TRUEnever evaluated
FALSEnever evaluated
0
2131 d_ptr->scene->d_func()->enterModal(this, previousModality);
never executed: d_ptr->scene->d_func()->enterModal(this, previousModality);
0
2132}
never executed: end of block
0
2133-
2134/*!-
2135 \since 4.6-
2136-
2137 Returns \c true if this item is blocked by a modal panel, false otherwise. If \a blockingPanel is-
2138 non-zero, \a blockingPanel will be set to the modal panel that is blocking this item. If this-
2139 item is not blocked, \a blockingPanel will not be set by this function.-
2140-
2141 This function always returns \c false for items not in a scene.-
2142-
2143 \sa panelModality(), setPanelModality(), PanelModality-
2144*/-
2145bool QGraphicsItem::isBlockedByModalPanel(QGraphicsItem **blockingPanel) const-
2146{-
2147 if (!d_ptr->scene)
!d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2148 return false;
never executed: return false;
0
2149-
2150-
2151 QGraphicsItem *dummy = 0;-
2152 if (!blockingPanel)
!blockingPanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
2153 blockingPanel = &dummy;
never executed: blockingPanel = &dummy;
0
2154-
2155 const QGraphicsScenePrivate *scene_d = d_ptr->scene->d_func();-
2156 if (scene_d->modalPanels.isEmpty())
scene_d->modalPanels.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2157 return false;
never executed: return false;
0
2158-
2159 // ###-
2160 if (!scene_d->popupWidgets.isEmpty() && scene_d->popupWidgets.first() == this)
!scene_d->popu...gets.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
scene_d->popup...irst() == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
2161 return false;
never executed: return false;
0
2162-
2163 for (int i = 0; i < scene_d->modalPanels.count(); ++i) {
i < scene_d->m...Panels.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2164 QGraphicsItem *modalPanel = scene_d->modalPanels.at(i);-
2165 if (modalPanel->panelModality() == QGraphicsItem::SceneModal) {
modalPanel->pa...em::SceneModalDescription
TRUEnever evaluated
FALSEnever evaluated
0
2166 // Scene modal panels block all non-descendents.-
2167 if (modalPanel != this && !modalPanel->isAncestorOf(this)) {
modalPanel != thisDescription
TRUEnever evaluated
FALSEnever evaluated
!modalPanel->i...cestorOf(this)Description
TRUEnever evaluated
FALSEnever evaluated
0
2168 *blockingPanel = modalPanel;-
2169 return true;
never executed: return true;
0
2170 }-
2171 } else {
never executed: end of block
0
2172 // Window modal panels block ancestors and siblings/cousins.-
2173 if (modalPanel != this
modalPanel != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
2174 && !modalPanel->isAncestorOf(this)
!modalPanel->i...cestorOf(this)Description
TRUEnever evaluated
FALSEnever evaluated
0
2175 && commonAncestorItem(modalPanel)) {
commonAncestorItem(modalPanel)Description
TRUEnever evaluated
FALSEnever evaluated
0
2176 *blockingPanel = modalPanel;-
2177 return true;
never executed: return true;
0
2178 }-
2179 }
never executed: end of block
0
2180 }-
2181 return false;
never executed: return false;
0
2182}-
2183-
2184#ifndef QT_NO_TOOLTIP-
2185/*!-
2186 Returns the item's tool tip, or an empty QString if no tool tip has been-
2187 set.-
2188-
2189 \sa setToolTip(), QToolTip-
2190*/-
2191QString QGraphicsItem::toolTip() const-
2192{-
2193 return d_ptr->extra(QGraphicsItemPrivate::ExtraToolTip).toString();
never executed: return d_ptr->extra(QGraphicsItemPrivate::ExtraToolTip).toString();
0
2194}-
2195-
2196/*!-
2197 Sets the item's tool tip to \a toolTip. If \a toolTip is empty, the item's-
2198 tool tip is cleared.-
2199-
2200 \sa toolTip(), QToolTip-
2201*/-
2202void QGraphicsItem::setToolTip(const QString &toolTip)-
2203{-
2204 const QVariant toolTipVariant(itemChange(ItemToolTipChange, toolTip));-
2205 d_ptr->setExtra(QGraphicsItemPrivate::ExtraToolTip, toolTipVariant.toString());-
2206 itemChange(ItemToolTipHasChanged, toolTipVariant);-
2207}
never executed: end of block
0
2208#endif // QT_NO_TOOLTIP-
2209-
2210#ifndef QT_NO_CURSOR-
2211/*!-
2212 Returns the current cursor shape for the item. The mouse cursor-
2213 will assume this shape when it's over this item.-
2214 See the \l{Qt::CursorShape}{list of predefined cursor objects} for a-
2215 range of useful shapes.-
2216-
2217 An editor item might want to use an I-beam cursor:-
2218-
2219 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 2-
2220-
2221 If no cursor has been set, the cursor of the item beneath is used.-
2222-
2223 \sa setCursor(), hasCursor(), unsetCursor(), QWidget::cursor,-
2224 QApplication::overrideCursor()-
2225*/-
2226QCursor QGraphicsItem::cursor() const-
2227{-
2228 return qvariant_cast<QCursor>(d_ptr->extra(QGraphicsItemPrivate::ExtraCursor));
never executed: return qvariant_cast<QCursor>(d_ptr->extra(QGraphicsItemPrivate::ExtraCursor));
0
2229}-
2230-
2231/*!-
2232 Sets the current cursor shape for the item to \a cursor. The mouse cursor-
2233 will assume this shape when it's over this item.-
2234 See the \l{Qt::CursorShape}{list of predefined cursor objects} for a-
2235 range of useful shapes.-
2236-
2237 An editor item might want to use an I-beam cursor:-
2238-
2239 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 3-
2240-
2241 If no cursor has been set, the cursor of the item beneath is used.-
2242-
2243 \sa cursor(), hasCursor(), unsetCursor(), QWidget::cursor,-
2244 QApplication::overrideCursor()-
2245*/-
2246void QGraphicsItem::setCursor(const QCursor &cursor)-
2247{-
2248 const QVariant cursorVariant(itemChange(ItemCursorChange, QVariant::fromValue<QCursor>(cursor)));-
2249 d_ptr->setExtra(QGraphicsItemPrivate::ExtraCursor, qvariant_cast<QCursor>(cursorVariant));-
2250 d_ptr->hasCursor = 1;-
2251 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2252 d_ptr->scene->d_func()->allItemsUseDefaultCursor = false;-
2253 const auto views = d_ptr->scene->views();-
2254 for (QGraphicsView *view : views) {-
2255 view->viewport()->setMouseTracking(true);-
2256 // Note: Some of this logic is duplicated in QGraphicsView's mouse events.-
2257 if (view->underMouse()) {
view->underMouse()Description
TRUEnever evaluated
FALSEnever evaluated
0
2258 const auto itemsUnderCursor = view->items(view->mapFromGlobal(QCursor::pos()));-
2259 for (QGraphicsItem *itemUnderCursor : itemsUnderCursor) {-
2260 if (itemUnderCursor->hasCursor()) {
itemUnderCursor->hasCursor()Description
TRUEnever evaluated
FALSEnever evaluated
0
2261 QMetaObject::invokeMethod(view, "_q_setViewportCursor",-
2262 Q_ARG(QCursor, itemUnderCursor->cursor()));-
2263 break;
never executed: break;
0
2264 }-
2265 }
never executed: end of block
0
2266 break;
never executed: break;
0
2267 }-
2268 }
never executed: end of block
0
2269 }
never executed: end of block
0
2270 itemChange(ItemCursorHasChanged, cursorVariant);-
2271}
never executed: end of block
0
2272-
2273/*!-
2274 Returns \c true if this item has a cursor set; otherwise, false is returned.-
2275-
2276 By default, items don't have any cursor set. cursor() will return a-
2277 standard pointing arrow cursor.-
2278-
2279 \sa unsetCursor()-
2280*/-
2281bool QGraphicsItem::hasCursor() const-
2282{-
2283 return d_ptr->hasCursor;
never executed: return d_ptr->hasCursor;
0
2284}-
2285-
2286/*!-
2287 Clears the cursor from this item.-
2288-
2289 \sa hasCursor(), setCursor()-
2290*/-
2291void QGraphicsItem::unsetCursor()-
2292{-
2293 if (!d_ptr->hasCursor)
!d_ptr->hasCursorDescription
TRUEnever evaluated
FALSEnever evaluated
0
2294 return;
never executed: return;
0
2295 d_ptr->unsetExtra(QGraphicsItemPrivate::ExtraCursor);-
2296 d_ptr->hasCursor = 0;-
2297 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2298 const auto views = d_ptr->scene->views();-
2299 for (QGraphicsView *view : views) {-
2300 if (view->underMouse() && view->itemAt(view->mapFromGlobal(QCursor::pos())) == this) {
view->underMouse()Description
TRUEnever evaluated
FALSEnever evaluated
view->itemAt(v...os())) == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
2301 QMetaObject::invokeMethod(view, "_q_unsetViewportCursor");-
2302 break;
never executed: break;
0
2303 }-
2304 }
never executed: end of block
0
2305 }
never executed: end of block
0
2306}
never executed: end of block
0
2307-
2308#endif // QT_NO_CURSOR-
2309-
2310/*!-
2311 Returns \c true if the item is visible; otherwise, false is returned.-
2312-
2313 Note that the item's general visibility is unrelated to whether or not it-
2314 is actually being visualized by a QGraphicsView.-
2315-
2316 \sa setVisible()-
2317*/-
2318bool QGraphicsItem::isVisible() const-
2319{-
2320 return d_ptr->visible;
never executed: return d_ptr->visible;
0
2321}-
2322-
2323/*!-
2324 \since 4.4-
2325 Returns \c true if the item is visible to \a parent; otherwise, false is-
2326 returned. \a parent can be 0, in which case this function will return-
2327 whether the item is visible to the scene or not.-
2328-
2329 An item may not be visible to its ancestors even if isVisible() is true. It-
2330 may also be visible to its ancestors even if isVisible() is false. If-
2331 any ancestor is hidden, the item itself will be implicitly hidden, in which-
2332 case this function will return false.-
2333-
2334 \sa isVisible(), setVisible()-
2335*/-
2336bool QGraphicsItem::isVisibleTo(const QGraphicsItem *parent) const-
2337{-
2338 const QGraphicsItem *p = this;-
2339 if (d_ptr->explicitlyHidden)
d_ptr->explicitlyHiddenDescription
TRUEnever evaluated
FALSEnever evaluated
0
2340 return false;
never executed: return false;
0
2341 do {-
2342 if (p == parent)
p == parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
2343 return true;
never executed: return true;
0
2344 if (p->d_ptr->explicitlyHidden)
p->d_ptr->explicitlyHiddenDescription
TRUEnever evaluated
FALSEnever evaluated
0
2345 return false;
never executed: return false;
0
2346 } while ((p = p->d_ptr->parent));
never executed: end of block
(p = p->d_ptr->parent)Description
TRUEnever evaluated
FALSEnever evaluated
0
2347 return parent == 0;
never executed: return parent == 0;
0
2348}-
2349-
2350/*!-
2351 \internal-
2352-
2353 Sets this item's visibility to \a newVisible. If \a explicitly is true,-
2354 this item will be "explicitly" \a newVisible; otherwise, it.. will not be.-
2355*/-
2356void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly,-
2357 bool update, bool hiddenByPanel)-
2358{-
2359 Q_Q(QGraphicsItem);-
2360-
2361 // Update explicit bit.-
2362 if (explicitly)
explicitlyDescription
TRUEnever evaluated
FALSEnever evaluated
0
2363 explicitlyHidden = newVisible ? 0 : 1;
never executed: explicitlyHidden = newVisible ? 0 : 1;
newVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
2364-
2365 // Check if there's nothing to do.-
2366 if (visible == quint32(newVisible))
visible == quint32(newVisible)Description
TRUEnever evaluated
FALSEnever evaluated
0
2367 return;
never executed: return;
0
2368-
2369 // Don't show child if parent is not visible-
2370 if (parent && newVisible && !parent->d_ptr->visible)
parentDescription
TRUEnever evaluated
FALSEnever evaluated
newVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
!parent->d_ptr->visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
2371 return;
never executed: return;
0
2372-
2373 // Modify the property.-
2374 const QVariant newVisibleVariant(q_ptr->itemChange(QGraphicsItem::ItemVisibleChange,-
2375 quint32(newVisible)));-
2376 newVisible = newVisibleVariant.toBool();-
2377 if (visible == quint32(newVisible))
visible == quint32(newVisible)Description
TRUEnever evaluated
FALSEnever evaluated
0
2378 return;
never executed: return;
0
2379 visible = newVisible;-
2380-
2381 // Schedule redrawing-
2382 if (update) {
updateDescription
TRUEnever evaluated
FALSEnever evaluated
0
2383 Q