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) 2015 The Qt Company Ltd.-
4** Contact: http://www.qt.io/licensing/-
5**-
6** This file is part of the QtWidgets module of the Qt Toolkit.-
7**-
8** $QT_BEGIN_LICENSE:LGPL21$-
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 http://www.qt.io/terms-conditions. For further-
15** information use the contact form at http://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 2.1 or version 3 as published by the Free-
20** Software Foundation and appearing in the file LICENSE.LGPLv21 and-
21** LICENSE.LGPLv3 included in the packaging of this file. Please review the-
22** following information to ensure the GNU Lesser General Public License-
23** requirements will be met: https://www.gnu.org/licenses/lgpl.html and-
24** http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html.-
25**-
26** As a special exception, The Qt Company gives you certain additional-
27** rights. These rights are described in The Qt Company LGPL Exception-
28** version 1.1, included in the file LGPL_EXCEPTION.txt in this package.-
29**-
30** $QT_END_LICENSE$-
31**-
32****************************************************************************/-
33-
34/*!-
35 \class QGraphicsItem-
36 \brief The QGraphicsItem class is the base class for all graphical-
37 items in a QGraphicsScene.-
38 \since 4.2-
39-
40 \ingroup graphicsview-api-
41 \inmodule QtWidgets-
42-
43 It provides a light-weight foundation for writing your own custom items.-
44 This includes defining the item's geometry, collision detection, its-
45 painting implementation and item interaction through its event handlers.-
46 QGraphicsItem is part of the \l{Graphics View Framework}-
47-
48 \image graphicsview-items.png-
49-
50 For convenience, Qt provides a set of standard graphics items for the most-
51 common shapes. These are:-
52-
53 \list-
54 \li QGraphicsEllipseItem provides an ellipse item-
55 \li QGraphicsLineItem provides a line item-
56 \li QGraphicsPathItem provides an arbitrary path item-
57 \li QGraphicsPixmapItem provides a pixmap item-
58 \li QGraphicsPolygonItem provides a polygon item-
59 \li QGraphicsRectItem provides a rectangular item-
60 \li QGraphicsSimpleTextItem provides a simple text label item-
61 \li QGraphicsTextItem provides an advanced text browser item-
62 \endlist-
63-
64 All of an item's geometric information is based on its local coordinate-
65 system. The item's position, pos(), is the only function that does not-
66 operate in local coordinates, as it returns a position in parent-
67 coordinates. \l {The Graphics View Coordinate System} describes the coordinate-
68 system in detail.-
69-
70 You can set whether an item should be visible (i.e., drawn, and accepting-
71 events), by calling setVisible(). Hiding an item will also hide its-
72 children. Similarly, you can enable or disable an item by calling-
73 setEnabled(). If you disable an item, all its children will also be-
74 disabled. By default, items are both visible and enabled. To toggle-
75 whether an item is selected or not, first enable selection by setting-
76 the ItemIsSelectable flag, and then call setSelected(). Normally,-
77 selection is toggled by the scene, as a result of user interaction.-
78-
79 To write your own graphics item, you first create a subclass of-
80 QGraphicsItem, and then start by implementing its two pure virtual public-
81 functions: boundingRect(), which returns an estimate of the area painted-
82 by the item, and paint(), which implements the actual painting. For-
83 example:-
84-
85 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 0-
86-
87 The boundingRect() function has many different purposes.-
88 QGraphicsScene bases its item index on boundingRect(), and-
89 QGraphicsView uses it both for culling invisible items, and for-
90 determining the area that needs to be recomposed when drawing-
91 overlapping items. In addition, QGraphicsItem's collision-
92 detection mechanisms use boundingRect() to provide an efficient-
93 cut-off. The fine grained collision algorithm in-
94 collidesWithItem() is based on calling shape(), which returns an-
95 accurate outline of the item's shape as a QPainterPath.-
96-
97 QGraphicsScene expects all items boundingRect() and shape() to-
98 remain unchanged unless it is notified. If you want to change an-
99 item's geometry in any way, you must first call-
100 prepareGeometryChange() to allow QGraphicsScene to update its-
101 bookkeeping.-
102-
103 Collision detection can be done in two ways:-
104-
105 \list 1-
106-
107 \li Reimplement shape() to return an accurate shape for your item,-
108 and rely on the default implementation of collidesWithItem() to do-
109 shape-shape intersection. This can be rather expensive if the-
110 shapes are complex.-
111-
112 \li Reimplement collidesWithItem() to provide your own custom item-
113 and shape collision algorithm.-
114-
115 \endlist-
116-
117 The contains() function can be called to determine whether the item \e-
118 contains a point or not. This function can also be reimplemented by the-
119 item. The default behavior of contains() is based on calling shape().-
120-
121 Items can contain other items, and also be contained by other items. All-
122 items can have a parent item and a list of children. Unless the item has-
123 no parent, its position is in \e parent coordinates (i.e., the parent's-
124 local coordinates). Parent items propagate both their position and their-
125 transformation to all children.-
126-
127 \image graphicsview-parentchild.png-
128-
129 \target Transformations-
130 \section1 Transformations-
131-
132 QGraphicsItem supports projective transformations in addition to its base-
133 position, pos(). There are several ways to change an item's transformation.-
134 For simple transformations, you can call either of the convenience-
135 functions setRotation() or setScale(), or you can pass any transformation-
136 matrix to setTransform(). For advanced transformation control you also have-
137 the option of setting several combined transformations by calling-
138 setTransformations().-
139-
140 Item transformations accumulate from parent to child, so if both a parent-
141 and child item are rotated 90 degrees, the child's total transformation-
142 will be 180 degrees. Similarly, if the item's parent is scaled to 2x its-
143 original size, its children will also be twice as large. An item's-
144 transformation does not affect its own local geometry; all geometry-
145 functions (e.g., contains(), update(), and all the mapping functions) still-
146 operate in local coordinates. For convenience, QGraphicsItem provides the-
147 functions sceneTransform(), which returns the item's total transformation-
148 matrix (including its position and all parents' positions and-
149 transformations), and scenePos(), which returns its position in scene-
150 coordinates. To reset an item's matrix, call resetTransform().-
151-
152 Certain transformation operations produce a different outcome depending on-
153 the order in which they are applied. For example, if you scale an-
154 transform, and then rotate it, you may get a different result than if the-
155 transform was rotated first. However, the order you set the transformation-
156 properties on QGraphicsItem does not affect the resulting transformation;-
157 QGraphicsItem always applies the properties in a fixed, defined order:-
158-
159 \list-
160 \li The item's base transform is applied (transform())-
161 \li The item's transformations list is applied in order (transformations())-
162 \li The item is rotated relative to its transform origin point (rotation(), transformOriginPoint())-
163 \li The item is scaled relative to its transform origin point (scale(), transformOriginPoint())-
164 \endlist-
165-
166 \section1 Painting-
167-
168 The paint() function is called by QGraphicsView to paint the item's-
169 contents. The item has no background or default fill of its own; whatever-
170 is behind the item will shine through all areas that are not explicitly-
171 painted in this function. You can call update() to schedule a repaint,-
172 optionally passing the rectangle that needs a repaint. Depending on-
173 whether or not the item is visible in a view, the item may or may not be-
174 repainted; there is no equivalent to QWidget::repaint() in QGraphicsItem.-
175-
176 Items are painted by the view, starting with the parent items and then-
177 drawing children, in ascending stacking order. You can set an item's-
178 stacking order by calling setZValue(), and test it by calling-
179 zValue(), where items with low z-values are painted before items with-
180 high z-values. Stacking order applies to sibling items; parents are always-
181 drawn before their children.-
182-
183 \section1 Sorting-
184-
185 All items are drawn in a defined, stable order, and this same order decides-
186 which items will receive mouse input first when you click on the scene.-
187 Normally you don't have to worry about sorting, as the items follow a-
188 "natural order", following the logical structure of the scene.-
189-
190 An item's children are stacked on top of the parent, and sibling items are-
191 stacked by insertion order (i.e., in the same order that they were either-
192 added to the scene, or added to the same parent). If you add item A, and-
193 then B, then B will be on top of A. If you then add C, the items' stacking-
194 order will be A, then B, then C.-
195-
196 \image graphicsview-zorder.png-
197-
198 This example shows the stacking order of all limbs of the robot from the-
199 \l{graphicsview/dragdroprobot}{Drag and Drop Robot} example. The torso is-
200 the root item (all other items are children or descendants of the torso),-
201 so it is drawn first. Next, the head is drawn, as it is the first item in-
202 the torso's list of children. Then the upper left arm is drawn. As the-
203 lower arm is a child of the upper arm, the lower arm is then drawn,-
204 followed by the upper arm's next sibling, which is the upper right arm, and-
205 so on.-
206-
207 For advanced users, there are ways to alter how your items are sorted:-
208-
209 \list-
210 \li You can call setZValue() on an item to explicitly stack it on top of, or-
211 under, other sibling items. The default Z value for an item is 0. Items-
212 with the same Z value are stacked by insertion order.-
213-
214 \li You can call stackBefore() to reorder the list of children. This will-
215 directly modify the insertion order.-
216-
217 \li You can set the ItemStacksBehindParent flag to stack a child item behind-
218 its parent.-
219 \endlist-
220-
221 The stacking order of two sibling items also counts for each item's-
222 children and descendant items. So if one item is on top of another, then-
223 all its children will also be on top of all the other item's children as-
224 well.-
225-
226 \section1 Events-
227-
228 QGraphicsItem receives events from QGraphicsScene through the virtual-
229 function sceneEvent(). This function distributes the most common events-
230 to a set of convenience event handlers:-
231-
232 \list-
233 \li contextMenuEvent() handles context menu events-
234 \li focusInEvent() and focusOutEvent() handle focus in and out events-
235 \li hoverEnterEvent(), hoverMoveEvent(), and hoverLeaveEvent() handles-
236 hover enter, move and leave events-
237 \li inputMethodEvent() handles input events, for accessibility support-
238 \li keyPressEvent() and keyReleaseEvent() handle key press and release events-
239 \li mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(), and-
240 mouseDoubleClickEvent() handles mouse press, move, release, click and-
241 doubleclick events-
242 \endlist-
243-
244 You can filter events for any other item by installing event filters. This-
245 functionality is separate from Qt's regular event filters (see-
246 QObject::installEventFilter()), which only work on subclasses of QObject. After-
247 installing your item as an event filter for another item by calling-
248 installSceneEventFilter(), the filtered events will be received by the virtual-
249 function sceneEventFilter(). You can remove item event filters by calling-
250 removeSceneEventFilter().-
251-
252 \section1 Custom Data-
253-
254 Sometimes it's useful to register custom data with an item, be it a custom-
255 item, or a standard item. You can call setData() on any item to store data-
256 in it using a key-value pair (the key being an integer, and the value is a-
257 QVariant). To get custom data from an item, call data(). This-
258 functionality is completely untouched by Qt itself; it is provided for the-
259 user's convenience.-
260-
261 \sa QGraphicsScene, QGraphicsView, {Graphics View Framework}-
262*/-
263-
264/*!-
265 \variable QGraphicsItem::Type-
266-
267 The type value returned by the virtual type() function in standard-
268 graphics item classes in Qt. All such standard graphics item-
269 classes in Qt are associated with a unique value for Type,-
270 e.g. the value returned by QGraphicsPathItem::type() is 2.-
271-
272 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 18-
273*/-
274-
275/*!-
276 \variable QGraphicsItem::UserType-
277-
278 The lowest permitted type value for custom items (subclasses-
279 of QGraphicsItem or any of the standard items). This value is-
280 used in conjunction with a reimplementation of QGraphicsItem::type()-
281 and declaring a Type enum value. Example:-
282-
283 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 1-
284-
285 \note UserType = 65536-
286*/-
287-
288/*!-
289 \enum QGraphicsItem::GraphicsItemFlag-
290-
291 This enum describes different flags that you can set on an item to-
292 toggle different features in the item's behavior.-
293-
294 All flags are disabled by default.-
295-
296 \value ItemIsMovable The item supports interactive movement using-
297 the mouse. By clicking on the item and then dragging, the item-
298 will move together with the mouse cursor. If the item has-
299 children, all children are also moved. If the item is part of a-
300 selection, all selected items are also moved. This feature is-
301 provided as a convenience through the base implementation of-
302 QGraphicsItem's mouse event handlers.-
303-
304 \value ItemIsSelectable The item supports selection. Enabling this-
305 feature will enable setSelected() to toggle selection for the-
306 item. It will also let the item be selected automatically as a-
307 result of calling QGraphicsScene::setSelectionArea(), by clicking-
308 on an item, or by using rubber band selection in QGraphicsView.-
309-
310 \value ItemIsFocusable The item supports keyboard input focus (i.e., it is-
311 an input item). Enabling this flag will allow the item to accept focus,-
312 which again allows the delivery of key events to-
313 QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent().-
314-
315 \value ItemClipsToShape The item clips to its own shape. The item cannot-
316 draw or receive mouse, tablet, drag and drop or hover events outside its-
317 shape. It is disabled by default. This behavior is enforced by-
318 QGraphicsView::drawItems() or QGraphicsScene::drawItems(). This flag was-
319 introduced in Qt 4.3.-
320-
321 \value ItemClipsChildrenToShape The item clips the painting of all its-
322 descendants to its own shape. Items that are either direct or indirect-
323 children of this item cannot draw outside this item's shape. By default,-
324 this flag is disabled; children can draw anywhere. This behavior is-
325 enforced by QGraphicsView::drawItems() or-
326 QGraphicsScene::drawItems(). This flag was introduced in Qt 4.3.-
327 \note This flag is similar to ItemContainsChildrenInShape but in addition-
328 enforces the containment by clipping the children.-
329-
330 \value ItemIgnoresTransformations The item ignores inherited-
331 transformations (i.e., its position is still anchored to its parent, but-
332 the parent or view rotation, zoom or shear transformations are ignored).-
333 This flag is useful for keeping text label items horizontal and unscaled,-
334 so they will still be readable if the view is transformed. When set, the-
335 item's view geometry and scene geometry will be maintained separately. You-
336 must call deviceTransform() to map coordinates and detect collisions in-
337 the view. By default, this flag is disabled. This flag was introduced in-
338 Qt 4.3. \note With this flag set you can still scale the item itself, and-
339 that scale transformation will influence the item's children.-
340-
341 \value ItemIgnoresParentOpacity The item ignores its parent's opacity. The-
342 item's effective opacity is the same as its own; it does not combine with-
343 the parent's opacity. This flags allows your item to keep its absolute-
344 opacity even if the parent is semitransparent. This flag was introduced in-
345 Qt 4.5.-
346-
347 \value ItemDoesntPropagateOpacityToChildren The item doesn't propagate its-
348 opacity to its children. This flag allows you to create a semitransparent-
349 item that does not affect the opacity of its children. This flag was-
350 introduced in Qt 4.5.-
351-
352 \value ItemStacksBehindParent The item is stacked behind its parent. By-
353 default, child items are stacked on top of the parent item. But setting-
354 this flag, the child will be stacked behind it. This flag is useful for-
355 drop shadow effects and for decoration objects that follow the parent-
356 item's geometry without drawing on top of it. This flag was introduced-
357 in Qt 4.5.-
358-
359 \value ItemUsesExtendedStyleOption The item makes use of either-
360 \l{QStyleOptionGraphicsItem::} {exposedRect} or-
361 \l{QStyleOptionGraphicsItem::} {matrix} in-
362 QStyleOptionGraphicsItem. By default, the-
363 \l{QStyleOptionGraphicsItem::} {exposedRect} is initialized to the-
364 item's boundingRect() and the-
365 \l{QStyleOptionGraphicsItem::}{matrix} is untransformed. You can-
366 enable this flag for the style options to be set up with more-
367 fine-grained values. Note that-
368 QStyleOptionGraphicsItem::levelOfDetail is unaffected by this flag-
369 and always initialized to 1. Use-
370 QStyleOptionGraphicsItem::levelOfDetailFromTransform() if you need-
371 a higher value. This flag was introduced in Qt 4.6.-
372-
373 \value ItemHasNoContents The item does not paint anything (i.e., calling-
374 paint() on the item has no effect). You should set this flag on items that-
375 do not need to be painted to ensure that Graphics View avoids unnecessary-
376 painting preparations. This flag was introduced in Qt 4.6.-
377-
378 \value ItemSendsGeometryChanges The item enables itemChange()-
379 notifications for ItemPositionChange, ItemPositionHasChanged,-
380 ItemMatrixChange, ItemTransformChange, ItemTransformHasChanged,-
381 ItemRotationChange, ItemRotationHasChanged, ItemScaleChange, ItemScaleHasChanged,-
382 ItemTransformOriginPointChange, and ItemTransformOriginPointHasChanged. For-
383 performance reasons, these notifications are disabled by default. You must-
384 enable this flag to receive notifications for position and transform-
385 changes. This flag was introduced in Qt 4.6.-
386-
387 \value ItemAcceptsInputMethod The item supports input methods typically-
388 used for Asian languages.-
389 This flag was introduced in Qt 4.6.-
390-
391 \value ItemNegativeZStacksBehindParent The item automatically-
392 stacks behind it's parent if it's z-value is negative. This flag-
393 enables setZValue() to toggle ItemStacksBehindParent. This flag-
394 was introduced in Qt 4.6.-
395-
396 \value ItemIsPanel The item is a panel. A panel provides activation and-
397 contained focus handling. Only one panel can be active at a time (see-
398 QGraphicsItem::isActive()). When no panel is active, QGraphicsScene-
399 activates all non-panel items. Window items (i.e.,-
400 QGraphicsItem::isWindow() returns \c true) are panels. This flag was-
401 introduced in Qt 4.6.-
402-
403 \omitvalue ItemIsFocusScope \omit Internal only (for now). \endomit-
404-
405 \value ItemSendsScenePositionChanges The item enables itemChange()-
406 notifications for ItemScenePositionHasChanged. For performance reasons,-
407 these notifications are disabled by default. You must enable this flag-
408 to receive notifications for scene position changes. This flag was-
409 introduced in Qt 4.6.-
410-
411 \omitvalue ItemStopsClickFocusPropagation \omit The item stops propagating-
412 click focus to items underneath when being clicked on. This flag-
413 allows you create a non-focusable item that can be clicked on without-
414 changing the focus. \endomit-
415-
416 \omitvalue ItemStopsFocusHandling \omit Same as-
417 ItemStopsClickFocusPropagation, but also suppresses focus-out. This flag-
418 allows you to completely take over focus handling.-
419 This flag was introduced in Qt 4.7. \endomit-
420-
421 \value ItemContainsChildrenInShape This flag indicates that all of the-
422 item's direct or indirect children only draw within the item's shape.-
423 Unlike ItemClipsChildrenToShape, this restriction is not enforced. Set-
424 ItemContainsChildrenInShape when you manually assure that drawing-
425 is bound to the item's shape and want to avoid the cost associated with-
426 enforcing the clip. Setting this flag enables more efficient drawing and-
427 collision detection. The flag is disabled by default.-
428 \note If both this flag and ItemClipsChildrenToShape are set, the clip-
429 will be enforced. This is equivalent to just setting-
430 ItemClipsChildrenToShape.-
431-
432 This flag was introduced in Qt 5.4.-
433*/-
434-
435/*!-
436 \enum QGraphicsItem::GraphicsItemChange-
437-
438 This enum describes the state changes that are notified by-
439 QGraphicsItem::itemChange(). The notifications are sent as the state-
440 changes, and in some cases, adjustments can be made (see the documentation-
441 for each change for details).-
442-
443 Note: Be careful with calling functions on the QGraphicsItem itself inside-
444 itemChange(), as certain function calls can lead to unwanted-
445 recursion. For example, you cannot call setPos() in itemChange() on an-
446 ItemPositionChange notification, as the setPos() function will again call-
447 itemChange(ItemPositionChange). Instead, you can return the new, adjusted-
448 position from itemChange().-
449-
450 \value ItemEnabledChange The item's enabled state changes. If the item is-
451 presently enabled, it will become disabled, and vice verca. The value-
452 argument is the new enabled state (i.e., true or false). Do not call-
453 setEnabled() in itemChange() as this notification is delivered. Instead,-
454 you can return the new state from itemChange().-
455-
456 \value ItemEnabledHasChanged The item's enabled state has changed. The-
457 value argument is the new enabled state (i.e., true or false). Do not call-
458 setEnabled() in itemChange() as this notification is delivered. The return-
459 value is ignored.-
460-
461 \value ItemMatrixChange The item's affine transformation matrix is-
462 changing. This value is obsolete; you can use ItemTransformChange instead.-
463-
464 \value ItemPositionChange The item's position changes. This notification-
465 is sent if the ItemSendsGeometryChanges flag is enabled, and when the-
466 item's local position changes, relative to its parent (i.e., as a result-
467 of calling setPos() or moveBy()). The value argument is the new position-
468 (i.e., a QPointF). You can call pos() to get the original position. Do-
469 not call setPos() or moveBy() in itemChange() as this notification is-
470 delivered; instead, you can return the new, adjusted position from-
471 itemChange(). After this notification, QGraphicsItem immediately sends the-
472 ItemPositionHasChanged notification if the position changed.-
473-
474 \value ItemPositionHasChanged The item's position has changed. This-
475 notification is sent if the ItemSendsGeometryChanges flag is enabled, and-
476 after the item's local position, relative to its parent, has changed. The-
477 value argument is the new position (the same as pos()), and QGraphicsItem-
478 ignores the return value for this notification (i.e., a read-only-
479 notification).-
480-
481 \value ItemTransformChange The item's transformation matrix changes. This-
482 notification is sent if the ItemSendsGeometryChanges flag is enabled, and-
483 when the item's local transformation matrix changes (i.e., as a result of-
484 calling setTransform(). The value argument is the new matrix (i.e., a-
485 QTransform); to get the old matrix, call transform(). Do not call-
486 setTransform() or set any of the transformation properties in itemChange()-
487 as this notification is delivered; instead, you can return the new matrix-
488 from itemChange(). This notification is not sent if you change the-
489 transformation properties.-
490-
491 \value ItemTransformHasChanged The item's transformation matrix has-
492 changed either because setTransform is called, or one of the-
493 transformation properties is changed. This notification is sent if the-
494 ItemSendsGeometryChanges flag is enabled, and after the item's local-
495 transformation matrix has changed. The value argument is the new matrix-
496 (same as transform()), and QGraphicsItem ignores the return value for this-
497 notification (i.e., a read-only notification).-
498-
499 \value ItemRotationChange The item's rotation property changes. This-
500 notification is sent if the ItemSendsGeometryChanges flag is enabled, and-
501 when the item's rotation property changes (i.e., as a result of calling-
502 setRotation()). The value argument is the new rotation (i.e., a double);-
503 to get the old rotation, call rotation(). Do not call setRotation() in-
504 itemChange() as this notification is delivered; instead, you can return-
505 the new rotation from itemChange().-
506-
507 \value ItemRotationHasChanged The item's rotation property has changed.-
508 This notification is sent if the ItemSendsGeometryChanges flag is enabled,-
509 and after the item's rotation property has changed. The value argument is-
510 the new rotation (i.e., a double), and QGraphicsItem ignores the return-
511 value for this notification (i.e., a read-only notification). Do not call-
512 setRotation() in itemChange() as this notification is delivered.-
513-
514 \value ItemScaleChange The item's scale property changes. This notification-
515 is sent if the ItemSendsGeometryChanges flag is enabled, and when the item's-
516 scale property changes (i.e., as a result of calling setScale()). The value-
517 argument is the new scale (i.e., a double); to get the old scale, call-
518 scale(). Do not call setScale() in itemChange() as this notification is-
519 delivered; instead, you can return the new scale from itemChange().-
520-
521 \value ItemScaleHasChanged The item's scale property has changed. This-
522 notification is sent if the ItemSendsGeometryChanges flag is enabled, and-
523 after the item's scale property has changed. The value argument is the new-
524 scale (i.e., a double), and QGraphicsItem ignores the return value for this-
525 notification (i.e., a read-only notification). Do not call setScale() in-
526 itemChange() as this notification is delivered.-
527-
528 \value ItemTransformOriginPointChange The item's transform origin point-
529 property changes. This notification is sent if the ItemSendsGeometryChanges-
530 flag is enabled, and when the item's transform origin point property changes-
531 (i.e., as a result of calling setTransformOriginPoint()). The value argument-
532 is the new origin point (i.e., a QPointF); to get the old origin point, call-
533 transformOriginPoint(). Do not call setTransformOriginPoint() in itemChange()-
534 as this notification is delivered; instead, you can return the new transform-
535 origin point from itemChange().-
536-
537 \value ItemTransformOriginPointHasChanged The item's transform origin point-
538 property has changed. This notification is sent if the ItemSendsGeometryChanges-
539 flag is enabled, and after the item's transform origin point property has-
540 changed. The value argument is the new origin point (i.e., a QPointF), and-
541 QGraphicsItem ignores the return value for this notification (i.e., a read-only-
542 notification). Do not call setTransformOriginPoint() in itemChange() as this-
543 notification is delivered.-
544-
545 \value ItemSelectedChange The item's selected state changes. If the item is-
546 presently selected, it will become unselected, and vice verca. The value-
547 argument is the new selected state (i.e., true or false). Do not call-
548 setSelected() in itemChange() as this notification is delivered; instead, you-
549 can return the new selected state from itemChange().-
550-
551 \value ItemSelectedHasChanged The item's selected state has changed. The-
552 value argument is the new selected state (i.e., true or false). Do not-
553 call setSelected() in itemChange() as this notification is delivered. The-
554 return value is ignored.-
555-
556 \value ItemVisibleChange The item's visible state changes. If the item is-
557 presently visible, it will become invisible, and vice verca. The value-
558 argument is the new visible state (i.e., true or false). Do not call-
559 setVisible() in itemChange() as this notification is delivered; instead,-
560 you can return the new visible state from itemChange().-
561-
562 \value ItemVisibleHasChanged The item's visible state has changed. The-
563 value argument is the new visible state (i.e., true or false). Do not call-
564 setVisible() in itemChange() as this notification is delivered. The return-
565 value is ignored.-
566-
567 \value ItemParentChange The item's parent changes. The value argument is-
568 the new parent item (i.e., a QGraphicsItem pointer). Do not call-
569 setParentItem() in itemChange() as this notification is delivered;-
570 instead, you can return the new parent from itemChange().-
571-
572 \value ItemParentHasChanged The item's parent has changed. The value-
573 argument is the new parent (i.e., a pointer to a QGraphicsItem). Do not-
574 call setParentItem() in itemChange() as this notification is-
575 delivered. The return value is ignored.-
576-
577 \value ItemChildAddedChange A child is added to this item. The value-
578 argument is the new child item (i.e., a QGraphicsItem pointer). Do not-
579 pass this item to any item's setParentItem() function as this notification-
580 is delivered. The return value is unused; you cannot adjust anything in-
581 this notification. Note that the new child might not be fully constructed-
582 when this notification is sent; calling pure virtual functions on-
583 the child can lead to a crash.-
584-
585 \value ItemChildRemovedChange A child is removed from this item. The value-
586 argument is the child item that is about to be removed (i.e., a-
587 QGraphicsItem pointer). The return value is unused; you cannot adjust-
588 anything in this notification.-
589-
590 \value ItemSceneChange The item is moved to a new scene. This notification is-
591 also sent when the item is added to its initial scene, and when it is removed.-
592 The item's scene() is the old scene (or 0 if the item has not been added to a-
593 scene yet). The value argument is the new scene (i.e., a QGraphicsScene-
594 pointer), or a null pointer if the item is removed from a scene. Do not-
595 override this change by passing this item to QGraphicsScene::addItem() as this-
596 notification is delivered; instead, you can return the new scene from-
597 itemChange(). Use this feature with caution; objecting to a scene change can-
598 quickly lead to unwanted recursion.-
599-
600 \value ItemSceneHasChanged The item's scene has changed. The item's scene() is-
601 the new scene. This notification is also sent when the item is added to its-
602 initial scene, and when it is removed.The value argument is the new scene-
603 (i.e., a pointer to a QGraphicsScene). Do not call setScene() in itemChange()-
604 as this notification is delivered. The return value is ignored.-
605-
606 \value ItemCursorChange The item's cursor changes. The value argument is-
607 the new cursor (i.e., a QCursor). Do not call setCursor() in itemChange()-
608 as this notification is delivered. Instead, you can return a new cursor-
609 from itemChange().-
610-
611 \value ItemCursorHasChanged The item's cursor has changed. The value-
612 argument is the new cursor (i.e., a QCursor). Do not call setCursor() as-
613 this notification is delivered. The return value is ignored.-
614-
615 \value ItemToolTipChange The item's tooltip changes. The value argument is-
616 the new tooltip (i.e., a QToolTip). Do not call setToolTip() in-
617 itemChange() as this notification is delivered. Instead, you can return a-
618 new tooltip from itemChange().-
619-
620 \value ItemToolTipHasChanged The item's tooltip has changed. The value-
621 argument is the new tooltip (i.e., a QToolTip). Do not call setToolTip()-
622 as this notification is delivered. The return value is ignored.-
623-
624 \value ItemFlagsChange The item's flags change. The value argument is the-
625 new flags (i.e., a quint32). Do not call setFlags() in itemChange() as-
626 this notification is delivered. Instead, you can return the new flags from-
627 itemChange().-
628-
629 \value ItemFlagsHaveChanged The item's flags have changed. The value-
630 argument is the new flags (i.e., a quint32). Do not call setFlags() in-
631 itemChange() as this notification is delivered. The return value is-
632 ignored.-
633-
634 \value ItemZValueChange The item's Z-value changes. The value argument is-
635 the new Z-value (i.e., a double). Do not call setZValue() in itemChange()-
636 as this notification is delivered. Instead, you can return a new Z-value-
637 from itemChange().-
638-
639 \value ItemZValueHasChanged The item's Z-value has changed. The value-
640 argument is the new Z-value (i.e., a double). Do not call setZValue() as-
641 this notification is delivered. The return value is ignored.-
642-
643 \value ItemOpacityChange The item's opacity changes. The value argument is-
644 the new opacity (i.e., a double). Do not call setOpacity() in itemChange()-
645 as this notification is delivered. Instead, you can return a new opacity-
646 from itemChange().-
647-
648 \value ItemOpacityHasChanged The item's opacity has changed. The value-
649 argument is the new opacity (i.e., a double). Do not call setOpacity() as-
650 this notification is delivered. The return value is ignored.-
651-
652 \value ItemScenePositionHasChanged The item's scene position has changed.-
653 This notification is sent if the ItemSendsScenePositionChanges flag is-
654 enabled, and after the item's scene position has changed (i.e., the-
655 position or transformation of the item itself or the position or-
656 transformation of any ancestor has changed). The value argument is the-
657 new scene position (the same as scenePos()), and QGraphicsItem ignores-
658 the return value for this notification (i.e., a read-only notification).-
659*/-
660-
661/*!-
662 \enum QGraphicsItem::CacheMode-
663 \since 4.4-
664-
665 This enum describes QGraphicsItem's cache modes. Caching is used to speed-
666 up rendering by allocating and rendering to an off-screen pixel buffer,-
667 which can be reused when the item requires redrawing. For some paint-
668 devices, the cache is stored directly in graphics memory, which makes-
669 rendering very quick.-
670-
671 \value NoCache The default; all item caching is-
672 disabled. QGraphicsItem::paint() is called every time the item needs-
673 redrawing.-
674-
675 \value ItemCoordinateCache Caching is enabled for the item's logical-
676 (local) coordinate system. QGraphicsItem creates an off-screen pixel-
677 buffer with a configurable size / resolution that you can pass to-
678 QGraphicsItem::setCacheMode(). Rendering quality will typically degrade,-
679 depending on the resolution of the cache and the item transformation. The-
680 first time the item is redrawn, it will render itself into the cache, and-
681 the cache is then reused for every subsequent expose. The cache is also-
682 reused as the item is transformed. To adjust the resolution of the cache,-
683 you can call setCacheMode() again.-
684-
685 \value DeviceCoordinateCache Caching is enabled at the paint device level,-
686 in device coordinates. This mode is for items that can move, but are not-
687 rotated, scaled or sheared. If the item is transformed directly or-
688 indirectly, the cache will be regenerated automatically. Unlike-
689 ItemCoordinateCacheMode, DeviceCoordinateCache always renders at maximum-
690 quality.-
691-
692 \sa QGraphicsItem::setCacheMode()-
693*/-
694-
695/*!-
696 \enum QGraphicsItem::Extension-
697 \internal-
698-
699 Note: This is provided as a hook to avoid future problems related-
700 to adding virtual functions. See also extension(),-
701 supportsExtension() and setExtension().-
702*/-
703-
704/*!-
705 \enum QGraphicsItem::PanelModality-
706 \since 4.6-
707-
708 This enum specifies the behavior of a modal panel. A modal panel-
709 is one that blocks input to other panels. Note that items that-
710 are children of a modal panel are not blocked.-
711-
712 The values are:-
713-
714 \value NonModal The panel is not modal and does not block input to-
715 other panels. This is the default value for panels.-
716-
717 \value PanelModal The panel is modal to a single item hierarchy-
718 and blocks input to its parent pane, all grandparent panels, and-
719 all siblings of its parent and grandparent panels.-
720-
721 \value SceneModal The window is modal to the entire scene and-
722 blocks input to all panels.-
723-
724 \sa QGraphicsItem::setPanelModality(), QGraphicsItem::panelModality(), QGraphicsItem::ItemIsPanel-
725*/-
726-
727#include "qgraphicsitem.h"-
728-
729#ifndef QT_NO_GRAPHICSVIEW-
730-
731#include "qgraphicsscene.h"-
732#include "qgraphicsscene_p.h"-
733#include "qgraphicssceneevent.h"-
734#include "qgraphicsview.h"-
735#include "qgraphicswidget.h"-
736#include "qgraphicsproxywidget.h"-
737#include "qgraphicsscenebsptreeindex_p.h"-
738#include <QtCore/qbitarray.h>-
739#include <QtCore/qpoint.h>-
740#include <QtCore/qstack.h>-
741#include <QtCore/qtimer.h>-
742#include <QtCore/qvariant.h>-
743#include <QtCore/qvarlengtharray.h>-
744#include <QtCore/qnumeric.h>-
745#include <QtWidgets/qapplication.h>-
746#include <QtGui/qbitmap.h>-
747#include <QtGui/qpainter.h>-
748#include <QtGui/qpainterpath.h>-
749#include <QtGui/qpixmapcache.h>-
750#include <QtWidgets/qstyleoption.h>-
751#include <QtGui/qevent.h>-
752#include <QtGui/qinputmethod.h>-
753#include <QtWidgets/qgraphicseffect.h>-
754-
755#include <private/qgraphicsitem_p.h>-
756#include <private/qgraphicswidget_p.h>-
757#include <private/qwidgettextcontrol_p.h>-
758#include <private/qtextdocumentlayout_p.h>-
759#include <private/qtextengine_p.h>-
760#include <private/qwidget_p.h>-
761#include <private/qapplication_p.h>-
762#include <private/qgesturemanager_p.h>-
763#include <private/qdebug_p.h>-
764-
765QT_BEGIN_NAMESPACE-
766-
767static inline void _q_adjustRect(QRect *rect)-
768{-
769 Q_ASSERT(rect);-
770 if (!rect->width())
!rect->width()Description
TRUEnever evaluated
FALSEnever evaluated
0
771 rect->adjust(0, 0, 1, 0);
never executed: rect->adjust(0, 0, 1, 0);
0
772 if (!rect->height())
!rect->height()Description
TRUEnever evaluated
FALSEnever evaluated
0
773 rect->adjust(0, 0, 0, 1);
never executed: rect->adjust(0, 0, 0, 1);
0
774}
never executed: end of block
0
775-
776/*-
777 ### Move this into QGraphicsItemPrivate-
778 */-
779class QGraphicsItemCustomDataStore-
780{-
781public:-
782 QHash<const QGraphicsItem *, QMap<int, QVariant> > data;-
783};-
784Q_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
785-
786/*!-
787 \internal-
788-
789 Returns a QPainterPath of \a path when stroked with the \a pen.-
790 Ignoring dash pattern.-
791*/-
792static QPainterPath qt_graphicsItem_shapeFromPath(const QPainterPath &path, const QPen &pen)-
793{-
794 // We unfortunately need this hack as QPainterPathStroker will set a width of 1.0-
795 // if we pass a value of 0.0 to QPainterPathStroker::setWidth()-
796 const qreal penWidthZero = qreal(0.00000001);-
797-
798 if (path == QPainterPath() || pen == Qt::NoPen)
path == QPainterPath()Description
TRUEnever evaluated
FALSEnever evaluated
pen == Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
0
799 return path;
never executed: return path;
0
800 QPainterPathStroker ps;-
801 ps.setCapStyle(pen.capStyle());-
802 if (pen.widthF() <= 0.0)
pen.widthF() <= 0.0Description
TRUEnever evaluated
FALSEnever evaluated
0
803 ps.setWidth(penWidthZero);
never executed: ps.setWidth(penWidthZero);
0
804 else-
805 ps.setWidth(pen.widthF());
never executed: ps.setWidth(pen.widthF());
0
806 ps.setJoinStyle(pen.joinStyle());-
807 ps.setMiterLimit(pen.miterLimit());-
808 QPainterPath p = ps.createStroke(path);-
809 p.addPath(path);-
810 return p;
never executed: return p;
0
811}-
812-
813/*!-
814 \internal-
815-
816 Propagates the ancestor flag \a flag with value \a enabled to all this-
817 item's children. If \a root is false, the flag is also set on this item-
818 (default is true).-
819*/-
820void QGraphicsItemPrivate::updateAncestorFlag(QGraphicsItem::GraphicsItemFlag childFlag,-
821 AncestorFlag flag, bool enabled, bool root)-
822{-
823 Q_Q(QGraphicsItem);-
824 if (root) {
rootDescription
TRUEnever evaluated
FALSEnever evaluated
0
825 // For root items only. This is the item that has either enabled or-
826 // disabled \a childFlag, or has been reparented.-
827 switch (int(childFlag)) {-
828 case -2:
never executed: case -2:
0
829 flag = AncestorFiltersChildEvents;-
830 enabled = q->filtersChildEvents();-
831 break;
never executed: break;
0
832 case -1:
never executed: case -1:
0
833 flag = AncestorHandlesChildEvents;-
834 enabled = q->handlesChildEvents();-
835 break;
never executed: break;
0
836 case QGraphicsItem::ItemClipsChildrenToShape:
never executed: case QGraphicsItem::ItemClipsChildrenToShape:
0
837 flag = AncestorClipsChildren;-
838 enabled = flags & QGraphicsItem::ItemClipsChildrenToShape;-
839 break;
never executed: break;
0
840 case QGraphicsItem::ItemIgnoresTransformations:
never executed: case QGraphicsItem::ItemIgnoresTransformations:
0
841 flag = AncestorIgnoresTransformations;-
842 enabled = flags & QGraphicsItem::ItemIgnoresTransformations;-
843 break;
never executed: break;
0
844 case QGraphicsItem::ItemContainsChildrenInShape:
never executed: case QGraphicsItem::ItemContainsChildrenInShape:
0
845 flag = AncestorContainsChildren;-
846 enabled = flags & QGraphicsItem::ItemContainsChildrenInShape;-
847 break;
never executed: break;
0
848 default:
never executed: default:
0
849 return;
never executed: return;
0
850 }-
851-
852 if (parent) {
parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
853 // Inherit the enabled-state from our parents.-
854 if ((parent->d_ptr->ancestorFlags & flag)
(parent->d_ptr...rFlags & flag)Description
TRUEnever evaluated
FALSEnever evaluated
0
855 || (int(parent->d_ptr->flags & childFlag) == childFlag)
(int(parent->d... == childFlag)Description
TRUEnever evaluated
FALSEnever evaluated
0
856 || (int(childFlag) == -1 && parent->d_ptr->handlesChildEvents)
int(childFlag) == -1Description
TRUEnever evaluated
FALSEnever evaluated
parent->d_ptr-...lesChildEventsDescription
TRUEnever evaluated
FALSEnever evaluated
0
857 || (int(childFlag) == -2 && parent->d_ptr->filtersDescendantEvents)) {
int(childFlag) == -2Description
TRUEnever evaluated
FALSEnever evaluated
parent->d_ptr-...scendantEventsDescription
TRUEnever evaluated
FALSEnever evaluated
0
858 enabled = true;-
859 ancestorFlags |= flag;-
860 } else {
never executed: end of block
0
861 ancestorFlags &= ~flag;-
862 }
never executed: end of block
0
863 } else {-
864 // Top-level root items don't have any ancestors, so there are no-
865 // ancestor flags either.-
866 ancestorFlags = 0;-
867 }
never executed: end of block
0
868 } else {-
869 // Don't set or propagate the ancestor flag if it's already correct.-
870 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
871 return;
never executed: return;
0
872-
873 // Set the flag.-
874 if (enabled)
enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
875 ancestorFlags |= flag;
never executed: ancestorFlags |= flag;
0
876 else-
877 ancestorFlags &= ~flag;
never executed: ancestorFlags &= ~flag;
0
878-
879 // Don't process children if the item has the main flag set on itself.-
880 if ((int(childFlag) != -1 && int(flags & childFlag) == childFlag)
int(childFlag) != -1Description
TRUEnever evaluated
FALSEnever evaluated
int(flags & ch...) == childFlagDescription
TRUEnever evaluated
FALSEnever evaluated
0
881 || (int(childFlag) == -1 && handlesChildEvents)
int(childFlag) == -1Description
TRUEnever evaluated
FALSEnever evaluated
handlesChildEventsDescription
TRUEnever evaluated
FALSEnever evaluated
0
882 || (int(childFlag) == -2 && filtersDescendantEvents))
int(childFlag) == -2Description
TRUEnever evaluated
FALSEnever evaluated
filtersDescendantEventsDescription
TRUEnever evaluated
FALSEnever evaluated
0
883 return;
never executed: return;
0
884 }
never executed: end of block
0
885-
886 for (int i = 0; i < children.size(); ++i)
i < children.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
887 children.at(i)->d_ptr->updateAncestorFlag(childFlag, flag, enabled, false);
never executed: children.at(i)->d_ptr->updateAncestorFlag(childFlag, flag, enabled, false);
0
888}
never executed: end of block
0
889-
890void QGraphicsItemPrivate::updateAncestorFlags()-
891{-
892 int flags = 0;-
893 if (parent) {
parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
894 // Inherit the parent's ancestor flags.-
895 QGraphicsItemPrivate *pd = parent->d_ptr.data();-
896 flags = pd->ancestorFlags;-
897-
898 // Add in flags from the parent.-
899 if (pd->filtersDescendantEvents)
pd->filtersDescendantEventsDescription
TRUEnever evaluated
FALSEnever evaluated
0
900 flags |= AncestorFiltersChildEvents;
never executed: flags |= AncestorFiltersChildEvents;
0
901 if (pd->handlesChildEvents)
pd->handlesChildEventsDescription
TRUEnever evaluated
FALSEnever evaluated
0
902 flags |= AncestorHandlesChildEvents;
never executed: flags |= AncestorHandlesChildEvents;
0
903 if (pd->flags & QGraphicsItem::ItemClipsChildrenToShape)
pd->flags & QG...hildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
904 flags |= AncestorClipsChildren;
never executed: flags |= AncestorClipsChildren;
0
905 if (pd->flags & QGraphicsItem::ItemIgnoresTransformations)
pd->flags & QG...ransformationsDescription
TRUEnever evaluated
FALSEnever evaluated
0
906 flags |= AncestorIgnoresTransformations;
never executed: flags |= AncestorIgnoresTransformations;
0
907 if (pd->flags & QGraphicsItem::ItemContainsChildrenInShape)
pd->flags & QG...hildrenInShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
908 flags |= AncestorContainsChildren;
never executed: flags |= AncestorContainsChildren;
0
909 }
never executed: end of block
0
910-
911 if (ancestorFlags == flags)
ancestorFlags == flagsDescription
TRUEnever evaluated
FALSEnever evaluated
0
912 return; // No change; stop propagation.
never executed: return;
0
913 ancestorFlags = flags;-
914-
915 // Propagate to children recursively.-
916 for (int i = 0; i < children.size(); ++i)
i < children.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
917 children.at(i)->d_ptr->updateAncestorFlags();
never executed: children.at(i)->d_ptr->updateAncestorFlags();
0
918}
never executed: end of block
0
919-
920/*!-
921 \internal-
922-
923 Propagates item group membership.-
924*/-
925void QGraphicsItemPrivate::setIsMemberOfGroup(bool enabled)-
926{-
927 Q_Q(QGraphicsItem);-
928 isMemberOfGroup = enabled;-
929 if (!qgraphicsitem_cast<QGraphicsItemGroup *>(q)) {
!qgraphicsitem...temGroup *>(q)Description
TRUEnever evaluated
FALSEnever evaluated
0
930 foreach (QGraphicsItem *child, children)-
931 child->d_func()->setIsMemberOfGroup(enabled);
never executed: child->d_func()->setIsMemberOfGroup(enabled);
0
932 }
never executed: end of block
0
933}
never executed: end of block
0
934-
935/*!-
936 \internal-
937-
938 Maps any item pos properties of \a event to \a item's coordinate system.-
939*/-
940void QGraphicsItemPrivate::remapItemPos(QEvent *event, QGraphicsItem *item)-
941{-
942 Q_Q(QGraphicsItem);-
943 switch (event->type()) {-
944 case QEvent::GraphicsSceneMouseMove:
never executed: case QEvent::GraphicsSceneMouseMove:
0
945 case QEvent::GraphicsSceneMousePress:
never executed: case QEvent::GraphicsSceneMousePress:
0
946 case QEvent::GraphicsSceneMouseRelease:
never executed: case QEvent::GraphicsSceneMouseRelease:
0
947 case QEvent::GraphicsSceneMouseDoubleClick: {
never executed: case QEvent::GraphicsSceneMouseDoubleClick:
0
948 QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event);-
949 mouseEvent->setPos(item->mapFromItem(q, mouseEvent->pos()));-
950 mouseEvent->setLastPos(item->mapFromItem(q, mouseEvent->pos()));-
951 for (int i = 0x1; i <= 0x10; i <<= 1) {
i <= 0x10Description
TRUEnever evaluated
FALSEnever evaluated
0
952 if (mouseEvent->buttons() & i) {
mouseEvent->buttons() & iDescription
TRUEnever evaluated
FALSEnever evaluated
0
953 Qt::MouseButton button = Qt::MouseButton(i);-
954 mouseEvent->setButtonDownPos(button, item->mapFromItem(q, mouseEvent->buttonDownPos(button)));-
955 }
never executed: end of block
0
956 }
never executed: end of block
0
957 break;
never executed: break;
0
958 }-
959 case QEvent::GraphicsSceneWheel: {
never executed: case QEvent::GraphicsSceneWheel:
0
960 QGraphicsSceneWheelEvent *wheelEvent = static_cast<QGraphicsSceneWheelEvent *>(event);-
961 wheelEvent->setPos(item->mapFromItem(q, wheelEvent->pos()));-
962 break;
never executed: break;
0
963 }-
964 case QEvent::GraphicsSceneContextMenu: {
never executed: case QEvent::GraphicsSceneContextMenu:
0
965 QGraphicsSceneContextMenuEvent *contextEvent = static_cast<QGraphicsSceneContextMenuEvent *>(event);-
966 contextEvent->setPos(item->mapFromItem(q, contextEvent->pos()));-
967 break;
never executed: break;
0
968 }-
969 case QEvent::GraphicsSceneHoverMove: {
never executed: case QEvent::GraphicsSceneHoverMove:
0
970 QGraphicsSceneHoverEvent *hoverEvent = static_cast<QGraphicsSceneHoverEvent *>(event);-
971 hoverEvent->setPos(item->mapFromItem(q, hoverEvent->pos()));-
972 break;
never executed: break;
0
973 }-
974 default:
never executed: default:
0
975 break;
never executed: break;
0
976 }-
977}-
978-
979/*!-
980 \internal-
981-
982 Maps the point \a pos from scene to item coordinates. If \a view is passed and the item-
983 is untransformable, this function will correctly map \a pos from the scene using the-
984 view's transformation.-
985*/-
986QPointF QGraphicsItemPrivate::genericMapFromScene(const QPointF &pos,-
987 const QWidget *viewport) const-
988{-
989 Q_Q(const QGraphicsItem);-
990 if (!itemIsUntransformable())
!itemIsUntransformable()Description
TRUEnever evaluated
FALSEnever evaluated
0
991 return q->mapFromScene(pos);
never executed: return q->mapFromScene(pos);
0
992 QGraphicsView *view = 0;-
993 if (viewport)
viewportDescription
TRUEnever evaluated
FALSEnever evaluated
0
994 view = qobject_cast<QGraphicsView *>(viewport->parentWidget());
never executed: view = qobject_cast<QGraphicsView *>(viewport->parentWidget());
0
995 if (!view)
!viewDescription
TRUEnever evaluated
FALSEnever evaluated
0
996 return q->mapFromScene(pos);
never executed: return q->mapFromScene(pos);
0
997 // ### More ping pong than needed.-
998 return q->deviceTransform(view->viewportTransform()).inverted().map(view->mapFromScene(pos));
never executed: return q->deviceTransform(view->viewportTransform()).inverted().map(view->mapFromScene(pos));
0
999}-
1000-
1001/*!-
1002 \internal-
1003-
1004 Combines this item's position and transform onto \a transform.-
1005-
1006 If you need to change this function (e.g., adding more transformation-
1007 modes / options), make sure to change all places marked with COMBINE.-
1008*/-
1009void QGraphicsItemPrivate::combineTransformToParent(QTransform *x, const QTransform *viewTransform) const-
1010{-
1011 // COMBINE-
1012 if (viewTransform && itemIsUntransformable()) {
viewTransformDescription
TRUEnever evaluated
FALSEnever evaluated
itemIsUntransformable()Description
TRUEnever evaluated
FALSEnever evaluated
0
1013 *x = q_ptr->deviceTransform(*viewTransform);-
1014 } else {
never executed: end of block
0
1015 if (transformData)
transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
1016 *x *= transformData->computedFullTransform();
never executed: *x *= transformData->computedFullTransform();
0
1017 if (!pos.isNull())
!pos.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1018 *x *= QTransform::fromTranslate(pos.x(), pos.y());
never executed: *x *= QTransform::fromTranslate(pos.x(), pos.y());
0
1019 }
never executed: end of block
0
1020}-
1021-
1022/*!-
1023 \internal-
1024-
1025 Combines this item's position and transform onto \a transform.-
1026-
1027 If you need to change this function (e.g., adding more transformation-
1028 modes / options), make sure to change QGraphicsItem::deviceTransform() as-
1029 well.-
1030*/-
1031void QGraphicsItemPrivate::combineTransformFromParent(QTransform *x, const QTransform *viewTransform) const-
1032{-
1033 // COMBINE-
1034 if (viewTransform && itemIsUntransformable()) {
viewTransformDescription
TRUEnever evaluated
FALSEnever evaluated
itemIsUntransformable()Description
TRUEnever evaluated
FALSEnever evaluated
0
1035 *x = q_ptr->deviceTransform(*viewTransform);-
1036 } else {
never executed: end of block
0
1037 x->translate(pos.x(), pos.y());-
1038 if (transformData)
transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
1039 *x = transformData->computedFullTransform(x);
never executed: *x = transformData->computedFullTransform(x);
0
1040 }
never executed: end of block
0
1041}-
1042-
1043void QGraphicsItemPrivate::updateSceneTransformFromParent()-
1044{-
1045 if (parent) {
parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1046 Q_ASSERT(!parent->d_ptr->dirtySceneTransform);-
1047 if (parent->d_ptr->sceneTransformTranslateOnly) {
parent->d_ptr-...mTranslateOnlyDescription
TRUEnever evaluated
FALSEnever evaluated
0
1048 sceneTransform = QTransform::fromTranslate(parent->d_ptr->sceneTransform.dx() + pos.x(),-
1049 parent->d_ptr->sceneTransform.dy() + pos.y());-
1050 } else {
never executed: end of block
0
1051 sceneTransform = parent->d_ptr->sceneTransform;-
1052 sceneTransform.translate(pos.x(), pos.y());-
1053 }
never executed: end of block
0
1054 if (transformData) {
transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
1055 sceneTransform = transformData->computedFullTransform(&sceneTransform);-
1056 sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);-
1057 } else {
never executed: end of block
0
1058 sceneTransformTranslateOnly = parent->d_ptr->sceneTransformTranslateOnly;-
1059 }
never executed: end of block
0
1060 } else if (!transformData) {
!transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
1061 sceneTransform = QTransform::fromTranslate(pos.x(), pos.y());-
1062 sceneTransformTranslateOnly = 1;-
1063 } else if (transformData->onlyTransform) {
never executed: end of block
transformData->onlyTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
1064 sceneTransform = transformData->transform;-
1065 if (!pos.isNull())
!pos.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1066 sceneTransform *= QTransform::fromTranslate(pos.x(), pos.y());
never executed: sceneTransform *= QTransform::fromTranslate(pos.x(), pos.y());
0
1067 sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);-
1068 } else if (pos.isNull()) {
never executed: end of block
pos.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
1069 sceneTransform = transformData->computedFullTransform();-
1070 sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);-
1071 } else {
never executed: end of block
0
1072 sceneTransform = QTransform::fromTranslate(pos.x(), pos.y());-
1073 sceneTransform = transformData->computedFullTransform(&sceneTransform);-
1074 sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate);-
1075 }
never executed: end of block
0
1076 dirtySceneTransform = 0;-
1077}
never executed: end of block
0
1078-
1079/*!-
1080 \internal-
1081-
1082 Make sure not to trigger any pure virtual function calls (e.g.,-
1083 prepareGeometryChange) if the item is in its destructor, i.e.-
1084 inDestructor is 1.-
1085*/-
1086void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const QVariant *newParentVariant,-
1087 const QVariant *thisPointerVariant)-
1088{-
1089 Q_Q(QGraphicsItem);-
1090 if (newParent == parent)
newParent == parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1091 return;
never executed: return;
0
1092-
1093 if (isWidget)
isWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
1094 static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent &&
never executed: static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent && newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0, scene);
0
1095 newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0,
never executed: static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent && newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0, scene);
0
1096 scene);
never executed: static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent && newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0, scene);
0
1097 if (scene) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
1098 // Deliver the change to the index-
1099 if (scene->d_func()->indexMethod != QGraphicsScene::NoIndex)
scene->d_func(...Scene::NoIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
1100 scene->d_func()->index->itemChange(q, QGraphicsItem::ItemParentChange, newParent);
never executed: scene->d_func()->index->itemChange(q, QGraphicsItem::ItemParentChange, newParent);
0
1101-
1102 // Disable scene pos notifications for old ancestors-
1103 if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges))
scenePosDescendantsDescription
TRUEnever evaluated
FALSEnever evaluated
(flags & QGrap...sitionChanges)Description
TRUEnever evaluated
FALSEnever evaluated
0
1104 scene->d_func()->setScenePosItemEnabled(q, false);
never executed: scene->d_func()->setScenePosItemEnabled(q, false);
0
1105 }
never executed: end of block
0
1106-
1107 if (subFocusItem && parent) {
subFocusItemDescription
TRUEnever evaluated
FALSEnever evaluated
parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1108 // Make sure none of the old parents point to this guy.-
1109 subFocusItem->d_ptr->clearSubFocus(parent);-
1110 }
never executed: end of block
0
1111-
1112 // We anticipate geometry changes. If the item is deleted, it will be-
1113 // removed from the index at a later stage, and the whole scene will be-
1114 // updated.-
1115 if (!inDestructor)
!inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
0
1116 q_ptr->prepareGeometryChange();
never executed: q_ptr->prepareGeometryChange();
0
1117-
1118 if (parent) {
parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1119 // Remove from current parent-
1120 parent->d_ptr->removeChild(q);-
1121 if (thisPointerVariant)
thisPointerVariantDescription
TRUEnever evaluated
FALSEnever evaluated
0
1122 parent->itemChange(QGraphicsItem::ItemChildRemovedChange, *thisPointerVariant);
never executed: parent->itemChange(QGraphicsItem::ItemChildRemovedChange, *thisPointerVariant);
0
1123 }
never executed: end of block
0
1124-
1125 // Update toplevelitem list. If this item is being deleted, its parent-
1126 // will be 0 but we don't want to register/unregister it in the TLI list.-
1127 if (scene && !inDestructor) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
!inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
0
1128 if (parent && !newParent) {
parentDescription
TRUEnever evaluated
FALSEnever evaluated
!newParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1129 scene->d_func()->registerTopLevelItem(q);-
1130 } else if (!parent && newParent) {
never executed: end of block
!parentDescription
TRUEnever evaluated
FALSEnever evaluated
newParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1131 scene->d_func()->unregisterTopLevelItem(q);-
1132 }
never executed: end of block
0
1133 }
never executed: end of block
0
1134-
1135 // Ensure any last parent focus scope does not point to this item or any of-
1136 // its descendents.-
1137 QGraphicsItem *p = parent;-
1138 QGraphicsItem *parentFocusScopeItem = 0;-
1139 while (p) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
0
1140 if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) {
p->d_ptr->flag...emIsFocusScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1141 // If this item's focus scope's focus scope item points-
1142 // to this item or a descendent, then clear it.-
1143 QGraphicsItem *fsi = p->d_ptr->focusScopeItem;-
1144 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
1145 parentFocusScopeItem = fsi;-
1146 p->d_ptr->focusScopeItem = 0;-
1147 fsi->d_ptr->focusScopeItemChange(false);-
1148 }
never executed: end of block
0
1149 break;
never executed: break;
0
1150 }-
1151 p = p->d_ptr->parent;-
1152 }
never executed: end of block
0
1153-
1154 // Update graphics effect optimization flag-
1155 if (newParent && (graphicsEffect || mayHaveChildWithGraphicsEffect))
newParentDescription
TRUEnever evaluated
FALSEnever evaluated
graphicsEffectDescription
TRUEnever evaluated
FALSEnever evaluated
mayHaveChildWithGraphicsEffectDescription
TRUEnever evaluated
FALSEnever evaluated
0
1156 newParent->d_ptr->updateChildWithGraphicsEffectFlagRecursively();
never executed: newParent->d_ptr->updateChildWithGraphicsEffectFlagRecursively();
0
1157-
1158 // Update focus scope item ptr in new scope.-
1159 QGraphicsItem *newFocusScopeItem = subFocusItem ? subFocusItem : parentFocusScopeItem;
subFocusItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
1160 if (newFocusScopeItem && newParent) {
newFocusScopeItemDescription
TRUEnever evaluated
FALSEnever evaluated
newParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1161 QGraphicsItem *p = newParent;-
1162 while (p) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
0
1163 if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) {
p->d_ptr->flag...emIsFocusScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1164 if (subFocusItem && subFocusItem != q_ptr) {
subFocusItemDescription
TRUEnever evaluated
FALSEnever evaluated
subFocusItem != q_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
1165 // Find the subFocusItem's topmost focus scope within the new parent's focusscope-
1166 QGraphicsItem *ancestorScope = 0;-
1167 QGraphicsItem *p2 = subFocusItem->d_ptr->parent;-
1168 while (p2 && p2 != p) {
p2Description
TRUEnever evaluated
FALSEnever evaluated
p2 != pDescription
TRUEnever evaluated
FALSEnever evaluated
0
1169 if (p2->d_ptr->flags & QGraphicsItem::ItemIsFocusScope)
p2->d_ptr->fla...emIsFocusScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1170 ancestorScope = p2;
never executed: ancestorScope = p2;
0
1171 if (p2->d_ptr->flags & QGraphicsItem::ItemIsPanel)
p2->d_ptr->fla...m::ItemIsPanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1172 break;
never executed: break;
0
1173 if (p2 == q_ptr)
p2 == q_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
1174 break;
never executed: break;
0
1175 p2 = p2->d_ptr->parent;-
1176 }
never executed: end of block
0
1177 if (ancestorScope)
ancestorScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1178 newFocusScopeItem = ancestorScope;
never executed: newFocusScopeItem = ancestorScope;
0
1179 }
never executed: end of block
0
1180-
1181 p->d_ptr->focusScopeItem = newFocusScopeItem;-
1182 newFocusScopeItem->d_ptr->focusScopeItemChange(true);-
1183 // Ensure the new item is no longer the subFocusItem. The-
1184 // only way to set focus on a child of a focus scope is-
1185 // by setting focus on the scope itself.-
1186 if (subFocusItem && !p->focusItem())
subFocusItemDescription
TRUEnever evaluated
FALSEnever evaluated
!p->focusItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
1187 subFocusItem->d_ptr->clearSubFocus();
never executed: subFocusItem->d_ptr->clearSubFocus();
0
1188 break;
never executed: break;
0
1189 }-
1190 p = p->d_ptr->parent;-
1191 }
never executed: end of block
0
1192 }
never executed: end of block
0
1193-
1194 // Resolve depth.-
1195 invalidateDepthRecursively();-
1196-
1197 if ((parent = newParent)) {
(parent = newParent)Description
TRUEnever evaluated
FALSEnever evaluated
0
1198 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
1199 // Move this item to its new parent's scene-
1200 parent->d_func()->scene->addItem(q);-
1201 } 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
1202 // Remove this item from its former scene-
1203 scene->removeItem(q);-
1204 }
never executed: end of block
0
1205-
1206 parent->d_ptr->addChild(q);-
1207 if (thisPointerVariant)
thisPointerVariantDescription
TRUEnever evaluated
FALSEnever evaluated
0
1208 parent->itemChange(QGraphicsItem::ItemChildAddedChange, *thisPointerVariant);
never executed: parent->itemChange(QGraphicsItem::ItemChildAddedChange, *thisPointerVariant);
0
1209 if (scene) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
1210 // Re-enable scene pos notifications for new ancestors-
1211 if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges))
scenePosDescendantsDescription
TRUEnever evaluated
FALSEnever evaluated
(flags & QGrap...sitionChanges)Description
TRUEnever evaluated
FALSEnever evaluated
0
1212 scene->d_func()->setScenePosItemEnabled(q, true);
never executed: scene->d_func()->setScenePosItemEnabled(q, true);
0
1213 }
never executed: end of block
0
1214-
1215 // Propagate dirty flags to the new parent-
1216 markParentDirty(/*updateBoundingRect=*/true);-
1217-
1218 // Inherit ancestor flags from the new parent.-
1219 updateAncestorFlags();-
1220-
1221 // Update item visible / enabled.-
1222 if (parent->d_ptr->visible != visible) {
parent->d_ptr-...ble != visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
1223 if (!parent->d_ptr->visible || !explicitlyHidden)
!parent->d_ptr->visibleDescription
TRUEnever evaluated
FALSEnever evaluated
!explicitlyHiddenDescription
TRUEnever evaluated
FALSEnever evaluated
0
1224 setVisibleHelper(parent->d_ptr->visible, /* explicit = */ false, /* update = */ false);
never executed: setVisibleHelper(parent->d_ptr->visible, false, false);
0
1225 }
never executed: end of block
0
1226 if (parent->isEnabled() != enabled) {
parent->isEnabled() != enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1227 if (!parent->d_ptr->enabled || !explicitlyDisabled)
!parent->d_ptr->enabledDescription
TRUEnever evaluated
FALSEnever evaluated
!explicitlyDisabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1228 setEnabledHelper(parent->d_ptr->enabled, /* explicit = */ false, /* update = */ false);
never executed: setEnabledHelper(parent->d_ptr->enabled, false, false);
0
1229 }
never executed: end of block
0
1230-
1231 // Auto-activate if visible and the parent is active.-
1232 if (visible && parent->isActive())
visibleDescription
TRUEnever evaluated
FALSEnever evaluated
parent->isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
1233 q->setActive(true);
never executed: q->setActive(true);
0
1234 } else {
never executed: end of block
0
1235 // Inherit ancestor flags from the new parent.-
1236 updateAncestorFlags();-
1237-
1238 if (!inDestructor) {
!inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
0
1239 // Update item visible / enabled.-
1240 if (!visible && !explicitlyHidden)
!visibleDescription
TRUEnever evaluated
FALSEnever evaluated
!explicitlyHiddenDescription
TRUEnever evaluated
FALSEnever evaluated
0
1241 setVisibleHelper(true, /* explicit = */ false);
never executed: setVisibleHelper(true, false);
0
1242 if (!enabled && !explicitlyDisabled)
!enabledDescription
TRUEnever evaluated
FALSEnever evaluated
!explicitlyDisabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1243 setEnabledHelper(true, /* explicit = */ false);
never executed: setEnabledHelper(true, false);
0
1244 }
never executed: end of block
0
1245 }
never executed: end of block
0
1246-
1247 dirtySceneTransform = 1;-
1248 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
1249 transformChanged();
never executed: transformChanged();
0
1250-
1251 // Restore the sub focus chain.-
1252 if (subFocusItem) {
subFocusItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
1253 subFocusItem->d_ptr->setSubFocus(newParent);-
1254 if (parent && parent->isActive())
parentDescription
TRUEnever evaluated
FALSEnever evaluated
parent->isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
1255 subFocusItem->setFocus();
never executed: subFocusItem->setFocus();
0
1256 }
never executed: end of block
0
1257-
1258 // Deliver post-change notification-
1259 if (newParentVariant)
newParentVariantDescription
TRUEnever evaluated
FALSEnever evaluated
0
1260 q->itemChange(QGraphicsItem::ItemParentHasChanged, *newParentVariant);
never executed: q->itemChange(QGraphicsItem::ItemParentHasChanged, *newParentVariant);
0
1261-
1262 if (isObject)
isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
1263 emit static_cast<QGraphicsObject *>(q)->parentChanged();
never executed: static_cast<QGraphicsObject *>(q)->parentChanged();
0
1264}
never executed: end of block
0
1265-
1266/*!-
1267 \internal-
1268-
1269 Returns the bounding rect of this item's children (excluding itself).-
1270*/-
1271void QGraphicsItemPrivate::childrenBoundingRectHelper(QTransform *x, QRectF *rect, QGraphicsItem *topMostEffectItem)-
1272{-
1273 Q_Q(QGraphicsItem);-
1274-
1275 QRectF childrenRect;-
1276 QRectF *result = rect;-
1277 rect = &childrenRect;-
1278 const bool setTopMostEffectItem = !topMostEffectItem;-
1279-
1280 for (int i = 0; i < children.size(); ++i) {
i < children.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1281 QGraphicsItem *child = children.at(i);-
1282 QGraphicsItemPrivate *childd = child->d_ptr.data();-
1283 if (setTopMostEffectItem)
setTopMostEffectItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
1284 topMostEffectItem = child;
never executed: topMostEffectItem = child;
0
1285 bool hasPos = !childd->pos.isNull();-
1286 if (hasPos || childd->transformData) {
hasPosDescription
TRUEnever evaluated
FALSEnever evaluated
childd->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
1287 // COMBINE-
1288 QTransform matrix = childd->transformToParent();-
1289 if (x)
xDescription
TRUEnever evaluated
FALSEnever evaluated
0
1290 matrix *= *x;
never executed: matrix *= *x;
0
1291 *rect |= matrix.mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem));-
1292 if (!childd->children.isEmpty())
!childd->children.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1293 childd->childrenBoundingRectHelper(&matrix, rect, topMostEffectItem);
never executed: childd->childrenBoundingRectHelper(&matrix, rect, topMostEffectItem);
0
1294 } else {
never executed: end of block
0
1295 if (x)
xDescription
TRUEnever evaluated
FALSEnever evaluated
0
1296 *rect |= x->mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem));
never executed: *rect |= x->mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem));
0
1297 else-
1298 *rect |= child->d_ptr->effectiveBoundingRect(topMostEffectItem);
never executed: *rect |= child->d_ptr->effectiveBoundingRect(topMostEffectItem);
0
1299 if (!childd->children.isEmpty())
!childd->children.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1300 childd->childrenBoundingRectHelper(x, rect, topMostEffectItem);
never executed: childd->childrenBoundingRectHelper(x, rect, topMostEffectItem);
0
1301 }
never executed: end of block
0
1302 }-
1303-
1304 if (flags & QGraphicsItem::ItemClipsChildrenToShape){
flags & QGraph...hildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1305 if (x)
xDescription
TRUEnever evaluated
FALSEnever evaluated
0
1306 *rect &= x->mapRect(q->boundingRect());
never executed: *rect &= x->mapRect(q->boundingRect());
0
1307 else-
1308 *rect &= q->boundingRect();
never executed: *rect &= q->boundingRect();
0
1309 }-
1310-
1311 *result |= *rect;-
1312}
never executed: end of block
0
1313-
1314void QGraphicsItemPrivate::initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform,-
1315 const QRegion &exposedRegion, bool allItems) const-
1316{-
1317 Q_ASSERT(option);-
1318 Q_Q(const QGraphicsItem);-
1319-
1320 // Initialize standard QStyleOption values.-
1321 const QRectF brect = q->boundingRect();-
1322 option->state = QStyle::State_None;-
1323 option->rect = brect.toRect();-
1324 option->levelOfDetail = 1;-
1325 option->exposedRect = brect;-
1326-
1327 // Style animations require a QObject-based animation target.-
1328 // If a plain QGraphicsItem is used to draw animated controls,-
1329 // QStyle is let to send animation updates to the whole scene.-
1330 option->styleObject = q_ptr->toGraphicsObject();-
1331 if (!option->styleObject)
!option->styleObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
1332 option->styleObject = scene;
never executed: option->styleObject = scene;
0
1333-
1334 if (selected)
selectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1335 option->state |= QStyle::State_Selected;
never executed: option->state |= QStyle::State_Selected;
0
1336 if (enabled)
enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1337 option->state |= QStyle::State_Enabled;
never executed: option->state |= QStyle::State_Enabled;
0
1338 if (q->hasFocus())
q->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
1339 option->state |= QStyle::State_HasFocus;
never executed: option->state |= QStyle::State_HasFocus;
0
1340 if (scene) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
1341 if (scene->d_func()->hoverItems.contains(q_ptr))
scene->d_func(...ontains(q_ptr)Description
TRUEnever evaluated
FALSEnever evaluated
0
1342 option->state |= QStyle::State_MouseOver;
never executed: option->state |= QStyle::State_MouseOver;
0
1343 if (q == scene->mouseGrabberItem())
q == scene->mouseGrabberItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
1344 option->state |= QStyle::State_Sunken;
never executed: option->state |= QStyle::State_Sunken;
0
1345 }
never executed: end of block
0
1346-
1347 if (!(flags & QGraphicsItem::ItemUsesExtendedStyleOption))
!(flags & QGra...edStyleOption)Description
TRUEnever evaluated
FALSEnever evaluated
0
1348 return;
never executed: return;
0
1349-
1350 // Initialize QStyleOptionGraphicsItem specific values (matrix, exposedRect).-
1351 option->matrix = worldTransform.toAffine(); //### discards perspective-
1352-
1353 if (!allItems) {
!allItemsDescription
TRUEnever evaluated
FALSEnever evaluated
0
1354 // Determine the item's exposed area-
1355 option->exposedRect = QRectF();-
1356 const QTransform reverseMap = worldTransform.inverted();-
1357 const QVector<QRect> exposedRects(exposedRegion.rects());-
1358 for (int i = 0; i < exposedRects.size(); ++i) {
i < exposedRects.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1359 option->exposedRect |= reverseMap.mapRect(QRectF(exposedRects.at(i)));-
1360 if (option->exposedRect.contains(brect))
option->expose...ontains(brect)Description
TRUEnever evaluated
FALSEnever evaluated
0
1361 break;
never executed: break;
0
1362 }
never executed: end of block
0
1363 option->exposedRect &= brect;-
1364 }
never executed: end of block
0
1365}
never executed: end of block
0
1366-
1367/*!-
1368 \internal-
1369-
1370 Empty all cached pixmaps from the pixmap cache.-
1371*/-
1372void QGraphicsItemCache::purge()-
1373{-
1374 QPixmapCache::remove(key);-
1375 key = QPixmapCache::Key();-
1376 QMutableHashIterator<QPaintDevice *, DeviceData> it(deviceData);-
1377 while (it.hasNext()) {
it.hasNext()Description
TRUEnever evaluated
FALSEnever evaluated
0
1378 DeviceData &data = it.next().value();-
1379 QPixmapCache::remove(data.key);-
1380 data.cacheIndent = QPoint();-
1381 }
never executed: end of block
0
1382 deviceData.clear();-
1383 allExposed = true;-
1384 exposed.clear();-
1385}
never executed: end of block
0
1386-
1387/*!-
1388 Constructs a QGraphicsItem with the given \a parent item.-
1389 It does not modify the parent object returned by QObject::parent().-
1390-
1391 If \a parent is 0, you can add the item to a scene by calling-
1392 QGraphicsScene::addItem(). The item will then become a top-level item.-
1393-
1394 \sa QGraphicsScene::addItem(), setParentItem()-
1395*/-
1396QGraphicsItem::QGraphicsItem(QGraphicsItem *parent)-
1397 : d_ptr(new QGraphicsItemPrivate)-
1398{-
1399 d_ptr->q_ptr = this;-
1400 setParentItem(parent);-
1401}
never executed: end of block
0
1402-
1403/*!-
1404 \internal-
1405*/-
1406QGraphicsItem::QGraphicsItem(QGraphicsItemPrivate &dd, QGraphicsItem *parent)-
1407 : d_ptr(&dd)-
1408{-
1409 d_ptr->q_ptr = this;-
1410 setParentItem(parent);-
1411}
never executed: end of block
0
1412-
1413/*!-
1414 Destroys the QGraphicsItem and all its children. If this item is currently-
1415 associated with a scene, the item will be removed from the scene before it-
1416 is deleted.-
1417-
1418 \note It is more efficient to remove the item from the QGraphicsScene before-
1419 destroying the item.-
1420*/-
1421QGraphicsItem::~QGraphicsItem()-
1422{-
1423 if (d_ptr->isObject) {
d_ptr->isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
1424 QGraphicsObject *o = static_cast<QGraphicsObject *>(this);-
1425 QObjectPrivate *p = QObjectPrivate::get(o);-
1426 p->wasDeleted = true;-
1427 if (p->declarativeData) {
p->declarativeDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
1428 if (static_cast<QAbstractDeclarativeDataImpl*>(p->declarativeData)->ownedByQml1) {
static_cast<QA...)->ownedByQml1Description
TRUEnever evaluated
FALSEnever evaluated
0
1429 if (QAbstractDeclarativeData::destroyed_qml1)
QAbstractDecla...destroyed_qml1Description
TRUEnever evaluated
FALSEnever evaluated
0
1430 QAbstractDeclarativeData::destroyed_qml1(p->declarativeData, o);
never executed: QAbstractDeclarativeData::destroyed_qml1(p->declarativeData, o);
0
1431 } else {
never executed: end of block
0
1432 if (QAbstractDeclarativeData::destroyed)
QAbstractDecla...ata::destroyedDescription
TRUEnever evaluated
FALSEnever evaluated
0
1433 QAbstractDeclarativeData::destroyed(p->declarativeData, o);
never executed: QAbstractDeclarativeData::destroyed(p->declarativeData, o);
0
1434 }
never executed: end of block
0
1435 p->declarativeData = 0;-
1436 }
never executed: end of block
0
1437 }
never executed: end of block
0
1438-
1439 d_ptr->inDestructor = 1;-
1440 d_ptr->removeExtraItemCache();-
1441-
1442#ifndef QT_NO_GESTURES-
1443 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
1444 QGraphicsObject *o = static_cast<QGraphicsObject *>(this);-
1445 if (QGestureManager *manager = QGestureManager::instance()) {
QGestureManage...er::instance()Description
TRUEnever evaluated
FALSEnever evaluated
0
1446 foreach (Qt::GestureType type, d_ptr->gestureContext.keys())-
1447 manager->cleanupCachedGestures(o, type);
never executed: manager->cleanupCachedGestures(o, type);
0
1448 }
never executed: end of block
0
1449 }
never executed: end of block
0
1450#endif-
1451-
1452 clearFocus();-
1453 setFocusProxy(0);-
1454-
1455 // Update focus scope item ptr.-
1456 QGraphicsItem *p = d_ptr->parent;-
1457 while (p) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
0
1458 if (p->flags() & ItemIsFocusScope) {
p->flags() & ItemIsFocusScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
1459 if (p->d_ptr->focusScopeItem == this)
p->d_ptr->focu...peItem == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1460 p->d_ptr->focusScopeItem = 0;
never executed: p->d_ptr->focusScopeItem = 0;
0
1461 break;
never executed: break;
0
1462 }-
1463 p = p->d_ptr->parent;-
1464 }
never executed: end of block
0
1465-
1466 if (!d_ptr->children.isEmpty()) {
!d_ptr->children.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1467 while (!d_ptr->children.isEmpty())
!d_ptr->children.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
1468 delete d_ptr->children.first();
never executed: delete d_ptr->children.first();
0
1469 Q_ASSERT(d_ptr->children.isEmpty());-
1470 }
never executed: end of block
0
1471-
1472 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
1473 d_ptr->scene->d_func()->removeItemHelper(this);-
1474 } else {
never executed: end of block
0
1475 d_ptr->resetFocusProxy();-
1476 setParentItem(0);-
1477 }
never executed: end of block
0
1478-
1479#ifndef QT_NO_GRAPHICSEFFECT-
1480 delete d_ptr->graphicsEffect;-
1481#endif //QT_NO_GRAPHICSEFFECT-
1482 if (d_ptr->transformData) {
d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
1483 for(int i = 0; i < d_ptr->transformData->graphicsTransforms.size(); ++i) {
i < d_ptr->tra...nsforms.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
1484 QGraphicsTransform *t = d_ptr->transformData->graphicsTransforms.at(i);-
1485 static_cast<QGraphicsTransformPrivate *>(t->d_ptr.data())->item = 0;-
1486 delete t;-
1487 }
never executed: end of block
0
1488 }
never executed: end of block
0
1489 delete d_ptr->transformData;-
1490-
1491 if (QGraphicsItemCustomDataStore *dataStore = qt_dataStore())
QGraphicsItemC...qt_dataStore()Description
TRUEnever evaluated
FALSEnever evaluated
0
1492 dataStore->data.remove(this);
never executed: dataStore->data.remove(this);
0
1493}
never executed: end of block
0
1494-
1495/*!-
1496 Returns the current scene for the item, or 0 if the item is not stored in-
1497 a scene.-
1498-
1499 To add or move an item to a scene, call QGraphicsScene::addItem().-
1500*/-
1501QGraphicsScene *QGraphicsItem::scene() const-
1502{-
1503 return d_ptr->scene;
never executed: return d_ptr->scene;
0
1504}-
1505-
1506/*!-
1507 Returns a pointer to this item's item group, or 0 if this item is not-
1508 member of a group.-
1509-
1510 \sa QGraphicsItemGroup, QGraphicsScene::createItemGroup()-
1511*/-
1512QGraphicsItemGroup *QGraphicsItem::group() const-
1513{-
1514 if (!d_ptr->isMemberOfGroup)
!d_ptr->isMemberOfGroupDescription
TRUEnever evaluated
FALSEnever evaluated
0
1515 return 0;
never executed: return 0;
0
1516 QGraphicsItem *parent = const_cast<QGraphicsItem *>(this);-
1517 while ((parent = parent->d_ptr->parent)) {
(parent = pare...d_ptr->parent)Description
TRUEnever evaluated
FALSEnever evaluated
0
1518 if (QGraphicsItemGroup *group = qgraphicsitem_cast<QGraphicsItemGroup *>(parent))
QGraphicsItemG...oup *>(parent)Description
TRUEnever evaluated
FALSEnever evaluated
0
1519 return group;
never executed: return group;
0
1520 }
never executed: end of block
0
1521 // Unreachable; if d_ptr->isMemberOfGroup is != 0, then one parent of this-
1522 // item is a group item.-
1523 return 0;
never executed: return 0;
0
1524}-
1525-
1526/*!-
1527 Adds this item to the item group \a group. If \a group is 0, this item is-
1528 removed from any current group and added as a child of the previous-
1529 group's parent.-
1530-
1531 \sa group(), QGraphicsScene::createItemGroup()-
1532*/-
1533void QGraphicsItem::setGroup(QGraphicsItemGroup *group)-
1534{-
1535 if (!group) {
!groupDescription
TRUEnever evaluated
FALSEnever evaluated
0
1536 if (QGraphicsItemGroup *group = this->group())
QGraphicsItemG... this->group()Description
TRUEnever evaluated
FALSEnever evaluated
0
1537 group->removeFromGroup(this);
never executed: group->removeFromGroup(this);
0
1538 } else {
never executed: end of block
0
1539 group->addToGroup(this);-
1540 }
never executed: end of block
0
1541}-
1542-
1543/*!-
1544 Returns a pointer to this item's parent item. If this item does not have a-
1545 parent, 0 is returned.-
1546-
1547 \sa setParentItem(), childItems()-
1548*/-
1549QGraphicsItem *QGraphicsItem::parentItem() const-
1550{-
1551 return d_ptr->parent;
never executed: return d_ptr->parent;
0
1552}-
1553-
1554/*!-
1555 Returns this item's top-level item. The top-level item is the item's-
1556 topmost ancestor item whose parent is 0. If an item has no parent, its own-
1557 pointer is returned (i.e., a top-level item is its own top-level item).-
1558-
1559 \sa parentItem()-
1560*/-
1561QGraphicsItem *QGraphicsItem::topLevelItem() const-
1562{-
1563 QGraphicsItem *parent = const_cast<QGraphicsItem *>(this);-
1564 while (QGraphicsItem *grandPa = parent->parentItem())
QGraphicsItem ...->parentItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
1565 parent = grandPa;
never executed: parent = grandPa;
0
1566 return parent;
never executed: return parent;
0
1567}-
1568-
1569/*!-
1570 \since 4.6-
1571-
1572 Returns a pointer to the item's parent, cast to a QGraphicsObject. returns 0 if the parent item-
1573 is not a QGraphicsObject.-
1574-
1575 \sa parentItem(), childItems()-
1576*/-
1577QGraphicsObject *QGraphicsItem::parentObject() const-
1578{-
1579 QGraphicsItem *p = d_ptr->parent;-
1580 return (p && p->d_ptr->isObject) ? static_cast<QGraphicsObject *>(p) : 0;
never executed: return (p && p->d_ptr->isObject) ? static_cast<QGraphicsObject *>(p) : 0;
pDescription
TRUEnever evaluated
FALSEnever evaluated
p->d_ptr->isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
1581}-
1582-
1583/*!-
1584 \since 4.4-
1585-
1586 Returns a pointer to the item's parent widget. The item's parent widget is-
1587 the closest parent item that is a widget.-
1588-
1589 \sa parentItem(), childItems()-
1590*/-
1591QGraphicsWidget *QGraphicsItem::parentWidget() const-
1592{-
1593 QGraphicsItem *p = parentItem();-
1594 while (p && !p->isWidget())
pDescription
TRUEnever evaluated
FALSEnever evaluated
!p->isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
1595 p = p->parentItem();
never executed: p = p->parentItem();
0
1596 return (p && p->isWidget()) ? static_cast<QGraphicsWidget *>(p) : 0;
never executed: return (p && p->isWidget()) ? static_cast<QGraphicsWidget *>(p) : 0;
pDescription
TRUEnever evaluated
FALSEnever evaluated
p->isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
1597}-
1598-
1599/*!-
1600 \since 4.4-
1601-
1602 Returns a pointer to the item's top level widget (i.e., the item's-
1603 ancestor whose parent is 0, or whose parent is not a widget), or 0 if this-
1604 item does not have a top level widget. If the item is its own top level-
1605 widget, this function returns a pointer to the item itself.-
1606*/-
1607QGraphicsWidget *QGraphicsItem::topLevelWidget() const-
1608{-
1609 if (const QGraphicsWidget *p = parentWidget())
const QGraphic...parentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
1610 return p->topLevelWidget();
never executed: return p->topLevelWidget();
0
1611 return isWidget() ? static_cast<QGraphicsWidget *>(const_cast<QGraphicsItem *>(this)) : 0;
never executed: return isWidget() ? static_cast<QGraphicsWidget *>(const_cast<QGraphicsItem *>(this)) : 0;
isWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
1612}-
1613-
1614/*!-
1615 \since 4.4-
1616-
1617 Returns the item's window, or 0 if this item does not have a window. If-
1618 the item is a window, it will return itself. Otherwise it will return the-
1619 closest ancestor that is a window.-
1620-
1621 \sa QGraphicsWidget::isWindow()-
1622*/-
1623QGraphicsWidget *QGraphicsItem::window() const-
1624{-
1625 QGraphicsItem *p = panel();-
1626 if (p && p->isWindow())
pDescription
TRUEnever evaluated
FALSEnever evaluated
p->isWindow()Description
TRUEnever evaluated
FALSEnever evaluated
0
1627 return static_cast<QGraphicsWidget *>(p);
never executed: return static_cast<QGraphicsWidget *>(p);
0
1628 return 0;
never executed: return 0;
0
1629}-
1630-
1631/*!-
1632 \since 4.6-
1633-
1634 Returns the item's panel, or 0 if this item does not have a panel. If the-
1635 item is a panel, it will return itself. Otherwise it will return the-
1636 closest ancestor that is a panel.-
1637-
1638 \sa isPanel(), ItemIsPanel-
1639*/-
1640QGraphicsItem *QGraphicsItem::panel() const-
1641{-
1642 if (d_ptr->flags & ItemIsPanel)
d_ptr->flags & ItemIsPanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1643 return const_cast<QGraphicsItem *>(this);
never executed: return const_cast<QGraphicsItem *>(this);
0
1644 return d_ptr->parent ? d_ptr->parent->panel() : 0;
never executed: return d_ptr->parent ? d_ptr->parent->panel() : 0;
d_ptr->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1645}-
1646-
1647/*!-
1648 \since 4.6-
1649-
1650 Return the graphics item cast to a QGraphicsObject, if the class is actually a-
1651 graphics object, 0 otherwise.-
1652*/-
1653QGraphicsObject *QGraphicsItem::toGraphicsObject()-
1654{-
1655 return d_ptr->isObject ? static_cast<QGraphicsObject *>(this) : 0;
never executed: return d_ptr->isObject ? static_cast<QGraphicsObject *>(this) : 0;
d_ptr->isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
1656}-
1657-
1658/*!-
1659 \since 4.6-
1660-
1661 Return the graphics item cast to a QGraphicsObject, if the class is actually a-
1662 graphics object, 0 otherwise.-
1663*/-
1664const QGraphicsObject *QGraphicsItem::toGraphicsObject() const-
1665{-
1666 return d_ptr->isObject ? static_cast<const QGraphicsObject *>(this) : 0;
never executed: return d_ptr->isObject ? static_cast<const QGraphicsObject *>(this) : 0;
d_ptr->isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
1667}-
1668-
1669/*!-
1670 Sets this item's parent item to \a newParent. If this item already-
1671 has a parent, it is first removed from the previous parent. If \a-
1672 newParent is 0, this item will become a top-level item.-
1673-
1674 Note that this implicitly adds this graphics item to the scene of-
1675 the parent. You should not \l{QGraphicsScene::addItem()}{add} the-
1676 item to the scene yourself.-
1677-
1678 The behavior when calling this function on an item that is an ancestor of-
1679 \a newParent is undefined.-
1680-
1681 \sa parentItem(), childItems()-
1682*/-
1683void QGraphicsItem::setParentItem(QGraphicsItem *newParent)-
1684{-
1685 if (newParent == this) {
newParent == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
1686 qWarning("QGraphicsItem::setParentItem: cannot assign %p as a parent of itself", this);-
1687 return;
never executed: return;
0
1688 }-
1689 if (newParent == d_ptr->parent)
newParent == d_ptr->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1690 return;
never executed: return;
0
1691-
1692 const QVariant newParentVariant(itemChange(QGraphicsItem::ItemParentChange,-
1693 QVariant::fromValue<QGraphicsItem *>(newParent)));-
1694 newParent = qvariant_cast<QGraphicsItem *>(newParentVariant);-
1695 if (newParent == d_ptr->parent)
newParent == d_ptr->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1696 return;
never executed: return;
0
1697-
1698 const QVariant thisPointerVariant(QVariant::fromValue<QGraphicsItem *>(this));-
1699 d_ptr->setParentItemHelper(newParent, &newParentVariant, &thisPointerVariant);-
1700}
never executed: end of block
0
1701-
1702/*!-
1703 \fn QList<QGraphicsItem *> QGraphicsItem::children() const-
1704 \obsolete-
1705-
1706 Use childItems() instead.-
1707-
1708 \sa setParentItem()-
1709*/-
1710-
1711/*!-
1712 \since 4.4-
1713-
1714 Returns a list of this item's children.-
1715-
1716 The items are sorted by stacking order. This takes into account both the-
1717 items' insertion order and their Z-values.-
1718-
1719 \sa setParentItem(), zValue(), {QGraphicsItem#Sorting}{Sorting}-
1720*/-
1721QList<QGraphicsItem *> QGraphicsItem::childItems() const-
1722{-
1723 const_cast<QGraphicsItem *>(this)->d_ptr->ensureSortedChildren();-
1724 return d_ptr->children;
never executed: return d_ptr->children;
0
1725}-
1726-
1727/*!-
1728 \since 4.4-
1729 Returns \c true if this item is a widget (i.e., QGraphicsWidget); otherwise,-
1730 returns \c false.-
1731*/-
1732bool QGraphicsItem::isWidget() const-
1733{-
1734 return d_ptr->isWidget;
never executed: return d_ptr->isWidget;
0
1735}-
1736-
1737/*!-
1738 \since 4.4-
1739 Returns \c true if the item is a QGraphicsWidget window, otherwise returns-
1740 false.-
1741-
1742 \sa QGraphicsWidget::windowFlags()-
1743*/-
1744bool QGraphicsItem::isWindow() const-
1745{-
1746 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);
d_ptr->isWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
(static_cast<c... & Qt::Window)Description
TRUEnever evaluated
FALSEnever evaluated
0
1747}-
1748-
1749/*!-
1750 \since 4.6-
1751 Returns \c true if the item is a panel; otherwise returns \c false.-
1752-
1753 \sa QGraphicsItem::panel(), ItemIsPanel-
1754*/-
1755bool QGraphicsItem::isPanel() const-
1756{-
1757 return d_ptr->flags & ItemIsPanel;
never executed: return d_ptr->flags & ItemIsPanel;
0
1758}-
1759-
1760/*!-
1761 Returns this item's flags. The flags describe what configurable features-
1762 of the item are enabled and not. For example, if the flags include-
1763 ItemIsFocusable, the item can accept input focus.-
1764-
1765 By default, no flags are enabled.-
1766-
1767 \sa setFlags(), setFlag()-
1768*/-
1769QGraphicsItem::GraphicsItemFlags QGraphicsItem::flags() const-
1770{-
1771 return GraphicsItemFlags(d_ptr->flags);
never executed: return GraphicsItemFlags(d_ptr->flags);
0
1772}-
1773-
1774/*!-
1775 If \a enabled is true, the item flag \a flag is enabled; otherwise, it is-
1776 disabled.-
1777-
1778 \sa flags(), setFlags()-
1779*/-
1780void QGraphicsItem::setFlag(GraphicsItemFlag flag, bool enabled)-
1781{-
1782 if (enabled)
enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
1783 setFlags(GraphicsItemFlags(d_ptr->flags) | flag);
never executed: setFlags(GraphicsItemFlags(d_ptr->flags) | flag);
0
1784 else-
1785 setFlags(GraphicsItemFlags(d_ptr->flags) & ~flag);
never executed: setFlags(GraphicsItemFlags(d_ptr->flags) & ~flag);
0
1786}-
1787-
1788/*!-
1789 Sets the item flags to \a flags. All flags in \a flags are enabled; all-
1790 flags not in \a flags are disabled.-
1791-
1792 If the item had focus and \a flags does not enable ItemIsFocusable, the-
1793 item loses focus as a result of calling this function. Similarly, if the-
1794 item was selected, and \a flags does not enabled ItemIsSelectable, the-
1795 item is automatically unselected.-
1796-
1797 By default, no flags are enabled. (QGraphicsWidget enables the-
1798 ItemSendsGeometryChanges flag by default in order to track position-
1799 changes.)-
1800-
1801 \sa flags(), setFlag()-
1802*/-
1803void QGraphicsItem::setFlags(GraphicsItemFlags flags)-
1804{-
1805 // Notify change and check for adjustment.-
1806 if (quint32(d_ptr->flags) == quint32(flags))
quint32(d_ptr-...quint32(flags)Description
TRUEnever evaluated
FALSEnever evaluated
0
1807 return;
never executed: return;
0
1808 flags = GraphicsItemFlags(itemChange(ItemFlagsChange, quint32(flags)).toUInt());-
1809 if (quint32(d_ptr->flags) == quint32(flags))
quint32(d_ptr-...quint32(flags)Description
TRUEnever evaluated
FALSEnever evaluated
0
1810 return;
never executed: return;
0
1811 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
1812 d_ptr->scene->d_func()->index->itemChange(this, ItemFlagsChange, &flags);
never executed: d_ptr->scene->d_func()->index->itemChange(this, ItemFlagsChange, &flags);
0
1813-
1814 // Flags that alter the geometry of the item (or its children).-
1815 const quint32 geomChangeFlagsMask = (ItemClipsChildrenToShape | ItemClipsToShape | ItemIgnoresTransformations | ItemIsSelectable);-
1816 bool fullUpdate = (quint32(flags) & geomChangeFlagsMask) != (d_ptr->flags & geomChangeFlagsMask);-
1817 if (fullUpdate)
fullUpdateDescription
TRUEnever evaluated
FALSEnever evaluated
0
1818 d_ptr->updatePaintedViewBoundingRects(/*children=*/true);
never executed: d_ptr->updatePaintedViewBoundingRects( true);
0
1819-
1820 // Keep the old flags to compare the diff.-
1821 GraphicsItemFlags oldFlags = GraphicsItemFlags(d_ptr->flags);-
1822-
1823 // Update flags.-
1824 d_ptr->flags = flags;-
1825-
1826 if (!(d_ptr->flags & ItemIsFocusable) && hasFocus()) {
!(d_ptr->flags...emIsFocusable)Description
TRUEnever evaluated
FALSEnever evaluated
hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
1827 // Clear focus on the item if it has focus when the focusable flag-
1828 // is unset.-
1829 clearFocus();-
1830 }
never executed: end of block
0
1831-
1832 if (!(d_ptr->flags & ItemIsSelectable) && isSelected()) {
!(d_ptr->flags...mIsSelectable)Description
TRUEnever evaluated
FALSEnever evaluated
isSelected()Description
TRUEnever evaluated
FALSEnever evaluated
0
1833 // Unselect the item if it is selected when the selectable flag is-
1834 // unset.-
1835 setSelected(false);-
1836 }
never executed: end of block
0
1837-
1838 if ((flags & ItemClipsChildrenToShape) != (oldFlags & ItemClipsChildrenToShape)) {
(flags & ItemC...ildrenToShape)Description
TRUEnever evaluated
FALSEnever evaluated
0
1839 // Item children clipping changes. Propagate the ancestor flag to-
1840 // all children.-
1841 d_ptr->updateAncestorFlag(ItemClipsChildrenToShape);-
1842 // The childrenBoundingRect is clipped to the boundingRect in case of ItemClipsChildrenToShape,-
1843 // which means we have to invalidate the cached childrenBoundingRect whenever this flag changes.-
1844 d_ptr->dirtyChildrenBoundingRect = 1;-
1845 d_ptr->markParentDirty(true);-
1846 }
never executed: end of block
0
1847-
1848 if ((flags & ItemContainsChildrenInShape) != (oldFlags & ItemContainsChildrenInShape)) {
(flags & ItemC...ildrenInShape)Description
TRUEnever evaluated
FALSEnever evaluated
0
1849 // Item children containtment changes. Propagate the ancestor flag to all children.-
1850 d_ptr->updateAncestorFlag(ItemContainsChildrenInShape);-
1851 }
never executed: end of block
0
1852-
1853 if ((flags & ItemIgnoresTransformations) != (oldFlags & ItemIgnoresTransformations)) {
(flags & ItemI...ansformations)Description
TRUEnever evaluated
FALSEnever evaluated
0
1854 // Item children clipping changes. Propagate the ancestor flag to-
1855 // all children.-
1856 d_ptr->updateAncestorFlag(ItemIgnoresTransformations);-
1857 }
never executed: end of block
0
1858-
1859 if ((flags & ItemNegativeZStacksBehindParent) != (oldFlags & ItemNegativeZStacksBehindParent)) {
(flags & ItemN...sBehindParent)Description
TRUEnever evaluated
FALSEnever evaluated
0
1860 // NB! We change the flags directly here, so we must also update d_ptr->flags.-
1861 // Note that this has do be done before the ItemStacksBehindParent check-
1862 // below; otherwise we will loose the change.-
1863-
1864 // Update stack-behind.-
1865 if (d_ptr->z < qreal(0.0))
d_ptr->z < qreal(0.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
1866 flags |= ItemStacksBehindParent;
never executed: flags |= ItemStacksBehindParent;
0
1867 else-
1868 flags &= ~ItemStacksBehindParent;
never executed: flags &= ~ItemStacksBehindParent;
0
1869 d_ptr->flags = flags;-
1870 }
never executed: end of block
0
1871-
1872 if ((flags & ItemStacksBehindParent) != (oldFlags & ItemStacksBehindParent)) {
(flags & ItemS...sBehindParent)Description
TRUEnever evaluated
FALSEnever evaluated
0
1873 // NB! This check has to come after the ItemNegativeZStacksBehindParent-
1874 // check above. Be careful.-
1875-
1876 // Ensure child item sorting is up to date when toggling this flag.-
1877 if (d_ptr->parent)
d_ptr->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
1878 d_ptr->parent->d_ptr->needSortChildren = 1;
never executed: d_ptr->parent->d_ptr->needSortChildren = 1;
0
1879 else if (d_ptr->scene)
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
1880 d_ptr->scene->d_func()->needSortTopLevelItems = 1;
never executed: d_ptr->scene->d_func()->needSortTopLevelItems = 1;
0
1881 }
never executed: end of block
0
1882-
1883 if ((flags & ItemAcceptsInputMethod) != (oldFlags & ItemAcceptsInputMethod)) {
(flags & ItemA...tsInputMethod)Description
TRUEnever evaluated
FALSEnever evaluated
0
1884 // Update input method sensitivity in any views.-
1885 if (d_ptr->scene)
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
1886 d_ptr->scene->d_func()->updateInputMethodSensitivityInViews();
never executed: d_ptr->scene->d_func()->updateInputMethodSensitivityInViews();
0
1887 }
never executed: end of block
0
1888-
1889 if ((flags & ItemIsPanel) != (oldFlags & ItemIsPanel)) {
(flags & ItemI...& ItemIsPanel)Description
TRUEnever evaluated
FALSEnever evaluated
0
1890 bool becomesPanel = (flags & ItemIsPanel);-
1891 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
1892 // update the panel's modal state-
1893 if (becomesPanel)
becomesPanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1894 d_ptr->scene->d_func()->enterModal(this);
never executed: d_ptr->scene->d_func()->enterModal(this);
0
1895 else-
1896 d_ptr->scene->d_func()->leaveModal(this);
never executed: d_ptr->scene->d_func()->leaveModal(this);
0
1897 }-
1898 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
1899 QGraphicsWidget *w = static_cast<QGraphicsWidget *>(this);-
1900 QGraphicsWidget *focusFirst = w;-
1901 QGraphicsWidget *focusLast = w;-
1902 for (;;) {-
1903 QGraphicsWidget *test = focusLast->d_func()->focusNext;-
1904 if (!w->isAncestorOf(test) || test == w)
!w->isAncestorOf(test)Description
TRUEnever evaluated
FALSEnever evaluated
test == wDescription
TRUEnever evaluated
FALSEnever evaluated
0
1905 break;
never executed: break;
0
1906 focusLast = test;-
1907 }
never executed: end of block
0
1908-
1909 if (becomesPanel) {
becomesPanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
1910 // unlink own widgets from focus chain-
1911 QGraphicsWidget *beforeMe = w->d_func()->focusPrev;-
1912 QGraphicsWidget *afterMe = focusLast->d_func()->focusNext;-
1913 beforeMe->d_func()->focusNext = afterMe;-
1914 afterMe->d_func()->focusPrev = beforeMe;-
1915 focusFirst->d_func()->focusPrev = focusLast;-
1916 focusLast->d_func()->focusNext = focusFirst;-
1917 if (!isAncestorOf(focusFirst->d_func()->focusNext))
!isAncestorOf(...()->focusNext)Description
TRUEnever evaluated
FALSEnever evaluated
0
1918 focusFirst->d_func()->focusNext = w;
never executed: focusFirst->d_func()->focusNext = w;
0
1919 } else if (QGraphicsWidget *pw = parentWidget()) {
never executed: end of block
QGraphicsWidge...parentWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
1920 // link up own widgets to focus chain-
1921 QGraphicsWidget *beforeMe = pw;-
1922 QGraphicsWidget *afterMe = pw->d_func()->focusNext;-
1923 beforeMe->d_func()->focusNext = w;-
1924 afterMe->d_func()->focusPrev = focusLast;-
1925 w->d_func()->focusPrev = beforeMe;-
1926 focusLast->d_func()->focusNext = afterMe;-
1927 }
never executed: end of block
0
1928 }
never executed: end of block
0
1929 }
never executed: end of block
0
1930-
1931 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
1932 if ((flags & ItemSendsScenePositionChanges) != (oldFlags & ItemSendsScenePositionChanges)) {
(flags & ItemS...sitionChanges)Description
TRUEnever evaluated
FALSEnever evaluated
0
1933 if (flags & ItemSendsScenePositionChanges)
flags & ItemSe...ositionChangesDescription
TRUEnever evaluated
FALSEnever evaluated
0
1934 d_ptr->scene->d_func()->registerScenePosItem(this);
never executed: d_ptr->scene->d_func()->registerScenePosItem(this);
0
1935 else-
1936 d_ptr->scene->d_func()->unregisterScenePosItem(this);
never executed: d_ptr->scene->d_func()->unregisterScenePosItem(this);
0
1937 }-
1938 d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true);-
1939 }
never executed: end of block
0
1940-
1941 // Notify change.-
1942 itemChange(ItemFlagsHaveChanged, quint32(flags));-
1943}
never executed: end of block
0
1944-
1945/*!-
1946 \since 4.4-
1947 Returns the cache mode for this item. The default mode is NoCache (i.e.,-
1948 cache is disabled and all painting is immediate).-
1949-
1950 \sa setCacheMode()-
1951*/-
1952QGraphicsItem::CacheMode QGraphicsItem::cacheMode() const-
1953{-
1954 return QGraphicsItem::CacheMode(d_ptr->cacheMode);
never executed: return QGraphicsItem::CacheMode(d_ptr->cacheMode);
0
1955}-
1956-
1957/*!-
1958 \since 4.4-
1959 Sets the item's cache mode to \a mode.-
1960-
1961 The optional \a logicalCacheSize argument is used only by-
1962 ItemCoordinateCache mode, and describes the resolution of the cache-
1963 buffer; if \a logicalCacheSize is (100, 100), QGraphicsItem will fit the-
1964 item into 100x100 pixels in graphics memory, regardless of the logical-
1965 size of the item itself. By default QGraphicsItem uses the size of-
1966 boundingRect(). For all other cache modes than ItemCoordinateCache, \a-
1967 logicalCacheSize is ignored.-
1968-
1969 Caching can speed up rendering if your item spends a significant time-
1970 redrawing itself. In some cases the cache can also slow down rendering, in-
1971 particular when the item spends less time redrawing than QGraphicsItem-
1972 spends redrawing from the cache.-
1973-
1974 When caching is enabled, an item's paint() function will generally draw into an-
1975 offscreen pixmap cache; for any subsequent-
1976 repaint requests, the Graphics View framework will redraw from the-
1977 cache. This approach works particularly well with QGLWidget, which stores-
1978 all the cache as OpenGL textures.-
1979-
1980 Be aware that QPixmapCache's cache limit may need to be changed to obtain-
1981 optimal performance.-
1982-
1983 You can read more about the different cache modes in the CacheMode-
1984 documentation.-
1985-
1986 \note Enabling caching does not imply that the item's paint() function will be-
1987 called only in response to an explicit update() call. For instance, under-
1988 memory pressure, Qt may decide to drop some of the cache information;-
1989 in such cases an item's paint() function will be called even if there-
1990 was no update() call (that is, exactly as if there were no caching enabled).-
1991-
1992 \sa CacheMode, QPixmapCache::setCacheLimit()-
1993*/-
1994void QGraphicsItem::setCacheMode(CacheMode mode, const QSize &logicalCacheSize)-
1995{-
1996 CacheMode lastMode = CacheMode(d_ptr->cacheMode);-
1997 d_ptr->cacheMode = mode;-
1998 bool noVisualChange = (mode == NoCache && lastMode == NoCache)
mode == NoCacheDescription
TRUEnever evaluated
FALSEnever evaluated
lastMode == NoCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
1999 || (mode == NoCache && lastMode == DeviceCoordinateCache)
mode == NoCacheDescription
TRUEnever evaluated
FALSEnever evaluated
lastMode == De...oordinateCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
2000 || (mode == DeviceCoordinateCache && lastMode == NoCache)
mode == DeviceCoordinateCacheDescription
TRUEnever evaluated
FALSEnever evaluated
lastMode == NoCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
2001 || (mode == DeviceCoordinateCache && lastMode == DeviceCoordinateCache);
mode == DeviceCoordinateCacheDescription
TRUEnever evaluated
FALSEnever evaluated
lastMode == De...oordinateCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
2002 if (mode == NoCache) {
mode == NoCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
2003 d_ptr->removeExtraItemCache();-
2004 } else {
never executed: end of block
0
2005 QGraphicsItemCache *cache = d_ptr->extraItemCache();-
2006-
2007 // Reset old cache-
2008 cache->purge();-
2009-
2010 if (mode == ItemCoordinateCache) {
mode == ItemCoordinateCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
2011 if (lastMode == mode && cache->fixedSize == logicalCacheSize)
lastMode == modeDescription
TRUEnever evaluated
FALSEnever evaluated
cache->fixedSi...gicalCacheSizeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2012 noVisualChange = true;
never executed: noVisualChange = true;
0
2013 cache->fixedSize = logicalCacheSize;-
2014 }
never executed: end of block
0
2015 }
never executed: end of block
0
2016 if (!noVisualChange)
!noVisualChangeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2017 update();
never executed: update();
0
2018}
never executed: end of block
0
2019-
2020/*!-
2021 \since 4.6-
2022-
2023 Returns the modality for this item.-
2024*/-
2025QGraphicsItem::PanelModality QGraphicsItem::panelModality() const-
2026{-
2027 return d_ptr->panelModality;
never executed: return d_ptr->panelModality;
0
2028}-
2029-
2030/*!-
2031 \since 4.6-
2032-
2033 Sets the modality for this item to \a panelModality.-
2034-
2035 Changing the modality of a visible item takes effect immediately.-
2036*/-
2037void QGraphicsItem::setPanelModality(PanelModality panelModality)-
2038{-
2039 if (d_ptr->panelModality == panelModality)
d_ptr->panelMo... panelModalityDescription
TRUEnever evaluated
FALSEnever evaluated
0
2040 return;
never executed: return;
0
2041-
2042 PanelModality previousModality = d_ptr->panelModality;-
2043 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
2044 if (enterLeaveModal && panelModality == NonModal)
enterLeaveModalDescription
TRUEnever evaluated
FALSEnever evaluated
panelModality == NonModalDescription
TRUEnever evaluated
FALSEnever evaluated
0
2045 d_ptr->scene->d_func()->leaveModal(this);
never executed: d_ptr->scene->d_func()->leaveModal(this);
0
2046 d_ptr->panelModality = panelModality;-
2047 if (enterLeaveModal && d_ptr->panelModality != NonModal)
enterLeaveModalDescription
TRUEnever evaluated
FALSEnever evaluated
d_ptr->panelMo...ty != NonModalDescription
TRUEnever evaluated
FALSEnever evaluated
0
2048 d_ptr->scene->d_func()->enterModal(this, previousModality);
never executed: d_ptr->scene->d_func()->enterModal(this, previousModality);
0
2049}
never executed: end of block
0
2050-
2051/*!-
2052 \since 4.6-
2053-
2054 Returns \c true if this item is blocked by a modal panel, false otherwise. If \a blockingPanel is-
2055 non-zero, \a blockingPanel will be set to the modal panel that is blocking this item. If this-
2056 item is not blocked, \a blockingPanel will not be set by this function.-
2057-
2058 This function always returns \c false for items not in a scene.-
2059-
2060 \sa panelModality(), setPanelModality(), PanelModality-
2061*/-
2062bool QGraphicsItem::isBlockedByModalPanel(QGraphicsItem **blockingPanel) const-
2063{-
2064 if (!d_ptr->scene)
!d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2065 return false;
never executed: return false;
0
2066-
2067-
2068 QGraphicsItem *dummy = 0;-
2069 if (!blockingPanel)
!blockingPanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
2070 blockingPanel = &dummy;
never executed: blockingPanel = &dummy;
0
2071-
2072 QGraphicsScenePrivate *scene_d = d_ptr->scene->d_func();-
2073 if (scene_d->modalPanels.isEmpty())
scene_d->modalPanels.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2074 return false;
never executed: return false;
0
2075-
2076 // ###-
2077 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
2078 return false;
never executed: return false;
0
2079-
2080 for (int i = 0; i < scene_d->modalPanels.count(); ++i) {
i < scene_d->m...Panels.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
2081 QGraphicsItem *modalPanel = scene_d->modalPanels.at(i);-
2082 if (modalPanel->panelModality() == QGraphicsItem::SceneModal) {
modalPanel->pa...em::SceneModalDescription
TRUEnever evaluated
FALSEnever evaluated
0
2083 // Scene modal panels block all non-descendents.-
2084 if (modalPanel != this && !modalPanel->isAncestorOf(this)) {
modalPanel != thisDescription
TRUEnever evaluated
FALSEnever evaluated
!modalPanel->i...cestorOf(this)Description
TRUEnever evaluated
FALSEnever evaluated
0
2085 *blockingPanel = modalPanel;-
2086 return true;
never executed: return true;
0
2087 }-
2088 } else {
never executed: end of block
0
2089 // Window modal panels block ancestors and siblings/cousins.-
2090 if (modalPanel != this
modalPanel != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
2091 && !modalPanel->isAncestorOf(this)
!modalPanel->i...cestorOf(this)Description
TRUEnever evaluated
FALSEnever evaluated
0
2092 && commonAncestorItem(modalPanel)) {
commonAncestorItem(modalPanel)Description
TRUEnever evaluated
FALSEnever evaluated
0
2093 *blockingPanel = modalPanel;-
2094 return true;
never executed: return true;
0
2095 }-
2096 }
never executed: end of block
0
2097 }-
2098 return false;
never executed: return false;
0
2099}-
2100-
2101#ifndef QT_NO_TOOLTIP-
2102/*!-
2103 Returns the item's tool tip, or an empty QString if no tool tip has been-
2104 set.-
2105-
2106 \sa setToolTip(), QToolTip-
2107*/-
2108QString QGraphicsItem::toolTip() const-
2109{-
2110 return d_ptr->extra(QGraphicsItemPrivate::ExtraToolTip).toString();
never executed: return d_ptr->extra(QGraphicsItemPrivate::ExtraToolTip).toString();
0
2111}-
2112-
2113/*!-
2114 Sets the item's tool tip to \a toolTip. If \a toolTip is empty, the item's-
2115 tool tip is cleared.-
2116-
2117 \sa toolTip(), QToolTip-
2118*/-
2119void QGraphicsItem::setToolTip(const QString &toolTip)-
2120{-
2121 const QVariant toolTipVariant(itemChange(ItemToolTipChange, toolTip));-
2122 d_ptr->setExtra(QGraphicsItemPrivate::ExtraToolTip, toolTipVariant.toString());-
2123 itemChange(ItemToolTipHasChanged, toolTipVariant);-
2124}
never executed: end of block
0
2125#endif // QT_NO_TOOLTIP-
2126-
2127#ifndef QT_NO_CURSOR-
2128/*!-
2129 Returns the current cursor shape for the item. The mouse cursor-
2130 will assume this shape when it's over this item.-
2131 See the \l{Qt::CursorShape}{list of predefined cursor objects} for a-
2132 range of useful shapes.-
2133-
2134 An editor item might want to use an I-beam cursor:-
2135-
2136 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 2-
2137-
2138 If no cursor has been set, the cursor of the item beneath is used.-
2139-
2140 \sa setCursor(), hasCursor(), unsetCursor(), QWidget::cursor,-
2141 QApplication::overrideCursor()-
2142*/-
2143QCursor QGraphicsItem::cursor() const-
2144{-
2145 return qvariant_cast<QCursor>(d_ptr->extra(QGraphicsItemPrivate::ExtraCursor));
never executed: return qvariant_cast<QCursor>(d_ptr->extra(QGraphicsItemPrivate::ExtraCursor));
0
2146}-
2147-
2148/*!-
2149 Sets the current cursor shape for the item to \a cursor. The mouse cursor-
2150 will assume this shape when it's over this item.-
2151 See the \l{Qt::CursorShape}{list of predefined cursor objects} for a-
2152 range of useful shapes.-
2153-
2154 An editor item might want to use an I-beam cursor:-
2155-
2156 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 3-
2157-
2158 If no cursor has been set, the cursor of the item beneath is used.-
2159-
2160 \sa cursor(), hasCursor(), unsetCursor(), QWidget::cursor,-
2161 QApplication::overrideCursor()-
2162*/-
2163void QGraphicsItem::setCursor(const QCursor &cursor)-
2164{-
2165 const QVariant cursorVariant(itemChange(ItemCursorChange, QVariant::fromValue<QCursor>(cursor)));-
2166 d_ptr->setExtra(QGraphicsItemPrivate::ExtraCursor, qvariant_cast<QCursor>(cursorVariant));-
2167 d_ptr->hasCursor = 1;-
2168 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2169 d_ptr->scene->d_func()->allItemsUseDefaultCursor = false;-
2170 foreach (QGraphicsView *view, d_ptr->scene->views()) {-
2171 view->viewport()->setMouseTracking(true);-
2172 // Note: Some of this logic is duplicated in QGraphicsView's mouse events.-
2173 if (view->underMouse()) {
view->underMouse()Description
TRUEnever evaluated
FALSEnever evaluated
0
2174 foreach (QGraphicsItem *itemUnderCursor, view->items(view->mapFromGlobal(QCursor::pos()))) {-
2175 if (itemUnderCursor->hasCursor()) {
itemUnderCursor->hasCursor()Description
TRUEnever evaluated
FALSEnever evaluated
0
2176 QMetaObject::invokeMethod(view, "_q_setViewportCursor",-
2177 Q_ARG(QCursor, itemUnderCursor->cursor()));-
2178 break;
never executed: break;
0
2179 }-
2180 }
never executed: end of block
0
2181 break;
never executed: break;
0
2182 }-
2183 }
never executed: end of block
0
2184 }
never executed: end of block
0
2185 itemChange(ItemCursorHasChanged, cursorVariant);-
2186}
never executed: end of block
0
2187-
2188/*!-
2189 Returns \c true if this item has a cursor set; otherwise, false is returned.-
2190-
2191 By default, items don't have any cursor set. cursor() will return a-
2192 standard pointing arrow cursor.-
2193-
2194 \sa unsetCursor()-
2195*/-
2196bool QGraphicsItem::hasCursor() const-
2197{-
2198 return d_ptr->hasCursor;
never executed: return d_ptr->hasCursor;
0
2199}-
2200-
2201/*!-
2202 Clears the cursor from this item.-
2203-
2204 \sa hasCursor(), setCursor()-
2205*/-
2206void QGraphicsItem::unsetCursor()-
2207{-
2208 if (!d_ptr->hasCursor)
!d_ptr->hasCursorDescription
TRUEnever evaluated
FALSEnever evaluated
0
2209 return;
never executed: return;
0
2210 d_ptr->unsetExtra(QGraphicsItemPrivate::ExtraCursor);-
2211 d_ptr->hasCursor = 0;-
2212 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2213 foreach (QGraphicsView *view, d_ptr->scene->views()) {-
2214 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
2215 QMetaObject::invokeMethod(view, "_q_unsetViewportCursor");-
2216 break;
never executed: break;
0
2217 }-
2218 }
never executed: end of block
0
2219 }
never executed: end of block
0
2220}
never executed: end of block
0
2221-
2222#endif // QT_NO_CURSOR-
2223-
2224/*!-
2225 Returns \c true if the item is visible; otherwise, false is returned.-
2226-
2227 Note that the item's general visibility is unrelated to whether or not it-
2228 is actually being visualized by a QGraphicsView.-
2229-
2230 \sa setVisible()-
2231*/-
2232bool QGraphicsItem::isVisible() const-
2233{-
2234 return d_ptr->visible;
never executed: return d_ptr->visible;
0
2235}-
2236-
2237/*!-
2238 \since 4.4-
2239 Returns \c true if the item is visible to \a parent; otherwise, false is-
2240 returned. \a parent can be 0, in which case this function will return-
2241 whether the item is visible to the scene or not.-
2242-
2243 An item may not be visible to its ancestors even if isVisible() is true. It-
2244 may also be visible to its ancestors even if isVisible() is false. If-
2245 any ancestor is hidden, the item itself will be implicitly hidden, in which-
2246 case this function will return false.-
2247-
2248 \sa isVisible(), setVisible()-
2249*/-
2250bool QGraphicsItem::isVisibleTo(const QGraphicsItem *parent) const-
2251{-
2252 const QGraphicsItem *p = this;-
2253 if (d_ptr->explicitlyHidden)
d_ptr->explicitlyHiddenDescription
TRUEnever evaluated
FALSEnever evaluated
0
2254 return false;
never executed: return false;
0
2255 do {-
2256 if (p == parent)
p == parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
2257 return true;
never executed: return true;
0
2258 if (p->d_ptr->explicitlyHidden)
p->d_ptr->explicitlyHiddenDescription
TRUEnever evaluated
FALSEnever evaluated
0
2259 return false;
never executed: return false;
0
2260 } while ((p = p->d_ptr->parent));
never executed: end of block
(p = p->d_ptr->parent)Description
TRUEnever evaluated
FALSEnever evaluated
0
2261 return parent == 0;
never executed: return parent == 0;
0
2262}-
2263-
2264/*!-
2265 \internal-
2266-
2267 Sets this item's visibility to \a newVisible. If \a explicitly is true,-
2268 this item will be "explicitly" \a newVisible; otherwise, it.. will not be.-
2269*/-
2270void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly,-
2271 bool update, bool hiddenByPanel)-
2272{-
2273 Q_Q(QGraphicsItem);-
2274-
2275 // Update explicit bit.-
2276 if (explicitly)
explicitlyDescription
TRUEnever evaluated
FALSEnever evaluated
0
2277 explicitlyHidden = newVisible ? 0 : 1;
never executed: explicitlyHidden = newVisible ? 0 : 1;
newVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
2278-
2279 // Check if there's nothing to do.-
2280 if (visible == quint32(newVisible))
visible == quint32(newVisible)Description
TRUEnever evaluated
FALSEnever evaluated
0
2281 return;
never executed: return;
0
2282-
2283 // Don't show child if parent is not visible-
2284 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
2285 return;
never executed: return;
0
2286-
2287 // Modify the property.-
2288 const QVariant newVisibleVariant(q_ptr->itemChange(QGraphicsItem::ItemVisibleChange,-
2289 quint32(newVisible)));-
2290 newVisible = newVisibleVariant.toBool();-
2291 if (visible == quint32(newVisible))
visible == quint32(newVisible)Description
TRUEnever evaluated
FALSEnever evaluated
0
2292 return;
never executed: return;
0
2293 visible = newVisible;-
2294-
2295 // Schedule redrawing-
2296 if (update) {
updateDescription
TRUEnever evaluated
FALSEnever evaluated
0
2297 QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));-
2298 if (c)
cDescription
TRUEnever evaluated
FALSEnever evaluated
0
2299 c->purge();
never executed: c->purge();
0
2300 if (scene) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2301#ifndef QT_NO_GRAPHICSEFFECT-
2302 invalidateParentGraphicsEffectsRecursively();-
2303#endif //QT_NO_GRAPHICSEFFECT-
2304 scene->d_func()->markDirty(q_ptr, QRectF(), /*invalidateChildren=*/false, /*force=*/true);-
2305 }
never executed: end of block
0
2306 }
never executed: end of block
0
2307-
2308 // Certain properties are dropped as an item becomes invisible.-
2309 bool hasFocus = q_ptr->hasFocus();-
2310 if (!newVisible) {
!newVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
2311 if (scene) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2312 if (scene->d_func()->mouseGrabberItems.contains(q))
scene->d_func(...ms.contains(q)Description
TRUEnever evaluated
FALSEnever evaluated
0
2313 q->ungrabMouse();
never executed: q->ungrabMouse();
0
2314 if (scene->d_func()->keyboardGrabberItems.contains(q))
scene->d_func(...ms.contains(q)Description
TRUEnever evaluated
FALSEnever evaluated
0
2315 q->ungrabKeyboard();
never executed: q->ungrabKeyboard();
0
2316 if (q->isPanel() && panelModality != QGraphicsItem::NonModal)
q->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
panelModality ...Item::NonModalDescription
TRUEnever evaluated
FALSEnever evaluated
0
2317 scene->d_func()->leaveModal(q_ptr);
never executed: scene->d_func()->leaveModal(q_ptr);
0
2318 }
never executed: end of block
0
2319 if (hasFocus && scene) {
hasFocusDescription
TRUEnever evaluated
FALSEnever evaluated
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2320 // Hiding the focus item or the closest non-panel ancestor of the focus item-
2321 QGraphicsItem *focusItem = scene->focusItem();-
2322 bool clear = true;-
2323 if (isWidget && !focusItem->isPanel()) {
isWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
!focusItem->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
2324 do {-
2325 if (focusItem == q_ptr) {
focusItem == q_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
2326 clear = !static_cast<QGraphicsWidget *>(q_ptr)->focusNextPrevChild(true);-
2327 break;
never executed: break;
0
2328 }-
2329 } 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
2330 }
never executed: end of block
0
2331 if (clear)
clearDescription
TRUEnever evaluated
FALSEnever evaluated
0
2332 clearFocusHelper(/* giveFocusToParent = */ false, hiddenByPanel);
never executed: clearFocusHelper( false, hiddenByPanel);
0
2333 }
never executed: end of block
0
2334 if (q_ptr->isSelected())
q_ptr->isSelected()Description
TRUEnever evaluated
FALSEnever evaluated
0
2335 q_ptr->setSelected(false);
never executed: q_ptr->setSelected(false);
0
2336 } else {
never executed: end of block
0
2337 geometryChanged = 1;-
2338 paintedViewBoundingRectsNeedRepaint = 1;-
2339 if (scene) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2340 if (isWidget) {
isWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
2341 QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(q_ptr);-
2342 if (widget->windowType() == Qt::Popup)
widget->window...) == Qt::PopupDescription
TRUEnever evaluated
FALSEnever evaluated
0
2343 scene->d_func()->addPopup(widget);
never executed: scene->d_func()->addPopup(widget);
0
2344 }
never executed: end of block
0
2345 if (q->isPanel() && panelModality != QGraphicsItem::NonModal) {
q->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
panelModality ...Item::NonModalDescription
TRUEnever evaluated
FALSEnever evaluated
0
2346 scene->d_func()->enterModal(q_ptr);-
2347 }
never executed: end of block
0
2348 }
never executed: end of block
0
2349 }
never executed: end of block
0
2350-
2351 // Update children with explicitly = false.-
2352 const bool updateChildren = update && !((flags & QGraphicsItem::ItemClipsChildrenToShape
updateDescription
TRUEnever evaluated
FALSEnever evaluated
flags & QGraph...hildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2353 || flags & QGraphicsItem::ItemContainsChildrenInShape)
flags & QGraph...hildrenInShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2354 && !(flags & QGraphicsItem::ItemHasNoContents));
!(flags & QGra...HasNoContents)Description
TRUEnever evaluated
FALSEnever evaluated
0
2355 foreach (QGraphicsItem *child, children) {-
2356 if (!newVisible || !child->d_ptr->explicitlyHidden)
!newVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
!child->d_ptr-...plicitlyHiddenDescription
TRUEnever evaluated
FALSEnever evaluated
0
2357 child->d_ptr->setVisibleHelper(newVisible, false, updateChildren, hiddenByPanel);
never executed: child->d_ptr->setVisibleHelper(newVisible, false, updateChildren, hiddenByPanel);
0
2358 }
never executed: end of block
0
2359-
2360 // Update activation-
2361 if (scene && q->isPanel()) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
q->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
2362 if (newVisible) {
newVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
2363 if (parent && parent->isActive())
parentDescription
TRUEnever evaluated
FALSEnever evaluated
parent->isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
2364 q->setActive(true);
never executed: q->setActive(true);
0
2365 } else {
never executed: end of block
0
2366 if (q->isActive())
q->isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
2367 scene->setActivePanel(parent);
never executed: scene->setActivePanel(parent);
0
2368 }
never executed: end of block
0
2369 }-
2370-
2371 // Enable subfocus-
2372 if (scene) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2373 if (newVisible) {
newVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
2374 // Item is shown-
2375 QGraphicsItem *p = parent;-
2376 bool done = false;-
2377 while (p) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
0
2378 if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
p->flags() & Q...emIsFocusScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2379 QGraphicsItem *fsi = p->d_ptr->focusScopeItem;-
2380 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
2381 done = true;-
2382 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
2383 fsi = fsi->d_ptr->focusScopeItem;
never executed: fsi = fsi->d_ptr->focusScopeItem;
0
2384 fsi->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ true,-
2385 /* focusFromHide = */ false);-
2386 }
never executed: end of block
0
2387 break;
never executed: break;
0
2388 }-
2389 p = p->d_ptr->parent;-
2390 }
never executed: end of block
0
2391 if (!done) {
!doneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2392 QGraphicsItem *fi = subFocusItem;-
2393 if (fi && fi != scene->focusItem()) {
fiDescription
TRUEnever evaluated
FALSEnever evaluated
fi != scene->focusItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
2394 scene->setFocusItem(fi);-
2395 } else if (flags & QGraphicsItem::ItemIsFocusScope &&
never executed: end of block
flags & QGraph...emIsFocusScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2396 !scene->focusItem() &&
!scene->focusItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
2397 q->isAncestorOf(scene->d_func()->lastFocusItem)) {
q->isAncestorO...lastFocusItem)Description
TRUEnever evaluated
FALSEnever evaluated
0
2398 q_ptr->setFocus();-
2399 }
never executed: end of block
0
2400 }
never executed: end of block
0
2401 } else {
never executed: end of block
0
2402 // Item is hidden-
2403 if (hasFocus) {
hasFocusDescription
TRUEnever evaluated
FALSEnever evaluated
0
2404 QGraphicsItem *p = parent;-
2405 while (p) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
0
2406 if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
p->flags() & Q...emIsFocusScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
2407 if (p->d_ptr->visible) {
p->d_ptr->visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
2408 p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ true,-
2409 /* focusFromHide = */ true);-
2410 }
never executed: end of block
0
2411 break;
never executed: break;
0
2412 }-
2413 p = p->d_ptr->parent;-
2414 }
never executed: end of block
0
2415 }
never executed: end of block
0
2416 }
never executed: end of block
0
2417 }-
2418-
2419 // Deliver post-change notification.-
2420 q_ptr->itemChange(QGraphicsItem::ItemVisibleHasChanged, newVisibleVariant);-
2421-
2422 if (isObject)
isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
2423 emit static_cast<QGraphicsObject *>(q_ptr)->visibleChanged();
never executed: static_cast<QGraphicsObject *>(q_ptr)->visibleChanged();
0
2424}
never executed: end of block
0
2425-
2426/*!-
2427 If \a visible is true, the item is made visible. Otherwise, the item is-
2428 made invisible. Invisible items are not painted, nor do they receive any-
2429 events. In particular, mouse events pass right through invisible items,-
2430 and are delivered to any item that may be behind. Invisible items are also-
2431 unselectable, they cannot take input focus, and are not detected by-
2432 QGraphicsScene's item location functions.-
2433-
2434 If an item becomes invisible while grabbing the mouse, (i.e., while it is-
2435 receiving mouse events,) it will automatically lose the mouse grab, and-
2436 the grab is not regained by making the item visible again; it must receive-
2437 a new mouse press to regain the mouse grab.-
2438-
2439 Similarly, an invisible item cannot have focus, so if the item has focus-
2440 when it becomes invisible, it will lose focus, and the focus is not-
2441 regained by simply making the item visible again.-
2442-
2443 If you hide a parent item, all its children will also be hidden. If you-
2444 show a parent item, all children will be shown, unless they have been-
2445 explicitly hidden (i.e., if you call setVisible(false) on a child, it will-
2446 not be reshown even if its parent is hidden, and then shown again).-
2447-
2448 Items are visible by default; it is unnecessary to call-
2449 setVisible() on a new item.-
2450-
2451 \note An item with opacity set to 0 will still be considered visible,-
2452 although it will be treated like an invisible item: mouse events will pass-
2453 through it, it will not be included in the items returned by-
2454 QGraphicsView::items(), and so on. However, the item will retain the focus.-
2455-
2456 \sa isVisible(), show(), hide(), setOpacity()-
2457*/-
2458void QGraphicsItem::setVisible(bool visible)-
2459{-
2460 d_ptr->setVisibleHelper(visible,-
2461 /* explicit = */ true,-
2462 /* update = */ true,-
2463 /* hiddenByPanel = */ isPanel());-
2464}
never executed: end of block
0
2465-
2466/*!-
2467 \fn void QGraphicsItem::hide()-
2468-
2469 Hides the item (items are visible by default).-
2470-
2471 This convenience function is equivalent to calling \c setVisible(false).-
2472-
2473 \sa show(), setVisible()-
2474*/-
2475-
2476/*!-
2477 \fn void QGraphicsItem::show()-
2478-
2479 Shows the item (items are visible by default).-
2480-
2481 This convenience function is equivalent to calling \c setVisible(true).-
2482-
2483 \sa hide(), setVisible()-
2484*/-
2485-
2486/*!-
2487 Returns \c true if the item is enabled; otherwise, false is returned.-
2488-
2489 \sa setEnabled()-
2490*/-
2491bool QGraphicsItem::isEnabled() const-
2492{-
2493 return d_ptr->enabled;
never executed: return d_ptr->enabled;
0
2494}-
2495-
2496/*!-
2497 \internal-
2498-
2499 Sets this item's visibility to \a newEnabled. If \a explicitly is true,-
2500 this item will be "explicitly" \a newEnabled; otherwise, it.. will not be.-
2501*/-
2502void QGraphicsItemPrivate::setEnabledHelper(bool newEnabled, bool explicitly, bool update)-
2503{-
2504 // Update explicit bit.-
2505 if (explicitly)
explicitlyDescription
TRUEnever evaluated
FALSEnever evaluated
0
2506 explicitlyDisabled = newEnabled ? 0 : 1;
never executed: explicitlyDisabled = newEnabled ? 0 : 1;
newEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
2507-
2508 // Check if there's nothing to do.-
2509 if (enabled == quint32(newEnabled))
enabled == quint32(newEnabled)Description
TRUEnever evaluated
FALSEnever evaluated
0
2510 return;
never executed: return;
0
2511-
2512 // Certain properties are dropped when an item is disabled.-
2513 if (!newEnabled) {
!newEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
2514 if (scene && scene->mouseGrabberItem() == q_ptr)
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
scene->mouseGr...tem() == q_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
2515 q_ptr->ungrabMouse();
never executed: q_ptr->ungrabMouse();
0
2516 if (q_ptr->hasFocus()) {
q_ptr->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
2517 // Disabling the closest non-panel ancestor of the focus item-
2518 // causes focus to pop to the next item, otherwise it's cleared.-
2519 QGraphicsItem *focusItem = scene->focusItem();-
2520 bool clear = true;-
2521 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
2522 do {-
2523 if (focusItem == q_ptr) {
focusItem == q_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
2524 clear = !static_cast<QGraphicsWidget *>(q_ptr)->focusNextPrevChild(true);-
2525 break;
never executed: break;
0
2526 }-
2527 } 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
2528 }
never executed: end of block
0
2529 if (clear)
clearDescription
TRUEnever evaluated
FALSEnever evaluated
0
2530 q_ptr->clearFocus();
never executed: q_ptr->clearFocus();
0
2531 }
never executed: end of block
0
2532 if (q_ptr->isSelected())
q_ptr->isSelected()Description
TRUEnever evaluated
FALSEnever evaluated
0
2533 q_ptr->setSelected(false);
never executed: q_ptr->setSelected(false);
0
2534 }
never executed: end of block
0
2535-
2536 // Modify the property.-
2537 const QVariant newEnabledVariant(q_ptr->itemChange(QGraphicsItem::ItemEnabledChange,-
2538 quint32(newEnabled)));-
2539 enabled = newEnabledVariant.toBool();-
2540-
2541 // Schedule redraw.-
2542 if (update)
updateDescription
TRUEnever evaluated
FALSEnever evaluated
0
2543 q_ptr->update();
never executed: q_ptr->update();
0
2544-
2545 foreach (QGraphicsItem *child, children) {-
2546 if (!newEnabled || !child->d_ptr->explicitlyDisabled)
!newEnabledDescription
TRUEnever evaluated
FALSEnever evaluated
!child->d_ptr-...icitlyDisabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
2547 child->d_ptr->setEnabledHelper(newEnabled, /* explicitly = */ false);
never executed: child->d_ptr->setEnabledHelper(newEnabled, false);
0
2548 }
never executed: end of block
0
2549-
2550 // Deliver post-change notification.-
2551 q_ptr->itemChange(QGraphicsItem::ItemEnabledHasChanged, newEnabledVariant);-
2552-
2553 if (isObject)
isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
2554 emit static_cast<QGraphicsObject *>(q_ptr)->enabledChanged();
never executed: static_cast<QGraphicsObject *>(q_ptr)->enabledChanged();
0
2555}
never executed: end of block
0
2556-
2557/*!-
2558 If \a enabled is true, the item is enabled; otherwise, it is disabled.-
2559-
2560 Disabled items are visible, but they do not receive any events, and cannot-
2561 take focus nor be selected. Mouse events are discarded; they are not-
2562 propagated unless the item is also invisible, or if it does not accept-
2563 mouse events (see acceptedMouseButtons()). A disabled item cannot become the-
2564 mouse grabber, and as a result of this, an item loses the grab if it-
2565 becomes disabled when grabbing the mouse, just like it loses focus if it-
2566 had focus when it was disabled.-
2567-
2568 Disabled items are traditionally drawn using grayed-out colors (see \l-
2569 QPalette::Disabled).-
2570-
2571 If you disable a parent item, all its children will also be disabled. If-
2572 you enable a parent item, all children will be enabled, unless they have-
2573 been explicitly disabled (i.e., if you call setEnabled(false) on a child,-
2574 it will not be reenabled if its parent is disabled, and then enabled-
2575 again).-
2576-
2577 Items are enabled by default.-
2578-
2579 \note If you install an event filter, you can still intercept events-
2580 before they are delivered to items; this mechanism disregards the item's-
2581 enabled state.-
2582-
2583 \sa isEnabled()-
2584*/-
2585void QGraphicsItem::setEnabled(bool enabled)-
2586{-
2587 d_ptr->setEnabledHelper(enabled, /* explicitly = */ true);-
2588}
never executed: end of block
0
2589-
2590/*!-
2591 Returns \c true if this item is selected; otherwise, false is returned.-
2592-
2593 Items that are in a group inherit the group's selected state.-
2594-
2595 Items are not selected by default.-
2596-
2597 \sa setSelected(), QGraphicsScene::setSelectionArea()-
2598*/-
2599bool QGraphicsItem::isSelected() const-
2600{-
2601 if (QGraphicsItemGroup *group = this->group())
QGraphicsItemG... this->group()Description
TRUEnever evaluated
FALSEnever evaluated
0
2602 return group->isSelected();
never executed: return group->isSelected();
0
2603 return d_ptr->selected;
never executed: return d_ptr->selected;
0
2604}-
2605-
2606/*!-
2607 If \a selected is true and this item is selectable, this item is selected;-
2608 otherwise, it is unselected.-
2609-
2610 If the item is in a group, the whole group's selected state is toggled by-
2611 this function. If the group is selected, all items in the group are also-
2612 selected, and if the group is not selected, no item in the group is-
2613 selected.-
2614-
2615 Only visible, enabled, selectable items can be selected. If \a selected-
2616 is true and this item is either invisible or disabled or unselectable,-
2617 this function does nothing.-
2618-
2619 By default, items cannot be selected. To enable selection, set the-
2620 ItemIsSelectable flag.-
2621-
2622 This function is provided for convenience, allowing individual toggling of-
2623 the selected state of an item. However, a more common way of selecting-
2624 items is to call QGraphicsScene::setSelectionArea(), which will call this-
2625 function for all visible, enabled, and selectable items within a specified-
2626 area on the scene.-
2627-
2628 \sa isSelected(), QGraphicsScene::selectedItems()-
2629*/-
2630void QGraphicsItem::setSelected(bool selected)-
2631{-
2632 if (QGraphicsItemGroup *group = this->group()) {
QGraphicsItemG... this->group()Description
TRUEnever evaluated
FALSEnever evaluated
0
2633 group->setSelected(selected);-
2634 return;
never executed: return;
0
2635 }-
2636-
2637 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
2638 selected = false;
never executed: selected = false;
0
2639 if (d_ptr->selected == selected)
d_ptr->selected == selectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2640 return;
never executed: return;
0
2641 const QVariant newSelectedVariant(itemChange(ItemSelectedChange, quint32(selected)));-
2642 bool newSelected = newSelectedVariant.toBool();-
2643 if (d_ptr->selected == newSelected)
d_ptr->selected == newSelectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2644 return;
never executed: return;
0
2645 d_ptr->selected = newSelected;-
2646-
2647 update();-
2648 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2649 QGraphicsScenePrivate *sceneD = d_ptr->scene->d_func();-
2650 if (selected) {
selectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
2651 sceneD->selectedItems << this;-
2652 } else {
never executed: end of block
0
2653 // QGraphicsScene::selectedItems() lazily pulls out all items that are-
2654 // no longer selected.-
2655 }
never executed: end of block
0
2656 if (!sceneD->selectionChanging)
!sceneD->selectionChangingDescription
TRUEnever evaluated
FALSEnever evaluated
0
2657 emit d_ptr->scene->selectionChanged();
never executed: d_ptr->scene->selectionChanged();
0
2658 }
never executed: end of block
0
2659-
2660 // Deliver post-change notification.-
2661 itemChange(QGraphicsItem::ItemSelectedHasChanged, newSelectedVariant);-
2662}
never executed: end of block
0
2663-
2664/*!-
2665 \since 4.5-
2666-
2667 Returns this item's local opacity, which is between 0.0 (transparent) and-
2668 1.0 (opaque). This value is combined with parent and ancestor values into-
2669 the effectiveOpacity(). The effective opacity decides how the item is-
2670 rendered and also affects its visibility when queried by functions such as-
2671 QGraphicsView::items().-
2672-
2673 The opacity property decides the state of the painter passed to the-
2674 paint() function. If the item is cached, i.e., ItemCoordinateCache or-
2675 DeviceCoordinateCache, the effective property will be applied to the item's-
2676 cache as it is rendered.-
2677-
2678 The default opacity is 1.0; fully opaque.-
2679-
2680 \sa setOpacity(), paint(), ItemIgnoresParentOpacity,-
2681 ItemDoesntPropagateOpacityToChildren-
2682*/-
2683qreal QGraphicsItem::opacity() const-
2684{-
2685 return d_ptr->opacity;
never executed: return d_ptr->opacity;
0
2686}-
2687-
2688/*!-
2689 \since 4.5-
2690-
2691 Returns this item's \e effective opacity, which is between 0.0-
2692 (transparent) and 1.0 (opaque). This value is a combination of this item's-
2693 local opacity, and its parent and ancestors' opacities. The effective-
2694 opacity decides how the item is rendered.-
2695-
2696 \sa opacity(), setOpacity(), paint(), ItemIgnoresParentOpacity,-
2697 ItemDoesntPropagateOpacityToChildren-
2698*/-
2699qreal QGraphicsItem::effectiveOpacity() const-
2700{-
2701 return d_ptr->effectiveOpacity();
never executed: return d_ptr->effectiveOpacity();
0
2702}-
2703-
2704/*!-
2705 \since 4.5-
2706-
2707 Sets this item's local \a opacity, between 0.0 (transparent) and 1.0-
2708 (opaque). The item's local opacity is combined with parent and ancestor-
2709 opacities into the effectiveOpacity().-
2710-
2711 By default, opacity propagates from parent to child, so if a parent's-
2712 opacity is 0.5 and the child is also 0.5, the child's effective opacity-
2713 will be 0.25.-
2714-
2715 The opacity property decides the state of the painter passed to the-
2716 paint() function. If the item is cached, i.e., ItemCoordinateCache or-
2717 DeviceCoordinateCache, the effective property will be applied to the-
2718 item's cache as it is rendered.-
2719-
2720 There are two item flags that affect how the item's opacity is combined-
2721 with the parent: ItemIgnoresParentOpacity and-
2722 ItemDoesntPropagateOpacityToChildren.-
2723-
2724 \note Setting the opacity of an item to 0 will not make the item invisible-
2725 (according to isVisible()), but the item will be treated like an invisible-
2726 one. See the documentation of setVisible() for more information.-
2727-
2728 \sa opacity(), effectiveOpacity(), setVisible()-
2729*/-
2730void QGraphicsItem::setOpacity(qreal opacity)-
2731{-
2732 // Notify change.-
2733 const QVariant newOpacityVariant(itemChange(ItemOpacityChange, opacity));-
2734-
2735 // Normalized opacity-
2736 qreal newOpacity = qBound(qreal(0), newOpacityVariant.toReal(), qreal(1));-
2737-
2738 // No change? Done.-
2739 if (newOpacity == d_ptr->opacity)
newOpacity == d_ptr->opacityDescription
TRUEnever evaluated
FALSEnever evaluated
0
2740 return;
never executed: return;
0
2741-
2742 bool wasFullyTransparent = d_ptr->isOpacityNull();-
2743 d_ptr->opacity = newOpacity;-
2744-
2745 // Notify change.-
2746 itemChange(ItemOpacityHasChanged, newOpacityVariant);-
2747-
2748 // Update.-
2749 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
2750#ifndef QT_NO_GRAPHICSEFFECT-
2751 d_ptr->invalidateParentGraphicsEffectsRecursively();-
2752 if (!(d_ptr->flags & ItemDoesntPropagateOpacityToChildren))
!(d_ptr->flags...ityToChildren)Description
TRUEnever evaluated
FALSEnever evaluated
0
2753 d_ptr->invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::OpacityChanged);
never executed: d_ptr->invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::OpacityChanged);
0
2754#endif //QT_NO_GRAPHICSEFFECT-
2755 d_ptr->scene->d_func()->markDirty(this, QRectF(),-
2756 /*invalidateChildren=*/true,-
2757 /*force=*/false,-
2758 /*ignoreOpacity=*/d_ptr->isOpacityNull());-
2759 if (wasFullyTransparent)
wasFullyTransparentDescription
TRUEnever evaluated
FALSEnever evaluated
0
2760 d_ptr->paintedViewBoundingRectsNeedRepaint = 1;
never executed: d_ptr->paintedViewBoundingRectsNeedRepaint = 1;
0
2761 }
never executed: end of block
0
2762-
2763 if (d_ptr->isObject)
d_ptr->isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
2764 emit static_cast<QGraphicsObject *>(this)->opacityChanged();
never executed: static_cast<QGraphicsObject *>(this)->opacityChanged();
0
2765}
never executed: end of block
0
2766-
2767/*!-
2768 Returns a pointer to this item's effect if it has one; otherwise 0.-
2769-
2770 \since 4.6-
2771*/-
2772#ifndef QT_NO_GRAPHICSEFFECT-
2773QGraphicsEffect *QGraphicsItem::graphicsEffect() const-
2774{-
2775 return d_ptr->graphicsEffect;
never executed: return d_ptr->graphicsEffect;
0
2776}-
2777-
2778/*!-
2779 Sets \a effect as the item's effect. If there already is an effect installed-
2780 on this item, QGraphicsItem will delete the existing effect before installing-
2781 the new \a effect. You can delete an existing effect by calling-
2782 setGraphicsEffect(0).-
2783-
2784 If \a effect is the installed effect on a different item, setGraphicsEffect() will remove-
2785 the effect from the item and install it on this item.-
2786-
2787 QGraphicsItem takes ownership of \a effect.-
2788-
2789 \note This function will apply the effect on itself and all its children.-
2790-
2791 \since 4.6-
2792*/-
2793void QGraphicsItem::setGraphicsEffect(QGraphicsEffect *effect)-
2794{-
2795 if (d_ptr->graphicsEffect == effect)
d_ptr->graphic...fect == effectDescription
TRUEnever evaluated
FALSEnever evaluated
0
2796 return;
never executed: return;
0
2797-
2798 if (d_ptr->graphicsEffect) {
d_ptr->graphicsEffectDescription
TRUEnever evaluated
FALSEnever evaluated
0
2799 delete d_ptr->graphicsEffect;-
2800 d_ptr->graphicsEffect = 0;-
2801 } else if (d_ptr->parent) {
never executed: end of block
d_ptr->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
2802 d_ptr->parent->d_ptr->updateChildWithGraphicsEffectFlagRecursively();-
2803 }
never executed: end of block
0
2804-
2805 if (effect) {
effectDescription
TRUEnever evaluated
FALSEnever evaluated
0
2806 // Set new effect.-
2807 QGraphicsEffectSourcePrivate *sourced = new QGraphicsItemEffectSourcePrivate(this);-
2808 QGraphicsEffectSource *source = new QGraphicsEffectSource(*sourced);-
2809 d_ptr->graphicsEffect = effect;-
2810 effect->d_func()->setGraphicsEffectSource(source);-
2811 prepareGeometryChange();-
2812 }
never executed: end of block
0
2813}
never executed: end of block
0
2814#endif //QT_NO_GRAPHICSEFFECT-
2815-
2816void QGraphicsItemPrivate::updateChildWithGraphicsEffectFlagRecursively()-
2817{-
2818#ifndef QT_NO_GRAPHICSEFFECT-
2819 QGraphicsItemPrivate *itemPrivate = this;-
2820 do {-
2821 // parent chain already notified?-
2822 if (itemPrivate->mayHaveChildWithGraphicsEffect)
itemPrivate->m...GraphicsEffectDescription
TRUEnever evaluated
FALSEnever evaluated
0
2823 return;
never executed: return;
0
2824 itemPrivate->mayHaveChildWithGraphicsEffect = 1;-
2825 } 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
2826#endif-
2827}
never executed: end of block
0
2828-
2829/*!-
2830 \internal-
2831 \since 4.6-
2832 Returns the effective bounding rect of the given item space rect.-
2833 If the item has no effect, the rect is returned unmodified.-
2834 If the item has an effect, the effective rect can be extend beyond the-
2835 item's bounding rect, depending on the effect.-
2836-
2837 \sa boundingRect()-
2838*/-
2839QRectF QGraphicsItemPrivate::effectiveBoundingRect(const QRectF &rect) const-
2840{-
2841#ifndef QT_NO_GRAPHICSEFFECT-
2842 Q_Q(const QGraphicsItem);-
2843 QGraphicsEffect *effect = graphicsEffect;-
2844 if (scene && effect && effect->isEnabled()) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
effectDescription
TRUEnever evaluated
FALSEnever evaluated
effect->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
2845 if (scene->d_func()->views.isEmpty())
scene->d_func(...iews.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
2846 return effect->boundingRectFor(rect);
never executed: return effect->boundingRectFor(rect);
0
2847 QRectF sceneRect = q->mapRectToScene(rect);-
2848 QRectF sceneEffectRect;-
2849 foreach (QGraphicsView *view, scene->views()) {-
2850 QRectF deviceRect = view->d_func()->mapRectFromScene(sceneRect);-
2851 QRect deviceEffectRect = effect->boundingRectFor(deviceRect).toAlignedRect();-
2852 sceneEffectRect |= view->d_func()->mapRectToScene(deviceEffectRect);-
2853 }
never executed: end of block
0
2854 return q->mapRectFromScene(sceneEffectRect);
never executed: return q->mapRectFromScene(sceneEffectRect);
0
2855 }-
2856#endif //QT_NO_GRAPHICSEFFECT-
2857 return rect;
never executed: return rect;
0
2858}-
2859-
2860/*!-
2861 \internal-
2862 \since 4.6-
2863 Returns the effective bounding rect of the item.-
2864 If the item has no effect, this is the same as the item's bounding rect.-
2865 If the item has an effect, the effective rect can be larger than the item's-
2866 bouding rect, depending on the effect.-
2867-
2868 \sa boundingRect()-
2869*/-
2870QRectF QGraphicsItemPrivate::effectiveBoundingRect(QGraphicsItem *topMostEffectItem) const-
2871{-
2872#ifndef QT_NO_GRAPHICSEFFECT-
2873 Q_Q(const QGraphicsItem);-
2874 QRectF brect = effectiveBoundingRect(q_ptr->boundingRect());-
2875 if (ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren
ancestorFlags ...rClipsChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
2876 || ancestorFlags & QGraphicsItemPrivate::AncestorContainsChildren
ancestorFlags ...ntainsChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
2877 || topMostEffectItem == q)
topMostEffectItem == qDescription
TRUEnever evaluated
FALSEnever evaluated
0
2878 return brect;
never executed: return brect;
0
2879-
2880 const QGraphicsItem *effectParent = parent;-
2881 while (effectParent) {
effectParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
2882 QGraphicsEffect *effect = effectParent->d_ptr->graphicsEffect;-
2883 if (scene && effect && effect->isEnabled()) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
effectDescription
TRUEnever evaluated
FALSEnever evaluated
effect->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
0
2884 const QRectF brectInParentSpace = q->mapRectToItem(effectParent, brect);-
2885 const QRectF effectRectInParentSpace = effectParent->d_ptr->effectiveBoundingRect(brectInParentSpace);-
2886 brect = effectParent->mapRectToItem(q, effectRectInParentSpace);-
2887 }
never executed: end of block
0
2888 if (effectParent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren
effectParent->...rClipsChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
2889 || effectParent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorContainsChildren
effectParent->...ntainsChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
2890 || topMostEffectItem == effectParent) {
topMostEffectI...= effectParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
2891 return brect;
never executed: return brect;
0
2892 }-
2893 effectParent = effectParent->d_ptr->parent;-
2894 }
never executed: end of block
0
2895-
2896 return brect;
never executed: return brect;
0
2897#else //QT_NO_GRAPHICSEFFECT-
2898 return q_ptr->boundingRect();-
2899#endif //QT_NO_GRAPHICSEFFECT-
2900-
2901}-
2902-
2903/*!-
2904 \internal-
2905 \since 4.6-
2906 Returns the effective bounding rect of this item in scene coordinates,-
2907 by combining sceneTransform() with boundingRect(), taking into account-
2908 the effect that the item might have.-
2909-
2910 If the item has no effect, this is the same as sceneBoundingRect().-
2911-
2912 \sa effectiveBoundingRect(), sceneBoundingRect()-
2913*/-
2914QRectF QGraphicsItemPrivate::sceneEffectiveBoundingRect() const-
2915{-
2916 // Find translate-only offset-
2917 // COMBINE-
2918 QPointF offset;-
2919 const QGraphicsItem *parentItem = q_ptr;-
2920 const QGraphicsItemPrivate *itemd;-
2921 do {-
2922 itemd = parentItem->d_ptr.data();-
2923 if (itemd->transformData)
itemd->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
2924 break;
never executed: break;
0
2925 offset += itemd->pos;-
2926 } while ((parentItem = itemd->parent));
never executed: end of block
(parentItem = itemd->parent)Description
TRUEnever evaluated
FALSEnever evaluated
0
2927-
2928 QRectF br = effectiveBoundingRect();-
2929 br.translate(offset);-
2930 return !parentItem ? br : parentItem->sceneTransform().mapRect(br);
never executed: return !parentItem ? br : parentItem->sceneTransform().mapRect(br);
!parentItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
2931}-
2932-
2933/*!-
2934 Returns \c true if this item can accept drag and drop events; otherwise,-
2935 returns \c false. By default, items do not accept drag and drop events; items-
2936 are transparent to drag and drop.-
2937-
2938 \sa setAcceptDrops()-
2939*/-
2940bool QGraphicsItem::acceptDrops() const-
2941{-
2942 return d_ptr->acceptDrops;
never executed: return d_ptr->acceptDrops;
0
2943}-
2944-
2945/*!-
2946 If \a on is true, this item will accept drag and drop events; otherwise,-
2947 it is transparent for drag and drop events. By default, items do not-
2948 accept drag and drop events.-
2949-
2950 \sa acceptDrops()-
2951*/-
2952void QGraphicsItem::setAcceptDrops(bool on)-
2953{-
2954 d_ptr->acceptDrops = on;-
2955}
never executed: end of block
0
2956-
2957/*!-
2958 Returns the mouse buttons that this item accepts mouse events for. By-
2959 default, all mouse buttons are accepted.-
2960-
2961 If an item accepts a mouse button, it will become the mouse-
2962 grabber item when a mouse press event is delivered for that mouse-
2963 button. However, if the item does not accept the button,-
2964 QGraphicsScene will forward the mouse events to the first item-
2965 beneath it that does.-
2966-
2967 \sa setAcceptedMouseButtons(), mousePressEvent()-
2968*/-
2969Qt::MouseButtons QGraphicsItem::acceptedMouseButtons() const-
2970{-
2971 return Qt::MouseButtons(d_ptr->acceptedMouseButtons);
never executed: return Qt::MouseButtons(d_ptr->acceptedMouseButtons);
0
2972}-
2973-
2974/*!-
2975 Sets the mouse \a buttons that this item accepts mouse events for.-
2976-
2977 By default, all mouse buttons are accepted. If an item accepts a-
2978 mouse button, it will become the mouse grabber item when a mouse-
2979 press event is delivered for that button. However, if the item-
2980 does not accept the mouse button, QGraphicsScene will forward the-
2981 mouse events to the first item beneath it that does.-
2982-
2983 To disable mouse events for an item (i.e., make it transparent for mouse-
2984 events), call setAcceptedMouseButtons(0).-
2985-
2986 \sa acceptedMouseButtons(), mousePressEvent()-
2987*/-
2988void QGraphicsItem::setAcceptedMouseButtons(Qt::MouseButtons buttons)-
2989{-
2990 if (Qt::MouseButtons(d_ptr->acceptedMouseButtons) != buttons) {
Qt::MouseButto...ns) != buttonsDescription
TRUEnever evaluated
FALSEnever evaluated
0
2991 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
2992 && d_ptr->scene->d_func()->lastMouseGrabberItemHasImplicitMouseGrab) {
d_ptr->scene->...licitMouseGrabDescription
TRUEnever evaluated
FALSEnever evaluated
0
2993 ungrabMouse();-
2994 }
never executed: end of block
0
2995 d_ptr->acceptedMouseButtons = quint32(buttons);-
2996 }
never executed: end of block
0
2997}
never executed: end of block
0
2998-
2999/*!-
3000 \since 4.4-
3001-
3002 Returns \c true if an item accepts hover events-
3003 (QGraphicsSceneHoverEvent); otherwise, returns \c false. By default,-
3004 items do not accept hover events.-
3005-
3006 \sa setAcceptedMouseButtons()-
3007*/-
3008bool QGraphicsItem::acceptHoverEvents() const-
3009{-
3010 return d_ptr->acceptsHover;
never executed: return d_ptr->acceptsHover;
0
3011}-
3012-
3013/*!-
3014 \fn bool QGraphicsItem::acceptsHoverEvents() const-
3015 \obsolete-
3016-
3017 Call acceptHoverEvents() instead.-
3018*/-
3019-
3020/*!-
3021 \since 4.4-
3022-
3023 If \a enabled is true, this item will accept hover events;-
3024 otherwise, it will ignore them. By default, items do not accept-
3025 hover events.-
3026-
3027 Hover events are delivered when there is no current mouse grabber-
3028 item. They are sent when the mouse cursor enters an item, when it-
3029 moves around inside the item, and when the cursor leaves an-
3030 item. Hover events are commonly used to highlight an item when-
3031 it's entered, and for tracking the mouse cursor as it hovers over-
3032 the item (equivalent to QWidget::mouseTracking).-
3033-
3034 Parent items receive hover enter events before their children, and-
3035 leave events after their children. The parent does not receive a-
3036 hover leave event if the cursor enters a child, though; the parent-
3037 stays "hovered" until the cursor leaves its area, including its-
3038 children's areas.-
3039-
3040 If a parent item handles child events, it will receive hover move,-
3041 drag move, and drop events as the cursor passes through its-
3042 children, but it does not receive hover enter and hover leave, nor-
3043 drag enter and drag leave events on behalf of its children.-
3044-
3045 A QGraphicsWidget with window decorations will accept hover events-
3046 regardless of the value of acceptHoverEvents().-
3047-
3048 \sa acceptHoverEvents(), hoverEnterEvent(), hoverMoveEvent(),-
3049 hoverLeaveEvent()-
3050*/-
3051void QGraphicsItem::setAcceptHoverEvents(bool enabled)-
3052{-
3053 if (d_ptr->acceptsHover == quint32(enabled))
d_ptr->accepts...int32(enabled)Description
TRUEnever evaluated
FALSEnever evaluated
0
3054 return;
never executed: return;
0
3055 d_ptr->acceptsHover = quint32(enabled);-
3056 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
3057 d_ptr->scene->d_func()->allItemsIgnoreHoverEvents = false;-
3058 d_ptr->scene->d_func()->enableMouseTrackingOnViews();-
3059 }
never executed: end of block
0
3060}
never executed: end of block
0
3061-
3062/*!-
3063 \fn void QGraphicsItem::setAcceptsHoverEvents(bool enabled)-
3064 \obsolete-
3065-
3066 Use setAcceptHoverEvents(\a enabled) instead.-
3067*/-
3068-
3069/*! \since 4.6-
3070-
3071 Returns \c true if an item accepts \l{QTouchEvent}{touch events};-
3072 otherwise, returns \c false. By default, items do not accept touch events.-
3073-
3074 \sa setAcceptTouchEvents()-
3075*/-
3076bool QGraphicsItem::acceptTouchEvents() const-
3077{-
3078 return d_ptr->acceptTouchEvents;
never executed: return d_ptr->acceptTouchEvents;
0
3079}-
3080-
3081/*!-
3082 \since 4.6-
3083-
3084 If \a enabled is true, this item will accept \l{QTouchEvent}{touch events};-
3085 otherwise, it will ignore them. By default, items do not accept-
3086 touch events.-
3087*/-
3088void QGraphicsItem::setAcceptTouchEvents(bool enabled)-
3089{-
3090 if (d_ptr->acceptTouchEvents == quint32(enabled))
d_ptr->acceptT...int32(enabled)Description
TRUEnever evaluated
FALSEnever evaluated
0
3091 return;
never executed: return;
0
3092 d_ptr->acceptTouchEvents = quint32(enabled);-
3093 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
3094 d_ptr->scene->d_func()->allItemsIgnoreTouchEvents = false;-
3095 d_ptr->scene->d_func()->enableTouchEventsOnViews();-
3096 }
never executed: end of block
0
3097}
never executed: end of block
0
3098-
3099/*!-
3100 \since 4.6-
3101-
3102 Returns \c true if this item filters child events (i.e., all events-
3103 intended for any of its children are instead sent to this item);-
3104 otherwise, false is returned.-
3105-
3106 The default value is false; child events are not filtered.-
3107-
3108 \sa setFiltersChildEvents()-
3109*/-
3110bool QGraphicsItem::filtersChildEvents() const-
3111{-
3112 return d_ptr->filtersDescendantEvents;
never executed: return d_ptr->filtersDescendantEvents;
0
3113}-
3114-
3115/*!-
3116 \since 4.6-
3117-
3118 If \a enabled is true, this item is set to filter all events for-
3119 all its children (i.e., all events intented for any of its-
3120 children are instead sent to this item); otherwise, if \a enabled-
3121 is false, this item will only handle its own events. The default-
3122 value is false.-
3123-
3124 \sa filtersChildEvents()-
3125*/-
3126void QGraphicsItem::setFiltersChildEvents(bool enabled)-
3127{-
3128 if (d_ptr->filtersDescendantEvents == enabled)
d_ptr->filters...nts == enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
3129 return;
never executed: return;
0
3130-
3131 d_ptr->filtersDescendantEvents = enabled;-
3132 d_ptr->updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-2));-
3133}
never executed: end of block
0
3134-
3135/*!-
3136 \obsolete-
3137-
3138 Returns \c true if this item handles child events (i.e., all events-
3139 intended for any of its children are instead sent to this item);-
3140 otherwise, false is returned.-
3141-
3142 This property is useful for item groups; it allows one item to-
3143 handle events on behalf of its children, as opposed to its-
3144 children handling their events individually.-
3145-
3146 The default is to return false; children handle their own events.-
3147 The exception for this is if the item is a QGraphicsItemGroup, then-
3148 it defaults to return true.-
3149-
3150 \sa setHandlesChildEvents()-
3151*/-
3152bool QGraphicsItem::handlesChildEvents() const-
3153{-
3154 return d_ptr->handlesChildEvents;
never executed: return d_ptr->handlesChildEvents;
0
3155}-
3156-
3157/*!-
3158 \obsolete-
3159-
3160 If \a enabled is true, this item is set to handle all events for-
3161 all its children (i.e., all events intented for any of its-
3162 children are instead sent to this item); otherwise, if \a enabled-
3163 is false, this item will only handle its own events. The default-
3164 value is false.-
3165-
3166 This property is useful for item groups; it allows one item to-
3167 handle events on behalf of its children, as opposed to its-
3168 children handling their events individually.-
3169-
3170 If a child item accepts hover events, its parent will receive-
3171 hover move events as the cursor passes through the child, but it-
3172 does not receive hover enter and hover leave events on behalf of-
3173 its child.-
3174-
3175 \sa handlesChildEvents()-
3176*/-
3177void QGraphicsItem::setHandlesChildEvents(bool enabled)-
3178{-
3179 if (d_ptr->handlesChildEvents == enabled)
d_ptr->handles...nts == enabledDescription
TRUEnever evaluated
FALSEnever evaluated
0
3180 return;
never executed: return;
0
3181-
3182 d_ptr->handlesChildEvents = enabled;-
3183 d_ptr->updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-1));-
3184}
never executed: end of block
0
3185/*!-
3186 \since 4.6-
3187 Returns \c true if this item is active; otherwise returns \c false.-
3188-
3189 An item can only be active if the scene is active. An item is active-
3190 if it is, or is a descendent of, an active panel. Items in non-active-
3191 panels are not active.-
3192-
3193 Items that are not part of a panel follow scene activation when the-
3194 scene has no active panel.-
3195-
3196 Only active items can gain input focus.-
3197-
3198 \sa QGraphicsScene::isActive(), QGraphicsScene::activePanel(), panel(), isPanel()-
3199*/-
3200bool QGraphicsItem::isActive() const-
3201{-
3202 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
3203 return false;
never executed: return false;
0
3204 return panel() == d_ptr->scene->activePanel();
never executed: return panel() == d_ptr->scene->activePanel();
0
3205}-
3206-
3207/*!-
3208 \since 4.6-
3209-
3210 If \a active is true, and the scene is active, this item's panel will be-
3211 activated. Otherwise, the panel is deactivated.-
3212-
3213 If the item is not part of an active scene, \a active will decide what-
3214 happens to the panel when the scene becomes active or the item is added to-
3215 the scene. If true, the item's panel will be activated when the item is-
3216 either added to the scene or the scene is activated. Otherwise, the item-
3217 will stay inactive independent of the scene's activated state.-
3218-
3219 \sa isPanel(), QGraphicsScene::setActivePanel(), QGraphicsScene::isActive()-
3220*/-
3221void QGraphicsItem::setActive(bool active)-
3222{-
3223 d_ptr->explicitActivate = 1;-
3224 d_ptr->wantsActive = active;-
3225 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
3226 if (active) {
activeDescription
TRUEnever evaluated
FALSEnever evaluated
0
3227 // Activate this item.-
3228 d_ptr->scene->setActivePanel(this);-
3229 } else {
never executed: end of block
0
3230 QGraphicsItem *activePanel = d_ptr->scene->activePanel();-
3231 QGraphicsItem *thisPanel = panel();-
3232 if (!activePanel || activePanel == thisPanel) {
!activePanelDescription
TRUEnever evaluated
FALSEnever evaluated
activePanel == thisPanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
3233 // Deactivate this item, and reactivate the parent panel,-
3234 // or the last active panel (if any).-
3235 QGraphicsItem *nextToActivate = 0;-
3236 if (d_ptr->parent)
d_ptr->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
3237 nextToActivate = d_ptr->parent->panel();
never executed: nextToActivate = d_ptr->parent->panel();
0
3238 if (!nextToActivate)
!nextToActivateDescription
TRUEnever evaluated
FALSEnever evaluated
0
3239 nextToActivate = d_ptr->scene->d_func()->lastActivePanel;
never executed: nextToActivate = d_ptr->scene->d_func()->lastActivePanel;
0
3240 if (nextToActivate == this || isAncestorOf(nextToActivate))
nextToActivate == thisDescription
TRUEnever evaluated
FALSEnever evaluated
isAncestorOf(nextToActivate)Description
TRUEnever evaluated
FALSEnever evaluated
0
3241 nextToActivate = 0;
never executed: nextToActivate = 0;
0
3242 d_ptr->scene->setActivePanel(nextToActivate);-
3243 }
never executed: end of block
0
3244 }
never executed: end of block
0
3245 }-
3246}
never executed: end of block
0
3247-
3248/*!-
3249 Returns \c true if this item is active, and it or its \l{focusProxy()}{focus-
3250 proxy} has keyboard input focus; otherwise, returns \c false.-
3251-
3252 \sa focusItem(), setFocus(), QGraphicsScene::setFocusItem(), isActive()-
3253*/-
3254bool QGraphicsItem::hasFocus() const-
3255{-
3256 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
3257 return false;
never executed: return false;
0
3258-
3259 if (d_ptr->focusProxy)
d_ptr->focusProxyDescription
TRUEnever evaluated
FALSEnever evaluated
0
3260 return d_ptr->focusProxy->hasFocus();
never executed: return d_ptr->focusProxy->hasFocus();
0
3261-
3262 if (d_ptr->scene->d_func()->focusItem != this)
d_ptr->scene->...usItem != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
3263 return false;
never executed: return false;
0
3264-
3265 return panel() == d_ptr->scene->d_func()->activePanel;
never executed: return panel() == d_ptr->scene->d_func()->activePanel;
0
3266}-
3267-
3268/*!-
3269 Gives keyboard input focus to this item. The \a focusReason argument will-
3270 be passed into any \l{QFocusEvent}{focus event} generated by this function;-
3271 it is used to give an explanation of what caused the item to get focus.-
3272-
3273 Only enabled items that set the ItemIsFocusable flag can accept keyboard-
3274 focus.-
3275-
3276 If this item is not visible, not active, or not associated with a scene,-
3277 it will not gain immediate input focus. However, it will be registered as-
3278 the preferred focus item for its subtree of items, should it later become-
3279 visible.-
3280-
3281 As a result of calling this function, this item will receive a-
3282 \l{focusInEvent()}{focus in event} with \a focusReason. If another item-
3283 already has focus, that item will first receive a \l{focusOutEvent()}-
3284 {focus out event} indicating that it has lost input focus.-
3285-
3286 \sa clearFocus(), hasFocus(), focusItem(), focusProxy()-
3287*/-
3288void QGraphicsItem::setFocus(Qt::FocusReason focusReason)-
3289{-
3290 d_ptr->setFocusHelper(focusReason, /* climb = */ true, /* focusFromHide = */ false);-
3291}
never executed: end of block
0
3292-
3293/*!-
3294 \internal-
3295*/-
3296void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromHide)-
3297{-
3298 // Disabled / unfocusable items cannot accept focus.-
3299 if (!q_ptr->isEnabled() || !(flags & QGraphicsItem::ItemIsFocusable))
!q_ptr->isEnabled()Description
TRUEnever evaluated
FALSEnever evaluated
!(flags & QGra...emIsFocusable)Description
TRUEnever evaluated
FALSEnever evaluated
0
3300 return;
never executed: return;
0
3301-
3302 // Find focus proxy.-
3303 QGraphicsItem *f = q_ptr;-
3304 while (f->d_ptr->focusProxy)
f->d_ptr->focusProxyDescription
TRUEnever evaluated
FALSEnever evaluated
0
3305 f = f->d_ptr->focusProxy;
never executed: f = f->d_ptr->focusProxy;
0
3306-
3307 // Return if it already has focus.-
3308 if (scene && scene->focusItem() == f)
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
scene->focusItem() == fDescription
TRUEnever evaluated
FALSEnever evaluated
0
3309 return;
never executed: return;
0
3310-
3311 // Update focus scope item ptr.-
3312 QGraphicsItem *p = parent;-
3313 while (p) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
0
3314 if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
p->flags() & Q...emIsFocusScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
3315 QGraphicsItem *oldFocusScopeItem = p->d_ptr->focusScopeItem;-
3316 p->d_ptr->focusScopeItem = q_ptr;-
3317 if (oldFocusScopeItem)
oldFocusScopeItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3318 oldFocusScopeItem->d_ptr->focusScopeItemChange(false);
never executed: oldFocusScopeItem->d_ptr->focusScopeItemChange(false);
0
3319 focusScopeItemChange(true);-
3320 if (!p->focusItem() && !focusFromHide) {
!p->focusItem()Description
TRUEnever evaluated
FALSEnever evaluated
!focusFromHideDescription
TRUEnever evaluated
FALSEnever evaluated
0
3321 // Calling setFocus() on a child of a focus scope that does-
3322 // not have focus changes only the focus scope pointer,-
3323 // so that focus is restored the next time the scope gains-
3324 // focus.-
3325 return;
never executed: return;
0
3326 }-
3327 break;
never executed: break;
0
3328 }-
3329 p = p->d_ptr->parent;-
3330 }
never executed: end of block
0
3331-
3332 if (climb) {
climbDescription
TRUEnever evaluated
FALSEnever evaluated
0
3333 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
3334 f = f->d_ptr->focusScopeItem;
never executed: f = f->d_ptr->focusScopeItem;
0
3335 }
never executed: end of block
0
3336-
3337 // Update the child focus chain.-
3338 QGraphicsItem *commonAncestor = 0;-
3339 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
3340 commonAncestor = scene->focusItem()->commonAncestorItem(f);-
3341 scene->focusItem()->d_ptr->clearSubFocus(scene->focusItem(), commonAncestor);-
3342 }
never executed: end of block
0
3343-
3344 f->d_ptr->setSubFocus(f, commonAncestor);-
3345-
3346 // Update the scene's focus item.-
3347 if (scene) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
3348 QGraphicsItem *p = q_ptr->panel();-
3349 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
3350 // Visible items immediately gain focus from scene.-
3351 scene->d_func()->setFocusItemHelper(f, focusReason);-
3352 }
never executed: end of block
0
3353 }
never executed: end of block
0
3354}
never executed: end of block
0
3355-
3356/*!-
3357 Takes keyboard input focus from the item.-
3358-
3359 If it has focus, a \l{focusOutEvent()}{focus out event} is sent to this-
3360 item to tell it that it is about to lose the focus.-
3361-
3362 Only items that set the ItemIsFocusable flag, or widgets that set an-
3363 appropriate focus policy, can accept keyboard focus.-
3364-
3365 \sa setFocus(), hasFocus(), QGraphicsWidget::focusPolicy-
3366*/-
3367void QGraphicsItem::clearFocus()-
3368{-
3369 d_ptr->clearFocusHelper(/* giveFocusToParent = */ true,-
3370 /* hiddenByParentPanel = */ false);-
3371}
never executed: end of block
0
3372-
3373/*!-
3374 \internal-
3375*/-
3376void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent, bool hiddenByParentPanel)-
3377{-
3378 QGraphicsItem *subFocusItem = q_ptr;-
3379 if (flags & QGraphicsItem::ItemIsFocusScope) {
flags & QGraph...emIsFocusScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
3380 while (subFocusItem->d_ptr->focusScopeItem)
subFocusItem->...focusScopeItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3381 subFocusItem = subFocusItem->d_ptr->focusScopeItem;
never executed: subFocusItem = subFocusItem->d_ptr->focusScopeItem;
0
3382 }
never executed: end of block
0
3383-
3384 if (giveFocusToParent) {
giveFocusToParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
3385 // Pass focus to the closest parent focus scope-
3386 if (!inDestructor) {
!inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
0
3387 QGraphicsItem *p = parent;-
3388 while (p) {
pDescription
TRUEnever evaluated
FALSEnever evaluated
0
3389 if (p->flags() & QGraphicsItem::ItemIsFocusScope) {
p->flags() & Q...emIsFocusScopeDescription
TRUEnever evaluated
FALSEnever evaluated
0
3390 if (p->d_ptr->focusScopeItem == q_ptr) {
p->d_ptr->focu...eItem == q_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
3391 p->d_ptr->focusScopeItem = 0;-
3392 if (!subFocusItem->hasFocus()) //if it has focus, focusScopeItemChange is called elsewhere
!subFocusItem->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
3393 focusScopeItemChange(false);
never executed: focusScopeItemChange(false);
0
3394 }
never executed: end of block
0
3395 if (subFocusItem->hasFocus())
subFocusItem->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
3396 p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ false,
never executed: p->d_ptr->setFocusHelper(Qt::OtherFocusReason, false, false);
0
3397 /* focusFromHide = */ false);
never executed: p->d_ptr->setFocusHelper(Qt::OtherFocusReason, false, false);
0
3398 return;
never executed: return;
0
3399 }-
3400 p = p->d_ptr->parent;-
3401 }
never executed: end of block
0
3402 }
never executed: end of block
0
3403 }
never executed: end of block
0
3404-
3405 if (subFocusItem->hasFocus()) {
subFocusItem->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
3406 // Invisible items with focus must explicitly clear subfocus.-
3407 if (!hiddenByParentPanel)
!hiddenByParentPanelDescription
TRUEnever evaluated
FALSEnever evaluated
0
3408 clearSubFocus(q_ptr);
never executed: clearSubFocus(q_ptr);
0
3409-
3410 // If this item has the scene's input focus, clear it.-
3411 scene->setFocusItem(0);-
3412 }
never executed: end of block
0
3413}
never executed: end of block
0
3414-
3415/*!-
3416 \since 4.6-
3417-
3418 Returns this item's focus proxy, or 0 if this item has no-
3419 focus proxy.-
3420-
3421 \sa setFocusProxy(), setFocus(), hasFocus()-
3422*/-
3423QGraphicsItem *QGraphicsItem::focusProxy() const-
3424{-
3425 return d_ptr->focusProxy;
never executed: return d_ptr->focusProxy;
0
3426}-
3427-
3428/*!-
3429 \since 4.6-
3430-
3431 Sets the item's focus proxy to \a item.-
3432-
3433 If an item has a focus proxy, the focus proxy will receive-
3434 input focus when the item gains input focus. The item itself-
3435 will still have focus (i.e., hasFocus() will return true),-
3436 but only the focus proxy will receive the keyboard input.-
3437-
3438 A focus proxy can itself have a focus proxy, and so on. In-
3439 such case, keyboard input will be handled by the outermost-
3440 focus proxy.-
3441-
3442 The focus proxy \a item must belong to the same scene as-
3443 this item.-
3444-
3445 \sa focusProxy(), setFocus(), hasFocus()-
3446*/-
3447void QGraphicsItem::setFocusProxy(QGraphicsItem *item)-
3448{-
3449 if (item == d_ptr->focusProxy)
item == d_ptr->focusProxyDescription
TRUEnever evaluated
FALSEnever evaluated
0
3450 return;
never executed: return;
0
3451 if (item == this) {
item == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
3452 qWarning("QGraphicsItem::setFocusProxy: cannot assign self as focus proxy");-
3453 return;
never executed: return;
0
3454 }-
3455 if (item) {
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3456 if (item->d_ptr->scene != d_ptr->scene) {
item->d_ptr->s...= d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
3457 qWarning("QGraphicsItem::setFocusProxy: focus proxy must be in same scene");-
3458 return;
never executed: return;
0
3459 }-
3460 for (QGraphicsItem *f = item->focusProxy(); f != 0; f = f->focusProxy()) {
f != 0Description
TRUEnever evaluated
FALSEnever evaluated
0
3461 if (f == this) {
f == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
3462 qWarning("QGraphicsItem::setFocusProxy: %p is already in the focus proxy chain", item);-
3463 return;
never executed: return;
0
3464 }-
3465 }
never executed: end of block
0
3466 }
never executed: end of block
0
3467-
3468 QGraphicsItem *lastFocusProxy = d_ptr->focusProxy;-
3469 if (lastFocusProxy)
lastFocusProxyDescription
TRUEnever evaluated
FALSEnever evaluated
0
3470 lastFocusProxy->d_ptr->focusProxyRefs.removeOne(&d_ptr->focusProxy);
never executed: lastFocusProxy->d_ptr->focusProxyRefs.removeOne(&d_ptr->focusProxy);
0
3471 d_ptr->focusProxy = item;-
3472 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
3473 item->d_ptr->focusProxyRefs << &d_ptr->focusProxy;
never executed: item->d_ptr->focusProxyRefs << &d_ptr->focusProxy;
0
3474}
never executed: end of block
0
3475-
3476/*!-
3477 \since 4.6-
3478-
3479 If this item, a child or descendant of this item currently has input-
3480 focus, this function will return a pointer to that item. If-
3481 no descendant has input focus, 0 is returned.-
3482-
3483 \sa hasFocus(), setFocus(), QWidget::focusWidget()-
3484*/-
3485QGraphicsItem *QGraphicsItem::focusItem() const-
3486{-
3487 return d_ptr->subFocusItem;
never executed: return d_ptr->subFocusItem;
0
3488}-
3489-
3490/*!-
3491 \internal-
3492-
3493 Returns this item's focus scope item.-
3494*/-
3495QGraphicsItem *QGraphicsItem::focusScopeItem() const-
3496{-
3497 return d_ptr->focusScopeItem;
never executed: return d_ptr->focusScopeItem;
0
3498}-
3499-
3500/*!-
3501 \since 4.4-
3502 Grabs the mouse input.-
3503-
3504 This item will receive all mouse events for the scene until any of the-
3505 following events occurs:-
3506-
3507 \list-
3508 \li The item becomes invisible-
3509 \li The item is removed from the scene-
3510 \li The item is deleted-
3511 \li The item call ungrabMouse()-
3512 \li Another item calls grabMouse(); the item will regain the mouse grab-
3513 when the other item calls ungrabMouse().-
3514 \endlist-
3515-
3516 When an item gains the mouse grab, it receives a QEvent::GrabMouse-
3517 event. When it loses the mouse grab, it receives a QEvent::UngrabMouse-
3518 event. These events can be used to detect when your item gains or loses-
3519 the mouse grab through other means than receiving mouse button events.-
3520-
3521 It is almost never necessary to explicitly grab the mouse in Qt, as Qt-
3522 grabs and releases it sensibly. In particular, Qt grabs the mouse when you-
3523 press a mouse button, and keeps the mouse grabbed until you release the-
3524 last mouse button. Also, Qt::Popup widgets implicitly call grabMouse()-
3525 when shown, and ungrabMouse() when hidden.-
3526-
3527 Note that only visible items can grab mouse input. Calling grabMouse() on-
3528 an invisible item has no effect.-
3529-
3530 Keyboard events are not affected.-
3531-
3532 \sa QGraphicsScene::mouseGrabberItem(), ungrabMouse(), grabKeyboard()-
3533*/-
3534void QGraphicsItem::grabMouse()-
3535{-
3536 if (!d_ptr->scene) {
!d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
3537 qWarning("QGraphicsItem::grabMouse: cannot grab mouse without scene");-
3538 return;
never executed: return;
0
3539 }-
3540 if (!d_ptr->visible) {
!d_ptr->visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
3541 qWarning("QGraphicsItem::grabMouse: cannot grab mouse while invisible");-
3542 return;
never executed: return;
0
3543 }-
3544 d_ptr->scene->d_func()->grabMouse(this);-
3545}
never executed: end of block
0
3546-
3547/*!-
3548 \since 4.4-
3549 Releases the mouse grab.-
3550-
3551 \sa grabMouse(), ungrabKeyboard()-
3552*/-
3553void QGraphicsItem::ungrabMouse()-
3554{-
3555 if (!d_ptr->scene) {
!d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
3556 qWarning("QGraphicsItem::ungrabMouse: cannot ungrab mouse without scene");-
3557 return;
never executed: return;
0
3558 }-
3559 d_ptr->scene->d_func()->ungrabMouse(this);-
3560}
never executed: end of block
0
3561-
3562/*!-
3563 \since 4.4-
3564 Grabs the keyboard input.-
3565-
3566 The item will receive all keyboard input to the scene until one of the-
3567 following events occur:-
3568-
3569 \list-
3570 \li The item becomes invisible-
3571 \li The item is removed from the scene-
3572 \li The item is deleted-
3573 \li The item calls ungrabKeyboard()-
3574 \li Another item calls grabKeyboard(); the item will regain the keyboard grab-
3575 when the other item calls ungrabKeyboard().-
3576 \endlist-
3577-
3578 When an item gains the keyboard grab, it receives a QEvent::GrabKeyboard-
3579 event. When it loses the keyboard grab, it receives a-
3580 QEvent::UngrabKeyboard event. These events can be used to detect when your-
3581 item gains or loses the keyboard grab through other means than gaining-
3582 input focus.-
3583-
3584 It is almost never necessary to explicitly grab the keyboard in Qt, as Qt-
3585 grabs and releases it sensibly. In particular, Qt grabs the keyboard when-
3586 your item gains input focus, and releases it when your item loses input-
3587 focus, or when the item is hidden.-
3588-
3589 Note that only visible items can grab keyboard input. Calling-
3590 grabKeyboard() on an invisible item has no effect.-
3591-
3592 Keyboard events are not affected.-
3593-
3594 \sa ungrabKeyboard(), grabMouse(), setFocus()-
3595*/-
3596void QGraphicsItem::grabKeyboard()-
3597{-
3598 if (!d_ptr->scene) {
!d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
3599 qWarning("QGraphicsItem::grabKeyboard: cannot grab keyboard without scene");-
3600 return;
never executed: return;
0
3601 }-
3602 if (!d_ptr->visible) {
!d_ptr->visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
3603 qWarning("QGraphicsItem::grabKeyboard: cannot grab keyboard while invisible");-
3604 return;
never executed: return;
0
3605 }-
3606 d_ptr->scene->d_func()->grabKeyboard(this);-
3607}
never executed: end of block
0
3608-
3609/*!-
3610 \since 4.4-
3611 Releases the keyboard grab.-
3612-
3613 \sa grabKeyboard(), ungrabMouse()-
3614*/-
3615void QGraphicsItem::ungrabKeyboard()-
3616{-
3617 if (!d_ptr->scene) {
!d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
3618 qWarning("QGraphicsItem::ungrabKeyboard: cannot ungrab keyboard without scene");-
3619 return;
never executed: return;
0
3620 }-
3621 d_ptr->scene->d_func()->ungrabKeyboard(this);-
3622}
never executed: end of block
0
3623-
3624/*!-
3625 Returns the position of the item in parent coordinates. If the item has no-
3626 parent, its position is given in scene coordinates.-
3627-
3628 The position of the item describes its origin (local coordinate-
3629 (0, 0)) in parent coordinates; this function returns the same as-
3630 mapToParent(0, 0).-
3631-
3632 For convenience, you can also call scenePos() to determine the-
3633 item's position in scene coordinates, regardless of its parent.-
3634-
3635 \sa x(), y(), setPos(), transform(), {The Graphics View Coordinate System}-
3636*/-
3637QPointF QGraphicsItem::pos() const-
3638{-
3639 return d_ptr->pos;
never executed: return d_ptr->pos;
0
3640}-
3641-
3642/*!-
3643 \fn QGraphicsItem::x() const-
3644-
3645 This convenience function is equivalent to calling pos().x().-
3646-
3647 \sa y()-
3648*/-
3649-
3650/*!-
3651 \since 4.6-
3652-
3653 Set's the \a x coordinate of the item's position. Equivalent to-
3654 calling setPos(x, y()).-
3655-
3656 \sa x(), setPos()-
3657*/-
3658void QGraphicsItem::setX(qreal x)-
3659{-
3660 if (d_ptr->inDestructor)
d_ptr->inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
0
3661 return;
never executed: return;
0
3662-
3663 if (qIsNaN(x))
qIsNaN(x)Description
TRUEnever evaluated
FALSEnever evaluated
0
3664 return;
never executed: return;
0
3665-
3666 setPos(QPointF(x, d_ptr->pos.y()));-
3667}
never executed: end of block
0
3668-
3669/*!-
3670 \fn QGraphicsItem::y() const-
3671-
3672 This convenience function is equivalent to calling pos().y().-
3673-
3674 \sa x()-
3675*/-
3676-
3677/*!-
3678 \since 4.6-
3679-
3680 Set's the \a y coordinate of the item's position. Equivalent to-
3681 calling setPos(x(), y).-
3682-
3683 \sa x(), setPos()-
3684*/-
3685void QGraphicsItem::setY(qreal y)-
3686{-
3687 if (d_ptr->inDestructor)
d_ptr->inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
0
3688 return;
never executed: return;
0
3689-
3690 if (qIsNaN(y))
qIsNaN(y)Description
TRUEnever evaluated
FALSEnever evaluated
0
3691 return;
never executed: return;
0
3692-
3693 setPos(QPointF(d_ptr->pos.x(), y));-
3694}
never executed: end of block
0
3695-
3696/*!-
3697 Returns the item's position in scene coordinates. This is-
3698 equivalent to calling \c mapToScene(0, 0).-
3699-
3700 \sa pos(), sceneTransform(), {The Graphics View Coordinate System}-
3701*/-
3702QPointF QGraphicsItem::scenePos() const-
3703{-
3704 return mapToScene(0, 0);
never executed: return mapToScene(0, 0);
0
3705}-
3706-
3707/*!-
3708 \internal-
3709-
3710 Sets the position \a pos.-
3711*/-
3712void QGraphicsItemPrivate::setPosHelper(const QPointF &pos)-
3713{-
3714 Q_Q(QGraphicsItem);-
3715 inSetPosHelper = 1;-
3716 if (scene)
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
3717 q->prepareGeometryChange();
never executed: q->prepareGeometryChange();
0
3718 QPointF oldPos = this->pos;-
3719 this->pos = pos;-
3720 dirtySceneTransform = 1;-
3721 inSetPosHelper = 0;-
3722 if (isObject) {
isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
3723 if (pos.x() != oldPos.x())
pos.x() != oldPos.x()Description
TRUEnever evaluated
FALSEnever evaluated
0
3724 emit static_cast<QGraphicsObject *>(q_ptr)->xChanged();
never executed: static_cast<QGraphicsObject *>(q_ptr)->xChanged();
0
3725 if (pos.y() != oldPos.y())
pos.y() != oldPos.y()Description
TRUEnever evaluated
FALSEnever evaluated
0
3726 emit static_cast<QGraphicsObject *>(q_ptr)->yChanged();
never executed: static_cast<QGraphicsObject *>(q_ptr)->yChanged();
0
3727 }
never executed: end of block
0
3728}
never executed: end of block
0
3729-
3730/*!-
3731 \internal-
3732-
3733 Sets the transform \a transform.-
3734*/-
3735void QGraphicsItemPrivate::setTransformHelper(const QTransform &transform)-
3736{-
3737 q_ptr->prepareGeometryChange();-
3738 transformData->transform = transform;-
3739 dirtySceneTransform = 1;-
3740 transformChanged();-
3741}
never executed: end of block
0
3742-
3743/*!-
3744 Sets the position of the item to \a pos, which is in parent-
3745 coordinates. For items with no parent, \a pos is in scene-
3746 coordinates.-
3747-
3748 The position of the item describes its origin (local coordinate-
3749 (0, 0)) in parent coordinates.-
3750-
3751 \sa pos(), scenePos(), {The Graphics View Coordinate System}-
3752*/-
3753void QGraphicsItem::setPos(const QPointF &pos)-
3754{-
3755 if (d_ptr->pos == pos)
d_ptr->pos == posDescription
TRUEnever evaluated
FALSEnever evaluated
0
3756 return;
never executed: return;
0
3757-
3758 if (d_ptr->inDestructor)
d_ptr->inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
0
3759 return;
never executed: return;
0
3760-
3761 // Update and repositition.-
3762 if (!(d_ptr->flags & (ItemSendsGeometryChanges | ItemSendsScenePositionChanges))) {
!(d_ptr->flags...itionChanges))Description
TRUEnever evaluated
FALSEnever evaluated
0
3763 d_ptr->setPosHelper(pos);-
3764 if (d_ptr->isWidget)
d_ptr->isWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
3765 static_cast<QGraphicsWidget *>(this)->d_func()->setGeometryFromSetPos();
never executed: static_cast<QGraphicsWidget *>(this)->d_func()->setGeometryFromSetPos();
0
3766 if (d_ptr->scenePosDescendants)
d_ptr->scenePosDescendantsDescription
TRUEnever evaluated
FALSEnever evaluated
0
3767 d_ptr->sendScenePosChange();
never executed: d_ptr->sendScenePosChange();
0
3768 return;
never executed: return;
0
3769 }-
3770-
3771 // Notify the item that the position is changing.-
3772 const QVariant newPosVariant(itemChange(ItemPositionChange, QVariant::fromValue<QPointF>(pos)));-
3773 QPointF newPos = newPosVariant.toPointF();-
3774 if (newPos == d_ptr->pos)
newPos == d_ptr->posDescription
TRUEnever evaluated
FALSEnever evaluated
0
3775 return;
never executed: return;
0
3776-
3777 // Update and repositition.-
3778 d_ptr->setPosHelper(newPos);-
3779-
3780 // Send post-notification.-
3781 itemChange(QGraphicsItem::ItemPositionHasChanged, newPosVariant);-
3782 d_ptr->sendScenePosChange();-
3783}
never executed: end of block
0
3784-
3785/*!-
3786 \fn void QGraphicsItem::setPos(qreal x, qreal y)-
3787 \overload-
3788-
3789 This convenience function is equivalent to calling setPos(QPointF(\a x, \a-
3790 y)).-
3791*/-
3792-
3793/*!-
3794 \fn void QGraphicsItem::moveBy(qreal dx, qreal dy)-
3795-
3796 Moves the item by \a dx points horizontally, and \a dy point-
3797 vertically. This function is equivalent to calling setPos(pos() +-
3798 QPointF(\a dx, \a dy)).-
3799*/-
3800-
3801/*!-
3802 If this item is part of a scene that is viewed by a QGraphicsView, this-
3803 convenience function will attempt to scroll the view to ensure that \a-
3804 rect is visible inside the view's viewport. If \a rect is a null rect (the-
3805 default), QGraphicsItem will default to the item's bounding rect. \a xmargin-
3806 and \a ymargin are the number of pixels the view should use for margins.-
3807-
3808 If the specified rect cannot be reached, the contents are scrolled to the-
3809 nearest valid position.-
3810-
3811 If this item is not viewed by a QGraphicsView, this function does nothing.-
3812-
3813 \sa QGraphicsView::ensureVisible()-
3814*/-
3815void QGraphicsItem::ensureVisible(const QRectF &rect, int xmargin, int ymargin)-
3816{-
3817 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
3818 QRectF sceneRect;-
3819 if (!rect.isNull())
!rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
3820 sceneRect = sceneTransform().mapRect(rect);
never executed: sceneRect = sceneTransform().mapRect(rect);
0
3821 else-
3822 sceneRect = sceneBoundingRect();
never executed: sceneRect = sceneBoundingRect();
0
3823 foreach (QGraphicsView *view, d_ptr->scene->d_func()->views)-
3824 view->ensureVisible(sceneRect, xmargin, ymargin);
never executed: view->ensureVisible(sceneRect, xmargin, ymargin);
0
3825 }
never executed: end of block
0
3826}
never executed: end of block
0
3827-
3828/*!-
3829 \fn void QGraphicsItem::ensureVisible(qreal x, qreal y, qreal w, qreal h,-
3830 int xmargin = 50, int ymargin = 50)-
3831-
3832 This convenience function is equivalent to calling-
3833 ensureVisible(QRectF(\a x, \a y, \a w, \a h), \a xmargin, \a ymargin).-
3834*/-
3835-
3836/*!-
3837 \obsolete-
3838-
3839 Returns the item's affine transformation matrix. This is a subset or the-
3840 item's full transformation matrix, and might not represent the item's full-
3841 transformation.-
3842-
3843 Use transform() instead.-
3844-
3845 \sa setTransform(), sceneTransform()-
3846*/-
3847QMatrix QGraphicsItem::matrix() const-
3848{-
3849 return transform().toAffine();
never executed: return transform().toAffine();
0
3850}-
3851-
3852/*!-
3853 \since 4.3-
3854-
3855 Returns this item's transformation matrix.-
3856-
3857 The transformation matrix is combined with the item's rotation(), scale()-
3858 and transformations() into a combined transformations for the item.-
3859-
3860 The default transformation matrix is an identity matrix.-
3861-
3862 \sa setTransform(), sceneTransform()-
3863*/-
3864QTransform QGraphicsItem::transform() const-
3865{-
3866 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
3867 return QTransform();
never executed: return QTransform();
0
3868 return d_ptr->transformData->transform;
never executed: return d_ptr->transformData->transform;
0
3869}-
3870-
3871/*!-
3872 \since 4.6-
3873-
3874 Returns the clockwise rotation, in degrees, around the Z axis. The default-
3875 value is 0 (i.e., the item is not rotated).-
3876-
3877 The rotation is combined with the item's scale(), transform() and-
3878 transformations() to map the item's coordinate system to the parent item.-
3879-
3880 \sa setRotation(), transformOriginPoint(), {Transformations}-
3881*/-
3882qreal QGraphicsItem::rotation() const-
3883{-
3884 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
3885 return 0;
never executed: return 0;
0
3886 return d_ptr->transformData->rotation;
never executed: return d_ptr->transformData->rotation;
0
3887}-
3888-
3889/*!-
3890 \since 4.6-
3891-
3892 Sets the clockwise rotation \a angle, in degrees, around the Z axis. The-
3893 default value is 0 (i.e., the item is not rotated). Assigning a negative-
3894 value will rotate the item counter-clockwise. Normally the rotation angle-
3895 is in the range (-360, 360), but it's also possible to assign values-
3896 outside of this range (e.g., a rotation of 370 degrees is the same as a-
3897 rotation of 10 degrees).-
3898-
3899 The item is rotated around its transform origin point, which by default-
3900 is (0, 0). You can select a different transformation origin by calling-
3901 setTransformOriginPoint().-
3902-
3903 The rotation is combined with the item's scale(), transform() and-
3904 transformations() to map the item's coordinate system to the parent item.-
3905-
3906 \sa rotation(), setTransformOriginPoint(), {Transformations}-
3907*/-
3908void QGraphicsItem::setRotation(qreal angle)-
3909{-
3910 prepareGeometryChange();-
3911 qreal newRotation = angle;-
3912-
3913 if (d_ptr->flags & ItemSendsGeometryChanges) {
d_ptr->flags &...eometryChangesDescription
TRUEnever evaluated
FALSEnever evaluated
0
3914 // Notify the item that the rotation is changing.-
3915 const QVariant newRotationVariant(itemChange(ItemRotationChange, angle));-
3916 newRotation = newRotationVariant.toReal();-
3917 }
never executed: end of block
0
3918-
3919 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
3920 d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
0
3921-
3922 if (d_ptr->transformData->rotation == newRotation)
d_ptr->transfo...== newRotationDescription
TRUEnever evaluated
FALSEnever evaluated
0
3923 return;
never executed: return;
0
3924-
3925 d_ptr->transformData->rotation = newRotation;-
3926 d_ptr->transformData->onlyTransform = false;-
3927 d_ptr->dirtySceneTransform = 1;-
3928-
3929 // Send post-notification.-
3930 if (d_ptr->flags & ItemSendsGeometryChanges)
d_ptr->flags &...eometryChangesDescription
TRUEnever evaluated
FALSEnever evaluated
0
3931 itemChange(ItemRotationHasChanged, newRotation);
never executed: itemChange(ItemRotationHasChanged, newRotation);
0
3932-
3933 if (d_ptr->isObject)
d_ptr->isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
3934 emit static_cast<QGraphicsObject *>(this)->rotationChanged();
never executed: static_cast<QGraphicsObject *>(this)->rotationChanged();
0
3935-
3936 d_ptr->transformChanged();-
3937}
never executed: end of block
0
3938-
3939/*!-
3940 \since 4.6-
3941-
3942 Returns the scale factor of the item. The default scale factor is 1.0-
3943 (i.e., the item is not scaled).-
3944-
3945 The scale is combined with the item's rotation(), transform() and-
3946 transformations() to map the item's coordinate system to the parent item.-
3947-
3948 \sa setScale(), rotation(), {Transformations}-
3949*/-
3950qreal QGraphicsItem::scale() const-
3951{-
3952 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
3953 return 1.;
never executed: return 1.;
0
3954 return d_ptr->transformData->scale;
never executed: return d_ptr->transformData->scale;
0
3955}-
3956-
3957/*!-
3958 \since 4.6-
3959-
3960 Sets the scale \a factor of the item. The default scale factor is 1.0-
3961 (i.e., the item is not scaled). A scale factor of 0.0 will collapse the-
3962 item to a single point. If you provide a negative scale factor, the-
3963 item will be flipped and mirrored (i.e., rotated 180 degrees).-
3964-
3965 The item is scaled around its transform origin point, which by default-
3966 is (0, 0). You can select a different transformation origin by calling-
3967 setTransformOriginPoint().-
3968-
3969 The scale is combined with the item's rotation(), transform() and-
3970 transformations() to map the item's coordinate system to the parent item.-
3971-
3972 \sa scale(), setTransformOriginPoint(), {Transformations Example}-
3973*/-
3974void QGraphicsItem::setScale(qreal factor)-
3975{-
3976 prepareGeometryChange();-
3977 qreal newScale = factor;-
3978-
3979 if (d_ptr->flags & ItemSendsGeometryChanges) {
d_ptr->flags &...eometryChangesDescription
TRUEnever evaluated
FALSEnever evaluated
0
3980 // Notify the item that the scale is changing.-
3981 const QVariant newScaleVariant(itemChange(ItemScaleChange, factor));-
3982 newScale = newScaleVariant.toReal();-
3983 }
never executed: end of block
0
3984-
3985 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
3986 d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
0
3987-
3988 if (d_ptr->transformData->scale == newScale)
d_ptr->transfo...le == newScaleDescription
TRUEnever evaluated
FALSEnever evaluated
0
3989 return;
never executed: return;
0
3990-
3991 d_ptr->transformData->scale = newScale;-
3992 d_ptr->transformData->onlyTransform = false;-
3993 d_ptr->dirtySceneTransform = 1;-
3994-
3995 // Send post-notification.-
3996 if (d_ptr->flags & ItemSendsGeometryChanges)
d_ptr->flags &...eometryChangesDescription
TRUEnever evaluated
FALSEnever evaluated
0
3997 itemChange(ItemScaleHasChanged, newScale);
never executed: itemChange(ItemScaleHasChanged, newScale);
0
3998-
3999 if (d_ptr->isObject)
d_ptr->isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
4000 emit static_cast<QGraphicsObject *>(this)->scaleChanged();
never executed: static_cast<QGraphicsObject *>(this)->scaleChanged();
0
4001-
4002 d_ptr->transformChanged();-
4003}
never executed: end of block
0
4004-
4005-
4006/*!-
4007 \since 4.6-
4008-
4009 Returns a list of graphics transforms that currently apply to this item.-
4010-
4011 QGraphicsTransform is for applying and controlling a chain of individual-
4012 transformation operations on an item. It's particularly useful in-
4013 animations, where each transform operation needs to be interpolated-
4014 independently, or differently.-
4015-
4016 The transformations are combined with the item's rotation(), scale() and-
4017 transform() to map the item's coordinate system to the parent item.-
4018-
4019 \sa scale(), rotation(), transformOriginPoint(), {Transformations}-
4020*/-
4021QList<QGraphicsTransform *> QGraphicsItem::transformations() const-
4022{-
4023 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4024 return QList<QGraphicsTransform *>();
never executed: return QList<QGraphicsTransform *>();
0
4025 return d_ptr->transformData->graphicsTransforms;
never executed: return d_ptr->transformData->graphicsTransforms;
0
4026}-
4027-
4028/*!-
4029 \since 4.6-
4030-
4031 Sets a list of graphics \a transformations (QGraphicsTransform) that-
4032 currently apply to this item.-
4033-
4034 If all you want is to rotate or scale an item, you should call setRotation()-
4035 or setScale() instead. If you want to set an arbitrary transformation on-
4036 an item, you can call setTransform().-
4037-
4038 QGraphicsTransform is for applying and controlling a chain of individual-
4039 transformation operations on an item. It's particularly useful in-
4040 animations, where each transform operation needs to be interpolated-
4041 independently, or differently.-
4042-
4043 The transformations are combined with the item's rotation(), scale() and-
4044 transform() to map the item's coordinate system to the parent item.-
4045-
4046 \sa scale(), setTransformOriginPoint(), {Transformations}-
4047*/-
4048void QGraphicsItem::setTransformations(const QList<QGraphicsTransform *> &transformations)-
4049{-
4050 prepareGeometryChange();-
4051 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4052 d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
0
4053 d_ptr->transformData->graphicsTransforms = transformations;-
4054 for (int i = 0; i < transformations.size(); ++i)
i < transformations.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
4055 transformations.at(i)->d_func()->setItem(this);
never executed: transformations.at(i)->d_func()->setItem(this);
0
4056 d_ptr->transformData->onlyTransform = false;-
4057 d_ptr->dirtySceneTransform = 1;-
4058 d_ptr->transformChanged();-
4059}
never executed: end of block
0
4060-
4061/*!-
4062 \internal-
4063*/-
4064void QGraphicsItemPrivate::prependGraphicsTransform(QGraphicsTransform *t)-
4065{-
4066 if (!transformData)
!transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4067 transformData = new QGraphicsItemPrivate::TransformData;
never executed: transformData = new QGraphicsItemPrivate::TransformData;
0
4068 if (!transformData->graphicsTransforms.contains(t))
!transformData...ms.contains(t)Description
TRUEnever evaluated
FALSEnever evaluated
0
4069 transformData->graphicsTransforms.prepend(t);
never executed: transformData->graphicsTransforms.prepend(t);
0
4070-
4071 Q_Q(QGraphicsItem);-
4072 t->d_func()->setItem(q);-
4073 transformData->onlyTransform = false;-
4074 dirtySceneTransform = 1;-
4075 transformChanged();-
4076}
never executed: end of block
0
4077-
4078/*!-
4079 \internal-
4080*/-
4081void QGraphicsItemPrivate::appendGraphicsTransform(QGraphicsTransform *t)-
4082{-
4083 if (!transformData)
!transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4084 transformData = new QGraphicsItemPrivate::TransformData;
never executed: transformData = new QGraphicsItemPrivate::TransformData;
0
4085 if (!transformData->graphicsTransforms.contains(t))
!transformData...ms.contains(t)Description
TRUEnever evaluated
FALSEnever evaluated
0
4086 transformData->graphicsTransforms.append(t);
never executed: transformData->graphicsTransforms.append(t);
0
4087-
4088 Q_Q(QGraphicsItem);-
4089 t->d_func()->setItem(q);-
4090 transformData->onlyTransform = false;-
4091 dirtySceneTransform = 1;-
4092 transformChanged();-
4093}
never executed: end of block
0
4094-
4095/*!-
4096 \since 4.6-
4097-
4098 Returns the origin point for the transformation in item coordinates.-
4099-
4100 The default is QPointF(0,0).-
4101-
4102 \sa setTransformOriginPoint(), {Transformations}-
4103*/-
4104QPointF QGraphicsItem::transformOriginPoint() const-
4105{-
4106 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4107 return QPointF(0,0);
never executed: return QPointF(0,0);
0
4108 return QPointF(d_ptr->transformData->xOrigin, d_ptr->transformData->yOrigin);
never executed: return QPointF(d_ptr->transformData->xOrigin, d_ptr->transformData->yOrigin);
0
4109}-
4110-
4111/*!-
4112 \since 4.6-
4113-
4114 Sets the \a origin point for the transformation in item coordinates.-
4115-
4116 \sa transformOriginPoint(), {Transformations}-
4117*/-
4118void QGraphicsItem::setTransformOriginPoint(const QPointF &origin)-
4119{-
4120 prepareGeometryChange();-
4121 QPointF newOrigin = origin;-
4122-
4123 if (d_ptr->flags & ItemSendsGeometryChanges) {
d_ptr->flags &...eometryChangesDescription
TRUEnever evaluated
FALSEnever evaluated
0
4124 // Notify the item that the origin point is changing.-
4125 const QVariant newOriginVariant(itemChange(ItemTransformOriginPointChange,-
4126 QVariant::fromValue<QPointF>(origin)));-
4127 newOrigin = newOriginVariant.toPointF();-
4128 }
never executed: end of block
0
4129-
4130 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4131 d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
0
4132-
4133 if (d_ptr->transformData->xOrigin == newOrigin.x()
d_ptr->transfo... newOrigin.x()Description
TRUEnever evaluated
FALSEnever evaluated
0
4134 && d_ptr->transformData->yOrigin == newOrigin.y()) {
d_ptr->transfo... newOrigin.y()Description
TRUEnever evaluated
FALSEnever evaluated
0
4135 return;
never executed: return;
0
4136 }-
4137-
4138 d_ptr->transformData->xOrigin = newOrigin.x();-
4139 d_ptr->transformData->yOrigin = newOrigin.y();-
4140 d_ptr->transformData->onlyTransform = false;-
4141 d_ptr->dirtySceneTransform = 1;-
4142-
4143 // Send post-notification.-
4144 if (d_ptr->flags & ItemSendsGeometryChanges)
d_ptr->flags &...eometryChangesDescription
TRUEnever evaluated
FALSEnever evaluated
0
4145 itemChange(ItemTransformOriginPointHasChanged, QVariant::fromValue<QPointF>(newOrigin));
never executed: itemChange(ItemTransformOriginPointHasChanged, QVariant::fromValue<QPointF>(newOrigin));
0
4146}
never executed: end of block
0
4147-
4148/*!-
4149 \fn void QGraphicsItem::setTransformOriginPoint(qreal x, qreal y)-
4150-
4151 \since 4.6-
4152 \overload-
4153-
4154 Sets the origin point for the transformation in item coordinates.-
4155 This is equivalent to calling setTransformOriginPoint(QPointF(\a x, \a y)).-
4156-
4157 \sa setTransformOriginPoint(), {Transformations}-
4158*/-
4159-
4160-
4161/*!-
4162 \obsolete-
4163-
4164 Use sceneTransform() instead.-
4165-
4166 \sa transform(), setTransform(), scenePos(), {The Graphics View Coordinate System}-
4167*/-
4168QMatrix QGraphicsItem::sceneMatrix() const-
4169{-
4170 d_ptr->ensureSceneTransform();-
4171 return d_ptr->sceneTransform.toAffine();
never executed: return d_ptr->sceneTransform.toAffine();
0
4172}-
4173-
4174-
4175/*!-
4176 \since 4.3-
4177-
4178 Returns this item's scene transformation matrix. This matrix can be used-
4179 to map coordinates and geometrical shapes from this item's local-
4180 coordinate system to the scene's coordinate system. To map coordinates-
4181 from the scene, you must first invert the returned matrix.-
4182-
4183 Example:-
4184-
4185 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 4-
4186-
4187 Unlike transform(), which returns only an item's local transformation, this-
4188 function includes the item's (and any parents') position, and all the transfomation properties.-
4189-
4190 \sa transform(), setTransform(), scenePos(), {The Graphics View Coordinate System}, {Transformations}-
4191*/-
4192QTransform QGraphicsItem::sceneTransform() const-
4193{-
4194 d_ptr->ensureSceneTransform();-
4195 return d_ptr->sceneTransform;
never executed: return d_ptr->sceneTransform;
0
4196}-
4197-
4198/*!-
4199 \since 4.3-
4200-
4201 Returns this item's device transformation matrix, using \a-
4202 viewportTransform to map from scene to device coordinates. This matrix can-
4203 be used to map coordinates and geometrical shapes from this item's local-
4204 coordinate system to the viewport's (or any device's) coordinate-
4205 system. To map coordinates from the viewport, you must first invert the-
4206 returned matrix.-
4207-
4208 Example:-
4209-
4210 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 5-
4211-
4212 This function is the same as combining this item's scene transform with-
4213 the view's viewport transform, but it also understands the-
4214 ItemIgnoresTransformations flag. The device transform can be used to do-
4215 accurate coordinate mapping (and collision detection) for untransformable-
4216 items.-
4217-
4218 \sa transform(), setTransform(), scenePos(), {The Graphics View Coordinate-
4219 System}, itemTransform()-
4220*/-
4221QTransform QGraphicsItem::deviceTransform(const QTransform &viewportTransform) const-
4222{-
4223 // Ensure we return the standard transform if we're not untransformable.-
4224 if (!d_ptr->itemIsUntransformable()) {
!d_ptr->itemIs...ransformable()Description
TRUEnever evaluated
FALSEnever evaluated
0
4225 d_ptr->ensureSceneTransform();-
4226 return d_ptr->sceneTransform * viewportTransform;
never executed: return d_ptr->sceneTransform * viewportTransform;
0
4227 }-
4228-
4229 // Find the topmost item that ignores view transformations.-
4230 const QGraphicsItem *untransformedAncestor = this;-
4231 QList<const QGraphicsItem *> parents;-
4232 while (untransformedAncestor && ((untransformedAncestor->d_ptr->ancestorFlags
untransformedAncestorDescription
TRUEnever evaluated
FALSEnever evaluated
((untransforme...nsformations))Description
TRUEnever evaluated
FALSEnever evaluated
0
4233 & QGraphicsItemPrivate::AncestorIgnoresTransformations))) {
((untransforme...nsformations))Description
TRUEnever evaluated
FALSEnever evaluated
0
4234 parents.prepend(untransformedAncestor);-
4235 untransformedAncestor = untransformedAncestor->parentItem();-
4236 }
never executed: end of block
0
4237-
4238 if (!untransformedAncestor) {
!untransformedAncestorDescription
TRUEnever evaluated
FALSEnever evaluated
0
4239 // Assert in debug mode, continue in release.-
4240 Q_ASSERT_X(untransformedAncestor, "QGraphicsItem::deviceTransform",-
4241 "Invalid object structure!");-
4242 return QTransform();
never executed: return QTransform();
0
4243 }-
4244-
4245 // Determine the inherited origin. Find the parent of the topmost untransformable.-
4246 // Use its scene transform to map the position of the untransformable. Then use-
4247 // that viewport position as the anchoring point for the untransformable subtree.-
4248 QGraphicsItem *parentOfUntransformedAncestor = untransformedAncestor->parentItem();-
4249 QTransform inheritedMatrix;-
4250 if (parentOfUntransformedAncestor)
parentOfUntransformedAncestorDescription
TRUEnever evaluated
FALSEnever evaluated
0
4251 inheritedMatrix = parentOfUntransformedAncestor->sceneTransform();
never executed: inheritedMatrix = parentOfUntransformedAncestor->sceneTransform();
0
4252 QPointF mappedPoint = (inheritedMatrix * viewportTransform).map(untransformedAncestor->pos());-
4253-
4254 // COMBINE-
4255 QTransform matrix = QTransform::fromTranslate(mappedPoint.x(), mappedPoint.y());-
4256 if (untransformedAncestor->d_ptr->transformData)
untransformedA...>transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4257 matrix = untransformedAncestor->d_ptr->transformData->computedFullTransform(&matrix);
never executed: matrix = untransformedAncestor->d_ptr->transformData->computedFullTransform(&matrix);
0
4258-
4259 // Then transform and translate all children.-
4260 for (int i = 0; i < parents.size(); ++i) {
i < parents.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
4261 const QGraphicsItem *parent = parents.at(i);-
4262 parent->d_ptr->combineTransformFromParent(&matrix);-
4263 }
never executed: end of block
0
4264-
4265 return matrix;
never executed: return matrix;
0
4266}-
4267-
4268/*!-
4269 \since 4.5-
4270-
4271 Returns a QTransform that maps coordinates from this item to \a other. If-
4272 \a ok is not null, and if there is no such transform, the boolean pointed-
4273 to by \a ok will be set to false; otherwise it will be set to true.-
4274-
4275 This transform provides an alternative to the mapToItem() or mapFromItem()-
4276 functions, by returning the appropriate transform so that you can map-
4277 shapes and coordinates yourself. It also helps you write more efficient-
4278 code when repeatedly mapping between the same two items.-
4279-
4280 \note In rare circumstances, there is no transform that maps between two-
4281 items.-
4282-
4283 \sa mapToItem(), mapFromItem(), deviceTransform()-
4284*/-
4285QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) const-
4286{-
4287 // Catch simple cases first.-
4288 if (other == 0) {
other == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
4289 qWarning("QGraphicsItem::itemTransform: null pointer passed");-
4290 return QTransform();
never executed: return QTransform();
0
4291 }-
4292 if (other == this) {
other == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
4293 if (ok)
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
4294 *ok = true;
never executed: *ok = true;
0
4295 return QTransform();
never executed: return QTransform();
0
4296 }-
4297-
4298 QGraphicsItem *parent = d_ptr->parent;-
4299 const QGraphicsItem *otherParent = other->d_ptr->parent;-
4300-
4301 // This is other's child-
4302 if (parent == other) {
parent == otherDescription
TRUEnever evaluated
FALSEnever evaluated
0
4303 if (ok)
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
4304 *ok = true;
never executed: *ok = true;
0
4305 QTransform x;-
4306 d_ptr->combineTransformFromParent(&x);-
4307 return x;
never executed: return x;
0
4308 }-
4309-
4310 // This is other's parent-
4311 if (otherParent == this) {
otherParent == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
4312 const QPointF &otherPos = other->d_ptr->pos;-
4313 if (other->d_ptr->transformData) {
other->d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4314 QTransform otherToParent;-
4315 other->d_ptr->combineTransformFromParent(&otherToParent);-
4316 return otherToParent.inverted(ok);
never executed: return otherToParent.inverted(ok);
0
4317 }-
4318 if (ok)
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
4319 *ok = true;
never executed: *ok = true;
0
4320 return QTransform::fromTranslate(-otherPos.x(), -otherPos.y());
never executed: return QTransform::fromTranslate(-otherPos.x(), -otherPos.y());
0
4321 }-
4322-
4323 // Siblings-
4324 if (parent == otherParent) {
parent == otherParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
4325 // COMBINE-
4326 const QPointF &itemPos = d_ptr->pos;-
4327 const QPointF &otherPos = other->d_ptr->pos;-
4328 if (!d_ptr->transformData && !other->d_ptr->transformData) {
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
!other->d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4329 QPointF delta = itemPos - otherPos;-
4330 if (ok)
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
4331 *ok = true;
never executed: *ok = true;
0
4332 return QTransform::fromTranslate(delta.x(), delta.y());
never executed: return QTransform::fromTranslate(delta.x(), delta.y());
0
4333 }-
4334-
4335 QTransform itemToParent;-
4336 d_ptr->combineTransformFromParent(&itemToParent);-
4337 QTransform otherToParent;-
4338 other->d_ptr->combineTransformFromParent(&otherToParent);-
4339 return itemToParent * otherToParent.inverted(ok);
never executed: return itemToParent * otherToParent.inverted(ok);
0
4340 }-
4341-
4342 // Find the closest common ancestor. If the two items don't share an-
4343 // ancestor, then the only way is to combine their scene transforms.-
4344 const QGraphicsItem *commonAncestor = commonAncestorItem(other);-
4345 if (!commonAncestor) {
!commonAncestorDescription
TRUEnever evaluated
FALSEnever evaluated
0
4346 d_ptr->ensureSceneTransform();-
4347 other->d_ptr->ensureSceneTransform();-
4348 return d_ptr->sceneTransform * other->d_ptr->sceneTransform.inverted(ok);
never executed: return d_ptr->sceneTransform * other->d_ptr->sceneTransform.inverted(ok);
0
4349 }-
4350-
4351 // If the two items are cousins (in sibling branches), map both to the-
4352 // common ancestor, and combine the two transforms.-
4353 bool cousins = other != commonAncestor && this != commonAncestor;
other != commonAncestorDescription
TRUEnever evaluated
FALSEnever evaluated
this != commonAncestorDescription
TRUEnever evaluated
FALSEnever evaluated
0
4354 if (cousins) {
cousinsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4355 bool good = false;-
4356 QTransform thisToScene = itemTransform(commonAncestor, &good);-
4357 QTransform otherToScene(Qt::Uninitialized);-
4358 if (good)
goodDescription
TRUEnever evaluated
FALSEnever evaluated
0
4359 otherToScene = other->itemTransform(commonAncestor, &good);
never executed: otherToScene = other->itemTransform(commonAncestor, &good);
0
4360 if (!good) {
!goodDescription
TRUEnever evaluated
FALSEnever evaluated
0
4361 if (ok)
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
4362 *ok = false;
never executed: *ok = false;
0
4363 return QTransform();
never executed: return QTransform();
0
4364 }-
4365 return thisToScene * otherToScene.inverted(ok);
never executed: return thisToScene * otherToScene.inverted(ok);
0
4366 }-
4367-
4368 // One is an ancestor of the other; walk the chain.-
4369 bool parentOfOther = isAncestorOf(other);-
4370 const QGraphicsItem *child = parentOfOther ? other : this;
parentOfOtherDescription
TRUEnever evaluated
FALSEnever evaluated
0
4371 const QGraphicsItem *root = parentOfOther ? this : other;
parentOfOtherDescription
TRUEnever evaluated
FALSEnever evaluated
0
4372-
4373 QTransform x;-
4374 const QGraphicsItem *p = child;-
4375 do {-
4376 p->d_ptr.data()->combineTransformToParent(&x);-
4377 } 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
4378 if (parentOfOther)
parentOfOtherDescription
TRUEnever evaluated
FALSEnever evaluated
0
4379 return x.inverted(ok);
never executed: return x.inverted(ok);
0
4380 if (ok)
okDescription
TRUEnever evaluated
FALSEnever evaluated
0
4381 *ok = true;
never executed: *ok = true;
0
4382 return x;
never executed: return x;
0
4383}-
4384-
4385/*!-
4386 \obsolete-
4387-
4388 Sets the item's affine transformation matrix. This is a subset or the-
4389 item's full transformation matrix, and might not represent the item's full-
4390 transformation.-
4391-
4392 Use setTransform() instead.-
4393-
4394 \sa transform(), {The Graphics View Coordinate System}-
4395*/-
4396void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine)-
4397{-
4398 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4399 d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
0
4400-
4401 QTransform newTransform(combine ? QTransform(matrix) * d_ptr->transformData->transform : QTransform(matrix));-
4402 if (d_ptr->transformData->transform == newTransform)
d_ptr->transfo...= newTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4403 return;
never executed: return;
0
4404-
4405 // Update and set the new transformation.-
4406 if (!(d_ptr->flags & ItemSendsGeometryChanges)) {
!(d_ptr->flags...ometryChanges)Description
TRUEnever evaluated
FALSEnever evaluated
0
4407 d_ptr->setTransformHelper(newTransform);-
4408 return;
never executed: return;
0
4409 }-
4410-
4411 // Notify the item that the transformation matrix is changing.-
4412 const QVariant newMatrixVariant = QVariant::fromValue<QMatrix>(newTransform.toAffine());-
4413 newTransform = QTransform(qvariant_cast<QMatrix>(itemChange(ItemMatrixChange, newMatrixVariant)));-
4414 if (d_ptr->transformData->transform == newTransform)
d_ptr->transfo...= newTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4415 return;
never executed: return;
0
4416-
4417 // Update and set the new transformation.-
4418 d_ptr->setTransformHelper(newTransform);-
4419-
4420 // Send post-notification.-
4421 itemChange(ItemTransformHasChanged, QVariant::fromValue<QTransform>(newTransform));-
4422}
never executed: end of block
0
4423-
4424/*!-
4425 \since 4.3-
4426-
4427 Sets the item's current transformation matrix to \a matrix.-
4428-
4429 If \a combine is true, then \a matrix is combined with the current matrix;-
4430 otherwise, \a matrix \e replaces the current matrix. \a combine is false-
4431 by default.-
4432-
4433 To simplify interaction with items using a transformed view, QGraphicsItem-
4434 provides mapTo... and mapFrom... functions that can translate between-
4435 items' and the scene's coordinates. For example, you can call mapToScene()-
4436 to map an item coordiate to a scene coordinate, or mapFromScene() to map-
4437 from scene coordinates to item coordinates.-
4438-
4439 The transformation matrix is combined with the item's rotation(), scale()-
4440 and transformations() into a combined transformation that maps the item's-
4441 coordinate system to its parent.-
4442-
4443 \sa transform(), setRotation(), setScale(), setTransformOriginPoint(), {The Graphics View Coordinate System}, {Transformations}-
4444*/-
4445void QGraphicsItem::setTransform(const QTransform &matrix, bool combine)-
4446{-
4447 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4448 d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData;
0
4449-
4450 QTransform newTransform(combine ? matrix * d_ptr->transformData->transform : matrix);-
4451 if (d_ptr->transformData->transform == newTransform)
d_ptr->transfo...= newTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4452 return;
never executed: return;
0
4453-
4454 // Update and set the new transformation.-
4455 if (!(d_ptr->flags & (ItemSendsGeometryChanges | ItemSendsScenePositionChanges))) {
!(d_ptr->flags...itionChanges))Description
TRUEnever evaluated
FALSEnever evaluated
0
4456 d_ptr->setTransformHelper(newTransform);-
4457 if (d_ptr->scenePosDescendants)
d_ptr->scenePosDescendantsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4458 d_ptr->sendScenePosChange();
never executed: d_ptr->sendScenePosChange();
0
4459 return;
never executed: return;
0
4460 }-
4461-
4462 // Notify the item that the transformation matrix is changing.-
4463 const QVariant newTransformVariant(itemChange(ItemTransformChange,-
4464 QVariant::fromValue<QTransform>(newTransform)));-
4465 newTransform = qvariant_cast<QTransform>(newTransformVariant);-
4466 if (d_ptr->transformData->transform == newTransform)
d_ptr->transfo...= newTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
4467 return;
never executed: return;
0
4468-
4469 // Update and set the new transformation.-
4470 d_ptr->setTransformHelper(newTransform);-
4471-
4472 // Send post-notification.-
4473 itemChange(ItemTransformHasChanged, newTransformVariant);-
4474 d_ptr->sendScenePosChange();-
4475}
never executed: end of block
0
4476-
4477/*!-
4478 \obsolete-
4479-
4480 Use resetTransform() instead.-
4481*/-
4482void QGraphicsItem::resetMatrix()-
4483{-
4484 resetTransform();-
4485}
never executed: end of block
0
4486-
4487/*!-
4488 \since 4.3-
4489-
4490 Resets this item's transformation matrix to the identity matrix or-
4491 all the transformation properties to their default values.-
4492 This is equivalent to calling \c setTransform(QTransform()).-
4493-
4494 \sa setTransform(), transform()-
4495*/-
4496void QGraphicsItem::resetTransform()-
4497{-
4498 setTransform(QTransform(), false);-
4499}
never executed: end of block
0
4500-
4501/*!-
4502 \fn void QGraphicsItem::rotate(qreal angle)-
4503 \obsolete-
4504-
4505 Use-
4506-
4507 \code-
4508 item->setTransform(QTransform().rotate(angle), true);-
4509 \endcode-
4510-
4511 instead.-
4512-
4513 Rotates the current item transformation \a angle degrees clockwise around-
4514 its origin. To translate around an arbitrary point (x, y), you need to-
4515 combine translation and rotation with setTransform().-
4516-
4517 Example:-
4518-
4519 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 6-
4520-
4521 \sa setTransform(), transform(), scale(), shear(), translate()-
4522*/-
4523-
4524/*!-
4525 \fn void QGraphicsItem::scale(qreal sx, qreal sy)-
4526 \obsolete-
4527-
4528 Use-
4529-
4530 \code-
4531 setTransform(QTransform::fromScale(sx, sy), true);-
4532 \endcode-
4533-
4534 instead.-
4535-
4536 Scales the current item transformation by (\a sx, \a sy) around its-
4537 origin. To scale from an arbitrary point (x, y), you need to combine-
4538 translation and scaling with setTransform().-
4539-
4540 Example:-
4541-
4542 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 7-
4543-
4544 \sa setTransform(), transform()-
4545*/-
4546-
4547/*!-
4548 \fn void QGraphicsItem::shear(qreal sh, qreal sv)-
4549 \obsolete-
4550-
4551 Use-
4552-
4553 \code-
4554 setTransform(QTransform().shear(sh, sv), true);-
4555 \endcode-
4556-
4557 instead.-
4558-
4559 Shears the current item transformation by (\a sh, \a sv).-
4560-
4561 \sa setTransform(), transform()-
4562*/-
4563-
4564/*!-
4565 \fn void QGraphicsItem::translate(qreal dx, qreal dy)-
4566 \obsolete-
4567-
4568 Use setPos() or setTransformOriginPoint() instead. For identical-
4569 behavior, use-
4570-
4571 \code-
4572 setTransform(QTransform::fromTranslate(dx, dy), true);-
4573 \endcode-
4574-
4575 Translates the current item transformation by (\a dx, \a dy).-
4576-
4577 If all you want is to move an item, you should call moveBy() or-
4578 setPos() instead; this function changes the item's translation,-
4579 which is conceptually separate from its position.-
4580-
4581 \sa setTransform(), transform()-
4582*/-
4583-
4584/*!-
4585 This virtual function is called twice for all items by the-
4586 QGraphicsScene::advance() slot. In the first phase, all items are called-
4587 with \a phase == 0, indicating that items on the scene are about to-
4588 advance, and then all items are called with \a phase == 1. Reimplement-
4589 this function to update your item if you need simple scene-controlled-
4590 animation.-
4591-
4592 The default implementation does nothing.-
4593-
4594 This function is intended for animations. An alternative is to-
4595 multiple-inherit from QObject and QGraphicsItem and use the \l{The Animation-
4596 Framework}{Animation Framework}.-
4597-
4598 \sa QGraphicsScene::advance(), QTimeLine-
4599*/-
4600void QGraphicsItem::advance(int phase)-
4601{-
4602 Q_UNUSED(phase);-
4603}
never executed: end of block
0
4604-
4605/*!-
4606 Returns the Z-value of the item. The Z-value affects the stacking order of-
4607 sibling (neighboring) items.-
4608-
4609 The default Z-value is 0.-
4610-
4611 \sa setZValue(), {QGraphicsItem#Sorting}{Sorting}, stackBefore(), ItemStacksBehindParent-
4612*/-
4613qreal QGraphicsItem::zValue() const-
4614{-
4615 return d_ptr->z;
never executed: return d_ptr->z;
0
4616}-
4617-
4618/*!-
4619 Sets the Z-value of the item to \a z. The Z value decides the stacking-
4620 order of sibling (neighboring) items. A sibling item of high Z value will-
4621 always be drawn on top of another sibling item with a lower Z value.-
4622-
4623 If you restore the Z value, the item's insertion order will decide its-
4624 stacking order.-
4625-
4626 The Z-value does not affect the item's size in any way.-
4627-
4628 The default Z-value is 0.-
4629-
4630 \sa zValue(), {QGraphicsItem#Sorting}{Sorting}, stackBefore(), ItemStacksBehindParent-
4631*/-
4632void QGraphicsItem::setZValue(qreal z)-
4633{-
4634 const QVariant newZVariant(itemChange(ItemZValueChange, z));-
4635 qreal newZ = newZVariant.toReal();-
4636 if (newZ == d_ptr->z)
newZ == d_ptr->zDescription
TRUEnever evaluated
FALSEnever evaluated
0
4637 return;
never executed: return;
0
4638-
4639 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
4640 // Z Value has changed, we have to notify the index.-
4641 d_ptr->scene->d_func()->index->itemChange(this, ItemZValueChange, &newZ);-
4642 }
never executed: end of block
0
4643-
4644 d_ptr->z = newZ;-
4645 if (d_ptr->parent)
d_ptr->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
4646 d_ptr->parent->d_ptr->needSortChildren = 1;
never executed: d_ptr->parent->d_ptr->needSortChildren = 1;
0
4647 else if (d_ptr->scene)
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
4648 d_ptr->scene->d_func()->needSortTopLevelItems = 1;
never executed: d_ptr->scene->d_func()->needSortTopLevelItems = 1;
0
4649-
4650 if (d_ptr->scene)
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
4651 d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true);
never executed: d_ptr->scene->d_func()->markDirty(this, QRectF(), true);
0
4652-
4653 itemChange(ItemZValueHasChanged, newZVariant);-
4654-
4655 if (d_ptr->flags & ItemNegativeZStacksBehindParent)
d_ptr->flags &...ksBehindParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
4656 setFlag(QGraphicsItem::ItemStacksBehindParent, z < qreal(0.0));
never executed: setFlag(QGraphicsItem::ItemStacksBehindParent, z < qreal(0.0));
0
4657-
4658 if (d_ptr->isObject)
d_ptr->isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
4659 emit static_cast<QGraphicsObject *>(this)->zChanged();
never executed: static_cast<QGraphicsObject *>(this)->zChanged();
0
4660}
never executed: end of block
0
4661-
4662/*!-
4663 \internal-
4664-
4665 Ensures that the list of children is sorted by insertion order, and that-
4666 the siblingIndexes are packed (no gaps), and start at 0.-
4667-
4668 ### This function is almost identical to-
4669 QGraphicsScenePrivate::ensureSequentialTopLevelSiblingIndexes().-
4670*/-
4671void QGraphicsItemPrivate::ensureSequentialSiblingIndex()-
4672{-
4673 if (!sequentialOrdering) {
!sequentialOrderingDescription
TRUEnever evaluated
FALSEnever evaluated
0
4674 std::sort(children.begin(), children.end(), insertionOrder);-
4675 sequentialOrdering = 1;-
4676 needSortChildren = 1;-
4677 }
never executed: end of block
0
4678 if (holesInSiblingIndex) {
holesInSiblingIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
4679 holesInSiblingIndex = 0;-
4680 for (int i = 0; i < children.size(); ++i)
i < children.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
4681 children[i]->d_ptr->siblingIndex = i;
never executed: children[i]->d_ptr->siblingIndex = i;
0
4682 }
never executed: end of block
0
4683}
never executed: end of block
0
4684-
4685/*!-
4686 \internal-
4687*/-
4688inline void QGraphicsItemPrivate::sendScenePosChange()-
4689{-
4690 Q_Q(QGraphicsItem);-
4691 if (scene) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
4692 if (flags & QGraphicsItem::ItemSendsScenePositionChanges)
flags & QGraph...ositionChangesDescription
TRUEnever evaluated
FALSEnever evaluated
0
4693 q->itemChange(QGraphicsItem::ItemScenePositionHasChanged, q->scenePos());
never executed: q->itemChange(QGraphicsItem::ItemScenePositionHasChanged, q->scenePos());
0
4694 if (scenePosDescendants) {
scenePosDescendantsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4695 foreach (QGraphicsItem *item, scene->d_func()->scenePosItems) {-
4696 if (q->isAncestorOf(item))
q->isAncestorOf(item)Description
TRUEnever evaluated
FALSEnever evaluated
0
4697 item->itemChange(QGraphicsItem::ItemScenePositionHasChanged, item->scenePos());
never executed: item->itemChange(QGraphicsItem::ItemScenePositionHasChanged, item->scenePos());
0
4698 }
never executed: end of block
0
4699 }
never executed: end of block
0
4700 }
never executed: end of block
0
4701}
never executed: end of block
0
4702-
4703/*!-
4704 \since 4.6-
4705-
4706 Stacks this item before \a sibling, which must be a sibling item (i.e., the-
4707 two items must share the same parent item, or must both be toplevel items).-
4708 The \a sibling must have the same Z value as this item, otherwise calling-
4709 this function will have no effect.-
4710-
4711 By default, all sibling items are stacked by insertion order (i.e., the-
4712 first item you add is drawn before the next item you add). If two items' Z-
4713 values are different, then the item with the highest Z value is drawn on-
4714 top. When the Z values are the same, the insertion order will decide the-
4715 stacking order.-
4716-
4717 \sa setZValue(), ItemStacksBehindParent, {QGraphicsItem#Sorting}{Sorting}-
4718*/-
4719void QGraphicsItem::stackBefore(const QGraphicsItem *sibling)-
4720{-
4721 if (sibling == this)
sibling == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
4722 return;
never executed: return;
0
4723 if (!sibling || d_ptr->parent != sibling->parentItem()) {
!siblingDescription
TRUEnever evaluated
FALSEnever evaluated
d_ptr->parent ...->parentItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
4724 qWarning("QGraphicsItem::stackUnder: cannot stack under %p, which must be a sibling", sibling);-
4725 return;
never executed: return;
0
4726 }-
4727 QList<QGraphicsItem *> *siblings = d_ptr->parent
d_ptr->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
4728 ? &d_ptr->parent->d_ptr->children-
4729 : (d_ptr->scene ? &d_ptr->scene->d_func()->topLevelItems : 0);
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
4730 if (!siblings) {
!siblingsDescription
TRUEnever evaluated
FALSEnever evaluated
0
4731 qWarning("QGraphicsItem::stackUnder: cannot stack under %p, which must be a sibling", sibling);-
4732 return;
never executed: return;
0
4733 }-
4734-
4735 // First, make sure that the sibling indexes have no holes. This also-
4736 // marks the children list for sorting.-
4737 if (d_ptr->parent)
d_ptr->parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
4738 d_ptr->parent->d_ptr->ensureSequentialSiblingIndex();
never executed: d_ptr->parent->d_ptr->ensureSequentialSiblingIndex();
0
4739 else-
4740 d_ptr->scene->d_func()->ensureSequentialTopLevelSiblingIndexes();
never executed: d_ptr->scene->d_func()->ensureSequentialTopLevelSiblingIndexes();
0
4741-
4742 // Only move items with the same Z value, and that need moving.-
4743 int siblingIndex = sibling->d_ptr->siblingIndex;-
4744 int myIndex = d_ptr->siblingIndex;-
4745 if (myIndex >= siblingIndex) {
myIndex >= siblingIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
4746 siblings->move(myIndex, siblingIndex);-
4747 // Fixup the insertion ordering.-
4748 for (int i = 0; i < siblings->size(); ++i) {
i < siblings->size()Description
TRUEnever evaluated
FALSEnever evaluated
0
4749 int &index = siblings->at(i)->d_ptr->siblingIndex;-
4750 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
4751 ++index;
never executed: ++index;
0
4752 }
never executed: end of block
0
4753 d_ptr->siblingIndex = siblingIndex;-
4754 for (int i = 0; i < siblings->size(); ++i) {
i < siblings->size()Description
TRUEnever evaluated
FALSEnever evaluated
0
4755 int &index = siblings->at(i)->d_ptr->siblingIndex;-
4756 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
4757 siblings->at(i)->d_ptr->siblingOrderChange();
never executed: siblings->at(i)->d_ptr->siblingOrderChange();
0
4758 }
never executed: end of block
0
4759 d_ptr->siblingOrderChange();-
4760 }
never executed: end of block
0
4761}
never executed: end of block
0
4762-
4763/*!-
4764 Returns the bounding rect of this item's descendants (i.e., its-
4765 children, their children, etc.) in local coordinates. The-
4766 rectangle will contain all descendants after they have been mapped-
4767 to local coordinates. If the item has no children, this function-
4768 returns an empty QRectF.-
4769-
4770 This does not include this item's own bounding rect; it only returns-
4771 its descendants' accumulated bounding rect. If you need to include this-
4772 item's bounding rect, you can add boundingRect() to childrenBoundingRect()-
4773 using QRectF::operator|().-
4774-
4775 This function is linear in complexity; it determines the size of the-
4776 returned bounding rect by iterating through all descendants.-
4777-
4778 \sa boundingRect(), sceneBoundingRect()-
4779*/-
4780QRectF QGraphicsItem::childrenBoundingRect() const-
4781{-
4782 if (!d_ptr->dirtyChildrenBoundingRect)
!d_ptr->dirtyC...enBoundingRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
4783 return d_ptr->childrenBoundingRect;
never executed: return d_ptr->childrenBoundingRect;
0
4784-
4785 d_ptr->childrenBoundingRect = QRectF();-
4786 d_ptr->childrenBoundingRectHelper(0, &d_ptr->childrenBoundingRect, 0);-
4787 d_ptr->dirtyChildrenBoundingRect = 0;-
4788 return d_ptr->childrenBoundingRect;
never executed: return d_ptr->childrenBoundingRect;
0
4789}-
4790-
4791/*!-
4792 \fn virtual QRectF QGraphicsItem::boundingRect() const = 0-
4793-
4794 This pure virtual function defines the outer bounds of the item as-
4795 a rectangle; all painting must be restricted to inside an item's-
4796 bounding rect. QGraphicsView uses this to determine whether the-
4797 item requires redrawing.-
4798-
4799 Although the item's shape can be arbitrary, the bounding rect is-
4800 always rectangular, and it is unaffected by the items'-
4801 transformation.-
4802-
4803 If you want to change the item's bounding rectangle, you must first call-
4804 prepareGeometryChange(). This notifies the scene of the imminent change,-
4805 so that it can update its item geometry index; otherwise, the scene will-
4806 be unaware of the item's new geometry, and the results are undefined-
4807 (typically, rendering artifacts are left within the view).-
4808-
4809 Reimplement this function to let QGraphicsView determine what-
4810 parts of the widget, if any, need to be redrawn.-
4811-
4812 Note: For shapes that paint an outline / stroke, it is important-
4813 to include half the pen width in the bounding rect. It is not-
4814 necessary to compensate for antialiasing, though.-
4815-
4816 Example:-
4817-
4818 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 8-
4819-
4820 \sa boundingRegion(), shape(), contains(), {The Graphics View Coordinate-
4821 System}, prepareGeometryChange()-
4822*/-
4823-
4824/*!-
4825 Returns the bounding rect of this item in scene coordinates, by combining-
4826 sceneTransform() with boundingRect().-
4827-
4828 \sa boundingRect(), {The Graphics View Coordinate System}-
4829*/-
4830QRectF QGraphicsItem::sceneBoundingRect() const-
4831{-
4832 // Find translate-only offset-
4833 // COMBINE-
4834 QPointF offset;-
4835 const QGraphicsItem *parentItem = this;-
4836 const QGraphicsItemPrivate *itemd;-
4837 do {-
4838 itemd = parentItem->d_ptr.data();-
4839 if (itemd->transformData)
itemd->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
4840 break;
never executed: break;
0
4841 offset += itemd->pos;-
4842 } while ((parentItem = itemd->parent));
never executed: end of block
(parentItem = itemd->parent)Description
TRUEnever evaluated
FALSEnever evaluated
0
4843-
4844 QRectF br = boundingRect();-
4845 br.translate(offset);-
4846 if (!parentItem)
!parentItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
4847 return br;
never executed: return br;
0
4848 if (parentItem->d_ptr->hasTranslateOnlySceneTransform()) {
parentItem->d_...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
4849 br.translate(parentItem->d_ptr->sceneTransform.dx(), parentItem->d_ptr->sceneTransform.dy());-
4850 return br;
never executed: return br;
0
4851 }-
4852 return parentItem->d_ptr->sceneTransform.mapRect(br);
never executed: return parentItem->d_ptr->sceneTransform.mapRect(br);
0
4853}-
4854-
4855/*!-
4856 Returns the shape of this item as a QPainterPath in local-
4857 coordinates. The shape is used for many things, including collision-
4858 detection, hit tests, and for the QGraphicsScene::items() functions.-
4859-
4860 The default implementation calls boundingRect() to return a simple-
4861 rectangular shape, but subclasses can reimplement this function to return-
4862 a more accurate shape for non-rectangular items. For example, a round item-
4863 may choose to return an elliptic shape for better collision detection. For-
4864 example:-
4865-
4866 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 9-
4867-
4868 The outline of a shape can vary depending on the width and style of the-
4869 pen used when drawing. If you want to include this outline in the item's-
4870 shape, you can create a shape from the stroke using QPainterPathStroker.-
4871-
4872 This function is called by the default implementations of contains() and-
4873 collidesWithPath().-
4874-
4875 \sa boundingRect(), contains(), prepareGeometryChange(), QPainterPathStroker-
4876*/-
4877QPainterPath QGraphicsItem::shape() const-
4878{-
4879 QPainterPath path;-
4880 path.addRect(boundingRect());-
4881 return path;
never executed: return path;
0
4882}-
4883-
4884/*!-
4885 Returns \c true if this item is clipped. An item is clipped if it has either-
4886 set the \l ItemClipsToShape flag, or if it or any of its ancestors has set-
4887 the \l ItemClipsChildrenToShape flag.-
4888-
4889 Clipping affects the item's appearance (i.e., painting), as well as mouse-
4890 and hover event delivery.-
4891-
4892 \sa clipPath(), shape(), setFlags()-
4893*/-
4894bool QGraphicsItem::isClipped() const-
4895{-
4896 Q_D(const QGraphicsItem);-
4897 return (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)
never executed: return (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) || (d->flags & QGraphicsItem::ItemClipsToShape);
(d->ancestorFl...ClipsChildren)Description
TRUEnever evaluated
FALSEnever evaluated
0
4898 || (d->flags & QGraphicsItem::ItemClipsToShape);
never executed: return (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) || (d->flags & QGraphicsItem::ItemClipsToShape);
(d->flags & QG...mClipsToShape)Description
TRUEnever evaluated
FALSEnever evaluated
0
4899}-
4900-
4901/*!-
4902 \since 4.5-
4903-
4904 Returns this item's clip path, or an empty QPainterPath if this item is-
4905 not clipped. The clip path constrains the item's appearance and-
4906 interaction (i.e., restricts the area the item can draw within and receive-
4907 events for).-
4908-
4909 You can enable clipping by setting the ItemClipsToShape or-
4910 ItemClipsChildrenToShape flags. The item's clip path is calculated by-
4911 intersecting all clipping ancestors' shapes. If the item sets-
4912 ItemClipsToShape, the final clip is intersected with the item's own shape.-
4913-
4914 \note Clipping introduces a performance penalty for all items involved;-
4915 you should generally avoid using clipping if you can (e.g., if your items-
4916 always draw inside boundingRect() or shape() boundaries, clipping is not-
4917 necessary).-
4918-
4919 \sa isClipped(), shape(), setFlags()-
4920*/-
4921QPainterPath QGraphicsItem::clipPath() const-
4922{-
4923 Q_D(const QGraphicsItem);-
4924 if (!isClipped())
!isClipped()Description
TRUEnever evaluated
FALSEnever evaluated
0
4925 return QPainterPath();
never executed: return QPainterPath();
0
4926-
4927 const QRectF thisBoundingRect(boundingRect());-
4928 if (thisBoundingRect.isEmpty())
thisBoundingRect.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
4929 return QPainterPath();
never executed: return QPainterPath();
0
4930-
4931 QPainterPath clip;-
4932 // Start with the item's bounding rect.-
4933 clip.addRect(thisBoundingRect);-
4934-
4935 if (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) {
d->ancestorFla...rClipsChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
4936 const QGraphicsItem *parent = this;-
4937 const QGraphicsItem *lastParent = this;-
4938-
4939 // Intersect any in-between clips starting at the top and moving downwards.-
4940 while ((parent = parent->d_ptr->parent)) {
(parent = pare...d_ptr->parent)Description
TRUEnever evaluated
FALSEnever evaluated
0
4941 if (parent->d_ptr->flags & ItemClipsChildrenToShape) {
parent->d_ptr-...hildrenToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
4942 // Map clip to the current parent and intersect with its shape/clipPath-
4943 clip = lastParent->itemTransform(parent).map(clip);-
4944 clip = clip.intersected(parent->shape());-
4945 if (clip.isEmpty())
clip.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
4946 return clip;
never executed: return clip;
0
4947 lastParent = parent;-
4948 }
never executed: end of block
0
4949-
4950 if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren))
!(parent->d_pt...ClipsChildren)Description
TRUEnever evaluated
FALSEnever evaluated
0
4951 break;
never executed: break;
0
4952 }
never executed: end of block
0
4953-
4954 if (lastParent != this) {
lastParent != thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
4955 // Map clip back to the item's transform.-
4956 // ### what if itemtransform fails-
4957 clip = lastParent->itemTransform(this).map(clip);-
4958 }
never executed: end of block
0
4959 }
never executed: end of block
0
4960-
4961 if (d->flags & ItemClipsToShape)
d->flags & ItemClipsToShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
4962 clip = clip.intersected(shape());
never executed: clip = clip.intersected(shape());
0
4963-
4964 return clip;
never executed: return clip;
0
4965}-
4966-
4967/*!-
4968 Returns \c true if this item contains \a point, which is in local-
4969 coordinates; otherwise, false is returned. It is most often called from-
4970 QGraphicsView to determine what item is under the cursor, and for that-
4971 reason, the implementation of this function should be as light-weight as-
4972 possible.-
4973-
4974 By default, this function calls shape(), but you can reimplement it in a-
4975 subclass to provide a (perhaps more efficient) implementation.-
4976-
4977 \sa shape(), boundingRect(), collidesWithPath()-
4978*/-
4979bool QGraphicsItem::contains(const QPointF &point) const-
4980{-
4981 return isClipped() ? clipPath().contains(point) : shape().contains(point);
never executed: return isClipped() ? clipPath().contains(point) : shape().contains(point);
isClipped()Description
TRUEnever evaluated
FALSEnever evaluated
0
4982}-
4983-
4984/*!-
4985-
4986 Returns \c true if this item collides with \a other; otherwise-
4987 returns \c false.-
4988-
4989 The \a mode is applied to \a other, and the resulting shape or-
4990 bounding rectangle is then compared to this item's shape. The-
4991 default value for \a mode is Qt::IntersectsItemShape; \a other-
4992 collides with this item if it either intersects, contains, or is-
4993 contained by this item's shape (see Qt::ItemSelectionMode for-
4994 details).-
4995-
4996 The default implementation is based on shape intersection, and it calls-
4997 shape() on both items. Because the complexity of arbitrary shape-shape-
4998 intersection grows with an order of magnitude when the shapes are complex,-
4999 this operation can be noticably time consuming. You have the option of-
5000 reimplementing this function in a subclass of QGraphicsItem to provide a-
5001 custom algorithm. This allows you to make use of natural constraints in-
5002 the shapes of your own items, in order to improve the performance of the-
5003 collision detection. For instance, two untransformed perfectly circular-
5004 items' collision can be determined very efficiently by comparing their-
5005 positions and radii.-
5006-
5007 Keep in mind that when reimplementing this function and calling shape() or-
5008 boundingRect() on \a other, the returned coordinates must be mapped to-
5009 this item's coordinate system before any intersection can take place.-
5010-
5011 \sa contains(), shape()-
5012*/-
5013bool QGraphicsItem::collidesWithItem(const QGraphicsItem *other, Qt::ItemSelectionMode mode) const-
5014{-
5015 if (other == this)
other == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
5016 return true;
never executed: return true;
0
5017 if (!other)
!otherDescription
TRUEnever evaluated
FALSEnever evaluated
0
5018 return false;
never executed: return false;
0
5019 // The items share the same clip if their closest clipper is the same, or-
5020 // if one clips the other.-
5021 bool clips = (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren);-
5022 bool otherClips = (other->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren);-
5023 if (clips || otherClips) {
clipsDescription
TRUEnever evaluated
FALSEnever evaluated
otherClipsDescription
TRUEnever evaluated
FALSEnever evaluated
0
5024 const QGraphicsItem *closestClipper = isAncestorOf(other) ? this : parentItem();
isAncestorOf(other)Description
TRUEnever evaluated
FALSEnever evaluated
0
5025 while (closestClipper && !(closestClipper->flags() & ItemClipsChildrenToShape))
closestClipperDescription
TRUEnever evaluated
FALSEnever evaluated
!(closestClipp...ildrenToShape)Description
TRUEnever evaluated
FALSEnever evaluated
0
5026 closestClipper = closestClipper->parentItem();
never executed: closestClipper = closestClipper->parentItem();
0
5027 const QGraphicsItem *otherClosestClipper = other->isAncestorOf(this) ? other : other->parentItem();
other->isAncestorOf(this)Description
TRUEnever evaluated
FALSEnever evaluated
0
5028 while (otherClosestClipper && !(otherClosestClipper->flags() & ItemClipsChildrenToShape))
otherClosestClipperDescription
TRUEnever evaluated
FALSEnever evaluated
!(otherClosest...ildrenToShape)Description
TRUEnever evaluated
FALSEnever evaluated
0
5029 otherClosestClipper = otherClosestClipper->parentItem();
never executed: otherClosestClipper = otherClosestClipper->parentItem();
0
5030 if (closestClipper == otherClosestClipper) {
closestClipper...ClosestClipperDescription
TRUEnever evaluated
FALSEnever evaluated
0
5031 d_ptr->localCollisionHack = 1;-
5032 bool res = collidesWithPath(mapFromItem(other, other->shape()), mode);-
5033 d_ptr->localCollisionHack = 0;-
5034 return res;
never executed: return res;
0
5035 }-
5036 }
never executed: end of block
0
5037-
5038 QPainterPath otherShape = other->isClipped() ? other->clipPath() : other->shape();
other->isClipped()Description
TRUEnever evaluated
FALSEnever evaluated
0
5039 return collidesWithPath(mapFromItem(other, otherShape), mode);
never executed: return collidesWithPath(mapFromItem(other, otherShape), mode);
0
5040}-
5041-
5042/*!-
5043 Returns \c true if this item collides with \a path.-
5044-
5045 The collision is determined by \a mode. The default value for \a mode is-
5046 Qt::IntersectsItemShape; \a path collides with this item if it either-
5047 intersects, contains, or is contained by this item's shape.-
5048-
5049 Note that this function checks whether the item's shape or-
5050 bounding rectangle (depending on \a mode) is contained within \a-
5051 path, and not whether \a path is contained within the items shape-
5052 or bounding rectangle.-
5053-
5054 \sa collidesWithItem(), contains(), shape()-
5055*/-
5056bool QGraphicsItem::collidesWithPath(const QPainterPath &path, Qt::ItemSelectionMode mode) const-
5057{-
5058 if (path.isEmpty()) {
path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
5059 // No collision with empty paths.-
5060 return false;
never executed: return false;
0
5061 }-
5062-
5063 QRectF rectA(boundingRect());-
5064 _q_adjustRect(&rectA);-
5065 QRectF rectB(path.controlPointRect());-
5066 _q_adjustRect(&rectB);-
5067 if (!rectA.intersects(rectB)) {
!rectA.intersects(rectB)Description
TRUEnever evaluated
FALSEnever evaluated
0
5068 // This we can determine efficiently. If the two rects neither-
5069 // intersect nor contain eachother, then the two items do not collide.-
5070 return false;
never executed: return false;
0
5071 }-
5072-
5073 // For further testing, we need this item's shape or bounding rect.-
5074 QPainterPath thisShape;-
5075 if (mode == Qt::IntersectsItemShape || mode == Qt::ContainsItemShape)
mode == Qt::In...sectsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::ContainsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
5076 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
5077 else-
5078 thisShape.addRect(rectA);
never executed: thisShape.addRect(rectA);
0
5079-
5080 if (thisShape == QPainterPath()) {
thisShape == QPainterPath()Description
TRUEnever evaluated
FALSEnever evaluated
0
5081 // Empty shape? No collision.-
5082 return false;
never executed: return false;
0
5083 }-
5084-
5085 // Use QPainterPath boolean operations to determine the collision, O(N*logN).-
5086 if (mode == Qt::IntersectsItemShape || mode == Qt::IntersectsItemBoundingRect)
mode == Qt::In...sectsItemShapeDescription
TRUEnever evaluated
FALSEnever evaluated
mode == Qt::In...emBoundingRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
5087 return path.intersects(thisShape);
never executed: return path.intersects(thisShape);
0
5088 return path.contains(thisShape);
never executed: return path.contains(thisShape);
0
5089}-
5090-
5091/*!-
5092 Returns a list of all items that collide with this item.-
5093-
5094 The way collisions are detected is determined by applying \a mode-
5095 to items that are compared to this item, i.e., each item's shape-
5096 or bounding rectangle is checked against this item's shape. The-
5097 default value for \a mode is Qt::IntersectsItemShape.-
5098-
5099 \sa collidesWithItem()-
5100*/-
5101QList<QGraphicsItem *> QGraphicsItem::collidingItems(Qt::ItemSelectionMode mode) const-
5102{-
5103 if (d_ptr->scene)
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
5104 return d_ptr->scene->collidingItems(this, mode);
never executed: return d_ptr->scene->collidingItems(this, mode);
0
5105 return QList<QGraphicsItem *>();
never executed: return QList<QGraphicsItem *>();
0
5106}-
5107-
5108/*!-
5109 \internal-
5110-
5111 Item obscurity helper function.-
5112-
5113 Returns \c true if the subrect \a rect of \a item's bounding rect is obscured-
5114 by \a other (i.e., \a other's opaque area covers \a item's \a rect-
5115 completely. \a other is assumed to already be "on top of" \a item-
5116 wrt. stacking order.-
5117*/-
5118static bool qt_QGraphicsItem_isObscured(const QGraphicsItem *item,-
5119 const QGraphicsItem *other,-
5120 const QRectF &rect)-
5121{-
5122 return other->mapToItem(item, other->opaqueArea()).contains(rect);
never executed: return other->mapToItem(item, other->opaqueArea()).contains(rect);
0
5123}-
5124-
5125/*!-
5126 \overload-
5127 \since 4.3-
5128-
5129 Returns \c true if \a rect is completely obscured by the opaque shape of any-
5130 of colliding items above it (i.e., with a higher Z value than this item).-
5131-
5132 \sa opaqueArea()-
5133*/-
5134bool QGraphicsItem::isObscured(const QRectF &rect) const-
5135{-
5136 Q_D(const QGraphicsItem);-
5137 if (!d->scene)
!d->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
5138 return false;
never executed: return false;
0
5139-
5140 QRectF br = boundingRect();-
5141 QRectF testRect = rect.isNull() ? br : rect;
rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
5142-
5143 foreach (QGraphicsItem *item, d->scene->items(mapToScene(br), Qt::IntersectsItemBoundingRect)) {-
5144 if (item == this)
item == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
5145 break;
never executed: break;
0
5146 if (qt_QGraphicsItem_isObscured(this, item, testRect))
qt_QGraphicsIt...tem, testRect)Description
TRUEnever evaluated
FALSEnever evaluated
0
5147 return true;
never executed: return true;
0
5148 }
never executed: end of block
0
5149 return false;
never executed: return false;
0
5150}-
5151-
5152/*!-
5153 \fn bool QGraphicsItem::isObscured(qreal x, qreal y, qreal w, qreal h) const-
5154 \overload-
5155 \since 4.3-
5156-
5157 This convenience function is equivalent to calling isObscured(QRectF(\a x, \a y, \a w, \a h)).-
5158*/-
5159-
5160/*!-
5161 Returns \c true if this item's bounding rect is completely obscured by the-
5162 opaque shape of \a item.-
5163-
5164 The base implementation maps \a item's opaqueArea() to this item's-
5165 coordinate system, and then checks if this item's boundingRect() is fully-
5166 contained within the mapped shape.-
5167-
5168 You can reimplement this function to provide a custom algorithm for-
5169 determining whether this item is obscured by \a item.-
5170-
5171 \sa opaqueArea(), isObscured()-
5172*/-
5173bool QGraphicsItem::isObscuredBy(const QGraphicsItem *item) const-
5174{-
5175 if (!item)
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
5176 return false;
never executed: return false;
0
5177 return qt_closestItemFirst(item, this)
never executed: return qt_closestItemFirst(item, this) && qt_QGraphicsItem_isObscured(this, item, boundingRect());
qt_closestItem...st(item, this)Description
TRUEnever evaluated
FALSEnever evaluated
0
5178 && qt_QGraphicsItem_isObscured(this, item, boundingRect());
never executed: return qt_closestItemFirst(item, this) && qt_QGraphicsItem_isObscured(this, item, boundingRect());
qt_QGraphicsIt...oundingRect())Description
TRUEnever evaluated
FALSEnever evaluated
0
5179}-
5180-
5181/*!-
5182 This virtual function returns a shape representing the area where this-
5183 item is opaque. An area is opaque if it is filled using an opaque brush or-
5184 color (i.e., not transparent).-
5185-
5186 This function is used by isObscuredBy(), which is called by underlying-
5187 items to determine if they are obscured by this item.-
5188-
5189 The default implementation returns an empty QPainterPath, indicating that-
5190 this item is completely transparent and does not obscure any other items.-
5191-
5192 \sa isObscuredBy(), isObscured(), shape()-
5193*/-
5194QPainterPath QGraphicsItem::opaqueArea() const-
5195{-
5196 return QPainterPath();
never executed: return QPainterPath();
0
5197}-
5198-
5199/*!-
5200 \since 4.4-
5201-
5202 Returns the bounding region for this item. The coordinate space of the-
5203 returned region depends on \a itemToDeviceTransform. If you pass an-
5204 identity QTransform as a parameter, this function will return a local-
5205 coordinate region.-
5206-
5207 The bounding region describes a coarse outline of the item's visual-
5208 contents. Although it's expensive to calculate, it's also more precise-
5209 than boundingRect(), and it can help to avoid unnecessary repainting when-
5210 an item is updated. This is particularly efficient for thin items (e.g.,-
5211 lines or simple polygons). You can tune the granularity for the bounding-
5212 region by calling setBoundingRegionGranularity(). The default granularity-
5213 is 0; in which the item's bounding region is the same as its bounding-
5214 rect.-
5215-
5216 \a itemToDeviceTransform is the transformation from item coordinates to-
5217 device coordinates. If you want this function to return a QRegion in scene-
5218 coordinates, you can pass sceneTransform() as an argument.-
5219-
5220 \sa boundingRegionGranularity()-
5221*/-
5222QRegion QGraphicsItem::boundingRegion(const QTransform &itemToDeviceTransform) const-
5223{-
5224 // ### Ideally we would have a better way to generate this region,-
5225 // preferably something in the lines of QPainterPath::toRegion(QTransform)-
5226 // coupled with a way to generate a painter path from a set of painter-
5227 // operations (e.g., QPicture::toPainterPath() or so). The current-
5228 // approach generates a bitmap with the size of the item's bounding rect-
5229 // in device coordinates, scaled by b.r.granularity, then paints the item-
5230 // into the bitmap, converts the result to a QRegion and scales the region-
5231 // back to device space with inverse granularity.-
5232 qreal granularity = boundingRegionGranularity();-
5233 QRect deviceRect = itemToDeviceTransform.mapRect(boundingRect()).toRect();-
5234 _q_adjustRect(&deviceRect);-
5235 if (granularity == 0.0)
granularity == 0.0Description
TRUEnever evaluated
FALSEnever evaluated
0
5236 return QRegion(deviceRect);
never executed: return QRegion(deviceRect);
0
5237-
5238 int pad = 1;-
5239 QSize bitmapSize(qMax(1, int(deviceRect.width() * granularity) + pad * 2),-
5240 qMax(1, int(deviceRect.height() * granularity) + pad * 2));-
5241 QImage mask(bitmapSize, QImage::Format_ARGB32_Premultiplied);-
5242 mask.fill(0);-
5243 QPainter p(&mask);-
5244 p.setRenderHints(QPainter::Antialiasing);-
5245-
5246 // Transform painter (### this code is from QGraphicsScene::drawItemHelper-
5247 // and doesn't work properly with perspective transformations).-
5248 QPointF viewOrigo = itemToDeviceTransform.map(QPointF(0, 0));-
5249 QPointF offset = viewOrigo - deviceRect.topLeft();-
5250 p.scale(granularity, granularity);-
5251 p.translate(offset);-
5252 p.translate(pad, pad);-
5253 p.setWorldTransform(itemToDeviceTransform, true);-
5254 p.translate(itemToDeviceTransform.inverted().map(QPointF(0, 0)));-
5255-
5256 // Render-
5257 QStyleOptionGraphicsItem option;-
5258 const_cast<QGraphicsItem *>(this)->paint(&p, &option, 0);-
5259 p.end();-
5260-
5261 // Transform QRegion back to device space-
5262 QTransform unscale = QTransform::fromScale(1 / granularity, 1 / granularity);-
5263 QRegion r;-
5264 QBitmap colorMask = QBitmap::fromImage(mask.createMaskFromColor(0));-
5265 foreach (const QRect &rect, QRegion( colorMask ).rects()) {-
5266 QRect xrect = unscale.mapRect(rect).translated(deviceRect.topLeft() - QPoint(pad, pad));-
5267 r += xrect.adjusted(-1, -1, 1, 1) & deviceRect;-
5268 }
never executed: end of block
0
5269 return r;
never executed: return r;
0
5270}-
5271-
5272/*!-
5273 \since 4.4-
5274-
5275 Returns the item's bounding region granularity; a value between and-
5276 including 0 and 1. The default value is 0 (i.e., the lowest granularity,-
5277 where the bounding region corresponds to the item's bounding rectangle).-
5278-
5279\omit-
5280### NOTE-
5281\endomit-
5282-
5283 \sa setBoundingRegionGranularity()-
5284*/-
5285qreal QGraphicsItem::boundingRegionGranularity() const-
5286{-
5287 return d_ptr->hasBoundingRegionGranularity
never executed: return d_ptr->hasBoundingRegionGranularity ? qvariant_cast<qreal>(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity)) : 0;
d_ptr->hasBoun...ionGranularityDescription
TRUEnever evaluated
FALSEnever evaluated
0
5288 ? qvariant_cast<qreal>(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity))
never executed: return d_ptr->hasBoundingRegionGranularity ? qvariant_cast<qreal>(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity)) : 0;
0
5289 : 0;
never executed: return d_ptr->hasBoundingRegionGranularity ? qvariant_cast<qreal>(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity)) : 0;
0
5290}-
5291-
5292/*!-
5293 \since 4.4-
5294 Sets the bounding region granularity to \a granularity; a value between-
5295 and including 0 and 1. The default value is 0 (i.e., the lowest-
5296 granularity, where the bounding region corresponds to the item's bounding-
5297 rectangle).-
5298-
5299 The granularity is used by boundingRegion() to calculate how fine the-
5300 bounding region of the item should be. The highest achievable granularity-
5301 is 1, where boundingRegion() will return the finest outline possible for-
5302 the respective device (e.g., for a QGraphicsView viewport, this gives you-
5303 a pixel-perfect bounding region). The lowest possible granularity is-
5304 0. The value of \a granularity describes the ratio between device-
5305 resolution and the resolution of the bounding region (e.g., a value of-
5306 0.25 will provide a region where each chunk corresponds to 4x4 device-
5307 units / pixels).-
5308-
5309 \sa boundingRegionGranularity()-
5310*/-
5311void QGraphicsItem::setBoundingRegionGranularity(qreal granularity)-
5312{-
5313 if (granularity < 0.0 || granularity > 1.0) {
granularity < 0.0Description
TRUEnever evaluated
FALSEnever evaluated
granularity > 1.0Description
TRUEnever evaluated
FALSEnever evaluated
0
5314 qWarning("QGraphicsItem::setBoundingRegionGranularity: invalid granularity %g", granularity);-
5315 return;
never executed: return;
0
5316 }-
5317 if (granularity == 0.0) {
granularity == 0.0Description
TRUEnever evaluated
FALSEnever evaluated
0
5318 d_ptr->unsetExtra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity);-
5319 d_ptr->hasBoundingRegionGranularity = 0;-
5320 return;
never executed: return;
0
5321 }-
5322 d_ptr->hasBoundingRegionGranularity = 1;-
5323 d_ptr->setExtra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity,-
5324 QVariant::fromValue<qreal>(granularity));-
5325}
never executed: end of block
0
5326-
5327/*!-
5328 \fn virtual void QGraphicsItem::paint(QPainter *painter, const-
5329 QStyleOptionGraphicsItem *option, QWidget *widget = 0) = 0-
5330-
5331 This function, which is usually called by QGraphicsView, paints the-
5332 contents of an item in local coordinates.-
5333-
5334 Reimplement this function in a QGraphicsItem subclass to provide the-
5335 item's painting implementation, using \a painter. The \a option parameter-
5336 provides style options for the item, such as its state, exposed area and-
5337 its level-of-detail hints. The \a widget argument is optional. If-
5338 provided, it points to the widget that is being painted on; otherwise, it-
5339 is 0. For cached painting, \a widget is always 0.-
5340-
5341 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 10-
5342-
5343 The painter's pen is 0-width by default, and its pen is initialized to the-
5344 QPalette::Text brush from the paint device's palette. The brush is-
5345 initialized to QPalette::Window.-
5346-
5347 Make sure to constrain all painting inside the boundaries of-
5348 boundingRect() to avoid rendering artifacts (as QGraphicsView does not-
5349 clip the painter for you). In particular, when QPainter renders the-
5350 outline of a shape using an assigned QPen, half of the outline will be-
5351 drawn outside, and half inside, the shape you're rendering (e.g., with a-
5352 pen width of 2 units, you must draw outlines 1 unit inside-
5353 boundingRect()). QGraphicsItem does not support use of cosmetic pens with-
5354 a non-zero width.-
5355-
5356 All painting is done in local coordinates.-
5357-
5358 \note It is mandatory that an item will always redraw itself in the exact-
5359 same way, unless update() was called; otherwise visual artifacts may-
5360 occur. In other words, two subsequent calls to paint() must always produce-
5361 the same output, unless update() was called between them.-
5362-
5363 \note Enabling caching for an item does not guarantee that paint()-
5364 will be invoked only once by the Graphics View framework,-
5365 even without any explicit call to update(). See the documentation of-
5366 setCacheMode() for more details.-
5367-
5368 \sa setCacheMode(), QPen::width(), {Item Coordinates}, ItemUsesExtendedStyleOption-
5369*/-
5370-
5371/*!-
5372 \internal-
5373 Returns \c true if we can discard an update request; otherwise false.-
5374*/-
5375bool QGraphicsItemPrivate::discardUpdateRequest(bool ignoreVisibleBit, bool ignoreDirtyBit,-
5376 bool ignoreOpacity) const-
5377{-
5378 // No scene, or if the scene is updating everything, means we have nothing-
5379 // to do. The only exception is if the scene tracks the growing scene rect.-
5380 return !scene
never executed: return !scene || (!visible && !ignoreVisibleBit && !this->ignoreVisible) || (!ignoreDirtyBit && fullUpdatePending) || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent());
!sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
5381 || (!visible && !ignoreVisibleBit && !this->ignoreVisible)
never executed: return !scene || (!visible && !ignoreVisibleBit && !this->ignoreVisible) || (!ignoreDirtyBit && fullUpdatePending) || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent());
!visibleDescription
TRUEnever evaluated
FALSEnever evaluated
!ignoreVisibleBitDescription
TRUEnever evaluated
FALSEnever evaluated
!this->ignoreVisibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
5382 || (!ignoreDirtyBit && fullUpdatePending)
never executed: return !scene || (!visible && !ignoreVisibleBit && !this->ignoreVisible) || (!ignoreDirtyBit && fullUpdatePending) || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent());
!ignoreDirtyBitDescription
TRUEnever evaluated
FALSEnever evaluated
fullUpdatePendingDescription
TRUEnever evaluated
FALSEnever evaluated
0
5383 || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent());
never executed: return !scene || (!visible && !ignoreVisibleBit && !this->ignoreVisible) || (!ignoreDirtyBit && fullUpdatePending) || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent());
!ignoreOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
!this->ignoreOpacityDescription
TRUEnever evaluated
FALSEnever evaluated
childrenCombineOpacity()Description
TRUEnever evaluated
FALSEnever evaluated
isFullyTransparent()Description
TRUEnever evaluated
FALSEnever evaluated
0
5384}-
5385-
5386/*!-
5387 \internal-
5388*/-
5389int QGraphicsItemPrivate::depth() const-
5390{-
5391 if (itemDepth == -1)
itemDepth == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
5392 const_cast<QGraphicsItemPrivate *>(this)->resolveDepth();
never executed: const_cast<QGraphicsItemPrivate *>(this)->resolveDepth();
0
5393-
5394 return itemDepth;
never executed: return itemDepth;
0
5395}-
5396-
5397/*!-
5398 \internal-
5399*/-
5400#ifndef QT_NO_GRAPHICSEFFECT-
5401void QGraphicsItemPrivate::invalidateParentGraphicsEffectsRecursively()-
5402{-
5403 QGraphicsItemPrivate *itemPrivate = this;-
5404 do {-
5405 if (itemPrivate->graphicsEffect) {
itemPrivate->graphicsEffectDescription
TRUEnever evaluated
FALSEnever evaluated
0
5406 itemPrivate->notifyInvalidated = 1;-
5407-
5408 if (!itemPrivate->updateDueToGraphicsEffect)
!itemPrivate->...GraphicsEffectDescription
TRUEnever evaluated
FALSEnever evaluated
0
5409 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
5410 }
never executed: end of block
0
5411 } 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
5412}
never executed: end of block
0
5413-
5414void QGraphicsItemPrivate::invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::InvalidateReason reason)-
5415{-
5416 if (!mayHaveChildWithGraphicsEffect)
!mayHaveChildW...GraphicsEffectDescription
TRUEnever evaluated
FALSEnever evaluated
0
5417 return;
never executed: return;
0
5418-
5419 for (int i = 0; i < children.size(); ++i) {
i < children.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
5420 QGraphicsItemPrivate *childPrivate = children.at(i)->d_ptr.data();-
5421 if (reason == OpacityChanged && (childPrivate->flags & QGraphicsItem::ItemIgnoresParentOpacity))
reason == OpacityChangedDescription
TRUEnever evaluated
FALSEnever evaluated
(childPrivate-...ParentOpacity)Description
TRUEnever evaluated
FALSEnever evaluated
0
5422 continue;
never executed: continue;
0
5423 if (childPrivate->graphicsEffect) {
childPrivate->graphicsEffectDescription
TRUEnever evaluated
FALSEnever evaluated
0
5424 childPrivate->notifyInvalidated = 1;-
5425 static_cast<QGraphicsItemEffectSourcePrivate *>(childPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache();-
5426 }
never executed: end of block
0
5427-
5428 childPrivate->invalidateChildGraphicsEffectsRecursively(reason);-
5429 }
never executed: end of block
0
5430}
never executed: end of block
0
5431#endif //QT_NO_GRAPHICSEFFECT-
5432-
5433/*!-
5434 \internal-
5435*/-
5436void QGraphicsItemPrivate::invalidateDepthRecursively()-
5437{-
5438 if (itemDepth == -1)
itemDepth == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
5439 return;
never executed: return;
0
5440-
5441 itemDepth = -1;-
5442 for (int i = 0; i < children.size(); ++i)
i < children.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
5443 children.at(i)->d_ptr->invalidateDepthRecursively();
never executed: children.at(i)->d_ptr->invalidateDepthRecursively();
0
5444}
never executed: end of block
0
5445-
5446/*!-
5447 \internal-
5448-
5449 Resolves the stacking depth of this object and all its ancestors.-
5450*/-
5451void QGraphicsItemPrivate::resolveDepth()-
5452{-
5453 if (!parent)
!parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
5454 itemDepth = 0;
never executed: itemDepth = 0;
0
5455 else {-
5456 if (parent->d_ptr->itemDepth == -1)
parent->d_ptr->itemDepth == -1Description
TRUEnever evaluated
FALSEnever evaluated
0
5457 parent->d_ptr->resolveDepth();
never executed: parent->d_ptr->resolveDepth();
0
5458 itemDepth = parent->d_ptr->itemDepth + 1;-
5459 }
never executed: end of block
0
5460}-
5461-
5462/*!-
5463 \internal-
5464-
5465 ### This function is almost identical to-
5466 QGraphicsScenePrivate::registerTopLevelItem().-
5467*/-
5468void QGraphicsItemPrivate::addChild(QGraphicsItem *child)-
5469{-
5470 // Remove all holes from the sibling index list. Now the max index-
5471 // number is equal to the size of the children list.-
5472 ensureSequentialSiblingIndex();-
5473 needSortChildren = 1; // ### maybe 0-
5474 child->d_ptr->siblingIndex = children.size();-
5475 children.append(child);-
5476 if (isObject)
isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
5477 emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged();
never executed: static_cast<QGraphicsObject *>(q_ptr)->childrenChanged();
0
5478}
never executed: end of block
0
5479-
5480/*!-
5481 \internal-
5482-
5483 ### This function is almost identical to-
5484 QGraphicsScenePrivate::unregisterTopLevelItem().-
5485*/-
5486void QGraphicsItemPrivate::removeChild(QGraphicsItem *child)-
5487{-
5488 // When removing elements in the middle of the children list,-
5489 // there will be a "gap" in the list of sibling indexes (0,1,3,4).-
5490 if (!holesInSiblingIndex)
!holesInSiblingIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
5491 holesInSiblingIndex = child->d_ptr->siblingIndex != children.size() - 1;
never executed: holesInSiblingIndex = child->d_ptr->siblingIndex != children.size() - 1;
0
5492 if (sequentialOrdering && !holesInSiblingIndex)
sequentialOrderingDescription
TRUEnever evaluated
FALSEnever evaluated
!holesInSiblingIndexDescription
TRUEnever evaluated
FALSEnever evaluated
0
5493 children.removeAt(child->d_ptr->siblingIndex);
never executed: children.removeAt(child->d_ptr->siblingIndex);
0
5494 else-
5495 children.removeOne(child);
never executed: children.removeOne(child);
0
5496 // NB! Do not use children.removeAt(child->d_ptr->siblingIndex) because-
5497 // the child is not guaranteed to be at the index after the list is sorted.-
5498 // (see ensureSortedChildren()).-
5499 child->d_ptr->siblingIndex = -1;-
5500 if (isObject)
isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
5501 emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged();
never executed: static_cast<QGraphicsObject *>(q_ptr)->childrenChanged();
0
5502}
never executed: end of block
0
5503-
5504/*!-
5505 \internal-
5506*/-
5507QGraphicsItemCache *QGraphicsItemPrivate::maybeExtraItemCache() const-
5508{-
5509 return (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
never executed: return (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));
0
5510}-
5511-
5512/*!-
5513 \internal-
5514*/-
5515QGraphicsItemCache *QGraphicsItemPrivate::extraItemCache() const-
5516{-
5517 QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));-
5518 if (!c) {
!cDescription
TRUEnever evaluated
FALSEnever evaluated
0
5519 QGraphicsItemPrivate *that = const_cast<QGraphicsItemPrivate *>(this);-
5520 c = new QGraphicsItemCache;-
5521 that->setExtra(ExtraCacheData, QVariant::fromValue<void *>(c));-
5522 }
never executed: end of block
0
5523 return c;
never executed: return c;
0
5524}-
5525-
5526/*!-
5527 \internal-
5528*/-
5529void QGraphicsItemPrivate::removeExtraItemCache()-
5530{-
5531 QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData));-
5532 if (c) {
cDescription
TRUEnever evaluated
FALSEnever evaluated
0
5533 c->purge();-
5534 delete c;-
5535 }
never executed: end of block
0
5536 unsetExtra(ExtraCacheData);-
5537}
never executed: end of block
0
5538-
5539void QGraphicsItemPrivate::updatePaintedViewBoundingRects(bool updateChildren)-
5540{-
5541 if (!scene)
!sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
5542 return;
never executed: return;
0
5543-
5544 for (int i = 0; i < scene->d_func()->views.size(); ++i) {
i < scene->d_f...->views.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
5545 QGraphicsViewPrivate *viewPrivate = scene->d_func()->views.at(i)->d_func();-
5546 QRect rect = paintedViewBoundingRects.value(viewPrivate->viewport);-
5547 rect.translate(viewPrivate->dirtyScrollOffset);-
5548 viewPrivate->updateRect(rect);-
5549 }
never executed: end of block
0
5550-
5551 if (updateChildren) {
updateChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
5552 for (int i = 0; i < children.size(); ++i)
i < children.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
5553 children.at(i)->d_ptr->updatePaintedViewBoundingRects(true);
never executed: children.at(i)->d_ptr->updatePaintedViewBoundingRects(true);
0
5554 }
never executed: end of block
0
5555}
never executed: end of block
0
5556-
5557// Traverses all the ancestors up to the top-level and updates the pointer to-
5558// always point to the top-most item that has a dirty scene transform.-
5559// It then backtracks to the top-most dirty item and start calculating the-
5560// scene transform by combining the item's transform (+pos) with the parent's-
5561// cached scene transform (which we at this point know for sure is valid).-
5562void QGraphicsItemPrivate::ensureSceneTransformRecursive(QGraphicsItem **topMostDirtyItem)-
5563{-
5564 Q_ASSERT(topMostDirtyItem);-
5565-
5566 if (dirtySceneTransform)
dirtySceneTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
5567 *topMostDirtyItem = q_ptr;
never executed: *topMostDirtyItem = q_ptr;
0
5568-
5569 if (parent)
parentDescription
TRUEnever evaluated
FALSEnever evaluated
0
5570 parent->d_ptr->ensureSceneTransformRecursive(topMostDirtyItem);
never executed: parent->d_ptr->ensureSceneTransformRecursive(topMostDirtyItem);
0
5571-
5572 if (*topMostDirtyItem == q_ptr) {
*topMostDirtyItem == q_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
5573 if (!dirtySceneTransform)
!dirtySceneTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
5574 return; // OK, neither my ancestors nor I have dirty scene transforms.
never executed: return;
0
5575 *topMostDirtyItem = 0;-
5576 } else if (*topMostDirtyItem) {
never executed: end of block
*topMostDirtyItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
5577 return; // Continue backtrack.
never executed: return;
0
5578 }-
5579-
5580 // This item and all its descendants have dirty scene transforms.-
5581 // We're about to validate this item's scene transform, so we have to-
5582 // invalidate all the children; otherwise there's no way for the descendants-
5583 // to detect that the ancestor has changed.-
5584 invalidateChildrenSceneTransform();-
5585-
5586 // COMBINE my transform with the parent's scene transform.-
5587 updateSceneTransformFromParent();-
5588 Q_ASSERT(!dirtySceneTransform);-
5589}
never executed: end of block
0
5590-
5591/*!-
5592 \internal-
5593*/-
5594void QGraphicsItemPrivate::setSubFocus(QGraphicsItem *rootItem, QGraphicsItem *stopItem)-
5595{-
5596 // Update focus child chain. Stop at panels, or if this item-
5597 // is hidden, stop at the first item with a visible parent.-
5598 QGraphicsItem *parent = rootItem ? rootItem : q_ptr;
rootItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
5599 if (parent->panel() != q_ptr->panel())
parent->panel(...q_ptr->panel()Description
TRUEnever evaluated
FALSEnever evaluated
0
5600 return;
never executed: return;
0
5601-
5602 do {-
5603 // Clear any existing ancestor's subFocusItem.-
5604 if (parent != q_ptr && parent->d_ptr->subFocusItem) {
parent != q_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
parent->d_ptr->subFocusItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
5605 if (parent->d_ptr->subFocusItem == q_ptr)
parent->d_ptr-...sItem == q_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
5606 break;
never executed: break;
0
5607 parent->d_ptr->subFocusItem->d_ptr->clearSubFocus(0, stopItem);-
5608 }
never executed: end of block
0
5609 parent->d_ptr->subFocusItem = q_ptr;-
5610 parent->d_ptr->subFocusItemChange();-
5611 } 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
5612-
5613 if (scene && !scene->isActive()) {
sceneDescription
TRUEnever evaluated
FALSEnever evaluated
!scene->isActive()Description
TRUEnever evaluated
FALSEnever evaluated
0
5614 scene->d_func()->passiveFocusItem = subFocusItem;-
5615 scene->d_func()->lastFocusItem = subFocusItem;-
5616 }
never executed: end of block
0
5617}
never executed: end of block
0
5618-
5619/*!-
5620 \internal-
5621*/-
5622void QGraphicsItemPrivate::clearSubFocus(QGraphicsItem *rootItem, QGraphicsItem *stopItem)-
5623{-
5624 // Reset sub focus chain.-
5625 QGraphicsItem *parent = rootItem ? rootItem : q_ptr;
rootItemDescription
TRUEnever evaluated
FALSEnever evaluated
0
5626 do {-
5627 if (parent->d_ptr->subFocusItem != q_ptr)
parent->d_ptr-...sItem != q_ptrDescription
TRUEnever evaluated
FALSEnever evaluated
0
5628 break;
never executed: break;
0
5629 parent->d_ptr->subFocusItem = 0;-
5630 if (parent != stopItem && !parent->isAncestorOf(stopItem))
parent != stopItemDescription
TRUEnever evaluated
FALSEnever evaluated
!parent->isAnc...orOf(stopItem)Description
TRUEnever evaluated
FALSEnever evaluated
0
5631 parent->d_ptr->subFocusItemChange();
never executed: parent->d_ptr->subFocusItemChange();
0
5632 } 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
5633}
never executed: end of block
0
5634-
5635/*!-
5636 \internal-
5637-
5638 Sets the focusProxy pointer to 0 for all items that have this item as their-
5639 focusProxy.-
5640*/-
5641void QGraphicsItemPrivate::resetFocusProxy()-
5642{-
5643 for (int i = 0; i < focusProxyRefs.size(); ++i)
i < focusProxyRefs.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
5644 *focusProxyRefs.at(i) = 0;
never executed: *focusProxyRefs.at(i) = 0;
0
5645 focusProxyRefs.clear();-
5646}
never executed: end of block
0
5647-
5648/*!-
5649 \internal-
5650-
5651 Subclasses can reimplement this function to be notified when subFocusItem-
5652 changes.-
5653*/-
5654void QGraphicsItemPrivate::subFocusItemChange()-
5655{-
5656}-
5657-
5658/*!-
5659 \internal-
5660-
5661 Subclasses can reimplement this function to be notified when an item-
5662 becomes a focusScopeItem (or is no longer a focusScopeItem).-
5663*/-
5664void QGraphicsItemPrivate::focusScopeItemChange(bool isSubFocusItem)-
5665{-
5666 Q_UNUSED(isSubFocusItem);-
5667}
never executed: end of block
0
5668-
5669/*!-
5670 \internal-
5671-
5672 Subclasses can reimplement this function to be notified when its-
5673 siblingIndex order is changed.-
5674*/-
5675void QGraphicsItemPrivate::siblingOrderChange()-
5676{-
5677}-
5678-
5679/*!-
5680 \internal-
5681-
5682 Tells us if it is a proxy widget-
5683*/-
5684bool QGraphicsItemPrivate::isProxyWidget() const-
5685{-
5686 return false;
never executed: return false;
0
5687}-
5688-
5689/*!-
5690 Schedules a redraw of the area covered by \a rect in this item. You can-
5691 call this function whenever your item needs to be redrawn, such as if it-
5692 changes appearance or size.-
5693-
5694 This function does not cause an immediate paint; instead it schedules a-
5695 paint request that is processed by QGraphicsView after control reaches the-
5696 event loop. The item will only be redrawn if it is visible in any-
5697 associated view.-
5698-
5699 As a side effect of the item being repainted, other items that overlap the-
5700 area \a rect may also be repainted.-
5701-
5702 If the item is invisible (i.e., isVisible() returns \c false), this function-
5703 does nothing.-
5704-
5705 \sa paint(), boundingRect()-
5706*/-
5707void QGraphicsItem::update(const QRectF &rect)-
5708{-
5709 if (rect.isEmpty() && !rect.isNull())
rect.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
!rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
5710 return;
never executed: return;
0
5711-
5712 // Make sure we notify effects about invalidated source.-
5713#ifndef QT_NO_GRAPHICSEFFECT-
5714 d_ptr->invalidateParentGraphicsEffectsRecursively();-
5715#endif //QT_NO_GRAPHICSEFFECT-
5716-
5717 if (CacheMode(d_ptr->cacheMode) != NoCache) {
CacheMode(d_pt...de) != NoCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
5718 // Invalidate cache.-
5719 QGraphicsItemCache *cache = d_ptr->extraItemCache();-
5720 if (!cache->allExposed) {
!cache->allExposedDescription
TRUEnever evaluated
FALSEnever evaluated
0
5721 if (rect.isNull()) {
rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
5722 cache->allExposed = true;-
5723 cache->exposed.clear();-
5724 } else {
never executed: end of block
0
5725 cache->exposed.append(rect);-
5726 }
never executed: end of block
0
5727 }-
5728 // Only invalidate cache; item is already dirty.-
5729 if (d_ptr->fullUpdatePending)
d_ptr->fullUpdatePendingDescription
TRUEnever evaluated
FALSEnever evaluated
0
5730 return;
never executed: return;
0
5731 }
never executed: end of block
0
5732-
5733 if (d_ptr->scene)
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
5734 d_ptr->scene->d_func()->markDirty(this, rect);
never executed: d_ptr->scene->d_func()->markDirty(this, rect);
0
5735}
never executed: end of block
0
5736-
5737/*!-
5738 \since 4.4-
5739 Scrolls the contents of \a rect by \a dx, \a dy. If \a rect is a null rect-
5740 (the default), the item's bounding rect is scrolled.-
5741-
5742 Scrolling provides a fast alternative to simply redrawing when the-
5743 contents of the item (or parts of the item) are shifted vertically or-
5744 horizontally. Depending on the current transformation and the capabilities-
5745 of the paint device (i.e., the viewport), this operation may consist of-
5746 simply moving pixels from one location to another using memmove(). In most-
5747 cases this is faster than rerendering the entire area.-
5748-
5749 After scrolling, the item will issue an update for the newly exposed-
5750 areas. If scrolling is not supported (e.g., you are rendering to an OpenGL-
5751 viewport, which does not benefit from scroll optimizations), this function-
5752 is equivalent to calling update(\a rect).-
5753-
5754 \b{Note:} Scrolling is only supported when QGraphicsItem::ItemCoordinateCache-
5755 is enabled; in all other cases calling this function is equivalent to calling-
5756 update(\a rect). If you for sure know that the item is opaque and not overlapped-
5757 by other items, you can map the \a rect to viewport coordinates and scroll the-
5758 viewport.-
5759-
5760 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 19-
5761-
5762 \sa boundingRect()-
5763*/-
5764void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect)-
5765{-
5766 Q_D(QGraphicsItem);-
5767 if (dx == 0.0 && dy == 0.0)
dx == 0.0Description
TRUEnever evaluated
FALSEnever evaluated
dy == 0.0Description
TRUEnever evaluated
FALSEnever evaluated
0
5768 return;
never executed: return;
0
5769 if (!d->scene)
!d->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
5770 return;
never executed: return;
0
5771-
5772 // Accelerated scrolling means moving pixels from one location to another-
5773 // and only redraw the newly exposed area. The following requirements must-
5774 // be fulfilled in order to do that:-
5775 //-
5776 // 1) Item is opaque.-
5777 // 2) Item is not overlapped by other items.-
5778 //-
5779 // There's (yet) no way to detect whether an item is opaque or not, which means-
5780 // we cannot do accelerated scrolling unless the cache is enabled. In case of using-
5781 // DeviceCoordinate cache we also have to take the device transform into account in-
5782 // order to determine whether we can do accelerated scrolling or not. That's left out-
5783 // for simplicity here, but it is definitely something we can consider in the future-
5784 // as a performance improvement.-
5785 if (d->cacheMode != QGraphicsItem::ItemCoordinateCache
d->cacheMode !...oordinateCacheDescription
TRUEnever evaluated
FALSEnever evaluated
0
5786 || !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
5787 update(rect);-
5788 return;
never executed: return;
0
5789 }-
5790-
5791 QGraphicsItemCache *cache = d->extraItemCache();-
5792 if (cache->allExposed || cache->fixedSize.isValid()) {
cache->allExposedDescription
TRUEnever evaluated
FALSEnever evaluated
cache->fixedSize.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
5793 // Cache is either invalidated or item is scaled (see QGraphicsItem::setCacheMode).-
5794 update(rect);-
5795 return;
never executed: return;
0
5796 }-
5797-
5798 // Find pixmap in cache.-
5799 QPixmap cachedPixmap;-
5800 if (!QPixmapCache::find(cache->key, &cachedPixmap)) {
!QPixmapCache:...&cachedPixmap)Description
TRUEnever evaluated
FALSEnever evaluated
0
5801 update(rect);-
5802 return;
never executed: return;
0
5803 }-
5804-
5805 QRect scrollRect = (rect.isNull() ? boundingRect() : rect).toAlignedRect();
rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
5806 if (!scrollRect.intersects(cache->boundingRect))
!scrollRect.in...>boundingRect)Description
TRUEnever evaluated
FALSEnever evaluated
0
5807 return; // Nothing to scroll.
never executed: return;
0
5808-
5809 // Remove from cache to avoid deep copy when modifying.-
5810 QPixmapCache::remove(cache->key);-
5811-
5812 QRegion exposed;-
5813 cachedPixmap.scroll(dx, dy, scrollRect.translated(-cache->boundingRect.topLeft()), &exposed);-
5814-
5815 // Reinsert into cache.-
5816 cache->key = QPixmapCache::insert(cachedPixmap);-
5817-
5818 // Translate the existing expose.-
5819 for (int i = 0; i < cache->exposed.size(); ++i) {
i < cache->exposed.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
5820 QRectF &e = cache->exposed[i];-
5821 if (!rect.isNull() && !e.intersects(rect))
!rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
!e.intersects(rect)Description
TRUEnever evaluated
FALSEnever evaluated
0
5822 continue;
never executed: continue;
0
5823 e.translate(dx, dy);-
5824 }
never executed: end of block
0
5825-
5826 // Append newly exposed areas. Note that the exposed region is currently-
5827 // in pixmap coordinates, so we have to translate it to item coordinates.-
5828 exposed.translate(cache->boundingRect.topLeft());-
5829 const QVector<QRect> exposedRects = exposed.rects();-
5830 for (int i = 0; i < exposedRects.size(); ++i)
i < exposedRects.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
5831 cache->exposed += exposedRects.at(i);
never executed: cache->exposed += exposedRects.at(i);
0
5832-
5833 // Trigger update. This will redraw the newly exposed area and make sure-
5834 // the pixmap is re-blitted in case there are overlapping items.-
5835 d->scene->d_func()->markDirty(this, rect);-
5836}
never executed: end of block
0
5837-
5838/*!-
5839 \fn void QGraphicsItem::update(qreal x, qreal y, qreal width, qreal height)-
5840 \overload-
5841-
5842 This convenience function is equivalent to calling update(QRectF(\a x, \a-
5843 y, \a width, \a height)).-
5844*/-
5845-
5846/*!-
5847 Maps the point \a point, which is in this item's coordinate system, to \a-
5848 item's coordinate system, and returns the mapped coordinate.-
5849-
5850 If \a item is 0, this function returns the same as mapToScene().-
5851-
5852 \sa itemTransform(), mapToParent(), mapToScene(), transform(), mapFromItem(), {The Graphics-
5853 View Coordinate System}-
5854*/-
5855QPointF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPointF &point) const-
5856{-
5857 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
5858 return itemTransform(item).map(point);
never executed: return itemTransform(item).map(point);
0
5859 return mapToScene(point);
never executed: return mapToScene(point);
0
5860}-
5861-
5862/*!-
5863 \fn QPointF QGraphicsItem::mapToItem(const QGraphicsItem *item, qreal x, qreal y) const-
5864 \overload-
5865-
5866 This convenience function is equivalent to calling mapToItem(\a item,-
5867 QPointF(\a x, \a y)).-
5868*/-
5869-
5870/*!-
5871 Maps the point \a point, which is in this item's coordinate system, to its-
5872 parent's coordinate system, and returns the mapped coordinate. If the item-
5873 has no parent, \a point will be mapped to the scene's coordinate system.-
5874-
5875 \sa mapToItem(), mapToScene(), transform(), mapFromParent(), {The Graphics-
5876 View Coordinate System}-
5877*/-
5878QPointF QGraphicsItem::mapToParent(const QPointF &point) const-
5879{-
5880 // COMBINE-
5881 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
5882 return point + d_ptr->pos;
never executed: return point + d_ptr->pos;
0
5883 return d_ptr->transformToParent().map(point);
never executed: return d_ptr->transformToParent().map(point);
0
5884}-
5885-
5886/*!-
5887 \fn QPointF QGraphicsItem::mapToParent(qreal x, qreal y) const-
5888 \overload-
5889-
5890 This convenience function is equivalent to calling mapToParent(QPointF(\a-
5891 x, \a y)).-
5892*/-
5893-
5894/*!-
5895 Maps the point \a point, which is in this item's coordinate system, to the-
5896 scene's coordinate system, and returns the mapped coordinate.-
5897-
5898 \sa mapToItem(), mapToParent(), transform(), mapFromScene(), {The Graphics-
5899 View Coordinate System}-
5900*/-
5901QPointF QGraphicsItem::mapToScene(const QPointF &point) const-
5902{-
5903 if (d_ptr->hasTranslateOnlySceneTransform())
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
5904 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
5905 return d_ptr->sceneTransform.map(point);
never executed: return d_ptr->sceneTransform.map(point);
0
5906}-
5907-
5908/*!-
5909 \fn QPointF QGraphicsItem::mapToScene(qreal x, qreal y) const-
5910 \overload-
5911-
5912 This convenience function is equivalent to calling mapToScene(QPointF(\a-
5913 x, \a y)).-
5914*/-
5915-
5916/*!-
5917 Maps the rectangle \a rect, which is in this item's coordinate system, to-
5918 \a item's coordinate system, and returns the mapped rectangle as a polygon.-
5919-
5920 If \a item is 0, this function returns the same as mapToScene().-
5921-
5922 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The-
5923 Graphics View Coordinate System}-
5924*/-
5925QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QRectF &rect) const-
5926{-
5927 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
5928 return itemTransform(item).map(rect);
never executed: return itemTransform(item).map(rect);
0
5929 return mapToScene(rect);
never executed: return mapToScene(rect);
0
5930}-
5931-
5932/*!-
5933 \fn QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const-
5934 \since 4.3-
5935-
5936 This convenience function is equivalent to calling mapToItem(item, QRectF(\a x, \a y, \a w, \a h)).-
5937*/-
5938-
5939/*!-
5940 Maps the rectangle \a rect, which is in this item's coordinate system, to-
5941 its parent's coordinate system, and returns the mapped rectangle as a-
5942 polygon. If the item has no parent, \a rect will be mapped to the scene's-
5943 coordinate system.-
5944-
5945 \sa mapToScene(), mapToItem(), mapFromParent(), {The Graphics View-
5946 Coordinate System}-
5947*/-
5948QPolygonF QGraphicsItem::mapToParent(const QRectF &rect) const-
5949{-
5950 // COMBINE-
5951 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
5952 return rect.translated(d_ptr->pos);
never executed: return rect.translated(d_ptr->pos);
0
5953 return d_ptr->transformToParent().map(rect);
never executed: return d_ptr->transformToParent().map(rect);
0
5954}-
5955-
5956/*!-
5957 \fn QPolygonF QGraphicsItem::mapToParent(qreal x, qreal y, qreal w, qreal h) const-
5958 \since 4.3-
5959-
5960 This convenience function is equivalent to calling mapToParent(QRectF(\a x, \a y, \a w, \a h)).-
5961*/-
5962-
5963/*!-
5964 Maps the rectangle \a rect, which is in this item's coordinate system, to-
5965 the scene's coordinate system, and returns the mapped rectangle as a polygon.-
5966-
5967 \sa mapToParent(), mapToItem(), mapFromScene(), {The Graphics View-
5968 Coordinate System}-
5969*/-
5970QPolygonF QGraphicsItem::mapToScene(const QRectF &rect) const-
5971{-
5972 if (d_ptr->hasTranslateOnlySceneTransform())
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
5973 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
5974 return d_ptr->sceneTransform.map(rect);
never executed: return d_ptr->sceneTransform.map(rect);
0
5975}-
5976-
5977/*!-
5978 \fn QPolygonF QGraphicsItem::mapToScene(qreal x, qreal y, qreal w, qreal h) const-
5979 \since 4.3-
5980-
5981 This convenience function is equivalent to calling mapToScene(QRectF(\a x, \a y, \a w, \a h)).-
5982*/-
5983-
5984/*!-
5985 \since 4.5-
5986-
5987 Maps the rectangle \a rect, which is in this item's coordinate system, to-
5988 \a item's coordinate system, and returns the mapped rectangle as a new-
5989 rectangle (i.e., the bounding rectangle of the resulting polygon).-
5990-
5991 If \a item is 0, this function returns the same as mapRectToScene().-
5992-
5993 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The-
5994 Graphics View Coordinate System}-
5995*/-
5996QRectF QGraphicsItem::mapRectToItem(const QGraphicsItem *item, const QRectF &rect) const-
5997{-
5998 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
5999 return itemTransform(item).mapRect(rect);
never executed: return itemTransform(item).mapRect(rect);
0
6000 return mapRectToScene(rect);
never executed: return mapRectToScene(rect);
0
6001}-
6002-
6003/*!-
6004 \fn QRectF QGraphicsItem::mapRectToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const-
6005 \since 4.5-
6006-
6007 This convenience function is equivalent to calling mapRectToItem(item, QRectF(\a x, \a y, \a w, \a h)).-
6008*/-
6009-
6010/*!-
6011 \since 4.5-
6012-
6013 Maps the rectangle \a rect, which is in this item's coordinate system, to-
6014 its parent's coordinate system, and returns the mapped rectangle as a new-
6015 rectangle (i.e., the bounding rectangle of the resulting polygon).-
6016-
6017 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The-
6018 Graphics View Coordinate System}-
6019*/-
6020QRectF QGraphicsItem::mapRectToParent(const QRectF &rect) const-
6021{-
6022 // COMBINE-
6023 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
6024 return rect.translated(d_ptr->pos);
never executed: return rect.translated(d_ptr->pos);
0
6025 return d_ptr->transformToParent().mapRect(rect);
never executed: return d_ptr->transformToParent().mapRect(rect);
0
6026}-
6027-
6028/*!-
6029 \fn QRectF QGraphicsItem::mapRectToParent(qreal x, qreal y, qreal w, qreal h) const-
6030 \since 4.5-
6031-
6032 This convenience function is equivalent to calling mapRectToParent(QRectF(\a x, \a y, \a w, \a h)).-
6033*/-
6034-
6035/*!-
6036 \since 4.5-
6037-
6038 Maps the rectangle \a rect, which is in this item's coordinate system, to-
6039 the scene coordinate system, and returns the mapped rectangle as a new-
6040 rectangle (i.e., the bounding rectangle of the resulting polygon).-
6041-
6042 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The-
6043 Graphics View Coordinate System}-
6044*/-
6045QRectF QGraphicsItem::mapRectToScene(const QRectF &rect) const-
6046{-
6047 if (d_ptr->hasTranslateOnlySceneTransform())
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
6048 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
6049 return d_ptr->sceneTransform.mapRect(rect);
never executed: return d_ptr->sceneTransform.mapRect(rect);
0
6050}-
6051-
6052/*!-
6053 \fn QRectF QGraphicsItem::mapRectToScene(qreal x, qreal y, qreal w, qreal h) const-
6054 \since 4.5-
6055-
6056 This convenience function is equivalent to calling mapRectToScene(QRectF(\a x, \a y, \a w, \a h)).-
6057*/-
6058-
6059/*!-
6060 \since 4.5-
6061-
6062 Maps the rectangle \a rect, which is in \a item's coordinate system, to-
6063 this item's coordinate system, and returns the mapped rectangle as a new-
6064 rectangle (i.e., the bounding rectangle of the resulting polygon).-
6065-
6066 If \a item is 0, this function returns the same as mapRectFromScene().-
6067-
6068 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The-
6069 Graphics View Coordinate System}-
6070*/-
6071QRectF QGraphicsItem::mapRectFromItem(const QGraphicsItem *item, const QRectF &rect) const-
6072{-
6073 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
6074 return item->itemTransform(this).mapRect(rect);
never executed: return item->itemTransform(this).mapRect(rect);
0
6075 return mapRectFromScene(rect);
never executed: return mapRectFromScene(rect);
0
6076}-
6077-
6078/*!-
6079 \fn QRectF QGraphicsItem::mapRectFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const-
6080 \since 4.5-
6081-
6082 This convenience function is equivalent to calling mapRectFromItem(item, QRectF(\a x, \a y, \a w, \a h)).-
6083*/-
6084-
6085/*!-
6086 \since 4.5-
6087-
6088 Maps the rectangle \a rect, which is in this item's parent's coordinate-
6089 system, to this item's coordinate system, and returns the mapped rectangle-
6090 as a new rectangle (i.e., the bounding rectangle of the resulting-
6091 polygon).-
6092-
6093 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The-
6094 Graphics View Coordinate System}-
6095*/-
6096QRectF QGraphicsItem::mapRectFromParent(const QRectF &rect) const-
6097{-
6098 // COMBINE-
6099 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
6100 return rect.translated(-d_ptr->pos);
never executed: return rect.translated(-d_ptr->pos);
0
6101 return d_ptr->transformToParent().inverted().mapRect(rect);
never executed: return d_ptr->transformToParent().inverted().mapRect(rect);
0
6102}-
6103-
6104/*!-
6105 \fn QRectF QGraphicsItem::mapRectFromParent(qreal x, qreal y, qreal w, qreal h) const-
6106 \since 4.5-
6107-
6108 This convenience function is equivalent to calling mapRectFromParent(QRectF(\a x, \a y, \a w, \a h)).-
6109*/-
6110-
6111/*!-
6112 \since 4.5-
6113-
6114 Maps the rectangle \a rect, which is in scene coordinates, to this item's-
6115 coordinate system, and returns the mapped rectangle as a new rectangle-
6116 (i.e., the bounding rectangle of the resulting polygon).-
6117-
6118 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The-
6119 Graphics View Coordinate System}-
6120*/-
6121QRectF QGraphicsItem::mapRectFromScene(const QRectF &rect) const-
6122{-
6123 if (d_ptr->hasTranslateOnlySceneTransform())
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
6124 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
6125 return d_ptr->sceneTransform.inverted().mapRect(rect);
never executed: return d_ptr->sceneTransform.inverted().mapRect(rect);
0
6126}-
6127-
6128/*!-
6129 \fn QRectF QGraphicsItem::mapRectFromScene(qreal x, qreal y, qreal w, qreal h) const-
6130 \since 4.5-
6131-
6132 This convenience function is equivalent to calling mapRectFromScene(QRectF(\a x, \a y, \a w, \a h)).-
6133*/-
6134-
6135/*!-
6136 Maps the polygon \a polygon, which is in this item's coordinate system, to-
6137 \a item's coordinate system, and returns the mapped polygon.-
6138-
6139 If \a item is 0, this function returns the same as mapToScene().-
6140-
6141 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The-
6142 Graphics View Coordinate System}-
6143*/-
6144QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPolygonF &polygon) const-
6145{-
6146 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
6147 return itemTransform(item).map(polygon);
never executed: return itemTransform(item).map(polygon);
0
6148 return mapToScene(polygon);
never executed: return mapToScene(polygon);
0
6149}-
6150-
6151/*!-
6152 Maps the polygon \a polygon, which is in this item's coordinate system, to-
6153 its parent's coordinate system, and returns the mapped polygon. If the-
6154 item has no parent, \a polygon will be mapped to the scene's coordinate-
6155 system.-
6156-
6157 \sa mapToScene(), mapToItem(), mapFromParent(), {The Graphics View-
6158 Coordinate System}-
6159*/-
6160QPolygonF QGraphicsItem::mapToParent(const QPolygonF &polygon) const-
6161{-
6162 // COMBINE-
6163 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
6164 return polygon.translated(d_ptr->pos);
never executed: return polygon.translated(d_ptr->pos);
0
6165 return d_ptr->transformToParent().map(polygon);
never executed: return d_ptr->transformToParent().map(polygon);
0
6166}-
6167-
6168/*!-
6169 Maps the polygon \a polygon, which is in this item's coordinate system, to-
6170 the scene's coordinate system, and returns the mapped polygon.-
6171-
6172 \sa mapToParent(), mapToItem(), mapFromScene(), {The Graphics View-
6173 Coordinate System}-
6174*/-
6175QPolygonF QGraphicsItem::mapToScene(const QPolygonF &polygon) const-
6176{-
6177 if (d_ptr->hasTranslateOnlySceneTransform())
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
6178 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
6179 return d_ptr->sceneTransform.map(polygon);
never executed: return d_ptr->sceneTransform.map(polygon);
0
6180}-
6181-
6182/*!-
6183 Maps the path \a path, which is in this item's coordinate system, to-
6184 \a item's coordinate system, and returns the mapped path.-
6185-
6186 If \a item is 0, this function returns the same as mapToScene().-
6187-
6188 \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The-
6189 Graphics View Coordinate System}-
6190*/-
6191QPainterPath QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPainterPath &path) const-
6192{-
6193 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
6194 return itemTransform(item).map(path);
never executed: return itemTransform(item).map(path);
0
6195 return mapToScene(path);
never executed: return mapToScene(path);
0
6196}-
6197-
6198/*!-
6199 Maps the path \a path, which is in this item's coordinate system, to-
6200 its parent's coordinate system, and returns the mapped path. If the-
6201 item has no parent, \a path will be mapped to the scene's coordinate-
6202 system.-
6203-
6204 \sa mapToScene(), mapToItem(), mapFromParent(), {The Graphics View-
6205 Coordinate System}-
6206*/-
6207QPainterPath QGraphicsItem::mapToParent(const QPainterPath &path) const-
6208{-
6209 // COMBINE-
6210 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
6211 return path.translated(d_ptr->pos);
never executed: return path.translated(d_ptr->pos);
0
6212 return d_ptr->transformToParent().map(path);
never executed: return d_ptr->transformToParent().map(path);
0
6213}-
6214-
6215/*!-
6216 Maps the path \a path, which is in this item's coordinate system, to-
6217 the scene's coordinate system, and returns the mapped path.-
6218-
6219 \sa mapToParent(), mapToItem(), mapFromScene(), {The Graphics View-
6220 Coordinate System}-
6221*/-
6222QPainterPath QGraphicsItem::mapToScene(const QPainterPath &path) const-
6223{-
6224 if (d_ptr->hasTranslateOnlySceneTransform())
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
6225 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
6226 return d_ptr->sceneTransform.map(path);
never executed: return d_ptr->sceneTransform.map(path);
0
6227}-
6228-
6229/*!-
6230 Maps the point \a point, which is in \a item's coordinate system, to this-
6231 item's coordinate system, and returns the mapped coordinate.-
6232-
6233 If \a item is 0, this function returns the same as mapFromScene().-
6234-
6235 \sa itemTransform(), mapFromParent(), mapFromScene(), transform(), mapToItem(), {The Graphics-
6236 View Coordinate System}-
6237*/-
6238QPointF QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QPointF &point) const-
6239{-
6240 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
6241 return item->itemTransform(this).map(point);
never executed: return item->itemTransform(this).map(point);
0
6242 return mapFromScene(point);
never executed: return mapFromScene(point);
0
6243}-
6244-
6245/*!-
6246 \fn QPointF QGraphicsItem::mapFromItem(const QGraphicsItem *item, qreal x, qreal y) const-
6247 \overload-
6248-
6249 This convenience function is equivalent to calling mapFromItem(\a item,-
6250 QPointF(\a x, \a y)).-
6251*/-
6252-
6253/*!-
6254 Maps the point \a point, which is in this item's parent's coordinate-
6255 system, to this item's coordinate system, and returns the mapped-
6256 coordinate.-
6257-
6258 \sa mapFromItem(), mapFromScene(), transform(), mapToParent(), {The Graphics-
6259 View Coordinate System}-
6260*/-
6261QPointF QGraphicsItem::mapFromParent(const QPointF &point) const-
6262{-
6263 // COMBINE-
6264 if (d_ptr->transformData)
d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
6265 return d_ptr->transformToParent().inverted().map(point);
never executed: return d_ptr->transformToParent().inverted().map(point);
0
6266 return point - d_ptr->pos;
never executed: return point - d_ptr->pos;
0
6267}-
6268-
6269/*!-
6270 \fn QPointF QGraphicsItem::mapFromParent(qreal x, qreal y) const-
6271 \overload-
6272-
6273 This convenience function is equivalent to calling-
6274 mapFromParent(QPointF(\a x, \a y)).-
6275*/-
6276-
6277/*!-
6278 Maps the point \a point, which is in this item's scene's coordinate-
6279 system, to this item's coordinate system, and returns the mapped-
6280 coordinate.-
6281-
6282 \sa mapFromItem(), mapFromParent(), transform(), mapToScene(), {The Graphics-
6283 View Coordinate System}-
6284*/-
6285QPointF QGraphicsItem::mapFromScene(const QPointF &point) const-
6286{-
6287 if (d_ptr->hasTranslateOnlySceneTransform())
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
6288 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
6289 return d_ptr->sceneTransform.inverted().map(point);
never executed: return d_ptr->sceneTransform.inverted().map(point);
0
6290}-
6291-
6292/*!-
6293 \fn QPointF QGraphicsItem::mapFromScene(qreal x, qreal y) const-
6294 \overload-
6295-
6296 This convenience function is equivalent to calling mapFromScene(QPointF(\a-
6297 x, \a y)).-
6298*/-
6299-
6300/*!-
6301 Maps the rectangle \a rect, which is in \a item's coordinate system, to-
6302 this item's coordinate system, and returns the mapped rectangle as a-
6303 polygon.-
6304-
6305 If \a item is 0, this function returns the same as mapFromScene()-
6306-
6307 \sa itemTransform(), mapToItem(), mapFromParent(), transform(), {The Graphics View Coordinate-
6308 System}-
6309*/-
6310QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QRectF &rect) const-
6311{-
6312 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
6313 return item->itemTransform(this).map(rect);
never executed: return item->itemTransform(this).map(rect);
0
6314 return mapFromScene(rect);
never executed: return mapFromScene(rect);
0
6315}-
6316-
6317/*!-
6318 \fn QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const-
6319 \since 4.3-
6320-
6321 This convenience function is equivalent to calling mapFromItem(item, QRectF(\a x, \a y, \a w, \a h)).-
6322*/-
6323-
6324/*!-
6325 Maps the rectangle \a rect, which is in this item's parent's coordinate-
6326 system, to this item's coordinate system, and returns the mapped rectangle-
6327 as a polygon.-
6328-
6329 \sa mapToParent(), mapFromItem(), transform(), {The Graphics View Coordinate-
6330 System}-
6331*/-
6332QPolygonF QGraphicsItem::mapFromParent(const QRectF &rect) const-
6333{-
6334 // COMBINE-
6335 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
6336 return rect.translated(-d_ptr->pos);
never executed: return rect.translated(-d_ptr->pos);
0
6337 return d_ptr->transformToParent().inverted().map(rect);
never executed: return d_ptr->transformToParent().inverted().map(rect);
0
6338}-
6339-
6340/*!-
6341 \fn QPolygonF QGraphicsItem::mapFromParent(qreal x, qreal y, qreal w, qreal h) const-
6342 \since 4.3-
6343-
6344 This convenience function is equivalent to calling mapFromItem(QRectF(\a x, \a y, \a w, \a h)).-
6345*/-
6346-
6347/*!-
6348 Maps the rectangle \a rect, which is in this item's scene's coordinate-
6349 system, to this item's coordinate system, and returns the mapped rectangle-
6350 as a polygon.-
6351-
6352 \sa mapToScene(), mapFromItem(), transform(), {The Graphics View Coordinate-
6353 System}-
6354*/-
6355QPolygonF QGraphicsItem::mapFromScene(const QRectF &rect) const-
6356{-
6357 if (d_ptr->hasTranslateOnlySceneTransform())
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
6358 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
6359 return d_ptr->sceneTransform.inverted().map(rect);
never executed: return d_ptr->sceneTransform.inverted().map(rect);
0
6360}-
6361-
6362/*!-
6363 \fn QPolygonF QGraphicsItem::mapFromScene(qreal x, qreal y, qreal w, qreal h) const-
6364 \since 4.3-
6365-
6366 This convenience function is equivalent to calling mapFromScene(QRectF(\a x, \a y, \a w, \a h)).-
6367*/-
6368-
6369/*!-
6370 Maps the polygon \a polygon, which is in \a item's coordinate system, to-
6371 this item's coordinate system, and returns the mapped polygon.-
6372-
6373 If \a item is 0, this function returns the same as mapFromScene().-
6374-
6375 \sa itemTransform(), mapToItem(), mapFromParent(), transform(), {The-
6376 Graphics View Coordinate System}-
6377*/-
6378QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QPolygonF &polygon) const-
6379{-
6380 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
6381 return item->itemTransform(this).map(polygon);
never executed: return item->itemTransform(this).map(polygon);
0
6382 return mapFromScene(polygon);
never executed: return mapFromScene(polygon);
0
6383}-
6384-
6385/*!-
6386 Maps the polygon \a polygon, which is in this item's parent's coordinate-
6387 system, to this item's coordinate system, and returns the mapped polygon.-
6388-
6389 \sa mapToParent(), mapToItem(), transform(), {The Graphics View Coordinate-
6390 System}-
6391*/-
6392QPolygonF QGraphicsItem::mapFromParent(const QPolygonF &polygon) const-
6393{-
6394 // COMBINE-
6395 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
6396 return polygon.translated(-d_ptr->pos);
never executed: return polygon.translated(-d_ptr->pos);
0
6397 return d_ptr->transformToParent().inverted().map(polygon);
never executed: return d_ptr->transformToParent().inverted().map(polygon);
0
6398}-
6399-
6400/*!-
6401 Maps the polygon \a polygon, which is in this item's scene's coordinate-
6402 system, to this item's coordinate system, and returns the mapped polygon.-
6403-
6404 \sa mapToScene(), mapFromParent(), transform(), {The Graphics View Coordinate-
6405 System}-
6406*/-
6407QPolygonF QGraphicsItem::mapFromScene(const QPolygonF &polygon) const-
6408{-
6409 if (d_ptr->hasTranslateOnlySceneTransform())
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
6410 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
6411 return d_ptr->sceneTransform.inverted().map(polygon);
never executed: return d_ptr->sceneTransform.inverted().map(polygon);
0
6412}-
6413-
6414/*!-
6415 Maps the path \a path, which is in \a item's coordinate system, to-
6416 this item's coordinate system, and returns the mapped path.-
6417-
6418 If \a item is 0, this function returns the same as mapFromScene().-
6419-
6420 \sa itemTransform(), mapFromParent(), mapFromScene(), mapToItem(), {The-
6421 Graphics View Coordinate System}-
6422*/-
6423QPainterPath QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QPainterPath &path) const-
6424{-
6425 if (item)
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
6426 return item->itemTransform(this).map(path);
never executed: return item->itemTransform(this).map(path);
0
6427 return mapFromScene(path);
never executed: return mapFromScene(path);
0
6428}-
6429-
6430/*!-
6431 Maps the path \a path, which is in this item's parent's coordinate-
6432 system, to this item's coordinate system, and returns the mapped path.-
6433-
6434 \sa mapFromScene(), mapFromItem(), mapToParent(), {The Graphics View-
6435 Coordinate System}-
6436*/-
6437QPainterPath QGraphicsItem::mapFromParent(const QPainterPath &path) const-
6438{-
6439 // COMBINE-
6440 if (!d_ptr->transformData)
!d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
6441 return path.translated(-d_ptr->pos);
never executed: return path.translated(-d_ptr->pos);
0
6442 return d_ptr->transformToParent().inverted().map(path);
never executed: return d_ptr->transformToParent().inverted().map(path);
0
6443}-
6444-
6445/*!-
6446 Maps the path \a path, which is in this item's scene's coordinate-
6447 system, to this item's coordinate system, and returns the mapped path.-
6448-
6449 \sa mapFromParent(), mapFromItem(), mapToScene(), {The Graphics View-
6450 Coordinate System}-
6451*/-
6452QPainterPath QGraphicsItem::mapFromScene(const QPainterPath &path) const-
6453{-
6454 if (d_ptr->hasTranslateOnlySceneTransform())
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
6455 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
6456 return d_ptr->sceneTransform.inverted().map(path);
never executed: return d_ptr->sceneTransform.inverted().map(path);
0
6457}-
6458-
6459/*!-
6460 Returns \c true if this item is an ancestor of \a child (i.e., if this item-
6461 is \a child's parent, or one of \a child's parent's ancestors).-
6462-
6463 \sa parentItem()-
6464*/-
6465bool QGraphicsItem::isAncestorOf(const QGraphicsItem *child) const-
6466{-
6467 if (!child || child == this)
!childDescription
TRUEnever evaluated
FALSEnever evaluated
child == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
6468 return false;
never executed: return false;
0
6469 if (child->d_ptr->depth() < d_ptr->depth())
child->d_ptr->...d_ptr->depth()Description
TRUEnever evaluated
FALSEnever evaluated
0
6470 return false;
never executed: return false;
0
6471 const QGraphicsItem *ancestor = child;-
6472 while ((ancestor = ancestor->d_ptr->parent)) {
(ancestor = an...d_ptr->parent)Description
TRUEnever evaluated
FALSEnever evaluated
0
6473 if (ancestor == this)
ancestor == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
6474 return true;
never executed: return true;
0
6475 }
never executed: end of block
0
6476 return false;
never executed: return false;
0
6477}-
6478-
6479/*!-
6480 \since 4.4-
6481-
6482 Returns the closest common ancestor item of this item and \a other, or 0-
6483 if either \a other is 0, or there is no common ancestor.-
6484-
6485 \sa isAncestorOf()-
6486*/-
6487QGraphicsItem *QGraphicsItem::commonAncestorItem(const QGraphicsItem *other) const-
6488{-
6489 if (!other)
!otherDescription
TRUEnever evaluated
FALSEnever evaluated
0
6490 return 0;
never executed: return 0;
0
6491 if (other == this)
other == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
6492 return const_cast<QGraphicsItem *>(this);
never executed: return const_cast<QGraphicsItem *>(this);
0
6493 const QGraphicsItem *thisw = this;-
6494 const QGraphicsItem *otherw = other;-
6495 int thisDepth = d_ptr->depth();-
6496 int otherDepth = other->d_ptr->depth();-
6497 while (thisDepth > otherDepth) {
thisDepth > otherDepthDescription
TRUEnever evaluated
FALSEnever evaluated
0
6498 thisw = thisw->d_ptr->parent;-
6499 --thisDepth;-
6500 }
never executed: end of block
0
6501 while (otherDepth > thisDepth) {
otherDepth > thisDepthDescription
TRUEnever evaluated
FALSEnever evaluated
0
6502 otherw = otherw->d_ptr->parent;-
6503 --otherDepth;-
6504 }
never executed: end of block
0
6505 while (thisw && thisw != otherw) {
thiswDescription
TRUEnever evaluated
FALSEnever evaluated
thisw != otherwDescription
TRUEnever evaluated
FALSEnever evaluated
0
6506 thisw = thisw->d_ptr->parent;-
6507 otherw = otherw->d_ptr->parent;-
6508 }
never executed: end of block
0
6509 return const_cast<QGraphicsItem *>(thisw);
never executed: return const_cast<QGraphicsItem *>(thisw);
0
6510}-
6511-
6512/*!-
6513 \since 4,4-
6514 Returns \c true if this item is currently under the mouse cursor in one of-
6515 the views; otherwise, false is returned.-
6516-
6517 \sa QGraphicsScene::views(), QCursor::pos()-
6518*/-
6519bool QGraphicsItem::isUnderMouse() const-
6520{-
6521 Q_D(const QGraphicsItem);-
6522 if (!d->scene)
!d->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
6523 return false;
never executed: return false;
0
6524-
6525 QPoint cursorPos = QCursor::pos();-
6526 foreach (QGraphicsView *view, d->scene->views()) {-
6527 if (contains(mapFromScene(view->mapToScene(view->mapFromGlobal(cursorPos)))))
contains(mapFr...(cursorPos))))Description
TRUEnever evaluated
FALSEnever evaluated
0
6528 return true;
never executed: return true;
0
6529 }
never executed: end of block
0
6530 return false;
never executed: return false;
0
6531}-
6532-
6533/*!-
6534 Returns this item's custom data for the key \a key as a QVariant.-
6535-
6536 Custom item data is useful for storing arbitrary properties in any-
6537 item. Example:-
6538-
6539 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 11-
6540-
6541 Qt does not use this feature for storing data; it is provided solely-
6542 for the convenience of the user.-
6543-
6544 \sa setData()-
6545*/-
6546QVariant QGraphicsItem::data(int key) const-
6547{-
6548 QGraphicsItemCustomDataStore *store = qt_dataStore();-
6549 if (!store->data.contains(this))
!store->data.contains(this)Description
TRUEnever evaluated
FALSEnever evaluated
0
6550 return QVariant();
never executed: return QVariant();
0
6551 return store->data.value(this).value(key);
never executed: return store->data.value(this).value(key);
0
6552}-
6553-
6554/*!-
6555 Sets this item's custom data for the key \a key to \a value.-
6556-
6557 Custom item data is useful for storing arbitrary properties for any-
6558 item. Qt does not use this feature for storing data; it is provided solely-
6559 for the convenience of the user.-
6560-
6561 \sa data()-
6562*/-
6563void QGraphicsItem::setData(int key, const QVariant &value)-
6564{-
6565 qt_dataStore()->data[this][key] = value;-
6566}
never executed: end of block
0
6567-
6568/*!-
6569 \fn T qgraphicsitem_cast(QGraphicsItem *item)-
6570 \relates QGraphicsItem-
6571 \since 4.2-
6572-
6573 Returns the given \a item cast to type T if \a item is of type T;-
6574 otherwise, 0 is returned.-
6575-
6576 \note To make this function work correctly with custom items, reimplement-
6577 the \l{QGraphicsItem::}{type()} function for each custom QGraphicsItem-
6578 subclass.-
6579-
6580 \sa QGraphicsItem::type(), QGraphicsItem::UserType-
6581*/-
6582-
6583/*!-
6584 Returns the type of an item as an int. All standard graphicsitem classes-
6585 are associated with a unique value; see QGraphicsItem::Type. This type-
6586 information is used by qgraphicsitem_cast() to distinguish between types.-
6587-
6588 The default implementation (in QGraphicsItem) returns UserType.-
6589-
6590 To enable use of qgraphicsitem_cast() with a custom item, reimplement this-
6591 function and declare a Type enum value equal to your custom item's type.-
6592 Custom items must return a value larger than or equal to UserType (65536).-
6593-
6594 For example:-
6595-
6596 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 1-
6597-
6598 \sa UserType-
6599*/-
6600int QGraphicsItem::type() const-
6601{-
6602 return (int)UserType;
never executed: return (int)UserType;
0
6603}-
6604-
6605/*!-
6606 Installs an event filter for this item on \a filterItem, causing-
6607 all events for this item to first pass through \a filterItem's-
6608 sceneEventFilter() function.-
6609-
6610 To filter another item's events, install this item as an event filter-
6611 for the other item. Example:-
6612-
6613 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 12-
6614-
6615 An item can only filter events for other items in the same-
6616 scene. Also, an item cannot filter its own events; instead, you-
6617 can reimplement sceneEvent() directly.-
6618-
6619 Items must belong to a scene for scene event filters to be installed and-
6620 used.-
6621-
6622 \sa removeSceneEventFilter(), sceneEventFilter(), sceneEvent()-
6623*/-
6624void QGraphicsItem::installSceneEventFilter(QGraphicsItem *filterItem)-
6625{-
6626 if (!d_ptr->scene) {
!d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
6627 qWarning("QGraphicsItem::installSceneEventFilter: event filters can only be installed"-
6628 " on items in a scene.");-
6629 return;
never executed: return;
0
6630 }-
6631 if (d_ptr->scene != filterItem->scene()) {
d_ptr->scene !...rItem->scene()Description
TRUEnever evaluated
FALSEnever evaluated
0
6632 qWarning("QGraphicsItem::installSceneEventFilter: event filters can only be installed"-
6633 " on items in the same scene.");-
6634 return;
never executed: return;
0
6635 }-
6636 d_ptr->scene->d_func()->installSceneEventFilter(this, filterItem);-
6637}
never executed: end of block
0
6638-
6639/*!-
6640 Removes an event filter on this item from \a filterItem.-
6641-
6642 \sa installSceneEventFilter()-
6643*/-
6644void QGraphicsItem::removeSceneEventFilter(QGraphicsItem *filterItem)-
6645{-
6646 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
6647 return;
never executed: return;
0
6648 d_ptr->scene->d_func()->removeSceneEventFilter(this, filterItem);-
6649}
never executed: end of block
0
6650-
6651/*!-
6652 Filters events for the item \a watched. \a event is the filtered-
6653 event.-
6654-
6655 Reimplementing this function in a subclass makes it possible-
6656 for the item to be used as an event filter for other items,-
6657 intercepting all the events sent to those items before they are-
6658 able to respond.-
6659-
6660 Reimplementations must return true to prevent further processing of-
6661 a given event, ensuring that it will not be delivered to the watched-
6662 item, or return false to indicate that the event should be propagated-
6663 further by the event system.-
6664-
6665 \sa installSceneEventFilter()-
6666*/-
6667bool QGraphicsItem::sceneEventFilter(QGraphicsItem *watched, QEvent *event)-
6668{-
6669 Q_UNUSED(watched);-
6670 Q_UNUSED(event);-
6671 return false;
never executed: return false;
0
6672}-
6673-
6674/*!-
6675 This virtual function receives events to this item. Reimplement-
6676 this function to intercept events before they are dispatched to-
6677 the specialized event handlers contextMenuEvent(), focusInEvent(),-
6678 focusOutEvent(), hoverEnterEvent(), hoverMoveEvent(),-
6679 hoverLeaveEvent(), keyPressEvent(), keyReleaseEvent(),-
6680 mousePressEvent(), mouseReleaseEvent(), mouseMoveEvent(), and-
6681 mouseDoubleClickEvent().-
6682-
6683 Returns \c true if the event was recognized and handled; otherwise, (e.g., if-
6684 the event type was not recognized,) false is returned.-
6685-
6686 \a event is the intercepted event.-
6687*/-
6688bool QGraphicsItem::sceneEvent(QEvent *event)-
6689{-
6690 if (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents) {
d_ptr->ancesto...lesChildEventsDescription
TRUEnever evaluated
FALSEnever evaluated
0
6691 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
6692 || 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
6693 // Hover enter and hover leave events for children are ignored;-
6694 // hover move events are forwarded.-
6695 return true;
never executed: return true;
0
6696 }-
6697-
6698 QGraphicsItem *handler = this;-
6699 do {-
6700 handler = handler->d_ptr->parent;-
6701 Q_ASSERT(handler);-
6702 } while (handler->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents);
never executed: end of block
handler->d_ptr...lesChildEventsDescription
TRUEnever evaluated
FALSEnever evaluated
0
6703 // Forward the event to the closest parent that handles child-
6704 // events, mapping existing item-local coordinates to its-
6705 // coordinate system.-
6706 d_ptr->remapItemPos(event, handler);-
6707 handler->sceneEvent(event);-
6708 return true;
never executed: return true;
0
6709 }-
6710-
6711 if (event->type() == QEvent::FocusOut) {
event->type() ...vent::FocusOutDescription
TRUEnever evaluated
FALSEnever evaluated
0
6712 focusOutEvent(static_cast<QFocusEvent *>(event));-
6713 return true;
never executed: return true;
0
6714 }-
6715-
6716 if (!d_ptr->visible) {
!d_ptr->visibleDescription
TRUEnever evaluated
FALSEnever evaluated
0
6717 // Eaten-
6718 return true;
never executed: return true;
0
6719 }-
6720-
6721 switch (event->type()) {-
6722 case QEvent::FocusIn:
never executed: case QEvent::FocusIn:
0
6723 focusInEvent(static_cast<QFocusEvent *>(event));-
6724 break;
never executed: break;
0
6725 case QEvent::GraphicsSceneContextMenu:
never executed: case QEvent::GraphicsSceneContextMenu:
0
6726 contextMenuEvent(static_cast<QGraphicsSceneContextMenuEvent *>(event));-
6727 break;
never executed: break;
0
6728 case QEvent::GraphicsSceneDragEnter:
never executed: case QEvent::GraphicsSceneDragEnter:
0
6729 dragEnterEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));-
6730 break;
never executed: break;
0
6731 case QEvent::GraphicsSceneDragMove:
never executed: case QEvent::GraphicsSceneDragMove:
0
6732 dragMoveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));-
6733 break;
never executed: break;
0
6734 case QEvent::GraphicsSceneDragLeave:
never executed: case QEvent::GraphicsSceneDragLeave:
0
6735 dragLeaveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));-
6736 break;
never executed: break;
0
6737 case QEvent::GraphicsSceneDrop:
never executed: case QEvent::GraphicsSceneDrop:
0
6738 dropEvent(static_cast<QGraphicsSceneDragDropEvent *>(event));-
6739 break;
never executed: break;
0
6740 case QEvent::GraphicsSceneHoverEnter:
never executed: case QEvent::GraphicsSceneHoverEnter:
0
6741 hoverEnterEvent(static_cast<QGraphicsSceneHoverEvent *>(event));-
6742 break;
never executed: break;
0
6743 case QEvent::GraphicsSceneHoverMove:
never executed: case QEvent::GraphicsSceneHoverMove:
0
6744 hoverMoveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));-
6745 break;
never executed: break;
0
6746 case QEvent::GraphicsSceneHoverLeave:
never executed: case QEvent::GraphicsSceneHoverLeave:
0
6747 hoverLeaveEvent(static_cast<QGraphicsSceneHoverEvent *>(event));-
6748 break;
never executed: break;
0
6749 case QEvent::GraphicsSceneMouseMove:
never executed: case QEvent::GraphicsSceneMouseMove:
0
6750 mouseMoveEvent(static_cast<QGraphicsSceneMouseEvent *>(event));-
6751 break;
never executed: break;
0
6752 case QEvent::GraphicsSceneMousePress:
never executed: case QEvent::GraphicsSceneMousePress:
0
6753 mousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event));-
6754 break;
never executed: break;
0
6755 case QEvent::GraphicsSceneMouseRelease:
never executed: case QEvent::GraphicsSceneMouseRelease:
0
6756 mouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event));-
6757 break;
never executed: break;
0
6758 case QEvent::GraphicsSceneMouseDoubleClick:
never executed: case QEvent::GraphicsSceneMouseDoubleClick:
0
6759 mouseDoubleClickEvent(static_cast<QGraphicsSceneMouseEvent *>(event));-
6760 break;
never executed: break;
0
6761 case QEvent::GraphicsSceneWheel:
never executed: case QEvent::GraphicsSceneWheel:
0
6762 wheelEvent(static_cast<QGraphicsSceneWheelEvent *>(event));-
6763 break;
never executed: break;
0
6764 case QEvent::KeyPress: {
never executed: case QEvent::KeyPress:
0
6765 QKeyEvent *k = static_cast<QKeyEvent *>(event);-
6766 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
6767 if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier?
!(k->modifiers...:AltModifier))Description
TRUEnever evaluated
FALSEnever evaluated
0
6768 bool res = false;-
6769 if (k->key() == Qt::Key_Backtab
k->key() == Qt::Key_BacktabDescription
TRUEnever evaluated
FALSEnever evaluated
0
6770 || (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
6771 if (d_ptr->isWidget) {
d_ptr->isWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
6772 res = static_cast<QGraphicsWidget *>(this)->focusNextPrevChild(false);-
6773 } else if (d_ptr->scene) {
never executed: end of block
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
6774 res = d_ptr->scene->focusNextPrevChild(false);-
6775 }
never executed: end of block
0
6776 } else if (k->key() == Qt::Key_Tab) {
never executed: end of block
k->key() == Qt::Key_TabDescription
TRUEnever evaluated
FALSEnever evaluated
0
6777 if (d_ptr->isWidget) {
d_ptr->isWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
6778 res = static_cast<QGraphicsWidget *>(this)->focusNextPrevChild(true);-
6779 } else if (d_ptr->scene) {
never executed: end of block
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
6780 res = d_ptr->scene->focusNextPrevChild(true);-
6781 }
never executed: end of block
0
6782 }
never executed: end of block
0
6783 if (!res)
!resDescription
TRUEnever evaluated
FALSEnever evaluated
0
6784 event->ignore();
never executed: event->ignore();
0
6785 return true;
never executed: return true;
0
6786 }-
6787 }
never executed: end of block
0
6788 keyPressEvent(static_cast<QKeyEvent *>(event));-
6789 break;
never executed: break;
0
6790 }-
6791 case QEvent::KeyRelease:
never executed: case QEvent::KeyRelease:
0
6792 keyReleaseEvent(static_cast<QKeyEvent *>(event));-
6793 break;
never executed: break;
0
6794 case QEvent::InputMethod:
never executed: case QEvent::InputMethod:
0
6795 inputMethodEvent(static_cast<QInputMethodEvent *>(event));-
6796 break;
never executed: break;
0
6797 case QEvent::WindowActivate:
never executed: case QEvent::WindowActivate:
0
6798 case QEvent::WindowDeactivate:
never executed: case QEvent::WindowDeactivate:
0
6799 // Propagate panel activation.-
6800 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
6801 for (int i = 0; i < d_ptr->children.size(); ++i) {
i < d_ptr->children.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
6802 QGraphicsItem *child = d_ptr->children.at(i);-
6803 if (child->isVisible() && !child->isPanel()) {
child->isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
!child->isPanel()Description
TRUEnever evaluated
FALSEnever evaluated
0
6804 if (!(child->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents))
!(child->d_ptr...esChildEvents)Description
TRUEnever evaluated
FALSEnever evaluated
0
6805 d_ptr->scene->sendEvent(child, event);
never executed: d_ptr->scene->sendEvent(child, event);
0
6806 }
never executed: end of block
0
6807 }
never executed: end of block
0
6808 }
never executed: end of block
0
6809 break;
never executed: break;
0
6810 default:
never executed: default:
0
6811 return false;
never executed: return false;
0
6812 }-
6813-
6814 return true;
never executed: return true;
0
6815}-
6816-
6817/*!-
6818 This event handler can be reimplemented in a subclass to process context-
6819 menu events. The \a event parameter contains details about the event to-
6820 be handled.-
6821-
6822 If you ignore the event (i.e., by calling QEvent::ignore()), \a event-
6823 will propagate to any item beneath this item. If no items accept the-
6824 event, it will be ignored by the scene and propagate to the view.-
6825-
6826 It's common to open a QMenu in response to receiving a context menu-
6827 event. Example:-
6828-
6829 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 13-
6830-
6831 The default implementation ignores the event.-
6832-
6833 \sa sceneEvent()-
6834*/-
6835void QGraphicsItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)-
6836{-
6837 event->ignore();-
6838}
never executed: end of block
0
6839-
6840/*!-
6841 This event handler, for event \a event, can be reimplemented to receive-
6842 drag enter events for this item. Drag enter events are generated as the-
6843 cursor enters the item's area.-
6844-
6845 By accepting the event (i.e., by calling QEvent::accept()), the item will-
6846 accept drop events, in addition to receiving drag move and drag-
6847 leave. Otherwise, the event will be ignored and propagate to the item-
6848 beneath. If the event is accepted, the item will receive a drag move event-
6849 before control goes back to the event loop.-
6850-
6851 A common implementation of dragEnterEvent accepts or ignores \a event-
6852 depending on the associated mime data in \a event. Example:-
6853-
6854 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 14-
6855-
6856 Items do not receive drag and drop events by default; to enable this-
6857 feature, call \c setAcceptDrops(true).-
6858-
6859 The default implementation does nothing.-
6860-
6861 \sa dropEvent(), dragMoveEvent(), dragLeaveEvent()-
6862*/-
6863void QGraphicsItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)-
6864{-
6865 Q_D(QGraphicsItem);-
6866 // binary compatibility workaround between 4.4 and 4.5-
6867 if (d->isProxyWidget())
d->isProxyWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
6868 static_cast<QGraphicsProxyWidget*>(this)->dragEnterEvent(event);
never executed: static_cast<QGraphicsProxyWidget*>(this)->dragEnterEvent(event);
0
6869}
never executed: end of block
0
6870-
6871/*!-
6872 This event handler, for event \a event, can be reimplemented to receive-
6873 drag leave events for this item. Drag leave events are generated as the-
6874 cursor leaves the item's area. Most often you will not need to reimplement-
6875 this function, but it can be useful for resetting state in your item-
6876 (e.g., highlighting).-
6877-
6878 Calling QEvent::ignore() or QEvent::accept() on \a event has no effect.-
6879-
6880 Items do not receive drag and drop events by default; to enable this-
6881 feature, call \c setAcceptDrops(true).-
6882-
6883 The default implementation does nothing.-
6884-
6885 \sa dragEnterEvent(), dropEvent(), dragMoveEvent()-
6886*/-
6887void QGraphicsItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)-
6888{-
6889 Q_D(QGraphicsItem);-
6890 // binary compatibility workaround between 4.4 and 4.5-
6891 if (d->isProxyWidget())
d->isProxyWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
6892 static_cast<QGraphicsProxyWidget*>(this)->dragLeaveEvent(event);
never executed: static_cast<QGraphicsProxyWidget*>(this)->dragLeaveEvent(event);
0
6893}
never executed: end of block
0
6894-
6895/*!-
6896 This event handler, for event \a event, can be reimplemented to receive-
6897 drag move events for this item. Drag move events are generated as the-
6898 cursor moves around inside the item's area. Most often you will not need-
6899 to reimplement this function; it is used to indicate that only parts of-
6900 the item can accept drops.-
6901-
6902 Calling QEvent::ignore() or QEvent::accept() on \a event toggles whether-
6903 or not the item will accept drops at the position from the event. By-
6904 default, \a event is accepted, indicating that the item allows drops at-
6905 the specified position.-
6906-
6907 Items do not receive drag and drop events by default; to enable this-
6908 feature, call \c setAcceptDrops(true).-
6909-
6910 The default implementation does nothing.-
6911-
6912 \sa dropEvent(), dragEnterEvent(), dragLeaveEvent()-
6913*/-
6914void QGraphicsItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event)-
6915{-
6916 Q_D(QGraphicsItem);-
6917 // binary compatibility workaround between 4.4 and 4.5-
6918 if (d->isProxyWidget())
d->isProxyWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
6919 static_cast<QGraphicsProxyWidget*>(this)->dragMoveEvent(event);
never executed: static_cast<QGraphicsProxyWidget*>(this)->dragMoveEvent(event);
0
6920}
never executed: end of block
0
6921-
6922/*!-
6923 This event handler, for event \a event, can be reimplemented to receive-
6924 drop events for this item. Items can only receive drop events if the last-
6925 drag move event was accepted.-
6926-
6927 Calling QEvent::ignore() or QEvent::accept() on \a event has no effect.-
6928-
6929 Items do not receive drag and drop events by default; to enable this-
6930 feature, call \c setAcceptDrops(true).-
6931-
6932 The default implementation does nothing.-
6933-
6934 \sa dragEnterEvent(), dragMoveEvent(), dragLeaveEvent()-
6935*/-
6936void QGraphicsItem::dropEvent(QGraphicsSceneDragDropEvent *event)-
6937{-
6938 Q_D(QGraphicsItem);-
6939 // binary compatibility workaround between 4.4 and 4.5-
6940 if (d->isProxyWidget())
d->isProxyWidget()Description
TRUEnever evaluated
FALSEnever evaluated
0
6941 static_cast<QGraphicsProxyWidget*>(this)->dropEvent(event);
never executed: static_cast<QGraphicsProxyWidget*>(this)->dropEvent(event);
0
6942}
never executed: end of block
0
6943-
6944/*!-
6945 This event handler, for event \a event, can be reimplemented to receive-
6946 focus in events for this item. The default implementation calls-
6947 ensureVisible().-
6948-
6949 \sa focusOutEvent(), sceneEvent(), setFocus()-
6950*/-
6951void QGraphicsItem::focusInEvent(QFocusEvent *event)-
6952{-
6953 Q_UNUSED(event);-
6954 update();-
6955}
never executed: end of block
0
6956-
6957/*!-
6958 This event handler, for event \a event, can be reimplemented to receive-
6959 focus out events for this item. The default implementation does nothing.-
6960-
6961 \sa focusInEvent(), sceneEvent(), setFocus()-
6962*/-
6963void QGraphicsItem::focusOutEvent(QFocusEvent *event)-
6964{-
6965 Q_UNUSED(event);-
6966 update();-
6967}
never executed: end of block
0
6968-
6969/*!-
6970 This event handler, for event \a event, can be reimplemented to receive-
6971 hover enter events for this item. The default implementation calls-
6972 update(); otherwise it does nothing.-
6973-
6974 Calling QEvent::ignore() or QEvent::accept() on \a event has no effect.-
6975-
6976 \sa hoverMoveEvent(), hoverLeaveEvent(), sceneEvent(), setAcceptHoverEvents()-
6977*/-
6978void QGraphicsItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)-
6979{-
6980 Q_UNUSED(event);-
6981 update();-
6982}
never executed: end of block
0
6983-
6984/*!-
6985 This event handler, for event \a event, can be reimplemented to receive-
6986 hover move events for this item. The default implementation does nothing.-
6987-
6988 Calling QEvent::ignore() or QEvent::accept() on \a event has no effect.-
6989-
6990 \sa hoverEnterEvent(), hoverLeaveEvent(), sceneEvent(), setAcceptHoverEvents()-
6991*/-
6992void QGraphicsItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)-
6993{-
6994 Q_UNUSED(event);-
6995}
never executed: end of block
0
6996-
6997/*!-
6998 This event handler, for event \a event, can be reimplemented to receive-
6999 hover leave events for this item. The default implementation calls-
7000 update(); otherwise it does nothing.-
7001-
7002 Calling QEvent::ignore() or QEvent::accept() on \a event has no effect.-
7003-
7004 \sa hoverEnterEvent(), hoverMoveEvent(), sceneEvent(), setAcceptHoverEvents()-
7005*/-
7006void QGraphicsItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)-
7007{-
7008 Q_UNUSED(event);-
7009 update();-
7010}
never executed: end of block
0
7011-
7012/*!-
7013 This event handler, for event \a event, can be reimplemented to-
7014 receive key press events for this item. The default implementation-
7015 ignores the event. If you reimplement this handler, the event will by-
7016 default be accepted.-
7017-
7018 Note that key events are only received for items that set the-
7019 ItemIsFocusable flag, and that have keyboard input focus.-
7020-
7021 \sa keyReleaseEvent(), setFocus(), QGraphicsScene::setFocusItem(),-
7022 sceneEvent()-
7023*/-
7024void QGraphicsItem::keyPressEvent(QKeyEvent *event)-
7025{-
7026 event->ignore();-
7027}
never executed: end of block
0
7028-
7029/*!-
7030 This event handler, for event \a event, can be reimplemented to receive-
7031 key release events for this item. The default implementation-
7032 ignores the event. If you reimplement this handler, the event will by-
7033 default be accepted.-
7034-
7035 Note that key events are only received for items that set the-
7036 ItemIsFocusable flag, and that have keyboard input focus.-
7037-
7038 \sa keyPressEvent(), setFocus(), QGraphicsScene::setFocusItem(),-
7039 sceneEvent()-
7040*/-
7041void QGraphicsItem::keyReleaseEvent(QKeyEvent *event)-
7042{-
7043 event->ignore();-
7044}
never executed: end of block
0
7045-
7046/*!-
7047 This event handler, for event \a event, can be reimplemented to-
7048 receive mouse press events for this item. Mouse press events are-
7049 only delivered to items that accept the mouse button that is-
7050 pressed. By default, an item accepts all mouse buttons, but you-
7051 can change this by calling setAcceptedMouseButtons().-
7052-
7053 The mouse press event decides which item should become the mouse-
7054 grabber (see QGraphicsScene::mouseGrabberItem()). If you do not-
7055 reimplement this function, the press event will propagate to any-
7056 topmost item beneath this item, and no other mouse events will be-
7057 delivered to this item.-
7058-
7059 If you do reimplement this function, \a event will by default be-
7060 accepted (see QEvent::accept()), and this item is then the mouse-
7061 grabber. This allows the item to receive future move, release and-
7062 doubleclick events. If you call QEvent::ignore() on \a event, this-
7063 item will lose the mouse grab, and \a event will propagate to any-
7064 topmost item beneath. No further mouse events will be delivered to-
7065 this item unless a new mouse press event is received.-
7066-
7067 The default implementation handles basic item interaction, such as-
7068 selection and moving. If you want to keep the base implementation-
7069 when reimplementing this function, call-
7070 QGraphicsItem::mousePressEvent() in your reimplementation.-
7071-
7072 The event is \l{QEvent::ignore()}d for items that are neither-
7073 \l{QGraphicsItem::ItemIsMovable}{movable} nor-
7074 \l{QGraphicsItem::ItemIsSelectable}{selectable}.-
7075-
7076 \sa mouseMoveEvent(), mouseReleaseEvent(),-
7077 mouseDoubleClickEvent(), sceneEvent()-
7078*/-
7079void QGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event)-
7080{-
7081 if (event->button() == Qt::LeftButton && (flags() & ItemIsSelectable)) {
event->button(...Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
(flags() & ItemIsSelectable)Description
TRUEnever evaluated
FALSEnever evaluated
0
7082 bool multiSelect = (event->modifiers() & Qt::ControlModifier) != 0;-
7083 if (!multiSelect) {
!multiSelectDescription
TRUEnever evaluated
FALSEnever evaluated
0
7084 if (!d_ptr->selected) {
!d_ptr->selectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
7085 if (QGraphicsScene *scene = d_ptr->scene) {
QGraphicsScene...= d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
7086 ++scene->d_func()->selectionChanging;-
7087 scene->clearSelection();-
7088 --scene->d_func()->selectionChanging;-
7089 }
never executed: end of block
0
7090 setSelected(true);-
7091 }
never executed: end of block
0
7092 }
never executed: end of block
0
7093 } else if (!(flags() & ItemIsMovable)) {
never executed: end of block
!(flags() & ItemIsMovable)Description
TRUEnever evaluated
FALSEnever evaluated
0
7094 event->ignore();-
7095 }
never executed: end of block
0
7096 if (d_ptr->isWidget) {
d_ptr->isWidgetDescription
TRUEnever evaluated
FALSEnever evaluated
0
7097 // Qt::Popup closes when you click outside.-
7098 QGraphicsWidget *w = static_cast<QGraphicsWidget *>(this);-
7099 if ((w->windowFlags() & Qt::Popup) == Qt::Popup) {
(w->windowFlag...) == Qt::PopupDescription
TRUEnever evaluated
FALSEnever evaluated
0
7100 event->accept();-
7101 if (!w->rect().contains(event->pos()))
!w->rect().con...(event->pos())Description
TRUEnever evaluated
FALSEnever evaluated
0
7102 w->close();
never executed: w->close();
0
7103 }
never executed: end of block
0
7104 }
never executed: end of block
0
7105}
never executed: end of block
0
7106-
7107/*!-
7108 obsolete-
7109*/-
7110bool _qt_movableAncestorIsSelected(const QGraphicsItem *item)-
7111{-
7112 const QGraphicsItem *parent = item->parentItem();-
7113 return parent && (((parent->flags() & QGraphicsItem::ItemIsMovable) && parent->isSelected()) || _qt_movableAncestorIsSelected(parent));
never executed: return parent && (((parent->flags() & QGraphicsItem::ItemIsMovable) && parent->isSelected()) || _qt_movableAncestorIsSelected(parent));
parentDescription
TRUEnever evaluated
FALSEnever evaluated
(parent->flags...ItemIsMovable)Description
TRUEnever evaluated
FALSEnever evaluated
parent->isSelected()Description
TRUEnever evaluated
FALSEnever evaluated
_qt_movableAnc...lected(parent)Description
TRUEnever evaluated
FALSEnever evaluated
0
7114}-
7115-
7116bool QGraphicsItemPrivate::movableAncestorIsSelected(const QGraphicsItem *item)-
7117{-
7118 const QGraphicsItem *parent = item->d_ptr->parent;-
7119 return parent && (((parent->flags() & QGraphicsItem::ItemIsMovable) && parent->isSelected()) || _qt_movableAncestorIsSelected(parent));
never executed: return parent && (((parent->flags() & QGraphicsItem::ItemIsMovable) && parent->isSelected()) || _qt_movableAncestorIsSelected(parent));
parentDescription
TRUEnever evaluated
FALSEnever evaluated
(parent->flags...ItemIsMovable)Description
TRUEnever evaluated
FALSEnever evaluated
parent->isSelected()Description
TRUEnever evaluated
FALSEnever evaluated
_qt_movableAnc...lected(parent)Description
TRUEnever evaluated
FALSEnever evaluated
0
7120}-
7121-
7122/*!-
7123 This event handler, for event \a event, can be reimplemented to-
7124 receive mouse move events for this item. If you do receive this-
7125 event, you can be certain that this item also received a mouse-
7126 press event, and that this item is the current mouse grabber.-
7127-
7128 Calling QEvent::ignore() or QEvent::accept() on \a event has no-
7129 effect.-
7130-
7131 The default implementation handles basic item interaction, such as-
7132 selection and moving. If you want to keep the base implementation-
7133 when reimplementing this function, call-
7134 QGraphicsItem::mouseMoveEvent() in your reimplementation.-
7135-
7136 Please note that mousePressEvent() decides which graphics item it-
7137 is that receives mouse events. See the mousePressEvent()-
7138 description for details.-
7139-
7140 \sa mousePressEvent(), mouseReleaseEvent(),-
7141 mouseDoubleClickEvent(), sceneEvent()-
7142*/-
7143void QGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)-
7144{-
7145 if ((event->buttons() & Qt::LeftButton) && (flags() & ItemIsMovable)) {
(event->button...t::LeftButton)Description
TRUEnever evaluated
FALSEnever evaluated
(flags() & ItemIsMovable)Description
TRUEnever evaluated
FALSEnever evaluated
0
7146 // Determine the list of items that need to be moved.-
7147 QList<QGraphicsItem *> selectedItems;-
7148 QHash<QGraphicsItem *, QPointF> initialPositions;-
7149 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
7150 selectedItems = d_ptr->scene->selectedItems();-
7151 initialPositions = d_ptr->scene->d_func()->movingItemsInitialPositions;-
7152 if (initialPositions.isEmpty()) {
initialPositions.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
7153 foreach (QGraphicsItem *item, selectedItems)-
7154 initialPositions[item] = item->pos();
never executed: initialPositions[item] = item->pos();
0
7155 initialPositions[this] = pos();-
7156 }
never executed: end of block
0
7157 d_ptr->scene->d_func()->movingItemsInitialPositions = initialPositions;-
7158 }
never executed: end of block
0
7159-
7160 // Find the active view.-
7161 QGraphicsView *view = 0;-
7162 if (event->widget())
event->widget()Description
TRUEnever evaluated
FALSEnever evaluated
0
7163 view = qobject_cast<QGraphicsView *>(event->widget()->parentWidget());
never executed: view = qobject_cast<QGraphicsView *>(event->widget()->parentWidget());
0
7164-
7165 // Move all selected items-
7166 int i = 0;-
7167 bool movedMe = false;-
7168 while (i <= selectedItems.size()) {
i <= selectedItems.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
7169 QGraphicsItem *item = 0;-
7170 if (i < selectedItems.size())
i < selectedItems.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
7171 item = selectedItems.at(i);
never executed: item = selectedItems.at(i);
0
7172 else-
7173 item = this;
never executed: item = this;
0
7174 if (item == this) {
item == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
7175 // Slightly clumsy-looking way to ensure that "this" is part-
7176 // of the list of items to move, this is to avoid allocations-
7177 // (appending this item to the list of selected items causes a-
7178 // detach).-
7179 if (movedMe)
movedMeDescription
TRUEnever evaluated
FALSEnever evaluated
0
7180 break;
never executed: break;
0
7181 movedMe = true;-
7182 }
never executed: end of block
0
7183-
7184 if ((item->flags() & ItemIsMovable) && !QGraphicsItemPrivate::movableAncestorIsSelected(item)) {
(item->flags()...ItemIsMovable)Description
TRUEnever evaluated
FALSEnever evaluated
!QGraphicsItem...Selected(item)Description
TRUEnever evaluated
FALSEnever evaluated
0
7185 QPointF currentParentPos;-
7186 QPointF buttonDownParentPos;-
7187 if (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorIgnoresTransformations) {
item->d_ptr->a...ransformationsDescription
TRUEnever evaluated
FALSEnever evaluated
0
7188 // Items whose ancestors ignore transformations need to-
7189 // map screen coordinates to local coordinates, then map-
7190 // those to the parent.-
7191 QTransform viewToItemTransform = (item->deviceTransform(view->viewportTransform())).inverted();-
7192 currentParentPos = mapToParent(viewToItemTransform.map(QPointF(view->mapFromGlobal(event->screenPos()))));-
7193 buttonDownParentPos = mapToParent(viewToItemTransform.map(QPointF(view->mapFromGlobal(event->buttonDownScreenPos(Qt::LeftButton)))));-
7194 } else if (item->flags() & ItemIgnoresTransformations) {
never executed: end of block
item->flags() ...ransformationsDescription
TRUEnever evaluated
FALSEnever evaluated
0
7195 // Root items that ignore transformations need to-
7196 // calculate their diff by mapping viewport coordinates-
7197 // directly to parent coordinates.-
7198 // COMBINE-
7199 QTransform itemTransform;-
7200 if (item->d_ptr->transformData)
item->d_ptr->transformDataDescription
TRUEnever evaluated
FALSEnever evaluated
0
7201 itemTransform = item->d_ptr->transformData->computedFullTransform();
never executed: itemTransform = item->d_ptr->transformData->computedFullTransform();
0
7202 itemTransform.translate(item->d_ptr->pos.x(), item->d_ptr->pos.y());-
7203 QTransform viewToParentTransform = itemTransform-
7204 * (item->sceneTransform() * view->viewportTransform()).inverted();-
7205 currentParentPos = viewToParentTransform.map(QPointF(view->mapFromGlobal(event->screenPos())));-
7206 buttonDownParentPos = viewToParentTransform.map(QPointF(view->mapFromGlobal(event->buttonDownScreenPos(Qt::LeftButton))));-
7207 } else {
never executed: end of block
0
7208 // All other items simply map from the scene.-
7209 currentParentPos = item->mapToParent(item->mapFromScene(event->scenePos()));-
7210 buttonDownParentPos = item->mapToParent(item->mapFromScene(event->buttonDownScenePos(Qt::LeftButton)));-
7211 }
never executed: end of block
0
7212-
7213 item->setPos(initialPositions.value(item) + currentParentPos - buttonDownParentPos);-
7214-
7215 if (item->flags() & ItemIsSelectable)
item->flags() ...emIsSelectableDescription
TRUEnever evaluated
FALSEnever evaluated
0
7216 item->setSelected(true);
never executed: item->setSelected(true);
0
7217 }
never executed: end of block
0
7218 ++i;-
7219 }
never executed: end of block
0
7220-
7221 } else {
never executed: end of block
0
7222 event->ignore();-
7223 }
never executed: end of block
0
7224}-
7225-
7226/*!-
7227 This event handler, for event \a event, can be reimplemented to-
7228 receive mouse release events for this item.-
7229-
7230 Calling QEvent::ignore() or QEvent::accept() on \a event has no-
7231 effect.-
7232-
7233 The default implementation handles basic item interaction, such as-
7234 selection and moving. If you want to keep the base implementation-
7235 when reimplementing this function, call-
7236 QGraphicsItem::mouseReleaseEvent() in your reimplementation.-
7237-
7238 Please note that mousePressEvent() decides which graphics item it-
7239 is that receives mouse events. See the mousePressEvent()-
7240 description for details.-
7241-
7242 \sa mousePressEvent(), mouseMoveEvent(), mouseDoubleClickEvent(),-
7243 sceneEvent()-
7244*/-
7245void QGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)-
7246{-
7247 if (event->button() == Qt::LeftButton && (flags() & ItemIsSelectable)) {
event->button(...Qt::LeftButtonDescription
TRUEnever evaluated
FALSEnever evaluated
(flags() & ItemIsSelectable)Description
TRUEnever evaluated
FALSEnever evaluated
0
7248 bool multiSelect = (event->modifiers() & Qt::ControlModifier) != 0;-
7249 if (event->scenePos() == event->buttonDownScenePos(Qt::LeftButton)) {
event->scenePo...t::LeftButton)Description
TRUEnever evaluated
FALSEnever evaluated
0
7250 // The item didn't move-
7251 if (multiSelect) {
multiSelectDescription
TRUEnever evaluated
FALSEnever evaluated
0
7252 setSelected(!isSelected());-
7253 } else {
never executed: end of block
0
7254 bool selectionChanged = false;-
7255 if (QGraphicsScene *scene = d_ptr->scene) {
QGraphicsScene...= d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
7256 ++scene->d_func()->selectionChanging;-
7257 // Clear everything but this item. Bypass-
7258 // QGraphicsScene::clearSelection()'s default behavior by-
7259 // temporarily removing this item from the selection list.-
7260 if (d_ptr->selected) {
d_ptr->selectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
7261 scene->d_func()->selectedItems.remove(this);-
7262 foreach (QGraphicsItem *item, scene->d_func()->selectedItems) {-
7263 if (item->isSelected()) {
item->isSelected()Description
TRUEnever evaluated
FALSEnever evaluated
0
7264 selectionChanged = true;-
7265 break;
never executed: break;
0
7266 }-
7267 }
never executed: end of block
0
7268 }
never executed: end of block
0
7269 scene->clearSelection();-
7270 if (d_ptr->selected)
d_ptr->selectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
7271 scene->d_func()->selectedItems.insert(this);
never executed: scene->d_func()->selectedItems.insert(this);
0
7272 --scene->d_func()->selectionChanging;-
7273 if (selectionChanged)
selectionChangedDescription
TRUEnever evaluated
FALSEnever evaluated
0
7274 emit d_ptr->scene->selectionChanged();
never executed: d_ptr->scene->selectionChanged();
0
7275 }
never executed: end of block
0
7276 setSelected(true);-
7277 }
never executed: end of block
0
7278 }-
7279 }
never executed: end of block
0
7280 if (d_ptr->scene && !event->buttons())
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
!event->buttons()Description
TRUEnever evaluated
FALSEnever evaluated
0
7281 d_ptr->scene->d_func()->movingItemsInitialPositions.clear();
never executed: d_ptr->scene->d_func()->movingItemsInitialPositions.clear();
0
7282}
never executed: end of block
0
7283-
7284/*!-
7285 This event handler, for event \a event, can be reimplemented to-
7286 receive mouse doubleclick events for this item.-
7287-
7288 When doubleclicking an item, the item will first receive a mouse-
7289 press event, followed by a release event (i.e., a click), then a-
7290 doubleclick event, and finally a release event.-
7291-
7292 Calling QEvent::ignore() or QEvent::accept() on \a event has no-
7293 effect.-
7294-
7295 The default implementation calls mousePressEvent(). If you want to-
7296 keep the base implementation when reimplementing this function,-
7297 call QGraphicsItem::mouseDoubleClickEvent() in your-
7298 reimplementation.-
7299-
7300 Note that an item will not receive double click events if it is-
7301 neither \l {QGraphicsItem::ItemIsSelectable}{selectable} nor-
7302 \l{QGraphicsItem::ItemIsMovable}{movable} (single mouse clicks are-
7303 ignored in this case, and that stops the generation of double-
7304 clicks).-
7305-
7306 \sa mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(), sceneEvent()-
7307*/-
7308void QGraphicsItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)-
7309{-
7310 mousePressEvent(event);-
7311}
never executed: end of block
0
7312-
7313/*!-
7314 This event handler, for event \a event, can be reimplemented to receive-
7315 wheel events for this item. If you reimplement this function, \a event-
7316 will be accepted by default.-
7317-
7318 If you ignore the event, (i.e., by calling QEvent::ignore(),) it will-
7319 propagate to any item beneath this item. If no items accept the event, it-
7320 will be ignored by the scene, and propagate to the view (e.g., the view's-
7321 vertical scroll bar).-
7322-
7323 The default implementation ignores the event.-
7324-
7325 \sa sceneEvent()-
7326*/-
7327void QGraphicsItem::wheelEvent(QGraphicsSceneWheelEvent *event)-
7328{-
7329 event->ignore();-
7330}
never executed: end of block
0
7331-
7332/*!-
7333 This event handler, for event \a event, can be reimplemented to receive-
7334 input method events for this item. The default implementation ignores the-
7335 event.-
7336-
7337 \sa inputMethodQuery(), sceneEvent()-
7338*/-
7339void QGraphicsItem::inputMethodEvent(QInputMethodEvent *event)-
7340{-
7341 event->ignore();-
7342}
never executed: end of block
0
7343-
7344/*!-
7345 This method is only relevant for input items. It is used by the-
7346 input method to query a set of properties of the item to be able-
7347 to support complex input method operations, such as support for-
7348 surrounding text and reconversions. \a query specifies which-
7349 property is queried.-
7350-
7351 \sa inputMethodEvent(), QInputMethodEvent-
7352*/-
7353QVariant QGraphicsItem::inputMethodQuery(Qt::InputMethodQuery query) const-
7354{-
7355 Q_UNUSED(query);-
7356 return QVariant();
never executed: return QVariant();
0
7357}-
7358-
7359/*!-
7360 Returns the current input method hints of this item.-
7361-
7362 Input method hints are only relevant for input items.-
7363 The hints are used by the input method to indicate how it should operate.-
7364 For example, if the Qt::ImhNumbersOnly flag is set, the input method may change-
7365 its visual components to reflect that only numbers can be entered.-
7366-
7367 The effect may vary between input method implementations.-
7368-
7369 \since 4.6-
7370-
7371 \sa setInputMethodHints(), inputMethodQuery()-
7372*/-
7373Qt::InputMethodHints QGraphicsItem::inputMethodHints() const-
7374{-
7375 Q_D(const QGraphicsItem);-
7376 return d->imHints;
never executed: return d->imHints;
0
7377}-
7378-
7379/*!-
7380 Sets the current input method hints of this item to \a hints.-
7381-
7382 \since 4.6-
7383-
7384 \sa inputMethodHints(), inputMethodQuery()-
7385*/-
7386void QGraphicsItem::setInputMethodHints(Qt::InputMethodHints hints)-
7387{-
7388 Q_D(QGraphicsItem);-
7389 d->imHints = hints;-
7390 if (!hasFocus())
!hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
7391 return;
never executed: return;
0
7392 d->scene->d_func()->updateInputMethodSensitivityInViews();-
7393 QWidget *fw = QApplication::focusWidget();-
7394 if (!fw)
!fwDescription
TRUEnever evaluated
FALSEnever evaluated
0
7395 return;
never executed: return;
0
7396 QGuiApplication::inputMethod()->update(Qt::ImHints);-
7397}
never executed: end of block
0
7398-
7399/*!-
7400 Updates the item's micro focus.-
7401-
7402 \since 4.7-
7403-
7404 \sa QInputMethod-
7405*/-
7406void QGraphicsItem::updateMicroFocus()-
7407{-
7408#if !defined(QT_NO_IM) && defined(Q_DEAD_CODE_FROM_QT4_X11)-
7409 if (QWidget *fw = QApplication::focusWidget()) {-
7410 if (scene()) {-
7411 for (int i = 0 ; i < scene()->views().count() ; ++i) {-
7412 if (scene()->views().at(i) == fw) {-
7413 if (qApp)-
7414 QGuiApplication::inputMethod()->update(Qt::ImQueryAll);-
7415 break;-
7416 }-
7417 }-
7418 }-
7419 }-
7420#endif-
7421}-
7422-
7423/*!-
7424 This virtual function is called by QGraphicsItem to notify custom items-
7425 that some part of the item's state changes. By reimplementing this-
7426 function, you can react to a change, and in some cases (depending on \a-
7427 change), adjustments can be made.-
7428-
7429 \a change is the parameter of the item that is changing. \a value is the-
7430 new value; the type of the value depends on \a change.-
7431-
7432 Example:-
7433-
7434 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 15-
7435-
7436 The default implementation does nothing, and returns \a value.-
7437-
7438 Note: Certain QGraphicsItem functions cannot be called in a-
7439 reimplementation of this function; see the GraphicsItemChange-
7440 documentation for details.-
7441-
7442 \sa GraphicsItemChange-
7443*/-
7444QVariant QGraphicsItem::itemChange(GraphicsItemChange change, const QVariant &value)-
7445{-
7446 Q_UNUSED(change);-
7447 return value;
never executed: return value;
0
7448}-
7449-
7450/*!-
7451 \internal-
7452-
7453 Note: This is provided as a hook to avoid future problems related-
7454 to adding virtual functions.-
7455*/-
7456bool QGraphicsItem::supportsExtension(Extension extension) const-
7457{-
7458 Q_UNUSED(extension);-
7459 return false;
never executed: return false;
0
7460}-
7461-
7462/*!-
7463 \internal-
7464-
7465 Note: This is provided as a hook to avoid future problems related-
7466 to adding virtual functions.-
7467*/-
7468void QGraphicsItem::setExtension(Extension extension, const QVariant &variant)-
7469{-
7470 Q_UNUSED(extension);-
7471 Q_UNUSED(variant);-
7472}
never executed: end of block
0
7473-
7474/*!-
7475 \internal-
7476-
7477 Note: This is provided as a hook to avoid future problems related-
7478 to adding virtual functions.-
7479*/-
7480QVariant QGraphicsItem::extension(const QVariant &variant) const-
7481{-
7482 Q_UNUSED(variant);-
7483 return QVariant();
never executed: return QVariant();
0
7484}-
7485-
7486/*!-
7487 \internal-
7488-
7489 Adds this item to the scene's index. Called in conjunction with-
7490 removeFromIndex() to ensure the index bookkeeping is correct when-
7491 the item's position, transformation or shape changes.-
7492*/-
7493void QGraphicsItem::addToIndex()-
7494{-
7495 if (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren
d_ptr->ancesto...rClipsChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
7496 || d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorContainsChildren) {
d_ptr->ancesto...ntainsChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
7497 // ### add to child index only if applicable-
7498 return;
never executed: return;
0
7499 }-
7500 if (d_ptr->scene)
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
7501 d_ptr->scene->d_func()->index->addItem(this);
never executed: d_ptr->scene->d_func()->index->addItem(this);
0
7502}
never executed: end of block
0
7503-
7504/*!-
7505 \internal-
7506-
7507 Removes this item from the scene's index. Called in conjunction-
7508 with addToIndex() to ensure the index bookkeeping is correct when-
7509 the item's position, transformation or shape changes.-
7510*/-
7511void QGraphicsItem::removeFromIndex()-
7512{-
7513 if (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren
d_ptr->ancesto...rClipsChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
7514 || d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorContainsChildren) {
d_ptr->ancesto...ntainsChildrenDescription
TRUEnever evaluated
FALSEnever evaluated
0
7515 // ### remove from child index only if applicable-
7516 return;
never executed: return;
0
7517 }-
7518 if (d_ptr->scene)
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
7519 d_ptr->scene->d_func()->index->removeItem(this);
never executed: d_ptr->scene->d_func()->index->removeItem(this);
0
7520}
never executed: end of block
0
7521-
7522/*!-
7523 Prepares the item for a geometry change. Call this function before-
7524 changing the bounding rect of an item to keep QGraphicsScene's index up to-
7525 date.-
7526-
7527 prepareGeometryChange() will call update() if this is necessary.-
7528-
7529 Example:-
7530-
7531 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 16-
7532-
7533 \sa boundingRect()-
7534*/-
7535void QGraphicsItem::prepareGeometryChange()-
7536{-
7537 if (d_ptr->inDestructor)
d_ptr->inDestructorDescription
TRUEnever evaluated
FALSEnever evaluated
0
7538 return;
never executed: return;
0
7539 if (d_ptr->scene) {
d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
7540 d_ptr->scene->d_func()->dirtyGrowingItemsBoundingRect = true;-
7541 d_ptr->geometryChanged = 1;-
7542 d_ptr->paintedViewBoundingRectsNeedRepaint = 1;-
7543 d_ptr->notifyBoundingRectChanged = !d_ptr->inSetPosHelper;-
7544-
7545 QGraphicsScenePrivate *scenePrivate = d_ptr->scene->d_func();-
7546 scenePrivate->index->prepareBoundingRectChange(this);-
7547 scenePrivate->markDirty(this, QRectF(), /*invalidateChildren=*/true, /*force=*/false,-
7548 /*ignoreOpacity=*/ false, /*removingItemFromScene=*/ false,-
7549 /*updateBoundingRect=*/true);-
7550-
7551 // For compatibility reasons, we have to update the item's old geometry-
7552 // if someone is connected to the changed signal or the scene has no views.-
7553 // Note that this has to be done *after* markDirty to ensure that-
7554 // _q_processDirtyItems is called before _q_emitUpdated.-
7555 if (scenePrivate->isSignalConnected(scenePrivate->changedSignalIndex)
scenePrivate->...edSignalIndex)Description
TRUEnever evaluated
FALSEnever evaluated
0
7556 || scenePrivate->views.isEmpty()) {
scenePrivate->views.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
7557 if (d_ptr->hasTranslateOnlySceneTransform()) {
d_ptr->hasTran...eneTransform()Description
TRUEnever evaluated
FALSEnever evaluated
0
7558 d_ptr->scene->update(boundingRect().translated(d_ptr->sceneTransform.dx(),-
7559 d_ptr->sceneTransform.dy()));-
7560 } else {
never executed: end of block
0
7561 d_ptr->scene->update(d_ptr->sceneTransform.mapRect(boundingRect()));-
7562 }
never executed: end of block
0
7563 }-
7564 }
never executed: end of block
0
7565-
7566 d_ptr->markParentDirty(/*updateBoundingRect=*/true);-
7567}
never executed: end of block
0
7568-
7569/*!-
7570 \internal-
7571-
7572 Highlights \a item as selected.-
7573-
7574 NOTE: This function is a duplicate of qt_graphicsItem_highlightSelected() in-
7575 qgraphicssvgitem.cpp!-
7576*/-
7577static void qt_graphicsItem_highlightSelected(-
7578 QGraphicsItem *item, QPainter *painter, const QStyleOptionGraphicsItem *option)-
7579{-
7580 const QRectF murect = painter->transform().mapRect(QRectF(0, 0, 1, 1));-
7581 if (qFuzzyIsNull(qMax(murect.width(), murect.height())))
qFuzzyIsNull(q...ect.height()))Description
TRUEnever evaluated
FALSEnever evaluated
0
7582 return;
never executed: return;
0
7583-
7584 const QRectF mbrect = painter->transform().mapRect(item->boundingRect());-
7585 if (qMin(mbrect.width(), mbrect.height()) < qreal(1.0))
qMin(mbrect.wi...) < qreal(1.0)Description
TRUEnever evaluated
FALSEnever evaluated
0
7586 return;
never executed: return;
0
7587-
7588 qreal itemPenWidth;-
7589 switch (item->type()) {-
7590 case QGraphicsEllipseItem::Type:
never executed: case QGraphicsEllipseItem::Type:
0
7591 itemPenWidth = static_cast<QGraphicsEllipseItem *>(item)->pen().widthF();-
7592 break;
never executed: break;
0
7593 case QGraphicsPathItem::Type:
never executed: case QGraphicsPathItem::Type:
0
7594 itemPenWidth = static_cast<QGraphicsPathItem *>(item)->pen().widthF();-
7595 break;
never executed: break;
0
7596 case QGraphicsPolygonItem::Type:
never executed: case QGraphicsPolygonItem::Type:
0
7597 itemPenWidth = static_cast<QGraphicsPolygonItem *>(item)->pen().widthF();-
7598 break;
never executed: break;
0
7599 case QGraphicsRectItem::Type:
never executed: case QGraphicsRectItem::Type:
0
7600 itemPenWidth = static_cast<QGraphicsRectItem *>(item)->pen().widthF();-
7601 break;
never executed: break;
0
7602 case QGraphicsSimpleTextItem::Type:
never executed: case QGraphicsSimpleTextItem::Type:
0
7603 itemPenWidth = static_cast<QGraphicsSimpleTextItem *>(item)->pen().widthF();-
7604 break;
never executed: break;
0
7605 case QGraphicsLineItem::Type:
never executed: case QGraphicsLineItem::Type:
0
7606 itemPenWidth = static_cast<QGraphicsLineItem *>(item)->pen().widthF();-
7607 break;
never executed: break;
0
7608 default:
never executed: default:
0
7609 itemPenWidth = 1.0;-
7610 }
never executed: end of block
0
7611 const qreal pad = itemPenWidth / 2;-
7612-
7613 const qreal penWidth = 0; // cosmetic pen-
7614-
7615 const QColor fgcolor = option->palette.windowText().color();-
7616 const QColor bgcolor( // ensure good contrast against fgcolor-
7617 fgcolor.red() > 127 ? 0 : 255,-
7618 fgcolor.green() > 127 ? 0 : 255,-
7619 fgcolor.blue() > 127 ? 0 : 255);-
7620-
7621 painter->setPen(QPen(bgcolor, penWidth, Qt::SolidLine));-
7622 painter->setBrush(Qt::NoBrush);-
7623 painter->drawRect(item->boundingRect().adjusted(pad, pad, -pad, -pad));-
7624-
7625 painter->setPen(QPen(option->palette.windowText(), 0, Qt::DashLine));-
7626 painter->setBrush(Qt::NoBrush);-
7627 painter->drawRect(item->boundingRect().adjusted(pad, pad, -pad, -pad));-
7628}
never executed: end of block
0
7629-
7630/*!-
7631 \class QGraphicsObject-
7632 \brief The QGraphicsObject class provides a base class for all graphics items that-
7633 require signals, slots and properties.-
7634 \since 4.6-
7635 \ingroup graphicsview-api-
7636 \inmodule QtWidgets-
7637-
7638 The class extends a QGraphicsItem with QObject's signal/slot and property mechanisms.-
7639 It maps many of QGraphicsItem's basic setters and getters to properties and adds notification-
7640 signals for many of them.-
7641-
7642 \section1 Parents and Children-
7643-
7644 Each graphics object can be constructed with a parent item. This ensures that the-
7645 item will be destroyed when its parent item is destroyed. Although QGraphicsObject-
7646 inherits from both QObject and QGraphicsItem, you should use the functions provided-
7647 by QGraphicsItem, \e not QObject, to manage the relationships between parent and-
7648 child items.-
7649-
7650 The relationships between items can be explored using the parentItem() and childItems()-
7651 functions. In the hierarchy of items in a scene, the parentObject() and parentWidget()-
7652 functions are the equivalent of the QWidget::parent() and QWidget::parentWidget()-
7653 functions for QWidget subclasses.-
7654-
7655 \sa QGraphicsWidget-
7656*/-
7657-
7658/*!-
7659 Constructs a QGraphicsObject with \a parent.-
7660*/-
7661QGraphicsObject::QGraphicsObject(QGraphicsItem *parent)-
7662 : QGraphicsItem(parent)-
7663{-
7664 QGraphicsItem::d_ptr->isObject = true;-
7665}
never executed: end of block
0
7666-
7667/*!-
7668 \internal-
7669*/-
7670QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent)-
7671 : QGraphicsItem(dd, parent)-
7672{-
7673 QGraphicsItem::d_ptr->isObject = true;-
7674}
never executed: end of block
0
7675-
7676/*!-
7677 Destructor.-
7678*/-
7679QGraphicsObject::~QGraphicsObject()-
7680{-
7681}-
7682-
7683/*!-
7684 \reimp-
7685*/-
7686bool QGraphicsObject::event(QEvent *ev)-
7687{-
7688 if (ev->type() == QEvent::StyleAnimationUpdate) {
ev->type() == ...nimationUpdateDescription
TRUEnever evaluated
FALSEnever evaluated
0
7689 if (isVisible()) {
isVisible()Description
TRUEnever evaluated
FALSEnever evaluated
0
7690 ev->accept();-
7691 update();-
7692 }
never executed: end of block
0
7693 return true;
never executed: return true;
0
7694 }-
7695 return QObject::event(ev);
never executed: return QObject::event(ev);
0
7696}-
7697-
7698#ifndef QT_NO_GESTURES-
7699/*!-
7700 Subscribes the graphics object to the given \a gesture with specific \a flags.-
7701-
7702 \sa ungrabGesture(), QGestureEvent-
7703*/-
7704void QGraphicsObject::grabGesture(Qt::GestureType gesture, Qt::GestureFlags flags)-
7705{-
7706 bool contains = QGraphicsItem::d_ptr->gestureContext.contains(gesture);-
7707 QGraphicsItem::d_ptr->gestureContext.insert(gesture, flags);-
7708 if (!contains && QGraphicsItem::d_ptr->scene)
!containsDescription
TRUEnever evaluated
FALSEnever evaluated
QGraphicsItem::d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
7709 QGraphicsItem::d_ptr->scene->d_func()->grabGesture(this, gesture);
never executed: QGraphicsItem::d_ptr->scene->d_func()->grabGesture(this, gesture);
0
7710}
never executed: end of block
0
7711-
7712/*!-
7713 Unsubscribes the graphics object from the given \a gesture.-
7714-
7715 \sa grabGesture(), QGestureEvent-
7716*/-
7717void QGraphicsObject::ungrabGesture(Qt::GestureType gesture)-
7718{-
7719 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
7720 QGraphicsItem::d_ptr->scene->d_func()->ungrabGesture(this, gesture);
never executed: QGraphicsItem::d_ptr->scene->d_func()->ungrabGesture(this, gesture);
0
7721}
never executed: end of block
0
7722#endif // QT_NO_GESTURES-
7723-
7724/*!-
7725 Updates the item's micro focus. This is slot for convenience.-
7726-
7727 \since 4.7-
7728-
7729 \sa QInputMethod-
7730*/-
7731void QGraphicsObject::updateMicroFocus()-
7732{-
7733 QGraphicsItem::updateMicroFocus();-
7734}
never executed: end of block
0
7735-
7736void QGraphicsItemPrivate::children_append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item)-
7737{-
7738 if (item) {
itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
7739 QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(list->object);-
7740 if (QGraphicsItemPrivate::get(graphicsObject)->sendParentChangeNotification) {
QGraphicsItemP...geNotificationDescription
TRUEnever evaluated
FALSEnever evaluated
0
7741 item->setParentItem(graphicsObject);-
7742 } else {
never executed: end of block
0
7743 QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, 0, 0);-
7744 }
never executed: end of block
0
7745 }-
7746}
never executed: end of block
0
7747-
7748int QGraphicsItemPrivate::children_count(QDeclarativeListProperty<QGraphicsObject> *list)-
7749{-
7750 QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object));-
7751 return d->children.count();
never executed: return d->children.count();
0
7752}-
7753-
7754QGraphicsObject *QGraphicsItemPrivate::children_at(QDeclarativeListProperty<QGraphicsObject> *list, int index)-
7755{-
7756 QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object));-
7757 if (index >= 0 && index < d->children.count())
index >= 0Description
TRUEnever evaluated
FALSEnever evaluated
index < d->children.count()Description
TRUEnever evaluated
FALSEnever evaluated
0
7758 return d->children.at(index)->toGraphicsObject();
never executed: return d->children.at(index)->toGraphicsObject();
0
7759 else-
7760 return 0;
never executed: return 0;
0
7761}-
7762-
7763void QGraphicsItemPrivate::children_clear(QDeclarativeListProperty<QGraphicsObject> *list)-
7764{-
7765 QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object));-
7766 int childCount = d->children.count();-
7767 if (d->sendParentChangeNotification) {
d->sendParentC...geNotificationDescription
TRUEnever evaluated
FALSEnever evaluated
0
7768 for (int index = 0; index < childCount; index++)
index < childCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
7769 d->children.at(0)->setParentItem(0);
never executed: d->children.at(0)->setParentItem(0);
0
7770 } else {
never executed: end of block
0
7771 for (int index = 0; index < childCount; index++)
index < childCountDescription
TRUEnever evaluated
FALSEnever evaluated
0
7772 QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(0, 0, 0);
never executed: QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(0, 0, 0);
0
7773 }
never executed: end of block
0
7774}-
7775-
7776/*!-
7777 Returns a list of this item's children.-
7778-
7779 The items are sorted by stacking order. This takes into account both the-
7780 items' insertion order and their Z-values.-
7781-
7782*/-
7783QDeclarativeListProperty<QGraphicsObject> QGraphicsItemPrivate::childrenList()-
7784{-
7785 Q_Q(QGraphicsItem);-
7786 if (isObject) {
isObjectDescription
TRUEnever evaluated
FALSEnever evaluated
0
7787 QGraphicsObject *that = static_cast<QGraphicsObject *>(q);-
7788 return QDeclarativeListProperty<QGraphicsObject>(that, &children, children_append,
never executed: return QDeclarativeListProperty<QGraphicsObject>(that, &children, children_append, children_count, children_at, children_clear);
0
7789 children_count, children_at, children_clear);
never executed: return QDeclarativeListProperty<QGraphicsObject>(that, &children, children_append, children_count, children_at, children_clear);
0
7790 } else {-
7791 //QGraphicsItem is not supported for this property-
7792 return QDeclarativeListProperty<QGraphicsObject>();
never executed: return QDeclarativeListProperty<QGraphicsObject>();
0
7793 }-
7794}-
7795-
7796/*!-
7797 \internal-
7798 Returns the width of the item-
7799 Reimplemented by QGraphicsWidget-
7800*/-
7801qreal QGraphicsItemPrivate::width() const-
7802{-
7803 return 0;
never executed: return 0;
0
7804}-
7805-
7806/*!-
7807 \internal-
7808 Set the width of the item-
7809 Reimplemented by QGraphicsWidget-
7810*/-
7811void QGraphicsItemPrivate::setWidth(qreal w)-
7812{-
7813 Q_UNUSED(w);-
7814}
never executed: end of block
0
7815-
7816/*!-
7817 \internal-
7818 Reset the width of the item-
7819 Reimplemented by QGraphicsWidget-
7820*/-
7821void QGraphicsItemPrivate::resetWidth()-
7822{-
7823}-
7824-
7825/*!-
7826 \internal-
7827 Returns the height of the item-
7828 Reimplemented by QGraphicsWidget-
7829*/-
7830qreal QGraphicsItemPrivate::height() const-
7831{-
7832 return 0;
never executed: return 0;
0
7833}-
7834-
7835/*!-
7836 \internal-
7837 Set the height of the item-
7838 Reimplemented by QGraphicsWidget-
7839*/-
7840void QGraphicsItemPrivate::setHeight(qreal h)-
7841{-
7842 Q_UNUSED(h);-
7843}
never executed: end of block
0
7844-
7845/*!-
7846 \internal-
7847 Reset the height of the item-
7848 Reimplemented by QGraphicsWidget-
7849*/-
7850void QGraphicsItemPrivate::resetHeight()-
7851{-
7852}-
7853-
7854/*!-
7855 \property QGraphicsObject::children-
7856 \since 4.7-
7857 \internal-
7858*/-
7859-
7860/*!-
7861 \property QGraphicsObject::width-
7862 \since 4.7-
7863 \internal-
7864*/-
7865-
7866/*!-
7867 \property QGraphicsObject::height-
7868 \since 4.7-
7869 \internal-
7870*/-
7871-
7872/*!-
7873 \property QGraphicsObject::parent-
7874 \brief the parent of the item-
7875-
7876 \note The item's parent is set independently of the parent object returned-
7877 by QObject::parent().-
7878-
7879 \sa QGraphicsItem::setParentItem(), QGraphicsItem::parentObject()-
7880*/-
7881-
7882/*!-
7883 \property QGraphicsObject::opacity-
7884 \brief the opacity of the item-
7885-
7886 \sa QGraphicsItem::setOpacity(), QGraphicsItem::opacity()-
7887*/-
7888-
7889/*!-
7890 \fn QGraphicsObject::opacityChanged()-
7891-
7892 This signal gets emitted whenever the opacity of the item changes-
7893-
7894 \sa QGraphicsItem::opacity()-
7895*/-
7896-
7897/*!-
7898 \fn QGraphicsObject::parentChanged()-
7899-
7900 This signal gets emitted whenever the parent of the item changes-
7901*/-
7902-
7903/*!-
7904 \property QGraphicsObject::pos-
7905 \brief the position of the item-
7906-
7907 Describes the items position.-
7908-
7909 \sa QGraphicsItem::setPos(), QGraphicsItem::pos()-
7910*/-
7911-
7912/*!-
7913 \property QGraphicsObject::x-
7914 \brief the x position of the item-
7915-
7916 Describes the items x position.-
7917-
7918 \sa QGraphicsItem::setX(), setPos()-
7919*/-
7920-
7921/*!-
7922 \fn QGraphicsObject::xChanged()-
7923-
7924 This signal gets emitted whenever the x position of the item changes-
7925-
7926 \sa pos()-
7927*/-
7928-
7929/*!-
7930 \property QGraphicsObject::y-
7931 \brief the y position of the item-
7932-
7933 Describes the items y position.-
7934-
7935 \sa QGraphicsItem::setY(), setPos()-
7936*/-
7937-
7938/*!-
7939 \fn QGraphicsObject::yChanged()-
7940-
7941 This signal gets emitted whenever the y position of the item changes.-
7942-
7943 \sa pos()-
7944*/-
7945-
7946/*!-
7947 \property QGraphicsObject::z-
7948 \brief the z value of the item-
7949-
7950 Describes the items z value.-
7951-
7952 \sa QGraphicsItem::setZValue(), zValue()-
7953*/-
7954-
7955/*!-
7956 \fn QGraphicsObject::zChanged()-
7957-
7958 This signal gets emitted whenever the z value of the item changes.-
7959-
7960 \sa pos()-
7961*/-
7962-
7963/*!-
7964 \property QGraphicsObject::rotation-
7965 This property holds the rotation of the item in degrees.-
7966-
7967 This specifies how many degrees to rotate the item around its transformOrigin.-
7968 The default rotation is 0 degrees (i.e. not rotated at all).-
7969*/-
7970-
7971/*!-
7972 \fn QGraphicsObject::rotationChanged()-
7973-
7974 This signal gets emitted whenever the roation of the item changes.-
7975*/-
7976-
7977/*!-
7978 \property QGraphicsObject::scale-
7979 This property holds the scale of the item.-
7980-
7981 A scale of less than 1 means the item will be displayed smaller than-
7982 normal, and a scale of greater than 1 means the item will be-
7983 displayed larger than normal. A negative scale means the item will-
7984 be mirrored.-
7985-
7986 By default, items are displayed at a scale of 1 (i.e. at their-
7987 normal size).-
7988-
7989 Scaling is from the item's transformOrigin.-
7990*/-
7991-
7992/*!-
7993 \fn void QGraphicsObject::scaleChanged()-
7994-
7995 This signal is emitted when the scale of the item changes.-
7996*/-
7997-
7998-
7999/*!-
8000 \property QGraphicsObject::enabled-
8001 \brief whether the item is enabled or not-
8002-
8003 This property is declared in QGraphicsItem.-
8004-
8005 By default, this property is \c true.-
8006-
8007 \sa QGraphicsItem::isEnabled(), QGraphicsItem::setEnabled()-
8008*/-
8009-
8010/*!-
8011 \fn void QGraphicsObject::enabledChanged()-
8012-
8013 This signal gets emitted whenever the item get's enabled or disabled.-
8014-
8015 \sa isEnabled()-
8016*/-
8017-
8018/*!-
8019 \property QGraphicsObject::visible-
8020 \brief whether the item is visible or not-
8021-
8022 This property is declared in QGraphicsItem.-
8023-
8024 By default, this property is \c true.-
8025-
8026 \sa QGraphicsItem::isVisible(), QGraphicsItem::setVisible()-
8027*/-
8028-
8029/*!-
8030 \fn QGraphicsObject::visibleChanged()-
8031-
8032 This signal gets emitted whenever the visibility of the item changes-
8033-
8034 \sa visible-
8035*/-
8036-
8037/*!-
8038 \property QGraphicsObject::transformOriginPoint-
8039 \brief the transformation origin-
8040-
8041 This property sets a specific point in the items coordiante system as the-
8042 origin for scale and rotation.-
8043-
8044 \sa scale, rotation, QGraphicsItem::transformOriginPoint()-
8045*/-
8046-
8047/*!-
8048 \fn void QGraphicsObject::widthChanged()-
8049 \internal-
8050*/-
8051-
8052/*!-
8053 \fn void QGraphicsObject::heightChanged()-
8054 \internal-
8055*/-
8056-
8057/*!-
8058-
8059 \fn QGraphicsObject::childrenChanged()-
8060-
8061 This signal gets emitted whenever the children list changes-
8062 \internal-
8063*/-
8064-
8065/*!-
8066 \property QGraphicsObject::effect-
8067 \since 4.7-
8068 \brief the effect attached to this item-
8069-
8070 \sa QGraphicsItem::setGraphicsEffect(), QGraphicsItem::graphicsEffect()-
8071*/-
8072-
8073/*!-
8074 \class QAbstractGraphicsShapeItem-
8075 \brief The QAbstractGraphicsShapeItem class provides a common base for-
8076 all path items.-
8077 \since 4.2-
8078 \ingroup graphicsview-api-
8079 \inmodule QtWidgets-
8080-
8081 This class does not fully implement an item by itself; in particular, it-
8082 does not implement boundingRect() and paint(), which are inherited by-
8083 QGraphicsItem.-
8084-
8085 You can subclass this item to provide a simple base implementation of-
8086 accessors for the item's pen and brush.-
8087-
8088 \sa QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPathItem,-
8089 QGraphicsPolygonItem, QGraphicsTextItem, QGraphicsLineItem,-
8090 QGraphicsPixmapItem, {Graphics View Framework}-
8091*/-
8092-
8093class QAbstractGraphicsShapeItemPrivate : public QGraphicsItemPrivate-
8094{-
8095 Q_DECLARE_PUBLIC(QAbstractGraphicsShapeItem)-
8096public:-
8097-
8098 QBrush brush;-
8099 QPen pen;-
8100-
8101 // Cached bounding rectangle-
8102 mutable QRectF boundingRect;-
8103};-
8104-
8105/*!-
8106 Constructs a QAbstractGraphicsShapeItem. \a parent is passed to-
8107 QGraphicsItem's constructor.-
8108*/-
8109QAbstractGraphicsShapeItem::QAbstractGraphicsShapeItem(QGraphicsItem *parent)-
8110 : QGraphicsItem(*new QAbstractGraphicsShapeItemPrivate, parent)-
8111{-
8112}
never executed: end of block
0
8113-
8114/*!-
8115 \internal-
8116*/-
8117QAbstractGraphicsShapeItem::QAbstractGraphicsShapeItem(QAbstractGraphicsShapeItemPrivate &dd, QGraphicsItem *parent)-
8118 : QGraphicsItem(dd, parent)-
8119{-
8120}
never executed: end of block
0
8121-
8122/*!-
8123 Destroys a QAbstractGraphicsShapeItem.-
8124*/-
8125QAbstractGraphicsShapeItem::~QAbstractGraphicsShapeItem()-
8126{-
8127}-
8128-
8129/*!-
8130 Returns the item's pen. If no pen has been set, this function returns-
8131 QPen(), a default black solid line pen with 1 width.-
8132*/-
8133QPen QAbstractGraphicsShapeItem::pen() const-
8134{-
8135 Q_D(const QAbstractGraphicsShapeItem);-
8136 return d->pen;
never executed: return d->pen;
0
8137}-
8138-
8139/*!-
8140 Sets the pen for this item to \a pen.-
8141-
8142 The pen is used to draw the item's outline.-
8143-
8144 \sa pen()-
8145*/-
8146void QAbstractGraphicsShapeItem::setPen(const QPen &pen)-
8147{-
8148 Q_D(QAbstractGraphicsShapeItem);-
8149 if (d->pen == pen)
d->pen == penDescription
TRUEnever evaluated
FALSEnever evaluated
0
8150 return;
never executed: return;
0
8151 prepareGeometryChange();-
8152 d->pen = pen;-
8153 d->boundingRect = QRectF();-
8154 update();-
8155}
never executed: end of block
0
8156-
8157/*!-
8158 Returns the item's brush, or an empty brush if no brush has been set.-
8159-
8160 \sa setBrush()-
8161*/-
8162QBrush QAbstractGraphicsShapeItem::brush() const-
8163{-
8164 Q_D(const QAbstractGraphicsShapeItem);-
8165 return d->brush;
never executed: return d->brush;
0
8166}-
8167-
8168/*!-
8169 Sets the item's brush to \a brush.-
8170-
8171 The item's brush is used to fill the item.-
8172-
8173 If you use a brush with a QGradient, the gradient-
8174 is relative to the item's coordinate system.-
8175-
8176 \sa brush()-
8177*/-
8178void QAbstractGraphicsShapeItem::setBrush(const QBrush &brush)-
8179{-
8180 Q_D(QAbstractGraphicsShapeItem);-
8181 if (d->brush == brush)
d->brush == brushDescription
TRUEnever evaluated
FALSEnever evaluated
0
8182 return;
never executed: return;
0
8183 d->brush = brush;-
8184 update();-
8185}
never executed: end of block
0
8186-
8187/*!-
8188 \reimp-
8189*/-
8190bool QAbstractGraphicsShapeItem::isObscuredBy(const QGraphicsItem *item) const-
8191{-
8192 return QGraphicsItem::isObscuredBy(item);
never executed: return QGraphicsItem::isObscuredBy(item);
0
8193}-
8194-
8195/*!-
8196 \reimp-
8197*/-
8198QPainterPath QAbstractGraphicsShapeItem::opaqueArea() const-
8199{-
8200 Q_D(const QAbstractGraphicsShapeItem);-
8201 if (d->brush.isOpaque())
d->brush.isOpaque()Description
TRUEnever evaluated
FALSEnever evaluated
0
8202 return isClipped() ? clipPath() : shape();
never executed: return isClipped() ? clipPath() : shape();
isClipped()Description
TRUEnever evaluated
FALSEnever evaluated
0
8203 return QGraphicsItem::opaqueArea();
never executed: return QGraphicsItem::opaqueArea();
0
8204}-
8205-
8206/*!-
8207 \class QGraphicsPathItem-
8208 \brief The QGraphicsPathItem class provides a path item that you-
8209 can add to a QGraphicsScene.-
8210 \since 4.2-
8211 \ingroup graphicsview-api-
8212 \inmodule QtWidgets-
8213-
8214 To set the item's path, pass a QPainterPath to QGraphicsPathItem's-
8215 constructor, or call the setPath() function. The path() function-
8216 returns the current path.-
8217-
8218 \image graphicsview-pathitem.png-
8219-
8220 QGraphicsPathItem uses the path to provide a reasonable-
8221 implementation of boundingRect(), shape(), and contains(). The-
8222 paint() function draws the path using the item's associated pen-
8223 and brush, which you can set by calling the setPen() and-
8224 setBrush() functions.-
8225-
8226 \sa QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPolygonItem,-
8227 QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics-
8228 View Framework}-
8229*/-
8230-
8231class QGraphicsPathItemPrivate : public QAbstractGraphicsShapeItemPrivate-
8232{-
8233 Q_DECLARE_PUBLIC(QGraphicsPathItem)-
8234public:-
8235 QPainterPath path;-
8236};-
8237-
8238/*!-
8239 Constructs a QGraphicsPath item using \a path as the default path. \a-
8240 parent is passed to QAbstractGraphicsShapeItem's constructor.-
8241-
8242 \sa QGraphicsScene::addItem()-
8243*/-
8244QGraphicsPathItem::QGraphicsPathItem(const QPainterPath &path,-
8245 QGraphicsItem *parent)-
8246 : QAbstractGraphicsShapeItem(*new QGraphicsPathItemPrivate, parent)-
8247{-
8248 if (!path.isEmpty())
!path.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
8249 setPath(path);
never executed: setPath(path);
0
8250}
never executed: end of block
0
8251-
8252/*!-
8253 Constructs a QGraphicsPath. \a parent is passed to-
8254 QAbstractGraphicsShapeItem's constructor.-
8255-
8256 \sa QGraphicsScene::addItem()-
8257*/-
8258QGraphicsPathItem::QGraphicsPathItem(QGraphicsItem *parent)-
8259 : QAbstractGraphicsShapeItem(*new QGraphicsPathItemPrivate, parent)-
8260{-
8261}
never executed: end of block
0
8262-
8263/*!-
8264 Destroys the QGraphicsPathItem.-
8265*/-
8266QGraphicsPathItem::~QGraphicsPathItem()-
8267{-
8268}-
8269-
8270/*!-
8271 Returns the item's path as a QPainterPath. If no item has been set, an-
8272 empty QPainterPath is returned.-
8273-
8274 \sa setPath()-
8275*/-
8276QPainterPath QGraphicsPathItem::path() const-
8277{-
8278 Q_D(const QGraphicsPathItem);-
8279 return d->path;
never executed: return d->path;
0
8280}-
8281-
8282/*!-
8283 Sets the item's path to be the given \a path.-
8284-
8285 \sa path()-
8286*/-
8287void QGraphicsPathItem::setPath(const QPainterPath &path)-
8288{-
8289 Q_D(QGraphicsPathItem);-
8290 if (d->path == path)
d->path == pathDescription
TRUEnever evaluated
FALSEnever evaluated
0
8291 return;
never executed: return;
0
8292 prepareGeometryChange();-
8293 d->path = path;-
8294 d->boundingRect = QRectF();-
8295 update();-
8296}
never executed: end of block
0
8297-
8298/*!-
8299 \reimp-
8300*/-
8301QRectF QGraphicsPathItem::boundingRect() const-
8302{-
8303 Q_D(const QGraphicsPathItem);-
8304 if (d->boundingRect.isNull()) {
d->boundingRect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
8305 qreal pw = pen().style() == Qt::NoPen ? qreal(0) : pen().widthF();
pen().style() == Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
0
8306 if (pw == 0.0)
pw == 0.0Description
TRUEnever evaluated
FALSEnever evaluated
0
8307 d->boundingRect = d->path.controlPointRect();
never executed: d->boundingRect = d->path.controlPointRect();
0
8308 else {-
8309 d->boundingRect = shape().controlPointRect();-
8310 }
never executed: end of block
0
8311 }-
8312 return d->boundingRect;
never executed: return d->boundingRect;
0
8313}-
8314-
8315/*!-
8316 \reimp-
8317*/-
8318QPainterPath QGraphicsPathItem::shape() const-
8319{-
8320 Q_D(const QGraphicsPathItem);-
8321 return qt_graphicsItem_shapeFromPath(d->path, d->pen);
never executed: return qt_graphicsItem_shapeFromPath(d->path, d->pen);
0
8322}-
8323-
8324/*!-
8325 \reimp-
8326*/-
8327bool QGraphicsPathItem::contains(const QPointF &point) const-
8328{-
8329 return QAbstractGraphicsShapeItem::contains(point);
never executed: return QAbstractGraphicsShapeItem::contains(point);
0
8330}-
8331-
8332/*!-
8333 \reimp-
8334*/-
8335void QGraphicsPathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,-
8336 QWidget *widget)-
8337{-
8338 Q_D(QGraphicsPathItem);-
8339 Q_UNUSED(widget);-
8340 painter->setPen(d->pen);-
8341 painter->setBrush(d->brush);-
8342 painter->drawPath(d->path);-
8343-
8344 if (option->state & QStyle::State_Selected)
option->state ...State_SelectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
8345 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
8346}
never executed: end of block
0
8347-
8348/*!-
8349 \reimp-
8350*/-
8351bool QGraphicsPathItem::isObscuredBy(const QGraphicsItem *item) const-
8352{-
8353 return QAbstractGraphicsShapeItem::isObscuredBy(item);
never executed: return QAbstractGraphicsShapeItem::isObscuredBy(item);
0
8354}-
8355-
8356/*!-
8357 \reimp-
8358*/-
8359QPainterPath QGraphicsPathItem::opaqueArea() const-
8360{-
8361 return QAbstractGraphicsShapeItem::opaqueArea();
never executed: return QAbstractGraphicsShapeItem::opaqueArea();
0
8362}-
8363-
8364/*!-
8365 \reimp-
8366*/-
8367int QGraphicsPathItem::type() const-
8368{-
8369 return Type;
never executed: return Type;
0
8370}-
8371-
8372/*!-
8373 \internal-
8374*/-
8375bool QGraphicsPathItem::supportsExtension(Extension extension) const-
8376{-
8377 Q_UNUSED(extension);-
8378 return false;
never executed: return false;
0
8379}-
8380-
8381/*!-
8382 \internal-
8383*/-
8384void QGraphicsPathItem::setExtension(Extension extension, const QVariant &variant)-
8385{-
8386 Q_UNUSED(extension);-
8387 Q_UNUSED(variant);-
8388}
never executed: end of block
0
8389-
8390/*!-
8391 \internal-
8392*/-
8393QVariant QGraphicsPathItem::extension(const QVariant &variant) const-
8394{-
8395 Q_UNUSED(variant);-
8396 return QVariant();
never executed: return QVariant();
0
8397}-
8398-
8399/*!-
8400 \class QGraphicsRectItem-
8401 \brief The QGraphicsRectItem class provides a rectangle item that you-
8402 can add to a QGraphicsScene.-
8403 \since 4.2-
8404 \ingroup graphicsview-api-
8405 \inmodule QtWidgets-
8406-
8407 To set the item's rectangle, pass a QRectF to QGraphicsRectItem's-
8408 constructor, or call the setRect() function. The rect() function-
8409 returns the current rectangle.-
8410-
8411 \image graphicsview-rectitem.png-
8412-
8413 QGraphicsRectItem uses the rectangle and the pen width to provide-
8414 a reasonable implementation of boundingRect(), shape(), and-
8415 contains(). The paint() function draws the rectangle using the-
8416 item's associated pen and brush, which you can set by calling the-
8417 setPen() and setBrush() functions.-
8418-
8419 \note The rendering of invalid rectangles, such as those with negative-
8420 widths or heights, is undefined. If you cannot be sure that you are-
8421 using valid rectangles (for example, if you are creating-
8422 rectangles using data from an unreliable source) then you should-
8423 use QRectF::normalized() to create normalized rectangles, and use-
8424 those instead.-
8425-
8426 \sa QGraphicsPathItem, QGraphicsEllipseItem, QGraphicsPolygonItem,-
8427 QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics-
8428 View Framework}-
8429*/-
8430-
8431class QGraphicsRectItemPrivate : public QAbstractGraphicsShapeItemPrivate-
8432{-
8433 Q_DECLARE_PUBLIC(QGraphicsRectItem)-
8434public:-
8435 QRectF rect;-
8436};-
8437-
8438/*!-
8439 Constructs a QGraphicsRectItem, using \a rect as the default rectangle.-
8440 \a parent is passed to QAbstractGraphicsShapeItem's constructor.-
8441-
8442 \sa QGraphicsScene::addItem()-
8443*/-
8444QGraphicsRectItem::QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent)-
8445 : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent)-
8446{-
8447 setRect(rect);-
8448}
never executed: end of block
0
8449-
8450/*!-
8451 \fn QGraphicsRectItem::QGraphicsRectItem(qreal x, qreal y, qreal width, qreal height,-
8452 QGraphicsItem *parent)-
8453-
8454 Constructs a QGraphicsRectItem with a default rectangle defined-
8455 by (\a x, \a y) and the given \a width and \a height.-
8456-
8457 \a parent is passed to QAbstractGraphicsShapeItem's constructor.-
8458-
8459 \sa QGraphicsScene::addItem()-
8460*/-
8461QGraphicsRectItem::QGraphicsRectItem(qreal x, qreal y, qreal w, qreal h,-
8462 QGraphicsItem *parent)-
8463 : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent)-
8464{-
8465 setRect(QRectF(x, y, w, h));-
8466}
never executed: end of block
0
8467-
8468/*!-
8469 Constructs a QGraphicsRectItem. \a parent is passed to-
8470 QAbstractGraphicsShapeItem's constructor.-
8471-
8472 \sa QGraphicsScene::addItem()-
8473*/-
8474QGraphicsRectItem::QGraphicsRectItem(QGraphicsItem *parent)-
8475 : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent)-
8476{-
8477}
never executed: end of block
0
8478-
8479/*!-
8480 Destroys the QGraphicsRectItem.-
8481*/-
8482QGraphicsRectItem::~QGraphicsRectItem()-
8483{-
8484}-
8485-
8486/*!-
8487 Returns the item's rectangle.-
8488-
8489 \sa setRect()-
8490*/-
8491QRectF QGraphicsRectItem::rect() const-
8492{-
8493 Q_D(const QGraphicsRectItem);-
8494 return d->rect;
never executed: return d->rect;
0
8495}-
8496-
8497/*!-
8498 \fn void QGraphicsRectItem::setRect(const QRectF &rectangle)-
8499-
8500 Sets the item's rectangle to be the given \a rectangle.-
8501-
8502 \sa rect()-
8503*/-
8504void QGraphicsRectItem::setRect(const QRectF &rect)-
8505{-
8506 Q_D(QGraphicsRectItem);-
8507 if (d->rect == rect)
d->rect == rectDescription
TRUEnever evaluated
FALSEnever evaluated
0
8508 return;
never executed: return;
0
8509 prepareGeometryChange();-
8510 d->rect = rect;-
8511 d->boundingRect = QRectF();-
8512 update();-
8513}
never executed: end of block
0
8514-
8515/*!-
8516 \fn void QGraphicsRectItem::setRect(qreal x, qreal y, qreal width, qreal height)-
8517 \fn void QGraphicsEllipseItem::setRect(qreal x, qreal y, qreal width, qreal height)-
8518-
8519 Sets the item's rectangle to the rectangle defined by (\a x, \a y)-
8520 and the given \a width and \a height.-
8521-
8522 This convenience function is equivalent to calling \c-
8523 {setRect(QRectF(x, y, width, height))}-
8524-
8525 \sa rect()-
8526*/-
8527-
8528/*!-
8529 \reimp-
8530*/-
8531QRectF QGraphicsRectItem::boundingRect() const-
8532{-
8533 Q_D(const QGraphicsRectItem);-
8534 if (d->boundingRect.isNull()) {
d->boundingRect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
8535 qreal halfpw = pen().style() == Qt::NoPen ? qreal(0) : pen().widthF() / 2;
pen().style() == Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
0
8536 d->boundingRect = d->rect;-
8537 if (halfpw > 0.0)
halfpw > 0.0Description
TRUEnever evaluated
FALSEnever evaluated
0
8538 d->boundingRect.adjust(-halfpw, -halfpw, halfpw, halfpw);
never executed: d->boundingRect.adjust(-halfpw, -halfpw, halfpw, halfpw);
0
8539 }
never executed: end of block
0
8540 return d->boundingRect;
never executed: return d->boundingRect;
0
8541}-
8542-
8543/*!-
8544 \reimp-
8545*/-
8546QPainterPath QGraphicsRectItem::shape() const-
8547{-
8548 Q_D(const QGraphicsRectItem);-
8549 QPainterPath path;-
8550 path.addRect(d->rect);-
8551 return qt_graphicsItem_shapeFromPath(path, d->pen);
never executed: return qt_graphicsItem_shapeFromPath(path, d->pen);
0
8552}-
8553-
8554/*!-
8555 \reimp-
8556*/-
8557bool QGraphicsRectItem::contains(const QPointF &point) const-
8558{-
8559 return QAbstractGraphicsShapeItem::contains(point);
never executed: return QAbstractGraphicsShapeItem::contains(point);
0
8560}-
8561-
8562/*!-
8563 \reimp-
8564*/-
8565void QGraphicsRectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,-
8566 QWidget *widget)-
8567{-
8568 Q_D(QGraphicsRectItem);-
8569 Q_UNUSED(widget);-
8570 painter->setPen(d->pen);-
8571 painter->setBrush(d->brush);-
8572 painter->drawRect(d->rect);-
8573-
8574 if (option->state & QStyle::State_Selected)
option->state ...State_SelectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
8575 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
8576}
never executed: end of block
0
8577-
8578/*!-
8579 \reimp-
8580*/-
8581bool QGraphicsRectItem::isObscuredBy(const QGraphicsItem *item) const-
8582{-
8583 return QAbstractGraphicsShapeItem::isObscuredBy(item);
never executed: return QAbstractGraphicsShapeItem::isObscuredBy(item);
0
8584}-
8585-
8586/*!-
8587 \reimp-
8588*/-
8589QPainterPath QGraphicsRectItem::opaqueArea() const-
8590{-
8591 return QAbstractGraphicsShapeItem::opaqueArea();
never executed: return QAbstractGraphicsShapeItem::opaqueArea();
0
8592}-
8593-
8594/*!-
8595 \reimp-
8596*/-
8597int QGraphicsRectItem::type() const-
8598{-
8599 return Type;
never executed: return Type;
0
8600}-
8601-
8602/*!-
8603 \internal-
8604*/-
8605bool QGraphicsRectItem::supportsExtension(Extension extension) const-
8606{-
8607 Q_UNUSED(extension);-
8608 return false;
never executed: return false;
0
8609}-
8610-
8611/*!-
8612 \internal-
8613*/-
8614void QGraphicsRectItem::setExtension(Extension extension, const QVariant &variant)-
8615{-
8616 Q_UNUSED(extension);-
8617 Q_UNUSED(variant);-
8618}
never executed: end of block
0
8619-
8620/*!-
8621 \internal-
8622*/-
8623QVariant QGraphicsRectItem::extension(const QVariant &variant) const-
8624{-
8625 Q_UNUSED(variant);-
8626 return QVariant();
never executed: return QVariant();
0
8627}-
8628-
8629/*!-
8630 \class QGraphicsEllipseItem-
8631 \brief The QGraphicsEllipseItem class provides an ellipse item that you-
8632 can add to a QGraphicsScene.-
8633 \since 4.2-
8634 \ingroup graphicsview-api-
8635 \inmodule QtWidgets-
8636-
8637 QGraphicsEllipseItem respresents an ellipse with a fill and an outline,-
8638 and you can also use it for ellipse segments (see startAngle(),-
8639 spanAngle()).-
8640-
8641 \table-
8642 \row-
8643 \li \inlineimage graphicsview-ellipseitem.png-
8644 \li \inlineimage graphicsview-ellipseitem-pie.png-
8645 \endtable-
8646-
8647 To set the item's ellipse, pass a QRectF to QGraphicsEllipseItem's-
8648 constructor, or call setRect(). The rect() function returns the-
8649 current ellipse geometry.-
8650-
8651 QGraphicsEllipseItem uses the rect and the pen width to provide a-
8652 reasonable implementation of boundingRect(), shape(), and contains(). The-
8653 paint() function draws the ellipse using the item's associated pen and-
8654 brush, which you can set by calling setPen() and setBrush().-
8655-
8656 \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsPolygonItem,-
8657 QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics-
8658 View Framework}-
8659*/-
8660-
8661class QGraphicsEllipseItemPrivate : public QAbstractGraphicsShapeItemPrivate-
8662{-
8663 Q_DECLARE_PUBLIC(QGraphicsEllipseItem)-
8664public:-
8665 inline QGraphicsEllipseItemPrivate()-
8666 : startAngle(0), spanAngle(360 * 16)-
8667 { }
never executed: end of block
0
8668-
8669 QRectF rect;-
8670 int startAngle;-
8671 int spanAngle;-
8672};-
8673-
8674/*!-
8675 Constructs a QGraphicsEllipseItem using \a rect as the default rectangle.-
8676 \a parent is passed to QAbstractGraphicsShapeItem's constructor.-
8677-
8678 \sa QGraphicsScene::addItem()-
8679*/-
8680QGraphicsEllipseItem::QGraphicsEllipseItem(const QRectF &rect, QGraphicsItem *parent)-
8681 : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent)-
8682{-
8683 setRect(rect);-
8684}
never executed: end of block
0
8685-
8686/*!-
8687 \fn QGraphicsEllipseItem::QGraphicsEllipseItem(qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parent)-
8688 \since 4.3-
8689-
8690 Constructs a QGraphicsEllipseItem using the rectangle defined by (\a x, \a-
8691 y) and the given \a width and \a height, as the default rectangle. \a-
8692 parent is passed to QAbstractGraphicsShapeItem's constructor.-
8693-
8694 \sa QGraphicsScene::addItem()-
8695*/-
8696QGraphicsEllipseItem::QGraphicsEllipseItem(qreal x, qreal y, qreal w, qreal h,-
8697 QGraphicsItem *parent)-
8698 : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent)-
8699{-
8700 setRect(x,y,w,h);-
8701}
never executed: end of block
0
8702-
8703-
8704-
8705/*!-
8706 Constructs a QGraphicsEllipseItem. \a parent is passed to-
8707 QAbstractGraphicsShapeItem's constructor.-
8708-
8709 \sa QGraphicsScene::addItem()-
8710*/-
8711QGraphicsEllipseItem::QGraphicsEllipseItem(QGraphicsItem *parent)-
8712 : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent)-
8713{-
8714}
never executed: end of block
0
8715-
8716/*!-
8717 Destroys the QGraphicsEllipseItem.-
8718*/-
8719QGraphicsEllipseItem::~QGraphicsEllipseItem()-
8720{-
8721}-
8722-
8723/*!-
8724 Returns the item's ellipse geometry as a QRectF.-
8725-
8726 \sa setRect(), QPainter::drawEllipse()-
8727*/-
8728QRectF QGraphicsEllipseItem::rect() const-
8729{-
8730 Q_D(const QGraphicsEllipseItem);-
8731 return d->rect;
never executed: return d->rect;
0
8732}-
8733-
8734/*!-
8735 Sets the item's ellipse geometry to \a rect. The rectangle's left edge-
8736 defines the left edge of the ellipse, and the rectangle's top edge-
8737 describes the top of the ellipse. The height and width of the rectangle-
8738 describe the height and width of the ellipse.-
8739-
8740 \sa rect(), QPainter::drawEllipse()-
8741*/-
8742void QGraphicsEllipseItem::setRect(const QRectF &rect)-
8743{-
8744 Q_D(QGraphicsEllipseItem);-
8745 if (d->rect == rect)
d->rect == rectDescription
TRUEnever evaluated
FALSEnever evaluated
0
8746 return;
never executed: return;
0
8747 prepareGeometryChange();-
8748 d->rect = rect;-
8749 d->boundingRect = QRectF();-
8750 update();-
8751}
never executed: end of block
0
8752-
8753/*!-
8754 Returns the start angle for an ellipse segment in 16ths of a degree. This-
8755 angle is used together with spanAngle() for representing an ellipse-
8756 segment (a pie). By default, the start angle is 0.-
8757-
8758 \sa setStartAngle(), spanAngle()-
8759*/-
8760int QGraphicsEllipseItem::startAngle() const-
8761{-
8762 Q_D(const QGraphicsEllipseItem);-
8763 return d->startAngle;
never executed: return d->startAngle;
0
8764}-
8765-
8766/*!-
8767 Sets the start angle for an ellipse segment to \a angle, which is in 16ths-
8768 of a degree. This angle is used together with spanAngle() for representing-
8769 an ellipse segment (a pie). By default, the start angle is 0.-
8770-
8771 \sa startAngle(), setSpanAngle(), QPainter::drawPie()-
8772*/-
8773void QGraphicsEllipseItem::setStartAngle(int angle)-
8774{-
8775 Q_D(QGraphicsEllipseItem);-
8776 if (angle != d->startAngle) {
angle != d->startAngleDescription
TRUEnever evaluated
FALSEnever evaluated
0
8777 prepareGeometryChange();-
8778 d->boundingRect = QRectF();-
8779 d->startAngle = angle;-
8780 update();-
8781 }
never executed: end of block
0
8782}
never executed: end of block
0
8783-
8784/*!-
8785 Returns the span angle of an ellipse segment in 16ths of a degree. This-
8786 angle is used together with startAngle() for representing an ellipse-
8787 segment (a pie). By default, this function returns 5760 (360 * 16, a full-
8788 ellipse).-
8789-
8790 \sa setSpanAngle(), startAngle()-
8791*/-
8792int QGraphicsEllipseItem::spanAngle() const-
8793{-
8794 Q_D(const QGraphicsEllipseItem);-
8795 return d->spanAngle;
never executed: return d->spanAngle;
0
8796}-
8797-
8798/*!-
8799 Sets the span angle for an ellipse segment to \a angle, which is in 16ths-
8800 of a degree. This angle is used together with startAngle() to represent an-
8801 ellipse segment (a pie). By default, the span angle is 5760 (360 * 16, a-
8802 full ellipse).-
8803-
8804 \sa spanAngle(), setStartAngle(), QPainter::drawPie()-
8805*/-
8806void QGraphicsEllipseItem::setSpanAngle(int angle)-
8807{-
8808 Q_D(QGraphicsEllipseItem);-
8809 if (angle != d->spanAngle) {
angle != d->spanAngleDescription
TRUEnever evaluated
FALSEnever evaluated
0
8810 prepareGeometryChange();-
8811 d->boundingRect = QRectF();-
8812 d->spanAngle = angle;-
8813 update();-
8814 }
never executed: end of block
0
8815}
never executed: end of block
0
8816-
8817/*!-
8818 \reimp-
8819*/-
8820QRectF QGraphicsEllipseItem::boundingRect() const-
8821{-
8822 Q_D(const QGraphicsEllipseItem);-
8823 if (d->boundingRect.isNull()) {
d->boundingRect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
8824 qreal pw = pen().style() == Qt::NoPen ? qreal(0) : pen().widthF();
pen().style() == Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
0
8825 if (pw == 0.0 && d->spanAngle == 360 * 16)
pw == 0.0Description
TRUEnever evaluated
FALSEnever evaluated
d->spanAngle == 360 * 16Description
TRUEnever evaluated
FALSEnever evaluated
0
8826 d->boundingRect = d->rect;
never executed: d->boundingRect = d->rect;
0
8827 else-
8828 d->boundingRect = shape().controlPointRect();
never executed: d->boundingRect = shape().controlPointRect();
0
8829 }-
8830 return d->boundingRect;
never executed: return d->boundingRect;
0
8831}-
8832-
8833/*!-
8834 \reimp-
8835*/-
8836QPainterPath QGraphicsEllipseItem::shape() const-
8837{-
8838 Q_D(const QGraphicsEllipseItem);-
8839 QPainterPath path;-
8840 if (d->rect.isNull())
d->rect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
8841 return path;
never executed: return path;
0
8842 if (d->spanAngle != 360 * 16) {
d->spanAngle != 360 * 16Description
TRUEnever evaluated
FALSEnever evaluated
0
8843 path.moveTo(d->rect.center());-
8844 path.arcTo(d->rect, d->startAngle / 16.0, d->spanAngle / 16.0);-
8845 } else {
never executed: end of block
0
8846 path.addEllipse(d->rect);-
8847 }
never executed: end of block
0
8848-
8849 return qt_graphicsItem_shapeFromPath(path, d->pen);
never executed: return qt_graphicsItem_shapeFromPath(path, d->pen);
0
8850}-
8851-
8852/*!-
8853 \reimp-
8854*/-
8855bool QGraphicsEllipseItem::contains(const QPointF &point) const-
8856{-
8857 return QAbstractGraphicsShapeItem::contains(point);
never executed: return QAbstractGraphicsShapeItem::contains(point);
0
8858}-
8859-
8860/*!-
8861 \reimp-
8862*/-
8863void QGraphicsEllipseItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,-
8864 QWidget *widget)-
8865{-
8866 Q_D(QGraphicsEllipseItem);-
8867 Q_UNUSED(widget);-
8868 painter->setPen(d->pen);-
8869 painter->setBrush(d->brush);-
8870 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
8871 painter->drawEllipse(d->rect);
never executed: painter->drawEllipse(d->rect);
0
8872 else-
8873 painter->drawPie(d->rect, d->startAngle, d->spanAngle);
never executed: painter->drawPie(d->rect, d->startAngle, d->spanAngle);
0
8874-
8875 if (option->state & QStyle::State_Selected)
option->state ...State_SelectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
8876 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
8877}
never executed: end of block
0
8878-
8879/*!-
8880 \reimp-
8881*/-
8882bool QGraphicsEllipseItem::isObscuredBy(const QGraphicsItem *item) const-
8883{-
8884 return QAbstractGraphicsShapeItem::isObscuredBy(item);
never executed: return QAbstractGraphicsShapeItem::isObscuredBy(item);
0
8885}-
8886-
8887/*!-
8888 \reimp-
8889*/-
8890QPainterPath QGraphicsEllipseItem::opaqueArea() const-
8891{-
8892 return QAbstractGraphicsShapeItem::opaqueArea();
never executed: return QAbstractGraphicsShapeItem::opaqueArea();
0
8893}-
8894-
8895/*!-
8896 \reimp-
8897*/-
8898int QGraphicsEllipseItem::type() const-
8899{-
8900 return Type;
never executed: return Type;
0
8901}-
8902-
8903-
8904/*!-
8905 \internal-
8906*/-
8907bool QGraphicsEllipseItem::supportsExtension(Extension extension) const-
8908{-
8909 Q_UNUSED(extension);-
8910 return false;
never executed: return false;
0
8911}-
8912-
8913/*!-
8914 \internal-
8915*/-
8916void QGraphicsEllipseItem::setExtension(Extension extension, const QVariant &variant)-
8917{-
8918 Q_UNUSED(extension);-
8919 Q_UNUSED(variant);-
8920}
never executed: end of block
0
8921-
8922/*!-
8923 \internal-
8924*/-
8925QVariant QGraphicsEllipseItem::extension(const QVariant &variant) const-
8926{-
8927 Q_UNUSED(variant);-
8928 return QVariant();
never executed: return QVariant();
0
8929}-
8930-
8931/*!-
8932 \class QGraphicsPolygonItem-
8933 \brief The QGraphicsPolygonItem class provides a polygon item that you-
8934 can add to a QGraphicsScene.-
8935 \since 4.2-
8936 \ingroup graphicsview-api-
8937 \inmodule QtWidgets-
8938-
8939 To set the item's polygon, pass a QPolygonF to-
8940 QGraphicsPolygonItem's constructor, or call the setPolygon()-
8941 function. The polygon() function returns the current polygon.-
8942-
8943 \image graphicsview-polygonitem.png-
8944-
8945 QGraphicsPolygonItem uses the polygon and the pen width to provide-
8946 a reasonable implementation of boundingRect(), shape(), and-
8947 contains(). The paint() function draws the polygon using the-
8948 item's associated pen and brush, which you can set by calling the-
8949 setPen() and setBrush() functions.-
8950-
8951 \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem,-
8952 QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics-
8953 View Framework}-
8954*/-
8955-
8956class QGraphicsPolygonItemPrivate : public QAbstractGraphicsShapeItemPrivate-
8957{-
8958 Q_DECLARE_PUBLIC(QGraphicsPolygonItem)-
8959public:-
8960 inline QGraphicsPolygonItemPrivate()-
8961 : fillRule(Qt::OddEvenFill)-
8962 { }
never executed: end of block
0
8963-
8964 QPolygonF polygon;-
8965 Qt::FillRule fillRule;-
8966};-
8967-
8968/*!-
8969 Constructs a QGraphicsPolygonItem with \a polygon as the default-
8970 polygon. \a parent is passed to QAbstractGraphicsShapeItem's constructor.-
8971-
8972 \sa QGraphicsScene::addItem()-
8973*/-
8974QGraphicsPolygonItem::QGraphicsPolygonItem(const QPolygonF &polygon, QGraphicsItem *parent)-
8975 : QAbstractGraphicsShapeItem(*new QGraphicsPolygonItemPrivate, parent)-
8976{-
8977 setPolygon(polygon);-
8978}
never executed: end of block
0
8979-
8980/*!-
8981 Constructs a QGraphicsPolygonItem. \a parent is passed to-
8982 QAbstractGraphicsShapeItem's constructor.-
8983-
8984 \sa QGraphicsScene::addItem()-
8985*/-
8986QGraphicsPolygonItem::QGraphicsPolygonItem(QGraphicsItem *parent)-
8987 : QAbstractGraphicsShapeItem(*new QGraphicsPolygonItemPrivate, parent)-
8988{-
8989}
never executed: end of block
0
8990-
8991/*!-
8992 Destroys the QGraphicsPolygonItem.-
8993*/-
8994QGraphicsPolygonItem::~QGraphicsPolygonItem()-
8995{-
8996}-
8997-
8998/*!-
8999 Returns the item's polygon, or an empty polygon if no polygon-
9000 has been set.-
9001-
9002 \sa setPolygon()-
9003*/-
9004QPolygonF QGraphicsPolygonItem::polygon() const-
9005{-
9006 Q_D(const QGraphicsPolygonItem);-
9007 return d->polygon;
never executed: return d->polygon;
0
9008}-
9009-
9010/*!-
9011 Sets the item's polygon to be the given \a polygon.-
9012-
9013 \sa polygon()-
9014*/-
9015void QGraphicsPolygonItem::setPolygon(const QPolygonF &polygon)-
9016{-
9017 Q_D(QGraphicsPolygonItem);-
9018 if (d->polygon == polygon)
d->polygon == polygonDescription
TRUEnever evaluated
FALSEnever evaluated
0
9019 return;
never executed: return;
0
9020 prepareGeometryChange();-
9021 d->polygon = polygon;-
9022 d->boundingRect = QRectF();-
9023 update();-
9024}
never executed: end of block
0
9025-
9026/*!-
9027 Returns the fill rule of the polygon. The default fill rule is-
9028 Qt::OddEvenFill.-
9029-
9030 \sa setFillRule(), QPainterPath::fillRule(), QPainter::drawPolygon()-
9031*/-
9032Qt::FillRule QGraphicsPolygonItem::fillRule() const-
9033{-
9034 Q_D(const QGraphicsPolygonItem);-
9035 return d->fillRule;
never executed: return d->fillRule;
0
9036}-
9037-
9038/*!-
9039 Sets the fill rule of the polygon to \a rule. The default fill rule is-
9040 Qt::OddEvenFill.-
9041-
9042 \sa fillRule(), QPainterPath::fillRule(), QPainter::drawPolygon()-
9043*/-
9044void QGraphicsPolygonItem::setFillRule(Qt::FillRule rule)-
9045{-
9046 Q_D(QGraphicsPolygonItem);-
9047 if (rule != d->fillRule) {
rule != d->fillRuleDescription
TRUEnever evaluated
FALSEnever evaluated
0
9048 d->fillRule = rule;-
9049 update();-
9050 }
never executed: end of block
0
9051}
never executed: end of block
0
9052-
9053/*!-
9054 \reimp-
9055*/-
9056QRectF QGraphicsPolygonItem::boundingRect() const-
9057{-
9058 Q_D(const QGraphicsPolygonItem);-
9059 if (d->boundingRect.isNull()) {
d->boundingRect.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
9060 qreal pw = pen().style() == Qt::NoPen ? qreal(0) : pen().widthF();
pen().style() == Qt::NoPenDescription
TRUEnever evaluated
FALSEnever evaluated
0
9061 if (pw == 0.0)
pw == 0.0Description
TRUEnever evaluated
FALSEnever evaluated
0
9062 d->boundingRect = d->polygon.boundingRect();
never executed: d->boundingRect = d->polygon.boundingRect();
0
9063 else-
9064 d->boundingRect = shape().controlPointRect();
never executed: d->boundingRect = shape().controlPointRect();
0
9065 }-
9066 return d->boundingRect;
never executed: return d->boundingRect;
0
9067}-
9068-
9069/*!-
9070 \reimp-
9071*/-
9072QPainterPath QGraphicsPolygonItem::shape() const-
9073{-
9074 Q_D(const QGraphicsPolygonItem);-
9075 QPainterPath path;-
9076 path.addPolygon(d->polygon);-
9077 return qt_graphicsItem_shapeFromPath(path, d->pen);
never executed: return qt_graphicsItem_shapeFromPath(path, d->pen);
0
9078}-
9079-
9080/*!-
9081 \reimp-
9082*/-
9083bool QGraphicsPolygonItem::contains(const QPointF &point) const-
9084{-
9085 return QAbstractGraphicsShapeItem::contains(point);
never executed: return QAbstractGraphicsShapeItem::contains(point);
0
9086}-
9087-
9088/*!-
9089 \reimp-
9090*/-
9091void QGraphicsPolygonItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)-
9092{-
9093 Q_D(QGraphicsPolygonItem);-
9094 Q_UNUSED(widget);-
9095 painter->setPen(d->pen);-
9096 painter->setBrush(d->brush);-
9097 painter->drawPolygon(d->polygon, d->fillRule);-
9098-
9099 if (option->state & QStyle::State_Selected)
option->state ...State_SelectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
9100 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
9101}
never executed: end of block
0
9102-
9103/*!-
9104 \reimp-
9105*/-
9106bool QGraphicsPolygonItem::isObscuredBy(const QGraphicsItem *item) const-
9107{-
9108 return QAbstractGraphicsShapeItem::isObscuredBy(item);
never executed: return QAbstractGraphicsShapeItem::isObscuredBy(item);
0
9109}-
9110-
9111/*!-
9112 \reimp-
9113*/-
9114QPainterPath QGraphicsPolygonItem::opaqueArea() const-
9115{-
9116 return QAbstractGraphicsShapeItem::opaqueArea();
never executed: return QAbstractGraphicsShapeItem::opaqueArea();
0
9117}-
9118-
9119/*!-
9120 \reimp-
9121*/-
9122int QGraphicsPolygonItem::type() const-
9123{-
9124 return Type;
never executed: return Type;
0
9125}-
9126-
9127/*!-
9128 \internal-
9129*/-
9130bool QGraphicsPolygonItem::supportsExtension(Extension extension) const-
9131{-
9132 Q_UNUSED(extension);-
9133 return false;
never executed: return false;
0
9134}-
9135-
9136/*!-
9137 \internal-
9138*/-
9139void QGraphicsPolygonItem::setExtension(Extension extension, const QVariant &variant)-
9140{-
9141 Q_UNUSED(extension);-
9142 Q_UNUSED(variant);-
9143}
never executed: end of block
0
9144-
9145/*!-
9146 \internal-
9147*/-
9148QVariant QGraphicsPolygonItem::extension(const QVariant &variant) const-
9149{-
9150 Q_UNUSED(variant);-
9151 return QVariant();
never executed: return QVariant();
0
9152}-
9153-
9154/*!-
9155 \class QGraphicsLineItem-
9156 \brief The QGraphicsLineItem class provides a line item that you can add to a-
9157 QGraphicsScene.-
9158 \since 4.2-
9159 \ingroup graphicsview-api-
9160 \inmodule QtWidgets-
9161-
9162 To set the item's line, pass a QLineF to QGraphicsLineItem's-
9163 constructor, or call the setLine() function. The line() function-
9164 returns the current line. By default the line is black with a-
9165 width of 0, but you can change this by calling setPen().-
9166-
9167 \image graphicsview-lineitem.png-
9168-
9169 QGraphicsLineItem uses the line and the pen width to provide a reasonable-
9170 implementation of boundingRect(), shape(), and contains(). The paint()-
9171 function draws the line using the item's associated pen.-
9172-
9173 \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem,-
9174 QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsPixmapItem,-
9175 {Graphics View Framework}-
9176*/-
9177-
9178class QGraphicsLineItemPrivate : public QGraphicsItemPrivate-
9179{-
9180 Q_DECLARE_PUBLIC(QGraphicsLineItem)-
9181public:-
9182 QLineF line;-
9183 QPen pen;-
9184};-
9185-
9186/*!-
9187 Constructs a QGraphicsLineItem, using \a line as the default line. \a-
9188 parent is passed to QGraphicsItem's constructor.-
9189-
9190 \sa QGraphicsScene::addItem()-
9191*/-
9192QGraphicsLineItem::QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent)-
9193 : QGraphicsItem(*new QGraphicsLineItemPrivate, parent)-
9194{-
9195 setLine(line);-
9196}
never executed: end of block
0
9197-
9198/*!-
9199 Constructs a QGraphicsLineItem, using the line between (\a x1, \a y1) and-
9200 (\a x2, \a y2) as the default line. \a parent is passed to-
9201 QGraphicsItem's constructor.-
9202-
9203 \sa QGraphicsScene::addItem()-
9204*/-
9205QGraphicsLineItem::QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent)-
9206 : QGraphicsItem(*new QGraphicsLineItemPrivate, parent)-
9207{-
9208 setLine(x1, y1, x2, y2);-
9209}
never executed: end of block
0
9210-
9211-
9212-
9213/*!-
9214 Constructs a QGraphicsLineItem. \a parent is passed to QGraphicsItem's-
9215 constructor.-
9216-
9217 \sa QGraphicsScene::addItem()-
9218*/-
9219QGraphicsLineItem::QGraphicsLineItem(QGraphicsItem *parent)-
9220 : QGraphicsItem(*new QGraphicsLineItemPrivate, parent)-
9221{-
9222}
never executed: end of block
0
9223-
9224/*!-
9225 Destroys the QGraphicsLineItem.-
9226*/-
9227QGraphicsLineItem::~QGraphicsLineItem()-
9228{-
9229}-
9230-
9231/*!-
9232 Returns the item's pen, or a black solid 0-width pen if no pen has-
9233 been set.-
9234-
9235 \sa setPen()-
9236*/-
9237QPen QGraphicsLineItem::pen() const-
9238{-
9239 Q_D(const QGraphicsLineItem);-
9240 return d->pen;
never executed: return d->pen;
0
9241}-
9242-
9243/*!-
9244 Sets the item's pen to \a pen. If no pen is set, the line will be painted-
9245 using a black solid 0-width pen.-
9246-
9247 \sa pen()-
9248*/-
9249void QGraphicsLineItem::setPen(const QPen &pen)-
9250{-
9251 Q_D(QGraphicsLineItem);-
9252 if (d->pen == pen)
d->pen == penDescription
TRUEnever evaluated
FALSEnever evaluated
0
9253 return;
never executed: return;
0
9254 prepareGeometryChange();-
9255 d->pen = pen;-
9256 update();-
9257}
never executed: end of block
0
9258-
9259/*!-
9260 Returns the item's line, or a null line if no line has been set.-
9261-
9262 \sa setLine()-
9263*/-
9264QLineF QGraphicsLineItem::line() const-
9265{-
9266 Q_D(const QGraphicsLineItem);-
9267 return d->line;
never executed: return d->line;
0
9268}-
9269-
9270/*!-
9271 Sets the item's line to be the given \a line.-
9272-
9273 \sa line()-
9274*/-
9275void QGraphicsLineItem::setLine(const QLineF &line)-
9276{-
9277 Q_D(QGraphicsLineItem);-
9278 if (d->line == line)
d->line == lineDescription
TRUEnever evaluated
FALSEnever evaluated
0
9279 return;
never executed: return;
0
9280 prepareGeometryChange();-
9281 d->line = line;-
9282 update();-
9283}
never executed: end of block
0
9284-
9285/*!-
9286 \fn void QGraphicsLineItem::setLine(qreal x1, qreal y1, qreal x2, qreal y2)-
9287 \overload-
9288-
9289 Sets the item's line to be the line between (\a x1, \a y1) and (\a-
9290 x2, \a y2).-
9291-
9292 This is the same as calling \c {setLine(QLineF(x1, y1, x2, y2))}.-
9293*/-
9294-
9295/*!-
9296 \reimp-
9297*/-
9298QRectF QGraphicsLineItem::boundingRect() const-
9299{-
9300 Q_D(const QGraphicsLineItem);-
9301 if (d->pen.widthF() == 0.0) {
d->pen.widthF() == 0.0Description
TRUEnever evaluated
FALSEnever evaluated
0
9302 const qreal x1 = d->line.p1().x();-
9303 const qreal x2 = d->line.p2().x();-
9304 const qreal y1 = d->line.p1().y();-
9305 const qreal y2 = d->line.p2().y();-
9306 qreal lx = qMin(x1, x2);-
9307 qreal rx = qMax(x1, x2);-
9308 qreal ty = qMin(y1, y2);-
9309 qreal by = qMax(y1, y2);-
9310 return QRectF(lx, ty, rx - lx, by - ty);
never executed: return QRectF(lx, ty, rx - lx, by - ty);
0
9311 }-
9312 return shape().controlPointRect();
never executed: return shape().controlPointRect();
0
9313}-
9314-
9315/*!-
9316 \reimp-
9317*/-
9318QPainterPath QGraphicsLineItem::shape() const-
9319{-
9320 Q_D(const QGraphicsLineItem);-
9321 QPainterPath path;-
9322 if (d->line == QLineF())
d->line == QLineF()Description
TRUEnever evaluated
FALSEnever evaluated
0
9323 return path;
never executed: return path;
0
9324-
9325 path.moveTo(d->line.p1());-
9326 path.lineTo(d->line.p2());-
9327 return qt_graphicsItem_shapeFromPath(path, d->pen);
never executed: return qt_graphicsItem_shapeFromPath(path, d->pen);
0
9328}-
9329-
9330/*!-
9331 \reimp-
9332*/-
9333bool QGraphicsLineItem::contains(const QPointF &point) const-
9334{-
9335 return QGraphicsItem::contains(point);
never executed: return QGraphicsItem::contains(point);
0
9336}-
9337-
9338/*!-
9339 \reimp-
9340*/-
9341void QGraphicsLineItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)-
9342{-
9343 Q_D(QGraphicsLineItem);-
9344 Q_UNUSED(widget);-
9345 painter->setPen(d->pen);-
9346 painter->drawLine(d->line);-
9347-
9348 if (option->state & QStyle::State_Selected)
option->state ...State_SelectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
9349 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
9350}
never executed: end of block
0
9351-
9352/*!-
9353 \reimp-
9354*/-
9355bool QGraphicsLineItem::isObscuredBy(const QGraphicsItem *item) const-
9356{-
9357 return QGraphicsItem::isObscuredBy(item);
never executed: return QGraphicsItem::isObscuredBy(item);
0
9358}-
9359-
9360/*!-
9361 \reimp-
9362*/-
9363QPainterPath QGraphicsLineItem::opaqueArea() const-
9364{-
9365 return QGraphicsItem::opaqueArea();
never executed: return QGraphicsItem::opaqueArea();
0
9366}-
9367-
9368/*!-
9369 \reimp-
9370*/-
9371int QGraphicsLineItem::type() const-
9372{-
9373 return Type;
never executed: return Type;
0
9374}-
9375-
9376/*!-
9377 \internal-
9378*/-
9379bool QGraphicsLineItem::supportsExtension(Extension extension) const-
9380{-
9381 Q_UNUSED(extension);-
9382 return false;
never executed: return false;
0
9383}-
9384-
9385/*!-
9386 \internal-
9387*/-
9388void QGraphicsLineItem::setExtension(Extension extension, const QVariant &variant)-
9389{-
9390 Q_UNUSED(extension);-
9391 Q_UNUSED(variant);-
9392}
never executed: end of block
0
9393-
9394/*!-
9395 \internal-
9396*/-
9397QVariant QGraphicsLineItem::extension(const QVariant &variant) const-
9398{-
9399 Q_UNUSED(variant);-
9400 return QVariant();
never executed: return QVariant();
0
9401}-
9402-
9403/*!-
9404 \class QGraphicsPixmapItem-
9405 \brief The QGraphicsPixmapItem class provides a pixmap item that you can add to-
9406 a QGraphicsScene.-
9407 \since 4.2-
9408 \ingroup graphicsview-api-
9409 \inmodule QtWidgets-
9410-
9411 To set the item's pixmap, pass a QPixmap to QGraphicsPixmapItem's-
9412 constructor, or call the setPixmap() function. The pixmap()-
9413 function returns the current pixmap.-
9414-
9415 QGraphicsPixmapItem uses pixmap's optional alpha mask to provide a-
9416 reasonable implementation of boundingRect(), shape(), and contains().-
9417-
9418 \image graphicsview-pixmapitem.png-
9419-
9420 The pixmap is drawn at the item's (0, 0) coordinate, as returned by-
9421 offset(). You can change the drawing offset by calling setOffset().-
9422-
9423 You can set the pixmap's transformation mode by calling-
9424 setTransformationMode(). By default, Qt::FastTransformation is used, which-
9425 provides fast, non-smooth scaling. Qt::SmoothTransformation enables-
9426 QPainter::SmoothPixmapTransform on the painter, and the quality depends on-
9427 the platform and viewport. The result is usually not as good as calling-
9428 QPixmap::scale() directly. Call transformationMode() to get the current-
9429 transformation mode for the item.-
9430-
9431 \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem,-
9432 QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsLineItem,-
9433 {Graphics View Framework}-
9434*/-
9435-
9436/*!-
9437 \enum QGraphicsPixmapItem::ShapeMode-
9438-
9439 This enum describes how QGraphicsPixmapItem calculates its shape and-
9440 opaque area.-
9441-
9442 The default value is MaskShape.-
9443-
9444 \value MaskShape The shape is determined by calling QPixmap::mask().-
9445 This shape includes only the opaque pixels of the pixmap.-
9446 Because the shape is more complex, however, it can be slower than the other modes,-
9447 and uses more memory.-
9448-
9449 \value BoundingRectShape The shape is determined by tracing the outline of-
9450 the pixmap. This is the fastest shape mode, but it does not take into account-
9451 any transparent areas on the pixmap.-
9452-
9453 \value HeuristicMaskShape The shape is determine by calling-
9454 QPixmap::createHeuristicMask(). The performance and memory consumption-
9455 is similar to MaskShape.-
9456*/-
9457extern QPainterPath qt_regionToPath(const QRegion &region);-
9458-
9459class QGraphicsPixmapItemPrivate : public QGraphicsItemPrivate-
9460{-
9461 Q_DECLARE_PUBLIC(QGraphicsPixmapItem)-
9462public:-
9463 QGraphicsPixmapItemPrivate()-
9464 : transformationMode(Qt::FastTransformation),-
9465 shapeMode(QGraphicsPixmapItem::MaskShape),-
9466 hasShape(false)-
9467 {}
never executed: end of block
0
9468-
9469 QPixmap pixmap;-
9470 Qt::TransformationMode transformationMode;-
9471 QPointF offset;-
9472 QGraphicsPixmapItem::ShapeMode shapeMode;-
9473 QPainterPath shape;-
9474 bool hasShape;-
9475-
9476 void updateShape()-
9477 {-
9478 shape = QPainterPath();-
9479 switch (shapeMode) {-
9480 case QGraphicsPixmapItem::MaskShape: {
never executed: case QGraphicsPixmapItem::MaskShape:
0
9481 QBitmap mask = pixmap.mask();-
9482 if (!mask.isNull()) {
!mask.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
9483 shape = qt_regionToPath(QRegion(mask).translated(offset.toPoint()));-
9484 break;
never executed: break;
0
9485 }-
9486 // FALL THROUGH-
9487 }-
9488 case QGraphicsPixmapItem::BoundingRectShape:
code before this statement never executed: case QGraphicsPixmapItem::BoundingRectShape:
never executed: case QGraphicsPixmapItem::BoundingRectShape:
0
9489 shape.addRect(QRectF(offset.x(), offset.y(), pixmap.width(), pixmap.height()));-
9490 break;
never executed: break;
0
9491 case QGraphicsPixmapItem::HeuristicMaskShape:
never executed: case QGraphicsPixmapItem::HeuristicMaskShape:
0
9492#ifndef QT_NO_IMAGE_HEURISTIC_MASK-
9493 shape = qt_regionToPath(QRegion(pixmap.createHeuristicMask()).translated(offset.toPoint()));-
9494#else-
9495 shape.addRect(QRectF(offset.x(), offset.y(), pixmap.width(), pixmap.height()));-
9496#endif-
9497 break;
never executed: break;
0
9498 }-
9499 }
never executed: end of block
0
9500};-
9501-
9502/*!-
9503 Constructs a QGraphicsPixmapItem, using \a pixmap as the default pixmap.-
9504 \a parent is passed to QGraphicsItem's constructor.-
9505-
9506 \sa QGraphicsScene::addItem()-
9507*/-
9508QGraphicsPixmapItem::QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent)-
9509 : QGraphicsItem(*new QGraphicsPixmapItemPrivate, parent)-
9510{-
9511 setPixmap(pixmap);-
9512}
never executed: end of block
0
9513-
9514/*!-
9515 Constructs a QGraphicsPixmapItem. \a parent is passed to QGraphicsItem's-
9516 constructor.-
9517-
9518 \sa QGraphicsScene::addItem()-
9519*/-
9520QGraphicsPixmapItem::QGraphicsPixmapItem(QGraphicsItem *parent)-
9521 : QGraphicsItem(*new QGraphicsPixmapItemPrivate, parent)-
9522{-
9523}
never executed: end of block
0
9524-
9525/*!-
9526 Destroys the QGraphicsPixmapItem.-
9527*/-
9528QGraphicsPixmapItem::~QGraphicsPixmapItem()-
9529{-
9530}-
9531-
9532/*!-
9533 Sets the item's pixmap to \a pixmap.-
9534-
9535 \sa pixmap()-
9536*/-
9537void QGraphicsPixmapItem::setPixmap(const QPixmap &pixmap)-
9538{-
9539 Q_D(QGraphicsPixmapItem);-
9540 prepareGeometryChange();-
9541 d->pixmap = pixmap;-
9542 d->hasShape = false;-
9543 update();-
9544}
never executed: end of block
0
9545-
9546/*!-
9547 Returns the item's pixmap, or an invalid QPixmap if no pixmap has been-
9548 set.-
9549-
9550 \sa setPixmap()-
9551*/-
9552QPixmap QGraphicsPixmapItem::pixmap() const-
9553{-
9554 Q_D(const QGraphicsPixmapItem);-
9555 return d->pixmap;
never executed: return d->pixmap;
0
9556}-
9557-
9558/*!-
9559 Returns the transformation mode of the pixmap. The default mode is-
9560 Qt::FastTransformation, which provides quick transformation with no-
9561 smoothing.-
9562-
9563 \sa setTransformationMode()-
9564*/-
9565Qt::TransformationMode QGraphicsPixmapItem::transformationMode() const-
9566{-
9567 Q_D(const QGraphicsPixmapItem);-
9568 return d->transformationMode;
never executed: return d->transformationMode;
0
9569}-
9570-
9571/*!-
9572 Sets the pixmap item's transformation mode to \a mode, and toggles an-
9573 update of the item. The default mode is Qt::FastTransformation, which-
9574 provides quick transformation with no smoothing.-
9575-
9576 Qt::SmoothTransformation enables QPainter::SmoothPixmapTransform on the-
9577 painter, and the quality depends on the platform and viewport. The result-
9578 is usually not as good as calling QPixmap::scale() directly.-
9579-
9580 \sa transformationMode()-
9581*/-
9582void QGraphicsPixmapItem::setTransformationMode(Qt::TransformationMode mode)-
9583{-
9584 Q_D(QGraphicsPixmapItem);-
9585 if (mode != d->transformationMode) {
mode != d->transformationModeDescription
TRUEnever evaluated
FALSEnever evaluated
0
9586 d->transformationMode = mode;-
9587 update();-
9588 }
never executed: end of block
0
9589}
never executed: end of block
0
9590-
9591/*!-
9592 Returns the pixmap item's \e offset, which defines the point of the-
9593 top-left corner of the pixmap, in local coordinates.-
9594-
9595 \sa setOffset()-
9596*/-
9597QPointF QGraphicsPixmapItem::offset() const-
9598{-
9599 Q_D(const QGraphicsPixmapItem);-
9600 return d->offset;
never executed: return d->offset;
0
9601}-
9602-
9603/*!-
9604 Sets the pixmap item's offset to \a offset. QGraphicsPixmapItem will draw-
9605 its pixmap using \a offset for its top-left corner.-
9606-
9607 \sa offset()-
9608*/-
9609void QGraphicsPixmapItem::setOffset(const QPointF &offset)-
9610{-
9611 Q_D(QGraphicsPixmapItem);-
9612 if (d->offset == offset)
d->offset == offsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
9613 return;
never executed: return;
0
9614 prepareGeometryChange();-
9615 d->offset = offset;-
9616 d->hasShape = false;-
9617 update();-
9618}
never executed: end of block
0
9619-
9620/*!-
9621 \fn void QGraphicsPixmapItem::setOffset(qreal x, qreal y)-
9622 \since 4.3-
9623-
9624 This convenience function is equivalent to calling setOffset(QPointF(\a x, \a y)).-
9625*/-
9626-
9627/*!-
9628 \reimp-
9629*/-
9630QRectF QGraphicsPixmapItem::boundingRect() const-
9631{-
9632 Q_D(const QGraphicsPixmapItem);-
9633 if (d->pixmap.isNull())
d->pixmap.isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
9634 return QRectF();
never executed: return QRectF();
0
9635 if (d->flags & ItemIsSelectable) {
d->flags & ItemIsSelectableDescription
TRUEnever evaluated
FALSEnever evaluated
0
9636 qreal pw = 1.0;-
9637 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
9638 } else {-
9639 return QRectF(d->offset, d->pixmap.size() / d->pixmap.devicePixelRatio());
never executed: return QRectF(d->offset, d->pixmap.size() / d->pixmap.devicePixelRatio());
0
9640 }-
9641}-
9642-
9643/*!-
9644 \reimp-
9645*/-
9646QPainterPath QGraphicsPixmapItem::shape() const-
9647{-
9648 Q_D(const QGraphicsPixmapItem);-
9649 if (!d->hasShape) {
!d->hasShapeDescription
TRUEnever evaluated
FALSEnever evaluated
0
9650 QGraphicsPixmapItemPrivate *thatD = const_cast<QGraphicsPixmapItemPrivate *>(d);-
9651 thatD->updateShape();-
9652 thatD->hasShape = true;-
9653 }
never executed: end of block
0
9654 return d_func()->shape;
never executed: return d_func()->shape;
0
9655}-
9656-
9657/*!-
9658 \reimp-
9659*/-
9660bool QGraphicsPixmapItem::contains(const QPointF &point) const-
9661{-
9662 return QGraphicsItem::contains(point);
never executed: return QGraphicsItem::contains(point);
0
9663}-
9664-
9665/*!-
9666 \reimp-
9667*/-
9668void QGraphicsPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,-
9669 QWidget *widget)-
9670{-
9671 Q_D(QGraphicsPixmapItem);-
9672 Q_UNUSED(widget);-
9673-
9674 painter->setRenderHint(QPainter::SmoothPixmapTransform,-
9675 (d->transformationMode == Qt::SmoothTransformation));-
9676-
9677 painter->drawPixmap(d->offset, d->pixmap);-
9678-
9679 if (option->state & QStyle::State_Selected)
option->state ...State_SelectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
9680 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
9681}
never executed: end of block
0
9682-
9683/*!-
9684 \reimp-
9685*/-
9686bool QGraphicsPixmapItem::isObscuredBy(const QGraphicsItem *item) const-
9687{-
9688 return QGraphicsItem::isObscuredBy(item);
never executed: return QGraphicsItem::isObscuredBy(item);
0
9689}-
9690-
9691/*!-
9692 \reimp-
9693*/-
9694QPainterPath QGraphicsPixmapItem::opaqueArea() const-
9695{-
9696 return shape();
never executed: return shape();
0
9697}-
9698-
9699/*!-
9700 \reimp-
9701*/-
9702int QGraphicsPixmapItem::type() const-
9703{-
9704 return Type;
never executed: return Type;
0
9705}-
9706-
9707/*!-
9708 Returns the item's shape mode. The shape mode describes how-
9709 QGraphicsPixmapItem calculates its shape. The default mode is MaskShape.-
9710-
9711 \sa setShapeMode(), ShapeMode-
9712*/-
9713QGraphicsPixmapItem::ShapeMode QGraphicsPixmapItem::shapeMode() const-
9714{-
9715 return d_func()->shapeMode;
never executed: return d_func()->shapeMode;
0
9716}-
9717-
9718/*!-
9719 Sets the item's shape mode to \a mode. The shape mode describes how-
9720 QGraphicsPixmapItem calculates its shape. The default mode is MaskShape.-
9721-
9722 \sa shapeMode(), ShapeMode-
9723*/-
9724void QGraphicsPixmapItem::setShapeMode(ShapeMode mode)-
9725{-
9726 Q_D(QGraphicsPixmapItem);-
9727 if (d->shapeMode == mode)
d->shapeMode == modeDescription
TRUEnever evaluated
FALSEnever evaluated
0
9728 return;
never executed: return;
0
9729 d->shapeMode = mode;-
9730 d->hasShape = false;-
9731}
never executed: end of block
0
9732-
9733/*!-
9734 \internal-
9735*/-
9736bool QGraphicsPixmapItem::supportsExtension(Extension extension) const-
9737{-
9738 Q_UNUSED(extension);-
9739 return false;
never executed: return false;
0
9740}-
9741-
9742/*!-
9743 \internal-
9744*/-
9745void QGraphicsPixmapItem::setExtension(Extension extension, const QVariant &variant)-
9746{-
9747 Q_UNUSED(extension);-
9748 Q_UNUSED(variant);-
9749}
never executed: end of block
0
9750-
9751/*!-
9752 \internal-
9753*/-
9754QVariant QGraphicsPixmapItem::extension(const QVariant &variant) const-
9755{-
9756 Q_UNUSED(variant);-
9757 return QVariant();
never executed: return QVariant();
0
9758}-
9759-
9760/*!-
9761 \class QGraphicsTextItem-
9762 \brief The QGraphicsTextItem class provides a text item that you can add to-
9763 a QGraphicsScene to display formatted text.-
9764 \since 4.2-
9765 \ingroup graphicsview-api-
9766 \inmodule QtWidgets-
9767-
9768 If you only need to show plain text in an item, consider using QGraphicsSimpleTextItem-
9769 instead.-
9770-
9771 To set the item's text, pass a QString to QGraphicsTextItem's-
9772 constructor, or call setHtml()/setPlainText().-
9773-
9774 QGraphicsTextItem uses the text's formatted size and the associated font-
9775 to provide a reasonable implementation of boundingRect(), shape(),-
9776 and contains(). You can set the font by calling setFont().-
9777-
9778 It is possible to make the item editable by setting the Qt::TextEditorInteraction flag-
9779 using setTextInteractionFlags().-
9780-
9781 The item's preferred text width can be set using setTextWidth() and obtained-
9782 using textWidth().-
9783-
9784 \note In order to align HTML text in the center, the item's text width must be set.-
9785 Otherwise, you can call adjustSize() after setting the item's text.-
9786-
9787 \image graphicsview-textitem.png-
9788-
9789 \note QGraphicsTextItem accepts \l{QGraphicsItem::acceptHoverEvents()}{hover events}-
9790 by default. You can change this with \l{QGraphicsItem::}{setAcceptHoverEvents()}.-
9791-
9792 \sa QGraphicsSimpleTextItem, QGraphicsPathItem, QGraphicsRectItem,-
9793 QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem,-
9794 QGraphicsLineItem, {Graphics View Framework}-
9795*/-
9796-
9797class QGraphicsTextItemPrivate-
9798{-
9799public:-
9800 QGraphicsTextItemPrivate()-
9801 : control(0), pageNumber(0), useDefaultImpl(false), tabChangesFocus(false), clickCausedFocus(0)-
9802 { }
never executed: end of block
0
9803-
9804 mutable QWidgetTextControl *control;-
9805 QWidgetTextControl *textControl() const;-
9806-
9807 inline QPointF controlOffset() const-
9808 { return QPointF(0., pageNumber * control->document()->pageSize().height()); }
never executed: return QPointF(0., pageNumber * control->document()->pageSize().height());
0
9809 inline void sendControlEvent(QEvent *e)-
9810 { if (control) control->processEvent(e, controlOffset()); }
never executed: end of block
never executed: control->processEvent(e, controlOffset());
controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
9811-
9812 void _q_updateBoundingRect(const QSizeF &);-
9813 void _q_update(QRectF);-
9814 void _q_ensureVisible(QRectF);-
9815 bool _q_mouseOnEdge(QGraphicsSceneMouseEvent *);-
9816-
9817 QRectF boundingRect;-
9818 int pageNumber;-
9819 bool useDefaultImpl;-
9820 bool tabChangesFocus;-
9821-
9822 uint clickCausedFocus : 1;-
9823-
9824 QGraphicsTextItem *qq;-
9825};-
9826-
9827-
9828/*!-
9829 Constructs a QGraphicsTextItem, using \a text as the default plain-
9830 text. \a parent is passed to QGraphicsItem's constructor.-
9831-
9832 \sa QGraphicsScene::addItem()-
9833*/-
9834QGraphicsTextItem::QGraphicsTextItem(const QString &text, QGraphicsItem *parent)-
9835 : QGraphicsObject(*new QGraphicsItemPrivate, parent),-
9836 dd(new QGraphicsTextItemPrivate)-
9837{-
9838 dd->qq = this;-
9839 if (!text.isEmpty())
!text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
9840 setPlainText(text);
never executed: setPlainText(text);
0
9841 setAcceptDrops(true);-
9842 setAcceptHoverEvents(true);-
9843 setFlags(ItemUsesExtendedStyleOption);-
9844}
never executed: end of block
0
9845-
9846/*!-
9847 Constructs a QGraphicsTextItem. \a parent is passed to QGraphicsItem's-
9848 constructor.-
9849-
9850 \sa QGraphicsScene::addItem()-
9851*/-
9852QGraphicsTextItem::QGraphicsTextItem(QGraphicsItem *parent)-
9853 : QGraphicsObject(*new QGraphicsItemPrivate, parent),-
9854 dd(new QGraphicsTextItemPrivate)-
9855{-
9856 dd->qq = this;-
9857 setAcceptDrops(true);-
9858 setAcceptHoverEvents(true);-
9859 setFlag(ItemUsesExtendedStyleOption);-
9860}
never executed: end of block
0
9861-
9862/*!-
9863 Destroys the QGraphicsTextItem.-
9864*/-
9865QGraphicsTextItem::~QGraphicsTextItem()-
9866{-
9867 delete dd;-
9868}
never executed: end of block
0
9869-
9870/*!-
9871 Returns the item's text converted to HTML, or an empty QString if no text has been set.-
9872-
9873 \sa setHtml()-
9874*/-
9875QString QGraphicsTextItem::toHtml() const-
9876{-
9877#ifndef QT_NO_TEXTHTMLPARSER-
9878 if (dd->control)
dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
9879 return dd->control->toHtml();
never executed: return dd->control->toHtml();
0
9880#endif-
9881 return QString();
never executed: return QString();
0
9882}-
9883-
9884/*!-
9885 Sets the item's text to \a text, assuming that text is HTML formatted. If-
9886 the item has keyboard input focus, this function will also call-
9887 ensureVisible() to ensure that the text is visible in all viewports.-
9888-
9889 \sa toHtml(), hasFocus(), QGraphicsSimpleTextItem-
9890*/-
9891void QGraphicsTextItem::setHtml(const QString &text)-
9892{-
9893 dd->textControl()->setHtml(text);-
9894}
never executed: end of block
0
9895-
9896/*!-
9897 Returns the item's text converted to plain text, or an empty QString if no text has been set.-
9898-
9899 \sa setPlainText()-
9900*/-
9901QString QGraphicsTextItem::toPlainText() const-
9902{-
9903 if (dd->control)
dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
9904 return dd->control->toPlainText();
never executed: return dd->control->toPlainText();
0
9905 return QString();
never executed: return QString();
0
9906}-
9907-
9908/*!-
9909 Sets the item's text to \a text. If the item has keyboard input focus,-
9910 this function will also call ensureVisible() to ensure that the text is-
9911 visible in all viewports.-
9912-
9913 \sa toHtml(), hasFocus()-
9914*/-
9915void QGraphicsTextItem::setPlainText(const QString &text)-
9916{-
9917 dd->textControl()->setPlainText(text);-
9918}
never executed: end of block
0
9919-
9920/*!-
9921 Returns the item's font, which is used to render the text.-
9922-
9923 \sa setFont()-
9924*/-
9925QFont QGraphicsTextItem::font() const-
9926{-
9927 if (!dd->control)
!dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
9928 return QFont();
never executed: return QFont();
0
9929 return dd->control->document()->defaultFont();
never executed: return dd->control->document()->defaultFont();
0
9930}-
9931-
9932/*!-
9933 Sets the font used to render the text item to \a font.-
9934-
9935 \sa font()-
9936*/-
9937void QGraphicsTextItem::setFont(const QFont &font)-
9938{-
9939 dd->textControl()->document()->setDefaultFont(font);-
9940}
never executed: end of block
0
9941-
9942/*!-
9943 Sets the color for unformatted text to \a col.-
9944*/-
9945void QGraphicsTextItem::setDefaultTextColor(const QColor &col)-
9946{-
9947 QWidgetTextControl *c = dd->textControl();-
9948 QPalette pal = c->palette();-
9949 QColor old = pal.color(QPalette::Text);-
9950 pal.setColor(QPalette::Text, col);-
9951 c->setPalette(pal);-
9952 if (old != col)
old != colDescription
TRUEnever evaluated
FALSEnever evaluated
0
9953 update();
never executed: update();
0
9954}
never executed: end of block
0
9955-
9956/*!-
9957 Returns the default text color that is used for unformatted text.-
9958*/-
9959QColor QGraphicsTextItem::defaultTextColor() const-
9960{-
9961 return dd->textControl()->palette().color(QPalette::Text);
never executed: return dd->textControl()->palette().color(QPalette::Text);
0
9962}-
9963-
9964/*!-
9965 \reimp-
9966*/-
9967QRectF QGraphicsTextItem::boundingRect() const-
9968{-
9969 return dd->boundingRect;
never executed: return dd->boundingRect;
0
9970}-
9971-
9972/*!-
9973 \reimp-
9974*/-
9975QPainterPath QGraphicsTextItem::shape() const-
9976{-
9977 if (!dd->control)
!dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
9978 return QPainterPath();
never executed: return QPainterPath();
0
9979 QPainterPath path;-
9980 path.addRect(dd->boundingRect);-
9981 return path;
never executed: return path;
0
9982}-
9983-
9984/*!-
9985 \reimp-
9986*/-
9987bool QGraphicsTextItem::contains(const QPointF &point) const-
9988{-
9989 return dd->boundingRect.contains(point);
never executed: return dd->boundingRect.contains(point);
0
9990}-
9991-
9992/*!-
9993 \reimp-
9994*/-
9995void QGraphicsTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,-
9996 QWidget *widget)-
9997{-
9998 Q_UNUSED(widget);-
9999 if (dd->control) {
dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
10000 painter->save();-
10001 QRectF r = option->exposedRect;-
10002 painter->translate(-dd->controlOffset());-
10003 r.translate(dd->controlOffset());-
10004-
10005 QTextDocument *doc = dd->control->document();-
10006 QTextDocumentLayout *layout = qobject_cast<QTextDocumentLayout *>(doc->documentLayout());-
10007-
10008 // the layout might need to expand the root frame to-
10009 // the viewport if NoWrap is set-
10010 if (layout)
layoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
10011 layout->setViewport(dd->boundingRect);
never executed: layout->setViewport(dd->boundingRect);
0
10012-
10013 dd->control->drawContents(painter, r);-
10014-
10015 if (layout)
layoutDescription
TRUEnever evaluated
FALSEnever evaluated
0
10016 layout->setViewport(QRect());
never executed: layout->setViewport(QRect());
0
10017-
10018 painter->restore();-
10019 }
never executed: end of block
0
10020-
10021 if (option->state & (QStyle::State_Selected | QStyle::State_HasFocus))
option->state ...tate_HasFocus)Description
TRUEnever evaluated
FALSEnever evaluated
0
10022 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
10023}
never executed: end of block
0
10024-
10025/*!-
10026 \reimp-
10027*/-
10028bool QGraphicsTextItem::isObscuredBy(const QGraphicsItem *item) const-
10029{-
10030 return QGraphicsItem::isObscuredBy(item);
never executed: return QGraphicsItem::isObscuredBy(item);
0
10031}-
10032-
10033/*!-
10034 \reimp-
10035*/-
10036QPainterPath QGraphicsTextItem::opaqueArea() const-
10037{-
10038 return QGraphicsItem::opaqueArea();
never executed: return QGraphicsItem::opaqueArea();
0
10039}-
10040-
10041/*!-
10042 \reimp-
10043*/-
10044int QGraphicsTextItem::type() const-
10045{-
10046 return Type;
never executed: return Type;
0
10047}-
10048-
10049/*!-
10050 Sets the preferred width for the item's text. If the actual text-
10051 is wider than the specified width then it will be broken into-
10052 multiple lines.-
10053-
10054 If \a width is set to -1 then the text will not be broken into-
10055 multiple lines unless it is enforced through an explicit line-
10056 break or a new paragraph.-
10057-
10058 The default value is -1.-
10059-
10060 Note that QGraphicsTextItem keeps a QTextDocument internally,-
10061 which is used to calculate the text width.-
10062-
10063 \sa textWidth(), QTextDocument::setTextWidth()-
10064*/-
10065void QGraphicsTextItem::setTextWidth(qreal width)-
10066{-
10067 dd->textControl()->setTextWidth(width);-
10068}
never executed: end of block
0
10069-
10070/*!-
10071 Returns the text width.-
10072-
10073 The width is calculated with the QTextDocument that-
10074 QGraphicsTextItem keeps internally.-
10075-
10076 \sa setTextWidth(), QTextDocument::textWidth()-
10077*/-
10078qreal QGraphicsTextItem::textWidth() const-
10079{-
10080 if (!dd->control)
!dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
10081 return -1;
never executed: return -1;
0
10082 return dd->control->textWidth();
never executed: return dd->control->textWidth();
0
10083}-
10084-
10085/*!-
10086 Adjusts the text item to a reasonable size.-
10087*/-
10088void QGraphicsTextItem::adjustSize()-
10089{-
10090 if (dd->control)
dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
10091 dd->control->adjustSize();
never executed: dd->control->adjustSize();
0
10092}
never executed: end of block
0
10093-
10094/*!-
10095 Sets the text document \a document on the item.-
10096*/-
10097void QGraphicsTextItem::setDocument(QTextDocument *document)-
10098{-
10099 dd->textControl()->setDocument(document);-
10100 dd->_q_updateBoundingRect(dd->control->size());-
10101}
never executed: end of block
0
10102-
10103/*!-
10104 Returns the item's text document.-
10105*/-
10106QTextDocument *QGraphicsTextItem::document() const-
10107{-
10108 return dd->textControl()->document();
never executed: return dd->textControl()->document();
0
10109}-
10110-
10111/*!-
10112 \reimp-
10113*/-
10114bool QGraphicsTextItem::sceneEvent(QEvent *event)-
10115{-
10116 QEvent::Type t = event->type();-
10117 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
10118 int k = ((QKeyEvent *)event)->key();-
10119 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
10120 dd->sendControlEvent(event);-
10121 return true;
never executed: return true;
0
10122 }-
10123 }
never executed: end of block
0
10124 bool result = QGraphicsItem::sceneEvent(event);-
10125-
10126 // Ensure input context is updated.-
10127 switch (event->type()) {-
10128 case QEvent::ContextMenu:
never executed: case QEvent::ContextMenu:
0
10129 case QEvent::FocusIn:
never executed: case QEvent::FocusIn:
0
10130 case QEvent::FocusOut:
never executed: case QEvent::FocusOut:
0
10131 case QEvent::GraphicsSceneDragEnter:
never executed: case QEvent::GraphicsSceneDragEnter:
0
10132 case QEvent::GraphicsSceneDragLeave:
never executed: case QEvent::GraphicsSceneDragLeave:
0
10133 case QEvent::GraphicsSceneDragMove:
never executed: case QEvent::GraphicsSceneDragMove:
0
10134 case QEvent::GraphicsSceneDrop:
never executed: case QEvent::GraphicsSceneDrop:
0
10135 case QEvent::GraphicsSceneHoverEnter:
never executed: case QEvent::GraphicsSceneHoverEnter:
0
10136 case QEvent::GraphicsSceneHoverLeave:
never executed: case QEvent::GraphicsSceneHoverLeave:
0
10137 case QEvent::GraphicsSceneHoverMove:
never executed: case QEvent::GraphicsSceneHoverMove:
0
10138 case QEvent::GraphicsSceneMouseDoubleClick:
never executed: case QEvent::GraphicsSceneMouseDoubleClick:
0
10139 case QEvent::GraphicsSceneMousePress:
never executed: case QEvent::GraphicsSceneMousePress:
0
10140 case QEvent::GraphicsSceneMouseMove:
never executed: case QEvent::GraphicsSceneMouseMove:
0
10141 case QEvent::GraphicsSceneMouseRelease:
never executed: case QEvent::GraphicsSceneMouseRelease:
0
10142 case QEvent::KeyPress:
never executed: case QEvent::KeyPress:
0
10143 case QEvent::KeyRelease:
never executed: case QEvent::KeyRelease:
0
10144 // Reset the focus widget's input context, regardless-
10145 // of how this item gained or lost focus.-
10146 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
10147 QGuiApplication::inputMethod()->reset();-
10148 } else {
never executed: end of block
0
10149 QGuiApplication::inputMethod()->update(Qt::ImQueryInput);-
10150 }
never executed: end of block
0
10151 break;
never executed: break;
0
10152 case QEvent::ShortcutOverride:
never executed: case QEvent::ShortcutOverride:
0
10153 dd->sendControlEvent(event);-
10154 return true;
never executed: return true;
0
10155 default:
never executed: default:
0
10156 break;
never executed: break;
0
10157 }-
10158-
10159 return result;
never executed: return result;
0
10160}-
10161-
10162/*!-
10163 \reimp-
10164*/-
10165void QGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event)-
10166{-
10167 if ((QGraphicsItem::d_ptr->flags & (ItemIsSelectable | ItemIsMovable))
(QGraphicsItem...temIsMovable))Description
TRUEnever evaluated
FALSEnever evaluated
0
10168 && (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
10169 // User left-pressed on edge of selectable/movable item, use-
10170 // base impl.-
10171 dd->useDefaultImpl = true;-
10172 } else if (event->buttons() == event->button()
never executed: end of block
event->buttons...vent->button()Description
TRUEnever evaluated
FALSEnever evaluated
0
10173 && dd->control->textInteractionFlags() == Qt::NoTextInteraction) {
dd->control->t...extInteractionDescription
TRUEnever evaluated
FALSEnever evaluated
0
10174 // User pressed first button on non-interactive item.-
10175 dd->useDefaultImpl = true;-
10176 }
never executed: end of block
0
10177 if (dd->useDefaultImpl) {
dd->useDefaultImplDescription
TRUEnever evaluated
FALSEnever evaluated
0
10178 QGraphicsItem::mousePressEvent(event);-
10179 if (!event->isAccepted())
!event->isAccepted()Description
TRUEnever evaluated
FALSEnever evaluated
0
10180 dd->useDefaultImpl = false;
never executed: dd->useDefaultImpl = false;
0
10181 return;
never executed: return;
0
10182 }-
10183-
10184 dd->sendControlEvent(event);-
10185}
never executed: end of block
0
10186-
10187/*!-
10188 \reimp-
10189*/-
10190void QGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event)-
10191{-
10192 if (dd->useDefaultImpl) {
dd->useDefaultImplDescription
TRUEnever evaluated
FALSEnever evaluated
0
10193 QGraphicsItem::mouseMoveEvent(event);-
10194 return;
never executed: return;
0
10195 }-
10196-
10197 dd->sendControlEvent(event);-
10198}
never executed: end of block
0
10199-
10200/*!-
10201 \reimp-
10202*/-
10203void QGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event)-
10204{-
10205 if (dd->useDefaultImpl) {
dd->useDefaultImplDescription
TRUEnever evaluated
FALSEnever evaluated
0
10206 QGraphicsItem::mouseReleaseEvent(event);-
10207 if (dd->control->textInteractionFlags() == Qt::NoTextInteraction
dd->control->t...extInteractionDescription
TRUEnever evaluated
FALSEnever evaluated
0
10208 && !event->buttons()) {
!event->buttons()Description
TRUEnever evaluated
FALSEnever evaluated
0
10209 // User released last button on non-interactive item.-
10210 dd->useDefaultImpl = false;-
10211 } else if ((event->buttons() & Qt::LeftButton) == 0) {
never executed: end of block
(event->button...ftButton) == 0Description
TRUEnever evaluated
FALSEnever evaluated
0
10212 // User released the left button on an interactive item.-
10213 dd->useDefaultImpl = false;-
10214 }
never executed: end of block
0
10215 return;
never executed: return;
0
10216 }-
10217-
10218 QWidget *widget = event->widget();-
10219 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
10220 qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), dd->clickCausedFocus);-
10221 }
never executed: end of block
0
10222 dd->clickCausedFocus = 0;-
10223 dd->sendControlEvent(event);-
10224}
never executed: end of block
0
10225-
10226/*!-
10227 \reimp-
10228*/-
10229void QGraphicsTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event)-
10230{-
10231 if (dd->useDefaultImpl) {
dd->useDefaultImplDescription
TRUEnever evaluated
FALSEnever evaluated
0
10232 QGraphicsItem::mouseDoubleClickEvent(event);-
10233 return;
never executed: return;
0
10234 }-
10235-
10236 if (!hasFocus()) {
!hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
10237 QGraphicsItem::mouseDoubleClickEvent(event);-
10238 return;
never executed: return;
0
10239 }-
10240-
10241 dd->sendControlEvent(event);-
10242}
never executed: end of block
0
10243-
10244/*!-
10245 \reimp-
10246*/-
10247void QGraphicsTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event)-
10248{-
10249 dd->sendControlEvent(event);-
10250}
never executed: end of block
0
10251-
10252/*!-
10253 \reimp-
10254*/-
10255void QGraphicsTextItem::keyPressEvent(QKeyEvent *event)-
10256{-
10257 dd->sendControlEvent(event);-
10258}
never executed: end of block
0
10259-
10260/*!-
10261 \reimp-
10262*/-
10263void QGraphicsTextItem::keyReleaseEvent(QKeyEvent *event)-
10264{-
10265 dd->sendControlEvent(event);-
10266}
never executed: end of block
0
10267-
10268/*!-
10269 \reimp-
10270*/-
10271void QGraphicsTextItem::focusInEvent(QFocusEvent *event)-
10272{-
10273 dd->sendControlEvent(event);-
10274 if (event->reason() == Qt::MouseFocusReason) {
event->reason(...useFocusReasonDescription
TRUEnever evaluated
FALSEnever evaluated
0
10275 dd->clickCausedFocus = 1;-
10276 }
never executed: end of block
0
10277 update();-
10278}
never executed: end of block
0
10279-
10280/*!-
10281 \reimp-
10282*/-
10283void QGraphicsTextItem::focusOutEvent(QFocusEvent *event)-
10284{-
10285 dd->sendControlEvent(event);-
10286 update();-
10287}
never executed: end of block
0
10288-
10289/*!-
10290 \reimp-
10291*/-
10292void QGraphicsTextItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event)-
10293{-
10294 dd->sendControlEvent(event);-
10295}
never executed: end of block
0
10296-
10297/*!-
10298 \reimp-
10299*/-
10300void QGraphicsTextItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event)-
10301{-
10302 dd->sendControlEvent(event);-
10303}
never executed: end of block
0
10304-
10305/*!-
10306 \reimp-
10307*/-
10308void QGraphicsTextItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event)-
10309{-
10310 dd->sendControlEvent(event);-
10311}
never executed: end of block
0
10312-
10313/*!-
10314 \reimp-
10315*/-
10316void QGraphicsTextItem::dropEvent(QGraphicsSceneDragDropEvent *event)-
10317{-
10318 dd->sendControlEvent(event);-
10319}
never executed: end of block
0
10320-
10321/*!-
10322 \reimp-
10323*/-
10324void QGraphicsTextItem::inputMethodEvent(QInputMethodEvent *event)-
10325{-
10326 dd->sendControlEvent(event);-
10327}
never executed: end of block
0
10328-
10329/*!-
10330 \reimp-
10331*/-
10332void QGraphicsTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event)-
10333{-
10334 dd->sendControlEvent(event);-
10335}
never executed: end of block
0
10336-
10337/*!-
10338 \reimp-
10339*/-
10340void QGraphicsTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event)-
10341{-
10342 dd->sendControlEvent(event);-
10343}
never executed: end of block
0
10344-
10345/*!-
10346 \reimp-
10347*/-
10348void QGraphicsTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event)-
10349{-
10350 dd->sendControlEvent(event);-
10351}
never executed: end of block
0
10352-
10353/*!-
10354 \reimp-
10355*/-
10356QVariant QGraphicsTextItem::inputMethodQuery(Qt::InputMethodQuery query) const-
10357{-
10358 QVariant v;-
10359 if (query == Qt::ImHints)
query == Qt::ImHintsDescription
TRUEnever evaluated
FALSEnever evaluated
0
10360 v = int(inputMethodHints());
never executed: v = int(inputMethodHints());
0
10361 else if (dd->control)
dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
10362 v = dd->control->inputMethodQuery(query, QVariant());
never executed: v = dd->control->inputMethodQuery(query, QVariant());
0
10363 if (v.type() == QVariant::RectF)
v.type() == QVariant::RectFDescription
TRUEnever evaluated
FALSEnever evaluated
0
10364 v = v.toRectF().translated(-dd->controlOffset());
never executed: v = v.toRectF().translated(-dd->controlOffset());
0
10365 else if (v.type() == QVariant::PointF)
v.type() == QVariant::PointFDescription
TRUEnever evaluated
FALSEnever evaluated
0
10366 v = v.toPointF() - dd->controlOffset();
never executed: v = v.toPointF() - dd->controlOffset();
0
10367 else if (v.type() == QVariant::Rect)
v.type() == QVariant::RectDescription
TRUEnever evaluated
FALSEnever evaluated
0
10368 v = v.toRect().translated(-dd->controlOffset().toPoint());
never executed: v = v.toRect().translated(-dd->controlOffset().toPoint());
0
10369 else if (v.type() == QVariant::Point)
v.type() == QVariant::PointDescription
TRUEnever evaluated
FALSEnever evaluated
0
10370 v = v.toPoint() - dd->controlOffset().toPoint();
never executed: v = v.toPoint() - dd->controlOffset().toPoint();
0
10371 return v;
never executed: return v;
0
10372}-
10373-
10374/*!-
10375 \internal-
10376*/-
10377bool QGraphicsTextItem::supportsExtension(Extension extension) const-
10378{-
10379 Q_UNUSED(extension);-
10380 return false;
never executed: return false;
0
10381}-
10382-
10383/*!-
10384 \internal-
10385*/-
10386void QGraphicsTextItem::setExtension(Extension extension, const QVariant &variant)-
10387{-
10388 Q_UNUSED(extension);-
10389 Q_UNUSED(variant);-
10390}
never executed: end of block
0
10391-
10392/*!-
10393 \internal-
10394*/-
10395QVariant QGraphicsTextItem::extension(const QVariant &variant) const-
10396{-
10397 Q_UNUSED(variant);-
10398 return QVariant();
never executed: return QVariant();
0
10399}-
10400-
10401/*!-
10402 \internal-
10403*/-
10404void QGraphicsTextItemPrivate::_q_update(QRectF rect)-
10405{-
10406 if (rect.isValid()) {
rect.isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
10407 rect.translate(-controlOffset());-
10408 } else {
never executed: end of block
0
10409 rect = boundingRect;-
10410 }
never executed: end of block
0
10411 if (rect.intersects(boundingRect))
rect.intersects(boundingRect)Description
TRUEnever evaluated
FALSEnever evaluated
0
10412 qq->update(rect);
never executed: qq->update(rect);
0
10413}
never executed: end of block
0
10414-
10415/*!-
10416 \internal-
10417*/-
10418void QGraphicsTextItemPrivate::_q_updateBoundingRect(const QSizeF &size)-
10419{-
10420 if (!control) return; // can't happen
never executed: return;
!controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
10421 const QSizeF pageSize = control->document()->pageSize();-
10422 // paged items have a constant (page) size-
10423 if (size == boundingRect.size() || pageSize.height() != -1)
size == boundingRect.size()Description
TRUEnever evaluated
FALSEnever evaluated
pageSize.height() != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
10424 return;
never executed: return;
0
10425 qq->prepareGeometryChange();-
10426 boundingRect.setSize(size);-
10427 qq->update();-
10428}
never executed: end of block
0
10429-
10430/*!-
10431 \internal-
10432*/-
10433void QGraphicsTextItemPrivate::_q_ensureVisible(QRectF rect)-
10434{-
10435 if (qq->hasFocus()) {
qq->hasFocus()Description
TRUEnever evaluated
FALSEnever evaluated
0
10436 rect.translate(-controlOffset());-
10437 qq->ensureVisible(rect, /*xmargin=*/0, /*ymargin=*/0);-
10438 }
never executed: end of block
0
10439}
never executed: end of block
0
10440-
10441QWidgetTextControl *QGraphicsTextItemPrivate::textControl() const-
10442{-
10443 if (!control) {
!controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
10444 QGraphicsTextItem *that = const_cast<QGraphicsTextItem *>(qq);-
10445 control = new QWidgetTextControl(that);-
10446 control->setTextInteractionFlags(Qt::NoTextInteraction);-
10447-
10448 QObject::connect(control, SIGNAL(updateRequest(QRectF)),-
10449 qq, SLOT(_q_update(QRectF)));-
10450 QObject::connect(control, SIGNAL(documentSizeChanged(QSizeF)),-
10451 qq, SLOT(_q_updateBoundingRect(QSizeF)));-
10452 QObject::connect(control, SIGNAL(visibilityRequest(QRectF)),-
10453 qq, SLOT(_q_ensureVisible(QRectF)));-
10454 QObject::connect(control, SIGNAL(linkActivated(QString)),-
10455 qq, SIGNAL(linkActivated(QString)));-
10456 QObject::connect(control, SIGNAL(linkHovered(QString)),-
10457 qq, SIGNAL(linkHovered(QString)));-
10458-
10459 const QSizeF pgSize = control->document()->pageSize();-
10460 if (pgSize.height() != -1) {
pgSize.height() != -1Description
TRUEnever evaluated
FALSEnever evaluated
0
10461 qq->prepareGeometryChange();-
10462 that->dd->boundingRect.setSize(pgSize);-
10463 qq->update();-
10464 } else {
never executed: end of block
0
10465 that->dd->_q_updateBoundingRect(control->size());-
10466 }
never executed: end of block
0
10467 }-
10468 return control;
never executed: return control;
0
10469}-
10470-
10471/*!-
10472 \internal-
10473*/-
10474bool QGraphicsTextItemPrivate::_q_mouseOnEdge(QGraphicsSceneMouseEvent *event)-
10475{-
10476 QPainterPath path;-
10477 path.addRect(qq->boundingRect());-
10478-
10479 QPainterPath docPath;-
10480 const QTextFrameFormat format = control->document()->rootFrame()->frameFormat();-
10481 docPath.addRect(-
10482 qq->boundingRect().adjusted(-
10483 format.leftMargin(),-
10484 format.topMargin(),-
10485 -format.rightMargin(),-
10486 -format.bottomMargin()));-
10487-
10488 return path.subtracted(docPath).contains(event->pos());
never executed: return path.subtracted(docPath).contains(event->pos());
0
10489}-
10490-
10491/*!-
10492 \fn QGraphicsTextItem::linkActivated(const QString &link)-
10493-
10494 This signal is emitted when the user clicks on a link on a text item-
10495 that enables Qt::LinksAccessibleByMouse or Qt::LinksAccessibleByKeyboard.-
10496 \a link is the link that was clicked.-
10497-
10498 \sa setTextInteractionFlags()-
10499*/-
10500-
10501/*!-
10502 \fn QGraphicsTextItem::linkHovered(const QString &link)-
10503-
10504 This signal is emitted when the user hovers over a link on a text item-
10505 that enables Qt::LinksAccessibleByMouse. \a link is-
10506 the link that was hovered over.-
10507-
10508 \sa setTextInteractionFlags()-
10509*/-
10510-
10511/*!-
10512 Sets the flags \a flags to specify how the text item should react to user-
10513 input.-
10514-
10515 The default for a QGraphicsTextItem is Qt::NoTextInteraction. This function-
10516 also affects the ItemIsFocusable QGraphicsItem flag by setting it if \a flags-
10517 is different from Qt::NoTextInteraction and clearing it otherwise.-
10518-
10519 By default, the text is read-only. To transform the item into an editor,-
10520 set the Qt::TextEditable flag.-
10521*/-
10522void QGraphicsTextItem::setTextInteractionFlags(Qt::TextInteractionFlags flags)-
10523{-
10524 if (flags == Qt::NoTextInteraction)
flags == Qt::NoTextInteractionDescription
TRUEnever evaluated
FALSEnever evaluated
0
10525 setFlags(this->flags() & ~(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod));
never executed: setFlags(this->flags() & ~(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod));
0
10526 else-
10527 setFlags(this->flags() | QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod);
never executed: setFlags(this->flags() | QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod);
0
10528-
10529 dd->textControl()->setTextInteractionFlags(flags);-
10530}
never executed: end of block
0
10531-
10532/*!-
10533 Returns the current text interaction flags.-
10534-
10535 \sa setTextInteractionFlags()-
10536*/-
10537Qt::TextInteractionFlags QGraphicsTextItem::textInteractionFlags() const-
10538{-
10539 if (!dd->control)
!dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
10540 return Qt::NoTextInteraction;
never executed: return Qt::NoTextInteraction;
0
10541 return dd->control->textInteractionFlags();
never executed: return dd->control->textInteractionFlags();
0
10542}-
10543-
10544/*!-
10545 \since 4.5-
10546-
10547 If \a b is true, the \uicontrol Tab key will cause the widget to change focus;-
10548 otherwise, the tab key will insert a tab into the document.-
10549-
10550 In some occasions text edits should not allow the user to input tabulators-
10551 or change indentation using the \uicontrol Tab key, as this breaks the focus-
10552 chain. The default is false.-
10553-
10554 \sa tabChangesFocus(), ItemIsFocusable, textInteractionFlags()-
10555*/-
10556void QGraphicsTextItem::setTabChangesFocus(bool b)-
10557{-
10558 dd->tabChangesFocus = b;-
10559}
never executed: end of block
0
10560-
10561/*!-
10562 \since 4.5-
10563-
10564 Returns \c true if the \uicontrol Tab key will cause the widget to change focus;-
10565 otherwise, false is returned.-
10566-
10567 By default, this behavior is disabled, and this function will return false.-
10568-
10569 \sa setTabChangesFocus()-
10570*/-
10571bool QGraphicsTextItem::tabChangesFocus() const-
10572{-
10573 return dd->tabChangesFocus;
never executed: return dd->tabChangesFocus;
0
10574}-
10575-
10576/*!-
10577 \property QGraphicsTextItem::openExternalLinks-
10578-
10579 Specifies whether QGraphicsTextItem should automatically open links using-
10580 QDesktopServices::openUrl() instead of emitting the-
10581 linkActivated signal.-
10582-
10583 The default value is false.-
10584*/-
10585void QGraphicsTextItem::setOpenExternalLinks(bool open)-
10586{-
10587 dd->textControl()->setOpenExternalLinks(open);-
10588}
never executed: end of block
0
10589-
10590bool QGraphicsTextItem::openExternalLinks() const-
10591{-
10592 if (!dd->control)
!dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
10593 return false;
never executed: return false;
0
10594 return dd->control->openExternalLinks();
never executed: return dd->control->openExternalLinks();
0
10595}-
10596-
10597/*!-
10598 \property QGraphicsTextItem::textCursor-
10599-
10600 This property represents the visible text cursor in an editable-
10601 text item.-
10602-
10603 By default, if the item's text has not been set, this property-
10604 contains a null text cursor; otherwise it contains a text cursor-
10605 placed at the start of the item's document.-
10606*/-
10607void QGraphicsTextItem::setTextCursor(const QTextCursor &cursor)-
10608{-
10609 dd->textControl()->setTextCursor(cursor);-
10610}
never executed: end of block
0
10611-
10612QTextCursor QGraphicsTextItem::textCursor() const-
10613{-
10614 if (!dd->control)
!dd->controlDescription
TRUEnever evaluated
FALSEnever evaluated
0
10615 return QTextCursor();
never executed: return QTextCursor();
0
10616 return dd->control->textCursor();
never executed: return dd->control->textCursor();
0
10617}-
10618-
10619class QGraphicsSimpleTextItemPrivate : public QAbstractGraphicsShapeItemPrivate-
10620{-
10621 Q_DECLARE_PUBLIC(QGraphicsSimpleTextItem)-
10622public:-
10623 inline QGraphicsSimpleTextItemPrivate() {-
10624 pen.setStyle(Qt::NoPen);-
10625 brush.setStyle(Qt::SolidPattern);-
10626 }
never executed: end of block
0
10627 QString text;-
10628 QFont font;-
10629 QRectF boundingRect;-
10630-
10631 void updateBoundingRect();-
10632};-
10633-
10634static QRectF setupTextLayout(QTextLayout *layout)-
10635{-
10636 layout->setCacheEnabled(true);-
10637 layout->beginLayout();-
10638 while (layout->createLine().isValid())
layout->createLine().isValid()Description
TRUEnever evaluated
FALSEnever evaluated
0
10639 ;
never executed: ;
0
10640 layout->endLayout();-
10641 qreal maxWidth = 0;-
10642 qreal y = 0;-
10643 for (int i = 0; i < layout->lineCount(); ++i) {
i < layout->lineCount()Description
TRUEnever evaluated
FALSEnever evaluated
0
10644 QTextLine line = layout->lineAt(i);-
10645 maxWidth = qMax(maxWidth, line.naturalTextWidth());-
10646 line.setPosition(QPointF(0, y));-
10647 y += line.height();-
10648 }
never executed: end of block
0
10649 return QRectF(0, 0, maxWidth, y);
never executed: return QRectF(0, 0, maxWidth, y);
0
10650}-
10651-
10652void QGraphicsSimpleTextItemPrivate::updateBoundingRect()-
10653{-
10654 Q_Q(QGraphicsSimpleTextItem);-
10655 QRectF br;-
10656 if (text.isEmpty()) {
text.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
10657 br = QRectF();-
10658 } else {
never executed: end of block
0
10659 QString tmp = text;-
10660 tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);-
10661 QStackTextEngine engine(tmp, font);-
10662 QTextLayout layout(&engine);-
10663 br = setupTextLayout(&layout);-
10664 }
never executed: end of block
0
10665 if (br != boundingRect) {
br != boundingRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
10666 q->prepareGeometryChange();-
10667 boundingRect = br;-
10668 q->update();-
10669 }
never executed: end of block
0
10670}
never executed: end of block
0
10671-
10672/*!-
10673 \class QGraphicsSimpleTextItem-
10674 \brief The QGraphicsSimpleTextItem class provides a simple text path item-
10675 that you can add to a QGraphicsScene.-
10676 \since 4.2-
10677 \ingroup graphicsview-api-
10678 \inmodule QtWidgets-
10679-
10680 To set the item's text, you can either pass a QString to-
10681 QGraphicsSimpleTextItem's constructor, or call setText() to change the-
10682 text later. To set the text fill color, call setBrush().-
10683-
10684 The simple text item can have both a fill and an outline; setBrush() will-
10685 set the text fill (i.e., text color), and setPen() sets the pen that will-
10686 be used to draw the text outline. (The latter can be slow, especially for-
10687 complex pens, and items with long text content.) If all you want is to-
10688 draw a simple line of text, you should call setBrush() only, and leave the-
10689 pen unset; QGraphicsSimpleTextItem's pen is by default Qt::NoPen.-
10690-
10691 QGraphicsSimpleTextItem uses the text's formatted size and the associated-
10692 font to provide a reasonable implementation of boundingRect(), shape(),-
10693 and contains(). You can set the font by calling setFont().-
10694-
10695 QGraphicsSimpleText does not display rich text; instead, you can use-
10696 QGraphicsTextItem, which provides full text control capabilities.-
10697-
10698 \image graphicsview-simpletextitem.png-
10699-
10700 \sa QGraphicsTextItem, QGraphicsPathItem, QGraphicsRectItem,-
10701 QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem,-
10702 QGraphicsLineItem, {Graphics View Framework}-
10703*/-
10704-
10705/*!-
10706 Constructs a QGraphicsSimpleTextItem.-
10707-
10708 \a parent is passed to QGraphicsItem's constructor.-
10709-
10710 \sa QGraphicsScene::addItem()-
10711*/-
10712QGraphicsSimpleTextItem::QGraphicsSimpleTextItem(QGraphicsItem *parent)-
10713 : QAbstractGraphicsShapeItem(*new QGraphicsSimpleTextItemPrivate, parent)-
10714{-
10715}
never executed: end of block
0
10716-
10717/*!-
10718 Constructs a QGraphicsSimpleTextItem, using \a text as the default plain text.-
10719-
10720 \a parent is passed to QGraphicsItem's constructor.-
10721-
10722 \sa QGraphicsScene::addItem()-
10723*/-
10724QGraphicsSimpleTextItem::QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent)-
10725 : QAbstractGraphicsShapeItem(*new QGraphicsSimpleTextItemPrivate, parent)-
10726{-
10727 setText(text);-
10728}
never executed: end of block
0
10729-
10730/*!-
10731 Destroys the QGraphicsSimpleTextItem.-
10732*/-
10733QGraphicsSimpleTextItem::~QGraphicsSimpleTextItem()-
10734{-
10735}-
10736-
10737/*!-
10738 Sets the item's text to \a text. The text will be displayed as-
10739 plain text. Newline characters ('\\n') as well as characters of-
10740 type QChar::LineSeparator will cause item to break the text into-
10741 multiple lines.-
10742*/-
10743void QGraphicsSimpleTextItem::setText(const QString &text)-
10744{-
10745 Q_D(QGraphicsSimpleTextItem);-
10746 if (d->text == text)
d->text == textDescription
TRUEnever evaluated
FALSEnever evaluated
0
10747 return;
never executed: return;
0
10748 d->text = text;-
10749 d->updateBoundingRect();-
10750 update();-
10751}
never executed: end of block
0
10752-
10753/*!-
10754 Returns the item's text.-
10755*/-
10756QString QGraphicsSimpleTextItem::text() const-
10757{-
10758 Q_D(const QGraphicsSimpleTextItem);-
10759 return d->text;
never executed: return d->text;
0
10760}-
10761-
10762/*!-
10763 Sets the font that is used to draw the item's text to \a font.-
10764*/-
10765void QGraphicsSimpleTextItem::setFont(const QFont &font)-
10766{-
10767 Q_D(QGraphicsSimpleTextItem);-
10768 d->font = font;-
10769 d->updateBoundingRect();-
10770}
never executed: end of block
0
10771-
10772/*!-
10773 Returns the font that is used to draw the item's text.-
10774*/-
10775QFont QGraphicsSimpleTextItem::font() const-
10776{-
10777 Q_D(const QGraphicsSimpleTextItem);-
10778 return d->font;
never executed: return d->font;
0
10779}-
10780-
10781/*!-
10782 \reimp-
10783*/-
10784QRectF QGraphicsSimpleTextItem::boundingRect() const-
10785{-
10786 Q_D(const QGraphicsSimpleTextItem);-
10787 return d->boundingRect;
never executed: return d->boundingRect;
0
10788}-
10789-
10790/*!-
10791 \reimp-
10792*/-
10793QPainterPath QGraphicsSimpleTextItem::shape() const-
10794{-
10795 Q_D(const QGraphicsSimpleTextItem);-
10796 QPainterPath path;-
10797 path.addRect(d->boundingRect);-
10798 return path;
never executed: return path;
0
10799}-
10800-
10801/*!-
10802 \reimp-
10803*/-
10804bool QGraphicsSimpleTextItem::contains(const QPointF &point) const-
10805{-
10806 Q_D(const QGraphicsSimpleTextItem);-
10807 return d->boundingRect.contains(point);
never executed: return d->boundingRect.contains(point);
0
10808}-
10809-
10810/*!-
10811 \reimp-
10812*/-
10813void QGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget)-
10814{-
10815 Q_UNUSED(widget);-
10816 Q_D(QGraphicsSimpleTextItem);-
10817-
10818 painter->setFont(d->font);-
10819-
10820 QString tmp = d->text;-
10821 tmp.replace(QLatin1Char('\n'), QChar::LineSeparator);-
10822 QStackTextEngine engine(tmp, d->font);-
10823 QTextLayout layout(&engine);-
10824-
10825 QPen p;-
10826 p.setBrush(d->brush);-
10827 painter->setPen(p);-
10828 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
10829 painter->setBrush(Qt::NoBrush);-
10830 } else {
never executed: end of block
0
10831 QTextLayout::FormatRange range;-
10832 range.start = 0;-
10833 range.length = layout.text().length();-
10834 range.format.setTextOutline(d->pen);-
10835 layout.setFormats(QVector<QTextLayout::FormatRange>(1, range));-
10836 }
never executed: end of block
0
10837-
10838 setupTextLayout(&layout);-
10839 layout.draw(painter, QPointF(0, 0));-
10840-
10841 if (option->state & (QStyle::State_Selected | QStyle::State_HasFocus))
option->state ...tate_HasFocus)Description
TRUEnever evaluated
FALSEnever evaluated
0
10842 qt_graphicsItem_highlightSelected(this, painter, option);
never executed: qt_graphicsItem_highlightSelected(this, painter, option);
0
10843}
never executed: end of block
0
10844-
10845/*!-
10846 \reimp-
10847*/-
10848bool QGraphicsSimpleTextItem::isObscuredBy(const QGraphicsItem *item) const-
10849{-
10850 return QAbstractGraphicsShapeItem::isObscuredBy(item);
never executed: return QAbstractGraphicsShapeItem::isObscuredBy(item);
0
10851}-
10852-
10853/*!-
10854 \reimp-
10855*/-
10856QPainterPath QGraphicsSimpleTextItem::opaqueArea() const-
10857{-
10858 return QAbstractGraphicsShapeItem::opaqueArea();
never executed: return QAbstractGraphicsShapeItem::opaqueArea();
0
10859}-
10860-
10861/*!-
10862 \reimp-
10863*/-
10864int QGraphicsSimpleTextItem::type() const-
10865{-
10866 return Type;
never executed: return Type;
0
10867}-
10868-
10869/*!-
10870 \internal-
10871*/-
10872bool QGraphicsSimpleTextItem::supportsExtension(Extension extension) const-
10873{-
10874 Q_UNUSED(extension);-
10875 return false;
never executed: return false;
0
10876}-
10877-
10878/*!-
10879 \internal-
10880*/-
10881void QGraphicsSimpleTextItem::setExtension(Extension extension, const QVariant &variant)-
10882{-
10883 Q_UNUSED(extension);-
10884 Q_UNUSED(variant);-
10885}
never executed: end of block
0
10886-
10887/*!-
10888 \internal-
10889*/-
10890QVariant QGraphicsSimpleTextItem::extension(const QVariant &variant) const-
10891{-
10892 Q_UNUSED(variant);-
10893 return QVariant();
never executed: return QVariant();
0
10894}-
10895-
10896/*!-
10897 \class QGraphicsItemGroup-
10898 \brief The QGraphicsItemGroup class provides a container that treats-
10899 a group of items as a single item.-
10900 \since 4.2-
10901 \ingroup graphicsview-api-
10902 \inmodule QtWidgets-
10903-
10904 A QGraphicsItemGroup is a special type of compound item that-
10905 treats itself and all its children as one item (i.e., all events-
10906 and geometries for all children are merged together). It's common-
10907 to use item groups in presentation tools, when the user wants to-
10908 group several smaller items into one big item in order to simplify-
10909 moving and copying of items.-
10910-
10911 If all you want is to store items inside other items, you can use-
10912 any QGraphicsItem directly by passing a suitable parent to-
10913 setParentItem().-
10914-
10915 The boundingRect() function of QGraphicsItemGroup returns the-
10916 bounding rectangle of all items in the item group.-
10917 QGraphicsItemGroup ignores the ItemIgnoresTransformations flag on-
10918 its children (i.e., with respect to the geometry of the group-
10919 item, the children are treated as if they were transformable).-
10920-
10921 There are two ways to construct an item group. The easiest and-
10922 most common approach is to pass a list of items (e.g., all-
10923 selected items) to QGraphicsScene::createItemGroup(), which-
10924 returns a new QGraphicsItemGroup item. The other approach is to-
10925 manually construct a QGraphicsItemGroup item, add it to the scene-
10926 calling QGraphicsScene::addItem(), and then add items to the group-
10927 manually, one at a time by calling addToGroup(). To dismantle-
10928 ("ungroup") an item group, you can either call-
10929 QGraphicsScene::destroyItemGroup(), or you can manually remove all-
10930 items from the group by calling removeFromGroup().-
10931-
10932 \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 17-
10933-
10934 The operation of adding and removing items preserves the items'-
10935 scene-relative position and transformation, as opposed to calling-
10936 setParentItem(), where only the child item's parent-relative-
10937 position and transformation are kept.-
10938-
10939 The addtoGroup() function reparents the target item to this item-
10940 group, keeping the item's position and transformation intact-
10941 relative to the scene. Visually, this means that items added via-
10942 addToGroup() will remain completely unchanged as a result of this-
10943 operation, regardless of the item or the group's current position-
10944 or transformation; although the item's position and matrix are-
10945 likely to change.-
10946-
10947 The removeFromGroup() function has similar semantics to-
10948 setParentItem(); it reparents the item to the parent item of the-
10949 item group. As with addToGroup(), the item's scene-relative-
10950 position and transformation remain intact.-
10951-
10952 \sa QGraphicsItem, {Graphics View Framework}-
10953*/-
10954-
10955class QGraphicsItemGroupPrivate : public QGraphicsItemPrivate-
10956{-
10957public:-
10958 QRectF itemsBoundingRect;-
10959};-
10960-
10961/*!-
10962 Constructs a QGraphicsItemGroup. \a parent is passed to QGraphicsItem's-
10963 constructor.-
10964-
10965 \sa QGraphicsScene::addItem()-
10966*/-
10967QGraphicsItemGroup::QGraphicsItemGroup(QGraphicsItem *parent)-
10968 : QGraphicsItem(*new QGraphicsItemGroupPrivate, parent)-
10969{-
10970 setHandlesChildEvents(true);-
10971}
never executed: end of block
0
10972-
10973/*!-
10974 Destroys the QGraphicsItemGroup.-
10975*/-
10976QGraphicsItemGroup::~QGraphicsItemGroup()-
10977{-
10978}-
10979-
10980/*!-
10981 Adds the given \a item and item's child items to this item group.-
10982 The item and child items will be reparented to this group, but its-
10983 position and transformation relative to the scene will stay intact.-
10984-
10985 \sa removeFromGroup(), QGraphicsScene::createItemGroup()-
10986*/-
10987void QGraphicsItemGroup::addToGroup(QGraphicsItem *item)-
10988{-
10989 Q_D(QGraphicsItemGroup);-
10990 if (!item) {
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
10991 qWarning("QGraphicsItemGroup::addToGroup: cannot add null item");-
10992 return;
never executed: return;
0
10993 }-
10994 if (item == this) {
item == thisDescription
TRUEnever evaluated
FALSEnever evaluated
0
10995 qWarning("QGraphicsItemGroup::addToGroup: cannot add a group to itself");-
10996 return;
never executed: return;
0
10997 }-
10998-
10999 // COMBINE-
11000 bool ok;-
11001 QTransform itemTransform = item->itemTransform(this, &ok);-
11002-
11003 if (!ok) {
!okDescription
TRUEnever evaluated
FALSEnever evaluated
0
11004 qWarning("QGraphicsItemGroup::addToGroup: could not find a valid transformation from item to group coordinates");-
11005 return;
never executed: return;
0
11006 }-
11007-
11008 QTransform newItemTransform(itemTransform);-
11009 item->setPos(mapFromItem(item, 0, 0));-
11010 item->setParentItem(this);-
11011-
11012 // removing position from translation component of the new transform-
11013 if (!item->pos().isNull())
!item->pos().isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
11014 newItemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
never executed: newItemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
0
11015-
11016 // removing additional transformations properties applied with itemTransform()-
11017 QPointF origin = item->transformOriginPoint();-
11018 QMatrix4x4 m;-
11019 QList<QGraphicsTransform*> transformList = item->transformations();-
11020 for (int i = 0; i < transformList.size(); ++i)
i < transformList.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
11021 transformList.at(i)->applyTo(&m);
never executed: transformList.at(i)->applyTo(&m);
0
11022 newItemTransform *= m.toTransform().inverted();-
11023 newItemTransform.translate(origin.x(), origin.y());-
11024 newItemTransform.rotate(-item->rotation());-
11025 newItemTransform.scale(1/item->scale(), 1/item->scale());-
11026 newItemTransform.translate(-origin.x(), -origin.y());-
11027-
11028 // ### Expensive, we could maybe use dirtySceneTransform bit for optimization-
11029-
11030 item->setTransform(newItemTransform);-
11031 item->d_func()->setIsMemberOfGroup(true);-
11032 prepareGeometryChange();-
11033 d->itemsBoundingRect |= itemTransform.mapRect(item->boundingRect() | item->childrenBoundingRect());-
11034 update();-
11035}
never executed: end of block
0
11036-
11037/*!-
11038 Removes the specified \a item from this group. The item will be-
11039 reparented to this group's parent item, or to 0 if this group has-
11040 no parent. Its position and transformation relative to the scene-
11041 will stay intact.-
11042-
11043 \sa addToGroup(), QGraphicsScene::destroyItemGroup()-
11044*/-
11045void QGraphicsItemGroup::removeFromGroup(QGraphicsItem *item)-
11046{-
11047 Q_D(QGraphicsItemGroup);-
11048 if (!item) {
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
11049 qWarning("QGraphicsItemGroup::removeFromGroup: cannot remove null item");-
11050 return;
never executed: return;
0
11051 }-
11052-
11053 QGraphicsItem *newParent = d_ptr->parent;-
11054-
11055 // COMBINE-
11056 bool ok;-
11057 QTransform itemTransform;-
11058 if (newParent)
newParentDescription
TRUEnever evaluated
FALSEnever evaluated
0
11059 itemTransform = item->itemTransform(newParent, &ok);
never executed: itemTransform = item->itemTransform(newParent, &ok);
0
11060 else-
11061 itemTransform = item->sceneTransform();
never executed: itemTransform = item->sceneTransform();
0
11062-
11063 QPointF oldPos = item->mapToItem(newParent, 0, 0);-
11064 item->setParentItem(newParent);-
11065 item->setPos(oldPos);-
11066-
11067 // removing position from translation component of the new transform-
11068 if (!item->pos().isNull())
!item->pos().isNull()Description
TRUEnever evaluated
FALSEnever evaluated
0
11069 itemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
never executed: itemTransform *= QTransform::fromTranslate(-item->x(), -item->y());
0
11070-
11071 // removing additional transformations properties applied-
11072 // with itemTransform() or sceneTransform()-
11073 QPointF origin = item->transformOriginPoint();-
11074 QMatrix4x4 m;-
11075 QList<QGraphicsTransform*> transformList = item->transformations();-
11076 for (int i = 0; i < transformList.size(); ++i)
i < transformList.size()Description
TRUEnever evaluated
FALSEnever evaluated
0
11077 transformList.at(i)->applyTo(&m);
never executed: transformList.at(i)->applyTo(&m);
0
11078 itemTransform *= m.toTransform().inverted();-
11079 itemTransform.translate(origin.x(), origin.y());-
11080 itemTransform.rotate(-item->rotation());-
11081 itemTransform.scale(1 / item->scale(), 1 / item->scale());-
11082 itemTransform.translate(-origin.x(), -origin.y());-
11083-
11084 // ### Expensive, we could maybe use dirtySceneTransform bit for optimization-
11085-
11086 item->setTransform(itemTransform);-
11087 item->d_func()->setIsMemberOfGroup(item->group() != 0);-
11088-
11089 // ### Quite expensive. But removeFromGroup() isn't called very often.-
11090 prepareGeometryChange();-
11091 d->itemsBoundingRect = childrenBoundingRect();-
11092}
never executed: end of block
0
11093-
11094/*!-
11095 \reimp-
11096-
11097 Returns the bounding rect of this group item, and all its children.-
11098*/-
11099QRectF QGraphicsItemGroup::boundingRect() const-
11100{-
11101 Q_D(const QGraphicsItemGroup);-
11102 return d->itemsBoundingRect;
never executed: return d->itemsBoundingRect;
0
11103}-
11104-
11105/*!-
11106 \reimp-
11107*/-
11108void QGraphicsItemGroup::paint(QPainter *painter, const QStyleOptionGraphicsItem *option,-
11109 QWidget *widget)-
11110{-
11111 Q_UNUSED(widget);-
11112 if (option->state & QStyle::State_Selected) {
option->state ...State_SelectedDescription
TRUEnever evaluated
FALSEnever evaluated
0
11113 Q_D(QGraphicsItemGroup);-
11114 painter->setBrush(Qt::NoBrush);-
11115 painter->drawRect(d->itemsBoundingRect);-
11116 }
never executed: end of block
0
11117}
never executed: end of block
0
11118-
11119/*!-
11120 \reimp-
11121*/-
11122bool QGraphicsItemGroup::isObscuredBy(const QGraphicsItem *item) const-
11123{-
11124 return QGraphicsItem::isObscuredBy(item);
never executed: return QGraphicsItem::isObscuredBy(item);
0
11125}-
11126-
11127/*!-
11128 \reimp-
11129*/-
11130QPainterPath QGraphicsItemGroup::opaqueArea() const-
11131{-
11132 return QGraphicsItem::opaqueArea();
never executed: return QGraphicsItem::opaqueArea();
0
11133}-
11134-
11135/*!-
11136 \reimp-
11137*/-
11138int QGraphicsItemGroup::type() const-
11139{-
11140 return Type;
never executed: return Type;
0
11141}-
11142-
11143#ifndef QT_NO_GRAPHICSEFFECT-
11144QRectF QGraphicsItemEffectSourcePrivate::boundingRect(Qt::CoordinateSystem system) const-
11145{-
11146 const bool deviceCoordinates = (system == Qt::DeviceCoordinates);-
11147 if (!info && deviceCoordinates) {
!infoDescription
TRUEnever evaluated
FALSEnever evaluated
deviceCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
0
11148 // Device coordinates without info not yet supported.-
11149 qWarning("QGraphicsEffectSource::boundingRect: Not yet implemented, lacking device context");-
11150 return QRectF();
never executed: return QRectF();
0
11151 }-
11152-
11153 QRectF rect = item->boundingRect();-
11154 if (!item->d_ptr->children.isEmpty())
!item->d_ptr->...dren.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
11155 rect |= item->childrenBoundingRect();
never executed: rect |= item->childrenBoundingRect();
0
11156-
11157 if (deviceCoordinates) {
deviceCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
0
11158 Q_ASSERT(info->painter);-
11159 rect = info->painter->worldTransform().mapRect(rect);-
11160 }
never executed: end of block
0
11161-
11162 return rect;
never executed: return rect;
0
11163}-
11164-
11165void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter)-
11166{-
11167 if (!info) {
!infoDescription
TRUEnever evaluated
FALSEnever evaluated
0
11168 qWarning("QGraphicsEffectSource::draw: Can only begin as a result of QGraphicsEffect::draw");-
11169 return;
never executed: return;
0
11170 }-
11171-
11172 Q_ASSERT(item->d_ptr->scene);-
11173 QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func();-
11174 if (painter == info->painter) {
painter == info->painterDescription
TRUEnever evaluated
FALSEnever evaluated
0
11175 scened->draw(item, painter, info->viewTransform, info->transformPtr, info->exposedRegion,-
11176 info->widget, info->opacity, info->effectTransform, info->wasDirtySceneTransform,-
11177 info->drawItem);-
11178 } else {
never executed: end of block
0
11179 QTransform effectTransform = info->painter->worldTransform().inverted();-
11180 effectTransform *= painter->worldTransform();-
11181 scened->draw(item, painter, info->viewTransform, info->transformPtr, info->exposedRegion,-
11182 info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform,-
11183 info->drawItem);-
11184 }
never executed: end of block
0
11185}-
11186-
11187// sourceRect must be in the given coordinate system-
11188QRect QGraphicsItemEffectSourcePrivate::paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded) const-
11189{-
11190 QRectF effectRectF;-
11191-
11192 if (unpadded)
unpaddedDescription
TRUEnever evaluated
FALSEnever evaluated
0
11193 *unpadded = false;
never executed: *unpadded = false;
0
11194-
11195 if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) {
mode == QGraph...veBoundingRectDescription
TRUEnever evaluated
FALSEnever evaluated
0
11196 if (info) {
infoDescription
TRUEnever evaluated
FALSEnever evaluated
0
11197 QRectF deviceRect = system == Qt::DeviceCoordinates ? sourceRect : info->painter->worldTransform().mapRect(sourceRect);
system == Qt::...iceCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
0
11198 effectRectF = item->graphicsEffect()->boundingRectFor(deviceRect);-
11199 if (unpadded)
unpaddedDescription
TRUEnever evaluated
FALSEnever evaluated
0
11200 *unpadded = (effectRectF.size() == sourceRect.size());
never executed: *unpadded = (effectRectF.size() == sourceRect.size());
0
11201 if (info && system == Qt::LogicalCoordinates)
infoDescription
TRUEnever evaluated
FALSEnever evaluated
system == Qt::...calCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
0
11202 effectRectF = info->painter->worldTransform().inverted().mapRect(effectRectF);
never executed: effectRectF = info->painter->worldTransform().inverted().mapRect(effectRectF);
0
11203 } else {
never executed: end of block
0
11204 // no choice but to send a logical coordinate bounding rect to boundingRectFor-
11205 effectRectF = item->graphicsEffect()->boundingRectFor(sourceRect);-
11206 }
never executed: end of block
0
11207 } else if (mode == QGraphicsEffect::PadToTransparentBorder) {
mode == QGraph...nsparentBorderDescription
TRUEnever evaluated
FALSEnever evaluated
0
11208 // adjust by 1.5 to account for cosmetic pens-
11209 effectRectF = sourceRect.adjusted(-1.5, -1.5, 1.5, 1.5);-
11210 } else {
never executed: end of block
0
11211 effectRectF = sourceRect;-
11212 if (unpadded)
unpaddedDescription
TRUEnever evaluated
FALSEnever evaluated
0
11213 *unpadded = true;
never executed: *unpadded = true;
0
11214 }
never executed: end of block
0
11215-
11216 return effectRectF.toAlignedRect();
never executed: return effectRectF.toAlignedRect();
0
11217}-
11218-
11219QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset,-
11220 QGraphicsEffect::PixmapPadMode mode) const-
11221{-
11222 const bool deviceCoordinates = (system == Qt::DeviceCoordinates);-
11223 if (!info && deviceCoordinates) {
!infoDescription
TRUEnever evaluated
FALSEnever evaluated
deviceCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
0
11224 // Device coordinates without info not yet supported.-
11225 qWarning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context");-
11226 return QPixmap();
never executed: return QPixmap();
0
11227 }-
11228 if (!item->d_ptr->scene)
!item->d_ptr->sceneDescription
TRUEnever evaluated
FALSEnever evaluated
0
11229 return QPixmap();
never executed: return QPixmap();
0
11230 QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func();-
11231-
11232 bool unpadded;-
11233 const QRectF sourceRect = boundingRect(system);-
11234 QRect effectRect = paddedEffectRect(system, mode, sourceRect, &unpadded);-
11235-
11236 if (offset)
offsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
11237 *offset = effectRect.topLeft();
never executed: *offset = effectRect.topLeft();
0
11238-
11239 bool untransformed = !deviceCoordinates
!deviceCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
0
11240 || info->painter->worldTransform().type() <= QTransform::TxTranslate;
info->painter-...m::TxTranslateDescription
TRUEnever evaluated
FALSEnever evaluated
0
11241 if (untransformed && unpadded && isPixmap()) {
untransformedDescription
TRUEnever evaluated
FALSEnever evaluated
unpaddedDescription
TRUEnever evaluated
FALSEnever evaluated
isPixmap()Description
TRUEnever evaluated
FALSEnever evaluated
0
11242 if (offset)
offsetDescription
TRUEnever evaluated
FALSEnever evaluated
0
11243 *offset = boundingRect(system).topLeft().toPoint();
never executed: *offset = boundingRect(system).topLeft().toPoint();
0
11244 return static_cast<QGraphicsPixmapItem *>(item)->pixmap();
never executed: return static_cast<QGraphicsPixmapItem *>(item)->pixmap();
0
11245 }-
11246-
11247 if (effectRect.isEmpty())
effectRect.isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
11248 return QPixmap();
never executed: return QPixmap();
0
11249-
11250 QPixmap pixmap(effectRect.size());-
11251 pixmap.fill(Qt::transparent);-
11252 QPainter pixmapPainter(&pixmap);-
11253 pixmapPainter.setRenderHints(info ? info->painter->renderHints() : QPainter::TextAntialiasing);-
11254-
11255 QTransform effectTransform = QTransform::fromTranslate(-effectRect.x(), -effectRect.y());-
11256 if (deviceCoordinates && info->effectTransform)
deviceCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
info->effectTransformDescription
TRUEnever evaluated
FALSEnever evaluated
0
11257 effectTransform *= *info->effectTransform;
never executed: effectTransform *= *info->effectTransform;
0
11258-
11259 if (!info) {
!infoDescription
TRUEnever evaluated
FALSEnever evaluated
0
11260 // Logical coordinates without info.-
11261 QTransform sceneTransform = item->sceneTransform();-
11262 QTransform newEffectTransform = sceneTransform.inverted();-
11263 newEffectTransform *= effectTransform;-
11264 scened->draw(item, &pixmapPainter, 0, &sceneTransform, 0, 0, qreal(1.0),-
11265 &newEffectTransform, false, true);-
11266 } else if (deviceCoordinates) {
never executed: end of block
deviceCoordinatesDescription
TRUEnever evaluated
FALSEnever evaluated
0
11267 // Device coordinates with info.-
11268 scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0,-
11269 info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform,-
11270 info->drawItem);-
11271 } else {
never executed: end of block
0
11272 // Item coordinates with info.-
11273 QTransform newEffectTransform = info->transformPtr->inverted();-
11274 newEffectTransform *= effectTransform;-
11275 scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0,-
11276 info->widget, info->opacity, &newEffectTransform, info->wasDirtySceneTransform,-
11277 info->drawItem);-
11278 }
never executed: end of block
0
11279-
11280 pixmapPainter.end();-
11281-
11282 return pixmap;
never executed: return pixmap;
0
11283}-
11284#endif //QT_NO_GRAPHICSEFFECT-
11285-
11286#ifndef QT_NO_DEBUG_STREAM-
11287static void formatGraphicsItemHelper(QDebug debug, const QGraphicsItem *item)-
11288{-
11289 if (const QGraphicsItem *parent = item->parentItem())
const QGraphic...->parentItem()Description
TRUEnever evaluated
FALSEnever evaluated
0
11290 debug << ", parent=" << static_cast<const void *>(parent);
never executed: debug << ", parent=" << static_cast<const void *>(parent);
0
11291 debug << ", pos=";-
11292 QtDebugUtils::formatQPoint(debug, item->pos());-
11293 if (const qreal z = item->zValue())
const qreal z = item->zValue()Description
TRUEnever evaluated
FALSEnever evaluated
0
11294 debug << ", z=" << z;
never executed: debug << ", z=" << z;
0
11295 if (item->flags())
item->flags()Description
TRUEnever evaluated
FALSEnever evaluated
0
11296 debug << ", flags=" << item->flags();
never executed: debug << ", flags=" << item->flags();
0
11297}
never executed: end of block
0
11298-
11299// FIXME: Qt 6: Make this QDebug operator<<(QDebug debug, const QGraphicsItem *item)-
11300QDebug operator<<(QDebug debug, QGraphicsItem *item)-
11301{-
11302 QDebugStateSaver saver(debug);-
11303 debug.nospace();-
11304-
11305 if (!item) {
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
11306 debug << "QGraphicsItem(0)";-
11307 return debug;
never executed: return debug;
0
11308 }-
11309-
11310 if (QGraphicsObject *o = item->toGraphicsObject())
QGraphicsObjec...aphicsObject()Description
TRUEnever evaluated
FALSEnever evaluated
0
11311 debug << o->metaObject()->className();
never executed: debug << o->metaObject()->className();
0
11312 else-
11313 debug << "QGraphicsItem";
never executed: debug << "QGraphicsItem";
0
11314 debug << '(' << static_cast<const void *>(item);-
11315 if (const QGraphicsProxyWidget *pw = qgraphicsitem_cast<const QGraphicsProxyWidget *>(item)) {
const QGraphic...idget *>(item)Description
TRUEnever evaluated
FALSEnever evaluated
0
11316 debug << ", widget=";-
11317 if (const QWidget *w = pw->widget()) {
const QWidget ...= pw->widget()Description
TRUEnever evaluated
FALSEnever evaluated
0
11318 debug << w->metaObject()->className() << '(' << static_cast<const void *>(w);-
11319 if (!w->objectName().isEmpty())
!w->objectName().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
11320 debug << ", name=" << w->objectName();
never executed: debug << ", name=" << w->objectName();
0
11321 debug << ')';-
11322 } else {
never executed: end of block
0
11323 debug << "QWidget(0)";-
11324 }
never executed: end of block
0
11325 }-
11326 formatGraphicsItemHelper(debug, item);-
11327 debug << ')';-
11328 return debug;
never executed: return debug;
0
11329}-
11330-
11331// FIXME: Qt 6: Make this QDebug operator<<(QDebug debug, const QGraphicsObject *item)-
11332QDebug operator<<(QDebug debug, QGraphicsObject *item)-
11333{-
11334 QDebugStateSaver saver(debug);-
11335 debug.nospace();-
11336-
11337 if (!item) {
!itemDescription
TRUEnever evaluated
FALSEnever evaluated
0
11338 debug << "QGraphicsObject(0)";-
11339 return debug;
never executed: return debug;
0
11340 }-
11341-
11342 debug << item->metaObject()->className() << '(' << static_cast<const void *>(item);-
11343 if (!item->objectName().isEmpty())
!item->objectName().isEmpty()Description
TRUEnever evaluated
FALSEnever evaluated
0
11344 debug << ", name=" << item->objectName();
never executed: debug << ", name=" << item->objectName();
0
11345 formatGraphicsItemHelper(debug, item);-
11346 debug << ')';-
11347 return debug;
never executed: return debug;
0
11348}-
11349-
11350QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemChange change)-
11351{-
11352 const char *str = "UnknownChange";-
11353 switch (change) {-
11354 case QGraphicsItem::ItemChildAddedChange:
never executed: case QGraphicsItem::ItemChildAddedChange:
0
11355 str = "ItemChildAddedChange";-
11356 break;
never executed: break;
0
11357 case QGraphicsItem::ItemChildRemovedChange:
never executed: case QGraphicsItem::ItemChildRemovedChange:
0
11358 str = "ItemChildRemovedChange";-
11359 break;
never executed: break;
0
11360 case QGraphicsItem::ItemCursorChange:
never executed: case QGraphicsItem::ItemCursorChange:
0
11361 str = "ItemCursorChange";-
11362 break;
never executed: break;
0
11363 case QGraphicsItem::ItemCursorHasChanged:
never executed: case QGraphicsItem::ItemCursorHasChanged:
0
11364 str = "ItemCursorHasChanged";-
11365 break;
never executed: break;
0
11366 case QGraphicsItem::ItemEnabledChange:
never executed: case QGraphicsItem::ItemEnabledChange:
0
11367 str = "ItemEnabledChange";-
11368 break;
never executed: break;
0
11369 case QGraphicsItem::ItemEnabledHasChanged:
never executed: case QGraphicsItem::ItemEnabledHasChanged:
0
11370 str = "ItemEnabledHasChanged";-
11371 break;
never executed: break;
0
11372 case QGraphicsItem::ItemFlagsChange:
never executed: case QGraphicsItem::ItemFlagsChange:
0
11373 str = "ItemFlagsChange";-
11374 break;
never executed: break;
0
11375 case QGraphicsItem::ItemFlagsHaveChanged:
never executed: case QGraphicsItem::ItemFlagsHaveChanged:
0
11376 str = "ItemFlagsHaveChanged";-
11377 break;
never executed: break;
0
11378 case QGraphicsItem::ItemMatrixChange:
never executed: case QGraphicsItem::ItemMatrixChange:
0
11379 str = "ItemMatrixChange";-
11380 break;
never executed: break;
0
11381 case QGraphicsItem::ItemParentChange:
never executed: case QGraphicsItem::ItemParentChange:
0
11382 str = "ItemParentChange";-
11383 break;
never executed: break;
0
11384 case QGraphicsItem::ItemParentHasChanged:
never executed: case QGraphicsItem::ItemParentHasChanged:
0
11385 str = "ItemParentHasChanged";-
11386 break;
never executed: break;
0
11387 case QGraphicsItem::ItemPositionChange:
never executed: case QGraphicsItem::ItemPositionChange:
0
11388 str = "ItemPositionChange";-
11389 break;
never executed: break;
0
11390 case QGraphicsItem::ItemPositionHasChanged:
never executed: case QGraphicsItem::ItemPositionHasChanged:
0
11391 str = "ItemPositionHasChanged";-
11392 break;
never executed: break;
0
11393 case QGraphicsItem::ItemSceneChange:
never executed: case QGraphicsItem::ItemSceneChange:
0
11394 str = "ItemSceneChange";-
11395 break;
never executed: break;
0
11396 case QGraphicsItem::ItemSceneHasChanged:
never executed: case QGraphicsItem::ItemSceneHasChanged:
0
11397 str = "ItemSceneHasChanged";-
11398 break;
never executed: break;
0
11399 case QGraphicsItem::ItemSelectedChange:
never executed: case QGraphicsItem::ItemSelectedChange:
0
11400 str = "ItemSelectedChange";-
11401 break;
never executed: break;
0
11402 case QGraphicsItem::ItemSelectedHasChanged:
never executed: case QGraphicsItem::ItemSelectedHasChanged:
0
11403 str = "ItemSelectedHasChanged";-
11404 break;
never executed: break;
0
11405 case QGraphicsItem::ItemToolTipChange:
never executed: case QGraphicsItem::ItemToolTipChange:
0
11406 str = "ItemToolTipChange";-
11407 break;
never executed: break;
0
11408 case QGraphicsItem::ItemToolTipHasChanged:
never executed: case QGraphicsItem::ItemToolTipHasChanged:
0
11409 str = "ItemToolTipHasChanged";-
11410 break;
never executed: break;
0
11411 case QGraphicsItem::ItemTransformChange:
never executed: case QGraphicsItem::ItemTransformChange:
0
11412 str = "ItemTransformChange";-
11413 break;
never executed: break;
0
11414 case QGraphicsItem::ItemTransformHasChanged:
never executed: case QGraphicsItem::ItemTransformHasChanged:
0
11415 str = "ItemTransformHasChanged";-
11416 break;
never executed: break;
0
11417 case QGraphicsItem::ItemVisibleChange:
never executed: case QGraphicsItem::ItemVisibleChange:
0
11418 str = "ItemVisibleChange";-
11419 break;
never executed: break;
0
11420 case QGraphicsItem::ItemVisibleHasChanged:
never executed: case QGraphicsItem::ItemVisibleHasChanged:
0
11421 str = "ItemVisibleHasChanged";-
11422 break;
never executed: break;
0
11423 case QGraphicsItem::ItemZValueChange:
never executed: case QGraphicsItem::ItemZValueChange:
0
11424 str = "ItemZValueChange";-
11425 break;
never executed: break;
0
11426 case QGraphicsItem::ItemZValueHasChanged:
never executed: case QGraphicsItem::ItemZValueHasChanged:
0
11427 str = "ItemZValueHasChanged";-
11428 break;
never executed: break;
0
11429 case QGraphicsItem::ItemOpacityChange:
never executed: case QGraphicsItem::ItemOpacityChange:
0
11430 str = "ItemOpacityChange";-
11431 break;
never executed: break;
0
11432 case QGraphicsItem::ItemOpacityHasChanged:
never executed: case QGraphicsItem::ItemOpacityHasChanged:
0
11433 str = "ItemOpacityHasChanged";-
11434 break;
never executed: break;
0
11435 case QGraphicsItem::ItemScenePositionHasChanged:
never executed: case QGraphicsItem::ItemScenePositionHasChanged:
0
11436 str = "ItemScenePositionHasChanged";-
11437 break;
never executed: break;
0
11438 case QGraphicsItem::ItemRotationChange:
never executed: case QGraphicsItem::ItemRotationChange:
0
11439 str = "ItemRotationChange";-
11440 break;
never executed: break;
0
11441 case QGraphicsItem::ItemRotationHasChanged:
never executed: case QGraphicsItem::ItemRotationHasChanged:
0
11442 str = "ItemRotationHasChanged";-
11443 break;
never executed: break;
0
11444 case QGraphicsItem::ItemScaleChange:
never executed: case QGraphicsItem::ItemScaleChange:
0
11445 str = "ItemScaleChange";-
11446 break;
never executed: break;
0
11447 case QGraphicsItem::ItemScaleHasChanged:
never executed: case QGraphicsItem::ItemScaleHasChanged:
0
11448 str = "ItemScaleHasChanged";-
11449 break;
never executed: break;
0
11450 case QGraphicsItem::ItemTransformOriginPointChange:
never executed: case QGraphicsItem::ItemTransformOriginPointChange:
0
11451 str = "ItemTransformOriginPointChange";-
11452 break;
never executed: break;
0
11453 case QGraphicsItem::ItemTransformOriginPointHasChanged:
never executed: case QGraphicsItem::ItemTransformOriginPointHasChanged:
0
11454 str = "ItemTransformOriginPointHasChanged";-
11455 break;
never executed: break;
0
11456 }-
11457 debug << str;-
11458 return debug;
never executed: return debug;
0
11459}-
11460-
11461QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlag flag)-
11462{-
11463 const char *str = "UnknownFlag";-
11464 switch (flag) {-
11465 case QGraphicsItem::ItemIsMovable:
never executed: case QGraphicsItem::ItemIsMovable:
0
11466 str = "ItemIsMovable";-
11467 break;
never executed: break;
0
11468 case QGraphicsItem::ItemIsSelectable:
never executed: case QGraphicsItem::ItemIsSelectable:
0
11469 str = "ItemIsSelectable";-
11470 break;
never executed: break;
0
11471 case QGraphicsItem::ItemIsFocusable:
never executed: case QGraphicsItem::ItemIsFocusable:
0
11472 str = "ItemIsFocusable";-
11473 break;
never executed: break;
0
11474 case QGraphicsItem::ItemClipsToShape:
never executed: case QGraphicsItem::ItemClipsToShape:
0
11475 str = "ItemClipsToShape";-
11476 break;
never executed: break;
0
11477 case QGraphicsItem::ItemClipsChildrenToShape:
never executed: case QGraphicsItem::ItemClipsChildrenToShape:
0
11478 str = "ItemClipsChildrenToShape";-
11479 break;
never executed: break;
0
11480 case QGraphicsItem::ItemIgnoresTransformations:
never executed: case QGraphicsItem::ItemIgnoresTransformations:
0
11481 str = "ItemIgnoresTransformations";-
11482 break;
never executed: break;
0
11483 case QGraphicsItem::ItemIgnoresParentOpacity:
never executed: case QGraphicsItem::ItemIgnoresParentOpacity:
0
11484 str = "ItemIgnoresParentOpacity";-
11485 break;
never executed: break;
0
11486 case QGraphicsItem::ItemDoesntPropagateOpacityToChildren:
never executed: case QGraphicsItem::ItemDoesntPropagateOpacityToChildren:
0
11487 str = "ItemDoesntPropagateOpacityToChildren";-
11488 break;
never executed: break;
0
11489 case QGraphicsItem::ItemStacksBehindParent:
never executed: case QGraphicsItem::ItemStacksBehindParent:
0
11490 str = "ItemStacksBehindParent";-
11491 break;
never executed: break;
0
11492 case QGraphicsItem::ItemUsesExtendedStyleOption:
never executed: case QGraphicsItem::ItemUsesExtendedStyleOption:
0
11493 str = "ItemUsesExtendedStyleOption";-
11494 break;
never executed: break;
0
11495 case QGraphicsItem::ItemHasNoContents:
never executed: case QGraphicsItem::ItemHasNoContents:
0
11496 str = "ItemHasNoContents";-
11497 break;
never executed: break;
0
11498 case QGraphicsItem::ItemSendsGeometryChanges:
never executed: case QGraphicsItem::ItemSendsGeometryChanges:
0
11499 str = "ItemSendsGeometryChanges";-
11500 break;
never executed: break;
0
11501 case QGraphicsItem::ItemAcceptsInputMethod:
never executed: case QGraphicsItem::ItemAcceptsInputMethod:
0
11502 str = "ItemAcceptsInputMethod";-
11503 break;
never executed: break;
0
11504 case QGraphicsItem::ItemNegativeZStacksBehindParent:
never executed: case QGraphicsItem::ItemNegativeZStacksBehindParent:
0
11505 str = "ItemNegativeZStacksBehindParent";-
11506 break;
never executed: break;
0
11507 case QGraphicsItem::ItemIsPanel:
never executed: case QGraphicsItem::ItemIsPanel:
0
11508 str = "ItemIsPanel";-
11509 break;
never executed: break;
0
11510 case QGraphicsItem::ItemIsFocusScope:
never executed: case QGraphicsItem::ItemIsFocusScope:
0
11511 str = "ItemIsFocusScope";-
11512 break;
never executed: break;
0
11513 case QGraphicsItem::ItemSendsScenePositionChanges:
never executed: case QGraphicsItem::ItemSendsScenePositionChanges:
0
11514 str = "ItemSendsScenePositionChanges";-
11515 break;
never executed: break;
0
11516 case QGraphicsItem::ItemStopsClickFocusPropagation:
never executed: case QGraphicsItem::ItemStopsClickFocusPropagation:
0
11517 str = "ItemStopsClickFocusPropagation";-
11518 break;
never executed: break;
0
11519 case QGraphicsItem::ItemStopsFocusHandling:
never executed: case QGraphicsItem::ItemStopsFocusHandling:
0
11520 str = "ItemStopsFocusHandling";-
11521 break;
never executed: break;
0
11522 case QGraphicsItem::ItemContainsChildrenInShape:
never executed: case QGraphicsItem::ItemContainsChildrenInShape:
0
11523 str = "ItemContainsChildrenInShape";-
11524 break;
never executed: break;
0
11525 }-
11526 debug << str;-
11527 return debug;
never executed: return debug;
0
11528}-
11529-
11530QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlags flags)-
11531{-
11532 debug << '(';-
11533 bool f = false;-
11534 for (int i = 0; i < 17; ++i) {
i < 17Description
TRUEnever evaluated
FALSEnever evaluated
0
11535 if (flags & (1 << i)) {
flags & (1 << i)Description
TRUEnever evaluated
FALSEnever evaluated
0
11536 if (f)
fDescription
TRUEnever evaluated
FALSEnever evaluated
0
11537 debug << '|';
never executed: debug << '|';
0
11538 f = true;-
11539 debug << QGraphicsItem::GraphicsItemFlag(int(flags & (1 << i)));-
11540 }
never executed: end of block
0
11541 }
never executed: end of block
0
11542 debug << ')';-
11543 return debug;
never executed: return debug;
0
11544}-
11545-
11546#endif-
11547-
11548QT_END_NAMESPACE-
11549-
11550#include "moc_qgraphicsitem.cpp"-
11551-
11552#endif // QT_NO_GRAPHICSVIEW-
Source codeSwitch to Preprocessed file

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