Line | Source Code | Coverage |
---|
1 | /**************************************************************************** | - |
2 | ** | - |
3 | ** Copyright (C) 2012 Digia Plc and/or its subsidiary(-ies). | - |
4 | ** Contact: http://www.qt-project.org/legal | - |
5 | ** | - |
6 | ** This file is part of the QtGui module of the Qt Toolkit. | - |
7 | ** | - |
8 | ** $QT_BEGIN_LICENSE:LGPL$ | - |
9 | ** Commercial License Usage | - |
10 | ** Licensees holding valid commercial Qt licenses may use this file in | - |
11 | ** accordance with the commercial license agreement provided with the | - |
12 | ** Software or, alternatively, in accordance with the terms contained in | - |
13 | ** a written agreement between you and Digia. For licensing terms and | - |
14 | ** conditions see http://qt.digia.com/licensing. For further information | - |
15 | ** use the contact form at http://qt.digia.com/contact-us. | - |
16 | ** | - |
17 | ** GNU Lesser General Public License Usage | - |
18 | ** Alternatively, this file may be used under the terms of the GNU Lesser | - |
19 | ** General Public License version 2.1 as published by the Free Software | - |
20 | ** Foundation and appearing in the file LICENSE.LGPL included in the | - |
21 | ** packaging of this file. Please review the following information to | - |
22 | ** ensure the GNU Lesser General Public License version 2.1 requirements | - |
23 | ** will be met: http://www.gnu.org/licenses/old-licenses/lgpl-2.1.html. | - |
24 | ** | - |
25 | ** In addition, as a special exception, Digia gives you certain additional | - |
26 | ** rights. These rights are described in the Digia Qt LGPL Exception | - |
27 | ** version 1.1, included in the file LGPL_EXCEPTION.txt in this package. | - |
28 | ** | - |
29 | ** GNU General Public License Usage | - |
30 | ** Alternatively, this file may be used under the terms of the GNU | - |
31 | ** General Public License version 3.0 as published by the Free Software | - |
32 | ** Foundation and appearing in the file LICENSE.GPL included in the | - |
33 | ** packaging of this file. Please review the following information to | - |
34 | ** ensure the GNU General Public License version 3.0 requirements will be | - |
35 | ** met: http://www.gnu.org/copyleft/gpl.html. | - |
36 | ** | - |
37 | ** | - |
38 | ** $QT_END_LICENSE$ | - |
39 | ** | - |
40 | ****************************************************************************/ | - |
41 | | - |
42 | /*! | - |
43 | \class QGraphicsItem | - |
44 | \brief The QGraphicsItem class is the base class for all graphical | - |
45 | items in a QGraphicsScene. | - |
46 | \since 4.2 | - |
47 | | - |
48 | \ingroup graphicsview-api | - |
49 | \inmodule QtWidgets | - |
50 | | - |
51 | It provides a light-weight foundation for writing your own custom items. | - |
52 | This includes defining the item's geometry, collision detection, its | - |
53 | painting implementation and item interaction through its event handlers. | - |
54 | QGraphicsItem is part of the \l{Graphics View Framework} | - |
55 | | - |
56 | \image graphicsview-items.png | - |
57 | | - |
58 | For convenience, Qt provides a set of standard graphics items for the most | - |
59 | common shapes. These are: | - |
60 | | - |
61 | \list | - |
62 | \li QGraphicsEllipseItem provides an ellipse item | - |
63 | \li QGraphicsLineItem provides a line item | - |
64 | \li QGraphicsPathItem provides an arbitrary path item | - |
65 | \li QGraphicsPixmapItem provides a pixmap item | - |
66 | \li QGraphicsPolygonItem provides a polygon item | - |
67 | \li QGraphicsRectItem provides a rectangular item | - |
68 | \li QGraphicsSimpleTextItem provides a simple text label item | - |
69 | \li QGraphicsTextItem provides an advanced text browser item | - |
70 | \endlist | - |
71 | | - |
72 | All of an item's geometric information is based on its local coordinate | - |
73 | system. The item's position, pos(), is the only function that does not | - |
74 | operate in local coordinates, as it returns a position in parent | - |
75 | coordinates. \l {The Graphics View Coordinate System} describes the coordinate | - |
76 | system in detail. | - |
77 | | - |
78 | You can set whether an item should be visible (i.e., drawn, and accepting | - |
79 | events), by calling setVisible(). Hiding an item will also hide its | - |
80 | children. Similarly, you can enable or disable an item by calling | - |
81 | setEnabled(). If you disable an item, all its children will also be | - |
82 | disabled. By default, items are both visible and enabled. To toggle | - |
83 | whether an item is selected or not, first enable selection by setting | - |
84 | the ItemIsSelectable flag, and then call setSelected(). Normally, | - |
85 | selection is toggled by the scene, as a result of user interaction. | - |
86 | | - |
87 | To write your own graphics item, you first create a subclass of | - |
88 | QGraphicsItem, and then start by implementing its two pure virtual public | - |
89 | functions: boundingRect(), which returns an estimate of the area painted | - |
90 | by the item, and paint(), which implements the actual painting. For | - |
91 | example: | - |
92 | | - |
93 | \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 0 | - |
94 | | - |
95 | The boundingRect() function has many different purposes. | - |
96 | QGraphicsScene bases its item index on boundingRect(), and | - |
97 | QGraphicsView uses it both for culling invisible items, and for | - |
98 | determining the area that needs to be recomposed when drawing | - |
99 | overlapping items. In addition, QGraphicsItem's collision | - |
100 | detection mechanisms use boundingRect() to provide an efficient | - |
101 | cut-off. The fine grained collision algorithm in | - |
102 | collidesWithItem() is based on calling shape(), which returns an | - |
103 | accurate outline of the item's shape as a QPainterPath. | - |
104 | | - |
105 | QGraphicsScene expects all items boundingRect() and shape() to | - |
106 | remain unchanged unless it is notified. If you want to change an | - |
107 | item's geometry in any way, you must first call | - |
108 | prepareGeometryChange() to allow QGraphicsScene to update its | - |
109 | bookkeeping. | - |
110 | | - |
111 | Collision detection can be done in two ways: | - |
112 | | - |
113 | \list 1 | - |
114 | | - |
115 | \li Reimplement shape() to return an accurate shape for your item, | - |
116 | and rely on the default implementation of collidesWithItem() to do | - |
117 | shape-shape intersection. This can be rather expensive if the | - |
118 | shapes are complex. | - |
119 | | - |
120 | \li Reimplement collidesWithItem() to provide your own custom item | - |
121 | and shape collision algorithm. | - |
122 | | - |
123 | \endlist | - |
124 | | - |
125 | The contains() function can be called to determine whether the item \e | - |
126 | contains a point or not. This function can also be reimplemented by the | - |
127 | item. The default behavior of contains() is based on calling shape(). | - |
128 | | - |
129 | Items can contain other items, and also be contained by other items. All | - |
130 | items can have a parent item and a list of children. Unless the item has | - |
131 | no parent, its position is in \e parent coordinates (i.e., the parent's | - |
132 | local coordinates). Parent items propagate both their position and their | - |
133 | transformation to all children. | - |
134 | | - |
135 | \image graphicsview-parentchild.png | - |
136 | | - |
137 | \target Transformations | - |
138 | \section1 Transformations | - |
139 | | - |
140 | QGraphicsItem supports projective transformations in addition to its base | - |
141 | position, pos(). There are several ways to change an item's transformation. | - |
142 | For simple transformations, you can call either of the convenience | - |
143 | functions setRotation() or setScale(), or you can pass any transformation | - |
144 | matrix to setTransform(). For advanced transformation control you also have | - |
145 | the option of setting several combined transformations by calling | - |
146 | setTransformations(). | - |
147 | | - |
148 | Item transformations accumulate from parent to child, so if both a parent | - |
149 | and child item are rotated 90 degrees, the child's total transformation | - |
150 | will be 180 degrees. Similarly, if the item's parent is scaled to 2x its | - |
151 | original size, its children will also be twice as large. An item's | - |
152 | transformation does not affect its own local geometry; all geometry | - |
153 | functions (e.g., contains(), update(), and all the mapping functions) still | - |
154 | operate in local coordinates. For convenience, QGraphicsItem provides the | - |
155 | functions sceneTransform(), which returns the item's total transformation | - |
156 | matrix (including its position and all parents' positions and | - |
157 | transformations), and scenePos(), which returns its position in scene | - |
158 | coordinates. To reset an item's matrix, call resetTransform(). | - |
159 | | - |
160 | Certain transformation operations produce a different outcome depending on | - |
161 | the order in which they are applied. For example, if you scale an | - |
162 | transform, and then rotate it, you may get a different result than if the | - |
163 | transform was rotated first. However, the order you set the transformation | - |
164 | properties on QGraphicsItem does not affect the resulting transformation; | - |
165 | QGraphicsItem always applies the properties in a fixed, defined order: | - |
166 | | - |
167 | \list | - |
168 | \li The item's base transform is applied (transform()) | - |
169 | \li The item's transformations list is applied in order (transformations()) | - |
170 | \li The item is rotated relative to its transform origin point (rotation(), transformOriginPoint()) | - |
171 | \li The item is scaled relative to its transform origin point (scale(), transformOriginPoint()) | - |
172 | \endlist | - |
173 | | - |
174 | \section1 Painting | - |
175 | | - |
176 | The paint() function is called by QGraphicsView to paint the item's | - |
177 | contents. The item has no background or default fill of its own; whatever | - |
178 | is behind the item will shine through all areas that are not explicitly | - |
179 | painted in this function. You can call update() to schedule a repaint, | - |
180 | optionally passing the rectangle that needs a repaint. Depending on | - |
181 | whether or not the item is visible in a view, the item may or may not be | - |
182 | repainted; there is no equivalent to QWidget::repaint() in QGraphicsItem. | - |
183 | | - |
184 | Items are painted by the view, starting with the parent items and then | - |
185 | drawing children, in ascending stacking order. You can set an item's | - |
186 | stacking order by calling setZValue(), and test it by calling | - |
187 | zValue(), where items with low z-values are painted before items with | - |
188 | high z-values. Stacking order applies to sibling items; parents are always | - |
189 | drawn before their children. | - |
190 | | - |
191 | \section1 Sorting | - |
192 | | - |
193 | All items are drawn in a defined, stable order, and this same order decides | - |
194 | which items will receive mouse input first when you click on the scene. | - |
195 | Normally you don't have to worry about sorting, as the items follow a | - |
196 | "natural order", following the logical structure of the scene. | - |
197 | | - |
198 | An item's children are stacked on top of the parent, and sibling items are | - |
199 | stacked by insertion order (i.e., in the same order that they were either | - |
200 | added to the scene, or added to the same parent). If you add item A, and | - |
201 | then B, then B will be on top of A. If you then add C, the items' stacking | - |
202 | order will be A, then B, then C. | - |
203 | | - |
204 | \image graphicsview-zorder.png | - |
205 | | - |
206 | This example shows the stacking order of all limbs of the robot from the | - |
207 | \l{graphicsview/dragdroprobot}{Drag and Drop Robot} example. The torso is | - |
208 | the root item (all other items are children or descendants of the torso), | - |
209 | so it is drawn first. Next, the head is drawn, as it is the first item in | - |
210 | the torso's list of children. Then the upper left arm is drawn. As the | - |
211 | lower arm is a child of the upper arm, the lower arm is then drawn, | - |
212 | followed by the upper arm's next sibling, which is the upper right arm, and | - |
213 | so on. | - |
214 | | - |
215 | For advanced users, there are ways to alter how your items are sorted: | - |
216 | | - |
217 | \list | - |
218 | \li You can call setZValue() on an item to explicitly stack it on top of, or | - |
219 | under, other sibling items. The default Z value for an item is 0. Items | - |
220 | with the same Z value are stacked by insertion order. | - |
221 | | - |
222 | \li You can call stackBefore() to reorder the list of children. This will | - |
223 | directly modify the insertion order. | - |
224 | | - |
225 | \li You can set the ItemStacksBehindParent flag to stack a child item behind | - |
226 | its parent. | - |
227 | \endlist | - |
228 | | - |
229 | The stacking order of two sibling items also counts for each item's | - |
230 | children and descendant items. So if one item is on top of another, then | - |
231 | all its children will also be on top of all the other item's children as | - |
232 | well. | - |
233 | | - |
234 | \section1 Events | - |
235 | | - |
236 | QGraphicsItem receives events from QGraphicsScene through the virtual | - |
237 | function sceneEvent(). This function distributes the most common events | - |
238 | to a set of convenience event handlers: | - |
239 | | - |
240 | \list | - |
241 | \li contextMenuEvent() handles context menu events | - |
242 | \li focusInEvent() and focusOutEvent() handle focus in and out events | - |
243 | \li hoverEnterEvent(), hoverMoveEvent(), and hoverLeaveEvent() handles | - |
244 | hover enter, move and leave events | - |
245 | \li inputMethodEvent() handles input events, for accessibility support | - |
246 | \li keyPressEvent() and keyReleaseEvent() handle key press and release events | - |
247 | \li mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(), and | - |
248 | mouseDoubleClickEvent() handles mouse press, move, release, click and | - |
249 | doubleclick events | - |
250 | \endlist | - |
251 | | - |
252 | You can filter events for any other item by installing event filters. This | - |
253 | functionality is separate from Qt's regular event filters (see | - |
254 | QObject::installEventFilter()), which only work on subclasses of QObject. After | - |
255 | installing your item as an event filter for another item by calling | - |
256 | installSceneEventFilter(), the filtered events will be received by the virtual | - |
257 | function sceneEventFilter(). You can remove item event filters by calling | - |
258 | removeSceneEventFilter(). | - |
259 | | - |
260 | \section1 Custom Data | - |
261 | | - |
262 | Sometimes it's useful to register custom data with an item, be it a custom | - |
263 | item, or a standard item. You can call setData() on any item to store data | - |
264 | in it using a key-value pair (the key being an integer, and the value is a | - |
265 | QVariant). To get custom data from an item, call data(). This | - |
266 | functionality is completely untouched by Qt itself; it is provided for the | - |
267 | user's convenience. | - |
268 | | - |
269 | \sa QGraphicsScene, QGraphicsView, {Graphics View Framework} | - |
270 | */ | - |
271 | | - |
272 | /*! | - |
273 | \variable QGraphicsItem::Type | - |
274 | | - |
275 | The type value returned by the virtual type() function in standard | - |
276 | graphics item classes in Qt. All such standard graphics item | - |
277 | classes in Qt are associated with a unique value for Type, | - |
278 | e.g. the value returned by QGraphicsPathItem::type() is 2. | - |
279 | | - |
280 | \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 18 | - |
281 | */ | - |
282 | | - |
283 | /*! | - |
284 | \variable QGraphicsItem::UserType | - |
285 | | - |
286 | The lowest permitted type value for custom items (subclasses | - |
287 | of QGraphicsItem or any of the standard items). This value is | - |
288 | used in conjunction with a reimplementation of QGraphicsItem::type() | - |
289 | and declaring a Type enum value. Example: | - |
290 | | - |
291 | \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 1 | - |
292 | | - |
293 | \note UserType = 65536 | - |
294 | */ | - |
295 | | - |
296 | /*! | - |
297 | \enum QGraphicsItem::GraphicsItemFlag | - |
298 | | - |
299 | This enum describes different flags that you can set on an item to | - |
300 | toggle different features in the item's behavior. | - |
301 | | - |
302 | All flags are disabled by default. | - |
303 | | - |
304 | \value ItemIsMovable The item supports interactive movement using | - |
305 | the mouse. By clicking on the item and then dragging, the item | - |
306 | will move together with the mouse cursor. If the item has | - |
307 | children, all children are also moved. If the item is part of a | - |
308 | selection, all selected items are also moved. This feature is | - |
309 | provided as a convenience through the base implementation of | - |
310 | QGraphicsItem's mouse event handlers. | - |
311 | | - |
312 | \value ItemIsSelectable The item supports selection. Enabling this | - |
313 | feature will enable setSelected() to toggle selection for the | - |
314 | item. It will also let the item be selected automatically as a | - |
315 | result of calling QGraphicsScene::setSelectionArea(), by clicking | - |
316 | on an item, or by using rubber band selection in QGraphicsView. | - |
317 | | - |
318 | \value ItemIsFocusable The item supports keyboard input focus (i.e., it is | - |
319 | an input item). Enabling this flag will allow the item to accept focus, | - |
320 | which again allows the delivery of key events to | - |
321 | QGraphicsItem::keyPressEvent() and QGraphicsItem::keyReleaseEvent(). | - |
322 | | - |
323 | \value ItemClipsToShape The item clips to its own shape. The item cannot | - |
324 | draw or receive mouse, tablet, drag and drop or hover events outside its | - |
325 | shape. It is disabled by default. This behavior is enforced by | - |
326 | QGraphicsView::drawItems() or QGraphicsScene::drawItems(). This flag was | - |
327 | introduced in Qt 4.3. | - |
328 | | - |
329 | \value ItemClipsChildrenToShape The item clips the painting of all its | - |
330 | descendants to its own shape. Items that are either direct or indirect | - |
331 | children of this item cannot draw outside this item's shape. By default, | - |
332 | this flag is disabled; children can draw anywhere. This behavior is | - |
333 | enforced by QGraphicsView::drawItems() or | - |
334 | QGraphicsScene::drawItems(). This flag was introduced in Qt 4.3. | - |
335 | | - |
336 | \value ItemIgnoresTransformations The item ignores inherited | - |
337 | transformations (i.e., its position is still anchored to its parent, but | - |
338 | the parent or view rotation, zoom or shear transformations are ignored). | - |
339 | This flag is useful for keeping text label items horizontal and unscaled, | - |
340 | so they will still be readable if the view is transformed. When set, the | - |
341 | item's view geometry and scene geometry will be maintained separately. You | - |
342 | must call deviceTransform() to map coordinates and detect collisions in | - |
343 | the view. By default, this flag is disabled. This flag was introduced in | - |
344 | Qt 4.3. \note With this flag set you can still scale the item itself, and | - |
345 | that scale transformation will influence the item's children. | - |
346 | | - |
347 | \value ItemIgnoresParentOpacity The item ignores its parent's opacity. The | - |
348 | item's effective opacity is the same as its own; it does not combine with | - |
349 | the parent's opacity. This flags allows your item to keep its absolute | - |
350 | opacity even if the parent is semitransparent. This flag was introduced in | - |
351 | Qt 4.5. | - |
352 | | - |
353 | \value ItemDoesntPropagateOpacityToChildren The item doesn't propagate its | - |
354 | opacity to its children. This flag allows you to create a semitransparent | - |
355 | item that does not affect the opacity of its children. This flag was | - |
356 | introduced in Qt 4.5. | - |
357 | | - |
358 | \value ItemStacksBehindParent The item is stacked behind its parent. By | - |
359 | default, child items are stacked on top of the parent item. But setting | - |
360 | this flag, the child will be stacked behind it. This flag is useful for | - |
361 | drop shadow effects and for decoration objects that follow the parent | - |
362 | item's geometry without drawing on top of it. This flag was introduced | - |
363 | in Qt 4.5. | - |
364 | | - |
365 | \value ItemUsesExtendedStyleOption The item makes use of either | - |
366 | \l{QStyleOptionGraphicsItem::} {exposedRect} or | - |
367 | \l{QStyleOptionGraphicsItem::} {matrix} in | - |
368 | QStyleOptionGraphicsItem. By default, the | - |
369 | \l{QStyleOptionGraphicsItem::} {exposedRect} is initialized to the | - |
370 | item's boundingRect() and the | - |
371 | \l{QStyleOptionGraphicsItem::}{matrix} is untransformed. You can | - |
372 | enable this flag for the style options to be set up with more | - |
373 | fine-grained values. Note that | - |
374 | QStyleOptionGraphicsItem::levelOfDetail is unaffected by this flag | - |
375 | and always initialized to 1. Use | - |
376 | QStyleOptionGraphicsItem::levelOfDetailFromTransform() if you need | - |
377 | a higher value. This flag was introduced in Qt 4.6. | - |
378 | | - |
379 | \value ItemHasNoContents The item does not paint anything (i.e., calling | - |
380 | paint() on the item has no effect). You should set this flag on items that | - |
381 | do not need to be painted to ensure that Graphics View avoids unnecessary | - |
382 | painting preparations. This flag was introduced in Qt 4.6. | - |
383 | | - |
384 | \value ItemSendsGeometryChanges The item enables itemChange() | - |
385 | notifications for ItemPositionChange, ItemPositionHasChanged, | - |
386 | ItemMatrixChange, ItemTransformChange, ItemTransformHasChanged, | - |
387 | ItemRotationChange, ItemRotationHasChanged, ItemScaleChange, ItemScaleHasChanged, | - |
388 | ItemTransformOriginPointChange, and ItemTransformOriginPointHasChanged. For | - |
389 | performance reasons, these notifications are disabled by default. You must | - |
390 | enable this flag to receive notifications for position and transform | - |
391 | changes. This flag was introduced in Qt 4.6. | - |
392 | | - |
393 | \value ItemAcceptsInputMethod The item supports input methods typically | - |
394 | used for Asian languages. | - |
395 | This flag was introduced in Qt 4.6. | - |
396 | | - |
397 | \value ItemNegativeZStacksBehindParent The item automatically | - |
398 | stacks behind it's parent if it's z-value is negative. This flag | - |
399 | enables setZValue() to toggle ItemStacksBehindParent. This flag | - |
400 | was introduced in Qt 4.6. | - |
401 | | - |
402 | \value ItemIsPanel The item is a panel. A panel provides activation and | - |
403 | contained focus handling. Only one panel can be active at a time (see | - |
404 | QGraphicsItem::isActive()). When no panel is active, QGraphicsScene | - |
405 | activates all non-panel items. Window items (i.e., | - |
406 | QGraphicsItem::isWindow() returns true) are panels. This flag was | - |
407 | introduced in Qt 4.6. | - |
408 | | - |
409 | \omitvalue ItemIsFocusScope \omit Internal only (for now). \endomit | - |
410 | | - |
411 | \value ItemSendsScenePositionChanges The item enables itemChange() | - |
412 | notifications for ItemScenePositionHasChanged. For performance reasons, | - |
413 | these notifications are disabled by default. You must enable this flag | - |
414 | to receive notifications for scene position changes. This flag was | - |
415 | introduced in Qt 4.6. | - |
416 | | - |
417 | \omitvalue ItemStopsClickFocusPropagation \omit The item stops propagating | - |
418 | click focus to items underneath when being clicked on. This flag | - |
419 | allows you create a non-focusable item that can be clicked on without | - |
420 | changing the focus. \endomit | - |
421 | | - |
422 | \omitvalue ItemStopsFocusHandling \omit Same as | - |
423 | ItemStopsClickFocusPropagation, but also suppresses focus-out. This flag | - |
424 | allows you to completely take over focus handling. | - |
425 | This flag was introduced in Qt 4.7. \endomit | - |
426 | */ | - |
427 | | - |
428 | /*! | - |
429 | \enum QGraphicsItem::GraphicsItemChange | - |
430 | | - |
431 | This enum describes the state changes that are notified by | - |
432 | QGraphicsItem::itemChange(). The notifications are sent as the state | - |
433 | changes, and in some cases, adjustments can be made (see the documentation | - |
434 | for each change for details). | - |
435 | | - |
436 | Note: Be careful with calling functions on the QGraphicsItem itself inside | - |
437 | itemChange(), as certain function calls can lead to unwanted | - |
438 | recursion. For example, you cannot call setPos() in itemChange() on an | - |
439 | ItemPositionChange notification, as the setPos() function will again call | - |
440 | itemChange(ItemPositionChange). Instead, you can return the new, adjusted | - |
441 | position from itemChange(). | - |
442 | | - |
443 | \value ItemEnabledChange The item's enabled state changes. If the item is | - |
444 | presently enabled, it will become disabled, and vice verca. The value | - |
445 | argument is the new enabled state (i.e., true or false). Do not call | - |
446 | setEnabled() in itemChange() as this notification is delivered. Instead, | - |
447 | you can return the new state from itemChange(). | - |
448 | | - |
449 | \value ItemEnabledHasChanged The item's enabled state has changed. The | - |
450 | value argument is the new enabled state (i.e., true or false). Do not call | - |
451 | setEnabled() in itemChange() as this notification is delivered. The return | - |
452 | value is ignored. | - |
453 | | - |
454 | \value ItemMatrixChange The item's affine transformation matrix is | - |
455 | changing. This value is obsolete; you can use ItemTransformChange instead. | - |
456 | | - |
457 | \value ItemPositionChange The item's position changes. This notification | - |
458 | is sent if the ItemSendsGeometryChanges flag is enabled, and when the | - |
459 | item's local position changes, relative to its parent (i.e., as a result | - |
460 | of calling setPos() or moveBy()). The value argument is the new position | - |
461 | (i.e., a QPointF). You can call pos() to get the original position. Do | - |
462 | not call setPos() or moveBy() in itemChange() as this notification is | - |
463 | delivered; instead, you can return the new, adjusted position from | - |
464 | itemChange(). After this notification, QGraphicsItem immediately sends the | - |
465 | ItemPositionHasChanged notification if the position changed. | - |
466 | | - |
467 | \value ItemPositionHasChanged The item's position has changed. This | - |
468 | notification is sent if the ItemSendsGeometryChanges flag is enabled, and | - |
469 | after the item's local position, relative to its parent, has changed. The | - |
470 | value argument is the new position (the same as pos()), and QGraphicsItem | - |
471 | ignores the return value for this notification (i.e., a read-only | - |
472 | notification). | - |
473 | | - |
474 | \value ItemTransformChange The item's transformation matrix changes. This | - |
475 | notification is send if the ItemSendsGeometryChanges flag is enabled, and | - |
476 | when the item's local transformation matrix changes (i.e., as a result of | - |
477 | calling setTransform(). The value argument is the new matrix (i.e., a | - |
478 | QTransform); to get the old matrix, call transform(). Do not call | - |
479 | setTransform() or set any of the transformation properties in itemChange() | - |
480 | as this notification is delivered; instead, you can return the new matrix | - |
481 | from itemChange(). This notification is not sent if you change the | - |
482 | transformation properties. | - |
483 | | - |
484 | \value ItemTransformHasChanged The item's transformation matrix has | - |
485 | changed either because setTransform is called, or one of the | - |
486 | transformation properties is changed. This notification is sent if the | - |
487 | ItemSendsGeometryChanges flag is enabled, and after the item's local | - |
488 | transformation matrix has changed. The value argument is the new matrix | - |
489 | (same as transform()), and QGraphicsItem ignores the return value for this | - |
490 | notification (i.e., a read-only notification). | - |
491 | | - |
492 | \value ItemRotationChange The item's rotation property changes. This | - |
493 | notification is sent if the ItemSendsGeometryChanges flag is enabled, and | - |
494 | when the item's rotation property changes (i.e., as a result of calling | - |
495 | setRotation()). The value argument is the new rotation (i.e., a double); | - |
496 | to get the old rotation, call rotation(). Do not call setRotation() in | - |
497 | itemChange() as this notification is delivered; instead, you can return | - |
498 | the new rotation from itemChange(). | - |
499 | | - |
500 | \value ItemRotationHasChanged The item's rotation property has changed. | - |
501 | This notification is sent if the ItemSendsGeometryChanges flag is enabled, | - |
502 | and after the item's rotation property has changed. The value argument is | - |
503 | the new rotation (i.e., a double), and QGraphicsItem ignores the return | - |
504 | value for this notification (i.e., a read-only notification). Do not call | - |
505 | setRotation() in itemChange() as this notification is delivered. | - |
506 | | - |
507 | \value ItemScaleChange The item's scale property changes. This notification | - |
508 | is sent if the ItemSendsGeometryChanges flag is enabled, and when the item's | - |
509 | scale property changes (i.e., as a result of calling setScale()). The value | - |
510 | argument is the new scale (i.e., a double); to get the old scale, call | - |
511 | scale(). Do not call setScale() in itemChange() as this notification is | - |
512 | delivered; instead, you can return the new scale from itemChange(). | - |
513 | | - |
514 | \value ItemScaleHasChanged The item's scale property has changed. This | - |
515 | notification is sent if the ItemSendsGeometryChanges flag is enabled, and | - |
516 | after the item's scale property has changed. The value argument is the new | - |
517 | scale (i.e., a double), and QGraphicsItem ignores the return value for this | - |
518 | notification (i.e., a read-only notification). Do not call setScale() in | - |
519 | itemChange() as this notification is delivered. | - |
520 | | - |
521 | \value ItemTransformOriginPointChange The item's transform origin point | - |
522 | property changes. This notification is sent if the ItemSendsGeometryChanges | - |
523 | flag is enabled, and when the item's transform origin point property changes | - |
524 | (i.e., as a result of calling setTransformOriginPoint()). The value argument | - |
525 | is the new origin point (i.e., a QPointF); to get the old origin point, call | - |
526 | transformOriginPoint(). Do not call setTransformOriginPoint() in itemChange() | - |
527 | as this notification is delivered; instead, you can return the new transform | - |
528 | origin point from itemChange(). | - |
529 | | - |
530 | \value ItemTransformOriginPointHasChanged The item's transform origin point | - |
531 | property has changed. This notification is sent if the ItemSendsGeometryChanges | - |
532 | flag is enabled, and after the item's transform origin point property has | - |
533 | changed. The value argument is the new origin point (i.e., a QPointF), and | - |
534 | QGraphicsItem ignores the return value for this notification (i.e., a read-only | - |
535 | notification). Do not call setTransformOriginPoint() in itemChange() as this | - |
536 | notification is delivered. | - |
537 | | - |
538 | \value ItemSelectedChange The item's selected state changes. If the item is | - |
539 | presently selected, it will become unselected, and vice verca. The value | - |
540 | argument is the new selected state (i.e., true or false). Do not call | - |
541 | setSelected() in itemChange() as this notification is delivered; instead, you | - |
542 | can return the new selected state from itemChange(). | - |
543 | | - |
544 | \value ItemSelectedHasChanged The item's selected state has changed. The | - |
545 | value argument is the new selected state (i.e., true or false). Do not | - |
546 | call setSelected() in itemChange() as this notification is delivered. The | - |
547 | return value is ignored. | - |
548 | | - |
549 | \value ItemVisibleChange The item's visible state changes. If the item is | - |
550 | presently visible, it will become invisible, and vice verca. The value | - |
551 | argument is the new visible state (i.e., true or false). Do not call | - |
552 | setVisible() in itemChange() as this notification is delivered; instead, | - |
553 | you can return the new visible state from itemChange(). | - |
554 | | - |
555 | \value ItemVisibleHasChanged The item's visible state has changed. The | - |
556 | value argument is the new visible state (i.e., true or false). Do not call | - |
557 | setVisible() in itemChange() as this notification is delivered. The return | - |
558 | value is ignored. | - |
559 | | - |
560 | \value ItemParentChange The item's parent changes. The value argument is | - |
561 | the new parent item (i.e., a QGraphicsItem pointer). Do not call | - |
562 | setParentItem() in itemChange() as this notification is delivered; | - |
563 | instead, you can return the new parent from itemChange(). | - |
564 | | - |
565 | \value ItemParentHasChanged The item's parent has changed. The value | - |
566 | argument is the new parent (i.e., a pointer to a QGraphicsItem). Do not | - |
567 | call setParentItem() in itemChange() as this notification is | - |
568 | delivered. The return value is ignored. | - |
569 | | - |
570 | \value ItemChildAddedChange A child is added to this item. The value | - |
571 | argument is the new child item (i.e., a QGraphicsItem pointer). Do not | - |
572 | pass this item to any item's setParentItem() function as this notification | - |
573 | is delivered. The return value is unused; you cannot adjust anything in | - |
574 | this notification. Note that the new child might not be fully constructed | - |
575 | when this notification is sent; calling pure virtual functions on | - |
576 | the child can lead to a crash. | - |
577 | | - |
578 | \value ItemChildRemovedChange A child is removed from this item. The value | - |
579 | argument is the child item that is about to be removed (i.e., a | - |
580 | QGraphicsItem pointer). The return value is unused; you cannot adjust | - |
581 | anything in this notification. | - |
582 | | - |
583 | \value ItemSceneChange The item is moved to a new scene. This notification is | - |
584 | also sent when the item is added to its initial scene, and when it is removed. | - |
585 | The item's scene() is the old scene (or 0 if the item has not been added to a | - |
586 | scene yet). The value argument is the new scene (i.e., a QGraphicsScene | - |
587 | pointer), or a null pointer if the item is removed from a scene. Do not | - |
588 | override this change by passing this item to QGraphicsScene::addItem() as this | - |
589 | notification is delivered; instead, you can return the new scene from | - |
590 | itemChange(). Use this feature with caution; objecting to a scene change can | - |
591 | quickly lead to unwanted recursion. | - |
592 | | - |
593 | \value ItemSceneHasChanged The item's scene has changed. The item's scene() is | - |
594 | the new scene. This notification is also sent when the item is added to its | - |
595 | initial scene, and when it is removed.The value argument is the new scene | - |
596 | (i.e., a pointer to a QGraphicsScene). Do not call setScene() in itemChange() | - |
597 | as this notification is delivered. The return value is ignored. | - |
598 | | - |
599 | \value ItemCursorChange The item's cursor changes. The value argument is | - |
600 | the new cursor (i.e., a QCursor). Do not call setCursor() in itemChange() | - |
601 | as this notification is delivered. Instead, you can return a new cursor | - |
602 | from itemChange(). | - |
603 | | - |
604 | \value ItemCursorHasChanged The item's cursor has changed. The value | - |
605 | argument is the new cursor (i.e., a QCursor). Do not call setCursor() as | - |
606 | this notification is delivered. The return value is ignored. | - |
607 | | - |
608 | \value ItemToolTipChange The item's tooltip changes. The value argument is | - |
609 | the new tooltip (i.e., a QToolTip). Do not call setToolTip() in | - |
610 | itemChange() as this notification is delivered. Instead, you can return a | - |
611 | new tooltip from itemChange(). | - |
612 | | - |
613 | \value ItemToolTipHasChanged The item's tooltip has changed. The value | - |
614 | argument is the new tooltip (i.e., a QToolTip). Do not call setToolTip() | - |
615 | as this notification is delivered. The return value is ignored. | - |
616 | | - |
617 | \value ItemFlagsChange The item's flags change. The value argument is the | - |
618 | new flags (i.e., a quint32). Do not call setFlags() in itemChange() as | - |
619 | this notification is delivered. Instead, you can return the new flags from | - |
620 | itemChange(). | - |
621 | | - |
622 | \value ItemFlagsHaveChanged The item's flags have changed. The value | - |
623 | argument is the new flags (i.e., a quint32). Do not call setFlags() in | - |
624 | itemChange() as this notification is delivered. The return value is | - |
625 | ignored. | - |
626 | | - |
627 | \value ItemZValueChange The item's Z-value changes. The value argument is | - |
628 | the new Z-value (i.e., a double). Do not call setZValue() in itemChange() | - |
629 | as this notification is delivered. Instead, you can return a new Z-value | - |
630 | from itemChange(). | - |
631 | | - |
632 | \value ItemZValueHasChanged The item's Z-value has changed. The value | - |
633 | argument is the new Z-value (i.e., a double). Do not call setZValue() as | - |
634 | this notification is delivered. The return value is ignored. | - |
635 | | - |
636 | \value ItemOpacityChange The item's opacity changes. The value argument is | - |
637 | the new opacity (i.e., a double). Do not call setOpacity() in itemChange() | - |
638 | as this notification is delivered. Instead, you can return a new opacity | - |
639 | from itemChange(). | - |
640 | | - |
641 | \value ItemOpacityHasChanged The item's opacity has changed. The value | - |
642 | argument is the new opacity (i.e., a double). Do not call setOpacity() as | - |
643 | this notification is delivered. The return value is ignored. | - |
644 | | - |
645 | \value ItemScenePositionHasChanged The item's scene position has changed. | - |
646 | This notification is sent if the ItemSendsScenePositionChanges flag is | - |
647 | enabled, and after the item's scene position has changed (i.e., the | - |
648 | position or transformation of the item itself or the position or | - |
649 | transformation of any ancestor has changed). The value argument is the | - |
650 | new scene position (the same as scenePos()), and QGraphicsItem ignores | - |
651 | the return value for this notification (i.e., a read-only notification). | - |
652 | */ | - |
653 | | - |
654 | /*! | - |
655 | \enum QGraphicsItem::CacheMode | - |
656 | \since 4.4 | - |
657 | | - |
658 | This enum describes QGraphicsItem's cache modes. Caching is used to speed | - |
659 | up rendering by allocating and rendering to an off-screen pixel buffer, | - |
660 | which can be reused when the item requires redrawing. For some paint | - |
661 | devices, the cache is stored directly in graphics memory, which makes | - |
662 | rendering very quick. | - |
663 | | - |
664 | \value NoCache The default; all item caching is | - |
665 | disabled. QGraphicsItem::paint() is called every time the item needs | - |
666 | redrawing. | - |
667 | | - |
668 | \value ItemCoordinateCache Caching is enabled for the item's logical | - |
669 | (local) coordinate system. QGraphicsItem creates an off-screen pixel | - |
670 | buffer with a configurable size / resolution that you can pass to | - |
671 | QGraphicsItem::setCacheMode(). Rendering quality will typically degrade, | - |
672 | depending on the resolution of the cache and the item transformation. The | - |
673 | first time the item is redrawn, it will render itself into the cache, and | - |
674 | the cache is then reused for every subsequent expose. The cache is also | - |
675 | reused as the item is transformed. To adjust the resolution of the cache, | - |
676 | you can call setCacheMode() again. | - |
677 | | - |
678 | \value DeviceCoordinateCache Caching is enabled at the paint device level, | - |
679 | in device coordinates. This mode is for items that can move, but are not | - |
680 | rotated, scaled or sheared. If the item is transformed directly or | - |
681 | indirectly, the cache will be regenerated automatically. Unlike | - |
682 | ItemCoordinateCacheMode, DeviceCoordinateCache always renders at maximum | - |
683 | quality. | - |
684 | | - |
685 | \sa QGraphicsItem::setCacheMode() | - |
686 | */ | - |
687 | | - |
688 | /*! | - |
689 | \enum QGraphicsItem::Extension | - |
690 | \internal | - |
691 | | - |
692 | Note: This is provided as a hook to avoid future problems related | - |
693 | to adding virtual functions. See also extension(), | - |
694 | supportsExtension() and setExtension(). | - |
695 | */ | - |
696 | | - |
697 | /*! | - |
698 | \enum QGraphicsItem::PanelModality | - |
699 | \since 4.6 | - |
700 | | - |
701 | This enum specifies the behavior of a modal panel. A modal panel | - |
702 | is one that blocks input to other panels. Note that items that | - |
703 | are children of a modal panel are not blocked. | - |
704 | | - |
705 | The values are: | - |
706 | | - |
707 | \value NonModal The panel is not modal and does not block input to | - |
708 | other panels. This is the default value for panels. | - |
709 | | - |
710 | \value PanelModal The panel is modal to a single item hierarchy | - |
711 | and blocks input to its parent pane, all grandparent panels, and | - |
712 | all siblings of its parent and grandparent panels. | - |
713 | | - |
714 | \value SceneModal The window is modal to the entire scene and | - |
715 | blocks input to all panels. | - |
716 | | - |
717 | \sa QGraphicsItem::setPanelModality(), QGraphicsItem::panelModality(), QGraphicsItem::ItemIsPanel | - |
718 | */ | - |
719 | | - |
720 | #include "qgraphicsitem.h" | - |
721 | | - |
722 | #ifndef QT_NO_GRAPHICSVIEW | - |
723 | | - |
724 | #include "qgraphicsscene.h" | - |
725 | #include "qgraphicsscene_p.h" | - |
726 | #include "qgraphicssceneevent.h" | - |
727 | #include "qgraphicsview.h" | - |
728 | #include "qgraphicswidget.h" | - |
729 | #include "qgraphicsproxywidget.h" | - |
730 | #include "qgraphicsscenebsptreeindex_p.h" | - |
731 | #include <QtCore/qbitarray.h> | - |
732 | #include <QtCore/qdebug.h> | - |
733 | #include <QtCore/qpoint.h> | - |
734 | #include <QtCore/qstack.h> | - |
735 | #include <QtCore/qtimer.h> | - |
736 | #include <QtCore/qvariant.h> | - |
737 | #include <QtCore/qvarlengtharray.h> | - |
738 | #include <QtCore/qnumeric.h> | - |
739 | #include <QtWidgets/qapplication.h> | - |
740 | #include <QtGui/qbitmap.h> | - |
741 | #include <QtGui/qpainter.h> | - |
742 | #include <QtGui/qpainterpath.h> | - |
743 | #include <QtGui/qpixmapcache.h> | - |
744 | #include <QtWidgets/qstyleoption.h> | - |
745 | #include <QtGui/qevent.h> | - |
746 | #include <QtGui/qinputmethod.h> | - |
747 | #include <QtWidgets/qgraphicseffect.h> | - |
748 | #ifndef QT_NO_ACCESSIBILITY | - |
749 | # include "qaccessible.h" | - |
750 | #endif | - |
751 | | - |
752 | #include <private/qgraphicsitem_p.h> | - |
753 | #include <private/qgraphicswidget_p.h> | - |
754 | #include <private/qwidgettextcontrol_p.h> | - |
755 | #include <private/qtextdocumentlayout_p.h> | - |
756 | #include <private/qtextengine_p.h> | - |
757 | #include <private/qwidget_p.h> | - |
758 | #include <private/qapplication_p.h> | - |
759 | #include <private/qgesturemanager_p.h> | - |
760 | | - |
761 | #include <math.h> | - |
762 | | - |
763 | QT_BEGIN_NAMESPACE | - |
764 | | - |
765 | static inline void _q_adjustRect(QRect *rect) | - |
766 | { | - |
767 | Q_ASSERT(rect); never executed (the execution status of this line is deduced): qt_noop(); | - |
768 | if (!rect->width()) never evaluated: !rect->width() | 0 |
769 | rect->adjust(0, 0, 1, 0); never executed: rect->adjust(0, 0, 1, 0); | 0 |
770 | if (!rect->height()) never evaluated: !rect->height() | 0 |
771 | rect->adjust(0, 0, 0, 1); never executed: rect->adjust(0, 0, 0, 1); | 0 |
772 | } | 0 |
773 | | - |
774 | /* | - |
775 | ### Move this into QGraphicsItemPrivate | - |
776 | */ | - |
777 | class QGraphicsItemCustomDataStore | - |
778 | { | - |
779 | public: | - |
780 | QHash<const QGraphicsItem *, QMap<int, QVariant> > data; | - |
781 | }; | - |
782 | Q_GLOBAL_STATIC(QGraphicsItemCustomDataStore, qt_dataStore) never executed: delete x; executed: return thisGlobalStatic.pointer.load(); Execution Count:1068 partially evaluated: !thisGlobalStatic.pointer.testAndSetOrdered(0, x) no Evaluation Count:0 | yes Evaluation Count:10 |
evaluated: !thisGlobalStatic.pointer.load() yes Evaluation Count:10 | yes Evaluation Count:1058 |
partially evaluated: !thisGlobalStatic.destroyed yes Evaluation Count:10 | no Evaluation Count:0 |
| 0-1068 |
783 | | - |
784 | /*! | - |
785 | \internal | - |
786 | | - |
787 | Returns a QPainterPath of \a path when stroked with the \a pen. | - |
788 | Ignoring dash pattern. | - |
789 | */ | - |
790 | static QPainterPath qt_graphicsItem_shapeFromPath(const QPainterPath &path, const QPen &pen) | - |
791 | { | - |
792 | // We unfortunately need this hack as QPainterPathStroker will set a width of 1.0 | - |
793 | // if we pass a value of 0.0 to QPainterPathStroker::setWidth() | - |
794 | const qreal penWidthZero = qreal(0.00000001); executed (the execution status of this line is deduced): const qreal penWidthZero = qreal(0.00000001); | - |
795 | | - |
796 | if (path == QPainterPath()) evaluated: path == QPainterPath() yes Evaluation Count:5 | yes Evaluation Count:2 |
| 2-5 |
797 | return path; executed: return path; Execution Count:5 | 5 |
798 | QPainterPathStroker ps; executed (the execution status of this line is deduced): QPainterPathStroker ps; | - |
799 | ps.setCapStyle(pen.capStyle()); executed (the execution status of this line is deduced): ps.setCapStyle(pen.capStyle()); | - |
800 | if (pen.widthF() <= 0.0) partially evaluated: pen.widthF() <= 0.0 no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
801 | ps.setWidth(penWidthZero); never executed: ps.setWidth(penWidthZero); | 0 |
802 | else | - |
803 | ps.setWidth(pen.widthF()); executed: ps.setWidth(pen.widthF()); Execution Count:2 | 2 |
804 | ps.setJoinStyle(pen.joinStyle()); executed (the execution status of this line is deduced): ps.setJoinStyle(pen.joinStyle()); | - |
805 | ps.setMiterLimit(pen.miterLimit()); executed (the execution status of this line is deduced): ps.setMiterLimit(pen.miterLimit()); | - |
806 | QPainterPath p = ps.createStroke(path); executed (the execution status of this line is deduced): QPainterPath p = ps.createStroke(path); | - |
807 | p.addPath(path); executed (the execution status of this line is deduced): p.addPath(path); | - |
808 | return p; executed: return p; Execution Count:2 | 2 |
809 | } | - |
810 | | - |
811 | /*! | - |
812 | \internal | - |
813 | | - |
814 | Propagates the ancestor flag \a flag with value \a enabled to all this | - |
815 | item's children. If \a root is false, the flag is also set on this item | - |
816 | (default is true). | - |
817 | */ | - |
818 | void QGraphicsItemPrivate::updateAncestorFlag(QGraphicsItem::GraphicsItemFlag childFlag, | - |
819 | AncestorFlag flag, bool enabled, bool root) | - |
820 | { | - |
821 | Q_Q(QGraphicsItem); executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func(); | - |
822 | if (root) { evaluated: root yes Evaluation Count:7 | yes Evaluation Count:5 |
| 5-7 |
823 | // For root items only. This is the item that has either enabled or | - |
824 | // disabled \a childFlag, or has been reparented. | - |
825 | switch (int(childFlag)) { | - |
826 | case -2: | - |
827 | flag = AncestorFiltersChildEvents; never executed (the execution status of this line is deduced): flag = AncestorFiltersChildEvents; | - |
828 | enabled = q->filtersChildEvents(); never executed (the execution status of this line is deduced): enabled = q->filtersChildEvents(); | - |
829 | break; | 0 |
830 | case -1: | - |
831 | flag = AncestorHandlesChildEvents; never executed (the execution status of this line is deduced): flag = AncestorHandlesChildEvents; | - |
832 | enabled = q->handlesChildEvents(); never executed (the execution status of this line is deduced): enabled = q->handlesChildEvents(); | - |
833 | break; | 0 |
834 | case QGraphicsItem::ItemClipsChildrenToShape: | - |
835 | flag = AncestorClipsChildren; executed (the execution status of this line is deduced): flag = AncestorClipsChildren; | - |
836 | enabled = flags & QGraphicsItem::ItemClipsChildrenToShape; executed (the execution status of this line is deduced): enabled = flags & QGraphicsItem::ItemClipsChildrenToShape; | - |
837 | break; executed: break; Execution Count:7 | 7 |
838 | case QGraphicsItem::ItemIgnoresTransformations: | - |
839 | flag = AncestorIgnoresTransformations; never executed (the execution status of this line is deduced): flag = AncestorIgnoresTransformations; | - |
840 | enabled = flags & QGraphicsItem::ItemIgnoresTransformations; never executed (the execution status of this line is deduced): enabled = flags & QGraphicsItem::ItemIgnoresTransformations; | - |
841 | break; | 0 |
842 | default: | - |
843 | return; | 0 |
844 | } | - |
845 | | - |
846 | if (parent) { evaluated: parent yes Evaluation Count:5 | yes Evaluation Count:2 |
| 2-5 |
847 | // Inherit the enabled-state from our parents. | - |
848 | if ((parent->d_ptr->ancestorFlags & flag) partially evaluated: (parent->d_ptr->ancestorFlags & flag) no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
849 | || (int(parent->d_ptr->flags & childFlag) == childFlag) partially evaluated: (int(parent->d_ptr->flags & childFlag) == childFlag) no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
850 | || (childFlag == -1 && parent->d_ptr->handlesChildEvents) partially evaluated: childFlag == -1 no Evaluation Count:0 | yes Evaluation Count:5 |
never evaluated: parent->d_ptr->handlesChildEvents | 0-5 |
851 | || (childFlag == -2 && parent->d_ptr->filtersDescendantEvents)) { partially evaluated: childFlag == -2 no Evaluation Count:0 | yes Evaluation Count:5 |
never evaluated: parent->d_ptr->filtersDescendantEvents | 0-5 |
852 | enabled = true; never executed (the execution status of this line is deduced): enabled = true; | - |
853 | ancestorFlags |= flag; never executed (the execution status of this line is deduced): ancestorFlags |= flag; | - |
854 | } else { | 0 |
855 | ancestorFlags &= ~flag; executed (the execution status of this line is deduced): ancestorFlags &= ~flag; | - |
856 | } executed: } Execution Count:5 | 5 |
857 | } else { | - |
858 | // Top-level root items don't have any ancestors, so there are no | - |
859 | // ancestor flags either. | - |
860 | ancestorFlags = 0; executed (the execution status of this line is deduced): ancestorFlags = 0; | - |
861 | } executed: } Execution Count:2 | 2 |
862 | } else { | - |
863 | // Don't set or propagate the ancestor flag if it's already correct. | - |
864 | if (((ancestorFlags & flag) && enabled) || (!(ancestorFlags & flag) && !enabled)) evaluated: (ancestorFlags & flag) yes Evaluation Count:3 | yes Evaluation Count:2 |
partially evaluated: enabled no Evaluation Count:0 | yes Evaluation Count:3 |
evaluated: !(ancestorFlags & flag) yes Evaluation Count:2 | yes Evaluation Count:3 |
partially evaluated: !enabled no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-3 |
865 | return; | 0 |
866 | | - |
867 | // Set the flag. | - |
868 | if (enabled) evaluated: enabled yes Evaluation Count:2 | yes Evaluation Count:3 |
| 2-3 |
869 | ancestorFlags |= flag; executed: ancestorFlags |= flag; Execution Count:2 | 2 |
870 | else | - |
871 | ancestorFlags &= ~flag; executed: ancestorFlags &= ~flag; Execution Count:3 | 3 |
872 | | - |
873 | // Don't process children if the item has the main flag set on itself. | - |
874 | if ((childFlag != -1 && int(flags & childFlag) == childFlag) partially evaluated: childFlag != -1 yes Evaluation Count:5 | no Evaluation Count:0 |
partially evaluated: int(flags & childFlag) == childFlag no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
875 | || (int(childFlag) == -1 && handlesChildEvents) partially evaluated: int(childFlag) == -1 no Evaluation Count:0 | yes Evaluation Count:5 |
never evaluated: handlesChildEvents | 0-5 |
876 | || (int(childFlag) == -2 && filtersDescendantEvents)) partially evaluated: int(childFlag) == -2 no Evaluation Count:0 | yes Evaluation Count:5 |
never evaluated: filtersDescendantEvents | 0-5 |
877 | return; | 0 |
878 | } executed: } Execution Count:5 | 5 |
879 | | - |
880 | for (int i = 0; i < children.size(); ++i) evaluated: i < children.size() yes Evaluation Count:5 | yes Evaluation Count:12 |
| 5-12 |
881 | children.at(i)->d_ptr->updateAncestorFlag(childFlag, flag, enabled, false); executed: children.at(i)->d_ptr->updateAncestorFlag(childFlag, flag, enabled, false); Execution Count:5 | 5 |
882 | } executed: } Execution Count:12 | 12 |
883 | | - |
884 | void QGraphicsItemPrivate::updateAncestorFlags() | - |
885 | { | - |
886 | int flags = 0; executed (the execution status of this line is deduced): int flags = 0; | - |
887 | if (parent) { evaluated: parent yes Evaluation Count:793 | yes Evaluation Count:745 |
| 745-793 |
888 | // Inherit the parent's ancestor flags. | - |
889 | QGraphicsItemPrivate *pd = parent->d_ptr.data(); executed (the execution status of this line is deduced): QGraphicsItemPrivate *pd = parent->d_ptr.data(); | - |
890 | flags = pd->ancestorFlags; executed (the execution status of this line is deduced): flags = pd->ancestorFlags; | - |
891 | | - |
892 | // Add in flags from the parent. | - |
893 | if (pd->filtersDescendantEvents) partially evaluated: pd->filtersDescendantEvents no Evaluation Count:0 | yes Evaluation Count:793 |
| 0-793 |
894 | flags |= AncestorFiltersChildEvents; never executed: flags |= AncestorFiltersChildEvents; | 0 |
895 | if (pd->handlesChildEvents) partially evaluated: pd->handlesChildEvents no Evaluation Count:0 | yes Evaluation Count:793 |
| 0-793 |
896 | flags |= AncestorHandlesChildEvents; never executed: flags |= AncestorHandlesChildEvents; | 0 |
897 | if (pd->flags & QGraphicsItem::ItemClipsChildrenToShape) evaluated: pd->flags & QGraphicsItem::ItemClipsChildrenToShape yes Evaluation Count:2 | yes Evaluation Count:791 |
| 2-791 |
898 | flags |= AncestorClipsChildren; executed: flags |= AncestorClipsChildren; Execution Count:2 | 2 |
899 | if (pd->flags & QGraphicsItem::ItemIgnoresTransformations) partially evaluated: pd->flags & QGraphicsItem::ItemIgnoresTransformations no Evaluation Count:0 | yes Evaluation Count:793 |
| 0-793 |
900 | flags |= AncestorIgnoresTransformations; never executed: flags |= AncestorIgnoresTransformations; | 0 |
901 | } executed: } Execution Count:793 | 793 |
902 | | - |
903 | if (ancestorFlags == flags) evaluated: ancestorFlags == flags yes Evaluation Count:1536 | yes Evaluation Count:2 |
| 2-1536 |
904 | return; // No change; stop propagation. executed: return; Execution Count:1536 | 1536 |
905 | ancestorFlags = flags; executed (the execution status of this line is deduced): ancestorFlags = flags; | - |
906 | | - |
907 | // Propagate to children recursively. | - |
908 | for (int i = 0; i < children.size(); ++i) partially evaluated: i < children.size() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
909 | children.at(i)->d_ptr->updateAncestorFlags(); never executed: children.at(i)->d_ptr->updateAncestorFlags(); | 0 |
910 | } executed: } Execution Count:2 | 2 |
911 | | - |
912 | /*! | - |
913 | \internal | - |
914 | | - |
915 | Propagates item group membership. | - |
916 | */ | - |
917 | void QGraphicsItemPrivate::setIsMemberOfGroup(bool enabled) | - |
918 | { | - |
919 | Q_Q(QGraphicsItem); never executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func(); | - |
920 | isMemberOfGroup = enabled; never executed (the execution status of this line is deduced): isMemberOfGroup = enabled; | - |
921 | if (!qgraphicsitem_cast<QGraphicsItemGroup *>(q)) { never evaluated: !qgraphicsitem_cast<QGraphicsItemGroup *>(q) | 0 |
922 | foreach (QGraphicsItem *child, children) never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(children)> _container_(children); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *child = *_container_.i;; __extension__ ({--_container_.brk; break;})) | - |
923 | child->d_func()->setIsMemberOfGroup(enabled); never executed: child->d_func()->setIsMemberOfGroup(enabled); | 0 |
924 | } | 0 |
925 | } | 0 |
926 | | - |
927 | /*! | - |
928 | \internal | - |
929 | | - |
930 | Maps any item pos properties of \a event to \a item's coordinate system. | - |
931 | */ | - |
932 | void QGraphicsItemPrivate::remapItemPos(QEvent *event, QGraphicsItem *item) | - |
933 | { | - |
934 | Q_Q(QGraphicsItem); never executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func(); | - |
935 | switch (event->type()) { | - |
936 | case QEvent::GraphicsSceneMouseMove: | - |
937 | case QEvent::GraphicsSceneMousePress: | - |
938 | case QEvent::GraphicsSceneMouseRelease: | - |
939 | case QEvent::GraphicsSceneMouseDoubleClick: { | - |
940 | QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event); never executed (the execution status of this line is deduced): QGraphicsSceneMouseEvent *mouseEvent = static_cast<QGraphicsSceneMouseEvent *>(event); | - |
941 | mouseEvent->setPos(item->mapFromItem(q, mouseEvent->pos())); never executed (the execution status of this line is deduced): mouseEvent->setPos(item->mapFromItem(q, mouseEvent->pos())); | - |
942 | mouseEvent->setLastPos(item->mapFromItem(q, mouseEvent->pos())); never executed (the execution status of this line is deduced): mouseEvent->setLastPos(item->mapFromItem(q, mouseEvent->pos())); | - |
943 | for (int i = 0x1; i <= 0x10; i <<= 1) { never evaluated: i <= 0x10 | 0 |
944 | if (mouseEvent->buttons() & i) { never evaluated: mouseEvent->buttons() & i | 0 |
945 | Qt::MouseButton button = Qt::MouseButton(i); never executed (the execution status of this line is deduced): Qt::MouseButton button = Qt::MouseButton(i); | - |
946 | mouseEvent->setButtonDownPos(button, item->mapFromItem(q, mouseEvent->buttonDownPos(button))); never executed (the execution status of this line is deduced): mouseEvent->setButtonDownPos(button, item->mapFromItem(q, mouseEvent->buttonDownPos(button))); | - |
947 | } | 0 |
948 | } | 0 |
949 | break; | 0 |
950 | } | - |
951 | case QEvent::GraphicsSceneWheel: { | - |
952 | QGraphicsSceneWheelEvent *wheelEvent = static_cast<QGraphicsSceneWheelEvent *>(event); never executed (the execution status of this line is deduced): QGraphicsSceneWheelEvent *wheelEvent = static_cast<QGraphicsSceneWheelEvent *>(event); | - |
953 | wheelEvent->setPos(item->mapFromItem(q, wheelEvent->pos())); never executed (the execution status of this line is deduced): wheelEvent->setPos(item->mapFromItem(q, wheelEvent->pos())); | - |
954 | break; | 0 |
955 | } | - |
956 | case QEvent::GraphicsSceneContextMenu: { | - |
957 | QGraphicsSceneContextMenuEvent *contextEvent = static_cast<QGraphicsSceneContextMenuEvent *>(event); never executed (the execution status of this line is deduced): QGraphicsSceneContextMenuEvent *contextEvent = static_cast<QGraphicsSceneContextMenuEvent *>(event); | - |
958 | contextEvent->setPos(item->mapFromItem(q, contextEvent->pos())); never executed (the execution status of this line is deduced): contextEvent->setPos(item->mapFromItem(q, contextEvent->pos())); | - |
959 | break; | 0 |
960 | } | - |
961 | case QEvent::GraphicsSceneHoverMove: { | - |
962 | QGraphicsSceneHoverEvent *hoverEvent = static_cast<QGraphicsSceneHoverEvent *>(event); never executed (the execution status of this line is deduced): QGraphicsSceneHoverEvent *hoverEvent = static_cast<QGraphicsSceneHoverEvent *>(event); | - |
963 | hoverEvent->setPos(item->mapFromItem(q, hoverEvent->pos())); never executed (the execution status of this line is deduced): hoverEvent->setPos(item->mapFromItem(q, hoverEvent->pos())); | - |
964 | break; | 0 |
965 | } | - |
966 | default: | - |
967 | break; | 0 |
968 | } | - |
969 | } | 0 |
970 | | - |
971 | /*! | - |
972 | \internal | - |
973 | | - |
974 | Maps the point \a pos from scene to item coordinates. If \a view is passed and the item | - |
975 | is untransformable, this function will correctly map \a pos from the scene using the | - |
976 | view's transformation. | - |
977 | */ | - |
978 | QPointF QGraphicsItemPrivate::genericMapFromScene(const QPointF &pos, | - |
979 | const QWidget *viewport) const | - |
980 | { | - |
981 | Q_Q(const QGraphicsItem); executed (the execution status of this line is deduced): const QGraphicsItem * const q = q_func(); | - |
982 | if (!itemIsUntransformable()) partially evaluated: !itemIsUntransformable() yes Evaluation Count:37 | no Evaluation Count:0 |
| 0-37 |
983 | return q->mapFromScene(pos); executed: return q->mapFromScene(pos); Execution Count:37 | 37 |
984 | QGraphicsView *view = 0; never executed (the execution status of this line is deduced): QGraphicsView *view = 0; | - |
985 | if (viewport) never evaluated: viewport | 0 |
986 | view = qobject_cast<QGraphicsView *>(viewport->parentWidget()); never executed: view = qobject_cast<QGraphicsView *>(viewport->parentWidget()); | 0 |
987 | if (!view) | 0 |
988 | return q->mapFromScene(pos); never executed: return q->mapFromScene(pos); | 0 |
989 | // ### More ping pong than needed. | - |
990 | return q->deviceTransform(view->viewportTransform()).inverted().map(view->mapFromScene(pos)); never executed: return q->deviceTransform(view->viewportTransform()).inverted().map(view->mapFromScene(pos)); | 0 |
991 | } | - |
992 | | - |
993 | /*! | - |
994 | \internal | - |
995 | | - |
996 | Combines this item's position and transform onto \a transform. | - |
997 | | - |
998 | If you need to change this function (e.g., adding more transformation | - |
999 | modes / options), make sure to change all places marked with COMBINE. | - |
1000 | */ | - |
1001 | void QGraphicsItemPrivate::combineTransformToParent(QTransform *x, const QTransform *viewTransform) const | - |
1002 | { | - |
1003 | // COMBINE | - |
1004 | if (viewTransform && itemIsUntransformable()) { never evaluated: viewTransform never evaluated: itemIsUntransformable() | 0 |
1005 | *x = q_ptr->deviceTransform(*viewTransform); never executed (the execution status of this line is deduced): *x = q_ptr->deviceTransform(*viewTransform); | - |
1006 | } else { | 0 |
1007 | if (transformData) never evaluated: transformData | 0 |
1008 | *x *= transformData->computedFullTransform(); never executed: *x *= transformData->computedFullTransform(); | 0 |
1009 | if (!pos.isNull()) never evaluated: !pos.isNull() | 0 |
1010 | *x *= QTransform::fromTranslate(pos.x(), pos.y()); never executed: *x *= QTransform::fromTranslate(pos.x(), pos.y()); | 0 |
1011 | } | 0 |
1012 | } | - |
1013 | | - |
1014 | /*! | - |
1015 | \internal | - |
1016 | | - |
1017 | Combines this item's position and transform onto \a transform. | - |
1018 | | - |
1019 | If you need to change this function (e.g., adding more transformation | - |
1020 | modes / options), make sure to change QGraphicsItem::deviceTransform() as | - |
1021 | well. | - |
1022 | */ | - |
1023 | void QGraphicsItemPrivate::combineTransformFromParent(QTransform *x, const QTransform *viewTransform) const | - |
1024 | { | - |
1025 | // COMBINE | - |
1026 | if (viewTransform && itemIsUntransformable()) { partially evaluated: viewTransform no Evaluation Count:0 | yes Evaluation Count:15 |
never evaluated: itemIsUntransformable() | 0-15 |
1027 | *x = q_ptr->deviceTransform(*viewTransform); never executed (the execution status of this line is deduced): *x = q_ptr->deviceTransform(*viewTransform); | - |
1028 | } else { | 0 |
1029 | x->translate(pos.x(), pos.y()); executed (the execution status of this line is deduced): x->translate(pos.x(), pos.y()); | - |
1030 | if (transformData) partially evaluated: transformData no Evaluation Count:0 | yes Evaluation Count:15 |
| 0-15 |
1031 | *x = transformData->computedFullTransform(x); never executed: *x = transformData->computedFullTransform(x); | 0 |
1032 | } executed: } Execution Count:15 | 15 |
1033 | } | - |
1034 | | - |
1035 | void QGraphicsItemPrivate::updateSceneTransformFromParent() | - |
1036 | { | - |
1037 | if (parent) { evaluated: parent yes Evaluation Count:133 | yes Evaluation Count:96 |
| 96-133 |
1038 | Q_ASSERT(!parent->d_ptr->dirtySceneTransform); executed (the execution status of this line is deduced): qt_noop(); | - |
1039 | if (parent->d_ptr->sceneTransformTranslateOnly) { partially evaluated: parent->d_ptr->sceneTransformTranslateOnly yes Evaluation Count:133 | no Evaluation Count:0 |
| 0-133 |
1040 | sceneTransform = QTransform::fromTranslate(parent->d_ptr->sceneTransform.dx() + pos.x(), executed (the execution status of this line is deduced): sceneTransform = QTransform::fromTranslate(parent->d_ptr->sceneTransform.dx() + pos.x(), | - |
1041 | parent->d_ptr->sceneTransform.dy() + pos.y()); executed (the execution status of this line is deduced): parent->d_ptr->sceneTransform.dy() + pos.y()); | - |
1042 | } else { executed: } Execution Count:133 | 133 |
1043 | sceneTransform = parent->d_ptr->sceneTransform; never executed (the execution status of this line is deduced): sceneTransform = parent->d_ptr->sceneTransform; | - |
1044 | sceneTransform.translate(pos.x(), pos.y()); never executed (the execution status of this line is deduced): sceneTransform.translate(pos.x(), pos.y()); | - |
1045 | } | 0 |
1046 | if (transformData) { partially evaluated: transformData no Evaluation Count:0 | yes Evaluation Count:133 |
| 0-133 |
1047 | sceneTransform = transformData->computedFullTransform(&sceneTransform); never executed (the execution status of this line is deduced): sceneTransform = transformData->computedFullTransform(&sceneTransform); | - |
1048 | sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate); never executed (the execution status of this line is deduced): sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate); | - |
1049 | } else { | 0 |
1050 | sceneTransformTranslateOnly = parent->d_ptr->sceneTransformTranslateOnly; executed (the execution status of this line is deduced): sceneTransformTranslateOnly = parent->d_ptr->sceneTransformTranslateOnly; | - |
1051 | } executed: } Execution Count:133 | 133 |
1052 | } else if (!transformData) { evaluated: !transformData yes Evaluation Count:94 | yes Evaluation Count:2 |
| 2-94 |
1053 | sceneTransform = QTransform::fromTranslate(pos.x(), pos.y()); executed (the execution status of this line is deduced): sceneTransform = QTransform::fromTranslate(pos.x(), pos.y()); | - |
1054 | sceneTransformTranslateOnly = 1; executed (the execution status of this line is deduced): sceneTransformTranslateOnly = 1; | - |
1055 | } else if (transformData->onlyTransform) { executed: } Execution Count:94 partially evaluated: transformData->onlyTransform yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-94 |
1056 | sceneTransform = transformData->transform; executed (the execution status of this line is deduced): sceneTransform = transformData->transform; | - |
1057 | if (!pos.isNull()) partially evaluated: !pos.isNull() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1058 | sceneTransform *= QTransform::fromTranslate(pos.x(), pos.y()); never executed: sceneTransform *= QTransform::fromTranslate(pos.x(), pos.y()); | 0 |
1059 | sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate); executed (the execution status of this line is deduced): sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate); | - |
1060 | } else if (pos.isNull()) { executed: } Execution Count:2 never evaluated: pos.isNull() | 0-2 |
1061 | sceneTransform = transformData->computedFullTransform(); never executed (the execution status of this line is deduced): sceneTransform = transformData->computedFullTransform(); | - |
1062 | sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate); never executed (the execution status of this line is deduced): sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate); | - |
1063 | } else { | 0 |
1064 | sceneTransform = QTransform::fromTranslate(pos.x(), pos.y()); never executed (the execution status of this line is deduced): sceneTransform = QTransform::fromTranslate(pos.x(), pos.y()); | - |
1065 | sceneTransform = transformData->computedFullTransform(&sceneTransform); never executed (the execution status of this line is deduced): sceneTransform = transformData->computedFullTransform(&sceneTransform); | - |
1066 | sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate); never executed (the execution status of this line is deduced): sceneTransformTranslateOnly = (sceneTransform.type() <= QTransform::TxTranslate); | - |
1067 | } | 0 |
1068 | dirtySceneTransform = 0; executed (the execution status of this line is deduced): dirtySceneTransform = 0; | - |
1069 | } executed: } Execution Count:229 | 229 |
1070 | | - |
1071 | /*! | - |
1072 | \internal | - |
1073 | | - |
1074 | Make sure not to trigger any pure virtual function calls (e.g., | - |
1075 | prepareGeometryChange) if the item is in its destructor, i.e. | - |
1076 | inDestructor is 1. | - |
1077 | */ | - |
1078 | void QGraphicsItemPrivate::setParentItemHelper(QGraphicsItem *newParent, const QVariant *newParentVariant, | - |
1079 | const QVariant *thisPointerVariant) | - |
1080 | { | - |
1081 | Q_Q(QGraphicsItem); executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func(); | - |
1082 | if (newParent == parent) partially evaluated: newParent == parent no Evaluation Count:0 | yes Evaluation Count:1538 |
| 0-1538 |
1083 | return; | 0 |
1084 | | - |
1085 | if (isWidget) evaluated: isWidget yes Evaluation Count:1503 | yes Evaluation Count:35 |
| 35-1503 |
1086 | static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent && executed: static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent && newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0, scene); Execution Count:1503 | 1503 |
1087 | newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0, executed: static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent && newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0, scene); Execution Count:1503 | 1503 |
1088 | scene); executed: static_cast<QGraphicsWidgetPrivate *>(this)->fixFocusChainBeforeReparenting((newParent && newParent->isWidget()) ? static_cast<QGraphicsWidget *>(newParent) : 0, scene); Execution Count:1503 | 1503 |
1089 | if (scene) { evaluated: scene yes Evaluation Count:12 | yes Evaluation Count:1526 |
| 12-1526 |
1090 | // Deliver the change to the index | - |
1091 | if (scene->d_func()->indexMethod != QGraphicsScene::NoIndex) partially evaluated: scene->d_func()->indexMethod != QGraphicsScene::NoIndex yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-12 |
1092 | scene->d_func()->index->itemChange(q, QGraphicsItem::ItemParentChange, newParent); executed: scene->d_func()->index->itemChange(q, QGraphicsItem::ItemParentChange, newParent); Execution Count:12 | 12 |
1093 | | - |
1094 | // Disable scene pos notifications for old ancestors | - |
1095 | if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges)) partially evaluated: scenePosDescendants no Evaluation Count:0 | yes Evaluation Count:12 |
partially evaluated: (flags & QGraphicsItem::ItemSendsScenePositionChanges) no Evaluation Count:0 | yes Evaluation Count:12 |
| 0-12 |
1096 | scene->d_func()->setScenePosItemEnabled(q, false); never executed: scene->d_func()->setScenePosItemEnabled(q, false); | 0 |
1097 | } executed: } Execution Count:12 | 12 |
1098 | | - |
1099 | if (subFocusItem && parent) { partially evaluated: subFocusItem no Evaluation Count:0 | yes Evaluation Count:1538 |
never evaluated: parent | 0-1538 |
1100 | // Make sure none of the old parents point to this guy. | - |
1101 | subFocusItem->d_ptr->clearSubFocus(parent); never executed (the execution status of this line is deduced): subFocusItem->d_ptr->clearSubFocus(parent); | - |
1102 | } | 0 |
1103 | | - |
1104 | // We anticipate geometry changes. If the item is deleted, it will be | - |
1105 | // removed from the index at a later stage, and the whole scene will be | - |
1106 | // updated. | - |
1107 | if (!inDestructor) evaluated: !inDestructor yes Evaluation Count:793 | yes Evaluation Count:745 |
| 745-793 |
1108 | q_ptr->prepareGeometryChange(); executed: q_ptr->prepareGeometryChange(); Execution Count:793 | 793 |
1109 | | - |
1110 | if (parent) { evaluated: parent yes Evaluation Count:748 | yes Evaluation Count:790 |
| 748-790 |
1111 | // Remove from current parent | - |
1112 | parent->d_ptr->removeChild(q); executed (the execution status of this line is deduced): parent->d_ptr->removeChild(q); | - |
1113 | if (thisPointerVariant) partially evaluated: thisPointerVariant yes Evaluation Count:748 | no Evaluation Count:0 |
| 0-748 |
1114 | parent->itemChange(QGraphicsItem::ItemChildRemovedChange, *thisPointerVariant); executed: parent->itemChange(QGraphicsItem::ItemChildRemovedChange, *thisPointerVariant); Execution Count:748 | 748 |
1115 | } executed: } Execution Count:748 | 748 |
1116 | | - |
1117 | // Update toplevelitem list. If this item is being deleted, its parent | - |
1118 | // will be 0 but we don't want to register/unregister it in the TLI list. | - |
1119 | if (scene && !inDestructor) { evaluated: scene yes Evaluation Count:12 | yes Evaluation Count:1526 |
partially evaluated: !inDestructor yes Evaluation Count:12 | no Evaluation Count:0 |
| 0-1526 |
1120 | if (parent && !newParent) { evaluated: parent yes Evaluation Count:3 | yes Evaluation Count:9 |
partially evaluated: !newParent no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-9 |
1121 | scene->d_func()->registerTopLevelItem(q); never executed (the execution status of this line is deduced): scene->d_func()->registerTopLevelItem(q); | - |
1122 | } else if (!parent && newParent) { never executed: } evaluated: !parent yes Evaluation Count:9 | yes Evaluation Count:3 |
partially evaluated: newParent yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-9 |
1123 | scene->d_func()->unregisterTopLevelItem(q); executed (the execution status of this line is deduced): scene->d_func()->unregisterTopLevelItem(q); | - |
1124 | } executed: } Execution Count:9 | 9 |
1125 | } | - |
1126 | | - |
1127 | // Ensure any last parent focus scope does not point to this item or any of | - |
1128 | // its descendents. | - |
1129 | QGraphicsItem *p = parent; executed (the execution status of this line is deduced): QGraphicsItem *p = parent; | - |
1130 | QGraphicsItem *parentFocusScopeItem = 0; executed (the execution status of this line is deduced): QGraphicsItem *parentFocusScopeItem = 0; | - |
1131 | while (p) { evaluated: p yes Evaluation Count:754 | yes Evaluation Count:1538 |
| 754-1538 |
1132 | if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) { partially evaluated: p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope no Evaluation Count:0 | yes Evaluation Count:754 |
| 0-754 |
1133 | // If this item's focus scope's focus scope item points | - |
1134 | // to this item or a descendent, then clear it. | - |
1135 | QGraphicsItem *fsi = p->d_ptr->focusScopeItem; never executed (the execution status of this line is deduced): QGraphicsItem *fsi = p->d_ptr->focusScopeItem; | - |
1136 | if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) { never evaluated: q_ptr == fsi never evaluated: q_ptr->isAncestorOf(fsi) | 0 |
1137 | parentFocusScopeItem = fsi; never executed (the execution status of this line is deduced): parentFocusScopeItem = fsi; | - |
1138 | p->d_ptr->focusScopeItem = 0; never executed (the execution status of this line is deduced): p->d_ptr->focusScopeItem = 0; | - |
1139 | fsi->d_ptr->focusScopeItemChange(false); never executed (the execution status of this line is deduced): fsi->d_ptr->focusScopeItemChange(false); | - |
1140 | } | 0 |
1141 | break; | 0 |
1142 | } | - |
1143 | p = p->d_ptr->parent; executed (the execution status of this line is deduced): p = p->d_ptr->parent; | - |
1144 | } executed: } Execution Count:754 | 754 |
1145 | | - |
1146 | // Update graphics effect optimization flag | - |
1147 | if (newParent && (graphicsEffect || mayHaveChildWithGraphicsEffect)) evaluated: newParent yes Evaluation Count:793 | yes Evaluation Count:745 |
partially evaluated: graphicsEffect no Evaluation Count:0 | yes Evaluation Count:793 |
partially evaluated: mayHaveChildWithGraphicsEffect no Evaluation Count:0 | yes Evaluation Count:793 |
| 0-793 |
1148 | newParent->d_ptr->updateChildWithGraphicsEffectFlagRecursively(); never executed: newParent->d_ptr->updateChildWithGraphicsEffectFlagRecursively(); | 0 |
1149 | | - |
1150 | // Update focus scope item ptr in new scope. | - |
1151 | QGraphicsItem *newFocusScopeItem = subFocusItem ? subFocusItem : parentFocusScopeItem; partially evaluated: subFocusItem no Evaluation Count:0 | yes Evaluation Count:1538 |
| 0-1538 |
1152 | if (newFocusScopeItem && newParent) { partially evaluated: newFocusScopeItem no Evaluation Count:0 | yes Evaluation Count:1538 |
never evaluated: newParent | 0-1538 |
1153 | QGraphicsItem *p = newParent; never executed (the execution status of this line is deduced): QGraphicsItem *p = newParent; | - |
1154 | while (p) { | 0 |
1155 | if (p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) { never evaluated: p->d_ptr->flags & QGraphicsItem::ItemIsFocusScope | 0 |
1156 | if (subFocusItem && subFocusItem != q_ptr) { never evaluated: subFocusItem never evaluated: subFocusItem != q_ptr | 0 |
1157 | // Find the subFocusItem's topmost focus scope within the new parent's focusscope | - |
1158 | QGraphicsItem *ancestorScope = 0; never executed (the execution status of this line is deduced): QGraphicsItem *ancestorScope = 0; | - |
1159 | QGraphicsItem *p2 = subFocusItem->d_ptr->parent; never executed (the execution status of this line is deduced): QGraphicsItem *p2 = subFocusItem->d_ptr->parent; | - |
1160 | while (p2 && p2 != p) { never evaluated: p2 never evaluated: p2 != p | 0 |
1161 | if (p2->d_ptr->flags & QGraphicsItem::ItemIsFocusScope) never evaluated: p2->d_ptr->flags & QGraphicsItem::ItemIsFocusScope | 0 |
1162 | ancestorScope = p2; never executed: ancestorScope = p2; | 0 |
1163 | if (p2->d_ptr->flags & QGraphicsItem::ItemIsPanel) never evaluated: p2->d_ptr->flags & QGraphicsItem::ItemIsPanel | 0 |
1164 | break; | 0 |
1165 | if (p2 == q_ptr) never evaluated: p2 == q_ptr | 0 |
1166 | break; | 0 |
1167 | p2 = p2->d_ptr->parent; never executed (the execution status of this line is deduced): p2 = p2->d_ptr->parent; | - |
1168 | } | 0 |
1169 | if (ancestorScope) never evaluated: ancestorScope | 0 |
1170 | newFocusScopeItem = ancestorScope; never executed: newFocusScopeItem = ancestorScope; | 0 |
1171 | } | 0 |
1172 | | - |
1173 | p->d_ptr->focusScopeItem = newFocusScopeItem; never executed (the execution status of this line is deduced): p->d_ptr->focusScopeItem = newFocusScopeItem; | - |
1174 | newFocusScopeItem->d_ptr->focusScopeItemChange(true); never executed (the execution status of this line is deduced): newFocusScopeItem->d_ptr->focusScopeItemChange(true); | - |
1175 | // Ensure the new item is no longer the subFocusItem. The | - |
1176 | // only way to set focus on a child of a focus scope is | - |
1177 | // by setting focus on the scope itself. | - |
1178 | if (subFocusItem && !p->focusItem()) never evaluated: subFocusItem never evaluated: !p->focusItem() | 0 |
1179 | subFocusItem->d_ptr->clearSubFocus(); never executed: subFocusItem->d_ptr->clearSubFocus(); | 0 |
1180 | break; | 0 |
1181 | } | - |
1182 | p = p->d_ptr->parent; never executed (the execution status of this line is deduced): p = p->d_ptr->parent; | - |
1183 | } | 0 |
1184 | } | 0 |
1185 | | - |
1186 | // Resolve depth. | - |
1187 | invalidateDepthRecursively(); executed (the execution status of this line is deduced): invalidateDepthRecursively(); | - |
1188 | | - |
1189 | if ((parent = newParent)) { evaluated: (parent = newParent) yes Evaluation Count:793 | yes Evaluation Count:745 |
| 745-793 |
1190 | if (parent->d_func()->scene && parent->d_func()->scene != scene) { evaluated: parent->d_func()->scene yes Evaluation Count:726 | yes Evaluation Count:67 |
evaluated: parent->d_func()->scene != scene yes Evaluation Count:721 | yes Evaluation Count:5 |
| 5-726 |
1191 | // Move this item to its new parent's scene | - |
1192 | parent->d_func()->scene->addItem(q); executed (the execution status of this line is deduced): parent->d_func()->scene->addItem(q); | - |
1193 | } else if (!parent->d_func()->scene && scene) { executed: } Execution Count:721 evaluated: !parent->d_func()->scene yes Evaluation Count:67 | yes Evaluation Count:5 |
evaluated: scene yes Evaluation Count:7 | yes Evaluation Count:60 |
| 5-721 |
1194 | // Remove this item from its former scene | - |
1195 | scene->removeItem(q); executed (the execution status of this line is deduced): scene->removeItem(q); | - |
1196 | } executed: } Execution Count:7 | 7 |
1197 | | - |
1198 | parent->d_ptr->addChild(q); executed (the execution status of this line is deduced): parent->d_ptr->addChild(q); | - |
1199 | if (thisPointerVariant) evaluated: thisPointerVariant yes Evaluation Count:485 | yes Evaluation Count:308 |
| 308-485 |
1200 | parent->itemChange(QGraphicsItem::ItemChildAddedChange, *thisPointerVariant); executed: parent->itemChange(QGraphicsItem::ItemChildAddedChange, *thisPointerVariant); Execution Count:485 | 485 |
1201 | if (scene) { evaluated: scene yes Evaluation Count:726 | yes Evaluation Count:67 |
| 67-726 |
1202 | // Re-enable scene pos notifications for new ancestors | - |
1203 | if (scenePosDescendants || (flags & QGraphicsItem::ItemSendsScenePositionChanges)) partially evaluated: scenePosDescendants no Evaluation Count:0 | yes Evaluation Count:726 |
partially evaluated: (flags & QGraphicsItem::ItemSendsScenePositionChanges) no Evaluation Count:0 | yes Evaluation Count:726 |
| 0-726 |
1204 | scene->d_func()->setScenePosItemEnabled(q, true); never executed: scene->d_func()->setScenePosItemEnabled(q, true); | 0 |
1205 | } executed: } Execution Count:726 | 726 |
1206 | | - |
1207 | // Propagate dirty flags to the new parent | - |
1208 | markParentDirty(/*updateBoundingRect=*/true); executed (the execution status of this line is deduced): markParentDirty( true); | - |
1209 | | - |
1210 | // Inherit ancestor flags from the new parent. | - |
1211 | updateAncestorFlags(); executed (the execution status of this line is deduced): updateAncestorFlags(); | - |
1212 | | - |
1213 | // Update item visible / enabled. | - |
1214 | if (parent->d_ptr->visible != visible) { partially evaluated: parent->d_ptr->visible != visible no Evaluation Count:0 | yes Evaluation Count:793 |
| 0-793 |
1215 | if (!parent->d_ptr->visible || !explicitlyHidden) never evaluated: !parent->d_ptr->visible never evaluated: !explicitlyHidden | 0 |
1216 | setVisibleHelper(parent->d_ptr->visible, /* explicit = */ false, /* update = */ false); never executed: setVisibleHelper(parent->d_ptr->visible, false, false); | 0 |
1217 | } | 0 |
1218 | if (parent->isEnabled() != enabled) { partially evaluated: parent->isEnabled() != enabled no Evaluation Count:0 | yes Evaluation Count:793 |
| 0-793 |
1219 | if (!parent->d_ptr->enabled || !explicitlyDisabled) never evaluated: !parent->d_ptr->enabled never evaluated: !explicitlyDisabled | 0 |
1220 | setEnabledHelper(parent->d_ptr->enabled, /* explicit = */ false, /* update = */ false); never executed: setEnabledHelper(parent->d_ptr->enabled, false, false); | 0 |
1221 | } | 0 |
1222 | | - |
1223 | // Auto-activate if visible and the parent is active. | - |
1224 | if (visible && parent->isActive()) partially evaluated: visible yes Evaluation Count:793 | no Evaluation Count:0 |
evaluated: parent->isActive() yes Evaluation Count:3 | yes Evaluation Count:790 |
| 0-793 |
1225 | q->setActive(true); executed: q->setActive(true); Execution Count:3 | 3 |
1226 | } else { executed: } Execution Count:793 | 793 |
1227 | // Inherit ancestor flags from the new parent. | - |
1228 | updateAncestorFlags(); executed (the execution status of this line is deduced): updateAncestorFlags(); | - |
1229 | | - |
1230 | if (!inDestructor) { partially evaluated: !inDestructor no Evaluation Count:0 | yes Evaluation Count:745 |
| 0-745 |
1231 | // Update item visible / enabled. | - |
1232 | if (!visible && !explicitlyHidden) never evaluated: !visible never evaluated: !explicitlyHidden | 0 |
1233 | setVisibleHelper(true, /* explicit = */ false); never executed: setVisibleHelper(true, false); | 0 |
1234 | if (!enabled && !explicitlyDisabled) never evaluated: !enabled never evaluated: !explicitlyDisabled | 0 |
1235 | setEnabledHelper(true, /* explicit = */ false); never executed: setEnabledHelper(true, false); | 0 |
1236 | } | 0 |
1237 | } executed: } Execution Count:745 | 745 |
1238 | | - |
1239 | dirtySceneTransform = 1; executed (the execution status of this line is deduced): dirtySceneTransform = 1; | - |
1240 | if (!inDestructor && (transformData || (newParent && newParent->d_ptr->transformData))) evaluated: !inDestructor yes Evaluation Count:793 | yes Evaluation Count:745 |
partially evaluated: transformData no Evaluation Count:0 | yes Evaluation Count:793 |
partially evaluated: newParent yes Evaluation Count:793 | no Evaluation Count:0 |
partially evaluated: newParent->d_ptr->transformData no Evaluation Count:0 | yes Evaluation Count:793 |
| 0-793 |
1241 | transformChanged(); never executed: transformChanged(); | 0 |
1242 | | - |
1243 | // Restore the sub focus chain. | - |
1244 | if (subFocusItem) { partially evaluated: subFocusItem no Evaluation Count:0 | yes Evaluation Count:1538 |
| 0-1538 |
1245 | subFocusItem->d_ptr->setSubFocus(newParent); never executed (the execution status of this line is deduced): subFocusItem->d_ptr->setSubFocus(newParent); | - |
1246 | if (parent && parent->isActive()) never evaluated: parent never evaluated: parent->isActive() | 0 |
1247 | subFocusItem->setFocus(); never executed: subFocusItem->setFocus(); | 0 |
1248 | } | 0 |
1249 | | - |
1250 | // Deliver post-change notification | - |
1251 | if (newParentVariant) evaluated: newParentVariant yes Evaluation Count:1230 | yes Evaluation Count:308 |
| 308-1230 |
1252 | q->itemChange(QGraphicsItem::ItemParentHasChanged, *newParentVariant); executed: q->itemChange(QGraphicsItem::ItemParentHasChanged, *newParentVariant); Execution Count:1230 | 1230 |
1253 | | - |
1254 | if (isObject) evaluated: isObject yes Evaluation Count:1524 | yes Evaluation Count:14 |
| 14-1524 |
1255 | emit static_cast<QGraphicsObject *>(q)->parentChanged(); executed: static_cast<QGraphicsObject *>(q)->parentChanged(); Execution Count:1524 | 1524 |
1256 | } executed: } Execution Count:1538 | 1538 |
1257 | | - |
1258 | /*! | - |
1259 | \internal | - |
1260 | | - |
1261 | Returns the bounding rect of this item's children (excluding itself). | - |
1262 | */ | - |
1263 | void QGraphicsItemPrivate::childrenBoundingRectHelper(QTransform *x, QRectF *rect, QGraphicsItem *topMostEffectItem) | - |
1264 | { | - |
1265 | Q_Q(QGraphicsItem); executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func(); | - |
1266 | | - |
1267 | QRectF childrenRect; executed (the execution status of this line is deduced): QRectF childrenRect; | - |
1268 | QRectF *result = rect; executed (the execution status of this line is deduced): QRectF *result = rect; | - |
1269 | rect = &childrenRect; executed (the execution status of this line is deduced): rect = &childrenRect; | - |
1270 | const bool setTopMostEffectItem = !topMostEffectItem; executed (the execution status of this line is deduced): const bool setTopMostEffectItem = !topMostEffectItem; | - |
1271 | | - |
1272 | for (int i = 0; i < children.size(); ++i) { evaluated: i < children.size() yes Evaluation Count:18 | yes Evaluation Count:18 |
| 18 |
1273 | QGraphicsItem *child = children.at(i); executed (the execution status of this line is deduced): QGraphicsItem *child = children.at(i); | - |
1274 | QGraphicsItemPrivate *childd = child->d_ptr.data(); executed (the execution status of this line is deduced): QGraphicsItemPrivate *childd = child->d_ptr.data(); | - |
1275 | if (setTopMostEffectItem) evaluated: setTopMostEffectItem yes Evaluation Count:10 | yes Evaluation Count:8 |
| 8-10 |
1276 | topMostEffectItem = child; executed: topMostEffectItem = child; Execution Count:10 | 10 |
1277 | bool hasPos = !childd->pos.isNull(); executed (the execution status of this line is deduced): bool hasPos = !childd->pos.isNull(); | - |
1278 | if (hasPos || childd->transformData) { partially evaluated: hasPos no Evaluation Count:0 | yes Evaluation Count:18 |
partially evaluated: childd->transformData no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
1279 | // COMBINE | - |
1280 | QTransform matrix = childd->transformToParent(); never executed (the execution status of this line is deduced): QTransform matrix = childd->transformToParent(); | - |
1281 | if (x) | 0 |
1282 | matrix *= *x; never executed: matrix *= *x; | 0 |
1283 | *rect |= matrix.mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem)); never executed (the execution status of this line is deduced): *rect |= matrix.mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem)); | - |
1284 | if (!childd->children.isEmpty()) never evaluated: !childd->children.isEmpty() | 0 |
1285 | childd->childrenBoundingRectHelper(&matrix, rect, topMostEffectItem); never executed: childd->childrenBoundingRectHelper(&matrix, rect, topMostEffectItem); | 0 |
1286 | } else { | 0 |
1287 | if (x) partially evaluated: x no Evaluation Count:0 | yes Evaluation Count:18 |
| 0-18 |
1288 | *rect |= x->mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem)); never executed: *rect |= x->mapRect(child->d_ptr->effectiveBoundingRect(topMostEffectItem)); | 0 |
1289 | else | - |
1290 | *rect |= child->d_ptr->effectiveBoundingRect(topMostEffectItem); executed: *rect |= child->d_ptr->effectiveBoundingRect(topMostEffectItem); Execution Count:18 | 18 |
1291 | if (!childd->children.isEmpty()) evaluated: !childd->children.isEmpty() yes Evaluation Count:8 | yes Evaluation Count:10 |
| 8-10 |
1292 | childd->childrenBoundingRectHelper(x, rect, topMostEffectItem); executed: childd->childrenBoundingRectHelper(x, rect, topMostEffectItem); Execution Count:8 | 8 |
1293 | } executed: } Execution Count:18 | 18 |
1294 | } | - |
1295 | | - |
1296 | if (flags & QGraphicsItem::ItemClipsChildrenToShape){ evaluated: flags & QGraphicsItem::ItemClipsChildrenToShape yes Evaluation Count:4 | yes Evaluation Count:14 |
| 4-14 |
1297 | if (x) partially evaluated: x no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
1298 | *rect &= x->mapRect(q->boundingRect()); never executed: *rect &= x->mapRect(q->boundingRect()); | 0 |
1299 | else | - |
1300 | *rect &= q->boundingRect(); executed: *rect &= q->boundingRect(); Execution Count:4 | 4 |
1301 | } | - |
1302 | | - |
1303 | *result |= *rect; executed (the execution status of this line is deduced): *result |= *rect; | - |
1304 | } executed: } Execution Count:18 | 18 |
1305 | | - |
1306 | void QGraphicsItemPrivate::initStyleOption(QStyleOptionGraphicsItem *option, const QTransform &worldTransform, | - |
1307 | const QRegion &exposedRegion, bool allItems) const | - |
1308 | { | - |
1309 | Q_ASSERT(option); executed (the execution status of this line is deduced): qt_noop(); | - |
1310 | Q_Q(const QGraphicsItem); executed (the execution status of this line is deduced): const QGraphicsItem * const q = q_func(); | - |
1311 | | - |
1312 | // Initialize standard QStyleOption values. | - |
1313 | const QRectF brect = q->boundingRect(); executed (the execution status of this line is deduced): const QRectF brect = q->boundingRect(); | - |
1314 | option->state = QStyle::State_None; executed (the execution status of this line is deduced): option->state = QStyle::State_None; | - |
1315 | option->rect = brect.toRect(); executed (the execution status of this line is deduced): option->rect = brect.toRect(); | - |
1316 | option->levelOfDetail = 1; executed (the execution status of this line is deduced): option->levelOfDetail = 1; | - |
1317 | option->exposedRect = brect; executed (the execution status of this line is deduced): option->exposedRect = brect; | - |
1318 | | - |
1319 | // Style animations require a QObject-based animation target. | - |
1320 | // If a plain QGraphicsItem is used to draw animated controls, | - |
1321 | // QStyle is let to send animation updates to the whole scene. | - |
1322 | option->styleObject = q_ptr->toGraphicsObject(); executed (the execution status of this line is deduced): option->styleObject = q_ptr->toGraphicsObject(); | - |
1323 | if (!option->styleObject) evaluated: !option->styleObject yes Evaluation Count:120 | yes Evaluation Count:292 |
| 120-292 |
1324 | option->styleObject = scene; executed: option->styleObject = scene; Execution Count:120 | 120 |
1325 | | - |
1326 | if (selected) partially evaluated: selected no Evaluation Count:0 | yes Evaluation Count:412 |
| 0-412 |
1327 | option->state |= QStyle::State_Selected; never executed: option->state |= QStyle::State_Selected; | 0 |
1328 | if (enabled) partially evaluated: enabled yes Evaluation Count:412 | no Evaluation Count:0 |
| 0-412 |
1329 | option->state |= QStyle::State_Enabled; executed: option->state |= QStyle::State_Enabled; Execution Count:412 | 412 |
1330 | if (q->hasFocus()) partially evaluated: q->hasFocus() no Evaluation Count:0 | yes Evaluation Count:412 |
| 0-412 |
1331 | option->state |= QStyle::State_HasFocus; never executed: option->state |= QStyle::State_HasFocus; | 0 |
1332 | if (scene) { partially evaluated: scene yes Evaluation Count:412 | no Evaluation Count:0 |
| 0-412 |
1333 | if (scene->d_func()->hoverItems.contains(q_ptr)) partially evaluated: scene->d_func()->hoverItems.contains(q_ptr) no Evaluation Count:0 | yes Evaluation Count:412 |
| 0-412 |
1334 | option->state |= QStyle::State_MouseOver; never executed: option->state |= QStyle::State_MouseOver; | 0 |
1335 | if (q == scene->mouseGrabberItem()) partially evaluated: q == scene->mouseGrabberItem() no Evaluation Count:0 | yes Evaluation Count:412 |
| 0-412 |
1336 | option->state |= QStyle::State_Sunken; never executed: option->state |= QStyle::State_Sunken; | 0 |
1337 | } executed: } Execution Count:412 | 412 |
1338 | | - |
1339 | if (!(flags & QGraphicsItem::ItemUsesExtendedStyleOption)) evaluated: !(flags & QGraphicsItem::ItemUsesExtendedStyleOption) yes Evaluation Count:172 | yes Evaluation Count:240 |
| 172-240 |
1340 | return; executed: return; Execution Count:172 | 172 |
1341 | | - |
1342 | // Initialize QStyleOptionGraphicsItem specific values (matrix, exposedRect). | - |
1343 | option->matrix = worldTransform.toAffine(); //### discards perspective executed (the execution status of this line is deduced): option->matrix = worldTransform.toAffine(); | - |
1344 | | - |
1345 | if (!allItems) { evaluated: !allItems yes Evaluation Count:235 | yes Evaluation Count:5 |
| 5-235 |
1346 | // Determine the item's exposed area | - |
1347 | option->exposedRect = QRectF(); executed (the execution status of this line is deduced): option->exposedRect = QRectF(); | - |
1348 | const QTransform reverseMap = worldTransform.inverted(); executed (the execution status of this line is deduced): const QTransform reverseMap = worldTransform.inverted(); | - |
1349 | const QVector<QRect> exposedRects(exposedRegion.rects()); executed (the execution status of this line is deduced): const QVector<QRect> exposedRects(exposedRegion.rects()); | - |
1350 | for (int i = 0; i < exposedRects.size(); ++i) { evaluated: i < exposedRects.size() yes Evaluation Count:283 | yes Evaluation Count:36 |
| 36-283 |
1351 | option->exposedRect |= reverseMap.mapRect(QRectF(exposedRects.at(i))); executed (the execution status of this line is deduced): option->exposedRect |= reverseMap.mapRect(QRectF(exposedRects.at(i))); | - |
1352 | if (option->exposedRect.contains(brect)) evaluated: option->exposedRect.contains(brect) yes Evaluation Count:199 | yes Evaluation Count:84 |
| 84-199 |
1353 | break; executed: break; Execution Count:199 | 199 |
1354 | } executed: } Execution Count:84 | 84 |
1355 | option->exposedRect &= brect; executed (the execution status of this line is deduced): option->exposedRect &= brect; | - |
1356 | } executed: } Execution Count:235 | 235 |
1357 | } executed: } Execution Count:240 | 240 |
1358 | | - |
1359 | /*! | - |
1360 | \internal | - |
1361 | | - |
1362 | Empty all cached pixmaps from the pixmap cache. | - |
1363 | */ | - |
1364 | void QGraphicsItemCache::purge() | - |
1365 | { | - |
1366 | QPixmapCache::remove(key); never executed (the execution status of this line is deduced): QPixmapCache::remove(key); | - |
1367 | key = QPixmapCache::Key(); never executed (the execution status of this line is deduced): key = QPixmapCache::Key(); | - |
1368 | QMutableHashIterator<QPaintDevice *, DeviceData> it(deviceData); never executed (the execution status of this line is deduced): QMutableHashIterator<QPaintDevice *, DeviceData> it(deviceData); | - |
1369 | while (it.hasNext()) { never evaluated: it.hasNext() | 0 |
1370 | DeviceData &data = it.next().value(); never executed (the execution status of this line is deduced): DeviceData &data = it.next().value(); | - |
1371 | QPixmapCache::remove(data.key); never executed (the execution status of this line is deduced): QPixmapCache::remove(data.key); | - |
1372 | data.cacheIndent = QPoint(); never executed (the execution status of this line is deduced): data.cacheIndent = QPoint(); | - |
1373 | } | 0 |
1374 | deviceData.clear(); never executed (the execution status of this line is deduced): deviceData.clear(); | - |
1375 | allExposed = true; never executed (the execution status of this line is deduced): allExposed = true; | - |
1376 | exposed.clear(); never executed (the execution status of this line is deduced): exposed.clear(); | - |
1377 | } | 0 |
1378 | | - |
1379 | /*! | - |
1380 | Constructs a QGraphicsItem with the given \a parent item. | - |
1381 | It does not modify the parent object returned by QObject::parent(). | - |
1382 | | - |
1383 | If \a parent is 0, you can add the item to a scene by calling | - |
1384 | QGraphicsScene::addItem(). The item will then become a top-level item. | - |
1385 | | - |
1386 | \sa QGraphicsScene::addItem(), setParentItem() | - |
1387 | */ | - |
1388 | QGraphicsItem::QGraphicsItem(QGraphicsItem *parent) | - |
1389 | : d_ptr(new QGraphicsItemPrivate) | - |
1390 | { | - |
1391 | d_ptr->q_ptr = this; executed (the execution status of this line is deduced): d_ptr->q_ptr = this; | - |
1392 | setParentItem(parent); executed (the execution status of this line is deduced): setParentItem(parent); | - |
1393 | } executed: } Execution Count:62 | 62 |
1394 | | - |
1395 | /*! | - |
1396 | \internal | - |
1397 | */ | - |
1398 | QGraphicsItem::QGraphicsItem(QGraphicsItemPrivate &dd, QGraphicsItem *parent) | - |
1399 | : d_ptr(&dd) | - |
1400 | { | - |
1401 | d_ptr->q_ptr = this; executed (the execution status of this line is deduced): d_ptr->q_ptr = this; | - |
1402 | setParentItem(parent); executed (the execution status of this line is deduced): setParentItem(parent); | - |
1403 | } executed: } Execution Count:1514 | 1514 |
1404 | | - |
1405 | /*! | - |
1406 | Destroys the QGraphicsItem and all its children. If this item is currently | - |
1407 | associated with a scene, the item will be removed from the scene before it | - |
1408 | is deleted. | - |
1409 | | - |
1410 | \note It is more efficient to remove the item from the QGraphicsScene before | - |
1411 | destroying the item. | - |
1412 | */ | - |
1413 | QGraphicsItem::~QGraphicsItem() | - |
1414 | { | - |
1415 | if (d_ptr->isObject) { evaluated: d_ptr->isObject yes Evaluation Count:993 | yes Evaluation Count:68 |
| 68-993 |
1416 | QGraphicsObject *o = static_cast<QGraphicsObject *>(this); executed (the execution status of this line is deduced): QGraphicsObject *o = static_cast<QGraphicsObject *>(this); | - |
1417 | QObjectPrivate *p = QObjectPrivate::get(o); executed (the execution status of this line is deduced): QObjectPrivate *p = QObjectPrivate::get(o); | - |
1418 | p->wasDeleted = true; executed (the execution status of this line is deduced): p->wasDeleted = true; | - |
1419 | if (p->declarativeData) { partially evaluated: p->declarativeData no Evaluation Count:0 | yes Evaluation Count:993 |
| 0-993 |
1420 | QAbstractDeclarativeData::destroyed(p->declarativeData, o); never executed (the execution status of this line is deduced): QAbstractDeclarativeData::destroyed(p->declarativeData, o); | - |
1421 | p->declarativeData = 0; never executed (the execution status of this line is deduced): p->declarativeData = 0; | - |
1422 | } | 0 |
1423 | } executed: } Execution Count:993 | 993 |
1424 | | - |
1425 | d_ptr->inDestructor = 1; executed (the execution status of this line is deduced): d_ptr->inDestructor = 1; | - |
1426 | d_ptr->removeExtraItemCache(); executed (the execution status of this line is deduced): d_ptr->removeExtraItemCache(); | - |
1427 | | - |
1428 | #ifndef QT_NO_GESTURES | - |
1429 | if (d_ptr->isObject && !d_ptr->gestureContext.isEmpty()) { evaluated: d_ptr->isObject yes Evaluation Count:993 | yes Evaluation Count:68 |
evaluated: !d_ptr->gestureContext.isEmpty() yes Evaluation Count:50 | yes Evaluation Count:943 |
| 50-993 |
1430 | QGraphicsObject *o = static_cast<QGraphicsObject *>(this); executed (the execution status of this line is deduced): QGraphicsObject *o = static_cast<QGraphicsObject *>(this); | - |
1431 | if (QGestureManager *manager = QGestureManager::instance()) { partially evaluated: QGestureManager *manager = QGestureManager::instance() yes Evaluation Count:50 | no Evaluation Count:0 |
| 0-50 |
1432 | foreach (Qt::GestureType type, d_ptr->gestureContext.keys()) executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(d_ptr->gestureContext.keys())> _container_(d_ptr->gestureContext.keys()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (Qt::GestureType type = *_container_.i;; __extension__ ({--_container_.brk; break;})) | - |
1433 | manager->cleanupCachedGestures(o, type); executed: manager->cleanupCachedGestures(o, type); Execution Count:50 | 50 |
1434 | } executed: } Execution Count:50 | 50 |
1435 | } executed: } Execution Count:50 | 50 |
1436 | #endif | - |
1437 | | - |
1438 | clearFocus(); executed (the execution status of this line is deduced): clearFocus(); | - |
1439 | setFocusProxy(0); executed (the execution status of this line is deduced): setFocusProxy(0); | - |
1440 | | - |
1441 | // Update focus scope item ptr. | - |
1442 | QGraphicsItem *p = d_ptr->parent; executed (the execution status of this line is deduced): QGraphicsItem *p = d_ptr->parent; | - |
1443 | while (p) { evaluated: p yes Evaluation Count:751 | yes Evaluation Count:1061 |
| 751-1061 |
1444 | if (p->flags() & ItemIsFocusScope) { partially evaluated: p->flags() & ItemIsFocusScope no Evaluation Count:0 | yes Evaluation Count:751 |
| 0-751 |
1445 | if (p->d_ptr->focusScopeItem == this) never evaluated: p->d_ptr->focusScopeItem == this | 0 |
1446 | p->d_ptr->focusScopeItem = 0; never executed: p->d_ptr->focusScopeItem = 0; | 0 |
1447 | break; | 0 |
1448 | } | - |
1449 | p = p->d_ptr->parent; executed (the execution status of this line is deduced): p = p->d_ptr->parent; | - |
1450 | } executed: } Execution Count:751 | 751 |
1451 | | - |
1452 | if (!d_ptr->children.isEmpty()) { evaluated: !d_ptr->children.isEmpty() yes Evaluation Count:190 | yes Evaluation Count:871 |
| 190-871 |
1453 | while (!d_ptr->children.isEmpty()) evaluated: !d_ptr->children.isEmpty() yes Evaluation Count:739 | yes Evaluation Count:190 |
| 190-739 |
1454 | delete d_ptr->children.first(); executed: delete d_ptr->children.first(); Execution Count:739 | 739 |
1455 | Q_ASSERT(d_ptr->children.isEmpty()); executed (the execution status of this line is deduced): qt_noop(); | - |
1456 | } executed: } Execution Count:190 | 190 |
1457 | | - |
1458 | if (d_ptr->scene) { evaluated: d_ptr->scene yes Evaluation Count:994 | yes Evaluation Count:67 |
| 67-994 |
1459 | d_ptr->scene->d_func()->removeItemHelper(this); executed (the execution status of this line is deduced): d_ptr->scene->d_func()->removeItemHelper(this); | - |
1460 | } else { executed: } Execution Count:994 | 994 |
1461 | d_ptr->resetFocusProxy(); executed (the execution status of this line is deduced): d_ptr->resetFocusProxy(); | - |
1462 | setParentItem(0); executed (the execution status of this line is deduced): setParentItem(0); | - |
1463 | } executed: } Execution Count:67 | 67 |
1464 | | - |
1465 | #ifndef QT_NO_GRAPHICSEFFECT | - |
1466 | delete d_ptr->graphicsEffect; executed (the execution status of this line is deduced): delete d_ptr->graphicsEffect; | - |
1467 | #endif //QT_NO_GRAPHICSEFFECT | - |
1468 | if (d_ptr->transformData) { evaluated: d_ptr->transformData yes Evaluation Count:2 | yes Evaluation Count:1059 |
| 2-1059 |
1469 | for(int i = 0; i < d_ptr->transformData->graphicsTransforms.size(); ++i) { partially evaluated: i < d_ptr->transformData->graphicsTransforms.size() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1470 | QGraphicsTransform *t = d_ptr->transformData->graphicsTransforms.at(i); never executed (the execution status of this line is deduced): QGraphicsTransform *t = d_ptr->transformData->graphicsTransforms.at(i); | - |
1471 | static_cast<QGraphicsTransformPrivate *>(t->d_ptr.data())->item = 0; never executed (the execution status of this line is deduced): static_cast<QGraphicsTransformPrivate *>(t->d_ptr.data())->item = 0; | - |
1472 | delete t; never executed (the execution status of this line is deduced): delete t; | - |
1473 | } | 0 |
1474 | } executed: } Execution Count:2 | 2 |
1475 | delete d_ptr->transformData; executed (the execution status of this line is deduced): delete d_ptr->transformData; | - |
1476 | | - |
1477 | if (QGraphicsItemCustomDataStore *dataStore = qt_dataStore()) partially evaluated: QGraphicsItemCustomDataStore *dataStore = qt_dataStore() yes Evaluation Count:1061 | no Evaluation Count:0 |
| 0-1061 |
1478 | dataStore->data.remove(this); executed: dataStore->data.remove(this); Execution Count:1061 | 1061 |
1479 | } executed: } Execution Count:1061 | 1061 |
1480 | | - |
1481 | /*! | - |
1482 | Returns the current scene for the item, or 0 if the item is not stored in | - |
1483 | a scene. | - |
1484 | | - |
1485 | To add or move an item to a scene, call QGraphicsScene::addItem(). | - |
1486 | */ | - |
1487 | QGraphicsScene *QGraphicsItem::scene() const | - |
1488 | { | - |
1489 | return d_ptr->scene; executed: return d_ptr->scene; Execution Count:8622 | 8622 |
1490 | } | - |
1491 | | - |
1492 | /*! | - |
1493 | Returns a pointer to this item's item group, or 0 if this item is not | - |
1494 | member of a group. | - |
1495 | | - |
1496 | \sa QGraphicsItemGroup, QGraphicsScene::createItemGroup() | - |
1497 | */ | - |
1498 | QGraphicsItemGroup *QGraphicsItem::group() const | - |
1499 | { | - |
1500 | if (!d_ptr->isMemberOfGroup) partially evaluated: !d_ptr->isMemberOfGroup yes Evaluation Count:1037 | no Evaluation Count:0 |
| 0-1037 |
1501 | return 0; executed: return 0; Execution Count:1037 | 1037 |
1502 | QGraphicsItem *parent = const_cast<QGraphicsItem *>(this); never executed (the execution status of this line is deduced): QGraphicsItem *parent = const_cast<QGraphicsItem *>(this); | - |
1503 | while ((parent = parent->d_ptr->parent)) { never evaluated: (parent = parent->d_ptr->parent) | 0 |
1504 | if (QGraphicsItemGroup *group = qgraphicsitem_cast<QGraphicsItemGroup *>(parent)) never evaluated: QGraphicsItemGroup *group = qgraphicsitem_cast<QGraphicsItemGroup *>(parent) | 0 |
1505 | return group; never executed: return group; | 0 |
1506 | } | 0 |
1507 | // Unreachable; if d_ptr->isMemberOfGroup is != 0, then one parent of this | - |
1508 | // item is a group item. | - |
1509 | return 0; never executed: return 0; | 0 |
1510 | } | - |
1511 | | - |
1512 | /*! | - |
1513 | Adds this item to the item group \a group. If \a group is 0, this item is | - |
1514 | removed from any current group and added as a child of the previous | - |
1515 | group's parent. | - |
1516 | | - |
1517 | \sa group(), QGraphicsScene::createItemGroup() | - |
1518 | */ | - |
1519 | void QGraphicsItem::setGroup(QGraphicsItemGroup *group) | - |
1520 | { | - |
1521 | if (!group) { | 0 |
1522 | if (QGraphicsItemGroup *group = this->group()) never evaluated: QGraphicsItemGroup *group = this->group() | 0 |
1523 | group->removeFromGroup(this); never executed: group->removeFromGroup(this); | 0 |
1524 | } else { | 0 |
1525 | group->addToGroup(this); never executed (the execution status of this line is deduced): group->addToGroup(this); | - |
1526 | } | 0 |
1527 | } | - |
1528 | | - |
1529 | /*! | - |
1530 | Returns a pointer to this item's parent item. If this item does not have a | - |
1531 | parent, 0 is returned. | - |
1532 | | - |
1533 | \sa setParentItem(), childItems() | - |
1534 | */ | - |
1535 | QGraphicsItem *QGraphicsItem::parentItem() const | - |
1536 | { | - |
1537 | return d_ptr->parent; executed: return d_ptr->parent; Execution Count:14128 | 14128 |
1538 | } | - |
1539 | | - |
1540 | /*! | - |
1541 | Returns this item's top-level item. The top-level item is the item's | - |
1542 | topmost ancestor item whose parent is 0. If an item has no parent, its own | - |
1543 | pointer is returned (i.e., a top-level item is its own top-level item). | - |
1544 | | - |
1545 | \sa parentItem() | - |
1546 | */ | - |
1547 | QGraphicsItem *QGraphicsItem::topLevelItem() const | - |
1548 | { | - |
1549 | QGraphicsItem *parent = const_cast<QGraphicsItem *>(this); executed (the execution status of this line is deduced): QGraphicsItem *parent = const_cast<QGraphicsItem *>(this); | - |
1550 | while (QGraphicsItem *grandPa = parent->parentItem()) evaluated: QGraphicsItem *grandPa = parent->parentItem() yes Evaluation Count:2309 | yes Evaluation Count:3029 |
| 2309-3029 |
1551 | parent = grandPa; executed: parent = grandPa; Execution Count:2309 | 2309 |
1552 | return parent; executed: return parent; Execution Count:3029 | 3029 |
1553 | } | - |
1554 | | - |
1555 | /*! | - |
1556 | \since 4.6 | - |
1557 | | - |
1558 | Returns a pointer to the item's parent, cast to a QGraphicsObject. returns 0 if the parent item | - |
1559 | is not a QGraphicsObject. | - |
1560 | | - |
1561 | \sa parentItem(), childItems() | - |
1562 | */ | - |
1563 | QGraphicsObject *QGraphicsItem::parentObject() const | - |
1564 | { | - |
1565 | QGraphicsItem *p = d_ptr->parent; executed (the execution status of this line is deduced): QGraphicsItem *p = d_ptr->parent; | - |
1566 | return (p && p->d_ptr->isObject) ? static_cast<QGraphicsObject *>(p) : 0; executed: return (p && p->d_ptr->isObject) ? static_cast<QGraphicsObject *>(p) : 0; Execution Count:776 | 776 |
1567 | } | - |
1568 | | - |
1569 | /*! | - |
1570 | \since 4.4 | - |
1571 | | - |
1572 | Returns a pointer to the item's parent widget. The item's parent widget is | - |
1573 | the closest parent item that is a widget. | - |
1574 | | - |
1575 | \sa parentItem(), childItems() | - |
1576 | */ | - |
1577 | QGraphicsWidget *QGraphicsItem::parentWidget() const | - |
1578 | { | - |
1579 | QGraphicsItem *p = parentItem(); executed (the execution status of this line is deduced): QGraphicsItem *p = parentItem(); | - |
1580 | while (p && !p->isWidget()) evaluated: p yes Evaluation Count:4702 | yes Evaluation Count:1754 |
evaluated: !p->isWidget() yes Evaluation Count:10 | yes Evaluation Count:4692 |
| 10-4702 |
1581 | p = p->parentItem(); executed: p = p->parentItem(); Execution Count:10 | 10 |
1582 | return (p && p->isWidget()) ? static_cast<QGraphicsWidget *>(p) : 0; executed: return (p && p->isWidget()) ? static_cast<QGraphicsWidget *>(p) : 0; Execution Count:6446 | 6446 |
1583 | } | - |
1584 | | - |
1585 | /*! | - |
1586 | \since 4.4 | - |
1587 | | - |
1588 | Returns a pointer to the item's top level widget (i.e., the item's | - |
1589 | ancestor whose parent is 0, or whose parent is not a widget), or 0 if this | - |
1590 | item does not have a top level widget. If the item is its own top level | - |
1591 | widget, this function returns a pointer to the item itself. | - |
1592 | */ | - |
1593 | QGraphicsWidget *QGraphicsItem::topLevelWidget() const | - |
1594 | { | - |
1595 | if (const QGraphicsWidget *p = parentWidget()) never evaluated: const QGraphicsWidget *p = parentWidget() | 0 |
1596 | return p->topLevelWidget(); never executed: return p->topLevelWidget(); | 0 |
1597 | return isWidget() ? static_cast<QGraphicsWidget *>(const_cast<QGraphicsItem *>(this)) : 0; never executed: return isWidget() ? static_cast<QGraphicsWidget *>(const_cast<QGraphicsItem *>(this)) : 0; | 0 |
1598 | } | - |
1599 | | - |
1600 | /*! | - |
1601 | \since 4.4 | - |
1602 | | - |
1603 | Returns the item's window, or 0 if this item does not have a window. If | - |
1604 | the item is a window, it will return itself. Otherwise it will return the | - |
1605 | closest ancestor that is a window. | - |
1606 | | - |
1607 | \sa QGraphicsWidget::isWindow() | - |
1608 | */ | - |
1609 | QGraphicsWidget *QGraphicsItem::window() const | - |
1610 | { | - |
1611 | QGraphicsItem *p = panel(); executed (the execution status of this line is deduced): QGraphicsItem *p = panel(); | - |
1612 | if (p && p->isWindow()) evaluated: p yes Evaluation Count:58 | yes Evaluation Count:186 |
partially evaluated: p->isWindow() yes Evaluation Count:58 | no Evaluation Count:0 |
| 0-186 |
1613 | return static_cast<QGraphicsWidget *>(p); executed: return static_cast<QGraphicsWidget *>(p); Execution Count:58 | 58 |
1614 | return 0; executed: return 0; Execution Count:186 | 186 |
1615 | } | - |
1616 | | - |
1617 | /*! | - |
1618 | \since 4.6 | - |
1619 | | - |
1620 | Returns the item's panel, or 0 if this item does not have a panel. If the | - |
1621 | item is a panel, it will return itself. Otherwise it will return the | - |
1622 | closest ancestor that is a panel. | - |
1623 | | - |
1624 | \sa isPanel(), ItemIsPanel | - |
1625 | */ | - |
1626 | QGraphicsItem *QGraphicsItem::panel() const | - |
1627 | { | - |
1628 | if (d_ptr->flags & ItemIsPanel) evaluated: d_ptr->flags & ItemIsPanel yes Evaluation Count:175 | yes Evaluation Count:193 |
| 175-193 |
1629 | return const_cast<QGraphicsItem *>(this); executed: return const_cast<QGraphicsItem *>(this); Execution Count:175 | 175 |
1630 | return d_ptr->parent ? d_ptr->parent->panel() : 0; executed: return d_ptr->parent ? d_ptr->parent->panel() : 0; Execution Count:193 | 193 |
1631 | } | - |
1632 | | - |
1633 | /*! | - |
1634 | \since 4.6 | - |
1635 | | - |
1636 | Return the graphics item cast to a QGraphicsObject, if the class is actually a | - |
1637 | graphics object, 0 otherwise. | - |
1638 | */ | - |
1639 | QGraphicsObject *QGraphicsItem::toGraphicsObject() | - |
1640 | { | - |
1641 | return d_ptr->isObject ? static_cast<QGraphicsObject *>(this) : 0; executed: return d_ptr->isObject ? static_cast<QGraphicsObject *>(this) : 0; Execution Count:1782 | 1782 |
1642 | } | - |
1643 | | - |
1644 | /*! | - |
1645 | \since 4.6 | - |
1646 | | - |
1647 | Return the graphics item cast to a QGraphicsObject, if the class is actually a | - |
1648 | graphics object, 0 otherwise. | - |
1649 | */ | - |
1650 | const QGraphicsObject *QGraphicsItem::toGraphicsObject() const | - |
1651 | { | - |
1652 | return d_ptr->isObject ? static_cast<const QGraphicsObject *>(this) : 0; never executed: return d_ptr->isObject ? static_cast<const QGraphicsObject *>(this) : 0; | 0 |
1653 | } | - |
1654 | | - |
1655 | /*! | - |
1656 | Sets this item's parent item to \a newParent. If this item already | - |
1657 | has a parent, it is first removed from the previous parent. If \a | - |
1658 | newParent is 0, this item will become a top-level item. | - |
1659 | | - |
1660 | Note that this implicitly adds this graphics item to the scene of | - |
1661 | the parent. You should not \l{QGraphicsScene::addItem()}{add} the | - |
1662 | item to the scene yourself. | - |
1663 | | - |
1664 | Calling this function on an item that is an ancestor of \a newParent | - |
1665 | have undefined behaviour. | - |
1666 | | - |
1667 | \sa parentItem(), childItems() | - |
1668 | */ | - |
1669 | void QGraphicsItem::setParentItem(QGraphicsItem *newParent) | - |
1670 | { | - |
1671 | if (newParent == this) { partially evaluated: newParent == this no Evaluation Count:0 | yes Evaluation Count:2867 |
| 0-2867 |
1672 | qWarning("QGraphicsItem::setParentItem: cannot assign %p as a parent of itself", this); never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 1672, __PRETTY_FUNCTION__).warning("QGraphicsItem::setParentItem: cannot assign %p as a parent of itself", this); | - |
1673 | return; | 0 |
1674 | } | - |
1675 | if (newParent == d_ptr->parent) evaluated: newParent == d_ptr->parent yes Evaluation Count:1637 | yes Evaluation Count:1230 |
| 1230-1637 |
1676 | return; executed: return; Execution Count:1637 | 1637 |
1677 | | - |
1678 | const QVariant newParentVariant(itemChange(QGraphicsItem::ItemParentChange, executed (the execution status of this line is deduced): const QVariant newParentVariant(itemChange(QGraphicsItem::ItemParentChange, | - |
1679 | QVariant::fromValue<QGraphicsItem *>(newParent))); executed (the execution status of this line is deduced): QVariant::fromValue<QGraphicsItem *>(newParent))); | - |
1680 | newParent = qvariant_cast<QGraphicsItem *>(newParentVariant); executed (the execution status of this line is deduced): newParent = qvariant_cast<QGraphicsItem *>(newParentVariant); | - |
1681 | if (newParent == d_ptr->parent) partially evaluated: newParent == d_ptr->parent no Evaluation Count:0 | yes Evaluation Count:1230 |
| 0-1230 |
1682 | return; | 0 |
1683 | | - |
1684 | const QVariant thisPointerVariant(QVariant::fromValue<QGraphicsItem *>(this)); executed (the execution status of this line is deduced): const QVariant thisPointerVariant(QVariant::fromValue<QGraphicsItem *>(this)); | - |
1685 | d_ptr->setParentItemHelper(newParent, &newParentVariant, &thisPointerVariant); executed (the execution status of this line is deduced): d_ptr->setParentItemHelper(newParent, &newParentVariant, &thisPointerVariant); | - |
1686 | } executed: } Execution Count:1230 | 1230 |
1687 | | - |
1688 | /*! | - |
1689 | \fn QList<QGraphicsItem *> QGraphicsItem::children() const | - |
1690 | \obsolete | - |
1691 | | - |
1692 | Use childItems() instead. | - |
1693 | | - |
1694 | \sa setParentItem() | - |
1695 | */ | - |
1696 | | - |
1697 | /*! | - |
1698 | \since 4.4 | - |
1699 | | - |
1700 | Returns a list of this item's children. | - |
1701 | | - |
1702 | The items are sorted by stacking order. This takes into account both the | - |
1703 | items' insertion order and their Z-values. | - |
1704 | | - |
1705 | \sa setParentItem(), zValue(), {QGraphicsItem#Sorting}{Sorting} | - |
1706 | */ | - |
1707 | QList<QGraphicsItem *> QGraphicsItem::childItems() const | - |
1708 | { | - |
1709 | const_cast<QGraphicsItem *>(this)->d_ptr->ensureSortedChildren(); executed (the execution status of this line is deduced): const_cast<QGraphicsItem *>(this)->d_ptr->ensureSortedChildren(); | - |
1710 | return d_ptr->children; executed: return d_ptr->children; Execution Count:188 | 188 |
1711 | } | - |
1712 | | - |
1713 | /*! | - |
1714 | \since 4.4 | - |
1715 | Returns true if this item is a widget (i.e., QGraphicsWidget); otherwise, | - |
1716 | returns false. | - |
1717 | */ | - |
1718 | bool QGraphicsItem::isWidget() const | - |
1719 | { | - |
1720 | return d_ptr->isWidget; executed: return d_ptr->isWidget; Execution Count:24662 | 24662 |
1721 | } | - |
1722 | | - |
1723 | /*! | - |
1724 | \since 4.4 | - |
1725 | Returns true if the item is a QGraphicsWidget window, otherwise returns | - |
1726 | false. | - |
1727 | | - |
1728 | \sa QGraphicsWidget::windowFlags() | - |
1729 | */ | - |
1730 | bool QGraphicsItem::isWindow() const | - |
1731 | { | - |
1732 | return d_ptr->isWidget && (static_cast<const QGraphicsWidget *>(this)->windowType() & Qt::Window); executed: return d_ptr->isWidget && (static_cast<const QGraphicsWidget *>(this)->windowType() & Qt::Window); Execution Count:3418 | 3418 |
1733 | } | - |
1734 | | - |
1735 | /*! | - |
1736 | \since 4.6 | - |
1737 | Returns true if the item is a panel; otherwise returns false. | - |
1738 | | - |
1739 | \sa QGraphicsItem::panel(), ItemIsPanel | - |
1740 | */ | - |
1741 | bool QGraphicsItem::isPanel() const | - |
1742 | { | - |
1743 | return d_ptr->flags & ItemIsPanel; executed: return d_ptr->flags & ItemIsPanel; Execution Count:3018 | 3018 |
1744 | } | - |
1745 | | - |
1746 | /*! | - |
1747 | Returns this item's flags. The flags describe what configurable features | - |
1748 | of the item are enabled and not. For example, if the flags include | - |
1749 | ItemIsFocusable, the item can accept input focus. | - |
1750 | | - |
1751 | By default, no flags are enabled. | - |
1752 | | - |
1753 | \sa setFlags(), setFlag() | - |
1754 | */ | - |
1755 | QGraphicsItem::GraphicsItemFlags QGraphicsItem::flags() const | - |
1756 | { | - |
1757 | return GraphicsItemFlags(d_ptr->flags); executed: return GraphicsItemFlags(d_ptr->flags); Execution Count:2503 | 2503 |
1758 | } | - |
1759 | | - |
1760 | /*! | - |
1761 | If \a enabled is true, the item flag \a flag is enabled; otherwise, it is | - |
1762 | disabled. | - |
1763 | | - |
1764 | \sa flags(), setFlags() | - |
1765 | */ | - |
1766 | void QGraphicsItem::setFlag(GraphicsItemFlag flag, bool enabled) | - |
1767 | { | - |
1768 | if (enabled) evaluated: enabled yes Evaluation Count:8 | yes Evaluation Count:6 |
| 6-8 |
1769 | setFlags(GraphicsItemFlags(d_ptr->flags) | flag); executed: setFlags(GraphicsItemFlags(d_ptr->flags) | flag); Execution Count:8 | 8 |
1770 | else | - |
1771 | setFlags(GraphicsItemFlags(d_ptr->flags) & ~flag); executed: setFlags(GraphicsItemFlags(d_ptr->flags) & ~flag); Execution Count:6 | 6 |
1772 | } | - |
1773 | | - |
1774 | /*! | - |
1775 | Sets the item flags to \a flags. All flags in \a flags are enabled; all | - |
1776 | flags not in \a flags are disabled. | - |
1777 | | - |
1778 | If the item had focus and \a flags does not enable ItemIsFocusable, the | - |
1779 | item loses focus as a result of calling this function. Similarly, if the | - |
1780 | item was selected, and \a flags does not enabled ItemIsSelectable, the | - |
1781 | item is automatically unselected. | - |
1782 | | - |
1783 | By default, no flags are enabled. (QGraphicsWidget enables the | - |
1784 | ItemSendsGeometryChanges flag by default in order to track position | - |
1785 | changes.) | - |
1786 | | - |
1787 | \sa flags(), setFlag() | - |
1788 | */ | - |
1789 | void QGraphicsItem::setFlags(GraphicsItemFlags flags) | - |
1790 | { | - |
1791 | // Notify change and check for adjustment. | - |
1792 | if (quint32(d_ptr->flags) == quint32(flags)) evaluated: quint32(d_ptr->flags) == quint32(flags) yes Evaluation Count:3 | yes Evaluation Count:14 |
| 3-14 |
1793 | return; executed: return; Execution Count:3 | 3 |
1794 | flags = GraphicsItemFlags(itemChange(ItemFlagsChange, quint32(flags)).toUInt()); executed (the execution status of this line is deduced): flags = GraphicsItemFlags(itemChange(ItemFlagsChange, quint32(flags)).toUInt()); | - |
1795 | if (quint32(d_ptr->flags) == quint32(flags)) partially evaluated: quint32(d_ptr->flags) == quint32(flags) no Evaluation Count:0 | yes Evaluation Count:14 |
| 0-14 |
1796 | return; | 0 |
1797 | if (d_ptr->scene && d_ptr->scene->d_func()->indexMethod != QGraphicsScene::NoIndex) evaluated: d_ptr->scene yes Evaluation Count:5 | yes Evaluation Count:9 |
partially evaluated: d_ptr->scene->d_func()->indexMethod != QGraphicsScene::NoIndex yes Evaluation Count:5 | no Evaluation Count:0 |
| 0-9 |
1798 | d_ptr->scene->d_func()->index->itemChange(this, ItemFlagsChange, &flags); executed: d_ptr->scene->d_func()->index->itemChange(this, ItemFlagsChange, &flags); Execution Count:5 | 5 |
1799 | | - |
1800 | // Flags that alter the geometry of the item (or its children). | - |
1801 | const quint32 geomChangeFlagsMask = (ItemClipsChildrenToShape | ItemClipsToShape | ItemIgnoresTransformations | ItemIsSelectable); executed (the execution status of this line is deduced): const quint32 geomChangeFlagsMask = (ItemClipsChildrenToShape | ItemClipsToShape | ItemIgnoresTransformations | ItemIsSelectable); | - |
1802 | bool fullUpdate = (quint32(flags) & geomChangeFlagsMask) != (d_ptr->flags & geomChangeFlagsMask); executed (the execution status of this line is deduced): bool fullUpdate = (quint32(flags) & geomChangeFlagsMask) != (d_ptr->flags & geomChangeFlagsMask); | - |
1803 | if (fullUpdate) evaluated: fullUpdate yes Evaluation Count:7 | yes Evaluation Count:7 |
| 7 |
1804 | d_ptr->updatePaintedViewBoundingRects(/*children=*/true); executed: d_ptr->updatePaintedViewBoundingRects( true); Execution Count:7 | 7 |
1805 | | - |
1806 | // Keep the old flags to compare the diff. | - |
1807 | GraphicsItemFlags oldFlags = GraphicsItemFlags(d_ptr->flags); executed (the execution status of this line is deduced): GraphicsItemFlags oldFlags = GraphicsItemFlags(d_ptr->flags); | - |
1808 | | - |
1809 | // Update flags. | - |
1810 | d_ptr->flags = flags; executed (the execution status of this line is deduced): d_ptr->flags = flags; | - |
1811 | | - |
1812 | if (!(d_ptr->flags & ItemIsFocusable) && hasFocus()) { evaluated: !(d_ptr->flags & ItemIsFocusable) yes Evaluation Count:11 | yes Evaluation Count:3 |
partially evaluated: hasFocus() no Evaluation Count:0 | yes Evaluation Count:11 |
| 0-11 |
1813 | // Clear focus on the item if it has focus when the focusable flag | - |
1814 | // is unset. | - |
1815 | clearFocus(); never executed (the execution status of this line is deduced): clearFocus(); | - |
1816 | } | 0 |
1817 | | - |
1818 | if (!(d_ptr->flags & ItemIsSelectable) && isSelected()) { partially evaluated: !(d_ptr->flags & ItemIsSelectable) yes Evaluation Count:14 | no Evaluation Count:0 |
partially evaluated: isSelected() no Evaluation Count:0 | yes Evaluation Count:14 |
| 0-14 |
1819 | // Unselect the item if it is selected when the selectable flag is | - |
1820 | // unset. | - |
1821 | setSelected(false); never executed (the execution status of this line is deduced): setSelected(false); | - |
1822 | } | 0 |
1823 | | - |
1824 | if ((flags & ItemClipsChildrenToShape) != (oldFlags & ItemClipsChildrenToShape)) { evaluated: (flags & ItemClipsChildrenToShape) != (oldFlags & ItemClipsChildrenToShape) yes Evaluation Count:7 | yes Evaluation Count:7 |
| 7 |
1825 | // Item children clipping changes. Propagate the ancestor flag to | - |
1826 | // all children. | - |
1827 | d_ptr->updateAncestorFlag(ItemClipsChildrenToShape); executed (the execution status of this line is deduced): d_ptr->updateAncestorFlag(ItemClipsChildrenToShape); | - |
1828 | // The childrenBoundingRect is clipped to the boundingRect in case of ItemClipsChildrenToShape, | - |
1829 | // which means we have to invalidate the cached childrenBoundingRect whenever this flag changes. | - |
1830 | d_ptr->dirtyChildrenBoundingRect = 1; executed (the execution status of this line is deduced): d_ptr->dirtyChildrenBoundingRect = 1; | - |
1831 | d_ptr->markParentDirty(true); executed (the execution status of this line is deduced): d_ptr->markParentDirty(true); | - |
1832 | } executed: } Execution Count:7 | 7 |
1833 | | - |
1834 | if ((flags & ItemIgnoresTransformations) != (oldFlags & ItemIgnoresTransformations)) { partially evaluated: (flags & ItemIgnoresTransformations) != (oldFlags & ItemIgnoresTransformations) no Evaluation Count:0 | yes Evaluation Count:14 |
| 0-14 |
1835 | // Item children clipping changes. Propagate the ancestor flag to | - |
1836 | // all children. | - |
1837 | d_ptr->updateAncestorFlag(ItemIgnoresTransformations); never executed (the execution status of this line is deduced): d_ptr->updateAncestorFlag(ItemIgnoresTransformations); | - |
1838 | } | 0 |
1839 | | - |
1840 | if ((flags & ItemNegativeZStacksBehindParent) != (oldFlags & ItemNegativeZStacksBehindParent)) { partially evaluated: (flags & ItemNegativeZStacksBehindParent) != (oldFlags & ItemNegativeZStacksBehindParent) no Evaluation Count:0 | yes Evaluation Count:14 |
| 0-14 |
1841 | // NB! We change the flags directly here, so we must also update d_ptr->flags. | - |
1842 | // Note that this has do be done before the ItemStacksBehindParent check | - |
1843 | // below; otherwise we will loose the change. | - |
1844 | | - |
1845 | // Update stack-behind. | - |
1846 | if (d_ptr->z < qreal(0.0)) never evaluated: d_ptr->z < qreal(0.0) | 0 |
1847 | flags |= ItemStacksBehindParent; never executed: flags |= ItemStacksBehindParent; | 0 |
1848 | else | - |
1849 | flags &= ~ItemStacksBehindParent; never executed: flags &= ~ItemStacksBehindParent; | 0 |
1850 | d_ptr->flags = flags; never executed (the execution status of this line is deduced): d_ptr->flags = flags; | - |
1851 | } | 0 |
1852 | | - |
1853 | if ((flags & ItemStacksBehindParent) != (oldFlags & ItemStacksBehindParent)) { evaluated: (flags & ItemStacksBehindParent) != (oldFlags & ItemStacksBehindParent) yes Evaluation Count:1 | yes Evaluation Count:13 |
| 1-13 |
1854 | // NB! This check has to come after the ItemNegativeZStacksBehindParent | - |
1855 | // check above. Be careful. | - |
1856 | | - |
1857 | // Ensure child item sorting is up to date when toggling this flag. | - |
1858 | if (d_ptr->parent) partially evaluated: d_ptr->parent no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1859 | d_ptr->parent->d_ptr->needSortChildren = 1; never executed: d_ptr->parent->d_ptr->needSortChildren = 1; | 0 |
1860 | else if (d_ptr->scene) partially evaluated: d_ptr->scene no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
1861 | d_ptr->scene->d_func()->needSortTopLevelItems = 1; never executed: d_ptr->scene->d_func()->needSortTopLevelItems = 1; | 0 |
1862 | } | - |
1863 | | - |
1864 | if ((flags & ItemAcceptsInputMethod) != (oldFlags & ItemAcceptsInputMethod)) { partially evaluated: (flags & ItemAcceptsInputMethod) != (oldFlags & ItemAcceptsInputMethod) no Evaluation Count:0 | yes Evaluation Count:14 |
| 0-14 |
1865 | // Update input method sensitivity in any views. | - |
1866 | if (d_ptr->scene) never evaluated: d_ptr->scene | 0 |
1867 | d_ptr->scene->d_func()->updateInputMethodSensitivityInViews(); never executed: d_ptr->scene->d_func()->updateInputMethodSensitivityInViews(); | 0 |
1868 | } | 0 |
1869 | | - |
1870 | | - |
1871 | if ((d_ptr->panelModality != NonModal) partially evaluated: (d_ptr->panelModality != NonModal) no Evaluation Count:0 | yes Evaluation Count:14 |
| 0-14 |
1872 | && d_ptr->scene never evaluated: d_ptr->scene | 0 |
1873 | && (flags & ItemIsPanel) != (oldFlags & ItemIsPanel)) { never evaluated: (flags & ItemIsPanel) != (oldFlags & ItemIsPanel) | 0 |
1874 | // update the panel's modal state | - |
1875 | if (flags & ItemIsPanel) never evaluated: flags & ItemIsPanel | 0 |
1876 | d_ptr->scene->d_func()->enterModal(this); never executed: d_ptr->scene->d_func()->enterModal(this); | 0 |
1877 | else | - |
1878 | d_ptr->scene->d_func()->leaveModal(this); never executed: d_ptr->scene->d_func()->leaveModal(this); | 0 |
1879 | } | - |
1880 | | - |
1881 | if (d_ptr->scene) { evaluated: d_ptr->scene yes Evaluation Count:5 | yes Evaluation Count:9 |
| 5-9 |
1882 | if ((flags & ItemSendsScenePositionChanges) != (oldFlags & ItemSendsScenePositionChanges)) { partially evaluated: (flags & ItemSendsScenePositionChanges) != (oldFlags & ItemSendsScenePositionChanges) no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
1883 | if (flags & ItemSendsScenePositionChanges) never evaluated: flags & ItemSendsScenePositionChanges | 0 |
1884 | d_ptr->scene->d_func()->registerScenePosItem(this); never executed: d_ptr->scene->d_func()->registerScenePosItem(this); | 0 |
1885 | else | - |
1886 | d_ptr->scene->d_func()->unregisterScenePosItem(this); never executed: d_ptr->scene->d_func()->unregisterScenePosItem(this); | 0 |
1887 | } | - |
1888 | d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true); executed (the execution status of this line is deduced): d_ptr->scene->d_func()->markDirty(this, QRectF(), true); | - |
1889 | } executed: } Execution Count:5 | 5 |
1890 | | - |
1891 | // Notify change. | - |
1892 | itemChange(ItemFlagsHaveChanged, quint32(flags)); executed (the execution status of this line is deduced): itemChange(ItemFlagsHaveChanged, quint32(flags)); | - |
1893 | } executed: } Execution Count:14 | 14 |
1894 | | - |
1895 | /*! | - |
1896 | \since 4.4 | - |
1897 | Returns the cache mode for this item. The default mode is NoCache (i.e., | - |
1898 | cache is disabled and all painting is immediate). | - |
1899 | | - |
1900 | \sa setCacheMode() | - |
1901 | */ | - |
1902 | QGraphicsItem::CacheMode QGraphicsItem::cacheMode() const | - |
1903 | { | - |
1904 | return QGraphicsItem::CacheMode(d_ptr->cacheMode); never executed: return QGraphicsItem::CacheMode(d_ptr->cacheMode); | 0 |
1905 | } | - |
1906 | | - |
1907 | /*! | - |
1908 | \since 4.4 | - |
1909 | Sets the item's cache mode to \a mode. | - |
1910 | | - |
1911 | The optional \a logicalCacheSize argument is used only by | - |
1912 | ItemCoordinateCache mode, and describes the resolution of the cache | - |
1913 | buffer; if \a logicalCacheSize is (100, 100), QGraphicsItem will fit the | - |
1914 | item into 100x100 pixels in graphics memory, regardless of the logical | - |
1915 | size of the item itself. By default QGraphicsItem uses the size of | - |
1916 | boundingRect(). For all other cache modes than ItemCoordinateCache, \a | - |
1917 | logicalCacheSize is ignored. | - |
1918 | | - |
1919 | Caching can speed up rendering if your item spends a significant time | - |
1920 | redrawing itself. In some cases the cache can also slow down rendering, in | - |
1921 | particular when the item spends less time redrawing than QGraphicsItem | - |
1922 | spends redrawing from the cache. When enabled, the item's paint() function | - |
1923 | will be called only once for each call to update(); for any subsequent | - |
1924 | repaint requests, the Graphics View framework will redraw from the | - |
1925 | cache. This approach works particularly well with QGLWidget, which stores | - |
1926 | all the cache as OpenGL textures. | - |
1927 | | - |
1928 | Be aware that QPixmapCache's cache limit may need to be changed to obtain | - |
1929 | optimal performance. | - |
1930 | | - |
1931 | You can read more about the different cache modes in the CacheMode | - |
1932 | documentation. | - |
1933 | | - |
1934 | \sa CacheMode, QPixmapCache::setCacheLimit() | - |
1935 | */ | - |
1936 | void QGraphicsItem::setCacheMode(CacheMode mode, const QSize &logicalCacheSize) | - |
1937 | { | - |
1938 | CacheMode lastMode = CacheMode(d_ptr->cacheMode); never executed (the execution status of this line is deduced): CacheMode lastMode = CacheMode(d_ptr->cacheMode); | - |
1939 | d_ptr->cacheMode = mode; never executed (the execution status of this line is deduced): d_ptr->cacheMode = mode; | - |
1940 | bool noVisualChange = (mode == NoCache && lastMode == NoCache) never evaluated: mode == NoCache never evaluated: lastMode == NoCache | 0 |
1941 | || (mode == NoCache && lastMode == DeviceCoordinateCache) never evaluated: mode == NoCache never evaluated: lastMode == DeviceCoordinateCache | 0 |
1942 | || (mode == DeviceCoordinateCache && lastMode == NoCache) never evaluated: mode == DeviceCoordinateCache never evaluated: lastMode == NoCache | 0 |
1943 | || (mode == DeviceCoordinateCache && lastMode == DeviceCoordinateCache); never evaluated: mode == DeviceCoordinateCache never evaluated: lastMode == DeviceCoordinateCache | 0 |
1944 | if (mode == NoCache) { never evaluated: mode == NoCache | 0 |
1945 | d_ptr->removeExtraItemCache(); never executed (the execution status of this line is deduced): d_ptr->removeExtraItemCache(); | - |
1946 | } else { | 0 |
1947 | QGraphicsItemCache *cache = d_ptr->extraItemCache(); never executed (the execution status of this line is deduced): QGraphicsItemCache *cache = d_ptr->extraItemCache(); | - |
1948 | | - |
1949 | // Reset old cache | - |
1950 | cache->purge(); never executed (the execution status of this line is deduced): cache->purge(); | - |
1951 | | - |
1952 | if (mode == ItemCoordinateCache) { never evaluated: mode == ItemCoordinateCache | 0 |
1953 | if (lastMode == mode && cache->fixedSize == logicalCacheSize) never evaluated: lastMode == mode never evaluated: cache->fixedSize == logicalCacheSize | 0 |
1954 | noVisualChange = true; never executed: noVisualChange = true; | 0 |
1955 | cache->fixedSize = logicalCacheSize; never executed (the execution status of this line is deduced): cache->fixedSize = logicalCacheSize; | - |
1956 | } | 0 |
1957 | } | 0 |
1958 | if (!noVisualChange) never evaluated: !noVisualChange | 0 |
1959 | update(); never executed: update(); | 0 |
1960 | } | 0 |
1961 | | - |
1962 | /*! | - |
1963 | \since 4.6 | - |
1964 | | - |
1965 | Returns the modality for this item. | - |
1966 | */ | - |
1967 | QGraphicsItem::PanelModality QGraphicsItem::panelModality() const | - |
1968 | { | - |
1969 | return d_ptr->panelModality; executed: return d_ptr->panelModality; Execution Count:360 | 360 |
1970 | } | - |
1971 | | - |
1972 | /*! | - |
1973 | \since 4.6 | - |
1974 | | - |
1975 | Sets the modality for this item to \a panelModality. | - |
1976 | | - |
1977 | Changing the modality of a visible item takes effect immediately. | - |
1978 | */ | - |
1979 | void QGraphicsItem::setPanelModality(PanelModality panelModality) | - |
1980 | { | - |
1981 | if (d_ptr->panelModality == panelModality) evaluated: d_ptr->panelModality == panelModality yes Evaluation Count:1 | yes Evaluation Count:3 |
| 1-3 |
1982 | return; executed: return; Execution Count:1 | 1 |
1983 | | - |
1984 | PanelModality previousModality = d_ptr->panelModality; executed (the execution status of this line is deduced): PanelModality previousModality = d_ptr->panelModality; | - |
1985 | bool enterLeaveModal = (isPanel() && d_ptr->scene && isVisible()); partially evaluated: isPanel() yes Evaluation Count:3 | no Evaluation Count:0 |
evaluated: d_ptr->scene yes Evaluation Count:2 | yes Evaluation Count:1 |
partially evaluated: isVisible() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-3 |
1986 | if (enterLeaveModal && panelModality == NonModal) evaluated: enterLeaveModal yes Evaluation Count:2 | yes Evaluation Count:1 |
partially evaluated: panelModality == NonModal no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
1987 | d_ptr->scene->d_func()->leaveModal(this); never executed: d_ptr->scene->d_func()->leaveModal(this); | 0 |
1988 | d_ptr->panelModality = panelModality; executed (the execution status of this line is deduced): d_ptr->panelModality = panelModality; | - |
1989 | if (enterLeaveModal && d_ptr->panelModality != NonModal) evaluated: enterLeaveModal yes Evaluation Count:2 | yes Evaluation Count:1 |
partially evaluated: d_ptr->panelModality != NonModal yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
1990 | d_ptr->scene->d_func()->enterModal(this, previousModality); executed: d_ptr->scene->d_func()->enterModal(this, previousModality); Execution Count:2 | 2 |
1991 | } executed: } Execution Count:3 | 3 |
1992 | | - |
1993 | /*! | - |
1994 | \since 4.6 | - |
1995 | | - |
1996 | Returns true if this item is blocked by a modal panel, false otherwise. If \a blockingPanel is | - |
1997 | non-zero, \a blockingPanel will be set to the modal panel that is blocking this item. If this | - |
1998 | item is not blocked, \a blockingPanel will not be set by this function. | - |
1999 | | - |
2000 | This function always returns false for items not in a scene. | - |
2001 | | - |
2002 | \sa panelModality(), setPanelModality(), PanelModality | - |
2003 | */ | - |
2004 | bool QGraphicsItem::isBlockedByModalPanel(QGraphicsItem **blockingPanel) const | - |
2005 | { | - |
2006 | if (!d_ptr->scene) partially evaluated: !d_ptr->scene no Evaluation Count:0 | yes Evaluation Count:335 |
| 0-335 |
2007 | return false; never executed: return false; | 0 |
2008 | | - |
2009 | | - |
2010 | QGraphicsItem *dummy = 0; executed (the execution status of this line is deduced): QGraphicsItem *dummy = 0; | - |
2011 | if (!blockingPanel) evaluated: !blockingPanel yes Evaluation Count:191 | yes Evaluation Count:144 |
| 144-191 |
2012 | blockingPanel = &dummy; executed: blockingPanel = &dummy; Execution Count:191 | 191 |
2013 | | - |
2014 | QGraphicsScenePrivate *scene_d = d_ptr->scene->d_func(); executed (the execution status of this line is deduced): QGraphicsScenePrivate *scene_d = d_ptr->scene->d_func(); | - |
2015 | if (scene_d->modalPanels.isEmpty()) evaluated: scene_d->modalPanels.isEmpty() yes Evaluation Count:327 | yes Evaluation Count:8 |
| 8-327 |
2016 | return false; executed: return false; Execution Count:327 | 327 |
2017 | | - |
2018 | // ### | - |
2019 | if (!scene_d->popupWidgets.isEmpty() && scene_d->popupWidgets.first() == this) partially evaluated: !scene_d->popupWidgets.isEmpty() no Evaluation Count:0 | yes Evaluation Count:8 |
never evaluated: scene_d->popupWidgets.first() == this | 0-8 |
2020 | return false; never executed: return false; | 0 |
2021 | | - |
2022 | for (int i = 0; i < scene_d->modalPanels.count(); ++i) { evaluated: i < scene_d->modalPanels.count() yes Evaluation Count:8 | yes Evaluation Count:5 |
| 5-8 |
2023 | QGraphicsItem *modalPanel = scene_d->modalPanels.at(i); executed (the execution status of this line is deduced): QGraphicsItem *modalPanel = scene_d->modalPanels.at(i); | - |
2024 | if (modalPanel->panelModality() == QGraphicsItem::SceneModal) { evaluated: modalPanel->panelModality() == QGraphicsItem::SceneModal yes Evaluation Count:2 | yes Evaluation Count:6 |
| 2-6 |
2025 | // Scene modal panels block all non-descendents. | - |
2026 | if (modalPanel != this && !modalPanel->isAncestorOf(this)) { evaluated: modalPanel != this yes Evaluation Count:1 | yes Evaluation Count:1 |
partially evaluated: !modalPanel->isAncestorOf(this) yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
2027 | *blockingPanel = modalPanel; executed (the execution status of this line is deduced): *blockingPanel = modalPanel; | - |
2028 | return true; executed: return true; Execution Count:1 | 1 |
2029 | } | - |
2030 | } else { executed: } Execution Count:1 | 1 |
2031 | // Window modal panels block ancestors and siblings/cousins. | - |
2032 | if (modalPanel != this evaluated: modalPanel != this yes Evaluation Count:3 | yes Evaluation Count:3 |
| 3 |
2033 | && !modalPanel->isAncestorOf(this) partially evaluated: !modalPanel->isAncestorOf(this) yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
2034 | && commonAncestorItem(modalPanel)) { evaluated: commonAncestorItem(modalPanel) yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
2035 | *blockingPanel = modalPanel; executed (the execution status of this line is deduced): *blockingPanel = modalPanel; | - |
2036 | return true; executed: return true; Execution Count:2 | 2 |
2037 | } | - |
2038 | } executed: } Execution Count:4 | 4 |
2039 | } | - |
2040 | return false; executed: return false; Execution Count:5 | 5 |
2041 | } | - |
2042 | | - |
2043 | #ifndef QT_NO_TOOLTIP | - |
2044 | /*! | - |
2045 | Returns the item's tool tip, or an empty QString if no tool tip has been | - |
2046 | set. | - |
2047 | | - |
2048 | \sa setToolTip(), QToolTip | - |
2049 | */ | - |
2050 | QString QGraphicsItem::toolTip() const | - |
2051 | { | - |
2052 | return d_ptr->extra(QGraphicsItemPrivate::ExtraToolTip).toString(); never executed: return d_ptr->extra(QGraphicsItemPrivate::ExtraToolTip).toString(); | 0 |
2053 | } | - |
2054 | | - |
2055 | /*! | - |
2056 | Sets the item's tool tip to \a toolTip. If \a toolTip is empty, the item's | - |
2057 | tool tip is cleared. | - |
2058 | | - |
2059 | \sa toolTip(), QToolTip | - |
2060 | */ | - |
2061 | void QGraphicsItem::setToolTip(const QString &toolTip) | - |
2062 | { | - |
2063 | const QVariant toolTipVariant(itemChange(ItemToolTipChange, toolTip)); executed (the execution status of this line is deduced): const QVariant toolTipVariant(itemChange(ItemToolTipChange, toolTip)); | - |
2064 | d_ptr->setExtra(QGraphicsItemPrivate::ExtraToolTip, toolTipVariant.toString()); executed (the execution status of this line is deduced): d_ptr->setExtra(QGraphicsItemPrivate::ExtraToolTip, toolTipVariant.toString()); | - |
2065 | itemChange(ItemToolTipHasChanged, toolTipVariant); executed (the execution status of this line is deduced): itemChange(ItemToolTipHasChanged, toolTipVariant); | - |
2066 | } executed: } Execution Count:52 | 52 |
2067 | #endif // QT_NO_TOOLTIP | - |
2068 | | - |
2069 | #ifndef QT_NO_CURSOR | - |
2070 | /*! | - |
2071 | Returns the current cursor shape for the item. The mouse cursor | - |
2072 | will assume this shape when it's over this item. | - |
2073 | See the \l{Qt::CursorShape}{list of predefined cursor objects} for a | - |
2074 | range of useful shapes. | - |
2075 | | - |
2076 | An editor item might want to use an I-beam cursor: | - |
2077 | | - |
2078 | \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 2 | - |
2079 | | - |
2080 | If no cursor has been set, the cursor of the item beneath is used. | - |
2081 | | - |
2082 | \sa setCursor(), hasCursor(), unsetCursor(), QWidget::cursor, | - |
2083 | QApplication::overrideCursor() | - |
2084 | */ | - |
2085 | QCursor QGraphicsItem::cursor() const | - |
2086 | { | - |
2087 | return qvariant_cast<QCursor>(d_ptr->extra(QGraphicsItemPrivate::ExtraCursor)); never executed: return qvariant_cast<QCursor>(d_ptr->extra(QGraphicsItemPrivate::ExtraCursor)); | 0 |
2088 | } | - |
2089 | | - |
2090 | /*! | - |
2091 | Sets the current cursor shape for the item to \a cursor. The mouse cursor | - |
2092 | will assume this shape when it's over this item. | - |
2093 | See the \l{Qt::CursorShape}{list of predefined cursor objects} for a | - |
2094 | range of useful shapes. | - |
2095 | | - |
2096 | An editor item might want to use an I-beam cursor: | - |
2097 | | - |
2098 | \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 3 | - |
2099 | | - |
2100 | If no cursor has been set, the cursor of the item beneath is used. | - |
2101 | | - |
2102 | \sa cursor(), hasCursor(), unsetCursor(), QWidget::cursor, | - |
2103 | QApplication::overrideCursor() | - |
2104 | */ | - |
2105 | void QGraphicsItem::setCursor(const QCursor &cursor) | - |
2106 | { | - |
2107 | const QVariant cursorVariant(itemChange(ItemCursorChange, QVariant::fromValue<QCursor>(cursor))); never executed (the execution status of this line is deduced): const QVariant cursorVariant(itemChange(ItemCursorChange, QVariant::fromValue<QCursor>(cursor))); | - |
2108 | d_ptr->setExtra(QGraphicsItemPrivate::ExtraCursor, qvariant_cast<QCursor>(cursorVariant)); never executed (the execution status of this line is deduced): d_ptr->setExtra(QGraphicsItemPrivate::ExtraCursor, qvariant_cast<QCursor>(cursorVariant)); | - |
2109 | d_ptr->hasCursor = 1; never executed (the execution status of this line is deduced): d_ptr->hasCursor = 1; | - |
2110 | if (d_ptr->scene) { never evaluated: d_ptr->scene | 0 |
2111 | d_ptr->scene->d_func()->allItemsUseDefaultCursor = false; never executed (the execution status of this line is deduced): d_ptr->scene->d_func()->allItemsUseDefaultCursor = false; | - |
2112 | foreach (QGraphicsView *view, d_ptr->scene->views()) { never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(d_ptr->scene->views())> _container_(d_ptr->scene->views()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsView *view = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
2113 | view->viewport()->setMouseTracking(true); never executed (the execution status of this line is deduced): view->viewport()->setMouseTracking(true); | - |
2114 | // Note: Some of this logic is duplicated in QGraphicsView's mouse events. | - |
2115 | if (view->underMouse()) { never evaluated: view->underMouse() | 0 |
2116 | foreach (QGraphicsItem *itemUnderCursor, view->items(view->mapFromGlobal(QCursor::pos()))) { never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(view->items(view->mapFromGlobal(QCursor::pos())))> _container_(view->items(view->mapFromGlobal(QCursor::pos()))); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *itemUnderCursor = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
2117 | if (itemUnderCursor->hasCursor()) { never evaluated: itemUnderCursor->hasCursor() | 0 |
2118 | QMetaObject::invokeMethod(view, "_q_setViewportCursor", never executed (the execution status of this line is deduced): QMetaObject::invokeMethod(view, "_q_setViewportCursor", | - |
2119 | Q_ARG(QCursor, itemUnderCursor->cursor())); never executed (the execution status of this line is deduced): QArgument<QCursor >("QCursor", itemUnderCursor->cursor())); | - |
2120 | break; | 0 |
2121 | } | - |
2122 | } | 0 |
2123 | break; | 0 |
2124 | } | - |
2125 | } | 0 |
2126 | } | 0 |
2127 | itemChange(ItemCursorHasChanged, cursorVariant); never executed (the execution status of this line is deduced): itemChange(ItemCursorHasChanged, cursorVariant); | - |
2128 | } | 0 |
2129 | | - |
2130 | /*! | - |
2131 | Returns true if this item has a cursor set; otherwise, false is returned. | - |
2132 | | - |
2133 | By default, items don't have any cursor set. cursor() will return a | - |
2134 | standard pointing arrow cursor. | - |
2135 | | - |
2136 | \sa unsetCursor() | - |
2137 | */ | - |
2138 | bool QGraphicsItem::hasCursor() const | - |
2139 | { | - |
2140 | return d_ptr->hasCursor; never executed: return d_ptr->hasCursor; | 0 |
2141 | } | - |
2142 | | - |
2143 | /*! | - |
2144 | Clears the cursor from this item. | - |
2145 | | - |
2146 | \sa hasCursor(), setCursor() | - |
2147 | */ | - |
2148 | void QGraphicsItem::unsetCursor() | - |
2149 | { | - |
2150 | d_ptr->unsetExtra(QGraphicsItemPrivate::ExtraCursor); never executed (the execution status of this line is deduced): d_ptr->unsetExtra(QGraphicsItemPrivate::ExtraCursor); | - |
2151 | d_ptr->hasCursor = 0; never executed (the execution status of this line is deduced): d_ptr->hasCursor = 0; | - |
2152 | if (d_ptr->scene) { never evaluated: d_ptr->scene | 0 |
2153 | foreach (QGraphicsView *view, d_ptr->scene->views()) { never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(d_ptr->scene->views())> _container_(d_ptr->scene->views()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsView *view = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
2154 | if (view->underMouse() && view->itemAt(view->mapFromGlobal(QCursor::pos())) == this) { never evaluated: view->underMouse() never evaluated: view->itemAt(view->mapFromGlobal(QCursor::pos())) == this | 0 |
2155 | QMetaObject::invokeMethod(view, "_q_unsetViewportCursor"); never executed (the execution status of this line is deduced): QMetaObject::invokeMethod(view, "_q_unsetViewportCursor"); | - |
2156 | break; | 0 |
2157 | } | - |
2158 | } | 0 |
2159 | } | 0 |
2160 | } | 0 |
2161 | | - |
2162 | #endif // QT_NO_CURSOR | - |
2163 | | - |
2164 | /*! | - |
2165 | Returns true if the item is visible; otherwise, false is returned. | - |
2166 | | - |
2167 | Note that the item's general visibility is unrelated to whether or not it | - |
2168 | is actually being visualized by a QGraphicsView. | - |
2169 | | - |
2170 | \sa setVisible() | - |
2171 | */ | - |
2172 | bool QGraphicsItem::isVisible() const | - |
2173 | { | - |
2174 | return d_ptr->visible; executed: return d_ptr->visible; Execution Count:1467 | 1467 |
2175 | } | - |
2176 | | - |
2177 | /*! | - |
2178 | \since 4.4 | - |
2179 | Returns true if the item is visible to \a parent; otherwise, false is | - |
2180 | returned. \a parent can be 0, in which case this function will return | - |
2181 | whether the item is visible to the scene or not. | - |
2182 | | - |
2183 | An item may not be visible to its ancestors even if isVisible() is true. It | - |
2184 | may also be visible to its ancestors even if isVisible() is false. If | - |
2185 | any ancestor is hidden, the item itself will be implicitly hidden, in which | - |
2186 | case this function will return false. | - |
2187 | | - |
2188 | \sa isVisible(), setVisible() | - |
2189 | */ | - |
2190 | bool QGraphicsItem::isVisibleTo(const QGraphicsItem *parent) const | - |
2191 | { | - |
2192 | const QGraphicsItem *p = this; never executed (the execution status of this line is deduced): const QGraphicsItem *p = this; | - |
2193 | if (d_ptr->explicitlyHidden) never evaluated: d_ptr->explicitlyHidden | 0 |
2194 | return false; never executed: return false; | 0 |
2195 | do { | - |
2196 | if (p == parent) never evaluated: p == parent | 0 |
2197 | return true; never executed: return true; | 0 |
2198 | if (p->d_ptr->explicitlyHidden) never evaluated: p->d_ptr->explicitlyHidden | 0 |
2199 | return false; never executed: return false; | 0 |
2200 | } while ((p = p->d_ptr->parent)); never executed: } never evaluated: (p = p->d_ptr->parent) | 0 |
2201 | return parent == 0; never executed: return parent == 0; | 0 |
2202 | } | - |
2203 | | - |
2204 | /*! | - |
2205 | \internal | - |
2206 | | - |
2207 | Sets this item's visibility to \a newVisible. If \a explicitly is true, | - |
2208 | this item will be "explicitly" \a newVisible; otherwise, it.. will not be. | - |
2209 | */ | - |
2210 | void QGraphicsItemPrivate::setVisibleHelper(bool newVisible, bool explicitly, | - |
2211 | bool update, bool hiddenByPanel) | - |
2212 | { | - |
2213 | Q_Q(QGraphicsItem); executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func(); | - |
2214 | | - |
2215 | // Update explicit bit. | - |
2216 | if (explicitly) evaluated: explicitly yes Evaluation Count:141 | yes Evaluation Count:2 |
| 2-141 |
2217 | explicitlyHidden = newVisible ? 0 : 1; executed: explicitlyHidden = newVisible ? 0 : 1; Execution Count:141 evaluated: newVisible yes Evaluation Count:137 | yes Evaluation Count:4 |
| 4-141 |
2218 | | - |
2219 | // Check if there's nothing to do. | - |
2220 | if (visible == quint32(newVisible)) evaluated: visible == quint32(newVisible) yes Evaluation Count:135 | yes Evaluation Count:8 |
| 8-135 |
2221 | return; executed: return; Execution Count:135 | 135 |
2222 | | - |
2223 | // Don't show child if parent is not visible | - |
2224 | if (parent && newVisible && !parent->d_ptr->visible) evaluated: parent yes Evaluation Count:4 | yes Evaluation Count:4 |
evaluated: newVisible yes Evaluation Count:2 | yes Evaluation Count:2 |
partially evaluated: !parent->d_ptr->visible no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-4 |
2225 | return; | 0 |
2226 | | - |
2227 | // Modify the property. | - |
2228 | const QVariant newVisibleVariant(q_ptr->itemChange(QGraphicsItem::ItemVisibleChange, executed (the execution status of this line is deduced): const QVariant newVisibleVariant(q_ptr->itemChange(QGraphicsItem::ItemVisibleChange, | - |
2229 | quint32(newVisible))); executed (the execution status of this line is deduced): quint32(newVisible))); | - |
2230 | newVisible = newVisibleVariant.toBool(); executed (the execution status of this line is deduced): newVisible = newVisibleVariant.toBool(); | - |
2231 | if (visible == quint32(newVisible)) partially evaluated: visible == quint32(newVisible) no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
2232 | return; | 0 |
2233 | visible = newVisible; executed (the execution status of this line is deduced): visible = newVisible; | - |
2234 | | - |
2235 | // Schedule redrawing | - |
2236 | if (update) { partially evaluated: update yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
2237 | QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData)); executed (the execution status of this line is deduced): QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData)); | - |
2238 | if (c) partially evaluated: c no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
2239 | c->purge(); never executed: c->purge(); | 0 |
2240 | if (scene) { evaluated: scene yes Evaluation Count:5 | yes Evaluation Count:3 |
| 3-5 |
2241 | #ifndef QT_NO_GRAPHICSEFFECT | - |
2242 | invalidateParentGraphicsEffectsRecursively(); executed (the execution status of this line is deduced): invalidateParentGraphicsEffectsRecursively(); | - |
2243 | #endif //QT_NO_GRAPHICSEFFECT | - |
2244 | scene->d_func()->markDirty(q_ptr, QRectF(), /*invalidateChildren=*/false, /*force=*/true); executed (the execution status of this line is deduced): scene->d_func()->markDirty(q_ptr, QRectF(), false, true); | - |
2245 | } executed: } Execution Count:5 | 5 |
2246 | } executed: } Execution Count:8 | 8 |
2247 | | - |
2248 | // Certain properties are dropped as an item becomes invisible. | - |
2249 | bool hasFocus = q_ptr->hasFocus(); executed (the execution status of this line is deduced): bool hasFocus = q_ptr->hasFocus(); | - |
2250 | if (!newVisible) { evaluated: !newVisible yes Evaluation Count:4 | yes Evaluation Count:4 |
| 4 |
2251 | if (scene) { evaluated: scene yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
2252 | if (scene->d_func()->mouseGrabberItems.contains(q)) partially evaluated: scene->d_func()->mouseGrabberItems.contains(q) no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
2253 | q->ungrabMouse(); never executed: q->ungrabMouse(); | 0 |
2254 | if (scene->d_func()->keyboardGrabberItems.contains(q)) partially evaluated: scene->d_func()->keyboardGrabberItems.contains(q) no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
2255 | q->ungrabKeyboard(); never executed: q->ungrabKeyboard(); | 0 |
2256 | if (q->isPanel() && panelModality != QGraphicsItem::NonModal) partially evaluated: q->isPanel() no Evaluation Count:0 | yes Evaluation Count:2 |
never evaluated: panelModality != QGraphicsItem::NonModal | 0-2 |
2257 | scene->d_func()->leaveModal(q_ptr); never executed: scene->d_func()->leaveModal(q_ptr); | 0 |
2258 | } executed: } Execution Count:2 | 2 |
2259 | if (hasFocus && scene) { partially evaluated: hasFocus no Evaluation Count:0 | yes Evaluation Count:4 |
never evaluated: scene | 0-4 |
2260 | // Hiding the closest non-panel ancestor of the focus item | - |
2261 | QGraphicsItem *focusItem = scene->focusItem(); never executed (the execution status of this line is deduced): QGraphicsItem *focusItem = scene->focusItem(); | - |
2262 | bool clear = true; never executed (the execution status of this line is deduced): bool clear = true; | - |
2263 | if (isWidget && !focusItem->isPanel()) { never evaluated: isWidget never evaluated: !focusItem->isPanel() | 0 |
2264 | do { | - |
2265 | if (focusItem == q_ptr) { never evaluated: focusItem == q_ptr | 0 |
2266 | clear = !static_cast<QGraphicsWidget *>(q_ptr)->focusNextPrevChild(true); never executed (the execution status of this line is deduced): clear = !static_cast<QGraphicsWidget *>(q_ptr)->focusNextPrevChild(true); | - |
2267 | break; | 0 |
2268 | } | - |
2269 | } while ((focusItem = focusItem->parentWidget()) && !focusItem->isPanel()); never executed: } never evaluated: (focusItem = focusItem->parentWidget()) never evaluated: !focusItem->isPanel() | 0 |
2270 | } | 0 |
2271 | if (clear) | 0 |
2272 | clearFocusHelper(/* giveFocusToParent = */ false, hiddenByPanel); never executed: clearFocusHelper( false, hiddenByPanel); | 0 |
2273 | } | 0 |
2274 | if (q_ptr->isSelected()) partially evaluated: q_ptr->isSelected() no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
2275 | q_ptr->setSelected(false); never executed: q_ptr->setSelected(false); | 0 |
2276 | } else { executed: } Execution Count:4 | 4 |
2277 | geometryChanged = 1; executed (the execution status of this line is deduced): geometryChanged = 1; | - |
2278 | paintedViewBoundingRectsNeedRepaint = 1; executed (the execution status of this line is deduced): paintedViewBoundingRectsNeedRepaint = 1; | - |
2279 | if (scene) { evaluated: scene yes Evaluation Count:3 | yes Evaluation Count:1 |
| 1-3 |
2280 | if (isWidget) { partially evaluated: isWidget yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
2281 | QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(q_ptr); executed (the execution status of this line is deduced): QGraphicsWidget *widget = static_cast<QGraphicsWidget *>(q_ptr); | - |
2282 | if (widget->windowType() == Qt::Popup) partially evaluated: widget->windowType() == Qt::Popup no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
2283 | scene->d_func()->addPopup(widget); never executed: scene->d_func()->addPopup(widget); | 0 |
2284 | } executed: } Execution Count:3 | 3 |
2285 | if (q->isPanel() && panelModality != QGraphicsItem::NonModal) { partially evaluated: q->isPanel() no Evaluation Count:0 | yes Evaluation Count:3 |
never evaluated: panelModality != QGraphicsItem::NonModal | 0-3 |
2286 | scene->d_func()->enterModal(q_ptr); never executed (the execution status of this line is deduced): scene->d_func()->enterModal(q_ptr); | - |
2287 | } | 0 |
2288 | } executed: } Execution Count:3 | 3 |
2289 | } executed: } Execution Count:4 | 4 |
2290 | | - |
2291 | // Update children with explicitly = false. | - |
2292 | const bool updateChildren = update && !((flags & QGraphicsItem::ItemClipsChildrenToShape) partially evaluated: update yes Evaluation Count:8 | no Evaluation Count:0 |
partially evaluated: (flags & QGraphicsItem::ItemClipsChildrenToShape) no Evaluation Count:0 | yes Evaluation Count:8 |
| 0-8 |
2293 | && !(flags & QGraphicsItem::ItemHasNoContents)); never evaluated: !(flags & QGraphicsItem::ItemHasNoContents) | 0 |
2294 | foreach (QGraphicsItem *child, children) { executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(children)> _container_(children); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *child = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
2295 | if (!newVisible || !child->d_ptr->explicitlyHidden) evaluated: !newVisible yes Evaluation Count:1 | yes Evaluation Count:1 |
partially evaluated: !child->d_ptr->explicitlyHidden yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
2296 | child->d_ptr->setVisibleHelper(newVisible, false, updateChildren, hiddenByPanel); executed: child->d_ptr->setVisibleHelper(newVisible, false, updateChildren, hiddenByPanel); Execution Count:2 | 2 |
2297 | } executed: } Execution Count:2 | 2 |
2298 | | - |
2299 | // Update activation | - |
2300 | if (scene && q->isPanel()) { evaluated: scene yes Evaluation Count:5 | yes Evaluation Count:3 |
partially evaluated: q->isPanel() no Evaluation Count:0 | yes Evaluation Count:5 |
| 0-5 |
2301 | if (newVisible) { never evaluated: newVisible | 0 |
2302 | if (parent && parent->isActive()) never evaluated: parent never evaluated: parent->isActive() | 0 |
2303 | q->setActive(true); never executed: q->setActive(true); | 0 |
2304 | } else { | 0 |
2305 | if (q->isActive()) never evaluated: q->isActive() | 0 |
2306 | scene->setActivePanel(parent); never executed: scene->setActivePanel(parent); | 0 |
2307 | } | 0 |
2308 | } | - |
2309 | | - |
2310 | // Enable subfocus | - |
2311 | if (scene) { evaluated: scene yes Evaluation Count:5 | yes Evaluation Count:3 |
| 3-5 |
2312 | if (newVisible) { evaluated: newVisible yes Evaluation Count:3 | yes Evaluation Count:2 |
| 2-3 |
2313 | // Item is shown | - |
2314 | QGraphicsItem *p = parent; executed (the execution status of this line is deduced): QGraphicsItem *p = parent; | - |
2315 | bool done = false; executed (the execution status of this line is deduced): bool done = false; | - |
2316 | while (p) { evaluated: p yes Evaluation Count:2 | yes Evaluation Count:3 |
| 2-3 |
2317 | if (p->flags() & QGraphicsItem::ItemIsFocusScope) { partially evaluated: p->flags() & QGraphicsItem::ItemIsFocusScope no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
2318 | QGraphicsItem *fsi = p->d_ptr->focusScopeItem; never executed (the execution status of this line is deduced): QGraphicsItem *fsi = p->d_ptr->focusScopeItem; | - |
2319 | if (q_ptr == fsi || q_ptr->isAncestorOf(fsi)) { never evaluated: q_ptr == fsi never evaluated: q_ptr->isAncestorOf(fsi) | 0 |
2320 | done = true; never executed (the execution status of this line is deduced): done = true; | - |
2321 | while (fsi->d_ptr->focusScopeItem && fsi->d_ptr->focusScopeItem->isVisible()) never evaluated: fsi->d_ptr->focusScopeItem never evaluated: fsi->d_ptr->focusScopeItem->isVisible() | 0 |
2322 | fsi = fsi->d_ptr->focusScopeItem; never executed: fsi = fsi->d_ptr->focusScopeItem; | 0 |
2323 | fsi->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ true, never executed (the execution status of this line is deduced): fsi->d_ptr->setFocusHelper(Qt::OtherFocusReason, true, | - |
2324 | /* focusFromHide = */ false); never executed (the execution status of this line is deduced): false); | - |
2325 | } | 0 |
2326 | break; | 0 |
2327 | } | - |
2328 | p = p->d_ptr->parent; executed (the execution status of this line is deduced): p = p->d_ptr->parent; | - |
2329 | } executed: } Execution Count:2 | 2 |
2330 | if (!done) { partially evaluated: !done yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
2331 | QGraphicsItem *fi = subFocusItem; executed (the execution status of this line is deduced): QGraphicsItem *fi = subFocusItem; | - |
2332 | if (fi && fi != scene->focusItem()) { partially evaluated: fi no Evaluation Count:0 | yes Evaluation Count:3 |
never evaluated: fi != scene->focusItem() | 0-3 |
2333 | scene->setFocusItem(fi); never executed (the execution status of this line is deduced): scene->setFocusItem(fi); | - |
2334 | } else if (flags & QGraphicsItem::ItemIsFocusScope && never executed: } partially evaluated: flags & QGraphicsItem::ItemIsFocusScope no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
2335 | !scene->focusItem() && never evaluated: !scene->focusItem() | 0 |
2336 | q->isAncestorOf(scene->d_func()->lastFocusItem)) { never evaluated: q->isAncestorOf(scene->d_func()->lastFocusItem) | 0 |
2337 | q_ptr->setFocus(); never executed (the execution status of this line is deduced): q_ptr->setFocus(); | - |
2338 | } | 0 |
2339 | } | - |
2340 | } else { executed: } Execution Count:3 | 3 |
2341 | // Item is hidden | - |
2342 | if (hasFocus) { partially evaluated: hasFocus no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
2343 | QGraphicsItem *p = parent; never executed (the execution status of this line is deduced): QGraphicsItem *p = parent; | - |
2344 | while (p) { | 0 |
2345 | if (p->flags() & QGraphicsItem::ItemIsFocusScope) { never evaluated: p->flags() & QGraphicsItem::ItemIsFocusScope | 0 |
2346 | if (p->d_ptr->visible) { never evaluated: p->d_ptr->visible | 0 |
2347 | p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ true, never executed (the execution status of this line is deduced): p->d_ptr->setFocusHelper(Qt::OtherFocusReason, true, | - |
2348 | /* focusFromHide = */ true); never executed (the execution status of this line is deduced): true); | - |
2349 | } | 0 |
2350 | break; | 0 |
2351 | } | - |
2352 | p = p->d_ptr->parent; never executed (the execution status of this line is deduced): p = p->d_ptr->parent; | - |
2353 | } | 0 |
2354 | } | 0 |
2355 | } executed: } Execution Count:2 | 2 |
2356 | } | - |
2357 | | - |
2358 | // Deliver post-change notification. | - |
2359 | q_ptr->itemChange(QGraphicsItem::ItemVisibleHasChanged, newVisibleVariant); executed (the execution status of this line is deduced): q_ptr->itemChange(QGraphicsItem::ItemVisibleHasChanged, newVisibleVariant); | - |
2360 | | - |
2361 | if (isObject) partially evaluated: isObject yes Evaluation Count:8 | no Evaluation Count:0 |
| 0-8 |
2362 | emit static_cast<QGraphicsObject *>(q_ptr)->visibleChanged(); executed: static_cast<QGraphicsObject *>(q_ptr)->visibleChanged(); Execution Count:8 | 8 |
2363 | } executed: } Execution Count:8 | 8 |
2364 | | - |
2365 | /*! | - |
2366 | If \a visible is true, the item is made visible. Otherwise, the item is | - |
2367 | made invisible. Invisible items are not painted, nor do they receive any | - |
2368 | events. In particular, mouse events pass right through invisible items, | - |
2369 | and are delivered to any item that may be behind. Invisible items are also | - |
2370 | unselectable, they cannot take input focus, and are not detected by | - |
2371 | QGraphicsScene's item location functions. | - |
2372 | | - |
2373 | If an item becomes invisible while grabbing the mouse, (i.e., while it is | - |
2374 | receiving mouse events,) it will automatically lose the mouse grab, and | - |
2375 | the grab is not regained by making the item visible again; it must receive | - |
2376 | a new mouse press to regain the mouse grab. | - |
2377 | | - |
2378 | Similarly, an invisible item cannot have focus, so if the item has focus | - |
2379 | when it becomes invisible, it will lose focus, and the focus is not | - |
2380 | regained by simply making the item visible again. | - |
2381 | | - |
2382 | If you hide a parent item, all its children will also be hidden. If you | - |
2383 | show a parent item, all children will be shown, unless they have been | - |
2384 | explicitly hidden (i.e., if you call setVisible(false) on a child, it will | - |
2385 | not be reshown even if its parent is hidden, and then shown again). | - |
2386 | | - |
2387 | Items are visible by default; it is unnecessary to call | - |
2388 | setVisible() on a new item. | - |
2389 | | - |
2390 | \sa isVisible(), show(), hide() | - |
2391 | */ | - |
2392 | void QGraphicsItem::setVisible(bool visible) | - |
2393 | { | - |
2394 | d_ptr->setVisibleHelper(visible, executed (the execution status of this line is deduced): d_ptr->setVisibleHelper(visible, | - |
2395 | /* explicit = */ true, executed (the execution status of this line is deduced): true, | - |
2396 | /* update = */ true, executed (the execution status of this line is deduced): true, | - |
2397 | /* hiddenByPanel = */ isPanel()); executed (the execution status of this line is deduced): isPanel()); | - |
2398 | } executed: } Execution Count:141 | 141 |
2399 | | - |
2400 | /*! | - |
2401 | \fn void QGraphicsItem::hide() | - |
2402 | | - |
2403 | Hides the item (items are visible by default). | - |
2404 | | - |
2405 | This convenience function is equivalent to calling \c setVisible(false). | - |
2406 | | - |
2407 | \sa show(), setVisible() | - |
2408 | */ | - |
2409 | | - |
2410 | /*! | - |
2411 | \fn void QGraphicsItem::show() | - |
2412 | | - |
2413 | Shows the item (items are visible by default). | - |
2414 | | - |
2415 | This convenience function is equivalent to calling \c setVisible(true). | - |
2416 | | - |
2417 | \sa hide(), setVisible() | - |
2418 | */ | - |
2419 | | - |
2420 | /*! | - |
2421 | Returns true if the item is enabled; otherwise, false is returned. | - |
2422 | | - |
2423 | \sa setEnabled() | - |
2424 | */ | - |
2425 | bool QGraphicsItem::isEnabled() const | - |
2426 | { | - |
2427 | return d_ptr->enabled; executed: return d_ptr->enabled; Execution Count:1895 | 1895 |
2428 | } | - |
2429 | | - |
2430 | /*! | - |
2431 | \internal | - |
2432 | | - |
2433 | Sets this item's visibility to \a newEnabled. If \a explicitly is true, | - |
2434 | this item will be "explicitly" \a newEnabled; otherwise, it.. will not be. | - |
2435 | */ | - |
2436 | void QGraphicsItemPrivate::setEnabledHelper(bool newEnabled, bool explicitly, bool update) | - |
2437 | { | - |
2438 | // Update explicit bit. | - |
2439 | if (explicitly) partially evaluated: explicitly yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
2440 | explicitlyDisabled = newEnabled ? 0 : 1; executed: explicitlyDisabled = newEnabled ? 0 : 1; Execution Count:6 evaluated: newEnabled yes Evaluation Count:4 | yes Evaluation Count:2 |
| 2-6 |
2441 | | - |
2442 | // Check if there's nothing to do. | - |
2443 | if (enabled == quint32(newEnabled)) evaluated: enabled == quint32(newEnabled) yes Evaluation Count:4 | yes Evaluation Count:2 |
| 2-4 |
2444 | return; executed: return; Execution Count:4 | 4 |
2445 | | - |
2446 | // Certain properties are dropped when an item is disabled. | - |
2447 | if (!newEnabled) { evaluated: !newEnabled yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
2448 | if (scene && scene->mouseGrabberItem() == q_ptr) partially evaluated: scene no Evaluation Count:0 | yes Evaluation Count:1 |
never evaluated: scene->mouseGrabberItem() == q_ptr | 0-1 |
2449 | q_ptr->ungrabMouse(); never executed: q_ptr->ungrabMouse(); | 0 |
2450 | if (q_ptr->hasFocus()) { partially evaluated: q_ptr->hasFocus() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
2451 | // Disabling the closest non-panel ancestor of the focus item | - |
2452 | // causes focus to pop to the next item, otherwise it's cleared. | - |
2453 | QGraphicsItem *focusItem = scene->focusItem(); never executed (the execution status of this line is deduced): QGraphicsItem *focusItem = scene->focusItem(); | - |
2454 | bool clear = true; never executed (the execution status of this line is deduced): bool clear = true; | - |
2455 | if (isWidget && !focusItem->isPanel() && q_ptr->isAncestorOf(focusItem)) { never evaluated: isWidget never evaluated: !focusItem->isPanel() never evaluated: q_ptr->isAncestorOf(focusItem) | 0 |
2456 | do { | - |
2457 | if (focusItem == q_ptr) { never evaluated: focusItem == q_ptr | 0 |
2458 | clear = !static_cast<QGraphicsWidget *>(q_ptr)->focusNextPrevChild(true); never executed (the execution status of this line is deduced): clear = !static_cast<QGraphicsWidget *>(q_ptr)->focusNextPrevChild(true); | - |
2459 | break; | 0 |
2460 | } | - |
2461 | } while ((focusItem = focusItem->parentWidget()) && !focusItem->isPanel()); never executed: } never evaluated: (focusItem = focusItem->parentWidget()) never evaluated: !focusItem->isPanel() | 0 |
2462 | } | 0 |
2463 | if (clear) | 0 |
2464 | q_ptr->clearFocus(); never executed: q_ptr->clearFocus(); | 0 |
2465 | } | 0 |
2466 | if (q_ptr->isSelected()) partially evaluated: q_ptr->isSelected() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
2467 | q_ptr->setSelected(false); never executed: q_ptr->setSelected(false); | 0 |
2468 | } executed: } Execution Count:1 | 1 |
2469 | | - |
2470 | // Modify the property. | - |
2471 | const QVariant newEnabledVariant(q_ptr->itemChange(QGraphicsItem::ItemEnabledChange, executed (the execution status of this line is deduced): const QVariant newEnabledVariant(q_ptr->itemChange(QGraphicsItem::ItemEnabledChange, | - |
2472 | quint32(newEnabled))); executed (the execution status of this line is deduced): quint32(newEnabled))); | - |
2473 | enabled = newEnabledVariant.toBool(); executed (the execution status of this line is deduced): enabled = newEnabledVariant.toBool(); | - |
2474 | | - |
2475 | // Schedule redraw. | - |
2476 | if (update) partially evaluated: update yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
2477 | q_ptr->update(); executed: q_ptr->update(); Execution Count:2 | 2 |
2478 | | - |
2479 | foreach (QGraphicsItem *child, children) { never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(children)> _container_(children); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *child = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
2480 | if (!newEnabled || !child->d_ptr->explicitlyDisabled) never evaluated: !newEnabled never evaluated: !child->d_ptr->explicitlyDisabled | 0 |
2481 | child->d_ptr->setEnabledHelper(newEnabled, /* explicitly = */ false); never executed: child->d_ptr->setEnabledHelper(newEnabled, false); | 0 |
2482 | } | 0 |
2483 | | - |
2484 | // Deliver post-change notification. | - |
2485 | q_ptr->itemChange(QGraphicsItem::ItemEnabledHasChanged, newEnabledVariant); executed (the execution status of this line is deduced): q_ptr->itemChange(QGraphicsItem::ItemEnabledHasChanged, newEnabledVariant); | - |
2486 | | - |
2487 | if (isObject) partially evaluated: isObject yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
2488 | emit static_cast<QGraphicsObject *>(q_ptr)->enabledChanged(); executed: static_cast<QGraphicsObject *>(q_ptr)->enabledChanged(); Execution Count:2 | 2 |
2489 | } executed: } Execution Count:2 | 2 |
2490 | | - |
2491 | /*! | - |
2492 | If \a enabled is true, the item is enabled; otherwise, it is disabled. | - |
2493 | | - |
2494 | Disabled items are visible, but they do not receive any events, and cannot | - |
2495 | take focus nor be selected. Mouse events are discarded; they are not | - |
2496 | propagated unless the item is also invisible, or if it does not accept | - |
2497 | mouse events (see acceptedMouseButtons()). A disabled item cannot become the | - |
2498 | mouse grabber, and as a result of this, an item loses the grab if it | - |
2499 | becomes disabled when grabbing the mouse, just like it loses focus if it | - |
2500 | had focus when it was disabled. | - |
2501 | | - |
2502 | Disabled items are traditionally drawn using grayed-out colors (see \l | - |
2503 | QPalette::Disabled). | - |
2504 | | - |
2505 | If you disable a parent item, all its children will also be disabled. If | - |
2506 | you enable a parent item, all children will be enabled, unless they have | - |
2507 | been explicitly disabled (i.e., if you call setEnabled(false) on a child, | - |
2508 | it will not be reenabled if its parent is disabled, and then enabled | - |
2509 | again). | - |
2510 | | - |
2511 | Items are enabled by default. | - |
2512 | | - |
2513 | \note If you install an event filter, you can still intercept events | - |
2514 | before they are delivered to items; this mechanism disregards the item's | - |
2515 | enabled state. | - |
2516 | | - |
2517 | \sa isEnabled() | - |
2518 | */ | - |
2519 | void QGraphicsItem::setEnabled(bool enabled) | - |
2520 | { | - |
2521 | d_ptr->setEnabledHelper(enabled, /* explicitly = */ true); executed (the execution status of this line is deduced): d_ptr->setEnabledHelper(enabled, true); | - |
2522 | } executed: } Execution Count:6 | 6 |
2523 | | - |
2524 | /*! | - |
2525 | Returns true if this item is selected; otherwise, false is returned. | - |
2526 | | - |
2527 | Items that are in a group inherit the group's selected state. | - |
2528 | | - |
2529 | Items are not selected by default. | - |
2530 | | - |
2531 | \sa setSelected(), QGraphicsScene::setSelectionArea() | - |
2532 | */ | - |
2533 | bool QGraphicsItem::isSelected() const | - |
2534 | { | - |
2535 | if (QGraphicsItemGroup *group = this->group()) partially evaluated: QGraphicsItemGroup *group = this->group() no Evaluation Count:0 | yes Evaluation Count:1037 |
| 0-1037 |
2536 | return group->isSelected(); never executed: return group->isSelected(); | 0 |
2537 | return d_ptr->selected; executed: return d_ptr->selected; Execution Count:1037 | 1037 |
2538 | } | - |
2539 | | - |
2540 | /*! | - |
2541 | If \a selected is true and this item is selectable, this item is selected; | - |
2542 | otherwise, it is unselected. | - |
2543 | | - |
2544 | If the item is in a group, the whole group's selected state is toggled by | - |
2545 | this function. If the group is selected, all items in the group are also | - |
2546 | selected, and if the group is not selected, no item in the group is | - |
2547 | selected. | - |
2548 | | - |
2549 | Only visible, enabled, selectable items can be selected. If \a selected | - |
2550 | is true and this item is either invisible or disabled or unselectable, | - |
2551 | this function does nothing. | - |
2552 | | - |
2553 | By default, items cannot be selected. To enable selection, set the | - |
2554 | ItemIsSelectable flag. | - |
2555 | | - |
2556 | This function is provided for convenience, allowing individual toggling of | - |
2557 | the selected state of an item. However, a more common way of selecting | - |
2558 | items is to call QGraphicsScene::setSelectionArea(), which will call this | - |
2559 | function for all visible, enabled, and selectable items within a specified | - |
2560 | area on the scene. | - |
2561 | | - |
2562 | \sa isSelected(), QGraphicsScene::selectedItems() | - |
2563 | */ | - |
2564 | void QGraphicsItem::setSelected(bool selected) | - |
2565 | { | - |
2566 | if (QGraphicsItemGroup *group = this->group()) { never evaluated: QGraphicsItemGroup *group = this->group() | 0 |
2567 | group->setSelected(selected); never executed (the execution status of this line is deduced): group->setSelected(selected); | - |
2568 | return; | 0 |
2569 | } | - |
2570 | | - |
2571 | if (!(d_ptr->flags & ItemIsSelectable) || !d_ptr->enabled || !d_ptr->visible) never evaluated: !(d_ptr->flags & ItemIsSelectable) never evaluated: !d_ptr->enabled never evaluated: !d_ptr->visible | 0 |
2572 | selected = false; never executed: selected = false; | 0 |
2573 | if (d_ptr->selected == selected) never evaluated: d_ptr->selected == selected | 0 |
2574 | return; | 0 |
2575 | const QVariant newSelectedVariant(itemChange(ItemSelectedChange, quint32(selected))); never executed (the execution status of this line is deduced): const QVariant newSelectedVariant(itemChange(ItemSelectedChange, quint32(selected))); | - |
2576 | bool newSelected = newSelectedVariant.toBool(); never executed (the execution status of this line is deduced): bool newSelected = newSelectedVariant.toBool(); | - |
2577 | if (d_ptr->selected == newSelected) never evaluated: d_ptr->selected == newSelected | 0 |
2578 | return; | 0 |
2579 | d_ptr->selected = newSelected; never executed (the execution status of this line is deduced): d_ptr->selected = newSelected; | - |
2580 | | - |
2581 | update(); never executed (the execution status of this line is deduced): update(); | - |
2582 | if (d_ptr->scene) { never evaluated: d_ptr->scene | 0 |
2583 | QGraphicsScenePrivate *sceneD = d_ptr->scene->d_func(); never executed (the execution status of this line is deduced): QGraphicsScenePrivate *sceneD = d_ptr->scene->d_func(); | - |
2584 | if (selected) { never evaluated: selected | 0 |
2585 | sceneD->selectedItems << this; never executed (the execution status of this line is deduced): sceneD->selectedItems << this; | - |
2586 | } else { | 0 |
2587 | // QGraphicsScene::selectedItems() lazily pulls out all items that are | - |
2588 | // no longer selected. | - |
2589 | } | 0 |
2590 | if (!sceneD->selectionChanging) never evaluated: !sceneD->selectionChanging | 0 |
2591 | emit d_ptr->scene->selectionChanged(); never executed: d_ptr->scene->selectionChanged(); | 0 |
2592 | } | 0 |
2593 | | - |
2594 | // Deliver post-change notification. | - |
2595 | itemChange(QGraphicsItem::ItemSelectedHasChanged, newSelectedVariant); never executed (the execution status of this line is deduced): itemChange(QGraphicsItem::ItemSelectedHasChanged, newSelectedVariant); | - |
2596 | } | 0 |
2597 | | - |
2598 | /*! | - |
2599 | \since 4.5 | - |
2600 | | - |
2601 | Returns this item's local opacity, which is between 0.0 (transparent) and | - |
2602 | 1.0 (opaque). This value is combined with parent and ancestor values into | - |
2603 | the effectiveOpacity(). The effective opacity decides how the item is | - |
2604 | rendered and also affects its visibility when queried by functions such as | - |
2605 | QGraphicsView::items(). | - |
2606 | | - |
2607 | The opacity property decides the state of the painter passed to the | - |
2608 | paint() function. If the item is cached, i.e., ItemCoordinateCache or | - |
2609 | DeviceCoordinateCache, the effective property will be applied to the item's | - |
2610 | cache as it is rendered. | - |
2611 | | - |
2612 | The default opacity is 1.0; fully opaque. | - |
2613 | | - |
2614 | \sa setOpacity(), paint(), ItemIgnoresParentOpacity, | - |
2615 | ItemDoesntPropagateOpacityToChildren | - |
2616 | */ | - |
2617 | qreal QGraphicsItem::opacity() const | - |
2618 | { | - |
2619 | return d_ptr->opacity; executed: return d_ptr->opacity; Execution Count:3 | 3 |
2620 | } | - |
2621 | | - |
2622 | /*! | - |
2623 | \since 4.5 | - |
2624 | | - |
2625 | Returns this item's \e effective opacity, which is between 0.0 | - |
2626 | (transparent) and 1.0 (opaque). This value is a combination of this item's | - |
2627 | local opacity, and its parent and ancestors' opacities. The effective | - |
2628 | opacity decides how the item is rendered. | - |
2629 | | - |
2630 | \sa opacity(), setOpacity(), paint(), ItemIgnoresParentOpacity, | - |
2631 | ItemDoesntPropagateOpacityToChildren | - |
2632 | */ | - |
2633 | qreal QGraphicsItem::effectiveOpacity() const | - |
2634 | { | - |
2635 | return d_ptr->effectiveOpacity(); never executed: return d_ptr->effectiveOpacity(); | 0 |
2636 | } | - |
2637 | | - |
2638 | /*! | - |
2639 | \since 4.5 | - |
2640 | | - |
2641 | Sets this item's local \a opacity, between 0.0 (transparent) and 1.0 | - |
2642 | (opaque). The item's local opacity is combined with parent and ancestor | - |
2643 | opacities into the effectiveOpacity(). | - |
2644 | | - |
2645 | By default, opacity propagates from parent to child, so if a parent's | - |
2646 | opacity is 0.5 and the child is also 0.5, the child's effective opacity | - |
2647 | will be 0.25. | - |
2648 | | - |
2649 | The opacity property decides the state of the painter passed to the | - |
2650 | paint() function. If the item is cached, i.e., ItemCoordinateCache or | - |
2651 | DeviceCoordinateCache, the effective property will be applied to the | - |
2652 | item's cache as it is rendered. | - |
2653 | | - |
2654 | There are two item flags that affect how the item's opacity is combined | - |
2655 | with the parent: ItemIgnoresParentOpacity and | - |
2656 | ItemDoesntPropagateOpacityToChildren. | - |
2657 | | - |
2658 | \sa opacity(), effectiveOpacity() | - |
2659 | */ | - |
2660 | void QGraphicsItem::setOpacity(qreal opacity) | - |
2661 | { | - |
2662 | // Notify change. | - |
2663 | const QVariant newOpacityVariant(itemChange(ItemOpacityChange, opacity)); executed (the execution status of this line is deduced): const QVariant newOpacityVariant(itemChange(ItemOpacityChange, opacity)); | - |
2664 | | - |
2665 | // Normalized opacity | - |
2666 | qreal newOpacity = qBound(qreal(0), newOpacityVariant.toReal(), qreal(1)); executed (the execution status of this line is deduced): qreal newOpacity = qBound(qreal(0), newOpacityVariant.toReal(), qreal(1)); | - |
2667 | | - |
2668 | // No change? Done. | - |
2669 | if (newOpacity == d_ptr->opacity) evaluated: newOpacity == d_ptr->opacity yes Evaluation Count:1 | yes Evaluation Count:5 |
| 1-5 |
2670 | return; executed: return; Execution Count:1 | 1 |
2671 | | - |
2672 | bool wasFullyTransparent = d_ptr->isOpacityNull(); executed (the execution status of this line is deduced): bool wasFullyTransparent = d_ptr->isOpacityNull(); | - |
2673 | d_ptr->opacity = newOpacity; executed (the execution status of this line is deduced): d_ptr->opacity = newOpacity; | - |
2674 | | - |
2675 | // Notify change. | - |
2676 | itemChange(ItemOpacityHasChanged, newOpacityVariant); executed (the execution status of this line is deduced): itemChange(ItemOpacityHasChanged, newOpacityVariant); | - |
2677 | | - |
2678 | // Update. | - |
2679 | if (d_ptr->scene) { evaluated: d_ptr->scene yes Evaluation Count:2 | yes Evaluation Count:3 |
| 2-3 |
2680 | #ifndef QT_NO_GRAPHICSEFFECT | - |
2681 | d_ptr->invalidateParentGraphicsEffectsRecursively(); executed (the execution status of this line is deduced): d_ptr->invalidateParentGraphicsEffectsRecursively(); | - |
2682 | if (!(d_ptr->flags & ItemDoesntPropagateOpacityToChildren)) partially evaluated: !(d_ptr->flags & ItemDoesntPropagateOpacityToChildren) yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
2683 | d_ptr->invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::OpacityChanged); executed: d_ptr->invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::OpacityChanged); Execution Count:2 | 2 |
2684 | #endif //QT_NO_GRAPHICSEFFECT | - |
2685 | d_ptr->scene->d_func()->markDirty(this, QRectF(), executed (the execution status of this line is deduced): d_ptr->scene->d_func()->markDirty(this, QRectF(), | - |
2686 | /*invalidateChildren=*/true, executed (the execution status of this line is deduced): true, | - |
2687 | /*force=*/false, executed (the execution status of this line is deduced): false, | - |
2688 | /*ignoreOpacity=*/d_ptr->isOpacityNull()); executed (the execution status of this line is deduced): d_ptr->isOpacityNull()); | - |
2689 | if (wasFullyTransparent) partially evaluated: wasFullyTransparent no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
2690 | d_ptr->paintedViewBoundingRectsNeedRepaint = 1; never executed: d_ptr->paintedViewBoundingRectsNeedRepaint = 1; | 0 |
2691 | } executed: } Execution Count:2 | 2 |
2692 | | - |
2693 | if (d_ptr->isObject) evaluated: d_ptr->isObject yes Evaluation Count:2 | yes Evaluation Count:3 |
| 2-3 |
2694 | emit static_cast<QGraphicsObject *>(this)->opacityChanged(); executed: static_cast<QGraphicsObject *>(this)->opacityChanged(); Execution Count:2 | 2 |
2695 | } executed: } Execution Count:5 | 5 |
2696 | | - |
2697 | /*! | - |
2698 | Returns a pointer to this item's effect if it has one; otherwise 0. | - |
2699 | | - |
2700 | \since 4.6 | - |
2701 | */ | - |
2702 | #ifndef QT_NO_GRAPHICSEFFECT | - |
2703 | QGraphicsEffect *QGraphicsItem::graphicsEffect() const | - |
2704 | { | - |
2705 | return d_ptr->graphicsEffect; executed: return d_ptr->graphicsEffect; Execution Count:16 | 16 |
2706 | } | - |
2707 | | - |
2708 | /*! | - |
2709 | Sets \a effect as the item's effect. If there already is an effect installed | - |
2710 | on this item, QGraphicsItem will delete the existing effect before installing | - |
2711 | the new \a effect. You can delete an existing effect by calling | - |
2712 | setGraphicsEffect(0). | - |
2713 | | - |
2714 | If \a effect is the installed on a different item, setGraphicsEffect() will remove | - |
2715 | the effect from the item and install it on this item. | - |
2716 | | - |
2717 | QGraphicsItem takes ownership of \a effect. | - |
2718 | | - |
2719 | \note This function will apply the effect on itself and all its children. | - |
2720 | | - |
2721 | \since 4.6 | - |
2722 | */ | - |
2723 | void QGraphicsItem::setGraphicsEffect(QGraphicsEffect *effect) | - |
2724 | { | - |
2725 | if (d_ptr->graphicsEffect == effect) partially evaluated: d_ptr->graphicsEffect == effect no Evaluation Count:0 | yes Evaluation Count:26 |
| 0-26 |
2726 | return; | 0 |
2727 | | - |
2728 | if (d_ptr->graphicsEffect) { evaluated: d_ptr->graphicsEffect yes Evaluation Count:4 | yes Evaluation Count:22 |
| 4-22 |
2729 | delete d_ptr->graphicsEffect; executed (the execution status of this line is deduced): delete d_ptr->graphicsEffect; | - |
2730 | d_ptr->graphicsEffect = 0; executed (the execution status of this line is deduced): d_ptr->graphicsEffect = 0; | - |
2731 | } else if (d_ptr->parent) { executed: } Execution Count:4 evaluated: d_ptr->parent yes Evaluation Count:2 | yes Evaluation Count:20 |
| 2-20 |
2732 | d_ptr->parent->d_ptr->updateChildWithGraphicsEffectFlagRecursively(); executed (the execution status of this line is deduced): d_ptr->parent->d_ptr->updateChildWithGraphicsEffectFlagRecursively(); | - |
2733 | } executed: } Execution Count:2 | 2 |
2734 | | - |
2735 | if (effect) { evaluated: effect yes Evaluation Count:22 | yes Evaluation Count:4 |
| 4-22 |
2736 | // Set new effect. | - |
2737 | QGraphicsEffectSourcePrivate *sourced = new QGraphicsItemEffectSourcePrivate(this); executed (the execution status of this line is deduced): QGraphicsEffectSourcePrivate *sourced = new QGraphicsItemEffectSourcePrivate(this); | - |
2738 | QGraphicsEffectSource *source = new QGraphicsEffectSource(*sourced); executed (the execution status of this line is deduced): QGraphicsEffectSource *source = new QGraphicsEffectSource(*sourced); | - |
2739 | d_ptr->graphicsEffect = effect; executed (the execution status of this line is deduced): d_ptr->graphicsEffect = effect; | - |
2740 | effect->d_func()->setGraphicsEffectSource(source); executed (the execution status of this line is deduced): effect->d_func()->setGraphicsEffectSource(source); | - |
2741 | prepareGeometryChange(); executed (the execution status of this line is deduced): prepareGeometryChange(); | - |
2742 | } executed: } Execution Count:22 | 22 |
2743 | } executed: } Execution Count:26 | 26 |
2744 | #endif //QT_NO_GRAPHICSEFFECT | - |
2745 | | - |
2746 | void QGraphicsItemPrivate::updateChildWithGraphicsEffectFlagRecursively() | - |
2747 | { | - |
2748 | #ifndef QT_NO_GRAPHICSEFFECT | - |
2749 | QGraphicsItemPrivate *itemPrivate = this; executed (the execution status of this line is deduced): QGraphicsItemPrivate *itemPrivate = this; | - |
2750 | do { | - |
2751 | // parent chain already notified? | - |
2752 | if (itemPrivate->mayHaveChildWithGraphicsEffect) partially evaluated: itemPrivate->mayHaveChildWithGraphicsEffect no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
2753 | return; | 0 |
2754 | itemPrivate->mayHaveChildWithGraphicsEffect = 1; executed (the execution status of this line is deduced): itemPrivate->mayHaveChildWithGraphicsEffect = 1; | - |
2755 | } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : 0)); executed: } Execution Count:2 partially evaluated: itemPrivate->parent no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
2756 | #endif | - |
2757 | } executed: } Execution Count:2 | 2 |
2758 | | - |
2759 | /*! | - |
2760 | \internal | - |
2761 | \since 4.6 | - |
2762 | Returns the effective bounding rect of the given item space rect. | - |
2763 | If the item has no effect, the rect is returned unmodified. | - |
2764 | If the item has an effect, the effective rect can be extend beyond the | - |
2765 | item's bounding rect, depending on the effect. | - |
2766 | | - |
2767 | \sa boundingRect() | - |
2768 | */ | - |
2769 | QRectF QGraphicsItemPrivate::effectiveBoundingRect(const QRectF &rect) const | - |
2770 | { | - |
2771 | #ifndef QT_NO_GRAPHICSEFFECT | - |
2772 | Q_Q(const QGraphicsItem); executed (the execution status of this line is deduced): const QGraphicsItem * const q = q_func(); | - |
2773 | QGraphicsEffect *effect = graphicsEffect; executed (the execution status of this line is deduced): QGraphicsEffect *effect = graphicsEffect; | - |
2774 | if (scene && effect && effect->isEnabled()) { evaluated: scene yes Evaluation Count:1142 | yes Evaluation Count:4 |
evaluated: effect yes Evaluation Count:107 | yes Evaluation Count:1035 |
evaluated: effect->isEnabled() yes Evaluation Count:103 | yes Evaluation Count:4 |
| 4-1142 |
2775 | if (scene->d_func()->views.isEmpty()) evaluated: scene->d_func()->views.isEmpty() yes Evaluation Count:14 | yes Evaluation Count:89 |
| 14-89 |
2776 | return effect->boundingRectFor(rect); executed: return effect->boundingRectFor(rect); Execution Count:14 | 14 |
2777 | QRectF sceneRect = q->mapRectToScene(rect); executed (the execution status of this line is deduced): QRectF sceneRect = q->mapRectToScene(rect); | - |
2778 | QRectF sceneEffectRect; executed (the execution status of this line is deduced): QRectF sceneEffectRect; | - |
2779 | foreach (QGraphicsView *view, scene->views()) { executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(scene->views())> _container_(scene->views()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsView *view = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
2780 | QRectF deviceRect = view->d_func()->mapRectFromScene(sceneRect); executed (the execution status of this line is deduced): QRectF deviceRect = view->d_func()->mapRectFromScene(sceneRect); | - |
2781 | QRect deviceEffectRect = effect->boundingRectFor(deviceRect).toAlignedRect(); executed (the execution status of this line is deduced): QRect deviceEffectRect = effect->boundingRectFor(deviceRect).toAlignedRect(); | - |
2782 | sceneEffectRect |= view->d_func()->mapRectToScene(deviceEffectRect); executed (the execution status of this line is deduced): sceneEffectRect |= view->d_func()->mapRectToScene(deviceEffectRect); | - |
2783 | } executed: } Execution Count:89 | 89 |
2784 | return q->mapRectFromScene(sceneEffectRect); executed: return q->mapRectFromScene(sceneEffectRect); Execution Count:89 | 89 |
2785 | } | - |
2786 | #endif //QT_NO_GRAPHICSEFFECT | - |
2787 | return rect; executed: return rect; Execution Count:1043 | 1043 |
2788 | } | - |
2789 | | - |
2790 | /*! | - |
2791 | \internal | - |
2792 | \since 4.6 | - |
2793 | Returns the effective bounding rect of the item. | - |
2794 | If the item has no effect, this is the same as the item's bounding rect. | - |
2795 | If the item has an effect, the effective rect can be larger than the item's | - |
2796 | bouding rect, depending on the effect. | - |
2797 | | - |
2798 | \sa boundingRect() | - |
2799 | */ | - |
2800 | QRectF QGraphicsItemPrivate::effectiveBoundingRect(QGraphicsItem *topMostEffectItem) const | - |
2801 | { | - |
2802 | #ifndef QT_NO_GRAPHICSEFFECT | - |
2803 | Q_Q(const QGraphicsItem); executed (the execution status of this line is deduced): const QGraphicsItem * const q = q_func(); | - |
2804 | QRectF brect = effectiveBoundingRect(q_ptr->boundingRect()); executed (the execution status of this line is deduced): QRectF brect = effectiveBoundingRect(q_ptr->boundingRect()); | - |
2805 | if (ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren || topMostEffectItem == q) evaluated: ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren yes Evaluation Count:6 | yes Evaluation Count:1125 |
evaluated: topMostEffectItem == q yes Evaluation Count:9 | yes Evaluation Count:1116 |
| 6-1125 |
2806 | return brect; executed: return brect; Execution Count:15 | 15 |
2807 | | - |
2808 | const QGraphicsItem *effectParent = parent; executed (the execution status of this line is deduced): const QGraphicsItem *effectParent = parent; | - |
2809 | while (effectParent) { evaluated: effectParent yes Evaluation Count:802 | yes Evaluation Count:1111 |
| 802-1111 |
2810 | QGraphicsEffect *effect = effectParent->d_ptr->graphicsEffect; executed (the execution status of this line is deduced): QGraphicsEffect *effect = effectParent->d_ptr->graphicsEffect; | - |
2811 | if (scene && effect && effect->isEnabled()) { evaluated: scene yes Evaluation Count:801 | yes Evaluation Count:1 |
evaluated: effect yes Evaluation Count:15 | yes Evaluation Count:786 |
partially evaluated: effect->isEnabled() yes Evaluation Count:15 | no Evaluation Count:0 |
| 0-801 |
2812 | const QRectF brectInParentSpace = q->mapRectToItem(effectParent, brect); executed (the execution status of this line is deduced): const QRectF brectInParentSpace = q->mapRectToItem(effectParent, brect); | - |
2813 | const QRectF effectRectInParentSpace = effectParent->d_ptr->effectiveBoundingRect(brectInParentSpace); executed (the execution status of this line is deduced): const QRectF effectRectInParentSpace = effectParent->d_ptr->effectiveBoundingRect(brectInParentSpace); | - |
2814 | brect = effectParent->mapRectToItem(q, effectRectInParentSpace); executed (the execution status of this line is deduced): brect = effectParent->mapRectToItem(q, effectRectInParentSpace); | - |
2815 | } executed: } Execution Count:15 | 15 |
2816 | if (effectParent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren partially evaluated: effectParent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren no Evaluation Count:0 | yes Evaluation Count:802 |
| 0-802 |
2817 | || topMostEffectItem == effectParent) { evaluated: topMostEffectItem == effectParent yes Evaluation Count:5 | yes Evaluation Count:797 |
| 5-797 |
2818 | return brect; executed: return brect; Execution Count:5 | 5 |
2819 | } | - |
2820 | effectParent = effectParent->d_ptr->parent; executed (the execution status of this line is deduced): effectParent = effectParent->d_ptr->parent; | - |
2821 | } executed: } Execution Count:797 | 797 |
2822 | | - |
2823 | return brect; executed: return brect; Execution Count:1111 | 1111 |
2824 | #else //QT_NO_GRAPHICSEFFECT | - |
2825 | return q_ptr->boundingRect(); | - |
2826 | #endif //QT_NO_GRAPHICSEFFECT | - |
2827 | | - |
2828 | } | - |
2829 | | - |
2830 | /*! | - |
2831 | \internal | - |
2832 | \since 4.6 | - |
2833 | Returns the effective bounding rect of this item in scene coordinates, | - |
2834 | by combining sceneTransform() with boundingRect(), taking into account | - |
2835 | the effect that the item might have. | - |
2836 | | - |
2837 | If the item has no effect, this is the same as sceneBoundingRect(). | - |
2838 | | - |
2839 | \sa effectiveBoundingRect(), sceneBoundingRect() | - |
2840 | */ | - |
2841 | QRectF QGraphicsItemPrivate::sceneEffectiveBoundingRect() const | - |
2842 | { | - |
2843 | // Find translate-only offset | - |
2844 | // COMBINE | - |
2845 | QPointF offset; executed (the execution status of this line is deduced): QPointF offset; | - |
2846 | const QGraphicsItem *parentItem = q_ptr; executed (the execution status of this line is deduced): const QGraphicsItem *parentItem = q_ptr; | - |
2847 | const QGraphicsItemPrivate *itemd; executed (the execution status of this line is deduced): const QGraphicsItemPrivate *itemd; | - |
2848 | do { | - |
2849 | itemd = parentItem->d_ptr.data(); executed (the execution status of this line is deduced): itemd = parentItem->d_ptr.data(); | - |
2850 | if (itemd->transformData) evaluated: itemd->transformData yes Evaluation Count:4 | yes Evaluation Count:844 |
| 4-844 |
2851 | break; executed: break; Execution Count:4 | 4 |
2852 | offset += itemd->pos; executed (the execution status of this line is deduced): offset += itemd->pos; | - |
2853 | } while ((parentItem = itemd->parent)); executed: } Execution Count:844 evaluated: (parentItem = itemd->parent) yes Evaluation Count:360 | yes Evaluation Count:484 |
| 360-844 |
2854 | | - |
2855 | QRectF br = effectiveBoundingRect(); executed (the execution status of this line is deduced): QRectF br = effectiveBoundingRect(); | - |
2856 | br.translate(offset); executed (the execution status of this line is deduced): br.translate(offset); | - |
2857 | return !parentItem ? br : parentItem->sceneTransform().mapRect(br); executed: return !parentItem ? br : parentItem->sceneTransform().mapRect(br); Execution Count:488 | 488 |
2858 | } | - |
2859 | | - |
2860 | /*! | - |
2861 | Returns true if this item can accept drag and drop events; otherwise, | - |
2862 | returns false. By default, items do not accept drag and drop events; items | - |
2863 | are transparent to drag and drop. | - |
2864 | | - |
2865 | \sa setAcceptDrops() | - |
2866 | */ | - |
2867 | bool QGraphicsItem::acceptDrops() const | - |
2868 | { | - |
2869 | return d_ptr->acceptDrops; never executed: return d_ptr->acceptDrops; | 0 |
2870 | } | - |
2871 | | - |
2872 | /*! | - |
2873 | If \a on is true, this item will accept drag and drop events; otherwise, | - |
2874 | it is transparent for drag and drop events. By default, items do not | - |
2875 | accept drag and drop events. | - |
2876 | | - |
2877 | \sa acceptDrops() | - |
2878 | */ | - |
2879 | void QGraphicsItem::setAcceptDrops(bool on) | - |
2880 | { | - |
2881 | d_ptr->acceptDrops = on; executed (the execution status of this line is deduced): d_ptr->acceptDrops = on; | - |
2882 | } executed: } Execution Count:4 | 4 |
2883 | | - |
2884 | /*! | - |
2885 | Returns the mouse buttons that this item accepts mouse events for. By | - |
2886 | default, all mouse buttons are accepted. | - |
2887 | | - |
2888 | If an item accepts a mouse button, it will become the mouse | - |
2889 | grabber item when a mouse press event is delivered for that mouse | - |
2890 | button. However, if the item does not accept the button, | - |
2891 | QGraphicsScene will forward the mouse events to the first item | - |
2892 | beneath it that does. | - |
2893 | | - |
2894 | \sa setAcceptedMouseButtons(), mousePressEvent() | - |
2895 | */ | - |
2896 | Qt::MouseButtons QGraphicsItem::acceptedMouseButtons() const | - |
2897 | { | - |
2898 | return Qt::MouseButtons(d_ptr->acceptedMouseButtons); executed: return Qt::MouseButtons(d_ptr->acceptedMouseButtons); Execution Count:2 | 2 |
2899 | } | - |
2900 | | - |
2901 | /*! | - |
2902 | Sets the mouse \a buttons that this item accepts mouse events for. | - |
2903 | | - |
2904 | By default, all mouse buttons are accepted. If an item accepts a | - |
2905 | mouse button, it will become the mouse grabber item when a mouse | - |
2906 | press event is delivered for that button. However, if the item | - |
2907 | does not accept the mouse button, QGraphicsScene will forward the | - |
2908 | mouse events to the first item beneath it that does. | - |
2909 | | - |
2910 | To disable mouse events for an item (i.e., make it transparent for mouse | - |
2911 | events), call setAcceptedMouseButtons(0). | - |
2912 | | - |
2913 | \sa acceptedMouseButtons(), mousePressEvent() | - |
2914 | */ | - |
2915 | void QGraphicsItem::setAcceptedMouseButtons(Qt::MouseButtons buttons) | - |
2916 | { | - |
2917 | if (Qt::MouseButtons(d_ptr->acceptedMouseButtons) != buttons) { never evaluated: Qt::MouseButtons(d_ptr->acceptedMouseButtons) != buttons | 0 |
2918 | if (buttons == 0 && d_ptr->scene && d_ptr->scene->mouseGrabberItem() == this never evaluated: buttons == 0 never evaluated: d_ptr->scene never evaluated: d_ptr->scene->mouseGrabberItem() == this | 0 |
2919 | && d_ptr->scene->d_func()->lastMouseGrabberItemHasImplicitMouseGrab) { never evaluated: d_ptr->scene->d_func()->lastMouseGrabberItemHasImplicitMouseGrab | 0 |
2920 | ungrabMouse(); never executed (the execution status of this line is deduced): ungrabMouse(); | - |
2921 | } | 0 |
2922 | d_ptr->acceptedMouseButtons = quint32(buttons); never executed (the execution status of this line is deduced): d_ptr->acceptedMouseButtons = quint32(buttons); | - |
2923 | } | 0 |
2924 | } | 0 |
2925 | | - |
2926 | /*! | - |
2927 | \since 4.4 | - |
2928 | | - |
2929 | Returns true if an item accepts hover events | - |
2930 | (QGraphicsSceneHoverEvent); otherwise, returns false. By default, | - |
2931 | items do not accept hover events. | - |
2932 | | - |
2933 | \sa setAcceptedMouseButtons() | - |
2934 | */ | - |
2935 | bool QGraphicsItem::acceptHoverEvents() const | - |
2936 | { | - |
2937 | return d_ptr->acceptsHover; never executed: return d_ptr->acceptsHover; | 0 |
2938 | } | - |
2939 | | - |
2940 | /*! | - |
2941 | \fn bool QGraphicsItem::acceptsHoverEvents() const | - |
2942 | \obsolete | - |
2943 | | - |
2944 | Call acceptHoverEvents() instead. | - |
2945 | */ | - |
2946 | | - |
2947 | /*! | - |
2948 | \since 4.4 | - |
2949 | | - |
2950 | If \a enabled is true, this item will accept hover events; | - |
2951 | otherwise, it will ignore them. By default, items do not accept | - |
2952 | hover events. | - |
2953 | | - |
2954 | Hover events are delivered when there is no current mouse grabber | - |
2955 | item. They are sent when the mouse cursor enters an item, when it | - |
2956 | moves around inside the item, and when the cursor leaves an | - |
2957 | item. Hover events are commonly used to highlight an item when | - |
2958 | it's entered, and for tracking the mouse cursor as it hovers over | - |
2959 | the item (equivalent to QWidget::mouseTracking). | - |
2960 | | - |
2961 | Parent items receive hover enter events before their children, and | - |
2962 | leave events after their children. The parent does not receive a | - |
2963 | hover leave event if the cursor enters a child, though; the parent | - |
2964 | stays "hovered" until the cursor leaves its area, including its | - |
2965 | children's areas. | - |
2966 | | - |
2967 | If a parent item handles child events, it will receive hover move, | - |
2968 | drag move, and drop events as the cursor passes through its | - |
2969 | children, but it does not receive hover enter and hover leave, nor | - |
2970 | drag enter and drag leave events on behalf of its children. | - |
2971 | | - |
2972 | A QGraphicsWidget with window decorations will accept hover events | - |
2973 | regardless of the value of acceptHoverEvents(). | - |
2974 | | - |
2975 | \sa acceptHoverEvents(), hoverEnterEvent(), hoverMoveEvent(), | - |
2976 | hoverLeaveEvent() | - |
2977 | */ | - |
2978 | void QGraphicsItem::setAcceptHoverEvents(bool enabled) | - |
2979 | { | - |
2980 | if (d_ptr->acceptsHover == quint32(enabled)) partially evaluated: d_ptr->acceptsHover == quint32(enabled) no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
2981 | return; | 0 |
2982 | d_ptr->acceptsHover = quint32(enabled); executed (the execution status of this line is deduced): d_ptr->acceptsHover = quint32(enabled); | - |
2983 | if (d_ptr->acceptsHover && d_ptr->scene && d_ptr->scene->d_func()->allItemsIgnoreHoverEvents) { partially evaluated: d_ptr->acceptsHover yes Evaluation Count:4 | no Evaluation Count:0 |
partially evaluated: d_ptr->scene no Evaluation Count:0 | yes Evaluation Count:4 |
never evaluated: d_ptr->scene->d_func()->allItemsIgnoreHoverEvents | 0-4 |
2984 | d_ptr->scene->d_func()->allItemsIgnoreHoverEvents = false; never executed (the execution status of this line is deduced): d_ptr->scene->d_func()->allItemsIgnoreHoverEvents = false; | - |
2985 | d_ptr->scene->d_func()->enableMouseTrackingOnViews(); never executed (the execution status of this line is deduced): d_ptr->scene->d_func()->enableMouseTrackingOnViews(); | - |
2986 | } | 0 |
2987 | } executed: } Execution Count:4 | 4 |
2988 | | - |
2989 | /*! | - |
2990 | \fn void QGraphicsItem::setAcceptsHoverEvents(bool enabled) | - |
2991 | \obsolete | - |
2992 | | - |
2993 | Use setAcceptHoverEvents(\a enabled) instead. | - |
2994 | */ | - |
2995 | | - |
2996 | /*! \since 4.6 | - |
2997 | | - |
2998 | Returns true if an item accepts \l{QTouchEvent}{touch events}; | - |
2999 | otherwise, returns false. By default, items do not accept touch events. | - |
3000 | | - |
3001 | \sa setAcceptTouchEvents() | - |
3002 | */ | - |
3003 | bool QGraphicsItem::acceptTouchEvents() const | - |
3004 | { | - |
3005 | return d_ptr->acceptTouchEvents; never executed: return d_ptr->acceptTouchEvents; | 0 |
3006 | } | - |
3007 | | - |
3008 | /*! | - |
3009 | \since 4.6 | - |
3010 | | - |
3011 | If \a enabled is true, this item will accept \l{QTouchEvent}{touch events}; | - |
3012 | otherwise, it will ignore them. By default, items do not accept | - |
3013 | touch events. | - |
3014 | */ | - |
3015 | void QGraphicsItem::setAcceptTouchEvents(bool enabled) | - |
3016 | { | - |
3017 | if (d_ptr->acceptTouchEvents == quint32(enabled)) never evaluated: d_ptr->acceptTouchEvents == quint32(enabled) | 0 |
3018 | return; | 0 |
3019 | d_ptr->acceptTouchEvents = quint32(enabled); never executed (the execution status of this line is deduced): d_ptr->acceptTouchEvents = quint32(enabled); | - |
3020 | if (d_ptr->acceptTouchEvents && d_ptr->scene && d_ptr->scene->d_func()->allItemsIgnoreTouchEvents) { never evaluated: d_ptr->acceptTouchEvents never evaluated: d_ptr->scene never evaluated: d_ptr->scene->d_func()->allItemsIgnoreTouchEvents | 0 |
3021 | d_ptr->scene->d_func()->allItemsIgnoreTouchEvents = false; never executed (the execution status of this line is deduced): d_ptr->scene->d_func()->allItemsIgnoreTouchEvents = false; | - |
3022 | d_ptr->scene->d_func()->enableTouchEventsOnViews(); never executed (the execution status of this line is deduced): d_ptr->scene->d_func()->enableTouchEventsOnViews(); | - |
3023 | } | 0 |
3024 | } | 0 |
3025 | | - |
3026 | /*! | - |
3027 | \since 4.6 | - |
3028 | | - |
3029 | Returns true if this item filters child events (i.e., all events | - |
3030 | intended for any of its children are instead sent to this item); | - |
3031 | otherwise, false is returned. | - |
3032 | | - |
3033 | The default value is false; child events are not filtered. | - |
3034 | | - |
3035 | \sa setFiltersChildEvents() | - |
3036 | */ | - |
3037 | bool QGraphicsItem::filtersChildEvents() const | - |
3038 | { | - |
3039 | return d_ptr->filtersDescendantEvents; never executed: return d_ptr->filtersDescendantEvents; | 0 |
3040 | } | - |
3041 | | - |
3042 | /*! | - |
3043 | \since 4.6 | - |
3044 | | - |
3045 | If \a enabled is true, this item is set to filter all events for | - |
3046 | all its children (i.e., all events intented for any of its | - |
3047 | children are instead sent to this item); otherwise, if \a enabled | - |
3048 | is false, this item will only handle its own events. The default | - |
3049 | value is false. | - |
3050 | | - |
3051 | \sa filtersChildEvents() | - |
3052 | */ | - |
3053 | void QGraphicsItem::setFiltersChildEvents(bool enabled) | - |
3054 | { | - |
3055 | if (d_ptr->filtersDescendantEvents == enabled) never evaluated: d_ptr->filtersDescendantEvents == enabled | 0 |
3056 | return; | 0 |
3057 | | - |
3058 | d_ptr->filtersDescendantEvents = enabled; never executed (the execution status of this line is deduced): d_ptr->filtersDescendantEvents = enabled; | - |
3059 | d_ptr->updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-2)); never executed (the execution status of this line is deduced): d_ptr->updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-2)); | - |
3060 | } | 0 |
3061 | | - |
3062 | /*! | - |
3063 | \obsolete | - |
3064 | | - |
3065 | Returns true if this item handles child events (i.e., all events | - |
3066 | intended for any of its children are instead sent to this item); | - |
3067 | otherwise, false is returned. | - |
3068 | | - |
3069 | This property is useful for item groups; it allows one item to | - |
3070 | handle events on behalf of its children, as opposed to its | - |
3071 | children handling their events individually. | - |
3072 | | - |
3073 | The default is to return false; children handle their own events. | - |
3074 | The exception for this is if the item is a QGraphicsItemGroup, then | - |
3075 | it defaults to return true. | - |
3076 | | - |
3077 | \sa setHandlesChildEvents() | - |
3078 | */ | - |
3079 | bool QGraphicsItem::handlesChildEvents() const | - |
3080 | { | - |
3081 | return d_ptr->handlesChildEvents; never executed: return d_ptr->handlesChildEvents; | 0 |
3082 | } | - |
3083 | | - |
3084 | /*! | - |
3085 | \obsolete | - |
3086 | | - |
3087 | If \a enabled is true, this item is set to handle all events for | - |
3088 | all its children (i.e., all events intented for any of its | - |
3089 | children are instead sent to this item); otherwise, if \a enabled | - |
3090 | is false, this item will only handle its own events. The default | - |
3091 | value is false. | - |
3092 | | - |
3093 | This property is useful for item groups; it allows one item to | - |
3094 | handle events on behalf of its children, as opposed to its | - |
3095 | children handling their events individually. | - |
3096 | | - |
3097 | If a child item accepts hover events, its parent will receive | - |
3098 | hover move events as the cursor passes through the child, but it | - |
3099 | does not receive hover enter and hover leave events on behalf of | - |
3100 | its child. | - |
3101 | | - |
3102 | \sa handlesChildEvents() | - |
3103 | */ | - |
3104 | void QGraphicsItem::setHandlesChildEvents(bool enabled) | - |
3105 | { | - |
3106 | if (d_ptr->handlesChildEvents == enabled) never evaluated: d_ptr->handlesChildEvents == enabled | 0 |
3107 | return; | 0 |
3108 | | - |
3109 | d_ptr->handlesChildEvents = enabled; never executed (the execution status of this line is deduced): d_ptr->handlesChildEvents = enabled; | - |
3110 | d_ptr->updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-1)); never executed (the execution status of this line is deduced): d_ptr->updateAncestorFlag(QGraphicsItem::GraphicsItemFlag(-1)); | - |
3111 | } | 0 |
3112 | /*! | - |
3113 | \since 4.6 | - |
3114 | Returns true if this item is active; otherwise returns false. | - |
3115 | | - |
3116 | An item can only be active if the scene is active. An item is active | - |
3117 | if it is, or is a descendent of, an active panel. Items in non-active | - |
3118 | panels are not active. | - |
3119 | | - |
3120 | Items that are not part of a panel follow scene activation when the | - |
3121 | scene has no active panel. | - |
3122 | | - |
3123 | Only active items can gain input focus. | - |
3124 | | - |
3125 | \sa QGraphicsScene::isActive(), QGraphicsScene::activePanel(), panel(), isPanel() | - |
3126 | */ | - |
3127 | bool QGraphicsItem::isActive() const | - |
3128 | { | - |
3129 | if (!d_ptr->scene || !d_ptr->scene->isActive()) evaluated: !d_ptr->scene yes Evaluation Count:435 | yes Evaluation Count:904 |
evaluated: !d_ptr->scene->isActive() yes Evaluation Count:805 | yes Evaluation Count:99 |
| 99-904 |
3130 | return false; executed: return false; Execution Count:1240 | 1240 |
3131 | return panel() == d_ptr->scene->activePanel(); executed: return panel() == d_ptr->scene->activePanel(); Execution Count:99 | 99 |
3132 | } | - |
3133 | | - |
3134 | /*! | - |
3135 | \since 4.6 | - |
3136 | | - |
3137 | If \a active is true, and the scene is active, this item's panel will be | - |
3138 | activated. Otherwise, the panel is deactivated. | - |
3139 | | - |
3140 | If the item is not part of an active scene, \a active will decide what | - |
3141 | happens to the panel when the scene becomes active or the item is added to | - |
3142 | the scene. If true, the item's panel will be activated when the item is | - |
3143 | either added to the scene or the scene is activated. Otherwise, the item | - |
3144 | will stay inactive independent of the scene's activated state. | - |
3145 | | - |
3146 | \sa isPanel(), QGraphicsScene::setActivePanel(), QGraphicsScene::isActive() | - |
3147 | */ | - |
3148 | void QGraphicsItem::setActive(bool active) | - |
3149 | { | - |
3150 | d_ptr->explicitActivate = 1; executed (the execution status of this line is deduced): d_ptr->explicitActivate = 1; | - |
3151 | d_ptr->wantsActive = active; executed (the execution status of this line is deduced): d_ptr->wantsActive = active; | - |
3152 | if (d_ptr->scene) { partially evaluated: d_ptr->scene yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
3153 | if (active) { partially evaluated: active yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
3154 | // Activate this item. | - |
3155 | d_ptr->scene->setActivePanel(this); executed (the execution status of this line is deduced): d_ptr->scene->setActivePanel(this); | - |
3156 | } else { executed: } Execution Count:3 | 3 |
3157 | // Deactivate this item, and reactivate the parent panel, | - |
3158 | // or the last active panel (if any). | - |
3159 | QGraphicsItem *nextToActivate = 0; never executed (the execution status of this line is deduced): QGraphicsItem *nextToActivate = 0; | - |
3160 | if (d_ptr->parent) never evaluated: d_ptr->parent | 0 |
3161 | nextToActivate = d_ptr->parent->panel(); never executed: nextToActivate = d_ptr->parent->panel(); | 0 |
3162 | if (!nextToActivate) never evaluated: !nextToActivate | 0 |
3163 | nextToActivate = d_ptr->scene->d_func()->lastActivePanel; never executed: nextToActivate = d_ptr->scene->d_func()->lastActivePanel; | 0 |
3164 | if (nextToActivate == this || isAncestorOf(nextToActivate)) never evaluated: nextToActivate == this never evaluated: isAncestorOf(nextToActivate) | 0 |
3165 | nextToActivate = 0; never executed: nextToActivate = 0; | 0 |
3166 | d_ptr->scene->setActivePanel(nextToActivate); never executed (the execution status of this line is deduced): d_ptr->scene->setActivePanel(nextToActivate); | - |
3167 | } | 0 |
3168 | } | - |
3169 | } executed: } Execution Count:3 | 3 |
3170 | | - |
3171 | /*! | - |
3172 | Returns true if this item is active, and it or its \l{focusProxy()}{focus | - |
3173 | proxy} has keyboard input focus; otherwise, returns false. | - |
3174 | | - |
3175 | \sa focusItem(), setFocus(), QGraphicsScene::setFocusItem(), isActive() | - |
3176 | */ | - |
3177 | bool QGraphicsItem::hasFocus() const | - |
3178 | { | - |
3179 | if (!d_ptr->scene || !d_ptr->scene->isActive()) evaluated: !d_ptr->scene yes Evaluation Count:281 | yes Evaluation Count:3418 |
evaluated: !d_ptr->scene->isActive() yes Evaluation Count:2674 | yes Evaluation Count:744 |
| 281-3418 |
3180 | return false; executed: return false; Execution Count:2955 | 2955 |
3181 | | - |
3182 | if (d_ptr->focusProxy) partially evaluated: d_ptr->focusProxy no Evaluation Count:0 | yes Evaluation Count:744 |
| 0-744 |
3183 | return d_ptr->focusProxy->hasFocus(); never executed: return d_ptr->focusProxy->hasFocus(); | 0 |
3184 | | - |
3185 | if (d_ptr->scene->d_func()->focusItem != this) partially evaluated: d_ptr->scene->d_func()->focusItem != this yes Evaluation Count:744 | no Evaluation Count:0 |
| 0-744 |
3186 | return false; executed: return false; Execution Count:744 | 744 |
3187 | | - |
3188 | return panel() == d_ptr->scene->d_func()->activePanel; never executed: return panel() == d_ptr->scene->d_func()->activePanel; | 0 |
3189 | } | - |
3190 | | - |
3191 | /*! | - |
3192 | Gives keyboard input focus to this item. The \a focusReason argument will | - |
3193 | be passed into any \l{QFocusEvent}{focus event} generated by this function; | - |
3194 | it is used to give an explanation of what caused the item to get focus. | - |
3195 | | - |
3196 | Only enabled items that set the ItemIsFocusable flag can accept keyboard | - |
3197 | focus. | - |
3198 | | - |
3199 | If this item is not visible, not active, or not associated with a scene, | - |
3200 | it will not gain immediate input focus. However, it will be registered as | - |
3201 | the preferred focus item for its subtree of items, should it later become | - |
3202 | visible. | - |
3203 | | - |
3204 | As a result of calling this function, this item will receive a | - |
3205 | \l{focusInEvent()}{focus in event} with \a focusReason. If another item | - |
3206 | already has focus, that item will first receive a \l{focusOutEvent()} | - |
3207 | {focus out event} indicating that it has lost input focus. | - |
3208 | | - |
3209 | \sa clearFocus(), hasFocus(), focusItem(), focusProxy() | - |
3210 | */ | - |
3211 | void QGraphicsItem::setFocus(Qt::FocusReason focusReason) | - |
3212 | { | - |
3213 | d_ptr->setFocusHelper(focusReason, /* climb = */ true, /* focusFromHide = */ false); never executed (the execution status of this line is deduced): d_ptr->setFocusHelper(focusReason, true, false); | - |
3214 | } | 0 |
3215 | | - |
3216 | /*! | - |
3217 | \internal | - |
3218 | */ | - |
3219 | void QGraphicsItemPrivate::setFocusHelper(Qt::FocusReason focusReason, bool climb, bool focusFromHide) | - |
3220 | { | - |
3221 | // Disabled / unfocusable items cannot accept focus. | - |
3222 | if (!q_ptr->isEnabled() || !(flags & QGraphicsItem::ItemIsFocusable)) never evaluated: !q_ptr->isEnabled() never evaluated: !(flags & QGraphicsItem::ItemIsFocusable) | 0 |
3223 | return; | 0 |
3224 | | - |
3225 | // Find focus proxy. | - |
3226 | QGraphicsItem *f = q_ptr; never executed (the execution status of this line is deduced): QGraphicsItem *f = q_ptr; | - |
3227 | while (f->d_ptr->focusProxy) never evaluated: f->d_ptr->focusProxy | 0 |
3228 | f = f->d_ptr->focusProxy; never executed: f = f->d_ptr->focusProxy; | 0 |
3229 | | - |
3230 | // Return if it already has focus. | - |
3231 | if (scene && scene->focusItem() == f) never evaluated: scene never evaluated: scene->focusItem() == f | 0 |
3232 | return; | 0 |
3233 | | - |
3234 | // Update focus scope item ptr. | - |
3235 | QGraphicsItem *p = parent; never executed (the execution status of this line is deduced): QGraphicsItem *p = parent; | - |
3236 | while (p) { | 0 |
3237 | if (p->flags() & QGraphicsItem::ItemIsFocusScope) { never evaluated: p->flags() & QGraphicsItem::ItemIsFocusScope | 0 |
3238 | QGraphicsItem *oldFocusScopeItem = p->d_ptr->focusScopeItem; never executed (the execution status of this line is deduced): QGraphicsItem *oldFocusScopeItem = p->d_ptr->focusScopeItem; | - |
3239 | p->d_ptr->focusScopeItem = q_ptr; never executed (the execution status of this line is deduced): p->d_ptr->focusScopeItem = q_ptr; | - |
3240 | if (!p->focusItem() && !focusFromHide) { never evaluated: !p->focusItem() never evaluated: !focusFromHide | 0 |
3241 | if (oldFocusScopeItem) never evaluated: oldFocusScopeItem | 0 |
3242 | oldFocusScopeItem->d_ptr->focusScopeItemChange(false); never executed: oldFocusScopeItem->d_ptr->focusScopeItemChange(false); | 0 |
3243 | focusScopeItemChange(true); never executed (the execution status of this line is deduced): focusScopeItemChange(true); | - |
3244 | // If you call setFocus on a child of a focus scope that | - |
3245 | // doesn't currently have a focus item, then stop. | - |
3246 | return; | 0 |
3247 | } | - |
3248 | break; | 0 |
3249 | } | - |
3250 | p = p->d_ptr->parent; never executed (the execution status of this line is deduced): p = p->d_ptr->parent; | - |
3251 | } | 0 |
3252 | | - |
3253 | if (climb) { | 0 |
3254 | while (f->d_ptr->focusScopeItem && f->d_ptr->focusScopeItem->isVisible()) never evaluated: f->d_ptr->focusScopeItem never evaluated: f->d_ptr->focusScopeItem->isVisible() | 0 |
3255 | f = f->d_ptr->focusScopeItem; never executed: f = f->d_ptr->focusScopeItem; | 0 |
3256 | } | 0 |
3257 | | - |
3258 | // Update the child focus chain. | - |
3259 | QGraphicsItem *commonAncestor = 0; never executed (the execution status of this line is deduced): QGraphicsItem *commonAncestor = 0; | - |
3260 | if (scene && scene->focusItem() && scene->focusItem()->panel() == q_ptr->panel()) { never evaluated: scene never evaluated: scene->focusItem() never evaluated: scene->focusItem()->panel() == q_ptr->panel() | 0 |
3261 | commonAncestor = scene->focusItem()->commonAncestorItem(f); never executed (the execution status of this line is deduced): commonAncestor = scene->focusItem()->commonAncestorItem(f); | - |
3262 | scene->focusItem()->d_ptr->clearSubFocus(scene->focusItem(), commonAncestor); never executed (the execution status of this line is deduced): scene->focusItem()->d_ptr->clearSubFocus(scene->focusItem(), commonAncestor); | - |
3263 | } | 0 |
3264 | | - |
3265 | f->d_ptr->setSubFocus(f, commonAncestor); never executed (the execution status of this line is deduced): f->d_ptr->setSubFocus(f, commonAncestor); | - |
3266 | | - |
3267 | // Update the scene's focus item. | - |
3268 | if (scene) { | 0 |
3269 | QGraphicsItem *p = q_ptr->panel(); never executed (the execution status of this line is deduced): QGraphicsItem *p = q_ptr->panel(); | - |
3270 | if ((!p && scene->isActive()) || (p && p->isActive())) { never evaluated: !p never evaluated: scene->isActive() never evaluated: p never evaluated: p->isActive() | 0 |
3271 | // Visible items immediately gain focus from scene. | - |
3272 | scene->d_func()->setFocusItemHelper(f, focusReason); never executed (the execution status of this line is deduced): scene->d_func()->setFocusItemHelper(f, focusReason); | - |
3273 | } | 0 |
3274 | } | 0 |
3275 | } | 0 |
3276 | | - |
3277 | /*! | - |
3278 | Takes keyboard input focus from the item. | - |
3279 | | - |
3280 | If it has focus, a \l{focusOutEvent()}{focus out event} is sent to this | - |
3281 | item to tell it that it is about to lose the focus. | - |
3282 | | - |
3283 | Only items that set the ItemIsFocusable flag, or widgets that set an | - |
3284 | appropriate focus policy, can accept keyboard focus. | - |
3285 | | - |
3286 | \sa setFocus(), hasFocus(), QGraphicsWidget::focusPolicy | - |
3287 | */ | - |
3288 | void QGraphicsItem::clearFocus() | - |
3289 | { | - |
3290 | d_ptr->clearFocusHelper(/* giveFocusToParent = */ true, executed (the execution status of this line is deduced): d_ptr->clearFocusHelper( true, | - |
3291 | /* hiddenByParentPanel = */ false); executed (the execution status of this line is deduced): false); | - |
3292 | } executed: } Execution Count:2992 | 2992 |
3293 | | - |
3294 | /*! | - |
3295 | \internal | - |
3296 | */ | - |
3297 | void QGraphicsItemPrivate::clearFocusHelper(bool giveFocusToParent, bool hiddenByParentPanel) | - |
3298 | { | - |
3299 | QGraphicsItem *subFocusItem = q_ptr; executed (the execution status of this line is deduced): QGraphicsItem *subFocusItem = q_ptr; | - |
3300 | if (flags & QGraphicsItem::ItemIsFocusScope) { partially evaluated: flags & QGraphicsItem::ItemIsFocusScope no Evaluation Count:0 | yes Evaluation Count:2992 |
| 0-2992 |
3301 | while (subFocusItem->d_ptr->focusScopeItem) never evaluated: subFocusItem->d_ptr->focusScopeItem | 0 |
3302 | subFocusItem = subFocusItem->d_ptr->focusScopeItem; never executed: subFocusItem = subFocusItem->d_ptr->focusScopeItem; | 0 |
3303 | } | 0 |
3304 | | - |
3305 | if (giveFocusToParent) { partially evaluated: giveFocusToParent yes Evaluation Count:2992 | no Evaluation Count:0 |
| 0-2992 |
3306 | // Pass focus to the closest parent focus scope | - |
3307 | if (!inDestructor) { evaluated: !inDestructor yes Evaluation Count:937 | yes Evaluation Count:2055 |
| 937-2055 |
3308 | QGraphicsItem *p = parent; executed (the execution status of this line is deduced): QGraphicsItem *p = parent; | - |
3309 | while (p) { evaluated: p yes Evaluation Count:738 | yes Evaluation Count:937 |
| 738-937 |
3310 | if (p->flags() & QGraphicsItem::ItemIsFocusScope) { partially evaluated: p->flags() & QGraphicsItem::ItemIsFocusScope no Evaluation Count:0 | yes Evaluation Count:738 |
| 0-738 |
3311 | if (p->d_ptr->focusScopeItem == q_ptr) { never evaluated: p->d_ptr->focusScopeItem == q_ptr | 0 |
3312 | p->d_ptr->focusScopeItem = 0; never executed (the execution status of this line is deduced): p->d_ptr->focusScopeItem = 0; | - |
3313 | if (!subFocusItem->hasFocus()) //if it has focus, focusScopeItemChange is called elsewhere never evaluated: !subFocusItem->hasFocus() | 0 |
3314 | focusScopeItemChange(false); never executed: focusScopeItemChange(false); | 0 |
3315 | } | 0 |
3316 | if (subFocusItem->hasFocus()) never evaluated: subFocusItem->hasFocus() | 0 |
3317 | p->d_ptr->setFocusHelper(Qt::OtherFocusReason, /* climb = */ false, never executed: p->d_ptr->setFocusHelper(Qt::OtherFocusReason, false, false); | 0 |
3318 | /* focusFromHide = */ false); never executed: p->d_ptr->setFocusHelper(Qt::OtherFocusReason, false, false); | 0 |
3319 | return; | 0 |
3320 | } | - |
3321 | p = p->d_ptr->parent; executed (the execution status of this line is deduced): p = p->d_ptr->parent; | - |
3322 | } executed: } Execution Count:738 | 738 |
3323 | } executed: } Execution Count:937 | 937 |
3324 | } executed: } Execution Count:2992 | 2992 |
3325 | | - |
3326 | if (subFocusItem->hasFocus()) { partially evaluated: subFocusItem->hasFocus() no Evaluation Count:0 | yes Evaluation Count:2992 |
| 0-2992 |
3327 | // Invisible items with focus must explicitly clear subfocus. | - |
3328 | if (!hiddenByParentPanel) never evaluated: !hiddenByParentPanel | 0 |
3329 | clearSubFocus(q_ptr); never executed: clearSubFocus(q_ptr); | 0 |
3330 | | - |
3331 | // If this item has the scene's input focus, clear it. | - |
3332 | scene->setFocusItem(0); never executed (the execution status of this line is deduced): scene->setFocusItem(0); | - |
3333 | } | 0 |
3334 | } executed: } Execution Count:2992 | 2992 |
3335 | | - |
3336 | /*! | - |
3337 | \since 4.6 | - |
3338 | | - |
3339 | Returns this item's focus proxy, or 0 if this item has no | - |
3340 | focus proxy. | - |
3341 | | - |
3342 | \sa setFocusProxy(), setFocus(), hasFocus() | - |
3343 | */ | - |
3344 | QGraphicsItem *QGraphicsItem::focusProxy() const | - |
3345 | { | - |
3346 | return d_ptr->focusProxy; never executed: return d_ptr->focusProxy; | 0 |
3347 | } | - |
3348 | | - |
3349 | /*! | - |
3350 | \since 4.6 | - |
3351 | | - |
3352 | Sets the item's focus proxy to \a item. | - |
3353 | | - |
3354 | If an item has a focus proxy, the focus proxy will receive | - |
3355 | input focus when the item gains input focus. The item itself | - |
3356 | will still have focus (i.e., hasFocus() will return true), | - |
3357 | but only the focus proxy will receive the keyboard input. | - |
3358 | | - |
3359 | A focus proxy can itself have a focus proxy, and so on. In | - |
3360 | such case, keyboard input will be handled by the outermost | - |
3361 | focus proxy. | - |
3362 | | - |
3363 | The focus proxy \a item must belong to the same scene as | - |
3364 | this item. | - |
3365 | | - |
3366 | \sa focusProxy(), setFocus(), hasFocus() | - |
3367 | */ | - |
3368 | void QGraphicsItem::setFocusProxy(QGraphicsItem *item) | - |
3369 | { | - |
3370 | if (item == d_ptr->focusProxy) partially evaluated: item == d_ptr->focusProxy yes Evaluation Count:1061 | no Evaluation Count:0 |
| 0-1061 |
3371 | return; executed: return; Execution Count:1061 | 1061 |
3372 | if (item == this) { never evaluated: item == this | 0 |
3373 | qWarning("QGraphicsItem::setFocusProxy: cannot assign self as focus proxy"); never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 3373, __PRETTY_FUNCTION__).warning("QGraphicsItem::setFocusProxy: cannot assign self as focus proxy"); | - |
3374 | return; | 0 |
3375 | } | - |
3376 | if (item) { | 0 |
3377 | if (item->d_ptr->scene != d_ptr->scene) { never evaluated: item->d_ptr->scene != d_ptr->scene | 0 |
3378 | qWarning("QGraphicsItem::setFocusProxy: focus proxy must be in same scene"); never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 3378, __PRETTY_FUNCTION__).warning("QGraphicsItem::setFocusProxy: focus proxy must be in same scene"); | - |
3379 | return; | 0 |
3380 | } | - |
3381 | for (QGraphicsItem *f = item->focusProxy(); f != 0; f = f->focusProxy()) { | 0 |
3382 | if (f == this) { never evaluated: f == this | 0 |
3383 | qWarning("QGraphicsItem::setFocusProxy: %p is already in the focus proxy chain", item); never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 3383, __PRETTY_FUNCTION__).warning("QGraphicsItem::setFocusProxy: %p is already in the focus proxy chain", item); | - |
3384 | return; | 0 |
3385 | } | - |
3386 | } | 0 |
3387 | } | 0 |
3388 | | - |
3389 | QGraphicsItem *lastFocusProxy = d_ptr->focusProxy; never executed (the execution status of this line is deduced): QGraphicsItem *lastFocusProxy = d_ptr->focusProxy; | - |
3390 | if (lastFocusProxy) never evaluated: lastFocusProxy | 0 |
3391 | lastFocusProxy->d_ptr->focusProxyRefs.removeOne(&d_ptr->focusProxy); never executed: lastFocusProxy->d_ptr->focusProxyRefs.removeOne(&d_ptr->focusProxy); | 0 |
3392 | d_ptr->focusProxy = item; never executed (the execution status of this line is deduced): d_ptr->focusProxy = item; | - |
3393 | if (item) | 0 |
3394 | item->d_ptr->focusProxyRefs << &d_ptr->focusProxy; never executed: item->d_ptr->focusProxyRefs << &d_ptr->focusProxy; | 0 |
3395 | } | 0 |
3396 | | - |
3397 | /*! | - |
3398 | \since 4.6 | - |
3399 | | - |
3400 | If this item, a child or descendant of this item currently has input | - |
3401 | focus, this function will return a pointer to that item. If | - |
3402 | no descendant has input focus, 0 is returned. | - |
3403 | | - |
3404 | \sa hasFocus(), setFocus(), QWidget::focusWidget() | - |
3405 | */ | - |
3406 | QGraphicsItem *QGraphicsItem::focusItem() const | - |
3407 | { | - |
3408 | return d_ptr->subFocusItem; executed: return d_ptr->subFocusItem; Execution Count:1035 | 1035 |
3409 | } | - |
3410 | | - |
3411 | /*! | - |
3412 | \internal | - |
3413 | | - |
3414 | Returns this item's focus scope item. | - |
3415 | */ | - |
3416 | QGraphicsItem *QGraphicsItem::focusScopeItem() const | - |
3417 | { | - |
3418 | return d_ptr->focusScopeItem; never executed: return d_ptr->focusScopeItem; | 0 |
3419 | } | - |
3420 | | - |
3421 | /*! | - |
3422 | \since 4.4 | - |
3423 | Grabs the mouse input. | - |
3424 | | - |
3425 | This item will receive all mouse events for the scene until any of the | - |
3426 | following events occurs: | - |
3427 | | - |
3428 | \list | - |
3429 | \li The item becomes invisible | - |
3430 | \li The item is removed from the scene | - |
3431 | \li The item is deleted | - |
3432 | \li The item call ungrabMouse() | - |
3433 | \li Another item calls grabMouse(); the item will regain the mouse grab | - |
3434 | when the other item calls ungrabMouse(). | - |
3435 | \endlist | - |
3436 | | - |
3437 | When an item gains the mouse grab, it receives a QEvent::GrabMouse | - |
3438 | event. When it loses the mouse grab, it receives a QEvent::UngrabMouse | - |
3439 | event. These events can be used to detect when your item gains or loses | - |
3440 | the mouse grab through other means than receiving mouse button events. | - |
3441 | | - |
3442 | It is almost never necessary to explicitly grab the mouse in Qt, as Qt | - |
3443 | grabs and releases it sensibly. In particular, Qt grabs the mouse when you | - |
3444 | press a mouse button, and keeps the mouse grabbed until you release the | - |
3445 | last mouse button. Also, Qt::Popup widgets implicitly call grabMouse() | - |
3446 | when shown, and ungrabMouse() when hidden. | - |
3447 | | - |
3448 | Note that only visible items can grab mouse input. Calling grabMouse() on | - |
3449 | an invisible item has no effect. | - |
3450 | | - |
3451 | Keyboard events are not affected. | - |
3452 | | - |
3453 | \sa QGraphicsScene::mouseGrabberItem(), ungrabMouse(), grabKeyboard() | - |
3454 | */ | - |
3455 | void QGraphicsItem::grabMouse() | - |
3456 | { | - |
3457 | if (!d_ptr->scene) { never evaluated: !d_ptr->scene | 0 |
3458 | qWarning("QGraphicsItem::grabMouse: cannot grab mouse without scene"); never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 3458, __PRETTY_FUNCTION__).warning("QGraphicsItem::grabMouse: cannot grab mouse without scene"); | - |
3459 | return; | 0 |
3460 | } | - |
3461 | if (!d_ptr->visible) { never evaluated: !d_ptr->visible | 0 |
3462 | qWarning("QGraphicsItem::grabMouse: cannot grab mouse while invisible"); never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 3462, __PRETTY_FUNCTION__).warning("QGraphicsItem::grabMouse: cannot grab mouse while invisible"); | - |
3463 | return; | 0 |
3464 | } | - |
3465 | d_ptr->scene->d_func()->grabMouse(this); never executed (the execution status of this line is deduced): d_ptr->scene->d_func()->grabMouse(this); | - |
3466 | } | 0 |
3467 | | - |
3468 | /*! | - |
3469 | \since 4.4 | - |
3470 | Releases the mouse grab. | - |
3471 | | - |
3472 | \sa grabMouse(), ungrabKeyboard() | - |
3473 | */ | - |
3474 | void QGraphicsItem::ungrabMouse() | - |
3475 | { | - |
3476 | if (!d_ptr->scene) { partially evaluated: !d_ptr->scene no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
3477 | qWarning("QGraphicsItem::ungrabMouse: cannot ungrab mouse without scene"); never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 3477, __PRETTY_FUNCTION__).warning("QGraphicsItem::ungrabMouse: cannot ungrab mouse without scene"); | - |
3478 | return; | 0 |
3479 | } | - |
3480 | d_ptr->scene->d_func()->ungrabMouse(this); executed (the execution status of this line is deduced): d_ptr->scene->d_func()->ungrabMouse(this); | - |
3481 | } executed: } Execution Count:2 | 2 |
3482 | | - |
3483 | /*! | - |
3484 | \since 4.4 | - |
3485 | Grabs the keyboard input. | - |
3486 | | - |
3487 | The item will receive all keyboard input to the scene until one of the | - |
3488 | following events occur: | - |
3489 | | - |
3490 | \list | - |
3491 | \li The item becomes invisible | - |
3492 | \li The item is removed from the scene | - |
3493 | \li The item is deleted | - |
3494 | \li The item calls ungrabKeyboard() | - |
3495 | \li Another item calls grabKeyboard(); the item will regain the keyboard grab | - |
3496 | when the other item calls ungrabKeyboard(). | - |
3497 | \endlist | - |
3498 | | - |
3499 | When an item gains the keyboard grab, it receives a QEvent::GrabKeyboard | - |
3500 | event. When it loses the keyboard grab, it receives a | - |
3501 | QEvent::UngrabKeyboard event. These events can be used to detect when your | - |
3502 | item gains or loses the keyboard grab through other means than gaining | - |
3503 | input focus. | - |
3504 | | - |
3505 | It is almost never necessary to explicitly grab the keyboard in Qt, as Qt | - |
3506 | grabs and releases it sensibly. In particular, Qt grabs the keyboard when | - |
3507 | your item gains input focus, and releases it when your item loses input | - |
3508 | focus, or when the item is hidden. | - |
3509 | | - |
3510 | Note that only visible items can grab keyboard input. Calling | - |
3511 | grabKeyboard() on an invisible item has no effect. | - |
3512 | | - |
3513 | Keyboard events are not affected. | - |
3514 | | - |
3515 | \sa ungrabKeyboard(), grabMouse(), setFocus() | - |
3516 | */ | - |
3517 | void QGraphicsItem::grabKeyboard() | - |
3518 | { | - |
3519 | if (!d_ptr->scene) { never evaluated: !d_ptr->scene | 0 |
3520 | qWarning("QGraphicsItem::grabKeyboard: cannot grab keyboard without scene"); never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 3520, __PRETTY_FUNCTION__).warning("QGraphicsItem::grabKeyboard: cannot grab keyboard without scene"); | - |
3521 | return; | 0 |
3522 | } | - |
3523 | if (!d_ptr->visible) { never evaluated: !d_ptr->visible | 0 |
3524 | qWarning("QGraphicsItem::grabKeyboard: cannot grab keyboard while invisible"); never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 3524, __PRETTY_FUNCTION__).warning("QGraphicsItem::grabKeyboard: cannot grab keyboard while invisible"); | - |
3525 | return; | 0 |
3526 | } | - |
3527 | d_ptr->scene->d_func()->grabKeyboard(this); never executed (the execution status of this line is deduced): d_ptr->scene->d_func()->grabKeyboard(this); | - |
3528 | } | 0 |
3529 | | - |
3530 | /*! | - |
3531 | \since 4.4 | - |
3532 | Releases the keyboard grab. | - |
3533 | | - |
3534 | \sa grabKeyboard(), ungrabMouse() | - |
3535 | */ | - |
3536 | void QGraphicsItem::ungrabKeyboard() | - |
3537 | { | - |
3538 | if (!d_ptr->scene) { never evaluated: !d_ptr->scene | 0 |
3539 | qWarning("QGraphicsItem::ungrabKeyboard: cannot ungrab keyboard without scene"); never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 3539, __PRETTY_FUNCTION__).warning("QGraphicsItem::ungrabKeyboard: cannot ungrab keyboard without scene"); | - |
3540 | return; | 0 |
3541 | } | - |
3542 | d_ptr->scene->d_func()->ungrabKeyboard(this); never executed (the execution status of this line is deduced): d_ptr->scene->d_func()->ungrabKeyboard(this); | - |
3543 | } | 0 |
3544 | | - |
3545 | /*! | - |
3546 | Returns the position of the item in parent coordinates. If the item has no | - |
3547 | parent, its position is given in scene coordinates. | - |
3548 | | - |
3549 | The position of the item describes its origin (local coordinate | - |
3550 | (0, 0)) in parent coordinates; this function returns the same as | - |
3551 | mapToParent(0, 0). | - |
3552 | | - |
3553 | For convenience, you can also call scenePos() to determine the | - |
3554 | item's position in scene coordinates, regardless of its parent. | - |
3555 | | - |
3556 | \sa x(), y(), setPos(), transform(), {The Graphics View Coordinate System} | - |
3557 | */ | - |
3558 | QPointF QGraphicsItem::pos() const | - |
3559 | { | - |
3560 | return d_ptr->pos; executed: return d_ptr->pos; Execution Count:7925 | 7925 |
3561 | } | - |
3562 | | - |
3563 | /*! | - |
3564 | \fn QGraphicsItem::x() const | - |
3565 | | - |
3566 | This convenience function is equivalent to calling pos().x(). | - |
3567 | | - |
3568 | \sa y() | - |
3569 | */ | - |
3570 | | - |
3571 | /*! | - |
3572 | \since 4.6 | - |
3573 | | - |
3574 | Set's the \a x coordinate of the item's position. Equivalent to | - |
3575 | calling setPos(x, y()). | - |
3576 | | - |
3577 | \sa x(), setPos() | - |
3578 | */ | - |
3579 | void QGraphicsItem::setX(qreal x) | - |
3580 | { | - |
3581 | if (d_ptr->inDestructor) partially evaluated: d_ptr->inDestructor no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
3582 | return; | 0 |
3583 | | - |
3584 | if (qIsNaN(x)) partially evaluated: qIsNaN(x) no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
3585 | return; | 0 |
3586 | | - |
3587 | setPos(QPointF(x, d_ptr->pos.y())); executed (the execution status of this line is deduced): setPos(QPointF(x, d_ptr->pos.y())); | - |
3588 | } executed: } Execution Count:3 | 3 |
3589 | | - |
3590 | /*! | - |
3591 | \fn QGraphicsItem::y() const | - |
3592 | | - |
3593 | This convenience function is equivalent to calling pos().y(). | - |
3594 | | - |
3595 | \sa x() | - |
3596 | */ | - |
3597 | | - |
3598 | /*! | - |
3599 | \since 4.6 | - |
3600 | | - |
3601 | Set's the \a y coordinate of the item's position. Equivalent to | - |
3602 | calling setPos(x(), y). | - |
3603 | | - |
3604 | \sa x(), setPos() | - |
3605 | */ | - |
3606 | void QGraphicsItem::setY(qreal y) | - |
3607 | { | - |
3608 | if (d_ptr->inDestructor) partially evaluated: d_ptr->inDestructor no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
3609 | return; | 0 |
3610 | | - |
3611 | if (qIsNaN(y)) partially evaluated: qIsNaN(y) no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
3612 | return; | 0 |
3613 | | - |
3614 | setPos(QPointF(d_ptr->pos.x(), y)); executed (the execution status of this line is deduced): setPos(QPointF(d_ptr->pos.x(), y)); | - |
3615 | } executed: } Execution Count:3 | 3 |
3616 | | - |
3617 | /*! | - |
3618 | Returns the item's position in scene coordinates. This is | - |
3619 | equivalent to calling \c mapToScene(0, 0). | - |
3620 | | - |
3621 | \sa pos(), sceneTransform(), {The Graphics View Coordinate System} | - |
3622 | */ | - |
3623 | QPointF QGraphicsItem::scenePos() const | - |
3624 | { | - |
3625 | return mapToScene(0, 0); never executed: return mapToScene(0, 0); | 0 |
3626 | } | - |
3627 | | - |
3628 | /*! | - |
3629 | \internal | - |
3630 | | - |
3631 | Sets the position \a pos. | - |
3632 | */ | - |
3633 | void QGraphicsItemPrivate::setPosHelper(const QPointF &pos) | - |
3634 | { | - |
3635 | Q_Q(QGraphicsItem); executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func(); | - |
3636 | inSetPosHelper = 1; executed (the execution status of this line is deduced): inSetPosHelper = 1; | - |
3637 | if (scene) evaluated: scene yes Evaluation Count:742 | yes Evaluation Count:37 |
| 37-742 |
3638 | q->prepareGeometryChange(); executed: q->prepareGeometryChange(); Execution Count:742 | 742 |
3639 | QPointF oldPos = this->pos; executed (the execution status of this line is deduced): QPointF oldPos = this->pos; | - |
3640 | this->pos = pos; executed (the execution status of this line is deduced): this->pos = pos; | - |
3641 | dirtySceneTransform = 1; executed (the execution status of this line is deduced): dirtySceneTransform = 1; | - |
3642 | inSetPosHelper = 0; executed (the execution status of this line is deduced): inSetPosHelper = 0; | - |
3643 | if (isObject) { partially evaluated: isObject yes Evaluation Count:779 | no Evaluation Count:0 |
| 0-779 |
3644 | if (pos.x() != oldPos.x()) evaluated: pos.x() != oldPos.x() yes Evaluation Count:613 | yes Evaluation Count:166 |
| 166-613 |
3645 | emit static_cast<QGraphicsObject *>(q_ptr)->xChanged(); executed: static_cast<QGraphicsObject *>(q_ptr)->xChanged(); Execution Count:613 | 613 |
3646 | if (pos.y() != oldPos.y()) evaluated: pos.y() != oldPos.y() yes Evaluation Count:486 | yes Evaluation Count:293 |
| 293-486 |
3647 | emit static_cast<QGraphicsObject *>(q_ptr)->yChanged(); executed: static_cast<QGraphicsObject *>(q_ptr)->yChanged(); Execution Count:486 | 486 |
3648 | } executed: } Execution Count:779 | 779 |
3649 | } executed: } Execution Count:779 | 779 |
3650 | | - |
3651 | /*! | - |
3652 | \internal | - |
3653 | | - |
3654 | Sets the transform \a transform. | - |
3655 | */ | - |
3656 | void QGraphicsItemPrivate::setTransformHelper(const QTransform &transform) | - |
3657 | { | - |
3658 | q_ptr->prepareGeometryChange(); executed (the execution status of this line is deduced): q_ptr->prepareGeometryChange(); | - |
3659 | transformData->transform = transform; executed (the execution status of this line is deduced): transformData->transform = transform; | - |
3660 | dirtySceneTransform = 1; executed (the execution status of this line is deduced): dirtySceneTransform = 1; | - |
3661 | transformChanged(); executed (the execution status of this line is deduced): transformChanged(); | - |
3662 | } executed: } Execution Count:3 | 3 |
3663 | | - |
3664 | /*! | - |
3665 | Sets the position of the item to \a pos, which is in parent | - |
3666 | coordinates. For items with no parent, \a pos is in scene | - |
3667 | coordinates. | - |
3668 | | - |
3669 | The position of the item describes its origin (local coordinate | - |
3670 | (0, 0)) in parent coordinates. | - |
3671 | | - |
3672 | \sa pos(), scenePos(), {The Graphics View Coordinate System} | - |
3673 | */ | - |
3674 | void QGraphicsItem::setPos(const QPointF &pos) | - |
3675 | { | - |
3676 | if (d_ptr->pos == pos) evaluated: d_ptr->pos == pos yes Evaluation Count:1215 | yes Evaluation Count:779 |
| 779-1215 |
3677 | return; executed: return; Execution Count:1215 | 1215 |
3678 | | - |
3679 | if (d_ptr->inDestructor) partially evaluated: d_ptr->inDestructor no Evaluation Count:0 | yes Evaluation Count:779 |
| 0-779 |
3680 | return; | 0 |
3681 | | - |
3682 | // Update and repositition. | - |
3683 | if (!(d_ptr->flags & (ItemSendsGeometryChanges | ItemSendsScenePositionChanges))) { evaluated: !(d_ptr->flags & (ItemSendsGeometryChanges | ItemSendsScenePositionChanges)) yes Evaluation Count:26 | yes Evaluation Count:753 |
| 26-753 |
3684 | d_ptr->setPosHelper(pos); executed (the execution status of this line is deduced): d_ptr->setPosHelper(pos); | - |
3685 | if (d_ptr->isWidget) partially evaluated: d_ptr->isWidget no Evaluation Count:0 | yes Evaluation Count:26 |
| 0-26 |
3686 | static_cast<QGraphicsWidget *>(this)->d_func()->setGeometryFromSetPos(); never executed: static_cast<QGraphicsWidget *>(this)->d_func()->setGeometryFromSetPos(); | 0 |
3687 | if (d_ptr->scenePosDescendants) partially evaluated: d_ptr->scenePosDescendants no Evaluation Count:0 | yes Evaluation Count:26 |
| 0-26 |
3688 | d_ptr->sendScenePosChange(); never executed: d_ptr->sendScenePosChange(); | 0 |
3689 | return; executed: return; Execution Count:26 | 26 |
3690 | } | - |
3691 | | - |
3692 | // Notify the item that the position is changing. | - |
3693 | const QVariant newPosVariant(itemChange(ItemPositionChange, QVariant::fromValue<QPointF>(pos))); executed (the execution status of this line is deduced): const QVariant newPosVariant(itemChange(ItemPositionChange, QVariant::fromValue<QPointF>(pos))); | - |
3694 | QPointF newPos = newPosVariant.toPointF(); executed (the execution status of this line is deduced): QPointF newPos = newPosVariant.toPointF(); | - |
3695 | if (newPos == d_ptr->pos) partially evaluated: newPos == d_ptr->pos no Evaluation Count:0 | yes Evaluation Count:753 |
| 0-753 |
3696 | return; | 0 |
3697 | | - |
3698 | // Update and repositition. | - |
3699 | d_ptr->setPosHelper(newPos); executed (the execution status of this line is deduced): d_ptr->setPosHelper(newPos); | - |
3700 | | - |
3701 | // Send post-notification. | - |
3702 | itemChange(QGraphicsItem::ItemPositionHasChanged, newPosVariant); executed (the execution status of this line is deduced): itemChange(QGraphicsItem::ItemPositionHasChanged, newPosVariant); | - |
3703 | d_ptr->sendScenePosChange(); executed (the execution status of this line is deduced): d_ptr->sendScenePosChange(); | - |
3704 | } executed: } Execution Count:753 | 753 |
3705 | | - |
3706 | /*! | - |
3707 | \fn void QGraphicsItem::setPos(qreal x, qreal y) | - |
3708 | \overload | - |
3709 | | - |
3710 | This convenience function is equivalent to calling setPos(QPointF(\a x, \a | - |
3711 | y)). | - |
3712 | */ | - |
3713 | | - |
3714 | /*! | - |
3715 | \fn void QGraphicsItem::moveBy(qreal dx, qreal dy) | - |
3716 | | - |
3717 | Moves the item by \a dx points horizontally, and \a dy point | - |
3718 | vertically. This function is equivalent to calling setPos(pos() + | - |
3719 | QPointF(\a dx, \a dy)). | - |
3720 | */ | - |
3721 | | - |
3722 | /*! | - |
3723 | If this item is part of a scene that is viewed by a QGraphicsView, this | - |
3724 | convenience function will attempt to scroll the view to ensure that \a | - |
3725 | rect is visible inside the view's viewport. If \a rect is a null rect (the | - |
3726 | default), QGraphicsItem will default to the item's bounding rect. \a xmargin | - |
3727 | and \a ymargin are the number of pixels the view should use for margins. | - |
3728 | | - |
3729 | If the specified rect cannot be reached, the contents are scrolled to the | - |
3730 | nearest valid position. | - |
3731 | | - |
3732 | If this item is not viewed by a QGraphicsView, this function does nothing. | - |
3733 | | - |
3734 | \sa QGraphicsView::ensureVisible() | - |
3735 | */ | - |
3736 | void QGraphicsItem::ensureVisible(const QRectF &rect, int xmargin, int ymargin) | - |
3737 | { | - |
3738 | if (d_ptr->scene) { never evaluated: d_ptr->scene | 0 |
3739 | QRectF sceneRect; never executed (the execution status of this line is deduced): QRectF sceneRect; | - |
3740 | if (!rect.isNull()) never evaluated: !rect.isNull() | 0 |
3741 | sceneRect = sceneTransform().mapRect(rect); never executed: sceneRect = sceneTransform().mapRect(rect); | 0 |
3742 | else | - |
3743 | sceneRect = sceneBoundingRect(); never executed: sceneRect = sceneBoundingRect(); | 0 |
3744 | foreach (QGraphicsView *view, d_ptr->scene->d_func()->views) never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(d_ptr->scene->d_func()->views)> _container_(d_ptr->scene->d_func()->views); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsView *view = *_container_.i;; __extension__ ({--_container_.brk; break;})) | - |
3745 | view->ensureVisible(sceneRect, xmargin, ymargin); never executed: view->ensureVisible(sceneRect, xmargin, ymargin); | 0 |
3746 | } | 0 |
3747 | } | 0 |
3748 | | - |
3749 | /*! | - |
3750 | \fn void QGraphicsItem::ensureVisible(qreal x, qreal y, qreal w, qreal h, | - |
3751 | int xmargin = 50, int ymargin = 50) | - |
3752 | | - |
3753 | This convenience function is equivalent to calling | - |
3754 | ensureVisible(QRectF(\a x, \a y, \a w, \a h), \a xmargin, \a ymargin). | - |
3755 | */ | - |
3756 | | - |
3757 | /*! | - |
3758 | \obsolete | - |
3759 | | - |
3760 | Returns the item's affine transformation matrix. This is a subset or the | - |
3761 | item's full transformation matrix, and might not represent the item's full | - |
3762 | transformation. | - |
3763 | | - |
3764 | Use transform() instead. | - |
3765 | | - |
3766 | \sa setTransform(), sceneTransform() | - |
3767 | */ | - |
3768 | QMatrix QGraphicsItem::matrix() const | - |
3769 | { | - |
3770 | return transform().toAffine(); never executed: return transform().toAffine(); | 0 |
3771 | } | - |
3772 | | - |
3773 | /*! | - |
3774 | \since 4.3 | - |
3775 | | - |
3776 | Returns this item's transformation matrix. | - |
3777 | | - |
3778 | The transformation matrix is combined with the item's rotation(), scale() | - |
3779 | and transformations() into a combined transformations for the item. | - |
3780 | | - |
3781 | The default transformation matrix is an identity matrix. | - |
3782 | | - |
3783 | \sa setTransform(), sceneTransform() | - |
3784 | */ | - |
3785 | QTransform QGraphicsItem::transform() const | - |
3786 | { | - |
3787 | if (!d_ptr->transformData) never evaluated: !d_ptr->transformData | 0 |
3788 | return QTransform(); never executed: return QTransform(); | 0 |
3789 | return d_ptr->transformData->transform; never executed: return d_ptr->transformData->transform; | 0 |
3790 | } | - |
3791 | | - |
3792 | /*! | - |
3793 | \since 4.6 | - |
3794 | | - |
3795 | Returns the clockwise rotation, in degrees, around the Z axis. The default | - |
3796 | value is 0 (i.e., the item is not rotated). | - |
3797 | | - |
3798 | The rotation is combined with the item's scale(), transform() and | - |
3799 | transformations() to map the item's coordinate system to the parent item. | - |
3800 | | - |
3801 | \sa setRotation(), transformOriginPoint(), {Transformations} | - |
3802 | */ | - |
3803 | qreal QGraphicsItem::rotation() const | - |
3804 | { | - |
3805 | if (!d_ptr->transformData) never evaluated: !d_ptr->transformData | 0 |
3806 | return 0; never executed: return 0; | 0 |
3807 | return d_ptr->transformData->rotation; never executed: return d_ptr->transformData->rotation; | 0 |
3808 | } | - |
3809 | | - |
3810 | /*! | - |
3811 | \since 4.6 | - |
3812 | | - |
3813 | Sets the clockwise rotation \a angle, in degrees, around the Z axis. The | - |
3814 | default value is 0 (i.e., the item is not rotated). Assigning a negative | - |
3815 | value will rotate the item counter-clockwise. Normally the rotation angle | - |
3816 | is in the range (-360, 360), but it's also possible to assign values | - |
3817 | outside of this range (e.g., a rotation of 370 degrees is the same as a | - |
3818 | rotation of 10 degrees). | - |
3819 | | - |
3820 | The item is rotated around its transform origin point, which by default | - |
3821 | is (0, 0). You can select a different transformation origin by calling | - |
3822 | setTransformOriginPoint(). | - |
3823 | | - |
3824 | The rotation is combined with the item's scale(), transform() and | - |
3825 | transformations() to map the item's coordinate system to the parent item. | - |
3826 | | - |
3827 | \sa rotation(), setTransformOriginPoint(), {Transformations} | - |
3828 | */ | - |
3829 | void QGraphicsItem::setRotation(qreal angle) | - |
3830 | { | - |
3831 | prepareGeometryChange(); never executed (the execution status of this line is deduced): prepareGeometryChange(); | - |
3832 | qreal newRotation = angle; never executed (the execution status of this line is deduced): qreal newRotation = angle; | - |
3833 | | - |
3834 | if (d_ptr->flags & ItemSendsGeometryChanges) { never evaluated: d_ptr->flags & ItemSendsGeometryChanges | 0 |
3835 | // Notify the item that the rotation is changing. | - |
3836 | const QVariant newRotationVariant(itemChange(ItemRotationChange, angle)); never executed (the execution status of this line is deduced): const QVariant newRotationVariant(itemChange(ItemRotationChange, angle)); | - |
3837 | newRotation = newRotationVariant.toReal(); never executed (the execution status of this line is deduced): newRotation = newRotationVariant.toReal(); | - |
3838 | } | 0 |
3839 | | - |
3840 | if (!d_ptr->transformData) never evaluated: !d_ptr->transformData | 0 |
3841 | d_ptr->transformData = new QGraphicsItemPrivate::TransformData; never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData; | 0 |
3842 | | - |
3843 | if (d_ptr->transformData->rotation == newRotation) never evaluated: d_ptr->transformData->rotation == newRotation | 0 |
3844 | return; | 0 |
3845 | | - |
3846 | d_ptr->transformData->rotation = newRotation; never executed (the execution status of this line is deduced): d_ptr->transformData->rotation = newRotation; | - |
3847 | d_ptr->transformData->onlyTransform = false; never executed (the execution status of this line is deduced): d_ptr->transformData->onlyTransform = false; | - |
3848 | d_ptr->dirtySceneTransform = 1; never executed (the execution status of this line is deduced): d_ptr->dirtySceneTransform = 1; | - |
3849 | | - |
3850 | // Send post-notification. | - |
3851 | if (d_ptr->flags & ItemSendsGeometryChanges) never evaluated: d_ptr->flags & ItemSendsGeometryChanges | 0 |
3852 | itemChange(ItemRotationHasChanged, newRotation); never executed: itemChange(ItemRotationHasChanged, newRotation); | 0 |
3853 | | - |
3854 | if (d_ptr->isObject) never evaluated: d_ptr->isObject | 0 |
3855 | emit static_cast<QGraphicsObject *>(this)->rotationChanged(); never executed: static_cast<QGraphicsObject *>(this)->rotationChanged(); | 0 |
3856 | | - |
3857 | d_ptr->transformChanged(); never executed (the execution status of this line is deduced): d_ptr->transformChanged(); | - |
3858 | } | 0 |
3859 | | - |
3860 | /*! | - |
3861 | \since 4.6 | - |
3862 | | - |
3863 | Returns the scale factor of the item. The default scale factor is 1.0 | - |
3864 | (i.e., the item is not scaled). | - |
3865 | | - |
3866 | The scale is combined with the item's rotation(), transform() and | - |
3867 | transformations() to map the item's coordinate system to the parent item. | - |
3868 | | - |
3869 | \sa setScale(), rotation(), {Transformations} | - |
3870 | */ | - |
3871 | qreal QGraphicsItem::scale() const | - |
3872 | { | - |
3873 | if (!d_ptr->transformData) never evaluated: !d_ptr->transformData | 0 |
3874 | return 1.; never executed: return 1.; | 0 |
3875 | return d_ptr->transformData->scale; never executed: return d_ptr->transformData->scale; | 0 |
3876 | } | - |
3877 | | - |
3878 | /*! | - |
3879 | \since 4.6 | - |
3880 | | - |
3881 | Sets the scale \a factor of the item. The default scale factor is 1.0 | - |
3882 | (i.e., the item is not scaled). A scale factor of 0.0 will collapse the | - |
3883 | item to a single point. If you provide a negative scale factor, the | - |
3884 | item will be flipped and mirrored (i.e., rotated 180 degrees). | - |
3885 | | - |
3886 | The item is scaled around its transform origin point, which by default | - |
3887 | is (0, 0). You can select a different transformation origin by calling | - |
3888 | setTransformOriginPoint(). | - |
3889 | | - |
3890 | The scale is combined with the item's rotation(), transform() and | - |
3891 | transformations() to map the item's coordinate system to the parent item. | - |
3892 | | - |
3893 | \sa scale(), setTransformOriginPoint(), {Transformations Example} | - |
3894 | */ | - |
3895 | void QGraphicsItem::setScale(qreal factor) | - |
3896 | { | - |
3897 | prepareGeometryChange(); never executed (the execution status of this line is deduced): prepareGeometryChange(); | - |
3898 | qreal newScale = factor; never executed (the execution status of this line is deduced): qreal newScale = factor; | - |
3899 | | - |
3900 | if (d_ptr->flags & ItemSendsGeometryChanges) { never evaluated: d_ptr->flags & ItemSendsGeometryChanges | 0 |
3901 | // Notify the item that the scale is changing. | - |
3902 | const QVariant newScaleVariant(itemChange(ItemScaleChange, factor)); never executed (the execution status of this line is deduced): const QVariant newScaleVariant(itemChange(ItemScaleChange, factor)); | - |
3903 | newScale = newScaleVariant.toReal(); never executed (the execution status of this line is deduced): newScale = newScaleVariant.toReal(); | - |
3904 | } | 0 |
3905 | | - |
3906 | if (!d_ptr->transformData) never evaluated: !d_ptr->transformData | 0 |
3907 | d_ptr->transformData = new QGraphicsItemPrivate::TransformData; never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData; | 0 |
3908 | | - |
3909 | if (d_ptr->transformData->scale == newScale) never evaluated: d_ptr->transformData->scale == newScale | 0 |
3910 | return; | 0 |
3911 | | - |
3912 | d_ptr->transformData->scale = newScale; never executed (the execution status of this line is deduced): d_ptr->transformData->scale = newScale; | - |
3913 | d_ptr->transformData->onlyTransform = false; never executed (the execution status of this line is deduced): d_ptr->transformData->onlyTransform = false; | - |
3914 | d_ptr->dirtySceneTransform = 1; never executed (the execution status of this line is deduced): d_ptr->dirtySceneTransform = 1; | - |
3915 | | - |
3916 | // Send post-notification. | - |
3917 | if (d_ptr->flags & ItemSendsGeometryChanges) never evaluated: d_ptr->flags & ItemSendsGeometryChanges | 0 |
3918 | itemChange(ItemScaleHasChanged, newScale); never executed: itemChange(ItemScaleHasChanged, newScale); | 0 |
3919 | | - |
3920 | if (d_ptr->isObject) never evaluated: d_ptr->isObject | 0 |
3921 | emit static_cast<QGraphicsObject *>(this)->scaleChanged(); never executed: static_cast<QGraphicsObject *>(this)->scaleChanged(); | 0 |
3922 | | - |
3923 | d_ptr->transformChanged(); never executed (the execution status of this line is deduced): d_ptr->transformChanged(); | - |
3924 | } | 0 |
3925 | | - |
3926 | | - |
3927 | /*! | - |
3928 | \since 4.6 | - |
3929 | | - |
3930 | Returns a list of graphics transforms that currently apply to this item. | - |
3931 | | - |
3932 | QGraphicsTransform is for applying and controlling a chain of individual | - |
3933 | transformation operations on an item. It's particularly useful in | - |
3934 | animations, where each transform operation needs to be interpolated | - |
3935 | independently, or differently. | - |
3936 | | - |
3937 | The transformations are combined with the item's rotation(), scale() and | - |
3938 | transform() to map the item's coordinate system to the parent item. | - |
3939 | | - |
3940 | \sa scale(), rotation(), transformOriginPoint(), {Transformations} | - |
3941 | */ | - |
3942 | QList<QGraphicsTransform *> QGraphicsItem::transformations() const | - |
3943 | { | - |
3944 | if (!d_ptr->transformData) never evaluated: !d_ptr->transformData | 0 |
3945 | return QList<QGraphicsTransform *>(); never executed: return QList<QGraphicsTransform *>(); | 0 |
3946 | return d_ptr->transformData->graphicsTransforms; never executed: return d_ptr->transformData->graphicsTransforms; | 0 |
3947 | } | - |
3948 | | - |
3949 | /*! | - |
3950 | \since 4.6 | - |
3951 | | - |
3952 | Sets a list of graphics \a transformations (QGraphicsTransform) that | - |
3953 | currently apply to this item. | - |
3954 | | - |
3955 | If all you want is to rotate or scale an item, you should call setRotation() | - |
3956 | or setScale() instead. If you want to set an arbitrary transformation on | - |
3957 | an item, you can call setTransform(). | - |
3958 | | - |
3959 | QGraphicsTransform is for applying and controlling a chain of individual | - |
3960 | transformation operations on an item. It's particularly useful in | - |
3961 | animations, where each transform operation needs to be interpolated | - |
3962 | independently, or differently. | - |
3963 | | - |
3964 | The transformations are combined with the item's rotation(), scale() and | - |
3965 | transform() to map the item's coordinate system to the parent item. | - |
3966 | | - |
3967 | \sa scale(), setTransformOriginPoint(), {Transformations} | - |
3968 | */ | - |
3969 | void QGraphicsItem::setTransformations(const QList<QGraphicsTransform *> &transformations) | - |
3970 | { | - |
3971 | prepareGeometryChange(); never executed (the execution status of this line is deduced): prepareGeometryChange(); | - |
3972 | if (!d_ptr->transformData) never evaluated: !d_ptr->transformData | 0 |
3973 | d_ptr->transformData = new QGraphicsItemPrivate::TransformData; never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData; | 0 |
3974 | d_ptr->transformData->graphicsTransforms = transformations; never executed (the execution status of this line is deduced): d_ptr->transformData->graphicsTransforms = transformations; | - |
3975 | for (int i = 0; i < transformations.size(); ++i) never evaluated: i < transformations.size() | 0 |
3976 | transformations.at(i)->d_func()->setItem(this); never executed: transformations.at(i)->d_func()->setItem(this); | 0 |
3977 | d_ptr->transformData->onlyTransform = false; never executed (the execution status of this line is deduced): d_ptr->transformData->onlyTransform = false; | - |
3978 | d_ptr->dirtySceneTransform = 1; never executed (the execution status of this line is deduced): d_ptr->dirtySceneTransform = 1; | - |
3979 | d_ptr->transformChanged(); never executed (the execution status of this line is deduced): d_ptr->transformChanged(); | - |
3980 | } | 0 |
3981 | | - |
3982 | /*! | - |
3983 | \internal | - |
3984 | */ | - |
3985 | void QGraphicsItemPrivate::prependGraphicsTransform(QGraphicsTransform *t) | - |
3986 | { | - |
3987 | if (!transformData) never evaluated: !transformData | 0 |
3988 | transformData = new QGraphicsItemPrivate::TransformData; never executed: transformData = new QGraphicsItemPrivate::TransformData; | 0 |
3989 | if (!transformData->graphicsTransforms.contains(t)) never evaluated: !transformData->graphicsTransforms.contains(t) | 0 |
3990 | transformData->graphicsTransforms.prepend(t); never executed: transformData->graphicsTransforms.prepend(t); | 0 |
3991 | | - |
3992 | Q_Q(QGraphicsItem); never executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func(); | - |
3993 | t->d_func()->setItem(q); never executed (the execution status of this line is deduced): t->d_func()->setItem(q); | - |
3994 | transformData->onlyTransform = false; never executed (the execution status of this line is deduced): transformData->onlyTransform = false; | - |
3995 | dirtySceneTransform = 1; never executed (the execution status of this line is deduced): dirtySceneTransform = 1; | - |
3996 | transformChanged(); never executed (the execution status of this line is deduced): transformChanged(); | - |
3997 | } | 0 |
3998 | | - |
3999 | /*! | - |
4000 | \internal | - |
4001 | */ | - |
4002 | void QGraphicsItemPrivate::appendGraphicsTransform(QGraphicsTransform *t) | - |
4003 | { | - |
4004 | if (!transformData) never evaluated: !transformData | 0 |
4005 | transformData = new QGraphicsItemPrivate::TransformData; never executed: transformData = new QGraphicsItemPrivate::TransformData; | 0 |
4006 | if (!transformData->graphicsTransforms.contains(t)) never evaluated: !transformData->graphicsTransforms.contains(t) | 0 |
4007 | transformData->graphicsTransforms.append(t); never executed: transformData->graphicsTransforms.append(t); | 0 |
4008 | | - |
4009 | Q_Q(QGraphicsItem); never executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func(); | - |
4010 | t->d_func()->setItem(q); never executed (the execution status of this line is deduced): t->d_func()->setItem(q); | - |
4011 | transformData->onlyTransform = false; never executed (the execution status of this line is deduced): transformData->onlyTransform = false; | - |
4012 | dirtySceneTransform = 1; never executed (the execution status of this line is deduced): dirtySceneTransform = 1; | - |
4013 | transformChanged(); never executed (the execution status of this line is deduced): transformChanged(); | - |
4014 | } | 0 |
4015 | | - |
4016 | /*! | - |
4017 | \since 4.6 | - |
4018 | | - |
4019 | Returns the origin point for the transformation in item coordinates. | - |
4020 | | - |
4021 | The default is QPointF(0,0). | - |
4022 | | - |
4023 | \sa setTransformOriginPoint(), {Transformations} | - |
4024 | */ | - |
4025 | QPointF QGraphicsItem::transformOriginPoint() const | - |
4026 | { | - |
4027 | if (!d_ptr->transformData) never evaluated: !d_ptr->transformData | 0 |
4028 | return QPointF(0,0); never executed: return QPointF(0,0); | 0 |
4029 | return QPointF(d_ptr->transformData->xOrigin, d_ptr->transformData->yOrigin); never executed: return QPointF(d_ptr->transformData->xOrigin, d_ptr->transformData->yOrigin); | 0 |
4030 | } | - |
4031 | | - |
4032 | /*! | - |
4033 | \since 4.6 | - |
4034 | | - |
4035 | Sets the \a origin point for the transformation in item coordinates. | - |
4036 | | - |
4037 | \sa transformOriginPoint(), {Transformations} | - |
4038 | */ | - |
4039 | void QGraphicsItem::setTransformOriginPoint(const QPointF &origin) | - |
4040 | { | - |
4041 | prepareGeometryChange(); never executed (the execution status of this line is deduced): prepareGeometryChange(); | - |
4042 | QPointF newOrigin = origin; never executed (the execution status of this line is deduced): QPointF newOrigin = origin; | - |
4043 | | - |
4044 | if (d_ptr->flags & ItemSendsGeometryChanges) { never evaluated: d_ptr->flags & ItemSendsGeometryChanges | 0 |
4045 | // Notify the item that the origin point is changing. | - |
4046 | const QVariant newOriginVariant(itemChange(ItemTransformOriginPointChange, never executed (the execution status of this line is deduced): const QVariant newOriginVariant(itemChange(ItemTransformOriginPointChange, | - |
4047 | QVariant::fromValue<QPointF>(origin))); never executed (the execution status of this line is deduced): QVariant::fromValue<QPointF>(origin))); | - |
4048 | newOrigin = newOriginVariant.toPointF(); never executed (the execution status of this line is deduced): newOrigin = newOriginVariant.toPointF(); | - |
4049 | } | 0 |
4050 | | - |
4051 | if (!d_ptr->transformData) never evaluated: !d_ptr->transformData | 0 |
4052 | d_ptr->transformData = new QGraphicsItemPrivate::TransformData; never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData; | 0 |
4053 | | - |
4054 | if (d_ptr->transformData->xOrigin == newOrigin.x() never evaluated: d_ptr->transformData->xOrigin == newOrigin.x() | 0 |
4055 | && d_ptr->transformData->yOrigin == newOrigin.y()) { never evaluated: d_ptr->transformData->yOrigin == newOrigin.y() | 0 |
4056 | return; | 0 |
4057 | } | - |
4058 | | - |
4059 | d_ptr->transformData->xOrigin = newOrigin.x(); never executed (the execution status of this line is deduced): d_ptr->transformData->xOrigin = newOrigin.x(); | - |
4060 | d_ptr->transformData->yOrigin = newOrigin.y(); never executed (the execution status of this line is deduced): d_ptr->transformData->yOrigin = newOrigin.y(); | - |
4061 | d_ptr->transformData->onlyTransform = false; never executed (the execution status of this line is deduced): d_ptr->transformData->onlyTransform = false; | - |
4062 | d_ptr->dirtySceneTransform = 1; never executed (the execution status of this line is deduced): d_ptr->dirtySceneTransform = 1; | - |
4063 | | - |
4064 | // Send post-notification. | - |
4065 | if (d_ptr->flags & ItemSendsGeometryChanges) never evaluated: d_ptr->flags & ItemSendsGeometryChanges | 0 |
4066 | itemChange(ItemTransformOriginPointHasChanged, QVariant::fromValue<QPointF>(newOrigin)); never executed: itemChange(ItemTransformOriginPointHasChanged, QVariant::fromValue<QPointF>(newOrigin)); | 0 |
4067 | } | 0 |
4068 | | - |
4069 | /*! | - |
4070 | \fn void QGraphicsItem::setTransformOriginPoint(qreal x, qreal y) | - |
4071 | | - |
4072 | \since 4.6 | - |
4073 | \overload | - |
4074 | | - |
4075 | Sets the origin point for the transformation in item coordinates. | - |
4076 | This is equivalent to calling setTransformOriginPoint(QPointF(\a x, \a y)). | - |
4077 | | - |
4078 | \sa setTransformOriginPoint(), {Transformations} | - |
4079 | */ | - |
4080 | | - |
4081 | | - |
4082 | /*! | - |
4083 | \obsolete | - |
4084 | | - |
4085 | Use sceneTransform() instead. | - |
4086 | | - |
4087 | \sa transform(), setTransform(), scenePos(), {The Graphics View Coordinate System} | - |
4088 | */ | - |
4089 | QMatrix QGraphicsItem::sceneMatrix() const | - |
4090 | { | - |
4091 | d_ptr->ensureSceneTransform(); never executed (the execution status of this line is deduced): d_ptr->ensureSceneTransform(); | - |
4092 | return d_ptr->sceneTransform.toAffine(); never executed: return d_ptr->sceneTransform.toAffine(); | 0 |
4093 | } | - |
4094 | | - |
4095 | | - |
4096 | /*! | - |
4097 | \since 4.3 | - |
4098 | | - |
4099 | Returns this item's scene transformation matrix. This matrix can be used | - |
4100 | to map coordinates and geometrical shapes from this item's local | - |
4101 | coordinate system to the scene's coordinate system. To map coordinates | - |
4102 | from the scene, you must first invert the returned matrix. | - |
4103 | | - |
4104 | Example: | - |
4105 | | - |
4106 | \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 4 | - |
4107 | | - |
4108 | Unlike transform(), which returns only an item's local transformation, this | - |
4109 | function includes the item's (and any parents') position, and all the transfomation properties. | - |
4110 | | - |
4111 | \sa transform(), setTransform(), scenePos(), {The Graphics View Coordinate System}, {Transformations} | - |
4112 | */ | - |
4113 | QTransform QGraphicsItem::sceneTransform() const | - |
4114 | { | - |
4115 | d_ptr->ensureSceneTransform(); executed (the execution status of this line is deduced): d_ptr->ensureSceneTransform(); | - |
4116 | return d_ptr->sceneTransform; executed: return d_ptr->sceneTransform; Execution Count:5 | 5 |
4117 | } | - |
4118 | | - |
4119 | /*! | - |
4120 | \since 4.3 | - |
4121 | | - |
4122 | Returns this item's device transformation matrix, using \a | - |
4123 | viewportTransform to map from scene to device coordinates. This matrix can | - |
4124 | be used to map coordinates and geometrical shapes from this item's local | - |
4125 | coordinate system to the viewport's (or any device's) coordinate | - |
4126 | system. To map coordinates from the viewport, you must first invert the | - |
4127 | returned matrix. | - |
4128 | | - |
4129 | Example: | - |
4130 | | - |
4131 | \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 5 | - |
4132 | | - |
4133 | This function is the same as combining this item's scene transform with | - |
4134 | the view's viewport transform, but it also understands the | - |
4135 | ItemIgnoresTransformations flag. The device transform can be used to do | - |
4136 | accurate coordinate mapping (and collision detection) for untransformable | - |
4137 | items. | - |
4138 | | - |
4139 | \sa transform(), setTransform(), scenePos(), {The Graphics View Coordinate | - |
4140 | System}, itemTransform() | - |
4141 | */ | - |
4142 | QTransform QGraphicsItem::deviceTransform(const QTransform &viewportTransform) const | - |
4143 | { | - |
4144 | // Ensure we return the standard transform if we're not untransformable. | - |
4145 | if (!d_ptr->itemIsUntransformable()) { partially evaluated: !d_ptr->itemIsUntransformable() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
4146 | d_ptr->ensureSceneTransform(); executed (the execution status of this line is deduced): d_ptr->ensureSceneTransform(); | - |
4147 | return d_ptr->sceneTransform * viewportTransform; executed: return d_ptr->sceneTransform * viewportTransform; Execution Count:1 | 1 |
4148 | } | - |
4149 | | - |
4150 | // Find the topmost item that ignores view transformations. | - |
4151 | const QGraphicsItem *untransformedAncestor = this; never executed (the execution status of this line is deduced): const QGraphicsItem *untransformedAncestor = this; | - |
4152 | QList<const QGraphicsItem *> parents; never executed (the execution status of this line is deduced): QList<const QGraphicsItem *> parents; | - |
4153 | while (untransformedAncestor && ((untransformedAncestor->d_ptr->ancestorFlags never evaluated: untransformedAncestor never evaluated: ((untransformedAncestor->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorIgnoresTransformations)) | 0 |
4154 | & QGraphicsItemPrivate::AncestorIgnoresTransformations))) { never evaluated: ((untransformedAncestor->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorIgnoresTransformations)) | 0 |
4155 | parents.prepend(untransformedAncestor); never executed (the execution status of this line is deduced): parents.prepend(untransformedAncestor); | - |
4156 | untransformedAncestor = untransformedAncestor->parentItem(); never executed (the execution status of this line is deduced): untransformedAncestor = untransformedAncestor->parentItem(); | - |
4157 | } | 0 |
4158 | | - |
4159 | if (!untransformedAncestor) { never evaluated: !untransformedAncestor | 0 |
4160 | // Assert in debug mode, continue in release. | - |
4161 | Q_ASSERT_X(untransformedAncestor, "QGraphicsItem::deviceTransform", never executed (the execution status of this line is deduced): qt_noop(); | - |
4162 | "Invalid object structure!"); | - |
4163 | return QTransform(); never executed: return QTransform(); | 0 |
4164 | } | - |
4165 | | - |
4166 | // First translate the base untransformable item. | - |
4167 | untransformedAncestor->d_ptr->ensureSceneTransform(); never executed (the execution status of this line is deduced): untransformedAncestor->d_ptr->ensureSceneTransform(); | - |
4168 | QPointF mappedPoint = (untransformedAncestor->d_ptr->sceneTransform * viewportTransform).map(QPointF(0, 0)); never executed (the execution status of this line is deduced): QPointF mappedPoint = (untransformedAncestor->d_ptr->sceneTransform * viewportTransform).map(QPointF(0, 0)); | - |
4169 | | - |
4170 | // COMBINE | - |
4171 | QTransform matrix = QTransform::fromTranslate(mappedPoint.x(), mappedPoint.y()); never executed (the execution status of this line is deduced): QTransform matrix = QTransform::fromTranslate(mappedPoint.x(), mappedPoint.y()); | - |
4172 | if (untransformedAncestor->d_ptr->transformData) never evaluated: untransformedAncestor->d_ptr->transformData | 0 |
4173 | matrix = untransformedAncestor->d_ptr->transformData->computedFullTransform(&matrix); never executed: matrix = untransformedAncestor->d_ptr->transformData->computedFullTransform(&matrix); | 0 |
4174 | | - |
4175 | // Then transform and translate all children. | - |
4176 | for (int i = 0; i < parents.size(); ++i) { never evaluated: i < parents.size() | 0 |
4177 | const QGraphicsItem *parent = parents.at(i); never executed (the execution status of this line is deduced): const QGraphicsItem *parent = parents.at(i); | - |
4178 | parent->d_ptr->combineTransformFromParent(&matrix); never executed (the execution status of this line is deduced): parent->d_ptr->combineTransformFromParent(&matrix); | - |
4179 | } | 0 |
4180 | | - |
4181 | return matrix; never executed: return matrix; | 0 |
4182 | } | - |
4183 | | - |
4184 | /*! | - |
4185 | \since 4.5 | - |
4186 | | - |
4187 | Returns a QTransform that maps coordinates from this item to \a other. If | - |
4188 | \a ok is not null, and if there is no such transform, the boolean pointed | - |
4189 | to by \a ok will be set to false; otherwise it will be set to true. | - |
4190 | | - |
4191 | This transform provides an alternative to the mapToItem() or mapFromItem() | - |
4192 | functions, by returning the appropriate transform so that you can map | - |
4193 | shapes and coordinates yourself. It also helps you write more efficient | - |
4194 | code when repeatedly mapping between the same two items. | - |
4195 | | - |
4196 | \note In rare circumstances, there is no transform that maps between two | - |
4197 | items. | - |
4198 | | - |
4199 | \sa mapToItem(), mapFromItem(), deviceTransform() | - |
4200 | */ | - |
4201 | QTransform QGraphicsItem::itemTransform(const QGraphicsItem *other, bool *ok) const | - |
4202 | { | - |
4203 | // Catch simple cases first. | - |
4204 | if (other == 0) { partially evaluated: other == 0 no Evaluation Count:0 | yes Evaluation Count:36 |
| 0-36 |
4205 | qWarning("QGraphicsItem::itemTransform: null pointer passed"); never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 4205, __PRETTY_FUNCTION__).warning("QGraphicsItem::itemTransform: null pointer passed"); | - |
4206 | return QTransform(); never executed: return QTransform(); | 0 |
4207 | } | - |
4208 | if (other == this) { partially evaluated: other == this no Evaluation Count:0 | yes Evaluation Count:36 |
| 0-36 |
4209 | if (ok) | 0 |
4210 | *ok = true; never executed: *ok = true; | 0 |
4211 | return QTransform(); never executed: return QTransform(); | 0 |
4212 | } | - |
4213 | | - |
4214 | QGraphicsItem *parent = d_ptr->parent; executed (the execution status of this line is deduced): QGraphicsItem *parent = d_ptr->parent; | - |
4215 | const QGraphicsItem *otherParent = other->d_ptr->parent; executed (the execution status of this line is deduced): const QGraphicsItem *otherParent = other->d_ptr->parent; | - |
4216 | | - |
4217 | // This is other's child | - |
4218 | if (parent == other) { evaluated: parent == other yes Evaluation Count:15 | yes Evaluation Count:21 |
| 15-21 |
4219 | if (ok) partially evaluated: ok no Evaluation Count:0 | yes Evaluation Count:15 |
| 0-15 |
4220 | *ok = true; never executed: *ok = true; | 0 |
4221 | QTransform x; executed (the execution status of this line is deduced): QTransform x; | - |
4222 | d_ptr->combineTransformFromParent(&x); executed (the execution status of this line is deduced): d_ptr->combineTransformFromParent(&x); | - |
4223 | return x; executed: return x; Execution Count:15 | 15 |
4224 | } | - |
4225 | | - |
4226 | // This is other's parent | - |
4227 | if (otherParent == this) { evaluated: otherParent == this yes Evaluation Count:15 | yes Evaluation Count:6 |
| 6-15 |
4228 | const QPointF &otherPos = other->d_ptr->pos; executed (the execution status of this line is deduced): const QPointF &otherPos = other->d_ptr->pos; | - |
4229 | if (other->d_ptr->transformData) { partially evaluated: other->d_ptr->transformData no Evaluation Count:0 | yes Evaluation Count:15 |
| 0-15 |
4230 | QTransform otherToParent; never executed (the execution status of this line is deduced): QTransform otherToParent; | - |
4231 | other->d_ptr->combineTransformFromParent(&otherToParent); never executed (the execution status of this line is deduced): other->d_ptr->combineTransformFromParent(&otherToParent); | - |
4232 | return otherToParent.inverted(ok); never executed: return otherToParent.inverted(ok); | 0 |
4233 | } | - |
4234 | if (ok) partially evaluated: ok no Evaluation Count:0 | yes Evaluation Count:15 |
| 0-15 |
4235 | *ok = true; never executed: *ok = true; | 0 |
4236 | return QTransform::fromTranslate(-otherPos.x(), -otherPos.y()); executed: return QTransform::fromTranslate(-otherPos.x(), -otherPos.y()); Execution Count:15 | 15 |
4237 | } | - |
4238 | | - |
4239 | // Siblings | - |
4240 | if (parent == otherParent) { partially evaluated: parent == otherParent yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
4241 | // COMBINE | - |
4242 | const QPointF &itemPos = d_ptr->pos; executed (the execution status of this line is deduced): const QPointF &itemPos = d_ptr->pos; | - |
4243 | const QPointF &otherPos = other->d_ptr->pos; executed (the execution status of this line is deduced): const QPointF &otherPos = other->d_ptr->pos; | - |
4244 | if (!d_ptr->transformData && !other->d_ptr->transformData) { partially evaluated: !d_ptr->transformData yes Evaluation Count:6 | no Evaluation Count:0 |
partially evaluated: !other->d_ptr->transformData yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
4245 | QPointF delta = itemPos - otherPos; executed (the execution status of this line is deduced): QPointF delta = itemPos - otherPos; | - |
4246 | if (ok) partially evaluated: ok no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
4247 | *ok = true; never executed: *ok = true; | 0 |
4248 | return QTransform::fromTranslate(delta.x(), delta.y()); executed: return QTransform::fromTranslate(delta.x(), delta.y()); Execution Count:6 | 6 |
4249 | } | - |
4250 | | - |
4251 | QTransform itemToParent; never executed (the execution status of this line is deduced): QTransform itemToParent; | - |
4252 | d_ptr->combineTransformFromParent(&itemToParent); never executed (the execution status of this line is deduced): d_ptr->combineTransformFromParent(&itemToParent); | - |
4253 | QTransform otherToParent; never executed (the execution status of this line is deduced): QTransform otherToParent; | - |
4254 | other->d_ptr->combineTransformFromParent(&otherToParent); never executed (the execution status of this line is deduced): other->d_ptr->combineTransformFromParent(&otherToParent); | - |
4255 | return itemToParent * otherToParent.inverted(ok); never executed: return itemToParent * otherToParent.inverted(ok); | 0 |
4256 | } | - |
4257 | | - |
4258 | // Find the closest common ancestor. If the two items don't share an | - |
4259 | // ancestor, then the only way is to combine their scene transforms. | - |
4260 | const QGraphicsItem *commonAncestor = commonAncestorItem(other); never executed (the execution status of this line is deduced): const QGraphicsItem *commonAncestor = commonAncestorItem(other); | - |
4261 | if (!commonAncestor) { never evaluated: !commonAncestor | 0 |
4262 | d_ptr->ensureSceneTransform(); never executed (the execution status of this line is deduced): d_ptr->ensureSceneTransform(); | - |
4263 | other->d_ptr->ensureSceneTransform(); never executed (the execution status of this line is deduced): other->d_ptr->ensureSceneTransform(); | - |
4264 | return d_ptr->sceneTransform * other->d_ptr->sceneTransform.inverted(ok); never executed: return d_ptr->sceneTransform * other->d_ptr->sceneTransform.inverted(ok); | 0 |
4265 | } | - |
4266 | | - |
4267 | // If the two items are cousins (in sibling branches), map both to the | - |
4268 | // common ancestor, and combine the two transforms. | - |
4269 | bool cousins = other != commonAncestor && this != commonAncestor; never evaluated: other != commonAncestor never evaluated: this != commonAncestor | 0 |
4270 | if (cousins) { | 0 |
4271 | bool good = false; never executed (the execution status of this line is deduced): bool good = false; | - |
4272 | QTransform thisToScene = itemTransform(commonAncestor, &good); never executed (the execution status of this line is deduced): QTransform thisToScene = itemTransform(commonAncestor, &good); | - |
4273 | QTransform otherToScene(Qt::Uninitialized); never executed (the execution status of this line is deduced): QTransform otherToScene(Qt::Uninitialized); | - |
4274 | if (good) | 0 |
4275 | otherToScene = other->itemTransform(commonAncestor, &good); never executed: otherToScene = other->itemTransform(commonAncestor, &good); | 0 |
4276 | if (!good) { | 0 |
4277 | if (ok) | 0 |
4278 | *ok = false; never executed: *ok = false; | 0 |
4279 | return QTransform(); never executed: return QTransform(); | 0 |
4280 | } | - |
4281 | return thisToScene * otherToScene.inverted(ok); never executed: return thisToScene * otherToScene.inverted(ok); | 0 |
4282 | } | - |
4283 | | - |
4284 | // One is an ancestor of the other; walk the chain. | - |
4285 | bool parentOfOther = isAncestorOf(other); never executed (the execution status of this line is deduced): bool parentOfOther = isAncestorOf(other); | - |
4286 | const QGraphicsItem *child = parentOfOther ? other : this; never evaluated: parentOfOther | 0 |
4287 | const QGraphicsItem *root = parentOfOther ? this : other; never evaluated: parentOfOther | 0 |
4288 | | - |
4289 | QTransform x; never executed (the execution status of this line is deduced): QTransform x; | - |
4290 | const QGraphicsItem *p = child; never executed (the execution status of this line is deduced): const QGraphicsItem *p = child; | - |
4291 | do { | - |
4292 | p->d_ptr.data()->combineTransformToParent(&x); never executed (the execution status of this line is deduced): p->d_ptr.data()->combineTransformToParent(&x); | - |
4293 | } while ((p = p->d_ptr->parent) && p != root); never executed: } never evaluated: (p = p->d_ptr->parent) never evaluated: p != root | 0 |
4294 | if (parentOfOther) never evaluated: parentOfOther | 0 |
4295 | return x.inverted(ok); never executed: return x.inverted(ok); | 0 |
4296 | if (ok) | 0 |
4297 | *ok = true; never executed: *ok = true; | 0 |
4298 | return x; never executed: return x; | 0 |
4299 | } | - |
4300 | | - |
4301 | /*! | - |
4302 | \obsolete | - |
4303 | | - |
4304 | Sets the item's affine transformation matrix. This is a subset or the | - |
4305 | item's full transformation matrix, and might not represent the item's full | - |
4306 | transformation. | - |
4307 | | - |
4308 | Use setTransform() instead. | - |
4309 | | - |
4310 | \sa transform(), {The Graphics View Coordinate System} | - |
4311 | */ | - |
4312 | void QGraphicsItem::setMatrix(const QMatrix &matrix, bool combine) | - |
4313 | { | - |
4314 | if (!d_ptr->transformData) never evaluated: !d_ptr->transformData | 0 |
4315 | d_ptr->transformData = new QGraphicsItemPrivate::TransformData; never executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData; | 0 |
4316 | | - |
4317 | QTransform newTransform(combine ? QTransform(matrix) * d_ptr->transformData->transform : QTransform(matrix)); never executed (the execution status of this line is deduced): QTransform newTransform(combine ? QTransform(matrix) * d_ptr->transformData->transform : QTransform(matrix)); | - |
4318 | if (d_ptr->transformData->transform == newTransform) never evaluated: d_ptr->transformData->transform == newTransform | 0 |
4319 | return; | 0 |
4320 | | - |
4321 | // Update and set the new transformation. | - |
4322 | if (!(d_ptr->flags & ItemSendsGeometryChanges)) { never evaluated: !(d_ptr->flags & ItemSendsGeometryChanges) | 0 |
4323 | d_ptr->setTransformHelper(newTransform); never executed (the execution status of this line is deduced): d_ptr->setTransformHelper(newTransform); | - |
4324 | return; | 0 |
4325 | } | - |
4326 | | - |
4327 | // Notify the item that the transformation matrix is changing. | - |
4328 | const QVariant newMatrixVariant = QVariant::fromValue<QMatrix>(newTransform.toAffine()); never executed (the execution status of this line is deduced): const QVariant newMatrixVariant = QVariant::fromValue<QMatrix>(newTransform.toAffine()); | - |
4329 | newTransform = QTransform(qvariant_cast<QMatrix>(itemChange(ItemMatrixChange, newMatrixVariant))); never executed (the execution status of this line is deduced): newTransform = QTransform(qvariant_cast<QMatrix>(itemChange(ItemMatrixChange, newMatrixVariant))); | - |
4330 | if (d_ptr->transformData->transform == newTransform) never evaluated: d_ptr->transformData->transform == newTransform | 0 |
4331 | return; | 0 |
4332 | | - |
4333 | // Update and set the new transformation. | - |
4334 | d_ptr->setTransformHelper(newTransform); never executed (the execution status of this line is deduced): d_ptr->setTransformHelper(newTransform); | - |
4335 | | - |
4336 | // Send post-notification. | - |
4337 | itemChange(ItemTransformHasChanged, QVariant::fromValue<QTransform>(newTransform)); never executed (the execution status of this line is deduced): itemChange(ItemTransformHasChanged, QVariant::fromValue<QTransform>(newTransform)); | - |
4338 | } | 0 |
4339 | | - |
4340 | /*! | - |
4341 | \since 4.3 | - |
4342 | | - |
4343 | Sets the item's current transformation matrix to \a matrix. | - |
4344 | | - |
4345 | If \a combine is true, then \a matrix is combined with the current matrix; | - |
4346 | otherwise, \a matrix \e replaces the current matrix. \a combine is false | - |
4347 | by default. | - |
4348 | | - |
4349 | To simplify interation with items using a transformed view, QGraphicsItem | - |
4350 | provides mapTo... and mapFrom... functions that can translate between | - |
4351 | items' and the scene's coordinates. For example, you can call mapToScene() | - |
4352 | to map an item coordiate to a scene coordinate, or mapFromScene() to map | - |
4353 | from scene coordinates to item coordinates. | - |
4354 | | - |
4355 | The transformation matrix is combined with the item's rotation(), scale() | - |
4356 | and transformations() into a combined transformation that maps the item's | - |
4357 | coordinate system to its parent. | - |
4358 | | - |
4359 | \sa transform(), setRotation(), setScale(), setTransformOriginPoint(), {The Graphics View Coordinate System}, {Transformations} | - |
4360 | */ | - |
4361 | void QGraphicsItem::setTransform(const QTransform &matrix, bool combine) | - |
4362 | { | - |
4363 | if (!d_ptr->transformData) partially evaluated: !d_ptr->transformData yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
4364 | d_ptr->transformData = new QGraphicsItemPrivate::TransformData; executed: d_ptr->transformData = new QGraphicsItemPrivate::TransformData; Execution Count:3 | 3 |
4365 | | - |
4366 | QTransform newTransform(combine ? matrix * d_ptr->transformData->transform : matrix); executed (the execution status of this line is deduced): QTransform newTransform(combine ? matrix * d_ptr->transformData->transform : matrix); | - |
4367 | if (d_ptr->transformData->transform == newTransform) partially evaluated: d_ptr->transformData->transform == newTransform no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
4368 | return; | 0 |
4369 | | - |
4370 | // Update and set the new transformation. | - |
4371 | if (!(d_ptr->flags & (ItemSendsGeometryChanges | ItemSendsScenePositionChanges))) { evaluated: !(d_ptr->flags & (ItemSendsGeometryChanges | ItemSendsScenePositionChanges)) yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
4372 | d_ptr->setTransformHelper(newTransform); executed (the execution status of this line is deduced): d_ptr->setTransformHelper(newTransform); | - |
4373 | if (d_ptr->scenePosDescendants) partially evaluated: d_ptr->scenePosDescendants no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
4374 | d_ptr->sendScenePosChange(); never executed: d_ptr->sendScenePosChange(); | 0 |
4375 | return; executed: return; Execution Count:2 | 2 |
4376 | } | - |
4377 | | - |
4378 | // Notify the item that the transformation matrix is changing. | - |
4379 | const QVariant newTransformVariant(itemChange(ItemTransformChange, executed (the execution status of this line is deduced): const QVariant newTransformVariant(itemChange(ItemTransformChange, | - |
4380 | QVariant::fromValue<QTransform>(newTransform))); executed (the execution status of this line is deduced): QVariant::fromValue<QTransform>(newTransform))); | - |
4381 | newTransform = qvariant_cast<QTransform>(newTransformVariant); executed (the execution status of this line is deduced): newTransform = qvariant_cast<QTransform>(newTransformVariant); | - |
4382 | if (d_ptr->transformData->transform == newTransform) partially evaluated: d_ptr->transformData->transform == newTransform no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
4383 | return; | 0 |
4384 | | - |
4385 | // Update and set the new transformation. | - |
4386 | d_ptr->setTransformHelper(newTransform); executed (the execution status of this line is deduced): d_ptr->setTransformHelper(newTransform); | - |
4387 | | - |
4388 | // Send post-notification. | - |
4389 | itemChange(ItemTransformHasChanged, newTransformVariant); executed (the execution status of this line is deduced): itemChange(ItemTransformHasChanged, newTransformVariant); | - |
4390 | d_ptr->sendScenePosChange(); executed (the execution status of this line is deduced): d_ptr->sendScenePosChange(); | - |
4391 | } executed: } Execution Count:1 | 1 |
4392 | | - |
4393 | /*! | - |
4394 | \obsolete | - |
4395 | | - |
4396 | Use resetTransform() instead. | - |
4397 | */ | - |
4398 | void QGraphicsItem::resetMatrix() | - |
4399 | { | - |
4400 | resetTransform(); never executed (the execution status of this line is deduced): resetTransform(); | - |
4401 | } | 0 |
4402 | | - |
4403 | /*! | - |
4404 | \since 4.3 | - |
4405 | | - |
4406 | Resets this item's transformation matrix to the identity matrix or | - |
4407 | all the transformation properties to their default values. | - |
4408 | This is equivalent to calling \c setTransform(QTransform()). | - |
4409 | | - |
4410 | \sa setTransform(), transform() | - |
4411 | */ | - |
4412 | void QGraphicsItem::resetTransform() | - |
4413 | { | - |
4414 | setTransform(QTransform(), false); never executed (the execution status of this line is deduced): setTransform(QTransform(), false); | - |
4415 | } | 0 |
4416 | | - |
4417 | /*! | - |
4418 | \fn void QGraphicsItem::rotate(qreal angle) | - |
4419 | \obsolete | - |
4420 | | - |
4421 | Use | - |
4422 | | - |
4423 | \code | - |
4424 | setRotation(rotation() + angle); | - |
4425 | \endcode | - |
4426 | | - |
4427 | instead. | - |
4428 | | - |
4429 | Rotates the current item transformation \a angle degrees clockwise around | - |
4430 | its origin. To translate around an arbitrary point (x, y), you need to | - |
4431 | combine translation and rotation with setTransform(). | - |
4432 | | - |
4433 | Example: | - |
4434 | | - |
4435 | \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 6 | - |
4436 | | - |
4437 | \sa setTransform(), transform(), scale(), shear(), translate() | - |
4438 | */ | - |
4439 | | - |
4440 | /*! | - |
4441 | \fn void QGraphicsItem::scale(qreal sx, qreal sy) | - |
4442 | \obsolete | - |
4443 | | - |
4444 | Use | - |
4445 | | - |
4446 | \code | - |
4447 | setTransform(QTransform::fromScale(sx, sy), true); | - |
4448 | \endcode | - |
4449 | | - |
4450 | instead. | - |
4451 | | - |
4452 | Scales the current item transformation by (\a sx, \a sy) around its | - |
4453 | origin. To scale from an arbitrary point (x, y), you need to combine | - |
4454 | translation and scaling with setTransform(). | - |
4455 | | - |
4456 | Example: | - |
4457 | | - |
4458 | \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 7 | - |
4459 | | - |
4460 | \sa setTransform(), transform() | - |
4461 | */ | - |
4462 | | - |
4463 | /*! | - |
4464 | \fn void QGraphicsItem::shear(qreal sh, qreal sv) | - |
4465 | \obsolete | - |
4466 | | - |
4467 | Use | - |
4468 | | - |
4469 | \code | - |
4470 | setTransform(QTransform().shear(sh, sv), true); | - |
4471 | \endcode | - |
4472 | | - |
4473 | instead. | - |
4474 | | - |
4475 | Shears the current item transformation by (\a sh, \a sv). | - |
4476 | | - |
4477 | \sa setTransform(), transform() | - |
4478 | */ | - |
4479 | | - |
4480 | /*! | - |
4481 | \fn void QGraphicsItem::translate(qreal dx, qreal dy) | - |
4482 | \obsolete | - |
4483 | | - |
4484 | Use setPos() or setTransformOriginPoint() instead. For identical | - |
4485 | behavior, use | - |
4486 | | - |
4487 | \code | - |
4488 | setTransform(QTransform::fromTranslate(dx, dy), true); | - |
4489 | \endcode | - |
4490 | | - |
4491 | Translates the current item transformation by (\a dx, \a dy). | - |
4492 | | - |
4493 | If all you want is to move an item, you should call moveBy() or | - |
4494 | setPos() instead; this function changes the item's translation, | - |
4495 | which is conceptually separate from its position. | - |
4496 | | - |
4497 | \sa setTransform(), transform() | - |
4498 | */ | - |
4499 | | - |
4500 | /*! | - |
4501 | This virtual function is called twice for all items by the | - |
4502 | QGraphicsScene::advance() slot. In the first phase, all items are called | - |
4503 | with \a phase == 0, indicating that items on the scene are about to | - |
4504 | advance, and then all items are called with \a phase == 1. Reimplement | - |
4505 | this function to update your item if you need simple scene-controlled | - |
4506 | animation. | - |
4507 | | - |
4508 | The default implementation does nothing. | - |
4509 | | - |
4510 | This function is intended for animations. An alternative is to | - |
4511 | multiple-inherit from QObject and QGraphicsItem and use the \l{The Animation | - |
4512 | Framework}{Animation Framework}. | - |
4513 | | - |
4514 | \sa QGraphicsScene::advance(), QTimeLine | - |
4515 | */ | - |
4516 | void QGraphicsItem::advance(int phase) | - |
4517 | { | - |
4518 | Q_UNUSED(phase); never executed (the execution status of this line is deduced): (void)phase;; | - |
4519 | } | 0 |
4520 | | - |
4521 | /*! | - |
4522 | Returns the Z-value of the item. The Z-value affects the stacking order of | - |
4523 | sibling (neighboring) items. | - |
4524 | | - |
4525 | The default Z-value is 0. | - |
4526 | | - |
4527 | \sa setZValue(), {QGraphicsItem#Sorting}{Sorting}, stackBefore(), ItemStacksBehindParent | - |
4528 | */ | - |
4529 | qreal QGraphicsItem::zValue() const | - |
4530 | { | - |
4531 | return d_ptr->z; executed: return d_ptr->z; Execution Count:3 | 3 |
4532 | } | - |
4533 | | - |
4534 | /*! | - |
4535 | Sets the Z-value of the item to \a z. The Z value decides the stacking | - |
4536 | order of sibling (neighboring) items. A sibling item of high Z value will | - |
4537 | always be drawn on top of another sibling item with a lower Z value. | - |
4538 | | - |
4539 | If you restore the Z value, the item's insertion order will decide its | - |
4540 | stacking order. | - |
4541 | | - |
4542 | The Z-value does not affect the item's size in any way. | - |
4543 | | - |
4544 | The default Z-value is 0. | - |
4545 | | - |
4546 | \sa zValue(), {QGraphicsItem#Sorting}{Sorting}, stackBefore(), ItemStacksBehindParent | - |
4547 | */ | - |
4548 | void QGraphicsItem::setZValue(qreal z) | - |
4549 | { | - |
4550 | const QVariant newZVariant(itemChange(ItemZValueChange, z)); executed (the execution status of this line is deduced): const QVariant newZVariant(itemChange(ItemZValueChange, z)); | - |
4551 | qreal newZ = newZVariant.toReal(); executed (the execution status of this line is deduced): qreal newZ = newZVariant.toReal(); | - |
4552 | if (newZ == d_ptr->z) evaluated: newZ == d_ptr->z yes Evaluation Count:1 | yes Evaluation Count:48 |
| 1-48 |
4553 | return; executed: return; Execution Count:1 | 1 |
4554 | | - |
4555 | if (d_ptr->scene && d_ptr->scene->d_func()->indexMethod != QGraphicsScene::NoIndex) { evaluated: d_ptr->scene yes Evaluation Count:19 | yes Evaluation Count:29 |
partially evaluated: d_ptr->scene->d_func()->indexMethod != QGraphicsScene::NoIndex yes Evaluation Count:19 | no Evaluation Count:0 |
| 0-29 |
4556 | // Z Value has changed, we have to notify the index. | - |
4557 | d_ptr->scene->d_func()->index->itemChange(this, ItemZValueChange, &newZ); executed (the execution status of this line is deduced): d_ptr->scene->d_func()->index->itemChange(this, ItemZValueChange, &newZ); | - |
4558 | } executed: } Execution Count:19 | 19 |
4559 | | - |
4560 | d_ptr->z = newZ; executed (the execution status of this line is deduced): d_ptr->z = newZ; | - |
4561 | if (d_ptr->parent) evaluated: d_ptr->parent yes Evaluation Count:3 | yes Evaluation Count:45 |
| 3-45 |
4562 | d_ptr->parent->d_ptr->needSortChildren = 1; executed: d_ptr->parent->d_ptr->needSortChildren = 1; Execution Count:3 | 3 |
4563 | else if (d_ptr->scene) evaluated: d_ptr->scene yes Evaluation Count:16 | yes Evaluation Count:29 |
| 16-29 |
4564 | d_ptr->scene->d_func()->needSortTopLevelItems = 1; executed: d_ptr->scene->d_func()->needSortTopLevelItems = 1; Execution Count:16 | 16 |
4565 | | - |
4566 | if (d_ptr->scene) evaluated: d_ptr->scene yes Evaluation Count:19 | yes Evaluation Count:29 |
| 19-29 |
4567 | d_ptr->scene->d_func()->markDirty(this, QRectF(), /*invalidateChildren=*/true); executed: d_ptr->scene->d_func()->markDirty(this, QRectF(), true); Execution Count:19 | 19 |
4568 | | - |
4569 | itemChange(ItemZValueHasChanged, newZVariant); executed (the execution status of this line is deduced): itemChange(ItemZValueHasChanged, newZVariant); | - |
4570 | | - |
4571 | if (d_ptr->flags & ItemNegativeZStacksBehindParent) partially evaluated: d_ptr->flags & ItemNegativeZStacksBehindParent no Evaluation Count:0 | yes Evaluation Count:48 |
| 0-48 |
4572 | setFlag(QGraphicsItem::ItemStacksBehindParent, z < qreal(0.0)); never executed: setFlag(QGraphicsItem::ItemStacksBehindParent, z < qreal(0.0)); | 0 |
4573 | | - |
4574 | if (d_ptr->isObject) evaluated: d_ptr->isObject yes Evaluation Count:42 | yes Evaluation Count:6 |
| 6-42 |
4575 | emit static_cast<QGraphicsObject *>(this)->zChanged(); executed: static_cast<QGraphicsObject *>(this)->zChanged(); Execution Count:42 | 42 |
4576 | } executed: } Execution Count:48 | 48 |
4577 | | - |
4578 | /*! | - |
4579 | \internal | - |
4580 | | - |
4581 | Ensures that the list of children is sorted by insertion order, and that | - |
4582 | the siblingIndexes are packed (no gaps), and start at 0. | - |
4583 | | - |
4584 | ### This function is almost identical to | - |
4585 | QGraphicsScenePrivate::ensureSequentialTopLevelSiblingIndexes(). | - |
4586 | */ | - |
4587 | void QGraphicsItemPrivate::ensureSequentialSiblingIndex() | - |
4588 | { | - |
4589 | if (!sequentialOrdering) { partially evaluated: !sequentialOrdering no Evaluation Count:0 | yes Evaluation Count:1066 |
| 0-1066 |
4590 | std::sort(children.begin(), children.end(), insertionOrder); never executed (the execution status of this line is deduced): std::sort(children.begin(), children.end(), insertionOrder); | - |
4591 | sequentialOrdering = 1; never executed (the execution status of this line is deduced): sequentialOrdering = 1; | - |
4592 | needSortChildren = 1; never executed (the execution status of this line is deduced): needSortChildren = 1; | - |
4593 | } | 0 |
4594 | if (holesInSiblingIndex) { partially evaluated: holesInSiblingIndex no Evaluation Count:0 | yes Evaluation Count:1066 |
| 0-1066 |
4595 | holesInSiblingIndex = 0; never executed (the execution status of this line is deduced): holesInSiblingIndex = 0; | - |
4596 | for (int i = 0; i < children.size(); ++i) never evaluated: i < children.size() | 0 |
4597 | children[i]->d_ptr->siblingIndex = i; never executed: children[i]->d_ptr->siblingIndex = i; | 0 |
4598 | } | 0 |
4599 | } executed: } Execution Count:1066 | 1066 |
4600 | | - |
4601 | /*! | - |
4602 | \internal | - |
4603 | */ | - |
4604 | inline void QGraphicsItemPrivate::sendScenePosChange() | - |
4605 | { | - |
4606 | Q_Q(QGraphicsItem); executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func(); | - |
4607 | if (scene) { evaluated: scene yes Evaluation Count:729 | yes Evaluation Count:25 |
| 25-729 |
4608 | if (flags & QGraphicsItem::ItemSendsScenePositionChanges) partially evaluated: flags & QGraphicsItem::ItemSendsScenePositionChanges no Evaluation Count:0 | yes Evaluation Count:729 |
| 0-729 |
4609 | q->itemChange(QGraphicsItem::ItemScenePositionHasChanged, q->scenePos()); never executed: q->itemChange(QGraphicsItem::ItemScenePositionHasChanged, q->scenePos()); | 0 |
4610 | if (scenePosDescendants) { partially evaluated: scenePosDescendants no Evaluation Count:0 | yes Evaluation Count:729 |
| 0-729 |
4611 | foreach (QGraphicsItem *item, scene->d_func()->scenePosItems) { never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(scene->d_func()->scenePosItems)> _container_(scene->d_func()->scenePosItems); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
4612 | if (q->isAncestorOf(item)) never evaluated: q->isAncestorOf(item) | 0 |
4613 | item->itemChange(QGraphicsItem::ItemScenePositionHasChanged, item->scenePos()); never executed: item->itemChange(QGraphicsItem::ItemScenePositionHasChanged, item->scenePos()); | 0 |
4614 | } | 0 |
4615 | } | 0 |
4616 | } executed: } Execution Count:729 | 729 |
4617 | } executed: } Execution Count:754 | 754 |
4618 | | - |
4619 | /*! | - |
4620 | \since 4.6 | - |
4621 | | - |
4622 | Stacks this item before \a sibling, which must be a sibling item (i.e., the | - |
4623 | two items must share the same parent item, or must both be toplevel items). | - |
4624 | The \a sibling must have the same Z value as this item, otherwise calling | - |
4625 | this function will have no effect. | - |
4626 | | - |
4627 | By default, all sibling items are stacked by insertion order (i.e., the | - |
4628 | first item you add is drawn before the next item you add). If two items' Z | - |
4629 | values are different, then the item with the highest Z value is drawn on | - |
4630 | top. When the Z values are the same, the insertion order will decide the | - |
4631 | stacking order. | - |
4632 | | - |
4633 | \sa setZValue(), ItemStacksBehindParent, {QGraphicsItem#Sorting}{Sorting} | - |
4634 | */ | - |
4635 | void QGraphicsItem::stackBefore(const QGraphicsItem *sibling) | - |
4636 | { | - |
4637 | if (sibling == this) never evaluated: sibling == this | 0 |
4638 | return; | 0 |
4639 | if (!sibling || d_ptr->parent != sibling->parentItem()) { never evaluated: !sibling never evaluated: d_ptr->parent != sibling->parentItem() | 0 |
4640 | qWarning("QGraphicsItem::stackUnder: cannot stack under %p, which must be a sibling", sibling); never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 4640, __PRETTY_FUNCTION__).warning("QGraphicsItem::stackUnder: cannot stack under %p, which must be a sibling", sibling); | - |
4641 | return; | 0 |
4642 | } | - |
4643 | QList<QGraphicsItem *> *siblings = d_ptr->parent never evaluated: d_ptr->parent | 0 |
4644 | ? &d_ptr->parent->d_ptr->children never executed (the execution status of this line is deduced): ? &d_ptr->parent->d_ptr->children | - |
4645 | : (d_ptr->scene ? &d_ptr->scene->d_func()->topLevelItems : 0); never executed (the execution status of this line is deduced): : (d_ptr->scene ? &d_ptr->scene->d_func()->topLevelItems : 0); | - |
4646 | if (!siblings) { never evaluated: !siblings | 0 |
4647 | qWarning("QGraphicsItem::stackUnder: cannot stack under %p, which must be a sibling", sibling); never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 4647, __PRETTY_FUNCTION__).warning("QGraphicsItem::stackUnder: cannot stack under %p, which must be a sibling", sibling); | - |
4648 | return; | 0 |
4649 | } | - |
4650 | | - |
4651 | // First, make sure that the sibling indexes have no holes. This also | - |
4652 | // marks the children list for sorting. | - |
4653 | if (d_ptr->parent) never evaluated: d_ptr->parent | 0 |
4654 | d_ptr->parent->d_ptr->ensureSequentialSiblingIndex(); never executed: d_ptr->parent->d_ptr->ensureSequentialSiblingIndex(); | 0 |
4655 | else | - |
4656 | d_ptr->scene->d_func()->ensureSequentialTopLevelSiblingIndexes(); never executed: d_ptr->scene->d_func()->ensureSequentialTopLevelSiblingIndexes(); | 0 |
4657 | | - |
4658 | // Only move items with the same Z value, and that need moving. | - |
4659 | int siblingIndex = sibling->d_ptr->siblingIndex; never executed (the execution status of this line is deduced): int siblingIndex = sibling->d_ptr->siblingIndex; | - |
4660 | int myIndex = d_ptr->siblingIndex; never executed (the execution status of this line is deduced): int myIndex = d_ptr->siblingIndex; | - |
4661 | if (myIndex >= siblingIndex) { never evaluated: myIndex >= siblingIndex | 0 |
4662 | siblings->move(myIndex, siblingIndex); never executed (the execution status of this line is deduced): siblings->move(myIndex, siblingIndex); | - |
4663 | // Fixup the insertion ordering. | - |
4664 | for (int i = 0; i < siblings->size(); ++i) { never evaluated: i < siblings->size() | 0 |
4665 | int &index = siblings->at(i)->d_ptr->siblingIndex; never executed (the execution status of this line is deduced): int &index = siblings->at(i)->d_ptr->siblingIndex; | - |
4666 | if (i != siblingIndex && index >= siblingIndex && index <= myIndex) never evaluated: i != siblingIndex never evaluated: index >= siblingIndex never evaluated: index <= myIndex | 0 |
4667 | ++index; | 0 |
4668 | } | 0 |
4669 | d_ptr->siblingIndex = siblingIndex; never executed (the execution status of this line is deduced): d_ptr->siblingIndex = siblingIndex; | - |
4670 | for (int i = 0; i < siblings->size(); ++i) { never evaluated: i < siblings->size() | 0 |
4671 | int &index = siblings->at(i)->d_ptr->siblingIndex; never executed (the execution status of this line is deduced): int &index = siblings->at(i)->d_ptr->siblingIndex; | - |
4672 | if (i != siblingIndex && index >= siblingIndex && index <= myIndex) never evaluated: i != siblingIndex never evaluated: index >= siblingIndex never evaluated: index <= myIndex | 0 |
4673 | siblings->at(i)->d_ptr->siblingOrderChange(); never executed: siblings->at(i)->d_ptr->siblingOrderChange(); | 0 |
4674 | } | 0 |
4675 | d_ptr->siblingOrderChange(); never executed (the execution status of this line is deduced): d_ptr->siblingOrderChange(); | - |
4676 | } | 0 |
4677 | } | 0 |
4678 | | - |
4679 | /*! | - |
4680 | Returns the bounding rect of this item's descendants (i.e., its | - |
4681 | children, their children, etc.) in local coordinates. The | - |
4682 | rectangle will contain all descendants after they have been mapped | - |
4683 | to local coordinates. If the item has no children, this function | - |
4684 | returns an empty QRectF. | - |
4685 | | - |
4686 | This does not include this item's own bounding rect; it only returns | - |
4687 | its descendants' accumulated bounding rect. If you need to include this | - |
4688 | item's bounding rect, you can add boundingRect() to childrenBoundingRect() | - |
4689 | using QRectF::operator|(). | - |
4690 | | - |
4691 | This function is linear in complexity; it determines the size of the | - |
4692 | returned bounding rect by iterating through all descendants. | - |
4693 | | - |
4694 | \sa boundingRect(), sceneBoundingRect() | - |
4695 | */ | - |
4696 | QRectF QGraphicsItem::childrenBoundingRect() const | - |
4697 | { | - |
4698 | if (!d_ptr->dirtyChildrenBoundingRect) evaluated: !d_ptr->dirtyChildrenBoundingRect yes Evaluation Count:9 | yes Evaluation Count:10 |
| 9-10 |
4699 | return d_ptr->childrenBoundingRect; executed: return d_ptr->childrenBoundingRect; Execution Count:9 | 9 |
4700 | | - |
4701 | d_ptr->childrenBoundingRect = QRectF(); executed (the execution status of this line is deduced): d_ptr->childrenBoundingRect = QRectF(); | - |
4702 | d_ptr->childrenBoundingRectHelper(0, &d_ptr->childrenBoundingRect, 0); executed (the execution status of this line is deduced): d_ptr->childrenBoundingRectHelper(0, &d_ptr->childrenBoundingRect, 0); | - |
4703 | d_ptr->dirtyChildrenBoundingRect = 0; executed (the execution status of this line is deduced): d_ptr->dirtyChildrenBoundingRect = 0; | - |
4704 | return d_ptr->childrenBoundingRect; executed: return d_ptr->childrenBoundingRect; Execution Count:10 | 10 |
4705 | } | - |
4706 | | - |
4707 | /*! | - |
4708 | \fn virtual QRectF QGraphicsItem::boundingRect() const = 0 | - |
4709 | | - |
4710 | This pure virtual function defines the outer bounds of the item as | - |
4711 | a rectangle; all painting must be restricted to inside an item's | - |
4712 | bounding rect. QGraphicsView uses this to determine whether the | - |
4713 | item requires redrawing. | - |
4714 | | - |
4715 | Although the item's shape can be arbitrary, the bounding rect is | - |
4716 | always rectangular, and it is unaffected by the items' | - |
4717 | transformation. | - |
4718 | | - |
4719 | If you want to change the item's bounding rectangle, you must first call | - |
4720 | prepareGeometryChange(). This notifies the scene of the imminent change, | - |
4721 | so that it can update its item geometry index; otherwise, the scene will | - |
4722 | be unaware of the item's new geometry, and the results are undefined | - |
4723 | (typically, rendering artifacts are left within the view). | - |
4724 | | - |
4725 | Reimplement this function to let QGraphicsView determine what | - |
4726 | parts of the widget, if any, need to be redrawn. | - |
4727 | | - |
4728 | Note: For shapes that paint an outline / stroke, it is important | - |
4729 | to include half the pen width in the bounding rect. It is not | - |
4730 | necessary to compensate for antialiasing, though. | - |
4731 | | - |
4732 | Example: | - |
4733 | | - |
4734 | \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 8 | - |
4735 | | - |
4736 | \sa boundingRegion(), shape(), contains(), {The Graphics View Coordinate | - |
4737 | System}, prepareGeometryChange() | - |
4738 | */ | - |
4739 | | - |
4740 | /*! | - |
4741 | Returns the bounding rect of this item in scene coordinates, by combining | - |
4742 | sceneTransform() with boundingRect(). | - |
4743 | | - |
4744 | \sa boundingRect(), {The Graphics View Coordinate System} | - |
4745 | */ | - |
4746 | QRectF QGraphicsItem::sceneBoundingRect() const | - |
4747 | { | - |
4748 | // Find translate-only offset | - |
4749 | // COMBINE | - |
4750 | QPointF offset; executed (the execution status of this line is deduced): QPointF offset; | - |
4751 | const QGraphicsItem *parentItem = this; executed (the execution status of this line is deduced): const QGraphicsItem *parentItem = this; | - |
4752 | const QGraphicsItemPrivate *itemd; executed (the execution status of this line is deduced): const QGraphicsItemPrivate *itemd; | - |
4753 | do { | - |
4754 | itemd = parentItem->d_ptr.data(); executed (the execution status of this line is deduced): itemd = parentItem->d_ptr.data(); | - |
4755 | if (itemd->transformData) evaluated: itemd->transformData yes Evaluation Count:1 | yes Evaluation Count:3366 |
| 1-3366 |
4756 | break; executed: break; Execution Count:1 | 1 |
4757 | offset += itemd->pos; executed (the execution status of this line is deduced): offset += itemd->pos; | - |
4758 | } while ((parentItem = itemd->parent)); executed: } Execution Count:3366 evaluated: (parentItem = itemd->parent) yes Evaluation Count:1478 | yes Evaluation Count:1888 |
| 1478-3366 |
4759 | | - |
4760 | QRectF br = boundingRect(); executed (the execution status of this line is deduced): QRectF br = boundingRect(); | - |
4761 | br.translate(offset); executed (the execution status of this line is deduced): br.translate(offset); | - |
4762 | if (!parentItem) evaluated: !parentItem yes Evaluation Count:1888 | yes Evaluation Count:1 |
| 1-1888 |
4763 | return br; executed: return br; Execution Count:1888 | 1888 |
4764 | if (parentItem->d_ptr->hasTranslateOnlySceneTransform()) { partially evaluated: parentItem->d_ptr->hasTranslateOnlySceneTransform() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
4765 | br.translate(parentItem->d_ptr->sceneTransform.dx(), parentItem->d_ptr->sceneTransform.dy()); never executed (the execution status of this line is deduced): br.translate(parentItem->d_ptr->sceneTransform.dx(), parentItem->d_ptr->sceneTransform.dy()); | - |
4766 | return br; never executed: return br; | 0 |
4767 | } | - |
4768 | return parentItem->d_ptr->sceneTransform.mapRect(br); executed: return parentItem->d_ptr->sceneTransform.mapRect(br); Execution Count:1 | 1 |
4769 | } | - |
4770 | | - |
4771 | /*! | - |
4772 | Returns the shape of this item as a QPainterPath in local | - |
4773 | coordinates. The shape is used for many things, including collision | - |
4774 | detection, hit tests, and for the QGraphicsScene::items() functions. | - |
4775 | | - |
4776 | The default implementation calls boundingRect() to return a simple | - |
4777 | rectangular shape, but subclasses can reimplement this function to return | - |
4778 | a more accurate shape for non-rectangular items. For example, a round item | - |
4779 | may choose to return an elliptic shape for better collision detection. For | - |
4780 | example: | - |
4781 | | - |
4782 | \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 9 | - |
4783 | | - |
4784 | The outline of a shape can vary depending on the width and style of the | - |
4785 | pen used when drawing. If you want to include this outline in the item's | - |
4786 | shape, you can create a shape from the stroke using QPainterPathStroker. | - |
4787 | | - |
4788 | This function is called by the default implementations of contains() and | - |
4789 | collidesWithPath(). | - |
4790 | | - |
4791 | \sa boundingRect(), contains(), prepareGeometryChange(), QPainterPathStroker | - |
4792 | */ | - |
4793 | QPainterPath QGraphicsItem::shape() const | - |
4794 | { | - |
4795 | QPainterPath path; executed (the execution status of this line is deduced): QPainterPath path; | - |
4796 | path.addRect(boundingRect()); executed (the execution status of this line is deduced): path.addRect(boundingRect()); | - |
4797 | return path; executed: return path; Execution Count:140 | 140 |
4798 | } | - |
4799 | | - |
4800 | /*! | - |
4801 | Returns true if this item is clipped. An item is clipped if it has either | - |
4802 | set the \l ItemClipsToShape flag, or if it or any of its ancestors has set | - |
4803 | the \l ItemClipsChildrenToShape flag. | - |
4804 | | - |
4805 | Clipping affects the item's appearance (i.e., painting), as well as mouse | - |
4806 | and hover event delivery. | - |
4807 | | - |
4808 | \sa clipPath(), shape(), setFlags() | - |
4809 | */ | - |
4810 | bool QGraphicsItem::isClipped() const | - |
4811 | { | - |
4812 | Q_D(const QGraphicsItem); executed (the execution status of this line is deduced): const QGraphicsItemPrivate * const d = d_func(); | - |
4813 | return (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) executed: return (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) || (d->flags & QGraphicsItem::ItemClipsToShape); Execution Count:216 | 216 |
4814 | || (d->flags & QGraphicsItem::ItemClipsToShape); executed: return (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) || (d->flags & QGraphicsItem::ItemClipsToShape); Execution Count:216 | 216 |
4815 | } | - |
4816 | | - |
4817 | /*! | - |
4818 | \since 4.5 | - |
4819 | | - |
4820 | Returns this item's clip path, or an empty QPainterPath if this item is | - |
4821 | not clipped. The clip path constrains the item's appearance and | - |
4822 | interaction (i.e., restricts the area the item can draw within and receive | - |
4823 | events for). | - |
4824 | | - |
4825 | You can enable clipping by setting the ItemClipsToShape or | - |
4826 | ItemClipsChildrenToShape flags. The item's clip path is calculated by | - |
4827 | intersecting all clipping ancestors' shapes. If the item sets | - |
4828 | ItemClipsToShape, the final clip is intersected with the item's own shape. | - |
4829 | | - |
4830 | \note Clipping introduces a performance penalty for all items involved; | - |
4831 | you should generally avoid using clipping if you can (e.g., if your items | - |
4832 | always draw inside boundingRect() or shape() boundaries, clipping is not | - |
4833 | necessary). | - |
4834 | | - |
4835 | \sa isClipped(), shape(), setFlags() | - |
4836 | */ | - |
4837 | QPainterPath QGraphicsItem::clipPath() const | - |
4838 | { | - |
4839 | Q_D(const QGraphicsItem); never executed (the execution status of this line is deduced): const QGraphicsItemPrivate * const d = d_func(); | - |
4840 | if (!isClipped()) never evaluated: !isClipped() | 0 |
4841 | return QPainterPath(); never executed: return QPainterPath(); | 0 |
4842 | | - |
4843 | const QRectF thisBoundingRect(boundingRect()); never executed (the execution status of this line is deduced): const QRectF thisBoundingRect(boundingRect()); | - |
4844 | if (thisBoundingRect.isEmpty()) never evaluated: thisBoundingRect.isEmpty() | 0 |
4845 | return QPainterPath(); never executed: return QPainterPath(); | 0 |
4846 | | - |
4847 | QPainterPath clip; never executed (the execution status of this line is deduced): QPainterPath clip; | - |
4848 | // Start with the item's bounding rect. | - |
4849 | clip.addRect(thisBoundingRect); never executed (the execution status of this line is deduced): clip.addRect(thisBoundingRect); | - |
4850 | | - |
4851 | if (d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) { never evaluated: d->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren | 0 |
4852 | const QGraphicsItem *parent = this; never executed (the execution status of this line is deduced): const QGraphicsItem *parent = this; | - |
4853 | const QGraphicsItem *lastParent = this; never executed (the execution status of this line is deduced): const QGraphicsItem *lastParent = this; | - |
4854 | | - |
4855 | // Intersect any in-between clips starting at the top and moving downwards. | - |
4856 | while ((parent = parent->d_ptr->parent)) { never evaluated: (parent = parent->d_ptr->parent) | 0 |
4857 | if (parent->d_ptr->flags & ItemClipsChildrenToShape) { never evaluated: parent->d_ptr->flags & ItemClipsChildrenToShape | 0 |
4858 | // Map clip to the current parent and intersect with its shape/clipPath | - |
4859 | clip = lastParent->itemTransform(parent).map(clip); never executed (the execution status of this line is deduced): clip = lastParent->itemTransform(parent).map(clip); | - |
4860 | clip = clip.intersected(parent->shape()); never executed (the execution status of this line is deduced): clip = clip.intersected(parent->shape()); | - |
4861 | if (clip.isEmpty()) never evaluated: clip.isEmpty() | 0 |
4862 | return clip; never executed: return clip; | 0 |
4863 | lastParent = parent; never executed (the execution status of this line is deduced): lastParent = parent; | - |
4864 | } | 0 |
4865 | | - |
4866 | if (!(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren)) never evaluated: !(parent->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) | 0 |
4867 | break; | 0 |
4868 | } | 0 |
4869 | | - |
4870 | if (lastParent != this) { never evaluated: lastParent != this | 0 |
4871 | // Map clip back to the item's transform. | - |
4872 | // ### what if itemtransform fails | - |
4873 | clip = lastParent->itemTransform(this).map(clip); never executed (the execution status of this line is deduced): clip = lastParent->itemTransform(this).map(clip); | - |
4874 | } | 0 |
4875 | } | 0 |
4876 | | - |
4877 | if (d->flags & ItemClipsToShape) never evaluated: d->flags & ItemClipsToShape | 0 |
4878 | clip = clip.intersected(shape()); never executed: clip = clip.intersected(shape()); | 0 |
4879 | | - |
4880 | return clip; never executed: return clip; | 0 |
4881 | } | - |
4882 | | - |
4883 | /*! | - |
4884 | Returns true if this item contains \a point, which is in local | - |
4885 | coordinates; otherwise, false is returned. It is most often called from | - |
4886 | QGraphicsView to determine what item is under the cursor, and for that | - |
4887 | reason, the implementation of this function should be as light-weight as | - |
4888 | possible. | - |
4889 | | - |
4890 | By default, this function calls shape(), but you can reimplement it in a | - |
4891 | subclass to provide a (perhaps more efficient) implementation. | - |
4892 | | - |
4893 | \sa shape(), boundingRect(), collidesWithPath() | - |
4894 | */ | - |
4895 | bool QGraphicsItem::contains(const QPointF &point) const | - |
4896 | { | - |
4897 | return isClipped() ? clipPath().contains(point) : shape().contains(point); executed: return isClipped() ? clipPath().contains(point) : shape().contains(point); Execution Count:212 | 212 |
4898 | } | - |
4899 | | - |
4900 | /*! | - |
4901 | | - |
4902 | Returns true if this item collides with \a other; otherwise | - |
4903 | returns false. | - |
4904 | | - |
4905 | The \a mode is applied to \a other, and the resulting shape or | - |
4906 | bounding rectangle is then compared to this item's shape. The | - |
4907 | default value for \a mode is Qt::IntersectsItemShape; \a other | - |
4908 | collides with this item if it either intersects, contains, or is | - |
4909 | contained by this item's shape (see Qt::ItemSelectionMode for | - |
4910 | details). | - |
4911 | | - |
4912 | The default implementation is based on shape intersection, and it calls | - |
4913 | shape() on both items. Because the complexity of arbitrary shape-shape | - |
4914 | intersection grows with an order of magnitude when the shapes are complex, | - |
4915 | this operation can be noticably time consuming. You have the option of | - |
4916 | reimplementing this function in a subclass of QGraphicsItem to provide a | - |
4917 | custom algorithm. This allows you to make use of natural constraints in | - |
4918 | the shapes of your own items, in order to improve the performance of the | - |
4919 | collision detection. For instance, two untransformed perfectly circular | - |
4920 | items' collision can be determined very efficiently by comparing their | - |
4921 | positions and radii. | - |
4922 | | - |
4923 | Keep in mind that when reimplementing this function and calling shape() or | - |
4924 | boundingRect() on \a other, the returned coordinates must be mapped to | - |
4925 | this item's coordinate system before any intersection can take place. | - |
4926 | | - |
4927 | \sa contains(), shape() | - |
4928 | */ | - |
4929 | bool QGraphicsItem::collidesWithItem(const QGraphicsItem *other, Qt::ItemSelectionMode mode) const | - |
4930 | { | - |
4931 | if (other == this) never evaluated: other == this | 0 |
4932 | return true; never executed: return true; | 0 |
4933 | if (!other) | 0 |
4934 | return false; never executed: return false; | 0 |
4935 | // The items share the same clip if their closest clipper is the same, or | - |
4936 | // if one clips the other. | - |
4937 | bool clips = (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren); never executed (the execution status of this line is deduced): bool clips = (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren); | - |
4938 | bool otherClips = (other->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren); never executed (the execution status of this line is deduced): bool otherClips = (other->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren); | - |
4939 | if (clips || otherClips) { never evaluated: clips never evaluated: otherClips | 0 |
4940 | const QGraphicsItem *closestClipper = isAncestorOf(other) ? this : parentItem(); never evaluated: isAncestorOf(other) | 0 |
4941 | while (closestClipper && !(closestClipper->flags() & ItemClipsChildrenToShape)) never evaluated: closestClipper never evaluated: !(closestClipper->flags() & ItemClipsChildrenToShape) | 0 |
4942 | closestClipper = closestClipper->parentItem(); never executed: closestClipper = closestClipper->parentItem(); | 0 |
4943 | const QGraphicsItem *otherClosestClipper = other->isAncestorOf(this) ? other : other->parentItem(); never evaluated: other->isAncestorOf(this) | 0 |
4944 | while (otherClosestClipper && !(otherClosestClipper->flags() & ItemClipsChildrenToShape)) never evaluated: otherClosestClipper never evaluated: !(otherClosestClipper->flags() & ItemClipsChildrenToShape) | 0 |
4945 | otherClosestClipper = otherClosestClipper->parentItem(); never executed: otherClosestClipper = otherClosestClipper->parentItem(); | 0 |
4946 | if (closestClipper == otherClosestClipper) { never evaluated: closestClipper == otherClosestClipper | 0 |
4947 | d_ptr->localCollisionHack = 1; never executed (the execution status of this line is deduced): d_ptr->localCollisionHack = 1; | - |
4948 | bool res = collidesWithPath(mapFromItem(other, other->shape()), mode); never executed (the execution status of this line is deduced): bool res = collidesWithPath(mapFromItem(other, other->shape()), mode); | - |
4949 | d_ptr->localCollisionHack = 0; never executed (the execution status of this line is deduced): d_ptr->localCollisionHack = 0; | - |
4950 | return res; never executed: return res; | 0 |
4951 | } | - |
4952 | } | 0 |
4953 | | - |
4954 | QPainterPath otherShape = other->isClipped() ? other->clipPath() : other->shape(); never evaluated: other->isClipped() | 0 |
4955 | return collidesWithPath(mapFromItem(other, otherShape), mode); never executed: return collidesWithPath(mapFromItem(other, otherShape), mode); | 0 |
4956 | } | - |
4957 | | - |
4958 | /*! | - |
4959 | Returns true if this item collides with \a path. | - |
4960 | | - |
4961 | The collision is determined by \a mode. The default value for \a mode is | - |
4962 | Qt::IntersectsItemShape; \a path collides with this item if it either | - |
4963 | intersects, contains, or is contained by this item's shape. | - |
4964 | | - |
4965 | Note that this function checks whether the item's shape or | - |
4966 | bounding rectangle (depending on \a mode) is contained within \a | - |
4967 | path, and not whether \a path is contained within the items shape | - |
4968 | or bounding rectangle. | - |
4969 | | - |
4970 | \sa collidesWithItem(), contains(), shape() | - |
4971 | */ | - |
4972 | bool QGraphicsItem::collidesWithPath(const QPainterPath &path, Qt::ItemSelectionMode mode) const | - |
4973 | { | - |
4974 | if (path.isEmpty()) { partially evaluated: path.isEmpty() no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
4975 | // No collision with empty paths. | - |
4976 | return false; never executed: return false; | 0 |
4977 | } | - |
4978 | | - |
4979 | QRectF rectA(boundingRect()); executed (the execution status of this line is deduced): QRectF rectA(boundingRect()); | - |
4980 | _q_adjustRect(&rectA); executed (the execution status of this line is deduced): _q_adjustRect(&rectA); | - |
4981 | QRectF rectB(path.controlPointRect()); executed (the execution status of this line is deduced): QRectF rectB(path.controlPointRect()); | - |
4982 | _q_adjustRect(&rectB); executed (the execution status of this line is deduced): _q_adjustRect(&rectB); | - |
4983 | if (!rectA.intersects(rectB)) { partially evaluated: !rectA.intersects(rectB) no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
4984 | // This we can determine efficiently. If the two rects neither | - |
4985 | // intersect nor contain eachother, then the two items do not collide. | - |
4986 | return false; never executed: return false; | 0 |
4987 | } | - |
4988 | | - |
4989 | // For further testing, we need this item's shape or bounding rect. | - |
4990 | QPainterPath thisShape; executed (the execution status of this line is deduced): QPainterPath thisShape; | - |
4991 | if (mode == Qt::IntersectsItemShape || mode == Qt::ContainsItemShape) partially evaluated: mode == Qt::IntersectsItemShape yes Evaluation Count:4 | no Evaluation Count:0 |
never evaluated: mode == Qt::ContainsItemShape | 0-4 |
4992 | thisShape = (isClipped() && !d_ptr->localCollisionHack) ? clipPath() : shape(); executed: thisShape = (isClipped() && !d_ptr->localCollisionHack) ? clipPath() : shape(); Execution Count:4 partially evaluated: isClipped() no Evaluation Count:0 | yes Evaluation Count:4 |
never evaluated: !d_ptr->localCollisionHack | 0-4 |
4993 | else | - |
4994 | thisShape.addRect(rectA); never executed: thisShape.addRect(rectA); | 0 |
4995 | | - |
4996 | if (thisShape == QPainterPath()) { partially evaluated: thisShape == QPainterPath() no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
4997 | // Empty shape? No collision. | - |
4998 | return false; never executed: return false; | 0 |
4999 | } | - |
5000 | | - |
5001 | // Use QPainterPath boolean operations to determine the collision, O(N*logN). | - |
5002 | if (mode == Qt::IntersectsItemShape || mode == Qt::IntersectsItemBoundingRect) partially evaluated: mode == Qt::IntersectsItemShape yes Evaluation Count:4 | no Evaluation Count:0 |
never evaluated: mode == Qt::IntersectsItemBoundingRect | 0-4 |
5003 | return path.intersects(thisShape); executed: return path.intersects(thisShape); Execution Count:4 | 4 |
5004 | return path.contains(thisShape); never executed: return path.contains(thisShape); | 0 |
5005 | } | - |
5006 | | - |
5007 | /*! | - |
5008 | Returns a list of all items that collide with this item. | - |
5009 | | - |
5010 | The way collisions are detected is determined by applying \a mode | - |
5011 | to items that are compared to this item, i.e., each item's shape | - |
5012 | or bounding rectangle is checked against this item's shape. The | - |
5013 | default value for \a mode is Qt::IntersectsItemShape. | - |
5014 | | - |
5015 | \sa collidesWithItem() | - |
5016 | */ | - |
5017 | QList<QGraphicsItem *> QGraphicsItem::collidingItems(Qt::ItemSelectionMode mode) const | - |
5018 | { | - |
5019 | if (d_ptr->scene) never evaluated: d_ptr->scene | 0 |
5020 | return d_ptr->scene->collidingItems(this, mode); never executed: return d_ptr->scene->collidingItems(this, mode); | 0 |
5021 | return QList<QGraphicsItem *>(); never executed: return QList<QGraphicsItem *>(); | 0 |
5022 | } | - |
5023 | | - |
5024 | /*! | - |
5025 | \internal | - |
5026 | | - |
5027 | Item obscurity helper function. | - |
5028 | | - |
5029 | Returns true if the subrect \a rect of \a item's bounding rect is obscured | - |
5030 | by \a other (i.e., \a other's opaque area covers \a item's \a rect | - |
5031 | completely. \a other is assumed to already be "on top of" \a item | - |
5032 | wrt. stacking order. | - |
5033 | */ | - |
5034 | static bool qt_QGraphicsItem_isObscured(const QGraphicsItem *item, | - |
5035 | const QGraphicsItem *other, | - |
5036 | const QRectF &rect) | - |
5037 | { | - |
5038 | return other->mapToItem(item, other->opaqueArea()).contains(rect); executed: return other->mapToItem(item, other->opaqueArea()).contains(rect); Execution Count:6 | 6 |
5039 | } | - |
5040 | | - |
5041 | /*! | - |
5042 | \overload | - |
5043 | \since 4.3 | - |
5044 | | - |
5045 | Returns true if \a rect is completely obscured by the opaque shape of any | - |
5046 | of colliding items above it (i.e., with a higher Z value than this item). | - |
5047 | | - |
5048 | \sa opaqueArea() | - |
5049 | */ | - |
5050 | bool QGraphicsItem::isObscured(const QRectF &rect) const | - |
5051 | { | - |
5052 | Q_D(const QGraphicsItem); never executed (the execution status of this line is deduced): const QGraphicsItemPrivate * const d = d_func(); | - |
5053 | if (!d->scene) never evaluated: !d->scene | 0 |
5054 | return false; never executed: return false; | 0 |
5055 | | - |
5056 | QRectF br = boundingRect(); never executed (the execution status of this line is deduced): QRectF br = boundingRect(); | - |
5057 | QRectF testRect = rect.isNull() ? br : rect; never evaluated: rect.isNull() | 0 |
5058 | | - |
5059 | foreach (QGraphicsItem *item, d->scene->items(mapToScene(br), Qt::IntersectsItemBoundingRect)) { never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(d->scene->items(mapToScene(br), Qt::IntersectsItemBoundingRect))> _container_(d->scene->items(mapToScene(br), Qt::IntersectsItemBoundingRect)); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
5060 | if (item == this) never evaluated: item == this | 0 |
5061 | break; | 0 |
5062 | if (qt_QGraphicsItem_isObscured(this, item, testRect)) never evaluated: qt_QGraphicsItem_isObscured(this, item, testRect) | 0 |
5063 | return true; never executed: return true; | 0 |
5064 | } | 0 |
5065 | return false; never executed: return false; | 0 |
5066 | } | - |
5067 | | - |
5068 | /*! | - |
5069 | \fn bool QGraphicsItem::isObscured(qreal x, qreal y, qreal w, qreal h) const | - |
5070 | \overload | - |
5071 | \since 4.3 | - |
5072 | | - |
5073 | This convenience function is equivalent to calling isObscured(QRectF(\a x, \a y, \a w, \a h)). | - |
5074 | */ | - |
5075 | | - |
5076 | /*! | - |
5077 | Returns true if this item's bounding rect is completely obscured by the | - |
5078 | opaque shape of \a item. | - |
5079 | | - |
5080 | The base implementation maps \a item's opaqueArea() to this item's | - |
5081 | coordinate system, and then checks if this item's boundingRect() is fully | - |
5082 | contained within the mapped shape. | - |
5083 | | - |
5084 | You can reimplement this function to provide a custom algorithm for | - |
5085 | determining whether this item is obscured by \a item. | - |
5086 | | - |
5087 | \sa opaqueArea(), isObscured() | - |
5088 | */ | - |
5089 | bool QGraphicsItem::isObscuredBy(const QGraphicsItem *item) const | - |
5090 | { | - |
5091 | if (!item) evaluated: !item yes Evaluation Count:2 | yes Evaluation Count:7 |
| 2-7 |
5092 | return false; executed: return false; Execution Count:2 | 2 |
5093 | return qt_closestItemFirst(item, this) executed: return qt_closestItemFirst(item, this) && qt_QGraphicsItem_isObscured(this, item, boundingRect()); Execution Count:7 | 7 |
5094 | && qt_QGraphicsItem_isObscured(this, item, boundingRect()); executed: return qt_closestItemFirst(item, this) && qt_QGraphicsItem_isObscured(this, item, boundingRect()); Execution Count:7 | 7 |
5095 | } | - |
5096 | | - |
5097 | /*! | - |
5098 | This virtual function returns a shape representing the area where this | - |
5099 | item is opaque. An area is opaque if it is filled using an opaque brush or | - |
5100 | color (i.e., not transparent). | - |
5101 | | - |
5102 | This function is used by isObscuredBy(), which is called by underlying | - |
5103 | items to determine if they are obscured by this item. | - |
5104 | | - |
5105 | The default implementation returns an empty QPainterPath, indicating that | - |
5106 | this item is completely transparent and does not obscure any other items. | - |
5107 | | - |
5108 | \sa isObscuredBy(), isObscured(), shape() | - |
5109 | */ | - |
5110 | QPainterPath QGraphicsItem::opaqueArea() const | - |
5111 | { | - |
5112 | return QPainterPath(); executed: return QPainterPath(); Execution Count:2 | 2 |
5113 | } | - |
5114 | | - |
5115 | /*! | - |
5116 | \since 4.4 | - |
5117 | | - |
5118 | Returns the bounding region for this item. The coordinate space of the | - |
5119 | returned region depends on \a itemToDeviceTransform. If you pass an | - |
5120 | identity QTransform as a parameter, this function will return a local | - |
5121 | coordinate region. | - |
5122 | | - |
5123 | The bounding region describes a coarse outline of the item's visual | - |
5124 | contents. Although it's expensive to calculate, it's also more precise | - |
5125 | than boundingRect(), and it can help to avoid unnecessary repainting when | - |
5126 | an item is updated. This is particularly efficient for thin items (e.g., | - |
5127 | lines or simple polygons). You can tune the granularity for the bounding | - |
5128 | region by calling setBoundingRegionGranularity(). The default granularity | - |
5129 | is 0; in which the item's bounding region is the same as its bounding | - |
5130 | rect. | - |
5131 | | - |
5132 | \a itemToDeviceTransform is the transformation from item coordinates to | - |
5133 | device coordinates. If you want this function to return a QRegion in scene | - |
5134 | coordinates, you can pass sceneTransform() as an argument. | - |
5135 | | - |
5136 | \sa boundingRegionGranularity() | - |
5137 | */ | - |
5138 | QRegion QGraphicsItem::boundingRegion(const QTransform &itemToDeviceTransform) const | - |
5139 | { | - |
5140 | // ### Ideally we would have a better way to generate this region, | - |
5141 | // preferably something in the lines of QPainterPath::toRegion(QTransform) | - |
5142 | // coupled with a way to generate a painter path from a set of painter | - |
5143 | // operations (e.g., QPicture::toPainterPath() or so). The current | - |
5144 | // approach generates a bitmap with the size of the item's bounding rect | - |
5145 | // in device coordinates, scaled by b.r.granularity, then paints the item | - |
5146 | // into the bitmap, converts the result to a QRegion and scales the region | - |
5147 | // back to device space with inverse granularity. | - |
5148 | qreal granularity = boundingRegionGranularity(); never executed (the execution status of this line is deduced): qreal granularity = boundingRegionGranularity(); | - |
5149 | QRect deviceRect = itemToDeviceTransform.mapRect(boundingRect()).toRect(); never executed (the execution status of this line is deduced): QRect deviceRect = itemToDeviceTransform.mapRect(boundingRect()).toRect(); | - |
5150 | _q_adjustRect(&deviceRect); never executed (the execution status of this line is deduced): _q_adjustRect(&deviceRect); | - |
5151 | if (granularity == 0.0) never evaluated: granularity == 0.0 | 0 |
5152 | return QRegion(deviceRect); never executed: return QRegion(deviceRect); | 0 |
5153 | | - |
5154 | int pad = 1; never executed (the execution status of this line is deduced): int pad = 1; | - |
5155 | QSize bitmapSize(qMax(1, int(deviceRect.width() * granularity) + pad * 2), never executed (the execution status of this line is deduced): QSize bitmapSize(qMax(1, int(deviceRect.width() * granularity) + pad * 2), | - |
5156 | qMax(1, int(deviceRect.height() * granularity) + pad * 2)); never executed (the execution status of this line is deduced): qMax(1, int(deviceRect.height() * granularity) + pad * 2)); | - |
5157 | QImage mask(bitmapSize, QImage::Format_ARGB32_Premultiplied); never executed (the execution status of this line is deduced): QImage mask(bitmapSize, QImage::Format_ARGB32_Premultiplied); | - |
5158 | mask.fill(0); never executed (the execution status of this line is deduced): mask.fill(0); | - |
5159 | QPainter p(&mask); never executed (the execution status of this line is deduced): QPainter p(&mask); | - |
5160 | p.setRenderHints(QPainter::Antialiasing); never executed (the execution status of this line is deduced): p.setRenderHints(QPainter::Antialiasing); | - |
5161 | | - |
5162 | // Transform painter (### this code is from QGraphicsScene::drawItemHelper | - |
5163 | // and doesn't work properly with perspective transformations). | - |
5164 | QPointF viewOrigo = itemToDeviceTransform.map(QPointF(0, 0)); never executed (the execution status of this line is deduced): QPointF viewOrigo = itemToDeviceTransform.map(QPointF(0, 0)); | - |
5165 | QPointF offset = viewOrigo - deviceRect.topLeft(); never executed (the execution status of this line is deduced): QPointF offset = viewOrigo - deviceRect.topLeft(); | - |
5166 | p.scale(granularity, granularity); never executed (the execution status of this line is deduced): p.scale(granularity, granularity); | - |
5167 | p.translate(offset); never executed (the execution status of this line is deduced): p.translate(offset); | - |
5168 | p.translate(pad, pad); never executed (the execution status of this line is deduced): p.translate(pad, pad); | - |
5169 | p.setWorldTransform(itemToDeviceTransform, true); never executed (the execution status of this line is deduced): p.setWorldTransform(itemToDeviceTransform, true); | - |
5170 | p.translate(itemToDeviceTransform.inverted().map(QPointF(0, 0))); never executed (the execution status of this line is deduced): p.translate(itemToDeviceTransform.inverted().map(QPointF(0, 0))); | - |
5171 | | - |
5172 | // Render | - |
5173 | QStyleOptionGraphicsItem option; never executed (the execution status of this line is deduced): QStyleOptionGraphicsItem option; | - |
5174 | const_cast<QGraphicsItem *>(this)->paint(&p, &option, 0); never executed (the execution status of this line is deduced): const_cast<QGraphicsItem *>(this)->paint(&p, &option, 0); | - |
5175 | p.end(); never executed (the execution status of this line is deduced): p.end(); | - |
5176 | | - |
5177 | // Transform QRegion back to device space | - |
5178 | QTransform unscale = QTransform::fromScale(1 / granularity, 1 / granularity); never executed (the execution status of this line is deduced): QTransform unscale = QTransform::fromScale(1 / granularity, 1 / granularity); | - |
5179 | QRegion r; never executed (the execution status of this line is deduced): QRegion r; | - |
5180 | QBitmap colorMask = QBitmap::fromImage(mask.createMaskFromColor(0)); never executed (the execution status of this line is deduced): QBitmap colorMask = QBitmap::fromImage(mask.createMaskFromColor(0)); | - |
5181 | foreach (const QRect &rect, QRegion( colorMask ).rects()) { never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(QRegion( colorMask ).rects())> _container_(QRegion( colorMask ).rects()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (const QRect &rect = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
5182 | QRect xrect = unscale.mapRect(rect).translated(deviceRect.topLeft() - QPoint(pad, pad)); never executed (the execution status of this line is deduced): QRect xrect = unscale.mapRect(rect).translated(deviceRect.topLeft() - QPoint(pad, pad)); | - |
5183 | r += xrect.adjusted(-1, -1, 1, 1) & deviceRect; never executed (the execution status of this line is deduced): r += xrect.adjusted(-1, -1, 1, 1) & deviceRect; | - |
5184 | } | 0 |
5185 | return r; never executed: return r; | 0 |
5186 | } | - |
5187 | | - |
5188 | /*! | - |
5189 | \since 4.4 | - |
5190 | | - |
5191 | Returns the item's bounding region granularity; a value between and | - |
5192 | including 0 and 1. The default value is 0 (i.e., the lowest granularity, | - |
5193 | where the bounding region corresponds to the item's bounding rectangle). | - |
5194 | | - |
5195 | \omit | - |
5196 | ### NOTE | - |
5197 | \endomit | - |
5198 | | - |
5199 | \sa setBoundingRegionGranularity() | - |
5200 | */ | - |
5201 | qreal QGraphicsItem::boundingRegionGranularity() const | - |
5202 | { | - |
5203 | return d_ptr->hasBoundingRegionGranularity executed: return d_ptr->hasBoundingRegionGranularity ? qvariant_cast<qreal>(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity)) : 0; Execution Count:2 | 2 |
5204 | ? qvariant_cast<qreal>(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity)) executed: return d_ptr->hasBoundingRegionGranularity ? qvariant_cast<qreal>(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity)) : 0; Execution Count:2 | 2 |
5205 | : 0; executed: return d_ptr->hasBoundingRegionGranularity ? qvariant_cast<qreal>(d_ptr->extra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity)) : 0; Execution Count:2 | 2 |
5206 | } | - |
5207 | | - |
5208 | /*! | - |
5209 | \since 4.4 | - |
5210 | Sets the bounding region granularity to \a granularity; a value between | - |
5211 | and including 0 and 1. The default value is 0 (i.e., the lowest | - |
5212 | granularity, where the bounding region corresponds to the item's bounding | - |
5213 | rectangle). | - |
5214 | | - |
5215 | The granularity is used by boundingRegion() to calculate how fine the | - |
5216 | bounding region of the item should be. The highest achievable granularity | - |
5217 | is 1, where boundingRegion() will return the finest outline possible for | - |
5218 | the respective device (e.g., for a QGraphicsView viewport, this gives you | - |
5219 | a pixel-perfect bounding region). The lowest possible granularity is | - |
5220 | 0. The value of \a granularity describes the ratio between device | - |
5221 | resolution and the resolution of the bounding region (e.g., a value of | - |
5222 | 0.25 will provide a region where each chunk corresponds to 4x4 device | - |
5223 | units / pixels). | - |
5224 | | - |
5225 | \sa boundingRegionGranularity() | - |
5226 | */ | - |
5227 | void QGraphicsItem::setBoundingRegionGranularity(qreal granularity) | - |
5228 | { | - |
5229 | if (granularity < 0.0 || granularity > 1.0) { never evaluated: granularity < 0.0 never evaluated: granularity > 1.0 | 0 |
5230 | qWarning("QGraphicsItem::setBoundingRegionGranularity: invalid granularity %g", granularity); never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 5230, __PRETTY_FUNCTION__).warning("QGraphicsItem::setBoundingRegionGranularity: invalid granularity %g", granularity); | - |
5231 | return; | 0 |
5232 | } | - |
5233 | if (granularity == 0.0) { never evaluated: granularity == 0.0 | 0 |
5234 | d_ptr->unsetExtra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity); never executed (the execution status of this line is deduced): d_ptr->unsetExtra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity); | - |
5235 | d_ptr->hasBoundingRegionGranularity = 0; never executed (the execution status of this line is deduced): d_ptr->hasBoundingRegionGranularity = 0; | - |
5236 | return; | 0 |
5237 | } | - |
5238 | d_ptr->hasBoundingRegionGranularity = 1; never executed (the execution status of this line is deduced): d_ptr->hasBoundingRegionGranularity = 1; | - |
5239 | d_ptr->setExtra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity, never executed (the execution status of this line is deduced): d_ptr->setExtra(QGraphicsItemPrivate::ExtraBoundingRegionGranularity, | - |
5240 | QVariant::fromValue<qreal>(granularity)); never executed (the execution status of this line is deduced): QVariant::fromValue<qreal>(granularity)); | - |
5241 | } | 0 |
5242 | | - |
5243 | /*! | - |
5244 | \fn virtual void QGraphicsItem::paint(QPainter *painter, const | - |
5245 | QStyleOptionGraphicsItem *option, QWidget *widget = 0) = 0 | - |
5246 | | - |
5247 | This function, which is usually called by QGraphicsView, paints the | - |
5248 | contents of an item in local coordinates. | - |
5249 | | - |
5250 | Reimplement this function in a QGraphicsItem subclass to provide the | - |
5251 | item's painting implementation, using \a painter. The \a option parameter | - |
5252 | provides style options for the item, such as its state, exposed area and | - |
5253 | its level-of-detail hints. The \a widget argument is optional. If | - |
5254 | provided, it points to the widget that is being painted on; otherwise, it | - |
5255 | is 0. For cached painting, \a widget is always 0. | - |
5256 | | - |
5257 | \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 10 | - |
5258 | | - |
5259 | The painter's pen is 0-width by default, and its pen is initialized to the | - |
5260 | QPalette::Text brush from the paint device's palette. The brush is | - |
5261 | initialized to QPalette::Window. | - |
5262 | | - |
5263 | Make sure to constrain all painting inside the boundaries of | - |
5264 | boundingRect() to avoid rendering artifacts (as QGraphicsView does not | - |
5265 | clip the painter for you). In particular, when QPainter renders the | - |
5266 | outline of a shape using an assigned QPen, half of the outline will be | - |
5267 | drawn outside, and half inside, the shape you're rendering (e.g., with a | - |
5268 | pen width of 2 units, you must draw outlines 1 unit inside | - |
5269 | boundingRect()). QGraphicsItem does not support use of cosmetic pens with | - |
5270 | a non-zero width. | - |
5271 | | - |
5272 | All painting is done in local coordinates. | - |
5273 | | - |
5274 | \sa setCacheMode(), QPen::width(), {Item Coordinates}, ItemUsesExtendedStyleOption | - |
5275 | */ | - |
5276 | | - |
5277 | /*! | - |
5278 | \internal | - |
5279 | Returns true if we can discard an update request; otherwise false. | - |
5280 | */ | - |
5281 | bool QGraphicsItemPrivate::discardUpdateRequest(bool ignoreVisibleBit, bool ignoreDirtyBit, | - |
5282 | bool ignoreOpacity) const | - |
5283 | { | - |
5284 | // No scene, or if the scene is updating everything, means we have nothing | - |
5285 | // to do. The only exception is if the scene tracks the growing scene rect. | - |
5286 | return !scene executed: return !scene || (!visible && !ignoreVisibleBit && !this->ignoreVisible) || (!ignoreDirtyBit && fullUpdatePending) || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent()); Execution Count:404 | 404 |
5287 | || (!visible && !ignoreVisibleBit && !this->ignoreVisible) executed: return !scene || (!visible && !ignoreVisibleBit && !this->ignoreVisible) || (!ignoreDirtyBit && fullUpdatePending) || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent()); Execution Count:404 | 404 |
5288 | || (!ignoreDirtyBit && fullUpdatePending) executed: return !scene || (!visible && !ignoreVisibleBit && !this->ignoreVisible) || (!ignoreDirtyBit && fullUpdatePending) || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent()); Execution Count:404 | 404 |
5289 | || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent()); executed: return !scene || (!visible && !ignoreVisibleBit && !this->ignoreVisible) || (!ignoreDirtyBit && fullUpdatePending) || (!ignoreOpacity && !this->ignoreOpacity && childrenCombineOpacity() && isFullyTransparent()); Execution Count:404 | 404 |
5290 | } | - |
5291 | | - |
5292 | /*! | - |
5293 | \internal | - |
5294 | */ | - |
5295 | int QGraphicsItemPrivate::depth() const | - |
5296 | { | - |
5297 | if (itemDepth == -1) evaluated: itemDepth == -1 yes Evaluation Count:203 | yes Evaluation Count:731 |
| 203-731 |
5298 | const_cast<QGraphicsItemPrivate *>(this)->resolveDepth(); executed: const_cast<QGraphicsItemPrivate *>(this)->resolveDepth(); Execution Count:203 | 203 |
5299 | | - |
5300 | return itemDepth; executed: return itemDepth; Execution Count:934 | 934 |
5301 | } | - |
5302 | | - |
5303 | /*! | - |
5304 | \internal | - |
5305 | */ | - |
5306 | #ifndef QT_NO_GRAPHICSEFFECT | - |
5307 | void QGraphicsItemPrivate::invalidateParentGraphicsEffectsRecursively() | - |
5308 | { | - |
5309 | QGraphicsItemPrivate *itemPrivate = this; executed (the execution status of this line is deduced): QGraphicsItemPrivate *itemPrivate = this; | - |
5310 | do { | - |
5311 | if (itemPrivate->graphicsEffect) { evaluated: itemPrivate->graphicsEffect yes Evaluation Count:19 | yes Evaluation Count:3093 |
| 19-3093 |
5312 | itemPrivate->notifyInvalidated = 1; executed (the execution status of this line is deduced): itemPrivate->notifyInvalidated = 1; | - |
5313 | | - |
5314 | if (!itemPrivate->updateDueToGraphicsEffect) evaluated: !itemPrivate->updateDueToGraphicsEffect yes Evaluation Count:11 | yes Evaluation Count:8 |
| 8-11 |
5315 | static_cast<QGraphicsItemEffectSourcePrivate *>(itemPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache(); executed: static_cast<QGraphicsItemEffectSourcePrivate *>(itemPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache(); Execution Count:11 | 11 |
5316 | } executed: } Execution Count:19 | 19 |
5317 | } while ((itemPrivate = itemPrivate->parent ? itemPrivate->parent->d_ptr.data() : 0)); executed: } Execution Count:3112 evaluated: itemPrivate->parent yes Evaluation Count:1396 | yes Evaluation Count:1716 |
| 1396-3112 |
5318 | } executed: } Execution Count:1716 | 1716 |
5319 | | - |
5320 | void QGraphicsItemPrivate::invalidateChildGraphicsEffectsRecursively(QGraphicsItemPrivate::InvalidateReason reason) | - |
5321 | { | - |
5322 | if (!mayHaveChildWithGraphicsEffect) evaluated: !mayHaveChildWithGraphicsEffect yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
5323 | return; executed: return; Execution Count:2 | 2 |
5324 | | - |
5325 | for (int i = 0; i < children.size(); ++i) { evaluated: i < children.size() yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
5326 | QGraphicsItemPrivate *childPrivate = children.at(i)->d_ptr.data(); executed (the execution status of this line is deduced): QGraphicsItemPrivate *childPrivate = children.at(i)->d_ptr.data(); | - |
5327 | if (reason == OpacityChanged && (childPrivate->flags & QGraphicsItem::ItemIgnoresParentOpacity)) partially evaluated: reason == OpacityChanged yes Evaluation Count:2 | no Evaluation Count:0 |
partially evaluated: (childPrivate->flags & QGraphicsItem::ItemIgnoresParentOpacity) no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
5328 | continue; never executed: continue; | 0 |
5329 | if (childPrivate->graphicsEffect) { partially evaluated: childPrivate->graphicsEffect yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
5330 | childPrivate->notifyInvalidated = 1; executed (the execution status of this line is deduced): childPrivate->notifyInvalidated = 1; | - |
5331 | static_cast<QGraphicsItemEffectSourcePrivate *>(childPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache(); executed (the execution status of this line is deduced): static_cast<QGraphicsItemEffectSourcePrivate *>(childPrivate->graphicsEffect->d_func()->source->d_func())->invalidateCache(); | - |
5332 | } executed: } Execution Count:2 | 2 |
5333 | | - |
5334 | childPrivate->invalidateChildGraphicsEffectsRecursively(reason); executed (the execution status of this line is deduced): childPrivate->invalidateChildGraphicsEffectsRecursively(reason); | - |
5335 | } executed: } Execution Count:2 | 2 |
5336 | } executed: } Execution Count:2 | 2 |
5337 | #endif //QT_NO_GRAPHICSEFFECT | - |
5338 | | - |
5339 | /*! | - |
5340 | \internal | - |
5341 | */ | - |
5342 | void QGraphicsItemPrivate::invalidateDepthRecursively() | - |
5343 | { | - |
5344 | if (itemDepth == -1) evaluated: itemDepth == -1 yes Evaluation Count:1346 | yes Evaluation Count:192 |
| 192-1346 |
5345 | return; executed: return; Execution Count:1346 | 1346 |
5346 | | - |
5347 | itemDepth = -1; executed (the execution status of this line is deduced): itemDepth = -1; | - |
5348 | for (int i = 0; i < children.size(); ++i) partially evaluated: i < children.size() no Evaluation Count:0 | yes Evaluation Count:192 |
| 0-192 |
5349 | children.at(i)->d_ptr->invalidateDepthRecursively(); never executed: children.at(i)->d_ptr->invalidateDepthRecursively(); | 0 |
5350 | } executed: } Execution Count:192 | 192 |
5351 | | - |
5352 | /*! | - |
5353 | \internal | - |
5354 | | - |
5355 | Resolves the stacking depth of this object and all its ancestors. | - |
5356 | */ | - |
5357 | void QGraphicsItemPrivate::resolveDepth() | - |
5358 | { | - |
5359 | if (!parent) evaluated: !parent yes Evaluation Count:178 | yes Evaluation Count:186 |
| 178-186 |
5360 | itemDepth = 0; executed: itemDepth = 0; Execution Count:178 | 178 |
5361 | else { | - |
5362 | if (parent->d_ptr->itemDepth == -1) evaluated: parent->d_ptr->itemDepth == -1 yes Evaluation Count:161 | yes Evaluation Count:25 |
| 25-161 |
5363 | parent->d_ptr->resolveDepth(); executed: parent->d_ptr->resolveDepth(); Execution Count:161 | 161 |
5364 | itemDepth = parent->d_ptr->itemDepth + 1; executed (the execution status of this line is deduced): itemDepth = parent->d_ptr->itemDepth + 1; | - |
5365 | } executed: } Execution Count:186 | 186 |
5366 | } | - |
5367 | | - |
5368 | /*! | - |
5369 | \internal | - |
5370 | | - |
5371 | ### This function is almost identical to | - |
5372 | QGraphicsScenePrivate::registerTopLevelItem(). | - |
5373 | */ | - |
5374 | void QGraphicsItemPrivate::addChild(QGraphicsItem *child) | - |
5375 | { | - |
5376 | // Remove all holes from the sibling index list. Now the max index | - |
5377 | // number is equal to the size of the children list. | - |
5378 | ensureSequentialSiblingIndex(); executed (the execution status of this line is deduced): ensureSequentialSiblingIndex(); | - |
5379 | needSortChildren = 1; // ### maybe 0 executed (the execution status of this line is deduced): needSortChildren = 1; | - |
5380 | child->d_ptr->siblingIndex = children.size(); executed (the execution status of this line is deduced): child->d_ptr->siblingIndex = children.size(); | - |
5381 | children.append(child); executed (the execution status of this line is deduced): children.append(child); | - |
5382 | if (isObject) evaluated: isObject yes Evaluation Count:788 | yes Evaluation Count:5 |
| 5-788 |
5383 | emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged(); executed: static_cast<QGraphicsObject *>(q_ptr)->childrenChanged(); Execution Count:788 | 788 |
5384 | } executed: } Execution Count:793 | 793 |
5385 | | - |
5386 | /*! | - |
5387 | \internal | - |
5388 | | - |
5389 | ### This function is almost identical to | - |
5390 | QGraphicsScenePrivate::unregisterTopLevelItem(). | - |
5391 | */ | - |
5392 | void QGraphicsItemPrivate::removeChild(QGraphicsItem *child) | - |
5393 | { | - |
5394 | // When removing elements in the middle of the children list, | - |
5395 | // there will be a "gap" in the list of sibling indexes (0,1,3,4). | - |
5396 | if (!holesInSiblingIndex) evaluated: !holesInSiblingIndex yes Evaluation Count:194 | yes Evaluation Count:554 |
| 194-554 |
5397 | holesInSiblingIndex = child->d_ptr->siblingIndex != children.size() - 1; executed: holesInSiblingIndex = child->d_ptr->siblingIndex != children.size() - 1; Execution Count:194 | 194 |
5398 | if (sequentialOrdering && !holesInSiblingIndex) partially evaluated: sequentialOrdering yes Evaluation Count:748 | no Evaluation Count:0 |
evaluated: !holesInSiblingIndex yes Evaluation Count:44 | yes Evaluation Count:704 |
| 0-748 |
5399 | children.removeAt(child->d_ptr->siblingIndex); executed: children.removeAt(child->d_ptr->siblingIndex); Execution Count:44 | 44 |
5400 | else | - |
5401 | children.removeOne(child); executed: children.removeOne(child); Execution Count:704 | 704 |
5402 | // NB! Do not use children.removeAt(child->d_ptr->siblingIndex) because | - |
5403 | // the child is not guaranteed to be at the index after the list is sorted. | - |
5404 | // (see ensureSortedChildren()). | - |
5405 | child->d_ptr->siblingIndex = -1; executed (the execution status of this line is deduced): child->d_ptr->siblingIndex = -1; | - |
5406 | if (isObject) evaluated: isObject yes Evaluation Count:744 | yes Evaluation Count:4 |
| 4-744 |
5407 | emit static_cast<QGraphicsObject *>(q_ptr)->childrenChanged(); executed: static_cast<QGraphicsObject *>(q_ptr)->childrenChanged(); Execution Count:744 | 744 |
5408 | } executed: } Execution Count:748 | 748 |
5409 | | - |
5410 | /*! | - |
5411 | \internal | - |
5412 | */ | - |
5413 | QGraphicsItemCache *QGraphicsItemPrivate::maybeExtraItemCache() const | - |
5414 | { | - |
5415 | return (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData)); never executed: return (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData)); | 0 |
5416 | } | - |
5417 | | - |
5418 | /*! | - |
5419 | \internal | - |
5420 | */ | - |
5421 | QGraphicsItemCache *QGraphicsItemPrivate::extraItemCache() const | - |
5422 | { | - |
5423 | QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData)); never executed (the execution status of this line is deduced): QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData)); | - |
5424 | if (!c) { | 0 |
5425 | QGraphicsItemPrivate *that = const_cast<QGraphicsItemPrivate *>(this); never executed (the execution status of this line is deduced): QGraphicsItemPrivate *that = const_cast<QGraphicsItemPrivate *>(this); | - |
5426 | c = new QGraphicsItemCache; never executed (the execution status of this line is deduced): c = new QGraphicsItemCache; | - |
5427 | that->setExtra(ExtraCacheData, QVariant::fromValue<void *>(c)); never executed (the execution status of this line is deduced): that->setExtra(ExtraCacheData, QVariant::fromValue<void *>(c)); | - |
5428 | } | 0 |
5429 | return c; never executed: return c; | 0 |
5430 | } | - |
5431 | | - |
5432 | /*! | - |
5433 | \internal | - |
5434 | */ | - |
5435 | void QGraphicsItemPrivate::removeExtraItemCache() | - |
5436 | { | - |
5437 | QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData)); executed (the execution status of this line is deduced): QGraphicsItemCache *c = (QGraphicsItemCache *)qvariant_cast<void *>(extra(ExtraCacheData)); | - |
5438 | if (c) { partially evaluated: c no Evaluation Count:0 | yes Evaluation Count:1061 |
| 0-1061 |
5439 | c->purge(); never executed (the execution status of this line is deduced): c->purge(); | - |
5440 | delete c; never executed (the execution status of this line is deduced): delete c; | - |
5441 | } | 0 |
5442 | unsetExtra(ExtraCacheData); executed (the execution status of this line is deduced): unsetExtra(ExtraCacheData); | - |
5443 | } executed: } Execution Count:1061 | 1061 |
5444 | | - |
5445 | void QGraphicsItemPrivate::updatePaintedViewBoundingRects(bool updateChildren) | - |
5446 | { | - |
5447 | if (!scene) evaluated: !scene yes Evaluation Count:2 | yes Evaluation Count:9 |
| 2-9 |
5448 | return; executed: return; Execution Count:2 | 2 |
5449 | | - |
5450 | for (int i = 0; i < scene->d_func()->views.size(); ++i) { evaluated: i < scene->d_func()->views.size() yes Evaluation Count:5 | yes Evaluation Count:9 |
| 5-9 |
5451 | QGraphicsViewPrivate *viewPrivate = scene->d_func()->views.at(i)->d_func(); executed (the execution status of this line is deduced): QGraphicsViewPrivate *viewPrivate = scene->d_func()->views.at(i)->d_func(); | - |
5452 | QRect rect = paintedViewBoundingRects.value(viewPrivate->viewport); executed (the execution status of this line is deduced): QRect rect = paintedViewBoundingRects.value(viewPrivate->viewport); | - |
5453 | rect.translate(viewPrivate->dirtyScrollOffset); executed (the execution status of this line is deduced): rect.translate(viewPrivate->dirtyScrollOffset); | - |
5454 | viewPrivate->updateRect(rect); executed (the execution status of this line is deduced): viewPrivate->updateRect(rect); | - |
5455 | } executed: } Execution Count:5 | 5 |
5456 | | - |
5457 | if (updateChildren) { partially evaluated: updateChildren yes Evaluation Count:9 | no Evaluation Count:0 |
| 0-9 |
5458 | for (int i = 0; i < children.size(); ++i) evaluated: i < children.size() yes Evaluation Count:4 | yes Evaluation Count:9 |
| 4-9 |
5459 | children.at(i)->d_ptr->updatePaintedViewBoundingRects(true); executed: children.at(i)->d_ptr->updatePaintedViewBoundingRects(true); Execution Count:4 | 4 |
5460 | } executed: } Execution Count:9 | 9 |
5461 | } executed: } Execution Count:9 | 9 |
5462 | | - |
5463 | // Traverses all the ancestors up to the top-level and updates the pointer to | - |
5464 | // always point to the top-most item that has a dirty scene transform. | - |
5465 | // It then backtracks to the top-most dirty item and start calculating the | - |
5466 | // scene transform by combining the item's transform (+pos) with the parent's | - |
5467 | // cached scene transform (which we at this point know for sure is valid). | - |
5468 | void QGraphicsItemPrivate::ensureSceneTransformRecursive(QGraphicsItem **topMostDirtyItem) | - |
5469 | { | - |
5470 | Q_ASSERT(topMostDirtyItem); executed (the execution status of this line is deduced): qt_noop(); | - |
5471 | | - |
5472 | if (dirtySceneTransform) evaluated: dirtySceneTransform yes Evaluation Count:50 | yes Evaluation Count:396 |
| 50-396 |
5473 | *topMostDirtyItem = q_ptr; executed: *topMostDirtyItem = q_ptr; Execution Count:50 | 50 |
5474 | | - |
5475 | if (parent) evaluated: parent yes Evaluation Count:85 | yes Evaluation Count:361 |
| 85-361 |
5476 | parent->d_ptr->ensureSceneTransformRecursive(topMostDirtyItem); executed: parent->d_ptr->ensureSceneTransformRecursive(topMostDirtyItem); Execution Count:85 | 85 |
5477 | | - |
5478 | if (*topMostDirtyItem == q_ptr) { evaluated: *topMostDirtyItem == q_ptr yes Evaluation Count:361 | yes Evaluation Count:85 |
| 85-361 |
5479 | if (!dirtySceneTransform) evaluated: !dirtySceneTransform yes Evaluation Count:318 | yes Evaluation Count:43 |
| 43-318 |
5480 | return; // OK, neither my ancestors nor I have dirty scene transforms. executed: return; Execution Count:318 | 318 |
5481 | *topMostDirtyItem = 0; executed (the execution status of this line is deduced): *topMostDirtyItem = 0; | - |
5482 | } else if (*topMostDirtyItem) { executed: } Execution Count:43 evaluated: *topMostDirtyItem yes Evaluation Count:78 | yes Evaluation Count:7 |
| 7-78 |
5483 | return; // Continue backtrack. executed: return; Execution Count:78 | 78 |
5484 | } | - |
5485 | | - |
5486 | // This item and all its descendants have dirty scene transforms. | - |
5487 | // We're about to validate this item's scene transform, so we have to | - |
5488 | // invalidate all the children; otherwise there's no way for the descendants | - |
5489 | // to detect that the ancestor has changed. | - |
5490 | invalidateChildrenSceneTransform(); executed (the execution status of this line is deduced): invalidateChildrenSceneTransform(); | - |
5491 | | - |
5492 | // COMBINE my transform with the parent's scene transform. | - |
5493 | updateSceneTransformFromParent(); executed (the execution status of this line is deduced): updateSceneTransformFromParent(); | - |
5494 | Q_ASSERT(!dirtySceneTransform); executed (the execution status of this line is deduced): qt_noop(); | - |
5495 | } executed: } Execution Count:50 | 50 |
5496 | | - |
5497 | /*! | - |
5498 | \internal | - |
5499 | */ | - |
5500 | void QGraphicsItemPrivate::setSubFocus(QGraphicsItem *rootItem, QGraphicsItem *stopItem) | - |
5501 | { | - |
5502 | // Update focus child chain. Stop at panels, or if this item | - |
5503 | // is hidden, stop at the first item with a visible parent. | - |
5504 | QGraphicsItem *parent = rootItem ? rootItem : q_ptr; never evaluated: rootItem | 0 |
5505 | if (parent->panel() != q_ptr->panel()) never evaluated: parent->panel() != q_ptr->panel() | 0 |
5506 | return; | 0 |
5507 | | - |
5508 | do { | - |
5509 | // Clear any existing ancestor's subFocusItem. | - |
5510 | if (parent != q_ptr && parent->d_ptr->subFocusItem) { never evaluated: parent != q_ptr never evaluated: parent->d_ptr->subFocusItem | 0 |
5511 | if (parent->d_ptr->subFocusItem == q_ptr) never evaluated: parent->d_ptr->subFocusItem == q_ptr | 0 |
5512 | break; | 0 |
5513 | parent->d_ptr->subFocusItem->d_ptr->clearSubFocus(0, stopItem); never executed (the execution status of this line is deduced): parent->d_ptr->subFocusItem->d_ptr->clearSubFocus(0, stopItem); | - |
5514 | } | 0 |
5515 | parent->d_ptr->subFocusItem = q_ptr; never executed (the execution status of this line is deduced): parent->d_ptr->subFocusItem = q_ptr; | - |
5516 | parent->d_ptr->subFocusItemChange(); never executed (the execution status of this line is deduced): parent->d_ptr->subFocusItemChange(); | - |
5517 | } while (!parent->isPanel() && (parent = parent->d_ptr->parent) && (visible || !parent->d_ptr->visible)); never executed: } never evaluated: !parent->isPanel() never evaluated: (parent = parent->d_ptr->parent) never evaluated: visible never evaluated: !parent->d_ptr->visible | 0 |
5518 | | - |
5519 | if (scene && !scene->isActive()) { never evaluated: scene never evaluated: !scene->isActive() | 0 |
5520 | scene->d_func()->passiveFocusItem = subFocusItem; never executed (the execution status of this line is deduced): scene->d_func()->passiveFocusItem = subFocusItem; | - |
5521 | scene->d_func()->lastFocusItem = subFocusItem; never executed (the execution status of this line is deduced): scene->d_func()->lastFocusItem = subFocusItem; | - |
5522 | } | 0 |
5523 | } | 0 |
5524 | | - |
5525 | /*! | - |
5526 | \internal | - |
5527 | */ | - |
5528 | void QGraphicsItemPrivate::clearSubFocus(QGraphicsItem *rootItem, QGraphicsItem *stopItem) | - |
5529 | { | - |
5530 | // Reset sub focus chain. | - |
5531 | QGraphicsItem *parent = rootItem ? rootItem : q_ptr; partially evaluated: rootItem no Evaluation Count:0 | yes Evaluation Count:1001 |
| 0-1001 |
5532 | do { | - |
5533 | if (parent->d_ptr->subFocusItem != q_ptr) partially evaluated: parent->d_ptr->subFocusItem != q_ptr yes Evaluation Count:1001 | no Evaluation Count:0 |
| 0-1001 |
5534 | break; executed: break; Execution Count:1001 | 1001 |
5535 | parent->d_ptr->subFocusItem = 0; never executed (the execution status of this line is deduced): parent->d_ptr->subFocusItem = 0; | - |
5536 | if (parent != stopItem && !parent->isAncestorOf(stopItem)) never evaluated: parent != stopItem never evaluated: !parent->isAncestorOf(stopItem) | 0 |
5537 | parent->d_ptr->subFocusItemChange(); never executed: parent->d_ptr->subFocusItemChange(); | 0 |
5538 | } while (!parent->isPanel() && (parent = parent->d_ptr->parent)); never executed: } never evaluated: !parent->isPanel() never evaluated: (parent = parent->d_ptr->parent) | 0 |
5539 | } executed: } Execution Count:1001 | 1001 |
5540 | | - |
5541 | /*! | - |
5542 | \internal | - |
5543 | | - |
5544 | Sets the focusProxy pointer to 0 for all items that have this item as their | - |
5545 | focusProxy. | - |
5546 | */ | - |
5547 | void QGraphicsItemPrivate::resetFocusProxy() | - |
5548 | { | - |
5549 | for (int i = 0; i < focusProxyRefs.size(); ++i) partially evaluated: i < focusProxyRefs.size() no Evaluation Count:0 | yes Evaluation Count:1068 |
| 0-1068 |
5550 | *focusProxyRefs.at(i) = 0; never executed: *focusProxyRefs.at(i) = 0; | 0 |
5551 | focusProxyRefs.clear(); executed (the execution status of this line is deduced): focusProxyRefs.clear(); | - |
5552 | } executed: } Execution Count:1068 | 1068 |
5553 | | - |
5554 | /*! | - |
5555 | \internal | - |
5556 | | - |
5557 | Subclasses can reimplement this function to be notified when subFocusItem | - |
5558 | changes. | - |
5559 | */ | - |
5560 | void QGraphicsItemPrivate::subFocusItemChange() | - |
5561 | { | - |
5562 | } | - |
5563 | | - |
5564 | /*! | - |
5565 | \internal | - |
5566 | | - |
5567 | Subclasses can reimplement this function to be notified when an item | - |
5568 | becomes a focusScopeItem (or is no longer a focusScopeItem). | - |
5569 | */ | - |
5570 | void QGraphicsItemPrivate::focusScopeItemChange(bool isSubFocusItem) | - |
5571 | { | - |
5572 | Q_UNUSED(isSubFocusItem); never executed (the execution status of this line is deduced): (void)isSubFocusItem;; | - |
5573 | } | 0 |
5574 | | - |
5575 | /*! | - |
5576 | \internal | - |
5577 | | - |
5578 | Subclasses can reimplement this function to be notified when its | - |
5579 | siblingIndex order is changed. | - |
5580 | */ | - |
5581 | void QGraphicsItemPrivate::siblingOrderChange() | - |
5582 | { | - |
5583 | } | - |
5584 | | - |
5585 | /*! | - |
5586 | \internal | - |
5587 | | - |
5588 | Tells us if it is a proxy widget | - |
5589 | */ | - |
5590 | bool QGraphicsItemPrivate::isProxyWidget() const | - |
5591 | { | - |
5592 | return false; never executed: return false; | 0 |
5593 | } | - |
5594 | | - |
5595 | /*! | - |
5596 | Schedules a redraw of the area covered by \a rect in this item. You can | - |
5597 | call this function whenever your item needs to be redrawn, such as if it | - |
5598 | changes appearance or size. | - |
5599 | | - |
5600 | This function does not cause an immediate paint; instead it schedules a | - |
5601 | paint request that is processed by QGraphicsView after control reaches the | - |
5602 | event loop. The item will only be redrawn if it is visible in any | - |
5603 | associated view. | - |
5604 | | - |
5605 | As a side effect of the item being repainted, other items that overlap the | - |
5606 | area \a rect may also be repainted. | - |
5607 | | - |
5608 | If the item is invisible (i.e., isVisible() returns false), this function | - |
5609 | does nothing. | - |
5610 | | - |
5611 | \sa paint(), boundingRect() | - |
5612 | */ | - |
5613 | void QGraphicsItem::update(const QRectF &rect) | - |
5614 | { | - |
5615 | if (rect.isEmpty() && !rect.isNull()) evaluated: rect.isEmpty() yes Evaluation Count:1705 | yes Evaluation Count:4 |
partially evaluated: !rect.isNull() no Evaluation Count:0 | yes Evaluation Count:1705 |
| 0-1705 |
5616 | return; | 0 |
5617 | | - |
5618 | // Make sure we notify effects about invalidated source. | - |
5619 | #ifndef QT_NO_GRAPHICSEFFECT | - |
5620 | d_ptr->invalidateParentGraphicsEffectsRecursively(); executed (the execution status of this line is deduced): d_ptr->invalidateParentGraphicsEffectsRecursively(); | - |
5621 | #endif //QT_NO_GRAPHICSEFFECT | - |
5622 | | - |
5623 | if (CacheMode(d_ptr->cacheMode) != NoCache) { partially evaluated: CacheMode(d_ptr->cacheMode) != NoCache no Evaluation Count:0 | yes Evaluation Count:1709 |
| 0-1709 |
5624 | // Invalidate cache. | - |
5625 | QGraphicsItemCache *cache = d_ptr->extraItemCache(); never executed (the execution status of this line is deduced): QGraphicsItemCache *cache = d_ptr->extraItemCache(); | - |
5626 | if (!cache->allExposed) { never evaluated: !cache->allExposed | 0 |
5627 | if (rect.isNull()) { never evaluated: rect.isNull() | 0 |
5628 | cache->allExposed = true; never executed (the execution status of this line is deduced): cache->allExposed = true; | - |
5629 | cache->exposed.clear(); never executed (the execution status of this line is deduced): cache->exposed.clear(); | - |
5630 | } else { | 0 |
5631 | cache->exposed.append(rect); never executed (the execution status of this line is deduced): cache->exposed.append(rect); | - |
5632 | } | 0 |
5633 | } | - |
5634 | // Only invalidate cache; item is already dirty. | - |
5635 | if (d_ptr->fullUpdatePending) never evaluated: d_ptr->fullUpdatePending | 0 |
5636 | return; | 0 |
5637 | } | 0 |
5638 | | - |
5639 | if (d_ptr->scene) evaluated: d_ptr->scene yes Evaluation Count:1566 | yes Evaluation Count:143 |
| 143-1566 |
5640 | d_ptr->scene->d_func()->markDirty(this, rect); executed: d_ptr->scene->d_func()->markDirty(this, rect); Execution Count:1566 | 1566 |
5641 | } executed: } Execution Count:1709 | 1709 |
5642 | | - |
5643 | /*! | - |
5644 | \since 4.4 | - |
5645 | Scrolls the contents of \a rect by \a dx, \a dy. If \a rect is a null rect | - |
5646 | (the default), the item's bounding rect is scrolled. | - |
5647 | | - |
5648 | Scrolling provides a fast alternative to simply redrawing when the | - |
5649 | contents of the item (or parts of the item) are shifted vertically or | - |
5650 | horizontally. Depending on the current transformation and the capabilities | - |
5651 | of the paint device (i.e., the viewport), this operation may consist of | - |
5652 | simply moving pixels from one location to another using memmove(). In most | - |
5653 | cases this is faster than rerendering the entire area. | - |
5654 | | - |
5655 | After scrolling, the item will issue an update for the newly exposed | - |
5656 | areas. If scrolling is not supported (e.g., you are rendering to an OpenGL | - |
5657 | viewport, which does not benefit from scroll optimizations), this function | - |
5658 | is equivalent to calling update(\a rect). | - |
5659 | | - |
5660 | \b{Note:} Scrolling is only supported when QGraphicsItem::ItemCoordinateCache | - |
5661 | is enabled; in all other cases calling this function is equivalent to calling | - |
5662 | update(\a rect). If you for sure know that the item is opaque and not overlapped | - |
5663 | by other items, you can map the \a rect to viewport coordinates and scroll the | - |
5664 | viewport. | - |
5665 | | - |
5666 | \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 19 | - |
5667 | | - |
5668 | \sa boundingRect() | - |
5669 | */ | - |
5670 | void QGraphicsItem::scroll(qreal dx, qreal dy, const QRectF &rect) | - |
5671 | { | - |
5672 | Q_D(QGraphicsItem); never executed (the execution status of this line is deduced): QGraphicsItemPrivate * const d = d_func(); | - |
5673 | if (dx == 0.0 && dy == 0.0) never evaluated: dx == 0.0 never evaluated: dy == 0.0 | 0 |
5674 | return; | 0 |
5675 | if (!d->scene) never evaluated: !d->scene | 0 |
5676 | return; | 0 |
5677 | | - |
5678 | // Accelerated scrolling means moving pixels from one location to another | - |
5679 | // and only redraw the newly exposed area. The following requirements must | - |
5680 | // be fulfilled in order to do that: | - |
5681 | // | - |
5682 | // 1) Item is opaque. | - |
5683 | // 2) Item is not overlapped by other items. | - |
5684 | // | - |
5685 | // There's (yet) no way to detect whether an item is opaque or not, which means | - |
5686 | // we cannot do accelerated scrolling unless the cache is enabled. In case of using | - |
5687 | // DeviceCoordinate cache we also have to take the device transform into account in | - |
5688 | // order to determine whether we can do accelerated scrolling or not. That's left out | - |
5689 | // for simplicity here, but it is definitely something we can consider in the future | - |
5690 | // as a performance improvement. | - |
5691 | if (d->cacheMode != QGraphicsItem::ItemCoordinateCache never evaluated: d->cacheMode != QGraphicsItem::ItemCoordinateCache | 0 |
5692 | || !qFuzzyIsNull(dx - int(dx)) || !qFuzzyIsNull(dy - int(dy))) { never evaluated: !qFuzzyIsNull(dx - int(dx)) never evaluated: !qFuzzyIsNull(dy - int(dy)) | 0 |
5693 | update(rect); never executed (the execution status of this line is deduced): update(rect); | - |
5694 | return; | 0 |
5695 | } | - |
5696 | | - |
5697 | QGraphicsItemCache *cache = d->extraItemCache(); never executed (the execution status of this line is deduced): QGraphicsItemCache *cache = d->extraItemCache(); | - |
5698 | if (cache->allExposed || cache->fixedSize.isValid()) { never evaluated: cache->allExposed never evaluated: cache->fixedSize.isValid() | 0 |
5699 | // Cache is either invalidated or item is scaled (see QGraphicsItem::setCacheMode). | - |
5700 | update(rect); never executed (the execution status of this line is deduced): update(rect); | - |
5701 | return; | 0 |
5702 | } | - |
5703 | | - |
5704 | // Find pixmap in cache. | - |
5705 | QPixmap cachedPixmap; never executed (the execution status of this line is deduced): QPixmap cachedPixmap; | - |
5706 | if (!QPixmapCache::find(cache->key, &cachedPixmap)) { never evaluated: !QPixmapCache::find(cache->key, &cachedPixmap) | 0 |
5707 | update(rect); never executed (the execution status of this line is deduced): update(rect); | - |
5708 | return; | 0 |
5709 | } | - |
5710 | | - |
5711 | QRect scrollRect = (rect.isNull() ? boundingRect() : rect).toAlignedRect(); never evaluated: rect.isNull() | 0 |
5712 | if (!scrollRect.intersects(cache->boundingRect)) never evaluated: !scrollRect.intersects(cache->boundingRect) | 0 |
5713 | return; // Nothing to scroll. | 0 |
5714 | | - |
5715 | // Remove from cache to avoid deep copy when modifying. | - |
5716 | QPixmapCache::remove(cache->key); never executed (the execution status of this line is deduced): QPixmapCache::remove(cache->key); | - |
5717 | | - |
5718 | QRegion exposed; never executed (the execution status of this line is deduced): QRegion exposed; | - |
5719 | cachedPixmap.scroll(dx, dy, scrollRect.translated(-cache->boundingRect.topLeft()), &exposed); never executed (the execution status of this line is deduced): cachedPixmap.scroll(dx, dy, scrollRect.translated(-cache->boundingRect.topLeft()), &exposed); | - |
5720 | | - |
5721 | // Reinsert into cache. | - |
5722 | cache->key = QPixmapCache::insert(cachedPixmap); never executed (the execution status of this line is deduced): cache->key = QPixmapCache::insert(cachedPixmap); | - |
5723 | | - |
5724 | // Translate the existing expose. | - |
5725 | for (int i = 0; i < cache->exposed.size(); ++i) { never evaluated: i < cache->exposed.size() | 0 |
5726 | QRectF &e = cache->exposed[i]; never executed (the execution status of this line is deduced): QRectF &e = cache->exposed[i]; | - |
5727 | if (!rect.isNull() && !e.intersects(rect)) never evaluated: !rect.isNull() never evaluated: !e.intersects(rect) | 0 |
5728 | continue; never executed: continue; | 0 |
5729 | e.translate(dx, dy); never executed (the execution status of this line is deduced): e.translate(dx, dy); | - |
5730 | } | 0 |
5731 | | - |
5732 | // Append newly exposed areas. Note that the exposed region is currently | - |
5733 | // in pixmap coordinates, so we have to translate it to item coordinates. | - |
5734 | exposed.translate(cache->boundingRect.topLeft()); never executed (the execution status of this line is deduced): exposed.translate(cache->boundingRect.topLeft()); | - |
5735 | const QVector<QRect> exposedRects = exposed.rects(); never executed (the execution status of this line is deduced): const QVector<QRect> exposedRects = exposed.rects(); | - |
5736 | for (int i = 0; i < exposedRects.size(); ++i) never evaluated: i < exposedRects.size() | 0 |
5737 | cache->exposed += exposedRects.at(i); never executed: cache->exposed += exposedRects.at(i); | 0 |
5738 | | - |
5739 | // Trigger update. This will redraw the newly exposed area and make sure | - |
5740 | // the pixmap is re-blitted in case there are overlapping items. | - |
5741 | d->scene->d_func()->markDirty(this, rect); never executed (the execution status of this line is deduced): d->scene->d_func()->markDirty(this, rect); | - |
5742 | } | 0 |
5743 | | - |
5744 | /*! | - |
5745 | \fn void QGraphicsItem::update(qreal x, qreal y, qreal width, qreal height) | - |
5746 | \overload | - |
5747 | | - |
5748 | This convenience function is equivalent to calling update(QRectF(\a x, \a | - |
5749 | y, \a width, \a height)). | - |
5750 | */ | - |
5751 | | - |
5752 | /*! | - |
5753 | Maps the point \a point, which is in this item's coordinate system, to \a | - |
5754 | item's coordinate system, and returns the mapped coordinate. | - |
5755 | | - |
5756 | If \a item is 0, this function returns the same as mapToScene(). | - |
5757 | | - |
5758 | \sa itemTransform(), mapToParent(), mapToScene(), transform(), mapFromItem(), {The Graphics | - |
5759 | View Coordinate System} | - |
5760 | */ | - |
5761 | QPointF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPointF &point) const | - |
5762 | { | - |
5763 | if (item) | 0 |
5764 | return itemTransform(item).map(point); never executed: return itemTransform(item).map(point); | 0 |
5765 | return mapToScene(point); never executed: return mapToScene(point); | 0 |
5766 | } | - |
5767 | | - |
5768 | /*! | - |
5769 | \fn QPointF QGraphicsItem::mapToItem(const QGraphicsItem *item, qreal x, qreal y) const | - |
5770 | \overload | - |
5771 | | - |
5772 | This convenience function is equivalent to calling mapToItem(\a item, | - |
5773 | QPointF(\a x, \a y)). | - |
5774 | */ | - |
5775 | | - |
5776 | /*! | - |
5777 | Maps the point \a point, which is in this item's coordinate system, to its | - |
5778 | parent's coordinate system, and returns the mapped coordinate. If the item | - |
5779 | has no parent, \a point will be mapped to the scene's coordinate system. | - |
5780 | | - |
5781 | \sa mapToItem(), mapToScene(), transform(), mapFromParent(), {The Graphics | - |
5782 | View Coordinate System} | - |
5783 | */ | - |
5784 | QPointF QGraphicsItem::mapToParent(const QPointF &point) const | - |
5785 | { | - |
5786 | // COMBINE | - |
5787 | if (!d_ptr->transformData) never evaluated: !d_ptr->transformData | 0 |
5788 | return point + d_ptr->pos; never executed: return point + d_ptr->pos; | 0 |
5789 | return d_ptr->transformToParent().map(point); never executed: return d_ptr->transformToParent().map(point); | 0 |
5790 | } | - |
5791 | | - |
5792 | /*! | - |
5793 | \fn QPointF QGraphicsItem::mapToParent(qreal x, qreal y) const | - |
5794 | \overload | - |
5795 | | - |
5796 | This convenience function is equivalent to calling mapToParent(QPointF(\a | - |
5797 | x, \a y)). | - |
5798 | */ | - |
5799 | | - |
5800 | /*! | - |
5801 | Maps the point \a point, which is in this item's coordinate system, to the | - |
5802 | scene's coordinate system, and returns the mapped coordinate. | - |
5803 | | - |
5804 | \sa mapToItem(), mapToParent(), transform(), mapFromScene(), {The Graphics | - |
5805 | View Coordinate System} | - |
5806 | */ | - |
5807 | QPointF QGraphicsItem::mapToScene(const QPointF &point) const | - |
5808 | { | - |
5809 | if (d_ptr->hasTranslateOnlySceneTransform()) partially evaluated: d_ptr->hasTranslateOnlySceneTransform() yes Evaluation Count:33 | no Evaluation Count:0 |
| 0-33 |
5810 | return QPointF(point.x() + d_ptr->sceneTransform.dx(), point.y() + d_ptr->sceneTransform.dy()); executed: return QPointF(point.x() + d_ptr->sceneTransform.dx(), point.y() + d_ptr->sceneTransform.dy()); Execution Count:33 | 33 |
5811 | return d_ptr->sceneTransform.map(point); never executed: return d_ptr->sceneTransform.map(point); | 0 |
5812 | } | - |
5813 | | - |
5814 | /*! | - |
5815 | \fn QPointF QGraphicsItem::mapToScene(qreal x, qreal y) const | - |
5816 | \overload | - |
5817 | | - |
5818 | This convenience function is equivalent to calling mapToScene(QPointF(\a | - |
5819 | x, \a y)). | - |
5820 | */ | - |
5821 | | - |
5822 | /*! | - |
5823 | Maps the rectangle \a rect, which is in this item's coordinate system, to | - |
5824 | \a item's coordinate system, and returns the mapped rectangle as a polygon. | - |
5825 | | - |
5826 | If \a item is 0, this function returns the same as mapToScene(). | - |
5827 | | - |
5828 | \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The | - |
5829 | Graphics View Coordinate System} | - |
5830 | */ | - |
5831 | QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QRectF &rect) const | - |
5832 | { | - |
5833 | if (item) | 0 |
5834 | return itemTransform(item).map(rect); never executed: return itemTransform(item).map(rect); | 0 |
5835 | return mapToScene(rect); never executed: return mapToScene(rect); | 0 |
5836 | } | - |
5837 | | - |
5838 | /*! | - |
5839 | \fn QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const | - |
5840 | \since 4.3 | - |
5841 | | - |
5842 | This convenience function is equivalent to calling mapToItem(item, QRectF(\a x, \a y, \a w, \a h)). | - |
5843 | */ | - |
5844 | | - |
5845 | /*! | - |
5846 | Maps the rectangle \a rect, which is in this item's coordinate system, to | - |
5847 | its parent's coordinate system, and returns the mapped rectangle as a | - |
5848 | polygon. If the item has no parent, \a rect will be mapped to the scene's | - |
5849 | coordinate system. | - |
5850 | | - |
5851 | \sa mapToScene(), mapToItem(), mapFromParent(), {The Graphics View | - |
5852 | Coordinate System} | - |
5853 | */ | - |
5854 | QPolygonF QGraphicsItem::mapToParent(const QRectF &rect) const | - |
5855 | { | - |
5856 | // COMBINE | - |
5857 | if (!d_ptr->transformData) never evaluated: !d_ptr->transformData | 0 |
5858 | return rect.translated(d_ptr->pos); never executed: return rect.translated(d_ptr->pos); | 0 |
5859 | return d_ptr->transformToParent().map(rect); never executed: return d_ptr->transformToParent().map(rect); | 0 |
5860 | } | - |
5861 | | - |
5862 | /*! | - |
5863 | \fn QPolygonF QGraphicsItem::mapToParent(qreal x, qreal y, qreal w, qreal h) const | - |
5864 | \since 4.3 | - |
5865 | | - |
5866 | This convenience function is equivalent to calling mapToParent(QRectF(\a x, \a y, \a w, \a h)). | - |
5867 | */ | - |
5868 | | - |
5869 | /*! | - |
5870 | Maps the rectangle \a rect, which is in this item's coordinate system, to | - |
5871 | the scene's coordinate system, and returns the mapped rectangle as a polygon. | - |
5872 | | - |
5873 | \sa mapToParent(), mapToItem(), mapFromScene(), {The Graphics View | - |
5874 | Coordinate System} | - |
5875 | */ | - |
5876 | QPolygonF QGraphicsItem::mapToScene(const QRectF &rect) const | - |
5877 | { | - |
5878 | if (d_ptr->hasTranslateOnlySceneTransform()) never evaluated: d_ptr->hasTranslateOnlySceneTransform() | 0 |
5879 | 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 |
5880 | return d_ptr->sceneTransform.map(rect); never executed: return d_ptr->sceneTransform.map(rect); | 0 |
5881 | } | - |
5882 | | - |
5883 | /*! | - |
5884 | \fn QPolygonF QGraphicsItem::mapToScene(qreal x, qreal y, qreal w, qreal h) const | - |
5885 | \since 4.3 | - |
5886 | | - |
5887 | This convenience function is equivalent to calling mapToScene(QRectF(\a x, \a y, \a w, \a h)). | - |
5888 | */ | - |
5889 | | - |
5890 | /*! | - |
5891 | \since 4.5 | - |
5892 | | - |
5893 | Maps the rectangle \a rect, which is in this item's coordinate system, to | - |
5894 | \a item's coordinate system, and returns the mapped rectangle as a new | - |
5895 | rectangle (i.e., the bounding rectangle of the resulting polygon). | - |
5896 | | - |
5897 | If \a item is 0, this function returns the same as mapRectToScene(). | - |
5898 | | - |
5899 | \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The | - |
5900 | Graphics View Coordinate System} | - |
5901 | */ | - |
5902 | QRectF QGraphicsItem::mapRectToItem(const QGraphicsItem *item, const QRectF &rect) const | - |
5903 | { | - |
5904 | if (item) partially evaluated: item yes Evaluation Count:30 | no Evaluation Count:0 |
| 0-30 |
5905 | return itemTransform(item).mapRect(rect); executed: return itemTransform(item).mapRect(rect); Execution Count:30 | 30 |
5906 | return mapRectToScene(rect); never executed: return mapRectToScene(rect); | 0 |
5907 | } | - |
5908 | | - |
5909 | /*! | - |
5910 | \fn QRectF QGraphicsItem::mapRectToItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const | - |
5911 | \since 4.5 | - |
5912 | | - |
5913 | This convenience function is equivalent to calling mapRectToItem(item, QRectF(\a x, \a y, \a w, \a h)). | - |
5914 | */ | - |
5915 | | - |
5916 | /*! | - |
5917 | \since 4.5 | - |
5918 | | - |
5919 | Maps the rectangle \a rect, which is in this item's coordinate system, to | - |
5920 | its parent's coordinate system, and returns the mapped rectangle as a new | - |
5921 | rectangle (i.e., the bounding rectangle of the resulting polygon). | - |
5922 | | - |
5923 | \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The | - |
5924 | Graphics View Coordinate System} | - |
5925 | */ | - |
5926 | QRectF QGraphicsItem::mapRectToParent(const QRectF &rect) const | - |
5927 | { | - |
5928 | // COMBINE | - |
5929 | if (!d_ptr->transformData) never evaluated: !d_ptr->transformData | 0 |
5930 | return rect.translated(d_ptr->pos); never executed: return rect.translated(d_ptr->pos); | 0 |
5931 | return d_ptr->transformToParent().mapRect(rect); never executed: return d_ptr->transformToParent().mapRect(rect); | 0 |
5932 | } | - |
5933 | | - |
5934 | /*! | - |
5935 | \fn QRectF QGraphicsItem::mapRectToParent(qreal x, qreal y, qreal w, qreal h) const | - |
5936 | \since 4.5 | - |
5937 | | - |
5938 | This convenience function is equivalent to calling mapRectToParent(QRectF(\a x, \a y, \a w, \a h)). | - |
5939 | */ | - |
5940 | | - |
5941 | /*! | - |
5942 | \since 4.5 | - |
5943 | | - |
5944 | Maps the rectangle \a rect, which is in this item's coordinate system, to | - |
5945 | the scene coordinate system, and returns the mapped rectangle as a new | - |
5946 | rectangle (i.e., the bounding rectangle of the resulting polygon). | - |
5947 | | - |
5948 | \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The | - |
5949 | Graphics View Coordinate System} | - |
5950 | */ | - |
5951 | QRectF QGraphicsItem::mapRectToScene(const QRectF &rect) const | - |
5952 | { | - |
5953 | if (d_ptr->hasTranslateOnlySceneTransform()) evaluated: d_ptr->hasTranslateOnlySceneTransform() yes Evaluation Count:86 | yes Evaluation Count:3 |
| 3-86 |
5954 | return rect.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy()); executed: return rect.translated(d_ptr->sceneTransform.dx(), d_ptr->sceneTransform.dy()); Execution Count:86 | 86 |
5955 | return d_ptr->sceneTransform.mapRect(rect); executed: return d_ptr->sceneTransform.mapRect(rect); Execution Count:3 | 3 |
5956 | } | - |
5957 | | - |
5958 | /*! | - |
5959 | \fn QRectF QGraphicsItem::mapRectToScene(qreal x, qreal y, qreal w, qreal h) const | - |
5960 | \since 4.5 | - |
5961 | | - |
5962 | This convenience function is equivalent to calling mapRectToScene(QRectF(\a x, \a y, \a w, \a h)). | - |
5963 | */ | - |
5964 | | - |
5965 | /*! | - |
5966 | \since 4.5 | - |
5967 | | - |
5968 | Maps the rectangle \a rect, which is in \a item's coordinate system, to | - |
5969 | this item's coordinate system, and returns the mapped rectangle as a new | - |
5970 | rectangle (i.e., the bounding rectangle of the resulting polygon). | - |
5971 | | - |
5972 | If \a item is 0, this function returns the same as mapRectFromScene(). | - |
5973 | | - |
5974 | \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The | - |
5975 | Graphics View Coordinate System} | - |
5976 | */ | - |
5977 | QRectF QGraphicsItem::mapRectFromItem(const QGraphicsItem *item, const QRectF &rect) const | - |
5978 | { | - |
5979 | if (item) | 0 |
5980 | return item->itemTransform(this).mapRect(rect); never executed: return item->itemTransform(this).mapRect(rect); | 0 |
5981 | return mapRectFromScene(rect); never executed: return mapRectFromScene(rect); | 0 |
5982 | } | - |
5983 | | - |
5984 | /*! | - |
5985 | \fn QRectF QGraphicsItem::mapRectFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const | - |
5986 | \since 4.5 | - |
5987 | | - |
5988 | This convenience function is equivalent to calling mapRectFromItem(item, QRectF(\a x, \a y, \a w, \a h)). | - |
5989 | */ | - |
5990 | | - |
5991 | /*! | - |
5992 | \since 4.5 | - |
5993 | | - |
5994 | Maps the rectangle \a rect, which is in this item's parent's coordinate | - |
5995 | system, to this item's coordinate system, and returns the mapped rectangle | - |
5996 | as a new rectangle (i.e., the bounding rectangle of the resulting | - |
5997 | polygon). | - |
5998 | | - |
5999 | \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The | - |
6000 | Graphics View Coordinate System} | - |
6001 | */ | - |
6002 | QRectF QGraphicsItem::mapRectFromParent(const QRectF &rect) const | - |
6003 | { | - |
6004 | // COMBINE | - |
6005 | if (!d_ptr->transformData) never evaluated: !d_ptr->transformData | 0 |
6006 | return rect.translated(-d_ptr->pos); never executed: return rect.translated(-d_ptr->pos); | 0 |
6007 | return d_ptr->transformToParent().inverted().mapRect(rect); never executed: return d_ptr->transformToParent().inverted().mapRect(rect); | 0 |
6008 | } | - |
6009 | | - |
6010 | /*! | - |
6011 | \fn QRectF QGraphicsItem::mapRectFromParent(qreal x, qreal y, qreal w, qreal h) const | - |
6012 | \since 4.5 | - |
6013 | | - |
6014 | This convenience function is equivalent to calling mapRectFromParent(QRectF(\a x, \a y, \a w, \a h)). | - |
6015 | */ | - |
6016 | | - |
6017 | /*! | - |
6018 | \since 4.5 | - |
6019 | | - |
6020 | Maps the rectangle \a rect, which is in scene coordinates, to this item's | - |
6021 | coordinate system, and returns the mapped rectangle as a new rectangle | - |
6022 | (i.e., the bounding rectangle of the resulting polygon). | - |
6023 | | - |
6024 | \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The | - |
6025 | Graphics View Coordinate System} | - |
6026 | */ | - |
6027 | QRectF QGraphicsItem::mapRectFromScene(const QRectF &rect) const | - |
6028 | { | - |
6029 | if (d_ptr->hasTranslateOnlySceneTransform()) evaluated: d_ptr->hasTranslateOnlySceneTransform() yes Evaluation Count:86 | yes Evaluation Count:3 |
| 3-86 |
6030 | return rect.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy()); executed: return rect.translated(-d_ptr->sceneTransform.dx(), -d_ptr->sceneTransform.dy()); Execution Count:86 | 86 |
6031 | return d_ptr->sceneTransform.inverted().mapRect(rect); executed: return d_ptr->sceneTransform.inverted().mapRect(rect); Execution Count:3 | 3 |
6032 | } | - |
6033 | | - |
6034 | /*! | - |
6035 | \fn QRectF QGraphicsItem::mapRectFromScene(qreal x, qreal y, qreal w, qreal h) const | - |
6036 | \since 4.5 | - |
6037 | | - |
6038 | This convenience function is equivalent to calling mapRectFromScene(QRectF(\a x, \a y, \a w, \a h)). | - |
6039 | */ | - |
6040 | | - |
6041 | /*! | - |
6042 | Maps the polygon \a polygon, which is in this item's coordinate system, to | - |
6043 | \a item's coordinate system, and returns the mapped polygon. | - |
6044 | | - |
6045 | If \a item is 0, this function returns the same as mapToScene(). | - |
6046 | | - |
6047 | \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The | - |
6048 | Graphics View Coordinate System} | - |
6049 | */ | - |
6050 | QPolygonF QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPolygonF &polygon) const | - |
6051 | { | - |
6052 | if (item) | 0 |
6053 | return itemTransform(item).map(polygon); never executed: return itemTransform(item).map(polygon); | 0 |
6054 | return mapToScene(polygon); never executed: return mapToScene(polygon); | 0 |
6055 | } | - |
6056 | | - |
6057 | /*! | - |
6058 | Maps the polygon \a polygon, which is in this item's coordinate system, to | - |
6059 | its parent's coordinate system, and returns the mapped polygon. If the | - |
6060 | item has no parent, \a polygon will be mapped to the scene's coordinate | - |
6061 | system. | - |
6062 | | - |
6063 | \sa mapToScene(), mapToItem(), mapFromParent(), {The Graphics View | - |
6064 | Coordinate System} | - |
6065 | */ | - |
6066 | QPolygonF QGraphicsItem::mapToParent(const QPolygonF &polygon) const | - |
6067 | { | - |
6068 | // COMBINE | - |
6069 | if (!d_ptr->transformData) never evaluated: !d_ptr->transformData | 0 |
6070 | return polygon.translated(d_ptr->pos); never executed: return polygon.translated(d_ptr->pos); | 0 |
6071 | return d_ptr->transformToParent().map(polygon); never executed: return d_ptr->transformToParent().map(polygon); | 0 |
6072 | } | - |
6073 | | - |
6074 | /*! | - |
6075 | Maps the polygon \a polygon, which is in this item's coordinate system, to | - |
6076 | the scene's coordinate system, and returns the mapped polygon. | - |
6077 | | - |
6078 | \sa mapToParent(), mapToItem(), mapFromScene(), {The Graphics View | - |
6079 | Coordinate System} | - |
6080 | */ | - |
6081 | QPolygonF QGraphicsItem::mapToScene(const QPolygonF &polygon) const | - |
6082 | { | - |
6083 | if (d_ptr->hasTranslateOnlySceneTransform()) never evaluated: d_ptr->hasTranslateOnlySceneTransform() | 0 |
6084 | 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 |
6085 | return d_ptr->sceneTransform.map(polygon); never executed: return d_ptr->sceneTransform.map(polygon); | 0 |
6086 | } | - |
6087 | | - |
6088 | /*! | - |
6089 | Maps the path \a path, which is in this item's coordinate system, to | - |
6090 | \a item's coordinate system, and returns the mapped path. | - |
6091 | | - |
6092 | If \a item is 0, this function returns the same as mapToScene(). | - |
6093 | | - |
6094 | \sa itemTransform(), mapToParent(), mapToScene(), mapFromItem(), {The | - |
6095 | Graphics View Coordinate System} | - |
6096 | */ | - |
6097 | QPainterPath QGraphicsItem::mapToItem(const QGraphicsItem *item, const QPainterPath &path) const | - |
6098 | { | - |
6099 | if (item) partially evaluated: item yes Evaluation Count:6 | no Evaluation Count:0 |
| 0-6 |
6100 | return itemTransform(item).map(path); executed: return itemTransform(item).map(path); Execution Count:6 | 6 |
6101 | return mapToScene(path); never executed: return mapToScene(path); | 0 |
6102 | } | - |
6103 | | - |
6104 | /*! | - |
6105 | Maps the path \a path, which is in this item's coordinate system, to | - |
6106 | its parent's coordinate system, and returns the mapped path. If the | - |
6107 | item has no parent, \a path will be mapped to the scene's coordinate | - |
6108 | system. | - |
6109 | | - |
6110 | \sa mapToScene(), mapToItem(), mapFromParent(), {The Graphics View | - |
6111 | Coordinate System} | - |
6112 | */ | - |
6113 | QPainterPath QGraphicsItem::mapToParent(const QPainterPath &path) const | - |
6114 | { | - |
6115 | // COMBINE | - |
6116 | if (!d_ptr->transformData) never evaluated: !d_ptr->transformData | 0 |
6117 | return path.translated(d_ptr->pos); never executed: return path.translated(d_ptr->pos); | 0 |
6118 | return d_ptr->transformToParent().map(path); never executed: return d_ptr->transformToParent().map(path); | 0 |
6119 | } | - |
6120 | | - |
6121 | /*! | - |
6122 | Maps the path \a path, which is in this item's coordinate system, to | - |
6123 | the scene's coordinate system, and returns the mapped path. | - |
6124 | | - |
6125 | \sa mapToParent(), mapToItem(), mapFromScene(), {The Graphics View | - |
6126 | Coordinate System} | - |
6127 | */ | - |
6128 | QPainterPath QGraphicsItem::mapToScene(const QPainterPath &path) const | - |
6129 | { | - |
6130 | if (d_ptr->hasTranslateOnlySceneTransform()) never evaluated: d_ptr->hasTranslateOnlySceneTransform() | 0 |
6131 | 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 |
6132 | return d_ptr->sceneTransform.map(path); never executed: return d_ptr->sceneTransform.map(path); | 0 |
6133 | } | - |
6134 | | - |
6135 | /*! | - |
6136 | Maps the point \a point, which is in \a item's coordinate system, to this | - |
6137 | item's coordinate system, and returns the mapped coordinate. | - |
6138 | | - |
6139 | If \a item is 0, this function returns the same as mapFromScene(). | - |
6140 | | - |
6141 | \sa itemTransform(), mapFromParent(), mapFromScene(), transform(), mapToItem(), {The Graphics | - |
6142 | View Coordinate System} | - |
6143 | */ | - |
6144 | QPointF QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QPointF &point) const | - |
6145 | { | - |
6146 | if (item) | 0 |
6147 | return item->itemTransform(this).map(point); never executed: return item->itemTransform(this).map(point); | 0 |
6148 | return mapFromScene(point); never executed: return mapFromScene(point); | 0 |
6149 | } | - |
6150 | | - |
6151 | /*! | - |
6152 | \fn QPointF QGraphicsItem::mapFromItem(const QGraphicsItem *item, qreal x, qreal y) const | - |
6153 | \overload | - |
6154 | | - |
6155 | This convenience function is equivalent to calling mapFromItem(\a item, | - |
6156 | QPointF(\a x, \a y)). | - |
6157 | */ | - |
6158 | | - |
6159 | /*! | - |
6160 | Maps the point \a point, which is in this item's parent's coordinate | - |
6161 | system, to this item's coordinate system, and returns the mapped | - |
6162 | coordinate. | - |
6163 | | - |
6164 | \sa mapFromItem(), mapFromScene(), transform(), mapToParent(), {The Graphics | - |
6165 | View Coordinate System} | - |
6166 | */ | - |
6167 | QPointF QGraphicsItem::mapFromParent(const QPointF &point) const | - |
6168 | { | - |
6169 | // COMBINE | - |
6170 | if (d_ptr->transformData) never evaluated: d_ptr->transformData | 0 |
6171 | return d_ptr->transformToParent().inverted().map(point); never executed: return d_ptr->transformToParent().inverted().map(point); | 0 |
6172 | return point - d_ptr->pos; never executed: return point - d_ptr->pos; | 0 |
6173 | } | - |
6174 | | - |
6175 | /*! | - |
6176 | \fn QPointF QGraphicsItem::mapFromParent(qreal x, qreal y) const | - |
6177 | \overload | - |
6178 | | - |
6179 | This convenience function is equivalent to calling | - |
6180 | mapFromParent(QPointF(\a x, \a y)). | - |
6181 | */ | - |
6182 | | - |
6183 | /*! | - |
6184 | Maps the point \a point, which is in this item's scene's coordinate | - |
6185 | system, to this item's coordinate system, and returns the mapped | - |
6186 | coordinate. | - |
6187 | | - |
6188 | \sa mapFromItem(), mapFromParent(), transform(), mapToScene(), {The Graphics | - |
6189 | View Coordinate System} | - |
6190 | */ | - |
6191 | QPointF QGraphicsItem::mapFromScene(const QPointF &point) const | - |
6192 | { | - |
6193 | if (d_ptr->hasTranslateOnlySceneTransform()) partially evaluated: d_ptr->hasTranslateOnlySceneTransform() yes Evaluation Count:95 | no Evaluation Count:0 |
| 0-95 |
6194 | return QPointF(point.x() - d_ptr->sceneTransform.dx(), point.y() - d_ptr->sceneTransform.dy()); executed: return QPointF(point.x() - d_ptr->sceneTransform.dx(), point.y() - d_ptr->sceneTransform.dy()); Execution Count:95 | 95 |
6195 | return d_ptr->sceneTransform.inverted().map(point); never executed: return d_ptr->sceneTransform.inverted().map(point); | 0 |
6196 | } | - |
6197 | | - |
6198 | /*! | - |
6199 | \fn QPointF QGraphicsItem::mapFromScene(qreal x, qreal y) const | - |
6200 | \overload | - |
6201 | | - |
6202 | This convenience function is equivalent to calling mapFromScene(QPointF(\a | - |
6203 | x, \a y)). | - |
6204 | */ | - |
6205 | | - |
6206 | /*! | - |
6207 | Maps the rectangle \a rect, which is in \a item's coordinate system, to | - |
6208 | this item's coordinate system, and returns the mapped rectangle as a | - |
6209 | polygon. | - |
6210 | | - |
6211 | If \a item is 0, this function returns the same as mapFromScene() | - |
6212 | | - |
6213 | \sa itemTransform(), mapToItem(), mapFromParent(), transform(), {The Graphics View Coordinate | - |
6214 | System} | - |
6215 | */ | - |
6216 | QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QRectF &rect) const | - |
6217 | { | - |
6218 | if (item) | 0 |
6219 | return item->itemTransform(this).map(rect); never executed: return item->itemTransform(this).map(rect); | 0 |
6220 | return mapFromScene(rect); never executed: return mapFromScene(rect); | 0 |
6221 | } | - |
6222 | | - |
6223 | /*! | - |
6224 | \fn QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, qreal x, qreal y, qreal w, qreal h) const | - |
6225 | \since 4.3 | - |
6226 | | - |
6227 | This convenience function is equivalent to calling mapFromItem(item, QRectF(\a x, \a y, \a w, \a h)). | - |
6228 | */ | - |
6229 | | - |
6230 | /*! | - |
6231 | Maps the rectangle \a rect, which is in this item's parent's coordinate | - |
6232 | system, to this item's coordinate system, and returns the mapped rectangle | - |
6233 | as a polygon. | - |
6234 | | - |
6235 | \sa mapToParent(), mapFromItem(), transform(), {The Graphics View Coordinate | - |
6236 | System} | - |
6237 | */ | - |
6238 | QPolygonF QGraphicsItem::mapFromParent(const QRectF &rect) const | - |
6239 | { | - |
6240 | // COMBINE | - |
6241 | if (!d_ptr->transformData) never evaluated: !d_ptr->transformData | 0 |
6242 | return rect.translated(-d_ptr->pos); never executed: return rect.translated(-d_ptr->pos); | 0 |
6243 | return d_ptr->transformToParent().inverted().map(rect); never executed: return d_ptr->transformToParent().inverted().map(rect); | 0 |
6244 | } | - |
6245 | | - |
6246 | /*! | - |
6247 | \fn QPolygonF QGraphicsItem::mapFromParent(qreal x, qreal y, qreal w, qreal h) const | - |
6248 | \since 4.3 | - |
6249 | | - |
6250 | This convenience function is equivalent to calling mapFromItem(QRectF(\a x, \a y, \a w, \a h)). | - |
6251 | */ | - |
6252 | | - |
6253 | /*! | - |
6254 | Maps the rectangle \a rect, which is in this item's scene's coordinate | - |
6255 | system, to this item's coordinate system, and returns the mapped rectangle | - |
6256 | as a polygon. | - |
6257 | | - |
6258 | \sa mapToScene(), mapFromItem(), transform(), {The Graphics View Coordinate | - |
6259 | System} | - |
6260 | */ | - |
6261 | QPolygonF QGraphicsItem::mapFromScene(const QRectF &rect) const | - |
6262 | { | - |
6263 | if (d_ptr->hasTranslateOnlySceneTransform()) never evaluated: d_ptr->hasTranslateOnlySceneTransform() | 0 |
6264 | 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 |
6265 | return d_ptr->sceneTransform.inverted().map(rect); never executed: return d_ptr->sceneTransform.inverted().map(rect); | 0 |
6266 | } | - |
6267 | | - |
6268 | /*! | - |
6269 | \fn QPolygonF QGraphicsItem::mapFromScene(qreal x, qreal y, qreal w, qreal h) const | - |
6270 | \since 4.3 | - |
6271 | | - |
6272 | This convenience function is equivalent to calling mapFromScene(QRectF(\a x, \a y, \a w, \a h)). | - |
6273 | */ | - |
6274 | | - |
6275 | /*! | - |
6276 | Maps the polygon \a polygon, which is in \a item's coordinate system, to | - |
6277 | this item's coordinate system, and returns the mapped polygon. | - |
6278 | | - |
6279 | If \a item is 0, this function returns the same as mapFromScene(). | - |
6280 | | - |
6281 | \sa itemTransform(), mapToItem(), mapFromParent(), transform(), {The | - |
6282 | Graphics View Coordinate System} | - |
6283 | */ | - |
6284 | QPolygonF QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QPolygonF &polygon) const | - |
6285 | { | - |
6286 | if (item) | 0 |
6287 | return item->itemTransform(this).map(polygon); never executed: return item->itemTransform(this).map(polygon); | 0 |
6288 | return mapFromScene(polygon); never executed: return mapFromScene(polygon); | 0 |
6289 | } | - |
6290 | | - |
6291 | /*! | - |
6292 | Maps the polygon \a polygon, which is in this item's parent's coordinate | - |
6293 | system, to this item's coordinate system, and returns the mapped polygon. | - |
6294 | | - |
6295 | \sa mapToParent(), mapToItem(), transform(), {The Graphics View Coordinate | - |
6296 | System} | - |
6297 | */ | - |
6298 | QPolygonF QGraphicsItem::mapFromParent(const QPolygonF &polygon) const | - |
6299 | { | - |
6300 | // COMBINE | - |
6301 | if (!d_ptr->transformData) never evaluated: !d_ptr->transformData | 0 |
6302 | return polygon.translated(-d_ptr->pos); never executed: return polygon.translated(-d_ptr->pos); | 0 |
6303 | return d_ptr->transformToParent().inverted().map(polygon); never executed: return d_ptr->transformToParent().inverted().map(polygon); | 0 |
6304 | } | - |
6305 | | - |
6306 | /*! | - |
6307 | Maps the polygon \a polygon, which is in this item's scene's coordinate | - |
6308 | system, to this item's coordinate system, and returns the mapped polygon. | - |
6309 | | - |
6310 | \sa mapToScene(), mapFromParent(), transform(), {The Graphics View Coordinate | - |
6311 | System} | - |
6312 | */ | - |
6313 | QPolygonF QGraphicsItem::mapFromScene(const QPolygonF &polygon) const | - |
6314 | { | - |
6315 | if (d_ptr->hasTranslateOnlySceneTransform()) never evaluated: d_ptr->hasTranslateOnlySceneTransform() | 0 |
6316 | 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 |
6317 | return d_ptr->sceneTransform.inverted().map(polygon); never executed: return d_ptr->sceneTransform.inverted().map(polygon); | 0 |
6318 | } | - |
6319 | | - |
6320 | /*! | - |
6321 | Maps the path \a path, which is in \a item's coordinate system, to | - |
6322 | this item's coordinate system, and returns the mapped path. | - |
6323 | | - |
6324 | If \a item is 0, this function returns the same as mapFromScene(). | - |
6325 | | - |
6326 | \sa itemTransform(), mapFromParent(), mapFromScene(), mapToItem(), {The | - |
6327 | Graphics View Coordinate System} | - |
6328 | */ | - |
6329 | QPainterPath QGraphicsItem::mapFromItem(const QGraphicsItem *item, const QPainterPath &path) const | - |
6330 | { | - |
6331 | if (item) | 0 |
6332 | return item->itemTransform(this).map(path); never executed: return item->itemTransform(this).map(path); | 0 |
6333 | return mapFromScene(path); never executed: return mapFromScene(path); | 0 |
6334 | } | - |
6335 | | - |
6336 | /*! | - |
6337 | Maps the path \a path, which is in this item's parent's coordinate | - |
6338 | system, to this item's coordinate system, and returns the mapped path. | - |
6339 | | - |
6340 | \sa mapFromScene(), mapFromItem(), mapToParent(), {The Graphics View | - |
6341 | Coordinate System} | - |
6342 | */ | - |
6343 | QPainterPath QGraphicsItem::mapFromParent(const QPainterPath &path) const | - |
6344 | { | - |
6345 | // COMBINE | - |
6346 | if (!d_ptr->transformData) never evaluated: !d_ptr->transformData | 0 |
6347 | return path.translated(-d_ptr->pos); never executed: return path.translated(-d_ptr->pos); | 0 |
6348 | return d_ptr->transformToParent().inverted().map(path); never executed: return d_ptr->transformToParent().inverted().map(path); | 0 |
6349 | } | - |
6350 | | - |
6351 | /*! | - |
6352 | Maps the path \a path, which is in this item's scene's coordinate | - |
6353 | system, to this item's coordinate system, and returns the mapped path. | - |
6354 | | - |
6355 | \sa mapFromParent(), mapFromItem(), mapToScene(), {The Graphics View | - |
6356 | Coordinate System} | - |
6357 | */ | - |
6358 | QPainterPath QGraphicsItem::mapFromScene(const QPainterPath &path) const | - |
6359 | { | - |
6360 | if (d_ptr->hasTranslateOnlySceneTransform()) never evaluated: d_ptr->hasTranslateOnlySceneTransform() | 0 |
6361 | 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 |
6362 | return d_ptr->sceneTransform.inverted().map(path); never executed: return d_ptr->sceneTransform.inverted().map(path); | 0 |
6363 | } | - |
6364 | | - |
6365 | /*! | - |
6366 | Returns true if this item is an ancestor of \a child (i.e., if this item | - |
6367 | is \a child's parent, or one of \a child's parent's ancestors). | - |
6368 | | - |
6369 | \sa parentItem() | - |
6370 | */ | - |
6371 | bool QGraphicsItem::isAncestorOf(const QGraphicsItem *child) const | - |
6372 | { | - |
6373 | if (!child || child == this) partially evaluated: !child no Evaluation Count:0 | yes Evaluation Count:23 |
partially evaluated: child == this no Evaluation Count:0 | yes Evaluation Count:23 |
| 0-23 |
6374 | return false; never executed: return false; | 0 |
6375 | if (child->d_ptr->depth() < d_ptr->depth()) evaluated: child->d_ptr->depth() < d_ptr->depth() yes Evaluation Count:11 | yes Evaluation Count:12 |
| 11-12 |
6376 | return false; executed: return false; Execution Count:11 | 11 |
6377 | const QGraphicsItem *ancestor = child; executed (the execution status of this line is deduced): const QGraphicsItem *ancestor = child; | - |
6378 | while ((ancestor = ancestor->d_ptr->parent)) { evaluated: (ancestor = ancestor->d_ptr->parent) yes Evaluation Count:8 | yes Evaluation Count:10 |
| 8-10 |
6379 | if (ancestor == this) evaluated: ancestor == this yes Evaluation Count:2 | yes Evaluation Count:6 |
| 2-6 |
6380 | return true; executed: return true; Execution Count:2 | 2 |
6381 | } executed: } Execution Count:6 | 6 |
6382 | return false; executed: return false; Execution Count:10 | 10 |
6383 | } | - |
6384 | | - |
6385 | /*! | - |
6386 | \since 4.4 | - |
6387 | | - |
6388 | Returns the closest common ancestor item of this item and \a other, or 0 | - |
6389 | if either \a other is 0, or there is no common ancestor. | - |
6390 | | - |
6391 | \sa isAncestorOf() | - |
6392 | */ | - |
6393 | QGraphicsItem *QGraphicsItem::commonAncestorItem(const QGraphicsItem *other) const | - |
6394 | { | - |
6395 | if (!other) partially evaluated: !other no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
6396 | return 0; never executed: return 0; | 0 |
6397 | if (other == this) partially evaluated: other == this no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
6398 | return const_cast<QGraphicsItem *>(this); never executed: return const_cast<QGraphicsItem *>(this); | 0 |
6399 | const QGraphicsItem *thisw = this; executed (the execution status of this line is deduced): const QGraphicsItem *thisw = this; | - |
6400 | const QGraphicsItem *otherw = other; executed (the execution status of this line is deduced): const QGraphicsItem *otherw = other; | - |
6401 | int thisDepth = d_ptr->depth(); executed (the execution status of this line is deduced): int thisDepth = d_ptr->depth(); | - |
6402 | int otherDepth = other->d_ptr->depth(); executed (the execution status of this line is deduced): int otherDepth = other->d_ptr->depth(); | - |
6403 | while (thisDepth > otherDepth) { partially evaluated: thisDepth > otherDepth no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
6404 | thisw = thisw->d_ptr->parent; never executed (the execution status of this line is deduced): thisw = thisw->d_ptr->parent; | - |
6405 | --thisDepth; never executed (the execution status of this line is deduced): --thisDepth; | - |
6406 | } | 0 |
6407 | while (otherDepth > thisDepth) { evaluated: otherDepth > thisDepth yes Evaluation Count:3 | yes Evaluation Count:3 |
| 3 |
6408 | otherw = otherw->d_ptr->parent; executed (the execution status of this line is deduced): otherw = otherw->d_ptr->parent; | - |
6409 | --otherDepth; executed (the execution status of this line is deduced): --otherDepth; | - |
6410 | } executed: } Execution Count:3 | 3 |
6411 | while (thisw && thisw != otherw) { evaluated: thisw yes Evaluation Count:3 | yes Evaluation Count:1 |
evaluated: thisw != otherw yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-3 |
6412 | thisw = thisw->d_ptr->parent; executed (the execution status of this line is deduced): thisw = thisw->d_ptr->parent; | - |
6413 | otherw = otherw->d_ptr->parent; executed (the execution status of this line is deduced): otherw = otherw->d_ptr->parent; | - |
6414 | } executed: } Execution Count:1 | 1 |
6415 | return const_cast<QGraphicsItem *>(thisw); executed: return const_cast<QGraphicsItem *>(thisw); Execution Count:3 | 3 |
6416 | } | - |
6417 | | - |
6418 | /*! | - |
6419 | \since 4,4 | - |
6420 | Returns true if this item is currently under the mouse cursor in one of | - |
6421 | the views; otherwise, false is returned. | - |
6422 | | - |
6423 | \sa QGraphicsScene::views(), QCursor::pos() | - |
6424 | */ | - |
6425 | bool QGraphicsItem::isUnderMouse() const | - |
6426 | { | - |
6427 | Q_D(const QGraphicsItem); executed (the execution status of this line is deduced): const QGraphicsItemPrivate * const d = d_func(); | - |
6428 | if (!d->scene) evaluated: !d->scene yes Evaluation Count:184 | yes Evaluation Count:58 |
| 58-184 |
6429 | return false; executed: return false; Execution Count:184 | 184 |
6430 | | - |
6431 | QPoint cursorPos = QCursor::pos(); executed (the execution status of this line is deduced): QPoint cursorPos = QCursor::pos(); | - |
6432 | foreach (QGraphicsView *view, d->scene->views()) { executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(d->scene->views())> _container_(d->scene->views()); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsView *view = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
6433 | if (contains(mapFromScene(view->mapToScene(view->mapFromGlobal(cursorPos))))) evaluated: contains(mapFromScene(view->mapToScene(view->mapFromGlobal(cursorPos)))) yes Evaluation Count:14 | yes Evaluation Count:44 |
| 14-44 |
6434 | return true; executed: return true; Execution Count:14 | 14 |
6435 | } executed: } Execution Count:44 | 44 |
6436 | return false; executed: return false; Execution Count:44 | 44 |
6437 | } | - |
6438 | | - |
6439 | /*! | - |
6440 | Returns this item's custom data for the key \a key as a QVariant. | - |
6441 | | - |
6442 | Custom item data is useful for storing arbitrary properties in any | - |
6443 | item. Example: | - |
6444 | | - |
6445 | \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 11 | - |
6446 | | - |
6447 | Qt does not use this feature for storing data; it is provided solely | - |
6448 | for the convenience of the user. | - |
6449 | | - |
6450 | \sa setData() | - |
6451 | */ | - |
6452 | QVariant QGraphicsItem::data(int key) const | - |
6453 | { | - |
6454 | QGraphicsItemCustomDataStore *store = qt_dataStore(); never executed (the execution status of this line is deduced): QGraphicsItemCustomDataStore *store = qt_dataStore(); | - |
6455 | if (!store->data.contains(this)) never evaluated: !store->data.contains(this) | 0 |
6456 | return QVariant(); never executed: return QVariant(); | 0 |
6457 | return store->data.value(this).value(key); never executed: return store->data.value(this).value(key); | 0 |
6458 | } | - |
6459 | | - |
6460 | /*! | - |
6461 | Sets this item's custom data for the key \a key to \a value. | - |
6462 | | - |
6463 | Custom item data is useful for storing arbitrary properties for any | - |
6464 | item. Qt does not use this feature for storing data; it is provided solely | - |
6465 | for the convenience of the user. | - |
6466 | | - |
6467 | \sa data() | - |
6468 | */ | - |
6469 | void QGraphicsItem::setData(int key, const QVariant &value) | - |
6470 | { | - |
6471 | qt_dataStore()->data[this][key] = value; executed (the execution status of this line is deduced): qt_dataStore()->data[this][key] = value; | - |
6472 | } executed: } Execution Count:7 | 7 |
6473 | | - |
6474 | /*! | - |
6475 | \fn T qgraphicsitem_cast(QGraphicsItem *item) | - |
6476 | \relates QGraphicsItem | - |
6477 | \since 4.2 | - |
6478 | | - |
6479 | Returns the given \a item cast to type T if \a item is of type T; | - |
6480 | otherwise, 0 is returned. | - |
6481 | | - |
6482 | \note To make this function work correctly with custom items, reimplement | - |
6483 | the \l{QGraphicsItem::}{type()} function for each custom QGraphicsItem | - |
6484 | subclass. | - |
6485 | | - |
6486 | \sa QGraphicsItem::type(), QGraphicsItem::UserType | - |
6487 | */ | - |
6488 | | - |
6489 | /*! | - |
6490 | Returns the type of an item as an int. All standard graphicsitem classes | - |
6491 | are associated with a unique value; see QGraphicsItem::Type. This type | - |
6492 | information is used by qgraphicsitem_cast() to distinguish between types. | - |
6493 | | - |
6494 | The default implementation (in QGraphicsItem) returns UserType. | - |
6495 | | - |
6496 | To enable use of qgraphicsitem_cast() with a custom item, reimplement this | - |
6497 | function and declare a Type enum value equal to your custom item's type. | - |
6498 | Custom items must return a value larger than or equal to UserType (65536). | - |
6499 | | - |
6500 | For example: | - |
6501 | | - |
6502 | \snippet code/src_gui_graphicsview_qgraphicsitem.cpp QGraphicsItem type | - |
6503 | | - |
6504 | \sa UserType | - |
6505 | */ | - |
6506 | int QGraphicsItem::type() const | - |
6507 | { | - |
6508 | return (int)UserType; never executed: return (int)UserType; | 0 |
6509 | } | - |
6510 | | - |
6511 | /*! | - |
6512 | Installs an event filter for this item on \a filterItem, causing | - |
6513 | all events for this item to first pass through \a filterItem's | - |
6514 | sceneEventFilter() function. | - |
6515 | | - |
6516 | To filter another item's events, install this item as an event filter | - |
6517 | for the other item. Example: | - |
6518 | | - |
6519 | \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 12 | - |
6520 | | - |
6521 | An item can only filter events for other items in the same | - |
6522 | scene. Also, an item cannot filter its own events; instead, you | - |
6523 | can reimplement sceneEvent() directly. | - |
6524 | | - |
6525 | Items must belong to a scene for scene event filters to be installed and | - |
6526 | used. | - |
6527 | | - |
6528 | \sa removeSceneEventFilter(), sceneEventFilter(), sceneEvent() | - |
6529 | */ | - |
6530 | void QGraphicsItem::installSceneEventFilter(QGraphicsItem *filterItem) | - |
6531 | { | - |
6532 | if (!d_ptr->scene) { never evaluated: !d_ptr->scene | 0 |
6533 | qWarning("QGraphicsItem::installSceneEventFilter: event filters can only be installed" never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 6533, __PRETTY_FUNCTION__).warning("QGraphicsItem::installSceneEventFilter: event filters can only be installed" | - |
6534 | " on items in a scene."); never executed (the execution status of this line is deduced): " on items in a scene."); | - |
6535 | return; | 0 |
6536 | } | - |
6537 | if (d_ptr->scene != filterItem->scene()) { never evaluated: d_ptr->scene != filterItem->scene() | 0 |
6538 | qWarning("QGraphicsItem::installSceneEventFilter: event filters can only be installed" never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 6538, __PRETTY_FUNCTION__).warning("QGraphicsItem::installSceneEventFilter: event filters can only be installed" | - |
6539 | " on items in the same scene."); never executed (the execution status of this line is deduced): " on items in the same scene."); | - |
6540 | return; | 0 |
6541 | } | - |
6542 | d_ptr->scene->d_func()->installSceneEventFilter(this, filterItem); never executed (the execution status of this line is deduced): d_ptr->scene->d_func()->installSceneEventFilter(this, filterItem); | - |
6543 | } | 0 |
6544 | | - |
6545 | /*! | - |
6546 | Removes an event filter on this item from \a filterItem. | - |
6547 | | - |
6548 | \sa installSceneEventFilter() | - |
6549 | */ | - |
6550 | void QGraphicsItem::removeSceneEventFilter(QGraphicsItem *filterItem) | - |
6551 | { | - |
6552 | if (!d_ptr->scene || d_ptr->scene != filterItem->scene()) never evaluated: !d_ptr->scene never evaluated: d_ptr->scene != filterItem->scene() | 0 |
6553 | return; | 0 |
6554 | d_ptr->scene->d_func()->removeSceneEventFilter(this, filterItem); never executed (the execution status of this line is deduced): d_ptr->scene->d_func()->removeSceneEventFilter(this, filterItem); | - |
6555 | } | 0 |
6556 | | - |
6557 | /*! | - |
6558 | Filters events for the item \a watched. \a event is the filtered | - |
6559 | event. | - |
6560 | | - |
6561 | Reimplementing this function in a subclass makes it possible | - |
6562 | for the item to be used as an event filter for other items, | - |
6563 | intercepting all the events send to those items before they are | - |
6564 | able to respond. | - |
6565 | | - |
6566 | Reimplementations must return true to prevent further processing of | - |
6567 | a given event, ensuring that it will not be delivered to the watched | - |
6568 | item, or return false to indicate that the event should be propagated | - |
6569 | further by the event system. | - |
6570 | | - |
6571 | \sa installSceneEventFilter() | - |
6572 | */ | - |
6573 | bool QGraphicsItem::sceneEventFilter(QGraphicsItem *watched, QEvent *event) | - |
6574 | { | - |
6575 | Q_UNUSED(watched); never executed (the execution status of this line is deduced): (void)watched;; | - |
6576 | Q_UNUSED(event); never executed (the execution status of this line is deduced): (void)event;; | - |
6577 | return false; never executed: return false; | 0 |
6578 | } | - |
6579 | | - |
6580 | /*! | - |
6581 | This virtual function receives events to this item. Reimplement | - |
6582 | this function to intercept events before they are dispatched to | - |
6583 | the specialized event handlers contextMenuEvent(), focusInEvent(), | - |
6584 | focusOutEvent(), hoverEnterEvent(), hoverMoveEvent(), | - |
6585 | hoverLeaveEvent(), keyPressEvent(), keyReleaseEvent(), | - |
6586 | mousePressEvent(), mouseReleaseEvent(), mouseMoveEvent(), and | - |
6587 | mouseDoubleClickEvent(). | - |
6588 | | - |
6589 | Returns true if the event was recognized and handled; otherwise, (e.g., if | - |
6590 | the event type was not recognized,) false is returned. | - |
6591 | | - |
6592 | \a event is the intercepted event. | - |
6593 | */ | - |
6594 | bool QGraphicsItem::sceneEvent(QEvent *event) | - |
6595 | { | - |
6596 | if (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents) { partially evaluated: d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents no Evaluation Count:0 | yes Evaluation Count:181 |
| 0-181 |
6597 | if (event->type() == QEvent::HoverEnter || event->type() == QEvent::HoverLeave never evaluated: event->type() == QEvent::HoverEnter never evaluated: event->type() == QEvent::HoverLeave | 0 |
6598 | || event->type() == QEvent::DragEnter || event->type() == QEvent::DragLeave) { never evaluated: event->type() == QEvent::DragEnter never evaluated: event->type() == QEvent::DragLeave | 0 |
6599 | // Hover enter and hover leave events for children are ignored; | - |
6600 | // hover move events are forwarded. | - |
6601 | return true; never executed: return true; | 0 |
6602 | } | - |
6603 | | - |
6604 | QGraphicsItem *handler = this; never executed (the execution status of this line is deduced): QGraphicsItem *handler = this; | - |
6605 | do { | - |
6606 | handler = handler->d_ptr->parent; never executed (the execution status of this line is deduced): handler = handler->d_ptr->parent; | - |
6607 | Q_ASSERT(handler); never executed (the execution status of this line is deduced): qt_noop(); | - |
6608 | } while (handler->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents); never executed: } never evaluated: handler->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents | 0 |
6609 | // Forward the event to the closest parent that handles child | - |
6610 | // events, mapping existing item-local coordinates to its | - |
6611 | // coordinate system. | - |
6612 | d_ptr->remapItemPos(event, handler); never executed (the execution status of this line is deduced): d_ptr->remapItemPos(event, handler); | - |
6613 | handler->sceneEvent(event); never executed (the execution status of this line is deduced): handler->sceneEvent(event); | - |
6614 | return true; never executed: return true; | 0 |
6615 | } | - |
6616 | | - |
6617 | if (event->type() == QEvent::FocusOut) { partially evaluated: event->type() == QEvent::FocusOut no Evaluation Count:0 | yes Evaluation Count:181 |
| 0-181 |
6618 | focusOutEvent(static_cast<QFocusEvent *>(event)); never executed (the execution status of this line is deduced): focusOutEvent(static_cast<QFocusEvent *>(event)); | - |
6619 | return true; never executed: return true; | 0 |
6620 | } | - |
6621 | | - |
6622 | if (!d_ptr->visible) { partially evaluated: !d_ptr->visible no Evaluation Count:0 | yes Evaluation Count:181 |
| 0-181 |
6623 | // Eaten | - |
6624 | return true; never executed: return true; | 0 |
6625 | } | - |
6626 | | - |
6627 | switch (event->type()) { | - |
6628 | case QEvent::FocusIn: | - |
6629 | focusInEvent(static_cast<QFocusEvent *>(event)); never executed (the execution status of this line is deduced): focusInEvent(static_cast<QFocusEvent *>(event)); | - |
6630 | break; | 0 |
6631 | case QEvent::GraphicsSceneContextMenu: | - |
6632 | contextMenuEvent(static_cast<QGraphicsSceneContextMenuEvent *>(event)); never executed (the execution status of this line is deduced): contextMenuEvent(static_cast<QGraphicsSceneContextMenuEvent *>(event)); | - |
6633 | break; | 0 |
6634 | case QEvent::GraphicsSceneDragEnter: | - |
6635 | dragEnterEvent(static_cast<QGraphicsSceneDragDropEvent *>(event)); never executed (the execution status of this line is deduced): dragEnterEvent(static_cast<QGraphicsSceneDragDropEvent *>(event)); | - |
6636 | break; | 0 |
6637 | case QEvent::GraphicsSceneDragMove: | - |
6638 | dragMoveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event)); never executed (the execution status of this line is deduced): dragMoveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event)); | - |
6639 | break; | 0 |
6640 | case QEvent::GraphicsSceneDragLeave: | - |
6641 | dragLeaveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event)); never executed (the execution status of this line is deduced): dragLeaveEvent(static_cast<QGraphicsSceneDragDropEvent *>(event)); | - |
6642 | break; | 0 |
6643 | case QEvent::GraphicsSceneDrop: | - |
6644 | dropEvent(static_cast<QGraphicsSceneDragDropEvent *>(event)); never executed (the execution status of this line is deduced): dropEvent(static_cast<QGraphicsSceneDragDropEvent *>(event)); | - |
6645 | break; | 0 |
6646 | case QEvent::GraphicsSceneHoverEnter: | - |
6647 | hoverEnterEvent(static_cast<QGraphicsSceneHoverEvent *>(event)); never executed (the execution status of this line is deduced): hoverEnterEvent(static_cast<QGraphicsSceneHoverEvent *>(event)); | - |
6648 | break; | 0 |
6649 | case QEvent::GraphicsSceneHoverMove: | - |
6650 | hoverMoveEvent(static_cast<QGraphicsSceneHoverEvent *>(event)); never executed (the execution status of this line is deduced): hoverMoveEvent(static_cast<QGraphicsSceneHoverEvent *>(event)); | - |
6651 | break; | 0 |
6652 | case QEvent::GraphicsSceneHoverLeave: | - |
6653 | hoverLeaveEvent(static_cast<QGraphicsSceneHoverEvent *>(event)); never executed (the execution status of this line is deduced): hoverLeaveEvent(static_cast<QGraphicsSceneHoverEvent *>(event)); | - |
6654 | break; | 0 |
6655 | case QEvent::GraphicsSceneMouseMove: | - |
6656 | mouseMoveEvent(static_cast<QGraphicsSceneMouseEvent *>(event)); executed (the execution status of this line is deduced): mouseMoveEvent(static_cast<QGraphicsSceneMouseEvent *>(event)); | - |
6657 | break; executed: break; Execution Count:1 | 1 |
6658 | case QEvent::GraphicsSceneMousePress: | - |
6659 | mousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event)); never executed (the execution status of this line is deduced): mousePressEvent(static_cast<QGraphicsSceneMouseEvent *>(event)); | - |
6660 | break; | 0 |
6661 | case QEvent::GraphicsSceneMouseRelease: | - |
6662 | mouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event)); executed (the execution status of this line is deduced): mouseReleaseEvent(static_cast<QGraphicsSceneMouseEvent *>(event)); | - |
6663 | break; executed: break; Execution Count:2 | 2 |
6664 | case QEvent::GraphicsSceneMouseDoubleClick: | - |
6665 | mouseDoubleClickEvent(static_cast<QGraphicsSceneMouseEvent *>(event)); never executed (the execution status of this line is deduced): mouseDoubleClickEvent(static_cast<QGraphicsSceneMouseEvent *>(event)); | - |
6666 | break; | 0 |
6667 | case QEvent::GraphicsSceneWheel: | - |
6668 | wheelEvent(static_cast<QGraphicsSceneWheelEvent *>(event)); never executed (the execution status of this line is deduced): wheelEvent(static_cast<QGraphicsSceneWheelEvent *>(event)); | - |
6669 | break; | 0 |
6670 | case QEvent::KeyPress: { | - |
6671 | QKeyEvent *k = static_cast<QKeyEvent *>(event); never executed (the execution status of this line is deduced): QKeyEvent *k = static_cast<QKeyEvent *>(event); | - |
6672 | if (k->key() == Qt::Key_Tab || k->key() == Qt::Key_Backtab) { never evaluated: k->key() == Qt::Key_Tab never evaluated: k->key() == Qt::Key_Backtab | 0 |
6673 | if (!(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier))) { //### Add MetaModifier? never evaluated: !(k->modifiers() & (Qt::ControlModifier | Qt::AltModifier)) | 0 |
6674 | bool res = false; never executed (the execution status of this line is deduced): bool res = false; | - |
6675 | if (k->key() == Qt::Key_Backtab never evaluated: k->key() == Qt::Key_Backtab | 0 |
6676 | || (k->key() == Qt::Key_Tab && (k->modifiers() & Qt::ShiftModifier))) { never evaluated: k->key() == Qt::Key_Tab never evaluated: (k->modifiers() & Qt::ShiftModifier) | 0 |
6677 | if (d_ptr->isWidget) { never evaluated: d_ptr->isWidget | 0 |
6678 | res = static_cast<QGraphicsWidget *>(this)->focusNextPrevChild(false); never executed (the execution status of this line is deduced): res = static_cast<QGraphicsWidget *>(this)->focusNextPrevChild(false); | - |
6679 | } else if (d_ptr->scene) { never executed: } never evaluated: d_ptr->scene | 0 |
6680 | res = d_ptr->scene->focusNextPrevChild(false); never executed (the execution status of this line is deduced): res = d_ptr->scene->focusNextPrevChild(false); | - |
6681 | } | 0 |
6682 | } else if (k->key() == Qt::Key_Tab) { never evaluated: k->key() == Qt::Key_Tab | 0 |
6683 | if (d_ptr->isWidget) { never evaluated: d_ptr->isWidget | 0 |
6684 | res = static_cast<QGraphicsWidget *>(this)->focusNextPrevChild(true); never executed (the execution status of this line is deduced): res = static_cast<QGraphicsWidget *>(this)->focusNextPrevChild(true); | - |
6685 | } else if (d_ptr->scene) { never executed: } never evaluated: d_ptr->scene | 0 |
6686 | res = d_ptr->scene->focusNextPrevChild(true); never executed (the execution status of this line is deduced): res = d_ptr->scene->focusNextPrevChild(true); | - |
6687 | } | 0 |
6688 | } | - |
6689 | if (!res) | 0 |
6690 | event->ignore(); never executed: event->ignore(); | 0 |
6691 | return true; never executed: return true; | 0 |
6692 | } | - |
6693 | } | 0 |
6694 | keyPressEvent(static_cast<QKeyEvent *>(event)); never executed (the execution status of this line is deduced): keyPressEvent(static_cast<QKeyEvent *>(event)); | - |
6695 | break; | 0 |
6696 | } | - |
6697 | case QEvent::KeyRelease: | - |
6698 | keyReleaseEvent(static_cast<QKeyEvent *>(event)); never executed (the execution status of this line is deduced): keyReleaseEvent(static_cast<QKeyEvent *>(event)); | - |
6699 | break; | 0 |
6700 | case QEvent::InputMethod: | - |
6701 | inputMethodEvent(static_cast<QInputMethodEvent *>(event)); never executed (the execution status of this line is deduced): inputMethodEvent(static_cast<QInputMethodEvent *>(event)); | - |
6702 | break; | 0 |
6703 | case QEvent::WindowActivate: | - |
6704 | case QEvent::WindowDeactivate: | - |
6705 | // Propagate panel activation. | - |
6706 | if (d_ptr->scene) { partially evaluated: d_ptr->scene yes Evaluation Count:174 | no Evaluation Count:0 |
| 0-174 |
6707 | for (int i = 0; i < d_ptr->children.size(); ++i) { evaluated: i < d_ptr->children.size() yes Evaluation Count:103 | yes Evaluation Count:174 |
| 103-174 |
6708 | QGraphicsItem *child = d_ptr->children.at(i); executed (the execution status of this line is deduced): QGraphicsItem *child = d_ptr->children.at(i); | - |
6709 | if (child->isVisible() && !child->isPanel()) { evaluated: child->isVisible() yes Evaluation Count:102 | yes Evaluation Count:1 |
partially evaluated: !child->isPanel() yes Evaluation Count:102 | no Evaluation Count:0 |
| 0-102 |
6710 | if (!(child->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents)) partially evaluated: !(child->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorHandlesChildEvents) yes Evaluation Count:102 | no Evaluation Count:0 |
| 0-102 |
6711 | d_ptr->scene->sendEvent(child, event); executed: d_ptr->scene->sendEvent(child, event); Execution Count:102 | 102 |
6712 | } executed: } Execution Count:102 | 102 |
6713 | } executed: } Execution Count:103 | 103 |
6714 | } executed: } Execution Count:174 | 174 |
6715 | break; executed: break; Execution Count:174 | 174 |
6716 | default: | - |
6717 | return false; executed: return false; Execution Count:4 | 4 |
6718 | } | - |
6719 | | - |
6720 | return true; executed: return true; Execution Count:177 | 177 |
6721 | } | - |
6722 | | - |
6723 | /*! | - |
6724 | This event handler can be reimplemented in a subclass to process context | - |
6725 | menu events. The \a event parameter contains details about the event to | - |
6726 | be handled. | - |
6727 | | - |
6728 | If you ignore the event (i.e., by calling QEvent::ignore()), \a event | - |
6729 | will propagate to any item beneath this item. If no items accept the | - |
6730 | event, it will be ignored by the scene and propagate to the view. | - |
6731 | | - |
6732 | It's common to open a QMenu in response to receiving a context menu | - |
6733 | event. Example: | - |
6734 | | - |
6735 | \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 13 | - |
6736 | | - |
6737 | The default implementation ignores the event. | - |
6738 | | - |
6739 | \sa sceneEvent() | - |
6740 | */ | - |
6741 | void QGraphicsItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) | - |
6742 | { | - |
6743 | event->ignore(); never executed (the execution status of this line is deduced): event->ignore(); | - |
6744 | } | 0 |
6745 | | - |
6746 | /*! | - |
6747 | This event handler, for event \a event, can be reimplemented to receive | - |
6748 | drag enter events for this item. Drag enter events are generated as the | - |
6749 | cursor enters the item's area. | - |
6750 | | - |
6751 | By accepting the event (i.e., by calling QEvent::accept()), the item will | - |
6752 | accept drop events, in addition to receiving drag move and drag | - |
6753 | leave. Otherwise, the event will be ignored and propagate to the item | - |
6754 | beneath. If the event is accepted, the item will receive a drag move event | - |
6755 | before control goes back to the event loop. | - |
6756 | | - |
6757 | A common implementation of dragEnterEvent accepts or ignores \a event | - |
6758 | depending on the associated mime data in \a event. Example: | - |
6759 | | - |
6760 | \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 14 | - |
6761 | | - |
6762 | Items do not receive drag and drop events by default; to enable this | - |
6763 | feature, call \c setAcceptDrops(true). | - |
6764 | | - |
6765 | The default implementation does nothing. | - |
6766 | | - |
6767 | \sa dropEvent(), dragMoveEvent(), dragLeaveEvent() | - |
6768 | */ | - |
6769 | void QGraphicsItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event) | - |
6770 | { | - |
6771 | Q_D(QGraphicsItem); never executed (the execution status of this line is deduced): QGraphicsItemPrivate * const d = d_func(); | - |
6772 | // binary compatibility workaround between 4.4 and 4.5 | - |
6773 | if (d->isProxyWidget()) never evaluated: d->isProxyWidget() | 0 |
6774 | static_cast<QGraphicsProxyWidget*>(this)->dragEnterEvent(event); never executed: static_cast<QGraphicsProxyWidget*>(this)->dragEnterEvent(event); | 0 |
6775 | } | 0 |
6776 | | - |
6777 | /*! | - |
6778 | This event handler, for event \a event, can be reimplemented to receive | - |
6779 | drag leave events for this item. Drag leave events are generated as the | - |
6780 | cursor leaves the item's area. Most often you will not need to reimplement | - |
6781 | this function, but it can be useful for resetting state in your item | - |
6782 | (e.g., highlighting). | - |
6783 | | - |
6784 | Calling QEvent::ignore() or QEvent::accept() on \a event has no effect. | - |
6785 | | - |
6786 | Items do not receive drag and drop events by default; to enable this | - |
6787 | feature, call \c setAcceptDrops(true). | - |
6788 | | - |
6789 | The default implementation does nothing. | - |
6790 | | - |
6791 | \sa dragEnterEvent(), dropEvent(), dragMoveEvent() | - |
6792 | */ | - |
6793 | void QGraphicsItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) | - |
6794 | { | - |
6795 | Q_D(QGraphicsItem); never executed (the execution status of this line is deduced): QGraphicsItemPrivate * const d = d_func(); | - |
6796 | // binary compatibility workaround between 4.4 and 4.5 | - |
6797 | if (d->isProxyWidget()) never evaluated: d->isProxyWidget() | 0 |
6798 | static_cast<QGraphicsProxyWidget*>(this)->dragLeaveEvent(event); never executed: static_cast<QGraphicsProxyWidget*>(this)->dragLeaveEvent(event); | 0 |
6799 | } | 0 |
6800 | | - |
6801 | /*! | - |
6802 | This event handler, for event \a event, can be reimplemented to receive | - |
6803 | drag move events for this item. Drag move events are generated as the | - |
6804 | cursor moves around inside the item's area. Most often you will not need | - |
6805 | to reimplement this function; it is used to indicate that only parts of | - |
6806 | the item can accept drops. | - |
6807 | | - |
6808 | Calling QEvent::ignore() or QEvent::accept() on \a event toggles whether | - |
6809 | or not the item will accept drops at the position from the event. By | - |
6810 | default, \a event is accepted, indicating that the item allows drops at | - |
6811 | the specified position. | - |
6812 | | - |
6813 | Items do not receive drag and drop events by default; to enable this | - |
6814 | feature, call \c setAcceptDrops(true). | - |
6815 | | - |
6816 | The default implementation does nothing. | - |
6817 | | - |
6818 | \sa dropEvent(), dragEnterEvent(), dragLeaveEvent() | - |
6819 | */ | - |
6820 | void QGraphicsItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event) | - |
6821 | { | - |
6822 | Q_D(QGraphicsItem); never executed (the execution status of this line is deduced): QGraphicsItemPrivate * const d = d_func(); | - |
6823 | // binary compatibility workaround between 4.4 and 4.5 | - |
6824 | if (d->isProxyWidget()) never evaluated: d->isProxyWidget() | 0 |
6825 | static_cast<QGraphicsProxyWidget*>(this)->dragMoveEvent(event); never executed: static_cast<QGraphicsProxyWidget*>(this)->dragMoveEvent(event); | 0 |
6826 | } | 0 |
6827 | | - |
6828 | /*! | - |
6829 | This event handler, for event \a event, can be reimplemented to receive | - |
6830 | drop events for this item. Items can only receive drop events if the last | - |
6831 | drag move event was accepted. | - |
6832 | | - |
6833 | Calling QEvent::ignore() or QEvent::accept() on \a event has no effect. | - |
6834 | | - |
6835 | Items do not receive drag and drop events by default; to enable this | - |
6836 | feature, call \c setAcceptDrops(true). | - |
6837 | | - |
6838 | The default implementation does nothing. | - |
6839 | | - |
6840 | \sa dragEnterEvent(), dragMoveEvent(), dragLeaveEvent() | - |
6841 | */ | - |
6842 | void QGraphicsItem::dropEvent(QGraphicsSceneDragDropEvent *event) | - |
6843 | { | - |
6844 | Q_D(QGraphicsItem); never executed (the execution status of this line is deduced): QGraphicsItemPrivate * const d = d_func(); | - |
6845 | // binary compatibility workaround between 4.4 and 4.5 | - |
6846 | if (d->isProxyWidget()) never evaluated: d->isProxyWidget() | 0 |
6847 | static_cast<QGraphicsProxyWidget*>(this)->dropEvent(event); never executed: static_cast<QGraphicsProxyWidget*>(this)->dropEvent(event); | 0 |
6848 | } | 0 |
6849 | | - |
6850 | /*! | - |
6851 | This event handler, for event \a event, can be reimplemented to receive | - |
6852 | focus in events for this item. The default implementation calls | - |
6853 | ensureVisible(). | - |
6854 | | - |
6855 | \sa focusOutEvent(), sceneEvent(), setFocus() | - |
6856 | */ | - |
6857 | void QGraphicsItem::focusInEvent(QFocusEvent *event) | - |
6858 | { | - |
6859 | Q_UNUSED(event); never executed (the execution status of this line is deduced): (void)event;; | - |
6860 | update(); never executed (the execution status of this line is deduced): update(); | - |
6861 | } | 0 |
6862 | | - |
6863 | /*! | - |
6864 | This event handler, for event \a event, can be reimplemented to receive | - |
6865 | focus out events for this item. The default implementation does nothing. | - |
6866 | | - |
6867 | \sa focusInEvent(), sceneEvent(), setFocus() | - |
6868 | */ | - |
6869 | void QGraphicsItem::focusOutEvent(QFocusEvent *event) | - |
6870 | { | - |
6871 | Q_UNUSED(event); never executed (the execution status of this line is deduced): (void)event;; | - |
6872 | update(); never executed (the execution status of this line is deduced): update(); | - |
6873 | } | 0 |
6874 | | - |
6875 | /*! | - |
6876 | This event handler, for event \a event, can be reimplemented to receive | - |
6877 | hover enter events for this item. The default implementation calls | - |
6878 | update(); otherwise it does nothing. | - |
6879 | | - |
6880 | Calling QEvent::ignore() or QEvent::accept() on \a event has no effect. | - |
6881 | | - |
6882 | \sa hoverMoveEvent(), hoverLeaveEvent(), sceneEvent(), setAcceptHoverEvents() | - |
6883 | */ | - |
6884 | void QGraphicsItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) | - |
6885 | { | - |
6886 | Q_UNUSED(event); never executed (the execution status of this line is deduced): (void)event;; | - |
6887 | update(); never executed (the execution status of this line is deduced): update(); | - |
6888 | } | 0 |
6889 | | - |
6890 | /*! | - |
6891 | This event handler, for event \a event, can be reimplemented to receive | - |
6892 | hover move events for this item. The default implementation does nothing. | - |
6893 | | - |
6894 | Calling QEvent::ignore() or QEvent::accept() on \a event has no effect. | - |
6895 | | - |
6896 | \sa hoverEnterEvent(), hoverLeaveEvent(), sceneEvent(), setAcceptHoverEvents() | - |
6897 | */ | - |
6898 | void QGraphicsItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) | - |
6899 | { | - |
6900 | Q_UNUSED(event); never executed (the execution status of this line is deduced): (void)event;; | - |
6901 | } | 0 |
6902 | | - |
6903 | /*! | - |
6904 | This event handler, for event \a event, can be reimplemented to receive | - |
6905 | hover leave events for this item. The default implementation calls | - |
6906 | update(); otherwise it does nothing. | - |
6907 | | - |
6908 | Calling QEvent::ignore() or QEvent::accept() on \a event has no effect. | - |
6909 | | - |
6910 | \sa hoverEnterEvent(), hoverMoveEvent(), sceneEvent(), setAcceptHoverEvents() | - |
6911 | */ | - |
6912 | void QGraphicsItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) | - |
6913 | { | - |
6914 | Q_UNUSED(event); never executed (the execution status of this line is deduced): (void)event;; | - |
6915 | update(); never executed (the execution status of this line is deduced): update(); | - |
6916 | } | 0 |
6917 | | - |
6918 | /*! | - |
6919 | This event handler, for event \a event, can be reimplemented to | - |
6920 | receive key press events for this item. The default implementation | - |
6921 | ignores the event. If you reimplement this handler, the event will by | - |
6922 | default be accepted. | - |
6923 | | - |
6924 | Note that key events are only received for items that set the | - |
6925 | ItemIsFocusable flag, and that have keyboard input focus. | - |
6926 | | - |
6927 | \sa keyReleaseEvent(), setFocus(), QGraphicsScene::setFocusItem(), | - |
6928 | sceneEvent() | - |
6929 | */ | - |
6930 | void QGraphicsItem::keyPressEvent(QKeyEvent *event) | - |
6931 | { | - |
6932 | event->ignore(); never executed (the execution status of this line is deduced): event->ignore(); | - |
6933 | } | 0 |
6934 | | - |
6935 | /*! | - |
6936 | This event handler, for event \a event, can be reimplemented to receive | - |
6937 | key release events for this item. The default implementation | - |
6938 | ignores the event. If you reimplement this handler, the event will by | - |
6939 | default be accepted. | - |
6940 | | - |
6941 | Note that key events are only received for items that set the | - |
6942 | ItemIsFocusable flag, and that have keyboard input focus. | - |
6943 | | - |
6944 | \sa keyPressEvent(), setFocus(), QGraphicsScene::setFocusItem(), | - |
6945 | sceneEvent() | - |
6946 | */ | - |
6947 | void QGraphicsItem::keyReleaseEvent(QKeyEvent *event) | - |
6948 | { | - |
6949 | event->ignore(); never executed (the execution status of this line is deduced): event->ignore(); | - |
6950 | } | 0 |
6951 | | - |
6952 | /*! | - |
6953 | This event handler, for event \a event, can be reimplemented to | - |
6954 | receive mouse press events for this item. Mouse press events are | - |
6955 | only delivered to items that accept the mouse button that is | - |
6956 | pressed. By default, an item accepts all mouse buttons, but you | - |
6957 | can change this by calling setAcceptedMouseButtons(). | - |
6958 | | - |
6959 | The mouse press event decides which item should become the mouse | - |
6960 | grabber (see QGraphicsScene::mouseGrabberItem()). If you do not | - |
6961 | reimplement this function, the press event will propagate to any | - |
6962 | topmost item beneath this item, and no other mouse events will be | - |
6963 | delivered to this item. | - |
6964 | | - |
6965 | If you do reimplement this function, \a event will by default be | - |
6966 | accepted (see QEvent::accept()), and this item is then the mouse | - |
6967 | grabber. This allows the item to receive future move, release and | - |
6968 | doubleclick events. If you call QEvent::ignore() on \a event, this | - |
6969 | item will lose the mouse grab, and \a event will propagate to any | - |
6970 | topmost item beneath. No further mouse events will be delivered to | - |
6971 | this item unless a new mouse press event is received. | - |
6972 | | - |
6973 | The default implementation handles basic item interaction, such as | - |
6974 | selection and moving. If you want to keep the base implementation | - |
6975 | when reimplementing this function, call | - |
6976 | QGraphicsItem::mousePressEvent() in your reimplementation. | - |
6977 | | - |
6978 | The event is \l{QEvent::ignore()}d for items that are neither | - |
6979 | \l{QGraphicsItem::ItemIsMovable}{movable} nor | - |
6980 | \l{QGraphicsItem::ItemIsSelectable}{selectable}. | - |
6981 | | - |
6982 | \sa mouseMoveEvent(), mouseReleaseEvent(), | - |
6983 | mouseDoubleClickEvent(), sceneEvent() | - |
6984 | */ | - |
6985 | void QGraphicsItem::mousePressEvent(QGraphicsSceneMouseEvent *event) | - |
6986 | { | - |
6987 | if (event->button() == Qt::LeftButton && (flags() & ItemIsSelectable)) { never evaluated: event->button() == Qt::LeftButton never evaluated: (flags() & ItemIsSelectable) | 0 |
6988 | bool multiSelect = (event->modifiers() & Qt::ControlModifier) != 0; never executed (the execution status of this line is deduced): bool multiSelect = (event->modifiers() & Qt::ControlModifier) != 0; | - |
6989 | if (!multiSelect) { never evaluated: !multiSelect | 0 |
6990 | if (!d_ptr->selected) { never evaluated: !d_ptr->selected | 0 |
6991 | if (QGraphicsScene *scene = d_ptr->scene) { never evaluated: QGraphicsScene *scene = d_ptr->scene | 0 |
6992 | ++scene->d_func()->selectionChanging; never executed (the execution status of this line is deduced): ++scene->d_func()->selectionChanging; | - |
6993 | scene->clearSelection(); never executed (the execution status of this line is deduced): scene->clearSelection(); | - |
6994 | --scene->d_func()->selectionChanging; never executed (the execution status of this line is deduced): --scene->d_func()->selectionChanging; | - |
6995 | } | 0 |
6996 | setSelected(true); never executed (the execution status of this line is deduced): setSelected(true); | - |
6997 | } | 0 |
6998 | } | 0 |
6999 | } else if (!(flags() & ItemIsMovable)) { never executed: } never evaluated: !(flags() & ItemIsMovable) | 0 |
7000 | event->ignore(); never executed (the execution status of this line is deduced): event->ignore(); | - |
7001 | } | 0 |
7002 | if (d_ptr->isWidget) { never evaluated: d_ptr->isWidget | 0 |
7003 | // Qt::Popup closes when you click outside. | - |
7004 | QGraphicsWidget *w = static_cast<QGraphicsWidget *>(this); never executed (the execution status of this line is deduced): QGraphicsWidget *w = static_cast<QGraphicsWidget *>(this); | - |
7005 | if ((w->windowFlags() & Qt::Popup) == Qt::Popup) { never evaluated: (w->windowFlags() & Qt::Popup) == Qt::Popup | 0 |
7006 | event->accept(); never executed (the execution status of this line is deduced): event->accept(); | - |
7007 | if (!w->rect().contains(event->pos())) never evaluated: !w->rect().contains(event->pos()) | 0 |
7008 | w->close(); never executed: w->close(); | 0 |
7009 | } | 0 |
7010 | } | 0 |
7011 | } | 0 |
7012 | | - |
7013 | /*! | - |
7014 | obsolete | - |
7015 | */ | - |
7016 | bool _qt_movableAncestorIsSelected(const QGraphicsItem *item) | - |
7017 | { | - |
7018 | const QGraphicsItem *parent = item->parentItem(); never executed (the execution status of this line is deduced): const QGraphicsItem *parent = item->parentItem(); | - |
7019 | return parent && (((parent->flags() & QGraphicsItem::ItemIsMovable) && parent->isSelected()) || _qt_movableAncestorIsSelected(parent)); never executed: return parent && (((parent->flags() & QGraphicsItem::ItemIsMovable) && parent->isSelected()) || _qt_movableAncestorIsSelected(parent)); | 0 |
7020 | } | - |
7021 | | - |
7022 | bool QGraphicsItemPrivate::movableAncestorIsSelected(const QGraphicsItem *item) | - |
7023 | { | - |
7024 | const QGraphicsItem *parent = item->d_ptr->parent; never executed (the execution status of this line is deduced): const QGraphicsItem *parent = item->d_ptr->parent; | - |
7025 | return parent && (((parent->flags() & QGraphicsItem::ItemIsMovable) && parent->isSelected()) || _qt_movableAncestorIsSelected(parent)); never executed: return parent && (((parent->flags() & QGraphicsItem::ItemIsMovable) && parent->isSelected()) || _qt_movableAncestorIsSelected(parent)); | 0 |
7026 | } | - |
7027 | | - |
7028 | /*! | - |
7029 | This event handler, for event \a event, can be reimplemented to | - |
7030 | receive mouse move events for this item. If you do receive this | - |
7031 | event, you can be certain that this item also received a mouse | - |
7032 | press event, and that this item is the current mouse grabber. | - |
7033 | | - |
7034 | Calling QEvent::ignore() or QEvent::accept() on \a event has no | - |
7035 | effect. | - |
7036 | | - |
7037 | The default implementation handles basic item interaction, such as | - |
7038 | selection and moving. If you want to keep the base implementation | - |
7039 | when reimplementing this function, call | - |
7040 | QGraphicsItem::mouseMoveEvent() in your reimplementation. | - |
7041 | | - |
7042 | Please note that mousePressEvent() decides which graphics item it | - |
7043 | is that receives mouse events. See the mousePressEvent() | - |
7044 | description for details. | - |
7045 | | - |
7046 | \sa mousePressEvent(), mouseReleaseEvent(), | - |
7047 | mouseDoubleClickEvent(), sceneEvent() | - |
7048 | */ | - |
7049 | void QGraphicsItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) | - |
7050 | { | - |
7051 | if ((event->buttons() & Qt::LeftButton) && (flags() & ItemIsMovable)) { never evaluated: (event->buttons() & Qt::LeftButton) never evaluated: (flags() & ItemIsMovable) | 0 |
7052 | // Determine the list of items that need to be moved. | - |
7053 | QList<QGraphicsItem *> selectedItems; never executed (the execution status of this line is deduced): QList<QGraphicsItem *> selectedItems; | - |
7054 | QHash<QGraphicsItem *, QPointF> initialPositions; never executed (the execution status of this line is deduced): QHash<QGraphicsItem *, QPointF> initialPositions; | - |
7055 | if (d_ptr->scene) { never evaluated: d_ptr->scene | 0 |
7056 | selectedItems = d_ptr->scene->selectedItems(); never executed (the execution status of this line is deduced): selectedItems = d_ptr->scene->selectedItems(); | - |
7057 | initialPositions = d_ptr->scene->d_func()->movingItemsInitialPositions; never executed (the execution status of this line is deduced): initialPositions = d_ptr->scene->d_func()->movingItemsInitialPositions; | - |
7058 | if (initialPositions.isEmpty()) { never evaluated: initialPositions.isEmpty() | 0 |
7059 | foreach (QGraphicsItem *item, selectedItems) never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(selectedItems)> _container_(selectedItems); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) | - |
7060 | initialPositions[item] = item->pos(); never executed: initialPositions[item] = item->pos(); | 0 |
7061 | initialPositions[this] = pos(); never executed (the execution status of this line is deduced): initialPositions[this] = pos(); | - |
7062 | } | 0 |
7063 | d_ptr->scene->d_func()->movingItemsInitialPositions = initialPositions; never executed (the execution status of this line is deduced): d_ptr->scene->d_func()->movingItemsInitialPositions = initialPositions; | - |
7064 | } | 0 |
7065 | | - |
7066 | // Find the active view. | - |
7067 | QGraphicsView *view = 0; never executed (the execution status of this line is deduced): QGraphicsView *view = 0; | - |
7068 | if (event->widget()) never evaluated: event->widget() | 0 |
7069 | view = qobject_cast<QGraphicsView *>(event->widget()->parentWidget()); never executed: view = qobject_cast<QGraphicsView *>(event->widget()->parentWidget()); | 0 |
7070 | | - |
7071 | // Move all selected items | - |
7072 | int i = 0; never executed (the execution status of this line is deduced): int i = 0; | - |
7073 | bool movedMe = false; never executed (the execution status of this line is deduced): bool movedMe = false; | - |
7074 | while (i <= selectedItems.size()) { never evaluated: i <= selectedItems.size() | 0 |
7075 | QGraphicsItem *item = 0; never executed (the execution status of this line is deduced): QGraphicsItem *item = 0; | - |
7076 | if (i < selectedItems.size()) never evaluated: i < selectedItems.size() | 0 |
7077 | item = selectedItems.at(i); never executed: item = selectedItems.at(i); | 0 |
7078 | else | - |
7079 | item = this; never executed: item = this; | 0 |
7080 | if (item == this) { never evaluated: item == this | 0 |
7081 | // Slightly clumsy-looking way to ensure that "this" is part | - |
7082 | // of the list of items to move, this is to avoid allocations | - |
7083 | // (appending this item to the list of selected items causes a | - |
7084 | // detach). | - |
7085 | if (movedMe) | 0 |
7086 | break; | 0 |
7087 | movedMe = true; never executed (the execution status of this line is deduced): movedMe = true; | - |
7088 | } | 0 |
7089 | | - |
7090 | if ((item->flags() & ItemIsMovable) && !QGraphicsItemPrivate::movableAncestorIsSelected(item)) { never evaluated: (item->flags() & ItemIsMovable) never evaluated: !QGraphicsItemPrivate::movableAncestorIsSelected(item) | 0 |
7091 | QPointF currentParentPos; never executed (the execution status of this line is deduced): QPointF currentParentPos; | - |
7092 | QPointF buttonDownParentPos; never executed (the execution status of this line is deduced): QPointF buttonDownParentPos; | - |
7093 | if (item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorIgnoresTransformations) { never evaluated: item->d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorIgnoresTransformations | 0 |
7094 | // Items whose ancestors ignore transformations need to | - |
7095 | // map screen coordinates to local coordinates, then map | - |
7096 | // those to the parent. | - |
7097 | QTransform viewToItemTransform = (item->deviceTransform(view->viewportTransform())).inverted(); never executed (the execution status of this line is deduced): QTransform viewToItemTransform = (item->deviceTransform(view->viewportTransform())).inverted(); | - |
7098 | currentParentPos = mapToParent(viewToItemTransform.map(QPointF(view->mapFromGlobal(event->screenPos())))); never executed (the execution status of this line is deduced): currentParentPos = mapToParent(viewToItemTransform.map(QPointF(view->mapFromGlobal(event->screenPos())))); | - |
7099 | buttonDownParentPos = mapToParent(viewToItemTransform.map(QPointF(view->mapFromGlobal(event->buttonDownScreenPos(Qt::LeftButton))))); never executed (the execution status of this line is deduced): buttonDownParentPos = mapToParent(viewToItemTransform.map(QPointF(view->mapFromGlobal(event->buttonDownScreenPos(Qt::LeftButton))))); | - |
7100 | } else if (item->flags() & ItemIgnoresTransformations) { never executed: } never evaluated: item->flags() & ItemIgnoresTransformations | 0 |
7101 | // Root items that ignore transformations need to | - |
7102 | // calculate their diff by mapping viewport coordinates | - |
7103 | // directly to parent coordinates. | - |
7104 | // COMBINE | - |
7105 | QTransform itemTransform; never executed (the execution status of this line is deduced): QTransform itemTransform; | - |
7106 | if (item->d_ptr->transformData) never evaluated: item->d_ptr->transformData | 0 |
7107 | itemTransform = item->d_ptr->transformData->computedFullTransform(); never executed: itemTransform = item->d_ptr->transformData->computedFullTransform(); | 0 |
7108 | itemTransform.translate(item->d_ptr->pos.x(), item->d_ptr->pos.y()); never executed (the execution status of this line is deduced): itemTransform.translate(item->d_ptr->pos.x(), item->d_ptr->pos.y()); | - |
7109 | QTransform viewToParentTransform = itemTransform never executed (the execution status of this line is deduced): QTransform viewToParentTransform = itemTransform | - |
7110 | * (item->sceneTransform() * view->viewportTransform()).inverted(); never executed (the execution status of this line is deduced): * (item->sceneTransform() * view->viewportTransform()).inverted(); | - |
7111 | currentParentPos = viewToParentTransform.map(QPointF(view->mapFromGlobal(event->screenPos()))); never executed (the execution status of this line is deduced): currentParentPos = viewToParentTransform.map(QPointF(view->mapFromGlobal(event->screenPos()))); | - |
7112 | buttonDownParentPos = viewToParentTransform.map(QPointF(view->mapFromGlobal(event->buttonDownScreenPos(Qt::LeftButton)))); never executed (the execution status of this line is deduced): buttonDownParentPos = viewToParentTransform.map(QPointF(view->mapFromGlobal(event->buttonDownScreenPos(Qt::LeftButton)))); | - |
7113 | } else { | 0 |
7114 | // All other items simply map from the scene. | - |
7115 | currentParentPos = item->mapToParent(item->mapFromScene(event->scenePos())); never executed (the execution status of this line is deduced): currentParentPos = item->mapToParent(item->mapFromScene(event->scenePos())); | - |
7116 | buttonDownParentPos = item->mapToParent(item->mapFromScene(event->buttonDownScenePos(Qt::LeftButton))); never executed (the execution status of this line is deduced): buttonDownParentPos = item->mapToParent(item->mapFromScene(event->buttonDownScenePos(Qt::LeftButton))); | - |
7117 | } | 0 |
7118 | | - |
7119 | item->setPos(initialPositions.value(item) + currentParentPos - buttonDownParentPos); never executed (the execution status of this line is deduced): item->setPos(initialPositions.value(item) + currentParentPos - buttonDownParentPos); | - |
7120 | | - |
7121 | if (item->flags() & ItemIsSelectable) never evaluated: item->flags() & ItemIsSelectable | 0 |
7122 | item->setSelected(true); never executed: item->setSelected(true); | 0 |
7123 | } | 0 |
7124 | ++i; never executed (the execution status of this line is deduced): ++i; | - |
7125 | } | 0 |
7126 | | - |
7127 | } else { | 0 |
7128 | event->ignore(); never executed (the execution status of this line is deduced): event->ignore(); | - |
7129 | } | 0 |
7130 | } | - |
7131 | | - |
7132 | /*! | - |
7133 | This event handler, for event \a event, can be reimplemented to | - |
7134 | receive mouse release events for this item. | - |
7135 | | - |
7136 | Calling QEvent::ignore() or QEvent::accept() on \a event has no | - |
7137 | effect. | - |
7138 | | - |
7139 | The default implementation handles basic item interaction, such as | - |
7140 | selection and moving. If you want to keep the base implementation | - |
7141 | when reimplementing this function, call | - |
7142 | QGraphicsItem::mouseReleaseEvent() in your reimplementation. | - |
7143 | | - |
7144 | Please note that mousePressEvent() decides which graphics item it | - |
7145 | is that receives mouse events. See the mousePressEvent() | - |
7146 | description for details. | - |
7147 | | - |
7148 | \sa mousePressEvent(), mouseMoveEvent(), mouseDoubleClickEvent(), | - |
7149 | sceneEvent() | - |
7150 | */ | - |
7151 | void QGraphicsItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) | - |
7152 | { | - |
7153 | if (flags() & ItemIsSelectable) { partially evaluated: flags() & ItemIsSelectable no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
7154 | bool multiSelect = (event->modifiers() & Qt::ControlModifier) != 0; never executed (the execution status of this line is deduced): bool multiSelect = (event->modifiers() & Qt::ControlModifier) != 0; | - |
7155 | if (event->scenePos() == event->buttonDownScenePos(Qt::LeftButton)) { never evaluated: event->scenePos() == event->buttonDownScenePos(Qt::LeftButton) | 0 |
7156 | // The item didn't move | - |
7157 | if (multiSelect) { never evaluated: multiSelect | 0 |
7158 | setSelected(!isSelected()); never executed (the execution status of this line is deduced): setSelected(!isSelected()); | - |
7159 | } else { | 0 |
7160 | bool selectionChanged = false; never executed (the execution status of this line is deduced): bool selectionChanged = false; | - |
7161 | if (QGraphicsScene *scene = d_ptr->scene) { never evaluated: QGraphicsScene *scene = d_ptr->scene | 0 |
7162 | ++scene->d_func()->selectionChanging; never executed (the execution status of this line is deduced): ++scene->d_func()->selectionChanging; | - |
7163 | // Clear everything but this item. Bypass | - |
7164 | // QGraphicsScene::clearSelection()'s default behavior by | - |
7165 | // temporarily removing this item from the selection list. | - |
7166 | if (d_ptr->selected) { never evaluated: d_ptr->selected | 0 |
7167 | scene->d_func()->selectedItems.remove(this); never executed (the execution status of this line is deduced): scene->d_func()->selectedItems.remove(this); | - |
7168 | foreach (QGraphicsItem *item, scene->d_func()->selectedItems) { never executed (the execution status of this line is deduced): for (QForeachContainer<__typeof__(scene->d_func()->selectedItems)> _container_(scene->d_func()->selectedItems); !_container_.brk && _container_.i != _container_.e; __extension__ ({ ++_container_.brk; ++_container_.i; })) for (QGraphicsItem *item = *_container_.i;; __extension__ ({--_container_.brk; break;})) { | - |
7169 | if (item->isSelected()) { never evaluated: item->isSelected() | 0 |
7170 | selectionChanged = true; never executed (the execution status of this line is deduced): selectionChanged = true; | - |
7171 | break; | 0 |
7172 | } | - |
7173 | } | 0 |
7174 | } | 0 |
7175 | scene->clearSelection(); never executed (the execution status of this line is deduced): scene->clearSelection(); | - |
7176 | if (d_ptr->selected) never evaluated: d_ptr->selected | 0 |
7177 | scene->d_func()->selectedItems.insert(this); never executed: scene->d_func()->selectedItems.insert(this); | 0 |
7178 | --scene->d_func()->selectionChanging; never executed (the execution status of this line is deduced): --scene->d_func()->selectionChanging; | - |
7179 | if (selectionChanged) never evaluated: selectionChanged | 0 |
7180 | emit d_ptr->scene->selectionChanged(); never executed: d_ptr->scene->selectionChanged(); | 0 |
7181 | } | 0 |
7182 | setSelected(true); never executed (the execution status of this line is deduced): setSelected(true); | - |
7183 | } | 0 |
7184 | } | - |
7185 | } | 0 |
7186 | if (d_ptr->scene && !event->buttons()) partially evaluated: d_ptr->scene yes Evaluation Count:2 | no Evaluation Count:0 |
partially evaluated: !event->buttons() yes Evaluation Count:2 | no Evaluation Count:0 |
| 0-2 |
7187 | d_ptr->scene->d_func()->movingItemsInitialPositions.clear(); executed: d_ptr->scene->d_func()->movingItemsInitialPositions.clear(); Execution Count:2 | 2 |
7188 | } executed: } Execution Count:2 | 2 |
7189 | | - |
7190 | /*! | - |
7191 | This event handler, for event \a event, can be reimplemented to | - |
7192 | receive mouse doubleclick events for this item. | - |
7193 | | - |
7194 | When doubleclicking an item, the item will first receive a mouse | - |
7195 | press event, followed by a release event (i.e., a click), then a | - |
7196 | doubleclick event, and finally a release event. | - |
7197 | | - |
7198 | Calling QEvent::ignore() or QEvent::accept() on \a event has no | - |
7199 | effect. | - |
7200 | | - |
7201 | The default implementation calls mousePressEvent(). If you want to | - |
7202 | keep the base implementation when reimplementing this function, | - |
7203 | call QGraphicsItem::mouseDoubleClickEvent() in your | - |
7204 | reimplementation. | - |
7205 | | - |
7206 | Note that an item will not receive double click events if it is | - |
7207 | neither \l {QGraphicsItem::ItemIsSelectable}{selectable} nor | - |
7208 | \l{QGraphicsItem::ItemIsMovable}{movable} (single mouse clicks are | - |
7209 | ignored in this case, and that stops the generation of double | - |
7210 | clicks). | - |
7211 | | - |
7212 | \sa mousePressEvent(), mouseMoveEvent(), mouseReleaseEvent(), sceneEvent() | - |
7213 | */ | - |
7214 | void QGraphicsItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) | - |
7215 | { | - |
7216 | mousePressEvent(event); never executed (the execution status of this line is deduced): mousePressEvent(event); | - |
7217 | } | 0 |
7218 | | - |
7219 | /*! | - |
7220 | This event handler, for event \a event, can be reimplemented to receive | - |
7221 | wheel events for this item. If you reimplement this function, \a event | - |
7222 | will be accepted by default. | - |
7223 | | - |
7224 | If you ignore the event, (i.e., by calling QEvent::ignore(),) it will | - |
7225 | propagate to any item beneath this item. If no items accept the event, it | - |
7226 | will be ignored by the scene, and propagate to the view (e.g., the view's | - |
7227 | vertical scroll bar). | - |
7228 | | - |
7229 | The default implementation ignores the event. | - |
7230 | | - |
7231 | \sa sceneEvent() | - |
7232 | */ | - |
7233 | void QGraphicsItem::wheelEvent(QGraphicsSceneWheelEvent *event) | - |
7234 | { | - |
7235 | event->ignore(); never executed (the execution status of this line is deduced): event->ignore(); | - |
7236 | } | 0 |
7237 | | - |
7238 | /*! | - |
7239 | This event handler, for event \a event, can be reimplemented to receive | - |
7240 | input method events for this item. The default implementation ignores the | - |
7241 | event. | - |
7242 | | - |
7243 | \sa inputMethodQuery(), sceneEvent() | - |
7244 | */ | - |
7245 | void QGraphicsItem::inputMethodEvent(QInputMethodEvent *event) | - |
7246 | { | - |
7247 | event->ignore(); never executed (the execution status of this line is deduced): event->ignore(); | - |
7248 | } | 0 |
7249 | | - |
7250 | /*! | - |
7251 | This method is only relevant for input items. It is used by the | - |
7252 | input method to query a set of properties of the item to be able | - |
7253 | to support complex input method operations, such as support for | - |
7254 | surrounding text and reconversions. \a query specifies which | - |
7255 | property is queried. | - |
7256 | | - |
7257 | \sa inputMethodEvent(), QInputMethodEvent | - |
7258 | */ | - |
7259 | QVariant QGraphicsItem::inputMethodQuery(Qt::InputMethodQuery query) const | - |
7260 | { | - |
7261 | Q_UNUSED(query); never executed (the execution status of this line is deduced): (void)query;; | - |
7262 | return QVariant(); never executed: return QVariant(); | 0 |
7263 | } | - |
7264 | | - |
7265 | /*! | - |
7266 | Returns the current input method hints of this item. | - |
7267 | | - |
7268 | Input method hints are only relevant for input items. | - |
7269 | The hints are used by the input method to indicate how it should operate. | - |
7270 | For example, if the Qt::ImhNumbersOnly flag is set, the input method may change | - |
7271 | its visual components to reflect that only numbers can be entered. | - |
7272 | | - |
7273 | The effect may vary between input method implementations. | - |
7274 | | - |
7275 | \since 4.6 | - |
7276 | | - |
7277 | \sa setInputMethodHints(), inputMethodQuery() | - |
7278 | */ | - |
7279 | Qt::InputMethodHints QGraphicsItem::inputMethodHints() const | - |
7280 | { | - |
7281 | Q_D(const QGraphicsItem); never executed (the execution status of this line is deduced): const QGraphicsItemPrivate * const d = d_func(); | - |
7282 | return d->imHints; never executed: return d->imHints; | 0 |
7283 | } | - |
7284 | | - |
7285 | /*! | - |
7286 | Sets the current input method hints of this item to \a hints. | - |
7287 | | - |
7288 | \since 4.6 | - |
7289 | | - |
7290 | \sa inputMethodHints(), inputMethodQuery() | - |
7291 | */ | - |
7292 | void QGraphicsItem::setInputMethodHints(Qt::InputMethodHints hints) | - |
7293 | { | - |
7294 | Q_D(QGraphicsItem); never executed (the execution status of this line is deduced): QGraphicsItemPrivate * const d = d_func(); | - |
7295 | d->imHints = hints; never executed (the execution status of this line is deduced): d->imHints = hints; | - |
7296 | if (!hasFocus()) never evaluated: !hasFocus() | 0 |
7297 | return; | 0 |
7298 | d->scene->d_func()->updateInputMethodSensitivityInViews(); never executed (the execution status of this line is deduced): d->scene->d_func()->updateInputMethodSensitivityInViews(); | - |
7299 | QWidget *fw = QApplication::focusWidget(); never executed (the execution status of this line is deduced): QWidget *fw = QApplication::focusWidget(); | - |
7300 | if (!fw) | 0 |
7301 | return; | 0 |
7302 | qApp->inputMethod()->update(Qt::ImHints); never executed (the execution status of this line is deduced): (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->update(Qt::ImHints); | - |
7303 | } | 0 |
7304 | | - |
7305 | /*! | - |
7306 | Updates the item's micro focus. | - |
7307 | | - |
7308 | \since 4.7 | - |
7309 | | - |
7310 | \sa QInputMethod | - |
7311 | */ | - |
7312 | void QGraphicsItem::updateMicroFocus() | - |
7313 | { | - |
7314 | #if !defined(QT_NO_IM) && defined(Q_WS_X11) | - |
7315 | if (QWidget *fw = QApplication::focusWidget()) { | - |
7316 | if (scene()) { | - |
7317 | for (int i = 0 ; i < scene()->views().count() ; ++i) { | - |
7318 | if (scene()->views().at(i) == fw) { | - |
7319 | if (qApp) | - |
7320 | qApp->inputMethod()->update(Qt::ImQueryAll); | - |
7321 | | - |
7322 | #ifndef QT_NO_ACCESSIBILITY | - |
7323 | // ##### is this correct | - |
7324 | if (toGraphicsObject()) | - |
7325 | QAccessible::updateAccessibility(toGraphicsObject(), 0, QAccessible::StateChanged); | - |
7326 | #endif | - |
7327 | break; | - |
7328 | } | - |
7329 | } | - |
7330 | } | - |
7331 | } | - |
7332 | } | - |
7333 | #endif | - |
7334 | } | - |
7335 | | - |
7336 | /*! | - |
7337 | This virtual function is called by QGraphicsItem to notify custom items | - |
7338 | that some part of the item's state changes. By reimplementing this | - |
7339 | function, your can react to a change, and in some cases, (depending on \a | - |
7340 | change,) adjustments can be made. | - |
7341 | | - |
7342 | \a change is the parameter of the item that is changing. \a value is the | - |
7343 | new value; the type of the value depends on \a change. | - |
7344 | | - |
7345 | Example: | - |
7346 | | - |
7347 | \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 15 | - |
7348 | | - |
7349 | The default implementation does nothing, and returns \a value. | - |
7350 | | - |
7351 | Note: Certain QGraphicsItem functions cannot be called in a | - |
7352 | reimplementation of this function; see the GraphicsItemChange | - |
7353 | documentation for details. | - |
7354 | | - |
7355 | \sa GraphicsItemChange | - |
7356 | */ | - |
7357 | QVariant QGraphicsItem::itemChange(GraphicsItemChange change, const QVariant &value) | - |
7358 | { | - |
7359 | Q_UNUSED(change); executed (the execution status of this line is deduced): (void)change;; | - |
7360 | return value; executed: return value; Execution Count:9135 | 9135 |
7361 | } | - |
7362 | | - |
7363 | /*! | - |
7364 | \internal | - |
7365 | | - |
7366 | Note: This is provided as a hook to avoid future problems related | - |
7367 | to adding virtual functions. | - |
7368 | */ | - |
7369 | bool QGraphicsItem::supportsExtension(Extension extension) const | - |
7370 | { | - |
7371 | Q_UNUSED(extension); never executed (the execution status of this line is deduced): (void)extension;; | - |
7372 | return false; never executed: return false; | 0 |
7373 | } | - |
7374 | | - |
7375 | /*! | - |
7376 | \internal | - |
7377 | | - |
7378 | Note: This is provided as a hook to avoid future problems related | - |
7379 | to adding virtual functions. | - |
7380 | */ | - |
7381 | void QGraphicsItem::setExtension(Extension extension, const QVariant &variant) | - |
7382 | { | - |
7383 | Q_UNUSED(extension); never executed (the execution status of this line is deduced): (void)extension;; | - |
7384 | Q_UNUSED(variant); never executed (the execution status of this line is deduced): (void)variant;; | - |
7385 | } | 0 |
7386 | | - |
7387 | /*! | - |
7388 | \internal | - |
7389 | | - |
7390 | Note: This is provided as a hook to avoid future problems related | - |
7391 | to adding virtual functions. | - |
7392 | */ | - |
7393 | QVariant QGraphicsItem::extension(const QVariant &variant) const | - |
7394 | { | - |
7395 | Q_UNUSED(variant); never executed (the execution status of this line is deduced): (void)variant;; | - |
7396 | return QVariant(); never executed: return QVariant(); | 0 |
7397 | } | - |
7398 | | - |
7399 | /*! | - |
7400 | \internal | - |
7401 | | - |
7402 | Adds this item to the scene's index. Called in conjunction with | - |
7403 | removeFromIndex() to ensure the index bookkeeping is correct when | - |
7404 | the item's position, transformation or shape changes. | - |
7405 | */ | - |
7406 | void QGraphicsItem::addToIndex() | - |
7407 | { | - |
7408 | if (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) { never evaluated: d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren | 0 |
7409 | // ### add to child index only if applicable | - |
7410 | return; | 0 |
7411 | } | - |
7412 | if (d_ptr->scene) never evaluated: d_ptr->scene | 0 |
7413 | d_ptr->scene->d_func()->index->addItem(this); never executed: d_ptr->scene->d_func()->index->addItem(this); | 0 |
7414 | } | 0 |
7415 | | - |
7416 | /*! | - |
7417 | \internal | - |
7418 | | - |
7419 | Removes this item from the scene's index. Called in conjunction | - |
7420 | with addToIndex() to ensure the index bookkeeping is correct when | - |
7421 | the item's position, transformation or shape changes. | - |
7422 | */ | - |
7423 | void QGraphicsItem::removeFromIndex() | - |
7424 | { | - |
7425 | if (d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren) { never evaluated: d_ptr->ancestorFlags & QGraphicsItemPrivate::AncestorClipsChildren | 0 |
7426 | // ### remove from child index only if applicable | - |
7427 | return; | 0 |
7428 | } | - |
7429 | if (d_ptr->scene) never evaluated: d_ptr->scene | 0 |
7430 | d_ptr->scene->d_func()->index->removeItem(this); never executed: d_ptr->scene->d_func()->index->removeItem(this); | 0 |
7431 | } | 0 |
7432 | | - |
7433 | /*! | - |
7434 | Prepares the item for a geometry change. Call this function before | - |
7435 | changing the bounding rect of an item to keep QGraphicsScene's index up to | - |
7436 | date. | - |
7437 | | - |
7438 | prepareGeometryChange() will call update() if this is necessary. | - |
7439 | | - |
7440 | Example: | - |
7441 | | - |
7442 | \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 16 | - |
7443 | | - |
7444 | \sa boundingRect() | - |
7445 | */ | - |
7446 | void QGraphicsItem::prepareGeometryChange() | - |
7447 | { | - |
7448 | if (d_ptr->inDestructor) evaluated: d_ptr->inDestructor yes Evaluation Count:11 | yes Evaluation Count:2523 |
| 11-2523 |
7449 | return; executed: return; Execution Count:11 | 11 |
7450 | if (d_ptr->scene) { evaluated: d_ptr->scene yes Evaluation Count:1470 | yes Evaluation Count:1053 |
| 1053-1470 |
7451 | d_ptr->scene->d_func()->dirtyGrowingItemsBoundingRect = true; executed (the execution status of this line is deduced): d_ptr->scene->d_func()->dirtyGrowingItemsBoundingRect = true; | - |
7452 | d_ptr->geometryChanged = 1; executed (the execution status of this line is deduced): d_ptr->geometryChanged = 1; | - |
7453 | d_ptr->paintedViewBoundingRectsNeedRepaint = 1; executed (the execution status of this line is deduced): d_ptr->paintedViewBoundingRectsNeedRepaint = 1; | - |
7454 | d_ptr->notifyBoundingRectChanged = !d_ptr->inSetPosHelper; executed (the execution status of this line is deduced): d_ptr->notifyBoundingRectChanged = !d_ptr->inSetPosHelper; | - |
7455 | | - |
7456 | QGraphicsScenePrivate *scenePrivate = d_ptr->scene->d_func(); executed (the execution status of this line is deduced): QGraphicsScenePrivate *scenePrivate = d_ptr->scene->d_func(); | - |
7457 | scenePrivate->index->prepareBoundingRectChange(this); executed (the execution status of this line is deduced): scenePrivate->index->prepareBoundingRectChange(this); | - |
7458 | scenePrivate->markDirty(this, QRectF(), /*invalidateChildren=*/true, /*force=*/false, executed (the execution status of this line is deduced): scenePrivate->markDirty(this, QRectF(), true, false, | - |
7459 | /*ignoreOpacity=*/ false, /*removingItemFromScene=*/ false, executed (the execution status of this line is deduced): false, false, | - |
7460 | /*updateBoundingRect=*/true); executed (the execution status of this line is deduced): true); | - |
7461 | | - |
7462 | // For compatibility reasons, we have to update the item's old geometry | - |
7463 | // if someone is connected to the changed signal or the scene has no views. | - |
7464 | // Note that this has to be done *after* markDirty to ensure that | - |
7465 | // _q_processDirtyItems is called before _q_emitUpdated. | - |
7466 | if (scenePrivate->isSignalConnected(scenePrivate->changedSignalIndex) partially evaluated: scenePrivate->isSignalConnected(scenePrivate->changedSignalIndex) no Evaluation Count:0 | yes Evaluation Count:1470 |
| 0-1470 |
7467 | || scenePrivate->views.isEmpty()) { evaluated: scenePrivate->views.isEmpty() yes Evaluation Count:48 | yes Evaluation Count:1422 |
| 48-1422 |
7468 | if (d_ptr->hasTranslateOnlySceneTransform()) { partially evaluated: d_ptr->hasTranslateOnlySceneTransform() yes Evaluation Count:48 | no Evaluation Count:0 |
| 0-48 |
7469 | d_ptr->scene->update(boundingRect().translated(d_ptr->sceneTransform.dx(), executed (the execution status of this line is deduced): d_ptr->scene->update(boundingRect().translated(d_ptr->sceneTransform.dx(), | - |
7470 | d_ptr->sceneTransform.dy())); executed (the execution status of this line is deduced): d_ptr->sceneTransform.dy())); | - |
7471 | } else { executed: } Execution Count:48 | 48 |
7472 | d_ptr->scene->update(d_ptr->sceneTransform.mapRect(boundingRect())); never executed (the execution status of this line is deduced): d_ptr->scene->update(d_ptr->sceneTransform.mapRect(boundingRect())); | - |
7473 | } | 0 |
7474 | } | - |
7475 | } executed: } Execution Count:1470 | 1470 |
7476 | | - |
7477 | d_ptr->markParentDirty(/*updateBoundingRect=*/true); executed (the execution status of this line is deduced): d_ptr->markParentDirty( true); | - |
7478 | } executed: } Execution Count:2523 | 2523 |
7479 | | - |
7480 | /*! | - |
7481 | \internal | - |
7482 | | - |
7483 | Highlights \a item as selected. | - |
7484 | | - |
7485 | NOTE: This function is a duplicate of qt_graphicsItem_highlightSelected() in | - |
7486 | qgraphicssvgitem.cpp! | - |
7487 | */ | - |
7488 | static void qt_graphicsItem_highlightSelected( | - |
7489 | QGraphicsItem *item, QPainter *painter, const QStyleOptionGraphicsItem *option) | - |
7490 | { | - |
7491 | const QRectF murect = painter->transform().mapRect(QRectF(0, 0, 1, 1)); never executed (the execution status of this line is deduced): const QRectF murect = painter->transform().mapRect(QRectF(0, 0, 1, 1)); | - |
7492 | if (qFuzzyIsNull(qMax(murect.width(), murect.height()))) never evaluated: qFuzzyIsNull(qMax(murect.width(), murect.height())) | 0 |
7493 | return; | 0 |
7494 | | - |
7495 | const QRectF mbrect = painter->transform().mapRect(item->boundingRect()); never executed (the execution status of this line is deduced): const QRectF mbrect = painter->transform().mapRect(item->boundingRect()); | - |
7496 | if (qMin(mbrect.width(), mbrect.height()) < qreal(1.0)) never evaluated: qMin(mbrect.width(), mbrect.height()) < qreal(1.0) | 0 |
7497 | return; | 0 |
7498 | | - |
7499 | qreal itemPenWidth; never executed (the execution status of this line is deduced): qreal itemPenWidth; | - |
7500 | switch (item->type()) { | - |
7501 | case QGraphicsEllipseItem::Type: | - |
7502 | itemPenWidth = static_cast<QGraphicsEllipseItem *>(item)->pen().widthF(); never executed (the execution status of this line is deduced): itemPenWidth = static_cast<QGraphicsEllipseItem *>(item)->pen().widthF(); | - |
7503 | break; | 0 |
7504 | case QGraphicsPathItem::Type: | - |
7505 | itemPenWidth = static_cast<QGraphicsPathItem *>(item)->pen().widthF(); never executed (the execution status of this line is deduced): itemPenWidth = static_cast<QGraphicsPathItem *>(item)->pen().widthF(); | - |
7506 | break; | 0 |
7507 | case QGraphicsPolygonItem::Type: | - |
7508 | itemPenWidth = static_cast<QGraphicsPolygonItem *>(item)->pen().widthF(); never executed (the execution status of this line is deduced): itemPenWidth = static_cast<QGraphicsPolygonItem *>(item)->pen().widthF(); | - |
7509 | break; | 0 |
7510 | case QGraphicsRectItem::Type: | - |
7511 | itemPenWidth = static_cast<QGraphicsRectItem *>(item)->pen().widthF(); never executed (the execution status of this line is deduced): itemPenWidth = static_cast<QGraphicsRectItem *>(item)->pen().widthF(); | - |
7512 | break; | 0 |
7513 | case QGraphicsSimpleTextItem::Type: | - |
7514 | itemPenWidth = static_cast<QGraphicsSimpleTextItem *>(item)->pen().widthF(); never executed (the execution status of this line is deduced): itemPenWidth = static_cast<QGraphicsSimpleTextItem *>(item)->pen().widthF(); | - |
7515 | break; | 0 |
7516 | case QGraphicsLineItem::Type: | - |
7517 | itemPenWidth = static_cast<QGraphicsLineItem *>(item)->pen().widthF(); never executed (the execution status of this line is deduced): itemPenWidth = static_cast<QGraphicsLineItem *>(item)->pen().widthF(); | - |
7518 | break; | 0 |
7519 | default: | - |
7520 | itemPenWidth = 1.0; never executed (the execution status of this line is deduced): itemPenWidth = 1.0; | - |
7521 | } | 0 |
7522 | const qreal pad = itemPenWidth / 2; never executed (the execution status of this line is deduced): const qreal pad = itemPenWidth / 2; | - |
7523 | | - |
7524 | const qreal penWidth = 0; // cosmetic pen never executed (the execution status of this line is deduced): const qreal penWidth = 0; | - |
7525 | | - |
7526 | const QColor fgcolor = option->palette.windowText().color(); never executed (the execution status of this line is deduced): const QColor fgcolor = option->palette.windowText().color(); | - |
7527 | const QColor bgcolor( // ensure good contrast against fgcolor never executed (the execution status of this line is deduced): const QColor bgcolor( | - |
7528 | fgcolor.red() > 127 ? 0 : 255, never executed (the execution status of this line is deduced): fgcolor.red() > 127 ? 0 : 255, | - |
7529 | fgcolor.green() > 127 ? 0 : 255, never executed (the execution status of this line is deduced): fgcolor.green() > 127 ? 0 : 255, | - |
7530 | fgcolor.blue() > 127 ? 0 : 255); never executed (the execution status of this line is deduced): fgcolor.blue() > 127 ? 0 : 255); | - |
7531 | | - |
7532 | painter->setPen(QPen(bgcolor, penWidth, Qt::SolidLine)); never executed (the execution status of this line is deduced): painter->setPen(QPen(bgcolor, penWidth, Qt::SolidLine)); | - |
7533 | painter->setBrush(Qt::NoBrush); never executed (the execution status of this line is deduced): painter->setBrush(Qt::NoBrush); | - |
7534 | painter->drawRect(item->boundingRect().adjusted(pad, pad, -pad, -pad)); never executed (the execution status of this line is deduced): painter->drawRect(item->boundingRect().adjusted(pad, pad, -pad, -pad)); | - |
7535 | | - |
7536 | painter->setPen(QPen(option->palette.windowText(), 0, Qt::DashLine)); never executed (the execution status of this line is deduced): painter->setPen(QPen(option->palette.windowText(), 0, Qt::DashLine)); | - |
7537 | painter->setBrush(Qt::NoBrush); never executed (the execution status of this line is deduced): painter->setBrush(Qt::NoBrush); | - |
7538 | painter->drawRect(item->boundingRect().adjusted(pad, pad, -pad, -pad)); never executed (the execution status of this line is deduced): painter->drawRect(item->boundingRect().adjusted(pad, pad, -pad, -pad)); | - |
7539 | } | 0 |
7540 | | - |
7541 | /*! | - |
7542 | \class QGraphicsObject | - |
7543 | \brief The QGraphicsObject class provides a base class for all graphics items that | - |
7544 | require signals, slots and properties. | - |
7545 | \since 4.6 | - |
7546 | \ingroup graphicsview-api | - |
7547 | \inmodule QtWidgets | - |
7548 | | - |
7549 | The class extends a QGraphicsItem with QObject's signal/slot and property mechanisms. | - |
7550 | It maps many of QGraphicsItem's basic setters and getters to properties and adds notification | - |
7551 | signals for many of them. | - |
7552 | | - |
7553 | \section1 Parents and Children | - |
7554 | | - |
7555 | Each graphics object can be constructed with a parent item. This ensures that the | - |
7556 | item will be destroyed when its parent item is destroyed. Although QGraphicsObject | - |
7557 | inherits from both QObject and QGraphicsItem, you should use the functions provided | - |
7558 | by QGraphicsItem, \e not QObject, to manage the relationships between parent and | - |
7559 | child items. | - |
7560 | | - |
7561 | The relationships between items can be explored using the parentItem() and childItems() | - |
7562 | functions. In the hierarchy of items in a scene, the parentObject() and parentWidget() | - |
7563 | functions are the equivalent of the QWidget::parent() and QWidget::parentWidget() | - |
7564 | functions for QWidget subclasses. | - |
7565 | | - |
7566 | \sa QGraphicsWidget | - |
7567 | */ | - |
7568 | | - |
7569 | /*! | - |
7570 | Constructs a QGraphicsObject with \a parent. | - |
7571 | */ | - |
7572 | QGraphicsObject::QGraphicsObject(QGraphicsItem *parent) | - |
7573 | : QGraphicsItem(parent) | - |
7574 | { | - |
7575 | QGraphicsItem::d_ptr->isObject = true; executed (the execution status of this line is deduced): QGraphicsItem::d_ptr->isObject = true; | - |
7576 | } executed: } Execution Count:62 | 62 |
7577 | | - |
7578 | /*! | - |
7579 | \internal | - |
7580 | */ | - |
7581 | QGraphicsObject::QGraphicsObject(QGraphicsItemPrivate &dd, QGraphicsItem *parent) | - |
7582 | : QGraphicsItem(dd, parent) | - |
7583 | { | - |
7584 | QGraphicsItem::d_ptr->isObject = true; executed (the execution status of this line is deduced): QGraphicsItem::d_ptr->isObject = true; | - |
7585 | } executed: } Execution Count:1438 | 1438 |
7586 | | - |
7587 | /*! | - |
7588 | Destructor. | - |
7589 | */ | - |
7590 | QGraphicsObject::~QGraphicsObject() | - |
7591 | { | - |
7592 | } | - |
7593 | | - |
7594 | /*! | - |
7595 | \reimp | - |
7596 | */ | - |
7597 | bool QGraphicsObject::event(QEvent *ev) | - |
7598 | { | - |
7599 | if (ev->type() == QEvent::StyleAnimationUpdate) { partially evaluated: ev->type() == QEvent::StyleAnimationUpdate no Evaluation Count:0 | yes Evaluation Count:53 |
| 0-53 |
7600 | update(); never executed (the execution status of this line is deduced): update(); | - |
7601 | return true; never executed: return true; | 0 |
7602 | } | - |
7603 | return QObject::event(ev); executed: return QObject::event(ev); Execution Count:53 | 53 |
7604 | } | - |
7605 | | - |
7606 | #ifndef QT_NO_GESTURES | - |
7607 | /*! | - |
7608 | Subscribes the graphics object to the given \a gesture with specific \a flags. | - |
7609 | | - |
7610 | \sa ungrabGesture(), QGestureEvent | - |
7611 | */ | - |
7612 | void QGraphicsObject::grabGesture(Qt::GestureType gesture, Qt::GestureFlags flags) | - |
7613 | { | - |
7614 | bool contains = QGraphicsItem::d_ptr->gestureContext.contains(gesture); executed (the execution status of this line is deduced): bool contains = QGraphicsItem::d_ptr->gestureContext.contains(gesture); | - |
7615 | QGraphicsItem::d_ptr->gestureContext.insert(gesture, flags); executed (the execution status of this line is deduced): QGraphicsItem::d_ptr->gestureContext.insert(gesture, flags); | - |
7616 | if (!contains && QGraphicsItem::d_ptr->scene) evaluated: !contains yes Evaluation Count:52 | yes Evaluation Count:4 |
evaluated: QGraphicsItem::d_ptr->scene yes Evaluation Count:21 | yes Evaluation Count:31 |
| 4-52 |
7617 | QGraphicsItem::d_ptr->scene->d_func()->grabGesture(this, gesture); executed: QGraphicsItem::d_ptr->scene->d_func()->grabGesture(this, gesture); Execution Count:21 | 21 |
7618 | } executed: } Execution Count:56 | 56 |
7619 | | - |
7620 | /*! | - |
7621 | Unsubscribes the graphics object from the given \a gesture. | - |
7622 | | - |
7623 | \sa grabGesture(), QGestureEvent | - |
7624 | */ | - |
7625 | void QGraphicsObject::ungrabGesture(Qt::GestureType gesture) | - |
7626 | { | - |
7627 | if (QGraphicsItem::d_ptr->gestureContext.remove(gesture) && QGraphicsItem::d_ptr->scene) never evaluated: QGraphicsItem::d_ptr->gestureContext.remove(gesture) never evaluated: QGraphicsItem::d_ptr->scene | 0 |
7628 | QGraphicsItem::d_ptr->scene->d_func()->ungrabGesture(this, gesture); never executed: QGraphicsItem::d_ptr->scene->d_func()->ungrabGesture(this, gesture); | 0 |
7629 | } | 0 |
7630 | #endif // QT_NO_GESTURES | - |
7631 | | - |
7632 | /*! | - |
7633 | Updates the item's micro focus. This is slot for convenience. | - |
7634 | | - |
7635 | \since 4.7 | - |
7636 | | - |
7637 | \sa QInputMethod | - |
7638 | */ | - |
7639 | void QGraphicsObject::updateMicroFocus() | - |
7640 | { | - |
7641 | QGraphicsItem::updateMicroFocus(); never executed (the execution status of this line is deduced): QGraphicsItem::updateMicroFocus(); | - |
7642 | } | 0 |
7643 | | - |
7644 | void QGraphicsItemPrivate::children_append(QDeclarativeListProperty<QGraphicsObject> *list, QGraphicsObject *item) | - |
7645 | { | - |
7646 | if (item) { | 0 |
7647 | QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(list->object); never executed (the execution status of this line is deduced): QGraphicsObject *graphicsObject = static_cast<QGraphicsObject *>(list->object); | - |
7648 | if (QGraphicsItemPrivate::get(graphicsObject)->sendParentChangeNotification) { never evaluated: QGraphicsItemPrivate::get(graphicsObject)->sendParentChangeNotification | 0 |
7649 | item->setParentItem(graphicsObject); never executed (the execution status of this line is deduced): item->setParentItem(graphicsObject); | - |
7650 | } else { | 0 |
7651 | QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, 0, 0); never executed (the execution status of this line is deduced): QGraphicsItemPrivate::get(item)->setParentItemHelper(graphicsObject, 0, 0); | - |
7652 | } | 0 |
7653 | } | - |
7654 | } | 0 |
7655 | | - |
7656 | int QGraphicsItemPrivate::children_count(QDeclarativeListProperty<QGraphicsObject> *list) | - |
7657 | { | - |
7658 | QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object)); never executed (the execution status of this line is deduced): QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object)); | - |
7659 | return d->children.count(); never executed: return d->children.count(); | 0 |
7660 | } | - |
7661 | | - |
7662 | QGraphicsObject *QGraphicsItemPrivate::children_at(QDeclarativeListProperty<QGraphicsObject> *list, int index) | - |
7663 | { | - |
7664 | QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object)); never executed (the execution status of this line is deduced): QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object)); | - |
7665 | if (index >= 0 && index < d->children.count()) never evaluated: index >= 0 never evaluated: index < d->children.count() | 0 |
7666 | return d->children.at(index)->toGraphicsObject(); never executed: return d->children.at(index)->toGraphicsObject(); | 0 |
7667 | else | - |
7668 | return 0; never executed: return 0; | 0 |
7669 | } | - |
7670 | | - |
7671 | void QGraphicsItemPrivate::children_clear(QDeclarativeListProperty<QGraphicsObject> *list) | - |
7672 | { | - |
7673 | QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object)); never executed (the execution status of this line is deduced): QGraphicsItemPrivate *d = QGraphicsItemPrivate::get(static_cast<QGraphicsObject *>(list->object)); | - |
7674 | int childCount = d->children.count(); never executed (the execution status of this line is deduced): int childCount = d->children.count(); | - |
7675 | if (d->sendParentChangeNotification) { never evaluated: d->sendParentChangeNotification | 0 |
7676 | for (int index = 0; index < childCount; index++) never evaluated: index < childCount | 0 |
7677 | d->children.at(0)->setParentItem(0); never executed: d->children.at(0)->setParentItem(0); | 0 |
7678 | } else { | 0 |
7679 | for (int index = 0; index < childCount; index++) never evaluated: index < childCount | 0 |
7680 | QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(0, 0, 0); never executed: QGraphicsItemPrivate::get(d->children.at(0))->setParentItemHelper(0, 0, 0); | 0 |
7681 | } | 0 |
7682 | } | - |
7683 | | - |
7684 | /*! | - |
7685 | Returns a list of this item's children. | - |
7686 | | - |
7687 | The items are sorted by stacking order. This takes into account both the | - |
7688 | items' insertion order and their Z-values. | - |
7689 | | - |
7690 | */ | - |
7691 | QDeclarativeListProperty<QGraphicsObject> QGraphicsItemPrivate::childrenList() | - |
7692 | { | - |
7693 | Q_Q(QGraphicsItem); never executed (the execution status of this line is deduced): QGraphicsItem * const q = q_func(); | - |
7694 | if (isObject) { never evaluated: isObject | 0 |
7695 | QGraphicsObject *that = static_cast<QGraphicsObject *>(q); never executed (the execution status of this line is deduced): QGraphicsObject *that = static_cast<QGraphicsObject *>(q); | - |
7696 | return QDeclarativeListProperty<QGraphicsObject>(that, &children, children_append, never executed: return QDeclarativeListProperty<QGraphicsObject>(that, &children, children_append, children_count, children_at, children_clear); | 0 |
7697 | children_count, children_at, children_clear); never executed: return QDeclarativeListProperty<QGraphicsObject>(that, &children, children_append, children_count, children_at, children_clear); | 0 |
7698 | } else { | - |
7699 | //QGraphicsItem is not supported for this property | - |
7700 | return QDeclarativeListProperty<QGraphicsObject>(); never executed: return QDeclarativeListProperty<QGraphicsObject>(); | 0 |
7701 | } | - |
7702 | } | - |
7703 | | - |
7704 | /*! | - |
7705 | \internal | - |
7706 | Returns the width of the item | - |
7707 | Reimplemented by QGraphicsWidget | - |
7708 | */ | - |
7709 | qreal QGraphicsItemPrivate::width() const | - |
7710 | { | - |
7711 | return 0; never executed: return 0; | 0 |
7712 | } | - |
7713 | | - |
7714 | /*! | - |
7715 | \internal | - |
7716 | Set the width of the item | - |
7717 | Reimplemented by QGraphicsWidget | - |
7718 | */ | - |
7719 | void QGraphicsItemPrivate::setWidth(qreal w) | - |
7720 | { | - |
7721 | Q_UNUSED(w); never executed (the execution status of this line is deduced): (void)w;; | - |
7722 | } | 0 |
7723 | | - |
7724 | /*! | - |
7725 | \internal | - |
7726 | Reset the width of the item | - |
7727 | Reimplemented by QGraphicsWidget | - |
7728 | */ | - |
7729 | void QGraphicsItemPrivate::resetWidth() | - |
7730 | { | - |
7731 | } | - |
7732 | | - |
7733 | /*! | - |
7734 | \internal | - |
7735 | Returns the height of the item | - |
7736 | Reimplemented by QGraphicsWidget | - |
7737 | */ | - |
7738 | qreal QGraphicsItemPrivate::height() const | - |
7739 | { | - |
7740 | return 0; never executed: return 0; | 0 |
7741 | } | - |
7742 | | - |
7743 | /*! | - |
7744 | \internal | - |
7745 | Set the height of the item | - |
7746 | Reimplemented by QGraphicsWidget | - |
7747 | */ | - |
7748 | void QGraphicsItemPrivate::setHeight(qreal h) | - |
7749 | { | - |
7750 | Q_UNUSED(h); never executed (the execution status of this line is deduced): (void)h;; | - |
7751 | } | 0 |
7752 | | - |
7753 | /*! | - |
7754 | \internal | - |
7755 | Reset the height of the item | - |
7756 | Reimplemented by QGraphicsWidget | - |
7757 | */ | - |
7758 | void QGraphicsItemPrivate::resetHeight() | - |
7759 | { | - |
7760 | } | - |
7761 | | - |
7762 | /*! | - |
7763 | \property QGraphicsObject::children | - |
7764 | \since 4.7 | - |
7765 | \internal | - |
7766 | */ | - |
7767 | | - |
7768 | /*! | - |
7769 | \property QGraphicsObject::width | - |
7770 | \since 4.7 | - |
7771 | \internal | - |
7772 | */ | - |
7773 | | - |
7774 | /*! | - |
7775 | \property QGraphicsObject::height | - |
7776 | \since 4.7 | - |
7777 | \internal | - |
7778 | */ | - |
7779 | | - |
7780 | /*! | - |
7781 | \property QGraphicsObject::parent | - |
7782 | \brief the parent of the item | - |
7783 | | - |
7784 | \note The item's parent is set independently of the parent object returned | - |
7785 | by QObject::parent(). | - |
7786 | | - |
7787 | \sa QGraphicsItem::setParentItem(), QGraphicsItem::parentObject() | - |
7788 | */ | - |
7789 | | - |
7790 | /*! | - |
7791 | \property QGraphicsObject::opacity | - |
7792 | \brief the opacity of the item | - |
7793 | | - |
7794 | \sa QGraphicsItem::setOpacity(), QGraphicsItem::opacity() | - |
7795 | */ | - |
7796 | | - |
7797 | /*! | - |
7798 | \fn QGraphicsObject::opacityChanged() | - |
7799 | | - |
7800 | This signal gets emitted whenever the opacity of the item changes | - |
7801 | | - |
7802 | \sa QGraphicsItem::opacity() | - |
7803 | */ | - |
7804 | | - |
7805 | /*! | - |
7806 | \fn QGraphicsObject::parentChanged() | - |
7807 | | - |
7808 | This signal gets emitted whenever the parent of the item changes | - |
7809 | */ | - |
7810 | | - |
7811 | /*! | - |
7812 | \property QGraphicsObject::pos | - |
7813 | \brief the position of the item | - |
7814 | | - |
7815 | Describes the items position. | - |
7816 | | - |
7817 | \sa QGraphicsItem::setPos(), QGraphicsItem::pos() | - |
7818 | */ | - |
7819 | | - |
7820 | /*! | - |
7821 | \property QGraphicsObject::x | - |
7822 | \brief the x position of the item | - |
7823 | | - |
7824 | Describes the items x position. | - |
7825 | | - |
7826 | \sa QGraphicsItem::setX(), setPos() | - |
7827 | */ | - |
7828 | | - |
7829 | /*! | - |
7830 | \fn QGraphicsObject::xChanged() | - |
7831 | | - |
7832 | This signal gets emitted whenever the x position of the item changes | - |
7833 | | - |
7834 | \sa pos() | - |
7835 | */ | - |
7836 | | - |
7837 | /*! | - |
7838 | \property QGraphicsObject::y | - |
7839 | \brief the y position of the item | - |
7840 | | - |
7841 | Describes the items y position. | - |
7842 | | - |
7843 | \sa QGraphicsItem::setY(), setPos() | - |
7844 | */ | - |
7845 | | - |
7846 | /*! | - |
7847 | \fn QGraphicsObject::yChanged() | - |
7848 | | - |
7849 | This signal gets emitted whenever the y position of the item changes. | - |
7850 | | - |
7851 | \sa pos() | - |
7852 | */ | - |
7853 | | - |
7854 | /*! | - |
7855 | \property QGraphicsObject::z | - |
7856 | \brief the z value of the item | - |
7857 | | - |
7858 | Describes the items z value. | - |
7859 | | - |
7860 | \sa QGraphicsItem::setZValue(), zValue() | - |
7861 | */ | - |
7862 | | - |
7863 | /*! | - |
7864 | \fn QGraphicsObject::zChanged() | - |
7865 | | - |
7866 | This signal gets emitted whenever the z value of the item changes. | - |
7867 | | - |
7868 | \sa pos() | - |
7869 | */ | - |
7870 | | - |
7871 | /*! | - |
7872 | \property QGraphicsObject::rotation | - |
7873 | This property holds the rotation of the item in degrees. | - |
7874 | | - |
7875 | This specifies how many degrees to rotate the item around its transformOrigin. | - |
7876 | The default rotation is 0 degrees (i.e. not rotated at all). | - |
7877 | */ | - |
7878 | | - |
7879 | /*! | - |
7880 | \fn QGraphicsObject::rotationChanged() | - |
7881 | | - |
7882 | This signal gets emitted whenever the roation of the item changes. | - |
7883 | */ | - |
7884 | | - |
7885 | /*! | - |
7886 | \property QGraphicsObject::scale | - |
7887 | This property holds the scale of the item. | - |
7888 | | - |
7889 | A scale of less than 1 means the item will be displayed smaller than | - |
7890 | normal, and a scale of greater than 1 means the item will be | - |
7891 | displayed larger than normal. A negative scale means the item will | - |
7892 | be mirrored. | - |
7893 | | - |
7894 | By default, items are displayed at a scale of 1 (i.e. at their | - |
7895 | normal size). | - |
7896 | | - |
7897 | Scaling is from the item's transformOrigin. | - |
7898 | */ | - |
7899 | | - |
7900 | /*! | - |
7901 | \fn void QGraphicsObject::scaleChanged() | - |
7902 | | - |
7903 | This signal is emitted when the scale of the item changes. | - |
7904 | */ | - |
7905 | | - |
7906 | | - |
7907 | /*! | - |
7908 | \property QGraphicsObject::enabled | - |
7909 | \brief whether the item is enabled or not | - |
7910 | | - |
7911 | This property is declared in QGraphicsItem. | - |
7912 | | - |
7913 | By default, this property is true. | - |
7914 | | - |
7915 | \sa QGraphicsItem::isEnabled(), QGraphicsItem::setEnabled() | - |
7916 | */ | - |
7917 | | - |
7918 | /*! | - |
7919 | \fn void QGraphicsObject::enabledChanged() | - |
7920 | | - |
7921 | This signal gets emitted whenever the item get's enabled or disabled. | - |
7922 | | - |
7923 | \sa isEnabled() | - |
7924 | */ | - |
7925 | | - |
7926 | /*! | - |
7927 | \property QGraphicsObject::visible | - |
7928 | \brief whether the item is visible or not | - |
7929 | | - |
7930 | This property is declared in QGraphicsItem. | - |
7931 | | - |
7932 | By default, this property is true. | - |
7933 | | - |
7934 | \sa QGraphicsItem::isVisible(), QGraphicsItem::setVisible() | - |
7935 | */ | - |
7936 | | - |
7937 | /*! | - |
7938 | \fn QGraphicsObject::visibleChanged() | - |
7939 | | - |
7940 | This signal gets emitted whenever the visibility of the item changes | - |
7941 | | - |
7942 | \sa visible | - |
7943 | */ | - |
7944 | | - |
7945 | /*! | - |
7946 | \fn const QObjectList &QGraphicsObject::children() const | - |
7947 | \internal | - |
7948 | | - |
7949 | This function returns the same value as QObject::children(). It's | - |
7950 | provided to differentiate between the obsolete member | - |
7951 | QGraphicsItem::children() and QObject::children(). QGraphicsItem now | - |
7952 | provides childItems() instead. | - |
7953 | */ | - |
7954 | | - |
7955 | /*! | - |
7956 | \property QGraphicsObject::transformOriginPoint | - |
7957 | \brief the transformation origin | - |
7958 | | - |
7959 | This property sets a specific point in the items coordiante system as the | - |
7960 | origin for scale and rotation. | - |
7961 | | - |
7962 | \sa scale, rotation, QGraphicsItem::transformOriginPoint() | - |
7963 | */ | - |
7964 | | - |
7965 | /*! | - |
7966 | \fn void QGraphicsObject::widthChanged() | - |
7967 | \internal | - |
7968 | */ | - |
7969 | | - |
7970 | /*! | - |
7971 | \fn void QGraphicsObject::heightChanged() | - |
7972 | \internal | - |
7973 | */ | - |
7974 | | - |
7975 | /*! | - |
7976 | | - |
7977 | \fn QGraphicsObject::childrenChanged() | - |
7978 | | - |
7979 | This signal gets emitted whenever the children list changes | - |
7980 | \internal | - |
7981 | */ | - |
7982 | | - |
7983 | /*! | - |
7984 | \property QGraphicsObject::effect | - |
7985 | \since 4.7 | - |
7986 | \brief the effect attached to this item | - |
7987 | | - |
7988 | \sa QGraphicsItem::setGraphicsEffect(), QGraphicsItem::graphicsEffect() | - |
7989 | */ | - |
7990 | | - |
7991 | /*! | - |
7992 | \class QAbstractGraphicsShapeItem | - |
7993 | \brief The QAbstractGraphicsShapeItem class provides a common base for | - |
7994 | all path items. | - |
7995 | \since 4.2 | - |
7996 | \ingroup graphicsview-api | - |
7997 | \inmodule QtWidgets | - |
7998 | | - |
7999 | This class does not fully implement an item by itself; in particular, it | - |
8000 | does not implement boundingRect() and paint(), which are inherited by | - |
8001 | QGraphicsItem. | - |
8002 | | - |
8003 | You can subclass this item to provide a simple base implementation of | - |
8004 | accessors for the item's pen and brush. | - |
8005 | | - |
8006 | \sa QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPathItem, | - |
8007 | QGraphicsPolygonItem, QGraphicsTextItem, QGraphicsLineItem, | - |
8008 | QGraphicsPixmapItem, {Graphics View Framework} | - |
8009 | */ | - |
8010 | | - |
8011 | class QAbstractGraphicsShapeItemPrivate : public QGraphicsItemPrivate | - |
8012 | { | - |
8013 | Q_DECLARE_PUBLIC(QAbstractGraphicsShapeItem) | - |
8014 | public: | - |
8015 | | - |
8016 | QBrush brush; | - |
8017 | QPen pen; | - |
8018 | | - |
8019 | // Cached bounding rectangle | - |
8020 | mutable QRectF boundingRect; | - |
8021 | }; | - |
8022 | | - |
8023 | /*! | - |
8024 | Constructs a QAbstractGraphicsShapeItem. \a parent is passed to | - |
8025 | QGraphicsItem's constructor. | - |
8026 | */ | - |
8027 | QAbstractGraphicsShapeItem::QAbstractGraphicsShapeItem(QGraphicsItem *parent) | - |
8028 | : QGraphicsItem(*new QAbstractGraphicsShapeItemPrivate, parent) | - |
8029 | { | - |
8030 | } | 0 |
8031 | | - |
8032 | /*! | - |
8033 | \internal | - |
8034 | */ | - |
8035 | QAbstractGraphicsShapeItem::QAbstractGraphicsShapeItem(QAbstractGraphicsShapeItemPrivate &dd, QGraphicsItem *parent) | - |
8036 | : QGraphicsItem(dd, parent) | - |
8037 | { | - |
8038 | } executed: } Execution Count:32 | 32 |
8039 | | - |
8040 | /*! | - |
8041 | Destroys a QAbstractGraphicsShapeItem. | - |
8042 | */ | - |
8043 | QAbstractGraphicsShapeItem::~QAbstractGraphicsShapeItem() | - |
8044 | { | - |
8045 | } | - |
8046 | | - |
8047 | /*! | - |
8048 | Returns the item's pen. If no pen has been set, this function returns | - |
8049 | QPen(), a default black solid line pen with 1 width. | - |
8050 | */ | - |
8051 | QPen QAbstractGraphicsShapeItem::pen() const | - |
8052 | { | - |
8053 | Q_D(const QAbstractGraphicsShapeItem); executed (the execution status of this line is deduced): const QAbstractGraphicsShapeItemPrivate * const d = d_func(); | - |
8054 | return d->pen; executed: return d->pen; Execution Count:213 | 213 |
8055 | } | - |
8056 | | - |
8057 | /*! | - |
8058 | Sets the pen for this item to \a pen. | - |
8059 | | - |
8060 | The pen is used to draw the item's outline. | - |
8061 | | - |
8062 | \sa pen() | - |
8063 | */ | - |
8064 | void QAbstractGraphicsShapeItem::setPen(const QPen &pen) | - |
8065 | { | - |
8066 | Q_D(QAbstractGraphicsShapeItem); executed (the execution status of this line is deduced): QAbstractGraphicsShapeItemPrivate * const d = d_func(); | - |
8067 | if (d->pen == pen) partially evaluated: d->pen == pen no Evaluation Count:0 | yes Evaluation Count:9 |
| 0-9 |
8068 | return; | 0 |
8069 | prepareGeometryChange(); executed (the execution status of this line is deduced): prepareGeometryChange(); | - |
8070 | d->pen = pen; executed (the execution status of this line is deduced): d->pen = pen; | - |
8071 | d->boundingRect = QRectF(); executed (the execution status of this line is deduced): d->boundingRect = QRectF(); | - |
8072 | update(); executed (the execution status of this line is deduced): update(); | - |
8073 | } executed: } Execution Count:9 | 9 |
8074 | | - |
8075 | /*! | - |
8076 | Returns the item's brush, or an empty brush if no brush has been set. | - |
8077 | | - |
8078 | \sa setBrush() | - |
8079 | */ | - |
8080 | QBrush QAbstractGraphicsShapeItem::brush() const | - |
8081 | { | - |
8082 | Q_D(const QAbstractGraphicsShapeItem); never executed (the execution status of this line is deduced): const QAbstractGraphicsShapeItemPrivate * const d = d_func(); | - |
8083 | return d->brush; never executed: return d->brush; | 0 |
8084 | } | - |
8085 | | - |
8086 | /*! | - |
8087 | Sets the item's brush to \a brush. | - |
8088 | | - |
8089 | The item's brush is used to fill the item. | - |
8090 | | - |
8091 | If you use a brush with a QGradient, the gradient | - |
8092 | is relative to the item's coordinate system. | - |
8093 | | - |
8094 | \sa brush() | - |
8095 | */ | - |
8096 | void QAbstractGraphicsShapeItem::setBrush(const QBrush &brush) | - |
8097 | { | - |
8098 | Q_D(QAbstractGraphicsShapeItem); executed (the execution status of this line is deduced): QAbstractGraphicsShapeItemPrivate * const d = d_func(); | - |
8099 | if (d->brush == brush) partially evaluated: d->brush == brush no Evaluation Count:0 | yes Evaluation Count:4 |
| 0-4 |
8100 | return; | 0 |
8101 | d->brush = brush; executed (the execution status of this line is deduced): d->brush = brush; | - |
8102 | update(); executed (the execution status of this line is deduced): update(); | - |
8103 | } executed: } Execution Count:4 | 4 |
8104 | | - |
8105 | /*! | - |
8106 | \reimp | - |
8107 | */ | - |
8108 | bool QAbstractGraphicsShapeItem::isObscuredBy(const QGraphicsItem *item) const | - |
8109 | { | - |
8110 | return QGraphicsItem::isObscuredBy(item); executed: return QGraphicsItem::isObscuredBy(item); Execution Count:2 | 2 |
8111 | } | - |
8112 | | - |
8113 | /*! | - |
8114 | \reimp | - |
8115 | */ | - |
8116 | QPainterPath QAbstractGraphicsShapeItem::opaqueArea() const | - |
8117 | { | - |
8118 | Q_D(const QAbstractGraphicsShapeItem); executed (the execution status of this line is deduced): const QAbstractGraphicsShapeItemPrivate * const d = d_func(); | - |
8119 | if (d->brush.isOpaque()) partially evaluated: d->brush.isOpaque() no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
8120 | return isClipped() ? clipPath() : shape(); never executed: return isClipped() ? clipPath() : shape(); | 0 |
8121 | return QGraphicsItem::opaqueArea(); executed: return QGraphicsItem::opaqueArea(); Execution Count:2 | 2 |
8122 | } | - |
8123 | | - |
8124 | /*! | - |
8125 | \class QGraphicsPathItem | - |
8126 | \brief The QGraphicsPathItem class provides a path item that you | - |
8127 | can add to a QGraphicsScene. | - |
8128 | \since 4.2 | - |
8129 | \ingroup graphicsview-api | - |
8130 | \inmodule QtWidgets | - |
8131 | | - |
8132 | To set the item's path, pass a QPainterPath to QGraphicsPathItem's | - |
8133 | constructor, or call the setPath() function. The path() function | - |
8134 | returns the current path. | - |
8135 | | - |
8136 | \image graphicsview-pathitem.png | - |
8137 | | - |
8138 | QGraphicsPathItem uses the path to provide a reasonable | - |
8139 | implementation of boundingRect(), shape(), and contains(). The | - |
8140 | paint() function draws the path using the item's associated pen | - |
8141 | and brush, which you can set by calling the setPen() and | - |
8142 | setBrush() functions. | - |
8143 | | - |
8144 | \sa QGraphicsRectItem, QGraphicsEllipseItem, QGraphicsPolygonItem, | - |
8145 | QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics | - |
8146 | View Framework} | - |
8147 | */ | - |
8148 | | - |
8149 | class QGraphicsPathItemPrivate : public QAbstractGraphicsShapeItemPrivate | - |
8150 | { | - |
8151 | Q_DECLARE_PUBLIC(QGraphicsPathItem) | - |
8152 | public: | - |
8153 | QPainterPath path; | - |
8154 | }; | - |
8155 | | - |
8156 | /*! | - |
8157 | Constructs a QGraphicsPath item using \a path as the default path. \a | - |
8158 | parent is passed to QAbstractGraphicsShapeItem's constructor. | - |
8159 | | - |
8160 | \sa QGraphicsScene::addItem() | - |
8161 | */ | - |
8162 | QGraphicsPathItem::QGraphicsPathItem(const QPainterPath &path, | - |
8163 | QGraphicsItem *parent) | - |
8164 | : QAbstractGraphicsShapeItem(*new QGraphicsPathItemPrivate, parent) | - |
8165 | { | - |
8166 | if (!path.isEmpty()) never evaluated: !path.isEmpty() | 0 |
8167 | setPath(path); never executed: setPath(path); | 0 |
8168 | } | 0 |
8169 | | - |
8170 | /*! | - |
8171 | Constructs a QGraphicsPath. \a parent is passed to | - |
8172 | QAbstractGraphicsShapeItem's constructor. | - |
8173 | | - |
8174 | \sa QGraphicsScene::addItem() | - |
8175 | */ | - |
8176 | QGraphicsPathItem::QGraphicsPathItem(QGraphicsItem *parent) | - |
8177 | : QAbstractGraphicsShapeItem(*new QGraphicsPathItemPrivate, parent) | - |
8178 | { | - |
8179 | } | 0 |
8180 | | - |
8181 | /*! | - |
8182 | Destroys the QGraphicsPathItem. | - |
8183 | */ | - |
8184 | QGraphicsPathItem::~QGraphicsPathItem() | - |
8185 | { | - |
8186 | } | - |
8187 | | - |
8188 | /*! | - |
8189 | Returns the item's path as a QPainterPath. If no item has been set, an | - |
8190 | empty QPainterPath is returned. | - |
8191 | | - |
8192 | \sa setPath() | - |
8193 | */ | - |
8194 | QPainterPath QGraphicsPathItem::path() const | - |
8195 | { | - |
8196 | Q_D(const QGraphicsPathItem); never executed (the execution status of this line is deduced): const QGraphicsPathItemPrivate * const d = d_func(); | - |
8197 | return d->path; never executed: return d->path; | 0 |
8198 | } | - |
8199 | | - |
8200 | /*! | - |
8201 | Sets the item's path to be the given \a path. | - |
8202 | | - |
8203 | \sa path() | - |
8204 | */ | - |
8205 | void QGraphicsPathItem::setPath(const QPainterPath &path) | - |
8206 | { | - |
8207 | Q_D(QGraphicsPathItem); never executed (the execution status of this line is deduced): QGraphicsPathItemPrivate * const d = d_func(); | - |
8208 | if (d->path == path) never evaluated: d->path == path | 0 |
8209 | return; | 0 |
8210 | prepareGeometryChange(); never executed (the execution status of this line is deduced): prepareGeometryChange(); | - |
8211 | d->path = path; never executed (the execution status of this line is deduced): d->path = path; | - |
8212 | d->boundingRect = QRectF(); never executed (the execution status of this line is deduced): d->boundingRect = QRectF(); | - |
8213 | update(); never executed (the execution status of this line is deduced): update(); | - |
8214 | } | 0 |
8215 | | - |
8216 | /*! | - |
8217 | \reimp | - |
8218 | */ | - |
8219 | QRectF QGraphicsPathItem::boundingRect() const | - |
8220 | { | - |
8221 | Q_D(const QGraphicsPathItem); never executed (the execution status of this line is deduced): const QGraphicsPathItemPrivate * const d = d_func(); | - |
8222 | if (d->boundingRect.isNull()) { never evaluated: d->boundingRect.isNull() | 0 |
8223 | qreal pw = pen().style() == Qt::NoPen ? qreal(0) : pen().widthF(); never evaluated: pen().style() == Qt::NoPen | 0 |
8224 | if (pw == 0.0) never evaluated: pw == 0.0 | 0 |
8225 | d->boundingRect = d->path.controlPointRect(); never executed: d->boundingRect = d->path.controlPointRect(); | 0 |
8226 | else { | - |
8227 | d->boundingRect = shape().controlPointRect(); never executed (the execution status of this line is deduced): d->boundingRect = shape().controlPointRect(); | - |
8228 | } | 0 |
8229 | } | - |
8230 | return d->boundingRect; never executed: return d->boundingRect; | 0 |
8231 | } | - |
8232 | | - |
8233 | /*! | - |
8234 | \reimp | - |
8235 | */ | - |
8236 | QPainterPath QGraphicsPathItem::shape() const | - |
8237 | { | - |
8238 | Q_D(const QGraphicsPathItem); never executed (the execution status of this line is deduced): const QGraphicsPathItemPrivate * const d = d_func(); | - |
8239 | return qt_graphicsItem_shapeFromPath(d->path, d->pen); never executed: return qt_graphicsItem_shapeFromPath(d->path, d->pen); | 0 |
8240 | } | - |
8241 | | - |
8242 | /*! | - |
8243 | \reimp | - |
8244 | */ | - |
8245 | bool QGraphicsPathItem::contains(const QPointF &point) const | - |
8246 | { | - |
8247 | return QAbstractGraphicsShapeItem::contains(point); never executed: return QAbstractGraphicsShapeItem::contains(point); | 0 |
8248 | } | - |
8249 | | - |
8250 | /*! | - |
8251 | \reimp | - |
8252 | */ | - |
8253 | void QGraphicsPathItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, | - |
8254 | QWidget *widget) | - |
8255 | { | - |
8256 | Q_D(QGraphicsPathItem); never executed (the execution status of this line is deduced): QGraphicsPathItemPrivate * const d = d_func(); | - |
8257 | Q_UNUSED(widget); never executed (the execution status of this line is deduced): (void)widget;; | - |
8258 | painter->setPen(d->pen); never executed (the execution status of this line is deduced): painter->setPen(d->pen); | - |
8259 | painter->setBrush(d->brush); never executed (the execution status of this line is deduced): painter->setBrush(d->brush); | - |
8260 | painter->drawPath(d->path); never executed (the execution status of this line is deduced): painter->drawPath(d->path); | - |
8261 | | - |
8262 | if (option->state & QStyle::State_Selected) never evaluated: option->state & QStyle::State_Selected | 0 |
8263 | qt_graphicsItem_highlightSelected(this, painter, option); never executed: qt_graphicsItem_highlightSelected(this, painter, option); | 0 |
8264 | } | 0 |
8265 | | - |
8266 | /*! | - |
8267 | \reimp | - |
8268 | */ | - |
8269 | bool QGraphicsPathItem::isObscuredBy(const QGraphicsItem *item) const | - |
8270 | { | - |
8271 | return QAbstractGraphicsShapeItem::isObscuredBy(item); never executed: return QAbstractGraphicsShapeItem::isObscuredBy(item); | 0 |
8272 | } | - |
8273 | | - |
8274 | /*! | - |
8275 | \reimp | - |
8276 | */ | - |
8277 | QPainterPath QGraphicsPathItem::opaqueArea() const | - |
8278 | { | - |
8279 | return QAbstractGraphicsShapeItem::opaqueArea(); never executed: return QAbstractGraphicsShapeItem::opaqueArea(); | 0 |
8280 | } | - |
8281 | | - |
8282 | /*! | - |
8283 | \reimp | - |
8284 | */ | - |
8285 | int QGraphicsPathItem::type() const | - |
8286 | { | - |
8287 | return Type; never executed: return Type; | 0 |
8288 | } | - |
8289 | | - |
8290 | /*! | - |
8291 | \internal | - |
8292 | */ | - |
8293 | bool QGraphicsPathItem::supportsExtension(Extension extension) const | - |
8294 | { | - |
8295 | Q_UNUSED(extension); never executed (the execution status of this line is deduced): (void)extension;; | - |
8296 | return false; never executed: return false; | 0 |
8297 | } | - |
8298 | | - |
8299 | /*! | - |
8300 | \internal | - |
8301 | */ | - |
8302 | void QGraphicsPathItem::setExtension(Extension extension, const QVariant &variant) | - |
8303 | { | - |
8304 | Q_UNUSED(extension); never executed (the execution status of this line is deduced): (void)extension;; | - |
8305 | Q_UNUSED(variant); never executed (the execution status of this line is deduced): (void)variant;; | - |
8306 | } | 0 |
8307 | | - |
8308 | /*! | - |
8309 | \internal | - |
8310 | */ | - |
8311 | QVariant QGraphicsPathItem::extension(const QVariant &variant) const | - |
8312 | { | - |
8313 | Q_UNUSED(variant); never executed (the execution status of this line is deduced): (void)variant;; | - |
8314 | return QVariant(); never executed: return QVariant(); | 0 |
8315 | } | - |
8316 | | - |
8317 | /*! | - |
8318 | \class QGraphicsRectItem | - |
8319 | \brief The QGraphicsRectItem class provides a rectangle item that you | - |
8320 | can add to a QGraphicsScene. | - |
8321 | \since 4.2 | - |
8322 | \ingroup graphicsview-api | - |
8323 | \inmodule QtWidgets | - |
8324 | | - |
8325 | To set the item's rectangle, pass a QRectF to QGraphicsRectItem's | - |
8326 | constructor, or call the setRect() function. The rect() function | - |
8327 | returns the current rectangle. | - |
8328 | | - |
8329 | \image graphicsview-rectitem.png | - |
8330 | | - |
8331 | QGraphicsRectItem uses the rectangle and the pen width to provide | - |
8332 | a reasonable implementation of boundingRect(), shape(), and | - |
8333 | contains(). The paint() function draws the rectangle using the | - |
8334 | item's associated pen and brush, which you can set by calling the | - |
8335 | setPen() and setBrush() functions. | - |
8336 | | - |
8337 | \note The rendering of invalid rectangles, such as those with negative | - |
8338 | widths or heights, is undefined. If you cannot be sure that you are | - |
8339 | using valid rectangles (for example, if you are creating | - |
8340 | rectangles using data from an unreliable source) then you should | - |
8341 | use QRectF::normalized() to create normalized rectangles, and use | - |
8342 | those instead. | - |
8343 | | - |
8344 | \sa QGraphicsPathItem, QGraphicsEllipseItem, QGraphicsPolygonItem, | - |
8345 | QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics | - |
8346 | View Framework} | - |
8347 | */ | - |
8348 | | - |
8349 | class QGraphicsRectItemPrivate : public QAbstractGraphicsShapeItemPrivate | - |
8350 | { | - |
8351 | Q_DECLARE_PUBLIC(QGraphicsRectItem) | - |
8352 | public: | - |
8353 | QRectF rect; | - |
8354 | }; | - |
8355 | | - |
8356 | /*! | - |
8357 | Constructs a QGraphicsRectItem, using \a rect as the default rectangle. | - |
8358 | \a parent is passed to QAbstractGraphicsShapeItem's constructor. | - |
8359 | | - |
8360 | \sa QGraphicsScene::addItem() | - |
8361 | */ | - |
8362 | QGraphicsRectItem::QGraphicsRectItem(const QRectF &rect, QGraphicsItem *parent) | - |
8363 | : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent) | - |
8364 | { | - |
8365 | setRect(rect); never executed (the execution status of this line is deduced): setRect(rect); | - |
8366 | } | 0 |
8367 | | - |
8368 | /*! | - |
8369 | \fn QGraphicsRectItem::QGraphicsRectItem(qreal x, qreal y, qreal width, qreal height, | - |
8370 | QGraphicsItem *parent) | - |
8371 | | - |
8372 | Constructs a QGraphicsRectItem with a default rectangle defined | - |
8373 | by (\a x, \a y) and the given \a width and \a height. | - |
8374 | | - |
8375 | \a parent is passed to QAbstractGraphicsShapeItem's constructor. | - |
8376 | | - |
8377 | \sa QGraphicsScene::addItem() | - |
8378 | */ | - |
8379 | QGraphicsRectItem::QGraphicsRectItem(qreal x, qreal y, qreal w, qreal h, | - |
8380 | QGraphicsItem *parent) | - |
8381 | : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent) | - |
8382 | { | - |
8383 | setRect(QRectF(x, y, w, h)); executed (the execution status of this line is deduced): setRect(QRectF(x, y, w, h)); | - |
8384 | } executed: } Execution Count:9 | 9 |
8385 | | - |
8386 | /*! | - |
8387 | Constructs a QGraphicsRectItem. \a parent is passed to | - |
8388 | QAbstractGraphicsShapeItem's constructor. | - |
8389 | | - |
8390 | \sa QGraphicsScene::addItem() | - |
8391 | */ | - |
8392 | QGraphicsRectItem::QGraphicsRectItem(QGraphicsItem *parent) | - |
8393 | : QAbstractGraphicsShapeItem(*new QGraphicsRectItemPrivate, parent) | - |
8394 | { | - |
8395 | } executed: } Execution Count:8 | 8 |
8396 | | - |
8397 | /*! | - |
8398 | Destroys the QGraphicsRectItem. | - |
8399 | */ | - |
8400 | QGraphicsRectItem::~QGraphicsRectItem() | - |
8401 | { | - |
8402 | } | - |
8403 | | - |
8404 | /*! | - |
8405 | Returns the item's rectangle. | - |
8406 | | - |
8407 | \sa setRect() | - |
8408 | */ | - |
8409 | QRectF QGraphicsRectItem::rect() const | - |
8410 | { | - |
8411 | Q_D(const QGraphicsRectItem); executed (the execution status of this line is deduced): const QGraphicsRectItemPrivate * const d = d_func(); | - |
8412 | return d->rect; executed: return d->rect; Execution Count:40 | 40 |
8413 | } | - |
8414 | | - |
8415 | /*! | - |
8416 | \fn void QGraphicsRectItem::setRect(const QRectF &rectangle) | - |
8417 | | - |
8418 | Sets the item's rectangle to be the given \a rectangle. | - |
8419 | | - |
8420 | \sa rect() | - |
8421 | */ | - |
8422 | void QGraphicsRectItem::setRect(const QRectF &rect) | - |
8423 | { | - |
8424 | Q_D(QGraphicsRectItem); executed (the execution status of this line is deduced): QGraphicsRectItemPrivate * const d = d_func(); | - |
8425 | if (d->rect == rect) evaluated: d->rect == rect yes Evaluation Count:3 | yes Evaluation Count:91 |
| 3-91 |
8426 | return; executed: return; Execution Count:3 | 3 |
8427 | prepareGeometryChange(); executed (the execution status of this line is deduced): prepareGeometryChange(); | - |
8428 | d->rect = rect; executed (the execution status of this line is deduced): d->rect = rect; | - |
8429 | d->boundingRect = QRectF(); executed (the execution status of this line is deduced): d->boundingRect = QRectF(); | - |
8430 | update(); executed (the execution status of this line is deduced): update(); | - |
8431 | } executed: } Execution Count:91 | 91 |
8432 | | - |
8433 | /*! | - |
8434 | \fn void QGraphicsRectItem::setRect(qreal x, qreal y, qreal width, qreal height) | - |
8435 | \fn void QGraphicsEllipseItem::setRect(qreal x, qreal y, qreal width, qreal height) | - |
8436 | | - |
8437 | Sets the item's rectangle to the rectangle defined by (\a x, \a y) | - |
8438 | and the given \a width and \a height. | - |
8439 | | - |
8440 | This convenience function is equivalent to calling \c | - |
8441 | {setRect(QRectF(x, y, width, height))} | - |
8442 | | - |
8443 | \sa rect() | - |
8444 | */ | - |
8445 | | - |
8446 | /*! | - |
8447 | \reimp | - |
8448 | */ | - |
8449 | QRectF QGraphicsRectItem::boundingRect() const | - |
8450 | { | - |
8451 | Q_D(const QGraphicsRectItem); executed (the execution status of this line is deduced): const QGraphicsRectItemPrivate * const d = d_func(); | - |
8452 | if (d->boundingRect.isNull()) { evaluated: d->boundingRect.isNull() yes Evaluation Count:105 | yes Evaluation Count:563 |
| 105-563 |
8453 | qreal halfpw = pen().style() == Qt::NoPen ? qreal(0) : pen().widthF() / 2; evaluated: pen().style() == Qt::NoPen yes Evaluation Count:3 | yes Evaluation Count:102 |
| 3-102 |
8454 | d->boundingRect = d->rect; executed (the execution status of this line is deduced): d->boundingRect = d->rect; | - |
8455 | if (halfpw > 0.0) evaluated: halfpw > 0.0 yes Evaluation Count:90 | yes Evaluation Count:15 |
| 15-90 |
8456 | d->boundingRect.adjust(-halfpw, -halfpw, halfpw, halfpw); executed: d->boundingRect.adjust(-halfpw, -halfpw, halfpw, halfpw); Execution Count:90 | 90 |
8457 | } executed: } Execution Count:105 | 105 |
8458 | return d->boundingRect; executed: return d->boundingRect; Execution Count:668 | 668 |
8459 | } | - |
8460 | | - |
8461 | /*! | - |
8462 | \reimp | - |
8463 | */ | - |
8464 | QPainterPath QGraphicsRectItem::shape() const | - |
8465 | { | - |
8466 | Q_D(const QGraphicsRectItem); executed (the execution status of this line is deduced): const QGraphicsRectItemPrivate * const d = d_func(); | - |
8467 | QPainterPath path; executed (the execution status of this line is deduced): QPainterPath path; | - |
8468 | path.addRect(d->rect); executed (the execution status of this line is deduced): path.addRect(d->rect); | - |
8469 | return qt_graphicsItem_shapeFromPath(path, d->pen); executed: return qt_graphicsItem_shapeFromPath(path, d->pen); Execution Count:2 | 2 |
8470 | } | - |
8471 | | - |
8472 | /*! | - |
8473 | \reimp | - |
8474 | */ | - |
8475 | bool QGraphicsRectItem::contains(const QPointF &point) const | - |
8476 | { | - |
8477 | return QAbstractGraphicsShapeItem::contains(point); never executed: return QAbstractGraphicsShapeItem::contains(point); | 0 |
8478 | } | - |
8479 | | - |
8480 | /*! | - |
8481 | \reimp | - |
8482 | */ | - |
8483 | void QGraphicsRectItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, | - |
8484 | QWidget *widget) | - |
8485 | { | - |
8486 | Q_D(QGraphicsRectItem); executed (the execution status of this line is deduced): QGraphicsRectItemPrivate * const d = d_func(); | - |
8487 | Q_UNUSED(widget); executed (the execution status of this line is deduced): (void)widget;; | - |
8488 | painter->setPen(d->pen); executed (the execution status of this line is deduced): painter->setPen(d->pen); | - |
8489 | painter->setBrush(d->brush); executed (the execution status of this line is deduced): painter->setBrush(d->brush); | - |
8490 | painter->drawRect(d->rect); executed (the execution status of this line is deduced): painter->drawRect(d->rect); | - |
8491 | | - |
8492 | if (option->state & QStyle::State_Selected) partially evaluated: option->state & QStyle::State_Selected no Evaluation Count:0 | yes Evaluation Count:107 |
| 0-107 |
8493 | qt_graphicsItem_highlightSelected(this, painter, option); never executed: qt_graphicsItem_highlightSelected(this, painter, option); | 0 |
8494 | } executed: } Execution Count:107 | 107 |
8495 | | - |
8496 | /*! | - |
8497 | \reimp | - |
8498 | */ | - |
8499 | bool QGraphicsRectItem::isObscuredBy(const QGraphicsItem *item) const | - |
8500 | { | - |
8501 | return QAbstractGraphicsShapeItem::isObscuredBy(item); never executed: return QAbstractGraphicsShapeItem::isObscuredBy(item); | 0 |
8502 | } | - |
8503 | | - |
8504 | /*! | - |
8505 | \reimp | - |
8506 | */ | - |
8507 | QPainterPath QGraphicsRectItem::opaqueArea() const | - |
8508 | { | - |
8509 | return QAbstractGraphicsShapeItem::opaqueArea(); never executed: return QAbstractGraphicsShapeItem::opaqueArea(); | 0 |
8510 | } | - |
8511 | | - |
8512 | /*! | - |
8513 | \reimp | - |
8514 | */ | - |
8515 | int QGraphicsRectItem::type() const | - |
8516 | { | - |
8517 | return Type; executed: return Type; Execution Count:4 | 4 |
8518 | } | - |
8519 | | - |
8520 | /*! | - |
8521 | \internal | - |
8522 | */ | - |
8523 | bool QGraphicsRectItem::supportsExtension(Extension extension) const | - |
8524 | { | - |
8525 | Q_UNUSED(extension); never executed (the execution status of this line is deduced): (void)extension;; | - |
8526 | return false; never executed: return false; | 0 |
8527 | } | - |
8528 | | - |
8529 | /*! | - |
8530 | \internal | - |
8531 | */ | - |
8532 | void QGraphicsRectItem::setExtension(Extension extension, const QVariant &variant) | - |
8533 | { | - |
8534 | Q_UNUSED(extension); never executed (the execution status of this line is deduced): (void)extension;; | - |
8535 | Q_UNUSED(variant); never executed (the execution status of this line is deduced): (void)variant;; | - |
8536 | } | 0 |
8537 | | - |
8538 | /*! | - |
8539 | \internal | - |
8540 | */ | - |
8541 | QVariant QGraphicsRectItem::extension(const QVariant &variant) const | - |
8542 | { | - |
8543 | Q_UNUSED(variant); never executed (the execution status of this line is deduced): (void)variant;; | - |
8544 | return QVariant(); never executed: return QVariant(); | 0 |
8545 | } | - |
8546 | | - |
8547 | /*! | - |
8548 | \class QGraphicsEllipseItem | - |
8549 | \brief The QGraphicsEllipseItem class provides an ellipse item that you | - |
8550 | can add to a QGraphicsScene. | - |
8551 | \since 4.2 | - |
8552 | \ingroup graphicsview-api | - |
8553 | \inmodule QtWidgets | - |
8554 | | - |
8555 | QGraphicsEllipseItem respresents an ellipse with a fill and an outline, | - |
8556 | and you can also use it for ellipse segments (see startAngle(), | - |
8557 | spanAngle()). | - |
8558 | | - |
8559 | \table | - |
8560 | \row | - |
8561 | \li \inlineimage graphicsview-ellipseitem.png | - |
8562 | \li \inlineimage graphicsview-ellipseitem-pie.png | - |
8563 | \endtable | - |
8564 | | - |
8565 | To set the item's ellipse, pass a QRectF to QGraphicsEllipseItem's | - |
8566 | constructor, or call setRect(). The rect() function returns the | - |
8567 | current ellipse geometry. | - |
8568 | | - |
8569 | QGraphicsEllipseItem uses the rect and the pen width to provide a | - |
8570 | reasonable implementation of boundingRect(), shape(), and contains(). The | - |
8571 | paint() function draws the ellipse using the item's associated pen and | - |
8572 | brush, which you can set by calling setPen() and setBrush(). | - |
8573 | | - |
8574 | \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsPolygonItem, | - |
8575 | QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics | - |
8576 | View Framework} | - |
8577 | */ | - |
8578 | | - |
8579 | class QGraphicsEllipseItemPrivate : public QAbstractGraphicsShapeItemPrivate | - |
8580 | { | - |
8581 | Q_DECLARE_PUBLIC(QGraphicsEllipseItem) | - |
8582 | public: | - |
8583 | inline QGraphicsEllipseItemPrivate() | - |
8584 | : startAngle(0), spanAngle(360 * 16) | - |
8585 | { } | 0 |
8586 | | - |
8587 | QRectF rect; | - |
8588 | int startAngle; | - |
8589 | int spanAngle; | - |
8590 | }; | - |
8591 | | - |
8592 | /*! | - |
8593 | Constructs a QGraphicsEllipseItem using \a rect as the default rectangle. | - |
8594 | \a parent is passed to QAbstractGraphicsShapeItem's constructor. | - |
8595 | | - |
8596 | \sa QGraphicsScene::addItem() | - |
8597 | */ | - |
8598 | QGraphicsEllipseItem::QGraphicsEllipseItem(const QRectF &rect, QGraphicsItem *parent) | - |
8599 | : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent) | - |
8600 | { | - |
8601 | setRect(rect); never executed (the execution status of this line is deduced): setRect(rect); | - |
8602 | } | 0 |
8603 | | - |
8604 | /*! | - |
8605 | \fn QGraphicsEllipseItem::QGraphicsEllipseItem(qreal x, qreal y, qreal width, qreal height, QGraphicsItem *parent) | - |
8606 | \since 4.3 | - |
8607 | | - |
8608 | Constructs a QGraphicsEllipseItem using the rectangle defined by (\a x, \a | - |
8609 | y) and the given \a width and \a height, as the default rectangle. \a | - |
8610 | parent is passed to QAbstractGraphicsShapeItem's constructor. | - |
8611 | | - |
8612 | \sa QGraphicsScene::addItem() | - |
8613 | */ | - |
8614 | QGraphicsEllipseItem::QGraphicsEllipseItem(qreal x, qreal y, qreal w, qreal h, | - |
8615 | QGraphicsItem *parent) | - |
8616 | : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent) | - |
8617 | { | - |
8618 | setRect(x,y,w,h); never executed (the execution status of this line is deduced): setRect(x,y,w,h); | - |
8619 | } | 0 |
8620 | | - |
8621 | | - |
8622 | | - |
8623 | /*! | - |
8624 | Constructs a QGraphicsEllipseItem. \a parent is passed to | - |
8625 | QAbstractGraphicsShapeItem's constructor. | - |
8626 | | - |
8627 | \sa QGraphicsScene::addItem() | - |
8628 | */ | - |
8629 | QGraphicsEllipseItem::QGraphicsEllipseItem(QGraphicsItem *parent) | - |
8630 | : QAbstractGraphicsShapeItem(*new QGraphicsEllipseItemPrivate, parent) | - |
8631 | { | - |
8632 | } | 0 |
8633 | | - |
8634 | /*! | - |
8635 | Destroys the QGraphicsEllipseItem. | - |
8636 | */ | - |
8637 | QGraphicsEllipseItem::~QGraphicsEllipseItem() | - |
8638 | { | - |
8639 | } | - |
8640 | | - |
8641 | /*! | - |
8642 | Returns the item's ellipse geometry as a QRectF. | - |
8643 | | - |
8644 | \sa setRect(), QPainter::drawEllipse() | - |
8645 | */ | - |
8646 | QRectF QGraphicsEllipseItem::rect() const | - |
8647 | { | - |
8648 | Q_D(const QGraphicsEllipseItem); never executed (the execution status of this line is deduced): const QGraphicsEllipseItemPrivate * const d = d_func(); | - |
8649 | return d->rect; never executed: return d->rect; | 0 |
8650 | } | - |
8651 | | - |
8652 | /*! | - |
8653 | Sets the item's ellipse geometry to \a rect. The rectangle's left edge | - |
8654 | defines the left edge of the ellipse, and the rectangle's top edge | - |
8655 | describes the top of the ellipse. The height and width of the rectangle | - |
8656 | describe the height and width of the ellipse. | - |
8657 | | - |
8658 | \sa rect(), QPainter::drawEllipse() | - |
8659 | */ | - |
8660 | void QGraphicsEllipseItem::setRect(const QRectF &rect) | - |
8661 | { | - |
8662 | Q_D(QGraphicsEllipseItem); never executed (the execution status of this line is deduced): QGraphicsEllipseItemPrivate * const d = d_func(); | - |
8663 | if (d->rect == rect) never evaluated: d->rect == rect | 0 |
8664 | return; | 0 |
8665 | prepareGeometryChange(); never executed (the execution status of this line is deduced): prepareGeometryChange(); | - |
8666 | d->rect = rect; never executed (the execution status of this line is deduced): d->rect = rect; | - |
8667 | d->boundingRect = QRectF(); never executed (the execution status of this line is deduced): d->boundingRect = QRectF(); | - |
8668 | update(); never executed (the execution status of this line is deduced): update(); | - |
8669 | } | 0 |
8670 | | - |
8671 | /*! | - |
8672 | Returns the start angle for an ellipse segment in 16ths of a degree. This | - |
8673 | angle is used together with spanAngle() for representing an ellipse | - |
8674 | segment (a pie). By default, the start angle is 0. | - |
8675 | | - |
8676 | \sa setStartAngle(), spanAngle() | - |
8677 | */ | - |
8678 | int QGraphicsEllipseItem::startAngle() const | - |
8679 | { | - |
8680 | Q_D(const QGraphicsEllipseItem); never executed (the execution status of this line is deduced): const QGraphicsEllipseItemPrivate * const d = d_func(); | - |
8681 | return d->startAngle; never executed: return d->startAngle; | 0 |
8682 | } | - |
8683 | | - |
8684 | /*! | - |
8685 | Sets the start angle for an ellipse segment to \a angle, which is in 16ths | - |
8686 | of a degree. This angle is used together with spanAngle() for representing | - |
8687 | an ellipse segment (a pie). By default, the start angle is 0. | - |
8688 | | - |
8689 | \sa startAngle(), setSpanAngle(), QPainter::drawPie() | - |
8690 | */ | - |
8691 | void QGraphicsEllipseItem::setStartAngle(int angle) | - |
8692 | { | - |
8693 | Q_D(QGraphicsEllipseItem); never executed (the execution status of this line is deduced): QGraphicsEllipseItemPrivate * const d = d_func(); | - |
8694 | if (angle != d->startAngle) { never evaluated: angle != d->startAngle | 0 |
8695 | prepareGeometryChange(); never executed (the execution status of this line is deduced): prepareGeometryChange(); | - |
8696 | d->boundingRect = QRectF(); never executed (the execution status of this line is deduced): d->boundingRect = QRectF(); | - |
8697 | d->startAngle = angle; never executed (the execution status of this line is deduced): d->startAngle = angle; | - |
8698 | update(); never executed (the execution status of this line is deduced): update(); | - |
8699 | } | 0 |
8700 | } | 0 |
8701 | | - |
8702 | /*! | - |
8703 | Returns the span angle of an ellipse segment in 16ths of a degree. This | - |
8704 | angle is used together with startAngle() for representing an ellipse | - |
8705 | segment (a pie). By default, this function returns 5760 (360 * 16, a full | - |
8706 | ellipse). | - |
8707 | | - |
8708 | \sa setSpanAngle(), startAngle() | - |
8709 | */ | - |
8710 | int QGraphicsEllipseItem::spanAngle() const | - |
8711 | { | - |
8712 | Q_D(const QGraphicsEllipseItem); never executed (the execution status of this line is deduced): const QGraphicsEllipseItemPrivate * const d = d_func(); | - |
8713 | return d->spanAngle; never executed: return d->spanAngle; | 0 |
8714 | } | - |
8715 | | - |
8716 | /*! | - |
8717 | Sets the span angle for an ellipse segment to \a angle, which is in 16ths | - |
8718 | of a degree. This angle is used together with startAngle() to represent an | - |
8719 | ellipse segment (a pie). By default, the span angle is 5760 (360 * 16, a | - |
8720 | full ellipse). | - |
8721 | | - |
8722 | \sa spanAngle(), setStartAngle(), QPainter::drawPie() | - |
8723 | */ | - |
8724 | void QGraphicsEllipseItem::setSpanAngle(int angle) | - |
8725 | { | - |
8726 | Q_D(QGraphicsEllipseItem); never executed (the execution status of this line is deduced): QGraphicsEllipseItemPrivate * const d = d_func(); | - |
8727 | if (angle != d->spanAngle) { never evaluated: angle != d->spanAngle | 0 |
8728 | prepareGeometryChange(); never executed (the execution status of this line is deduced): prepareGeometryChange(); | - |
8729 | d->boundingRect = QRectF(); never executed (the execution status of this line is deduced): d->boundingRect = QRectF(); | - |
8730 | d->spanAngle = angle; never executed (the execution status of this line is deduced): d->spanAngle = angle; | - |
8731 | update(); never executed (the execution status of this line is deduced): update(); | - |
8732 | } | 0 |
8733 | } | 0 |
8734 | | - |
8735 | /*! | - |
8736 | \reimp | - |
8737 | */ | - |
8738 | QRectF QGraphicsEllipseItem::boundingRect() const | - |
8739 | { | - |
8740 | Q_D(const QGraphicsEllipseItem); never executed (the execution status of this line is deduced): const QGraphicsEllipseItemPrivate * const d = d_func(); | - |
8741 | if (d->boundingRect.isNull()) { never evaluated: d->boundingRect.isNull() | 0 |
8742 | qreal pw = pen().style() == Qt::NoPen ? qreal(0) : pen().widthF(); never evaluated: pen().style() == Qt::NoPen | 0 |
8743 | if (pw == 0.0 && d->spanAngle == 360 * 16) never evaluated: pw == 0.0 never evaluated: d->spanAngle == 360 * 16 | 0 |
8744 | d->boundingRect = d->rect; never executed: d->boundingRect = d->rect; | 0 |
8745 | else | - |
8746 | d->boundingRect = shape().controlPointRect(); never executed: d->boundingRect = shape().controlPointRect(); | 0 |
8747 | } | - |
8748 | return d->boundingRect; never executed: return d->boundingRect; | 0 |
8749 | } | - |
8750 | | - |
8751 | /*! | - |
8752 | \reimp | - |
8753 | */ | - |
8754 | QPainterPath QGraphicsEllipseItem::shape() const | - |
8755 | { | - |
8756 | Q_D(const QGraphicsEllipseItem); never executed (the execution status of this line is deduced): const QGraphicsEllipseItemPrivate * const d = d_func(); | - |
8757 | QPainterPath path; never executed (the execution status of this line is deduced): QPainterPath path; | - |
8758 | if (d->rect.isNull()) never evaluated: d->rect.isNull() | 0 |
8759 | return path; never executed: return path; | 0 |
8760 | if (d->spanAngle != 360 * 16) { never evaluated: d->spanAngle != 360 * 16 | 0 |
8761 | path.moveTo(d->rect.center()); never executed (the execution status of this line is deduced): path.moveTo(d->rect.center()); | - |
8762 | path.arcTo(d->rect, d->startAngle / 16.0, d->spanAngle / 16.0); never executed (the execution status of this line is deduced): path.arcTo(d->rect, d->startAngle / 16.0, d->spanAngle / 16.0); | - |
8763 | } else { | 0 |
8764 | path.addEllipse(d->rect); never executed (the execution status of this line is deduced): path.addEllipse(d->rect); | - |
8765 | } | 0 |
8766 | | - |
8767 | return qt_graphicsItem_shapeFromPath(path, d->pen); never executed: return qt_graphicsItem_shapeFromPath(path, d->pen); | 0 |
8768 | } | - |
8769 | | - |
8770 | /*! | - |
8771 | \reimp | - |
8772 | */ | - |
8773 | bool QGraphicsEllipseItem::contains(const QPointF &point) const | - |
8774 | { | - |
8775 | return QAbstractGraphicsShapeItem::contains(point); never executed: return QAbstractGraphicsShapeItem::contains(point); | 0 |
8776 | } | - |
8777 | | - |
8778 | /*! | - |
8779 | \reimp | - |
8780 | */ | - |
8781 | void QGraphicsEllipseItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, | - |
8782 | QWidget *widget) | - |
8783 | { | - |
8784 | Q_D(QGraphicsEllipseItem); never executed (the execution status of this line is deduced): QGraphicsEllipseItemPrivate * const d = d_func(); | - |
8785 | Q_UNUSED(widget); never executed (the execution status of this line is deduced): (void)widget;; | - |
8786 | painter->setPen(d->pen); never executed (the execution status of this line is deduced): painter->setPen(d->pen); | - |
8787 | painter->setBrush(d->brush); never executed (the execution status of this line is deduced): painter->setBrush(d->brush); | - |
8788 | if ((d->spanAngle != 0) && (qAbs(d->spanAngle) % (360 * 16) == 0)) never evaluated: (d->spanAngle != 0) never evaluated: (qAbs(d->spanAngle) % (360 * 16) == 0) | 0 |
8789 | painter->drawEllipse(d->rect); never executed: painter->drawEllipse(d->rect); | 0 |
8790 | else | - |
8791 | painter->drawPie(d->rect, d->startAngle, d->spanAngle); never executed: painter->drawPie(d->rect, d->startAngle, d->spanAngle); | 0 |
8792 | | - |
8793 | if (option->state & QStyle::State_Selected) never evaluated: option->state & QStyle::State_Selected | 0 |
8794 | qt_graphicsItem_highlightSelected(this, painter, option); never executed: qt_graphicsItem_highlightSelected(this, painter, option); | 0 |
8795 | } | 0 |
8796 | | - |
8797 | /*! | - |
8798 | \reimp | - |
8799 | */ | - |
8800 | bool QGraphicsEllipseItem::isObscuredBy(const QGraphicsItem *item) const | - |
8801 | { | - |
8802 | return QAbstractGraphicsShapeItem::isObscuredBy(item); never executed: return QAbstractGraphicsShapeItem::isObscuredBy(item); | 0 |
8803 | } | - |
8804 | | - |
8805 | /*! | - |
8806 | \reimp | - |
8807 | */ | - |
8808 | QPainterPath QGraphicsEllipseItem::opaqueArea() const | - |
8809 | { | - |
8810 | return QAbstractGraphicsShapeItem::opaqueArea(); never executed: return QAbstractGraphicsShapeItem::opaqueArea(); | 0 |
8811 | } | - |
8812 | | - |
8813 | /*! | - |
8814 | \reimp | - |
8815 | */ | - |
8816 | int QGraphicsEllipseItem::type() const | - |
8817 | { | - |
8818 | return Type; never executed: return Type; | 0 |
8819 | } | - |
8820 | | - |
8821 | | - |
8822 | /*! | - |
8823 | \internal | - |
8824 | */ | - |
8825 | bool QGraphicsEllipseItem::supportsExtension(Extension extension) const | - |
8826 | { | - |
8827 | Q_UNUSED(extension); never executed (the execution status of this line is deduced): (void)extension;; | - |
8828 | return false; never executed: return false; | 0 |
8829 | } | - |
8830 | | - |
8831 | /*! | - |
8832 | \internal | - |
8833 | */ | - |
8834 | void QGraphicsEllipseItem::setExtension(Extension extension, const QVariant &variant) | - |
8835 | { | - |
8836 | Q_UNUSED(extension); never executed (the execution status of this line is deduced): (void)extension;; | - |
8837 | Q_UNUSED(variant); never executed (the execution status of this line is deduced): (void)variant;; | - |
8838 | } | 0 |
8839 | | - |
8840 | /*! | - |
8841 | \internal | - |
8842 | */ | - |
8843 | QVariant QGraphicsEllipseItem::extension(const QVariant &variant) const | - |
8844 | { | - |
8845 | Q_UNUSED(variant); never executed (the execution status of this line is deduced): (void)variant;; | - |
8846 | return QVariant(); never executed: return QVariant(); | 0 |
8847 | } | - |
8848 | | - |
8849 | /*! | - |
8850 | \class QGraphicsPolygonItem | - |
8851 | \brief The QGraphicsPolygonItem class provides a polygon item that you | - |
8852 | can add to a QGraphicsScene. | - |
8853 | \since 4.2 | - |
8854 | \ingroup graphicsview-api | - |
8855 | \inmodule QtWidgets | - |
8856 | | - |
8857 | To set the item's polygon, pass a QPolygonF to | - |
8858 | QGraphicsPolygonItem's constructor, or call the setPolygon() | - |
8859 | function. The polygon() function returns the current polygon. | - |
8860 | | - |
8861 | \image graphicsview-polygonitem.png | - |
8862 | | - |
8863 | QGraphicsPolygonItem uses the polygon and the pen width to provide | - |
8864 | a reasonable implementation of boundingRect(), shape(), and | - |
8865 | contains(). The paint() function draws the polygon using the | - |
8866 | item's associated pen and brush, which you can set by calling the | - |
8867 | setPen() and setBrush() functions. | - |
8868 | | - |
8869 | \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, | - |
8870 | QGraphicsTextItem, QGraphicsLineItem, QGraphicsPixmapItem, {Graphics | - |
8871 | View Framework} | - |
8872 | */ | - |
8873 | | - |
8874 | class QGraphicsPolygonItemPrivate : public QAbstractGraphicsShapeItemPrivate | - |
8875 | { | - |
8876 | Q_DECLARE_PUBLIC(QGraphicsPolygonItem) | - |
8877 | public: | - |
8878 | inline QGraphicsPolygonItemPrivate() | - |
8879 | : fillRule(Qt::OddEvenFill) | - |
8880 | { } executed: } Execution Count:15 | 15 |
8881 | | - |
8882 | QPolygonF polygon; | - |
8883 | Qt::FillRule fillRule; | - |
8884 | }; | - |
8885 | | - |
8886 | /*! | - |
8887 | Constructs a QGraphicsPolygonItem with \a polygon as the default | - |
8888 | polygon. \a parent is passed to QAbstractGraphicsShapeItem's constructor. | - |
8889 | | - |
8890 | \sa QGraphicsScene::addItem() | - |
8891 | */ | - |
8892 | QGraphicsPolygonItem::QGraphicsPolygonItem(const QPolygonF &polygon, QGraphicsItem *parent) | - |
8893 | : QAbstractGraphicsShapeItem(*new QGraphicsPolygonItemPrivate, parent) | - |
8894 | { | - |
8895 | setPolygon(polygon); executed (the execution status of this line is deduced): setPolygon(polygon); | - |
8896 | } executed: } Execution Count:8 | 8 |
8897 | | - |
8898 | /*! | - |
8899 | Constructs a QGraphicsPolygonItem. \a parent is passed to | - |
8900 | QAbstractGraphicsShapeItem's constructor. | - |
8901 | | - |
8902 | \sa QGraphicsScene::addItem() | - |
8903 | */ | - |
8904 | QGraphicsPolygonItem::QGraphicsPolygonItem(QGraphicsItem *parent) | - |
8905 | : QAbstractGraphicsShapeItem(*new QGraphicsPolygonItemPrivate, parent) | - |
8906 | { | - |
8907 | } executed: } Execution Count:7 | 7 |
8908 | | - |
8909 | /*! | - |
8910 | Destroys the QGraphicsPolygonItem. | - |
8911 | */ | - |
8912 | QGraphicsPolygonItem::~QGraphicsPolygonItem() | - |
8913 | { | - |
8914 | } | - |
8915 | | - |
8916 | /*! | - |
8917 | Returns the item's polygon, or an empty polygon if no polygon | - |
8918 | has been set. | - |
8919 | | - |
8920 | \sa setPolygon() | - |
8921 | */ | - |
8922 | QPolygonF QGraphicsPolygonItem::polygon() const | - |
8923 | { | - |
8924 | Q_D(const QGraphicsPolygonItem); executed (the execution status of this line is deduced): const QGraphicsPolygonItemPrivate * const d = d_func(); | - |
8925 | return d->polygon; executed: return d->polygon; Execution Count:3 | 3 |
8926 | } | - |
8927 | | - |
8928 | /*! | - |
8929 | Sets the item's polygon to be the given \a polygon. | - |
8930 | | - |
8931 | \sa polygon() | - |
8932 | */ | - |
8933 | void QGraphicsPolygonItem::setPolygon(const QPolygonF &polygon) | - |
8934 | { | - |
8935 | Q_D(QGraphicsPolygonItem); executed (the execution status of this line is deduced): QGraphicsPolygonItemPrivate * const d = d_func(); | - |
8936 | if (d->polygon == polygon) evaluated: d->polygon == polygon yes Evaluation Count:9 | yes Evaluation Count:2 |
| 2-9 |
8937 | return; executed: return; Execution Count:9 | 9 |
8938 | prepareGeometryChange(); executed (the execution status of this line is deduced): prepareGeometryChange(); | - |
8939 | d->polygon = polygon; executed (the execution status of this line is deduced): d->polygon = polygon; | - |
8940 | d->boundingRect = QRectF(); executed (the execution status of this line is deduced): d->boundingRect = QRectF(); | - |
8941 | update(); executed (the execution status of this line is deduced): update(); | - |
8942 | } executed: } Execution Count:2 | 2 |
8943 | | - |
8944 | /*! | - |
8945 | Returns the fill rule of the polygon. The default fill rule is | - |
8946 | Qt::OddEvenFill. | - |
8947 | | - |
8948 | \sa setFillRule(), QPainterPath::fillRule(), QPainter::drawPolygon() | - |
8949 | */ | - |
8950 | Qt::FillRule QGraphicsPolygonItem::fillRule() const | - |
8951 | { | - |
8952 | Q_D(const QGraphicsPolygonItem); executed (the execution status of this line is deduced): const QGraphicsPolygonItemPrivate * const d = d_func(); | - |
8953 | return d->fillRule; executed: return d->fillRule; Execution Count:3 | 3 |
8954 | } | - |
8955 | | - |
8956 | /*! | - |
8957 | Sets the fill rule of the polygon to \a rule. The default fill rule is | - |
8958 | Qt::OddEvenFill. | - |
8959 | | - |
8960 | \sa fillRule(), QPainterPath::fillRule(), QPainter::drawPolygon() | - |
8961 | */ | - |
8962 | void QGraphicsPolygonItem::setFillRule(Qt::FillRule rule) | - |
8963 | { | - |
8964 | Q_D(QGraphicsPolygonItem); executed (the execution status of this line is deduced): QGraphicsPolygonItemPrivate * const d = d_func(); | - |
8965 | if (rule != d->fillRule) { evaluated: rule != d->fillRule yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
8966 | d->fillRule = rule; executed (the execution status of this line is deduced): d->fillRule = rule; | - |
8967 | update(); executed (the execution status of this line is deduced): update(); | - |
8968 | } executed: } Execution Count:1 | 1 |
8969 | } executed: } Execution Count:3 | 3 |
8970 | | - |
8971 | /*! | - |
8972 | \reimp | - |
8973 | */ | - |
8974 | QRectF QGraphicsPolygonItem::boundingRect() const | - |
8975 | { | - |
8976 | Q_D(const QGraphicsPolygonItem); executed (the execution status of this line is deduced): const QGraphicsPolygonItemPrivate * const d = d_func(); | - |
8977 | if (d->boundingRect.isNull()) { partially evaluated: d->boundingRect.isNull() yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
8978 | qreal pw = pen().style() == Qt::NoPen ? qreal(0) : pen().widthF(); partially evaluated: pen().style() == Qt::NoPen no Evaluation Count:0 | yes Evaluation Count:3 |
| 0-3 |
8979 | if (pw == 0.0) evaluated: pw == 0.0 yes Evaluation Count:2 | yes Evaluation Count:1 |
| 1-2 |
8980 | d->boundingRect = d->polygon.boundingRect(); executed: d->boundingRect = d->polygon.boundingRect(); Execution Count:2 | 2 |
8981 | else | - |
8982 | d->boundingRect = shape().controlPointRect(); executed: d->boundingRect = shape().controlPointRect(); Execution Count:1 | 1 |
8983 | } | - |
8984 | return d->boundingRect; executed: return d->boundingRect; Execution Count:3 | 3 |
8985 | } | - |
8986 | | - |
8987 | /*! | - |
8988 | \reimp | - |
8989 | */ | - |
8990 | QPainterPath QGraphicsPolygonItem::shape() const | - |
8991 | { | - |
8992 | Q_D(const QGraphicsPolygonItem); executed (the execution status of this line is deduced): const QGraphicsPolygonItemPrivate * const d = d_func(); | - |
8993 | QPainterPath path; executed (the execution status of this line is deduced): QPainterPath path; | - |
8994 | path.addPolygon(d->polygon); executed (the execution status of this line is deduced): path.addPolygon(d->polygon); | - |
8995 | return qt_graphicsItem_shapeFromPath(path, d->pen); executed: return qt_graphicsItem_shapeFromPath(path, d->pen); Execution Count:5 | 5 |
8996 | } | - |
8997 | | - |
8998 | /*! | - |
8999 | \reimp | - |
9000 | */ | - |
9001 | bool QGraphicsPolygonItem::contains(const QPointF &point) const | - |
9002 | { | - |
9003 | return QAbstractGraphicsShapeItem::contains(point); executed: return QAbstractGraphicsShapeItem::contains(point); Execution Count:2 | 2 |
9004 | } | - |
9005 | | - |
9006 | /*! | - |
9007 | \reimp | - |
9008 | */ | - |
9009 | void QGraphicsPolygonItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | - |
9010 | { | - |
9011 | Q_D(QGraphicsPolygonItem); never executed (the execution status of this line is deduced): QGraphicsPolygonItemPrivate * const d = d_func(); | - |
9012 | Q_UNUSED(widget); never executed (the execution status of this line is deduced): (void)widget;; | - |
9013 | painter->setPen(d->pen); never executed (the execution status of this line is deduced): painter->setPen(d->pen); | - |
9014 | painter->setBrush(d->brush); never executed (the execution status of this line is deduced): painter->setBrush(d->brush); | - |
9015 | painter->drawPolygon(d->polygon, d->fillRule); never executed (the execution status of this line is deduced): painter->drawPolygon(d->polygon, d->fillRule); | - |
9016 | | - |
9017 | if (option->state & QStyle::State_Selected) never evaluated: option->state & QStyle::State_Selected | 0 |
9018 | qt_graphicsItem_highlightSelected(this, painter, option); never executed: qt_graphicsItem_highlightSelected(this, painter, option); | 0 |
9019 | } | 0 |
9020 | | - |
9021 | /*! | - |
9022 | \reimp | - |
9023 | */ | - |
9024 | bool QGraphicsPolygonItem::isObscuredBy(const QGraphicsItem *item) const | - |
9025 | { | - |
9026 | return QAbstractGraphicsShapeItem::isObscuredBy(item); executed: return QAbstractGraphicsShapeItem::isObscuredBy(item); Execution Count:2 | 2 |
9027 | } | - |
9028 | | - |
9029 | /*! | - |
9030 | \reimp | - |
9031 | */ | - |
9032 | QPainterPath QGraphicsPolygonItem::opaqueArea() const | - |
9033 | { | - |
9034 | return QAbstractGraphicsShapeItem::opaqueArea(); executed: return QAbstractGraphicsShapeItem::opaqueArea(); Execution Count:2 | 2 |
9035 | } | - |
9036 | | - |
9037 | /*! | - |
9038 | \reimp | - |
9039 | */ | - |
9040 | int QGraphicsPolygonItem::type() const | - |
9041 | { | - |
9042 | return Type; executed: return Type; Execution Count:1 | 1 |
9043 | } | - |
9044 | | - |
9045 | /*! | - |
9046 | \internal | - |
9047 | */ | - |
9048 | bool QGraphicsPolygonItem::supportsExtension(Extension extension) const | - |
9049 | { | - |
9050 | Q_UNUSED(extension); executed (the execution status of this line is deduced): (void)extension;; | - |
9051 | return false; executed: return false; Execution Count:2 | 2 |
9052 | } | - |
9053 | | - |
9054 | /*! | - |
9055 | \internal | - |
9056 | */ | - |
9057 | void QGraphicsPolygonItem::setExtension(Extension extension, const QVariant &variant) | - |
9058 | { | - |
9059 | Q_UNUSED(extension); executed (the execution status of this line is deduced): (void)extension;; | - |
9060 | Q_UNUSED(variant); executed (the execution status of this line is deduced): (void)variant;; | - |
9061 | } executed: } Execution Count:2 | 2 |
9062 | | - |
9063 | /*! | - |
9064 | \internal | - |
9065 | */ | - |
9066 | QVariant QGraphicsPolygonItem::extension(const QVariant &variant) const | - |
9067 | { | - |
9068 | Q_UNUSED(variant); executed (the execution status of this line is deduced): (void)variant;; | - |
9069 | return QVariant(); executed: return QVariant(); Execution Count:2 | 2 |
9070 | } | - |
9071 | | - |
9072 | /*! | - |
9073 | \class QGraphicsLineItem | - |
9074 | \brief The QGraphicsLineItem class provides a line item that you can add to a | - |
9075 | QGraphicsScene. | - |
9076 | \since 4.2 | - |
9077 | \ingroup graphicsview-api | - |
9078 | \inmodule QtWidgets | - |
9079 | | - |
9080 | To set the item's line, pass a QLineF to QGraphicsLineItem's | - |
9081 | constructor, or call the setLine() function. The line() function | - |
9082 | returns the current line. By default the line is black with a | - |
9083 | width of 0, but you can change this by calling setPen(). | - |
9084 | | - |
9085 | \image graphicsview-lineitem.png | - |
9086 | | - |
9087 | QGraphicsLineItem uses the line and the pen width to provide a reasonable | - |
9088 | implementation of boundingRect(), shape(), and contains(). The paint() | - |
9089 | function draws the line using the item's associated pen. | - |
9090 | | - |
9091 | \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, | - |
9092 | QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsPixmapItem, | - |
9093 | {Graphics View Framework} | - |
9094 | */ | - |
9095 | | - |
9096 | class QGraphicsLineItemPrivate : public QGraphicsItemPrivate | - |
9097 | { | - |
9098 | Q_DECLARE_PUBLIC(QGraphicsLineItem) | - |
9099 | public: | - |
9100 | QLineF line; | - |
9101 | QPen pen; | - |
9102 | }; | - |
9103 | | - |
9104 | /*! | - |
9105 | Constructs a QGraphicsLineItem, using \a line as the default line. \a | - |
9106 | parent is passed to QGraphicsItem's constructor. | - |
9107 | | - |
9108 | \sa QGraphicsScene::addItem() | - |
9109 | */ | - |
9110 | QGraphicsLineItem::QGraphicsLineItem(const QLineF &line, QGraphicsItem *parent) | - |
9111 | : QGraphicsItem(*new QGraphicsLineItemPrivate, parent) | - |
9112 | { | - |
9113 | setLine(line); never executed (the execution status of this line is deduced): setLine(line); | - |
9114 | } | 0 |
9115 | | - |
9116 | /*! | - |
9117 | Constructs a QGraphicsLineItem, using the line between (\a x1, \a y1) and | - |
9118 | (\a x2, \a y2) as the default line. \a parent is passed to | - |
9119 | QGraphicsItem's constructor. | - |
9120 | | - |
9121 | \sa QGraphicsScene::addItem() | - |
9122 | */ | - |
9123 | QGraphicsLineItem::QGraphicsLineItem(qreal x1, qreal y1, qreal x2, qreal y2, QGraphicsItem *parent) | - |
9124 | : QGraphicsItem(*new QGraphicsLineItemPrivate, parent) | - |
9125 | { | - |
9126 | setLine(x1, y1, x2, y2); never executed (the execution status of this line is deduced): setLine(x1, y1, x2, y2); | - |
9127 | } | 0 |
9128 | | - |
9129 | | - |
9130 | | - |
9131 | /*! | - |
9132 | Constructs a QGraphicsLineItem. \a parent is passed to QGraphicsItem's | - |
9133 | constructor. | - |
9134 | | - |
9135 | \sa QGraphicsScene::addItem() | - |
9136 | */ | - |
9137 | QGraphicsLineItem::QGraphicsLineItem(QGraphicsItem *parent) | - |
9138 | : QGraphicsItem(*new QGraphicsLineItemPrivate, parent) | - |
9139 | { | - |
9140 | } | 0 |
9141 | | - |
9142 | /*! | - |
9143 | Destroys the QGraphicsLineItem. | - |
9144 | */ | - |
9145 | QGraphicsLineItem::~QGraphicsLineItem() | - |
9146 | { | - |
9147 | } | - |
9148 | | - |
9149 | /*! | - |
9150 | Returns the item's pen, or a black solid 0-width pen if no pen has | - |
9151 | been set. | - |
9152 | | - |
9153 | \sa setPen() | - |
9154 | */ | - |
9155 | QPen QGraphicsLineItem::pen() const | - |
9156 | { | - |
9157 | Q_D(const QGraphicsLineItem); never executed (the execution status of this line is deduced): const QGraphicsLineItemPrivate * const d = d_func(); | - |
9158 | return d->pen; never executed: return d->pen; | 0 |
9159 | } | - |
9160 | | - |
9161 | /*! | - |
9162 | Sets the item's pen to \a pen. If no pen is set, the line will be painted | - |
9163 | using a black solid 0-width pen. | - |
9164 | | - |
9165 | \sa pen() | - |
9166 | */ | - |
9167 | void QGraphicsLineItem::setPen(const QPen &pen) | - |
9168 | { | - |
9169 | Q_D(QGraphicsLineItem); never executed (the execution status of this line is deduced): QGraphicsLineItemPrivate * const d = d_func(); | - |
9170 | if (d->pen == pen) never evaluated: d->pen == pen | 0 |
9171 | return; | 0 |
9172 | prepareGeometryChange(); never executed (the execution status of this line is deduced): prepareGeometryChange(); | - |
9173 | d->pen = pen; never executed (the execution status of this line is deduced): d->pen = pen; | - |
9174 | update(); never executed (the execution status of this line is deduced): update(); | - |
9175 | } | 0 |
9176 | | - |
9177 | /*! | - |
9178 | Returns the item's line, or a null line if no line has been set. | - |
9179 | | - |
9180 | \sa setLine() | - |
9181 | */ | - |
9182 | QLineF QGraphicsLineItem::line() const | - |
9183 | { | - |
9184 | Q_D(const QGraphicsLineItem); never executed (the execution status of this line is deduced): const QGraphicsLineItemPrivate * const d = d_func(); | - |
9185 | return d->line; never executed: return d->line; | 0 |
9186 | } | - |
9187 | | - |
9188 | /*! | - |
9189 | Sets the item's line to be the given \a line. | - |
9190 | | - |
9191 | \sa line() | - |
9192 | */ | - |
9193 | void QGraphicsLineItem::setLine(const QLineF &line) | - |
9194 | { | - |
9195 | Q_D(QGraphicsLineItem); never executed (the execution status of this line is deduced): QGraphicsLineItemPrivate * const d = d_func(); | - |
9196 | if (d->line == line) never evaluated: d->line == line | 0 |
9197 | return; | 0 |
9198 | prepareGeometryChange(); never executed (the execution status of this line is deduced): prepareGeometryChange(); | - |
9199 | d->line = line; never executed (the execution status of this line is deduced): d->line = line; | - |
9200 | update(); never executed (the execution status of this line is deduced): update(); | - |
9201 | } | 0 |
9202 | | - |
9203 | /*! | - |
9204 | \fn void QGraphicsLineItem::setLine(qreal x1, qreal y1, qreal x2, qreal y2) | - |
9205 | \overload | - |
9206 | | - |
9207 | Sets the item's line to be the line between (\a x1, \a y1) and (\a | - |
9208 | x2, \a y2). | - |
9209 | | - |
9210 | This is the same as calling \c {setLine(QLineF(x1, y1, x2, y2))}. | - |
9211 | */ | - |
9212 | | - |
9213 | /*! | - |
9214 | \reimp | - |
9215 | */ | - |
9216 | QRectF QGraphicsLineItem::boundingRect() const | - |
9217 | { | - |
9218 | Q_D(const QGraphicsLineItem); never executed (the execution status of this line is deduced): const QGraphicsLineItemPrivate * const d = d_func(); | - |
9219 | if (d->pen.widthF() == 0.0) { never evaluated: d->pen.widthF() == 0.0 | 0 |
9220 | const qreal x1 = d->line.p1().x(); never executed (the execution status of this line is deduced): const qreal x1 = d->line.p1().x(); | - |
9221 | const qreal x2 = d->line.p2().x(); never executed (the execution status of this line is deduced): const qreal x2 = d->line.p2().x(); | - |
9222 | const qreal y1 = d->line.p1().y(); never executed (the execution status of this line is deduced): const qreal y1 = d->line.p1().y(); | - |
9223 | const qreal y2 = d->line.p2().y(); never executed (the execution status of this line is deduced): const qreal y2 = d->line.p2().y(); | - |
9224 | qreal lx = qMin(x1, x2); never executed (the execution status of this line is deduced): qreal lx = qMin(x1, x2); | - |
9225 | qreal rx = qMax(x1, x2); never executed (the execution status of this line is deduced): qreal rx = qMax(x1, x2); | - |
9226 | qreal ty = qMin(y1, y2); never executed (the execution status of this line is deduced): qreal ty = qMin(y1, y2); | - |
9227 | qreal by = qMax(y1, y2); never executed (the execution status of this line is deduced): qreal by = qMax(y1, y2); | - |
9228 | return QRectF(lx, ty, rx - lx, by - ty); never executed: return QRectF(lx, ty, rx - lx, by - ty); | 0 |
9229 | } | - |
9230 | return shape().controlPointRect(); never executed: return shape().controlPointRect(); | 0 |
9231 | } | - |
9232 | | - |
9233 | /*! | - |
9234 | \reimp | - |
9235 | */ | - |
9236 | QPainterPath QGraphicsLineItem::shape() const | - |
9237 | { | - |
9238 | Q_D(const QGraphicsLineItem); never executed (the execution status of this line is deduced): const QGraphicsLineItemPrivate * const d = d_func(); | - |
9239 | QPainterPath path; never executed (the execution status of this line is deduced): QPainterPath path; | - |
9240 | if (d->line == QLineF()) never evaluated: d->line == QLineF() | 0 |
9241 | return path; never executed: return path; | 0 |
9242 | | - |
9243 | path.moveTo(d->line.p1()); never executed (the execution status of this line is deduced): path.moveTo(d->line.p1()); | - |
9244 | path.lineTo(d->line.p2()); never executed (the execution status of this line is deduced): path.lineTo(d->line.p2()); | - |
9245 | return qt_graphicsItem_shapeFromPath(path, d->pen); never executed: return qt_graphicsItem_shapeFromPath(path, d->pen); | 0 |
9246 | } | - |
9247 | | - |
9248 | /*! | - |
9249 | \reimp | - |
9250 | */ | - |
9251 | bool QGraphicsLineItem::contains(const QPointF &point) const | - |
9252 | { | - |
9253 | return QGraphicsItem::contains(point); never executed: return QGraphicsItem::contains(point); | 0 |
9254 | } | - |
9255 | | - |
9256 | /*! | - |
9257 | \reimp | - |
9258 | */ | - |
9259 | void QGraphicsLineItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | - |
9260 | { | - |
9261 | Q_D(QGraphicsLineItem); never executed (the execution status of this line is deduced): QGraphicsLineItemPrivate * const d = d_func(); | - |
9262 | Q_UNUSED(widget); never executed (the execution status of this line is deduced): (void)widget;; | - |
9263 | painter->setPen(d->pen); never executed (the execution status of this line is deduced): painter->setPen(d->pen); | - |
9264 | painter->drawLine(d->line); never executed (the execution status of this line is deduced): painter->drawLine(d->line); | - |
9265 | | - |
9266 | if (option->state & QStyle::State_Selected) never evaluated: option->state & QStyle::State_Selected | 0 |
9267 | qt_graphicsItem_highlightSelected(this, painter, option); never executed: qt_graphicsItem_highlightSelected(this, painter, option); | 0 |
9268 | } | 0 |
9269 | | - |
9270 | /*! | - |
9271 | \reimp | - |
9272 | */ | - |
9273 | bool QGraphicsLineItem::isObscuredBy(const QGraphicsItem *item) const | - |
9274 | { | - |
9275 | return QGraphicsItem::isObscuredBy(item); never executed: return QGraphicsItem::isObscuredBy(item); | 0 |
9276 | } | - |
9277 | | - |
9278 | /*! | - |
9279 | \reimp | - |
9280 | */ | - |
9281 | QPainterPath QGraphicsLineItem::opaqueArea() const | - |
9282 | { | - |
9283 | return QGraphicsItem::opaqueArea(); never executed: return QGraphicsItem::opaqueArea(); | 0 |
9284 | } | - |
9285 | | - |
9286 | /*! | - |
9287 | \reimp | - |
9288 | */ | - |
9289 | int QGraphicsLineItem::type() const | - |
9290 | { | - |
9291 | return Type; never executed: return Type; | 0 |
9292 | } | - |
9293 | | - |
9294 | /*! | - |
9295 | \internal | - |
9296 | */ | - |
9297 | bool QGraphicsLineItem::supportsExtension(Extension extension) const | - |
9298 | { | - |
9299 | Q_UNUSED(extension); never executed (the execution status of this line is deduced): (void)extension;; | - |
9300 | return false; never executed: return false; | 0 |
9301 | } | - |
9302 | | - |
9303 | /*! | - |
9304 | \internal | - |
9305 | */ | - |
9306 | void QGraphicsLineItem::setExtension(Extension extension, const QVariant &variant) | - |
9307 | { | - |
9308 | Q_UNUSED(extension); never executed (the execution status of this line is deduced): (void)extension;; | - |
9309 | Q_UNUSED(variant); never executed (the execution status of this line is deduced): (void)variant;; | - |
9310 | } | 0 |
9311 | | - |
9312 | /*! | - |
9313 | \internal | - |
9314 | */ | - |
9315 | QVariant QGraphicsLineItem::extension(const QVariant &variant) const | - |
9316 | { | - |
9317 | Q_UNUSED(variant); never executed (the execution status of this line is deduced): (void)variant;; | - |
9318 | return QVariant(); never executed: return QVariant(); | 0 |
9319 | } | - |
9320 | | - |
9321 | /*! | - |
9322 | \class QGraphicsPixmapItem | - |
9323 | \brief The QGraphicsPixmapItem class provides a pixmap item that you can add to | - |
9324 | a QGraphicsScene. | - |
9325 | \since 4.2 | - |
9326 | \ingroup graphicsview-api | - |
9327 | \inmodule QtWidgets | - |
9328 | | - |
9329 | To set the item's pixmap, pass a QPixmap to QGraphicsPixmapItem's | - |
9330 | constructor, or call the setPixmap() function. The pixmap() | - |
9331 | function returns the current pixmap. | - |
9332 | | - |
9333 | QGraphicsPixmapItem uses pixmap's optional alpha mask to provide a | - |
9334 | reasonable implementation of boundingRect(), shape(), and contains(). | - |
9335 | | - |
9336 | \image graphicsview-pixmapitem.png | - |
9337 | | - |
9338 | The pixmap is drawn at the item's (0, 0) coordinate, as returned by | - |
9339 | offset(). You can change the drawing offset by calling setOffset(). | - |
9340 | | - |
9341 | You can set the pixmap's transformation mode by calling | - |
9342 | setTransformationMode(). By default, Qt::FastTransformation is used, which | - |
9343 | provides fast, non-smooth scaling. Qt::SmoothTransformation enables | - |
9344 | QPainter::SmoothPixmapTransform on the painter, and the quality depends on | - |
9345 | the platform and viewport. The result is usually not as good as calling | - |
9346 | QPixmap::scale() directly. Call transformationMode() to get the current | - |
9347 | transformation mode for the item. | - |
9348 | | - |
9349 | \sa QGraphicsPathItem, QGraphicsRectItem, QGraphicsEllipseItem, | - |
9350 | QGraphicsTextItem, QGraphicsPolygonItem, QGraphicsLineItem, | - |
9351 | {Graphics View Framework} | - |
9352 | */ | - |
9353 | | - |
9354 | /*! | - |
9355 | \enum QGraphicsPixmapItem::ShapeMode | - |
9356 | | - |
9357 | This enum describes how QGraphicsPixmapItem calculates its shape and | - |
9358 | opaque area. | - |
9359 | | - |
9360 | The default value is MaskShape. | - |
9361 | | - |
9362 | \value MaskShape The shape is determined by calling QPixmap::mask(). | - |
9363 | This shape includes only the opaque pixels of the pixmap. | - |
9364 | Because the shape is more complex, however, it can be slower than the other modes, | - |
9365 | and uses more memory. | - |
9366 | | - |
9367 | \value BoundingRectShape The shape is determined by tracing the outline of | - |
9368 | the pixmap. This is the fastest shape mode, but it does not take into account | - |
9369 | any transparent areas on the pixmap. | - |
9370 | | - |
9371 | \value HeuristicMaskShape The shape is determine by calling | - |
9372 | QPixmap::createHeuristicMask(). The performance and memory consumption | - |
9373 | is similar to MaskShape. | - |
9374 | */ | - |
9375 | extern QPainterPath qt_regionToPath(const QRegion ®ion); | - |
9376 | | - |
9377 | class QGraphicsPixmapItemPrivate : public QGraphicsItemPrivate | - |
9378 | { | - |
9379 | Q_DECLARE_PUBLIC(QGraphicsPixmapItem) | - |
9380 | public: | - |
9381 | QGraphicsPixmapItemPrivate() | - |
9382 | : transformationMode(Qt::FastTransformation), | - |
9383 | shapeMode(QGraphicsPixmapItem::MaskShape), | - |
9384 | hasShape(false) | - |
9385 | {} executed: } Execution Count:44 | 44 |
9386 | | - |
9387 | QPixmap pixmap; | - |
9388 | Qt::TransformationMode transformationMode; | - |
9389 | QPointF offset; | - |
9390 | QGraphicsPixmapItem::ShapeMode shapeMode; | - |
9391 | QPainterPath shape; | - |
9392 | bool hasShape; | - |
9393 | | - |
9394 | void updateShape() | - |
9395 | { | - |
9396 | shape = QPainterPath(); executed (the execution status of this line is deduced): shape = QPainterPath(); | - |
9397 | switch (shapeMode) { | - |
9398 | case QGraphicsPixmapItem::MaskShape: { | - |
9399 | QBitmap mask = pixmap.mask(); executed (the execution status of this line is deduced): QBitmap mask = pixmap.mask(); | - |
9400 | if (!mask.isNull()) { partially evaluated: !mask.isNull() no Evaluation Count:0 | yes Evaluation Count:15 |
| 0-15 |
9401 | shape = qt_regionToPath(QRegion(mask).translated(offset.toPoint())); never executed (the execution status of this line is deduced): shape = qt_regionToPath(QRegion(mask).translated(offset.toPoint())); | - |
9402 | break; | 0 |
9403 | } | - |
9404 | // FALL THROUGH | - |
9405 | } | - |
9406 | case QGraphicsPixmapItem::BoundingRectShape: code before this statement executed: case QGraphicsPixmapItem::BoundingRectShape: Execution Count:15 | 15 |
9407 | shape.addRect(QRectF(offset.x(), offset.y(), pixmap.width(), pixmap.height())); executed (the execution status of this line is deduced): shape.addRect(QRectF(offset.x(), offset.y(), pixmap.width(), pixmap.height())); | - |
9408 | break; executed: break; Execution Count:15 | 15 |
9409 | case QGraphicsPixmapItem::HeuristicMaskShape: | - |
9410 | #ifndef QT_NO_IMAGE_HEURISTIC_MASK | - |
9411 | shape = qt_regionToPath(QRegion(pixmap.createHeuristicMask()).translated(offset.toPoint())); never executed (the execution status of this line is deduced): shape = qt_regionToPath(QRegion(pixmap.createHeuristicMask()).translated(offset.toPoint())); | - |
9412 | #else | - |
9413 | shape.addRect(QRectF(offset.x(), offset.y(), pixmap.width(), pixmap.height())); | - |
9414 | #endif | - |
9415 | break; | 0 |
9416 | } | - |
9417 | } executed: } Execution Count:15 | 15 |
9418 | }; | - |
9419 | | - |
9420 | /*! | - |
9421 | Constructs a QGraphicsPixmapItem, using \a pixmap as the default pixmap. | - |
9422 | \a parent is passed to QGraphicsItem's constructor. | - |
9423 | | - |
9424 | \sa QGraphicsScene::addItem() | - |
9425 | */ | - |
9426 | QGraphicsPixmapItem::QGraphicsPixmapItem(const QPixmap &pixmap, QGraphicsItem *parent) | - |
9427 | : QGraphicsItem(*new QGraphicsPixmapItemPrivate, parent) | - |
9428 | { | - |
9429 | setPixmap(pixmap); executed (the execution status of this line is deduced): setPixmap(pixmap); | - |
9430 | } executed: } Execution Count:36 | 36 |
9431 | | - |
9432 | /*! | - |
9433 | Constructs a QGraphicsPixmapItem. \a parent is passed to QGraphicsItem's | - |
9434 | constructor. | - |
9435 | | - |
9436 | \sa QGraphicsScene::addItem() | - |
9437 | */ | - |
9438 | QGraphicsPixmapItem::QGraphicsPixmapItem(QGraphicsItem *parent) | - |
9439 | : QGraphicsItem(*new QGraphicsPixmapItemPrivate, parent) | - |
9440 | { | - |
9441 | } executed: } Execution Count:8 | 8 |
9442 | | - |
9443 | /*! | - |
9444 | Destroys the QGraphicsPixmapItem. | - |
9445 | */ | - |
9446 | QGraphicsPixmapItem::~QGraphicsPixmapItem() | - |
9447 | { | - |
9448 | } | - |
9449 | | - |
9450 | /*! | - |
9451 | Sets the item's pixmap to \a pixmap. | - |
9452 | | - |
9453 | \sa pixmap() | - |
9454 | */ | - |
9455 | void QGraphicsPixmapItem::setPixmap(const QPixmap &pixmap) | - |
9456 | { | - |
9457 | Q_D(QGraphicsPixmapItem); executed (the execution status of this line is deduced): QGraphicsPixmapItemPrivate * const d = d_func(); | - |
9458 | prepareGeometryChange(); executed (the execution status of this line is deduced): prepareGeometryChange(); | - |
9459 | d->pixmap = pixmap; executed (the execution status of this line is deduced): d->pixmap = pixmap; | - |
9460 | d->hasShape = false; executed (the execution status of this line is deduced): d->hasShape = false; | - |
9461 | update(); executed (the execution status of this line is deduced): update(); | - |
9462 | } executed: } Execution Count:39 | 39 |
9463 | | - |
9464 | /*! | - |
9465 | Returns the item's pixmap, or an invalid QPixmap if no pixmap has been | - |
9466 | set. | - |
9467 | | - |
9468 | \sa setPixmap() | - |
9469 | */ | - |
9470 | QPixmap QGraphicsPixmapItem::pixmap() const | - |
9471 | { | - |
9472 | Q_D(const QGraphicsPixmapItem); executed (the execution status of this line is deduced): const QGraphicsPixmapItemPrivate * const d = d_func(); | - |
9473 | return d->pixmap; executed: return d->pixmap; Execution Count:10 | 10 |
9474 | } | - |
9475 | | - |
9476 | /*! | - |
9477 | Returns the transformation mode of the pixmap. The default mode is | - |
9478 | Qt::FastTransformation, which provides quick transformation with no | - |
9479 | smoothing. | - |
9480 | | - |
9481 | \sa setTransformationMode() | - |
9482 | */ | - |
9483 | Qt::TransformationMode QGraphicsPixmapItem::transformationMode() const | - |
9484 | { | - |
9485 | Q_D(const QGraphicsPixmapItem); executed (the execution status of this line is deduced): const QGraphicsPixmapItemPrivate * const d = d_func(); | - |
9486 | return d->transformationMode; executed: return d->transformationMode; Execution Count:3 | 3 |
9487 | } | - |
9488 | | - |
9489 | /*! | - |
9490 | Sets the pixmap item's transformation mode to \a mode, and toggles an | - |
9491 | update of the item. The default mode is Qt::FastTransformation, which | - |
9492 | provides quick transformation with no smoothing. | - |
9493 | | - |
9494 | Qt::SmoothTransformation enables QPainter::SmoothPixmapTransform on the | - |
9495 | painter, and the quality depends on the platform and viewport. The result | - |
9496 | is usually not as good as calling QPixmap::scale() directly. | - |
9497 | | - |
9498 | \sa transformationMode() | - |
9499 | */ | - |
9500 | void QGraphicsPixmapItem::setTransformationMode(Qt::TransformationMode mode) | - |
9501 | { | - |
9502 | Q_D(QGraphicsPixmapItem); executed (the execution status of this line is deduced): QGraphicsPixmapItemPrivate * const d = d_func(); | - |
9503 | if (mode != d->transformationMode) { evaluated: mode != d->transformationMode yes Evaluation Count:1 | yes Evaluation Count:2 |
| 1-2 |
9504 | d->transformationMode = mode; executed (the execution status of this line is deduced): d->transformationMode = mode; | - |
9505 | update(); executed (the execution status of this line is deduced): update(); | - |
9506 | } executed: } Execution Count:1 | 1 |
9507 | } executed: } Execution Count:3 | 3 |
9508 | | - |
9509 | /*! | - |
9510 | Returns the pixmap item's \e offset, which defines the point of the | - |
9511 | top-left corner of the pixmap, in local coordinates. | - |
9512 | | - |
9513 | \sa setOffset() | - |
9514 | */ | - |
9515 | QPointF QGraphicsPixmapItem::offset() const | - |
9516 | { | - |
9517 | Q_D(const QGraphicsPixmapItem); executed (the execution status of this line is deduced): const QGraphicsPixmapItemPrivate * const d = d_func(); | - |
9518 | return d->offset; executed: return d->offset; Execution Count:4 | 4 |
9519 | } | - |
9520 | | - |
9521 | /*! | - |
9522 | Sets the pixmap item's offset to \a offset. QGraphicsPixmapItem will draw | - |
9523 | its pixmap using \a offset for its top-left corner. | - |
9524 | | - |
9525 | \sa offset() | - |
9526 | */ | - |
9527 | void QGraphicsPixmapItem::setOffset(const QPointF &offset) | - |
9528 | { | - |
9529 | Q_D(QGraphicsPixmapItem); executed (the execution status of this line is deduced): QGraphicsPixmapItemPrivate * const d = d_func(); | - |
9530 | if (d->offset == offset) evaluated: d->offset == offset yes Evaluation Count:5 | yes Evaluation Count:11 |
| 5-11 |
9531 | return; executed: return; Execution Count:5 | 5 |
9532 | prepareGeometryChange(); executed (the execution status of this line is deduced): prepareGeometryChange(); | - |
9533 | d->offset = offset; executed (the execution status of this line is deduced): d->offset = offset; | - |
9534 | d->hasShape = false; executed (the execution status of this line is deduced): d->hasShape = false; | - |
9535 | update(); executed (the execution status of this line is deduced): update(); | - |
9536 | } executed: } Execution Count:11 | 11 |
9537 | | - |
9538 | /*! | - |
9539 | \fn void QGraphicsPixmapItem::setOffset(qreal x, qreal y) | - |
9540 | \since 4.3 | - |
9541 | | - |
9542 | This convenience function is equivalent to calling setOffset(QPointF(\a x, \a y)). | - |
9543 | */ | - |
9544 | | - |
9545 | /*! | - |
9546 | \reimp | - |
9547 | */ | - |
9548 | QRectF QGraphicsPixmapItem::boundingRect() const | - |
9549 | { | - |
9550 | Q_D(const QGraphicsPixmapItem); executed (the execution status of this line is deduced): const QGraphicsPixmapItemPrivate * const d = d_func(); | - |
9551 | if (d->pixmap.isNull()) evaluated: d->pixmap.isNull() yes Evaluation Count:3 | yes Evaluation Count:76 |
| 3-76 |
9552 | return QRectF(); executed: return QRectF(); Execution Count:3 | 3 |
9553 | if (d->flags & ItemIsSelectable) { partially evaluated: d->flags & ItemIsSelectable no Evaluation Count:0 | yes Evaluation Count:76 |
| 0-76 |
9554 | qreal pw = 1.0; never executed (the execution status of this line is deduced): qreal pw = 1.0; | - |
9555 | return QRectF(d->offset, d->pixmap.size()).adjusted(-pw/2, -pw/2, pw/2, pw/2); never executed: return QRectF(d->offset, d->pixmap.size()).adjusted(-pw/2, -pw/2, pw/2, pw/2); | 0 |
9556 | } else { | - |
9557 | return QRectF(d->offset, d->pixmap.size()); executed: return QRectF(d->offset, d->pixmap.size()); Execution Count:76 | 76 |
9558 | } | - |
9559 | } | - |
9560 | | - |
9561 | /*! | - |
9562 | \reimp | - |
9563 | */ | - |
9564 | QPainterPath QGraphicsPixmapItem::shape() const | - |
9565 | { | - |
9566 | Q_D(const QGraphicsPixmapItem); executed (the execution status of this line is deduced): const QGraphicsPixmapItemPrivate * const d = d_func(); | - |
9567 | if (!d->hasShape) { evaluated: !d->hasShape yes Evaluation Count:15 | yes Evaluation Count:1 |
| 1-15 |
9568 | QGraphicsPixmapItemPrivate *thatD = const_cast<QGraphicsPixmapItemPrivate *>(d); executed (the execution status of this line is deduced): QGraphicsPixmapItemPrivate *thatD = const_cast<QGraphicsPixmapItemPrivate *>(d); | - |
9569 | thatD->updateShape(); executed (the execution status of this line is deduced): thatD->updateShape(); | - |
9570 | thatD->hasShape = true; executed (the execution status of this line is deduced): thatD->hasShape = true; | - |
9571 | } executed: } Execution Count:15 | 15 |
9572 | return d_func()->shape; executed: return d_func()->shape; Execution Count:16 | 16 |
9573 | } | - |
9574 | | - |
9575 | /*! | - |
9576 | \reimp | - |
9577 | */ | - |
9578 | bool QGraphicsPixmapItem::contains(const QPointF &point) const | - |
9579 | { | - |
9580 | return QGraphicsItem::contains(point); executed: return QGraphicsItem::contains(point); Execution Count:6 | 6 |
9581 | } | - |
9582 | | - |
9583 | /*! | - |
9584 | \reimp | - |
9585 | */ | - |
9586 | void QGraphicsPixmapItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, | - |
9587 | QWidget *widget) | - |
9588 | { | - |
9589 | Q_D(QGraphicsPixmapItem); executed (the execution status of this line is deduced): QGraphicsPixmapItemPrivate * const d = d_func(); | - |
9590 | Q_UNUSED(widget); executed (the execution status of this line is deduced): (void)widget;; | - |
9591 | | - |
9592 | painter->setRenderHint(QPainter::SmoothPixmapTransform, executed (the execution status of this line is deduced): painter->setRenderHint(QPainter::SmoothPixmapTransform, | - |
9593 | (d->transformationMode == Qt::SmoothTransformation)); executed (the execution status of this line is deduced): (d->transformationMode == Qt::SmoothTransformation)); | - |
9594 | | - |
9595 | painter->drawPixmap(d->offset, d->pixmap); executed (the execution status of this line is deduced): painter->drawPixmap(d->offset, d->pixmap); | - |
9596 | | - |
9597 | if (option->state & QStyle::State_Selected) partially evaluated: option->state & QStyle::State_Selected no Evaluation Count:0 | yes Evaluation Count:6 |
| 0-6 |
9598 | qt_graphicsItem_highlightSelected(this, painter, option); never executed: qt_graphicsItem_highlightSelected(this, painter, option); | 0 |
9599 | } executed: } Execution Count:6 | 6 |
9600 | | - |
9601 | /*! | - |
9602 | \reimp | - |
9603 | */ | - |
9604 | bool QGraphicsPixmapItem::isObscuredBy(const QGraphicsItem *item) const | - |
9605 | { | - |
9606 | return QGraphicsItem::isObscuredBy(item); executed: return QGraphicsItem::isObscuredBy(item); Execution Count:7 | 7 |
9607 | } | - |
9608 | | - |
9609 | /*! | - |
9610 | \reimp | - |
9611 | */ | - |
9612 | QPainterPath QGraphicsPixmapItem::opaqueArea() const | - |
9613 | { | - |
9614 | return shape(); executed: return shape(); Execution Count:8 | 8 |
9615 | } | - |
9616 | | - |
9617 | /*! | - |
9618 | \reimp | - |
9619 | */ | - |
9620 | int QGraphicsPixmapItem::type() const | - |
9621 | { | - |
9622 | return Type; executed: return Type; Execution Count:6 | 6 |
9623 | } | - |
9624 | | - |
9625 | /*! | - |
9626 | Returns the item's shape mode. The shape mode describes how | - |
9627 | QGraphicsPixmapItem calculates its shape. The default mode is MaskShape. | - |
9628 | | - |
9629 | \sa setShapeMode(), ShapeMode | - |
9630 | */ | - |
9631 | QGraphicsPixmapItem::ShapeMode QGraphicsPixmapItem::shapeMode() const | - |
9632 | { | - |
9633 | return d_func()->shapeMode; executed: return d_func()->shapeMode; Execution Count:4 | 4 |
9634 | } | - |
9635 | | - |
9636 | /*! | - |
9637 | Sets the item's shape mode to \a mode. The shape mode describes how | - |
9638 | QGraphicsPixmapItem calculates its shape. The default mode is MaskShape. | - |
9639 | | - |
9640 | \sa shapeMode(), ShapeMode | - |
9641 | */ | - |
9642 | void QGraphicsPixmapItem::setShapeMode(ShapeMode mode) | - |
9643 | { | - |
9644 | Q_D(QGraphicsPixmapItem); executed (the execution status of this line is deduced): QGraphicsPixmapItemPrivate * const d = d_func(); | - |
9645 | if (d->shapeMode == mode) evaluated: d->shapeMode == mode yes Evaluation Count:2 | yes Evaluation Count:2 |
| 2 |
9646 | return; executed: return; Execution Count:2 | 2 |
9647 | d->shapeMode = mode; executed (the execution status of this line is deduced): d->shapeMode = mode; | - |
9648 | d->hasShape = false; executed (the execution status of this line is deduced): d->hasShape = false; | - |
9649 | } executed: } Execution Count:2 | 2 |
9650 | | - |
9651 | /*! | - |
9652 | \internal | - |
9653 | */ | - |
9654 | bool QGraphicsPixmapItem::supportsExtension(Extension extension) const | - |
9655 | { | - |
9656 | Q_UNUSED(extension); executed (the execution status of this line is deduced): (void)extension;; | - |
9657 | return false; executed: return false; Execution Count:2 | 2 |
9658 | } | - |
9659 | | - |
9660 | /*! | - |
9661 | \internal | - |
9662 | */ | - |
9663 | void QGraphicsPixmapItem::setExtension(Extension extension, const QVariant &variant) | - |
9664 | { | - |
9665 | Q_UNUSED(extension); executed (the execution status of this line is deduced): (void)extension;; | - |
9666 | Q_UNUSED(variant); executed (the execution status of this line is deduced): (void)variant;; | - |
9667 | } executed: } Execution Count:2 | 2 |
9668 | | - |
9669 | /*! | - |
9670 | \internal | - |
9671 | */ | - |
9672 | QVariant QGraphicsPixmapItem::extension(const QVariant &variant) const | - |
9673 | { | - |
9674 | Q_UNUSED(variant); executed (the execution status of this line is deduced): (void)variant;; | - |
9675 | return QVariant(); executed: return QVariant(); Execution Count:2 | 2 |
9676 | } | - |
9677 | | - |
9678 | /*! | - |
9679 | \class QGraphicsTextItem | - |
9680 | \brief The QGraphicsTextItem class provides a text item that you can add to | - |
9681 | a QGraphicsScene to display formatted text. | - |
9682 | \since 4.2 | - |
9683 | \ingroup graphicsview-api | - |
9684 | \inmodule QtWidgets | - |
9685 | | - |
9686 | If you only need to show plain text in an item, consider using QGraphicsSimpleTextItem | - |
9687 | instead. | - |
9688 | | - |
9689 | To set the item's text, pass a QString to QGraphicsTextItem's | - |
9690 | constructor, or call setHtml()/setPlainText(). | - |
9691 | | - |
9692 | QGraphicsTextItem uses the text's formatted size and the associated font | - |
9693 | to provide a reasonable implementation of boundingRect(), shape(), | - |
9694 | and contains(). You can set the font by calling setFont(). | - |
9695 | | - |
9696 | It is possible to make the item editable by setting the Qt::TextEditorInteraction flag | - |
9697 | using setTextInteractionFlags(). | - |
9698 | | - |
9699 | The item's preferred text width can be set using setTextWidth() and obtained | - |
9700 | using textWidth(). | - |
9701 | | - |
9702 | \note In order to align HTML text in the center, the item's text width must be set. | - |
9703 | | - |
9704 | \image graphicsview-textitem.png | - |
9705 | | - |
9706 | \note QGraphicsTextItem accepts \l{QGraphicsItem::acceptHoverEvents()}{hover events} | - |
9707 | by default. You can change this with \l{QGraphicsItem::}{setAcceptHoverEvents()}. | - |
9708 | | - |
9709 | \sa QGraphicsSimpleTextItem, QGraphicsPathItem, QGraphicsRectItem, | - |
9710 | QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem, | - |
9711 | QGraphicsLineItem, {Graphics View Framework} | - |
9712 | */ | - |
9713 | | - |
9714 | class QGraphicsTextItemPrivate | - |
9715 | { | - |
9716 | public: | - |
9717 | QGraphicsTextItemPrivate() | - |
9718 | : control(0), pageNumber(0), useDefaultImpl(false), tabChangesFocus(false), clickCausedFocus(0) | - |
9719 | { } executed: } Execution Count:1 | 1 |
9720 | | - |
9721 | mutable QWidgetTextControl *control; | - |
9722 | QWidgetTextControl *textControl() const; | - |
9723 | | - |
9724 | inline QPointF controlOffset() const | - |
9725 | { return QPointF(0., pageNumber * control->document()->pageSize().height()); } executed: return QPointF(0., pageNumber * control->document()->pageSize().height()); Execution Count:4 | 4 |
9726 | inline void sendControlEvent(QEvent *e) | - |
9727 | { if (control) control->processEvent(e, controlOffset()); } executed: control->processEvent(e, controlOffset()); Execution Count:1 executed: } Execution Count:1 partially evaluated: control yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
9728 | | - |
9729 | void _q_updateBoundingRect(const QSizeF &); | - |
9730 | void _q_update(QRectF); | - |
9731 | void _q_ensureVisible(QRectF); | - |
9732 | bool _q_mouseOnEdge(QGraphicsSceneMouseEvent *); | - |
9733 | | - |
9734 | QRectF boundingRect; | - |
9735 | int pageNumber; | - |
9736 | bool useDefaultImpl; | - |
9737 | bool tabChangesFocus; | - |
9738 | | - |
9739 | uint clickCausedFocus : 1; | - |
9740 | | - |
9741 | QGraphicsTextItem *qq; | - |
9742 | }; | - |
9743 | | - |
9744 | | - |
9745 | /*! | - |
9746 | Constructs a QGraphicsTextItem, using \a text as the default plain | - |
9747 | text. \a parent is passed to QGraphicsItem's constructor. | - |
9748 | | - |
9749 | \sa QGraphicsScene::addItem() | - |
9750 | */ | - |
9751 | QGraphicsTextItem::QGraphicsTextItem(const QString &text, QGraphicsItem *parent) | - |
9752 | : QGraphicsObject(*new QGraphicsItemPrivate, parent), | - |
9753 | dd(new QGraphicsTextItemPrivate) | - |
9754 | { | - |
9755 | dd->qq = this; executed (the execution status of this line is deduced): dd->qq = this; | - |
9756 | if (!text.isEmpty()) partially evaluated: !text.isEmpty() yes Evaluation Count:1 | no Evaluation Count:0 |
| 0-1 |
9757 | setPlainText(text); executed: setPlainText(text); Execution Count:1 | 1 |
9758 | setAcceptDrops(true); executed (the execution status of this line is deduced): setAcceptDrops(true); | - |
9759 | setAcceptHoverEvents(true); executed (the execution status of this line is deduced): setAcceptHoverEvents(true); | - |
9760 | setFlags(ItemUsesExtendedStyleOption); executed (the execution status of this line is deduced): setFlags(ItemUsesExtendedStyleOption); | - |
9761 | } executed: } Execution Count:1 | 1 |
9762 | | - |
9763 | /*! | - |
9764 | Constructs a QGraphicsTextItem. \a parent is passed to QGraphicsItem's | - |
9765 | constructor. | - |
9766 | | - |
9767 | \sa QGraphicsScene::addItem() | - |
9768 | */ | - |
9769 | QGraphicsTextItem::QGraphicsTextItem(QGraphicsItem *parent) | - |
9770 | : QGraphicsObject(*new QGraphicsItemPrivate, parent), | - |
9771 | dd(new QGraphicsTextItemPrivate) | - |
9772 | { | - |
9773 | dd->qq = this; never executed (the execution status of this line is deduced): dd->qq = this; | - |
9774 | setAcceptDrops(true); never executed (the execution status of this line is deduced): setAcceptDrops(true); | - |
9775 | setAcceptHoverEvents(true); never executed (the execution status of this line is deduced): setAcceptHoverEvents(true); | - |
9776 | setFlag(ItemUsesExtendedStyleOption); never executed (the execution status of this line is deduced): setFlag(ItemUsesExtendedStyleOption); | - |
9777 | } | 0 |
9778 | | - |
9779 | /*! | - |
9780 | Destroys the QGraphicsTextItem. | - |
9781 | */ | - |
9782 | QGraphicsTextItem::~QGraphicsTextItem() | - |
9783 | { | - |
9784 | delete dd; executed (the execution status of this line is deduced): delete dd; | - |
9785 | } executed: } Execution Count:1 | 1 |
9786 | | - |
9787 | /*! | - |
9788 | Returns the item's text converted to HTML, or an empty QString if no text has been set. | - |
9789 | | - |
9790 | \sa setHtml() | - |
9791 | */ | - |
9792 | QString QGraphicsTextItem::toHtml() const | - |
9793 | { | - |
9794 | #ifndef QT_NO_TEXTHTMLPARSER | - |
9795 | if (dd->control) never evaluated: dd->control | 0 |
9796 | return dd->control->toHtml(); never executed: return dd->control->toHtml(); | 0 |
9797 | #endif | - |
9798 | return QString(); never executed: return QString(); | 0 |
9799 | } | - |
9800 | | - |
9801 | /*! | - |
9802 | Sets the item's text to \a text, assuming that text is HTML formatted. If | - |
9803 | the item has keyboard input focus, this function will also call | - |
9804 | ensureVisible() to ensure that the text is visible in all viewports. | - |
9805 | | - |
9806 | \sa toHtml(), hasFocus(), QGraphicsSimpleTextItem | - |
9807 | */ | - |
9808 | void QGraphicsTextItem::setHtml(const QString &text) | - |
9809 | { | - |
9810 | dd->textControl()->setHtml(text); never executed (the execution status of this line is deduced): dd->textControl()->setHtml(text); | - |
9811 | } | 0 |
9812 | | - |
9813 | /*! | - |
9814 | Returns the item's text converted to plain text, or an empty QString if no text has been set. | - |
9815 | | - |
9816 | \sa setPlainText() | - |
9817 | */ | - |
9818 | QString QGraphicsTextItem::toPlainText() const | - |
9819 | { | - |
9820 | if (dd->control) never evaluated: dd->control | 0 |
9821 | return dd->control->toPlainText(); never executed: return dd->control->toPlainText(); | 0 |
9822 | return QString(); never executed: return QString(); | 0 |
9823 | } | - |
9824 | | - |
9825 | /*! | - |
9826 | Sets the item's text to \a text. If the item has keyboard input focus, | - |
9827 | this function will also call ensureVisible() to ensure that the text is | - |
9828 | visible in all viewports. | - |
9829 | | - |
9830 | \sa toHtml(), hasFocus() | - |
9831 | */ | - |
9832 | void QGraphicsTextItem::setPlainText(const QString &text) | - |
9833 | { | - |
9834 | dd->textControl()->setPlainText(text); executed (the execution status of this line is deduced): dd->textControl()->setPlainText(text); | - |
9835 | } executed: } Execution Count:1 | 1 |
9836 | | - |
9837 | /*! | - |
9838 | Returns the item's font, which is used to render the text. | - |
9839 | | - |
9840 | \sa setFont() | - |
9841 | */ | - |
9842 | QFont QGraphicsTextItem::font() const | - |
9843 | { | - |
9844 | if (!dd->control) never evaluated: !dd->control | 0 |
9845 | return QFont(); never executed: return QFont(); | 0 |
9846 | return dd->control->document()->defaultFont(); never executed: return dd->control->document()->defaultFont(); | 0 |
9847 | } | - |
9848 | | - |
9849 | /*! | - |
9850 | Sets the font used to render the text item to \a font. | - |
9851 | | - |
9852 | \sa font() | - |
9853 | */ | - |
9854 | void QGraphicsTextItem::setFont(const QFont &font) | - |
9855 | { | - |
9856 | dd->textControl()->document()->setDefaultFont(font); executed (the execution status of this line is deduced): dd->textControl()->document()->setDefaultFont(font); | - |
9857 | } executed: } Execution Count:1 | 1 |
9858 | | - |
9859 | /*! | - |
9860 | Sets the color for unformatted text to \a col. | - |
9861 | */ | - |
9862 | void QGraphicsTextItem::setDefaultTextColor(const QColor &col) | - |
9863 | { | - |
9864 | QWidgetTextControl *c = dd->textControl(); never executed (the execution status of this line is deduced): QWidgetTextControl *c = dd->textControl(); | - |
9865 | QPalette pal = c->palette(); never executed (the execution status of this line is deduced): QPalette pal = c->palette(); | - |
9866 | QColor old = pal.color(QPalette::Text); never executed (the execution status of this line is deduced): QColor old = pal.color(QPalette::Text); | - |
9867 | pal.setColor(QPalette::Text, col); never executed (the execution status of this line is deduced): pal.setColor(QPalette::Text, col); | - |
9868 | c->setPalette(pal); never executed (the execution status of this line is deduced): c->setPalette(pal); | - |
9869 | if (old != col) never evaluated: old != col | 0 |
9870 | update(); never executed: update(); | 0 |
9871 | } | 0 |
9872 | | - |
9873 | /*! | - |
9874 | Returns the default text color that is used to for unformatted text. | - |
9875 | */ | - |
9876 | QColor QGraphicsTextItem::defaultTextColor() const | - |
9877 | { | - |
9878 | return dd->textControl()->palette().color(QPalette::Text); never executed: return dd->textControl()->palette().color(QPalette::Text); | 0 |
9879 | } | - |
9880 | | - |
9881 | /*! | - |
9882 | \reimp | - |
9883 | */ | - |
9884 | QRectF QGraphicsTextItem::boundingRect() const | - |
9885 | { | - |
9886 | return dd->boundingRect; executed: return dd->boundingRect; Execution Count:2 | 2 |
9887 | } | - |
9888 | | - |
9889 | /*! | - |
9890 | \reimp | - |
9891 | */ | - |
9892 | QPainterPath QGraphicsTextItem::shape() const | - |
9893 | { | - |
9894 | if (!dd->control) never evaluated: !dd->control | 0 |
9895 | return QPainterPath(); never executed: return QPainterPath(); | 0 |
9896 | QPainterPath path; never executed (the execution status of this line is deduced): QPainterPath path; | - |
9897 | path.addRect(dd->boundingRect); never executed (the execution status of this line is deduced): path.addRect(dd->boundingRect); | - |
9898 | return path; never executed: return path; | 0 |
9899 | } | - |
9900 | | - |
9901 | /*! | - |
9902 | \reimp | - |
9903 | */ | - |
9904 | bool QGraphicsTextItem::contains(const QPointF &point) const | - |
9905 | { | - |
9906 | return dd->boundingRect.contains(point); never executed: return dd->boundingRect.contains(point); | 0 |
9907 | } | - |
9908 | | - |
9909 | /*! | - |
9910 | \reimp | - |
9911 | */ | - |
9912 | void QGraphicsTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, | - |
9913 | QWidget *widget) | - |
9914 | { | - |
9915 | Q_UNUSED(widget); never executed (the execution status of this line is deduced): (void)widget;; | - |
9916 | if (dd->control) { never evaluated: dd->control | 0 |
9917 | painter->save(); never executed (the execution status of this line is deduced): painter->save(); | - |
9918 | QRectF r = option->exposedRect; never executed (the execution status of this line is deduced): QRectF r = option->exposedRect; | - |
9919 | painter->translate(-dd->controlOffset()); never executed (the execution status of this line is deduced): painter->translate(-dd->controlOffset()); | - |
9920 | r.translate(dd->controlOffset()); never executed (the execution status of this line is deduced): r.translate(dd->controlOffset()); | - |
9921 | | - |
9922 | QTextDocument *doc = dd->control->document(); never executed (the execution status of this line is deduced): QTextDocument *doc = dd->control->document(); | - |
9923 | QTextDocumentLayout *layout = qobject_cast<QTextDocumentLayout *>(doc->documentLayout()); never executed (the execution status of this line is deduced): QTextDocumentLayout *layout = qobject_cast<QTextDocumentLayout *>(doc->documentLayout()); | - |
9924 | | - |
9925 | // the layout might need to expand the root frame to | - |
9926 | // the viewport if NoWrap is set | - |
9927 | if (layout) | 0 |
9928 | layout->setViewport(dd->boundingRect); never executed: layout->setViewport(dd->boundingRect); | 0 |
9929 | | - |
9930 | dd->control->drawContents(painter, r); never executed (the execution status of this line is deduced): dd->control->drawContents(painter, r); | - |
9931 | | - |
9932 | if (layout) | 0 |
9933 | layout->setViewport(QRect()); never executed: layout->setViewport(QRect()); | 0 |
9934 | | - |
9935 | painter->restore(); never executed (the execution status of this line is deduced): painter->restore(); | - |
9936 | } | 0 |
9937 | | - |
9938 | if (option->state & (QStyle::State_Selected | QStyle::State_HasFocus)) never evaluated: option->state & (QStyle::State_Selected | QStyle::State_HasFocus) | 0 |
9939 | qt_graphicsItem_highlightSelected(this, painter, option); never executed: qt_graphicsItem_highlightSelected(this, painter, option); | 0 |
9940 | } | 0 |
9941 | | - |
9942 | /*! | - |
9943 | \reimp | - |
9944 | */ | - |
9945 | bool QGraphicsTextItem::isObscuredBy(const QGraphicsItem *item) const | - |
9946 | { | - |
9947 | return QGraphicsItem::isObscuredBy(item); never executed: return QGraphicsItem::isObscuredBy(item); | 0 |
9948 | } | - |
9949 | | - |
9950 | /*! | - |
9951 | \reimp | - |
9952 | */ | - |
9953 | QPainterPath QGraphicsTextItem::opaqueArea() const | - |
9954 | { | - |
9955 | return QGraphicsItem::opaqueArea(); never executed: return QGraphicsItem::opaqueArea(); | 0 |
9956 | } | - |
9957 | | - |
9958 | /*! | - |
9959 | \reimp | - |
9960 | */ | - |
9961 | int QGraphicsTextItem::type() const | - |
9962 | { | - |
9963 | return Type; never executed: return Type; | 0 |
9964 | } | - |
9965 | | - |
9966 | /*! | - |
9967 | Sets the preferred width for the item's text. If the actual text | - |
9968 | is wider than the specified width then it will be broken into | - |
9969 | multiple lines. | - |
9970 | | - |
9971 | If \a width is set to -1 then the text will not be broken into | - |
9972 | multiple lines unless it is enforced through an explicit line | - |
9973 | break or a new paragraph. | - |
9974 | | - |
9975 | The default value is -1. | - |
9976 | | - |
9977 | Note that QGraphicsTextItem keeps a QTextDocument internally, | - |
9978 | which is used to calculate the text width. | - |
9979 | | - |
9980 | \sa textWidth(), QTextDocument::setTextWidth() | - |
9981 | */ | - |
9982 | void QGraphicsTextItem::setTextWidth(qreal width) | - |
9983 | { | - |
9984 | dd->textControl()->setTextWidth(width); never executed (the execution status of this line is deduced): dd->textControl()->setTextWidth(width); | - |
9985 | } | 0 |
9986 | | - |
9987 | /*! | - |
9988 | Returns the text width. | - |
9989 | | - |
9990 | The width is calculated with the QTextDocument that | - |
9991 | QGraphicsTextItem keeps internally. | - |
9992 | | - |
9993 | \sa setTextWidth(), QTextDocument::textWidth() | - |
9994 | */ | - |
9995 | qreal QGraphicsTextItem::textWidth() const | - |
9996 | { | - |
9997 | if (!dd->control) never evaluated: !dd->control | 0 |
9998 | return -1; never executed: return -1; | 0 |
9999 | return dd->control->textWidth(); never executed: return dd->control->textWidth(); | 0 |
10000 | } | - |
10001 | | - |
10002 | /*! | - |
10003 | Adjusts the text item to a reasonable size. | - |
10004 | */ | - |
10005 | void QGraphicsTextItem::adjustSize() | - |
10006 | { | - |
10007 | if (dd->control) never evaluated: dd->control | 0 |
10008 | dd->control->adjustSize(); never executed: dd->control->adjustSize(); | 0 |
10009 | } | 0 |
10010 | | - |
10011 | /*! | - |
10012 | Sets the text document \a document on the item. | - |
10013 | */ | - |
10014 | void QGraphicsTextItem::setDocument(QTextDocument *document) | - |
10015 | { | - |
10016 | dd->textControl()->setDocument(document); never executed (the execution status of this line is deduced): dd->textControl()->setDocument(document); | - |
10017 | dd->_q_updateBoundingRect(dd->control->size()); never executed (the execution status of this line is deduced): dd->_q_updateBoundingRect(dd->control->size()); | - |
10018 | } | 0 |
10019 | | - |
10020 | /*! | - |
10021 | Returns the item's text document. | - |
10022 | */ | - |
10023 | QTextDocument *QGraphicsTextItem::document() const | - |
10024 | { | - |
10025 | return dd->textControl()->document(); never executed: return dd->textControl()->document(); | 0 |
10026 | } | - |
10027 | | - |
10028 | /*! | - |
10029 | \reimp | - |
10030 | */ | - |
10031 | bool QGraphicsTextItem::sceneEvent(QEvent *event) | - |
10032 | { | - |
10033 | QEvent::Type t = event->type(); executed (the execution status of this line is deduced): QEvent::Type t = event->type(); | - |
10034 | if (!dd->tabChangesFocus && (t == QEvent::KeyPress || t == QEvent::KeyRelease)) { partially evaluated: !dd->tabChangesFocus yes Evaluation Count:1 | no Evaluation Count:0 |
partially evaluated: t == QEvent::KeyPress no Evaluation Count:0 | yes Evaluation Count:1 |
partially evaluated: t == QEvent::KeyRelease no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
10035 | int k = ((QKeyEvent *)event)->key(); never executed (the execution status of this line is deduced): int k = ((QKeyEvent *)event)->key(); | - |
10036 | if (k == Qt::Key_Tab || k == Qt::Key_Backtab) { never evaluated: k == Qt::Key_Tab never evaluated: k == Qt::Key_Backtab | 0 |
10037 | dd->sendControlEvent(event); never executed (the execution status of this line is deduced): dd->sendControlEvent(event); | - |
10038 | return true; never executed: return true; | 0 |
10039 | } | - |
10040 | } | 0 |
10041 | bool result = QGraphicsItem::sceneEvent(event); executed (the execution status of this line is deduced): bool result = QGraphicsItem::sceneEvent(event); | - |
10042 | | - |
10043 | // Ensure input context is updated. | - |
10044 | switch (event->type()) { | - |
10045 | case QEvent::ContextMenu: | - |
10046 | case QEvent::FocusIn: | - |
10047 | case QEvent::FocusOut: | - |
10048 | case QEvent::GraphicsSceneDragEnter: | - |
10049 | case QEvent::GraphicsSceneDragLeave: | - |
10050 | case QEvent::GraphicsSceneDragMove: | - |
10051 | case QEvent::GraphicsSceneDrop: | - |
10052 | case QEvent::GraphicsSceneHoverEnter: | - |
10053 | case QEvent::GraphicsSceneHoverLeave: | - |
10054 | case QEvent::GraphicsSceneHoverMove: | - |
10055 | case QEvent::GraphicsSceneMouseDoubleClick: | - |
10056 | case QEvent::GraphicsSceneMousePress: | - |
10057 | case QEvent::GraphicsSceneMouseMove: | - |
10058 | case QEvent::GraphicsSceneMouseRelease: | - |
10059 | case QEvent::KeyPress: | - |
10060 | case QEvent::KeyRelease: | - |
10061 | // Reset the focus widget's input context, regardless | - |
10062 | // of how this item gained or lost focus. | - |
10063 | if (event->type() == QEvent::FocusIn || event->type() == QEvent::FocusOut) { partially evaluated: event->type() == QEvent::FocusIn no Evaluation Count:0 | yes Evaluation Count:1 |
partially evaluated: event->type() == QEvent::FocusOut no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
10064 | qApp->inputMethod()->reset(); never executed (the execution status of this line is deduced): (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->reset(); | - |
10065 | } else { | 0 |
10066 | qApp->inputMethod()->update(Qt::ImQueryInput); executed (the execution status of this line is deduced): (static_cast<QApplication *>(QCoreApplication::instance()))->inputMethod()->update(Qt::ImQueryInput); | - |
10067 | } executed: } Execution Count:1 | 1 |
10068 | break; executed: break; Execution Count:1 | 1 |
10069 | case QEvent::ShortcutOverride: | - |
10070 | dd->sendControlEvent(event); never executed (the execution status of this line is deduced): dd->sendControlEvent(event); | - |
10071 | return true; never executed: return true; | 0 |
10072 | default: | - |
10073 | break; | 0 |
10074 | } | - |
10075 | | - |
10076 | return result; executed: return result; Execution Count:1 | 1 |
10077 | } | - |
10078 | | - |
10079 | /*! | - |
10080 | \reimp | - |
10081 | */ | - |
10082 | void QGraphicsTextItem::mousePressEvent(QGraphicsSceneMouseEvent *event) | - |
10083 | { | - |
10084 | if ((QGraphicsItem::d_ptr->flags & (ItemIsSelectable | ItemIsMovable)) never evaluated: (QGraphicsItem::d_ptr->flags & (ItemIsSelectable | ItemIsMovable)) | 0 |
10085 | && (event->buttons() & Qt::LeftButton) && dd->_q_mouseOnEdge(event)) { never evaluated: (event->buttons() & Qt::LeftButton) never evaluated: dd->_q_mouseOnEdge(event) | 0 |
10086 | // User left-pressed on edge of selectable/movable item, use | - |
10087 | // base impl. | - |
10088 | dd->useDefaultImpl = true; never executed (the execution status of this line is deduced): dd->useDefaultImpl = true; | - |
10089 | } else if (event->buttons() == event->button() never executed: } never evaluated: event->buttons() == event->button() | 0 |
10090 | && dd->control->textInteractionFlags() == Qt::NoTextInteraction) { never evaluated: dd->control->textInteractionFlags() == Qt::NoTextInteraction | 0 |
10091 | // User pressed first button on non-interactive item. | - |
10092 | dd->useDefaultImpl = true; never executed (the execution status of this line is deduced): dd->useDefaultImpl = true; | - |
10093 | } | 0 |
10094 | if (dd->useDefaultImpl) { never evaluated: dd->useDefaultImpl | 0 |
10095 | QGraphicsItem::mousePressEvent(event); never executed (the execution status of this line is deduced): QGraphicsItem::mousePressEvent(event); | - |
10096 | if (!event->isAccepted()) never evaluated: !event->isAccepted() | 0 |
10097 | dd->useDefaultImpl = false; never executed: dd->useDefaultImpl = false; | 0 |
10098 | return; | 0 |
10099 | } | - |
10100 | | - |
10101 | dd->sendControlEvent(event); never executed (the execution status of this line is deduced): dd->sendControlEvent(event); | - |
10102 | } | 0 |
10103 | | - |
10104 | /*! | - |
10105 | \reimp | - |
10106 | */ | - |
10107 | void QGraphicsTextItem::mouseMoveEvent(QGraphicsSceneMouseEvent *event) | - |
10108 | { | - |
10109 | if (dd->useDefaultImpl) { partially evaluated: dd->useDefaultImpl no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
10110 | QGraphicsItem::mouseMoveEvent(event); never executed (the execution status of this line is deduced): QGraphicsItem::mouseMoveEvent(event); | - |
10111 | return; | 0 |
10112 | } | - |
10113 | | - |
10114 | dd->sendControlEvent(event); executed (the execution status of this line is deduced): dd->sendControlEvent(event); | - |
10115 | } executed: } Execution Count:1 | 1 |
10116 | | - |
10117 | /*! | - |
10118 | \reimp | - |
10119 | */ | - |
10120 | void QGraphicsTextItem::mouseReleaseEvent(QGraphicsSceneMouseEvent *event) | - |
10121 | { | - |
10122 | if (dd->useDefaultImpl) { never evaluated: dd->useDefaultImpl | 0 |
10123 | QGraphicsItem::mouseReleaseEvent(event); never executed (the execution status of this line is deduced): QGraphicsItem::mouseReleaseEvent(event); | - |
10124 | if (dd->control->textInteractionFlags() == Qt::NoTextInteraction never evaluated: dd->control->textInteractionFlags() == Qt::NoTextInteraction | 0 |
10125 | && !event->buttons()) { never evaluated: !event->buttons() | 0 |
10126 | // User released last button on non-interactive item. | - |
10127 | dd->useDefaultImpl = false; never executed (the execution status of this line is deduced): dd->useDefaultImpl = false; | - |
10128 | } else if ((event->buttons() & Qt::LeftButton) == 0) { never executed: } never evaluated: (event->buttons() & Qt::LeftButton) == 0 | 0 |
10129 | // User released the left button on an interactive item. | - |
10130 | dd->useDefaultImpl = false; never executed (the execution status of this line is deduced): dd->useDefaultImpl = false; | - |
10131 | } | 0 |
10132 | return; | 0 |
10133 | } | - |
10134 | | - |
10135 | QWidget *widget = event->widget(); never executed (the execution status of this line is deduced): QWidget *widget = event->widget(); | - |
10136 | if (widget && (dd->control->textInteractionFlags() & Qt::TextEditable) && boundingRect().contains(event->pos())) { never evaluated: widget never evaluated: (dd->control->textInteractionFlags() & Qt::TextEditable) never evaluated: boundingRect().contains(event->pos()) | 0 |
10137 | qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), dd->clickCausedFocus); never executed (the execution status of this line is deduced): qt_widget_private(widget)->handleSoftwareInputPanel(event->button(), dd->clickCausedFocus); | - |
10138 | } | 0 |
10139 | dd->clickCausedFocus = 0; never executed (the execution status of this line is deduced): dd->clickCausedFocus = 0; | - |
10140 | dd->sendControlEvent(event); never executed (the execution status of this line is deduced): dd->sendControlEvent(event); | - |
10141 | } | 0 |
10142 | | - |
10143 | /*! | - |
10144 | \reimp | - |
10145 | */ | - |
10146 | void QGraphicsTextItem::mouseDoubleClickEvent(QGraphicsSceneMouseEvent *event) | - |
10147 | { | - |
10148 | if (dd->useDefaultImpl) { never evaluated: dd->useDefaultImpl | 0 |
10149 | QGraphicsItem::mouseDoubleClickEvent(event); never executed (the execution status of this line is deduced): QGraphicsItem::mouseDoubleClickEvent(event); | - |
10150 | return; | 0 |
10151 | } | - |
10152 | | - |
10153 | if (!hasFocus()) { never evaluated: !hasFocus() | 0 |
10154 | QGraphicsItem::mouseDoubleClickEvent(event); never executed (the execution status of this line is deduced): QGraphicsItem::mouseDoubleClickEvent(event); | - |
10155 | return; | 0 |
10156 | } | - |
10157 | | - |
10158 | dd->sendControlEvent(event); never executed (the execution status of this line is deduced): dd->sendControlEvent(event); | - |
10159 | } | 0 |
10160 | | - |
10161 | /*! | - |
10162 | \reimp | - |
10163 | */ | - |
10164 | void QGraphicsTextItem::contextMenuEvent(QGraphicsSceneContextMenuEvent *event) | - |
10165 | { | - |
10166 | dd->sendControlEvent(event); never executed (the execution status of this line is deduced): dd->sendControlEvent(event); | - |
10167 | } | 0 |
10168 | | - |
10169 | /*! | - |
10170 | \reimp | - |
10171 | */ | - |
10172 | void QGraphicsTextItem::keyPressEvent(QKeyEvent *event) | - |
10173 | { | - |
10174 | dd->sendControlEvent(event); never executed (the execution status of this line is deduced): dd->sendControlEvent(event); | - |
10175 | } | 0 |
10176 | | - |
10177 | /*! | - |
10178 | \reimp | - |
10179 | */ | - |
10180 | void QGraphicsTextItem::keyReleaseEvent(QKeyEvent *event) | - |
10181 | { | - |
10182 | dd->sendControlEvent(event); never executed (the execution status of this line is deduced): dd->sendControlEvent(event); | - |
10183 | } | 0 |
10184 | | - |
10185 | /*! | - |
10186 | \reimp | - |
10187 | */ | - |
10188 | void QGraphicsTextItem::focusInEvent(QFocusEvent *event) | - |
10189 | { | - |
10190 | dd->sendControlEvent(event); never executed (the execution status of this line is deduced): dd->sendControlEvent(event); | - |
10191 | if (event->reason() == Qt::MouseFocusReason) { never evaluated: event->reason() == Qt::MouseFocusReason | 0 |
10192 | dd->clickCausedFocus = 1; never executed (the execution status of this line is deduced): dd->clickCausedFocus = 1; | - |
10193 | } | 0 |
10194 | update(); never executed (the execution status of this line is deduced): update(); | - |
10195 | } | 0 |
10196 | | - |
10197 | /*! | - |
10198 | \reimp | - |
10199 | */ | - |
10200 | void QGraphicsTextItem::focusOutEvent(QFocusEvent *event) | - |
10201 | { | - |
10202 | dd->sendControlEvent(event); never executed (the execution status of this line is deduced): dd->sendControlEvent(event); | - |
10203 | update(); never executed (the execution status of this line is deduced): update(); | - |
10204 | } | 0 |
10205 | | - |
10206 | /*! | - |
10207 | \reimp | - |
10208 | */ | - |
10209 | void QGraphicsTextItem::dragEnterEvent(QGraphicsSceneDragDropEvent *event) | - |
10210 | { | - |
10211 | dd->sendControlEvent(event); never executed (the execution status of this line is deduced): dd->sendControlEvent(event); | - |
10212 | } | 0 |
10213 | | - |
10214 | /*! | - |
10215 | \reimp | - |
10216 | */ | - |
10217 | void QGraphicsTextItem::dragLeaveEvent(QGraphicsSceneDragDropEvent *event) | - |
10218 | { | - |
10219 | dd->sendControlEvent(event); never executed (the execution status of this line is deduced): dd->sendControlEvent(event); | - |
10220 | } | 0 |
10221 | | - |
10222 | /*! | - |
10223 | \reimp | - |
10224 | */ | - |
10225 | void QGraphicsTextItem::dragMoveEvent(QGraphicsSceneDragDropEvent *event) | - |
10226 | { | - |
10227 | dd->sendControlEvent(event); never executed (the execution status of this line is deduced): dd->sendControlEvent(event); | - |
10228 | } | 0 |
10229 | | - |
10230 | /*! | - |
10231 | \reimp | - |
10232 | */ | - |
10233 | void QGraphicsTextItem::dropEvent(QGraphicsSceneDragDropEvent *event) | - |
10234 | { | - |
10235 | dd->sendControlEvent(event); never executed (the execution status of this line is deduced): dd->sendControlEvent(event); | - |
10236 | } | 0 |
10237 | | - |
10238 | /*! | - |
10239 | \reimp | - |
10240 | */ | - |
10241 | void QGraphicsTextItem::inputMethodEvent(QInputMethodEvent *event) | - |
10242 | { | - |
10243 | dd->sendControlEvent(event); never executed (the execution status of this line is deduced): dd->sendControlEvent(event); | - |
10244 | } | 0 |
10245 | | - |
10246 | /*! | - |
10247 | \reimp | - |
10248 | */ | - |
10249 | void QGraphicsTextItem::hoverEnterEvent(QGraphicsSceneHoverEvent *event) | - |
10250 | { | - |
10251 | dd->sendControlEvent(event); never executed (the execution status of this line is deduced): dd->sendControlEvent(event); | - |
10252 | } | 0 |
10253 | | - |
10254 | /*! | - |
10255 | \reimp | - |
10256 | */ | - |
10257 | void QGraphicsTextItem::hoverMoveEvent(QGraphicsSceneHoverEvent *event) | - |
10258 | { | - |
10259 | dd->sendControlEvent(event); never executed (the execution status of this line is deduced): dd->sendControlEvent(event); | - |
10260 | } | 0 |
10261 | | - |
10262 | /*! | - |
10263 | \reimp | - |
10264 | */ | - |
10265 | void QGraphicsTextItem::hoverLeaveEvent(QGraphicsSceneHoverEvent *event) | - |
10266 | { | - |
10267 | dd->sendControlEvent(event); never executed (the execution status of this line is deduced): dd->sendControlEvent(event); | - |
10268 | } | 0 |
10269 | | - |
10270 | /*! | - |
10271 | \reimp | - |
10272 | */ | - |
10273 | QVariant QGraphicsTextItem::inputMethodQuery(Qt::InputMethodQuery query) const | - |
10274 | { | - |
10275 | QVariant v; never executed (the execution status of this line is deduced): QVariant v; | - |
10276 | if (dd->control) never evaluated: dd->control | 0 |
10277 | v = dd->control->inputMethodQuery(query); never executed: v = dd->control->inputMethodQuery(query); | 0 |
10278 | if (v.type() == QVariant::RectF) never evaluated: v.type() == QVariant::RectF | 0 |
10279 | v = v.toRectF().translated(-dd->controlOffset()); never executed: v = v.toRectF().translated(-dd->controlOffset()); | 0 |
10280 | else if (v.type() == QVariant::PointF) never evaluated: v.type() == QVariant::PointF | 0 |
10281 | v = v.toPointF() - dd->controlOffset(); never executed: v = v.toPointF() - dd->controlOffset(); | 0 |
10282 | else if (v.type() == QVariant::Rect) never evaluated: v.type() == QVariant::Rect | 0 |
10283 | v = v.toRect().translated(-dd->controlOffset().toPoint()); never executed: v = v.toRect().translated(-dd->controlOffset().toPoint()); | 0 |
10284 | else if (v.type() == QVariant::Point) never evaluated: v.type() == QVariant::Point | 0 |
10285 | v = v.toPoint() - dd->controlOffset().toPoint(); never executed: v = v.toPoint() - dd->controlOffset().toPoint(); | 0 |
10286 | return v; never executed: return v; | 0 |
10287 | } | - |
10288 | | - |
10289 | /*! | - |
10290 | \internal | - |
10291 | */ | - |
10292 | bool QGraphicsTextItem::supportsExtension(Extension extension) const | - |
10293 | { | - |
10294 | Q_UNUSED(extension); never executed (the execution status of this line is deduced): (void)extension;; | - |
10295 | return false; never executed: return false; | 0 |
10296 | } | - |
10297 | | - |
10298 | /*! | - |
10299 | \internal | - |
10300 | */ | - |
10301 | void QGraphicsTextItem::setExtension(Extension extension, const QVariant &variant) | - |
10302 | { | - |
10303 | Q_UNUSED(extension); never executed (the execution status of this line is deduced): (void)extension;; | - |
10304 | Q_UNUSED(variant); never executed (the execution status of this line is deduced): (void)variant;; | - |
10305 | } | 0 |
10306 | | - |
10307 | /*! | - |
10308 | \internal | - |
10309 | */ | - |
10310 | QVariant QGraphicsTextItem::extension(const QVariant &variant) const | - |
10311 | { | - |
10312 | Q_UNUSED(variant); never executed (the execution status of this line is deduced): (void)variant;; | - |
10313 | return QVariant(); never executed: return QVariant(); | 0 |
10314 | } | - |
10315 | | - |
10316 | /*! | - |
10317 | \internal | - |
10318 | */ | - |
10319 | void QGraphicsTextItemPrivate::_q_update(QRectF rect) | - |
10320 | { | - |
10321 | if (rect.isValid()) { partially evaluated: rect.isValid() yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
10322 | rect.translate(-controlOffset()); executed (the execution status of this line is deduced): rect.translate(-controlOffset()); | - |
10323 | } else { executed: } Execution Count:3 | 3 |
10324 | rect = boundingRect; never executed (the execution status of this line is deduced): rect = boundingRect; | - |
10325 | } | 0 |
10326 | if (rect.intersects(boundingRect)) partially evaluated: rect.intersects(boundingRect) yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
10327 | qq->update(rect); executed: qq->update(rect); Execution Count:3 | 3 |
10328 | } executed: } Execution Count:3 | 3 |
10329 | | - |
10330 | /*! | - |
10331 | \internal | - |
10332 | */ | - |
10333 | void QGraphicsTextItemPrivate::_q_updateBoundingRect(const QSizeF &size) | - |
10334 | { | - |
10335 | if (!control) return; // can't happen never executed: return; partially evaluated: !control no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
10336 | const QSizeF pageSize = control->document()->pageSize(); executed (the execution status of this line is deduced): const QSizeF pageSize = control->document()->pageSize(); | - |
10337 | // paged items have a constant (page) size | - |
10338 | if (size == boundingRect.size() || pageSize.height() != -1) partially evaluated: size == boundingRect.size() no Evaluation Count:0 | yes Evaluation Count:2 |
partially evaluated: pageSize.height() != -1 no Evaluation Count:0 | yes Evaluation Count:2 |
| 0-2 |
10339 | return; | 0 |
10340 | qq->prepareGeometryChange(); executed (the execution status of this line is deduced): qq->prepareGeometryChange(); | - |
10341 | boundingRect.setSize(size); executed (the execution status of this line is deduced): boundingRect.setSize(size); | - |
10342 | qq->update(); executed (the execution status of this line is deduced): qq->update(); | - |
10343 | } executed: } Execution Count:2 | 2 |
10344 | | - |
10345 | /*! | - |
10346 | \internal | - |
10347 | */ | - |
10348 | void QGraphicsTextItemPrivate::_q_ensureVisible(QRectF rect) | - |
10349 | { | - |
10350 | if (qq->hasFocus()) { partially evaluated: qq->hasFocus() no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
10351 | rect.translate(-controlOffset()); never executed (the execution status of this line is deduced): rect.translate(-controlOffset()); | - |
10352 | qq->ensureVisible(rect, /*xmargin=*/0, /*ymargin=*/0); never executed (the execution status of this line is deduced): qq->ensureVisible(rect, 0, 0); | - |
10353 | } | 0 |
10354 | } executed: } Execution Count:1 | 1 |
10355 | | - |
10356 | QWidgetTextControl *QGraphicsTextItemPrivate::textControl() const | - |
10357 | { | - |
10358 | if (!control) { evaluated: !control yes Evaluation Count:1 | yes Evaluation Count:1 |
| 1 |
10359 | QGraphicsTextItem *that = const_cast<QGraphicsTextItem *>(qq); executed (the execution status of this line is deduced): QGraphicsTextItem *that = const_cast<QGraphicsTextItem *>(qq); | - |
10360 | control = new QWidgetTextControl(that); executed (the execution status of this line is deduced): control = new QWidgetTextControl(that); | - |
10361 | control->setTextInteractionFlags(Qt::NoTextInteraction); executed (the execution status of this line is deduced): control->setTextInteractionFlags(Qt::NoTextInteraction); | - |
10362 | | - |
10363 | QObject::connect(control, SIGNAL(updateRequest(QRectF)), executed (the execution status of this line is deduced): QObject::connect(control, "2""updateRequest(QRectF)", | - |
10364 | qq, SLOT(_q_update(QRectF))); executed (the execution status of this line is deduced): qq, "1""_q_update(QRectF)"); | - |
10365 | QObject::connect(control, SIGNAL(documentSizeChanged(QSizeF)), executed (the execution status of this line is deduced): QObject::connect(control, "2""documentSizeChanged(QSizeF)", | - |
10366 | qq, SLOT(_q_updateBoundingRect(QSizeF))); executed (the execution status of this line is deduced): qq, "1""_q_updateBoundingRect(QSizeF)"); | - |
10367 | QObject::connect(control, SIGNAL(visibilityRequest(QRectF)), executed (the execution status of this line is deduced): QObject::connect(control, "2""visibilityRequest(QRectF)", | - |
10368 | qq, SLOT(_q_ensureVisible(QRectF))); executed (the execution status of this line is deduced): qq, "1""_q_ensureVisible(QRectF)"); | - |
10369 | QObject::connect(control, SIGNAL(linkActivated(QString)), executed (the execution status of this line is deduced): QObject::connect(control, "2""linkActivated(QString)", | - |
10370 | qq, SIGNAL(linkActivated(QString))); executed (the execution status of this line is deduced): qq, "2""linkActivated(QString)"); | - |
10371 | QObject::connect(control, SIGNAL(linkHovered(QString)), executed (the execution status of this line is deduced): QObject::connect(control, "2""linkHovered(QString)", | - |
10372 | qq, SIGNAL(linkHovered(QString))); executed (the execution status of this line is deduced): qq, "2""linkHovered(QString)"); | - |
10373 | | - |
10374 | const QSizeF pgSize = control->document()->pageSize(); executed (the execution status of this line is deduced): const QSizeF pgSize = control->document()->pageSize(); | - |
10375 | if (pgSize.height() != -1) { partially evaluated: pgSize.height() != -1 no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-1 |
10376 | qq->prepareGeometryChange(); never executed (the execution status of this line is deduced): qq->prepareGeometryChange(); | - |
10377 | that->dd->boundingRect.setSize(pgSize); never executed (the execution status of this line is deduced): that->dd->boundingRect.setSize(pgSize); | - |
10378 | qq->update(); never executed (the execution status of this line is deduced): qq->update(); | - |
10379 | } else { | 0 |
10380 | that->dd->_q_updateBoundingRect(control->size()); executed (the execution status of this line is deduced): that->dd->_q_updateBoundingRect(control->size()); | - |
10381 | } executed: } Execution Count:1 | 1 |
10382 | } | - |
10383 | return control; executed: return control; Execution Count:2 | 2 |
10384 | } | - |
10385 | | - |
10386 | /*! | - |
10387 | \internal | - |
10388 | */ | - |
10389 | bool QGraphicsTextItemPrivate::_q_mouseOnEdge(QGraphicsSceneMouseEvent *event) | - |
10390 | { | - |
10391 | QPainterPath path; never executed (the execution status of this line is deduced): QPainterPath path; | - |
10392 | path.addRect(qq->boundingRect()); never executed (the execution status of this line is deduced): path.addRect(qq->boundingRect()); | - |
10393 | | - |
10394 | QPainterPath docPath; never executed (the execution status of this line is deduced): QPainterPath docPath; | - |
10395 | const QTextFrameFormat format = control->document()->rootFrame()->frameFormat(); never executed (the execution status of this line is deduced): const QTextFrameFormat format = control->document()->rootFrame()->frameFormat(); | - |
10396 | docPath.addRect( never executed (the execution status of this line is deduced): docPath.addRect( | - |
10397 | qq->boundingRect().adjusted( never executed (the execution status of this line is deduced): qq->boundingRect().adjusted( | - |
10398 | format.leftMargin(), never executed (the execution status of this line is deduced): format.leftMargin(), | - |
10399 | format.topMargin(), never executed (the execution status of this line is deduced): format.topMargin(), | - |
10400 | -format.rightMargin(), never executed (the execution status of this line is deduced): -format.rightMargin(), | - |
10401 | -format.bottomMargin())); never executed (the execution status of this line is deduced): -format.bottomMargin())); | - |
10402 | | - |
10403 | return path.subtracted(docPath).contains(event->pos()); never executed: return path.subtracted(docPath).contains(event->pos()); | 0 |
10404 | } | - |
10405 | | - |
10406 | /*! | - |
10407 | \fn QGraphicsTextItem::linkActivated(const QString &link) | - |
10408 | | - |
10409 | This signal is emitted when the user clicks on a link on a text item | - |
10410 | that enables Qt::LinksAccessibleByMouse or Qt::LinksAccessibleByKeyboard. | - |
10411 | \a link is the link that was clicked. | - |
10412 | | - |
10413 | \sa setTextInteractionFlags() | - |
10414 | */ | - |
10415 | | - |
10416 | /*! | - |
10417 | \fn QGraphicsTextItem::linkHovered(const QString &link) | - |
10418 | | - |
10419 | This signal is emitted when the user hovers over a link on a text item | - |
10420 | that enables Qt::LinksAccessibleByMouse. \a link is | - |
10421 | the link that was hovered over. | - |
10422 | | - |
10423 | \sa setTextInteractionFlags() | - |
10424 | */ | - |
10425 | | - |
10426 | /*! | - |
10427 | Sets the flags \a flags to specify how the text item should react to user | - |
10428 | input. | - |
10429 | | - |
10430 | The default for a QGraphicsTextItem is Qt::NoTextInteraction. This function | - |
10431 | also affects the ItemIsFocusable QGraphicsItem flag by setting it if \a flags | - |
10432 | is different from Qt::NoTextInteraction and clearing it otherwise. | - |
10433 | | - |
10434 | By default, the text is read-only. To transform the item into an editor, | - |
10435 | set the Qt::TextEditable flag. | - |
10436 | */ | - |
10437 | void QGraphicsTextItem::setTextInteractionFlags(Qt::TextInteractionFlags flags) | - |
10438 | { | - |
10439 | if (flags == Qt::NoTextInteraction) never evaluated: flags == Qt::NoTextInteraction | 0 |
10440 | setFlags(this->flags() & ~(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod)); never executed: setFlags(this->flags() & ~(QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod)); | 0 |
10441 | else | - |
10442 | setFlags(this->flags() | QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod); never executed: setFlags(this->flags() | QGraphicsItem::ItemIsFocusable | QGraphicsItem::ItemAcceptsInputMethod); | 0 |
10443 | | - |
10444 | dd->textControl()->setTextInteractionFlags(flags); never executed (the execution status of this line is deduced): dd->textControl()->setTextInteractionFlags(flags); | - |
10445 | } | 0 |
10446 | | - |
10447 | /*! | - |
10448 | Returns the current text interaction flags. | - |
10449 | | - |
10450 | \sa setTextInteractionFlags() | - |
10451 | */ | - |
10452 | Qt::TextInteractionFlags QGraphicsTextItem::textInteractionFlags() const | - |
10453 | { | - |
10454 | if (!dd->control) never evaluated: !dd->control | 0 |
10455 | return Qt::NoTextInteraction; never executed: return Qt::NoTextInteraction; | 0 |
10456 | return dd->control->textInteractionFlags(); never executed: return dd->control->textInteractionFlags(); | 0 |
10457 | } | - |
10458 | | - |
10459 | /*! | - |
10460 | \since 4.5 | - |
10461 | | - |
10462 | If \a b is true, the \uicontrol Tab key will cause the widget to change focus; | - |
10463 | otherwise, the tab key will insert a tab into the document. | - |
10464 | | - |
10465 | In some occasions text edits should not allow the user to input tabulators | - |
10466 | or change indentation using the \uicontrol Tab key, as this breaks the focus | - |
10467 | chain. The default is false. | - |
10468 | | - |
10469 | \sa tabChangesFocus(), ItemIsFocusable, textInteractionFlags() | - |
10470 | */ | - |
10471 | void QGraphicsTextItem::setTabChangesFocus(bool b) | - |
10472 | { | - |
10473 | dd->tabChangesFocus = b; never executed (the execution status of this line is deduced): dd->tabChangesFocus = b; | - |
10474 | } | 0 |
10475 | | - |
10476 | /*! | - |
10477 | \since 4.5 | - |
10478 | | - |
10479 | Returns true if the \uicontrol Tab key will cause the widget to change focus; | - |
10480 | otherwise, false is returned. | - |
10481 | | - |
10482 | By default, this behavior is disabled, and this function will return false. | - |
10483 | | - |
10484 | \sa setTabChangesFocus() | - |
10485 | */ | - |
10486 | bool QGraphicsTextItem::tabChangesFocus() const | - |
10487 | { | - |
10488 | return dd->tabChangesFocus; never executed: return dd->tabChangesFocus; | 0 |
10489 | } | - |
10490 | | - |
10491 | /*! | - |
10492 | \property QGraphicsTextItem::openExternalLinks | - |
10493 | | - |
10494 | Specifies whether QGraphicsTextItem should automatically open links using | - |
10495 | QDesktopServices::openUrl() instead of emitting the | - |
10496 | linkActivated signal. | - |
10497 | | - |
10498 | The default value is false. | - |
10499 | */ | - |
10500 | void QGraphicsTextItem::setOpenExternalLinks(bool open) | - |
10501 | { | - |
10502 | dd->textControl()->setOpenExternalLinks(open); never executed (the execution status of this line is deduced): dd->textControl()->setOpenExternalLinks(open); | - |
10503 | } | 0 |
10504 | | - |
10505 | bool QGraphicsTextItem::openExternalLinks() const | - |
10506 | { | - |
10507 | if (!dd->control) never evaluated: !dd->control | 0 |
10508 | return false; never executed: return false; | 0 |
10509 | return dd->control->openExternalLinks(); never executed: return dd->control->openExternalLinks(); | 0 |
10510 | } | - |
10511 | | - |
10512 | /*! | - |
10513 | \property QGraphicsTextItem::textCursor | - |
10514 | | - |
10515 | This property represents the visible text cursor in an editable | - |
10516 | text item. | - |
10517 | | - |
10518 | By default, if the item's text has not been set, this property | - |
10519 | contains a null text cursor; otherwise it contains a text cursor | - |
10520 | placed at the start of the item's document. | - |
10521 | */ | - |
10522 | void QGraphicsTextItem::setTextCursor(const QTextCursor &cursor) | - |
10523 | { | - |
10524 | dd->textControl()->setTextCursor(cursor); never executed (the execution status of this line is deduced): dd->textControl()->setTextCursor(cursor); | - |
10525 | } | 0 |
10526 | | - |
10527 | QTextCursor QGraphicsTextItem::textCursor() const | - |
10528 | { | - |
10529 | if (!dd->control) never evaluated: !dd->control | 0 |
10530 | return QTextCursor(); never executed: return QTextCursor(); | 0 |
10531 | return dd->control->textCursor(); never executed: return dd->control->textCursor(); | 0 |
10532 | } | - |
10533 | | - |
10534 | class QGraphicsSimpleTextItemPrivate : public QAbstractGraphicsShapeItemPrivate | - |
10535 | { | - |
10536 | Q_DECLARE_PUBLIC(QGraphicsSimpleTextItem) | - |
10537 | public: | - |
10538 | inline QGraphicsSimpleTextItemPrivate() { | - |
10539 | pen.setStyle(Qt::NoPen); never executed (the execution status of this line is deduced): pen.setStyle(Qt::NoPen); | - |
10540 | brush.setStyle(Qt::SolidPattern); never executed (the execution status of this line is deduced): brush.setStyle(Qt::SolidPattern); | - |
10541 | } | 0 |
10542 | QString text; | - |
10543 | QFont font; | - |
10544 | QRectF boundingRect; | - |
10545 | | - |
10546 | void updateBoundingRect(); | - |
10547 | }; | - |
10548 | | - |
10549 | static QRectF setupTextLayout(QTextLayout *layout) | - |
10550 | { | - |
10551 | layout->setCacheEnabled(true); never executed (the execution status of this line is deduced): layout->setCacheEnabled(true); | - |
10552 | layout->beginLayout(); never executed (the execution status of this line is deduced): layout->beginLayout(); | - |
10553 | while (layout->createLine().isValid()) never evaluated: layout->createLine().isValid() | 0 |
10554 | ; | 0 |
10555 | layout->endLayout(); never executed (the execution status of this line is deduced): layout->endLayout(); | - |
10556 | qreal maxWidth = 0; never executed (the execution status of this line is deduced): qreal maxWidth = 0; | - |
10557 | qreal y = 0; never executed (the execution status of this line is deduced): qreal y = 0; | - |
10558 | for (int i = 0; i < layout->lineCount(); ++i) { never evaluated: i < layout->lineCount() | 0 |
10559 | QTextLine line = layout->lineAt(i); never executed (the execution status of this line is deduced): QTextLine line = layout->lineAt(i); | - |
10560 | maxWidth = qMax(maxWidth, line.naturalTextWidth()); never executed (the execution status of this line is deduced): maxWidth = qMax(maxWidth, line.naturalTextWidth()); | - |
10561 | line.setPosition(QPointF(0, y)); never executed (the execution status of this line is deduced): line.setPosition(QPointF(0, y)); | - |
10562 | y += line.height(); never executed (the execution status of this line is deduced): y += line.height(); | - |
10563 | } | 0 |
10564 | return QRectF(0, 0, maxWidth, y); never executed: return QRectF(0, 0, maxWidth, y); | 0 |
10565 | } | - |
10566 | | - |
10567 | void QGraphicsSimpleTextItemPrivate::updateBoundingRect() | - |
10568 | { | - |
10569 | Q_Q(QGraphicsSimpleTextItem); never executed (the execution status of this line is deduced): QGraphicsSimpleTextItem * const q = q_func(); | - |
10570 | QRectF br; never executed (the execution status of this line is deduced): QRectF br; | - |
10571 | if (text.isEmpty()) { never evaluated: text.isEmpty() | 0 |
10572 | br = QRectF(); never executed (the execution status of this line is deduced): br = QRectF(); | - |
10573 | } else { | 0 |
10574 | QString tmp = text; never executed (the execution status of this line is deduced): QString tmp = text; | - |
10575 | tmp.replace(QLatin1Char('\n'), QChar::LineSeparator); never executed (the execution status of this line is deduced): tmp.replace(QLatin1Char('\n'), QChar::LineSeparator); | - |
10576 | QStackTextEngine engine(tmp, font); never executed (the execution status of this line is deduced): QStackTextEngine engine(tmp, font); | - |
10577 | QTextLayout layout(&engine); never executed (the execution status of this line is deduced): QTextLayout layout(&engine); | - |
10578 | br = setupTextLayout(&layout); never executed (the execution status of this line is deduced): br = setupTextLayout(&layout); | - |
10579 | } | 0 |
10580 | if (br != boundingRect) { never evaluated: br != boundingRect | 0 |
10581 | q->prepareGeometryChange(); never executed (the execution status of this line is deduced): q->prepareGeometryChange(); | - |
10582 | boundingRect = br; never executed (the execution status of this line is deduced): boundingRect = br; | - |
10583 | q->update(); never executed (the execution status of this line is deduced): q->update(); | - |
10584 | } | 0 |
10585 | } | 0 |
10586 | | - |
10587 | /*! | - |
10588 | \class QGraphicsSimpleTextItem | - |
10589 | \brief The QGraphicsSimpleTextItem class provides a simple text path item | - |
10590 | that you can add to a QGraphicsScene. | - |
10591 | \since 4.2 | - |
10592 | \ingroup graphicsview-api | - |
10593 | \inmodule QtWidgets | - |
10594 | | - |
10595 | To set the item's text, you can either pass a QString to | - |
10596 | QGraphicsSimpleTextItem's constructor, or call setText() to change the | - |
10597 | text later. To set the text fill color, call setBrush(). | - |
10598 | | - |
10599 | The simple text item can have both a fill and an outline; setBrush() will | - |
10600 | set the text fill (i.e., text color), and setPen() sets the pen that will | - |
10601 | be used to draw the text outline. (The latter can be slow, especially for | - |
10602 | complex pens, and items with long text content.) If all you want is to | - |
10603 | draw a simple line of text, you should call setBrush() only, and leave the | - |
10604 | pen unset; QGraphicsSimpleTextItem's pen is by default Qt::NoPen. | - |
10605 | | - |
10606 | QGraphicsSimpleTextItem uses the text's formatted size and the associated | - |
10607 | font to provide a reasonable implementation of boundingRect(), shape(), | - |
10608 | and contains(). You can set the font by calling setFont(). | - |
10609 | | - |
10610 | QGraphicsSimpleText does not display rich text; instead, you can use | - |
10611 | QGraphicsTextItem, which provides full text control capabilities. | - |
10612 | | - |
10613 | \image graphicsview-simpletextitem.png | - |
10614 | | - |
10615 | \sa QGraphicsTextItem, QGraphicsPathItem, QGraphicsRectItem, | - |
10616 | QGraphicsEllipseItem, QGraphicsPixmapItem, QGraphicsPolygonItem, | - |
10617 | QGraphicsLineItem, {Graphics View Framework} | - |
10618 | */ | - |
10619 | | - |
10620 | /*! | - |
10621 | Constructs a QGraphicsSimpleTextItem. | - |
10622 | | - |
10623 | \a parent is passed to QGraphicsItem's constructor. | - |
10624 | | - |
10625 | \sa QGraphicsScene::addItem() | - |
10626 | */ | - |
10627 | QGraphicsSimpleTextItem::QGraphicsSimpleTextItem(QGraphicsItem *parent) | - |
10628 | : QAbstractGraphicsShapeItem(*new QGraphicsSimpleTextItemPrivate, parent) | - |
10629 | { | - |
10630 | } | 0 |
10631 | | - |
10632 | /*! | - |
10633 | Constructs a QGraphicsSimpleTextItem, using \a text as the default plain text. | - |
10634 | | - |
10635 | \a parent is passed to QGraphicsItem's constructor. | - |
10636 | | - |
10637 | \sa QGraphicsScene::addItem() | - |
10638 | */ | - |
10639 | QGraphicsSimpleTextItem::QGraphicsSimpleTextItem(const QString &text, QGraphicsItem *parent) | - |
10640 | : QAbstractGraphicsShapeItem(*new QGraphicsSimpleTextItemPrivate, parent) | - |
10641 | { | - |
10642 | setText(text); never executed (the execution status of this line is deduced): setText(text); | - |
10643 | } | 0 |
10644 | | - |
10645 | /*! | - |
10646 | Destroys the QGraphicsSimpleTextItem. | - |
10647 | */ | - |
10648 | QGraphicsSimpleTextItem::~QGraphicsSimpleTextItem() | - |
10649 | { | - |
10650 | } | - |
10651 | | - |
10652 | /*! | - |
10653 | Sets the item's text to \a text. The text will be displayed as | - |
10654 | plain text. Newline characters ('\\n') as well as characters of | - |
10655 | type QChar::LineSeparator will cause item to break the text into | - |
10656 | multiple lines. | - |
10657 | */ | - |
10658 | void QGraphicsSimpleTextItem::setText(const QString &text) | - |
10659 | { | - |
10660 | Q_D(QGraphicsSimpleTextItem); never executed (the execution status of this line is deduced): QGraphicsSimpleTextItemPrivate * const d = d_func(); | - |
10661 | if (d->text == text) never evaluated: d->text == text | 0 |
10662 | return; | 0 |
10663 | d->text = text; never executed (the execution status of this line is deduced): d->text = text; | - |
10664 | d->updateBoundingRect(); never executed (the execution status of this line is deduced): d->updateBoundingRect(); | - |
10665 | update(); never executed (the execution status of this line is deduced): update(); | - |
10666 | } | 0 |
10667 | | - |
10668 | /*! | - |
10669 | Returns the item's text. | - |
10670 | */ | - |
10671 | QString QGraphicsSimpleTextItem::text() const | - |
10672 | { | - |
10673 | Q_D(const QGraphicsSimpleTextItem); never executed (the execution status of this line is deduced): const QGraphicsSimpleTextItemPrivate * const d = d_func(); | - |
10674 | return d->text; never executed: return d->text; | 0 |
10675 | } | - |
10676 | | - |
10677 | /*! | - |
10678 | Sets the font that is used to draw the item's text to \a font. | - |
10679 | */ | - |
10680 | void QGraphicsSimpleTextItem::setFont(const QFont &font) | - |
10681 | { | - |
10682 | Q_D(QGraphicsSimpleTextItem); never executed (the execution status of this line is deduced): QGraphicsSimpleTextItemPrivate * const d = d_func(); | - |
10683 | d->font = font; never executed (the execution status of this line is deduced): d->font = font; | - |
10684 | d->updateBoundingRect(); never executed (the execution status of this line is deduced): d->updateBoundingRect(); | - |
10685 | } | 0 |
10686 | | - |
10687 | /*! | - |
10688 | Returns the font that is used to draw the item's text. | - |
10689 | */ | - |
10690 | QFont QGraphicsSimpleTextItem::font() const | - |
10691 | { | - |
10692 | Q_D(const QGraphicsSimpleTextItem); never executed (the execution status of this line is deduced): const QGraphicsSimpleTextItemPrivate * const d = d_func(); | - |
10693 | return d->font; never executed: return d->font; | 0 |
10694 | } | - |
10695 | | - |
10696 | /*! | - |
10697 | \reimp | - |
10698 | */ | - |
10699 | QRectF QGraphicsSimpleTextItem::boundingRect() const | - |
10700 | { | - |
10701 | Q_D(const QGraphicsSimpleTextItem); never executed (the execution status of this line is deduced): const QGraphicsSimpleTextItemPrivate * const d = d_func(); | - |
10702 | return d->boundingRect; never executed: return d->boundingRect; | 0 |
10703 | } | - |
10704 | | - |
10705 | /*! | - |
10706 | \reimp | - |
10707 | */ | - |
10708 | QPainterPath QGraphicsSimpleTextItem::shape() const | - |
10709 | { | - |
10710 | Q_D(const QGraphicsSimpleTextItem); never executed (the execution status of this line is deduced): const QGraphicsSimpleTextItemPrivate * const d = d_func(); | - |
10711 | QPainterPath path; never executed (the execution status of this line is deduced): QPainterPath path; | - |
10712 | path.addRect(d->boundingRect); never executed (the execution status of this line is deduced): path.addRect(d->boundingRect); | - |
10713 | return path; never executed: return path; | 0 |
10714 | } | - |
10715 | | - |
10716 | /*! | - |
10717 | \reimp | - |
10718 | */ | - |
10719 | bool QGraphicsSimpleTextItem::contains(const QPointF &point) const | - |
10720 | { | - |
10721 | Q_D(const QGraphicsSimpleTextItem); never executed (the execution status of this line is deduced): const QGraphicsSimpleTextItemPrivate * const d = d_func(); | - |
10722 | return d->boundingRect.contains(point); never executed: return d->boundingRect.contains(point); | 0 |
10723 | } | - |
10724 | | - |
10725 | /*! | - |
10726 | \reimp | - |
10727 | */ | - |
10728 | void QGraphicsSimpleTextItem::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, QWidget *widget) | - |
10729 | { | - |
10730 | Q_UNUSED(widget); never executed (the execution status of this line is deduced): (void)widget;; | - |
10731 | Q_D(QGraphicsSimpleTextItem); never executed (the execution status of this line is deduced): QGraphicsSimpleTextItemPrivate * const d = d_func(); | - |
10732 | | - |
10733 | painter->setFont(d->font); never executed (the execution status of this line is deduced): painter->setFont(d->font); | - |
10734 | | - |
10735 | QString tmp = d->text; never executed (the execution status of this line is deduced): QString tmp = d->text; | - |
10736 | tmp.replace(QLatin1Char('\n'), QChar::LineSeparator); never executed (the execution status of this line is deduced): tmp.replace(QLatin1Char('\n'), QChar::LineSeparator); | - |
10737 | QStackTextEngine engine(tmp, d->font); never executed (the execution status of this line is deduced): QStackTextEngine engine(tmp, d->font); | - |
10738 | QTextLayout layout(&engine); never executed (the execution status of this line is deduced): QTextLayout layout(&engine); | - |
10739 | setupTextLayout(&layout); never executed (the execution status of this line is deduced): setupTextLayout(&layout); | - |
10740 | | - |
10741 | QPen p; never executed (the execution status of this line is deduced): QPen p; | - |
10742 | p.setBrush(d->brush); never executed (the execution status of this line is deduced): p.setBrush(d->brush); | - |
10743 | painter->setPen(p); never executed (the execution status of this line is deduced): painter->setPen(p); | - |
10744 | if (d->pen.style() == Qt::NoPen && d->brush.style() == Qt::SolidPattern) { never evaluated: d->pen.style() == Qt::NoPen never evaluated: d->brush.style() == Qt::SolidPattern | 0 |
10745 | painter->setBrush(Qt::NoBrush); never executed (the execution status of this line is deduced): painter->setBrush(Qt::NoBrush); | - |
10746 | } else { | 0 |
10747 | QTextLayout::FormatRange range; never executed (the execution status of this line is deduced): QTextLayout::FormatRange range; | - |
10748 | range.start = 0; never executed (the execution status of this line is deduced): range.start = 0; | - |
10749 | range.length = layout.text().length(); never executed (the execution status of this line is deduced): range.length = layout.text().length(); | - |
10750 | range.format.setTextOutline(d->pen); never executed (the execution status of this line is deduced): range.format.setTextOutline(d->pen); | - |
10751 | QList<QTextLayout::FormatRange> formats; never executed (the execution status of this line is deduced): QList<QTextLayout::FormatRange> formats; | - |
10752 | formats.append(range); never executed (the execution status of this line is deduced): formats.append(range); | - |
10753 | layout.setAdditionalFormats(formats); never executed (the execution status of this line is deduced): layout.setAdditionalFormats(formats); | - |
10754 | } | 0 |
10755 | | - |
10756 | layout.draw(painter, QPointF(0, 0)); never executed (the execution status of this line is deduced): layout.draw(painter, QPointF(0, 0)); | - |
10757 | | - |
10758 | if (option->state & (QStyle::State_Selected | QStyle::State_HasFocus)) never evaluated: option->state & (QStyle::State_Selected | QStyle::State_HasFocus) | 0 |
10759 | qt_graphicsItem_highlightSelected(this, painter, option); never executed: qt_graphicsItem_highlightSelected(this, painter, option); | 0 |
10760 | } | 0 |
10761 | | - |
10762 | /*! | - |
10763 | \reimp | - |
10764 | */ | - |
10765 | bool QGraphicsSimpleTextItem::isObscuredBy(const QGraphicsItem *item) const | - |
10766 | { | - |
10767 | return QAbstractGraphicsShapeItem::isObscuredBy(item); never executed: return QAbstractGraphicsShapeItem::isObscuredBy(item); | 0 |
10768 | } | - |
10769 | | - |
10770 | /*! | - |
10771 | \reimp | - |
10772 | */ | - |
10773 | QPainterPath QGraphicsSimpleTextItem::opaqueArea() const | - |
10774 | { | - |
10775 | return QAbstractGraphicsShapeItem::opaqueArea(); never executed: return QAbstractGraphicsShapeItem::opaqueArea(); | 0 |
10776 | } | - |
10777 | | - |
10778 | /*! | - |
10779 | \reimp | - |
10780 | */ | - |
10781 | int QGraphicsSimpleTextItem::type() const | - |
10782 | { | - |
10783 | return Type; never executed: return Type; | 0 |
10784 | } | - |
10785 | | - |
10786 | /*! | - |
10787 | \internal | - |
10788 | */ | - |
10789 | bool QGraphicsSimpleTextItem::supportsExtension(Extension extension) const | - |
10790 | { | - |
10791 | Q_UNUSED(extension); never executed (the execution status of this line is deduced): (void)extension;; | - |
10792 | return false; never executed: return false; | 0 |
10793 | } | - |
10794 | | - |
10795 | /*! | - |
10796 | \internal | - |
10797 | */ | - |
10798 | void QGraphicsSimpleTextItem::setExtension(Extension extension, const QVariant &variant) | - |
10799 | { | - |
10800 | Q_UNUSED(extension); never executed (the execution status of this line is deduced): (void)extension;; | - |
10801 | Q_UNUSED(variant); never executed (the execution status of this line is deduced): (void)variant;; | - |
10802 | } | 0 |
10803 | | - |
10804 | /*! | - |
10805 | \internal | - |
10806 | */ | - |
10807 | QVariant QGraphicsSimpleTextItem::extension(const QVariant &variant) const | - |
10808 | { | - |
10809 | Q_UNUSED(variant); never executed (the execution status of this line is deduced): (void)variant;; | - |
10810 | return QVariant(); never executed: return QVariant(); | 0 |
10811 | } | - |
10812 | | - |
10813 | /*! | - |
10814 | \class QGraphicsItemGroup | - |
10815 | \brief The QGraphicsItemGroup class provides a container that treats | - |
10816 | a group of items as a single item. | - |
10817 | \since 4.2 | - |
10818 | \ingroup graphicsview-api | - |
10819 | \inmodule QtWidgets | - |
10820 | | - |
10821 | A QGraphicsItemGroup is a special type of compound item that | - |
10822 | treats itself and all its children as one item (i.e., all events | - |
10823 | and geometries for all children are merged together). It's common | - |
10824 | to use item groups in presentation tools, when the user wants to | - |
10825 | group several smaller items into one big item in order to simplify | - |
10826 | moving and copying of items. | - |
10827 | | - |
10828 | If all you want is to store items inside other items, you can use | - |
10829 | any QGraphicsItem directly by passing a suitable parent to | - |
10830 | setParentItem(). | - |
10831 | | - |
10832 | The boundingRect() function of QGraphicsItemGroup returns the | - |
10833 | bounding rectangle of all items in the item group. | - |
10834 | QGraphicsItemGroup ignores the ItemIgnoresTransformations flag on | - |
10835 | its children (i.e., with respect to the geometry of the group | - |
10836 | item, the children are treated as if they were transformable). | - |
10837 | | - |
10838 | There are two ways to construct an item group. The easiest and | - |
10839 | most common approach is to pass a list of items (e.g., all | - |
10840 | selected items) to QGraphicsScene::createItemGroup(), which | - |
10841 | returns a new QGraphicsItemGroup item. The other approach is to | - |
10842 | manually construct a QGraphicsItemGroup item, add it to the scene | - |
10843 | calling QGraphicsScene::addItem(), and then add items to the group | - |
10844 | manually, one at a time by calling addToGroup(). To dismantle | - |
10845 | ("ungroup") an item group, you can either call | - |
10846 | QGraphicsScene::destroyItemGroup(), or you can manually remove all | - |
10847 | items from the group by calling removeFromGroup(). | - |
10848 | | - |
10849 | \snippet code/src_gui_graphicsview_qgraphicsitem.cpp 17 | - |
10850 | | - |
10851 | The operation of adding and removing items preserves the items' | - |
10852 | scene-relative position and transformation, as opposed to calling | - |
10853 | setParentItem(), where only the child item's parent-relative | - |
10854 | position and transformation are kept. | - |
10855 | | - |
10856 | The addtoGroup() function reparents the target item to this item | - |
10857 | group, keeping the item's position and transformation intact | - |
10858 | relative to the scene. Visually, this means that items added via | - |
10859 | addToGroup() will remain completely unchanged as a result of this | - |
10860 | operation, regardless of the item or the group's current position | - |
10861 | or transformation; although the item's position and matrix are | - |
10862 | likely to change. | - |
10863 | | - |
10864 | The removeFromGroup() function has similar semantics to | - |
10865 | setParentItem(); it reparents the item to the parent item of the | - |
10866 | item group. As with addToGroup(), the item's scene-relative | - |
10867 | position and transformation remain intact. | - |
10868 | | - |
10869 | \sa QGraphicsItem, {Graphics View Framework} | - |
10870 | */ | - |
10871 | | - |
10872 | class QGraphicsItemGroupPrivate : public QGraphicsItemPrivate | - |
10873 | { | - |
10874 | public: | - |
10875 | QRectF itemsBoundingRect; | - |
10876 | }; | - |
10877 | | - |
10878 | /*! | - |
10879 | Constructs a QGraphicsItemGroup. \a parent is passed to QGraphicsItem's | - |
10880 | constructor. | - |
10881 | | - |
10882 | \sa QGraphicsScene::addItem() | - |
10883 | */ | - |
10884 | QGraphicsItemGroup::QGraphicsItemGroup(QGraphicsItem *parent) | - |
10885 | : QGraphicsItem(*new QGraphicsItemGroupPrivate, parent) | - |
10886 | { | - |
10887 | setHandlesChildEvents(true); never executed (the execution status of this line is deduced): setHandlesChildEvents(true); | - |
10888 | } | 0 |
10889 | | - |
10890 | /*! | - |
10891 | Destroys the QGraphicsItemGroup. | - |
10892 | */ | - |
10893 | QGraphicsItemGroup::~QGraphicsItemGroup() | - |
10894 | { | - |
10895 | } | - |
10896 | | - |
10897 | /*! | - |
10898 | Adds the given \a item and item's child items to this item group. | - |
10899 | The item and child items will be reparented to this group, but its | - |
10900 | position and transformation relative to the scene will stay intact. | - |
10901 | | - |
10902 | \sa removeFromGroup(), QGraphicsScene::createItemGroup() | - |
10903 | */ | - |
10904 | void QGraphicsItemGroup::addToGroup(QGraphicsItem *item) | - |
10905 | { | - |
10906 | Q_D(QGraphicsItemGroup); never executed (the execution status of this line is deduced): QGraphicsItemGroupPrivate * const d = d_func(); | - |
10907 | if (!item) { | 0 |
10908 | qWarning("QGraphicsItemGroup::addToGroup: cannot add null item"); never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 10908, __PRETTY_FUNCTION__).warning("QGraphicsItemGroup::addToGroup: cannot add null item"); | - |
10909 | return; | 0 |
10910 | } | - |
10911 | if (item == this) { never evaluated: item == this | 0 |
10912 | qWarning("QGraphicsItemGroup::addToGroup: cannot add a group to itself"); never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 10912, __PRETTY_FUNCTION__).warning("QGraphicsItemGroup::addToGroup: cannot add a group to itself"); | - |
10913 | return; | 0 |
10914 | } | - |
10915 | | - |
10916 | // COMBINE | - |
10917 | bool ok; never executed (the execution status of this line is deduced): bool ok; | - |
10918 | QTransform itemTransform = item->itemTransform(this, &ok); never executed (the execution status of this line is deduced): QTransform itemTransform = item->itemTransform(this, &ok); | - |
10919 | | - |
10920 | if (!ok) { | 0 |
10921 | qWarning("QGraphicsItemGroup::addToGroup: could not find a valid transformation from item to group coordinates"); never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 10921, __PRETTY_FUNCTION__).warning("QGraphicsItemGroup::addToGroup: could not find a valid transformation from item to group coordinates"); | - |
10922 | return; | 0 |
10923 | } | - |
10924 | | - |
10925 | QTransform newItemTransform(itemTransform); never executed (the execution status of this line is deduced): QTransform newItemTransform(itemTransform); | - |
10926 | item->setPos(mapFromItem(item, 0, 0)); never executed (the execution status of this line is deduced): item->setPos(mapFromItem(item, 0, 0)); | - |
10927 | item->setParentItem(this); never executed (the execution status of this line is deduced): item->setParentItem(this); | - |
10928 | | - |
10929 | // removing position from translation component of the new transform | - |
10930 | if (!item->pos().isNull()) never evaluated: !item->pos().isNull() | 0 |
10931 | newItemTransform *= QTransform::fromTranslate(-item->x(), -item->y()); never executed: newItemTransform *= QTransform::fromTranslate(-item->x(), -item->y()); | 0 |
10932 | | - |
10933 | // removing additional transformations properties applied with itemTransform() | - |
10934 | QPointF origin = item->transformOriginPoint(); never executed (the execution status of this line is deduced): QPointF origin = item->transformOriginPoint(); | - |
10935 | QMatrix4x4 m; never executed (the execution status of this line is deduced): QMatrix4x4 m; | - |
10936 | QList<QGraphicsTransform*> transformList = item->transformations(); never executed (the execution status of this line is deduced): QList<QGraphicsTransform*> transformList = item->transformations(); | - |
10937 | for (int i = 0; i < transformList.size(); ++i) never evaluated: i < transformList.size() | 0 |
10938 | transformList.at(i)->applyTo(&m); never executed: transformList.at(i)->applyTo(&m); | 0 |
10939 | newItemTransform *= m.toTransform().inverted(); never executed (the execution status of this line is deduced): newItemTransform *= m.toTransform().inverted(); | - |
10940 | newItemTransform.translate(origin.x(), origin.y()); never executed (the execution status of this line is deduced): newItemTransform.translate(origin.x(), origin.y()); | - |
10941 | newItemTransform.rotate(-item->rotation()); never executed (the execution status of this line is deduced): newItemTransform.rotate(-item->rotation()); | - |
10942 | newItemTransform.scale(1/item->scale(), 1/item->scale()); never executed (the execution status of this line is deduced): newItemTransform.scale(1/item->scale(), 1/item->scale()); | - |
10943 | newItemTransform.translate(-origin.x(), -origin.y()); never executed (the execution status of this line is deduced): newItemTransform.translate(-origin.x(), -origin.y()); | - |
10944 | | - |
10945 | // ### Expensive, we could maybe use dirtySceneTransform bit for optimization | - |
10946 | | - |
10947 | item->setTransform(newItemTransform); never executed (the execution status of this line is deduced): item->setTransform(newItemTransform); | - |
10948 | item->d_func()->setIsMemberOfGroup(true); never executed (the execution status of this line is deduced): item->d_func()->setIsMemberOfGroup(true); | - |
10949 | prepareGeometryChange(); never executed (the execution status of this line is deduced): prepareGeometryChange(); | - |
10950 | d->itemsBoundingRect |= itemTransform.mapRect(item->boundingRect() | item->childrenBoundingRect()); never executed (the execution status of this line is deduced): d->itemsBoundingRect |= itemTransform.mapRect(item->boundingRect() | item->childrenBoundingRect()); | - |
10951 | update(); never executed (the execution status of this line is deduced): update(); | - |
10952 | } | 0 |
10953 | | - |
10954 | /*! | - |
10955 | Removes the specified \a item from this group. The item will be | - |
10956 | reparented to this group's parent item, or to 0 if this group has | - |
10957 | no parent. Its position and transformation relative to the scene | - |
10958 | will stay intact. | - |
10959 | | - |
10960 | \sa addToGroup(), QGraphicsScene::destroyItemGroup() | - |
10961 | */ | - |
10962 | void QGraphicsItemGroup::removeFromGroup(QGraphicsItem *item) | - |
10963 | { | - |
10964 | Q_D(QGraphicsItemGroup); never executed (the execution status of this line is deduced): QGraphicsItemGroupPrivate * const d = d_func(); | - |
10965 | if (!item) { | 0 |
10966 | qWarning("QGraphicsItemGroup::removeFromGroup: cannot remove null item"); never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 10966, __PRETTY_FUNCTION__).warning("QGraphicsItemGroup::removeFromGroup: cannot remove null item"); | - |
10967 | return; | 0 |
10968 | } | - |
10969 | | - |
10970 | QGraphicsItem *newParent = d_ptr->parent; never executed (the execution status of this line is deduced): QGraphicsItem *newParent = d_ptr->parent; | - |
10971 | | - |
10972 | // COMBINE | - |
10973 | bool ok; never executed (the execution status of this line is deduced): bool ok; | - |
10974 | QTransform itemTransform; never executed (the execution status of this line is deduced): QTransform itemTransform; | - |
10975 | if (newParent) never evaluated: newParent | 0 |
10976 | itemTransform = item->itemTransform(newParent, &ok); never executed: itemTransform = item->itemTransform(newParent, &ok); | 0 |
10977 | else | - |
10978 | itemTransform = item->sceneTransform(); never executed: itemTransform = item->sceneTransform(); | 0 |
10979 | | - |
10980 | QPointF oldPos = item->mapToItem(newParent, 0, 0); never executed (the execution status of this line is deduced): QPointF oldPos = item->mapToItem(newParent, 0, 0); | - |
10981 | item->setParentItem(newParent); never executed (the execution status of this line is deduced): item->setParentItem(newParent); | - |
10982 | item->setPos(oldPos); never executed (the execution status of this line is deduced): item->setPos(oldPos); | - |
10983 | | - |
10984 | // removing position from translation component of the new transform | - |
10985 | if (!item->pos().isNull()) never evaluated: !item->pos().isNull() | 0 |
10986 | itemTransform *= QTransform::fromTranslate(-item->x(), -item->y()); never executed: itemTransform *= QTransform::fromTranslate(-item->x(), -item->y()); | 0 |
10987 | | - |
10988 | // removing additional transformations properties applied | - |
10989 | // with itemTransform() or sceneTransform() | - |
10990 | QPointF origin = item->transformOriginPoint(); never executed (the execution status of this line is deduced): QPointF origin = item->transformOriginPoint(); | - |
10991 | QMatrix4x4 m; never executed (the execution status of this line is deduced): QMatrix4x4 m; | - |
10992 | QList<QGraphicsTransform*> transformList = item->transformations(); never executed (the execution status of this line is deduced): QList<QGraphicsTransform*> transformList = item->transformations(); | - |
10993 | for (int i = 0; i < transformList.size(); ++i) never evaluated: i < transformList.size() | 0 |
10994 | transformList.at(i)->applyTo(&m); never executed: transformList.at(i)->applyTo(&m); | 0 |
10995 | itemTransform *= m.toTransform().inverted(); never executed (the execution status of this line is deduced): itemTransform *= m.toTransform().inverted(); | - |
10996 | itemTransform.translate(origin.x(), origin.y()); never executed (the execution status of this line is deduced): itemTransform.translate(origin.x(), origin.y()); | - |
10997 | itemTransform.rotate(-item->rotation()); never executed (the execution status of this line is deduced): itemTransform.rotate(-item->rotation()); | - |
10998 | itemTransform.scale(1 / item->scale(), 1 / item->scale()); never executed (the execution status of this line is deduced): itemTransform.scale(1 / item->scale(), 1 / item->scale()); | - |
10999 | itemTransform.translate(-origin.x(), -origin.y()); never executed (the execution status of this line is deduced): itemTransform.translate(-origin.x(), -origin.y()); | - |
11000 | | - |
11001 | // ### Expensive, we could maybe use dirtySceneTransform bit for optimization | - |
11002 | | - |
11003 | item->setTransform(itemTransform); never executed (the execution status of this line is deduced): item->setTransform(itemTransform); | - |
11004 | item->d_func()->setIsMemberOfGroup(item->group() != 0); never executed (the execution status of this line is deduced): item->d_func()->setIsMemberOfGroup(item->group() != 0); | - |
11005 | | - |
11006 | // ### Quite expensive. But removeFromGroup() isn't called very often. | - |
11007 | prepareGeometryChange(); never executed (the execution status of this line is deduced): prepareGeometryChange(); | - |
11008 | d->itemsBoundingRect = childrenBoundingRect(); never executed (the execution status of this line is deduced): d->itemsBoundingRect = childrenBoundingRect(); | - |
11009 | } | 0 |
11010 | | - |
11011 | /*! | - |
11012 | \reimp | - |
11013 | | - |
11014 | Returns the bounding rect of this group item, and all its children. | - |
11015 | */ | - |
11016 | QRectF QGraphicsItemGroup::boundingRect() const | - |
11017 | { | - |
11018 | Q_D(const QGraphicsItemGroup); never executed (the execution status of this line is deduced): const QGraphicsItemGroupPrivate * const d = d_func(); | - |
11019 | return d->itemsBoundingRect; never executed: return d->itemsBoundingRect; | 0 |
11020 | } | - |
11021 | | - |
11022 | /*! | - |
11023 | \reimp | - |
11024 | */ | - |
11025 | void QGraphicsItemGroup::paint(QPainter *painter, const QStyleOptionGraphicsItem *option, | - |
11026 | QWidget *widget) | - |
11027 | { | - |
11028 | Q_UNUSED(widget); never executed (the execution status of this line is deduced): (void)widget;; | - |
11029 | if (option->state & QStyle::State_Selected) { never evaluated: option->state & QStyle::State_Selected | 0 |
11030 | Q_D(QGraphicsItemGroup); never executed (the execution status of this line is deduced): QGraphicsItemGroupPrivate * const d = d_func(); | - |
11031 | painter->setBrush(Qt::NoBrush); never executed (the execution status of this line is deduced): painter->setBrush(Qt::NoBrush); | - |
11032 | painter->drawRect(d->itemsBoundingRect); never executed (the execution status of this line is deduced): painter->drawRect(d->itemsBoundingRect); | - |
11033 | } | 0 |
11034 | } | 0 |
11035 | | - |
11036 | /*! | - |
11037 | \reimp | - |
11038 | */ | - |
11039 | bool QGraphicsItemGroup::isObscuredBy(const QGraphicsItem *item) const | - |
11040 | { | - |
11041 | return QGraphicsItem::isObscuredBy(item); never executed: return QGraphicsItem::isObscuredBy(item); | 0 |
11042 | } | - |
11043 | | - |
11044 | /*! | - |
11045 | \reimp | - |
11046 | */ | - |
11047 | QPainterPath QGraphicsItemGroup::opaqueArea() const | - |
11048 | { | - |
11049 | return QGraphicsItem::opaqueArea(); never executed: return QGraphicsItem::opaqueArea(); | 0 |
11050 | } | - |
11051 | | - |
11052 | /*! | - |
11053 | \reimp | - |
11054 | */ | - |
11055 | int QGraphicsItemGroup::type() const | - |
11056 | { | - |
11057 | return Type; never executed: return Type; | 0 |
11058 | } | - |
11059 | | - |
11060 | #ifndef QT_NO_GRAPHICSEFFECT | - |
11061 | QRectF QGraphicsItemEffectSourcePrivate::boundingRect(Qt::CoordinateSystem system) const | - |
11062 | { | - |
11063 | const bool deviceCoordinates = (system == Qt::DeviceCoordinates); executed (the execution status of this line is deduced): const bool deviceCoordinates = (system == Qt::DeviceCoordinates); | - |
11064 | if (!info && deviceCoordinates) { evaluated: !info yes Evaluation Count:27 | yes Evaluation Count:35 |
evaluated: deviceCoordinates yes Evaluation Count:1 | yes Evaluation Count:26 |
| 1-35 |
11065 | // Device coordinates without info not yet supported. | - |
11066 | qWarning("QGraphicsEffectSource::boundingRect: Not yet implemented, lacking device context"); executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 11066, __PRETTY_FUNCTION__).warning("QGraphicsEffectSource::boundingRect: Not yet implemented, lacking device context"); | - |
11067 | return QRectF(); executed: return QRectF(); Execution Count:1 | 1 |
11068 | } | - |
11069 | | - |
11070 | QRectF rect = item->boundingRect(); executed (the execution status of this line is deduced): QRectF rect = item->boundingRect(); | - |
11071 | if (!item->d_ptr->children.isEmpty()) evaluated: !item->d_ptr->children.isEmpty() yes Evaluation Count:19 | yes Evaluation Count:42 |
| 19-42 |
11072 | rect |= item->childrenBoundingRect(); executed: rect |= item->childrenBoundingRect(); Execution Count:19 | 19 |
11073 | | - |
11074 | if (deviceCoordinates) { evaluated: deviceCoordinates yes Evaluation Count:29 | yes Evaluation Count:32 |
| 29-32 |
11075 | Q_ASSERT(info->painter); executed (the execution status of this line is deduced): qt_noop(); | - |
11076 | rect = info->painter->worldTransform().mapRect(rect); executed (the execution status of this line is deduced): rect = info->painter->worldTransform().mapRect(rect); | - |
11077 | } executed: } Execution Count:29 | 29 |
11078 | | - |
11079 | return rect; executed: return rect; Execution Count:61 | 61 |
11080 | } | - |
11081 | | - |
11082 | void QGraphicsItemEffectSourcePrivate::draw(QPainter *painter) | - |
11083 | { | - |
11084 | if (!info) { evaluated: !info yes Evaluation Count:1 | yes Evaluation Count:13 |
| 1-13 |
11085 | qWarning("QGraphicsEffectSource::draw: Can only begin as a result of QGraphicsEffect::draw"); executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 11085, __PRETTY_FUNCTION__).warning("QGraphicsEffectSource::draw: Can only begin as a result of QGraphicsEffect::draw"); | - |
11086 | return; executed: return; Execution Count:1 | 1 |
11087 | } | - |
11088 | | - |
11089 | Q_ASSERT(item->d_ptr->scene); executed (the execution status of this line is deduced): qt_noop(); | - |
11090 | QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func(); executed (the execution status of this line is deduced): QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func(); | - |
11091 | if (painter == info->painter) { partially evaluated: painter == info->painter yes Evaluation Count:13 | no Evaluation Count:0 |
| 0-13 |
11092 | scened->draw(item, painter, info->viewTransform, info->transformPtr, info->exposedRegion, executed (the execution status of this line is deduced): scened->draw(item, painter, info->viewTransform, info->transformPtr, info->exposedRegion, | - |
11093 | info->widget, info->opacity, info->effectTransform, info->wasDirtySceneTransform, executed (the execution status of this line is deduced): info->widget, info->opacity, info->effectTransform, info->wasDirtySceneTransform, | - |
11094 | info->drawItem); executed (the execution status of this line is deduced): info->drawItem); | - |
11095 | } else { executed: } Execution Count:13 | 13 |
11096 | QTransform effectTransform = info->painter->worldTransform().inverted(); never executed (the execution status of this line is deduced): QTransform effectTransform = info->painter->worldTransform().inverted(); | - |
11097 | effectTransform *= painter->worldTransform(); never executed (the execution status of this line is deduced): effectTransform *= painter->worldTransform(); | - |
11098 | scened->draw(item, painter, info->viewTransform, info->transformPtr, info->exposedRegion, never executed (the execution status of this line is deduced): scened->draw(item, painter, info->viewTransform, info->transformPtr, info->exposedRegion, | - |
11099 | info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform, never executed (the execution status of this line is deduced): info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform, | - |
11100 | info->drawItem); never executed (the execution status of this line is deduced): info->drawItem); | - |
11101 | } | 0 |
11102 | } | - |
11103 | | - |
11104 | // sourceRect must be in the given coordinate system | - |
11105 | QRect QGraphicsItemEffectSourcePrivate::paddedEffectRect(Qt::CoordinateSystem system, QGraphicsEffect::PixmapPadMode mode, const QRectF &sourceRect, bool *unpadded) const | - |
11106 | { | - |
11107 | QRectF effectRectF; executed (the execution status of this line is deduced): QRectF effectRectF; | - |
11108 | | - |
11109 | if (unpadded) evaluated: unpadded yes Evaluation Count:20 | yes Evaluation Count:9 |
| 9-20 |
11110 | *unpadded = false; executed: *unpadded = false; Execution Count:20 | 20 |
11111 | | - |
11112 | if (mode == QGraphicsEffect::PadToEffectiveBoundingRect) { evaluated: mode == QGraphicsEffect::PadToEffectiveBoundingRect yes Evaluation Count:16 | yes Evaluation Count:13 |
| 13-16 |
11113 | if (info) { evaluated: info yes Evaluation Count:15 | yes Evaluation Count:1 |
| 1-15 |
11114 | QRectF deviceRect = system == Qt::DeviceCoordinates ? sourceRect : info->painter->worldTransform().mapRect(sourceRect); evaluated: system == Qt::DeviceCoordinates yes Evaluation Count:12 | yes Evaluation Count:3 |
| 3-12 |
11115 | effectRectF = item->graphicsEffect()->boundingRectFor(deviceRect); executed (the execution status of this line is deduced): effectRectF = item->graphicsEffect()->boundingRectFor(deviceRect); | - |
11116 | if (unpadded) evaluated: unpadded yes Evaluation Count:13 | yes Evaluation Count:2 |
| 2-13 |
11117 | *unpadded = (effectRectF.size() == sourceRect.size()); executed: *unpadded = (effectRectF.size() == sourceRect.size()); Execution Count:13 | 13 |
11118 | if (info && system == Qt::LogicalCoordinates) partially evaluated: info yes Evaluation Count:15 | no Evaluation Count:0 |
evaluated: system == Qt::LogicalCoordinates yes Evaluation Count:3 | yes Evaluation Count:12 |
| 0-15 |
11119 | effectRectF = info->painter->worldTransform().inverted().mapRect(effectRectF); executed: effectRectF = info->painter->worldTransform().inverted().mapRect(effectRectF); Execution Count:3 | 3 |
11120 | } else { executed: } Execution Count:15 | 15 |
11121 | // no choice but to send a logical coordinate bounding rect to boundingRectFor | - |
11122 | effectRectF = item->graphicsEffect()->boundingRectFor(sourceRect); executed (the execution status of this line is deduced): effectRectF = item->graphicsEffect()->boundingRectFor(sourceRect); | - |
11123 | } executed: } Execution Count:1 | 1 |
11124 | } else if (mode == QGraphicsEffect::PadToTransparentBorder) { evaluated: mode == QGraphicsEffect::PadToTransparentBorder yes Evaluation Count:9 | yes Evaluation Count:4 |
| 4-9 |
11125 | // adjust by 1.5 to account for cosmetic pens | - |
11126 | effectRectF = sourceRect.adjusted(-1.5, -1.5, 1.5, 1.5); executed (the execution status of this line is deduced): effectRectF = sourceRect.adjusted(-1.5, -1.5, 1.5, 1.5); | - |
11127 | } else { executed: } Execution Count:9 | 9 |
11128 | effectRectF = sourceRect; executed (the execution status of this line is deduced): effectRectF = sourceRect; | - |
11129 | if (unpadded) partially evaluated: unpadded yes Evaluation Count:4 | no Evaluation Count:0 |
| 0-4 |
11130 | *unpadded = true; executed: *unpadded = true; Execution Count:4 | 4 |
11131 | } executed: } Execution Count:4 | 4 |
11132 | | - |
11133 | return effectRectF.toAlignedRect(); executed: return effectRectF.toAlignedRect(); Execution Count:29 | 29 |
11134 | } | - |
11135 | | - |
11136 | QPixmap QGraphicsItemEffectSourcePrivate::pixmap(Qt::CoordinateSystem system, QPoint *offset, | - |
11137 | QGraphicsEffect::PixmapPadMode mode) const | - |
11138 | { | - |
11139 | const bool deviceCoordinates = (system == Qt::DeviceCoordinates); executed (the execution status of this line is deduced): const bool deviceCoordinates = (system == Qt::DeviceCoordinates); | - |
11140 | if (!info && deviceCoordinates) { evaluated: !info yes Evaluation Count:1 | yes Evaluation Count:19 |
partially evaluated: deviceCoordinates no Evaluation Count:0 | yes Evaluation Count:1 |
| 0-19 |
11141 | // Device coordinates without info not yet supported. | - |
11142 | qWarning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context"); never executed (the execution status of this line is deduced): QMessageLogger("graphicsview/qgraphicsitem.cpp", 11142, __PRETTY_FUNCTION__).warning("QGraphicsEffectSource::pixmap: Not yet implemented, lacking device context"); | - |
11143 | return QPixmap(); never executed: return QPixmap(); | 0 |
11144 | } | - |
11145 | if (!item->d_ptr->scene) partially evaluated: !item->d_ptr->scene no Evaluation Count:0 | yes Evaluation Count:20 |
| 0-20 |
11146 | return QPixmap(); never executed: return QPixmap(); | 0 |
11147 | QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func(); executed (the execution status of this line is deduced): QGraphicsScenePrivate *scened = item->d_ptr->scene->d_func(); | - |
11148 | | - |
11149 | bool unpadded; executed (the execution status of this line is deduced): bool unpadded; | - |
11150 | const QRectF sourceRect = boundingRect(system); executed (the execution status of this line is deduced): const QRectF sourceRect = boundingRect(system); | - |
11151 | QRect effectRect = paddedEffectRect(system, mode, sourceRect, &unpadded); executed (the execution status of this line is deduced): QRect effectRect = paddedEffectRect(system, mode, sourceRect, &unpadded); | - |
11152 | | - |
11153 | if (offset) partially evaluated: offset yes Evaluation Count:20 | no Evaluation Count:0 |
| 0-20 |
11154 | *offset = effectRect.topLeft(); executed: *offset = effectRect.topLeft(); Execution Count:20 | 20 |
11155 | | - |
11156 | bool untransformed = !deviceCoordinates evaluated: !deviceCoordinates yes Evaluation Count:5 | yes Evaluation Count:15 |
| 5-15 |
11157 | || info->painter->worldTransform().type() <= QTransform::TxTranslate; evaluated: info->painter->worldTransform().type() <= QTransform::TxTranslate yes Evaluation Count:11 | yes Evaluation Count:4 |
| 4-11 |
11158 | if (untransformed && unpadded && isPixmap()) { evaluated: untransformed yes Evaluation Count:16 | yes Evaluation Count:4 |
evaluated: unpadded yes Evaluation Count:6 | yes Evaluation Count:10 |
evaluated: isPixmap() yes Evaluation Count:3 | yes Evaluation Count:3 |
| 3-16 |
11159 | if (offset) partially evaluated: offset yes Evaluation Count:3 | no Evaluation Count:0 |
| 0-3 |
11160 | *offset = boundingRect(system).topLeft().toPoint(); executed: *offset = boundingRect(system).topLeft().toPoint(); Execution Count:3 | 3 |
11161 | return static_cast<QGraphicsPixmapItem *>(item)->pixmap(); executed: return static_cast<QGraphicsPixmapItem *>(item)->pixmap(); Execution Count:3 | 3 |
11162 | } | - |
11163 | | - |
11164 | if (effectRect.isEmpty()) partially evaluated: effectRect.isEmpty() no Evaluation Count:0 | yes Evaluation Count:17 |
| 0-17 |
11165 | return QPixmap(); never executed: return QPixmap(); | 0 |
11166 | | - |
11167 | QPixmap pixmap(effectRect.size()); executed (the execution status of this line is deduced): QPixmap pixmap(effectRect.size()); | - |
11168 | pixmap.fill(Qt::transparent); executed (the execution status of this line is deduced): pixmap.fill(Qt::transparent); | - |
11169 | QPainter pixmapPainter(&pixmap); executed (the execution status of this line is deduced): QPainter pixmapPainter(&pixmap); | - |
11170 | pixmapPainter.setRenderHints(info ? info->painter->renderHints() : QPainter::TextAntialiasing); executed (the execution status of this line is deduced): pixmapPainter.setRenderHints(info ? info->painter->renderHints() : QPainter::TextAntialiasing); | - |
11171 | | - |
11172 | QTransform effectTransform = QTransform::fromTranslate(-effectRect.x(), -effectRect.y()); executed (the execution status of this line is deduced): QTransform effectTransform = QTransform::fromTranslate(-effectRect.x(), -effectRect.y()); | - |
11173 | if (deviceCoordinates && info->effectTransform) evaluated: deviceCoordinates yes Evaluation Count:14 | yes Evaluation Count:3 |
partially evaluated: info->effectTransform no Evaluation Count:0 | yes Evaluation Count:14 |
| 0-14 |
11174 | effectTransform *= *info->effectTransform; never executed: effectTransform *= *info->effectTransform; | 0 |
11175 | | - |
11176 | if (!info) { evaluated: !info yes Evaluation Count:1 | yes Evaluation Count:16 |
| 1-16 |
11177 | // Logical coordinates without info. | - |
11178 | QTransform sceneTransform = item->sceneTransform(); executed (the execution status of this line is deduced): QTransform sceneTransform = item->sceneTransform(); | - |
11179 | QTransform newEffectTransform = sceneTransform.inverted(); executed (the execution status of this line is deduced): QTransform newEffectTransform = sceneTransform.inverted(); | - |
11180 | newEffectTransform *= effectTransform; executed (the execution status of this line is deduced): newEffectTransform *= effectTransform; | - |
11181 | scened->draw(item, &pixmapPainter, 0, &sceneTransform, 0, 0, qreal(1.0), executed (the execution status of this line is deduced): scened->draw(item, &pixmapPainter, 0, &sceneTransform, 0, 0, qreal(1.0), | - |
11182 | &newEffectTransform, false, true); executed (the execution status of this line is deduced): &newEffectTransform, false, true); | - |
11183 | } else if (deviceCoordinates) { executed: } Execution Count:1 evaluated: deviceCoordinates yes Evaluation Count:14 | yes Evaluation Count:2 |
| 1-14 |
11184 | // Device coordinates with info. | - |
11185 | scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0, executed (the execution status of this line is deduced): scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0, | - |
11186 | info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform, executed (the execution status of this line is deduced): info->widget, info->opacity, &effectTransform, info->wasDirtySceneTransform, | - |
11187 | info->drawItem); executed (the execution status of this line is deduced): info->drawItem); | - |
11188 | } else { executed: } Execution Count:14 | 14 |
11189 | // Item coordinates with info. | - |
11190 | QTransform newEffectTransform = info->transformPtr->inverted(); executed (the execution status of this line is deduced): QTransform newEffectTransform = info->transformPtr->inverted(); | - |
11191 | newEffectTransform *= effectTransform; executed (the execution status of this line is deduced): newEffectTransform *= effectTransform; | - |
11192 | scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0, executed (the execution status of this line is deduced): scened->draw(item, &pixmapPainter, info->viewTransform, info->transformPtr, 0, | - |
11193 | info->widget, info->opacity, &newEffectTransform, info->wasDirtySceneTransform, executed (the execution status of this line is deduced): info->widget, info->opacity, &newEffectTransform, info->wasDirtySceneTransform, | - |
11194 | info->drawItem); executed (the execution status of this line is deduced): info->drawItem); | - |
11195 | } executed: } Execution Count:2 | 2 |
11196 | | - |
11197 | pixmapPainter.end(); executed (the execution status of this line is deduced): pixmapPainter.end(); | - |
11198 | | - |
11199 | return pixmap; executed: return pixmap; Execution Count:17 | 17 |
11200 | } | - |
11201 | #endif //QT_NO_GRAPHICSEFFECT | - |
11202 | | - |
11203 | #ifndef QT_NO_DEBUG_STREAM | - |
11204 | QDebug operator<<(QDebug debug, QGraphicsItem *item) | - |
11205 | { | - |
11206 | if (!item) { | 0 |
11207 | debug << "QGraphicsItem(0)"; never executed (the execution status of this line is deduced): debug << "QGraphicsItem(0)"; | - |
11208 | return debug; never executed: return debug; | 0 |
11209 | } | - |
11210 | | - |
11211 | if (QGraphicsObject *o = item->toGraphicsObject()) never evaluated: QGraphicsObject *o = item->toGraphicsObject() | 0 |
11212 | debug << o->metaObject()->className(); never executed: debug << o->metaObject()->className(); | 0 |
11213 | else | - |
11214 | debug << "QGraphicsItem"; never executed: debug << "QGraphicsItem"; | 0 |
11215 | debug << "(this =" << (void*)item never executed (the execution status of this line is deduced): debug << "(this =" << (void*)item | - |
11216 | << ", parent =" << (void*)item->parentItem() never executed (the execution status of this line is deduced): << ", parent =" << (void*)item->parentItem() | - |
11217 | << ", pos =" << item->pos() never executed (the execution status of this line is deduced): << ", pos =" << item->pos() | - |
11218 | << ", z =" << item->zValue() << ", flags = " never executed (the execution status of this line is deduced): << ", z =" << item->zValue() << ", flags = " | - |
11219 | << item->flags() << ")"; never executed (the execution status of this line is deduced): << item->flags() << ")"; | - |
11220 | return debug; never executed: return debug; | 0 |
11221 | } | - |
11222 | | - |
11223 | QDebug operator<<(QDebug debug, QGraphicsObject *item) | - |
11224 | { | - |
11225 | if (!item) { | 0 |
11226 | debug << "QGraphicsObject(0)"; never executed (the execution status of this line is deduced): debug << "QGraphicsObject(0)"; | - |
11227 | return debug; never executed: return debug; | 0 |
11228 | } | - |
11229 | | - |
11230 | debug.nospace() << item->metaObject()->className() << '(' << (void*)item; never executed (the execution status of this line is deduced): debug.nospace() << item->metaObject()->className() << '(' << (void*)item; | - |
11231 | if (!item->objectName().isEmpty()) never evaluated: !item->objectName().isEmpty() | 0 |
11232 | debug << ", name = " << item->objectName(); never executed: debug << ", name = " << item->objectName(); | 0 |
11233 | debug.nospace() << ", parent = " << ((void*)item->parentItem()) never executed (the execution status of this line is deduced): debug.nospace() << ", parent = " << ((void*)item->parentItem()) | - |
11234 | << ", pos = " << item->pos() never executed (the execution status of this line is deduced): << ", pos = " << item->pos() | - |
11235 | << ", z = " << item->zValue() << ", flags = " never executed (the execution status of this line is deduced): << ", z = " << item->zValue() << ", flags = " | - |
11236 | << item->flags() << ')'; never executed (the execution status of this line is deduced): << item->flags() << ')'; | - |
11237 | return debug.space(); never executed: return debug.space(); | 0 |
11238 | } | - |
11239 | | - |
11240 | QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemChange change) | - |
11241 | { | - |
11242 | const char *str = "UnknownChange"; never executed (the execution status of this line is deduced): const char *str = "UnknownChange"; | - |
11243 | switch (change) { | - |
11244 | case QGraphicsItem::ItemChildAddedChange: | - |
11245 | str = "ItemChildAddedChange"; never executed (the execution status of this line is deduced): str = "ItemChildAddedChange"; | - |
11246 | break; | 0 |
11247 | case QGraphicsItem::ItemChildRemovedChange: | - |
11248 | str = "ItemChildRemovedChange"; never executed (the execution status of this line is deduced): str = "ItemChildRemovedChange"; | - |
11249 | break; | 0 |
11250 | case QGraphicsItem::ItemCursorChange: | - |
11251 | str = "ItemCursorChange"; never executed (the execution status of this line is deduced): str = "ItemCursorChange"; | - |
11252 | break; | 0 |
11253 | case QGraphicsItem::ItemCursorHasChanged: | - |
11254 | str = "ItemCursorHasChanged"; never executed (the execution status of this line is deduced): str = "ItemCursorHasChanged"; | - |
11255 | break; | 0 |
11256 | case QGraphicsItem::ItemEnabledChange: | - |
11257 | str = "ItemEnabledChange"; never executed (the execution status of this line is deduced): str = "ItemEnabledChange"; | - |
11258 | break; | 0 |
11259 | case QGraphicsItem::ItemEnabledHasChanged: | - |
11260 | str = "ItemEnabledHasChanged"; never executed (the execution status of this line is deduced): str = "ItemEnabledHasChanged"; | - |
11261 | break; | 0 |
11262 | case QGraphicsItem::ItemFlagsChange: | - |
11263 | str = "ItemFlagsChange"; never executed (the execution status of this line is deduced): str = "ItemFlagsChange"; | - |
11264 | break; | 0 |
11265 | case QGraphicsItem::ItemFlagsHaveChanged: | - |
11266 | str = "ItemFlagsHaveChanged"; never executed (the execution status of this line is deduced): str = "ItemFlagsHaveChanged"; | - |
11267 | break; | 0 |
11268 | case QGraphicsItem::ItemMatrixChange: | - |
11269 | str = "ItemMatrixChange"; never executed (the execution status of this line is deduced): str = "ItemMatrixChange"; | - |
11270 | break; | 0 |
11271 | case QGraphicsItem::ItemParentChange: | - |
11272 | str = "ItemParentChange"; never executed (the execution status of this line is deduced): str = "ItemParentChange"; | - |
11273 | break; | 0 |
11274 | case QGraphicsItem::ItemParentHasChanged: | - |
11275 | str = "ItemParentHasChanged"; never executed (the execution status of this line is deduced): str = "ItemParentHasChanged"; | - |
11276 | break; | 0 |
11277 | case QGraphicsItem::ItemPositionChange: | - |
11278 | str = "ItemPositionChange"; never executed (the execution status of this line is deduced): str = "ItemPositionChange"; | - |
11279 | break; | 0 |
11280 | case QGraphicsItem::ItemPositionHasChanged: | - |
11281 | str = "ItemPositionHasChanged"; never executed (the execution status of this line is deduced): str = "ItemPositionHasChanged"; | - |
11282 | break; | 0 |
11283 | case QGraphicsItem::ItemSceneChange: | - |
11284 | str = "ItemSceneChange"; never executed (the execution status of this line is deduced): str = "ItemSceneChange"; | - |
11285 | break; | 0 |
11286 | case QGraphicsItem::ItemSceneHasChanged: | - |
11287 | str = "ItemSceneHasChanged"; never executed (the execution status of this line is deduced): str = "ItemSceneHasChanged"; | - |
11288 | break; | 0 |
11289 | case QGraphicsItem::ItemSelectedChange: | - |
11290 | str = "ItemSelectedChange"; never executed (the execution status of this line is deduced): str = "ItemSelectedChange"; | - |
11291 | break; | 0 |
11292 | case QGraphicsItem::ItemSelectedHasChanged: | - |
11293 | str = "ItemSelectedHasChanged"; never executed (the execution status of this line is deduced): str = "ItemSelectedHasChanged"; | - |
11294 | break; | 0 |
11295 | case QGraphicsItem::ItemToolTipChange: | - |
11296 | str = "ItemToolTipChange"; never executed (the execution status of this line is deduced): str = "ItemToolTipChange"; | - |
11297 | break; | 0 |
11298 | case QGraphicsItem::ItemToolTipHasChanged: | - |
11299 | str = "ItemToolTipHasChanged"; never executed (the execution status of this line is deduced): str = "ItemToolTipHasChanged"; | - |
11300 | break; | 0 |
11301 | case QGraphicsItem::ItemTransformChange: | - |
11302 | str = "ItemTransformChange"; never executed (the execution status of this line is deduced): str = "ItemTransformChange"; | - |
11303 | break; | 0 |
11304 | case QGraphicsItem::ItemTransformHasChanged: | - |
11305 | str = "ItemTransformHasChanged"; never executed (the execution status of this line is deduced): str = "ItemTransformHasChanged"; | - |
11306 | break; | 0 |
11307 | case QGraphicsItem::ItemVisibleChange: | - |
11308 | str = "ItemVisibleChange"; never executed (the execution status of this line is deduced): str = "ItemVisibleChange"; | - |
11309 | break; | 0 |
11310 | case QGraphicsItem::ItemVisibleHasChanged: | - |
11311 | str = "ItemVisibleHasChanged"; never executed (the execution status of this line is deduced): str = "ItemVisibleHasChanged"; | - |
11312 | break; | 0 |
11313 | case QGraphicsItem::ItemZValueChange: | - |
11314 | str = "ItemZValueChange"; never executed (the execution status of this line is deduced): str = "ItemZValueChange"; | - |
11315 | break; | 0 |
11316 | case QGraphicsItem::ItemZValueHasChanged: | - |
11317 | str = "ItemZValueHasChanged"; never executed (the execution status of this line is deduced): str = "ItemZValueHasChanged"; | - |
11318 | break; | 0 |
11319 | case QGraphicsItem::ItemOpacityChange: | - |
11320 | str = "ItemOpacityChange"; never executed (the execution status of this line is deduced): str = "ItemOpacityChange"; | - |
11321 | break; | 0 |
11322 | case QGraphicsItem::ItemOpacityHasChanged: | - |
11323 | str = "ItemOpacityHasChanged"; never executed (the execution status of this line is deduced): str = "ItemOpacityHasChanged"; | - |
11324 | break; | 0 |
11325 | case QGraphicsItem::ItemScenePositionHasChanged: | - |
11326 | str = "ItemScenePositionHasChanged"; never executed (the execution status of this line is deduced): str = "ItemScenePositionHasChanged"; | - |
11327 | break; | 0 |
11328 | case QGraphicsItem::ItemRotationChange: | - |
11329 | str = "ItemRotationChange"; never executed (the execution status of this line is deduced): str = "ItemRotationChange"; | - |
11330 | break; | 0 |
11331 | case QGraphicsItem::ItemRotationHasChanged: | - |
11332 | str = "ItemRotationHasChanged"; never executed (the execution status of this line is deduced): str = "ItemRotationHasChanged"; | - |
11333 | break; | 0 |
11334 | case QGraphicsItem::ItemScaleChange: | - |
11335 | str = "ItemScaleChange"; never executed (the execution status of this line is deduced): str = "ItemScaleChange"; | - |
11336 | break; | 0 |
11337 | case QGraphicsItem::ItemScaleHasChanged: | - |
11338 | str = "ItemScaleHasChanged"; never executed (the execution status of this line is deduced): str = "ItemScaleHasChanged"; | - |
11339 | break; | 0 |
11340 | case QGraphicsItem::ItemTransformOriginPointChange: | - |
11341 | str = "ItemTransformOriginPointChange"; never executed (the execution status of this line is deduced): str = "ItemTransformOriginPointChange"; | - |
11342 | break; | 0 |
11343 | case QGraphicsItem::ItemTransformOriginPointHasChanged: | - |
11344 | str = "ItemTransformOriginPointHasChanged"; never executed (the execution status of this line is deduced): str = "ItemTransformOriginPointHasChanged"; | - |
11345 | break; | 0 |
11346 | } | - |
11347 | debug << str; never executed (the execution status of this line is deduced): debug << str; | - |
11348 | return debug; never executed: return debug; | 0 |
11349 | } | - |
11350 | | - |
11351 | QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlag flag) | - |
11352 | { | - |
11353 | const char *str = "UnknownFlag"; never executed (the execution status of this line is deduced): const char *str = "UnknownFlag"; | - |
11354 | switch (flag) { | - |
11355 | case QGraphicsItem::ItemIsMovable: | - |
11356 | str = "ItemIsMovable"; never executed (the execution status of this line is deduced): str = "ItemIsMovable"; | - |
11357 | break; | 0 |
11358 | case QGraphicsItem::ItemIsSelectable: | - |
11359 | str = "ItemIsSelectable"; never executed (the execution status of this line is deduced): str = "ItemIsSelectable"; | - |
11360 | break; | 0 |
11361 | case QGraphicsItem::ItemIsFocusable: | - |
11362 | str = "ItemIsFocusable"; never executed (the execution status of this line is deduced): str = "ItemIsFocusable"; | - |
11363 | break; | 0 |
11364 | case QGraphicsItem::ItemClipsToShape: | - |
11365 | str = "ItemClipsToShape"; never executed (the execution status of this line is deduced): str = "ItemClipsToShape"; | - |
11366 | break; | 0 |
11367 | case QGraphicsItem::ItemClipsChildrenToShape: | - |
11368 | str = "ItemClipsChildrenToShape"; never executed (the execution status of this line is deduced): str = "ItemClipsChildrenToShape"; | - |
11369 | break; | 0 |
11370 | case QGraphicsItem::ItemIgnoresTransformations: | - |
11371 | str = "ItemIgnoresTransformations"; never executed (the execution status of this line is deduced): str = "ItemIgnoresTransformations"; | - |
11372 | break; | 0 |
11373 | case QGraphicsItem::ItemIgnoresParentOpacity: | - |
11374 | str = "ItemIgnoresParentOpacity"; never executed (the execution status of this line is deduced): str = "ItemIgnoresParentOpacity"; | - |
11375 | break; | 0 |
11376 | case QGraphicsItem::ItemDoesntPropagateOpacityToChildren: | - |
11377 | str = "ItemDoesntPropagateOpacityToChildren"; never executed (the execution status of this line is deduced): str = "ItemDoesntPropagateOpacityToChildren"; | - |
11378 | break; | 0 |
11379 | case QGraphicsItem::ItemStacksBehindParent: | - |
11380 | str = "ItemStacksBehindParent"; never executed (the execution status of this line is deduced): str = "ItemStacksBehindParent"; | - |
11381 | break; | 0 |
11382 | case QGraphicsItem::ItemUsesExtendedStyleOption: | - |
11383 | str = "ItemUsesExtendedStyleOption"; never executed (the execution status of this line is deduced): str = "ItemUsesExtendedStyleOption"; | - |
11384 | break; | 0 |
11385 | case QGraphicsItem::ItemHasNoContents: | - |
11386 | str = "ItemHasNoContents"; never executed (the execution status of this line is deduced): str = "ItemHasNoContents"; | - |
11387 | break; | 0 |
11388 | case QGraphicsItem::ItemSendsGeometryChanges: | - |
11389 | str = "ItemSendsGeometryChanges"; never executed (the execution status of this line is deduced): str = "ItemSendsGeometryChanges"; | - |
11390 | break; | 0 |
11391 | case QGraphicsItem::ItemAcceptsInputMethod: | - |
11392 | str = "ItemAcceptsInputMethod"; never executed (the execution status of this line is deduced): str = "ItemAcceptsInputMethod"; | - |
11393 | break; | 0 |
11394 | case QGraphicsItem::ItemNegativeZStacksBehindParent: | - |
11395 | str = "ItemNegativeZStacksBehindParent"; never executed (the execution status of this line is deduced): str = "ItemNegativeZStacksBehindParent"; | - |
11396 | break; | 0 |
11397 | case QGraphicsItem::ItemIsPanel: | - |
11398 | str = "ItemIsPanel"; never executed (the execution status of this line is deduced): str = "ItemIsPanel"; | - |
11399 | break; | 0 |
11400 | case QGraphicsItem::ItemIsFocusScope: | - |
11401 | str = "ItemIsFocusScope"; never executed (the execution status of this line is deduced): str = "ItemIsFocusScope"; | - |
11402 | break; | 0 |
11403 | case QGraphicsItem::ItemSendsScenePositionChanges: | - |
11404 | str = "ItemSendsScenePositionChanges"; never executed (the execution status of this line is deduced): str = "ItemSendsScenePositionChanges"; | - |
11405 | break; | 0 |
11406 | case QGraphicsItem::ItemStopsClickFocusPropagation: | - |
11407 | str = "ItemStopsClickFocusPropagation"; never executed (the execution status of this line is deduced): str = "ItemStopsClickFocusPropagation"; | - |
11408 | break; | 0 |
11409 | case QGraphicsItem::ItemStopsFocusHandling: | - |
11410 | str = "ItemStopsFocusHandling"; never executed (the execution status of this line is deduced): str = "ItemStopsFocusHandling"; | - |
11411 | break; | 0 |
11412 | } | - |
11413 | debug << str; never executed (the execution status of this line is deduced): debug << str; | - |
11414 | return debug; never executed: return debug; | 0 |
11415 | } | - |
11416 | | - |
11417 | QDebug operator<<(QDebug debug, QGraphicsItem::GraphicsItemFlags flags) | - |
11418 | { | - |
11419 | debug << '('; never executed (the execution status of this line is deduced): debug << '('; | - |
11420 | bool f = false; never executed (the execution status of this line is deduced): bool f = false; | - |
11421 | for (int i = 0; i < 17; ++i) { | 0 |
11422 | if (flags & (1 << i)) { never evaluated: flags & (1 << i) | 0 |
11423 | if (f) | 0 |
11424 | debug << '|'; never executed: debug << '|'; | 0 |
11425 | f = true; never executed (the execution status of this line is deduced): f = true; | - |
11426 | debug << QGraphicsItem::GraphicsItemFlag(int(flags & (1 << i))); never executed (the execution status of this line is deduced): debug << QGraphicsItem::GraphicsItemFlag(int(flags & (1 << i))); | - |
11427 | } | 0 |
11428 | } | 0 |
11429 | debug << ')'; never executed (the execution status of this line is deduced): debug << ')'; | - |
11430 | return debug; never executed: return debug; | 0 |
11431 | } | - |
11432 | | - |
11433 | #endif | - |
11434 | | - |
11435 | QT_END_NAMESPACE | - |
11436 | | - |
11437 | #include "moc_qgraphicsitem.cpp" | - |
11438 | | - |
11439 | #endif // QT_NO_GRAPHICSVIEW | - |
11440 | | - |
| | |