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 QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));-
2384 if (c)
cDescription
TRUEnever evaluated
FALSEnever evaluated
0
2385 c->purge();
never executed: c->purge();
0
2386 if (scene) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2387#ifndef QT_NO_GRAPHICSEFFECT-
2388 invalidateParentGraphicsEffectsRecursively();-
2389#endif //QT_NO_GRAPHICSEFFECT-
2390 scene->d_func()->markDirty(q_ptr, QRectF(), /*invalidateChildren=*/false, /*force=*/true);-
2391 }
never executed: end of block
0
2392 }
never executed: end of block
0
2393-
2394 // Certain properties are dropped as an item becomes invisible.-
2395 bool hasFocus = q_ptr->hasFocus();-
2396 if (!newVisible) {
!newVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
2397 if (scene) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2398 if (scene->d_func()->mouseGrabberItems.contains(q))
scene->d_func(...ms.contains(q)Description
TRUEnever evaluated
FALSEnever evaluated
0
2399 q->ungrabMouse();
never executed: q->ungrabMouse();
0
2400 if (scene->d_func()->keyboardGrabberItems.contains(q))
scene->d_func(...ms.contains(q)Description
TRUEnever evaluated
FALSEnever evaluated
0
2401 q->ungrabKeyboard();
never executed: q->ungrabKeyboard();
0
2402 if (q->isPanel() && panelModality != QGraphicsItem::NonModal)
q->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
panelModality ...Item::NonModalDescription
TRUEnever evaluated
FALSEnever evaluated
0
2403 scene->d_func()->leaveModal(q_ptr);
never executed: scene->d_func()->leaveModal(q_ptr);
0
2404 }
never executed: end of block
0
2405 if (hasFocus && scene) {
hasFocusDescription
TRUEnever evaluated
FALSEnever evaluated
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2406 // Hiding the focus item or the closest non-panel ancestor of the focus item-
2407 QGraphicsItem *focusItem = scene->focusItem();-
2408 bool clear = true;-
2409 if (isWidget && !focusItem->isPanel()) {
isWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
!focusItem->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
2410 do {-
2411 if (focusItem == q_ptr) {
focusItem == q_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
2412 clear = !static_cast<QGraphicsWidget *>(q_ptr)->focusNextPrevChild(true);-
2413 break;
never executed: break;
0
2414 }-
2415 } while ((focusItem = focusItem->parentWidget()) && !focusItem->isPanel());
never executed: end of block
(focusItem = f...arentWidget())Description
TRUEnever evaluated
FALSEnever evaluated
!focusItem->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
2416 }
never executed: end of block
0
2417 if (clear)
clearDescription
TRUEnever evaluated
FALSEnever evaluated
0
2418 clearFocusHelper(/* giveFocusToParent = */ false, hiddenByPanel);
never executed: clearFocusHelper( false, hiddenByPanel);
0
2419 }
never executed: end of block
0
2420 if (q_ptr->isSelected())
q_ptr->isSelected()Description
TRUEnever evaluated
FALSEnever evaluated
0
2421 q_ptr->setSelected(false);
never executed: q_ptr->setSelected(false);
0
2422 } else {
never executed: end of block
0
2423 geometryChanged = 1;-
2424 paintedViewBoundingRectsNeedRepaint = 1;-
2425 if (scene) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2426 if (isWidget) {
isWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
2427 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(q_ptr);-
2428 if (widget->windowType() == Qt::Popup)
widget->window...) == Qt::PopupDescription
TRUEnever evaluated
FALSEnever evaluated
0
2429 scene->d_func()->addPopup(widget);
never executed: scene->d_func()->addPopup(widget);
0
2430 }
never executed: end of block
0
2431 if (q->isPanel() && panelModality != QGraphicsItem::NonModal) {
q->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
panelModality ...Item::NonModalDescription
TRUEnever evaluated
FALSEnever evaluated
0
2432 scene->d_func()->enterModal(q_ptr);-
2433 }
never executed: end of block
0
2434 }
never executed: end of block
0
2435 }
never executed: end of block
0
2436-
2437 // Update children with explicitly = false.-
2438 const bool updateChildren = update && !((flags & QGraphicsItem::ItemClipsChildrenToShape
updateDescription
TRUEnever evaluated
FALSEnever evaluated
flags & QGraph...hildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2439 || flags & QGraphicsItem::ItemContainsChildrenInShape)
flags & QGraph...hildrenInShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2440 && !(flags & QGraphicsItem::ItemHasNoContents));
!(flags & QGra...HasNoContents)Description
TRUEnever evaluated
FALSEnever evaluated
0
2441 foreach (QGraphicsItem *child, children) {-
2442 if (!newVisible || !child->d_ptr->explicitlyHidden)
!newVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
!child->d_ptr-...plicitlyHiddenDescription
TRUEnever evaluated
FALSEnever evaluated
0
2443 child->d_ptr->setVisibleHelper(newVisible, false, updateChildren, hiddenByPanel);
never executed: child->d_ptr->setVisibleHelper(newVisible, false, updateChildren, hiddenByPanel);
0
2444 }
never executed: end of block
0
2445-
2446 // Update activation-
2447 if (scene && q->isPanel()) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
q->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
2448 if (newVisible) {
newVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
2449 if (parent && parent->isActive())
parentDescription
TRUEnever evaluated
FALSEnever evaluated
parent->isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
2450 q->setActive(true);
never executed: q->setActive(true);
0
2451 } else {
never executed: end of block
0
2452 if (q->isActive())
q->isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
2453 scene->setActivePanel(parent);
never executed: scene->setActivePanel(parent);
0
2454 }
never executed: end of block
0
2455 }-
2456-
2457 // Enable subfocus-
2458 if (scene) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2459 if (newVisible) {
newVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
2460 // Item is shown-
2461 QGraphicsItem *p = parent;-
2462 bool done = false;-
2463 while (p) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
0
2464 if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
p->flags() & Q...emIsFocusScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2465 QGraphicsItem *fsi = p->d_ptr->focusScopeItem;-
2466 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
2467 done = true;-
2468 while (fsi->d_ptr->focusScopeItem && fsi->d_ptr->focusScopeItem->isVisible())
fsi->d_ptr->focusScopeItemDescription
TRUEnever evaluated
FALSEnever evaluated
fsi->d_ptr->fo...m->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
2469 fsi = fsi->d_ptr->focusScopeItem;
never executed: fsi = fsi->d_ptr->focusScopeItem;
0
2470 fsi->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ true,-
2471 /* focusFromHide = */ false);-
2472 }
never executed: end of block
0
2473 break;
never executed: break;
0
2474 }-
2475 p = p->d_ptr->parent;-
2476 }
never executed: end of block
0
2477 if (!done) {
!doneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2478 QGraphicsItem *fi = subFocusItem;-
2479 if (fi && fi != scene->focusItem()) {
fiDescription
TRUEnever evaluated
FALSEnever evaluated
fi != scene->focusItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
2480 scene->setFocusItem(fi);-
2481 } else if (flags & QGraphicsItem::ItemIsFocusScope &&
never executed: end of block
flags & QGraph...emIsFocusScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2482 !scene->focusItem() &&
!scene->focusItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
2483 q->isAncestorOf(scene->d_func()->lastFocusItem)) {
q->isAncestorO...lastFocusItem)Description
TRUEnever evaluated
FALSEnever evaluated
0
2484 q_ptr->setFocus();-
2485 }
never executed: end of block
0
2486 }
never executed: end of block
0
2487 } else {
never executed: end of block
0
2488 // Item is hidden-
2489 if (hasFocus) {
hasFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
2490 QGraphicsItem *p = parent;-
2491 while (p) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
0
2492 if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
p->flags() & Q...emIsFocusScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2493 if (p->d_ptr->visible) {
p->d_ptr->visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
2494 p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ true,-
2495 /* focusFromHide = */ true);-
2496 }
never executed: end of block
0
2497 break;
never executed: break;
0
2498 }-
2499 p = p->d_ptr->parent;-
2500 }
never executed: end of block
0
2501 }
never executed: end of block
0
2502 }
never executed: end of block
0
2503 }-
2504-
2505 // Deliver post-change notification.-
2506 q_ptr->itemChange(QGraphicsItem::ItemVisibleHasChanged, newVisibleVariant);-
2507-
2508 if (isObject)
isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
2509 emit static_cast<QGraphicsObject *>(q_ptr)->visibleChanged();
never executed: static_cast<QGraphicsObject *>(q_ptr)->visibleChanged();
0
2510}
never executed: end of block
0
2511-
2512/*!-
2513 If \a visible is true, the item is made visible. Otherwise, the item is-
2514 made invisible. Invisible items are not painted, nor do they receive any-
2515 events. In particular, mouse events pass right through invisible items,-
2516 and are delivered to any item that may be behind. Invisible items are also-
2517 unselectable, they cannot take input focus, and are not detected by-
2518 QGraphicsScene's item location functions.-
2519-
2520 If an item becomes invisible while grabbing the mouse, (i.e., while it is-
2521 receiving mouse events,) it will automatically lose the mouse grab, and-
2522 the grab is not regained by making the item visible again; it must receive-
2523 a new mouse press to regain the mouse grab.-
2524-
2525 Similarly, an invisible item cannot have focus, so if the item has focus-
2526 when it becomes invisible, it will lose focus, and the focus is not-
2527 regained by simply making the item visible again.-
2528-
2529 If you hide a parent item, all its children will also be hidden. If you-
2530 show a parent item, all children will be shown, unless they have been-
2531 explicitly hidden (i.e., if you call setVisible(false) on a child, it will-
2532 not be reshown even if its parent is hidden, and then shown again).-
2533-
2534 Items are visible by default; it is unnecessary to call-
2535 setVisible() on a new item.-
2536-
2537 \note An item with opacity set to 0 will still be considered visible,-
2538 although it will be treated like an invisible item: mouse events will pass-
2539 through it, it will not be included in the items returned by-
2540 QGraphicsView::items(), and so on. However, the item will retain the focus.-
2541-
2542 \sa isVisible(), show(), hide(), setOpacity()-
2543*/-
2544void QGraphicsItem::setVisible(bool visible)-
2545{-
2546 d_ptr->setVisibleHelper(visible,-
2547 /* explicit = */ true,-
2548 /* update = */ true,-
2549 /* hiddenByPanel = */ isPanel());-
2550}
never executed: end of block
0
2551-
2552/*!-
2553 \fn void QGraphicsItem::hide()-
2554-
2555 Hides the item (items are visible by default).-
2556-
2557 This convenience function is equivalent to calling \c setVisible(false).-
2558-
2559 \sa show(), setVisible()-
2560*/-
2561-
2562/*!-
2563 \fn void QGraphicsItem::show()-
2564-
2565 Shows the item (items are visible by default).-
2566-
2567 This convenience function is equivalent to calling \c setVisible(true).-
2568-
2569 \sa hide(), setVisible()-
2570*/-
2571-
2572/*!-
2573 Returns \c true if the item is enabled; otherwise, false is returned.-
2574-
2575 \sa setEnabled()-
2576*/-
2577bool QGraphicsItem::isEnabled() const-
2578{-
2579 return d_ptr->enabled;
never executed: return d_ptr->enabled;
0
2580}-
2581-
2582/*!-
2583 \internal-
2584-
2585 Sets this item's visibility to \a newEnabled. If \a explicitly is true,-
2586 this item will be "explicitly" \a newEnabled; otherwise, it.. will not be.-
2587*/-
2588void QGraphicsItemPrivate::setEnabledHelper(bool newEnabled, bool explicitly, bool update)-
2589{-
2590 // Update explicit bit.-
2591 if (explicitly)
explicitlyDescription
TRUEnever evaluated
FALSEnever evaluated
0
2592 explicitlyDisabled = newEnabled ? 0 : 1;
never executed: explicitlyDisabled = newEnabled ? 0 : 1;
newEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
2593-
2594 // Check if there's nothing to do.-
2595 if (enabled == quint32(newEnabled))
enabled == quint32(newEnabled)Description
TRUEnever evaluated
FALSEnever evaluated
0
2596 return;
never executed: return;
0
2597-
2598 // Certain properties are dropped when an item is disabled.-
2599 if (!newEnabled) {
!newEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
2600 if (scene && scene->mouseGrabberItem() == q_ptr)
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
scene->mouseGr...tem() == q_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
2601 q_ptr->ungrabMouse();
never executed: q_ptr->ungrabMouse();
0
2602 if (q_ptr->hasFocus()) {
q_ptr->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
2603 // Disabling the closest non-panel ancestor of the focus item-
2604 // causes focus to pop to the next item, otherwise it's cleared.-
2605 QGraphicsItem *focusItem = scene->focusItem();-
2606 bool clear = true;-
2607 if (isWidget && !focusItem->isPanel() && q_ptr->isAncestorOf(focusItem)) {
isWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
!focusItem->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
q_ptr->isAncestorOf(focusItem)Description
TRUEnever evaluated
FALSEnever evaluated
0
2608 do {-
2609 if (focusItem == q_ptr) {
focusItem == q_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
2610 clear = !static_cast<QGraphicsWidget *>(q_ptr)->focusNextPrevChild(true);-
2611 break;
never executed: break;
0
2612 }-
2613 } while ((focusItem = focusItem->parentWidget()) && !focusItem->isPanel());
never executed: end of block
(focusItem = f...arentWidget())Description
TRUEnever evaluated
FALSEnever evaluated
!focusItem->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
2614 }
never executed: end of block
0
2615 if (clear)
clearDescription
TRUEnever evaluated
FALSEnever evaluated
0
2616 q_ptr->clearFocus();
never executed: q_ptr->clearFocus();
0
2617 }
never executed: end of block
0
2618 if (q_ptr->isSelected())
q_ptr->isSelected()Description
TRUEnever evaluated
FALSEnever evaluated
0
2619 q_ptr->setSelected(false);
never executed: q_ptr->setSelected(false);
0
2620 }
never executed: end of block
0
2621-
2622 // Modify the property.-
2623 const QVariant newEnabledVariant(q_ptr->itemChange(QGraphicsItem::ItemEnabledChange,-
2624 quint32(newEnabled)));-
2625 enabled = newEnabledVariant.toBool();-
2626-
2627 // Schedule redraw.-
2628 if (update)
updateDescription
TRUEnever evaluated
FALSEnever evaluated
0
2629 q_ptr->update();
never executed: q_ptr->update();
0
2630-
2631 foreach (QGraphicsItem *child, children) {-
2632 if (!newEnabled || !child->d_ptr->explicitlyDisabled)
!newEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
!child->d_ptr-...icitlyDisabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
2633 child->d_ptr->setEnabledHelper(newEnabled, /* explicitly = */ false);
never executed: child->d_ptr->setEnabledHelper(newEnabled, false);
0
2634 }
never executed: end of block
0
2635-
2636 // Deliver post-change notification.-
2637 q_ptr->itemChange(QGraphicsItem::ItemEnabledHasChanged, newEnabledVariant);-
2638-
2639 if (isObject)
isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
2640 emit static_cast<QGraphicsObject *>(q_ptr)->enabledChanged();
never executed: static_cast<QGraphicsObject *>(q_ptr)->enabledChanged();
0
2641}
never executed: end of block
0
2642-
2643/*!-
2644 If \a enabled is true, the item is enabled; otherwise, it is disabled.-
2645-
2646 Disabled items are visible, but they do not receive any events, and cannot-
2647 take focus nor be selected. Mouse events are discarded; they are not-
2648 propagated unless the item is also invisible, or if it does not accept-
2649 mouse events (see acceptedMouseButtons()). A disabled item cannot become the-
2650 mouse grabber, and as a result of this, an item loses the grab if it-
2651 becomes disabled when grabbing the mouse, just like it loses focus if it-
2652 had focus when it was disabled.-
2653-
2654 Disabled items are traditionally drawn using grayed-out colors (see \l-
2655 QPalette::Disabled).-
2656-
2657 If you disable a parent item, all its children will also be disabled. If-
2658 you enable a parent item, all children will be enabled, unless they have-
2659 been explicitly disabled (i.e., if you call setEnabled(false) on a child,-
2660 it will not be reenabled if its parent is disabled, and then enabled-
2661 again).-
2662-
2663 Items are enabled by default.-
2664-
2665 \note If you install an event filter, you can still intercept events-
2666 before they are delivered to items; this mechanism disregards the item's-
2667 enabled state.-
2668-
2669 \sa isEnabled()-
2670*/-
2671void QGraphicsItem::setEnabled(bool enabled)-
2672{-
2673 d_ptr->setEnabledHelper(enabled, /* explicitly = */ true);-
2674}
never executed: end of block
0
2675-
2676/*!-
2677 Returns \c true if this item is selected; otherwise, false is returned.-
2678-
2679 Items that are in a group inherit the group's selected state.-
2680-
2681 Items are not selected by default.-
2682-
2683 \sa setSelected(), QGraphicsScene::setSelectionArea()-
2684*/-
2685bool QGraphicsItem::isSelected() const-
2686{-
2687 if (QGraphicsItemGroup *group = this->group())
QGraphicsItemG... this->group()Description
TRUEnever evaluated
FALSEnever evaluated
0
2688 return group->isSelected();
never executed: return group->isSelected();
0
2689 return d_ptr->selected;
never executed: return d_ptr->selected;
0
2690}-
2691-
2692/*!-
2693 If \a selected is true and this item is selectable, this item is selected;-
2694 otherwise, it is unselected.-
2695-
2696 If the item is in a group, the whole group's selected state is toggled by-
2697 this function. If the group is selected, all items in the group are also-
2698 selected, and if the group is not selected, no item in the group is-
2699 selected.-
2700-
2701 Only visible, enabled, selectable items can be selected. If \a selected-
2702 is true and this item is either invisible or disabled or unselectable,-
2703 this function does nothing.-
2704-
2705 By default, items cannot be selected. To enable selection, set the-
2706 ItemIsSelectable flag.-
2707-
2708 This function is provided for convenience, allowing individual toggling of-
2709 the selected state of an item. However, a more common way of selecting-
2710 items is to call QGraphicsScene::setSelectionArea(), which will call this-
2711 function for all visible, enabled, and selectable items within a specified-
2712 area on the scene.-
2713-
2714 \sa isSelected(), QGraphicsScene::selectedItems()-
2715*/-
2716void QGraphicsItem::setSelected(bool selected)-
2717{-
2718 if (QGraphicsItemGroup *group = this->group()) {
QGraphicsItemG... this->group()Description
TRUEnever evaluated
FALSEnever evaluated
0
2719 group->setSelected(selected);-
2720 return;
never executed: return;
0
2721 }-
2722-
2723 if (!(d_ptr->flags & ItemIsSelectable) || !d_ptr->enabled || !d_ptr->visible)
!(d_ptr->flags...mIsSelectable)Description
TRUEnever evaluated
FALSEnever evaluated
!d_ptr->enabledDescription
TRUEnever evaluated
FALSEnever evaluated
!d_ptr->visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
2724 selected = false;
never executed: selected = false;
0
2725 if (d_ptr->selected == selected)
d_ptr->selected == selectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2726 return;
never executed: return;
0
2727 const QVariant newSelectedVariant(itemChange(ItemSelectedChange, quint32(selected)));-
2728 bool newSelected = newSelectedVariant.toBool();-
2729 if (d_ptr->selected == newSelected)
d_ptr->selected == newSelectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2730 return;
never executed: return;
0
2731 d_ptr->selected = newSelected;-
2732-
2733 update();-
2734 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2735 QGraphicsScenePrivate *sceneD = d_ptr->scene->d_func();-
2736 if (selected) {
selectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2737 sceneD->selectedItems << this;-
2738 } else {
never executed: end of block
0
2739 // QGraphicsScene::selectedItems() lazily pulls out all items that are-
2740 // no longer selected.-
2741 }
never executed: end of block
0
2742 if (!sceneD->selectionChanging)
!sceneD->selectionChangingDescription
TRUEnever evaluated
FALSEnever evaluated
0
2743 emit d_ptr->scene->selectionChanged();
never executed: d_ptr->scene->selectionChanged();
0
2744 }
never executed: end of block
0
2745-
2746 // Deliver post-change notification.-
2747 itemChange(QGraphicsItem::ItemSelectedHasChanged, newSelectedVariant);-
2748}
never executed: end of block
0
2749-
2750/*!-
2751 \since 4.5-
2752-
2753 Returns this item's local opacity, which is between 0.0 (transparent) and-
2754 1.0 (opaque). This value is combined with parent and ancestor values into-
2755 the effectiveOpacity(). The effective opacity decides how the item is-
2756 rendered and also affects its visibility when queried by functions such as-
2757 QGraphicsView::items().-
2758-
2759 The opacity property decides the state of the painter passed to the-
2760 paint() function. If the item is cached, i.e., ItemCoordinateCache or-
2761 DeviceCoordinateCache, the effective property will be applied to the item's-
2762 cache as it is rendered.-
2763-
2764 The default opacity is 1.0; fully opaque.-
2765-
2766 \sa setOpacity(), paint(), ItemIgnoresParentOpacity,-
2767 ItemDoesntPropagateOpacityToChildren-
2768*/-
2769qreal QGraphicsItem::opacity() const-
2770{-
2771 return d_ptr->opacity;
never executed: return d_ptr->opacity;
0
2772}-
2773-
2774/*!-
2775 \since 4.5-
2776-
2777 Returns this item's \e effective opacity, which is between 0.0-
2778 (transparent) and 1.0 (opaque). This value is a combination of this item's-
2779 local opacity, and its parent and ancestors' opacities. The effective-
2780 opacity decides how the item is rendered.-
2781-
2782 \sa opacity(), setOpacity(), paint(), ItemIgnoresParentOpacity,-
2783 ItemDoesntPropagateOpacityToChildren-
2784*/-
2785qreal QGraphicsItem::effectiveOpacity() const-
2786{-
2787 return d_ptr->effectiveOpacity();
never executed: return d_ptr->effectiveOpacity();
0
2788}-
2789-
2790/*!-
2791 \since 4.5-
2792-
2793 Sets this item's local \a opacity, between 0.0 (transparent) and 1.0-
2794 (opaque). The item's local opacity is combined with parent and ancestor-
2795 opacities into the effectiveOpacity().-
2796-
2797 By default, opacity propagates from parent to child, so if a parent's-
2798 opacity is 0.5 and the child is also 0.5, the child's effective opacity-
2799 will be 0.25.-
2800-
2801 The opacity property decides the state of the painter passed to the-
2802 paint() function. If the item is cached, i.e., ItemCoordinateCache or-
2803 DeviceCoordinateCache, the effective property will be applied to the-
2804 item's cache as it is rendered.-
2805-
2806 There are two item flags that affect how the item's opacity is combined-
2807 with the parent: ItemIgnoresParentOpacity and-
2808 ItemDoesntPropagateOpacityToChildren.-
2809-
2810 \note Setting the opacity of an item to 0 will not make the item invisible-
2811 (according to isVisible()), but the item will be treated like an invisible-
2812 one. See the documentation of setVisible() for more information.-
2813-
2814 \sa opacity(), effectiveOpacity(), setVisible()-
2815*/-
2816void QGraphicsItem::setOpacity(qreal opacity)-
2817{-
2818 // Notify change.-
2819 const QVariant newOpacityVariant(itemChange(ItemOpacityChange, opacity));-
2820-
2821 // Normalized opacity-
2822 qreal newOpacity = qBound(qreal(0), newOpacityVariant.toReal(), qreal(1));-
2823-
2824 // No change? Done.-
2825 if (newOpacity == d_ptr->opacity)
newOpacity == d_ptr->opacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
2826 return;
never executed: return;
0
2827-
2828 bool wasFullyTransparent = d_ptr->isOpacityNull();-
2829 d_ptr->opacity = newOpacity;-
2830-
2831 // Notify change.-
2832 itemChange(ItemOpacityHasChanged, newOpacityVariant);-
2833-
2834 // Update.-
2835 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2836#ifndef QT_NO_GRAPHICSEFFECT-
2837 d_ptr->invalidateParentGraphicsEffectsRecursively();-
2838 if (!(d_ptr->flags & ItemDoesntPropagateOpacityToChildren))
!(d_ptr->flags...ityToChildren)Description
TRUEnever evaluated
FALSEnever evaluated
0
2839 d_ptr->invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::OpacityChanged);
never executed: d_ptr->invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::OpacityChanged);
0
2840#endif //QT_NO_GRAPHICSEFFECT-
2841 d_ptr->scene->d_func()->markDirty(this, QRectF(),-
2842 /*invalidateChildren=*/true,-
2843 /*force=*/false,-
2844 /*ignoreOpacity=*/d_ptr->isOpacityNull());-
2845 if (wasFullyTransparent)
wasFullyTransparentDescription
TRUEnever evaluated
FALSEnever evaluated
0
2846 d_ptr->paintedViewBoundingRectsNeedRepaint = 1;
never executed: d_ptr->paintedViewBoundingRectsNeedRepaint = 1;
0
2847 }
never executed: end of block
0
2848-
2849 if (d_ptr->isObject)
d_ptr->isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
2850 emit static_cast<QGraphicsObject *>(this)->opacityChanged();
never executed: static_cast<QGraphicsObject *>(this)->opacityChanged();
0
2851}
never executed: end of block
0
2852-
2853/*!-
2854 Returns a pointer to this item's effect if it has one; otherwise 0.-
2855-
2856 \since 4.6-
2857*/-
2858#ifndef QT_NO_GRAPHICSEFFECT-
2859QGraphicsEffect *QGraphicsItem::graphicsEffect() const-
2860{-
2861 return d_ptr->graphicsEffect;
never executed: return d_ptr->graphicsEffect;
0
2862}-
2863-
2864/*!-
2865 Sets \a effect as the item's effect. If there already is an effect installed-
2866 on this item, QGraphicsItem will delete the existing effect before installing-
2867 the new \a effect. You can delete an existing effect by calling-
2868 setGraphicsEffect(0).-
2869-
2870 If \a effect is the installed effect on a different item, setGraphicsEffect() will remove-
2871 the effect from the item and install it on this item.-
2872-
2873 QGraphicsItem takes ownership of \a effect.-
2874-
2875 \note This function will apply the effect on itself and all its children.-
2876-
2877 \since 4.6-
2878*/-
2879void QGraphicsItem::setGraphicsEffect(QGraphicsEffect *effect)-
2880{-
2881 if (d_ptr->graphicsEffect == effect)
d_ptr->graphic...fect == effectDescription
TRUEnever evaluated
FALSEnever evaluated
0
2882 return;
never executed: return;
0
2883-
2884 if (d_ptr->graphicsEffect) {
d_ptr->graphicsEffectDescription
TRUEnever evaluated
FALSEnever evaluated
0
2885 delete d_ptr->graphicsEffect;-
2886 d_ptr->graphicsEffect = 0;-
2887 } else if (d_ptr->parent) {
never executed: end of block
d_ptr->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
2888 d_ptr->parent->d_ptr->updateChildWithGraphicsEffectFlagRecursively();-
2889 }
never executed: end of block
0
2890-
2891 if (effect) {
effectDescription
TRUEnever evaluated
FALSEnever evaluated
0
2892 // Set new effect.-
2893 QGraphicsEffectSourcePrivate *sourced = new QGraphicsItemEffectSourcePrivate(this);-
2894 QGraphicsEffectSource *source = new QGraphicsEffectSource(*sourced);-
2895 d_ptr->graphicsEffect = effect;-
2896 effect->d_func()->setGraphicsEffectSource(source);-
2897 prepareGeometryChange();-
2898 }
never executed: end of block
0
2899}
never executed: end of block
0
2900#endif //QT_NO_GRAPHICSEFFECT-
2901-
2902void QGraphicsItemPrivate::updateChildWithGraphicsEffectFlagRecursively()-
2903{-
2904#ifndef QT_NO_GRAPHICSEFFECT-
2905 QGraphicsItemPrivate *itemPrivate = this;-
2906 do {-
2907 // parent chain already notified?-
2908 if (itemPrivate->mayHaveChildWithGraphicsEffect)
itemPrivate->m...GraphicsEffectDescription
TRUEnever evaluated
FALSEnever evaluated
0
2909 return;
never executed: return;
0
2910 itemPrivate->mayHaveChildWithGraphicsEffect = 1;-
2911 } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : 0));
never executed: end of block
(itemPrivate =...tr.data() : 0)Description
TRUEnever evaluated
FALSEnever evaluated
itemPrivate->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
2912#endif-
2913}
never executed: end of block
0
2914-
2915/*!-
2916 \internal-
2917 \since 4.6-
2918 Returns the effective bounding rect of the given item space rect.-
2919 If the item has no effect, the rect is returned unmodified.-
2920 If the item has an effect, the effective rect can be extend beyond the-
2921 item's bounding rect, depending on the effect.-
2922-
2923 \sa boundingRect()-
2924*/-
2925QRectF QGraphicsItemPrivate::effectiveBoundingRect(const QRectF &rect) const-
2926{-
2927#ifndef QT_NO_GRAPHICSEFFECT-
2928 Q_Q(const QGraphicsItem);-
2929 QGraphicsEffect *effect = graphicsEffect;-
2930 if (scene && effect && effect->isEnabled()) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
effectDescription
TRUEnever evaluated
FALSEnever evaluated
effect->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
2931 if (scene->d_func()->views.isEmpty())
scene->d_func(...iews.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2932 return effect->boundingRectFor(rect);
never executed: return effect->boundingRectFor(rect);
0
2933 QRectF sceneRect = q->mapRectToScene(rect);-
2934 QRectF sceneEffectRect;-
2935 const auto views = scene->views();-
2936 for (QGraphicsView *view : views) {-
2937 QRectF deviceRect = view->d_func()->mapRectFromScene(sceneRect);-
2938 QRect deviceEffectRect = effect->boundingRectFor(deviceRect).toAlignedRect();-
2939 sceneEffectRect |= view->d_func()->mapRectToScene(deviceEffectRect);-
2940 }
never executed: end of block
0
2941 return q->mapRectFromScene(sceneEffectRect);
never executed: return q->mapRectFromScene(sceneEffectRect);
0
2942 }-
2943#endif //QT_NO_GRAPHICSEFFECT-
2944 return rect;
never executed: return rect;
0
2945}-
2946-
2947/*!-
2948 \internal-
2949 \since 4.6-
2950 Returns the effective bounding rect of the item.-
2951 If the item has no effect, this is the same as the item's bounding rect.-
2952 If the item has an effect, the effective rect can be larger than the item's-
2953 bouding rect, depending on the effect.-
2954-
2955 \sa boundingRect()-
2956*/-
2957QRectF QGraphicsItemPrivate::effectiveBoundingRect(QGraphicsItem *topMostEffectItem) const-
2958{-
2959#ifndef QT_NO_GRAPHICSEFFECT-
2960 Q_Q(const QGraphicsItem);-
2961 QRectF brect = effectiveBoundingRect(q_ptr->boundingRect());-
2962 if (ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren
ancestorFlags ...rClipsChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
2963 || ancestorFlags & QGraphicsItemPrivate::AncestorContainsChildren
ancestorFlags ...ntainsChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
2964 || topMostEffectItem == q)
topMostEffectItem == qDescription
TRUEnever evaluated
FALSEnever evaluated
0
2965 return brect;
never executed: return brect;
0
2966-
2967 const QGraphicsItem *effectParent = parent;-
2968 while (effectParent) {
effectParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
2969 QGraphicsEffect *effect = effectParent->d_ptr->graphicsEffect;-
2970 if (scene && effect && effect->isEnabled()) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
effectDescription
TRUEnever evaluated
FALSEnever evaluated
effect->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
2971 const QRectF brectInParentSpace = q->mapRectToItem(effectParent, brect);-
2972 const QRectF effectRectInParentSpace = effectParent->d_ptr->effectiveBoundingRect(brectInParentSpace);-
2973 brect = effectParent->mapRectToItem(q, effectRectInParentSpace);-
2974 }
never executed: end of block
0
2975 if (effectParent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren
effectParent->...rClipsChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
2976 || effectParent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorContainsChildren
effectParent->...ntainsChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
2977 || topMostEffectItem == effectParent) {
topMostEffectI...= effectParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
2978 return brect;
never executed: return brect;
0
2979 }-
2980 effectParent = effectParent->d_ptr->parent;-
2981 }
never executed: end of block
0
2982-
2983 return brect;
never executed: return brect;
0
2984#else //QT_NO_GRAPHICSEFFECT-
2985 return q_ptr->boundingRect();-
2986#endif //QT_NO_GRAPHICSEFFECT-
2987-
2988}-
2989-
2990/*!-
2991 \internal-
2992 \since 4.6-
2993 Returns the effective bounding rect of this item in scene coordinates,-
2994 by combining sceneTransform() with boundingRect(), taking into account-
2995 the effect that the item might have.-
2996-
2997 If the item has no effect, this is the same as sceneBoundingRect().-
2998-
2999 \sa effectiveBoundingRect(), sceneBoundingRect()-
3000*/-
3001QRectF QGraphicsItemPrivate::sceneEffectiveBoundingRect() const-
3002{-
3003 // Find translate-only offset-
3004 // COMBINE-
3005 QPointF offset;-
3006 const QGraphicsItem *parentItem = q_ptr;-
3007 const QGraphicsItemPrivate *itemd;-
3008 do {-
3009 itemd = parentItem->d_ptr.data();-
3010 if (itemd->transformData)
itemd->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
3011 break;
never executed: break;
0
3012 offset += itemd->pos;-
3013 } while ((parentItem = itemd->parent));
never executed: end of block
(parentItem = itemd->parent)Description
TRUEnever evaluated
FALSEnever evaluated
0
3014-
3015 QRectF br = effectiveBoundingRect();-
3016 br.translate(offset);-
3017 return !parentItem ? br : parentItem->sceneTransform().mapRect(br);
never executed: return !parentItem ? br : parentItem->sceneTransform().mapRect(br);
0
3018}-
3019-
3020/*!-
3021 Returns \c true if this item can accept drag and drop events; otherwise,-
3022 returns \c false. By default, items do not accept drag and drop events; items-
3023 are transparent to drag and drop.-
3024-
3025 \sa setAcceptDrops()-
3026*/-
3027bool QGraphicsItem::acceptDrops() const-
3028{-
3029 return d_ptr->acceptDrops;
never executed: return d_ptr->acceptDrops;
0
3030}-
3031-
3032/*!-
3033 If \a on is true, this item will accept drag and drop events; otherwise,-
3034 it is transparent for drag and drop events. By default, items do not-
3035 accept drag and drop events.-
3036-
3037 \sa acceptDrops()-
3038*/-
3039void QGraphicsItem::setAcceptDrops(bool on)-
3040{-
3041 d_ptr->acceptDrops = on;-
3042}
never executed: end of block
0
3043-
3044/*!-
3045 Returns the mouse buttons that this item accepts mouse events for. By-
3046 default, all mouse buttons are accepted.-
3047-
3048 If an item accepts a mouse button, it will become the mouse-
3049 grabber item when a mouse press event is delivered for that mouse-
3050 button. However, if the item does not accept the button,-
3051 QGraphicsScene will forward the mouse events to the first item-
3052 beneath it that does.-
3053-
3054 \sa setAcceptedMouseButtons(), mousePressEvent()-
3055*/-
3056Qt::MouseButtons QGraphicsItem::acceptedMouseButtons() const-
3057{-
3058 return Qt::MouseButtons(d_ptr->acceptedMouseButtons);
never executed: return Qt::MouseButtons(d_ptr->acceptedMouseButtons);
0
3059}-
3060-
3061/*!-
3062 Sets the mouse \a buttons that this item accepts mouse events for.-
3063-
3064 By default, all mouse buttons are accepted. If an item accepts a-
3065 mouse button, it will become the mouse grabber item when a mouse-
3066 press event is delivered for that button. However, if the item-
3067 does not accept the mouse button, QGraphicsScene will forward the-
3068 mouse events to the first item beneath it that does.-
3069-
3070 To disable mouse events for an item (i.e., make it transparent for mouse-
3071 events), call setAcceptedMouseButtons(0).-
3072-
3073 \sa acceptedMouseButtons(), mousePressEvent()-
3074*/-
3075void QGraphicsItem::setAcceptedMouseButtons(Qt::MouseButtons buttons)-
3076{-
3077 if (Qt::MouseButtons(d_ptr->acceptedMouseButtons) != buttons) {
Qt::MouseButto...ns) != buttonsDescription
TRUEnever evaluated
FALSEnever evaluated
0
3078 if (buttons == 0 && d_ptr->scene && d_ptr->scene->mouseGrabberItem() == this
buttons == 0Description
TRUEnever evaluated
FALSEnever evaluated
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
d_ptr->scene->...Item() == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
3079 && d_ptr->scene->d_func()->lastMouseGrabberItemHasImplicitMouseGrab) {
d_ptr->scene->...licitMouseGrabDescription
TRUEnever evaluated
FALSEnever evaluated
0
3080 ungrabMouse();-
3081 }
never executed: end of block
0
3082 d_ptr->acceptedMouseButtons = quint32(buttons);-
3083 }
never executed: end of block
0
3084}
never executed: end of block
0
3085-
3086/*!-
3087 \since 4.4-
3088-
3089 Returns \c true if an item accepts hover events-
3090 (QGraphicsSceneHoverEvent); otherwise, returns \c false. By default,-
3091 items do not accept hover events.-
3092-
3093 \sa setAcceptedMouseButtons()-
3094*/-
3095bool QGraphicsItem::acceptHoverEvents() const-
3096{-
3097 return d_ptr->acceptsHover;
never executed: return d_ptr->acceptsHover;
0
3098}-
3099-
3100/*!-
3101 \fn bool QGraphicsItem::acceptsHoverEvents() const-
3102 \obsolete-
3103-
3104 Call acceptHoverEvents() instead.-
3105*/-
3106-
3107/*!-
3108 \since 4.4-
3109-
3110 If \a enabled is true, this item will accept hover events;-
3111 otherwise, it will ignore them. By default, items do not accept-
3112 hover events.-
3113-
3114 Hover events are delivered when there is no current mouse grabber-
3115 item. They are sent when the mouse cursor enters an item, when it-
3116 moves around inside the item, and when the cursor leaves an-
3117 item. Hover events are commonly used to highlight an item when-
3118 it's entered, and for tracking the mouse cursor as it hovers over-
3119 the item (equivalent to QWidget::mouseTracking).-
3120-
3121 Parent items receive hover enter events before their children, and-
3122 leave events after their children. The parent does not receive a-
3123 hover leave event if the cursor enters a child, though; the parent-
3124 stays "hovered" until the cursor leaves its area, including its-
3125 children's areas.-
3126-
3127 If a parent item handles child events, it will receive hover move,-
3128 drag move, and drop events as the cursor passes through its-
3129 children, but it does not receive hover enter and hover leave, nor-
3130 drag enter and drag leave events on behalf of its children.-
3131-
3132 A QGraphicsWidget with window decorations will accept hover events-
3133 regardless of the value of acceptHoverEvents().-
3134-
3135 \sa acceptHoverEvents(), hoverEnterEvent(), hoverMoveEvent(),-
3136 hoverLeaveEvent()-
3137*/-
3138void QGraphicsItem::setAcceptHoverEvents(bool enabled)-
3139{-
3140 if (d_ptr->acceptsHover == quint32(enabled))
d_ptr->accepts...int32(enabled)Description
TRUEnever evaluated
FALSEnever evaluated
0
3141 return;
never executed: return;
0
3142 d_ptr->acceptsHover = quint32(enabled);-
3143 if (d_ptr->acceptsHover && d_ptr->scene && d_ptr->scene->d_func()->allItemsIgnoreHoverEvents) {
d_ptr->acceptsHoverDescription
TRUEnever evaluated
FALSEnever evaluated
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
d_ptr->scene->...oreHoverEventsDescription
TRUEnever evaluated
FALSEnever evaluated
0
3144 d_ptr->scene->d_func()->allItemsIgnoreHoverEvents = false;-
3145 d_ptr->scene->d_func()->enableMouseTrackingOnViews();-
3146 }
never executed: end of block
0
3147}
never executed: end of block
0
3148-
3149/*!-
3150 \fn void QGraphicsItem::setAcceptsHoverEvents(bool enabled)-
3151 \obsolete-
3152-
3153 Use setAcceptHoverEvents(\a enabled) instead.-
3154*/-
3155-
3156/*! \since 4.6-
3157-
3158 Returns \c true if an item accepts \l{QTouchEvent}{touch events};-
3159 otherwise, returns \c false. By default, items do not accept touch events.-
3160-
3161 \sa setAcceptTouchEvents()-
3162*/-
3163bool QGraphicsItem::acceptTouchEvents() const-
3164{-
3165 return d_ptr->acceptTouchEvents;
never executed: return d_ptr->acceptTouchEvents;
0
3166}-
3167-
3168/*!-
3169 \since 4.6-
3170-
3171 If \a enabled is true, this item will accept \l{QTouchEvent}{touch events};-
3172 otherwise, it will ignore them. By default, items do not accept-
3173 touch events.-
3174*/-
3175void QGraphicsItem::setAcceptTouchEvents(bool enabled)-
3176{-
3177 if (d_ptr->acceptTouchEvents == quint32(enabled))
d_ptr->acceptT...int32(enabled)Description
TRUEnever evaluated
FALSEnever evaluated
0
3178 return;
never executed: return;
0
3179 d_ptr->acceptTouchEvents = quint32(enabled);-
3180 if (d_ptr->acceptTouchEvents && d_ptr->scene && d_ptr->scene->d_func()->allItemsIgnoreTouchEvents) {
d_ptr->acceptTouchEventsDescription
TRUEnever evaluated
FALSEnever evaluated
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
d_ptr->scene->...oreTouchEventsDescription
TRUEnever evaluated
FALSEnever evaluated
0
3181 d_ptr->scene->d_func()->allItemsIgnoreTouchEvents = false;-
3182 d_ptr->scene->d_func()->enableTouchEventsOnViews();-
3183 }
never executed: end of block
0
3184}
never executed: end of block
0
3185-
3186/*!-
3187 \since 4.6-
3188-
3189 Returns \c true if this item filters child events (i.e., all events-
3190 intended for any of its children are instead sent to this item);-
3191 otherwise, false is returned.-
3192-
3193 The default value is false; child events are not filtered.-
3194-
3195 \sa setFiltersChildEvents()-
3196*/-
3197bool QGraphicsItem::filtersChildEvents() const-
3198{-
3199 return d_ptr->filtersDescendantEvents;
never executed: return d_ptr->filtersDescendantEvents;
0
3200}-
3201-
3202/*!-
3203 \since 4.6-
3204-
3205 If \a enabled is true, this item is set to filter all events for-
3206 all its children (i.e., all events intented for any of its-
3207 children are instead sent to this item); otherwise, if \a enabled-
3208 is false, this item will only handle its own events. The default-
3209 value is false.-
3210-
3211 \sa filtersChildEvents()-
3212*/-
3213void QGraphicsItem::setFiltersChildEvents(bool enabled)-
3214{-
3215 if (d_ptr->filtersDescendantEvents == enabled)
d_ptr->filters...nts == enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
3216 return;
never executed: return;
0
3217-
3218 d_ptr->filtersDescendantEvents = enabled;-
3219 d_ptr->updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-2));-
3220}
never executed: end of block
0
3221-
3222/*!-
3223 \obsolete-
3224-
3225 Returns \c true if this item handles child events (i.e., all events-
3226 intended for any of its children are instead sent to this item);-
3227 otherwise, false is returned.-
3228-
3229 This property is useful for item groups; it allows one item to-
3230 handle events on behalf of its children, as opposed to its-
3231 children handling their events individually.-
3232-
3233 The default is to return false; children handle their own events.-
3234 The exception for this is if the item is a QGraphicsItemGroup, then-
3235 it defaults to return true.-
3236-
3237 \sa setHandlesChildEvents()-
3238*/-
3239bool QGraphicsItem::handlesChildEvents() const-
3240{-
3241 return d_ptr->handlesChildEvents;
never executed: return d_ptr->handlesChildEvents;
0
3242}-
3243-
3244/*!-
3245 \obsolete-
3246-
3247 If \a enabled is true, this item is set to handle all events for-
3248 all its children (i.e., all events intented for any of its-
3249 children are instead sent to this item); otherwise, if \a enabled-
3250 is false, this item will only handle its own events. The default-
3251 value is false.-
3252-
3253 This property is useful for item groups; it allows one item to-
3254 handle events on behalf of its children, as opposed to its-
3255 children handling their events individually.-
3256-
3257 If a child item accepts hover events, its parent will receive-
3258 hover move events as the cursor passes through the child, but it-
3259 does not receive hover enter and hover leave events on behalf of-
3260 its child.-
3261-
3262 \sa handlesChildEvents()-
3263*/-
3264void QGraphicsItem::setHandlesChildEvents(bool enabled)-
3265{-
3266 if (d_ptr->handlesChildEvents == enabled)
d_ptr->handles...nts == enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
3267 return;
never executed: return;
0
3268-
3269 d_ptr->handlesChildEvents = enabled;-
3270 d_ptr->updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-1));-
3271}
never executed: end of block
0
3272/*!-
3273 \since 4.6-
3274 Returns \c true if this item is active; otherwise returns \c false.-
3275-
3276 An item can only be active if the scene is active. An item is active-
3277 if it is, or is a descendent of, an active panel. Items in non-active-
3278 panels are not active.-
3279-
3280 Items that are not part of a panel follow scene activation when the-
3281 scene has no active panel.-
3282-
3283 Only active items can gain input focus.-
3284-
3285 \sa QGraphicsScene::isActive(), QGraphicsScene::activePanel(), panel(), isPanel()-
3286*/-
3287bool QGraphicsItem::isActive() const-
3288{-
3289 if (!d_ptr->scene || !d_ptr->scene->isActive())
!d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
!d_ptr->scene->isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
3290 return false;
never executed: return false;
0
3291 return panel() == d_ptr->scene->activePanel();
never executed: return panel() == d_ptr->scene->activePanel();
0
3292}-
3293-
3294/*!-
3295 \since 4.6-
3296-
3297 If \a active is true, and the scene is active, this item's panel will be-
3298 activated. Otherwise, the panel is deactivated.-
3299-
3300 If the item is not part of an active scene, \a active will decide what-
3301 happens to the panel when the scene becomes active or the item is added to-
3302 the scene. If true, the item's panel will be activated when the item is-
3303 either added to the scene or the scene is activated. Otherwise, the item-
3304 will stay inactive independent of the scene's activated state.-
3305-
3306 \sa isPanel(), QGraphicsScene::setActivePanel(), QGraphicsScene::isActive()-
3307*/-
3308void QGraphicsItem::setActive(bool active)-
3309{-
3310 d_ptr->explicitActivate = 1;-
3311 d_ptr->wantsActive = active;-
3312 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
3313 if (active) {
activeDescription
TRUEnever evaluated
FALSEnever evaluated
0
3314 // Activate this item.-
3315 d_ptr->scene->setActivePanel(this);-
3316 } else {
never executed: end of block
0
3317 QGraphicsItem *activePanel = d_ptr->scene->activePanel();-
3318 QGraphicsItem *thisPanel = panel();-
3319 if (!activePanel || activePanel == thisPanel) {
!activePanelDescription
TRUEnever evaluated
FALSEnever evaluated
activePanel == thisPanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
3320 // Deactivate this item, and reactivate the parent panel,-
3321 // or the last active panel (if any).-
3322 QGraphicsItem *nextToActivate = 0;-
3323 if (d_ptr->parent)
d_ptr->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
3324 nextToActivate = d_ptr->parent->panel();
never executed: nextToActivate = d_ptr->parent->panel();
0
3325 if (!nextToActivate)
!nextToActivateDescription
TRUEnever evaluated
FALSEnever evaluated
0
3326 nextToActivate = d_ptr->scene->d_func()->lastActivePanel;
never executed: nextToActivate = d_ptr->scene->d_func()->lastActivePanel;
0
3327 if (nextToActivate == this || isAncestorOf(nextToActivate))
nextToActivate == thisDescription
TRUEnever evaluated
FALSEnever evaluated
isAncestorOf(nextToActivate)Description
TRUEnever evaluated
FALSEnever evaluated
0
3328 nextToActivate = 0;
never executed: nextToActivate = 0;
0
3329 d_ptr->scene->setActivePanel(nextToActivate);-
3330 }
never executed: end of block
0
3331 }
never executed: end of block
0
3332 }-
3333}
never executed: end of block
0
3334-
3335/*!-
3336 Returns \c true if this item is active, and it or its \l{focusProxy()}{focus-
3337 proxy} has keyboard input focus; otherwise, returns \c false.-
3338-
3339 \sa focusItem(), setFocus(), QGraphicsScene::setFocusItem(), isActive()-
3340*/-
3341bool QGraphicsItem::hasFocus() const-
3342{-
3343 if (!d_ptr->scene || !d_ptr->scene->isActive())
!d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
!d_ptr->scene->isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
3344 return false;
never executed: return false;
0
3345-
3346 if (d_ptr->focusProxy)
d_ptr->focusProxyDescription
TRUEnever evaluated
FALSEnever evaluated
0
3347 return d_ptr->focusProxy->hasFocus();
never executed: return d_ptr->focusProxy->hasFocus();
0
3348-
3349 if (d_ptr->scene->d_func()->focusItem != this)
d_ptr->scene->...usItem != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
3350 return false;
never executed: return false;
0
3351-
3352 return panel() == d_ptr->scene->d_func()->activePanel;
never executed: return panel() == d_ptr->scene->d_func()->activePanel;
0
3353}-
3354-
3355/*!-
3356 Gives keyboard input focus to this item. The \a focusReason argument will-
3357 be passed into any \l{QFocusEvent}{focus event} generated by this function;-
3358 it is used to give an explanation of what caused the item to get focus.-
3359-
3360 Only enabled items that set the ItemIsFocusable flag can accept keyboard-
3361 focus.-
3362-
3363 If this item is not visible, not active, or not associated with a scene,-
3364 it will not gain immediate input focus. However, it will be registered as-
3365 the preferred focus item for its subtree of items, should it later become-
3366 visible.-
3367-
3368 As a result of calling this function, this item will receive a-
3369 \l{focusInEvent()}{focus in event} with \a focusReason. If another item-
3370 already has focus, that item will first receive a \l{focusOutEvent()}-
3371 {focus out event} indicating that it has lost input focus.-
3372-
3373 \sa clearFocus(), hasFocus(), focusItem(), focusProxy()-
3374*/-
3375void QGraphicsItem::setFocus(Qt::FocusReason focusReason)-
3376{-
3377 d_ptr->setFocusHelper(focusReason, /* climb = */ true, /* focusFromHide = */ false);-
3378}
never executed: end of block
0
3379-
3380/*!-
3381 \internal-
3382*/-
3383void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromHide)-
3384{-
3385 // Disabled / unfocusable items cannot accept focus.-
3386 if (!q_ptr->isEnabled() || !(flags & QGraphicsItem::ItemIsFocusable))
!q_ptr->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
!(flags & QGra...emIsFocusable)Description
TRUEnever evaluated
FALSEnever evaluated
0
3387 return;
never executed: return;
0
3388-
3389 // Find focus proxy.-
3390 QGraphicsItem *f = q_ptr;-
3391 while (f->d_ptr->focusProxy)
f->d_ptr->focusProxyDescription
TRUEnever evaluated
FALSEnever evaluated
0
3392 f = f->d_ptr->focusProxy;
never executed: f = f->d_ptr->focusProxy;
0
3393-
3394 // Return if it already has focus.-
3395 if (scene && scene->focusItem() == f)
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
scene->focusItem() == fDescription
TRUEnever evaluated
FALSEnever evaluated
0
3396 return;
never executed: return;
0
3397-
3398 // Update focus scope item ptr.-
3399 QGraphicsItem *p = parent;-
3400 while (p) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
0
3401 if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
p->flags() & Q...emIsFocusScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
3402 QGraphicsItem *oldFocusScopeItem = p->d_ptr->focusScopeItem;-
3403 p->d_ptr->focusScopeItem = q_ptr;-
3404 if (oldFocusScopeItem)
oldFocusScopeItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3405 oldFocusScopeItem->d_ptr->focusScopeItemChange(false);
never executed: oldFocusScopeItem->d_ptr->focusScopeItemChange(false);
0
3406 focusScopeItemChange(true);-
3407 if (!p->focusItem() && !focusFromHide) {
!p->focusItem()Description
TRUEnever evaluated
FALSEnever evaluated
!focusFromHideDescription
TRUEnever evaluated
FALSEnever evaluated
0
3408 // Calling setFocus() on a child of a focus scope that does-
3409 // not have focus changes only the focus scope pointer,-
3410 // so that focus is restored the next time the scope gains-
3411 // focus.-
3412 return;
never executed: return;
0
3413 }-
3414 break;
never executed: break;
0
3415 }-
3416 p = p->d_ptr->parent;-
3417 }
never executed: end of block
0
3418-
3419 if (climb) {
climbDescription
TRUEnever evaluated
FALSEnever evaluated
0
3420 while (f->d_ptr->focusScopeItem && f->d_ptr->focusScopeItem->isVisible())
f->d_ptr->focusScopeItemDescription
TRUEnever evaluated
FALSEnever evaluated
f->d_ptr->focu...m->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
3421 f = f->d_ptr->focusScopeItem;
never executed: f = f->d_ptr->focusScopeItem;
0
3422 }
never executed: end of block
0
3423-
3424 // Update the child focus chain.-
3425 QGraphicsItem *commonAncestor = 0;-
3426 if (scene && scene->focusItem() && scene->focusItem()->panel() == q_ptr->panel()) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
scene->focusItem()Description
TRUEnever evaluated
FALSEnever evaluated
scene->focusIt...q_ptr->panel()Description
TRUEnever evaluated
FALSEnever evaluated
0
3427 commonAncestor = scene->focusItem()->commonAncestorItem(f);-
3428 scene->focusItem()->d_ptr->clearSubFocus(scene->focusItem(), commonAncestor);-
3429 }
never executed: end of block
0
3430-
3431 f->d_ptr->setSubFocus(f, commonAncestor);-
3432-
3433 // Update the scene's focus item.-
3434 if (scene) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
3435 QGraphicsItem *p = q_ptr->panel();-
3436 if ((!p && scene->isActive()) || (p && p->isActive())) {
!pDescription
TRUEnever evaluated
FALSEnever evaluated
scene->isActive()Description
TRUEnever evaluated
FALSEnever evaluated
pDescription
TRUEnever evaluated
FALSEnever evaluated
p->isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
3437 // Visible items immediately gain focus from scene.-
3438 scene->d_func()->setFocusItemHelper(f, focusReason);-
3439 }
never executed: end of block
0
3440 }
never executed: end of block
0
3441}
never executed: end of block
0
3442-
3443/*!-
3444 Takes keyboard input focus from the item.-
3445-
3446 If it has focus, a \l{focusOutEvent()}{focus out event} is sent to this-
3447 item to tell it that it is about to lose the focus.-
3448-
3449 Only items that set the ItemIsFocusable flag, or widgets that set an-
3450 appropriate focus policy, can accept keyboard focus.-
3451-
3452 \sa setFocus(), hasFocus(), QGraphicsWidget::focusPolicy-
3453*/-
3454void QGraphicsItem::clearFocus()-
3455{-
3456 d_ptr->clearFocusHelper(/* giveFocusToParent = */ true,-
3457 /* hiddenByParentPanel = */ false);-
3458}
never executed: end of block
0
3459-
3460/*!-
3461 \internal-
3462*/-
3463void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent, bool hiddenByParentPanel)-
3464{-
3465 QGraphicsItem *subFocusItem = q_ptr;-
3466 if (flags & QGraphicsItem::ItemIsFocusScope) {
flags & QGraph...emIsFocusScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
3467 while (subFocusItem->d_ptr->focusScopeItem)
subFocusItem->...focusScopeItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3468 subFocusItem = subFocusItem->d_ptr->focusScopeItem;
never executed: subFocusItem = subFocusItem->d_ptr->focusScopeItem;
0
3469 }
never executed: end of block
0
3470-
3471 if (giveFocusToParent) {
giveFocusToParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
3472 // Pass focus to the closest parent focus scope-
3473 if (!inDestructor) {
!inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
0
3474 QGraphicsItem *p = parent;-
3475 while (p) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
0
3476 if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
p->flags() & Q...emIsFocusScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
3477 if (p->d_ptr->focusScopeItem == q_ptr) {
p->d_ptr->focu...eItem == q_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
3478 p->d_ptr->focusScopeItem = 0;-
3479 if (!subFocusItem->hasFocus()) //if it has focus, focusScopeItemChange is called elsewhere
!subFocusItem->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
3480 focusScopeItemChange(false);
never executed: focusScopeItemChange(false);
0
3481 }
never executed: end of block
0
3482 if (subFocusItem->hasFocus())
subFocusItem->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
3483 p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ false,
never executed: p->d_ptr->setFocusHelper(Qt::OtherFocusReason, false, false);
0
3484 /* focusFromHide = */ false);
never executed: p->d_ptr->setFocusHelper(Qt::OtherFocusReason, false, false);
0
3485 return;
never executed: return;
0
3486 }-
3487 p = p->d_ptr->parent;-
3488 }
never executed: end of block
0
3489 }
never executed: end of block
0
3490 }
never executed: end of block
0
3491-
3492 if (subFocusItem->hasFocus()) {
subFocusItem->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
3493 // Invisible items with focus must explicitly clear subfocus.-
3494 if (!hiddenByParentPanel)
!hiddenByParentPanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
3495 clearSubFocus(q_ptr);
never executed: clearSubFocus(q_ptr);
0
3496-
3497 // If this item has the scene's input focus, clear it.-
3498 scene->setFocusItem(0);-
3499 }
never executed: end of block
0
3500}
never executed: end of block
0
3501-
3502/*!-
3503 \since 4.6-
3504-
3505 Returns this item's focus proxy, or 0 if this item has no-
3506 focus proxy.-
3507-
3508 \sa setFocusProxy(), setFocus(), hasFocus()-
3509*/-
3510QGraphicsItem *QGraphicsItem::focusProxy() const-
3511{-
3512 return d_ptr->focusProxy;
never executed: return d_ptr->focusProxy;
0
3513}-
3514-
3515/*!-
3516 \since 4.6-
3517-
3518 Sets the item's focus proxy to \a item.-
3519-
3520 If an item has a focus proxy, the focus proxy will receive-
3521 input focus when the item gains input focus. The item itself-
3522 will still have focus (i.e., hasFocus() will return true),-
3523 but only the focus proxy will receive the keyboard input.-
3524-
3525 A focus proxy can itself have a focus proxy, and so on. In-
3526 such case, keyboard input will be handled by the outermost-
3527 focus proxy.-
3528-
3529 The focus proxy \a item must belong to the same scene as-
3530 this item.-
3531-
3532 \sa focusProxy(), setFocus(), hasFocus()-
3533*/-
3534void QGraphicsItem::setFocusProxy(QGraphicsItem *item)-
3535{-
3536 if (item == d_ptr->focusProxy)
item == d_ptr->focusProxyDescription
TRUEnever evaluated
FALSEnever evaluated
0
3537 return;
never executed: return;
0
3538 if (item == this) {
item == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
3539 qWarning("QGraphicsItem::setFocusProxy: cannot assign self as focus proxy");-
3540 return;
never executed: return;
0
3541 }-
3542 if (item) {
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3543 if (item->d_ptr->scene != d_ptr->scene) {
item->d_ptr->s...= d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
3544 qWarning("QGraphicsItem::setFocusProxy: focus proxy must be in same scene");-
3545 return;
never executed: return;
0
3546 }-
3547 for (QGraphicsItem *f = item->focusProxy(); f != 0; f = f->focusProxy()) {
f != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3548 if (f == this) {
f == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
3549 qWarning("QGraphicsItem::setFocusProxy: %p is already in the focus proxy chain", item);-
3550 return;
never executed: return;
0
3551 }-
3552 }
never executed: end of block
0
3553 }
never executed: end of block
0
3554-
3555 QGraphicsItem *lastFocusProxy = d_ptr->focusProxy;-
3556 if (lastFocusProxy)
lastFocusProxyDescription
TRUEnever evaluated
FALSEnever evaluated
0
3557 lastFocusProxy->d_ptr->focusProxyRefs.removeOne(&d_ptr->focusProxy);
never executed: lastFocusProxy->d_ptr->focusProxyRefs.removeOne(&d_ptr->focusProxy);
0
3558 d_ptr->focusProxy = item;-
3559 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3560 item->d_ptr->focusProxyRefs << &d_ptr->focusProxy;
never executed: item->d_ptr->focusProxyRefs << &d_ptr->focusProxy;
0
3561}
never executed: end of block
0
3562-
3563/*!-
3564 \since 4.6-
3565-
3566 If this item, a child or descendant of this item currently has input-
3567 focus, this function will return a pointer to that item. If-
3568 no descendant has input focus, 0 is returned.-
3569-
3570 \sa hasFocus(), setFocus(), QWidget::focusWidget()-
3571*/-
3572QGraphicsItem *QGraphicsItem::focusItem() const-
3573{-
3574 return d_ptr->subFocusItem;
never executed: return d_ptr->subFocusItem;
0
3575}-
3576-
3577/*!-
3578 \internal-
3579-
3580 Returns this item's focus scope item.-
3581*/-
3582QGraphicsItem *QGraphicsItem::focusScopeItem() const-
3583{-
3584 return d_ptr->focusScopeItem;
never executed: return d_ptr->focusScopeItem;
0
3585}-
3586-
3587/*!-
3588 \since 4.4-
3589 Grabs the mouse input.-
3590-
3591 This item will receive all mouse events for the scene until any of the-
3592 following events occurs:-
3593-
3594 \list-
3595 \li The item becomes invisible-
3596 \li The item is removed from the scene-
3597 \li The item is deleted-
3598 \li The item call ungrabMouse()-
3599 \li Another item calls grabMouse(); the item will regain the mouse grab-
3600 when the other item calls ungrabMouse().-
3601 \endlist-
3602-
3603 When an item gains the mouse grab, it receives a QEvent::GrabMouse-
3604 event. When it loses the mouse grab, it receives a QEvent::UngrabMouse-
3605 event. These events can be used to detect when your item gains or loses-
3606 the mouse grab through other means than receiving mouse button events.-
3607-
3608 It is almost never necessary to explicitly grab the mouse in Qt, as Qt-
3609 grabs and releases it sensibly. In particular, Qt grabs the mouse when you-
3610 press a mouse button, and keeps the mouse grabbed until you release the-
3611 last mouse button. Also, Qt::Popup widgets implicitly call grabMouse()-
3612 when shown, and ungrabMouse() when hidden.-
3613-
3614 Note that only visible items can grab mouse input. Calling grabMouse() on-
3615 an invisible item has no effect.-
3616-
3617 Keyboard events are not affected.-
3618-
3619 \sa QGraphicsScene::mouseGrabberItem(), ungrabMouse(), grabKeyboard()-
3620*/-
3621void QGraphicsItem::grabMouse()-
3622{-
3623 if (!d_ptr->scene) {
!d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
3624 qWarning("QGraphicsItem::grabMouse: cannot grab mouse without scene");-
3625 return;
never executed: return;
0
3626 }-
3627 if (!d_ptr->visible) {
!d_ptr->visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
3628 qWarning("QGraphicsItem::grabMouse: cannot grab mouse while invisible");-
3629 return;
never executed: return;
0
3630 }-
3631 d_ptr->scene->d_func()->grabMouse(this);-
3632}
never executed: end of block
0
3633-
3634/*!-
3635 \since 4.4-
3636 Releases the mouse grab.-
3637-
3638 \sa grabMouse(), ungrabKeyboard()-
3639*/-
3640void QGraphicsItem::ungrabMouse()-
3641{-
3642 if (!d_ptr->scene) {
!d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
3643 qWarning("QGraphicsItem::ungrabMouse: cannot ungrab mouse without scene");-
3644 return;
never executed: return;
0
3645 }-
3646 d_ptr->scene->d_func()->ungrabMouse(this);-
3647}
never executed: end of block
0
3648-
3649/*!-
3650 \since 4.4-
3651 Grabs the keyboard input.-
3652-
3653 The item will receive all keyboard input to the scene until one of the-
3654 following events occur:-
3655-
3656 \list-
3657 \li The item becomes invisible-
3658 \li The item is removed from the scene-
3659 \li The item is deleted-
3660 \li The item calls ungrabKeyboard()-
3661 \li Another item calls grabKeyboard(); the item will regain the keyboard grab-
3662 when the other item calls ungrabKeyboard().-
3663 \endlist-
3664-
3665 When an item gains the keyboard grab, it receives a QEvent::GrabKeyboard-
3666 event. When it loses the keyboard grab, it receives a-
3667 QEvent::UngrabKeyboard event. These events can be used to detect when your-
3668 item gains or loses the keyboard grab through other means than gaining-
3669 input focus.-
3670-
3671 It is almost never necessary to explicitly grab the keyboard in Qt, as Qt-
3672 grabs and releases it sensibly. In particular, Qt grabs the keyboard when-
3673 your item gains input focus, and releases it when your item loses input-
3674 focus, or when the item is hidden.-
3675-
3676 Note that only visible items can grab keyboard input. Calling-
3677 grabKeyboard() on an invisible item has no effect.-
3678-
3679 Keyboard events are not affected.-
3680-
3681 \sa ungrabKeyboard(), grabMouse(), setFocus()-
3682*/-
3683void QGraphicsItem::grabKeyboard()-
3684{-
3685 if (!d_ptr->scene) {
!d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
3686 qWarning("QGraphicsItem::grabKeyboard: cannot grab keyboard without scene");-
3687 return;
never executed: return;
0
3688 }-
3689 if (!d_ptr->visible) {
!d_ptr->visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
3690 qWarning("QGraphicsItem::grabKeyboard: cannot grab keyboard while invisible");-
3691 return;
never executed: return;
0
3692 }-
3693 d_ptr->scene->d_func()->grabKeyboard(this);-
3694}
never executed: end of block
0
3695-
3696/*!-
3697 \since 4.4-
3698 Releases the keyboard grab.-
3699-
3700 \sa grabKeyboard(), ungrabMouse()-
3701*/-
3702void QGraphicsItem::ungrabKeyboard()-
3703{-
3704 if (!d_ptr->scene) {
!d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
3705 qWarning("QGraphicsItem::ungrabKeyboard: cannot ungrab keyboard without scene");-
3706 return;
never executed: return;
0
3707 }-
3708 d_ptr->scene->d_func()->ungrabKeyboard(this);-
3709}
never executed: end of block
0
3710-
3711/*!-
3712 Returns the position of the item in parent coordinates. If the item has no-
3713 parent, its position is given in scene coordinates.-
3714-
3715 The position of the item describes its origin (local coordinate-
3716 (0, 0)) in parent coordinates; this function returns the same as-
3717 mapToParent(0, 0).-
3718-
3719 For convenience, you can also call scenePos() to determine the-
3720 item's position in scene coordinates, regardless of its parent.-
3721-
3722 \sa x(), y(), setPos(), transform(), {The Graphics View Coordinate System}-
3723*/-
3724QPointF QGraphicsItem::pos() const-
3725{-
3726 return d_ptr->pos;
never executed: return d_ptr->pos;
0
3727}-
3728-
3729/*!-
3730 \fn QGraphicsItem::x() const-
3731-
3732 This convenience function is equivalent to calling pos().x().-
3733-
3734 \sa y()-
3735*/-
3736-
3737/*!-
3738 \since 4.6-
3739-
3740 Set's the \a x coordinate of the item's position. Equivalent to-
3741 calling setPos(x, y()).-
3742-
3743 \sa x(), setPos()-
3744*/-
3745void QGraphicsItem::setX(qreal x)-
3746{-
3747 if (d_ptr->inDestructor)
d_ptr->inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
0
3748 return;
never executed: return;
0
3749-
3750 if (qIsNaN(x))
qIsNaN(x)Description
TRUEnever evaluated
FALSEnever evaluated
0
3751 return;
never executed: return;
0
3752-
3753 setPos(QPointF(x, d_ptr->pos.y()));-
3754}
never executed: end of block
0
3755-
3756/*!-
3757 \fn QGraphicsItem::y() const-
3758-
3759 This convenience function is equivalent to calling pos().y().-
3760-
3761 \sa x()-
3762*/-
3763-
3764/*!-
3765 \since 4.6-
3766-
3767 Set's the \a y coordinate of the item's position. Equivalent to-
3768 calling setPos(x(), y).-
3769-
3770 \sa x(), setPos()-
3771*/-
3772void QGraphicsItem::setY(qreal y)-
3773{-
3774 if (d_ptr->inDestructor)
d_ptr->inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
0
3775 return;
never executed: return;
0
3776-
3777 if (qIsNaN(y))
qIsNaN(y)Description
TRUEnever evaluated
FALSEnever evaluated
0
3778 return;
never executed: return;
0
3779-
3780 setPos(QPointF(d_ptr->pos.x(), y));-
3781}
never executed: end of block
0
3782-
3783/*!-
3784 Returns the item's position in scene coordinates. This is-
3785 equivalent to calling \c mapToScene(0, 0).-
3786-
3787 \sa pos(), sceneTransform(), {The Graphics View Coordinate System}-
3788*/-
3789QPointF QGraphicsItem::scenePos() const-
3790{-
3791 return mapToScene(0, 0);
never executed: return mapToScene(0, 0);
0
3792}-
3793-
3794/*!-
3795 \internal-
3796-
3797 Sets the position \a pos.-
3798*/-
3799void QGraphicsItemPrivate::setPosHelper(const QPointF &pos)-
3800{-
3801 Q_Q(QGraphicsItem);-
3802 inSetPosHelper = 1;-
3803 if (scene)
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
3804 q->prepareGeometryChange();
never executed: q->prepareGeometryChange();
0
3805 QPointF oldPos = this->pos;-
3806 this->pos = pos;-
3807 dirtySceneTransform = 1;-
3808 inSetPosHelper = 0;-
3809 if (isObject) {
isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
3810 if (pos.x() != oldPos.x())
pos.x() != oldPos.x()Description
TRUEnever evaluated
FALSEnever evaluated
0
3811 emit static_cast<QGraphicsObject *>(q_ptr)->xChanged();
never executed: static_cast<QGraphicsObject *>(q_ptr)->xChanged();
0
3812 if (pos.y() != oldPos.y())
pos.y() != oldPos.y()Description
TRUEnever evaluated
FALSEnever evaluated
0
3813 emit static_cast<QGraphicsObject *>(q_ptr)->yChanged();
never executed: static_cast<QGraphicsObject *>(q_ptr)->yChanged();
0
3814 }
never executed: end of block
0
3815}
never executed: end of block
0
3816-
3817/*!-
3818 \internal-
3819-
3820 Sets the transform \a transform.-
3821*/-
3822void QGraphicsItemPrivate::setTransformHelper(const QTransform &transform)-
3823{-
3824 q_ptr->prepareGeometryChange();-
3825 transformData->transform = transform;-
3826 dirtySceneTransform = 1;-
3827 transformChanged();-
3828}
never executed: end of block
0
3829-
3830/*!-
3831 Sets the position of the item to \a pos, which is in parent-
3832 coordinates. For items with no parent, \a pos is in scene-
3833 coordinates.-
3834-
3835 The position of the item describes its origin (local coordinate-
3836 (0, 0)) in parent coordinates.-
3837-
3838 \sa pos(), scenePos(), {The Graphics View Coordinate System}-
3839*/-
3840void QGraphicsItem::setPos(const QPointF &pos)-
3841{-
3842 if (d_ptr->pos == pos)
d_ptr->pos == posDescription
TRUEnever evaluated
FALSEnever evaluated
0
3843 return;
never executed: return;
0
3844-
3845 if (d_ptr->inDestructor)
d_ptr->inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
0
3846 return;
never executed: return;
0
3847-
3848 // Update and repositition.-
3849 if (!(d_ptr->flags & (ItemSendsGeometryChanges | ItemSendsScenePositionChanges))) {
!(d_ptr->flags...itionChanges))Description
TRUEnever evaluated
FALSEnever evaluated
0
3850 d_ptr->setPosHelper(pos);-
3851 if (d_ptr->isWidget)
d_ptr->isWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
3852 static_cast<QGraphicsWidget *>(this)->d_func()->setGeometryFromSetPos();
never executed: static_cast<QGraphicsWidget *>(this)->d_func()->setGeometryFromSetPos();
0
3853 if (d_ptr->scenePosDescendants)
d_ptr->scenePosDescendantsDescription
TRUEnever evaluated
FALSEnever evaluated
0
3854 d_ptr->sendScenePosChange();
never executed: d_ptr->sendScenePosChange();
0
3855 return;
never executed: return;
0
3856 }-
3857-
3858 // Notify the item that the position is changing.-
3859 const QVariant newPosVariant(itemChange(ItemPositionChange, QVariant::fromValue<QPointF>(pos)));-
3860 QPointF newPos = newPosVariant.toPointF();-
3861 if (newPos == d_ptr->pos)
newPos == d_ptr->posDescription
TRUEnever evaluated
FALSEnever evaluated
0
3862 return;
never executed: return;
0
3863-
3864 // Update and repositition.-
3865 d_ptr->setPosHelper(newPos);-
3866-
3867 // Send post-notification.-
3868 itemChange(QGraphicsItem::ItemPositionHasChanged, newPosVariant);-
3869 d_ptr->sendScenePosChange();-
3870}
never executed: end of block
0
3871-
3872/*!-
3873 \fn void QGraphicsItem::setPos(qreal x, qreal y)-
3874 \overload-
3875-
3876 This convenience function is equivalent to calling setPos(QPointF(\a x, \a-
3877 y)).-
3878*/-
3879-
3880/*!-
3881 \fn void QGraphicsItem::moveBy(qreal dx, qreal dy)-
3882-
3883 Moves the item by \a dx points horizontally, and \a dy point-
3884 vertically. This function is equivalent to calling setPos(pos() +-
3885 QPointF(\a dx, \a dy)).-
3886*/-
3887-
3888/*!-
3889 If this item is part of a scene that is viewed by a QGraphicsView, this-
3890 convenience function will attempt to scroll the view to ensure that \a-
3891 rect is visible inside the view's viewport. If \a rect is a null rect (the-
3892 default), QGraphicsItem will default to the item's bounding rect. \a xmargin-
3893 and \a ymargin are the number of pixels the view should use for margins.-
3894-
3895 If the specified rect cannot be reached, the contents are scrolled to the-
3896 nearest valid position.-
3897-
3898 If this item is not viewed by a QGraphicsView, this function does nothing.-
3899-
3900 \sa QGraphicsView::ensureVisible()-
3901*/-
3902void QGraphicsItem::ensureVisible(const QRectF &rect, int xmargin, int ymargin)-
3903{-
3904 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
3905 QRectF sceneRect;-
3906 if (!rect.isNull())
!rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
3907 sceneRect = sceneTransform().mapRect(rect);
never executed: sceneRect = sceneTransform().mapRect(rect);
0
3908 else-
3909 sceneRect = sceneBoundingRect();
never executed: sceneRect = sceneBoundingRect();
0
3910 foreach (QGraphicsView *view, d_ptr->scene->d_func()->views)-
3911 view->ensureVisible(sceneRect, xmargin, ymargin);
never executed: view->ensureVisible(sceneRect, xmargin, ymargin);
0
3912 }
never executed: end of block
0
3913}
never executed: end of block
0
3914-
3915/*!-
3916 \fn void QGraphicsItem::ensureVisible(qreal x, qreal y, qreal w, qreal h,-
3917 int xmargin = 50, int ymargin = 50)-
3918-
3919 This convenience function is equivalent to calling-
3920 ensureVisible(QRectF(\a x, \a y, \a w, \a h), \a xmargin, \a ymargin).-
3921*/-
3922-
3923/*!-
3924 \obsolete-
3925-
3926 Returns the item's affine transformation matrix. This is a subset or the-
3927 item's full transformation matrix, and might not represent the item's full-
3928 transformation.-
3929-
3930 Use transform() instead.-
3931-
3932 \sa setTransform(), sceneTransform()-
3933*/-
3934QMatrix QGraphicsItem::matrix() const-
3935{-
3936 return transform().toAffine();
never executed: return transform().toAffine();
0
3937}-
3938-
3939/*!-
3940 \since 4.3-
3941-
3942 Returns this item's transformation matrix.-
3943-
3944 The transformation matrix is combined with the item's rotation(), scale()-
3945 and transformations() into a combined transformations for the item.-
3946-
3947 The default transformation matrix is an identity matrix.-
3948-
3949 \sa setTransform(), sceneTransform()-
3950*/-
3951QTransform QGraphicsItem::transform() const-
3952{-
3953 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
3954 return QTransform();
never executed: return QTransform();
0
3955 return d_ptr->transformData->transform;
never executed: return d_ptr->transformData->transform;
0
3956}-
3957-
3958/*!-
3959 \since 4.6-
3960-
3961 Returns the clockwise rotation, in degrees, around the Z axis. The default-
3962 value is 0 (i.e., the item is not rotated).-
3963-
3964 The rotation is combined with the item's scale(), transform() and-
3965 transformations() to map the item's coordinate system to the parent item.-
3966-
3967 \sa setRotation(), transformOriginPoint(), {Transformations}-
3968*/-
3969qreal QGraphicsItem::rotation() const-
3970{-
3971 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
3972 return 0;
never executed: return 0;
0
3973 return d_ptr->transformData->rotation;
never executed: return d_ptr->transformData->rotation;
0
3974}-
3975-
3976/*!-
3977 \since 4.6-
3978-
3979 Sets the clockwise rotation \a angle, in degrees, around the Z axis. The-
3980 default value is 0 (i.e., the item is not rotated). Assigning a negative-
3981 value will rotate the item counter-clockwise. Normally the rotation angle-
3982 is in the range (-360, 360), but it's also possible to assign values-
3983 outside of this range (e.g., a rotation of 370 degrees is the same as a-
3984 rotation of 10 degrees).-
3985-
3986 The item is rotated around its transform origin point, which by default-
3987 is (0, 0). You can select a different transformation origin by calling-
3988 setTransformOriginPoint().-
3989-
3990 The rotation is combined with the item's scale(), transform() and-
3991 transformations() to map the item's coordinate system to the parent item.-
3992-
3993 \sa rotation(), setTransformOriginPoint(), {Transformations}-
3994*/-
3995void QGraphicsItem::setRotation(qreal angle)-
3996{-
3997 prepareGeometryChange();-
3998 qreal newRotation = angle;-
3999-
4000 if (d_ptr->flags & ItemSendsGeometryChanges) {
d_ptr->flags &...eometryChangesDescription
TRUEnever evaluated
FALSEnever evaluated
0
4001 // Notify the item that the rotation is changing.-
4002 const QVariant newRotationVariant(itemChange(ItemRotationChange, angle));-
4003 newRotation = newRotationVariant.toReal();-
4004 }
never executed: end of block
0
4005-
4006 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4007 d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
0
4008-
4009 if (d_ptr->transformData->rotation == newRotation)
d_ptr->transfo...== newRotationDescription
TRUEnever evaluated
FALSEnever evaluated
0
4010 return;
never executed: return;
0
4011-
4012 d_ptr->transformData->rotation = newRotation;-
4013 d_ptr->transformData->onlyTransform = false;-
4014 d_ptr->dirtySceneTransform = 1;-
4015-
4016 // Send post-notification.-
4017 if (d_ptr->flags & ItemSendsGeometryChanges)
d_ptr->flags &...eometryChangesDescription
TRUEnever evaluated
FALSEnever evaluated
0
4018 itemChange(ItemRotationHasChanged, newRotation);
never executed: itemChange(ItemRotationHasChanged, newRotation);
0
4019-
4020 if (d_ptr->isObject)
d_ptr->isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
4021 emit static_cast<QGraphicsObject *>(this)->rotationChanged();
never executed: static_cast<QGraphicsObject *>(this)->rotationChanged();
0
4022-
4023 d_ptr->transformChanged();-
4024}
never executed: end of block
0
4025-
4026/*!-
4027 \since 4.6-
4028-
4029 Returns the scale factor of the item. The default scale factor is 1.0-
4030 (i.e., the item is not scaled).-
4031-
4032 The scale is combined with the item's rotation(), transform() and-
4033 transformations() to map the item's coordinate system to the parent item.-
4034-
4035 \sa setScale(), rotation(), {Transformations}-
4036*/-
4037qreal QGraphicsItem::scale() const-
4038{-
4039 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4040 return 1.;
never executed: return 1.;
0
4041 return d_ptr->transformData->scale;
never executed: return d_ptr->transformData->scale;
0
4042}-
4043-
4044/*!-
4045 \since 4.6-
4046-
4047 Sets the scale \a factor of the item. The default scale factor is 1.0-
4048 (i.e., the item is not scaled). A scale factor of 0.0 will collapse the-
4049 item to a single point. If you provide a negative scale factor, the-
4050 item will be flipped and mirrored (i.e., rotated 180 degrees).-
4051-
4052 The item is scaled around its transform origin point, which by default-
4053 is (0, 0). You can select a different transformation origin by calling-
4054 setTransformOriginPoint().-
4055-
4056 The scale is combined with the item's rotation(), transform() and-
4057 transformations() to map the item's coordinate system to the parent item.-
4058-
4059 \sa scale(), setTransformOriginPoint(), {Transformations Example}-
4060*/-
4061void QGraphicsItem::setScale(qreal factor)-
4062{-
4063 prepareGeometryChange();-
4064 qreal newScale = factor;-
4065-
4066 if (d_ptr->flags & ItemSendsGeometryChanges) {
d_ptr->flags &...eometryChangesDescription
TRUEnever evaluated
FALSEnever evaluated
0
4067 // Notify the item that the scale is changing.-
4068 const QVariant newScaleVariant(itemChange(ItemScaleChange, factor));-
4069 newScale = newScaleVariant.toReal();-
4070 }
never executed: end of block
0
4071-
4072 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4073 d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
0
4074-
4075 if (d_ptr->transformData->scale == newScale)
d_ptr->transfo...le == newScaleDescription
TRUEnever evaluated
FALSEnever evaluated
0
4076 return;
never executed: return;
0
4077-
4078 d_ptr->transformData->scale = newScale;-
4079 d_ptr->transformData->onlyTransform = false;-
4080 d_ptr->dirtySceneTransform = 1;-
4081-
4082 // Send post-notification.-
4083 if (d_ptr->flags & ItemSendsGeometryChanges)
d_ptr->flags &...eometryChangesDescription
TRUEnever evaluated
FALSEnever evaluated
0
4084 itemChange(ItemScaleHasChanged, newScale);
never executed: itemChange(ItemScaleHasChanged, newScale);
0
4085-
4086 if (d_ptr->isObject)
d_ptr->isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
4087 emit static_cast<QGraphicsObject *>(this)->scaleChanged();
never executed: static_cast<QGraphicsObject *>(this)->scaleChanged();
0
4088-
4089 d_ptr->transformChanged();-
4090}
never executed: end of block
0
4091-
4092-
4093/*!-
4094 \since 4.6-
4095-
4096 Returns a list of graphics transforms that currently apply to this item.-
4097-
4098 QGraphicsTransform is for applying and controlling a chain of individual-
4099 transformation operations on an item. It's particularly useful in-
4100 animations, where each transform operation needs to be interpolated-
4101 independently, or differently.-
4102-
4103 The transformations are combined with the item's rotation(), scale() and-
4104 transform() to map the item's coordinate system to the parent item.-
4105-
4106 \sa scale(), rotation(), transformOriginPoint(), {Transformations}-
4107*/-
4108QList<QGraphicsTransform *> QGraphicsItem::transformations() const-
4109{-
4110 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4111 return QList<QGraphicsTransform *>();
never executed: return QList<QGraphicsTransform *>();
0
4112 return d_ptr->transformData->graphicsTransforms;
never executed: return d_ptr->transformData->graphicsTransforms;
0
4113}-
4114-
4115/*!-
4116 \since 4.6-
4117-
4118 Sets a list of graphics \a transformations (QGraphicsTransform) that-
4119 currently apply to this item.-
4120-
4121 If all you want is to rotate or scale an item, you should call setRotation()-
4122 or setScale() instead. If you want to set an arbitrary transformation on-
4123 an item, you can call setTransform().-
4124-
4125 QGraphicsTransform is for applying and controlling a chain of individual-
4126 transformation operations on an item. It's particularly useful in-
4127 animations, where each transform operation needs to be interpolated-
4128 independently, or differently.-
4129-
4130 The transformations are combined with the item's rotation(), scale() and-
4131 transform() to map the item's coordinate system to the parent item.-
4132-
4133 \sa scale(), setTransformOriginPoint(), {Transformations}-
4134*/-
4135void QGraphicsItem::setTransformations(const QList<QGraphicsTransform *> &transformations)-
4136{-
4137 prepareGeometryChange();-
4138 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4139 d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
0
4140 d_ptr->transformData->graphicsTransforms = transformations;-
4141 for (int i = 0; i < transformations.size(); ++i)
i < transformations.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
4142 transformations.at(i)->d_func()->setItem(this);
never executed: transformations.at(i)->d_func()->setItem(this);
0
4143 d_ptr->transformData->onlyTransform = false;-
4144 d_ptr->dirtySceneTransform = 1;-
4145 d_ptr->transformChanged();-
4146}
never executed: end of block
0
4147-
4148/*!-
4149 \internal-
4150*/-
4151void QGraphicsItemPrivate::prependGraphicsTransform(QGraphicsTransform *t)-
4152{-
4153 if (!transformData)
!transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4154 transformData = new QGraphicsItemPrivate::TransformData;
never executed: transformData = new QGraphicsItemPrivate::TransformData;
0
4155 if (!transformData->graphicsTransforms.contains(t))
!transformData...ms.contains(t)Description
TRUEnever evaluated
FALSEnever evaluated
0
4156 transformData->graphicsTransforms.prepend(t);
never executed: transformData->graphicsTransforms.prepend(t);
0
4157-
4158 Q_Q(QGraphicsItem);-
4159 t->d_func()->setItem(q);-
4160 transformData->onlyTransform = false;-
4161 dirtySceneTransform = 1;-
4162 transformChanged();-
4163}
never executed: end of block
0
4164-
4165/*!-
4166 \internal-
4167*/-
4168void QGraphicsItemPrivate::appendGraphicsTransform(QGraphicsTransform *t)-
4169{-
4170 if (!transformData)
!transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4171 transformData = new QGraphicsItemPrivate::TransformData;
never executed: transformData = new QGraphicsItemPrivate::TransformData;
0
4172 if (!transformData->graphicsTransforms.contains(t))
!transformData...ms.contains(t)Description
TRUEnever evaluated
FALSEnever evaluated
0
4173 transformData->graphicsTransforms.append(t);
never executed: transformData->graphicsTransforms.append(t);
0
4174-
4175 Q_Q(QGraphicsItem);-
4176 t->d_func()->setItem(q);-
4177 transformData->onlyTransform = false;-
4178 dirtySceneTransform = 1;-
4179 transformChanged();-
4180}
never executed: end of block
0
4181-
4182/*!-
4183 \since 4.6-
4184-
4185 Returns the origin point for the transformation in item coordinates.-
4186-
4187 The default is QPointF(0,0).-
4188-
4189 \sa setTransformOriginPoint(), {Transformations}-
4190*/-
4191QPointF QGraphicsItem::transformOriginPoint() const-
4192{-
4193 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4194 return QPointF(0,0);
never executed: return QPointF(0,0);
0
4195 return QPointF(d_ptr->transformData->xOrigin, d_ptr->transformData->yOrigin);
never executed: return QPointF(d_ptr->transformData->xOrigin, d_ptr->transformData->yOrigin);
0
4196}-
4197-
4198/*!-
4199 \since 4.6-
4200-
4201 Sets the \a origin point for the transformation in item coordinates.-
4202-
4203 \sa transformOriginPoint(), {Transformations}-
4204*/-
4205void QGraphicsItem::setTransformOriginPoint(const QPointF &origin)-
4206{-
4207 prepareGeometryChange();-
4208 QPointF newOrigin = origin;-
4209-
4210 if (d_ptr->flags & ItemSendsGeometryChanges) {
d_ptr->flags &...eometryChangesDescription
TRUEnever evaluated
FALSEnever evaluated
0
4211 // Notify the item that the origin point is changing.-
4212 const QVariant newOriginVariant(itemChange(ItemTransformOriginPointChange,-
4213 QVariant::fromValue<QPointF>(origin)));-
4214 newOrigin = newOriginVariant.toPointF();-
4215 }
never executed: end of block
0
4216-
4217 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4218 d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
0
4219-
4220 if (d_ptr->transformData->xOrigin == newOrigin.x()
d_ptr->transfo... newOrigin.x()Description
TRUEnever evaluated
FALSEnever evaluated
0
4221 && d_ptr->transformData->yOrigin == newOrigin.y()) {
d_ptr->transfo... newOrigin.y()Description
TRUEnever evaluated
FALSEnever evaluated
0
4222 return;
never executed: return;
0
4223 }-
4224-
4225 d_ptr->transformData->xOrigin = newOrigin.x();-
4226 d_ptr->transformData->yOrigin = newOrigin.y();-
4227 d_ptr->transformData->onlyTransform = false;-
4228 d_ptr->dirtySceneTransform = 1;-
4229-
4230 // Send post-notification.-
4231 if (d_ptr->flags & ItemSendsGeometryChanges)
d_ptr->flags &...eometryChangesDescription
TRUEnever evaluated
FALSEnever evaluated
0
4232 itemChange(ItemTransformOriginPointHasChanged, QVariant::fromValue<QPointF>(newOrigin));
never executed: itemChange(ItemTransformOriginPointHasChanged, QVariant::fromValue<QPointF>(newOrigin));
0
4233}
never executed: end of block
0
4234-
4235/*!-
4236 \fn void QGraphicsItem::setTransformOriginPoint(qreal x, qreal y)-
4237-
4238 \since 4.6-
4239 \overload-
4240-
4241 Sets the origin point for the transformation in item coordinates.-
4242 This is equivalent to calling setTransformOriginPoint(QPointF(\a x, \a y)).-
4243-
4244 \sa setTransformOriginPoint(), {Transformations}-
4245*/-
4246-
4247-
4248/*!-
4249 \obsolete-
4250-
4251 Use sceneTransform() instead.-
4252-
4253 \sa transform(), setTransform(), scenePos(), {The Graphics View Coordinate System}-
4254*/-
4255QMatrix QGraphicsItem::sceneMatrix() const-
4256{-
4257 d_ptr->ensureSceneTransform();-
4258 return d_ptr->sceneTransform.toAffine();
never executed: return d_ptr->sceneTransform.toAffine();
0
4259}-
4260-
4261-
4262/*!-
4263 \since 4.3-
4264-
4265 Returns this item's scene transformation matrix. This matrix can be used-
4266 to map coordinates and geometrical shapes from this item's local-
4267 coordinate system to the scene's coordinate system. To map coordinates-
4268 from the scene, you must first invert the returned matrix.-
4269-
4270 Example:-
4271-
4272 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 4-
4273-
4274 Unlike transform(), which returns only an item's local transformation, this-
4275 function includes the item's (and any parents') position, and all the transfomation properties.-
4276-
4277 \sa transform(), setTransform(), scenePos(), {The Graphics View Coordinate System}, {Transformations}-
4278*/-
4279QTransform QGraphicsItem::sceneTransform() const-
4280{-
4281 d_ptr->ensureSceneTransform();-
4282 return d_ptr->sceneTransform;
never executed: return d_ptr->sceneTransform;
0
4283}-
4284-
4285/*!-
4286 \since 4.3-
4287-
4288 Returns this item's device transformation matrix, using \a-
4289 viewportTransform to map from scene to device coordinates. This matrix can-
4290 be used to map coordinates and geometrical shapes from this item's local-
4291 coordinate system to the viewport's (or any device's) coordinate-
4292 system. To map coordinates from the viewport, you must first invert the-
4293 returned matrix.-
4294-
4295 Example:-
4296-
4297 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 5-
4298-
4299 This function is the same as combining this item's scene transform with-
4300 the view's viewport transform, but it also understands the-
4301 ItemIgnoresTransformations flag. The device transform can be used to do-
4302 accurate coordinate mapping (and collision detection) for untransformable-
4303 items.-
4304-
4305 \sa transform(), setTransform(), scenePos(), {The Graphics View Coordinate-
4306 System}, itemTransform()-
4307*/-
4308QTransform QGraphicsItem::deviceTransform(const QTransform &viewportTransform) const-
4309{-
4310 // Ensure we return the standard transform if we're not untransformable.-
4311 if (!d_ptr->itemIsUntransformable()) {
!d_ptr->itemIs...ransformable()Description
TRUEnever evaluated
FALSEnever evaluated
0
4312 d_ptr->ensureSceneTransform();-
4313 return d_ptr->sceneTransform * viewportTransform;
never executed: return d_ptr->sceneTransform * viewportTransform;
0
4314 }-
4315-
4316 // Find the topmost item that ignores view transformations.-
4317 const QGraphicsItem *untransformedAncestor = this;-
4318 QList<const QGraphicsItem *> parents;-
4319 while (untransformedAncestor && ((untransformedAncestor->d_ptr->ancestorFlags
untransformedAncestorDescription
TRUEnever evaluated
FALSEnever evaluated
((untransforme...nsformations))Description
TRUEnever evaluated
FALSEnever evaluated
0
4320 & QGraphicsItemPrivate::AncestorIgnoresTransformations))) {
((untransforme...nsformations))Description
TRUEnever evaluated
FALSEnever evaluated
0
4321 parents.prepend(untransformedAncestor);-
4322 untransformedAncestor = untransformedAncestor->parentItem();-
4323 }
never executed: end of block
0
4324-
4325 if (!untransformedAncestor) {
!untransformedAncestorDescription
TRUEnever evaluated
FALSEnever evaluated
0
4326 // Assert in debug mode, continue in release.-
4327 Q_ASSERT_X(untransformedAncestor, "QGraphicsItem::deviceTransform",-
4328 "Invalid object structure!");-
4329 return QTransform();
never executed: return QTransform();
0
4330 }-
4331-
4332 // Determine the inherited origin. Find the parent of the topmost untransformable.-
4333 // Use its scene transform to map the position of the untransformable. Then use-
4334 // that viewport position as the anchoring point for the untransformable subtree.-
4335 QGraphicsItem *parentOfUntransformedAncestor = untransformedAncestor->parentItem();-
4336 QTransform inheritedMatrix;-
4337 if (parentOfUntransformedAncestor)
parentOfUntransformedAncestorDescription
TRUEnever evaluated
FALSEnever evaluated
0
4338 inheritedMatrix = parentOfUntransformedAncestor->sceneTransform();
never executed: inheritedMatrix = parentOfUntransformedAncestor->sceneTransform();
0
4339 QPointF mappedPoint = (inheritedMatrix * viewportTransform).map(untransformedAncestor->pos());-
4340-
4341 // COMBINE-
4342 QTransform matrix = QTransform::fromTranslate(mappedPoint.x(), mappedPoint.y());-
4343 if (untransformedAncestor->d_ptr->transformData)
untransformedA...>transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4344 matrix = untransformedAncestor->d_ptr->transformData->computedFullTransform(&matrix);
never executed: matrix = untransformedAncestor->d_ptr->transformData->computedFullTransform(&matrix);
0
4345-
4346 // Then transform and translate all children.-
4347 for (int i = 0; i < parents.size(); ++i) {
i < parents.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
4348 const QGraphicsItem *parent = parents.at(i);-
4349 parent->d_ptr->combineTransformFromParent(&matrix);-
4350 }
never executed: end of block
0
4351-
4352 return matrix;
never executed: return matrix;
0
4353}-
4354-
4355/*!-
4356 \since 4.5-
4357-
4358 Returns a QTransform that maps coordinates from this item to \a other. If-
4359 \a ok is not null, and if there is no such transform, the boolean pointed-
4360 to by \a ok will be set to false; otherwise it will be set to true.-
4361-
4362 This transform provides an alternative to the mapToItem() or mapFromItem()-
4363 functions, by returning the appropriate transform so that you can map-
4364 shapes and coordinates yourself. It also helps you write more efficient-
4365 code when repeatedly mapping between the same two items.-
4366-
4367 \note In rare circumstances, there is no transform that maps between two-
4368 items.-
4369-
4370 \sa mapToItem(), mapFromItem(), deviceTransform()-
4371*/-
4372QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) const-
4373{-
4374 // Catch simple cases first.-
4375 if (other == 0) {
other == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
4376 qWarning("QGraphicsItem::itemTransform: null pointer passed");-
4377 return QTransform();
never executed: return QTransform();
0
4378 }-
4379 if (other == this) {
other == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
4380 if (ok)
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
4381 *ok = true;
never executed: *ok = true;
0
4382 return QTransform();
never executed: return QTransform();
0
4383 }-
4384-
4385 QGraphicsItem *parent = d_ptr->parent;-
4386 const QGraphicsItem *otherParent = other->d_ptr->parent;-
4387-
4388 // This is other's child-
4389 if (parent == other) {
parent == otherDescription
TRUEnever evaluated
FALSEnever evaluated
0
4390 if (ok)
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
4391 *ok = true;
never executed: *ok = true;
0
4392 QTransform x;-
4393 d_ptr->combineTransformFromParent(&x);-
4394 return x;
never executed: return x;
0
4395 }-
4396-
4397 // This is other's parent-
4398 if (otherParent == this) {
otherParent == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
4399 const QPointF &otherPos = other->d_ptr->pos;-
4400 if (other->d_ptr->transformData) {
other->d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4401 QTransform otherToParent;-
4402 other->d_ptr->combineTransformFromParent(&otherToParent);-
4403 return otherToParent.inverted(ok);
never executed: return otherToParent.inverted(ok);
0
4404 }-
4405 if (ok)
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
4406 *ok = true;
never executed: *ok = true;
0
4407 return QTransform::fromTranslate(-otherPos.x(), -otherPos.y());
never executed: return QTransform::fromTranslate(-otherPos.x(), -otherPos.y());
0
4408 }-
4409-
4410 // Siblings-
4411 if (parent == otherParent) {
parent == otherParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
4412 // COMBINE-
4413 const QPointF &itemPos = d_ptr->pos;-
4414 const QPointF &otherPos = other->d_ptr->pos;-
4415 if (!d_ptr->transformData && !other->d_ptr->transformData) {
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
!other->d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4416 QPointF delta = itemPos - otherPos;-
4417 if (ok)
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
4418 *ok = true;
never executed: *ok = true;
0
4419 return QTransform::fromTranslate(delta.x(), delta.y());
never executed: return QTransform::fromTranslate(delta.x(), delta.y());
0
4420 }-
4421-
4422 QTransform itemToParent;-
4423 d_ptr->combineTransformFromParent(&itemToParent);-
4424 QTransform otherToParent;-
4425 other->d_ptr->combineTransformFromParent(&otherToParent);-
4426 return itemToParent * otherToParent.inverted(ok);
never executed: return itemToParent * otherToParent.inverted(ok);
0
4427 }-
4428-
4429 // Find the closest common ancestor. If the two items don't share an-
4430 // ancestor, then the only way is to combine their scene transforms.-
4431 const QGraphicsItem *commonAncestor = commonAncestorItem(other);-
4432 if (!commonAncestor) {
!commonAncestorDescription
TRUEnever evaluated
FALSEnever evaluated
0
4433 d_ptr->ensureSceneTransform();-
4434 other->d_ptr->ensureSceneTransform();-
4435 return d_ptr->sceneTransform * other->d_ptr->sceneTransform.inverted(ok);
never executed: return d_ptr->sceneTransform * other->d_ptr->sceneTransform.inverted(ok);
0
4436 }-
4437-
4438 // If the two items are cousins (in sibling branches), map both to the-
4439 // common ancestor, and combine the two transforms.-
4440 bool cousins = other != commonAncestor && this != commonAncestor;
other != commonAncestorDescription
TRUEnever evaluated
FALSEnever evaluated
this != commonAncestorDescription
TRUEnever evaluated
FALSEnever evaluated
0
4441 if (cousins) {
cousinsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4442 bool good = false;-
4443 QTransform thisToScene = itemTransform(commonAncestor, &good);-
4444 QTransform otherToScene(Qt::Uninitialized);-
4445 if (good)
goodDescription
TRUEnever evaluated
FALSEnever evaluated
0
4446 otherToScene = other->itemTransform(commonAncestor, &good);
never executed: otherToScene = other->itemTransform(commonAncestor, &good);
0
4447 if (!good) {
!goodDescription
TRUEnever evaluated
FALSEnever evaluated
0
4448 if (ok)
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
4449 *ok = false;
never executed: *ok = false;
0
4450 return QTransform();
never executed: return QTransform();
0
4451 }-
4452 return thisToScene * otherToScene.inverted(ok);
never executed: return thisToScene * otherToScene.inverted(ok);
0
4453 }-
4454-
4455 // One is an ancestor of the other; walk the chain.-
4456 bool parentOfOther = isAncestorOf(other);-
4457 const QGraphicsItem *child = parentOfOther ? other : this;
parentOfOtherDescription
TRUEnever evaluated
FALSEnever evaluated
0
4458 const QGraphicsItem *root = parentOfOther ? this : other;
parentOfOtherDescription
TRUEnever evaluated
FALSEnever evaluated
0
4459-
4460 QTransform x;-
4461 const QGraphicsItem *p = child;-
4462 do {-
4463 p->d_ptr.data()->combineTransformToParent(&x);-
4464 } while ((p = p->d_ptr->parent) && p != root);
never executed: end of block
(p = p->d_ptr->parent)Description
TRUEnever evaluated
FALSEnever evaluated
p != rootDescription
TRUEnever evaluated
FALSEnever evaluated
0
4465 if (parentOfOther)
parentOfOtherDescription
TRUEnever evaluated
FALSEnever evaluated
0
4466 return x.inverted(ok);
never executed: return x.inverted(ok);
0
4467 if (ok)
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
4468 *ok = true;
never executed: *ok = true;
0
4469 return x;
never executed: return x;
0
4470}-
4471-
4472/*!-
4473 \obsolete-
4474-
4475 Sets the item's affine transformation matrix. This is a subset or the-
4476 item's full transformation matrix, and might not represent the item's full-
4477 transformation.-
4478-
4479 Use setTransform() instead.-
4480-
4481 \sa transform(), {The Graphics View Coordinate System}-
4482*/-
4483void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine)-
4484{-
4485 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4486 d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
0
4487-
4488 QTransform newTransform(combine ? QTransform(matrix) * d_ptr->transformData->transform : QTransform(matrix));-
4489 if (d_ptr->transformData->transform == newTransform)
d_ptr->transfo...= newTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4490 return;
never executed: return;
0
4491-
4492 // Update and set the new transformation.-
4493 if (!(d_ptr->flags & ItemSendsGeometryChanges)) {
!(d_ptr->flags...ometryChanges)Description
TRUEnever evaluated
FALSEnever evaluated
0
4494 d_ptr->setTransformHelper(newTransform);-
4495 return;
never executed: return;
0
4496 }-
4497-
4498 // Notify the item that the transformation matrix is changing.-
4499 const QVariant newMatrixVariant = QVariant::fromValue<QMatrix>(newTransform.toAffine());-
4500 newTransform = QTransform(qvariant_cast<QMatrix>(itemChange(ItemMatrixChange, newMatrixVariant)));-
4501 if (d_ptr->transformData->transform == newTransform)
d_ptr->transfo...= newTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4502 return;
never executed: return;
0
4503-
4504 // Update and set the new transformation.-
4505 d_ptr->setTransformHelper(newTransform);-
4506-
4507 // Send post-notification.-
4508 itemChange(ItemTransformHasChanged, QVariant::fromValue<QTransform>(newTransform));-
4509}
never executed: end of block
0
4510-
4511/*!-
4512 \since 4.3-
4513-
4514 Sets the item's current transformation matrix to \a matrix.-
4515-
4516 If \a combine is true, then \a matrix is combined with the current matrix;-
4517 otherwise, \a matrix \e replaces the current matrix. \a combine is false-
4518 by default.-
4519-
4520 To simplify interation with items using a transformed view, QGraphicsItem-
4521 provides mapTo... and mapFrom... functions that can translate between-
4522 items' and the scene's coordinates. For example, you can call mapToScene()-
4523 to map an item coordiate to a scene coordinate, or mapFromScene() to map-
4524 from scene coordinates to item coordinates.-
4525-
4526 The transformation matrix is combined with the item's rotation(), scale()-
4527 and transformations() into a combined transformation that maps the item's-
4528 coordinate system to its parent.-
4529-
4530 \sa transform(), setRotation(), setScale(), setTransformOriginPoint(), {The Graphics View Coordinate System}, {Transformations}-
4531*/-
4532void QGraphicsItem::setTransform(const QTransform &matrix, bool combine)-
4533{-
4534 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4535 d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
0
4536-
4537 QTransform newTransform(combine ? matrix * d_ptr->transformData->transform : matrix);-
4538 if (d_ptr->transformData->transform == newTransform)
d_ptr->transfo...= newTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4539 return;
never executed: return;
0
4540-
4541 // Update and set the new transformation.-
4542 if (!(d_ptr->flags & (ItemSendsGeometryChanges | ItemSendsScenePositionChanges))) {
!(d_ptr->flags...itionChanges))Description
TRUEnever evaluated
FALSEnever evaluated
0
4543 d_ptr->setTransformHelper(newTransform);-
4544 if (d_ptr->scenePosDescendants)
d_ptr->scenePosDescendantsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4545 d_ptr->sendScenePosChange();
never executed: d_ptr->sendScenePosChange();
0
4546 return;
never executed: return;
0
4547 }-
4548-
4549 // Notify the item that the transformation matrix is changing.-
4550 const QVariant newTransformVariant(itemChange(ItemTransformChange,-
4551 QVariant::fromValue<QTransform>(newTransform)));-
4552 newTransform = qvariant_cast<QTransform>(newTransformVariant);-
4553 if (d_ptr->transformData->transform == newTransform)
d_ptr->transfo...= newTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4554 return;
never executed: return;
0
4555-
4556 // Update and set the new transformation.-
4557 d_ptr->setTransformHelper(newTransform);-
4558-
4559 // Send post-notification.-
4560 itemChange(ItemTransformHasChanged, newTransformVariant);-
4561 d_ptr->sendScenePosChange();-
4562}
never executed: end of block
0
4563-
4564/*!-
4565 \obsolete-
4566-
4567 Use resetTransform() instead.-
4568*/-
4569void QGraphicsItem::resetMatrix()-
4570{-
4571 resetTransform();-
4572}
never executed: end of block
0
4573-
4574/*!-
4575 \since 4.3-
4576-
4577 Resets this item's transformation matrix to the identity matrix or-
4578 all the transformation properties to their default values.-
4579 This is equivalent to calling \c setTransform(QTransform()).-
4580-
4581 \sa setTransform(), transform()-
4582*/-
4583void QGraphicsItem::resetTransform()-
4584{-
4585 setTransform(QTransform(), false);-
4586}
never executed: end of block
0
4587-
4588/*!-
4589 \fn void QGraphicsItem::rotate(qreal angle)-
4590 \obsolete-
4591-
4592 Use-
4593-
4594 \code-
4595 item->setTransform(QTransform().rotate(angle), true);-
4596 \endcode-
4597-
4598 instead.-
4599-
4600 Rotates the current item transformation \a angle degrees clockwise around-
4601 its origin. To translate around an arbitrary point (x, y), you need to-
4602 combine translation and rotation with setTransform().-
4603-
4604 Example:-
4605-
4606 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 6-
4607-
4608 \sa setTransform(), transform(), scale(), shear(), translate()-
4609*/-
4610-
4611/*!-
4612 \fn void QGraphicsItem::scale(qreal sx, qreal sy)-
4613 \obsolete-
4614-
4615 Use-
4616-
4617 \code-
4618 setTransform(QTransform::fromScale(sx, sy), true);-
4619 \endcode-
4620-
4621 instead.-
4622-
4623 Scales the current item transformation by (\a sx, \a sy) around its-
4624 origin. To scale from an arbitrary point (x, y), you need to combine-
4625 translation and scaling with setTransform().-
4626-
4627 Example:-
4628-
4629 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 7-
4630-
4631 \sa setTransform(), transform()-
4632*/-
4633-
4634/*!-
4635 \fn void QGraphicsItem::shear(qreal sh, qreal sv)-
4636 \obsolete-
4637-
4638 Use-
4639-
4640 \code-
4641 setTransform(QTransform().shear(sh, sv), true);-
4642 \endcode-
4643-
4644 instead.-
4645-
4646 Shears the current item transformation by (\a sh, \a sv).-
4647-
4648 \sa setTransform(), transform()-
4649*/-
4650-
4651/*!-
4652 \fn void QGraphicsItem::translate(qreal dx, qreal dy)-
4653 \obsolete-
4654-
4655 Use setPos() or setTransformOriginPoint() instead. For identical-
4656 behavior, use-
4657-
4658 \code-
4659 setTransform(QTransform::fromTranslate(dx, dy), true);-
4660 \endcode-
4661-
4662 Translates the current item transformation by (\a dx, \a dy).-
4663-
4664 If all you want is to move an item, you should call moveBy() or-
4665 setPos() instead; this function changes the item's translation,-
4666 which is conceptually separate from its position.-
4667-
4668 \sa setTransform(), transform()-
4669*/-
4670-
4671/*!-
4672 This virtual function is called twice for all items by the-
4673 QGraphicsScene::advance() slot. In the first phase, all items are called-
4674 with \a phase == 0, indicating that items on the scene are about to-
4675 advance, and then all items are called with \a phase == 1. Reimplement-
4676 this function to update your item if you need simple scene-controlled-
4677 animation.-
4678-
4679 The default implementation does nothing.-
4680-
4681 This function is intended for animations. An alternative is to-
4682 multiple-inherit from QObject and QGraphicsItem and use the \l{The Animation-
4683 Framework}{Animation Framework}.-
4684-
4685 \sa QGraphicsScene::advance(), QTimeLine-
4686*/-
4687void QGraphicsItem::advance(int phase)-
4688{-
4689 Q_UNUSED(phase);-
4690}
never executed: end of block
0
4691-
4692/*!-
4693 Returns the Z-value of the item. The Z-value affects the stacking order of-
4694 sibling (neighboring) items.-
4695-
4696 The default Z-value is 0.-
4697-
4698 \sa setZValue(), {QGraphicsItem#Sorting}{Sorting}, stackBefore(), ItemStacksBehindParent-
4699*/-
4700qreal QGraphicsItem::zValue() const-
4701{-
4702 return d_ptr->z;
never executed: return d_ptr->z;
0
4703}-
4704-
4705/*!-
4706 Sets the Z-value of the item to \a z. The Z value decides the stacking-
4707 order of sibling (neighboring) items. A sibling item of high Z value will-
4708 always be drawn on top of another sibling item with a lower Z value.-
4709-
4710 If you restore the Z value, the item's insertion order will decide its-
4711 stacking order.-
4712-
4713 The Z-value does not affect the item's size in any way.-
4714-
4715 The default Z-value is 0.-
4716-
4717 \sa zValue(), {QGraphicsItem#Sorting}{Sorting}, stackBefore(), ItemStacksBehindParent-
4718*/-
4719void QGraphicsItem::setZValue(qreal z)-
4720{-
4721 const QVariant newZVariant(itemChange(ItemZValueChange, z));-
4722 qreal newZ = newZVariant.toReal();-
4723 if (newZ == d_ptr->z)
newZ == d_ptr->zDescription
TRUEnever evaluated
FALSEnever evaluated
0
4724 return;
never executed: return;
0
4725-
4726 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
4727 // Z Value has changed, we have to notify the index.-
4728 d_ptr->scene->d_func()->index->itemChange(this, ItemZValueChange, &newZ);-
4729 }
never executed: end of block
0
4730-
4731 d_ptr->z = newZ;-
4732 if (d_ptr->parent)
d_ptr->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
4733 d_ptr->parent->d_ptr->needSortChildren = 1;
never executed: d_ptr->parent->d_ptr->needSortChildren = 1;
0
4734 else if (d_ptr->scene)
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
4735 d_ptr->scene->d_func()->needSortTopLevelItems = 1;
never executed: d_ptr->scene->d_func()->needSortTopLevelItems = 1;
0
4736-
4737 if (d_ptr->scene)
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
4738 d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true);
never executed: d_ptr->scene->d_func()->markDirty(this, QRectF(), true);
0
4739-
4740 itemChange(ItemZValueHasChanged, newZVariant);-
4741-
4742 if (d_ptr->flags & ItemNegativeZStacksBehindParent)
d_ptr->flags &...ksBehindParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
4743 setFlag(QGraphicsItem::ItemStacksBehindParent, z < qreal(0.0));
never executed: setFlag(QGraphicsItem::ItemStacksBehindParent, z < qreal(0.0));
0
4744-
4745 if (d_ptr->isObject)
d_ptr->isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
4746 emit static_cast<QGraphicsObject *>(this)->zChanged();
never executed: static_cast<QGraphicsObject *>(this)->zChanged();
0
4747}
never executed: end of block
0
4748-
4749/*!-
4750 \internal-
4751-
4752 Ensures that the list of children is sorted by insertion order, and that-
4753 the siblingIndexes are packed (no gaps), and start at 0.-
4754-
4755 ### This function is almost identical to-
4756 QGraphicsScenePrivate::ensureSequentialTopLevelSiblingIndexes().-
4757*/-
4758void QGraphicsItemPrivate::ensureSequentialSiblingIndex()-
4759{-
4760 if (!sequentialOrdering) {
!sequentialOrderingDescription
TRUEnever evaluated
FALSEnever evaluated
0
4761 std::sort(children.begin(), children.end(), insertionOrder);-
4762 sequentialOrdering = 1;-
4763 needSortChildren = 1;-
4764 }
never executed: end of block
0
4765 if (holesInSiblingIndex) {
holesInSiblingIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
4766 holesInSiblingIndex = 0;-
4767 for (int i = 0; i < children.size(); ++i)
i < children.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
4768 children[i]->d_ptr->siblingIndex = i;
never executed: children[i]->d_ptr->siblingIndex = i;
0
4769 }
never executed: end of block
0
4770}
never executed: end of block
0
4771-
4772/*!-
4773 \internal-
4774*/-
4775inline void QGraphicsItemPrivate::sendScenePosChange()-
4776{-
4777 Q_Q(QGraphicsItem);-
4778 if (scene) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
4779 if (flags & QGraphicsItem::ItemSendsScenePositionChanges)
flags & QGraph...ositionChangesDescription
TRUEnever evaluated
FALSEnever evaluated
0
4780 q->itemChange(QGraphicsItem::ItemScenePositionHasChanged, q->scenePos());
never executed: q->itemChange(QGraphicsItem::ItemScenePositionHasChanged, q->scenePos());
0
4781 if (scenePosDescendants) {
scenePosDescendantsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4782 foreach (QGraphicsItem *item, scene->d_func()->scenePosItems) {-
4783 if (q->isAncestorOf(item))
q->isAncestorOf(item)Description
TRUEnever evaluated
FALSEnever evaluated
0
4784 item->itemChange(QGraphicsItem::ItemScenePositionHasChanged, item->scenePos());
never executed: item->itemChange(QGraphicsItem::ItemScenePositionHasChanged, item->scenePos());
0
4785 }
never executed: end of block
0
4786 }
never executed: end of block
0
4787 }
never executed: end of block
0
4788}
never executed: end of block
0
4789-
4790/*!-
4791 \since 4.6-
4792-
4793 Stacks this item before \a sibling, which must be a sibling item (i.e., the-
4794 two items must share the same parent item, or must both be toplevel items).-
4795 The \a sibling must have the same Z value as this item, otherwise calling-
4796 this function will have no effect.-
4797-
4798 By default, all sibling items are stacked by insertion order (i.e., the-
4799 first item you add is drawn before the next item you add). If two items' Z-
4800 values are different, then the item with the highest Z value is drawn on-
4801 top. When the Z values are the same, the insertion order will decide the-
4802 stacking order.-
4803-
4804 \sa setZValue(), ItemStacksBehindParent, {QGraphicsItem#Sorting}{Sorting}-
4805*/-
4806void QGraphicsItem::stackBefore(const QGraphicsItem *sibling)-
4807{-
4808 if (sibling == this)
sibling == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
4809 return;
never executed: return;
0
4810 if (!sibling || d_ptr->parent != sibling->parentItem()) {
!siblingDescription
TRUEnever evaluated
FALSEnever evaluated
d_ptr->parent ...->parentItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
4811 qWarning("QGraphicsItem::stackUnder: cannot stack under %p, which must be a sibling", sibling);-
4812 return;
never executed: return;
0
4813 }-
4814 QList<QGraphicsItem *> *siblings = d_ptr->parent
d_ptr->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
4815 ? &d_ptr->parent->d_ptr->children-
4816 : (d_ptr->scene ? &d_ptr->scene->d_func()->topLevelItems : 0);
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
4817 if (!siblings) {
!siblingsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4818 qWarning("QGraphicsItem::stackUnder: cannot stack under %p, which must be a sibling", sibling);-
4819 return;
never executed: return;
0
4820 }-
4821-
4822 // First, make sure that the sibling indexes have no holes. This also-
4823 // marks the children list for sorting.-
4824 if (d_ptr->parent)
d_ptr->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
4825 d_ptr->parent->d_ptr->ensureSequentialSiblingIndex();
never executed: d_ptr->parent->d_ptr->ensureSequentialSiblingIndex();
0
4826 else-
4827 d_ptr->scene->d_func()->ensureSequentialTopLevelSiblingIndexes();
never executed: d_ptr->scene->d_func()->ensureSequentialTopLevelSiblingIndexes();
0
4828-
4829 // Only move items with the same Z value, and that need moving.-
4830 int siblingIndex = sibling->d_ptr->siblingIndex;-
4831 int myIndex = d_ptr->siblingIndex;-
4832 if (myIndex >= siblingIndex) {
myIndex >= siblingIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
4833 siblings->move(myIndex, siblingIndex);-
4834 // Fixup the insertion ordering.-
4835 for (int i = 0; i < siblings->size(); ++i) {
i < siblings->size()Description
TRUEnever evaluated
FALSEnever evaluated
0
4836 int &index = siblings->at(i)->d_ptr->siblingIndex;-
4837 if (i != siblingIndex && index >= siblingIndex && index <= myIndex)
i != siblingIndexDescription
TRUEnever evaluated
FALSEnever evaluated
index >= siblingIndexDescription
TRUEnever evaluated
FALSEnever evaluated
index <= myIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
4838 ++index;
never executed: ++index;
0
4839 }
never executed: end of block
0
4840 d_ptr->siblingIndex = siblingIndex;-
4841 for (int i = 0; i < siblings->size(); ++i) {
i < siblings->size()Description
TRUEnever evaluated
FALSEnever evaluated
0
4842 int &index = siblings->at(i)->d_ptr->siblingIndex;-
4843 if (i != siblingIndex && index >= siblingIndex && index <= myIndex)
i != siblingIndexDescription
TRUEnever evaluated
FALSEnever evaluated
index >= siblingIndexDescription
TRUEnever evaluated
FALSEnever evaluated
index <= myIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
4844 siblings->at(i)->d_ptr->siblingOrderChange();
never executed: siblings->at(i)->d_ptr->siblingOrderChange();
0
4845 }
never executed: end of block
0
4846 d_ptr->siblingOrderChange();-
4847 }
never executed: end of block
0
4848}
never executed: end of block
0
4849-
4850/*!-
4851 Returns the bounding rect of this item's descendants (i.e., its-
4852 children, their children, etc.) in local coordinates. The-
4853 rectangle will contain all descendants after they have been mapped-
4854 to local coordinates. If the item has no children, this function-
4855 returns an empty QRectF.-
4856-
4857 This does not include this item's own bounding rect; it only returns-
4858 its descendants' accumulated bounding rect. If you need to include this-
4859 item's bounding rect, you can add boundingRect() to childrenBoundingRect()-
4860 using QRectF::operator|().-
4861-
4862 This function is linear in complexity; it determines the size of the-
4863 returned bounding rect by iterating through all descendants.-
4864-
4865 \sa boundingRect(), sceneBoundingRect()-
4866*/-
4867QRectF QGraphicsItem::childrenBoundingRect() const-
4868{-
4869 if (!d_ptr->dirtyChildrenBoundingRect)
!d_ptr->dirtyC...enBoundingRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
4870 return d_ptr->childrenBoundingRect;
never executed: return d_ptr->childrenBoundingRect;
0
4871-
4872 d_ptr->childrenBoundingRect = QRectF();-
4873 d_ptr->childrenBoundingRectHelper(0, &d_ptr->childrenBoundingRect, 0);-
4874 d_ptr->dirtyChildrenBoundingRect = 0;-
4875 return d_ptr->childrenBoundingRect;
never executed: return d_ptr->childrenBoundingRect;
0
4876}-
4877-
4878/*!-
4879 \fn virtual QRectF QGraphicsItem::boundingRect() const = 0-
4880-
4881 This pure virtual function defines the outer bounds of the item as-
4882 a rectangle; all painting must be restricted to inside an item's-
4883 bounding rect. QGraphicsView uses this to determine whether the-
4884 item requires redrawing.-
4885-
4886 Although the item's shape can be arbitrary, the bounding rect is-
4887 always rectangular, and it is unaffected by the items'-
4888 transformation.-
4889-
4890 If you want to change the item's bounding rectangle, you must first call-
4891 prepareGeometryChange(). This notifies the scene of the imminent change,-
4892 so that it can update its item geometry index; otherwise, the scene will-
4893 be unaware of the item's new geometry, and the results are undefined-
4894 (typically, rendering artifacts are left within the view).-
4895-
4896 Reimplement this function to let QGraphicsView determine what-
4897 parts of the widget, if any, need to be redrawn.-
4898-
4899 Note: For shapes that paint an outline / stroke, it is important-
4900 to include half the pen width in the bounding rect. It is not-
4901 necessary to compensate for antialiasing, though.-
4902-
4903 Example:-
4904-
4905 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 8-
4906-
4907 \sa boundingRegion(), shape(), contains(), {The Graphics View Coordinate-
4908 System}, prepareGeometryChange()-
4909*/-
4910-
4911/*!-
4912 Returns the bounding rect of this item in scene coordinates, by combining-
4913 sceneTransform() with boundingRect().-
4914-
4915 \sa boundingRect(), {The Graphics View Coordinate System}-
4916*/-
4917QRectF QGraphicsItem::sceneBoundingRect() const-
4918{-
4919 // Find translate-only offset-
4920 // COMBINE-
4921 QPointF offset;-
4922 const QGraphicsItem *parentItem = this;-
4923 const QGraphicsItemPrivate *itemd;-
4924 do {-
4925 itemd = parentItem->d_ptr.data();-
4926 if (itemd->transformData)
itemd->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4927 break;
never executed: break;
0
4928 offset += itemd->pos;-
4929 } while ((parentItem = itemd->parent));
never executed: end of block
(parentItem = itemd->parent)Description
TRUEnever evaluated
FALSEnever evaluated
0
4930-
4931 QRectF br = boundingRect();-
4932 br.translate(offset);-
4933 if (!parentItem)
!parentItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
4934 return br;
never executed: return br;
0
4935 if (parentItem->d_ptr->hasTranslateOnlySceneTransform()) {
parentItem->d_...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
4936 br.translate(parentItem->d_ptr->sceneTransform.dx(), parentItem->d_ptr->sceneTransform.dy());-
4937 return br;
never executed: return br;
0
4938 }-
4939 return parentItem->d_ptr->sceneTransform.mapRect(br);
never executed: return parentItem->d_ptr->sceneTransform.mapRect(br);
0
4940}-
4941-
4942/*!-
4943 Returns the shape of this item as a QPainterPath in local-
4944 coordinates. The shape is used for many things, including collision-
4945 detection, hit tests, and for the QGraphicsScene::items() functions.-
4946-
4947 The default implementation calls boundingRect() to return a simple-
4948 rectangular shape, but subclasses can reimplement this function to return-
4949 a more accurate shape for non-rectangular items. For example, a round item-
4950 may choose to return an elliptic shape for better collision detection. For-
4951 example:-
4952-
4953 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 9-
4954-
4955 The outline of a shape can vary depending on the width and style of the-
4956 pen used when drawing. If you want to include this outline in the item's-
4957 shape, you can create a shape from the stroke using QPainterPathStroker.-
4958-
4959 This function is called by the default implementations of contains() and-
4960 collidesWithPath().-
4961-
4962 \sa boundingRect(), contains(), prepareGeometryChange(), QPainterPathStroker-
4963*/-
4964QPainterPath QGraphicsItem::shape() const-
4965{-
4966 QPainterPath path;-
4967 path.addRect(boundingRect());-
4968 return path;
never executed: return path;
0
4969}-
4970-
4971/*!-
4972 Returns \c true if this item is clipped. An item is clipped if it has either-
4973 set the \l ItemClipsToShape flag, or if it or any of its ancestors has set-
4974 the \l ItemClipsChildrenToShape flag.-
4975-
4976 Clipping affects the item's appearance (i.e., painting), as well as mouse-
4977 and hover event delivery.-
4978-
4979 \sa clipPath(), shape(), setFlags()-
4980*/-
4981bool QGraphicsItem::isClipped() const-
4982{-
4983 Q_D(const QGraphicsItem);-
4984 return (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)
never executed: return (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) || (d->flags & QGraphicsItem::ItemClipsToShape);
0
4985 || (d->flags & QGraphicsItem::ItemClipsToShape);
never executed: return (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) || (d->flags & QGraphicsItem::ItemClipsToShape);
0
4986}-
4987-
4988/*!-
4989 \since 4.5-
4990-
4991 Returns this item's clip path, or an empty QPainterPath if this item is-
4992 not clipped. The clip path constrains the item's appearance and-
4993 interaction (i.e., restricts the area the item can draw within and receive-
4994 events for).-
4995-
4996 You can enable clipping by setting the ItemClipsToShape or-
4997 ItemClipsChildrenToShape flags. The item's clip path is calculated by-
4998 intersecting all clipping ancestors' shapes. If the item sets-
4999 ItemClipsToShape, the final clip is intersected with the item's own shape.-
5000-
5001 \note Clipping introduces a performance penalty for all items involved;-
5002 you should generally avoid using clipping if you can (e.g., if your items-
5003 always draw inside boundingRect() or shape() boundaries, clipping is not-
5004 necessary).-
5005-
5006 \sa isClipped(), shape(), setFlags()-
5007*/-
5008QPainterPath QGraphicsItem::clipPath() const-
5009{-
5010 Q_D(const QGraphicsItem);-
5011 if (!isClipped())
!isClipped()Description
TRUEnever evaluated
FALSEnever evaluated
0
5012 return QPainterPath();
never executed: return QPainterPath();
0
5013-
5014 const QRectF thisBoundingRect(boundingRect());-
5015 if (thisBoundingRect.isEmpty())
thisBoundingRect.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
5016 return QPainterPath();
never executed: return QPainterPath();
0
5017-
5018 QPainterPath clip;-
5019 // Start with the item's bounding rect.-
5020 clip.addRect(thisBoundingRect);-
5021-
5022 if (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) {
d->ancestorFla...rClipsChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
5023 const QGraphicsItem *parent = this;-
5024 const QGraphicsItem *lastParent = this;-
5025-
5026 // Intersect any in-between clips starting at the top and moving downwards.-
5027 while ((parent = parent->d_ptr->parent)) {
(parent = pare...d_ptr->parent)Description
TRUEnever evaluated
FALSEnever evaluated
0
5028 if (parent->d_ptr->flags & ItemClipsChildrenToShape) {
parent->d_ptr-...hildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
5029 // Map clip to the current parent and intersect with its shape/clipPath-
5030 clip = lastParent->itemTransform(parent).map(clip);-
5031 clip = clip.intersected(parent->shape());-
5032 if (clip.isEmpty())
clip.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
5033 return clip;
never executed: return clip;
0
5034 lastParent = parent;-
5035 }
never executed: end of block
0
5036-
5037 if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren))
!(parent->d_pt...ClipsChildren)Description
TRUEnever evaluated
FALSEnever evaluated
0
5038 break;
never executed: break;
0
5039 }
never executed: end of block
0
5040-
5041 if (lastParent != this) {
lastParent != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
5042 // Map clip back to the item's transform.-
5043 // ### what if itemtransform fails-
5044 clip = lastParent->itemTransform(this).map(clip);-
5045 }
never executed: end of block
0
5046 }
never executed: end of block
0
5047-
5048 if (d->flags & ItemClipsToShape)
d->flags & ItemClipsToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
5049 clip = clip.intersected(shape());
never executed: clip = clip.intersected(shape());
0
5050-
5051 return clip;
never executed: return clip;
0
5052}-
5053-
5054/*!-
5055 Returns \c true if this item contains \a point, which is in local-
5056 coordinates; otherwise, false is returned. It is most often called from-
5057 QGraphicsView to determine what item is under the cursor, and for that-
5058 reason, the implementation of this function should be as light-weight as-
5059 possible.-
5060-
5061 By default, this function calls shape(), but you can reimplement it in a-
5062 subclass to provide a (perhaps more efficient) implementation.-
5063-
5064 \sa shape(), boundingRect(), collidesWithPath()-
5065*/-
5066bool QGraphicsItem::contains(const QPointF &point) const-
5067{-
5068 return isClipped() ? clipPath().contains(point) : shape().contains(point);
never executed: return isClipped() ? clipPath().contains(point) : shape().contains(point);
0
5069}-
5070-
5071/*!-
5072-
5073 Returns \c true if this item collides with \a other; otherwise-
5074 returns \c false.-
5075-
5076 The \a mode is applied to \a other, and the resulting shape or-
5077 bounding rectangle is then compared to this item's shape. The-
5078 default value for \a mode is Qt::IntersectsItemShape; \a other-
5079 collides with this item if it either intersects, contains, or is-
5080 contained by this item's shape (see Qt::ItemSelectionMode for-
5081 details).-
5082-
5083 The default implementation is based on shape intersection, and it calls-
5084 shape() on both items. Because the complexity of arbitrary shape-shape-
5085 intersection grows with an order of magnitude when the shapes are complex,-
5086 this operation can be noticably time consuming. You have the option of-
5087 reimplementing this function in a subclass of QGraphicsItem to provide a-
5088 custom algorithm. This allows you to make use of natural constraints in-
5089 the shapes of your own items, in order to improve the performance of the-
5090 collision detection. For instance, two untransformed perfectly circular-
5091 items' collision can be determined very efficiently by comparing their-
5092 positions and radii.-
5093-
5094 Keep in mind that when reimplementing this function and calling shape() or-
5095 boundingRect() on \a other, the returned coordinates must be mapped to-
5096 this item's coordinate system before any intersection can take place.-
5097-
5098 \sa contains(), shape()-
5099*/-
5100bool QGraphicsItem::collidesWithItem(const QGraphicsItem *other, Qt::ItemSelectionMode mode) const-
5101{-
5102 if (other == this)
other == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
5103 return true;
never executed: return true;
0
5104 if (!other)
!otherDescription
TRUEnever evaluated
FALSEnever evaluated
0
5105 return false;
never executed: return false;
0
5106 // The items share the same clip if their closest clipper is the same, or-
5107 // if one clips the other.-
5108 bool clips = (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren);-
5109 bool otherClips = (other->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren);-
5110 if (clips || otherClips) {
clipsDescription
TRUEnever evaluated
FALSEnever evaluated
otherClipsDescription
TRUEnever evaluated
FALSEnever evaluated
0
5111 const QGraphicsItem *closestClipper = isAncestorOf(other) ? this : parentItem();
isAncestorOf(other)Description
TRUEnever evaluated
FALSEnever evaluated
0
5112 while (closestClipper && !(closestClipper->flags() & ItemClipsChildrenToShape))
closestClipperDescription
TRUEnever evaluated
FALSEnever evaluated
!(closestClipp...ildrenToShape)Description
TRUEnever evaluated
FALSEnever evaluated
0
5113 closestClipper = closestClipper->parentItem();
never executed: closestClipper = closestClipper->parentItem();
0
5114 const QGraphicsItem *otherClosestClipper = other->isAncestorOf(this) ? other : other->parentItem();
other->isAncestorOf(this)Description
TRUEnever evaluated
FALSEnever evaluated
0
5115 while (otherClosestClipper && !(otherClosestClipper->flags() & ItemClipsChildrenToShape))
otherClosestClipperDescription
TRUEnever evaluated
FALSEnever evaluated
!(otherClosest...ildrenToShape)Description
TRUEnever evaluated
FALSEnever evaluated
0
5116 otherClosestClipper = otherClosestClipper->parentItem();
never executed: otherClosestClipper = otherClosestClipper->parentItem();
0
5117 if (closestClipper == otherClosestClipper) {
closestClipper...ClosestClipperDescription
TRUEnever evaluated
FALSEnever evaluated
0
5118 d_ptr->localCollisionHack = 1;-
5119 bool res = collidesWithPath(mapFromItem(other, other->shape()), mode);-
5120 d_ptr->localCollisionHack = 0;-
5121 return res;
never executed: return res;
0
5122 }-
5123 }
never executed: end of block
0
5124-
5125 QPainterPath otherShape = other->isClipped() ? other->clipPath() : other->shape();
other->isClipped()Description
TRUEnever evaluated
FALSEnever evaluated
0
5126 return collidesWithPath(mapFromItem(other, otherShape), mode);
never executed: return collidesWithPath(mapFromItem(other, otherShape), mode);
0
5127}-
5128-
5129/*!-
5130 Returns \c true if this item collides with \a path.-
5131-
5132 The collision is determined by \a mode. The default value for \a mode is-
5133 Qt::IntersectsItemShape; \a path collides with this item if it either-
5134 intersects, contains, or is contained by this item's shape.-
5135-
5136 Note that this function checks whether the item's shape or-
5137 bounding rectangle (depending on \a mode) is contained within \a-
5138 path, and not whether \a path is contained within the items shape-
5139 or bounding rectangle.-
5140-
5141 \sa collidesWithItem(), contains(), shape()-
5142*/-
5143bool QGraphicsItem::collidesWithPath(const QPainterPath &path, Qt::ItemSelectionMode mode) const-
5144{-
5145 if (path.isEmpty()) {
path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
5146 // No collision with empty paths.-
5147 return false;
never executed: return false;
0
5148 }-
5149-
5150 QRectF rectA(boundingRect());-
5151 _q_adjustRect(&rectA);-
5152 QRectF rectB(path.controlPointRect());-
5153 _q_adjustRect(&rectB);-
5154 if (!rectA.intersects(rectB)) {
!rectA.intersects(rectB)Description
TRUEnever evaluated
FALSEnever evaluated
0
5155 // This we can determine efficiently. If the two rects neither-
5156 // intersect nor contain eachother, then the two items do not collide.-
5157 return false;
never executed: return false;
0
5158 }-
5159-
5160 // For further testing, we need this item's shape or bounding rect.-
5161 QPainterPath thisShape;-
5162 if (mode == Qt::IntersectsItemShape || mode == Qt::ContainsItemShape)
mode == Qt::In...sectsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::ContainsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
5163 thisShape = (isClipped() && !d_ptr->localCollisionHack) ? clipPath() : shape();
never executed: thisShape = (isClipped() && !d_ptr->localCollisionHack) ? clipPath() : shape();
isClipped()Description
TRUEnever evaluated
FALSEnever evaluated
!d_ptr->localCollisionHackDescription
TRUEnever evaluated
FALSEnever evaluated
0
5164 else-
5165 thisShape.addRect(rectA);
never executed: thisShape.addRect(rectA);
0
5166-
5167 if (thisShape == QPainterPath()) {
thisShape == QPainterPath()Description
TRUEnever evaluated
FALSEnever evaluated
0
5168 // Empty shape? No collision.-
5169 return false;
never executed: return false;
0
5170 }-
5171-
5172 // Use QPainterPath boolean operations to determine the collision, O(N*logN).-
5173 if (mode == Qt::IntersectsItemShape || mode == Qt::IntersectsItemBoundingRect)
mode == Qt::In...sectsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::In...emBoundingRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
5174 return path.intersects(thisShape);
never executed: return path.intersects(thisShape);
0
5175 return path.contains(thisShape);
never executed: return path.contains(thisShape);
0
5176}-
5177-
5178/*!-
5179 Returns a list of all items that collide with this item.-
5180-
5181 The way collisions are detected is determined by applying \a mode-
5182 to items that are compared to this item, i.e., each item's shape-
5183 or bounding rectangle is checked against this item's shape. The-
5184 default value for \a mode is Qt::IntersectsItemShape.-
5185-
5186 \sa collidesWithItem()-
5187*/-
5188QList<QGraphicsItem *> QGraphicsItem::collidingItems(Qt::ItemSelectionMode mode) const-
5189{-
5190 if (d_ptr->scene)
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
5191 return d_ptr->scene->collidingItems(this, mode);
never executed: return d_ptr->scene->collidingItems(this, mode);
0
5192 return QList<QGraphicsItem *>();
never executed: return QList<QGraphicsItem *>();
0
5193}-
5194-
5195/*!-
5196 \internal-
5197-
5198 Item obscurity helper function.-
5199-
5200 Returns \c true if the subrect \a rect of \a item's bounding rect is obscured-
5201 by \a other (i.e., \a other's opaque area covers \a item's \a rect-
5202 completely. \a other is assumed to already be "on top of" \a item-
5203 wrt. stacking order.-
5204*/-
5205static bool qt_QGraphicsItem_isObscured(const QGraphicsItem *item,-
5206 const QGraphicsItem *other,-
5207 const QRectF &rect)-
5208{-
5209 return other->mapToItem(item, other->opaqueArea()).contains(rect);
never executed: return other->mapToItem(item, other->opaqueArea()).contains(rect);
0
5210}-
5211-
5212/*!-
5213 \overload-
5214 \since 4.3-
5215-
5216 Returns \c true if \a rect is completely obscured by the opaque shape of any-
5217 of colliding items above it (i.e., with a higher Z value than this item).-
5218-
5219 \sa opaqueArea()-
5220*/-
5221bool QGraphicsItem::isObscured(const QRectF &rect) const-
5222{-
5223 Q_D(const QGraphicsItem);-
5224 if (!d->scene)
!d->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
5225 return false;
never executed: return false;
0
5226-
5227 QRectF br = boundingRect();-
5228 QRectF testRect = rect.isNull() ? br : rect;
rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
5229-
5230 const auto items = d->scene->items(mapToScene(br), Qt::IntersectsItemBoundingRect);-
5231 for (QGraphicsItem *item : items) {-
5232 if (item == this)
item == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
5233 break;
never executed: break;
0
5234 if (qt_QGraphicsItem_isObscured(this, item, testRect))
qt_QGraphicsIt...tem, testRect)Description
TRUEnever evaluated
FALSEnever evaluated
0
5235 return true;
never executed: return true;
0
5236 }
never executed: end of block
0
5237 return false;
never executed: return false;
0
5238}-
5239-
5240/*!-
5241 \fn bool QGraphicsItem::isObscured(qreal x, qreal y, qreal w, qreal h) const-
5242 \overload-
5243 \since 4.3-
5244-
5245 This convenience function is equivalent to calling isObscured(QRectF(\a x, \a y, \a w, \a h)).-
5246*/-
5247-
5248/*!-
5249 Returns \c true if this item's bounding rect is completely obscured by the-
5250 opaque shape of \a item.-
5251-
5252 The base implementation maps \a item's opaqueArea() to this item's-
5253 coordinate system, and then checks if this item's boundingRect() is fully-
5254 contained within the mapped shape.-
5255-
5256 You can reimplement this function to provide a custom algorithm for-
5257 determining whether this item is obscured by \a item.-
5258-
5259 \sa opaqueArea(), isObscured()-
5260*/-
5261bool QGraphicsItem::isObscuredBy(const QGraphicsItem *item) const-
5262{-
5263 if (!item)
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
5264 return false;
never executed: return false;
0
5265 return qt_closestItemFirst(item, this)
never executed: return qt_closestItemFirst(item, this) && qt_QGraphicsItem_isObscured(this, item, boundingRect());
0
5266 && qt_QGraphicsItem_isObscured(this, item, boundingRect());
never executed: return qt_closestItemFirst(item, this) && qt_QGraphicsItem_isObscured(this, item, boundingRect());
0
5267}-
5268-
5269/*!-
5270 This virtual function returns a shape representing the area where this-
5271 item is opaque. An area is opaque if it is filled using an opaque brush or-
5272 color (i.e., not transparent).-
5273-
5274 This function is used by isObscuredBy(), which is called by underlying-
5275 items to determine if they are obscured by this item.-
5276-
5277 The default implementation returns an empty QPainterPath, indicating that-
5278 this item is completely transparent and does not obscure any other items.-
5279-
5280 \sa isObscuredBy(), isObscured(), shape()-
5281*/-
5282QPainterPath QGraphicsItem::opaqueArea() const-
5283{-
5284 return QPainterPath();
never executed: return QPainterPath();
0
5285}-
5286-
5287/*!-
5288 \since 4.4-
5289-
5290 Returns the bounding region for this item. The coordinate space of the-
5291 returned region depends on \a itemToDeviceTransform. If you pass an-
5292 identity QTransform as a parameter, this function will return a local-
5293 coordinate region.-
5294-
5295 The bounding region describes a coarse outline of the item's visual-
5296 contents. Although it's expensive to calculate, it's also more precise-
5297 than boundingRect(), and it can help to avoid unnecessary repainting when-
5298 an item is updated. This is particularly efficient for thin items (e.g.,-
5299 lines or simple polygons). You can tune the granularity for the bounding-
5300 region by calling setBoundingRegionGranularity(). The default granularity-
5301 is 0; in which the item's bounding region is the same as its bounding-
5302 rect.-
5303-
5304 \a itemToDeviceTransform is the transformation from item coordinates to-
5305 device coordinates. If you want this function to return a QRegion in scene-
5306 coordinates, you can pass sceneTransform() as an argument.-
5307-
5308 \sa boundingRegionGranularity()-
5309*/-
5310QRegion QGraphicsItem::boundingRegion(const QTransform &itemToDeviceTransform) const-
5311{-
5312 // ### Ideally we would have a better way to generate this region,-
5313 // preferably something in the lines of QPainterPath::toRegion(QTransform)-
5314 // coupled with a way to generate a painter path from a set of painter-
5315 // operations (e.g., QPicture::toPainterPath() or so). The current-
5316 // approach generates a bitmap with the size of the item's bounding rect-
5317 // in device coordinates, scaled by b.r.granularity, then paints the item-
5318 // into the bitmap, converts the result to a QRegion and scales the region-
5319 // back to device space with inverse granularity.-
5320 qreal granularity = boundingRegionGranularity();-
5321 QRect deviceRect = itemToDeviceTransform.mapRect(boundingRect()).toRect();-
5322 _q_adjustRect(&deviceRect);-
5323 if (granularity == 0.0)
granularity == 0.0Description
TRUEnever evaluated
FALSEnever evaluated
0
5324 return QRegion(deviceRect);
never executed: return QRegion(deviceRect);
0
5325-
5326 int pad = 1;-
5327 QSize bitmapSize(qMax(1, int(deviceRect.width() * granularity) + pad * 2),-
5328 qMax(1, int(deviceRect.height() * granularity) + pad * 2));-
5329 QImage mask(bitmapSize, QImage::Format_ARGB32_Premultiplied);-
5330 mask.fill(0);-
5331 QPainter p(&mask);-
5332 p.setRenderHints(QPainter::Antialiasing);-
5333-
5334 // Transform painter (### this code is from QGraphicsScene::drawItemHelper-
5335 // and doesn't work properly with perspective transformations).-
5336 QPointF viewOrigo = itemToDeviceTransform.map(QPointF(0, 0));-
5337 QPointF offset = viewOrigo - deviceRect.topLeft();-
5338 p.scale(granularity, granularity);-
5339 p.translate(offset);-
5340 p.translate(pad, pad);-
5341 p.setWorldTransform(itemToDeviceTransform, true);-
5342 p.translate(itemToDeviceTransform.inverted().map(QPointF(0, 0)));-
5343-
5344 // Render-
5345 QStyleOptionGraphicsItem option;-
5346 const_cast<QGraphicsItem *>(this)->paint(&p, &option, 0);-
5347 p.end();-
5348-
5349 // Transform QRegion back to device space-
5350 QTransform unscale = QTransform::fromScale(1 / granularity, 1 / granularity);-
5351 QRegion r;-
5352 QBitmap colorMask = QBitmap::fromImage(mask.createMaskFromColor(0));-
5353 const auto rects = QRegion(colorMask).rects();-
5354 for (const QRect &rect : rects) {-
5355 QRect xrect = unscale.mapRect(rect).translated(deviceRect.topLeft() - QPoint(pad, pad));-
5356 r += xrect.adjusted(-1, -1, 1, 1) & deviceRect;-
5357 }
never executed: end of block
0
5358 return r;
never executed: return r;
0
5359}-
5360-
5361/*!-
5362 \since 4.4-
5363-
5364 Returns the item's bounding region granularity; a value between and-
5365 including 0 and 1. The default value is 0 (i.e., the lowest granularity,-
5366 where the bounding region corresponds to the item's bounding rectangle).-
5367-
5368\omit-
5369### NOTE-
5370\endomit-
5371-
5372 \sa setBoundingRegionGranularity()-
5373*/-
5374qreal QGraphicsItem::boundingRegionGranularity() const-
5375{-
5376 return d_ptr->hasBoundingRegionGranularity
never executed: return d_ptr->hasBoundingRegionGranularity ? qvariant_cast<qreal>(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity)) : 0;
0
5377 ? qvariant_cast<qreal>(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity))
never executed: return d_ptr->hasBoundingRegionGranularity ? qvariant_cast<qreal>(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity)) : 0;
0
5378 : 0;
never executed: return d_ptr->hasBoundingRegionGranularity ? qvariant_cast<qreal>(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity)) : 0;
0
5379}-
5380-
5381/*!-
5382 \since 4.4-
5383 Sets the bounding region granularity to \a granularity; a value between-
5384 and including 0 and 1. The default value is 0 (i.e., the lowest-
5385 granularity, where the bounding region corresponds to the item's bounding-
5386 rectangle).-
5387-
5388 The granularity is used by boundingRegion() to calculate how fine the-
5389 bounding region of the item should be. The highest achievable granularity-
5390 is 1, where boundingRegion() will return the finest outline possible for-
5391 the respective device (e.g., for a QGraphicsView viewport, this gives you-
5392 a pixel-perfect bounding region). The lowest possible granularity is-
5393 0. The value of \a granularity describes the ratio between device-
5394 resolution and the resolution of the bounding region (e.g., a value of-
5395 0.25 will provide a region where each chunk corresponds to 4x4 device-
5396 units / pixels).-
5397-
5398 \sa boundingRegionGranularity()-
5399*/-
5400void QGraphicsItem::setBoundingRegionGranularity(qreal granularity)-
5401{-
5402 if (granularity < 0.0 || granularity > 1.0) {
granularity < 0.0Description
TRUEnever evaluated
FALSEnever evaluated
granularity > 1.0Description
TRUEnever evaluated
FALSEnever evaluated
0
5403 qWarning("QGraphicsItem::setBoundingRegionGranularity: invalid granularity %g", granularity);-
5404 return;
never executed: return;
0
5405 }-
5406 if (granularity == 0.0) {
granularity == 0.0Description
TRUEnever evaluated
FALSEnever evaluated
0
5407 d_ptr->unsetExtra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity);-
5408 d_ptr->hasBoundingRegionGranularity = 0;-
5409 return;
never executed: return;
0
5410 }-
5411 d_ptr->hasBoundingRegionGranularity = 1;-
5412 d_ptr->setExtra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity,-
5413 QVariant::fromValue<qreal>(granularity));-
5414}
never executed: end of block
0
5415-
5416/*!-
5417 \fn virtual void QGraphicsItem::paint(QPainter *painter, const-
5418 QStyleOptionGraphicsItem *option, QWidget *widget = 0) = 0-
5419-
5420 This function, which is usually called by QGraphicsView, paints the-
5421 contents of an item in local coordinates.-
5422-
5423 Reimplement this function in a QGraphicsItem subclass to provide the-
5424 item's painting implementation, using \a painter. The \a option parameter-
5425 provides style options for the item, such as its state, exposed area and-
5426 its level-of-detail hints. The \a widget argument is optional. If-
5427 provided, it points to the widget that is being painted on; otherwise, it-
5428 is 0. For cached painting, \a widget is always 0.-
5429-
5430 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 10-
5431-
5432 The painter's pen is 0-width by default, and its pen is initialized to the-
5433 QPalette::Text brush from the paint device's palette. The brush is-
5434 initialized to QPalette::Window.-
5435-
5436 Make sure to constrain all painting inside the boundaries of-
5437 boundingRect() to avoid rendering artifacts (as QGraphicsView does not-
5438 clip the painter for you). In particular, when QPainter renders the-
5439 outline of a shape using an assigned QPen, half of the outline will be-
5440 drawn outside, and half inside, the shape you're rendering (e.g., with a-
5441 pen width of 2 units, you must draw outlines 1 unit inside-
5442 boundingRect()). QGraphicsItem does not support use of cosmetic pens with-
5443 a non-zero width.-
5444-
5445 All painting is done in local coordinates.-
5446-
5447 \note It is mandatory that an item will always redraw itself in the exact-
5448 same way, unless update() was called; otherwise visual artifacts may-
5449 occur. In other words, two subsequent calls to paint() must always produce-
5450 the same output, unless update() was called between them.-
5451-
5452 \note Enabling caching for an item does not guarantee that paint()-
5453 will be invoked only once by the Graphics View framework,-
5454 even without any explicit call to update(). See the documentation of-
5455 setCacheMode() for more details.-
5456-
5457 \sa setCacheMode(), QPen::width(), {Item Coordinates}, ItemUsesExtendedStyleOption-
5458*/-
5459-
5460/*!-
5461 \internal-
5462 Returns \c true if we can discard an update request; otherwise false.-
5463*/-
5464bool QGraphicsItemPrivate::discardUpdateRequest(bool ignoreVisibleBit, bool ignoreDirtyBit,-
5465 bool ignoreOpacity) const-
5466{-
5467 // No scene, or if the scene is updating everything, means we have nothing-
5468 // to do. The only exception is if the scene tracks the growing scene rect.-
5469 return !scene
never executed: return !scene || (!visible && !ignoreVisibleBit && !this->ignoreVisible) || (!ignoreDirtyBit && fullUpdatePending) || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent());
0
5470 || (!visible && !ignoreVisibleBit && !this->ignoreVisible)
never executed: return !scene || (!visible && !ignoreVisibleBit && !this->ignoreVisible) || (!ignoreDirtyBit && fullUpdatePending) || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent());
0
5471 || (!ignoreDirtyBit && fullUpdatePending)
never executed: return !scene || (!visible && !ignoreVisibleBit && !this->ignoreVisible) || (!ignoreDirtyBit && fullUpdatePending) || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent());
0
5472 || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent());
never executed: return !scene || (!visible && !ignoreVisibleBit && !this->ignoreVisible) || (!ignoreDirtyBit && fullUpdatePending) || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent());
0
5473}-
5474-
5475/*!-
5476 \internal-
5477*/-
5478int QGraphicsItemPrivate::depth() const-
5479{-
5480 if (itemDepth == -1)
itemDepth == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
5481 const_cast<QGraphicsItemPrivate *>(this)->resolveDepth();
never executed: const_cast<QGraphicsItemPrivate *>(this)->resolveDepth();
0
5482-
5483 return itemDepth;
never executed: return itemDepth;
0
5484}-
5485-
5486/*!-
5487 \internal-
5488*/-
5489#ifndef QT_NO_GRAPHICSEFFECT-
5490void QGraphicsItemPrivate::invalidateParentGraphicsEffectsRecursively()-
5491{-
5492 QGraphicsItemPrivate *itemPrivate = this;-
5493 do {-
5494 if (itemPrivate->graphicsEffect) {
itemPrivate->graphicsEffectDescription
TRUEnever evaluated
FALSEnever evaluated
0
5495 itemPrivate->notifyInvalidated = 1;-
5496-
5497 if (!itemPrivate->updateDueToGraphicsEffect)
!itemPrivate->...GraphicsEffectDescription
TRUEnever evaluated
FALSEnever evaluated
0
5498 static_cast<QGraphicsItemEffectSourcePrivate *>(itemPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache();
never executed: static_cast<QGraphicsItemEffectSourcePrivate *>(itemPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache();
0
5499 }
never executed: end of block
0
5500 } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : 0));
never executed: end of block
(itemPrivate =...tr.data() : 0)Description
TRUEnever evaluated
FALSEnever evaluated
itemPrivate->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
5501}
never executed: end of block
0
5502-
5503void QGraphicsItemPrivate::invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::InvalidateReason reason)-
5504{-
5505 if (!mayHaveChildWithGraphicsEffect)
!mayHaveChildW...GraphicsEffectDescription
TRUEnever evaluated
FALSEnever evaluated
0
5506 return;
never executed: return;
0
5507-
5508 for (int i = 0; i < children.size(); ++i) {
i < children.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
5509 QGraphicsItemPrivate *childPrivate = children.at(i)->d_ptr.data();-
5510 if (reason == OpacityChanged && (childPrivate->flags & QGraphicsItem::ItemIgnoresParentOpacity))
reason == OpacityChangedDescription
TRUEnever evaluated
FALSEnever evaluated
(childPrivate-...ParentOpacity)Description
TRUEnever evaluated
FALSEnever evaluated
0
5511 continue;
never executed: continue;
0
5512 if (childPrivate->graphicsEffect) {
childPrivate->graphicsEffectDescription
TRUEnever evaluated
FALSEnever evaluated
0
5513 childPrivate->notifyInvalidated = 1;-
5514 static_cast<QGraphicsItemEffectSourcePrivate *>(childPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache();-
5515 }
never executed: end of block
0
5516-
5517 childPrivate->invalidateChildGraphicsEffectsRecursively(reason);-
5518 }
never executed: end of block
0
5519}
never executed: end of block
0
5520#endif //QT_NO_GRAPHICSEFFECT-
5521-
5522/*!-
5523 \internal-
5524*/-
5525void QGraphicsItemPrivate::invalidateDepthRecursively()-
5526{-
5527 if (itemDepth == -1)
itemDepth == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
5528 return;
never executed: return;
0
5529-
5530 itemDepth = -1;-
5531 for (int i = 0; i < children.size(); ++i)
i < children.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
5532 children.at(i)->d_ptr->invalidateDepthRecursively();
never executed: children.at(i)->d_ptr->invalidateDepthRecursively();
0
5533}
never executed: end of block
0
5534-
5535/*!-
5536 \internal-
5537-
5538 Resolves the stacking depth of this object and all its ancestors.-
5539*/-
5540void QGraphicsItemPrivate::resolveDepth()-
5541{-
5542 if (!parent)
!parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
5543 itemDepth = 0;
never executed: itemDepth = 0;
0
5544 else {-
5545 if (parent->d_ptr->itemDepth == -1)
parent->d_ptr->itemDepth == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
5546 parent->d_ptr->resolveDepth();
never executed: parent->d_ptr->resolveDepth();
0
5547 itemDepth = parent->d_ptr->itemDepth + 1;-
5548 }
never executed: end of block
0
5549}-
5550-
5551/*!-
5552 \internal-
5553-
5554 ### This function is almost identical to-
5555 QGraphicsScenePrivate::registerTopLevelItem().-
5556*/-
5557void QGraphicsItemPrivate::addChild(QGraphicsItem *child)-
5558{-
5559 // Remove all holes from the sibling index list. Now the max index-
5560 // number is equal to the size of the children list.-
5561 ensureSequentialSiblingIndex();-
5562 needSortChildren = 1; // ### maybe 0-
5563 child->d_ptr->siblingIndex = children.size();-
5564 children.append(child);-
5565 if (isObject)
isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
5566 emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged();
never executed: static_cast<QGraphicsObject *>(q_ptr)->childrenChanged();
0
5567}
never executed: end of block
0
5568-
5569/*!-
5570 \internal-
5571-
5572 ### This function is almost identical to-
5573 QGraphicsScenePrivate::unregisterTopLevelItem().-
5574*/-
5575void QGraphicsItemPrivate::removeChild(QGraphicsItem *child)-
5576{-
5577 // When removing elements in the middle of the children list,-
5578 // there will be a "gap" in the list of sibling indexes (0,1,3,4).-
5579 if (!holesInSiblingIndex)
!holesInSiblingIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
5580 holesInSiblingIndex = child->d_ptr->siblingIndex != children.size() - 1;
never executed: holesInSiblingIndex = child->d_ptr->siblingIndex != children.size() - 1;
0
5581 if (sequentialOrdering && !holesInSiblingIndex)
sequentialOrderingDescription
TRUEnever evaluated
FALSEnever evaluated
!holesInSiblingIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
5582 children.removeAt(child->d_ptr->siblingIndex);
never executed: children.removeAt(child->d_ptr->siblingIndex);
0
5583 else-
5584 children.removeOne(child);
never executed: children.removeOne(child);
0
5585 // NB! Do not use children.removeAt(child->d_ptr->siblingIndex) because-
5586 // the child is not guaranteed to be at the index after the list is sorted.-
5587 // (see ensureSortedChildren()).-
5588 child->d_ptr->siblingIndex = -1;-
5589 if (isObject)
isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
5590 emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged();
never executed: static_cast<QGraphicsObject *>(q_ptr)->childrenChanged();
0
5591}
never executed: end of block
0
5592-
5593/*!-
5594 \internal-
5595*/-
5596QGraphicsItemCache *QGraphicsItemPrivate::maybeExtraItemCache() const-
5597{-
5598 return (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
never executed: return (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
0
5599}-
5600-
5601/*!-
5602 \internal-
5603*/-
5604QGraphicsItemCache *QGraphicsItemPrivate::extraItemCache() const-
5605{-
5606 QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));-
5607 if (!c) {
!cDescription
TRUEnever evaluated
FALSEnever evaluated
0
5608 QGraphicsItemPrivate *that = const_cast<QGraphicsItemPrivate *>(this);-
5609 c = new QGraphicsItemCache;-
5610 that->setExtra(ExtraCacheData, QVariant::fromValue<void *>(c));-
5611 }
never executed: end of block
0
5612 return c;
never executed: return c;
0
5613}-
5614-
5615/*!-
5616 \internal-
5617*/-
5618void QGraphicsItemPrivate::removeExtraItemCache()-
5619{-
5620 QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));-
5621 if (c) {
cDescription
TRUEnever evaluated
FALSEnever evaluated
0
5622 c->purge();-
5623 delete c;-
5624 }
never executed: end of block
0
5625 unsetExtra(ExtraCacheData);-
5626}
never executed: end of block
0
5627-
5628void QGraphicsItemPrivate::updatePaintedViewBoundingRects(bool updateChildren)-
5629{-
5630 if (!scene)
!sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
5631 return;
never executed: return;
0
5632-
5633 for (int i = 0; i < scene->d_func()->views.size(); ++i) {
i < scene->d_f...->views.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
5634 QGraphicsViewPrivate *viewPrivate = scene->d_func()->views.at(i)->d_func();-
5635 QRect rect = paintedViewBoundingRects.value(viewPrivate->viewport);-
5636 rect.translate(viewPrivate->dirtyScrollOffset);-
5637 viewPrivate->updateRect(rect);-
5638 }
never executed: end of block
0
5639-
5640 if (updateChildren) {
updateChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
5641 for (int i = 0; i < children.size(); ++i)
i < children.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
5642 children.at(i)->d_ptr->updatePaintedViewBoundingRects(true);
never executed: children.at(i)->d_ptr->updatePaintedViewBoundingRects(true);
0
5643 }
never executed: end of block
0
5644}
never executed: end of block
0
5645-
5646// Traverses all the ancestors up to the top-level and updates the pointer to-
5647// always point to the top-most item that has a dirty scene transform.-
5648// It then backtracks to the top-most dirty item and start calculating the-
5649// scene transform by combining the item's transform (+pos) with the parent's-
5650// cached scene transform (which we at this point know for sure is valid).-
5651void QGraphicsItemPrivate::ensureSceneTransformRecursive(QGraphicsItem **topMostDirtyItem)-
5652{-
5653 Q_ASSERT(topMostDirtyItem);-
5654-
5655 if (dirtySceneTransform)
dirtySceneTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
5656 *topMostDirtyItem = q_ptr;
never executed: *topMostDirtyItem = q_ptr;
0
5657-
5658 if (parent)
parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
5659 parent->d_ptr->ensureSceneTransformRecursive(topMostDirtyItem);
never executed: parent->d_ptr->ensureSceneTransformRecursive(topMostDirtyItem);
0
5660-
5661 if (*topMostDirtyItem == q_ptr) {
*topMostDirtyItem == q_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
5662 if (!dirtySceneTransform)
!dirtySceneTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
5663 return; // OK, neither my ancestors nor I have dirty scene transforms.
never executed: return;
0
5664 *topMostDirtyItem = 0;-
5665 } else if (*topMostDirtyItem) {
never executed: end of block
*topMostDirtyItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
5666 return; // Continue backtrack.
never executed: return;
0
5667 }-
5668-
5669 // This item and all its descendants have dirty scene transforms.-
5670 // We're about to validate this item's scene transform, so we have to-
5671 // invalidate all the children; otherwise there's no way for the descendants-
5672 // to detect that the ancestor has changed.-
5673 invalidateChildrenSceneTransform();-
5674-
5675 // COMBINE my transform with the parent's scene transform.-
5676 updateSceneTransformFromParent();-
5677 Q_ASSERT(!dirtySceneTransform);-
5678}
never executed: end of block
0
5679-
5680/*!-
5681 \internal-
5682*/-
5683void QGraphicsItemPrivate::setSubFocus(QGraphicsItem *rootItem, QGraphicsItem *stopItem)-
5684{-
5685 // Update focus child chain. Stop at panels, or if this item-
5686 // is hidden, stop at the first item with a visible parent.-
5687 QGraphicsItem *parent = rootItem ? rootItem : q_ptr;
rootItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
5688 if (parent->panel() != q_ptr->panel())
parent->panel(...q_ptr->panel()Description
TRUEnever evaluated
FALSEnever evaluated
0
5689 return;
never executed: return;
0
5690-
5691 do {-
5692 // Clear any existing ancestor's subFocusItem.-
5693 if (parent != q_ptr && parent->d_ptr->subFocusItem) {
parent != q_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
parent->d_ptr->subFocusItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
5694 if (parent->d_ptr->subFocusItem == q_ptr)
parent->d_ptr-...sItem == q_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
5695 break;
never executed: break;
0
5696 parent->d_ptr->subFocusItem->d_ptr->clearSubFocus(0, stopItem);-
5697 }
never executed: end of block
0
5698 parent->d_ptr->subFocusItem = q_ptr;-
5699 parent->d_ptr->subFocusItemChange();-
5700 } while (!parent->isPanel() && (parent = parent->d_ptr->parent) && (visible || !parent->d_ptr->visible));
never executed: end of block
!parent->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
(parent = pare...d_ptr->parent)Description
TRUEnever evaluated
FALSEnever evaluated
visibleDescription
TRUEnever evaluated
FALSEnever evaluated
!parent->d_ptr->visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
5701-
5702 if (scene && !scene->isActive()) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
!scene->isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
5703 scene->d_func()->passiveFocusItem = subFocusItem;-
5704 scene->d_func()->lastFocusItem = subFocusItem;-
5705 }
never executed: end of block
0
5706}
never executed: end of block
0
5707-
5708/*!-
5709 \internal-
5710*/-
5711void QGraphicsItemPrivate::clearSubFocus(QGraphicsItem *rootItem, QGraphicsItem *stopItem)-
5712{-
5713 // Reset sub focus chain.-
5714 QGraphicsItem *parent = rootItem ? rootItem : q_ptr;
rootItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
5715 do {-
5716 if (parent->d_ptr->subFocusItem != q_ptr)
parent->d_ptr-...sItem != q_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
5717 break;
never executed: break;
0
5718 parent->d_ptr->subFocusItem = 0;-
5719 if (parent != stopItem && !parent->isAncestorOf(stopItem))
parent != stopItemDescription
TRUEnever evaluated
FALSEnever evaluated
!parent->isAnc...orOf(stopItem)Description
TRUEnever evaluated
FALSEnever evaluated
0
5720 parent->d_ptr->subFocusItemChange();
never executed: parent->d_ptr->subFocusItemChange();
0
5721 } while (!parent->isPanel() && (parent = parent->d_ptr->parent));
never executed: end of block
!parent->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
(parent = pare...d_ptr->parent)Description
TRUEnever evaluated
FALSEnever evaluated
0
5722}
never executed: end of block
0
5723-
5724/*!-
5725 \internal-
5726-
5727 Sets the focusProxy pointer to 0 for all items that have this item as their-
5728 focusProxy.-
5729*/-
5730void QGraphicsItemPrivate::resetFocusProxy()-
5731{-
5732 for (int i = 0; i < focusProxyRefs.size(); ++i)
i < focusProxyRefs.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
5733 *focusProxyRefs.at(i) = 0;
never executed: *focusProxyRefs.at(i) = 0;
0
5734 focusProxyRefs.clear();-
5735}
never executed: end of block
0
5736-
5737/*!-
5738 \internal-
5739-
5740 Subclasses can reimplement this function to be notified when subFocusItem-
5741 changes.-
5742*/-
5743void QGraphicsItemPrivate::subFocusItemChange()-
5744{-
5745}-
5746-
5747/*!-
5748 \internal-
5749-
5750 Subclasses can reimplement this function to be notified when an item-
5751 becomes a focusScopeItem (or is no longer a focusScopeItem).-
5752*/-
5753void QGraphicsItemPrivate::focusScopeItemChange(bool isSubFocusItem)-
5754{-
5755 Q_UNUSED(isSubFocusItem);-
5756}
never executed: end of block
0
5757-
5758/*!-
5759 \internal-
5760-
5761 Subclasses can reimplement this function to be notified when its-
5762 siblingIndex order is changed.-
5763*/-
5764void QGraphicsItemPrivate::siblingOrderChange()-
5765{-
5766}-
5767-
5768/*!-
5769 \internal-
5770-
5771 Tells us if it is a proxy widget-
5772*/-
5773bool QGraphicsItemPrivate::isProxyWidget() const-
5774{-
5775 return false;
never executed: return false;
0
5776}-
5777-
5778/*!-
5779 Schedules a redraw of the area covered by \a rect in this item. You can-
5780 call this function whenever your item needs to be redrawn, such as if it-
5781 changes appearance or size.-
5782-
5783 This function does not cause an immediate paint; instead it schedules a-
5784 paint request that is processed by QGraphicsView after control reaches the-
5785 event loop. The item will only be redrawn if it is visible in any-
5786 associated view.-
5787-
5788 As a side effect of the item being repainted, other items that overlap the-
5789 area \a rect may also be repainted.-
5790-
5791 If the item is invisible (i.e., isVisible() returns \c false), this function-
5792 does nothing.-
5793-
5794 \sa paint(), boundingRect()-
5795*/-
5796void QGraphicsItem::update(const QRectF &rect)-
5797{-
5798 if (rect.isEmpty() && !rect.isNull())
rect.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
!rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
5799 return;
never executed: return;
0
5800-
5801 // Make sure we notify effects about invalidated source.-
5802#ifndef QT_NO_GRAPHICSEFFECT-
5803 d_ptr->invalidateParentGraphicsEffectsRecursively();-
5804#endif //QT_NO_GRAPHICSEFFECT-
5805-
5806 if (CacheMode(d_ptr->cacheMode) != NoCache) {
CacheMode(d_pt...de) != NoCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
5807 // Invalidate cache.-
5808 QGraphicsItemCache *cache = d_ptr->extraItemCache();-
5809 if (!cache->allExposed) {
!cache->allExposedDescription
TRUEnever evaluated
FALSEnever evaluated
0
5810 if (rect.isNull()) {
rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
5811 cache->allExposed = true;-
5812 cache->exposed.clear();-
5813 } else {
never executed: end of block
0
5814 cache->exposed.append(rect);-
5815 }
never executed: end of block
0
5816 }-
5817 // Only invalidate cache; item is already dirty.-
5818 if (d_ptr->fullUpdatePending)
d_ptr->fullUpdatePendingDescription
TRUEnever evaluated
FALSEnever evaluated
0
5819 return;
never executed: return;
0
5820 }
never executed: end of block
0
5821-
5822 if (d_ptr->scene)
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
5823 d_ptr->scene->d_func()->markDirty(this, rect);
never executed: d_ptr->scene->d_func()->markDirty(this, rect);
0
5824}
never executed: end of block
0
5825-
5826/*!-
5827 \since 4.4-
5828 Scrolls the contents of \a rect by \a dx, \a dy. If \a rect is a null rect-
5829 (the default), the item's bounding rect is scrolled.-
5830-
5831 Scrolling provides a fast alternative to simply redrawing when the-
5832 contents of the item (or parts of the item) are shifted vertically or-
5833 horizontally. Depending on the current transformation and the capabilities-
5834 of the paint device (i.e., the viewport), this operation may consist of-
5835 simply moving pixels from one location to another using memmove(). In most-
5836 cases this is faster than rerendering the entire area.-
5837-
5838 After scrolling, the item will issue an update for the newly exposed-
5839 areas. If scrolling is not supported (e.g., you are rendering to an OpenGL-
5840 viewport, which does not benefit from scroll optimizations), this function-
5841 is equivalent to calling update(\a rect).-
5842-
5843 \b{Note:} Scrolling is only supported when QGraphicsItem::ItemCoordinateCache-
5844 is enabled; in all other cases calling this function is equivalent to calling-
5845 update(\a rect). If you for sure know that the item is opaque and not overlapped-
5846 by other items, you can map the \a rect to viewport coordinates and scroll the-
5847 viewport.-
5848-
5849 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 19-
5850-
5851 \sa boundingRect()-
5852*/-
5853void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect)-
5854{-
5855 Q_D(QGraphicsItem);-
5856 if (dx == 0.0 && dy == 0.0)
dx == 0.0Description
TRUEnever evaluated
FALSEnever evaluated
dy == 0.0Description
TRUEnever evaluated
FALSEnever evaluated
0
5857 return;
never executed: return;
0
5858 if (!d->scene)
!d->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
5859 return;
never executed: return;
0
5860-
5861 // Accelerated scrolling means moving pixels from one location to another-
5862 // and only redraw the newly exposed area. The following requirements must-
5863 // be fulfilled in order to do that:-
5864 //-
5865 // 1) Item is opaque.-
5866 // 2) Item is not overlapped by other items.-
5867 //-
5868 // There's (yet) no way to detect whether an item is opaque or not, which means-
5869 // we cannot do accelerated scrolling unless the cache is enabled. In case of using-
5870 // DeviceCoordinate cache we also have to take the device transform into account in-
5871 // order to determine whether we can do accelerated scrolling or not. That's left out-
5872 // for simplicity here, but it is definitely something we can consider in the future-
5873 // as a performance improvement.-
5874 if (d->cacheMode != QGraphicsItem::ItemCoordinateCache
d->cacheMode !...oordinateCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
5875 || !qFuzzyIsNull(dx - int(dx)) || !qFuzzyIsNull(dy - int(dy))) {
!qFuzzyIsNull(dx - int(dx))Description
TRUEnever evaluated
FALSEnever evaluated
!qFuzzyIsNull(dy - int(dy))Description
TRUEnever evaluated
FALSEnever evaluated
0
5876 update(rect);-
5877 return;
never executed: return;
0
5878 }-
5879-
5880 QGraphicsItemCache *cache = d->extraItemCache();-
5881 if (cache->allExposed || cache->fixedSize.isValid()) {
cache->allExposedDescription
TRUEnever evaluated
FALSEnever evaluated
cache->fixedSize.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
5882 // Cache is either invalidated or item is scaled (see QGraphicsItem::setCacheMode).-
5883 update(rect);-
5884 return;
never executed: return;
0
5885 }-
5886-
5887 // Find pixmap in cache.-
5888 QPixmap cachedPixmap;-
5889 if (!QPixmapCache::find(cache->key, &cachedPixmap)) {
!QPixmapCache:...&cachedPixmap)Description
TRUEnever evaluated
FALSEnever evaluated
0
5890 update(rect);-
5891 return;
never executed: return;
0
5892 }-
5893-
5894 QRect scrollRect = (rect.isNull() ? boundingRect() : rect).toAlignedRect();
rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
5895 if (!scrollRect.intersects(cache->boundingRect))
!scrollRect.in...>boundingRect)Description
TRUEnever evaluated
FALSEnever evaluated
0
5896 return; // Nothing to scroll.
never executed: return;
0
5897-
5898 // Remove from cache to avoid deep copy when modifying.-
5899 QPixmapCache::remove(cache->key);-
5900-
5901 QRegion exposed;-
5902 cachedPixmap.scroll(dx, dy, scrollRect.translated(-cache->boundingRect.topLeft()), &exposed);-
5903-
5904 // Reinsert into cache.-
5905 cache->key = QPixmapCache::insert(cachedPixmap);-
5906-
5907 // Translate the existing expose.-
5908 for (int i = 0; i < cache->exposed.size(); ++i) {
i < cache->exposed.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
5909 QRectF &e = cache->exposed[i];-
5910 if (!rect.isNull() && !e.intersects(rect))
!rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
!e.intersects(rect)Description
TRUEnever evaluated
FALSEnever evaluated
0
5911 continue;
never executed: continue;
0
5912 e.translate(dx, dy);-
5913 }
never executed: end of block
0
5914-
5915 // Append newly exposed areas. Note that the exposed region is currently-
5916 // in pixmap coordinates, so we have to translate it to item coordinates.-
5917 exposed.translate(cache->boundingRect.topLeft());-
5918 const QVector<QRect> exposedRects = exposed.rects();-
5919 for (int i = 0; i < exposedRects.size(); ++i)
i < exposedRects.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
5920 cache->exposed += exposedRects.at(i);
never executed: cache->exposed += exposedRects.at(i);
0
5921-
5922 // Trigger update. This will redraw the newly exposed area and make sure-
5923 // the pixmap is re-blitted in case there are overlapping items.-
5924 d->scene->d_func()->markDirty(this, rect);-
5925}
never executed: end of block
0
5926-
5927/*!-
5928 \fn void QGraphicsItem::update(qreal x, qreal y, qreal width, qreal height)-
5929 \overload-
5930-
5931 This convenience function is equivalent to calling update(QRectF(\a x, \a-
5932 y, \a width, \a height)).-
5933*/-
5934-
5935/*!-
5936 Maps the point \a point, which is in this item's coordinate system, to \a-
5937 item's coordinate system, and returns the mapped coordinate.-
5938-
5939 If \a item is 0, this function returns the same as mapToScene().-
5940-
5941 \sa itemTransform(), mapToParent(), mapToScene(), transform(), mapFromItem(), {The Graphics-
5942 View Coordinate System}-
5943*/-
5944QPointF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPointF &point) const-
5945{-
5946 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
5947 return itemTransform(item).map(point);
never executed: return itemTransform(item).map(point);
0
5948 return mapToScene(point);
never executed: return mapToScene(point);
0
5949}-
5950-
5951/*!-
5952 \fn QPointF QGraphicsItem::mapToItem(const QGraphicsItem *item, qreal x, qreal y) const-
5953 \overload-
5954-
5955 This convenience function is equivalent to calling mapToItem(\a item,-
5956 QPointF(\a x, \a y)).-
5957*/-
5958-
5959/*!-
5960 Maps the point \a point, which is in this item's coordinate system, to its-
5961 parent's coordinate system, and returns the mapped coordinate. If the item-
5962 has no parent, \a point will be mapped to the scene's coordinate system.-
5963-
5964 \sa mapToItem(), mapToScene(), transform(), mapFromParent(), {The Graphics-
5965 View Coordinate System}-
5966*/-
5967QPointF QGraphicsItem::mapToParent(const QPointF &point) const-
5968{-
5969 // COMBINE-
5970 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
5971 return point + d_ptr->pos;
never executed: return point + d_ptr->pos;
0
5972 return d_ptr->transformToParent().map(point);
never executed: return d_ptr->transformToParent().map(point);
0
5973}-
5974-
5975/*!-
5976 \fn QPointF QGraphicsItem::mapToParent(qreal x, qreal y) const-
5977 \overload-
5978-
5979 This convenience function is equivalent to calling mapToParent(QPointF(\a-
5980 x, \a y)).-
5981*/-
5982-
5983/*!-
5984 Maps the point \a point, which is in this item's coordinate system, to the-
5985 scene's coordinate system, and returns the mapped coordinate.-
5986-
5987 \sa mapToItem(), mapToParent(), transform(), mapFromScene(), {The Graphics-
5988 View Coordinate System}-
5989*/-
5990QPointF QGraphicsItem::mapToScene(const QPointF &point) const-
5991{-
5992 if (d_ptr->hasTranslateOnlySceneTransform())
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
5993 return QPointF(point.x() + d_ptr->sceneTransform.dx(), point.y() + d_ptr->sceneTransform.dy());
never executed: return QPointF(point.x() + d_ptr->sceneTransform.dx(), point.y() + d_ptr->sceneTransform.dy());
0
5994 return d_ptr->sceneTransform.map(point);
never executed: return d_ptr->sceneTransform.map(point);
0
5995}-
5996-
5997/*!-
5998 \fn QPointF QGraphicsItem::mapToScene(qreal x, qreal y) const-
5999 \overload-
6000-
6001 This convenience function is equivalent to calling mapToScene(QPointF(\a-
6002 x, \a y)).-
6003*/-
6004-
6005/*!-
6006 Maps the rectangle \a rect, which is in this item's coordinate system, to-
6007 \a item's coordinate system, and returns the mapped rectangle as a polygon.-
6008-
6009 If \a item is 0, this function returns the same as mapToScene().-
6010-
6011 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The-
6012 Graphics View Coordinate System}-
6013*/-
6014QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QRectF &rect) const-
6015{-
6016 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
6017 return itemTransform(item).map(rect);
never executed: return itemTransform(item).map(rect);
0
6018 return mapToScene(rect);
never executed: return mapToScene(rect);
0
6019}-
6020-
6021/*!-
6022 \fn QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const-
6023 \since 4.3-
6024-
6025 This convenience function is equivalent to calling mapToItem(item, QRectF(\a x, \a y, \a w, \a h)).-
6026*/-
6027-
6028/*!-
6029 Maps the rectangle \a rect, which is in this item's coordinate system, to-
6030 its parent's coordinate system, and returns the mapped rectangle as a-
6031 polygon. If the item has no parent, \a rect will be mapped to the scene's-
6032 coordinate system.-
6033-
6034 \sa mapToScene(), mapToItem(), mapFromParent(), {The Graphics View-
6035 Coordinate System}-
6036*/-
6037QPolygonF QGraphicsItem::mapToParent(const QRectF &rect) const-
6038{-
6039 // COMBINE-
6040 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
6041 return rect.translated(d_ptr->pos);
never executed: return rect.translated(d_ptr->pos);
0
6042 return d_ptr->transformToParent().map(rect);
never executed: return d_ptr->transformToParent().map(rect);
0
6043}-
6044-
6045/*!-
6046 \fn QPolygonF QGraphicsItem::mapToParent(qreal x, qreal y, qreal w, qreal h) const-
6047 \since 4.3-
6048-
6049 This convenience function is equivalent to calling mapToParent(QRectF(\a x, \a y, \a w, \a h)).-
6050*/-
6051-
6052/*!-
6053 Maps the rectangle \a rect, which is in this item's coordinate system, to-
6054 the scene's coordinate system, and returns the mapped rectangle as a polygon.-
6055-
6056 \sa mapToParent(), mapToItem(), mapFromScene(), {The Graphics View-
6057 Coordinate System}-
6058*/-
6059QPolygonF QGraphicsItem::mapToScene(const QRectF &rect) const-
6060{-
6061 if (d_ptr->hasTranslateOnlySceneTransform())
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
6062 return rect.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
never executed: return rect.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
0
6063 return d_ptr->sceneTransform.map(rect);
never executed: return d_ptr->sceneTransform.map(rect);
0
6064}-
6065-
6066/*!-
6067 \fn QPolygonF QGraphicsItem::mapToScene(qreal x, qreal y, qreal w, qreal h) const-
6068 \since 4.3-
6069-
6070 This convenience function is equivalent to calling mapToScene(QRectF(\a x, \a y, \a w, \a h)).-
6071*/-
6072-
6073/*!-
6074 \since 4.5-
6075-
6076 Maps the rectangle \a rect, which is in this item's coordinate system, to-
6077 \a item's coordinate system, and returns the mapped rectangle as a new-
6078 rectangle (i.e., the bounding rectangle of the resulting polygon).-
6079-
6080 If \a item is 0, this function returns the same as mapRectToScene().-
6081-
6082 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The-
6083 Graphics View Coordinate System}-
6084*/-
6085QRectF QGraphicsItem::mapRectToItem(const QGraphicsItem *item, const QRectF &rect) const-
6086{-
6087 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
6088 return itemTransform(item).mapRect(rect);
never executed: return itemTransform(item).mapRect(rect);
0
6089 return mapRectToScene(rect);
never executed: return mapRectToScene(rect);
0
6090}-
6091-
6092/*!-
6093 \fn QRectF QGraphicsItem::mapRectToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const-
6094 \since 4.5-
6095-
6096 This convenience function is equivalent to calling mapRectToItem(item, QRectF(\a x, \a y, \a w, \a h)).-
6097*/-
6098-
6099/*!-
6100 \since 4.5-
6101-
6102 Maps the rectangle \a rect, which is in this item's coordinate system, to-
6103 its parent's coordinate system, and returns the mapped rectangle as a new-
6104 rectangle (i.e., the bounding rectangle of the resulting polygon).-
6105-
6106 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The-
6107 Graphics View Coordinate System}-
6108*/-
6109QRectF QGraphicsItem::mapRectToParent(const QRectF &rect) const-
6110{-
6111 // COMBINE-
6112 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
6113 return rect.translated(d_ptr->pos);
never executed: return rect.translated(d_ptr->pos);
0
6114 return d_ptr->transformToParent().mapRect(rect);
never executed: return d_ptr->transformToParent().mapRect(rect);
0
6115}-
6116-
6117/*!-
6118 \fn QRectF QGraphicsItem::mapRectToParent(qreal x, qreal y, qreal w, qreal h) const-
6119 \since 4.5-
6120-
6121 This convenience function is equivalent to calling mapRectToParent(QRectF(\a x, \a y, \a w, \a h)).-
6122*/-
6123-
6124/*!-
6125 \since 4.5-
6126-
6127 Maps the rectangle \a rect, which is in this item's coordinate system, to-
6128 the scene coordinate system, and returns the mapped rectangle as a new-
6129 rectangle (i.e., the bounding rectangle of the resulting polygon).-
6130-
6131 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The-
6132 Graphics View Coordinate System}-
6133*/-
6134QRectF QGraphicsItem::mapRectToScene(const QRectF &rect) const-
6135{-
6136 if (d_ptr->hasTranslateOnlySceneTransform())
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
6137 return rect.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
never executed: return rect.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
0
6138 return d_ptr->sceneTransform.mapRect(rect);
never executed: return d_ptr->sceneTransform.mapRect(rect);
0
6139}-
6140-
6141/*!-
6142 \fn QRectF QGraphicsItem::mapRectToScene(qreal x, qreal y, qreal w, qreal h) const-
6143 \since 4.5-
6144-
6145 This convenience function is equivalent to calling mapRectToScene(QRectF(\a x, \a y, \a w, \a h)).-
6146*/-
6147-
6148/*!-
6149 \since 4.5-
6150-
6151 Maps the rectangle \a rect, which is in \a item's coordinate system, to-
6152 this item's coordinate system, and returns the mapped rectangle as a new-
6153 rectangle (i.e., the bounding rectangle of the resulting polygon).-
6154-
6155 If \a item is 0, this function returns the same as mapRectFromScene().-
6156-
6157 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The-
6158 Graphics View Coordinate System}-
6159*/-
6160QRectF QGraphicsItem::mapRectFromItem(const QGraphicsItem *item, const QRectF &rect) const-
6161{-
6162 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
6163 return item->itemTransform(this).mapRect(rect);
never executed: return item->itemTransform(this).mapRect(rect);
0
6164 return mapRectFromScene(rect);
never executed: return mapRectFromScene(rect);
0
6165}-
6166-
6167/*!-
6168 \fn QRectF QGraphicsItem::mapRectFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const-
6169 \since 4.5-
6170-
6171 This convenience function is equivalent to calling mapRectFromItem(item, QRectF(\a x, \a y, \a w, \a h)).-
6172*/-
6173-
6174/*!-
6175 \since 4.5-
6176-
6177 Maps the rectangle \a rect, which is in this item's parent's coordinate-
6178 system, to this item's coordinate system, and returns the mapped rectangle-
6179 as a new rectangle (i.e., the bounding rectangle of the resulting-
6180 polygon).-
6181-
6182 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The-
6183 Graphics View Coordinate System}-
6184*/-
6185QRectF QGraphicsItem::mapRectFromParent(const QRectF &rect) const-
6186{-
6187 // COMBINE-
6188 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
6189 return rect.translated(-d_ptr->pos);
never executed: return rect.translated(-d_ptr->pos);
0
6190 return d_ptr->transformToParent().inverted().mapRect(rect);
never executed: return d_ptr->transformToParent().inverted().mapRect(rect);
0
6191}-
6192-
6193/*!-
6194 \fn QRectF QGraphicsItem::mapRectFromParent(qreal x, qreal y, qreal w, qreal h) const-
6195 \since 4.5-
6196-
6197 This convenience function is equivalent to calling mapRectFromParent(QRectF(\a x, \a y, \a w, \a h)).-
6198*/-
6199-
6200/*!-
6201 \since 4.5-
6202-
6203 Maps the rectangle \a rect, which is in scene coordinates, to this item's-
6204 coordinate system, and returns the mapped rectangle as a new rectangle-
6205 (i.e., the bounding rectangle of the resulting polygon).-
6206-
6207 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The-
6208 Graphics View Coordinate System}-
6209*/-
6210QRectF QGraphicsItem::mapRectFromScene(const QRectF &rect) const-
6211{-
6212 if (d_ptr->hasTranslateOnlySceneTransform())
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
6213 return rect.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
never executed: return rect.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
0
6214 return d_ptr->sceneTransform.inverted().mapRect(rect);
never executed: return d_ptr->sceneTransform.inverted().mapRect(rect);
0
6215}-
6216-
6217/*!-
6218 \fn QRectF QGraphicsItem::mapRectFromScene(qreal x, qreal y, qreal w, qreal h) const-
6219 \since 4.5-
6220-
6221 This convenience function is equivalent to calling mapRectFromScene(QRectF(\a x, \a y, \a w, \a h)).-
6222*/-
6223-
6224/*!-
6225 Maps the polygon \a polygon, which is in this item's coordinate system, to-
6226 \a item's coordinate system, and returns the mapped polygon.-
6227-
6228 If \a item is 0, this function returns the same as mapToScene().-
6229-
6230 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The-
6231 Graphics View Coordinate System}-
6232*/-
6233QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPolygonF &polygon) const-
6234{-
6235 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
6236 return itemTransform(item).map(polygon);
never executed: return itemTransform(item).map(polygon);
0
6237 return mapToScene(polygon);
never executed: return mapToScene(polygon);
0
6238}-
6239-
6240/*!-
6241 Maps the polygon \a polygon, which is in this item's coordinate system, to-
6242 its parent's coordinate system, and returns the mapped polygon. If the-
6243 item has no parent, \a polygon will be mapped to the scene's coordinate-
6244 system.-
6245-
6246 \sa mapToScene(), mapToItem(), mapFromParent(), {The Graphics View-
6247 Coordinate System}-
6248*/-
6249QPolygonF QGraphicsItem::mapToParent(const QPolygonF &polygon) const-
6250{-
6251 // COMBINE-
6252 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
6253 return polygon.translated(d_ptr->pos);
never executed: return polygon.translated(d_ptr->pos);
0
6254 return d_ptr->transformToParent().map(polygon);
never executed: return d_ptr->transformToParent().map(polygon);
0
6255}-
6256-
6257/*!-
6258 Maps the polygon \a polygon, which is in this item's coordinate system, to-
6259 the scene's coordinate system, and returns the mapped polygon.-
6260-
6261 \sa mapToParent(), mapToItem(), mapFromScene(), {The Graphics View-
6262 Coordinate System}-
6263*/-
6264QPolygonF QGraphicsItem::mapToScene(const QPolygonF &polygon) const-
6265{-
6266 if (d_ptr->hasTranslateOnlySceneTransform())
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
6267 return polygon.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
never executed: return polygon.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
0
6268 return d_ptr->sceneTransform.map(polygon);
never executed: return d_ptr->sceneTransform.map(polygon);
0
6269}-
6270-
6271/*!-
6272 Maps the path \a path, which is in this item's coordinate system, to-
6273 \a item's coordinate system, and returns the mapped path.-
6274-
6275 If \a item is 0, this function returns the same as mapToScene().-
6276-
6277 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The-
6278 Graphics View Coordinate System}-
6279*/-
6280QPainterPath QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPainterPath &path) const-
6281{-
6282 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
6283 return itemTransform(item).map(path);
never executed: return itemTransform(item).map(path);
0
6284 return mapToScene(path);
never executed: return mapToScene(path);
0
6285}-
6286-
6287/*!-
6288 Maps the path \a path, which is in this item's coordinate system, to-
6289 its parent's coordinate system, and returns the mapped path. If the-
6290 item has no parent, \a path will be mapped to the scene's coordinate-
6291 system.-
6292-
6293 \sa mapToScene(), mapToItem(), mapFromParent(), {The Graphics View-
6294 Coordinate System}-
6295*/-
6296QPainterPath QGraphicsItem::mapToParent(const QPainterPath &path) const-
6297{-
6298 // COMBINE-
6299 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
6300 return path.translated(d_ptr->pos);
never executed: return path.translated(d_ptr->pos);
0
6301 return d_ptr->transformToParent().map(path);
never executed: return d_ptr->transformToParent().map(path);
0
6302}-
6303-
6304/*!-
6305 Maps the path \a path, which is in this item's coordinate system, to-
6306 the scene's coordinate system, and returns the mapped path.-
6307-
6308 \sa mapToParent(), mapToItem(), mapFromScene(), {The Graphics View-
6309 Coordinate System}-
6310*/-
6311QPainterPath QGraphicsItem::mapToScene(const QPainterPath &path) const-
6312{-
6313 if (d_ptr->hasTranslateOnlySceneTransform())
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
6314 return path.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
never executed: return path.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy());
0
6315 return d_ptr->sceneTransform.map(path);
never executed: return d_ptr->sceneTransform.map(path);
0
6316}-
6317-
6318/*!-
6319 Maps the point \a point, which is in \a item's coordinate system, to this-
6320 item's coordinate system, and returns the mapped coordinate.-
6321-
6322 If \a item is 0, this function returns the same as mapFromScene().-
6323-
6324 \sa itemTransform(), mapFromParent(), mapFromScene(), transform(), mapToItem(), {The Graphics-
6325 View Coordinate System}-
6326*/-
6327QPointF QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QPointF &point) const-
6328{-
6329 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
6330 return item->itemTransform(this).map(point);
never executed: return item->itemTransform(this).map(point);
0
6331 return mapFromScene(point);
never executed: return mapFromScene(point);
0
6332}-
6333-
6334/*!-
6335 \fn QPointF QGraphicsItem::mapFromItem(const QGraphicsItem *item, qreal x, qreal y) const-
6336 \overload-
6337-
6338 This convenience function is equivalent to calling mapFromItem(\a item,-
6339 QPointF(\a x, \a y)).-
6340*/-
6341-
6342/*!-
6343 Maps the point \a point, which is in this item's parent's coordinate-
6344 system, to this item's coordinate system, and returns the mapped-
6345 coordinate.-
6346-
6347 \sa mapFromItem(), mapFromScene(), transform(), mapToParent(), {The Graphics-
6348 View Coordinate System}-
6349*/-
6350QPointF QGraphicsItem::mapFromParent(const QPointF &point) const-
6351{-
6352 // COMBINE-
6353 if (d_ptr->transformData)
d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
6354 return d_ptr->transformToParent().inverted().map(point);
never executed: return d_ptr->transformToParent().inverted().map(point);
0
6355 return point - d_ptr->pos;
never executed: return point - d_ptr->pos;
0
6356}-
6357-
6358/*!-
6359 \fn QPointF QGraphicsItem::mapFromParent(qreal x, qreal y) const-
6360 \overload-
6361-
6362 This convenience function is equivalent to calling-
6363 mapFromParent(QPointF(\a x, \a y)).-
6364*/-
6365-
6366/*!-
6367 Maps the point \a point, which is in this item's scene's coordinate-
6368 system, to this item's coordinate system, and returns the mapped-
6369 coordinate.-
6370-
6371 \sa mapFromItem(), mapFromParent(), transform(), mapToScene(), {The Graphics-
6372 View Coordinate System}-
6373*/-
6374QPointF QGraphicsItem::mapFromScene(const QPointF &point) const-
6375{-
6376 if (d_ptr->hasTranslateOnlySceneTransform())
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
6377 return QPointF(point.x() - d_ptr->sceneTransform.dx(), point.y() - d_ptr->sceneTransform.dy());
never executed: return QPointF(point.x() - d_ptr->sceneTransform.dx(), point.y() - d_ptr->sceneTransform.dy());
0
6378 return d_ptr->sceneTransform.inverted().map(point);
never executed: return d_ptr->sceneTransform.inverted().map(point);
0
6379}-
6380-
6381/*!-
6382 \fn QPointF QGraphicsItem::mapFromScene(qreal x, qreal y) const-
6383 \overload-
6384-
6385 This convenience function is equivalent to calling mapFromScene(QPointF(\a-
6386 x, \a y)).-
6387*/-
6388-
6389/*!-
6390 Maps the rectangle \a rect, which is in \a item's coordinate system, to-
6391 this item's coordinate system, and returns the mapped rectangle as a-
6392 polygon.-
6393-
6394 If \a item is 0, this function returns the same as mapFromScene()-
6395-
6396 \sa itemTransform(), mapToItem(), mapFromParent(), transform(), {The Graphics View Coordinate-
6397 System}-
6398*/-
6399QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QRectF &rect) const-
6400{-
6401 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
6402 return item->itemTransform(this).map(rect);
never executed: return item->itemTransform(this).map(rect);
0
6403 return mapFromScene(rect);
never executed: return mapFromScene(rect);
0
6404}-
6405-
6406/*!-
6407 \fn QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const-
6408 \since 4.3-
6409-
6410 This convenience function is equivalent to calling mapFromItem(item, QRectF(\a x, \a y, \a w, \a h)).-
6411*/-
6412-
6413/*!-
6414 Maps the rectangle \a rect, which is in this item's parent's coordinate-
6415 system, to this item's coordinate system, and returns the mapped rectangle-
6416 as a polygon.-
6417-
6418 \sa mapToParent(), mapFromItem(), transform(), {The Graphics View Coordinate-
6419 System}-
6420*/-
6421QPolygonF QGraphicsItem::mapFromParent(const QRectF &rect) const-
6422{-
6423 // COMBINE-
6424 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
6425 return rect.translated(-d_ptr->pos);
never executed: return rect.translated(-d_ptr->pos);
0
6426 return d_ptr->transformToParent().inverted().map(rect);
never executed: return d_ptr->transformToParent().inverted().map(rect);
0
6427}-
6428-
6429/*!-
6430 \fn QPolygonF QGraphicsItem::mapFromParent(qreal x, qreal y, qreal w, qreal h) const-
6431 \since 4.3-
6432-
6433 This convenience function is equivalent to calling mapFromItem(QRectF(\a x, \a y, \a w, \a h)).-
6434*/-
6435-
6436/*!-
6437 Maps the rectangle \a rect, which is in this item's scene's coordinate-
6438 system, to this item's coordinate system, and returns the mapped rectangle-
6439 as a polygon.-
6440-
6441 \sa mapToScene(), mapFromItem(), transform(), {The Graphics View Coordinate-
6442 System}-
6443*/-
6444QPolygonF QGraphicsItem::mapFromScene(const QRectF &rect) const-
6445{-
6446 if (d_ptr->hasTranslateOnlySceneTransform())
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
6447 return rect.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
never executed: return rect.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
0
6448 return d_ptr->sceneTransform.inverted().map(rect);
never executed: return d_ptr->sceneTransform.inverted().map(rect);
0
6449}-
6450-
6451/*!-
6452 \fn QPolygonF QGraphicsItem::mapFromScene(qreal x, qreal y, qreal w, qreal h) const-
6453 \since 4.3-
6454-
6455 This convenience function is equivalent to calling mapFromScene(QRectF(\a x, \a y, \a w, \a h)).-
6456*/-
6457-
6458/*!-
6459 Maps the polygon \a polygon, which is in \a item's coordinate system, to-
6460 this item's coordinate system, and returns the mapped polygon.-
6461-
6462 If \a item is 0, this function returns the same as mapFromScene().-
6463-
6464 \sa itemTransform(), mapToItem(), mapFromParent(), transform(), {The-
6465 Graphics View Coordinate System}-
6466*/-
6467QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QPolygonF &polygon) const-
6468{-
6469 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
6470 return item->itemTransform(this).map(polygon);
never executed: return item->itemTransform(this).map(polygon);
0
6471 return mapFromScene(polygon);
never executed: return mapFromScene(polygon);
0
6472}-
6473-
6474/*!-
6475 Maps the polygon \a polygon, which is in this item's parent's coordinate-
6476 system, to this item's coordinate system, and returns the mapped polygon.-
6477-
6478 \sa mapToParent(), mapToItem(), transform(), {The Graphics View Coordinate-
6479 System}-
6480*/-
6481QPolygonF QGraphicsItem::mapFromParent(const QPolygonF &polygon) const-
6482{-
6483 // COMBINE-
6484 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
6485 return polygon.translated(-d_ptr->pos);
never executed: return polygon.translated(-d_ptr->pos);
0
6486 return d_ptr->transformToParent().inverted().map(polygon);
never executed: return d_ptr->transformToParent().inverted().map(polygon);
0
6487}-
6488-
6489/*!-
6490 Maps the polygon \a polygon, which is in this item's scene's coordinate-
6491 system, to this item's coordinate system, and returns the mapped polygon.-
6492-
6493 \sa mapToScene(), mapFromParent(), transform(), {The Graphics View Coordinate-
6494 System}-
6495*/-
6496QPolygonF QGraphicsItem::mapFromScene(const QPolygonF &polygon) const-
6497{-
6498 if (d_ptr->hasTranslateOnlySceneTransform())
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
6499 return polygon.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
never executed: return polygon.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
0
6500 return d_ptr->sceneTransform.inverted().map(polygon);
never executed: return d_ptr->sceneTransform.inverted().map(polygon);
0
6501}-
6502-
6503/*!-
6504 Maps the path \a path, which is in \a item's coordinate system, to-
6505 this item's coordinate system, and returns the mapped path.-
6506-
6507 If \a item is 0, this function returns the same as mapFromScene().-
6508-
6509 \sa itemTransform(), mapFromParent(), mapFromScene(), mapToItem(), {The-
6510 Graphics View Coordinate System}-
6511*/-
6512QPainterPath QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QPainterPath &path) const-
6513{-
6514 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
6515 return item->itemTransform(this).map(path);
never executed: return item->itemTransform(this).map(path);
0
6516 return mapFromScene(path);
never executed: return mapFromScene(path);
0
6517}-
6518-
6519/*!-
6520 Maps the path \a path, which is in this item's parent's coordinate-
6521 system, to this item's coordinate system, and returns the mapped path.-
6522-
6523 \sa mapFromScene(), mapFromItem(), mapToParent(), {The Graphics View-
6524 Coordinate System}-
6525*/-
6526QPainterPath QGraphicsItem::mapFromParent(const QPainterPath &path) const-
6527{-
6528 // COMBINE-
6529 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
6530 return path.translated(-d_ptr->pos);
never executed: return path.translated(-d_ptr->pos);
0
6531 return d_ptr->transformToParent().inverted().map(path);
never executed: return d_ptr->transformToParent().inverted().map(path);
0
6532}-
6533-
6534/*!-
6535 Maps the path \a path, which is in this item's scene's coordinate-
6536 system, to this item's coordinate system, and returns the mapped path.-
6537-
6538 \sa mapFromParent(), mapFromItem(), mapToScene(), {The Graphics View-
6539 Coordinate System}-
6540*/-
6541QPainterPath QGraphicsItem::mapFromScene(const QPainterPath &path) const-
6542{-
6543 if (d_ptr->hasTranslateOnlySceneTransform())
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
6544 return path.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
never executed: return path.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy());
0
6545 return d_ptr->sceneTransform.inverted().map(path);
never executed: return d_ptr->sceneTransform.inverted().map(path);
0
6546}-
6547-
6548/*!-
6549 Returns \c true if this item is an ancestor of \a child (i.e., if this item-
6550 is \a child's parent, or one of \a child's parent's ancestors).-
6551-
6552 \sa parentItem()-
6553*/-
6554bool QGraphicsItem::isAncestorOf(const QGraphicsItem *child) const-
6555{-
6556 if (!child || child == this)
!childDescription
TRUEnever evaluated
FALSEnever evaluated
child == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
6557 return false;
never executed: return false;
0
6558 if (child->d_ptr->depth() < d_ptr->depth())
child->d_ptr->...d_ptr->depth()Description
TRUEnever evaluated
FALSEnever evaluated
0
6559 return false;
never executed: return false;
0
6560 const QGraphicsItem *ancestor = child;-
6561 while ((ancestor = ancestor->d_ptr->parent)) {
(ancestor = an...d_ptr->parent)Description
TRUEnever evaluated
FALSEnever evaluated
0
6562 if (ancestor == this)
ancestor == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
6563 return true;
never executed: return true;
0
6564 }
never executed: end of block
0
6565 return false;
never executed: return false;
0
6566}-
6567-
6568/*!-
6569 \since 4.4-
6570-
6571 Returns the closest common ancestor item of this item and \a other, or 0-
6572 if either \a other is 0, or there is no common ancestor.-
6573-
6574 \sa isAncestorOf()-
6575*/-
6576QGraphicsItem *QGraphicsItem::commonAncestorItem(const QGraphicsItem *other) const-
6577{-
6578 if (!other)
!otherDescription
TRUEnever evaluated
FALSEnever evaluated
0
6579 return 0;
never executed: return 0;
0
6580 if (other == this)
other == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
6581 return const_cast<QGraphicsItem *>(this);
never executed: return const_cast<QGraphicsItem *>(this);
0
6582 const QGraphicsItem *thisw = this;-
6583 const QGraphicsItem *otherw = other;-
6584 int thisDepth = d_ptr->depth();-
6585 int otherDepth = other->d_ptr->depth();-
6586 while (thisDepth > otherDepth) {
thisDepth > otherDepthDescription
TRUEnever evaluated
FALSEnever evaluated
0
6587 thisw = thisw->d_ptr->parent;-
6588 --thisDepth;-
6589 }
never executed: end of block
0
6590 while (otherDepth > thisDepth) {
otherDepth > thisDepthDescription
TRUEnever evaluated
FALSEnever evaluated
0
6591 otherw = otherw->d_ptr->parent;-
6592 --otherDepth;-
6593 }
never executed: end of block
0
6594 while (thisw && thisw != otherw) {
thiswDescription
TRUEnever evaluated
FALSEnever evaluated
thisw != otherwDescription
TRUEnever evaluated
FALSEnever evaluated
0
6595 thisw = thisw->d_ptr->parent;-
6596 otherw = otherw->d_ptr->parent;-
6597 }
never executed: end of block
0
6598 return const_cast<QGraphicsItem *>(thisw);
never executed: return const_cast<QGraphicsItem *>(thisw);
0
6599}-
6600-
6601/*!-
6602 \since 4,4-
6603 Returns \c true if this item is currently under the mouse cursor in one of-
6604 the views; otherwise, false is returned.-
6605-
6606 \sa QGraphicsScene::views(), QCursor::pos()-
6607*/-
6608bool QGraphicsItem::isUnderMouse() const-
6609{-
6610 Q_D(const QGraphicsItem);-
6611 if (!d->scene)
!d->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
6612 return false;
never executed: return false;
0
6613-
6614 QPoint cursorPos = QCursor::pos();-
6615 const auto views = d->scene->views();-
6616 for (QGraphicsView *view : views) {-
6617 if (contains(mapFromScene(view->mapToScene(view->mapFromGlobal(cursorPos)))))
contains(mapFr...(cursorPos))))Description
TRUEnever evaluated
FALSEnever evaluated
0
6618 return true;
never executed: return true;
0
6619 }
never executed: end of block
0
6620 return false;
never executed: return false;
0
6621}-
6622-
6623/*!-
6624 Returns this item's custom data for the key \a key as a QVariant.-
6625-
6626 Custom item data is useful for storing arbitrary properties in any-
6627 item. Example:-
6628-
6629 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 11-
6630-
6631 Qt does not use this feature for storing data; it is provided solely-
6632 for the convenience of the user.-
6633-
6634 \sa setData()-
6635*/-
6636QVariant QGraphicsItem::data(int key) const-
6637{-
6638 QGraphicsItemCustomDataStore *store = qt_dataStore();-
6639 if (!store->data.contains(this))
!store->data.contains(this)Description
TRUEnever evaluated
FALSEnever evaluated
0
6640 return QVariant();
never executed: return QVariant();
0
6641 return store->data.value(this).value(key);
never executed: return store->data.value(this).value(key);
0
6642}-
6643-
6644/*!-
6645 Sets this item's custom data for the key \a key to \a value.-
6646-
6647 Custom item data is useful for storing arbitrary properties for any-
6648 item. Qt does not use this feature for storing data; it is provided solely-
6649 for the convenience of the user.-
6650-
6651 \sa data()-
6652*/-
6653void QGraphicsItem::setData(int key, const QVariant &value)-
6654{-
6655 qt_dataStore()->data[this][key] = value;-
6656}
never executed: end of block
0
6657-
6658/*!-
6659 \fn T qgraphicsitem_cast(QGraphicsItem *item)-
6660 \relates QGraphicsItem-
6661 \since 4.2-
6662-
6663 Returns the given \a item cast to type T if \a item is of type T;-
6664 otherwise, 0 is returned.-
6665-
6666 \note To make this function work correctly with custom items, reimplement-
6667 the \l{QGraphicsItem::}{type()} function for each custom QGraphicsItem-
6668 subclass.-
6669-
6670 \sa QGraphicsItem::type(), QGraphicsItem::UserType-
6671*/-
6672-
6673/*!-
6674 Returns the type of an item as an int. All standard graphicsitem classes-
6675 are associated with a unique value; see QGraphicsItem::Type. This type-
6676 information is used by qgraphicsitem_cast() to distinguish between types.-
6677-
6678 The default implementation (in QGraphicsItem) returns UserType.-
6679-
6680 To enable use of qgraphicsitem_cast() with a custom item, reimplement this-
6681 function and declare a Type enum value equal to your custom item's type.-
6682 Custom items must return a value larger than or equal to UserType (65536).-
6683-
6684 For example:-
6685-
6686 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 1-
6687-
6688 \sa UserType-
6689*/-
6690int QGraphicsItem::type() const-
6691{-
6692 return (int)UserType;
never executed: return (int)UserType;
0
6693}-
6694-
6695/*!-
6696 Installs an event filter for this item on \a filterItem, causing-
6697 all events for this item to first pass through \a filterItem's-
6698 sceneEventFilter() function.-
6699-
6700 To filter another item's events, install this item as an event filter-
6701 for the other item. Example:-
6702-
6703 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 12-
6704-
6705 An item can only filter events for other items in the same-
6706 scene. Also, an item cannot filter its own events; instead, you-
6707 can reimplement sceneEvent() directly.-
6708-
6709 Items must belong to a scene for scene event filters to be installed and-
6710 used.-
6711-
6712 \sa removeSceneEventFilter(), sceneEventFilter(), sceneEvent()-
6713*/-
6714void QGraphicsItem::installSceneEventFilter(QGraphicsItem *filterItem)-
6715{-
6716 if (!d_ptr->scene) {
!d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
6717 qWarning("QGraphicsItem::installSceneEventFilter: event filters can only be installed"-
6718 " on items in a scene.");-
6719 return;
never executed: return;
0
6720 }-
6721 if (d_ptr->scene != filterItem->scene()) {
d_ptr->scene !...rItem->scene()Description
TRUEnever evaluated
FALSEnever evaluated
0
6722 qWarning("QGraphicsItem::installSceneEventFilter: event filters can only be installed"-
6723 " on items in the same scene.");-
6724 return;
never executed: return;
0
6725 }-
6726 d_ptr->scene->d_func()->installSceneEventFilter(this, filterItem);-
6727}
never executed: end of block
0
6728-
6729/*!-
6730 Removes an event filter on this item from \a filterItem.-
6731-
6732 \sa installSceneEventFilter()-
6733*/-
6734void QGraphicsItem::removeSceneEventFilter(QGraphicsItem *filterItem)-
6735{-
6736 if (!d_ptr->scene || d_ptr->scene != filterItem->scene())
!d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
d_ptr->scene !...rItem->scene()Description
TRUEnever evaluated
FALSEnever evaluated
0
6737 return;
never executed: return;
0
6738 d_ptr->scene->d_func()->removeSceneEventFilter(this, filterItem);-
6739}
never executed: end of block
0
6740-
6741/*!-
6742 Filters events for the item \a watched. \a event is the filtered-
6743 event.-
6744-
6745 Reimplementing this function in a subclass makes it possible-
6746 for the item to be used as an event filter for other items,-
6747 intercepting all the events sent to those items before they are-
6748 able to respond.-
6749-
6750 Reimplementations must return true to prevent further processing of-
6751 a given event, ensuring that it will not be delivered to the watched-
6752 item, or return false to indicate that the event should be propagated-
6753 further by the event system.-
6754-
6755 \sa installSceneEventFilter()-
6756*/-
6757bool QGraphicsItem::sceneEventFilter(QGraphicsItem *watched, QEvent *event)-
6758{-
6759 Q_UNUSED(watched);-
6760 Q_UNUSED(event);-
6761 return false;
never executed: return false;
0
6762}-
6763-
6764/*!-
6765 This virtual function receives events to this item. Reimplement-
6766 this function to intercept events before they are dispatched to-
6767 the specialized event handlers contextMenuEvent(), focusInEvent(),-
6768 focusOutEvent(), hoverEnterEvent(), hoverMoveEvent(),-
6769 hoverLeaveEvent(), keyPressEvent(), keyReleaseEvent(),-
6770 mousePressEvent(), mouseReleaseEvent(), mouseMoveEvent(), and-
6771 mouseDoubleClickEvent().-
6772-
6773 Returns \c true if the event was recognized and handled; otherwise, (e.g., if-
6774 the event type was not recognized,) false is returned.-
6775-
6776 \a event is the intercepted event.-
6777*/-
6778bool QGraphicsItem::sceneEvent(QEvent *event)-
6779{-
6780 if (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents) {
d_ptr->ancesto...lesChildEventsDescription
TRUEnever evaluated
FALSEnever evaluated
0
6781 if (event->type() == QEvent::HoverEnter || event->type() == QEvent::HoverLeave
event->type() ...nt::HoverEnterDescription
TRUEnever evaluated
FALSEnever evaluated
event->type() ...nt::HoverLeaveDescription
TRUEnever evaluated
FALSEnever evaluated
0
6782 || event->type() == QEvent::DragEnter || event->type() == QEvent::DragLeave) {
event->type() ...ent::DragEnterDescription
TRUEnever evaluated
FALSEnever evaluated
event->type() ...ent::DragLeaveDescription
TRUEnever evaluated
FALSEnever evaluated
0
6783 // Hover enter and hover leave events for children are ignored;-
6784 // hover move events are forwarded.-
6785 return true;
never executed: return true;
0
6786 }-
6787-
6788 QGraphicsItem *handler = this;-
6789 do {-
6790 handler = handler->d_ptr->parent;-
6791 Q_ASSERT(handler);-
6792 } while (handler->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents);
never executed: end of block
handler->d_ptr...lesChildEventsDescription
TRUEnever evaluated
FALSEnever evaluated
0
6793 // Forward the event to the closest parent that handles child-
6794 // events, mapping existing item-local coordinates to its-
6795 // coordinate system.-
6796 d_ptr->remapItemPos(event, handler);-
6797 handler->sceneEvent(event);-
6798 return true;
never executed: return true;
0
6799 }-
6800-
6801 if (event->type() == QEvent::FocusOut) {
event->type() ...vent::FocusOutDescription
TRUEnever evaluated
FALSEnever evaluated
0
6802 focusOutEvent(static_cast<QFocusEvent *>(event));-
6803 return true;
never executed: return true;
0
6804 }-
6805-
6806 if (!d_ptr->visible) {
!d_ptr->visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
6807 // Eaten-
6808 return true;
never executed: return true;
0
6809 }-
6810-
6811 switch (event->type()) {-
6812 case QEvent::FocusIn:
never executed: case QEvent::FocusIn:
0
6813 focusInEvent(static_cast<QFocusEvent *>(event));-
6814 break;
never executed: break;
0
6815 case QEvent::GraphicsSceneContextMenu:
never executed: case QEvent::GraphicsSceneContextMenu:
0
6816 contextMenuEvent(static_cast<QGraphicsSceneContextMenuEvent *>(event));-
6817 break;
never executed: break;
0
6818 case QEvent::GraphicsSceneDragEnter:
never executed: case QEvent::GraphicsSceneDragEnter:
0
6819 dragEnterEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));-
6820 break;
never executed: break;
0
6821 case QEvent::GraphicsSceneDragMove:
never executed: case QEvent::GraphicsSceneDragMove:
0
6822 dragMoveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));-
6823 break;
never executed: break;
0
6824 case QEvent::GraphicsSceneDragLeave:
never executed: case QEvent::GraphicsSceneDragLeave:
0
6825 dragLeaveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));-
6826 break;
never executed: break;
0
6827 case QEvent::GraphicsSceneDrop:
never executed: case QEvent::GraphicsSceneDrop:
0
6828 dropEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));-
6829 break;
never executed: break;
0
6830 case QEvent::GraphicsSceneHoverEnter:
never executed: case QEvent::GraphicsSceneHoverEnter:
0
6831 hoverEnterEvent(static_cast<QGraphicsSceneHoverEvent *>(event));-
6832 break;
never executed: break;
0
6833 case QEvent::GraphicsSceneHoverMove:
never executed: case QEvent::GraphicsSceneHoverMove:
0
6834 hoverMoveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));-
6835 break;
never executed: break;
0
6836 case QEvent::GraphicsSceneHoverLeave:
never executed: case QEvent::GraphicsSceneHoverLeave:
0
6837 hoverLeaveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));-
6838 break;
never executed: break;
0
6839 case QEvent::GraphicsSceneMouseMove:
never executed: case QEvent::GraphicsSceneMouseMove:
0
6840 mouseMoveEvent(static_cast<QGraphicsSceneMouseEvent *>(event));-
6841 break;
never executed: break;
0
6842 case QEvent::GraphicsSceneMousePress:
never executed: case QEvent::GraphicsSceneMousePress:
0
6843 mousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event));-
6844 break;
never executed: break;
0
6845 case QEvent::GraphicsSceneMouseRelease:
never executed: case QEvent::GraphicsSceneMouseRelease:
0
6846 mouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));-
6847 break;
never executed: break;
0
6848 case QEvent::GraphicsSceneMouseDoubleClick:
never executed: case QEvent::GraphicsSceneMouseDoubleClick:
0
6849 mouseDoubleClickEvent(static_cast<QGraphicsSceneMouseEvent *>(event));-
6850 break;
never executed: break;
0
6851 case QEvent::GraphicsSceneWheel:
never executed: case QEvent::GraphicsSceneWheel:
0
6852 wheelEvent(static_cast<QGraphicsSceneWheelEvent *>(event));-
6853 break;
never executed: break;
0
6854 case QEvent::KeyPress: {
never executed: case QEvent::KeyPress:
0
6855 QKeyEvent *k = static_cast<QKeyEvent *>(event);-
6856 if (k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) {
k->key() == Qt::Key_TabDescription
TRUEnever evaluated
FALSEnever evaluated
k->key() == Qt::Key_BacktabDescription
TRUEnever evaluated
FALSEnever evaluated
0
6857 if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
!(k->modifiers...:AltModifier))Description
TRUEnever evaluated
FALSEnever evaluated
0
6858 bool res = false;-
6859 if (k->key() == Qt::Key_Backtab
k->key() == Qt::Key_BacktabDescription
TRUEnever evaluated
FALSEnever evaluated
0
6860 || (k->key() == Qt::Key_Tab && (k->modifiers() & Qt::ShiftModifier))) {
k->key() == Qt::Key_TabDescription
TRUEnever evaluated
FALSEnever evaluated
(k->modifiers(...ShiftModifier)Description
TRUEnever evaluated
FALSEnever evaluated
0
6861 if (d_ptr->isWidget) {
d_ptr->isWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
6862 res = static_cast<QGraphicsWidget *>(this)->focusNextPrevChild(false);-
6863 } else if (d_ptr->scene) {
never executed: end of block
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
6864 res = d_ptr->scene->focusNextPrevChild(false);-
6865 }
never executed: end of block
0
6866 } else if (k->key() == Qt::Key_Tab) {
never executed: end of block
k->key() == Qt::Key_TabDescription
TRUEnever evaluated
FALSEnever evaluated
0
6867 if (d_ptr->isWidget) {
d_ptr->isWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
6868 res = static_cast<QGraphicsWidget *>(this)->focusNextPrevChild(true);-
6869 } else if (d_ptr->scene) {
never executed: end of block
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
6870 res = d_ptr->scene->focusNextPrevChild(true);-
6871 }
never executed: end of block
0
6872 }
never executed: end of block
0
6873 if (!res)
!resDescription
TRUEnever evaluated
FALSEnever evaluated
0
6874 event->ignore();
never executed: event->ignore();
0
6875 return true;
never executed: return true;
0
6876 }-
6877 }
never executed: end of block
0
6878 keyPressEvent(static_cast<QKeyEvent *>(event));-
6879 break;
never executed: break;
0
6880 }-
6881 case QEvent::KeyRelease:
never executed: case QEvent::KeyRelease:
0
6882 keyReleaseEvent(static_cast<QKeyEvent *>(event));-
6883 break;
never executed: break;
0
6884 case QEvent::InputMethod:
never executed: case QEvent::InputMethod:
0
6885 inputMethodEvent(static_cast<QInputMethodEvent *>(event));-
6886 break;
never executed: break;
0
6887 case QEvent::WindowActivate:
never executed: case QEvent::WindowActivate:
0
6888 case QEvent::WindowDeactivate:
never executed: case QEvent::WindowDeactivate:
0
6889 // Propagate panel activation.-
6890 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
6891 for (int i = 0; i < d_ptr->children.size(); ++i) {
i < d_ptr->children.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
6892 QGraphicsItem *child = d_ptr->children.at(i);-
6893 if (child->isVisible() && !child->isPanel()) {
child->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
!child->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
6894 if (!(child->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents))
!(child->d_ptr...esChildEvents)Description
TRUEnever evaluated
FALSEnever evaluated
0
6895 d_ptr->scene->sendEvent(child, event);
never executed: d_ptr->scene->sendEvent(child, event);
0
6896 }
never executed: end of block
0
6897 }
never executed: end of block
0
6898 }
never executed: end of block
0
6899 break;
never executed: break;
0
6900 default:
never executed: default:
0
6901 return false;
never executed: return false;
0
6902 }-
6903-
6904 return true;
never executed: return true;
0
6905}-
6906-
6907/*!-
6908 This event handler can be reimplemented in a subclass to process context-
6909 menu events. The \a event parameter contains details about the event to-
6910 be handled.-
6911-
6912 If you ignore the event (i.e., by calling QEvent::ignore()), \a event-
6913 will propagate to any item beneath this item. If no items accept the-
6914 event, it will be ignored by the scene and propagate to the view.-
6915-
6916 It's common to open a QMenu in response to receiving a context menu-
6917 event. Example:-
6918-
6919 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 13-
6920-
6921 The default implementation ignores the event.-
6922-
6923 \sa sceneEvent()-
6924*/-
6925void QGraphicsItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)-
6926{-
6927 event->ignore();-
6928}
never executed: end of block
0
6929-
6930/*!-
6931 This event handler, for event \a event, can be reimplemented to receive-
6932 drag enter events for this item. Drag enter events are generated as the-
6933 cursor enters the item's area.-
6934-
6935 By accepting the event (i.e., by calling QEvent::accept()), the item will-
6936 accept drop events, in addition to receiving drag move and drag-
6937 leave. Otherwise, the event will be ignored and propagate to the item-
6938 beneath. If the event is accepted, the item will receive a drag move event-
6939 before control goes back to the event loop.-
6940-
6941 A common implementation of dragEnterEvent accepts or ignores \a event-
6942 depending on the associated mime data in \a event. Example:-
6943-
6944 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 14-
6945-
6946 Items do not receive drag and drop events by default; to enable this-
6947 feature, call \c setAcceptDrops(true).-
6948-
6949 The default implementation does nothing.-
6950-
6951 \sa dropEvent(), dragMoveEvent(), dragLeaveEvent()-
6952*/-
6953void QGraphicsItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)-
6954{-
6955 Q_D(QGraphicsItem);-
6956 // binary compatibility workaround between 4.4 and 4.5-
6957 if (d->isProxyWidget())
d->isProxyWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
6958 static_cast<QGraphicsProxyWidget*>(this)->dragEnterEvent(event);
never executed: static_cast<QGraphicsProxyWidget*>(this)->dragEnterEvent(event);
0
6959}
never executed: end of block
0
6960-
6961/*!-
6962 This event handler, for event \a event, can be reimplemented to receive-
6963 drag leave events for this item. Drag leave events are generated as the-
6964 cursor leaves the item's area. Most often you will not need to reimplement-
6965 this function, but it can be useful for resetting state in your item-
6966 (e.g., highlighting).-
6967-
6968 Calling QEvent::ignore() or QEvent::accept() on \a event has no effect.-
6969-
6970 Items do not receive drag and drop events by default; to enable this-
6971 feature, call \c setAcceptDrops(true).-
6972-
6973 The default implementation does nothing.-
6974-
6975 \sa dragEnterEvent(), dropEvent(), dragMoveEvent()-
6976*/-
6977void QGraphicsItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)-
6978{-
6979 Q_D(QGraphicsItem);-
6980 // binary compatibility workaround between 4.4 and 4.5-
6981 if (d->isProxyWidget())
d->isProxyWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
6982 static_cast<QGraphicsProxyWidget*>(this)->dragLeaveEvent(event);
never executed: static_cast<QGraphicsProxyWidget*>(this)->dragLeaveEvent(event);
0
6983}
never executed: end of block
0
6984-
6985/*!-
6986 This event handler, for event \a event, can be reimplemented to receive-
6987 drag move events for this item. Drag move events are generated as the-
6988 cursor moves around inside the item's area. Most often you will not need-
6989 to reimplement this function; it is used to indicate that only parts of-
6990 the item can accept drops.-
6991-
6992 Calling QEvent::ignore() or QEvent::accept() on \a event toggles whether-
6993 or not the item will accept drops at the position from the event. By-
6994 default, \a event is accepted, indicating that the item allows drops at-
6995 the specified position.-
6996-
6997 Items do not receive drag and drop events by default; to enable this-
6998 feature, call \c setAcceptDrops(true).-
6999-
7000 The default implementation does nothing.-
7001-
7002 \sa dropEvent(), dragEnterEvent(), dragLeaveEvent()-
7003*/-
7004void QGraphicsItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event)-
7005{-
7006 Q_D(QGraphicsItem);-
7007 // binary compatibility workaround between 4.4 and 4.5-
7008 if (d->isProxyWidget())
d->isProxyWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
7009 static_cast<QGraphicsProxyWidget*>(this)->dragMoveEvent(event);
never executed: static_cast<QGraphicsProxyWidget*>(this)->dragMoveEvent(event);
0
7010}
never executed: end of block
0
7011-
7012/*!-
7013 This event handler, for event \a event, can be reimplemented to receive-
7014 drop events for this item. Items can only receive drop events if the last-
7015 drag move event was accepted.-
7016-
7017 Calling QEvent::ignore() or QEvent::accept() on \a event has no effect.-
7018-
7019 Items do not receive drag and drop events by default; to enable this-
7020 feature, call \c setAcceptDrops(true).-
7021-
7022 The default implementation does nothing.-
7023-
7024 \sa dragEnterEvent(), dragMoveEvent(), dragLeaveEvent()-
7025*/-
7026void QGraphicsItem::dropEvent(QGraphicsSceneDragDropEvent *event)-
7027{-
7028 Q_D(QGraphicsItem);-
7029 // binary compatibility workaround between 4.4 and 4.5-
7030 if (d->isProxyWidget())
d->isProxyWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
7031 static_cast<QGraphicsProxyWidget*>(this)->dropEvent(event);
never executed: static_cast<QGraphicsProxyWidget*>(this)->dropEvent(event);
0
7032}
never executed: end of block
0
7033-
7034/*!-
7035 This event handler, for event \a event, can be reimplemented to receive-
7036 focus in events for this item. The default implementation calls-
7037 ensureVisible().-
7038-
7039 \sa focusOutEvent(), sceneEvent(), setFocus()-
7040*/-
7041void QGraphicsItem::focusInEvent(QFocusEvent *event)-
7042{-
7043 Q_UNUSED(event);-
7044 update();-
7045}
never executed: end of block
0
7046-
7047/*!-
7048 This event handler, for event \a event, can be reimplemented to receive-
7049 focus out events for this item. The default implementation does nothing.-
7050-
7051 \sa focusInEvent(), sceneEvent(), setFocus()-
7052*/-
7053void QGraphicsItem::focusOutEvent(QFocusEvent *event)-
7054{-
7055 Q_UNUSED(event);-
7056 update();-
7057}
never executed: end of block
0
7058-
7059/*!-
7060 This event handler, for event \a event, can be reimplemented to receive-
7061 hover enter events for this item. The default implementation calls-
7062 update(); otherwise it does nothing.-
7063-
7064 Calling QEvent::ignore() or QEvent::accept() on \a event has no effect.-
7065-
7066 \sa hoverMoveEvent(), hoverLeaveEvent(), sceneEvent(), setAcceptHoverEvents()-
7067*/-
7068void QGraphicsItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)-
7069{-
7070 Q_UNUSED(event);-
7071 update();-
7072}
never executed: end of block
0
7073-
7074/*!-
7075 This event handler, for event \a event, can be reimplemented to receive-
7076 hover move events for this item. The default implementation does nothing.-
7077-
7078 Calling QEvent::ignore() or QEvent::accept() on \a event has no effect.-
7079-
7080 \sa hoverEnterEvent(), hoverLeaveEvent(), sceneEvent(), setAcceptHoverEvents()-
7081*/-
7082void QGraphicsItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)-
7083{-
7084 Q_UNUSED(event);-
7085}
never executed: end of block
0
7086-
7087/*!-
7088 This event handler, for event \a event, can be reimplemented to receive-
7089 hover leave events for this item. The default implementation calls-
7090 update(); otherwise it does nothing.-
7091-
7092 Calling QEvent::ignore() or QEvent::accept() on \a event has no effect.-
7093-
7094 \sa hoverEnterEvent(), hoverMoveEvent(), sceneEvent(), setAcceptHoverEvents()-
7095*/-
7096void QGraphicsItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)-
7097{-
7098 Q_UNUSED(event);-
7099 update();-
7100}
never executed: end of block
0
7101-
7102/*!-
7103 This event handler, for event \a event, can be reimplemented to-
7104 receive key press events for this item. The default implementation-
7105 ignores the event. If you reimplement this handler, the event will by-
7106 default be accepted.-
7107-
7108 Note that key events are only received for items that set the-
7109 ItemIsFocusable flag, and that have keyboard input focus.-
7110-
7111 \sa keyReleaseEvent(), setFocus(), QGraphicsScene::setFocusItem(),-
7112 sceneEvent()-
7113*/-
7114void QGraphicsItem::keyPressEvent(QKeyEvent *event)-
7115{-
7116 event->ignore();-
7117}
never executed: end of block
0
7118-
7119/*!-
7120 This event handler, for event \a event, can be reimplemented to receive-
7121 key release events for this item. The default implementation-
7122 ignores the event. If you reimplement this handler, the event will by-
7123 default be accepted.-
7124-
7125 Note that key events are only received for items that set the-
7126 ItemIsFocusable flag, and that have keyboard input focus.-
7127-
7128 \sa keyPressEvent(), setFocus(), QGraphicsScene::setFocusItem(),-
7129 sceneEvent()-
7130*/-
7131void QGraphicsItem::keyReleaseEvent(QKeyEvent *event)-
7132{-
7133 event->ignore();-
7134}
never executed: end of block
0
7135-
7136/*!-
7137 This event handler, for event \a event, can be reimplemented to-
7138 receive mouse press events for this item. Mouse press events are-
7139 only delivered to items that accept the mouse button that is-
7140 pressed. By default, an item accepts all mouse buttons, but you-
7141 can change this by calling setAcceptedMouseButtons().-
7142-
7143 The mouse press event decides which item should become the mouse-
7144 grabber (see QGraphicsScene::mouseGrabberItem()). If you do not-
7145 reimplement this function, the press event will propagate to any-
7146 topmost item beneath this item, and no other mouse events will be-
7147 delivered to this item.-
7148-
7149 If you do reimplement this function, \a event will by default be-
7150 accepted (see QEvent::accept()), and this item is then the mouse-
7151 grabber. This allows the item to receive future move, release and-
7152 doubleclick events. If you call QEvent::ignore() on \a event, this-
7153 item will lose the mouse grab, and \a event will propagate to any-
7154 topmost item beneath. No further mouse events will be delivered to-
7155 this item unless a new mouse press event is received.-
7156-
7157 The default implementation handles basic item interaction, such as-
7158 selection and moving. If you want to keep the base implementation-
7159 when reimplementing this function, call-
7160 QGraphicsItem::mousePressEvent() in your reimplementation.-
7161-
7162 The event is \l{QEvent::ignore()}d for items that are neither-
7163 \l{QGraphicsItem::ItemIsMovable}{movable} nor-
7164 \l{QGraphicsItem::ItemIsSelectable}{selectable}.-
7165-
7166 \sa mouseMoveEvent(), mouseReleaseEvent(),-
7167 mouseDoubleClickEvent(), sceneEvent()-
7168*/-
7169void QGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event)-
7170{-
7171 if (event->button() == Qt::LeftButton && (flags() & ItemIsSelectable)) {
event->button(...Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
(flags() & ItemIsSelectable)Description
TRUEnever evaluated
FALSEnever evaluated
0
7172 bool multiSelect = (event->modifiers() & Qt::ControlModifier) != 0;-
7173 if (!multiSelect) {
!multiSelectDescription
TRUEnever evaluated
FALSEnever evaluated
0
7174 if (!d_ptr->selected) {
!d_ptr->selectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
7175 if (QGraphicsScene *scene = d_ptr->scene) {
QGraphicsScene...= d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
7176 ++scene->d_func()->selectionChanging;-
7177 scene->clearSelection();-
7178 --scene->d_func()->selectionChanging;-
7179 }
never executed: end of block
0
7180 setSelected(true);-
7181 }
never executed: end of block
0
7182 }
never executed: end of block
0
7183 } else if (!(flags() & ItemIsMovable)) {
never executed: end of block
!(flags() & ItemIsMovable)Description
TRUEnever evaluated
FALSEnever evaluated
0
7184 event->ignore();-
7185 }
never executed: end of block
0
7186 if (d_ptr->isWidget) {
d_ptr->isWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
7187 // Qt::Popup closes when you click outside.-
7188 QGraphicsWidget *w = static_cast<QGraphicsWidget *>(this);-
7189 if ((w->windowFlags() & Qt::Popup) == Qt::Popup) {
(w->windowFlag...) == Qt::PopupDescription
TRUEnever evaluated
FALSEnever evaluated
0
7190 event->accept();-
7191 if (!w->rect().contains(event->pos()))
!w->rect().con...(event->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
7192 w->close();
never executed: w->close();
0
7193 }
never executed: end of block
0
7194 }
never executed: end of block
0
7195}
never executed: end of block
0
7196-
7197/*!-
7198 obsolete-
7199*/-
7200bool _qt_movableAncestorIsSelected(const QGraphicsItem *item)-
7201{-
7202 const QGraphicsItem *parent = item->parentItem();-
7203 return parent && (((parent->flags() & QGraphicsItem::ItemIsMovable) && parent->isSelected()) || _qt_movableAncestorIsSelected(parent));
never executed: return parent && (((parent->flags() & QGraphicsItem::ItemIsMovable) && parent->isSelected()) || _qt_movableAncestorIsSelected(parent));
0
7204}-
7205-
7206bool QGraphicsItemPrivate::movableAncestorIsSelected(const QGraphicsItem *item)-
7207{-
7208 const QGraphicsItem *parent = item->d_ptr->parent;-
7209 return parent && (((parent->flags() & QGraphicsItem::ItemIsMovable) && parent->isSelected()) || _qt_movableAncestorIsSelected(parent));
never executed: return parent && (((parent->flags() & QGraphicsItem::ItemIsMovable) && parent->isSelected()) || _qt_movableAncestorIsSelected(parent));
0
7210}-
7211-
7212/*!-
7213 This event handler, for event \a event, can be reimplemented to-
7214 receive mouse move events for this item. If you do receive this-
7215 event, you can be certain that this item also received a mouse-
7216 press event, and that this item is the current mouse grabber.-
7217-
7218 Calling QEvent::ignore() or QEvent::accept() on \a event has no-
7219 effect.-
7220-
7221 The default implementation handles basic item interaction, such as-
7222 selection and moving. If you want to keep the base implementation-
7223 when reimplementing this function, call-
7224 QGraphicsItem::mouseMoveEvent() in your reimplementation.-
7225-
7226 Please note that mousePressEvent() decides which graphics item it-
7227 is that receives mouse events. See the mousePressEvent()-
7228 description for details.-
7229-
7230 \sa mousePressEvent(), mouseReleaseEvent(),-
7231 mouseDoubleClickEvent(), sceneEvent()-
7232*/-
7233void QGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)-
7234{-
7235 if ((event->buttons() & Qt::LeftButton) && (flags() & ItemIsMovable)) {
(event->button...t::LeftButton)Description
TRUEnever evaluated
FALSEnever evaluated
(flags() & ItemIsMovable)Description
TRUEnever evaluated
FALSEnever evaluated
0
7236 // Determine the list of items that need to be moved.-
7237 QList<QGraphicsItem *> selectedItems;-
7238 QHash<QGraphicsItem *, QPointF> initialPositions;-
7239 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
7240 selectedItems = d_ptr->scene->selectedItems();-
7241 initialPositions = d_ptr->scene->d_func()->movingItemsInitialPositions;-
7242 if (initialPositions.isEmpty()) {
initialPositions.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
7243 foreach (QGraphicsItem *item, selectedItems)-
7244 initialPositions[item] = item->pos();
never executed: initialPositions[item] = item->pos();
0
7245 initialPositions[this] = pos();-
7246 }
never executed: end of block
0
7247 d_ptr->scene->d_func()->movingItemsInitialPositions = initialPositions;-
7248 }
never executed: end of block
0
7249-
7250 // Find the active view.-
7251 QGraphicsView *view = 0;-
7252 if (event->widget())
event->widget()Description
TRUEnever evaluated
FALSEnever evaluated
0
7253 view = qobject_cast<QGraphicsView *>(event->widget()->parentWidget());
never executed: view = qobject_cast<QGraphicsView *>(event->widget()->parentWidget());
0
7254-
7255 // Move all selected items-
7256 int i = 0;-
7257 bool movedMe = false;-
7258 while (i <= selectedItems.size()) {
i <= selectedItems.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
7259 QGraphicsItem *item = 0;-
7260 if (i < selectedItems.size())
i < selectedItems.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
7261 item = selectedItems.at(i);
never executed: item = selectedItems.at(i);
0
7262 else-
7263 item = this;
never executed: item = this;
0
7264 if (item == this) {
item == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
7265 // Slightly clumsy-looking way to ensure that "this" is part-
7266 // of the list of items to move, this is to avoid allocations-
7267 // (appending this item to the list of selected items causes a-
7268 // detach).-
7269 if (movedMe)
movedMeDescription
TRUEnever evaluated
FALSEnever evaluated
0
7270 break;
never executed: break;
0
7271 movedMe = true;-
7272 }
never executed: end of block
0
7273-
7274 if ((item->flags() & ItemIsMovable) && !QGraphicsItemPrivate::movableAncestorIsSelected(item)) {
(item->flags()...ItemIsMovable)Description
TRUEnever evaluated
FALSEnever evaluated
!QGraphicsItem...Selected(item)Description
TRUEnever evaluated
FALSEnever evaluated
0
7275 QPointF currentParentPos;-
7276 QPointF buttonDownParentPos;-
7277 if (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorIgnoresTransformations) {
item->d_ptr->a...ransformationsDescription
TRUEnever evaluated
FALSEnever evaluated
0
7278 // Items whose ancestors ignore transformations need to-
7279 // map screen coordinates to local coordinates, then map-
7280 // those to the parent.-
7281 QTransform viewToItemTransform = (item->deviceTransform(view->viewportTransform())).inverted();-
7282 currentParentPos = mapToParent(viewToItemTransform.map(QPointF(view->mapFromGlobal(event->screenPos()))));-
7283 buttonDownParentPos = mapToParent(viewToItemTransform.map(QPointF(view->mapFromGlobal(event->buttonDownScreenPos(Qt::LeftButton)))));-
7284 } else if (item->flags() & ItemIgnoresTransformations) {
never executed: end of block
item->flags() ...ransformationsDescription
TRUEnever evaluated
FALSEnever evaluated
0
7285 // Root items that ignore transformations need to-
7286 // calculate their diff by mapping viewport coordinates-
7287 // directly to parent coordinates.-
7288 // COMBINE-
7289 QTransform itemTransform;-
7290 if (item->d_ptr->transformData)
item->d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
7291 itemTransform = item->d_ptr->transformData->computedFullTransform();
never executed: itemTransform = item->d_ptr->transformData->computedFullTransform();
0
7292 itemTransform.translate(item->d_ptr->pos.x(), item->d_ptr->pos.y());-
7293 QTransform viewToParentTransform = itemTransform-
7294 * (item->sceneTransform() * view->viewportTransform()).inverted();-
7295 currentParentPos = viewToParentTransform.map(QPointF(view->mapFromGlobal(event->screenPos())));-
7296 buttonDownParentPos = viewToParentTransform.map(QPointF(view->mapFromGlobal(event->buttonDownScreenPos(Qt::LeftButton))));-
7297 } else {
never executed: end of block
0
7298 // All other items simply map from the scene.-
7299 currentParentPos = item->mapToParent(item->mapFromScene(event->scenePos()));-
7300 buttonDownParentPos = item->mapToParent(item->mapFromScene(event->buttonDownScenePos(Qt::LeftButton)));-
7301 }
never executed: end of block
0
7302-
7303 item->setPos(initialPositions.value(item) + currentParentPos - buttonDownParentPos);-
7304-
7305 if (item->flags() & ItemIsSelectable)
item->flags() ...emIsSelectableDescription
TRUEnever evaluated
FALSEnever evaluated
0
7306 item->setSelected(true);
never executed: item->setSelected(true);
0
7307 }
never executed: end of block
0
7308 ++i;-
7309 }
never executed: end of block
0
7310-
7311 } else {
never executed: end of block
0
7312 event->ignore();-
7313 }
never executed: end of block
0
7314}-
7315-
7316/*!-
7317 This event handler, for event \a event, can be reimplemented to-
7318 receive mouse release events for this item.-
7319-
7320 Calling QEvent::ignore() or QEvent::accept() on \a event has no-
7321 effect.-
7322-
7323 The default implementation handles basic item interaction, such as-
7324 selection and moving. If you want to keep the base implementation-
7325 when reimplementing this function, call-
7326 QGraphicsItem::mouseReleaseEvent() in your reimplementation.-
7327-
7328 Please note that mousePressEvent() decides which graphics item it-
7329 is that receives mouse events. See the mousePressEvent()-
7330 description for details.-
7331-
7332 \sa mousePressEvent(), mouseMoveEvent(), mouseDoubleClickEvent(),-
7333 sceneEvent()-
7334*/-
7335void QGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)-
7336{-
7337 if (event->button() == Qt::LeftButton && (flags() & ItemIsSelectable)) {
event->button(...Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
(flags() & ItemIsSelectable)Description
TRUEnever evaluated
FALSEnever evaluated
0
7338 bool multiSelect = (event->modifiers() & Qt::ControlModifier) != 0;-
7339 if (event->scenePos() == event->buttonDownScenePos(Qt::LeftButton)) {
event->scenePo...t::LeftButton)Description
TRUEnever evaluated
FALSEnever evaluated
0
7340 // The item didn't move-
7341 if (multiSelect) {
multiSelectDescription
TRUEnever evaluated
FALSEnever evaluated
0
7342 setSelected(!isSelected());-
7343 } else {
never executed: end of block
0
7344 bool selectionChanged = false;-
7345 if (QGraphicsScene *scene = d_ptr->scene) {
QGraphicsScene...= d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
7346 ++scene->d_func()->selectionChanging;-
7347 // Clear everything but this item. Bypass-
7348 // QGraphicsScene::clearSelection()'s default behavior by-
7349 // temporarily removing this item from the selection list.-
7350 if (d_ptr->selected) {
d_ptr->selectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
7351 scene->d_func()->selectedItems.remove(this);-
7352 foreach (QGraphicsItem *item, scene->d_func()->selectedItems) {-
7353 if (item->isSelected()) {
item->isSelected()Description
TRUEnever evaluated
FALSEnever evaluated
0
7354 selectionChanged = true;-
7355 break;
never executed: break;
0
7356 }-
7357 }
never executed: end of block
0
7358 }
never executed: end of block
0
7359 scene->clearSelection();-
7360 if (d_ptr->selected)
d_ptr->selectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
7361 scene->d_func()->selectedItems.insert(this);
never executed: scene->d_func()->selectedItems.insert(this);
0
7362 --scene->d_func()->selectionChanging;-
7363 if (selectionChanged)
selectionChangedDescription
TRUEnever evaluated
FALSEnever evaluated
0
7364 emit d_ptr->scene->selectionChanged();
never executed: d_ptr->scene->selectionChanged();
0
7365 }
never executed: end of block
0
7366 setSelected(true);-
7367 }
never executed: end of block
0
7368 }-
7369 }
never executed: end of block
0
7370 if (d_ptr->scene && !event->buttons())
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
!event->buttons()Description
TRUEnever evaluated
FALSEnever evaluated
0
7371 d_ptr->scene->d_func()->movingItemsInitialPositions.clear();
never executed: d_ptr->scene->d_func()->movingItemsInitialPositions.clear();
0
7372}
never executed: end of block
0
7373-
7374/*!-
7375 This event handler, for event \a event, can be reimplemented to-
7376 receive mouse doubleclick events for this item.-
7377-
7378 When doubleclicking an item, the item will first receive a mouse-
7379 press event, followed by a release event (i.e., a click), then a-
7380 doubleclick event, and finally a release event.-
7381-
7382 Calling QEvent::ignore() or QEvent::accept() on \a event has no-
7383 effect.-
7384-
7385 The default implementation calls mousePressEvent(). If you want to-
7386 keep the base implementation when reimplementing this function,-
7387 call QGraphicsItem::mouseDoubleClickEvent() in your-
7388 reimplementation.-
7389-
7390 Note that an item will not receive double click events if it is-
7391 neither \l {QGraphicsItem::ItemIsSelectable}{selectable} nor-
7392 \l{QGraphicsItem::ItemIsMovable}{movable} (single mouse clicks are-
7393 ignored in this case, and that stops the generation of double-
7394 clicks).-
7395-
7396 \sa mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(), sceneEvent()-
7397*/-
7398void QGraphicsItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)-
7399{-
7400 mousePressEvent(event);-
7401}
never executed: end of block
0
7402-
7403/*!-
7404 This event handler, for event \a event, can be reimplemented to receive-
7405 wheel events for this item. If you reimplement this function, \a event-
7406 will be accepted by default.-
7407-
7408 If you ignore the event, (i.e., by calling QEvent::ignore(),) it will-
7409 propagate to any item beneath this item. If no items accept the event, it-
7410 will be ignored by the scene, and propagate to the view (e.g., the view's-
7411 vertical scroll bar).-
7412-
7413 The default implementation ignores the event.-
7414-
7415 \sa sceneEvent()-
7416*/-
7417void QGraphicsItem::wheelEvent(QGraphicsSceneWheelEvent *event)-
7418{-
7419 event->ignore();-
7420}
never executed: end of block
0
7421-
7422/*!-
7423 This event handler, for event \a event, can be reimplemented to receive-
7424 input method events for this item. The default implementation ignores the-
7425 event.-
7426-
7427 \sa inputMethodQuery(), sceneEvent()-
7428*/-
7429void QGraphicsItem::inputMethodEvent(QInputMethodEvent *event)-
7430{-
7431 event->ignore();-
7432}
never executed: end of block
0
7433-
7434/*!-
7435 This method is only relevant for input items. It is used by the-
7436 input method to query a set of properties of the item to be able-
7437 to support complex input method operations, such as support for-
7438 surrounding text and reconversions. \a query specifies which-
7439 property is queried.-
7440-
7441 \sa inputMethodEvent(), QInputMethodEvent-
7442*/-
7443QVariant QGraphicsItem::inputMethodQuery(Qt::InputMethodQuery query) const-
7444{-
7445 Q_UNUSED(query);-
7446 return QVariant();
never executed: return QVariant();
0
7447}-
7448-
7449/*!-
7450 Returns the current input method hints of this item.-
7451-
7452 Input method hints are only relevant for input items.-
7453 The hints are used by the input method to indicate how it should operate.-
7454 For example, if the Qt::ImhNumbersOnly flag is set, the input method may change-
7455 its visual components to reflect that only numbers can be entered.-
7456-
7457 The effect may vary between input method implementations.-
7458-
7459 \since 4.6-
7460-
7461 \sa setInputMethodHints(), inputMethodQuery()-
7462*/-
7463Qt::InputMethodHints QGraphicsItem::inputMethodHints() const-
7464{-
7465 Q_D(const QGraphicsItem);-
7466 return d->imHints;
never executed: return d->imHints;
0
7467}-
7468-
7469/*!-
7470 Sets the current input method hints of this item to \a hints.-
7471-
7472 \since 4.6-
7473-
7474 \sa inputMethodHints(), inputMethodQuery()-
7475*/-
7476void QGraphicsItem::setInputMethodHints(Qt::InputMethodHints hints)-
7477{-
7478 Q_D(QGraphicsItem);-
7479 d->imHints = hints;-
7480 if (!hasFocus())
!hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
7481 return;
never executed: return;
0
7482 d->scene->d_func()->updateInputMethodSensitivityInViews();-
7483 QWidget *fw = QApplication::focusWidget();-
7484 if (!fw)
!fwDescription
TRUEnever evaluated
FALSEnever evaluated
0
7485 return;
never executed: return;
0
7486 QGuiApplication::inputMethod()->update(Qt::ImHints);-
7487}
never executed: end of block
0
7488-
7489/*!-
7490 Updates the item's micro focus.-
7491-
7492 \since 4.7-
7493-
7494 \sa QInputMethod-
7495*/-
7496void QGraphicsItem::updateMicroFocus()-
7497{-
7498#if !defined(QT_NO_IM) && defined(Q_DEAD_CODE_FROM_QT4_X11)-
7499 if (QWidget *fw = QApplication::focusWidget()) {-
7500 if (scene()) {-
7501 for (int i = 0 ; i < scene()->views().count() ; ++i) {-
7502 if (scene()->views().at(i) == fw) {-
7503 if (qApp)-
7504 QGuiApplication::inputMethod()->update(Qt::ImQueryAll);-
7505 break;-
7506 }-
7507 }-
7508 }-
7509 }-
7510#endif-
7511}-
7512-
7513/*!-
7514 This virtual function is called by QGraphicsItem to notify custom items-
7515 that some part of the item's state changes. By reimplementing this-
7516 function, you can react to a change, and in some cases (depending on \a-
7517 change), adjustments can be made.-
7518-
7519 \a change is the parameter of the item that is changing. \a value is the-
7520 new value; the type of the value depends on \a change.-
7521-
7522 Example:-
7523-
7524 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 15-
7525-
7526 The default implementation does nothing, and returns \a value.-
7527-
7528 Note: Certain QGraphicsItem functions cannot be called in a-
7529 reimplementation of this function; see the GraphicsItemChange-
7530 documentation for details.-
7531-
7532 \sa GraphicsItemChange-
7533*/-
7534QVariant QGraphicsItem::itemChange(GraphicsItemChange change, const QVariant &value)-
7535{-
7536 Q_UNUSED(change);-
7537 return value;
never executed: return value;
0
7538}-
7539-
7540/*!-
7541 \internal-
7542-
7543 Note: This is provided as a hook to avoid future problems related-
7544 to adding virtual functions.-
7545*/-
7546bool QGraphicsItem::supportsExtension(Extension extension) const-
7547{-
7548 Q_UNUSED(extension);-
7549 return false;
never executed: return false;
0
7550}-
7551-
7552/*!-
7553 \internal-
7554-
7555 Note: This is provided as a hook to avoid future problems related-
7556 to adding virtual functions.-
7557*/-
7558void QGraphicsItem::setExtension(Extension extension, const QVariant &variant)-
7559{-
7560 Q_UNUSED(extension);-
7561 Q_UNUSED(variant);-
7562}
never executed: end of block
0
7563-
7564/*!-
7565 \internal-
7566-
7567 Note: This is provided as a hook to avoid future problems related-
7568 to adding virtual functions.-
7569*/-
7570QVariant QGraphicsItem::extension(const QVariant &variant) const-
7571{-
7572 Q_UNUSED(variant);-
7573 return QVariant();
never executed: return QVariant();
0
7574}-
7575-
7576/*!-
7577 \internal-
7578-
7579 Adds this item to the scene's index. Called in conjunction with-
7580 removeFromIndex() to ensure the index bookkeeping is correct when-
7581 the item's position, transformation or shape changes.-
7582*/-
7583void QGraphicsItem::addToIndex()-
7584{-
7585 if (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren
d_ptr->ancesto...rClipsChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
7586 || d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorContainsChildren) {
d_ptr->ancesto...ntainsChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
7587 // ### add to child index only if applicable-
7588 return;
never executed: return;
0
7589 }-
7590 if (d_ptr->scene)
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
7591 d_ptr->scene->d_func()->index->addItem(this);
never executed: d_ptr->scene->d_func()->index->addItem(this);
0
7592}
never executed: end of block
0
7593-
7594/*!-
7595 \internal-
7596-
7597 Removes this item from the scene's index. Called in conjunction-
7598 with addToIndex() to ensure the index bookkeeping is correct when-
7599 the item's position, transformation or shape changes.-
7600*/-
7601void QGraphicsItem::removeFromIndex()-
7602{-
7603 if (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren
d_ptr->ancesto...rClipsChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
7604 || d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorContainsChildren) {
d_ptr->ancesto...ntainsChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
7605 // ### remove from child index only if applicable-
7606 return;
never executed: return;
0
7607 }-
7608 if (d_ptr->scene)
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
7609 d_ptr->scene->d_func()->index->removeItem(this);
never executed: d_ptr->scene->d_func()->index->removeItem(this);
0
7610}
never executed: end of block
0
7611-
7612/*!-
7613 Prepares the item for a geometry change. Call this function before-
7614 changing the bounding rect of an item to keep QGraphicsScene's index up to-
7615 date.-
7616-
7617 prepareGeometryChange() will call update() if this is necessary.-
7618-
7619 Example:-
7620-
7621 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 16-
7622-
7623 \sa boundingRect()-
7624*/-
7625void QGraphicsItem::prepareGeometryChange()-
7626{-
7627 if (d_ptr->inDestructor)
d_ptr->inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
0
7628 return;
never executed: return;
0
7629 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
7630 d_ptr->scene->d_func()->dirtyGrowingItemsBoundingRect = true;-
7631 d_ptr->geometryChanged = 1;-
7632 d_ptr->paintedViewBoundingRectsNeedRepaint = 1;-
7633 d_ptr->notifyBoundingRectChanged = !d_ptr->inSetPosHelper;-
7634-
7635 QGraphicsScenePrivate *scenePrivate = d_ptr->scene->d_func();-
7636 scenePrivate->index->prepareBoundingRectChange(this);-
7637 scenePrivate->markDirty(this, QRectF(), /*invalidateChildren=*/true, /*force=*/false,-
7638 /*ignoreOpacity=*/ false, /*removingItemFromScene=*/ false,-
7639 /*updateBoundingRect=*/true);-
7640-
7641 // For compatibility reasons, we have to update the item's old geometry-
7642 // if someone is connected to the changed signal or the scene has no views.-
7643 // Note that this has to be done *after* markDirty to ensure that-
7644 // _q_processDirtyItems is called before _q_emitUpdated.-
7645 if (scenePrivate->isSignalConnected(scenePrivate->changedSignalIndex)
scenePrivate->...edSignalIndex)Description
TRUEnever evaluated
FALSEnever evaluated
0
7646 || scenePrivate->views.isEmpty()) {
scenePrivate->views.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
7647 if (d_ptr->hasTranslateOnlySceneTransform()) {
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
7648 d_ptr->scene->update(boundingRect().translated(d_ptr->sceneTransform.dx(),-
7649 d_ptr->sceneTransform.dy()));-
7650 } else {
never executed: end of block
0
7651 d_ptr->scene->update(d_ptr->sceneTransform.mapRect(boundingRect()));-
7652 }
never executed: end of block
0
7653 }-
7654 }
never executed: end of block
0
7655-
7656 d_ptr->markParentDirty(/*updateBoundingRect=*/true);-
7657}
never executed: end of block
0
7658-
7659/*!-
7660 \internal-
7661-
7662 Highlights \a item as selected.-
7663-
7664 NOTE: This function is a duplicate of qt_graphicsItem_highlightSelected() in-
7665 qgraphicssvgitem.cpp!-
7666*/-
7667static void qt_graphicsItem_highlightSelected(-
7668 QGraphicsItem *item, QPainter *painter, const QStyleOptionGraphicsItem *option)-
7669{-
7670 const QRectF murect = painter->transform().mapRect(QRectF(0, 0, 1, 1));-
7671 if (qFuzzyIsNull(qMax(murect.width(), murect.height())))
qFuzzyIsNull(q...ect.height()))Description
TRUEnever evaluated
FALSEnever evaluated
0
7672 return;
never executed: return;
0
7673-
7674 const QRectF mbrect = painter->transform().mapRect(item->boundingRect());-
7675 if (qMin(mbrect.width(), mbrect.height()) < qreal(1.0))
qMin(mbrect.wi...) < qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
7676 return;
never executed: return;
0
7677-
7678 qreal itemPenWidth;-
7679 switch (item->type()) {-
7680 case QGraphicsEllipseItem::Type:
never executed: case QGraphicsEllipseItem::Type:
0
7681 itemPenWidth = static_cast<QGraphicsEllipseItem *>(item)->pen().widthF();-
7682 break;
never executed: break;
0
7683 case QGraphicsPathItem::Type:
never executed: case QGraphicsPathItem::Type:
0
7684 itemPenWidth = static_cast<QGraphicsPathItem *>(item)->pen().widthF();-
7685 break;
never executed: break;
0
7686 case QGraphicsPolygonItem::Type:
never executed: case QGraphicsPolygonItem::Type:
0
7687 itemPenWidth = static_cast<QGraphicsPolygonItem *>(item)->pen().widthF();-
7688 break;
never executed: break;
0
7689 case QGraphicsRectItem::Type:
never executed: case QGraphicsRectItem::Type:
0
7690 itemPenWidth = static_cast<QGraphicsRectItem *>(item)->pen().widthF();-
7691 break;
never executed: break;
0
7692 case QGraphicsSimpleTextItem::Type:
never executed: case QGraphicsSimpleTextItem::Type:
0
7693 itemPenWidth = static_cast<QGraphicsSimpleTextItem *>(item)->pen().widthF();-
7694 break;
never executed: break;
0
7695 case QGraphicsLineItem::Type:
never executed: case QGraphicsLineItem::Type:
0
7696 itemPenWidth = static_cast<QGraphicsLineItem *>(item)->pen().widthF();-
7697 break;
never executed: break;
0
7698 default:
never executed: default:
0
7699 itemPenWidth = 1.0;-
7700 }
never executed: end of block
0
7701 const qreal pad = itemPenWidth / 2;-
7702-
7703 const qreal penWidth = 0; // cosmetic pen-
7704-
7705 const QColor fgcolor = option->palette.windowText().color();-
7706 const QColor bgcolor( // ensure good contrast against fgcolor-
7707 fgcolor.red() > 127 ? 0 : 255,-
7708 fgcolor.green() > 127 ? 0 : 255,-
7709 fgcolor.blue() > 127 ? 0 : 255);-
7710-
7711 painter->setPen(QPen(bgcolor, penWidth, Qt::SolidLine));-
7712 painter->setBrush(Qt::NoBrush);-
7713 painter->drawRect(item->boundingRect().adjusted(pad, pad, -pad, -pad));-
7714-
7715 painter->setPen(QPen(option->palette.windowText(), 0, Qt::DashLine));-
7716 painter->setBrush(Qt::NoBrush);-
7717 painter->drawRect(item->boundingRect().adjusted(pad, pad, -pad, -pad));-
7718}
never executed: end of block
0
7719-
7720/*!-
7721 \class QGraphicsObject-
7722 \brief The QGraphicsObject class provides a base class for all graphics items that-
7723 require signals, slots and properties.-
7724 \since 4.6-
7725 \ingroup graphicsview-api-
7726 \inmodule QtWidgets-
7727-
7728 The class extends a QGraphicsItem with QObject's signal/slot and property mechanisms.-
7729 It maps many of QGraphicsItem's basic setters and getters to properties and adds notification-
7730 signals for many of them.-
7731-
7732 \section1 Parents and Children-
7733-
7734 Each graphics object can be constructed with a parent item. This ensures that the-
7735 item will be destroyed when its parent item is destroyed. Although QGraphicsObject-
7736 inherits from both QObject and QGraphicsItem, you should use the functions provided-
7737 by QGraphicsItem, \e not QObject, to manage the relationships between parent and-
7738 child items.-
7739-
7740 The relationships between items can be explored using the parentItem() and childItems()-
7741 functions. In the hierarchy of items in a scene, the parentObject() and parentWidget()-
7742 functions are the equivalent of the QWidget::parent() and QWidget::parentWidget()-
7743 functions for QWidget subclasses.-
7744-
7745 \sa QGraphicsWidget-
7746*/-
7747-
7748/*!-
7749 Constructs a QGraphicsObject with \a parent.-
7750*/-
7751QGraphicsObject::QGraphicsObject(QGraphicsItem *parent)-
7752 : QGraphicsItem(parent)-
7753{-
7754 QGraphicsItem::d_ptr->isObject = true;-
7755}
never executed: end of block
0
7756-
7757/*!-
7758 \internal-
7759*/-
7760QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent)-
7761 : QGraphicsItem(dd, parent)-
7762{-
7763 QGraphicsItem::d_ptr->isObject = true;-
7764}
never executed: end of block
0
7765-
7766/*!-
7767 Destructor.-
7768*/-
7769QGraphicsObject::~QGraphicsObject()-
7770{-
7771}-
7772-
7773/*!-
7774 \reimp-
7775*/-
7776bool QGraphicsObject::event(QEvent *ev)-
7777{-
7778 if (ev->type() == QEvent::StyleAnimationUpdate) {
ev->type() == ...nimationUpdateDescription
TRUEnever evaluated
FALSEnever evaluated
0
7779 if (isVisible()) {
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
7780 ev->accept();-
7781 update();-
7782 }
never executed: end of block
0
7783 return true;
never executed: return true;
0
7784 }-
7785 return QObject::event(ev);
never executed: return QObject::event(ev);
0
7786}-
7787-
7788#ifndef QT_NO_GESTURES-
7789/*!-
7790 Subscribes the graphics object to the given \a gesture with specific \a flags.-
7791-
7792 \sa ungrabGesture(), QGestureEvent-
7793*/-
7794void QGraphicsObject::grabGesture(Qt::GestureType gesture, Qt::GestureFlags flags)-
7795{-
7796 bool contains = QGraphicsItem::d_ptr->gestureContext.contains(gesture);-
7797 QGraphicsItem::d_ptr->gestureContext.insert(gesture, flags);-
7798 if (!contains && QGraphicsItem::d_ptr->scene)
!containsDescription
TRUEnever evaluated
FALSEnever evaluated
QGraphicsItem::d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
7799 QGraphicsItem::d_ptr->scene->d_func()->grabGesture(this, gesture);
never executed: QGraphicsItem::d_ptr->scene->d_func()->grabGesture(this, gesture);
0
7800}
never executed: end of block
0
7801-
7802/*!-
7803 Unsubscribes the graphics object from the given \a gesture.-
7804-
7805 \sa grabGesture(), QGestureEvent-
7806*/-
7807void QGraphicsObject::ungrabGesture(Qt::GestureType gesture)-
7808{-
7809 if (QGraphicsItem::d_ptr->gestureContext.remove(gesture) && QGraphicsItem::d_ptr->scene)
QGraphicsItem:...emove(gesture)Description
TRUEnever evaluated
FALSEnever evaluated
QGraphicsItem::d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
7810 QGraphicsItem::d_ptr->scene->d_func()->ungrabGesture(this, gesture);
never executed: QGraphicsItem::d_ptr->scene->d_func()->ungrabGesture(this, gesture);
0
7811}
never executed: end of block
0
7812#endif // QT_NO_GESTURES-
7813-
7814/*!-
7815 Updates the item's micro focus. This is slot for convenience.-
7816-
7817 \since 4.7-
7818-
7819 \sa QInputMethod-
7820*/-
7821void QGraphicsObject::updateMicroFocus()-
7822{-
7823 QGraphicsItem::updateMicroFocus();-
7824}
never executed: end of block
0
7825-
7826void QGraphicsItemPrivate::children_append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item)-
7827{-
7828 if (item) {
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
7829 QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(list->object);-
7830 if (QGraphicsItemPrivate::get(graphicsObject)->sendParentChangeNotification) {
QGraphicsItemP...geNotificationDescription
TRUEnever evaluated
FALSEnever evaluated
0
7831 item->setParentItem(graphicsObject);-
7832 } else {
never executed: end of block
0
7833 QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, 0, 0);-
7834 }
never executed: end of block
0
7835 }-
7836}
never executed: end of block
0
7837-
7838int QGraphicsItemPrivate::children_count(QDeclarativeListProperty<QGraphicsObject> *list)-
7839{-
7840 QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object));-
7841 return d->children.count();
never executed: return d->children.count();
0
7842}-
7843-
7844QGraphicsObject *QGraphicsItemPrivate::children_at(QDeclarativeListProperty<QGraphicsObject> *list, int index)-
7845{-
7846 QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object));-
7847 if (index >= 0 && index < d->children.count())
index >= 0Description
TRUEnever evaluated
FALSEnever evaluated
index < d->children.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
7848 return d->children.at(index)->toGraphicsObject();
never executed: return d->children.at(index)->toGraphicsObject();
0
7849 else-
7850 return 0;
never executed: return 0;
0
7851}-
7852-
7853void QGraphicsItemPrivate::children_clear(QDeclarativeListProperty<QGraphicsObject> *list)-
7854{-
7855 QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object));-
7856 int childCount = d->children.count();-
7857 if (d->sendParentChangeNotification) {
d->sendParentC...geNotificationDescription
TRUEnever evaluated
FALSEnever evaluated
0
7858 for (int index = 0; index < childCount; index++)
index < childCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
7859 d->children.at(0)->setParentItem(0);
never executed: d->children.at(0)->setParentItem(0);
0
7860 } else {
never executed: end of block
0
7861 for (int index = 0; index < childCount; index++)
index < childCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
7862 QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(0, 0, 0);
never executed: QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(0, 0, 0);
0
7863 }
never executed: end of block
0
7864}-
7865-
7866/*!-
7867 Returns a list of this item's children.-
7868-
7869 The items are sorted by stacking order. This takes into account both the-
7870 items' insertion order and their Z-values.-
7871-
7872*/-
7873QDeclarativeListProperty<QGraphicsObject> QGraphicsItemPrivate::childrenList()-
7874{-
7875 Q_Q(QGraphicsItem);-
7876 if (isObject) {
isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
7877 QGraphicsObject *that = static_cast<QGraphicsObject *>(q);-
7878 return QDeclarativeListProperty<QGraphicsObject>(that, &children, children_append,
never executed: return QDeclarativeListProperty<QGraphicsObject>(that, &children, children_append, children_count, children_at, children_clear);
0
7879 children_count, children_at, children_clear);
never executed: return QDeclarativeListProperty<QGraphicsObject>(that, &children, children_append, children_count, children_at, children_clear);
0
7880 } else {-
7881 //QGraphicsItem is not supported for this property-
7882 return QDeclarativeListProperty<QGraphicsObject>();
never executed: return QDeclarativeListProperty<QGraphicsObject>();
0
7883 }-
7884}-
7885-
7886/*!-
7887 \internal-
7888 Returns the width of the item-
7889 Reimplemented by QGraphicsWidget-
7890*/-
7891qreal QGraphicsItemPrivate::width() const-
7892{-
7893 return 0;
never executed: return 0;
0
7894}-
7895-
7896/*!-
7897 \internal-
7898 Set the width of the item-
7899 Reimplemented by QGraphicsWidget-
7900*/-
7901void QGraphicsItemPrivate::setWidth(qreal w)-
7902{-
7903 Q_UNUSED(w);-
7904}
never executed: end of block
0
7905-
7906/*!-
7907 \internal-
7908 Reset the width of the item-
7909 Reimplemented by QGraphicsWidget-
7910*/-
7911void QGraphicsItemPrivate::resetWidth()-
7912{-
7913}-
7914-
7915/*!-
7916 \internal-
7917 Returns the height of the item-
7918 Reimplemented by QGraphicsWidget-
7919*/-
7920qreal QGraphicsItemPrivate::height() const-
7921{-
7922 return 0;
never executed: return 0;
0
7923}-
7924-
7925/*!-
7926 \internal-
7927 Set the height of the item-
7928 Reimplemented by QGraphicsWidget-
7929*/-
7930void QGraphicsItemPrivate::setHeight(qreal h)-
7931{-
7932 Q_UNUSED(h);-
7933}
never executed: end of block
0
7934-
7935/*!-
7936 \internal-
7937 Reset the height of the item-
7938 Reimplemented by QGraphicsWidget-
7939*/-
7940void QGraphicsItemPrivate::resetHeight()-
7941{-
7942}-
7943-
7944/*!-
7945 \property QGraphicsObject::children-
7946 \since 4.7-
7947 \internal-
7948*/-
7949-
7950/*!-
7951 \property QGraphicsObject::width-
7952 \since 4.7-
7953 \internal-
7954*/-
7955-
7956/*!-
7957 \property QGraphicsObject::height-
7958 \since 4.7-
7959 \internal-
7960*/-
7961-
7962/*!-
7963 \property QGraphicsObject::parent-
7964 \brief the parent of the item-
7965-
7966 \note The item's parent is set independently of the parent object returned-
7967 by QObject::parent().-
7968-
7969 \sa QGraphicsItem::setParentItem(), QGraphicsItem::parentObject()-
7970*/-
7971-
7972/*!-
7973 \property QGraphicsObject::opacity-
7974 \brief the opacity of the item-
7975-
7976 \sa QGraphicsItem::setOpacity(), QGraphicsItem::opacity()-
7977*/-
7978-
7979/*!-
7980 \fn QGraphicsObject::opacityChanged()-
7981-
7982 This signal gets emitted whenever the opacity of the item changes-
7983-
7984 \sa QGraphicsItem::opacity()-
7985*/-
7986-
7987/*!-
7988 \fn QGraphicsObject::parentChanged()-
7989-
7990 This signal gets emitted whenever the parent of the item changes-
7991*/-
7992-
7993/*!-
7994 \property QGraphicsObject::pos-
7995 \brief the position of the item-
7996-
7997 Describes the items position.-
7998-
7999 \sa QGraphicsItem::setPos(), QGraphicsItem::pos()-
8000*/-
8001-
8002/*!-
8003 \property QGraphicsObject::x-
8004 \brief the x position of the item-
8005-
8006 Describes the items x position.-
8007-
8008 \sa QGraphicsItem::setX(), setPos()-
8009*/-
8010-
8011/*!-
8012 \fn QGraphicsObject::xChanged()-
8013-
8014 This signal gets emitted whenever the x position of the item changes-
8015-
8016 \sa pos()-
8017*/-
8018-
8019/*!-
8020 \property QGraphicsObject::y-
8021 \brief the y position of the item-
8022-
8023 Describes the items y position.-
8024-
8025 \sa QGraphicsItem::setY(), setPos()-
8026*/-
8027-
8028/*!-
8029 \fn QGraphicsObject::yChanged()-
8030-
8031 This signal gets emitted whenever the y position of the item changes.-
8032-
8033 \sa pos()-
8034*/-
8035-
8036/*!-
8037 \property QGraphicsObject::z-
8038 \brief the z value of the item-
8039-
8040 Describes the items z value.-
8041-
8042 \sa QGraphicsItem::setZValue(), zValue()-
8043*/-
8044-
8045/*!-
8046 \fn QGraphicsObject::zChanged()-
8047-
8048 This signal gets emitted whenever the z value of the item changes.-
8049-
8050 \sa pos()-
8051*/-
8052-
8053/*!-
8054 \property QGraphicsObject::rotation-
8055 This property holds the rotation of the item in degrees.-
8056-
8057 This specifies how many degrees to rotate the item around its transformOrigin.-
8058 The default rotation is 0 degrees (i.e. not rotated at all).-
8059*/-
8060-
8061/*!-
8062 \fn QGraphicsObject::rotationChanged()-
8063-
8064 This signal gets emitted whenever the roation of the item changes.-
8065*/-
8066-
8067/*!-
8068 \property QGraphicsObject::scale-
8069 This property holds the scale of the item.-
8070-
8071 A scale of less than 1 means the item will be displayed smaller than-
8072 normal, and a scale of greater than 1 means the item will be-
8073 displayed larger than normal. A negative scale means the item will-
8074 be mirrored.-
8075-
8076 By default, items are displayed at a scale of 1 (i.e. at their-
8077 normal size).-
8078-
8079 Scaling is from the item's transformOrigin.-
8080*/-
8081-
8082/*!-
8083 \fn void QGraphicsObject::scaleChanged()-
8084-
8085 This signal is emitted when the scale of the item changes.-
8086*/-
8087-
8088-
8089/*!-
8090 \property QGraphicsObject::enabled-
8091 \brief whether the item is enabled or not-
8092-
8093 This property is declared in QGraphicsItem.-
8094-
8095 By default, this property is \c true.-
8096-
8097 \sa QGraphicsItem::isEnabled(), QGraphicsItem::setEnabled()-
8098*/-
8099-
8100/*!-
8101 \fn void QGraphicsObject::enabledChanged()-
8102-
8103 This signal gets emitted whenever the item get's enabled or disabled.-
8104-
8105 \sa isEnabled()-
8106*/-
8107-
8108/*!-
8109 \property QGraphicsObject::visible-
8110 \brief whether the item is visible or not-
8111-
8112 This property is declared in QGraphicsItem.-
8113-
8114 By default, this property is \c true.-
8115-
8116 \sa QGraphicsItem::isVisible(), QGraphicsItem::setVisible()-
8117*/-
8118-
8119/*!-
8120 \fn QGraphicsObject::visibleChanged()-
8121-
8122 This signal gets emitted whenever the visibility of the item changes-
8123-
8124 \sa visible-
8125*/-
8126-
8127/*!-
8128 \property QGraphicsObject::transformOriginPoint-
8129 \brief the transformation origin-
8130-
8131 This property sets a specific point in the items coordiante system as the-
8132 origin for scale and rotation.-
8133-
8134 \sa scale, rotation, QGraphicsItem::transformOriginPoint()-
8135*/-
8136-
8137/*!-
8138 \fn void QGraphicsObject::widthChanged()-
8139 \internal-
8140*/-
8141-
8142/*!-
8143 \fn void QGraphicsObject::heightChanged()-
8144 \internal-
8145*/-
8146-
8147/*!-
8148-
8149 \fn QGraphicsObject::childrenChanged()-
8150-
8151 This signal gets emitted whenever the children list changes-
8152 \internal-
8153*/-
8154-
8155/*!-
8156 \property QGraphicsObject::effect-
8157 \since 4.7-
8158 \brief the effect attached to this item-
8159-
8160 \sa QGraphicsItem::setGraphicsEffect(), QGraphicsItem::graphicsEffect()-
8161*/-
8162-
8163/*!-
8164 \class QAbstractGraphicsShapeItem-
8165 \brief The QAbstractGraphicsShapeItem class provides a common base for-
8166 all path items.-
8167 \since 4.2-
8168 \ingroup graphicsview-api-
8169 \inmodule QtWidgets-
8170-
8171 This class does not fully implement an item by itself; in particular, it-
8172 does not implement boundingRect() and paint(), which are inherited by-
8173 QGraphicsItem.-
8174-
8175 You can subclass this item to provide a simple base implementation of-
8176 accessors for the item's pen and brush.-
8177-
8178 \sa QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPathItem,-
8179 QGraphicsPolygonItem, QGraphicsTextItem, QGraphicsLineItem,-
8180 QGraphicsPixmapItem, {Graphics View Framework}-
8181*/-
8182-
8183class QAbstractGraphicsShapeItemPrivate : public QGraphicsItemPrivate-
8184{-
8185 Q_DECLARE_PUBLIC(QAbstractGraphicsShapeItem)-
8186public:-
8187-
8188 QBrush brush;-
8189 QPen pen;-
8190-
8191 // Cached bounding rectangle-
8192 mutable QRectF boundingRect;-
8193};-
8194-
8195/*!-
8196 Constructs a QAbstractGraphicsShapeItem. \a parent is passed to-
8197 QGraphicsItem's constructor.-
8198*/-
8199QAbstractGraphicsShapeItem::QAbstractGraphicsShapeItem(QGraphicsItem *parent)-
8200 : QGraphicsItem(*new QAbstractGraphicsShapeItemPrivate, parent)-
8201{-
8202}
never executed: end of block
0
8203-
8204/*!-
8205 \internal-
8206*/-
8207QAbstractGraphicsShapeItem::QAbstractGraphicsShapeItem(QAbstractGraphicsShapeItemPrivate &dd, QGraphicsItem *parent)-
8208 : QGraphicsItem(dd, parent)-
8209{-
8210}
never executed: end of block
0
8211-
8212/*!-
8213 Destroys a QAbstractGraphicsShapeItem.-
8214*/-
8215QAbstractGraphicsShapeItem::~QAbstractGraphicsShapeItem()-
8216{-
8217}-
8218-
8219/*!-
8220 Returns the item's pen. If no pen has been set, this function returns-
8221 QPen(), a default black solid line pen with 1 width.-
8222*/-
8223QPen QAbstractGraphicsShapeItem::pen() const-
8224{-
8225 Q_D(const QAbstractGraphicsShapeItem);-
8226 return d->pen;
never executed: return d->pen;
0
8227}-
8228-
8229/*!-
8230 Sets the pen for this item to \a pen.-
8231-
8232 The pen is used to draw the item's outline.-
8233-
8234 \sa pen()-
8235*/-
8236void QAbstractGraphicsShapeItem::setPen(const QPen &pen)-
8237{-
8238 Q_D(QAbstractGraphicsShapeItem);-
8239 if (d->pen == pen)
d->pen == penDescription
TRUEnever evaluated
FALSEnever evaluated
0
8240 return;
never executed: return;
0
8241 prepareGeometryChange();-
8242 d->pen = pen;-
8243 d->boundingRect = QRectF();-
8244 update();-
8245}
never executed: end of block
0
8246-
8247/*!-
8248 Returns the item's brush, or an empty brush if no brush has been set.-
8249-
8250 \sa setBrush()-
8251*/-
8252QBrush QAbstractGraphicsShapeItem::brush() const-
8253{-
8254 Q_D(const QAbstractGraphicsShapeItem);-
8255 return d->brush;
never executed: return d->brush;
0
8256}-
8257-
8258/*!-
8259 Sets the item's brush to \a brush.-
8260-
8261 The item's brush is used to fill the item.-
8262-
8263 If you use a brush with a QGradient, the gradient-
8264 is relative to the item's coordinate system.-
8265-
8266 \sa brush()-
8267*/-
8268void QAbstractGraphicsShapeItem::setBrush(const QBrush &brush)-
8269{-
8270 Q_D(QAbstractGraphicsShapeItem);-
8271 if (d->brush == brush)
d->brush == brushDescription
TRUEnever evaluated
FALSEnever evaluated
0
8272 return;
never executed: return;
0
8273 d->brush = brush;-
8274 update();-
8275}
never executed: end of block
0
8276-
8277/*!-
8278 \reimp-
8279*/-
8280bool QAbstractGraphicsShapeItem::isObscuredBy(const QGraphicsItem *item) const-
8281{-
8282 return QGraphicsItem::isObscuredBy(item);
never executed: return QGraphicsItem::isObscuredBy(item);
0
8283}-
8284-
8285/*!-
8286 \reimp-
8287*/-
8288QPainterPath QAbstractGraphicsShapeItem::opaqueArea() const-
8289{-
8290 Q_D(const QAbstractGraphicsShapeItem);-
8291 if (d->brush.isOpaque())
d->brush.isOpaque()Description
TRUEnever evaluated
FALSEnever evaluated
0
8292 return isClipped() ? clipPath() : shape();
never executed: return isClipped() ? clipPath() : shape();
0
8293 return QGraphicsItem::opaqueArea();
never executed: return QGraphicsItem::opaqueArea();
0
8294}-
8295-
8296/*!-
8297 \class QGraphicsPathItem-
8298 \brief The QGraphicsPathItem class provides a path item that you-
8299 can add to a QGraphicsScene.-
8300 \since 4.2-
8301 \ingroup graphicsview-api-
8302 \inmodule QtWidgets-
8303-
8304 To set the item's path, pass a QPainterPath to QGraphicsPathItem's-
8305 constructor, or call the setPath() function. The path() function-
8306 returns the current path.-
8307-
8308 \image graphicsview-pathitem.png-
8309-
8310 QGraphicsPathItem uses the path to provide a reasonable-
8311 implementation of boundingRect(), shape(), and contains(). The-
8312 paint() function draws the path using the item's associated pen-
8313 and brush, which you can set by calling the setPen() and-
8314 setBrush() functions.-
8315-
8316 \sa QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPolygonItem,-
8317 QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics-
8318 View Framework}-
8319*/-
8320-
8321class QGraphicsPathItemPrivate : public QAbstractGraphicsShapeItemPrivate-
8322{-
8323 Q_DECLARE_PUBLIC(QGraphicsPathItem)-
8324public:-
8325 QPainterPath path;-
8326};-
8327-
8328/*!-
8329 Constructs a QGraphicsPath item using \a path as the default path. \a-
8330 parent is passed to QAbstractGraphicsShapeItem's constructor.-
8331-
8332 \sa QGraphicsScene::addItem()-
8333*/-
8334QGraphicsPathItem::QGraphicsPathItem(const QPainterPath &path,-
8335 QGraphicsItem *parent)-
8336 : QAbstractGraphicsShapeItem(*new QGraphicsPathItemPrivate, parent)-
8337{-
8338 if (!path.isEmpty())
!path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
8339 setPath(path);
never executed: setPath(path);
0
8340}
never executed: end of block
0
8341-
8342/*!-
8343 Constructs a QGraphicsPath. \a parent is passed to-
8344 QAbstractGraphicsShapeItem's constructor.-
8345-
8346 \sa QGraphicsScene::addItem()-
8347*/-
8348QGraphicsPathItem::QGraphicsPathItem(QGraphicsItem *parent)-
8349 : QAbstractGraphicsShapeItem(*new QGraphicsPathItemPrivate, parent)-
8350{-
8351}
never executed: end of block
0
8352-
8353/*!-
8354 Destroys the QGraphicsPathItem.-
8355*/-
8356QGraphicsPathItem::~QGraphicsPathItem()-
8357{-
8358}-
8359-
8360/*!-
8361 Returns the item's path as a QPainterPath. If no item has been set, an-
8362 empty QPainterPath is returned.-
8363-
8364 \sa setPath()-
8365*/-
8366QPainterPath QGraphicsPathItem::path() const-
8367{-
8368 Q_D(const QGraphicsPathItem);-
8369 return d->path;
never executed: return d->path;
0
8370}-
8371-
8372/*!-
8373 Sets the item's path to be the given \a path.-
8374-
8375 \sa path()-
8376*/-
8377void QGraphicsPathItem::setPath(const QPainterPath &path)-
8378{-
8379 Q_D(QGraphicsPathItem);-
8380 if (d->path == path)
d->path == pathDescription
TRUEnever evaluated
FALSEnever evaluated
0
8381 return;
never executed: return;
0
8382 prepareGeometryChange();-
8383 d->path = path;-
8384 d->boundingRect = QRectF();-
8385 update();-
8386}
never executed: end of block
0
8387-
8388/*!-
8389 \reimp-
8390*/-
8391QRectF QGraphicsPathItem::boundingRect() const-
8392{-
8393 Q_D(const QGraphicsPathItem);-
8394 if (d->boundingRect.isNull()) {
d->boundingRect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
8395 qreal pw = pen().style() == Qt::NoPen ? qreal(0) : pen().widthF();
pen().style() == Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
0
8396 if (pw == 0.0)
pw == 0.0Description
TRUEnever evaluated
FALSEnever evaluated
0
8397 d->boundingRect = d->path.controlPointRect();
never executed: d->boundingRect = d->path.controlPointRect();
0
8398 else {-
8399 d->boundingRect = shape().controlPointRect();-
8400 }
never executed: end of block
0
8401 }-
8402 return d->boundingRect;
never executed: return d->boundingRect;
0
8403}-
8404-
8405/*!-
8406 \reimp-
8407*/-
8408QPainterPath QGraphicsPathItem::shape() const-
8409{-
8410 Q_D(const QGraphicsPathItem);-
8411 return qt_graphicsItem_shapeFromPath(d->path, d->pen);
never executed: return qt_graphicsItem_shapeFromPath(d->path, d->pen);
0
8412}-
8413-
8414/*!-
8415 \reimp-
8416*/-
8417bool QGraphicsPathItem::contains(const QPointF &point) const-
8418{-
8419 return QAbstractGraphicsShapeItem::contains(point);
never executed: return QAbstractGraphicsShapeItem::contains(point);
0
8420}-
8421-
8422/*!-
8423 \reimp-
8424*/-
8425void QGraphicsPathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,-
8426 QWidget *widget)-
8427{-
8428 Q_D(QGraphicsPathItem);-
8429 Q_UNUSED(widget);-
8430 painter->setPen(d->pen);-
8431 painter->setBrush(d->brush);-
8432 painter->drawPath(d->path);-
8433-
8434 if (option->state & QStyle::State_Selected)
option->state ...State_SelectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
8435 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
8436}
never executed: end of block
0
8437-
8438/*!-
8439 \reimp-
8440*/-
8441bool QGraphicsPathItem::isObscuredBy(const QGraphicsItem *item) const-
8442{-
8443 return QAbstractGraphicsShapeItem::isObscuredBy(item);
never executed: return QAbstractGraphicsShapeItem::isObscuredBy(item);
0
8444}-
8445-
8446/*!-
8447 \reimp-
8448*/-
8449QPainterPath QGraphicsPathItem::opaqueArea() const-
8450{-
8451 return QAbstractGraphicsShapeItem::opaqueArea();
never executed: return QAbstractGraphicsShapeItem::opaqueArea();
0
8452}-
8453-
8454/*!-
8455 \reimp-
8456*/-
8457int QGraphicsPathItem::type() const-
8458{-
8459 return Type;
never executed: return Type;
0
8460}-
8461-
8462/*!-
8463 \internal-
8464*/-
8465bool QGraphicsPathItem::supportsExtension(Extension extension) const-
8466{-
8467 Q_UNUSED(extension);-
8468 return false;
never executed: return false;
0
8469}-
8470-
8471/*!-
8472 \internal-
8473*/-
8474void QGraphicsPathItem::setExtension(Extension extension, const QVariant &variant)-
8475{-
8476 Q_UNUSED(extension);-
8477 Q_UNUSED(variant);-
8478}
never executed: end of block
0
8479-
8480/*!-
8481 \internal-
8482*/-
8483QVariant QGraphicsPathItem::extension(const QVariant &variant) const-
8484{-
8485 Q_UNUSED(variant);-
8486 return QVariant();
never executed: return QVariant();
0
8487}-
8488-
8489/*!-
8490 \class QGraphicsRectItem-
8491 \brief The QGraphicsRectItem class provides a rectangle item that you-
8492 can add to a QGraphicsScene.-
8493 \since 4.2-
8494 \ingroup graphicsview-api-
8495 \inmodule QtWidgets-
8496-
8497 To set the item's rectangle, pass a QRectF to QGraphicsRectItem's-
8498 constructor, or call the setRect() function. The rect() function-
8499 returns the current rectangle.-
8500-
8501 \image graphicsview-rectitem.png-
8502-
8503 QGraphicsRectItem uses the rectangle and the pen width to provide-
8504 a reasonable implementation of boundingRect(), shape(), and-
8505 contains(). The paint() function draws the rectangle using the-
8506 item's associated pen and brush, which you can set by calling the-
8507 setPen() and setBrush() functions.-
8508-
8509 \note The rendering of invalid rectangles, such as those with negative-
8510 widths or heights, is undefined. If you cannot be sure that you are-
8511 using valid rectangles (for example, if you are creating-
8512 rectangles using data from an unreliable source) then you should-
8513 use QRectF::normalized() to create normalized rectangles, and use-
8514 those instead.-
8515-
8516 \sa QGraphicsPathItem, QGraphicsEllipseItem, QGraphicsPolygonItem,-
8517 QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics-
8518 View Framework}-
8519*/-
8520-
8521class QGraphicsRectItemPrivate : public QAbstractGraphicsShapeItemPrivate-
8522{-
8523 Q_DECLARE_PUBLIC(QGraphicsRectItem)-
8524public:-
8525 QRectF rect;-
8526};-
8527-
8528/*!-
8529 Constructs a QGraphicsRectItem, using \a rect as the default rectangle.-
8530 \a parent is passed to QAbstractGraphicsShapeItem's constructor.-
8531-
8532 \sa QGraphicsScene::addItem()-
8533*/-
8534QGraphicsRectItem::QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent)-
8535 : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent)-
8536{-
8537 setRect(rect);-
8538}
never executed: end of block
0
8539-
8540/*!-
8541 \fn QGraphicsRectItem::QGraphicsRectItem(qreal x, qreal y, qreal width, qreal height,-
8542 QGraphicsItem *parent)-
8543-
8544 Constructs a QGraphicsRectItem with a default rectangle defined-
8545 by (\a x, \a y) and the given \a width and \a height.-
8546-
8547 \a parent is passed to QAbstractGraphicsShapeItem's constructor.-
8548-
8549 \sa QGraphicsScene::addItem()-
8550*/-
8551QGraphicsRectItem::QGraphicsRectItem(qreal x, qreal y, qreal w, qreal h,-
8552 QGraphicsItem *parent)-
8553 : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent)-
8554{-
8555 setRect(QRectF(x, y, w, h));-
8556}
never executed: end of block
0
8557-
8558/*!-
8559 Constructs a QGraphicsRectItem. \a parent is passed to-
8560 QAbstractGraphicsShapeItem's constructor.-
8561-
8562 \sa QGraphicsScene::addItem()-
8563*/-
8564QGraphicsRectItem::QGraphicsRectItem(QGraphicsItem *parent)-
8565 : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent)-
8566{-
8567}
never executed: end of block
0
8568-
8569/*!-
8570 Destroys the QGraphicsRectItem.-
8571*/-
8572QGraphicsRectItem::~QGraphicsRectItem()-
8573{-
8574}-
8575-
8576/*!-
8577 Returns the item's rectangle.-
8578-
8579 \sa setRect()-
8580*/-
8581QRectF QGraphicsRectItem::rect() const-
8582{-
8583 Q_D(const QGraphicsRectItem);-
8584 return d->rect;
never executed: return d->rect;
0
8585}-
8586-
8587/*!-
8588 \fn void QGraphicsRectItem::setRect(const QRectF &rectangle)-
8589-
8590 Sets the item's rectangle to be the given \a rectangle.-
8591-
8592 \sa rect()-
8593*/-
8594void QGraphicsRectItem::setRect(const QRectF &rect)-
8595{-
8596 Q_D(QGraphicsRectItem);-
8597 if (d->rect == rect)
d->rect == rectDescription
TRUEnever evaluated
FALSEnever evaluated
0
8598 return;
never executed: return;
0
8599 prepareGeometryChange();-
8600 d->rect = rect;-
8601 d->boundingRect = QRectF();-
8602 update();-
8603}
never executed: end of block
0
8604-
8605/*!-
8606 \fn void QGraphicsRectItem::setRect(qreal x, qreal y, qreal width, qreal height)-
8607 \fn void QGraphicsEllipseItem::setRect(qreal x, qreal y, qreal width, qreal height)-
8608-
8609 Sets the item's rectangle to the rectangle defined by (\a x, \a y)-
8610 and the given \a width and \a height.-
8611-
8612 This convenience function is equivalent to calling \c-
8613 {setRect(QRectF(x, y, width, height))}-
8614-
8615 \sa rect()-
8616*/-
8617-
8618/*!-
8619 \reimp-
8620*/-
8621QRectF QGraphicsRectItem::boundingRect() const-
8622{-
8623 Q_D(const QGraphicsRectItem);-
8624 if (d->boundingRect.isNull()) {
d->boundingRect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
8625 qreal halfpw = pen().style() == Qt::NoPen ? qreal(0) : pen().widthF() / 2;
pen().style() == Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
0
8626 d->boundingRect = d->rect;-
8627 if (halfpw > 0.0)
halfpw > 0.0Description
TRUEnever evaluated
FALSEnever evaluated
0
8628 d->boundingRect.adjust(-halfpw, -halfpw, halfpw, halfpw);
never executed: d->boundingRect.adjust(-halfpw, -halfpw, halfpw, halfpw);
0
8629 }
never executed: end of block
0
8630 return d->boundingRect;
never executed: return d->boundingRect;
0
8631}-
8632-
8633/*!-
8634 \reimp-
8635*/-
8636QPainterPath QGraphicsRectItem::shape() const-
8637{-
8638 Q_D(const QGraphicsRectItem);-
8639 QPainterPath path;-
8640 path.addRect(d->rect);-
8641 return qt_graphicsItem_shapeFromPath(path, d->pen);
never executed: return qt_graphicsItem_shapeFromPath(path, d->pen);
0
8642}-
8643-
8644/*!-
8645 \reimp-
8646*/-
8647bool QGraphicsRectItem::contains(const QPointF &point) const-
8648{-
8649 return QAbstractGraphicsShapeItem::contains(point);
never executed: return QAbstractGraphicsShapeItem::contains(point);
0
8650}-
8651-
8652/*!-
8653 \reimp-
8654*/-
8655void QGraphicsRectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,-
8656 QWidget *widget)-
8657{-
8658 Q_D(QGraphicsRectItem);-
8659 Q_UNUSED(widget);-
8660 painter->setPen(d->pen);-
8661 painter->setBrush(d->brush);-
8662 painter->drawRect(d->rect);-
8663-
8664 if (option->state & QStyle::State_Selected)
option->state ...State_SelectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
8665 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
8666}
never executed: end of block
0
8667-
8668/*!-
8669 \reimp-
8670*/-
8671bool QGraphicsRectItem::isObscuredBy(const QGraphicsItem *item) const-
8672{-
8673 return QAbstractGraphicsShapeItem::isObscuredBy(item);
never executed: return QAbstractGraphicsShapeItem::isObscuredBy(item);
0
8674}-
8675-
8676/*!-
8677 \reimp-
8678*/-
8679QPainterPath QGraphicsRectItem::opaqueArea() const-
8680{-
8681 return QAbstractGraphicsShapeItem::opaqueArea();
never executed: return QAbstractGraphicsShapeItem::opaqueArea();
0
8682}-
8683-
8684/*!-
8685 \reimp-
8686*/-
8687int QGraphicsRectItem::type() const-
8688{-
8689 return Type;
never executed: return Type;
0
8690}-
8691-
8692/*!-
8693 \internal-
8694*/-
8695bool QGraphicsRectItem::supportsExtension(Extension extension) const-
8696{-
8697 Q_UNUSED(extension);-
8698 return false;
never executed: return false;
0
8699}-
8700-
8701/*!-
8702 \internal-
8703*/-
8704void QGraphicsRectItem::setExtension(Extension extension, const QVariant &variant)-
8705{-
8706 Q_UNUSED(extension);-
8707 Q_UNUSED(variant);-
8708}
never executed: end of block
0
8709-
8710/*!-
8711 \internal-
8712*/-
8713QVariant QGraphicsRectItem::extension(const QVariant &variant) const-
8714{-
8715 Q_UNUSED(variant);-
8716 return QVariant();
never executed: return QVariant();
0
8717}-
8718-
8719/*!-
8720 \class QGraphicsEllipseItem-
8721 \brief The QGraphicsEllipseItem class provides an ellipse item that you-
8722 can add to a QGraphicsScene.-
8723 \since 4.2-
8724 \ingroup graphicsview-api-
8725 \inmodule QtWidgets-
8726-
8727 QGraphicsEllipseItem respresents an ellipse with a fill and an outline,-
8728 and you can also use it for ellipse segments (see startAngle(),-
8729 spanAngle()).-
8730-
8731 \table-
8732 \row-
8733 \li \inlineimage graphicsview-ellipseitem.png-
8734 \li \inlineimage graphicsview-ellipseitem-pie.png-
8735 \endtable-
8736-
8737 To set the item's ellipse, pass a QRectF to QGraphicsEllipseItem's-
8738 constructor, or call setRect(). The rect() function returns the-
8739 current ellipse geometry.-
8740-
8741 QGraphicsEllipseItem uses the rect and the pen width to provide a-
8742 reasonable implementation of boundingRect(), shape(), and contains(). The-
8743 paint() function draws the ellipse using the item's associated pen and-
8744 brush, which you can set by calling setPen() and setBrush().-
8745-
8746 \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsPolygonItem,-
8747 QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics-
8748 View Framework}-
8749*/-
8750-
8751class QGraphicsEllipseItemPrivate : public QAbstractGraphicsShapeItemPrivate-
8752{-
8753 Q_DECLARE_PUBLIC(QGraphicsEllipseItem)-
8754public:-
8755 inline QGraphicsEllipseItemPrivate()-
8756 : startAngle(0), spanAngle(360 * 16)-
8757 { }
never executed: end of block
0
8758-
8759 QRectF rect;-
8760 int startAngle;-
8761 int spanAngle;-
8762};-
8763-
8764/*!-
8765 Constructs a QGraphicsEllipseItem using \a rect as the default rectangle.-
8766 \a parent is passed to QAbstractGraphicsShapeItem's constructor.-
8767-
8768 \sa QGraphicsScene::addItem()-
8769*/-
8770QGraphicsEllipseItem::QGraphicsEllipseItem(const QRectF &rect, QGraphicsItem *parent)-
8771 : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent)-
8772{-
8773 setRect(rect);-
8774}
never executed: end of block
0
8775-
8776/*!-
8777 \fn QGraphicsEllipseItem::QGraphicsEllipseItem(qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parent)-
8778 \since 4.3-
8779-
8780 Constructs a QGraphicsEllipseItem using the rectangle defined by (\a x, \a-
8781 y) and the given \a width and \a height, as the default rectangle. \a-
8782 parent is passed to QAbstractGraphicsShapeItem's constructor.-
8783-
8784 \sa QGraphicsScene::addItem()-
8785*/-
8786QGraphicsEllipseItem::QGraphicsEllipseItem(qreal x, qreal y, qreal w, qreal h,-
8787 QGraphicsItem *parent)-
8788 : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent)-
8789{-
8790 setRect(x,y,w,h);-
8791}
never executed: end of block
0
8792-
8793-
8794-
8795/*!-
8796 Constructs a QGraphicsEllipseItem. \a parent is passed to-
8797 QAbstractGraphicsShapeItem's constructor.-
8798-
8799 \sa QGraphicsScene::addItem()-
8800*/-
8801QGraphicsEllipseItem::QGraphicsEllipseItem(QGraphicsItem *parent)-
8802 : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent)-
8803{-
8804}
never executed: end of block
0
8805-
8806/*!-
8807 Destroys the QGraphicsEllipseItem.-
8808*/-
8809QGraphicsEllipseItem::~QGraphicsEllipseItem()-
8810{-
8811}-
8812-
8813/*!-
8814 Returns the item's ellipse geometry as a QRectF.-
8815-
8816 \sa setRect(), QPainter::drawEllipse()-
8817*/-
8818QRectF QGraphicsEllipseItem::rect() const-
8819{-
8820 Q_D(const QGraphicsEllipseItem);-
8821 return d->rect;
never executed: return d->rect;
0
8822}-
8823-
8824/*!-
8825 Sets the item's ellipse geometry to \a rect. The rectangle's left edge-
8826 defines the left edge of the ellipse, and the rectangle's top edge-
8827 describes the top of the ellipse. The height and width of the rectangle-
8828 describe the height and width of the ellipse.-
8829-
8830 \sa rect(), QPainter::drawEllipse()-
8831*/-
8832void QGraphicsEllipseItem::setRect(const QRectF &rect)-
8833{-
8834 Q_D(QGraphicsEllipseItem);-
8835 if (d->rect == rect)
d->rect == rectDescription
TRUEnever evaluated
FALSEnever evaluated
0
8836 return;
never executed: return;
0
8837 prepareGeometryChange();-
8838 d->rect = rect;-
8839 d->boundingRect = QRectF();-
8840 update();-
8841}
never executed: end of block
0
8842-
8843/*!-
8844 Returns the start angle for an ellipse segment in 16ths of a degree. This-
8845 angle is used together with spanAngle() for representing an ellipse-
8846 segment (a pie). By default, the start angle is 0.-
8847-
8848 \sa setStartAngle(), spanAngle()-
8849*/-
8850int QGraphicsEllipseItem::startAngle() const-
8851{-
8852 Q_D(const QGraphicsEllipseItem);-
8853 return d->startAngle;
never executed: return d->startAngle;
0
8854}-
8855-
8856/*!-
8857 Sets the start angle for an ellipse segment to \a angle, which is in 16ths-
8858 of a degree. This angle is used together with spanAngle() for representing-
8859 an ellipse segment (a pie). By default, the start angle is 0.-
8860-
8861 \sa startAngle(), setSpanAngle(), QPainter::drawPie()-
8862*/-
8863void QGraphicsEllipseItem::setStartAngle(int angle)-
8864{-
8865 Q_D(QGraphicsEllipseItem);-
8866 if (angle != d->startAngle) {
angle != d->startAngleDescription
TRUEnever evaluated
FALSEnever evaluated
0
8867 prepareGeometryChange();-
8868 d->boundingRect = QRectF();-
8869 d->startAngle = angle;-
8870 update();-
8871 }
never executed: end of block
0
8872}
never executed: end of block
0
8873-
8874/*!-
8875 Returns the span angle of an ellipse segment in 16ths of a degree. This-
8876 angle is used together with startAngle() for representing an ellipse-
8877 segment (a pie). By default, this function returns 5760 (360 * 16, a full-
8878 ellipse).-
8879-
8880 \sa setSpanAngle(), startAngle()-
8881*/-
8882int QGraphicsEllipseItem::spanAngle() const-
8883{-
8884 Q_D(const QGraphicsEllipseItem);-
8885 return d->spanAngle;
never executed: return d->spanAngle;
0
8886}-
8887-
8888/*!-
8889 Sets the span angle for an ellipse segment to \a angle, which is in 16ths-
8890 of a degree. This angle is used together with startAngle() to represent an-
8891 ellipse segment (a pie). By default, the span angle is 5760 (360 * 16, a-
8892 full ellipse).-
8893-
8894 \sa spanAngle(), setStartAngle(), QPainter::drawPie()-
8895*/-
8896void QGraphicsEllipseItem::setSpanAngle(int angle)-
8897{-
8898 Q_D(QGraphicsEllipseItem);-
8899 if (angle != d->spanAngle) {
angle != d->spanAngleDescription
TRUEnever evaluated
FALSEnever evaluated
0
8900 prepareGeometryChange();-
8901 d->boundingRect = QRectF();-
8902 d->spanAngle = angle;-
8903 update();-
8904 }
never executed: end of block
0
8905}
never executed: end of block
0
8906-
8907/*!-
8908 \reimp-
8909*/-
8910QRectF QGraphicsEllipseItem::boundingRect() const-
8911{-
8912 Q_D(const QGraphicsEllipseItem);-
8913 if (d->boundingRect.isNull()) {
d->boundingRect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
8914 qreal pw = pen().style() == Qt::NoPen ? qreal(0) : pen().widthF();
pen().style() == Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
0
8915 if (pw == 0.0 && d->spanAngle == 360 * 16)
pw == 0.0Description
TRUEnever evaluated
FALSEnever evaluated
d->spanAngle == 360 * 16Description
TRUEnever evaluated
FALSEnever evaluated
0
8916 d->boundingRect = d->rect;
never executed: d->boundingRect = d->rect;
0
8917 else-
8918 d->boundingRect = shape().controlPointRect();
never executed: d->boundingRect = shape().controlPointRect();
0
8919 }-
8920 return d->boundingRect;
never executed: return d->boundingRect;
0
8921}-
8922-
8923/*!-
8924 \reimp-
8925*/-
8926QPainterPath QGraphicsEllipseItem::shape() const-
8927{-
8928 Q_D(const QGraphicsEllipseItem);-
8929 QPainterPath path;-
8930 if (d->rect.isNull())
d->rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
8931 return path;
never executed: return path;
0
8932 if (d->spanAngle != 360 * 16) {
d->spanAngle != 360 * 16Description
TRUEnever evaluated
FALSEnever evaluated
0
8933 path.moveTo(d->rect.center());-
8934 path.arcTo(d->rect, d->startAngle / 16.0, d->spanAngle / 16.0);-
8935 } else {
never executed: end of block
0
8936 path.addEllipse(d->rect);-
8937 }
never executed: end of block
0
8938-
8939 return qt_graphicsItem_shapeFromPath(path, d->pen);
never executed: return qt_graphicsItem_shapeFromPath(path, d->pen);
0
8940}-
8941-
8942/*!-
8943 \reimp-
8944*/-
8945bool QGraphicsEllipseItem::contains(const QPointF &point) const-
8946{-
8947 return QAbstractGraphicsShapeItem::contains(point);
never executed: return QAbstractGraphicsShapeItem::contains(point);
0
8948}-
8949-
8950/*!-
8951 \reimp-
8952*/-
8953void QGraphicsEllipseItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,-
8954 QWidget *widget)-
8955{-
8956 Q_D(QGraphicsEllipseItem);-
8957 Q_UNUSED(widget);-
8958 painter->setPen(d->pen);-
8959 painter->setBrush(d->brush);-
8960 if ((d->spanAngle != 0) && (qAbs(d->spanAngle) % (360 * 16) == 0))
(d->spanAngle != 0)Description
TRUEnever evaluated
FALSEnever evaluated
(qAbs(d->spanA...60 * 16) == 0)Description
TRUEnever evaluated
FALSEnever evaluated
0
8961 painter->drawEllipse(d->rect);
never executed: painter->drawEllipse(d->rect);
0
8962 else-
8963 painter->drawPie(d->rect, d->startAngle, d->spanAngle);
never executed: painter->drawPie(d->rect, d->startAngle, d->spanAngle);
0
8964-
8965 if (option->state & QStyle::State_Selected)
option->state ...State_SelectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
8966 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
8967}
never executed: end of block
0
8968-
8969/*!-
8970 \reimp-
8971*/-
8972bool QGraphicsEllipseItem::isObscuredBy(const QGraphicsItem *item) const-
8973{-
8974 return QAbstractGraphicsShapeItem::isObscuredBy(item);
never executed: return QAbstractGraphicsShapeItem::isObscuredBy(item);
0
8975}-
8976-
8977/*!-
8978 \reimp-
8979*/-
8980QPainterPath QGraphicsEllipseItem::opaqueArea() const-
8981{-
8982 return QAbstractGraphicsShapeItem::opaqueArea();
never executed: return QAbstractGraphicsShapeItem::opaqueArea();
0
8983}-
8984-
8985/*!-
8986 \reimp-
8987*/-
8988int QGraphicsEllipseItem::type() const-
8989{-
8990 return Type;
never executed: return Type;
0
8991}-
8992-
8993-
8994/*!-
8995 \internal-
8996*/-
8997bool QGraphicsEllipseItem::supportsExtension(Extension extension) const-
8998{-
8999 Q_UNUSED(extension);-
9000 return false;
never executed: return false;
0
9001}-
9002-
9003/*!-
9004 \internal-
9005*/-
9006void QGraphicsEllipseItem::setExtension(Extension extension, const QVariant &variant)-
9007{-
9008 Q_UNUSED(extension);-
9009 Q_UNUSED(variant);-
9010}
never executed: end of block
0
9011-
9012/*!-
9013 \internal-
9014*/-
9015QVariant QGraphicsEllipseItem::extension(const QVariant &variant) const-
9016{-
9017 Q_UNUSED(variant);-
9018 return QVariant();
never executed: return QVariant();
0
9019}-
9020-
9021/*!-
9022 \class QGraphicsPolygonItem-
9023 \brief The QGraphicsPolygonItem class provides a polygon item that you-
9024 can add to a QGraphicsScene.-
9025 \since 4.2-
9026 \ingroup graphicsview-api-
9027 \inmodule QtWidgets-
9028-
9029 To set the item's polygon, pass a QPolygonF to-
9030 QGraphicsPolygonItem's constructor, or call the setPolygon()-
9031 function. The polygon() function returns the current polygon.-
9032-
9033 \image graphicsview-polygonitem.png-
9034-
9035 QGraphicsPolygonItem uses the polygon and the pen width to provide-
9036 a reasonable implementation of boundingRect(), shape(), and-
9037 contains(). The paint() function draws the polygon using the-
9038 item's associated pen and brush, which you can set by calling the-
9039 setPen() and setBrush() functions.-
9040-
9041 \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem,-
9042 QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics-
9043 View Framework}-
9044*/-
9045-
9046class QGraphicsPolygonItemPrivate : public QAbstractGraphicsShapeItemPrivate-
9047{-
9048 Q_DECLARE_PUBLIC(QGraphicsPolygonItem)-
9049public:-
9050 inline QGraphicsPolygonItemPrivate()-
9051 : fillRule(Qt::OddEvenFill)-
9052 { }
never executed: end of block
0
9053-
9054 QPolygonF polygon;-
9055 Qt::FillRule fillRule;-
9056};-
9057-
9058/*!-
9059 Constructs a QGraphicsPolygonItem with \a polygon as the default-
9060 polygon. \a parent is passed to QAbstractGraphicsShapeItem's constructor.-
9061-
9062 \sa QGraphicsScene::addItem()-
9063*/-
9064QGraphicsPolygonItem::QGraphicsPolygonItem(const QPolygonF &polygon, QGraphicsItem *parent)-
9065 : QAbstractGraphicsShapeItem(*new QGraphicsPolygonItemPrivate, parent)-
9066{-
9067 setPolygon(polygon);-
9068}
never executed: end of block
0
9069-
9070/*!-
9071 Constructs a QGraphicsPolygonItem. \a parent is passed to-
9072 QAbstractGraphicsShapeItem's constructor.-
9073-
9074 \sa QGraphicsScene::addItem()-
9075*/-
9076QGraphicsPolygonItem::QGraphicsPolygonItem(QGraphicsItem *parent)-
9077 : QAbstractGraphicsShapeItem(*new QGraphicsPolygonItemPrivate, parent)-
9078{-
9079}
never executed: end of block
0
9080-
9081/*!-
9082 Destroys the QGraphicsPolygonItem.-
9083*/-
9084QGraphicsPolygonItem::~QGraphicsPolygonItem()-
9085{-
9086}-
9087-
9088/*!-
9089 Returns the item's polygon, or an empty polygon if no polygon-
9090 has been set.-
9091-
9092 \sa setPolygon()-
9093*/-
9094QPolygonF QGraphicsPolygonItem::polygon() const-
9095{-
9096 Q_D(const QGraphicsPolygonItem);-
9097 return d->polygon;
never executed: return d->polygon;
0
9098}-
9099-
9100/*!-
9101 Sets the item's polygon to be the given \a polygon.-
9102-
9103 \sa polygon()-
9104*/-
9105void QGraphicsPolygonItem::setPolygon(const QPolygonF &polygon)-
9106{-
9107 Q_D(QGraphicsPolygonItem);-
9108 if (d->polygon == polygon)
d->polygon == polygonDescription
TRUEnever evaluated
FALSEnever evaluated
0
9109 return;
never executed: return;
0
9110 prepareGeometryChange();-
9111 d->polygon = polygon;-
9112 d->boundingRect = QRectF();-
9113 update();-
9114}
never executed: end of block
0
9115-
9116/*!-
9117 Returns the fill rule of the polygon. The default fill rule is-
9118 Qt::OddEvenFill.-
9119-
9120 \sa setFillRule(), QPainterPath::fillRule(), QPainter::drawPolygon()-
9121*/-
9122Qt::FillRule QGraphicsPolygonItem::fillRule() const-
9123{-
9124 Q_D(const QGraphicsPolygonItem);-
9125 return d->fillRule;
never executed: return d->fillRule;
0
9126}-
9127-
9128/*!-
9129 Sets the fill rule of the polygon to \a rule. The default fill rule is-
9130 Qt::OddEvenFill.-
9131-
9132 \sa fillRule(), QPainterPath::fillRule(), QPainter::drawPolygon()-
9133*/-
9134void QGraphicsPolygonItem::setFillRule(Qt::FillRule rule)-
9135{-
9136 Q_D(QGraphicsPolygonItem);-
9137 if (rule != d->fillRule) {
rule != d->fillRuleDescription
TRUEnever evaluated
FALSEnever evaluated
0
9138 d->fillRule = rule;-
9139 update();-
9140 }
never executed: end of block
0
9141}
never executed: end of block
0
9142-
9143/*!-
9144 \reimp-
9145*/-
9146QRectF QGraphicsPolygonItem::boundingRect() const-
9147{-
9148 Q_D(const QGraphicsPolygonItem);-
9149 if (d->boundingRect.isNull()) {
d->boundingRect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
9150 qreal pw = pen().style() == Qt::NoPen ? qreal(0) : pen().widthF();
pen().style() == Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
0
9151 if (pw == 0.0)
pw == 0.0Description
TRUEnever evaluated
FALSEnever evaluated
0
9152 d->boundingRect = d->polygon.boundingRect();
never executed: d->boundingRect = d->polygon.boundingRect();
0
9153 else-
9154 d->boundingRect = shape().controlPointRect();
never executed: d->boundingRect = shape().controlPointRect();
0
9155 }-
9156 return d->boundingRect;
never executed: return d->boundingRect;
0
9157}-
9158-
9159/*!-
9160 \reimp-
9161*/-
9162QPainterPath QGraphicsPolygonItem::shape() const-
9163{-
9164 Q_D(const QGraphicsPolygonItem);-
9165 QPainterPath path;-
9166 path.addPolygon(d->polygon);-
9167 return qt_graphicsItem_shapeFromPath(path, d->pen);
never executed: return qt_graphicsItem_shapeFromPath(path, d->pen);
0
9168}-
9169-
9170/*!-
9171 \reimp-
9172*/-
9173bool QGraphicsPolygonItem::contains(const QPointF &point) const-
9174{-
9175 return QAbstractGraphicsShapeItem::contains(point);
never executed: return QAbstractGraphicsShapeItem::contains(point);
0
9176}-
9177-
9178/*!-
9179 \reimp-
9180*/-
9181void QGraphicsPolygonItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)-
9182{-
9183 Q_D(QGraphicsPolygonItem);-
9184 Q_UNUSED(widget);-
9185 painter->setPen(d->pen);-
9186 painter->setBrush(d->brush);-
9187 painter->drawPolygon(d->polygon, d->fillRule);-
9188-
9189 if (option->state & QStyle::State_Selected)
option->state ...State_SelectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
9190 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
9191}
never executed: end of block
0
9192-
9193/*!-
9194 \reimp-
9195*/-
9196bool QGraphicsPolygonItem::isObscuredBy(const QGraphicsItem *item) const-
9197{-
9198 return QAbstractGraphicsShapeItem::isObscuredBy(item);
never executed: return QAbstractGraphicsShapeItem::isObscuredBy(item);
0
9199}-
9200-
9201/*!-
9202 \reimp-
9203*/-
9204QPainterPath QGraphicsPolygonItem::opaqueArea() const-
9205{-
9206 return QAbstractGraphicsShapeItem::opaqueArea();
never executed: return QAbstractGraphicsShapeItem::opaqueArea();
0
9207}-
9208-
9209/*!-
9210 \reimp-
9211*/-
9212int QGraphicsPolygonItem::type() const-
9213{-
9214 return Type;
never executed: return Type;
0
9215}-
9216-
9217/*!-
9218 \internal-
9219*/-
9220bool QGraphicsPolygonItem::supportsExtension(Extension extension) const-
9221{-
9222 Q_UNUSED(extension);-
9223 return false;
never executed: return false;
0
9224}-
9225-
9226/*!-
9227 \internal-
9228*/-
9229void QGraphicsPolygonItem::setExtension(Extension extension, const QVariant &variant)-
9230{-
9231 Q_UNUSED(extension);-
9232 Q_UNUSED(variant);-
9233}
never executed: end of block
0
9234-
9235/*!-
9236 \internal-
9237*/-
9238QVariant QGraphicsPolygonItem::extension(const QVariant &variant) const-
9239{-
9240 Q_UNUSED(variant);-
9241 return QVariant();
never executed: return QVariant();
0
9242}-
9243-
9244/*!-
9245 \class QGraphicsLineItem-
9246 \brief The QGraphicsLineItem class provides a line item that you can add to a-
9247 QGraphicsScene.-
9248 \since 4.2-
9249 \ingroup graphicsview-api-
9250 \inmodule QtWidgets-
9251-
9252 To set the item's line, pass a QLineF to QGraphicsLineItem's-
9253 constructor, or call the setLine() function. The line() function-
9254 returns the current line. By default the line is black with a-
9255 width of 0, but you can change this by calling setPen().-
9256-
9257 \image graphicsview-lineitem.png-
9258-
9259 QGraphicsLineItem uses the line and the pen width to provide a reasonable-
9260 implementation of boundingRect(), shape(), and contains(). The paint()-
9261 function draws the line using the item's associated pen.-
9262-
9263 \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem,-
9264 QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsPixmapItem,-
9265 {Graphics View Framework}-
9266*/-
9267-
9268class QGraphicsLineItemPrivate : public QGraphicsItemPrivate-
9269{-
9270 Q_DECLARE_PUBLIC(QGraphicsLineItem)-
9271public:-
9272 QLineF line;-
9273 QPen pen;-
9274};-
9275-
9276/*!-
9277 Constructs a QGraphicsLineItem, using \a line as the default line. \a-
9278 parent is passed to QGraphicsItem's constructor.-
9279-
9280 \sa QGraphicsScene::addItem()-
9281*/-
9282QGraphicsLineItem::QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent)-
9283 : QGraphicsItem(*new QGraphicsLineItemPrivate, parent)-
9284{-
9285 setLine(line);-
9286}
never executed: end of block
0
9287-
9288/*!-
9289 Constructs a QGraphicsLineItem, using the line between (\a x1, \a y1) and-
9290 (\a x2, \a y2) as the default line. \a parent is passed to-
9291 QGraphicsItem's constructor.-
9292-
9293 \sa QGraphicsScene::addItem()-
9294*/-
9295QGraphicsLineItem::QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent)-
9296 : QGraphicsItem(*new QGraphicsLineItemPrivate, parent)-
9297{-
9298 setLine(x1, y1, x2, y2);-
9299}
never executed: end of block
0
9300-
9301-
9302-
9303/*!-
9304 Constructs a QGraphicsLineItem. \a parent is passed to QGraphicsItem's-
9305 constructor.-
9306-
9307 \sa QGraphicsScene::addItem()-
9308*/-
9309QGraphicsLineItem::QGraphicsLineItem(QGraphicsItem *parent)-
9310 : QGraphicsItem(*new QGraphicsLineItemPrivate, parent)-
9311{-
9312}
never executed: end of block
0
9313-
9314/*!-
9315 Destroys the QGraphicsLineItem.-
9316*/-
9317QGraphicsLineItem::~QGraphicsLineItem()-
9318{-
9319}-
9320-
9321/*!-
9322 Returns the item's pen, or a black solid 0-width pen if no pen has-
9323 been set.-
9324-
9325 \sa setPen()-
9326*/-
9327QPen QGraphicsLineItem::pen() const-
9328{-
9329 Q_D(const QGraphicsLineItem);-
9330 return d->pen;
never executed: return d->pen;
0
9331}-
9332-
9333/*!-
9334 Sets the item's pen to \a pen. If no pen is set, the line will be painted-
9335 using a black solid 0-width pen.-
9336-
9337 \sa pen()-
9338*/-
9339void QGraphicsLineItem::setPen(const QPen &pen)-
9340{-
9341 Q_D(QGraphicsLineItem);-
9342 if (d->pen == pen)
d->pen == penDescription
TRUEnever evaluated
FALSEnever evaluated
0
9343 return;
never executed: return;
0
9344 prepareGeometryChange();-
9345 d->pen = pen;-
9346 update();-
9347}
never executed: end of block
0
9348-
9349/*!-
9350 Returns the item's line, or a null line if no line has been set.-
9351-
9352 \sa setLine()-
9353*/-
9354QLineF QGraphicsLineItem::line() const-
9355{-
9356 Q_D(const QGraphicsLineItem);-
9357 return d->line;
never executed: return d->line;
0
9358}-
9359-
9360/*!-
9361 Sets the item's line to be the given \a line.-
9362-
9363 \sa line()-
9364*/-
9365void QGraphicsLineItem::setLine(const QLineF &line)-
9366{-
9367 Q_D(QGraphicsLineItem);-
9368 if (d->line == line)
d->line == lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
9369 return;
never executed: return;
0
9370 prepareGeometryChange();-
9371 d->line = line;-
9372 update();-
9373}
never executed: end of block
0
9374-
9375/*!-
9376 \fn void QGraphicsLineItem::setLine(qreal x1, qreal y1, qreal x2, qreal y2)-
9377 \overload-
9378-
9379 Sets the item's line to be the line between (\a x1, \a y1) and (\a-
9380 x2, \a y2).-
9381-
9382 This is the same as calling \c {setLine(QLineF(x1, y1, x2, y2))}.-
9383*/-
9384-
9385/*!-
9386 \reimp-
9387*/-
9388QRectF QGraphicsLineItem::boundingRect() const-
9389{-
9390 Q_D(const QGraphicsLineItem);-
9391 if (d->pen.widthF() == 0.0) {
d->pen.widthF() == 0.0Description
TRUEnever evaluated
FALSEnever evaluated
0
9392 const qreal x1 = d->line.p1().x();-
9393 const qreal x2 = d->line.p2().x();-
9394 const qreal y1 = d->line.p1().y();-
9395 const qreal y2 = d->line.p2().y();-
9396 qreal lx = qMin(x1, x2);-
9397 qreal rx = qMax(x1, x2);-
9398 qreal ty = qMin(y1, y2);-
9399 qreal by = qMax(y1, y2);-
9400 return QRectF(lx, ty, rx - lx, by - ty);
never executed: return QRectF(lx, ty, rx - lx, by - ty);
0
9401 }-
9402 return shape().controlPointRect();
never executed: return shape().controlPointRect();
0
9403}-
9404-
9405/*!-
9406 \reimp-
9407*/-
9408QPainterPath QGraphicsLineItem::shape() const-
9409{-
9410 Q_D(const QGraphicsLineItem);-
9411 QPainterPath path;-
9412 if (d->line == QLineF())
d->line == QLineF()Description
TRUEnever evaluated
FALSEnever evaluated
0
9413 return path;
never executed: return path;
0
9414-
9415 path.moveTo(d->line.p1());-
9416 path.lineTo(d->line.p2());-
9417 return qt_graphicsItem_shapeFromPath(path, d->pen);
never executed: return qt_graphicsItem_shapeFromPath(path, d->pen);
0
9418}-
9419-
9420/*!-
9421 \reimp-
9422*/-
9423bool QGraphicsLineItem::contains(const QPointF &point) const-
9424{-
9425 return QGraphicsItem::contains(point);
never executed: return QGraphicsItem::contains(point);
0
9426}-
9427-
9428/*!-
9429 \reimp-
9430*/-
9431void QGraphicsLineItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)-
9432{-
9433 Q_D(QGraphicsLineItem);-
9434 Q_UNUSED(widget);-
9435 painter->setPen(d->pen);-
9436 painter->drawLine(d->line);-
9437-
9438 if (option->state & QStyle::State_Selected)
option->state ...State_SelectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
9439 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
9440}
never executed: end of block
0
9441-
9442/*!-
9443 \reimp-
9444*/-
9445bool QGraphicsLineItem::isObscuredBy(const QGraphicsItem *item) const-
9446{-
9447 return QGraphicsItem::isObscuredBy(item);
never executed: return QGraphicsItem::isObscuredBy(item);
0
9448}-
9449-
9450/*!-
9451 \reimp-
9452*/-
9453QPainterPath QGraphicsLineItem::opaqueArea() const-
9454{-
9455 return QGraphicsItem::opaqueArea();
never executed: return QGraphicsItem::opaqueArea();
0
9456}-
9457-
9458/*!-
9459 \reimp-
9460*/-
9461int QGraphicsLineItem::type() const-
9462{-
9463 return Type;
never executed: return Type;
0
9464}-
9465-
9466/*!-
9467 \internal-
9468*/-
9469bool QGraphicsLineItem::supportsExtension(Extension extension) const-
9470{-
9471 Q_UNUSED(extension);-
9472 return false;
never executed: return false;
0
9473}-
9474-
9475/*!-
9476 \internal-
9477*/-
9478void QGraphicsLineItem::setExtension(Extension extension, const QVariant &variant)-
9479{-
9480 Q_UNUSED(extension);-
9481 Q_UNUSED(variant);-
9482}
never executed: end of block
0
9483-
9484/*!-
9485 \internal-
9486*/-
9487QVariant QGraphicsLineItem::extension(const QVariant &variant) const-
9488{-
9489 Q_UNUSED(variant);-
9490 return QVariant();
never executed: return QVariant();
0
9491}-
9492-
9493/*!-
9494 \class QGraphicsPixmapItem-
9495 \brief The QGraphicsPixmapItem class provides a pixmap item that you can add to-
9496 a QGraphicsScene.-
9497 \since 4.2-
9498 \ingroup graphicsview-api-
9499 \inmodule QtWidgets-
9500-
9501 To set the item's pixmap, pass a QPixmap to QGraphicsPixmapItem's-
9502 constructor, or call the setPixmap() function. The pixmap()-
9503 function returns the current pixmap.-
9504-
9505 QGraphicsPixmapItem uses pixmap's optional alpha mask to provide a-
9506 reasonable implementation of boundingRect(), shape(), and contains().-
9507-
9508 \image graphicsview-pixmapitem.png-
9509-
9510 The pixmap is drawn at the item's (0, 0) coordinate, as returned by-
9511 offset(). You can change the drawing offset by calling setOffset().-
9512-
9513 You can set the pixmap's transformation mode by calling-
9514 setTransformationMode(). By default, Qt::FastTransformation is used, which-
9515 provides fast, non-smooth scaling. Qt::SmoothTransformation enables-
9516 QPainter::SmoothPixmapTransform on the painter, and the quality depends on-
9517 the platform and viewport. The result is usually not as good as calling-
9518 QPixmap::scale() directly. Call transformationMode() to get the current-
9519 transformation mode for the item.-
9520-
9521 \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem,-
9522 QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsLineItem,-
9523 {Graphics View Framework}-
9524*/-
9525-
9526/*!-
9527 \enum QGraphicsPixmapItem::ShapeMode-
9528-
9529 This enum describes how QGraphicsPixmapItem calculates its shape and-
9530 opaque area.-
9531-
9532 The default value is MaskShape.-
9533-
9534 \value MaskShape The shape is determined by calling QPixmap::mask().-
9535 This shape includes only the opaque pixels of the pixmap.-
9536 Because the shape is more complex, however, it can be slower than the other modes,-
9537 and uses more memory.-
9538-
9539 \value BoundingRectShape The shape is determined by tracing the outline of-
9540 the pixmap. This is the fastest shape mode, but it does not take into account-
9541 any transparent areas on the pixmap.-
9542-
9543 \value HeuristicMaskShape The shape is determine by calling-
9544 QPixmap::createHeuristicMask(). The performance and memory consumption-
9545 is similar to MaskShape.-
9546*/-
9547extern QPainterPath qt_regionToPath(const QRegion &region);-
9548-
9549class QGraphicsPixmapItemPrivate : public QGraphicsItemPrivate-
9550{-
9551 Q_DECLARE_PUBLIC(QGraphicsPixmapItem)-
9552public:-
9553 QGraphicsPixmapItemPrivate()-
9554 : transformationMode(Qt::FastTransformation),-
9555 shapeMode(QGraphicsPixmapItem::MaskShape),-
9556 hasShape(false)-
9557 {}
never executed: end of block
0
9558-
9559 QPixmap pixmap;-
9560 Qt::TransformationMode transformationMode;-
9561 QPointF offset;-
9562 QGraphicsPixmapItem::ShapeMode shapeMode;-
9563 QPainterPath shape;-
9564 bool hasShape;-
9565-
9566 void updateShape()-
9567 {-
9568 shape = QPainterPath();-
9569 switch (shapeMode) {-
9570 case QGraphicsPixmapItem::MaskShape: {
never executed: case QGraphicsPixmapItem::MaskShape:
0
9571 QBitmap mask = pixmap.mask();-
9572 if (!mask.isNull()) {
!mask.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
9573 shape = qt_regionToPath(QRegion(mask).translated(offset.toPoint()));-
9574 break;
never executed: break;
0
9575 }-
9576 // FALL THROUGH-
9577 }-
9578 case QGraphicsPixmapItem::BoundingRectShape:
code before this statement never executed: case QGraphicsPixmapItem::BoundingRectShape:
never executed: case QGraphicsPixmapItem::BoundingRectShape:
0
9579 shape.addRect(QRectF(offset.x(), offset.y(), pixmap.width(), pixmap.height()));-
9580 break;
never executed: break;
0
9581 case QGraphicsPixmapItem::HeuristicMaskShape:
never executed: case QGraphicsPixmapItem::HeuristicMaskShape:
0
9582#ifndef QT_NO_IMAGE_HEURISTIC_MASK-
9583 shape = qt_regionToPath(QRegion(pixmap.createHeuristicMask()).translated(offset.toPoint()));-
9584#else-
9585 shape.addRect(QRectF(offset.x(), offset.y(), pixmap.width(), pixmap.height()));-
9586#endif-
9587 break;
never executed: break;
0
9588 }-
9589 }
never executed: end of block
0
9590};-
9591-
9592/*!-
9593 Constructs a QGraphicsPixmapItem, using \a pixmap as the default pixmap.-
9594 \a parent is passed to QGraphicsItem's constructor.-
9595-
9596 \sa QGraphicsScene::addItem()-
9597*/-
9598QGraphicsPixmapItem::QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent)-
9599 : QGraphicsItem(*new QGraphicsPixmapItemPrivate, parent)-
9600{-
9601 setPixmap(pixmap);-
9602}
never executed: end of block
0
9603-
9604/*!-
9605 Constructs a QGraphicsPixmapItem. \a parent is passed to QGraphicsItem's-
9606 constructor.-
9607-
9608 \sa QGraphicsScene::addItem()-
9609*/-
9610QGraphicsPixmapItem::QGraphicsPixmapItem(QGraphicsItem *parent)-
9611 : QGraphicsItem(*new QGraphicsPixmapItemPrivate, parent)-
9612{-
9613}
never executed: end of block
0
9614-
9615/*!-
9616 Destroys the QGraphicsPixmapItem.-
9617*/-
9618QGraphicsPixmapItem::~QGraphicsPixmapItem()-
9619{-
9620}-
9621-
9622/*!-
9623 Sets the item's pixmap to \a pixmap.-
9624-
9625 \sa pixmap()-
9626*/-
9627void QGraphicsPixmapItem::setPixmap(const QPixmap &pixmap)-
9628{-
9629 Q_D(QGraphicsPixmapItem);-
9630 prepareGeometryChange();-
9631 d->pixmap = pixmap;-
9632 d->hasShape = false;-
9633 update();-
9634}
never executed: end of block
0
9635-
9636/*!-
9637 Returns the item's pixmap, or an invalid QPixmap if no pixmap has been-
9638 set.-
9639-
9640 \sa setPixmap()-
9641*/-
9642QPixmap QGraphicsPixmapItem::pixmap() const-
9643{-
9644 Q_D(const QGraphicsPixmapItem);-
9645 return d->pixmap;
never executed: return d->pixmap;
0
9646}-
9647-
9648/*!-
9649 Returns the transformation mode of the pixmap. The default mode is-
9650 Qt::FastTransformation, which provides quick transformation with no-
9651 smoothing.-
9652-
9653 \sa setTransformationMode()-
9654*/-
9655Qt::TransformationMode QGraphicsPixmapItem::transformationMode() const-
9656{-
9657 Q_D(const QGraphicsPixmapItem);-
9658 return d->transformationMode;
never executed: return d->transformationMode;
0
9659}-
9660-
9661/*!-
9662 Sets the pixmap item's transformation mode to \a mode, and toggles an-
9663 update of the item. The default mode is Qt::FastTransformation, which-
9664 provides quick transformation with no smoothing.-
9665-
9666 Qt::SmoothTransformation enables QPainter::SmoothPixmapTransform on the-
9667 painter, and the quality depends on the platform and viewport. The result-
9668 is usually not as good as calling QPixmap::scale() directly.-
9669-
9670 \sa transformationMode()-
9671*/-
9672void QGraphicsPixmapItem::setTransformationMode(Qt::TransformationMode mode)-
9673{-
9674 Q_D(QGraphicsPixmapItem);-
9675 if (mode != d->transformationMode) {
mode != d->transformationModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
9676 d->transformationMode = mode;-
9677 update();-
9678 }
never executed: end of block
0
9679}
never executed: end of block
0
9680-
9681/*!-
9682 Returns the pixmap item's \e offset, which defines the point of the-
9683 top-left corner of the pixmap, in local coordinates.-
9684-
9685 \sa setOffset()-
9686*/-
9687QPointF QGraphicsPixmapItem::offset() const-
9688{-
9689 Q_D(const QGraphicsPixmapItem);-
9690 return d->offset;
never executed: return d->offset;
0
9691}-
9692-
9693/*!-
9694 Sets the pixmap item's offset to \a offset. QGraphicsPixmapItem will draw-
9695 its pixmap using \a offset for its top-left corner.-
9696-
9697 \sa offset()-
9698*/-
9699void QGraphicsPixmapItem::setOffset(const QPointF &offset)-
9700{-
9701 Q_D(QGraphicsPixmapItem);-
9702 if (d->offset == offset)
d->offset == offsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
9703 return;
never executed: return;
0
9704 prepareGeometryChange();-
9705 d->offset = offset;-
9706 d->hasShape = false;-
9707 update();-
9708}
never executed: end of block
0
9709-
9710/*!-
9711 \fn void QGraphicsPixmapItem::setOffset(qreal x, qreal y)-
9712 \since 4.3-
9713-
9714 This convenience function is equivalent to calling setOffset(QPointF(\a x, \a y)).-
9715*/-
9716-
9717/*!-
9718 \reimp-
9719*/-
9720QRectF QGraphicsPixmapItem::boundingRect() const-
9721{-
9722 Q_D(const QGraphicsPixmapItem);-
9723 if (d->pixmap.isNull())
d->pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
9724 return QRectF();
never executed: return QRectF();
0
9725 if (d->flags & ItemIsSelectable) {
d->flags & ItemIsSelectableDescription
TRUEnever evaluated
FALSEnever evaluated
0
9726 qreal pw = 1.0;-
9727 return QRectF(d->offset, d->pixmap.size() / d->pixmap.devicePixelRatio()).adjusted(-pw/2, -pw/2, pw/2, pw/2);
never executed: return QRectF(d->offset, d->pixmap.size() / d->pixmap.devicePixelRatio()).adjusted(-pw/2, -pw/2, pw/2, pw/2);
0
9728 } else {-
9729 return QRectF(d->offset, d->pixmap.size() / d->pixmap.devicePixelRatio());
never executed: return QRectF(d->offset, d->pixmap.size() / d->pixmap.devicePixelRatio());
0
9730 }-
9731}-
9732-
9733/*!-
9734 \reimp-
9735*/-
9736QPainterPath QGraphicsPixmapItem::shape() const-
9737{-
9738 Q_D(const QGraphicsPixmapItem);-
9739 if (!d->hasShape) {
!d->hasShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
9740 QGraphicsPixmapItemPrivate *thatD = const_cast<QGraphicsPixmapItemPrivate *>(d);-
9741 thatD->updateShape();-
9742 thatD->hasShape = true;-
9743 }
never executed: end of block
0
9744 return d_func()->shape;
never executed: return d_func()->shape;
0
9745}-
9746-
9747/*!-
9748 \reimp-
9749*/-
9750bool QGraphicsPixmapItem::contains(const QPointF &point) const-
9751{-
9752 return QGraphicsItem::contains(point);
never executed: return QGraphicsItem::contains(point);
0
9753}-
9754-
9755/*!-
9756 \reimp-
9757*/-
9758void QGraphicsPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,-
9759 QWidget *widget)-
9760{-
9761 Q_D(QGraphicsPixmapItem);-
9762 Q_UNUSED(widget);-
9763-
9764 painter->setRenderHint(QPainter::SmoothPixmapTransform,-
9765 (d->transformationMode == Qt::SmoothTransformation));-
9766-
9767 painter->drawPixmap(d->offset, d->pixmap);-
9768-
9769 if (option->state & QStyle::State_Selected)
option->state ...State_SelectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
9770 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
9771}
never executed: end of block
0
9772-
9773/*!-
9774 \reimp-
9775*/-
9776bool QGraphicsPixmapItem::isObscuredBy(const QGraphicsItem *item) const-
9777{-
9778 return QGraphicsItem::isObscuredBy(item);
never executed: return QGraphicsItem::isObscuredBy(item);
0
9779}-
9780-
9781/*!-
9782 \reimp-
9783*/-
9784QPainterPath QGraphicsPixmapItem::opaqueArea() const-
9785{-
9786 return shape();
never executed: return shape();
0
9787}-
9788-
9789/*!-
9790 \reimp-
9791*/-
9792int QGraphicsPixmapItem::type() const-
9793{-
9794 return Type;
never executed: return Type;
0
9795}-
9796-
9797/*!-
9798 Returns the item's shape mode. The shape mode describes how-
9799 QGraphicsPixmapItem calculates its shape. The default mode is MaskShape.-
9800-
9801 \sa setShapeMode(), ShapeMode-
9802*/-
9803QGraphicsPixmapItem::ShapeMode QGraphicsPixmapItem::shapeMode() const-
9804{-
9805 return d_func()->shapeMode;
never executed: return d_func()->shapeMode;
0
9806}-
9807-
9808/*!-
9809 Sets the item's shape mode to \a mode. The shape mode describes how-
9810 QGraphicsPixmapItem calculates its shape. The default mode is MaskShape.-
9811-
9812 \sa shapeMode(), ShapeMode-
9813*/-
9814void QGraphicsPixmapItem::setShapeMode(ShapeMode mode)-
9815{-
9816 Q_D(QGraphicsPixmapItem);-
9817 if (d->shapeMode == mode)
d->shapeMode == modeDescription
TRUEnever evaluated
FALSEnever evaluated
0
9818 return;
never executed: return;
0
9819 d->shapeMode = mode;-
9820 d->hasShape = false;-
9821}
never executed: end of block
0
9822-
9823/*!-
9824 \internal-
9825*/-
9826bool QGraphicsPixmapItem::supportsExtension(Extension extension) const-
9827{-
9828 Q_UNUSED(extension);-
9829 return false;
never executed: return false;
0
9830}-
9831-
9832/*!-
9833 \internal-
9834*/-
9835void QGraphicsPixmapItem::setExtension(Extension extension, const QVariant &variant)-
9836{-
9837 Q_UNUSED(extension);-
9838 Q_UNUSED(variant);-
9839}
never executed: end of block
0
9840-
9841/*!-
9842 \internal-
9843*/-
9844QVariant QGraphicsPixmapItem::extension(const QVariant &variant) const-
9845{-
9846 Q_UNUSED(variant);-
9847 return QVariant();
never executed: return QVariant();
0
9848}-
9849-
9850/*!-
9851 \class QGraphicsTextItem-
9852 \brief The QGraphicsTextItem class provides a text item that you can add to-
9853 a QGraphicsScene to display formatted text.-
9854 \since 4.2-
9855 \ingroup graphicsview-api-
9856 \inmodule QtWidgets-
9857-
9858 If you only need to show plain text in an item, consider using QGraphicsSimpleTextItem-
9859 instead.-
9860-
9861 To set the item's text, pass a QString to QGraphicsTextItem's-
9862 constructor, or call setHtml()/setPlainText().-
9863-
9864 QGraphicsTextItem uses the text's formatted size and the associated font-
9865 to provide a reasonable implementation of boundingRect(), shape(),-
9866 and contains(). You can set the font by calling setFont().-
9867-
9868 It is possible to make the item editable by setting the Qt::TextEditorInteraction flag-
9869 using setTextInteractionFlags().-
9870-
9871 The item's preferred text width can be set using setTextWidth() and obtained-
9872 using textWidth().-
9873-
9874 \note In order to align HTML text in the center, the item's text width must be set.-
9875 Otherwise, you can call adjustSize() after setting the item's text.-
9876-
9877 \image graphicsview-textitem.png-
9878-
9879 \note QGraphicsTextItem accepts \l{QGraphicsItem::acceptHoverEvents()}{hover events}-
9880 by default. You can change this with \l{QGraphicsItem::}{setAcceptHoverEvents()}.-
9881-
9882 \sa QGraphicsSimpleTextItem, QGraphicsPathItem, QGraphicsRectItem,-
9883 QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem,-
9884 QGraphicsLineItem, {Graphics View Framework}-
9885*/-
9886-
9887class QGraphicsTextItemPrivate-
9888{-
9889public:-
9890 QGraphicsTextItemPrivate()-
9891 : control(0), pageNumber(0), useDefaultImpl(false), tabChangesFocus(false), clickCausedFocus(0)-
9892 { }
never executed: end of block
0
9893-
9894 mutable QWidgetTextControl *control;-
9895 QWidgetTextControl *textControl() const;-
9896-
9897 inline QPointF controlOffset() const-
9898 { return QPointF(0., pageNumber * control->document()->pageSize().height()); }
never executed: return QPointF(0., pageNumber * control->document()->pageSize().height());
0
9899 inline void sendControlEvent(QEvent *e)-
9900 { if (control) control->processEvent(e, controlOffset()); }
never executed: end of block
never executed: control->processEvent(e, controlOffset());
controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
9901-
9902 void _q_updateBoundingRect(const QSizeF &);-
9903 void _q_update(QRectF);-
9904 void _q_ensureVisible(QRectF);-
9905 bool _q_mouseOnEdge(QGraphicsSceneMouseEvent *);-
9906-
9907 QRectF boundingRect;-
9908 int pageNumber;-
9909 bool useDefaultImpl;-
9910 bool tabChangesFocus;-
9911-
9912 uint clickCausedFocus : 1;-
9913-
9914 QGraphicsTextItem *qq;-
9915};-
9916-
9917-
9918/*!-
9919 Constructs a QGraphicsTextItem, using \a text as the default plain-
9920 text. \a parent is passed to QGraphicsItem's constructor.-
9921-
9922 \sa QGraphicsScene::addItem()-
9923*/-
9924QGraphicsTextItem::QGraphicsTextItem(const QString &text, QGraphicsItem *parent)-
9925 : QGraphicsObject(*new QGraphicsItemPrivate, parent),-
9926 dd(new QGraphicsTextItemPrivate)-
9927{-
9928 dd->qq = this;-
9929 if (!text.isEmpty())
!text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
9930 setPlainText(text);
never executed: setPlainText(text);
0
9931 setAcceptDrops(true);-
9932 setAcceptHoverEvents(true);-
9933 setFlags(ItemUsesExtendedStyleOption);-
9934}
never executed: end of block
0
9935-
9936/*!-
9937 Constructs a QGraphicsTextItem. \a parent is passed to QGraphicsItem's-
9938 constructor.-
9939-
9940 \sa QGraphicsScene::addItem()-
9941*/-
9942QGraphicsTextItem::QGraphicsTextItem(QGraphicsItem *parent)-
9943 : QGraphicsObject(*new QGraphicsItemPrivate, parent),-
9944 dd(new QGraphicsTextItemPrivate)-
9945{-
9946 dd->qq = this;-
9947 setAcceptDrops(true);-
9948 setAcceptHoverEvents(true);-
9949 setFlag(ItemUsesExtendedStyleOption);-
9950}
never executed: end of block
0
9951-
9952/*!-
9953 Destroys the QGraphicsTextItem.-
9954*/-
9955QGraphicsTextItem::~QGraphicsTextItem()-
9956{-
9957 delete dd;-
9958}
never executed: end of block
0
9959-
9960/*!-
9961 Returns the item's text converted to HTML, or an empty QString if no text has been set.-
9962-
9963 \sa setHtml()-
9964*/-
9965QString QGraphicsTextItem::toHtml() const-
9966{-
9967#ifndef QT_NO_TEXTHTMLPARSER-
9968 if (dd->control)
dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
9969 return dd->control->toHtml();
never executed: return dd->control->toHtml();
0
9970#endif-
9971 return QString();
never executed: return QString();
0
9972}-
9973-
9974/*!-
9975 Sets the item's text to \a text, assuming that text is HTML formatted. If-
9976 the item has keyboard input focus, this function will also call-
9977 ensureVisible() to ensure that the text is visible in all viewports.-
9978-
9979 \sa toHtml(), hasFocus(), QGraphicsSimpleTextItem-
9980*/-
9981void QGraphicsTextItem::setHtml(const QString &text)-
9982{-
9983 dd->textControl()->setHtml(text);-
9984}
never executed: end of block
0
9985-
9986/*!-
9987 Returns the item's text converted to plain text, or an empty QString if no text has been set.-
9988-
9989 \sa setPlainText()-
9990*/-
9991QString QGraphicsTextItem::toPlainText() const-
9992{-
9993 if (dd->control)
dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
9994 return dd->control->toPlainText();
never executed: return dd->control->toPlainText();
0
9995 return QString();
never executed: return QString();
0
9996}-
9997-
9998/*!-
9999 Sets the item's text to \a text. If the item has keyboard input focus,-
10000 this function will also call ensureVisible() to ensure that the text is-
10001 visible in all viewports.-
10002-
10003 \sa toHtml(), hasFocus()-
10004*/-
10005void QGraphicsTextItem::setPlainText(const QString &text)-
10006{-
10007 dd->textControl()->setPlainText(text);-
10008}
never executed: end of block
0
10009-
10010/*!-
10011 Returns the item's font, which is used to render the text.-
10012-
10013 \sa setFont()-
10014*/-
10015QFont QGraphicsTextItem::font() const-
10016{-
10017 if (!dd->control)
!dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
10018 return QFont();
never executed: return QFont();
0
10019 return dd->control->document()->defaultFont();
never executed: return dd->control->document()->defaultFont();
0
10020}-
10021-
10022/*!-
10023 Sets the font used to render the text item to \a font.-
10024-
10025 \sa font()-
10026*/-
10027void QGraphicsTextItem::setFont(const QFont &font)-
10028{-
10029 dd->textControl()->document()->setDefaultFont(font);-
10030}
never executed: end of block
0
10031-
10032/*!-
10033 Sets the color for unformatted text to \a col.-
10034*/-
10035void QGraphicsTextItem::setDefaultTextColor(const QColor &col)-
10036{-
10037 QWidgetTextControl *c = dd->textControl();-
10038 QPalette pal = c->palette();-
10039 QColor old = pal.color(QPalette::Text);-
10040 pal.setColor(QPalette::Text, col);-
10041 c->setPalette(pal);-
10042 if (old != col)
old != colDescription
TRUEnever evaluated
FALSEnever evaluated
0
10043 update();
never executed: update();
0
10044}
never executed: end of block
0
10045-
10046/*!-
10047 Returns the default text color that is used for unformatted text.-
10048*/-
10049QColor QGraphicsTextItem::defaultTextColor() const-
10050{-
10051 return dd->textControl()->palette().color(QPalette::Text);
never executed: return dd->textControl()->palette().color(QPalette::Text);
0
10052}-
10053-
10054/*!-
10055 \reimp-
10056*/-
10057QRectF QGraphicsTextItem::boundingRect() const-
10058{-
10059 return dd->boundingRect;
never executed: return dd->boundingRect;
0
10060}-
10061-
10062/*!-
10063 \reimp-
10064*/-
10065QPainterPath QGraphicsTextItem::shape() const-
10066{-
10067 if (!dd->control)
!dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
10068 return QPainterPath();
never executed: return QPainterPath();
0
10069 QPainterPath path;-
10070 path.addRect(dd->boundingRect);-
10071 return path;
never executed: return path;
0
10072}-
10073-
10074/*!-
10075 \reimp-
10076*/-
10077bool QGraphicsTextItem::contains(const QPointF &point) const-
10078{-
10079 return dd->boundingRect.contains(point);
never executed: return dd->boundingRect.contains(point);
0
10080}-
10081-
10082/*!-
10083 \reimp-
10084*/-
10085void QGraphicsTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,-
10086 QWidget *widget)-
10087{-
10088 Q_UNUSED(widget);-
10089 if (dd->control) {
dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
10090 painter->save();-
10091 QRectF r = option->exposedRect;-
10092 painter->translate(-dd->controlOffset());-
10093 r.translate(dd->controlOffset());-
10094-
10095 QTextDocument *doc = dd->control->document();-
10096 QTextDocumentLayout *layout = qobject_cast<QTextDocumentLayout *>(doc->documentLayout());-
10097-
10098 // the layout might need to expand the root frame to-
10099 // the viewport if NoWrap is set-
10100 if (layout)
layoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
10101 layout->setViewport(dd->boundingRect);
never executed: layout->setViewport(dd->boundingRect);
0
10102-
10103 dd->control->drawContents(painter, r);-
10104-
10105 if (layout)
layoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
10106 layout->setViewport(QRect());
never executed: layout->setViewport(QRect());
0
10107-
10108 painter->restore();-
10109 }
never executed: end of block
0
10110-
10111 if (option->state & (QStyle::State_Selected | QStyle::State_HasFocus))
option->state ...tate_HasFocus)Description
TRUEnever evaluated
FALSEnever evaluated
0
10112 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
10113}
never executed: end of block
0
10114-
10115/*!-
10116 \reimp-
10117*/-
10118bool QGraphicsTextItem::isObscuredBy(const QGraphicsItem *item) const-
10119{-
10120 return QGraphicsItem::isObscuredBy(item);
never executed: return QGraphicsItem::isObscuredBy(item);
0
10121}-
10122-
10123/*!-
10124 \reimp-
10125*/-
10126QPainterPath QGraphicsTextItem::opaqueArea() const-
10127{-
10128 return QGraphicsItem::opaqueArea();
never executed: return QGraphicsItem::opaqueArea();
0
10129}-
10130-
10131/*!-
10132 \reimp-
10133*/-
10134int QGraphicsTextItem::type() const-
10135{-
10136 return Type;
never executed: return Type;
0
10137}-
10138-
10139/*!-
10140 Sets the preferred width for the item's text. If the actual text-
10141 is wider than the specified width then it will be broken into-
10142 multiple lines.-
10143-
10144 If \a width is set to -1 then the text will not be broken into-
10145 multiple lines unless it is enforced through an explicit line-
10146 break or a new paragraph.-
10147-
10148 The default value is -1.-
10149-
10150 Note that QGraphicsTextItem keeps a QTextDocument internally,-
10151 which is used to calculate the text width.-
10152-
10153 \sa textWidth(), QTextDocument::setTextWidth()-
10154*/-
10155void QGraphicsTextItem::setTextWidth(qreal width)-
10156{-
10157 dd->textControl()->setTextWidth(width);-
10158}
never executed: end of block
0
10159-
10160/*!-
10161 Returns the text width.-
10162-
10163 The width is calculated with the QTextDocument that-
10164 QGraphicsTextItem keeps internally.-
10165-
10166 \sa setTextWidth(), QTextDocument::textWidth()-
10167*/-
10168qreal QGraphicsTextItem::textWidth() const-
10169{-
10170 if (!dd->control)
!dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
10171 return -1;
never executed: return -1;
0
10172 return dd->control->textWidth();
never executed: return dd->control->textWidth();
0
10173}-
10174-
10175/*!-
10176 Adjusts the text item to a reasonable size.-
10177*/-
10178void QGraphicsTextItem::adjustSize()-
10179{-
10180 if (dd->control)
dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
10181 dd->control->adjustSize();
never executed: dd->control->adjustSize();
0
10182}
never executed: end of block
0
10183-
10184/*!-
10185 Sets the text document \a document on the item.-
10186*/-
10187void QGraphicsTextItem::setDocument(QTextDocument *document)-
10188{-
10189 dd->textControl()->setDocument(document);-
10190 dd->_q_updateBoundingRect(dd->control->size());-
10191}
never executed: end of block
0
10192-
10193/*!-
10194 Returns the item's text document.-
10195*/-
10196QTextDocument *QGraphicsTextItem::document() const-
10197{-
10198 return dd->textControl()->document();
never executed: return dd->textControl()->document();
0
10199}-
10200-
10201/*!-
10202 \reimp-
10203*/-
10204bool QGraphicsTextItem::sceneEvent(QEvent *event)-
10205{-
10206 QEvent::Type t = event->type();-
10207 if (!dd->tabChangesFocus && (t == QEvent::KeyPress || t == QEvent::KeyRelease)) {
!dd->tabChangesFocusDescription
TRUEnever evaluated
FALSEnever evaluated
t == QEvent::KeyPressDescription
TRUEnever evaluated
FALSEnever evaluated
t == QEvent::KeyReleaseDescription
TRUEnever evaluated
FALSEnever evaluated
0
10208 int k = ((QKeyEvent *)event)->key();-
10209 if (k == Qt::Key_Tab || k == Qt::Key_Backtab) {
k == Qt::Key_TabDescription
TRUEnever evaluated
FALSEnever evaluated
k == Qt::Key_BacktabDescription
TRUEnever evaluated
FALSEnever evaluated
0
10210 dd->sendControlEvent(event);-
10211 return true;
never executed: return true;
0
10212 }-
10213 }
never executed: end of block
0
10214 bool result = QGraphicsItem::sceneEvent(event);-
10215-
10216 // Ensure input context is updated.-
10217 switch (event->type()) {-
10218 case QEvent::ContextMenu:
never executed: case QEvent::ContextMenu:
0
10219 case QEvent::FocusIn:
never executed: case QEvent::FocusIn:
0
10220 case QEvent::FocusOut:
never executed: case QEvent::FocusOut:
0
10221 case QEvent::GraphicsSceneDragEnter:
never executed: case QEvent::GraphicsSceneDragEnter:
0
10222 case QEvent::GraphicsSceneDragLeave:
never executed: case QEvent::GraphicsSceneDragLeave:
0
10223 case QEvent::GraphicsSceneDragMove:
never executed: case QEvent::GraphicsSceneDragMove:
0
10224 case QEvent::GraphicsSceneDrop:
never executed: case QEvent::GraphicsSceneDrop:
0
10225 case QEvent::GraphicsSceneHoverEnter:
never executed: case QEvent::GraphicsSceneHoverEnter:
0
10226 case QEvent::GraphicsSceneHoverLeave:
never executed: case QEvent::GraphicsSceneHoverLeave:
0
10227 case QEvent::GraphicsSceneHoverMove:
never executed: case QEvent::GraphicsSceneHoverMove:
0
10228 case QEvent::GraphicsSceneMouseDoubleClick:
never executed: case QEvent::GraphicsSceneMouseDoubleClick:
0
10229 case QEvent::GraphicsSceneMousePress:
never executed: case QEvent::GraphicsSceneMousePress:
0
10230 case QEvent::GraphicsSceneMouseMove:
never executed: case QEvent::GraphicsSceneMouseMove:
0
10231 case QEvent::GraphicsSceneMouseRelease:
never executed: case QEvent::GraphicsSceneMouseRelease:
0
10232 case QEvent::KeyPress:
never executed: case QEvent::KeyPress:
0
10233 case QEvent::KeyRelease:
never executed: case QEvent::KeyRelease:
0
10234 // Reset the focus widget's input context, regardless-
10235 // of how this item gained or lost focus.-
10236 if (event->type() == QEvent::FocusIn || event->type() == QEvent::FocusOut) {
event->type() ...Event::FocusInDescription
TRUEnever evaluated
FALSEnever evaluated
event->type() ...vent::FocusOutDescription
TRUEnever evaluated
FALSEnever evaluated
0
10237 QGuiApplication::inputMethod()->reset();-
10238 } else {
never executed: end of block
0
10239 QGuiApplication::inputMethod()->update(Qt::ImQueryInput);-
10240 }
never executed: end of block
0
10241 break;
never executed: break;
0
10242 case QEvent::ShortcutOverride:
never executed: case QEvent::ShortcutOverride:
0
10243 dd->sendControlEvent(event);-
10244 return true;
never executed: return true;
0
10245 default:
never executed: default:
0
10246 break;
never executed: break;
0
10247 }-
10248-
10249 return result;
never executed: return result;
0
10250}-
10251-
10252/*!-
10253 \reimp-
10254*/-
10255void QGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)-
10256{-
10257 if ((QGraphicsItem::d_ptr->flags & (ItemIsSelectable | ItemIsMovable))
(QGraphicsItem...temIsMovable))Description
TRUEnever evaluated
FALSEnever evaluated
0
10258 && (event->buttons() & Qt::LeftButton) && dd->_q_mouseOnEdge(event)) {
(event->button...t::LeftButton)Description
TRUEnever evaluated
FALSEnever evaluated
dd->_q_mouseOnEdge(event)Description
TRUEnever evaluated
FALSEnever evaluated
0
10259 // User left-pressed on edge of selectable/movable item, use-
10260 // base impl.-
10261 dd->useDefaultImpl = true;-
10262 } else if (event->buttons() == event->button()
never executed: end of block
event->buttons...vent->button()Description
TRUEnever evaluated
FALSEnever evaluated
0
10263 && dd->control->textInteractionFlags() == Qt::NoTextInteraction) {
dd->control->t...extInteractionDescription
TRUEnever evaluated
FALSEnever evaluated
0
10264 // User pressed first button on non-interactive item.-
10265 dd->useDefaultImpl = true;-
10266 }
never executed: end of block
0
10267 if (dd->useDefaultImpl) {
dd->useDefaultImplDescription
TRUEnever evaluated
FALSEnever evaluated
0
10268 QGraphicsItem::mousePressEvent(event);-
10269 if (!event->isAccepted())
!event->isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
10270 dd->useDefaultImpl = false;
never executed: dd->useDefaultImpl = false;
0
10271 return;
never executed: return;
0
10272 }-
10273-
10274 dd->sendControlEvent(event);-
10275}
never executed: end of block
0
10276-
10277/*!-
10278 \reimp-
10279*/-
10280void QGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)-
10281{-
10282 if (dd->useDefaultImpl) {
dd->useDefaultImplDescription
TRUEnever evaluated
FALSEnever evaluated
0
10283 QGraphicsItem::mouseMoveEvent(event);-
10284 return;
never executed: return;
0
10285 }-
10286-
10287 dd->sendControlEvent(event);-
10288}
never executed: end of block
0
10289-
10290/*!-
10291 \reimp-
10292*/-
10293void QGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)-
10294{-
10295 if (dd->useDefaultImpl) {
dd->useDefaultImplDescription
TRUEnever evaluated
FALSEnever evaluated
0
10296 QGraphicsItem::mouseReleaseEvent(event);-
10297 if (dd->control->textInteractionFlags() == Qt::NoTextInteraction
dd->control->t...extInteractionDescription
TRUEnever evaluated
FALSEnever evaluated
0
10298 && !event->buttons()) {
!event->buttons()Description
TRUEnever evaluated
FALSEnever evaluated
0
10299 // User released last button on non-interactive item.-
10300 dd->useDefaultImpl = false;-
10301 } else if ((event->buttons() & Qt::LeftButton) == 0) {
never executed: end of block
(event->button...ftButton) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
10302 // User released the left button on an interactive item.-
10303 dd->useDefaultImpl = false;-
10304 }
never executed: end of block
0
10305 return;
never executed: return;
0
10306 }-
10307-
10308 QWidget *widget = event->widget();-
10309 if (widget && (dd->control->textInteractionFlags() & Qt::TextEditable) && boundingRect().contains(event->pos())) {
widgetDescription
TRUEnever evaluated
FALSEnever evaluated
(dd->control->...:TextEditable)Description
TRUEnever evaluated
FALSEnever evaluated
boundingRect()...(event->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
10310 qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), dd->clickCausedFocus);-
10311 }
never executed: end of block
0
10312 dd->clickCausedFocus = 0;-
10313 dd->sendControlEvent(event);-
10314}
never executed: end of block
0
10315-
10316/*!-
10317 \reimp-
10318*/-
10319void QGraphicsTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)-
10320{-
10321 if (dd->useDefaultImpl) {
dd->useDefaultImplDescription
TRUEnever evaluated
FALSEnever evaluated
0
10322 QGraphicsItem::mouseDoubleClickEvent(event);-
10323 return;
never executed: return;
0
10324 }-
10325-
10326 if (!hasFocus()) {
!hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
10327 QGraphicsItem::mouseDoubleClickEvent(event);-
10328 return;
never executed: return;
0
10329 }-
10330-
10331 dd->sendControlEvent(event);-
10332}
never executed: end of block
0
10333-
10334/*!-
10335 \reimp-
10336*/-
10337void QGraphicsTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)-
10338{-
10339 dd->sendControlEvent(event);-
10340}
never executed: end of block
0
10341-
10342/*!-
10343 \reimp-
10344*/-
10345void QGraphicsTextItem::keyPressEvent(QKeyEvent *event)-
10346{-
10347 dd->sendControlEvent(event);-
10348}
never executed: end of block
0
10349-
10350/*!-
10351 \reimp-
10352*/-
10353void QGraphicsTextItem::keyReleaseEvent(QKeyEvent *event)-
10354{-
10355 dd->sendControlEvent(event);-
10356}
never executed: end of block
0
10357-
10358/*!-
10359 \reimp-
10360*/-
10361void QGraphicsTextItem::focusInEvent(QFocusEvent *event)-
10362{-
10363 dd->sendControlEvent(event);-
10364 if (event->reason() == Qt::MouseFocusReason) {
event->reason(...useFocusReasonDescription
TRUEnever evaluated
FALSEnever evaluated
0
10365 dd->clickCausedFocus = 1;-
10366 }
never executed: end of block
0
10367 update();-
10368}
never executed: end of block
0
10369-
10370/*!-
10371 \reimp-
10372*/-
10373void QGraphicsTextItem::focusOutEvent(QFocusEvent *event)-
10374{-
10375 dd->sendControlEvent(event);-
10376 update();-
10377}
never executed: end of block
0
10378-
10379/*!-
10380 \reimp-
10381*/-
10382void QGraphicsTextItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)-
10383{-
10384 dd->sendControlEvent(event);-
10385}
never executed: end of block
0
10386-
10387/*!-
10388 \reimp-
10389*/-
10390void QGraphicsTextItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)-
10391{-
10392 dd->sendControlEvent(event);-
10393}
never executed: end of block
0
10394-
10395/*!-
10396 \reimp-
10397*/-
10398void QGraphicsTextItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event)-
10399{-
10400 dd->sendControlEvent(event);-
10401}
never executed: end of block
0
10402-
10403/*!-
10404 \reimp-
10405*/-
10406void QGraphicsTextItem::dropEvent(QGraphicsSceneDragDropEvent *event)-
10407{-
10408 dd->sendControlEvent(event);-
10409}
never executed: end of block
0
10410-
10411/*!-
10412 \reimp-
10413*/-
10414void QGraphicsTextItem::inputMethodEvent(QInputMethodEvent *event)-
10415{-
10416 dd->sendControlEvent(event);-
10417}
never executed: end of block
0
10418-
10419/*!-
10420 \reimp-
10421*/-
10422void QGraphicsTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)-
10423{-
10424 dd->sendControlEvent(event);-
10425}
never executed: end of block
0
10426-
10427/*!-
10428 \reimp-
10429*/-
10430void QGraphicsTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)-
10431{-
10432 dd->sendControlEvent(event);-
10433}
never executed: end of block
0
10434-
10435/*!-
10436 \reimp-
10437*/-
10438void QGraphicsTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)-
10439{-
10440 dd->sendControlEvent(event);-
10441}
never executed: end of block
0
10442-
10443/*!-
10444 \reimp-
10445*/-
10446QVariant QGraphicsTextItem::inputMethodQuery(Qt::InputMethodQuery query) const-
10447{-
10448 QVariant v;-
10449 if (query == Qt::ImHints)
query == Qt::ImHintsDescription
TRUEnever evaluated
FALSEnever evaluated
0
10450 v = int(inputMethodHints());
never executed: v = int(inputMethodHints());
0
10451 else if (dd->control)
dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
10452 v = dd->control->inputMethodQuery(query, QVariant());
never executed: v = dd->control->inputMethodQuery(query, QVariant());
0
10453 if (v.type() == QVariant::RectF)
v.type() == QVariant::RectFDescription
TRUEnever evaluated
FALSEnever evaluated
0
10454 v = v.toRectF().translated(-dd->controlOffset());
never executed: v = v.toRectF().translated(-dd->controlOffset());
0
10455 else if (v.type() == QVariant::PointF)
v.type() == QVariant::PointFDescription
TRUEnever evaluated
FALSEnever evaluated
0
10456 v = v.toPointF() - dd->controlOffset();
never executed: v = v.toPointF() - dd->controlOffset();
0
10457 else if (v.type() == QVariant::Rect)
v.type() == QVariant::RectDescription
TRUEnever evaluated
FALSEnever evaluated
0
10458 v = v.toRect().translated(-dd->controlOffset().toPoint());
never executed: v = v.toRect().translated(-dd->controlOffset().toPoint());
0
10459 else if (v.type() == QVariant::Point)
v.type() == QVariant::PointDescription
TRUEnever evaluated
FALSEnever evaluated
0
10460 v = v.toPoint() - dd->controlOffset().toPoint();
never executed: v = v.toPoint() - dd->controlOffset().toPoint();
0
10461 return v;
never executed: return v;
0
10462}-
10463-
10464/*!-
10465 \internal-
10466*/-
10467bool QGraphicsTextItem::supportsExtension(Extension extension) const-
10468{-
10469 Q_UNUSED(extension);-
10470 return false;
never executed: return false;
0
10471}-
10472-
10473/*!-
10474 \internal-
10475*/-
10476void QGraphicsTextItem::setExtension(Extension extension, const QVariant &variant)-
10477{-
10478 Q_UNUSED(extension);-
10479 Q_UNUSED(variant);-
10480}
never executed: end of block
0
10481-
10482/*!-
10483 \internal-
10484*/-
10485QVariant QGraphicsTextItem::extension(const QVariant &variant) const-
10486{-
10487 Q_UNUSED(variant);-
10488 return QVariant();
never executed: return QVariant();
0
10489}-
10490-
10491/*!-
10492 \internal-
10493*/-
10494void QGraphicsTextItemPrivate::_q_update(QRectF rect)-
10495{-
10496 if (rect.isValid()) {
rect.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
10497 rect.translate(-controlOffset());-
10498 } else {
never executed: end of block
0
10499 rect = boundingRect;-
10500 }
never executed: end of block
0
10501 if (rect.intersects(boundingRect))
rect.intersects(boundingRect)Description
TRUEnever evaluated
FALSEnever evaluated
0
10502 qq->update(rect);
never executed: qq->update(rect);
0
10503}
never executed: end of block
0
10504-
10505/*!-
10506 \internal-
10507*/-
10508void QGraphicsTextItemPrivate::_q_updateBoundingRect(const QSizeF &size)-
10509{-
10510 if (!control) return; // can't happen
never executed: return;
!controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
10511 const QSizeF pageSize = control->document()->pageSize();-
10512 // paged items have a constant (page) size-
10513 if (size == boundingRect.size() || pageSize.height() != -1)
size == boundingRect.size()Description
TRUEnever evaluated
FALSEnever evaluated
pageSize.height() != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
10514 return;
never executed: return;
0
10515 qq->prepareGeometryChange();-
10516 boundingRect.setSize(size);-
10517 qq->update();-
10518}
never executed: end of block
0
10519-
10520/*!-
10521 \internal-
10522*/-
10523void QGraphicsTextItemPrivate::_q_ensureVisible(QRectF rect)-
10524{-
10525 if (qq->hasFocus()) {
qq->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
10526 rect.translate(-controlOffset());-
10527 qq->ensureVisible(rect, /*xmargin=*/0, /*ymargin=*/0);-
10528 }
never executed: end of block
0
10529}
never executed: end of block
0
10530-
10531QWidgetTextControl *QGraphicsTextItemPrivate::textControl() const-
10532{-
10533 if (!control) {
!controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
10534 QGraphicsTextItem *that = const_cast<QGraphicsTextItem *>(qq);-
10535 control = new QWidgetTextControl(that);-
10536 control->setTextInteractionFlags(Qt::NoTextInteraction);-
10537-
10538 QObject::connect(control, SIGNAL(updateRequest(QRectF)),-
10539 qq, SLOT(_q_update(QRectF)));-
10540 QObject::connect(control, SIGNAL(documentSizeChanged(QSizeF)),-
10541 qq, SLOT(_q_updateBoundingRect(QSizeF)));-
10542 QObject::connect(control, SIGNAL(visibilityRequest(QRectF)),-
10543 qq, SLOT(_q_ensureVisible(QRectF)));-
10544 QObject::connect(control, SIGNAL(linkActivated(QString)),-
10545 qq, SIGNAL(linkActivated(QString)));-
10546 QObject::connect(control, SIGNAL(linkHovered(QString)),-
10547 qq, SIGNAL(linkHovered(QString)));-
10548-
10549 const QSizeF pgSize = control->document()->pageSize();-
10550 if (pgSize.height() != -1) {
pgSize.height() != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
10551 qq->prepareGeometryChange();-
10552 that->dd->boundingRect.setSize(pgSize);-
10553 qq->update();-
10554 } else {
never executed: end of block
0
10555 that->dd->_q_updateBoundingRect(control->size());-
10556 }
never executed: end of block
0
10557 }-
10558 return control;
never executed: return control;
0
10559}-
10560-
10561/*!-
10562 \internal-
10563*/-
10564bool QGraphicsTextItemPrivate::_q_mouseOnEdge(QGraphicsSceneMouseEvent *event)-
10565{-
10566 QPainterPath path;-
10567 path.addRect(qq->boundingRect());-
10568-
10569 QPainterPath docPath;-
10570 const QTextFrameFormat format = control->document()->rootFrame()->frameFormat();-
10571 docPath.addRect(-
10572 qq->boundingRect().adjusted(-
10573 format.leftMargin(),-
10574 format.topMargin(),-
10575 -format.rightMargin(),-
10576 -format.bottomMargin()));-
10577-
10578 return path.subtracted(docPath).contains(event->pos());
never executed: return path.subtracted(docPath).contains(event->pos());
0
10579}-
10580-
10581/*!-
10582 \fn QGraphicsTextItem::linkActivated(const QString &link)-
10583-
10584 This signal is emitted when the user clicks on a link on a text item-
10585 that enables Qt::LinksAccessibleByMouse or Qt::LinksAccessibleByKeyboard.-
10586 \a link is the link that was clicked.-
10587-
10588 \sa setTextInteractionFlags()-
10589*/-
10590-
10591/*!-
10592 \fn QGraphicsTextItem::linkHovered(const QString &link)-
10593-
10594 This signal is emitted when the user hovers over a link on a text item-
10595 that enables Qt::LinksAccessibleByMouse. \a link is-
10596 the link that was hovered over.-
10597-
10598 \sa setTextInteractionFlags()-
10599*/-
10600-
10601/*!-
10602 Sets the flags \a flags to specify how the text item should react to user-
10603 input.-
10604-
10605 The default for a QGraphicsTextItem is Qt::NoTextInteraction. This function-
10606 also affects the ItemIsFocusable QGraphicsItem flag by setting it if \a flags-
10607 is different from Qt::NoTextInteraction and clearing it otherwise.-
10608-
10609 By default, the text is read-only. To transform the item into an editor,-
10610 set the Qt::TextEditable flag.-
10611*/-
10612void QGraphicsTextItem::setTextInteractionFlags(Qt::TextInteractionFlags flags)-
10613{-
10614 if (flags == Qt::NoTextInteraction)
flags == Qt::NoTextInteractionDescription
TRUEnever evaluated
FALSEnever evaluated
0
10615 setFlags(this->flags() & ~(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod));
never executed: setFlags(this->flags() & ~(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod));
0
10616 else-
10617 setFlags(this->flags() | QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod);
never executed: setFlags(this->flags() | QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod);
0
10618-
10619 dd->textControl()->setTextInteractionFlags(flags);-
10620}
never executed: end of block
0
10621-
10622/*!-
10623 Returns the current text interaction flags.-
10624-
10625 \sa setTextInteractionFlags()-
10626*/-
10627Qt::TextInteractionFlags QGraphicsTextItem::textInteractionFlags() const-
10628{-
10629 if (!dd->control)
!dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
10630 return Qt::NoTextInteraction;
never executed: return Qt::NoTextInteraction;
0
10631 return dd->control->textInteractionFlags();
never executed: return dd->control->textInteractionFlags();
0
10632}-
10633-
10634/*!-
10635 \since 4.5-
10636-
10637 If \a b is true, the \uicontrol Tab key will cause the widget to change focus;-
10638 otherwise, the tab key will insert a tab into the document.-
10639-
10640 In some occasions text edits should not allow the user to input tabulators-
10641 or change indentation using the \uicontrol Tab key, as this breaks the focus-
10642 chain. The default is false.-
10643-
10644 \sa tabChangesFocus(), ItemIsFocusable, textInteractionFlags()-
10645*/-
10646void QGraphicsTextItem::setTabChangesFocus(bool b)-
10647{-
10648 dd->tabChangesFocus = b;-
10649}
never executed: end of block
0
10650-
10651/*!-
10652 \since 4.5-
10653-
10654 Returns \c true if the \uicontrol Tab key will cause the widget to change focus;-
10655 otherwise, false is returned.-
10656-
10657 By default, this behavior is disabled, and this function will return false.-
10658-
10659 \sa setTabChangesFocus()-
10660*/-
10661bool QGraphicsTextItem::tabChangesFocus() const-
10662{-
10663 return dd->tabChangesFocus;
never executed: return dd->tabChangesFocus;
0
10664}-
10665-
10666/*!-
10667 \property QGraphicsTextItem::openExternalLinks-
10668-
10669 Specifies whether QGraphicsTextItem should automatically open links using-
10670 QDesktopServices::openUrl() instead of emitting the-
10671 linkActivated signal.-
10672-
10673 The default value is false.-
10674*/-
10675void QGraphicsTextItem::setOpenExternalLinks(bool open)-
10676{-
10677 dd->textControl()->setOpenExternalLinks(open);-
10678}
never executed: end of block
0
10679-
10680bool QGraphicsTextItem::openExternalLinks() const-
10681{-
10682 if (!dd->control)
!dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
10683 return false;
never executed: return false;
0
10684 return dd->control->openExternalLinks();
never executed: return dd->control->openExternalLinks();
0
10685}-
10686-
10687/*!-
10688 \property QGraphicsTextItem::textCursor-
10689-
10690 This property represents the visible text cursor in an editable-
10691 text item.-
10692-
10693 By default, if the item's text has not been set, this property-
10694 contains a null text cursor; otherwise it contains a text cursor-
10695 placed at the start of the item's document.-
10696*/-
10697void QGraphicsTextItem::setTextCursor(const QTextCursor &cursor)-
10698{-
10699 dd->textControl()->setTextCursor(cursor);-
10700}
never executed: end of block
0
10701-
10702QTextCursor QGraphicsTextItem::textCursor() const-
10703{-
10704 if (!dd->control)
!dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
10705 return QTextCursor();
never executed: return QTextCursor();
0
10706 return dd->control->textCursor();
never executed: return dd->control->textCursor();
0
10707}-
10708-
10709class QGraphicsSimpleTextItemPrivate : public QAbstractGraphicsShapeItemPrivate-
10710{-
10711 Q_DECLARE_PUBLIC(QGraphicsSimpleTextItem)-
10712public:-
10713 inline QGraphicsSimpleTextItemPrivate() {-
10714 pen.setStyle(Qt::NoPen);-
10715 brush.setStyle(Qt::SolidPattern);-
10716 }
never executed: end of block
0
10717 QString text;-
10718 QFont font;-
10719 QRectF boundingRect;-
10720-
10721 void updateBoundingRect();-
10722};-
10723-
10724static QRectF setupTextLayout(QTextLayout *layout)-
10725{-
10726 layout->setCacheEnabled(true);-
10727 layout->beginLayout();-
10728 while (layout->createLine().isValid())
layout->createLine().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
10729 ;
never executed: ;
0
10730 layout->endLayout();-
10731 qreal maxWidth = 0;-
10732 qreal y = 0;-
10733 for (int i = 0; i < layout->lineCount(); ++i) {
i < layout->lineCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
10734 QTextLine line = layout->lineAt(i);-
10735 maxWidth = qMax(maxWidth, line.naturalTextWidth());-
10736 line.setPosition(QPointF(0, y));-
10737 y += line.height();-
10738 }
never executed: end of block
0
10739 return QRectF(0, 0, maxWidth, y);
never executed: return QRectF(0, 0, maxWidth, y);
0
10740}-
10741-
10742void QGraphicsSimpleTextItemPrivate::updateBoundingRect()-
10743{-
10744 Q_Q(QGraphicsSimpleTextItem);-
10745 QRectF br;-
10746 if (text.isEmpty()) {
text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
10747 br = QRectF();-
10748 } else {
never executed: end of block
0
10749 QString tmp = text;-
10750 tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);-
10751 QStackTextEngine engine(tmp, font);-
10752 QTextLayout layout(&engine);-
10753 br = setupTextLayout(&layout);-
10754 }
never executed: end of block
0
10755 if (br != boundingRect) {
br != boundingRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
10756 q->prepareGeometryChange();-
10757 boundingRect = br;-
10758 q->update();-
10759 }
never executed: end of block
0
10760}
never executed: end of block
0
10761-
10762/*!-
10763 \class QGraphicsSimpleTextItem-
10764 \brief The QGraphicsSimpleTextItem class provides a simple text path item-
10765 that you can add to a QGraphicsScene.-
10766 \since 4.2-
10767 \ingroup graphicsview-api-
10768 \inmodule QtWidgets-
10769-
10770 To set the item's text, you can either pass a QString to-
10771 QGraphicsSimpleTextItem's constructor, or call setText() to change the-
10772 text later. To set the text fill color, call setBrush().-
10773-
10774 The simple text item can have both a fill and an outline; setBrush() will-
10775 set the text fill (i.e., text color), and setPen() sets the pen that will-
10776 be used to draw the text outline. (The latter can be slow, especially for-
10777 complex pens, and items with long text content.) If all you want is to-
10778 draw a simple line of text, you should call setBrush() only, and leave the-
10779 pen unset; QGraphicsSimpleTextItem's pen is by default Qt::NoPen.-
10780-
10781 QGraphicsSimpleTextItem uses the text's formatted size and the associated-
10782 font to provide a reasonable implementation of boundingRect(), shape(),-
10783 and contains(). You can set the font by calling setFont().-
10784-
10785 QGraphicsSimpleText does not display rich text; instead, you can use-
10786 QGraphicsTextItem, which provides full text control capabilities.-
10787-
10788 \image graphicsview-simpletextitem.png-
10789-
10790 \sa QGraphicsTextItem, QGraphicsPathItem, QGraphicsRectItem,-
10791 QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem,-
10792 QGraphicsLineItem, {Graphics View Framework}-
10793*/-
10794-
10795/*!-
10796 Constructs a QGraphicsSimpleTextItem.-
10797-
10798 \a parent is passed to QGraphicsItem's constructor.-
10799-
10800 \sa QGraphicsScene::addItem()-
10801*/-
10802QGraphicsSimpleTextItem::QGraphicsSimpleTextItem(QGraphicsItem *parent)-
10803 : QAbstractGraphicsShapeItem(*new QGraphicsSimpleTextItemPrivate, parent)-
10804{-
10805}
never executed: end of block
0
10806-
10807/*!-
10808 Constructs a QGraphicsSimpleTextItem, using \a text as the default plain text.-
10809-
10810 \a parent is passed to QGraphicsItem's constructor.-
10811-
10812 \sa QGraphicsScene::addItem()-
10813*/-
10814QGraphicsSimpleTextItem::QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent)-
10815 : QAbstractGraphicsShapeItem(*new QGraphicsSimpleTextItemPrivate, parent)-
10816{-
10817 setText(text);-
10818}
never executed: end of block
0
10819-
10820/*!-
10821 Destroys the QGraphicsSimpleTextItem.-
10822*/-
10823QGraphicsSimpleTextItem::~QGraphicsSimpleTextItem()-
10824{-
10825}-
10826-
10827/*!-
10828 Sets the item's text to \a text. The text will be displayed as-
10829 plain text. Newline characters ('\\n') as well as characters of-
10830 type QChar::LineSeparator will cause item to break the text into-
10831 multiple lines.-
10832*/-
10833void QGraphicsSimpleTextItem::setText(const QString &text)-
10834{-
10835 Q_D(QGraphicsSimpleTextItem);-
10836 if (d->text == text)
d->text == textDescription
TRUEnever evaluated
FALSEnever evaluated
0
10837 return;
never executed: return;
0
10838 d->text = text;-
10839 d->updateBoundingRect();-
10840 update();-
10841}
never executed: end of block
0
10842-
10843/*!-
10844 Returns the item's text.-
10845*/-
10846QString QGraphicsSimpleTextItem::text() const-
10847{-
10848 Q_D(const QGraphicsSimpleTextItem);-
10849 return d->text;
never executed: return d->text;
0
10850}-
10851-
10852/*!-
10853 Sets the font that is used to draw the item's text to \a font.-
10854*/-
10855void QGraphicsSimpleTextItem::setFont(const QFont &font)-
10856{-
10857 Q_D(QGraphicsSimpleTextItem);-
10858 d->font = font;-
10859 d->updateBoundingRect();-
10860}
never executed: end of block
0
10861-
10862/*!-
10863 Returns the font that is used to draw the item's text.-
10864*/-
10865QFont QGraphicsSimpleTextItem::font() const-
10866{-
10867 Q_D(const QGraphicsSimpleTextItem);-
10868 return d->font;
never executed: return d->font;
0
10869}-
10870-
10871/*!-
10872 \reimp-
10873*/-
10874QRectF QGraphicsSimpleTextItem::boundingRect() const-
10875{-
10876 Q_D(const QGraphicsSimpleTextItem);-
10877 return d->boundingRect;
never executed: return d->boundingRect;
0
10878}-
10879-
10880/*!-
10881 \reimp-
10882*/-
10883QPainterPath QGraphicsSimpleTextItem::shape() const-
10884{-
10885 Q_D(const QGraphicsSimpleTextItem);-
10886 QPainterPath path;-
10887 path.addRect(d->boundingRect);-
10888 return path;
never executed: return path;
0
10889}-
10890-
10891/*!-
10892 \reimp-
10893*/-
10894bool QGraphicsSimpleTextItem::contains(const QPointF &point) const-
10895{-
10896 Q_D(const QGraphicsSimpleTextItem);-
10897 return d->boundingRect.contains(point);
never executed: return d->boundingRect.contains(point);
0
10898}-
10899-
10900/*!-
10901 \reimp-
10902*/-
10903void QGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)-
10904{-
10905 Q_UNUSED(widget);-
10906 Q_D(QGraphicsSimpleTextItem);-
10907-
10908 painter->setFont(d->font);-
10909-
10910 QString tmp = d->text;-
10911 tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);-
10912 QStackTextEngine engine(tmp, d->font);-
10913 QTextLayout layout(&engine);-
10914-
10915 QPen p;-
10916 p.setBrush(d->brush);-
10917 painter->setPen(p);-
10918 if (d->pen.style() == Qt::NoPen && d->brush.style() == Qt::SolidPattern) {
d->pen.style() == Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
d->brush.style...::SolidPatternDescription
TRUEnever evaluated
FALSEnever evaluated
0
10919 painter->setBrush(Qt::NoBrush);-
10920 } else {
never executed: end of block
0
10921 QTextLayout::FormatRange range;-
10922 range.start = 0;-
10923 range.length = layout.text().length();-
10924 range.format.setTextOutline(d->pen);-
10925 layout.setFormats(QVector<QTextLayout::FormatRange>(1, range));-
10926 }
never executed: end of block
0
10927-
10928 setupTextLayout(&layout);-
10929 layout.draw(painter, QPointF(0, 0));-
10930-
10931 if (option->state & (QStyle::State_Selected | QStyle::State_HasFocus))
option->state ...tate_HasFocus)Description
TRUEnever evaluated
FALSEnever evaluated
0
10932 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
10933}
never executed: end of block
0
10934-
10935/*!-
10936 \reimp-
10937*/-
10938bool QGraphicsSimpleTextItem::isObscuredBy(const QGraphicsItem *item) const-
10939{-
10940 return QAbstractGraphicsShapeItem::isObscuredBy(item);
never executed: return QAbstractGraphicsShapeItem::isObscuredBy(item);
0
10941}-
10942-
10943/*!-
10944 \reimp-
10945*/-
10946QPainterPath QGraphicsSimpleTextItem::opaqueArea() const-
10947{-
10948 return QAbstractGraphicsShapeItem::opaqueArea();
never executed: return QAbstractGraphicsShapeItem::opaqueArea();
0
10949}-
10950-
10951/*!-
10952 \reimp-
10953*/-
10954int QGraphicsSimpleTextItem::type() const-
10955{-
10956 return Type;
never executed: return Type;
0
10957}-
10958-
10959/*!-
10960 \internal-
10961*/-
10962bool QGraphicsSimpleTextItem::supportsExtension(Extension extension) const-
10963{-
10964 Q_UNUSED(extension);-
10965 return false;
never executed: return false;
0
10966}-
10967-
10968/*!-
10969 \internal-
10970*/-
10971void QGraphicsSimpleTextItem::setExtension(Extension extension, const QVariant &variant)-
10972{-
10973 Q_UNUSED(extension);-
10974 Q_UNUSED(variant);-
10975}
never executed: end of block
0
10976-
10977/*!-
10978 \internal-
10979*/-
10980QVariant QGraphicsSimpleTextItem::extension(const QVariant &variant) const-
10981{-
10982 Q_UNUSED(variant);-
10983 return QVariant();
never executed: return QVariant();
0
10984}-
10985-
10986/*!-
10987 \class QGraphicsItemGroup-
10988 \brief The QGraphicsItemGroup class provides a container that treats-
10989 a group of items as a single item.-
10990 \since 4.2-
10991 \ingroup graphicsview-api-
10992 \inmodule QtWidgets-
10993-
10994 A QGraphicsItemGroup is a special type of compound item that-
10995 treats itself and all its children as one item (i.e., all events-
10996 and geometries for all children are merged together). It's common-
10997 to use item groups in presentation tools, when the user wants to-
10998 group several smaller items into one big item in order to simplify-
10999 moving and copying of items.-
11000-
11001 If all you want is to store items inside other items, you can use-
11002 any QGraphicsItem directly by passing a suitable parent to-
11003 setParentItem().-
11004-
11005 The boundingRect() function of QGraphicsItemGroup returns the-
11006 bounding rectangle of all items in the item group.-
11007 QGraphicsItemGroup ignores the ItemIgnoresTransformations flag on-
11008 its children (i.e., with respect to the geometry of the group-
11009 item, the children are treated as if they were transformable).-
11010-
11011 There are two ways to construct an item group. The easiest and-
11012 most common approach is to pass a list of items (e.g., all-
11013 selected items) to QGraphicsScene::createItemGroup(), which-
11014 returns a new QGraphicsItemGroup item. The other approach is to-
11015 manually construct a QGraphicsItemGroup item, add it to the scene-
11016 calling QGraphicsScene::addItem(), and then add items to the group-
11017 manually, one at a time by calling addToGroup(). To dismantle-
11018 ("ungroup") an item group, you can either call-
11019 QGraphicsScene::destroyItemGroup(), or you can manually remove all-
11020 items from the group by calling removeFromGroup().-
11021-
11022 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 17-
11023-
11024 The operation of adding and removing items preserves the items'-
11025 scene-relative position and transformation, as opposed to calling-
11026 setParentItem(), where only the child item's parent-relative-
11027 position and transformation are kept.-
11028-
11029 The addtoGroup() function reparents the target item to this item-
11030 group, keeping the item's position and transformation intact-
11031 relative to the scene. Visually, this means that items added via-
11032 addToGroup() will remain completely unchanged as a result of this-
11033 operation, regardless of the item or the group's current position-
11034 or transformation; although the item's position and matrix are-
11035 likely to change.-
11036-
11037 The removeFromGroup() function has similar semantics to-
11038 setParentItem(); it reparents the item to the parent item of the-
11039 item group. As with addToGroup(), the item's scene-relative-
11040 position and transformation remain intact.-
11041-
11042 \sa QGraphicsItem, {Graphics View Framework}-
11043*/-
11044-
11045class QGraphicsItemGroupPrivate : public QGraphicsItemPrivate-
11046{-
11047public:-
11048 QRectF itemsBoundingRect;-
11049};-
11050-
11051/*!-
11052 Constructs a QGraphicsItemGroup. \a parent is passed to QGraphicsItem's-
11053 constructor.-
11054-
11055 \sa QGraphicsScene::addItem()-
11056*/-
11057QGraphicsItemGroup::QGraphicsItemGroup(QGraphicsItem *parent)-
11058 : QGraphicsItem(*new QGraphicsItemGroupPrivate, parent)-
11059{-
11060 setHandlesChildEvents(true);-
11061}
never executed: end of block
0
11062-
11063/*!-
11064 Destroys the QGraphicsItemGroup.-
11065*/-
11066QGraphicsItemGroup::~QGraphicsItemGroup()-
11067{-
11068}-
11069-
11070/*!-
11071 Adds the given \a item and item's child items to this item group.-
11072 The item and child items will be reparented to this group, but its-
11073 position and transformation relative to the scene will stay intact.-
11074-
11075 \sa removeFromGroup(), QGraphicsScene::createItemGroup()-
11076*/-
11077void QGraphicsItemGroup::addToGroup(QGraphicsItem *item)-
11078{-
11079 Q_D(QGraphicsItemGroup);-
11080 if (!item) {
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
11081 qWarning("QGraphicsItemGroup::addToGroup: cannot add null item");-
11082 return;
never executed: return;
0
11083 }-
11084 if (item == this) {
item == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
11085 qWarning("QGraphicsItemGroup::addToGroup: cannot add a group to itself");-
11086 return;
never executed: return;
0
11087 }-
11088-
11089 // COMBINE-
11090 bool ok;-
11091 QTransform itemTransform = item->itemTransform(this, &ok);-
11092-
11093 if (!ok) {
!okDescription
TRUEnever evaluated
FALSEnever evaluated
0
11094 qWarning("QGraphicsItemGroup::addToGroup: could not find a valid transformation from item to group coordinates");-
11095 return;
never executed: return;
0
11096 }-
11097-
11098 QTransform newItemTransform(itemTransform);-
11099 item->setPos(mapFromItem(item, 0, 0));-
11100 item->setParentItem(this);-
11101-
11102 // removing position from translation component of the new transform-
11103 if (!item->pos().isNull())
!item->pos().isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
11104 newItemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
never executed: newItemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
0
11105-
11106 // removing additional transformations properties applied with itemTransform()-
11107 QPointF origin = item->transformOriginPoint();-
11108 QMatrix4x4 m;-
11109 QList<QGraphicsTransform*> transformList = item->transformations();-
11110 for (int i = 0; i < transformList.size(); ++i)
i < transformList.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
11111 transformList.at(i)->applyTo(&m);
never executed: transformList.at(i)->applyTo(&m);
0
11112 newItemTransform *= m.toTransform().inverted();-
11113 newItemTransform.translate(origin.x(), origin.y());-
11114 newItemTransform.rotate(-item->rotation());-
11115 newItemTransform.scale(1/item->scale(), 1/item->scale());-
11116 newItemTransform.translate(-origin.x(), -origin.y());-
11117-
11118 // ### Expensive, we could maybe use dirtySceneTransform bit for optimization-
11119-
11120 item->setTransform(newItemTransform);-
11121 item->d_func()->setIsMemberOfGroup(true);-
11122 prepareGeometryChange();-
11123 d->itemsBoundingRect |= itemTransform.mapRect(item->boundingRect() | item->childrenBoundingRect());-
11124 update();-
11125}
never executed: end of block
0
11126-
11127/*!-
11128 Removes the specified \a item from this group. The item will be-
11129 reparented to this group's parent item, or to 0 if this group has-
11130 no parent. Its position and transformation relative to the scene-
11131 will stay intact.-
11132-
11133 \sa addToGroup(), QGraphicsScene::destroyItemGroup()-
11134*/-
11135void QGraphicsItemGroup::removeFromGroup(QGraphicsItem *item)-
11136{-
11137 Q_D(QGraphicsItemGroup);-
11138 if (!item) {
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
11139 qWarning("QGraphicsItemGroup::removeFromGroup: cannot remove null item");-
11140 return;
never executed: return;
0
11141 }-
11142-
11143 QGraphicsItem *newParent = d_ptr->parent;-
11144-
11145 // COMBINE-
11146 bool ok;-
11147 QTransform itemTransform;-
11148 if (newParent)
newParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
11149 itemTransform = item->itemTransform(newParent, &ok);
never executed: itemTransform = item->itemTransform(newParent, &ok);
0
11150 else-
11151 itemTransform = item->sceneTransform();
never executed: itemTransform = item->sceneTransform();
0
11152-
11153 QPointF oldPos = item->mapToItem(newParent, 0, 0);-
11154 item->setParentItem(newParent);-
11155 item->setPos(oldPos);-
11156-
11157 // removing position from translation component of the new transform-
11158 if (!item->pos().isNull())
!item->pos().isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
11159 itemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
never executed: itemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
0
11160-
11161 // removing additional transformations properties applied-
11162 // with itemTransform() or sceneTransform()-
11163 QPointF origin = item->transformOriginPoint();-
11164 QMatrix4x4 m;-
11165 QList<QGraphicsTransform*> transformList = item->transformations();-
11166 for (int i = 0; i < transformList.size(); ++i)
i < transformList.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
11167 transformList.at(i)->applyTo(&m);
never executed: transformList.at(i)->applyTo(&m);
0
11168 itemTransform *= m.toTransform().inverted();-
11169 itemTransform.translate(origin.x(), origin.y());-
11170 itemTransform.rotate(-item->rotation());-
11171 itemTransform.scale(1 / item->scale(), 1 / item->scale());-
11172 itemTransform.translate(-origin.x(), -origin.y());-
11173-
11174 // ### Expensive, we could maybe use dirtySceneTransform bit for optimization-
11175-
11176 item->setTransform(itemTransform);-
11177 item->d_func()->setIsMemberOfGroup(item->group() != 0);-
11178-
11179 // ### Quite expensive. But removeFromGroup() isn't called very often.-
11180 prepareGeometryChange();-
11181 d->itemsBoundingRect = childrenBoundingRect();-
11182}
never executed: end of block
0
11183-
11184/*!-
11185 \reimp-
11186-
11187 Returns the bounding rect of this group item, and all its children.-
11188*/-
11189QRectF QGraphicsItemGroup::boundingRect() const-
11190{-
11191 Q_D(const QGraphicsItemGroup);-
11192 return d->itemsBoundingRect;
never executed: return d->itemsBoundingRect;
0
11193}-
11194-
11195/*!-
11196 \reimp-
11197*/-
11198void QGraphicsItemGroup::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,-
11199 QWidget *widget)-
11200{-
11201 Q_UNUSED(widget);-
11202 if (option->state & QStyle::State_Selected) {
option->state ...State_SelectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
11203 Q_D(QGraphicsItemGroup);-
11204 painter->setBrush(Qt::NoBrush);-
11205 painter->drawRect(d->itemsBoundingRect);-
11206 }
never executed: end of block
0
11207}
never executed: end of block
0
11208-
11209/*!-
11210 \reimp-
11211*/-
11212bool QGraphicsItemGroup::isObscuredBy(const QGraphicsItem *item) const-
11213{-
11214 return QGraphicsItem::isObscuredBy(item);
never executed: return QGraphicsItem::isObscuredBy(item);
0
11215}-
11216-
11217/*!-
11218 \reimp-
11219*/-
11220QPainterPath QGraphicsItemGroup::opaqueArea() const-
11221{-
11222 return QGraphicsItem::opaqueArea();
never executed: return QGraphicsItem::opaqueArea();
0
11223}-
11224-
11225/*!-
11226 \reimp-
11227*/-
11228int QGraphicsItemGroup::type() const-
11229{-
11230 return Type;
never executed: return Type;
0
11231}-
11232-
11233#ifndef QT_NO_GRAPHICSEFFECT-
11234QRectF QGraphicsItemEffectSourcePrivate::boundingRect(Qt::CoordinateSystem system) const-
11235{-
11236 const bool deviceCoordinates = (system == Qt::DeviceCoordinates);-
11237 if (!info && deviceCoordinates) {
!infoDescription
TRUEnever evaluated
FALSEnever evaluated
deviceCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
0
11238 // Device coordinates without info not yet supported.-
11239 qWarning("QGraphicsEffectSource::boundingRect: Not yet implemented, lacking device context");-
11240 return QRectF();
never executed: return QRectF();
0
11241 }-
11242-
11243 QRectF rect = item->boundingRect();-
11244 if (!item->d_ptr->children.isEmpty())
!item->d_ptr->...dren.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
11245 rect |= item->childrenBoundingRect();
never executed: rect |= item->childrenBoundingRect();
0
11246-
11247 if (deviceCoordinates) {
deviceCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
0
11248 Q_ASSERT(info->painter);-
11249 rect = info->painter->worldTransform().mapRect(rect);-
11250 }
never executed: end of block
0
11251-
11252 return rect;
never executed: return rect;
0
11253}-
11254-
11255void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter)-
11256{-
11257 if (!info) {
!infoDescription
TRUEnever evaluated
FALSEnever evaluated
0
11258 qWarning("QGraphicsEffectSource::draw: Can only begin as a result of QGraphicsEffect::draw");-
11259 return;
never executed: return;
0
11260 }-
11261-
11262 Q_ASSERT(item->d_ptr->scene);-
11263 QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func();-
11264 if (painter == info->painter) {
painter == info->painterDescription
TRUEnever evaluated
FALSEnever evaluated
0
11265 scened->draw(item, painter, info->viewTransform, info->transformPtr, info->exposedRegion,-
11266 info->widget, info->opacity, info->effectTransform, info->wasDirtySceneTransform,-
11267 info->drawItem);-
11268 } else {
never executed: end of block
0
11269 QTransform effectTransform = info->painter->worldTransform().inverted();-
11270 effectTransform *= painter->worldTransform();-
11271 scened->draw(item, painter, info->viewTransform, info->transformPtr, info->exposedRegion,-
11272 info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform,-
11273 info->drawItem);-
11274 }
never executed: end of block
0
11275}-
11276-
11277// sourceRect must be in the given coordinate system-
11278QRect QGraphicsItemEffectSourcePrivate::paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded) const-
11279{-
11280 QRectF effectRectF;-
11281-
11282 if (unpadded)
unpaddedDescription
TRUEnever evaluated
FALSEnever evaluated
0
11283 *unpadded = false;
never executed: *unpadded = false;
0
11284-
11285 if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) {
mode == QGraph...veBoundingRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
11286 if (info) {
infoDescription
TRUEnever evaluated
FALSEnever evaluated
0
11287 QRectF deviceRect = system == Qt::DeviceCoordinates ? sourceRect : info->painter->worldTransform().mapRect(sourceRect);
system == Qt::...iceCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
0
11288 effectRectF = item->graphicsEffect()->boundingRectFor(deviceRect);-
11289 if (unpadded)
unpaddedDescription
TRUEnever evaluated
FALSEnever evaluated
0
11290 *unpadded = (effectRectF.size() == sourceRect.size());
never executed: *unpadded = (effectRectF.size() == sourceRect.size());
0
11291 if (info && system == Qt::LogicalCoordinates)
infoDescription
TRUEnever evaluated
FALSEnever evaluated
system == Qt::...calCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
0
11292 effectRectF = info->painter->worldTransform().inverted().mapRect(effectRectF);
never executed: effectRectF = info->painter->worldTransform().inverted().mapRect(effectRectF);
0
11293 } else {
never executed: end of block
0
11294 // no choice but to send a logical coordinate bounding rect to boundingRectFor-
11295 effectRectF = item->graphicsEffect()->boundingRectFor(sourceRect);-
11296 }
never executed: end of block
0
11297 } else if (mode == QGraphicsEffect::PadToTransparentBorder) {
mode == QGraph...nsparentBorderDescription
TRUEnever evaluated
FALSEnever evaluated
0
11298 // adjust by 1.5 to account for cosmetic pens-
11299 effectRectF = sourceRect.adjusted(-1.5, -1.5, 1.5, 1.5);-
11300 } else {
never executed: end of block
0
11301 effectRectF = sourceRect;-
11302 if (unpadded)
unpaddedDescription
TRUEnever evaluated
FALSEnever evaluated
0
11303 *unpadded = true;
never executed: *unpadded = true;
0
11304 }
never executed: end of block
0
11305-
11306 return effectRectF.toAlignedRect();
never executed: return effectRectF.toAlignedRect();
0
11307}-
11308-
11309QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset,-
11310 QGraphicsEffect::PixmapPadMode mode) const-
11311{-
11312 const bool deviceCoordinates = (system == Qt::DeviceCoordinates);-
11313 if (!info && deviceCoordinates) {
!infoDescription
TRUEnever evaluated
FALSEnever evaluated
deviceCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
0
11314 // Device coordinates without info not yet supported.-
11315 qWarning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context");-
11316 return QPixmap();
never executed: return QPixmap();
0
11317 }-
11318 if (!item->d_ptr->scene)
!item->d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
11319 return QPixmap();
never executed: return QPixmap();
0
11320 QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func();-
11321-
11322 bool unpadded;-
11323 const QRectF sourceRect = boundingRect(system);-
11324 QRect effectRect = paddedEffectRect(system, mode, sourceRect, &unpadded);-
11325-
11326 if (offset)
offsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
11327 *offset = effectRect.topLeft();
never executed: *offset = effectRect.topLeft();
0
11328-
11329 bool untransformed = !deviceCoordinates
!deviceCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
0
11330 || info->painter->worldTransform().type() <= QTransform::TxTranslate;
info->painter-...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
11331 if (untransformed && unpadded && isPixmap()) {
untransformedDescription
TRUEnever evaluated
FALSEnever evaluated
unpaddedDescription
TRUEnever evaluated
FALSEnever evaluated
isPixmap()Description
TRUEnever evaluated
FALSEnever evaluated
0
11332 if (offset)
offsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
11333 *offset = boundingRect(system).topLeft().toPoint();
never executed: *offset = boundingRect(system).topLeft().toPoint();
0
11334 return static_cast<QGraphicsPixmapItem *>(item)->pixmap();
never executed: return static_cast<QGraphicsPixmapItem *>(item)->pixmap();
0
11335 }-
11336-
11337 if (effectRect.isEmpty())
effectRect.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
11338 return QPixmap();
never executed: return QPixmap();
0
11339-
11340 QPixmap pixmap(effectRect.size());-
11341 pixmap.fill(Qt::transparent);-
11342 QPainter pixmapPainter(&pixmap);-
11343 pixmapPainter.setRenderHints(info ? info->painter->renderHints() : QPainter::TextAntialiasing);-
11344-
11345 QTransform effectTransform = QTransform::fromTranslate(-effectRect.x(), -effectRect.y());-
11346 if (deviceCoordinates && info->effectTransform)
deviceCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
info->effectTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
11347 effectTransform *= *info->effectTransform;
never executed: effectTransform *= *info->effectTransform;
0
11348-
11349 if (!info) {
!infoDescription
TRUEnever evaluated
FALSEnever evaluated
0
11350 // Logical coordinates without info.-
11351 QTransform sceneTransform = item->sceneTransform();-
11352 QTransform newEffectTransform = sceneTransform.inverted();-
11353 newEffectTransform *= effectTransform;-
11354 scened->draw(item, &pixmapPainter, 0, &sceneTransform, 0, 0, qreal(1.0),-
11355 &newEffectTransform, false, true);-
11356 } else if (deviceCoordinates) {
never executed: end of block
deviceCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
0
11357 // Device coordinates with info.-
11358 scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0,-
11359 info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform,-
11360 info->drawItem);-
11361 } else {
never executed: end of block
0
11362 // Item coordinates with info.-
11363 QTransform newEffectTransform = info->transformPtr->inverted();-
11364 newEffectTransform *= effectTransform;-
11365 scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0,-
11366 info->widget, info->opacity, &newEffectTransform, info->wasDirtySceneTransform,-
11367 info->drawItem);-
11368 }
never executed: end of block
0
11369-
11370 pixmapPainter.end();-
11371-
11372 return pixmap;
never executed: return pixmap;
0
11373}-
11374#endif //QT_NO_GRAPHICSEFFECT-
11375-
11376#ifndef QT_NO_DEBUG_STREAM-
11377static void formatGraphicsItemHelper(QDebug debug, const QGraphicsItem *item)-
11378{-
11379 if (const QGraphicsItem *parent = item->parentItem())
const QGraphic...->parentItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
11380 debug << ", parent=" << static_cast<const void *>(parent);
never executed: debug << ", parent=" << static_cast<const void *>(parent);
0
11381 debug << ", pos=";-
11382 QtDebugUtils::formatQPoint(debug, item->pos());-
11383 if (const qreal z = item->zValue())
const qreal z = item->zValue()Description
TRUEnever evaluated
FALSEnever evaluated
0
11384 debug << ", z=" << z;
never executed: debug << ", z=" << z;
0
11385 if (item->flags())
item->flags()Description
TRUEnever evaluated
FALSEnever evaluated
0
11386 debug << ", flags=" << item->flags();
never executed: debug << ", flags=" << item->flags();
0
11387}
never executed: end of block
0
11388-
11389// FIXME: Qt 6: Make this QDebug operator<<(QDebug debug, const QGraphicsItem *item)-
11390QDebug operator<<(QDebug debug, QGraphicsItem *item)-
11391{-
11392 QDebugStateSaver saver(debug);-
11393 debug.nospace();-
11394-
11395 if (!item) {
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
11396 debug << "QGraphicsItem(0)";-
11397 return debug;
never executed: return debug;
0
11398 }-
11399-
11400 if (QGraphicsObject *o = item->toGraphicsObject())
QGraphicsObjec...aphicsObject()Description
TRUEnever evaluated
FALSEnever evaluated
0
11401 debug << o->metaObject()->className();
never executed: debug << o->metaObject()->className();
0
11402 else-
11403 debug << "QGraphicsItem";
never executed: debug << "QGraphicsItem";
0
11404 debug << '(' << static_cast<const void *>(item);-
11405 if (const QGraphicsProxyWidget *pw = qgraphicsitem_cast<const QGraphicsProxyWidget *>(item)) {
const QGraphic...idget *>(item)Description
TRUEnever evaluated
FALSEnever evaluated
0
11406 debug << ", widget=";-
11407 if (const QWidget *w = pw->widget()) {
const QWidget ...= pw->widget()Description
TRUEnever evaluated
FALSEnever evaluated
0
11408 debug << w->metaObject()->className() << '(' << static_cast<const void *>(w);-
11409 if (!w->objectName().isEmpty())
!w->objectName().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
11410 debug << ", name=" << w->objectName();
never executed: debug << ", name=" << w->objectName();
0
11411 debug << ')';-
11412 } else {
never executed: end of block
0
11413 debug << "QWidget(0)";-
11414 }
never executed: end of block
0
11415 }-
11416 formatGraphicsItemHelper(debug, item);-
11417 debug << ')';-
11418 return debug;
never executed: return debug;
0
11419}-
11420-
11421// FIXME: Qt 6: Make this QDebug operator<<(QDebug debug, const QGraphicsObject *item)-
11422QDebug operator<<(QDebug debug, QGraphicsObject *item)-
11423{-
11424 QDebugStateSaver saver(debug);-
11425 debug.nospace();-
11426-
11427 if (!item) {
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
11428 debug << "QGraphicsObject(0)";-
11429 return debug;
never executed: return debug;
0
11430 }-
11431-
11432 debug << item->metaObject()->className() << '(' << static_cast<const void *>(item);-
11433 if (!item->objectName().isEmpty())
!item->objectName().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
11434 debug << ", name=" << item->objectName();
never executed: debug << ", name=" << item->objectName();
0
11435 formatGraphicsItemHelper(debug, item);-
11436 debug << ')';-
11437 return debug;
never executed: return debug;
0
11438}-
11439-
11440QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemChange change)-
11441{-
11442 const char *str = "UnknownChange";-
11443 switch (change) {-
11444 case QGraphicsItem::ItemChildAddedChange:
never executed: case QGraphicsItem::ItemChildAddedChange:
0
11445 str = "ItemChildAddedChange";-
11446 break;
never executed: break;
0
11447 case QGraphicsItem::ItemChildRemovedChange:
never executed: case QGraphicsItem::ItemChildRemovedChange:
0
11448 str = "ItemChildRemovedChange";-
11449 break;
never executed: break;
0
11450 case QGraphicsItem::ItemCursorChange:
never executed: case QGraphicsItem::ItemCursorChange:
0
11451 str = "ItemCursorChange";-
11452 break;
never executed: break;
0
11453 case QGraphicsItem::ItemCursorHasChanged:
never executed: case QGraphicsItem::ItemCursorHasChanged:
0
11454 str = "ItemCursorHasChanged";-
11455 break;
never executed: break;
0
11456 case QGraphicsItem::ItemEnabledChange:
never executed: case QGraphicsItem::ItemEnabledChange:
0
11457 str = "ItemEnabledChange";-
11458 break;
never executed: break;
0
11459 case QGraphicsItem::ItemEnabledHasChanged:
never executed: case QGraphicsItem::ItemEnabledHasChanged:
0
11460 str = "ItemEnabledHasChanged";-
11461 break;
never executed: break;
0
11462 case QGraphicsItem::ItemFlagsChange:
never executed: case QGraphicsItem::ItemFlagsChange:
0
11463 str = "ItemFlagsChange";-
11464 break;
never executed: break;
0
11465 case QGraphicsItem::ItemFlagsHaveChanged:
never executed: case QGraphicsItem::ItemFlagsHaveChanged:
0
11466 str = "ItemFlagsHaveChanged";-
11467 break;
never executed: break;
0
11468 case QGraphicsItem::ItemMatrixChange:
never executed: case QGraphicsItem::ItemMatrixChange:
0
11469 str = "ItemMatrixChange";-
11470 break;
never executed: break;
0
11471 case QGraphicsItem::ItemParentChange:
never executed: case QGraphicsItem::ItemParentChange:
0
11472 str = "ItemParentChange";-
11473 break;
never executed: break;
0
11474 case QGraphicsItem::ItemParentHasChanged:
never executed: case QGraphicsItem::ItemParentHasChanged:
0
11475 str = "ItemParentHasChanged";-
11476 break;
never executed: break;
0
11477 case QGraphicsItem::ItemPositionChange:
never executed: case QGraphicsItem::ItemPositionChange:
0
11478 str = "ItemPositionChange";-
11479 break;
never executed: break;
0
11480 case QGraphicsItem::ItemPositionHasChanged:
never executed: case QGraphicsItem::ItemPositionHasChanged:
0
11481 str = "ItemPositionHasChanged";-
11482 break;
never executed: break;
0
11483 case QGraphicsItem::ItemSceneChange:
never executed: case QGraphicsItem::ItemSceneChange:
0
11484 str = "ItemSceneChange";-
11485 break;
never executed: break;
0
11486 case QGraphicsItem::ItemSceneHasChanged:
never executed: case QGraphicsItem::ItemSceneHasChanged:
0
11487 str = "ItemSceneHasChanged";-
11488 break;
never executed: break;
0
11489 case QGraphicsItem::ItemSelectedChange:
never executed: case QGraphicsItem::ItemSelectedChange:
0
11490 str = "ItemSelectedChange";-
11491 break;
never executed: break;
0
11492 case QGraphicsItem::ItemSelectedHasChanged:
never executed: case QGraphicsItem::ItemSelectedHasChanged:
0
11493 str = "ItemSelectedHasChanged";-
11494 break;
never executed: break;
0
11495 case QGraphicsItem::ItemToolTipChange:
never executed: case QGraphicsItem::ItemToolTipChange:
0
11496 str = "ItemToolTipChange";-
11497 break;
never executed: break;
0
11498 case QGraphicsItem::ItemToolTipHasChanged:
never executed: case QGraphicsItem::ItemToolTipHasChanged:
0
11499 str = "ItemToolTipHasChanged";-
11500 break;
never executed: break;
0
11501 case QGraphicsItem::ItemTransformChange:
never executed: case QGraphicsItem::ItemTransformChange:
0
11502 str = "ItemTransformChange";-
11503 break;
never executed: break;
0
11504 case QGraphicsItem::ItemTransformHasChanged:
never executed: case QGraphicsItem::ItemTransformHasChanged:
0
11505 str = "ItemTransformHasChanged";-
11506 break;
never executed: break;
0
11507 case QGraphicsItem::ItemVisibleChange:
never executed: case QGraphicsItem::ItemVisibleChange:
0
11508 str = "ItemVisibleChange";-
11509 break;
never executed: break;
0
11510 case QGraphicsItem::ItemVisibleHasChanged:
never executed: case QGraphicsItem::ItemVisibleHasChanged:
0
11511 str = "ItemVisibleHasChanged";-
11512 break;
never executed: break;
0
11513 case QGraphicsItem::ItemZValueChange:
never executed: case QGraphicsItem::ItemZValueChange:
0
11514 str = "ItemZValueChange";-
11515 break;
never executed: break;
0
11516 case QGraphicsItem::ItemZValueHasChanged:
never executed: case QGraphicsItem::ItemZValueHasChanged:
0
11517 str = "ItemZValueHasChanged";-
11518 break;
never executed: break;
0
11519 case QGraphicsItem::ItemOpacityChange:
never executed: case QGraphicsItem::ItemOpacityChange:
0
11520 str = "ItemOpacityChange";-
11521 break;
never executed: break;
0
11522 case QGraphicsItem::ItemOpacityHasChanged:
never executed: case QGraphicsItem::ItemOpacityHasChanged:
0
11523 str = "ItemOpacityHasChanged";-
11524 break;
never executed: break;
0
11525 case QGraphicsItem::ItemScenePositionHasChanged:
never executed: case QGraphicsItem::ItemScenePositionHasChanged:
0
11526 str = "ItemScenePositionHasChanged";-
11527 break;
never executed: break;
0
11528 case QGraphicsItem::ItemRotationChange:
never executed: case QGraphicsItem::ItemRotationChange:
0
11529 str = "ItemRotationChange";-
11530 break;
never executed: break;
0
11531 case QGraphicsItem::ItemRotationHasChanged:
never executed: case QGraphicsItem::ItemRotationHasChanged:
0
11532 str = "ItemRotationHasChanged";-
11533 break;
never executed: break;
0
11534 case QGraphicsItem::ItemScaleChange:
never executed: case QGraphicsItem::ItemScaleChange:
0
11535 str = "ItemScaleChange";-
11536 break;
never executed: break;
0
11537 case QGraphicsItem::ItemScaleHasChanged:
never executed: case QGraphicsItem::ItemScaleHasChanged:
0
11538 str = "ItemScaleHasChanged";-
11539 break;
never executed: break;
0
11540 case QGraphicsItem::ItemTransformOriginPointChange:
never executed: case QGraphicsItem::ItemTransformOriginPointChange:
0
11541 str = "ItemTransformOriginPointChange";-
11542 break;
never executed: break;
0
11543 case QGraphicsItem::ItemTransformOriginPointHasChanged:
never executed: case QGraphicsItem::ItemTransformOriginPointHasChanged:
0
11544 str = "ItemTransformOriginPointHasChanged";-
11545 break;
never executed: break;
0
11546 }-
11547 debug << str;-
11548 return debug;
never executed: return debug;
0
11549}-
11550-
11551QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlag flag)-
11552{-
11553 const char *str = "UnknownFlag";-
11554 switch (flag) {-
11555 case QGraphicsItem::ItemIsMovable:
never executed: case QGraphicsItem::ItemIsMovable:
0
11556 str = "ItemIsMovable";-
11557 break;
never executed: break;
0
11558 case QGraphicsItem::ItemIsSelectable:
never executed: case QGraphicsItem::ItemIsSelectable:
0
11559 str = "ItemIsSelectable";-
11560 break;
never executed: break;
0
11561 case QGraphicsItem::ItemIsFocusable:
never executed: case QGraphicsItem::ItemIsFocusable:
0
11562 str = "ItemIsFocusable";-
11563 break;
never executed: break;
0
11564 case QGraphicsItem::ItemClipsToShape:
never executed: case QGraphicsItem::ItemClipsToShape:
0
11565 str = "ItemClipsToShape";-
11566 break;
never executed: break;
0
11567 case QGraphicsItem::ItemClipsChildrenToShape:
never executed: case QGraphicsItem::ItemClipsChildrenToShape:
0
11568 str = "ItemClipsChildrenToShape";-
11569 break;
never executed: break;
0
11570 case QGraphicsItem::ItemIgnoresTransformations:
never executed: case QGraphicsItem::ItemIgnoresTransformations:
0
11571 str = "ItemIgnoresTransformations";-
11572 break;
never executed: break;
0
11573 case QGraphicsItem::ItemIgnoresParentOpacity:
never executed: case QGraphicsItem::ItemIgnoresParentOpacity:
0
11574 str = "ItemIgnoresParentOpacity";-
11575 break;
never executed: break;
0
11576 case QGraphicsItem::ItemDoesntPropagateOpacityToChildren:
never executed: case QGraphicsItem::ItemDoesntPropagateOpacityToChildren:
0
11577 str = "ItemDoesntPropagateOpacityToChildren";-
11578 break;
never executed: break;
0
11579 case QGraphicsItem::ItemStacksBehindParent:
never executed: case QGraphicsItem::ItemStacksBehindParent:
0
11580 str = "ItemStacksBehindParent";-
11581 break;
never executed: break;
0
11582 case QGraphicsItem::ItemUsesExtendedStyleOption:
never executed: case QGraphicsItem::ItemUsesExtendedStyleOption:
0
11583 str = "ItemUsesExtendedStyleOption";-
11584 break;
never executed: break;
0
11585 case QGraphicsItem::ItemHasNoContents:
never executed: case QGraphicsItem::ItemHasNoContents:
0
11586 str = "ItemHasNoContents";-
11587 break;
never executed: break;
0
11588 case QGraphicsItem::ItemSendsGeometryChanges:
never executed: case QGraphicsItem::ItemSendsGeometryChanges:
0
11589 str = "ItemSendsGeometryChanges";-
11590 break;
never executed: break;
0
11591 case QGraphicsItem::ItemAcceptsInputMethod:
never executed: case QGraphicsItem::ItemAcceptsInputMethod:
0
11592 str = "ItemAcceptsInputMethod";-
11593 break;
never executed: break;
0
11594 case QGraphicsItem::ItemNegativeZStacksBehindParent:
never executed: case QGraphicsItem::ItemNegativeZStacksBehindParent:
0
11595 str = "ItemNegativeZStacksBehindParent";-
11596 break;
never executed: break;
0
11597 case QGraphicsItem::ItemIsPanel:
never executed: case QGraphicsItem::ItemIsPanel:
0
11598 str = "ItemIsPanel";-
11599 break;
never executed: break;
0
11600 case QGraphicsItem::ItemIsFocusScope:
never executed: case QGraphicsItem::ItemIsFocusScope:
0
11601 str = "ItemIsFocusScope";-
11602 break;
never executed: break;
0
11603 case QGraphicsItem::ItemSendsScenePositionChanges:
never executed: case QGraphicsItem::ItemSendsScenePositionChanges:
0
11604 str = "ItemSendsScenePositionChanges";-
11605 break;
never executed: break;
0
11606 case QGraphicsItem::ItemStopsClickFocusPropagation:
never executed: case QGraphicsItem::ItemStopsClickFocusPropagation:
0
11607 str = "ItemStopsClickFocusPropagation";-
11608 break;
never executed: break;
0
11609 case QGraphicsItem::ItemStopsFocusHandling:
never executed: case QGraphicsItem::ItemStopsFocusHandling:
0
11610 str = "ItemStopsFocusHandling";-
11611 break;
never executed: break;
0
11612 case QGraphicsItem::ItemContainsChildrenInShape:
never executed: case QGraphicsItem::ItemContainsChildrenInShape:
0
11613 str = "ItemContainsChildrenInShape";-
11614 break;
never executed: break;
0
11615 }-
11616 debug << str;-
11617 return debug;
never executed: return debug;
0
11618}-
11619-
11620QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlags flags)-
11621{-
11622 debug << '(';-
11623 bool f = false;-
11624 for (int i = 0; i < 17; ++i) {
i < 17Description
TRUEnever evaluated
FALSEnever evaluated
0
11625 if (flags & (1 << i)) {
flags & (1 << i)Description
TRUEnever evaluated
FALSEnever evaluated
0
11626 if (f)
fDescription
TRUEnever evaluated
FALSEnever evaluated
0
11627 debug << '|';
never executed: debug << '|';
0
11628 f = true;-
11629 debug << QGraphicsItem::GraphicsItemFlag(int(flags & (1 << i)));-
11630 }
never executed: end of block
0
11631 }
never executed: end of block
0
11632 debug << ')';-
11633 return debug;
never executed: return debug;
0
11634}-
11635-
11636#endif-
11637-
11638QT_END_NAMESPACE-
11639-
11640#include "moc_qgraphicsitem.cpp"-
11641-
11642#endif // QT_NO_GRAPHICSVIEW-
Source codeSwitch to Preprocessed file

Generated by Squish Coco Non-Commercial 4.3.0-BETA-master-30-08-2018-4cb69e9